Ei kuvausta

deprecated.php 122KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227
  1. <?php
  2. /**
  3. * Deprecated functions from past WordPress versions. You shouldn't use these
  4. * functions and look for the alternatives instead. The functions will be
  5. * removed in a later version.
  6. *
  7. * @package WordPress
  8. * @subpackage Deprecated
  9. */
  10. /*
  11. * Deprecated functions come here to die.
  12. */
  13. /**
  14. * Retrieves all post data for a given post.
  15. *
  16. * @since 0.71
  17. * @deprecated 1.5.1 Use get_post()
  18. * @see get_post()
  19. *
  20. * @param int $postid Post ID.
  21. * @return array Post data.
  22. */
  23. function get_postdata($postid) {
  24. _deprecated_function( __FUNCTION__, '1.5.1', 'get_post()' );
  25. $post = get_post($postid);
  26. $postdata = array (
  27. 'ID' => $post->ID,
  28. 'Author_ID' => $post->post_author,
  29. 'Date' => $post->post_date,
  30. 'Content' => $post->post_content,
  31. 'Excerpt' => $post->post_excerpt,
  32. 'Title' => $post->post_title,
  33. 'Category' => $post->post_category,
  34. 'post_status' => $post->post_status,
  35. 'comment_status' => $post->comment_status,
  36. 'ping_status' => $post->ping_status,
  37. 'post_password' => $post->post_password,
  38. 'to_ping' => $post->to_ping,
  39. 'pinged' => $post->pinged,
  40. 'post_type' => $post->post_type,
  41. 'post_name' => $post->post_name
  42. );
  43. return $postdata;
  44. }
  45. /**
  46. * Sets up the WordPress Loop.
  47. *
  48. * Use The Loop instead.
  49. *
  50. * @link https://developer.wordpress.org/themes/basics/the-loop/
  51. *
  52. * @since 1.0.1
  53. * @deprecated 1.5.0
  54. */
  55. function start_wp() {
  56. global $wp_query;
  57. _deprecated_function( __FUNCTION__, '1.5.0', __('new WordPress Loop') );
  58. // Since the old style loop is being used, advance the query iterator here.
  59. $wp_query->next_post();
  60. setup_postdata( get_post() );
  61. }
  62. /**
  63. * Returns or prints a category ID.
  64. *
  65. * @since 0.71
  66. * @deprecated 0.71 Use get_the_category()
  67. * @see get_the_category()
  68. *
  69. * @param bool $echo Optional. Whether to echo the output. Default true.
  70. * @return int Category ID.
  71. */
  72. function the_category_ID($echo = true) {
  73. _deprecated_function( __FUNCTION__, '0.71', 'get_the_category()' );
  74. // Grab the first cat in the list.
  75. $categories = get_the_category();
  76. $cat = $categories[0]->term_id;
  77. if ( $echo )
  78. echo $cat;
  79. return $cat;
  80. }
  81. /**
  82. * Prints a category with optional text before and after.
  83. *
  84. * @since 0.71
  85. * @deprecated 0.71 Use get_the_category_by_ID()
  86. * @see get_the_category_by_ID()
  87. *
  88. * @param string $before Optional. Text to display before the category. Default empty.
  89. * @param string $after Optional. Text to display after the category. Default empty.
  90. */
  91. function the_category_head( $before = '', $after = '' ) {
  92. global $currentcat, $previouscat;
  93. _deprecated_function( __FUNCTION__, '0.71', 'get_the_category_by_ID()' );
  94. // Grab the first cat in the list.
  95. $categories = get_the_category();
  96. $currentcat = $categories[0]->category_id;
  97. if ( $currentcat != $previouscat ) {
  98. echo $before;
  99. echo get_the_category_by_ID($currentcat);
  100. echo $after;
  101. $previouscat = $currentcat;
  102. }
  103. }
  104. /**
  105. * Prints a link to the previous post.
  106. *
  107. * @since 1.5.0
  108. * @deprecated 2.0.0 Use previous_post_link()
  109. * @see previous_post_link()
  110. *
  111. * @param string $format
  112. * @param string $previous
  113. * @param string $title
  114. * @param string $in_same_cat
  115. * @param int $limitprev
  116. * @param string $excluded_categories
  117. */
  118. function previous_post($format='%', $previous='previous post: ', $title='yes', $in_same_cat='no', $limitprev=1, $excluded_categories='') {
  119. _deprecated_function( __FUNCTION__, '2.0.0', 'previous_post_link()' );
  120. if ( empty($in_same_cat) || 'no' == $in_same_cat )
  121. $in_same_cat = false;
  122. else
  123. $in_same_cat = true;
  124. $post = get_previous_post($in_same_cat, $excluded_categories);
  125. if ( !$post )
  126. return;
  127. $string = '<a href="'.get_permalink($post->ID).'">'.$previous;
  128. if ( 'yes' == $title )
  129. $string .= apply_filters('the_title', $post->post_title, $post->ID);
  130. $string .= '</a>';
  131. $format = str_replace('%', $string, $format);
  132. echo $format;
  133. }
  134. /**
  135. * Prints link to the next post.
  136. *
  137. * @since 0.71
  138. * @deprecated 2.0.0 Use next_post_link()
  139. * @see next_post_link()
  140. *
  141. * @param string $format
  142. * @param string $next
  143. * @param string $title
  144. * @param string $in_same_cat
  145. * @param int $limitnext
  146. * @param string $excluded_categories
  147. */
  148. function next_post($format='%', $next='next post: ', $title='yes', $in_same_cat='no', $limitnext=1, $excluded_categories='') {
  149. _deprecated_function( __FUNCTION__, '2.0.0', 'next_post_link()' );
  150. if ( empty($in_same_cat) || 'no' == $in_same_cat )
  151. $in_same_cat = false;
  152. else
  153. $in_same_cat = true;
  154. $post = get_next_post($in_same_cat, $excluded_categories);
  155. if ( !$post )
  156. return;
  157. $string = '<a href="'.get_permalink($post->ID).'">'.$next;
  158. if ( 'yes' == $title )
  159. $string .= apply_filters('the_title', $post->post_title, $post->ID);
  160. $string .= '</a>';
  161. $format = str_replace('%', $string, $format);
  162. echo $format;
  163. }
  164. /**
  165. * Whether user can create a post.
  166. *
  167. * @since 1.5.0
  168. * @deprecated 2.0.0 Use current_user_can()
  169. * @see current_user_can()
  170. *
  171. * @param int $user_id
  172. * @param int $blog_id Not Used
  173. * @param int $category_id Not Used
  174. * @return bool
  175. */
  176. function user_can_create_post($user_id, $blog_id = 1, $category_id = 'None') {
  177. _deprecated_function( __FUNCTION__, '2.0.0', 'current_user_can()' );
  178. $author_data = get_userdata($user_id);
  179. return ($author_data->user_level > 1);
  180. }
  181. /**
  182. * Whether user can create a post.
  183. *
  184. * @since 1.5.0
  185. * @deprecated 2.0.0 Use current_user_can()
  186. * @see current_user_can()
  187. *
  188. * @param int $user_id
  189. * @param int $blog_id Not Used
  190. * @param int $category_id Not Used
  191. * @return bool
  192. */
  193. function user_can_create_draft($user_id, $blog_id = 1, $category_id = 'None') {
  194. _deprecated_function( __FUNCTION__, '2.0.0', 'current_user_can()' );
  195. $author_data = get_userdata($user_id);
  196. return ($author_data->user_level >= 1);
  197. }
  198. /**
  199. * Whether user can edit a post.
  200. *
  201. * @since 1.5.0
  202. * @deprecated 2.0.0 Use current_user_can()
  203. * @see current_user_can()
  204. *
  205. * @param int $user_id
  206. * @param int $post_id
  207. * @param int $blog_id Not Used
  208. * @return bool
  209. */
  210. function user_can_edit_post($user_id, $post_id, $blog_id = 1) {
  211. _deprecated_function( __FUNCTION__, '2.0.0', 'current_user_can()' );
  212. $author_data = get_userdata($user_id);
  213. $post = get_post($post_id);
  214. $post_author_data = get_userdata($post->post_author);
  215. if ( (($user_id == $post_author_data->ID) && !($post->post_status == 'publish' && $author_data->user_level < 2))
  216. || ($author_data->user_level > $post_author_data->user_level)
  217. || ($author_data->user_level >= 10) ) {
  218. return true;
  219. } else {
  220. return false;
  221. }
  222. }
  223. /**
  224. * Whether user can delete a post.
  225. *
  226. * @since 1.5.0
  227. * @deprecated 2.0.0 Use current_user_can()
  228. * @see current_user_can()
  229. *
  230. * @param int $user_id
  231. * @param int $post_id
  232. * @param int $blog_id Not Used
  233. * @return bool
  234. */
  235. function user_can_delete_post($user_id, $post_id, $blog_id = 1) {
  236. _deprecated_function( __FUNCTION__, '2.0.0', 'current_user_can()' );
  237. // Right now if one can edit, one can delete.
  238. return user_can_edit_post($user_id, $post_id, $blog_id);
  239. }
  240. /**
  241. * Whether user can set new posts' dates.
  242. *
  243. * @since 1.5.0
  244. * @deprecated 2.0.0 Use current_user_can()
  245. * @see current_user_can()
  246. *
  247. * @param int $user_id
  248. * @param int $blog_id Not Used
  249. * @param int $category_id Not Used
  250. * @return bool
  251. */
  252. function user_can_set_post_date($user_id, $blog_id = 1, $category_id = 'None') {
  253. _deprecated_function( __FUNCTION__, '2.0.0', 'current_user_can()' );
  254. $author_data = get_userdata($user_id);
  255. return (($author_data->user_level > 4) && user_can_create_post($user_id, $blog_id, $category_id));
  256. }
  257. /**
  258. * Whether user can delete a post.
  259. *
  260. * @since 1.5.0
  261. * @deprecated 2.0.0 Use current_user_can()
  262. * @see current_user_can()
  263. *
  264. * @param int $user_id
  265. * @param int $post_id
  266. * @param int $blog_id Not Used
  267. * @return bool returns true if $user_id can edit $post_id's date
  268. */
  269. function user_can_edit_post_date($user_id, $post_id, $blog_id = 1) {
  270. _deprecated_function( __FUNCTION__, '2.0.0', 'current_user_can()' );
  271. $author_data = get_userdata($user_id);
  272. return (($author_data->user_level > 4) && user_can_edit_post($user_id, $post_id, $blog_id));
  273. }
  274. /**
  275. * Whether user can delete a post.
  276. *
  277. * @since 1.5.0
  278. * @deprecated 2.0.0 Use current_user_can()
  279. * @see current_user_can()
  280. *
  281. * @param int $user_id
  282. * @param int $post_id
  283. * @param int $blog_id Not Used
  284. * @return bool returns true if $user_id can edit $post_id's comments
  285. */
  286. function user_can_edit_post_comments($user_id, $post_id, $blog_id = 1) {
  287. _deprecated_function( __FUNCTION__, '2.0.0', 'current_user_can()' );
  288. // Right now if one can edit a post, one can edit comments made on it.
  289. return user_can_edit_post($user_id, $post_id, $blog_id);
  290. }
  291. /**
  292. * Whether user can delete a post.
  293. *
  294. * @since 1.5.0
  295. * @deprecated 2.0.0 Use current_user_can()
  296. * @see current_user_can()
  297. *
  298. * @param int $user_id
  299. * @param int $post_id
  300. * @param int $blog_id Not Used
  301. * @return bool returns true if $user_id can delete $post_id's comments
  302. */
  303. function user_can_delete_post_comments($user_id, $post_id, $blog_id = 1) {
  304. _deprecated_function( __FUNCTION__, '2.0.0', 'current_user_can()' );
  305. // Right now if one can edit comments, one can delete comments.
  306. return user_can_edit_post_comments($user_id, $post_id, $blog_id);
  307. }
  308. /**
  309. * Can user can edit other user.
  310. *
  311. * @since 1.5.0
  312. * @deprecated 2.0.0 Use current_user_can()
  313. * @see current_user_can()
  314. *
  315. * @param int $user_id
  316. * @param int $other_user
  317. * @return bool
  318. */
  319. function user_can_edit_user($user_id, $other_user) {
  320. _deprecated_function( __FUNCTION__, '2.0.0', 'current_user_can()' );
  321. $user = get_userdata($user_id);
  322. $other = get_userdata($other_user);
  323. if ( $user->user_level > $other->user_level || $user->user_level > 8 || $user->ID == $other->ID )
  324. return true;
  325. else
  326. return false;
  327. }
  328. /**
  329. * Gets the links associated with category $cat_name.
  330. *
  331. * @since 0.71
  332. * @deprecated 2.1.0 Use get_bookmarks()
  333. * @see get_bookmarks()
  334. *
  335. * @param string $cat_name Optional. The category name to use. If no match is found, uses all.
  336. * Default 'noname'.
  337. * @param string $before Optional. The HTML to output before the link. Default empty.
  338. * @param string $after Optional. The HTML to output after the link. Default '<br />'.
  339. * @param string $between Optional. The HTML to output between the link/image and its description.
  340. * Not used if no image or $show_images is true. Default ' '.
  341. * @param bool $show_images Optional. Whether to show images (if defined). Default true.
  342. * @param string $orderby Optional. The order to output the links. E.g. 'id', 'name', 'url',
  343. * 'description', 'rating', or 'owner'. Default 'id'.
  344. * If you start the name with an underscore, the order will be reversed.
  345. * Specifying 'rand' as the order will return links in a random order.
  346. * @param bool $show_description Optional. Whether to show the description if show_images=false/not defined.
  347. * Default true.
  348. * @param bool $show_rating Optional. Show rating stars/chars. Default false.
  349. * @param int $limit Optional. Limit to X entries. If not specified, all entries are shown.
  350. * Default -1.
  351. * @param int $show_updated Optional. Whether to show last updated timestamp. Default 0.
  352. */
  353. function get_linksbyname($cat_name = "noname", $before = '', $after = '<br />', $between = " ", $show_images = true, $orderby = 'id',
  354. $show_description = true, $show_rating = false,
  355. $limit = -1, $show_updated = 0) {
  356. _deprecated_function( __FUNCTION__, '2.1.0', 'get_bookmarks()' );
  357. $cat_id = -1;
  358. $cat = get_term_by('name', $cat_name, 'link_category');
  359. if ( $cat )
  360. $cat_id = $cat->term_id;
  361. get_links($cat_id, $before, $after, $between, $show_images, $orderby, $show_description, $show_rating, $limit, $show_updated);
  362. }
  363. /**
  364. * Gets the links associated with the named category.
  365. *
  366. * @since 1.0.1
  367. * @deprecated 2.1.0 Use wp_list_bookmarks()
  368. * @see wp_list_bookmarks()
  369. *
  370. * @param string $category The category to use.
  371. * @param string $args
  372. * @return string|null
  373. */
  374. function wp_get_linksbyname($category, $args = '') {
  375. _deprecated_function(__FUNCTION__, '2.1.0', 'wp_list_bookmarks()');
  376. $defaults = array(
  377. 'after' => '<br />',
  378. 'before' => '',
  379. 'categorize' => 0,
  380. 'category_after' => '',
  381. 'category_before' => '',
  382. 'category_name' => $category,
  383. 'show_description' => 1,
  384. 'title_li' => '',
  385. );
  386. $parsed_args = wp_parse_args( $args, $defaults );
  387. return wp_list_bookmarks($parsed_args);
  388. }
  389. /**
  390. * Gets an array of link objects associated with category $cat_name.
  391. *
  392. * $links = get_linkobjectsbyname( 'fred' );
  393. * foreach ( $links as $link ) {
  394. * echo '<li>' . $link->link_name . '</li>';
  395. * }
  396. *
  397. * @since 1.0.1
  398. * @deprecated 2.1.0 Use get_bookmarks()
  399. * @see get_bookmarks()
  400. *
  401. * @param string $cat_name Optional. The category name to use. If no match is found, uses all.
  402. * Default 'noname'.
  403. * @param string $orderby Optional. The order to output the links. E.g. 'id', 'name', 'url',
  404. * 'description', 'rating', or 'owner'. Default 'name'.
  405. * If you start the name with an underscore, the order will be reversed.
  406. * Specifying 'rand' as the order will return links in a random order.
  407. * @param int $limit Optional. Limit to X entries. If not specified, all entries are shown.
  408. * Default -1.
  409. * @return array
  410. */
  411. function get_linkobjectsbyname($cat_name = "noname" , $orderby = 'name', $limit = -1) {
  412. _deprecated_function( __FUNCTION__, '2.1.0', 'get_bookmarks()' );
  413. $cat_id = -1;
  414. $cat = get_term_by('name', $cat_name, 'link_category');
  415. if ( $cat )
  416. $cat_id = $cat->term_id;
  417. return get_linkobjects($cat_id, $orderby, $limit);
  418. }
  419. /**
  420. * Gets an array of link objects associated with category n.
  421. *
  422. * Usage:
  423. *
  424. * $links = get_linkobjects(1);
  425. * if ($links) {
  426. * foreach ($links as $link) {
  427. * echo '<li>'.$link->link_name.'<br />'.$link->link_description.'</li>';
  428. * }
  429. * }
  430. *
  431. * Fields are:
  432. *
  433. * - link_id
  434. * - link_url
  435. * - link_name
  436. * - link_image
  437. * - link_target
  438. * - link_category
  439. * - link_description
  440. * - link_visible
  441. * - link_owner
  442. * - link_rating
  443. * - link_updated
  444. * - link_rel
  445. * - link_notes
  446. *
  447. * @since 1.0.1
  448. * @deprecated 2.1.0 Use get_bookmarks()
  449. * @see get_bookmarks()
  450. *
  451. * @param int $category Optional. The category to use. If no category supplied, uses all.
  452. * Default 0.
  453. * @param string $orderby Optional. The order to output the links. E.g. 'id', 'name', 'url',
  454. * 'description', 'rating', or 'owner'. Default 'name'.
  455. * If you start the name with an underscore, the order will be reversed.
  456. * Specifying 'rand' as the order will return links in a random order.
  457. * @param int $limit Optional. Limit to X entries. If not specified, all entries are shown.
  458. * Default 0.
  459. * @return array
  460. */
  461. function get_linkobjects($category = 0, $orderby = 'name', $limit = 0) {
  462. _deprecated_function( __FUNCTION__, '2.1.0', 'get_bookmarks()' );
  463. $links = get_bookmarks( array( 'category' => $category, 'orderby' => $orderby, 'limit' => $limit ) ) ;
  464. $links_array = array();
  465. foreach ($links as $link)
  466. $links_array[] = $link;
  467. return $links_array;
  468. }
  469. /**
  470. * Gets the links associated with category 'cat_name' and display rating stars/chars.
  471. *
  472. * @since 0.71
  473. * @deprecated 2.1.0 Use get_bookmarks()
  474. * @see get_bookmarks()
  475. *
  476. * @param string $cat_name Optional. The category name to use. If no match is found, uses all.
  477. * Default 'noname'.
  478. * @param string $before Optional. The HTML to output before the link. Default empty.
  479. * @param string $after Optional. The HTML to output after the link. Default '<br />'.
  480. * @param string $between Optional. The HTML to output between the link/image and its description.
  481. * Not used if no image or $show_images is true. Default ' '.
  482. * @param bool $show_images Optional. Whether to show images (if defined). Default true.
  483. * @param string $orderby Optional. The order to output the links. E.g. 'id', 'name', 'url',
  484. * 'description', 'rating', or 'owner'. Default 'id'.
  485. * If you start the name with an underscore, the order will be reversed.
  486. * Specifying 'rand' as the order will return links in a random order.
  487. * @param bool $show_description Optional. Whether to show the description if show_images=false/not defined.
  488. * Default true.
  489. * @param int $limit Optional. Limit to X entries. If not specified, all entries are shown.
  490. * Default -1.
  491. * @param int $show_updated Optional. Whether to show last updated timestamp. Default 0.
  492. */
  493. function get_linksbyname_withrating($cat_name = "noname", $before = '', $after = '<br />', $between = " ",
  494. $show_images = true, $orderby = 'id', $show_description = true, $limit = -1, $show_updated = 0) {
  495. _deprecated_function( __FUNCTION__, '2.1.0', 'get_bookmarks()' );
  496. get_linksbyname($cat_name, $before, $after, $between, $show_images, $orderby, $show_description, true, $limit, $show_updated);
  497. }
  498. /**
  499. * Gets the links associated with category n and display rating stars/chars.
  500. *
  501. * @since 0.71
  502. * @deprecated 2.1.0 Use get_bookmarks()
  503. * @see get_bookmarks()
  504. *
  505. * @param int $category Optional. The category to use. If no category supplied, uses all.
  506. * Default 0.
  507. * @param string $before Optional. The HTML to output before the link. Default empty.
  508. * @param string $after Optional. The HTML to output after the link. Default '<br />'.
  509. * @param string $between Optional. The HTML to output between the link/image and its description.
  510. * Not used if no image or $show_images is true. Default ' '.
  511. * @param bool $show_images Optional. Whether to show images (if defined). Default true.
  512. * @param string $orderby Optional. The order to output the links. E.g. 'id', 'name', 'url',
  513. * 'description', 'rating', or 'owner'. Default 'id'.
  514. * If you start the name with an underscore, the order will be reversed.
  515. * Specifying 'rand' as the order will return links in a random order.
  516. * @param bool $show_description Optional. Whether to show the description if show_images=false/not defined.
  517. * Default true.
  518. * @param int $limit Optional. Limit to X entries. If not specified, all entries are shown.
  519. * Default -1.
  520. * @param int $show_updated Optional. Whether to show last updated timestamp. Default 0.
  521. */
  522. function get_links_withrating($category = -1, $before = '', $after = '<br />', $between = " ", $show_images = true,
  523. $orderby = 'id', $show_description = true, $limit = -1, $show_updated = 0) {
  524. _deprecated_function( __FUNCTION__, '2.1.0', 'get_bookmarks()' );
  525. get_links($category, $before, $after, $between, $show_images, $orderby, $show_description, true, $limit, $show_updated);
  526. }
  527. /**
  528. * Gets the auto_toggle setting.
  529. *
  530. * @since 0.71
  531. * @deprecated 2.1.0
  532. *
  533. * @param int $id The category to get. If no category supplied uses 0
  534. * @return int Only returns 0.
  535. */
  536. function get_autotoggle($id = 0) {
  537. _deprecated_function( __FUNCTION__, '2.1.0' );
  538. return 0;
  539. }
  540. /**
  541. * Lists categories.
  542. *
  543. * @since 0.71
  544. * @deprecated 2.1.0 Use wp_list_categories()
  545. * @see wp_list_categories()
  546. *
  547. * @param int $optionall
  548. * @param string $all
  549. * @param string $sort_column
  550. * @param string $sort_order
  551. * @param string $file
  552. * @param bool $list
  553. * @param int $optiondates
  554. * @param int $optioncount
  555. * @param int $hide_empty
  556. * @param int $use_desc_for_title
  557. * @param bool $children
  558. * @param int $child_of
  559. * @param int $categories
  560. * @param int $recurse
  561. * @param string $feed
  562. * @param string $feed_image
  563. * @param string $exclude
  564. * @param bool $hierarchical
  565. * @return null|false
  566. */
  567. function list_cats($optionall = 1, $all = 'All', $sort_column = 'ID', $sort_order = 'asc', $file = '', $list = true, $optiondates = 0,
  568. $optioncount = 0, $hide_empty = 1, $use_desc_for_title = 1, $children=false, $child_of=0, $categories=0,
  569. $recurse=0, $feed = '', $feed_image = '', $exclude = '', $hierarchical=false) {
  570. _deprecated_function( __FUNCTION__, '2.1.0', 'wp_list_categories()' );
  571. $query = compact('optionall', 'all', 'sort_column', 'sort_order', 'file', 'list', 'optiondates', 'optioncount', 'hide_empty', 'use_desc_for_title', 'children',
  572. 'child_of', 'categories', 'recurse', 'feed', 'feed_image', 'exclude', 'hierarchical');
  573. return wp_list_cats($query);
  574. }
  575. /**
  576. * Lists categories.
  577. *
  578. * @since 1.2.0
  579. * @deprecated 2.1.0 Use wp_list_categories()
  580. * @see wp_list_categories()
  581. *
  582. * @param string|array $args
  583. * @return null|string|false
  584. */
  585. function wp_list_cats($args = '') {
  586. _deprecated_function( __FUNCTION__, '2.1.0', 'wp_list_categories()' );
  587. $parsed_args = wp_parse_args( $args );
  588. // Map to new names.
  589. if ( isset($parsed_args['optionall']) && isset($parsed_args['all']))
  590. $parsed_args['show_option_all'] = $parsed_args['all'];
  591. if ( isset($parsed_args['sort_column']) )
  592. $parsed_args['orderby'] = $parsed_args['sort_column'];
  593. if ( isset($parsed_args['sort_order']) )
  594. $parsed_args['order'] = $parsed_args['sort_order'];
  595. if ( isset($parsed_args['optiondates']) )
  596. $parsed_args['show_last_update'] = $parsed_args['optiondates'];
  597. if ( isset($parsed_args['optioncount']) )
  598. $parsed_args['show_count'] = $parsed_args['optioncount'];
  599. if ( isset($parsed_args['list']) )
  600. $parsed_args['style'] = $parsed_args['list'] ? 'list' : 'break';
  601. $parsed_args['title_li'] = '';
  602. return wp_list_categories($parsed_args);
  603. }
  604. /**
  605. * Deprecated method for generating a drop-down of categories.
  606. *
  607. * @since 0.71
  608. * @deprecated 2.1.0 Use wp_dropdown_categories()
  609. * @see wp_dropdown_categories()
  610. *
  611. * @param int $optionall
  612. * @param string $all
  613. * @param string $orderby
  614. * @param string $order
  615. * @param int $show_last_update
  616. * @param int $show_count
  617. * @param int $hide_empty
  618. * @param bool $optionnone
  619. * @param int $selected
  620. * @param int $exclude
  621. * @return string
  622. */
  623. function dropdown_cats($optionall = 1, $all = 'All', $orderby = 'ID', $order = 'asc',
  624. $show_last_update = 0, $show_count = 0, $hide_empty = 1, $optionnone = false,
  625. $selected = 0, $exclude = 0) {
  626. _deprecated_function( __FUNCTION__, '2.1.0', 'wp_dropdown_categories()' );
  627. $show_option_all = '';
  628. if ( $optionall )
  629. $show_option_all = $all;
  630. $show_option_none = '';
  631. if ( $optionnone )
  632. $show_option_none = __('None');
  633. $vars = compact('show_option_all', 'show_option_none', 'orderby', 'order',
  634. 'show_last_update', 'show_count', 'hide_empty', 'selected', 'exclude');
  635. $query = add_query_arg($vars, '');
  636. return wp_dropdown_categories($query);
  637. }
  638. /**
  639. * Lists authors.
  640. *
  641. * @since 1.2.0
  642. * @deprecated 2.1.0 Use wp_list_authors()
  643. * @see wp_list_authors()
  644. *
  645. * @param bool $optioncount
  646. * @param bool $exclude_admin
  647. * @param bool $show_fullname
  648. * @param bool $hide_empty
  649. * @param string $feed
  650. * @param string $feed_image
  651. * @return null|string
  652. */
  653. function list_authors($optioncount = false, $exclude_admin = true, $show_fullname = false, $hide_empty = true, $feed = '', $feed_image = '') {
  654. _deprecated_function( __FUNCTION__, '2.1.0', 'wp_list_authors()' );
  655. $args = compact('optioncount', 'exclude_admin', 'show_fullname', 'hide_empty', 'feed', 'feed_image');
  656. return wp_list_authors($args);
  657. }
  658. /**
  659. * Retrieves a list of post categories.
  660. *
  661. * @since 1.0.1
  662. * @deprecated 2.1.0 Use wp_get_post_categories()
  663. * @see wp_get_post_categories()
  664. *
  665. * @param int $blogid Not Used
  666. * @param int $post_ID
  667. * @return array
  668. */
  669. function wp_get_post_cats($blogid = '1', $post_ID = 0) {
  670. _deprecated_function( __FUNCTION__, '2.1.0', 'wp_get_post_categories()' );
  671. return wp_get_post_categories($post_ID);
  672. }
  673. /**
  674. * Sets the categories that the post ID belongs to.
  675. *
  676. * @since 1.0.1
  677. * @deprecated 2.1.0
  678. * @deprecated Use wp_set_post_categories()
  679. * @see wp_set_post_categories()
  680. *
  681. * @param int $blogid Not used
  682. * @param int $post_ID
  683. * @param array $post_categories
  684. * @return bool|mixed
  685. */
  686. function wp_set_post_cats($blogid = '1', $post_ID = 0, $post_categories = array()) {
  687. _deprecated_function( __FUNCTION__, '2.1.0', 'wp_set_post_categories()' );
  688. return wp_set_post_categories($post_ID, $post_categories);
  689. }
  690. /**
  691. * Retrieves a list of archives.
  692. *
  693. * @since 0.71
  694. * @deprecated 2.1.0 Use wp_get_archives()
  695. * @see wp_get_archives()
  696. *
  697. * @param string $type
  698. * @param string $limit
  699. * @param string $format
  700. * @param string $before
  701. * @param string $after
  702. * @param bool $show_post_count
  703. * @return string|null
  704. */
  705. function get_archives($type='', $limit='', $format='html', $before = '', $after = '', $show_post_count = false) {
  706. _deprecated_function( __FUNCTION__, '2.1.0', 'wp_get_archives()' );
  707. $args = compact('type', 'limit', 'format', 'before', 'after', 'show_post_count');
  708. return wp_get_archives($args);
  709. }
  710. /**
  711. * Returns or Prints link to the author's posts.
  712. *
  713. * @since 1.2.0
  714. * @deprecated 2.1.0 Use get_author_posts_url()
  715. * @see get_author_posts_url()
  716. *
  717. * @param bool $echo
  718. * @param int $author_id
  719. * @param string $author_nicename Optional.
  720. * @return string|null
  721. */
  722. function get_author_link($echo, $author_id, $author_nicename = '') {
  723. _deprecated_function( __FUNCTION__, '2.1.0', 'get_author_posts_url()' );
  724. $link = get_author_posts_url($author_id, $author_nicename);
  725. if ( $echo )
  726. echo $link;
  727. return $link;
  728. }
  729. /**
  730. * Print list of pages based on arguments.
  731. *
  732. * @since 0.71
  733. * @deprecated 2.1.0 Use wp_link_pages()
  734. * @see wp_link_pages()
  735. *
  736. * @param string $before
  737. * @param string $after
  738. * @param string $next_or_number
  739. * @param string $nextpagelink
  740. * @param string $previouspagelink
  741. * @param string $pagelink
  742. * @param string $more_file
  743. * @return string
  744. */
  745. function link_pages($before='<br />', $after='<br />', $next_or_number='number', $nextpagelink='next page', $previouspagelink='previous page',
  746. $pagelink='%', $more_file='') {
  747. _deprecated_function( __FUNCTION__, '2.1.0', 'wp_link_pages()' );
  748. $args = compact('before', 'after', 'next_or_number', 'nextpagelink', 'previouspagelink', 'pagelink', 'more_file');
  749. return wp_link_pages($args);
  750. }
  751. /**
  752. * Get value based on option.
  753. *
  754. * @since 0.71
  755. * @deprecated 2.1.0 Use get_option()
  756. * @see get_option()
  757. *
  758. * @param string $option
  759. * @return string
  760. */
  761. function get_settings($option) {
  762. _deprecated_function( __FUNCTION__, '2.1.0', 'get_option()' );
  763. return get_option($option);
  764. }
  765. /**
  766. * Print the permalink of the current post in the loop.
  767. *
  768. * @since 0.71
  769. * @deprecated 1.2.0 Use the_permalink()
  770. * @see the_permalink()
  771. */
  772. function permalink_link() {
  773. _deprecated_function( __FUNCTION__, '1.2.0', 'the_permalink()' );
  774. the_permalink();
  775. }
  776. /**
  777. * Print the permalink to the RSS feed.
  778. *
  779. * @since 0.71
  780. * @deprecated 2.3.0 Use the_permalink_rss()
  781. * @see the_permalink_rss()
  782. *
  783. * @param string $deprecated
  784. */
  785. function permalink_single_rss($deprecated = '') {
  786. _deprecated_function( __FUNCTION__, '2.3.0', 'the_permalink_rss()' );
  787. the_permalink_rss();
  788. }
  789. /**
  790. * Gets the links associated with category.
  791. *
  792. * @since 1.0.1
  793. * @deprecated 2.1.0 Use wp_list_bookmarks()
  794. * @see wp_list_bookmarks()
  795. *
  796. * @param string $args a query string
  797. * @return null|string
  798. */
  799. function wp_get_links($args = '') {
  800. _deprecated_function( __FUNCTION__, '2.1.0', 'wp_list_bookmarks()' );
  801. if ( strpos( $args, '=' ) === false ) {
  802. $cat_id = $args;
  803. $args = add_query_arg( 'category', $cat_id, $args );
  804. }
  805. $defaults = array(
  806. 'after' => '<br />',
  807. 'before' => '',
  808. 'between' => ' ',
  809. 'categorize' => 0,
  810. 'category' => '',
  811. 'echo' => true,
  812. 'limit' => -1,
  813. 'orderby' => 'name',
  814. 'show_description' => true,
  815. 'show_images' => true,
  816. 'show_rating' => false,
  817. 'show_updated' => true,
  818. 'title_li' => '',
  819. );
  820. $parsed_args = wp_parse_args( $args, $defaults );
  821. return wp_list_bookmarks($parsed_args);
  822. }
  823. /**
  824. * Gets the links associated with category by ID.
  825. *
  826. * @since 0.71
  827. * @deprecated 2.1.0 Use get_bookmarks()
  828. * @see get_bookmarks()
  829. *
  830. * @param int $category Optional. The category to use. If no category supplied uses all.
  831. * Default 0.
  832. * @param string $before Optional. The HTML to output before the link. Default empty.
  833. * @param string $after Optional. The HTML to output after the link. Default '<br />'.
  834. * @param string $between Optional. The HTML to output between the link/image and its description.
  835. * Not used if no image or $show_images is true. Default ' '.
  836. * @param bool $show_images Optional. Whether to show images (if defined). Default true.
  837. * @param string $orderby Optional. The order to output the links. E.g. 'id', 'name', 'url',
  838. * 'description', 'rating', or 'owner'. Default 'name'.
  839. * If you start the name with an underscore, the order will be reversed.
  840. * Specifying 'rand' as the order will return links in a random order.
  841. * @param bool $show_description Optional. Whether to show the description if show_images=false/not defined.
  842. * Default true.
  843. * @param bool $show_rating Optional. Show rating stars/chars. Default false.
  844. * @param int $limit Optional. Limit to X entries. If not specified, all entries are shown.
  845. * Default -1.
  846. * @param int $show_updated Optional. Whether to show last updated timestamp. Default 1.
  847. * @param bool $echo Whether to echo the results, or return them instead.
  848. * @return null|string
  849. */
  850. function get_links($category = -1, $before = '', $after = '<br />', $between = ' ', $show_images = true, $orderby = 'name',
  851. $show_description = true, $show_rating = false, $limit = -1, $show_updated = 1, $echo = true) {
  852. _deprecated_function( __FUNCTION__, '2.1.0', 'get_bookmarks()' );
  853. $order = 'ASC';
  854. if ( substr($orderby, 0, 1) == '_' ) {
  855. $order = 'DESC';
  856. $orderby = substr($orderby, 1);
  857. }
  858. if ( $category == -1 ) // get_bookmarks() uses '' to signify all categories.
  859. $category = '';
  860. $results = get_bookmarks(array('category' => $category, 'orderby' => $orderby, 'order' => $order, 'show_updated' => $show_updated, 'limit' => $limit));
  861. if ( !$results )
  862. return;
  863. $output = '';
  864. foreach ( (array) $results as $row ) {
  865. if ( !isset($row->recently_updated) )
  866. $row->recently_updated = false;
  867. $output .= $before;
  868. if ( $show_updated && $row->recently_updated )
  869. $output .= get_option('links_recently_updated_prepend');
  870. $the_link = '#';
  871. if ( !empty($row->link_url) )
  872. $the_link = esc_url($row->link_url);
  873. $rel = $row->link_rel;
  874. if ( '' != $rel )
  875. $rel = ' rel="' . $rel . '"';
  876. $desc = esc_attr(sanitize_bookmark_field('link_description', $row->link_description, $row->link_id, 'display'));
  877. $name = esc_attr(sanitize_bookmark_field('link_name', $row->link_name, $row->link_id, 'display'));
  878. $title = $desc;
  879. if ( $show_updated )
  880. if (substr($row->link_updated_f, 0, 2) != '00')
  881. $title .= ' ('.__('Last updated') . ' ' . gmdate(get_option('links_updated_date_format'), $row->link_updated_f + (get_option('gmt_offset') * HOUR_IN_SECONDS)) . ')';
  882. if ( '' != $title )
  883. $title = ' title="' . $title . '"';
  884. $alt = ' alt="' . $name . '"';
  885. $target = $row->link_target;
  886. if ( '' != $target )
  887. $target = ' target="' . $target . '"';
  888. $output .= '<a href="' . $the_link . '"' . $rel . $title . $target. '>';
  889. if ( $row->link_image != null && $show_images ) {
  890. if ( strpos($row->link_image, 'http') !== false )
  891. $output .= "<img src=\"$row->link_image\" $alt $title />";
  892. else // If it's a relative path.
  893. $output .= "<img src=\"" . get_option('siteurl') . "$row->link_image\" $alt $title />";
  894. } else {
  895. $output .= $name;
  896. }
  897. $output .= '</a>';
  898. if ( $show_updated && $row->recently_updated )
  899. $output .= get_option('links_recently_updated_append');
  900. if ( $show_description && '' != $desc )
  901. $output .= $between . $desc;
  902. if ($show_rating) {
  903. $output .= $between . get_linkrating($row);
  904. }
  905. $output .= "$after\n";
  906. } // End while.
  907. if ( !$echo )
  908. return $output;
  909. echo $output;
  910. }
  911. /**
  912. * Output entire list of links by category.
  913. *
  914. * Output a list of all links, listed by category, using the settings in
  915. * $wpdb->linkcategories and output it as a nested HTML unordered list.
  916. *
  917. * @since 1.0.1
  918. * @deprecated 2.1.0 Use wp_list_bookmarks()
  919. * @see wp_list_bookmarks()
  920. *
  921. * @param string $order Sort link categories by 'name' or 'id'
  922. */
  923. function get_links_list($order = 'name') {
  924. _deprecated_function( __FUNCTION__, '2.1.0', 'wp_list_bookmarks()' );
  925. $order = strtolower($order);
  926. // Handle link category sorting.
  927. $direction = 'ASC';
  928. if ( '_' == substr($order,0,1) ) {
  929. $direction = 'DESC';
  930. $order = substr($order,1);
  931. }
  932. if ( !isset($direction) )
  933. $direction = '';
  934. $cats = get_categories(array('type' => 'link', 'orderby' => $order, 'order' => $direction, 'hierarchical' => 0));
  935. // Display each category.
  936. if ( $cats ) {
  937. foreach ( (array) $cats as $cat ) {
  938. // Handle each category.
  939. // Display the category name.
  940. echo ' <li id="linkcat-' . $cat->term_id . '" class="linkcat"><h2>' . apply_filters('link_category', $cat->name ) . "</h2>\n\t<ul>\n";
  941. // Call get_links() with all the appropriate params.
  942. get_links($cat->term_id, '<li>', "</li>", "\n", true, 'name', false);
  943. // Close the last category.
  944. echo "\n\t</ul>\n</li>\n";
  945. }
  946. }
  947. }
  948. /**
  949. * Show the link to the links popup and the number of links.
  950. *
  951. * @since 0.71
  952. * @deprecated 2.1.0
  953. *
  954. * @param string $text the text of the link
  955. * @param int $width the width of the popup window
  956. * @param int $height the height of the popup window
  957. * @param string $file the page to open in the popup window
  958. * @param bool $count the number of links in the db
  959. */
  960. function links_popup_script($text = 'Links', $width=400, $height=400, $file='links.all.php', $count = true) {
  961. _deprecated_function( __FUNCTION__, '2.1.0' );
  962. }
  963. /**
  964. * Legacy function that retrieved the value of a link's link_rating field.
  965. *
  966. * @since 1.0.1
  967. * @deprecated 2.1.0 Use sanitize_bookmark_field()
  968. * @see sanitize_bookmark_field()
  969. *
  970. * @param object $link Link object.
  971. * @return mixed Value of the 'link_rating' field, false otherwise.
  972. */
  973. function get_linkrating( $link ) {
  974. _deprecated_function( __FUNCTION__, '2.1.0', 'sanitize_bookmark_field()' );
  975. return sanitize_bookmark_field('link_rating', $link->link_rating, $link->link_id, 'display');
  976. }
  977. /**
  978. * Gets the name of category by ID.
  979. *
  980. * @since 0.71
  981. * @deprecated 2.1.0 Use get_category()
  982. * @see get_category()
  983. *
  984. * @param int $id The category to get. If no category supplied uses 0
  985. * @return string
  986. */
  987. function get_linkcatname($id = 0) {
  988. _deprecated_function( __FUNCTION__, '2.1.0', 'get_category()' );
  989. $id = (int) $id;
  990. if ( empty($id) )
  991. return '';
  992. $cats = wp_get_link_cats($id);
  993. if ( empty($cats) || ! is_array($cats) )
  994. return '';
  995. $cat_id = (int) $cats[0]; // Take the first cat.
  996. $cat = get_category($cat_id);
  997. return $cat->name;
  998. }
  999. /**
  1000. * Print RSS comment feed link.
  1001. *
  1002. * @since 1.0.1
  1003. * @deprecated 2.5.0 Use post_comments_feed_link()
  1004. * @see post_comments_feed_link()
  1005. *
  1006. * @param string $link_text
  1007. */
  1008. function comments_rss_link($link_text = 'Comments RSS') {
  1009. _deprecated_function( __FUNCTION__, '2.5.0', 'post_comments_feed_link()' );
  1010. post_comments_feed_link($link_text);
  1011. }
  1012. /**
  1013. * Print/Return link to category RSS2 feed.
  1014. *
  1015. * @since 1.2.0
  1016. * @deprecated 2.5.0 Use get_category_feed_link()
  1017. * @see get_category_feed_link()
  1018. *
  1019. * @param bool $echo
  1020. * @param int $cat_ID
  1021. * @return string
  1022. */
  1023. function get_category_rss_link($echo = false, $cat_ID = 1) {
  1024. _deprecated_function( __FUNCTION__, '2.5.0', 'get_category_feed_link()' );
  1025. $link = get_category_feed_link($cat_ID, 'rss2');
  1026. if ( $echo )
  1027. echo $link;
  1028. return $link;
  1029. }
  1030. /**
  1031. * Print/Return link to author RSS feed.
  1032. *
  1033. * @since 1.2.0
  1034. * @deprecated 2.5.0 Use get_author_feed_link()
  1035. * @see get_author_feed_link()
  1036. *
  1037. * @param bool $echo
  1038. * @param int $author_id
  1039. * @return string
  1040. */
  1041. function get_author_rss_link($echo = false, $author_id = 1) {
  1042. _deprecated_function( __FUNCTION__, '2.5.0', 'get_author_feed_link()' );
  1043. $link = get_author_feed_link($author_id);
  1044. if ( $echo )
  1045. echo $link;
  1046. return $link;
  1047. }
  1048. /**
  1049. * Return link to the post RSS feed.
  1050. *
  1051. * @since 1.5.0
  1052. * @deprecated 2.2.0 Use get_post_comments_feed_link()
  1053. * @see get_post_comments_feed_link()
  1054. *
  1055. * @return string
  1056. */
  1057. function comments_rss() {
  1058. _deprecated_function( __FUNCTION__, '2.2.0', 'get_post_comments_feed_link()' );
  1059. return esc_url( get_post_comments_feed_link() );
  1060. }
  1061. /**
  1062. * An alias of wp_create_user().
  1063. *
  1064. * @since 2.0.0
  1065. * @deprecated 2.0.0 Use wp_create_user()
  1066. * @see wp_create_user()
  1067. *
  1068. * @param string $username The user's username.
  1069. * @param string $password The user's password.
  1070. * @param string $email The user's email.
  1071. * @return int The new user's ID.
  1072. */
  1073. function create_user($username, $password, $email) {
  1074. _deprecated_function( __FUNCTION__, '2.0.0', 'wp_create_user()' );
  1075. return wp_create_user($username, $password, $email);
  1076. }
  1077. /**
  1078. * Unused function.
  1079. *
  1080. * @deprecated 2.5.0
  1081. */
  1082. function gzip_compression() {
  1083. _deprecated_function( __FUNCTION__, '2.5.0' );
  1084. return false;
  1085. }
  1086. /**
  1087. * Retrieve an array of comment data about comment $comment_ID.
  1088. *
  1089. * @since 0.71
  1090. * @deprecated 2.7.0 Use get_comment()
  1091. * @see get_comment()
  1092. *
  1093. * @param int $comment_ID The ID of the comment
  1094. * @param int $no_cache Whether to use the cache (cast to bool)
  1095. * @param bool $include_unapproved Whether to include unapproved comments
  1096. * @return array The comment data
  1097. */
  1098. function get_commentdata( $comment_ID, $no_cache = 0, $include_unapproved = false ) {
  1099. _deprecated_function( __FUNCTION__, '2.7.0', 'get_comment()' );
  1100. return get_comment($comment_ID, ARRAY_A);
  1101. }
  1102. /**
  1103. * Retrieve the category name by the category ID.
  1104. *
  1105. * @since 0.71
  1106. * @deprecated 2.8.0 Use get_cat_name()
  1107. * @see get_cat_name()
  1108. *
  1109. * @param int $cat_ID Category ID
  1110. * @return string category name
  1111. */
  1112. function get_catname( $cat_ID ) {
  1113. _deprecated_function( __FUNCTION__, '2.8.0', 'get_cat_name()' );
  1114. return get_cat_name( $cat_ID );
  1115. }
  1116. /**
  1117. * Retrieve category children list separated before and after the term IDs.
  1118. *
  1119. * @since 1.2.0
  1120. * @deprecated 2.8.0 Use get_term_children()
  1121. * @see get_term_children()
  1122. *
  1123. * @param int $id Category ID to retrieve children.
  1124. * @param string $before Optional. Prepend before category term ID. Default '/'.
  1125. * @param string $after Optional. Append after category term ID. Default empty string.
  1126. * @param array $visited Optional. Category Term IDs that have already been added.
  1127. * Default empty array.
  1128. * @return string
  1129. */
  1130. function get_category_children( $id, $before = '/', $after = '', $visited = array() ) {
  1131. _deprecated_function( __FUNCTION__, '2.8.0', 'get_term_children()' );
  1132. if ( 0 == $id )
  1133. return '';
  1134. $chain = '';
  1135. /** TODO: Consult hierarchy */
  1136. $cat_ids = get_all_category_ids();
  1137. foreach ( (array) $cat_ids as $cat_id ) {
  1138. if ( $cat_id == $id )
  1139. continue;
  1140. $category = get_category( $cat_id );
  1141. if ( is_wp_error( $category ) )
  1142. return $category;
  1143. if ( $category->parent == $id && !in_array( $category->term_id, $visited ) ) {
  1144. $visited[] = $category->term_id;
  1145. $chain .= $before.$category->term_id.$after;
  1146. $chain .= get_category_children( $category->term_id, $before, $after );
  1147. }
  1148. }
  1149. return $chain;
  1150. }
  1151. /**
  1152. * Retrieves all category IDs.
  1153. *
  1154. * @since 2.0.0
  1155. * @deprecated 4.0.0 Use get_terms()
  1156. * @see get_terms()
  1157. *
  1158. * @link https://developer.wordpress.org/reference/functions/get_all_category_ids/
  1159. *
  1160. * @return int[] List of all of the category IDs.
  1161. */
  1162. function get_all_category_ids() {
  1163. _deprecated_function( __FUNCTION__, '4.0.0', 'get_terms()' );
  1164. $cat_ids = get_terms(
  1165. array(
  1166. 'taxonomy' => 'category',
  1167. 'fields' => 'ids',
  1168. 'get' => 'all',
  1169. )
  1170. );
  1171. return $cat_ids;
  1172. }
  1173. /**
  1174. * Retrieve the description of the author of the current post.
  1175. *
  1176. * @since 1.5.0
  1177. * @deprecated 2.8.0 Use get_the_author_meta()
  1178. * @see get_the_author_meta()
  1179. *
  1180. * @return string The author's description.
  1181. */
  1182. function get_the_author_description() {
  1183. _deprecated_function( __FUNCTION__, '2.8.0', 'get_the_author_meta(\'description\')' );
  1184. return get_the_author_meta('description');
  1185. }
  1186. /**
  1187. * Display the description of the author of the current post.
  1188. *
  1189. * @since 1.0.0
  1190. * @deprecated 2.8.0 Use the_author_meta()
  1191. * @see the_author_meta()
  1192. */
  1193. function the_author_description() {
  1194. _deprecated_function( __FUNCTION__, '2.8.0', 'the_author_meta(\'description\')' );
  1195. the_author_meta('description');
  1196. }
  1197. /**
  1198. * Retrieve the login name of the author of the current post.
  1199. *
  1200. * @since 1.5.0
  1201. * @deprecated 2.8.0 Use get_the_author_meta()
  1202. * @see get_the_author_meta()
  1203. *
  1204. * @return string The author's login name (username).
  1205. */
  1206. function get_the_author_login() {
  1207. _deprecated_function( __FUNCTION__, '2.8.0', 'get_the_author_meta(\'login\')' );
  1208. return get_the_author_meta('login');
  1209. }
  1210. /**
  1211. * Display the login name of the author of the current post.
  1212. *
  1213. * @since 0.71
  1214. * @deprecated 2.8.0 Use the_author_meta()
  1215. * @see the_author_meta()
  1216. */
  1217. function the_author_login() {
  1218. _deprecated_function( __FUNCTION__, '2.8.0', 'the_author_meta(\'login\')' );
  1219. the_author_meta('login');
  1220. }
  1221. /**
  1222. * Retrieve the first name of the author of the current post.
  1223. *
  1224. * @since 1.5.0
  1225. * @deprecated 2.8.0 Use get_the_author_meta()
  1226. * @see get_the_author_meta()
  1227. *
  1228. * @return string The author's first name.
  1229. */
  1230. function get_the_author_firstname() {
  1231. _deprecated_function( __FUNCTION__, '2.8.0', 'get_the_author_meta(\'first_name\')' );
  1232. return get_the_author_meta('first_name');
  1233. }
  1234. /**
  1235. * Display the first name of the author of the current post.
  1236. *
  1237. * @since 0.71
  1238. * @deprecated 2.8.0 Use the_author_meta()
  1239. * @see the_author_meta()
  1240. */
  1241. function the_author_firstname() {
  1242. _deprecated_function( __FUNCTION__, '2.8.0', 'the_author_meta(\'first_name\')' );
  1243. the_author_meta('first_name');
  1244. }
  1245. /**
  1246. * Retrieve the last name of the author of the current post.
  1247. *
  1248. * @since 1.5.0
  1249. * @deprecated 2.8.0 Use get_the_author_meta()
  1250. * @see get_the_author_meta()
  1251. *
  1252. * @return string The author's last name.
  1253. */
  1254. function get_the_author_lastname() {
  1255. _deprecated_function( __FUNCTION__, '2.8.0', 'get_the_author_meta(\'last_name\')' );
  1256. return get_the_author_meta('last_name');
  1257. }
  1258. /**
  1259. * Display the last name of the author of the current post.
  1260. *
  1261. * @since 0.71
  1262. * @deprecated 2.8.0 Use the_author_meta()
  1263. * @see the_author_meta()
  1264. */
  1265. function the_author_lastname() {
  1266. _deprecated_function( __FUNCTION__, '2.8.0', 'the_author_meta(\'last_name\')' );
  1267. the_author_meta('last_name');
  1268. }
  1269. /**
  1270. * Retrieve the nickname of the author of the current post.
  1271. *
  1272. * @since 1.5.0
  1273. * @deprecated 2.8.0 Use get_the_author_meta()
  1274. * @see get_the_author_meta()
  1275. *
  1276. * @return string The author's nickname.
  1277. */
  1278. function get_the_author_nickname() {
  1279. _deprecated_function( __FUNCTION__, '2.8.0', 'get_the_author_meta(\'nickname\')' );
  1280. return get_the_author_meta('nickname');
  1281. }
  1282. /**
  1283. * Display the nickname of the author of the current post.
  1284. *
  1285. * @since 0.71
  1286. * @deprecated 2.8.0 Use the_author_meta()
  1287. * @see the_author_meta()
  1288. */
  1289. function the_author_nickname() {
  1290. _deprecated_function( __FUNCTION__, '2.8.0', 'the_author_meta(\'nickname\')' );
  1291. the_author_meta('nickname');
  1292. }
  1293. /**
  1294. * Retrieve the email of the author of the current post.
  1295. *
  1296. * @since 1.5.0
  1297. * @deprecated 2.8.0 Use get_the_author_meta()
  1298. * @see get_the_author_meta()
  1299. *
  1300. * @return string The author's username.
  1301. */
  1302. function get_the_author_email() {
  1303. _deprecated_function( __FUNCTION__, '2.8.0', 'get_the_author_meta(\'email\')' );
  1304. return get_the_author_meta('email');
  1305. }
  1306. /**
  1307. * Display the email of the author of the current post.
  1308. *
  1309. * @since 0.71
  1310. * @deprecated 2.8.0 Use the_author_meta()
  1311. * @see the_author_meta()
  1312. */
  1313. function the_author_email() {
  1314. _deprecated_function( __FUNCTION__, '2.8.0', 'the_author_meta(\'email\')' );
  1315. the_author_meta('email');
  1316. }
  1317. /**
  1318. * Retrieve the ICQ number of the author of the current post.
  1319. *
  1320. * @since 1.5.0
  1321. * @deprecated 2.8.0 Use get_the_author_meta()
  1322. * @see get_the_author_meta()
  1323. *
  1324. * @return string The author's ICQ number.
  1325. */
  1326. function get_the_author_icq() {
  1327. _deprecated_function( __FUNCTION__, '2.8.0', 'get_the_author_meta(\'icq\')' );
  1328. return get_the_author_meta('icq');
  1329. }
  1330. /**
  1331. * Display the ICQ number of the author of the current post.
  1332. *
  1333. * @since 0.71
  1334. * @deprecated 2.8.0 Use the_author_meta()
  1335. * @see the_author_meta()
  1336. */
  1337. function the_author_icq() {
  1338. _deprecated_function( __FUNCTION__, '2.8.0', 'the_author_meta(\'icq\')' );
  1339. the_author_meta('icq');
  1340. }
  1341. /**
  1342. * Retrieve the Yahoo! IM name of the author of the current post.
  1343. *
  1344. * @since 1.5.0
  1345. * @deprecated 2.8.0 Use get_the_author_meta()
  1346. * @see get_the_author_meta()
  1347. *
  1348. * @return string The author's Yahoo! IM name.
  1349. */
  1350. function get_the_author_yim() {
  1351. _deprecated_function( __FUNCTION__, '2.8.0', 'get_the_author_meta(\'yim\')' );
  1352. return get_the_author_meta('yim');
  1353. }
  1354. /**
  1355. * Display the Yahoo! IM name of the author of the current post.
  1356. *
  1357. * @since 0.71
  1358. * @deprecated 2.8.0 Use the_author_meta()
  1359. * @see the_author_meta()
  1360. */
  1361. function the_author_yim() {
  1362. _deprecated_function( __FUNCTION__, '2.8.0', 'the_author_meta(\'yim\')' );
  1363. the_author_meta('yim');
  1364. }
  1365. /**
  1366. * Retrieve the MSN address of the author of the current post.
  1367. *
  1368. * @since 1.5.0
  1369. * @deprecated 2.8.0 Use get_the_author_meta()
  1370. * @see get_the_author_meta()
  1371. *
  1372. * @return string The author's MSN address.
  1373. */
  1374. function get_the_author_msn() {
  1375. _deprecated_function( __FUNCTION__, '2.8.0', 'get_the_author_meta(\'msn\')' );
  1376. return get_the_author_meta('msn');
  1377. }
  1378. /**
  1379. * Display the MSN address of the author of the current post.
  1380. *
  1381. * @since 0.71
  1382. * @deprecated 2.8.0 Use the_author_meta()
  1383. * @see the_author_meta()
  1384. */
  1385. function the_author_msn() {
  1386. _deprecated_function( __FUNCTION__, '2.8.0', 'the_author_meta(\'msn\')' );
  1387. the_author_meta('msn');
  1388. }
  1389. /**
  1390. * Retrieve the AIM address of the author of the current post.
  1391. *
  1392. * @since 1.5.0
  1393. * @deprecated 2.8.0 Use get_the_author_meta()
  1394. * @see get_the_author_meta()
  1395. *
  1396. * @return string The author's AIM address.
  1397. */
  1398. function get_the_author_aim() {
  1399. _deprecated_function( __FUNCTION__, '2.8.0', 'get_the_author_meta(\'aim\')' );
  1400. return get_the_author_meta('aim');
  1401. }
  1402. /**
  1403. * Display the AIM address of the author of the current post.
  1404. *
  1405. * @since 0.71
  1406. * @deprecated 2.8.0 Use the_author_meta('aim')
  1407. * @see the_author_meta()
  1408. */
  1409. function the_author_aim() {
  1410. _deprecated_function( __FUNCTION__, '2.8.0', 'the_author_meta(\'aim\')' );
  1411. the_author_meta('aim');
  1412. }
  1413. /**
  1414. * Retrieve the specified author's preferred display name.
  1415. *
  1416. * @since 1.0.0
  1417. * @deprecated 2.8.0 Use get_the_author_meta()
  1418. * @see get_the_author_meta()
  1419. *
  1420. * @param int $auth_id The ID of the author.
  1421. * @return string The author's display name.
  1422. */
  1423. function get_author_name( $auth_id = false ) {
  1424. _deprecated_function( __FUNCTION__, '2.8.0', 'get_the_author_meta(\'display_name\')' );
  1425. return get_the_author_meta('display_name', $auth_id);
  1426. }
  1427. /**
  1428. * Retrieve the URL to the home page of the author of the current post.
  1429. *
  1430. * @since 1.5.0
  1431. * @deprecated 2.8.0 Use get_the_author_meta()
  1432. * @see get_the_author_meta()
  1433. *
  1434. * @return string The URL to the author's page.
  1435. */
  1436. function get_the_author_url() {
  1437. _deprecated_function( __FUNCTION__, '2.8.0', 'get_the_author_meta(\'url\')' );
  1438. return get_the_author_meta('url');
  1439. }
  1440. /**
  1441. * Display the URL to the home page of the author of the current post.
  1442. *
  1443. * @since 0.71
  1444. * @deprecated 2.8.0 Use the_author_meta()
  1445. * @see the_author_meta()
  1446. */
  1447. function the_author_url() {
  1448. _deprecated_function( __FUNCTION__, '2.8.0', 'the_author_meta(\'url\')' );
  1449. the_author_meta('url');
  1450. }
  1451. /**
  1452. * Retrieve the ID of the author of the current post.
  1453. *
  1454. * @since 1.5.0
  1455. * @deprecated 2.8.0 Use get_the_author_meta()
  1456. * @see get_the_author_meta()
  1457. *
  1458. * @return string|int The author's ID.
  1459. */
  1460. function get_the_author_ID() {
  1461. _deprecated_function( __FUNCTION__, '2.8.0', 'get_the_author_meta(\'ID\')' );
  1462. return get_the_author_meta('ID');
  1463. }
  1464. /**
  1465. * Display the ID of the author of the current post.
  1466. *
  1467. * @since 0.71
  1468. * @deprecated 2.8.0 Use the_author_meta()
  1469. * @see the_author_meta()
  1470. */
  1471. function the_author_ID() {
  1472. _deprecated_function( __FUNCTION__, '2.8.0', 'the_author_meta(\'ID\')' );
  1473. the_author_meta('ID');
  1474. }
  1475. /**
  1476. * Display the post content for the feed.
  1477. *
  1478. * For encoding the HTML or the $encode_html parameter, there are three possible values:
  1479. * - '0' will make urls footnotes and use make_url_footnote().
  1480. * - '1' will encode special characters and automatically display all of the content.
  1481. * - '2' will strip all HTML tags from the content.
  1482. *
  1483. * Also note that you cannot set the amount of words and not set the HTML encoding.
  1484. * If that is the case, then the HTML encoding will default to 2, which will strip
  1485. * all HTML tags.
  1486. *
  1487. * To restrict the amount of words of the content, you can use the cut parameter.
  1488. * If the content is less than the amount, then there won't be any dots added to the end.
  1489. * If there is content left over, then dots will be added and the rest of the content
  1490. * will be removed.
  1491. *
  1492. * @since 0.71
  1493. *
  1494. * @deprecated 2.9.0 Use the_content_feed()
  1495. * @see the_content_feed()
  1496. *
  1497. * @param string $more_link_text Optional. Text to display when more content is available
  1498. * but not displayed. Default '(more...)'.
  1499. * @param int $stripteaser Optional. Default 0.
  1500. * @param string $more_file Optional.
  1501. * @param int $cut Optional. Amount of words to keep for the content.
  1502. * @param int $encode_html Optional. How to encode the content.
  1503. */
  1504. function the_content_rss($more_link_text='(more...)', $stripteaser=0, $more_file='', $cut = 0, $encode_html = 0) {
  1505. _deprecated_function( __FUNCTION__, '2.9.0', 'the_content_feed()' );
  1506. $content = get_the_content($more_link_text, $stripteaser);
  1507. /**
  1508. * Filters the post content in the context of an RSS feed.
  1509. *
  1510. * @since 0.71
  1511. *
  1512. * @param string $content Content of the current post.
  1513. */
  1514. $content = apply_filters('the_content_rss', $content);
  1515. if ( $cut && !$encode_html )
  1516. $encode_html = 2;
  1517. if ( 1== $encode_html ) {
  1518. $content = esc_html($content);
  1519. $cut = 0;
  1520. } elseif ( 0 == $encode_html ) {
  1521. $content = make_url_footnote($content);
  1522. } elseif ( 2 == $encode_html ) {
  1523. $content = strip_tags($content);
  1524. }
  1525. if ( $cut ) {
  1526. $blah = explode(' ', $content);
  1527. if ( count($blah) > $cut ) {
  1528. $k = $cut;
  1529. $use_dotdotdot = 1;
  1530. } else {
  1531. $k = count($blah);
  1532. $use_dotdotdot = 0;
  1533. }
  1534. /** @todo Check performance, might be faster to use array slice instead. */
  1535. for ( $i=0; $i<$k; $i++ )
  1536. $excerpt .= $blah[$i].' ';
  1537. $excerpt .= ($use_dotdotdot) ? '...' : '';
  1538. $content = $excerpt;
  1539. }
  1540. $content = str_replace(']]>', ']]&gt;', $content);
  1541. echo $content;
  1542. }
  1543. /**
  1544. * Strip HTML and put links at the bottom of stripped content.
  1545. *
  1546. * Searches for all of the links, strips them out of the content, and places
  1547. * them at the bottom of the content with numbers.
  1548. *
  1549. * @since 0.71
  1550. * @deprecated 2.9.0
  1551. *
  1552. * @param string $content Content to get links.
  1553. * @return string HTML stripped out of content with links at the bottom.
  1554. */
  1555. function make_url_footnote( $content ) {
  1556. _deprecated_function( __FUNCTION__, '2.9.0', '' );
  1557. preg_match_all( '/<a(.+?)href=\"(.+?)\"(.*?)>(.+?)<\/a>/', $content, $matches );
  1558. $links_summary = "\n";
  1559. for ( $i = 0, $c = count( $matches[0] ); $i < $c; $i++ ) {
  1560. $link_match = $matches[0][$i];
  1561. $link_number = '['.($i+1).']';
  1562. $link_url = $matches[2][$i];
  1563. $link_text = $matches[4][$i];
  1564. $content = str_replace( $link_match, $link_text . ' ' . $link_number, $content );
  1565. $link_url = ( ( strtolower( substr( $link_url, 0, 7 ) ) != 'http://' ) && ( strtolower( substr( $link_url, 0, 8 ) ) != 'https://' ) ) ? get_option( 'home' ) . $link_url : $link_url;
  1566. $links_summary .= "\n" . $link_number . ' ' . $link_url;
  1567. }
  1568. $content = strip_tags( $content );
  1569. $content .= $links_summary;
  1570. return $content;
  1571. }
  1572. /**
  1573. * Retrieve translated string with vertical bar context
  1574. *
  1575. * Quite a few times, there will be collisions with similar translatable text
  1576. * found in more than two places but with different translated context.
  1577. *
  1578. * In order to use the separate contexts, the _c() function is used and the
  1579. * translatable string uses a pipe ('|') which has the context the string is in.
  1580. *
  1581. * When the translated string is returned, it is everything before the pipe, not
  1582. * including the pipe character. If there is no pipe in the translated text then
  1583. * everything is returned.
  1584. *
  1585. * @since 2.2.0
  1586. * @deprecated 2.9.0 Use _x()
  1587. * @see _x()
  1588. *
  1589. * @param string $text Text to translate.
  1590. * @param string $domain Optional. Domain to retrieve the translated text.
  1591. * @return string Translated context string without pipe.
  1592. */
  1593. function _c( $text, $domain = 'default' ) {
  1594. _deprecated_function( __FUNCTION__, '2.9.0', '_x()' );
  1595. return before_last_bar( translate( $text, $domain ) );
  1596. }
  1597. /**
  1598. * Translates $text like translate(), but assumes that the text
  1599. * contains a context after its last vertical bar.
  1600. *
  1601. * @since 2.5.0
  1602. * @deprecated 3.0.0 Use _x()
  1603. * @see _x()
  1604. *
  1605. * @param string $text Text to translate.
  1606. * @param string $domain Domain to retrieve the translated text.
  1607. * @return string Translated text.
  1608. */
  1609. function translate_with_context( $text, $domain = 'default' ) {
  1610. _deprecated_function( __FUNCTION__, '2.9.0', '_x()' );
  1611. return before_last_bar( translate( $text, $domain ) );
  1612. }
  1613. /**
  1614. * Legacy version of _n(), which supports contexts.
  1615. *
  1616. * Strips everything from the translation after the last bar.
  1617. *
  1618. * @since 2.7.0
  1619. * @deprecated 3.0.0 Use _nx()
  1620. * @see _nx()
  1621. *
  1622. * @param string $single The text to be used if the number is singular.
  1623. * @param string $plural The text to be used if the number is plural.
  1624. * @param int $number The number to compare against to use either the singular or plural form.
  1625. * @param string $domain Optional. Text domain. Unique identifier for retrieving translated strings.
  1626. * Default 'default'.
  1627. * @return string The translated singular or plural form.
  1628. */
  1629. function _nc( $single, $plural, $number, $domain = 'default' ) {
  1630. _deprecated_function( __FUNCTION__, '2.9.0', '_nx()' );
  1631. return before_last_bar( _n( $single, $plural, $number, $domain ) );
  1632. }
  1633. /**
  1634. * Retrieve the plural or single form based on the amount.
  1635. *
  1636. * @since 1.2.0
  1637. * @deprecated 2.8.0 Use _n()
  1638. * @see _n()
  1639. */
  1640. function __ngettext( ...$args ) { // phpcs:ignore PHPCompatibility.FunctionNameRestrictions.ReservedFunctionNames.FunctionDoubleUnderscore
  1641. _deprecated_function( __FUNCTION__, '2.8.0', '_n()' );
  1642. return _n( ...$args );
  1643. }
  1644. /**
  1645. * Register plural strings in POT file, but don't translate them.
  1646. *
  1647. * @since 2.5.0
  1648. * @deprecated 2.8.0 Use _n_noop()
  1649. * @see _n_noop()
  1650. */
  1651. function __ngettext_noop( ...$args ) { // phpcs:ignore PHPCompatibility.FunctionNameRestrictions.ReservedFunctionNames.FunctionDoubleUnderscore
  1652. _deprecated_function( __FUNCTION__, '2.8.0', '_n_noop()' );
  1653. return _n_noop( ...$args );
  1654. }
  1655. /**
  1656. * Retrieve all autoload options, or all options if no autoloaded ones exist.
  1657. *
  1658. * @since 1.0.0
  1659. * @deprecated 3.0.0 Use wp_load_alloptions())
  1660. * @see wp_load_alloptions()
  1661. *
  1662. * @return array List of all options.
  1663. */
  1664. function get_alloptions() {
  1665. _deprecated_function( __FUNCTION__, '3.0.0', 'wp_load_alloptions()' );
  1666. return wp_load_alloptions();
  1667. }
  1668. /**
  1669. * Retrieve HTML content of attachment image with link.
  1670. *
  1671. * @since 2.0.0
  1672. * @deprecated 2.5.0 Use wp_get_attachment_link()
  1673. * @see wp_get_attachment_link()
  1674. *
  1675. * @param int $id Optional. Post ID.
  1676. * @param bool $fullsize Optional. Whether to use full size image. Default false.
  1677. * @param array $max_dims Optional. Max image dimensions.
  1678. * @param bool $permalink Optional. Whether to include permalink to image. Default false.
  1679. * @return string
  1680. */
  1681. function get_the_attachment_link($id = 0, $fullsize = false, $max_dims = false, $permalink = false) {
  1682. _deprecated_function( __FUNCTION__, '2.5.0', 'wp_get_attachment_link()' );
  1683. $id = (int) $id;
  1684. $_post = get_post($id);
  1685. if ( ('attachment' != $_post->post_type) || !$url = wp_get_attachment_url($_post->ID) )
  1686. return __('Missing Attachment');
  1687. if ( $permalink )
  1688. $url = get_attachment_link($_post->ID);
  1689. $post_title = esc_attr($_post->post_title);
  1690. $innerHTML = get_attachment_innerHTML($_post->ID, $fullsize, $max_dims);
  1691. return "<a href='$url' title='$post_title'>$innerHTML</a>";
  1692. }
  1693. /**
  1694. * Retrieve icon URL and Path.
  1695. *
  1696. * @since 2.1.0
  1697. * @deprecated 2.5.0 Use wp_get_attachment_image_src()
  1698. * @see wp_get_attachment_image_src()
  1699. *
  1700. * @param int $id Optional. Post ID.
  1701. * @param bool $fullsize Optional. Whether to have full image. Default false.
  1702. * @return array Icon URL and full path to file, respectively.
  1703. */
  1704. function get_attachment_icon_src( $id = 0, $fullsize = false ) {
  1705. _deprecated_function( __FUNCTION__, '2.5.0', 'wp_get_attachment_image_src()' );
  1706. $id = (int) $id;
  1707. if ( !$post = get_post($id) )
  1708. return false;
  1709. $file = get_attached_file( $post->ID );
  1710. if ( !$fullsize && $src = wp_get_attachment_thumb_url( $post->ID ) ) {
  1711. // We have a thumbnail desired, specified and existing.
  1712. $src_file = wp_basename($src);
  1713. } elseif ( wp_attachment_is_image( $post->ID ) ) {
  1714. // We have an image without a thumbnail.
  1715. $src = wp_get_attachment_url( $post->ID );
  1716. $src_file = & $file;
  1717. } elseif ( $src = wp_mime_type_icon( $post->ID ) ) {
  1718. // No thumb, no image. We'll look for a mime-related icon instead.
  1719. /** This filter is documented in wp-includes/post.php */
  1720. $icon_dir = apply_filters( 'icon_dir', get_template_directory() . '/images' );
  1721. $src_file = $icon_dir . '/' . wp_basename($src);
  1722. }
  1723. if ( !isset($src) || !$src )
  1724. return false;
  1725. return array($src, $src_file);
  1726. }
  1727. /**
  1728. * Retrieve HTML content of icon attachment image element.
  1729. *
  1730. * @since 2.0.0
  1731. * @deprecated 2.5.0 Use wp_get_attachment_image()
  1732. * @see wp_get_attachment_image()
  1733. *
  1734. * @param int $id Optional. Post ID.
  1735. * @param bool $fullsize Optional. Whether to have full size image. Default false.
  1736. * @param array $max_dims Optional. Dimensions of image.
  1737. * @return string|false HTML content.
  1738. */
  1739. function get_attachment_icon( $id = 0, $fullsize = false, $max_dims = false ) {
  1740. _deprecated_function( __FUNCTION__, '2.5.0', 'wp_get_attachment_image()' );
  1741. $id = (int) $id;
  1742. if ( !$post = get_post($id) )
  1743. return false;
  1744. if ( !$src = get_attachment_icon_src( $post->ID, $fullsize ) )
  1745. return false;
  1746. list($src, $src_file) = $src;
  1747. // Do we need to constrain the image?
  1748. if ( ($max_dims = apply_filters('attachment_max_dims', $max_dims)) && file_exists($src_file) ) {
  1749. $imagesize = wp_getimagesize($src_file);
  1750. if (($imagesize[0] > $max_dims[0]) || $imagesize[1] > $max_dims[1] ) {
  1751. $actual_aspect = $imagesize[0] / $imagesize[1];
  1752. $desired_aspect = $max_dims[0] / $max_dims[1];
  1753. if ( $actual_aspect >= $desired_aspect ) {
  1754. $height = $actual_aspect * $max_dims[0];
  1755. $constraint = "width='{$max_dims[0]}' ";
  1756. $post->iconsize = array($max_dims[0], $height);
  1757. } else {
  1758. $width = $max_dims[1] / $actual_aspect;
  1759. $constraint = "height='{$max_dims[1]}' ";
  1760. $post->iconsize = array($width, $max_dims[1]);
  1761. }
  1762. } else {
  1763. $post->iconsize = array($imagesize[0], $imagesize[1]);
  1764. $constraint = '';
  1765. }
  1766. } else {
  1767. $constraint = '';
  1768. }
  1769. $post_title = esc_attr($post->post_title);
  1770. $icon = "<img src='$src' title='$post_title' alt='$post_title' $constraint/>";
  1771. return apply_filters( 'attachment_icon', $icon, $post->ID );
  1772. }
  1773. /**
  1774. * Retrieve HTML content of image element.
  1775. *
  1776. * @since 2.0.0
  1777. * @deprecated 2.5.0 Use wp_get_attachment_image()
  1778. * @see wp_get_attachment_image()
  1779. *
  1780. * @param int $id Optional. Post ID.
  1781. * @param bool $fullsize Optional. Whether to have full size image. Default false.
  1782. * @param array $max_dims Optional. Dimensions of image.
  1783. * @return string|false
  1784. */
  1785. function get_attachment_innerHTML($id = 0, $fullsize = false, $max_dims = false) {
  1786. _deprecated_function( __FUNCTION__, '2.5.0', 'wp_get_attachment_image()' );
  1787. $id = (int) $id;
  1788. if ( !$post = get_post($id) )
  1789. return false;
  1790. if ( $innerHTML = get_attachment_icon($post->ID, $fullsize, $max_dims))
  1791. return $innerHTML;
  1792. $innerHTML = esc_attr($post->post_title);
  1793. return apply_filters('attachment_innerHTML', $innerHTML, $post->ID);
  1794. }
  1795. /**
  1796. * Retrieves bookmark data based on ID.
  1797. *
  1798. * @since 2.0.0
  1799. * @deprecated 2.1.0 Use get_bookmark()
  1800. * @see get_bookmark()
  1801. *
  1802. * @param int $bookmark_id ID of link
  1803. * @param string $output Optional. Type of output. Accepts OBJECT, ARRAY_N, or ARRAY_A.
  1804. * Default OBJECT.
  1805. * @param string $filter Optional. How to filter the link for output. Accepts 'raw', 'edit',
  1806. * 'attribute', 'js', 'db', or 'display'. Default 'raw'.
  1807. * @return object|array Bookmark object or array, depending on the type specified by `$output`.
  1808. */
  1809. function get_link( $bookmark_id, $output = OBJECT, $filter = 'raw' ) {
  1810. _deprecated_function( __FUNCTION__, '2.1.0', 'get_bookmark()' );
  1811. return get_bookmark($bookmark_id, $output, $filter);
  1812. }
  1813. /**
  1814. * Performs esc_url() for database or redirect usage.
  1815. *
  1816. * @since 2.3.1
  1817. * @deprecated 2.8.0 Use esc_url_raw()
  1818. * @see esc_url_raw()
  1819. *
  1820. * @param string $url The URL to be cleaned.
  1821. * @param array $protocols An array of acceptable protocols.
  1822. * @return string The cleaned URL.
  1823. */
  1824. function sanitize_url( $url, $protocols = null ) {
  1825. _deprecated_function( __FUNCTION__, '2.8.0', 'esc_url_raw()' );
  1826. return esc_url_raw( $url, $protocols );
  1827. }
  1828. /**
  1829. * Checks and cleans a URL.
  1830. *
  1831. * A number of characters are removed from the URL. If the URL is for displaying
  1832. * (the default behaviour) ampersands are also replaced. The 'clean_url' filter
  1833. * is applied to the returned cleaned URL.
  1834. *
  1835. * @since 1.2.0
  1836. * @deprecated 3.0.0 Use esc_url()
  1837. * @see esc_url()
  1838. *
  1839. * @param string $url The URL to be cleaned.
  1840. * @param array $protocols Optional. An array of acceptable protocols.
  1841. * @param string $context Optional. How the URL will be used. Default is 'display'.
  1842. * @return string The cleaned $url after the {@see 'clean_url'} filter is applied.
  1843. */
  1844. function clean_url( $url, $protocols = null, $context = 'display' ) {
  1845. if ( $context == 'db' )
  1846. _deprecated_function( 'clean_url( $context = \'db\' )', '3.0.0', 'esc_url_raw()' );
  1847. else
  1848. _deprecated_function( __FUNCTION__, '3.0.0', 'esc_url()' );
  1849. return esc_url( $url, $protocols, $context );
  1850. }
  1851. /**
  1852. * Escape single quotes, specialchar double quotes, and fix line endings.
  1853. *
  1854. * The filter {@see 'js_escape'} is also applied by esc_js().
  1855. *
  1856. * @since 2.0.4
  1857. * @deprecated 2.8.0 Use esc_js()
  1858. * @see esc_js()
  1859. *
  1860. * @param string $text The text to be escaped.
  1861. * @return string Escaped text.
  1862. */
  1863. function js_escape( $text ) {
  1864. _deprecated_function( __FUNCTION__, '2.8.0', 'esc_js()' );
  1865. return esc_js( $text );
  1866. }
  1867. /**
  1868. * Legacy escaping for HTML blocks.
  1869. *
  1870. * @deprecated 2.8.0 Use esc_html()
  1871. * @see esc_html()
  1872. *
  1873. * @param string $string String to escape.
  1874. * @param string $quote_style Unused.
  1875. * @param false|string $charset Unused.
  1876. * @param false $double_encode Whether to double encode. Unused.
  1877. * @return string Escaped `$string`.
  1878. */
  1879. function wp_specialchars( $string, $quote_style = ENT_NOQUOTES, $charset = false, $double_encode = false ) {
  1880. _deprecated_function( __FUNCTION__, '2.8.0', 'esc_html()' );
  1881. if ( func_num_args() > 1 ) { // Maintain back-compat for people passing additional arguments.
  1882. return _wp_specialchars( $string, $quote_style, $charset, $double_encode );
  1883. } else {
  1884. return esc_html( $string );
  1885. }
  1886. }
  1887. /**
  1888. * Escaping for HTML attributes.
  1889. *
  1890. * @since 2.0.6
  1891. * @deprecated 2.8.0 Use esc_attr()
  1892. * @see esc_attr()
  1893. *
  1894. * @param string $text
  1895. * @return string
  1896. */
  1897. function attribute_escape( $text ) {
  1898. _deprecated_function( __FUNCTION__, '2.8.0', 'esc_attr()' );
  1899. return esc_attr( $text );
  1900. }
  1901. /**
  1902. * Register widget for sidebar with backward compatibility.
  1903. *
  1904. * Allows $name to be an array that accepts either three elements to grab the
  1905. * first element and the third for the name or just uses the first element of
  1906. * the array for the name.
  1907. *
  1908. * Passes to wp_register_sidebar_widget() after argument list and backward
  1909. * compatibility is complete.
  1910. *
  1911. * @since 2.2.0
  1912. * @deprecated 2.8.0 Use wp_register_sidebar_widget()
  1913. * @see wp_register_sidebar_widget()
  1914. *
  1915. * @param string|int $name Widget ID.
  1916. * @param callable $output_callback Run when widget is called.
  1917. * @param string $classname Optional. Classname widget option. Default empty.
  1918. * @param mixed ...$params Widget parameters.
  1919. */
  1920. function register_sidebar_widget($name, $output_callback, $classname = '', ...$params) {
  1921. _deprecated_function( __FUNCTION__, '2.8.0', 'wp_register_sidebar_widget()' );
  1922. // Compat.
  1923. if ( is_array( $name ) ) {
  1924. if ( count( $name ) === 3 ) {
  1925. $name = sprintf( $name[0], $name[2] );
  1926. } else {
  1927. $name = $name[0];
  1928. }
  1929. }
  1930. $id = sanitize_title( $name );
  1931. $options = array();
  1932. if ( ! empty( $classname ) && is_string( $classname ) ) {
  1933. $options['classname'] = $classname;
  1934. }
  1935. wp_register_sidebar_widget( $id, $name, $output_callback, $options, ...$params );
  1936. }
  1937. /**
  1938. * Serves as an alias of wp_unregister_sidebar_widget().
  1939. *
  1940. * @since 2.2.0
  1941. * @deprecated 2.8.0 Use wp_unregister_sidebar_widget()
  1942. * @see wp_unregister_sidebar_widget()
  1943. *
  1944. * @param int|string $id Widget ID.
  1945. */
  1946. function unregister_sidebar_widget($id) {
  1947. _deprecated_function( __FUNCTION__, '2.8.0', 'wp_unregister_sidebar_widget()' );
  1948. return wp_unregister_sidebar_widget($id);
  1949. }
  1950. /**
  1951. * Registers widget control callback for customizing options.
  1952. *
  1953. * Allows $name to be an array that accepts either three elements to grab the
  1954. * first element and the third for the name or just uses the first element of
  1955. * the array for the name.
  1956. *
  1957. * Passes to wp_register_widget_control() after the argument list has
  1958. * been compiled.
  1959. *
  1960. * @since 2.2.0
  1961. * @deprecated 2.8.0 Use wp_register_widget_control()
  1962. * @see wp_register_widget_control()
  1963. *
  1964. * @param int|string $name Sidebar ID.
  1965. * @param callable $control_callback Widget control callback to display and process form.
  1966. * @param int $width Widget width.
  1967. * @param int $height Widget height.
  1968. * @param mixed ...$params Widget parameters.
  1969. */
  1970. function register_widget_control($name, $control_callback, $width = '', $height = '', ...$params) {
  1971. _deprecated_function( __FUNCTION__, '2.8.0', 'wp_register_widget_control()' );
  1972. // Compat.
  1973. if ( is_array( $name ) ) {
  1974. if ( count( $name ) === 3 ) {
  1975. $name = sprintf( $name[0], $name[2] );
  1976. } else {
  1977. $name = $name[0];
  1978. }
  1979. }
  1980. $id = sanitize_title( $name );
  1981. $options = array();
  1982. if ( ! empty( $width ) ) {
  1983. $options['width'] = $width;
  1984. }
  1985. if ( ! empty( $height ) ) {
  1986. $options['height'] = $height;
  1987. }
  1988. wp_register_widget_control( $id, $name, $control_callback, $options, ...$params );
  1989. }
  1990. /**
  1991. * Alias of wp_unregister_widget_control().
  1992. *
  1993. * @since 2.2.0
  1994. * @deprecated 2.8.0 Use wp_unregister_widget_control()
  1995. * @see wp_unregister_widget_control()
  1996. *
  1997. * @param int|string $id Widget ID.
  1998. */
  1999. function unregister_widget_control($id) {
  2000. _deprecated_function( __FUNCTION__, '2.8.0', 'wp_unregister_widget_control()' );
  2001. return wp_unregister_widget_control($id);
  2002. }
  2003. /**
  2004. * Remove user meta data.
  2005. *
  2006. * @since 2.0.0
  2007. * @deprecated 3.0.0 Use delete_user_meta()
  2008. * @see delete_user_meta()
  2009. *
  2010. * @param int $user_id User ID.
  2011. * @param string $meta_key Metadata key.
  2012. * @param mixed $meta_value Optional. Metadata value. Default empty.
  2013. * @return bool True deletion completed and false if user_id is not a number.
  2014. */
  2015. function delete_usermeta( $user_id, $meta_key, $meta_value = '' ) {
  2016. _deprecated_function( __FUNCTION__, '3.0.0', 'delete_user_meta()' );
  2017. global $wpdb;
  2018. if ( !is_numeric( $user_id ) )
  2019. return false;
  2020. $meta_key = preg_replace('|[^a-z0-9_]|i', '', $meta_key);
  2021. if ( is_array($meta_value) || is_object($meta_value) )
  2022. $meta_value = serialize($meta_value);
  2023. $meta_value = trim( $meta_value );
  2024. $cur = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->usermeta WHERE user_id = %d AND meta_key = %s", $user_id, $meta_key) );
  2025. if ( $cur && $cur->umeta_id )
  2026. do_action( 'delete_usermeta', $cur->umeta_id, $user_id, $meta_key, $meta_value );
  2027. if ( ! empty($meta_value) )
  2028. $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE user_id = %d AND meta_key = %s AND meta_value = %s", $user_id, $meta_key, $meta_value) );
  2029. else
  2030. $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE user_id = %d AND meta_key = %s", $user_id, $meta_key) );
  2031. clean_user_cache( $user_id );
  2032. wp_cache_delete( $user_id, 'user_meta' );
  2033. if ( $cur && $cur->umeta_id )
  2034. do_action( 'deleted_usermeta', $cur->umeta_id, $user_id, $meta_key, $meta_value );
  2035. return true;
  2036. }
  2037. /**
  2038. * Retrieve user metadata.
  2039. *
  2040. * If $user_id is not a number, then the function will fail over with a 'false'
  2041. * boolean return value. Other returned values depend on whether there is only
  2042. * one item to be returned, which be that single item type. If there is more
  2043. * than one metadata value, then it will be list of metadata values.
  2044. *
  2045. * @since 2.0.0
  2046. * @deprecated 3.0.0 Use get_user_meta()
  2047. * @see get_user_meta()
  2048. *
  2049. * @param int $user_id User ID
  2050. * @param string $meta_key Optional. Metadata key. Default empty.
  2051. * @return mixed
  2052. */
  2053. function get_usermeta( $user_id, $meta_key = '' ) {
  2054. _deprecated_function( __FUNCTION__, '3.0.0', 'get_user_meta()' );
  2055. global $wpdb;
  2056. $user_id = (int) $user_id;
  2057. if ( !$user_id )
  2058. return false;
  2059. if ( !empty($meta_key) ) {
  2060. $meta_key = preg_replace('|[^a-z0-9_]|i', '', $meta_key);
  2061. $user = wp_cache_get($user_id, 'users');
  2062. // Check the cached user object.
  2063. if ( false !== $user && isset($user->$meta_key) )
  2064. $metas = array($user->$meta_key);
  2065. else
  2066. $metas = $wpdb->get_col( $wpdb->prepare("SELECT meta_value FROM $wpdb->usermeta WHERE user_id = %d AND meta_key = %s", $user_id, $meta_key) );
  2067. } else {
  2068. $metas = $wpdb->get_col( $wpdb->prepare("SELECT meta_value FROM $wpdb->usermeta WHERE user_id = %d", $user_id) );
  2069. }
  2070. if ( empty($metas) ) {
  2071. if ( empty($meta_key) )
  2072. return array();
  2073. else
  2074. return '';
  2075. }
  2076. $metas = array_map('maybe_unserialize', $metas);
  2077. if ( count($metas) == 1 )
  2078. return $metas[0];
  2079. else
  2080. return $metas;
  2081. }
  2082. /**
  2083. * Update metadata of user.
  2084. *
  2085. * There is no need to serialize values, they will be serialized if it is
  2086. * needed. The metadata key can only be a string with underscores. All else will
  2087. * be removed.
  2088. *
  2089. * Will remove the metadata, if the meta value is empty.
  2090. *
  2091. * @since 2.0.0
  2092. * @deprecated 3.0.0 Use update_user_meta()
  2093. * @see update_user_meta()
  2094. *
  2095. * @param int $user_id User ID
  2096. * @param string $meta_key Metadata key.
  2097. * @param mixed $meta_value Metadata value.
  2098. * @return bool True on successful update, false on failure.
  2099. */
  2100. function update_usermeta( $user_id, $meta_key, $meta_value ) {
  2101. _deprecated_function( __FUNCTION__, '3.0.0', 'update_user_meta()' );
  2102. global $wpdb;
  2103. if ( !is_numeric( $user_id ) )
  2104. return false;
  2105. $meta_key = preg_replace('|[^a-z0-9_]|i', '', $meta_key);
  2106. /** @todo Might need fix because usermeta data is assumed to be already escaped */
  2107. if ( is_string($meta_value) )
  2108. $meta_value = stripslashes($meta_value);
  2109. $meta_value = maybe_serialize($meta_value);
  2110. if (empty($meta_value)) {
  2111. return delete_usermeta($user_id, $meta_key);
  2112. }
  2113. $cur = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->usermeta WHERE user_id = %d AND meta_key = %s", $user_id, $meta_key) );
  2114. if ( $cur )
  2115. do_action( 'update_usermeta', $cur->umeta_id, $user_id, $meta_key, $meta_value );
  2116. if ( !$cur )
  2117. $wpdb->insert($wpdb->usermeta, compact('user_id', 'meta_key', 'meta_value') );
  2118. elseif ( $cur->meta_value != $meta_value )
  2119. $wpdb->update($wpdb->usermeta, compact('meta_value'), compact('user_id', 'meta_key') );
  2120. else
  2121. return false;
  2122. clean_user_cache( $user_id );
  2123. wp_cache_delete( $user_id, 'user_meta' );
  2124. if ( !$cur )
  2125. do_action( 'added_usermeta', $wpdb->insert_id, $user_id, $meta_key, $meta_value );
  2126. else
  2127. do_action( 'updated_usermeta', $cur->umeta_id, $user_id, $meta_key, $meta_value );
  2128. return true;
  2129. }
  2130. /**
  2131. * Get users for the site.
  2132. *
  2133. * For setups that use the multisite feature. Can be used outside of the
  2134. * multisite feature.
  2135. *
  2136. * @since 2.2.0
  2137. * @deprecated 3.1.0 Use get_users()
  2138. * @see get_users()
  2139. *
  2140. * @global wpdb $wpdb WordPress database abstraction object.
  2141. *
  2142. * @param int $id Site ID.
  2143. * @return array List of users that are part of that site ID
  2144. */
  2145. function get_users_of_blog( $id = '' ) {
  2146. _deprecated_function( __FUNCTION__, '3.1.0', 'get_users()' );
  2147. global $wpdb;
  2148. if ( empty( $id ) ) {
  2149. $id = get_current_blog_id();
  2150. }
  2151. $blog_prefix = $wpdb->get_blog_prefix($id);
  2152. $users = $wpdb->get_results( "SELECT user_id, user_id AS ID, user_login, display_name, user_email, meta_value FROM $wpdb->users, $wpdb->usermeta WHERE {$wpdb->users}.ID = {$wpdb->usermeta}.user_id AND meta_key = '{$blog_prefix}capabilities' ORDER BY {$wpdb->usermeta}.user_id" );
  2153. return $users;
  2154. }
  2155. /**
  2156. * Enable/disable automatic general feed link outputting.
  2157. *
  2158. * @since 2.8.0
  2159. * @deprecated 3.0.0 Use add_theme_support()
  2160. * @see add_theme_support()
  2161. *
  2162. * @param bool $add Optional. Add or remove links. Default true.
  2163. */
  2164. function automatic_feed_links( $add = true ) {
  2165. _deprecated_function( __FUNCTION__, '3.0.0', "add_theme_support( 'automatic-feed-links' )" );
  2166. if ( $add )
  2167. add_theme_support( 'automatic-feed-links' );
  2168. else
  2169. remove_action( 'wp_head', 'feed_links_extra', 3 ); // Just do this yourself in 3.0+.
  2170. }
  2171. /**
  2172. * Retrieve user data based on field.
  2173. *
  2174. * @since 1.5.0
  2175. * @deprecated 3.0.0 Use get_the_author_meta()
  2176. * @see get_the_author_meta()
  2177. *
  2178. * @param string $field User meta field.
  2179. * @param false|int $user Optional. User ID to retrieve the field for. Default false (current user).
  2180. * @return string The author's field from the current author's DB object.
  2181. */
  2182. function get_profile( $field, $user = false ) {
  2183. _deprecated_function( __FUNCTION__, '3.0.0', 'get_the_author_meta()' );
  2184. if ( $user ) {
  2185. $user = get_user_by( 'login', $user );
  2186. $user = $user->ID;
  2187. }
  2188. return get_the_author_meta( $field, $user );
  2189. }
  2190. /**
  2191. * Retrieves the number of posts a user has written.
  2192. *
  2193. * @since 0.71
  2194. * @deprecated 3.0.0 Use count_user_posts()
  2195. * @see count_user_posts()
  2196. *
  2197. * @param int $userid User to count posts for.
  2198. * @return int Number of posts the given user has written.
  2199. */
  2200. function get_usernumposts( $userid ) {
  2201. _deprecated_function( __FUNCTION__, '3.0.0', 'count_user_posts()' );
  2202. return count_user_posts( $userid );
  2203. }
  2204. /**
  2205. * Callback used to change %uXXXX to &#YYY; syntax
  2206. *
  2207. * @since 2.8.0
  2208. * @access private
  2209. * @deprecated 3.0.0
  2210. *
  2211. * @param array $matches Single Match
  2212. * @return string An HTML entity
  2213. */
  2214. function funky_javascript_callback($matches) {
  2215. return "&#".base_convert($matches[1],16,10).";";
  2216. }
  2217. /**
  2218. * Fixes JavaScript bugs in browsers.
  2219. *
  2220. * Converts unicode characters to HTML numbered entities.
  2221. *
  2222. * @since 1.5.0
  2223. * @deprecated 3.0.0
  2224. *
  2225. * @global $is_macIE
  2226. * @global $is_winIE
  2227. *
  2228. * @param string $text Text to be made safe.
  2229. * @return string Fixed text.
  2230. */
  2231. function funky_javascript_fix($text) {
  2232. _deprecated_function( __FUNCTION__, '3.0.0' );
  2233. // Fixes for browsers' JavaScript bugs.
  2234. global $is_macIE, $is_winIE;
  2235. if ( $is_winIE || $is_macIE )
  2236. $text = preg_replace_callback("/\%u([0-9A-F]{4,4})/",
  2237. "funky_javascript_callback",
  2238. $text);
  2239. return $text;
  2240. }
  2241. /**
  2242. * Checks that the taxonomy name exists.
  2243. *
  2244. * @since 2.3.0
  2245. * @deprecated 3.0.0 Use taxonomy_exists()
  2246. * @see taxonomy_exists()
  2247. *
  2248. * @param string $taxonomy Name of taxonomy object
  2249. * @return bool Whether the taxonomy exists.
  2250. */
  2251. function is_taxonomy( $taxonomy ) {
  2252. _deprecated_function( __FUNCTION__, '3.0.0', 'taxonomy_exists()' );
  2253. return taxonomy_exists( $taxonomy );
  2254. }
  2255. /**
  2256. * Check if Term exists.
  2257. *
  2258. * @since 2.3.0
  2259. * @deprecated 3.0.0 Use term_exists()
  2260. * @see term_exists()
  2261. *
  2262. * @param int|string $term The term to check
  2263. * @param string $taxonomy The taxonomy name to use
  2264. * @param int $parent ID of parent term under which to confine the exists search.
  2265. * @return mixed Get the term ID or term object, if exists.
  2266. */
  2267. function is_term( $term, $taxonomy = '', $parent = 0 ) {
  2268. _deprecated_function( __FUNCTION__, '3.0.0', 'term_exists()' );
  2269. return term_exists( $term, $taxonomy, $parent );
  2270. }
  2271. /**
  2272. * Determines whether the current admin page is generated by a plugin.
  2273. *
  2274. * Use global $plugin_page and/or get_plugin_page_hookname() hooks.
  2275. *
  2276. * For more information on this and similar theme functions, check out
  2277. * the {@link https://developer.wordpress.org/themes/basics/conditional-tags/
  2278. * Conditional Tags} article in the Theme Developer Handbook.
  2279. *
  2280. * @since 1.5.0
  2281. * @deprecated 3.1.0
  2282. *
  2283. * @global $plugin_page
  2284. *
  2285. * @return bool
  2286. */
  2287. function is_plugin_page() {
  2288. _deprecated_function( __FUNCTION__, '3.1.0' );
  2289. global $plugin_page;
  2290. if ( isset($plugin_page) )
  2291. return true;
  2292. return false;
  2293. }
  2294. /**
  2295. * Update the categories cache.
  2296. *
  2297. * This function does not appear to be used anymore or does not appear to be
  2298. * needed. It might be a legacy function left over from when there was a need
  2299. * for updating the category cache.
  2300. *
  2301. * @since 1.5.0
  2302. * @deprecated 3.1.0
  2303. *
  2304. * @return bool Always return True
  2305. */
  2306. function update_category_cache() {
  2307. _deprecated_function( __FUNCTION__, '3.1.0' );
  2308. return true;
  2309. }
  2310. /**
  2311. * Check for PHP timezone support
  2312. *
  2313. * @since 2.9.0
  2314. * @deprecated 3.2.0
  2315. *
  2316. * @return bool
  2317. */
  2318. function wp_timezone_supported() {
  2319. _deprecated_function( __FUNCTION__, '3.2.0' );
  2320. return true;
  2321. }
  2322. /**
  2323. * Displays an editor: TinyMCE, HTML, or both.
  2324. *
  2325. * @since 2.1.0
  2326. * @deprecated 3.3.0 Use wp_editor()
  2327. * @see wp_editor()
  2328. *
  2329. * @param string $content Textarea content.
  2330. * @param string $id Optional. HTML ID attribute value. Default 'content'.
  2331. * @param string $prev_id Optional. Unused.
  2332. * @param bool $media_buttons Optional. Whether to display media buttons. Default true.
  2333. * @param int $tab_index Optional. Unused.
  2334. * @param bool $extended Optional. Unused.
  2335. */
  2336. function the_editor($content, $id = 'content', $prev_id = 'title', $media_buttons = true, $tab_index = 2, $extended = true) {
  2337. _deprecated_function( __FUNCTION__, '3.3.0', 'wp_editor()' );
  2338. wp_editor( $content, $id, array( 'media_buttons' => $media_buttons ) );
  2339. }
  2340. /**
  2341. * Perform the query to get the $metavalues array(s) needed by _fill_user and _fill_many_users
  2342. *
  2343. * @since 3.0.0
  2344. * @deprecated 3.3.0
  2345. *
  2346. * @param array $ids User ID numbers list.
  2347. * @return array of arrays. The array is indexed by user_id, containing $metavalues object arrays.
  2348. */
  2349. function get_user_metavalues($ids) {
  2350. _deprecated_function( __FUNCTION__, '3.3.0' );
  2351. $objects = array();
  2352. $ids = array_map('intval', $ids);
  2353. foreach ( $ids as $id )
  2354. $objects[$id] = array();
  2355. $metas = update_meta_cache('user', $ids);
  2356. foreach ( $metas as $id => $meta ) {
  2357. foreach ( $meta as $key => $metavalues ) {
  2358. foreach ( $metavalues as $value ) {
  2359. $objects[$id][] = (object)array( 'user_id' => $id, 'meta_key' => $key, 'meta_value' => $value);
  2360. }
  2361. }
  2362. }
  2363. return $objects;
  2364. }
  2365. /**
  2366. * Sanitize every user field.
  2367. *
  2368. * If the context is 'raw', then the user object or array will get minimal santization of the int fields.
  2369. *
  2370. * @since 2.3.0
  2371. * @deprecated 3.3.0
  2372. *
  2373. * @param object|array $user The user object or array.
  2374. * @param string $context Optional. How to sanitize user fields. Default 'display'.
  2375. * @return object|array The now sanitized user object or array (will be the same type as $user).
  2376. */
  2377. function sanitize_user_object($user, $context = 'display') {
  2378. _deprecated_function( __FUNCTION__, '3.3.0' );
  2379. if ( is_object($user) ) {
  2380. if ( !isset($user->ID) )
  2381. $user->ID = 0;
  2382. if ( ! ( $user instanceof WP_User ) ) {
  2383. $vars = get_object_vars($user);
  2384. foreach ( array_keys($vars) as $field ) {
  2385. if ( is_string($user->$field) || is_numeric($user->$field) )
  2386. $user->$field = sanitize_user_field($field, $user->$field, $user->ID, $context);
  2387. }
  2388. }
  2389. $user->filter = $context;
  2390. } else {
  2391. if ( !isset($user['ID']) )
  2392. $user['ID'] = 0;
  2393. foreach ( array_keys($user) as $field )
  2394. $user[$field] = sanitize_user_field($field, $user[$field], $user['ID'], $context);
  2395. $user['filter'] = $context;
  2396. }
  2397. return $user;
  2398. }
  2399. /**
  2400. * Get boundary post relational link.
  2401. *
  2402. * Can either be start or end post relational link.
  2403. *
  2404. * @since 2.8.0
  2405. * @deprecated 3.3.0
  2406. *
  2407. * @param string $title Optional. Link title format. Default '%title'.
  2408. * @param bool $in_same_cat Optional. Whether link should be in a same category.
  2409. * Default false.
  2410. * @param string $excluded_categories Optional. Excluded categories IDs. Default empty.
  2411. * @param bool $start Optional. Whether to display link to first or last post.
  2412. * Default true.
  2413. * @return string
  2414. */
  2415. function get_boundary_post_rel_link($title = '%title', $in_same_cat = false, $excluded_categories = '', $start = true) {
  2416. _deprecated_function( __FUNCTION__, '3.3.0' );
  2417. $posts = get_boundary_post($in_same_cat, $excluded_categories, $start);
  2418. // If there is no post, stop.
  2419. if ( empty($posts) )
  2420. return;
  2421. // Even though we limited get_posts() to return only 1 item it still returns an array of objects.
  2422. $post = $posts[0];
  2423. if ( empty($post->post_title) )
  2424. $post->post_title = $start ? __('First Post') : __('Last Post');
  2425. $date = mysql2date(get_option('date_format'), $post->post_date);
  2426. $title = str_replace('%title', $post->post_title, $title);
  2427. $title = str_replace('%date', $date, $title);
  2428. $title = apply_filters('the_title', $title, $post->ID);
  2429. $link = $start ? "<link rel='start' title='" : "<link rel='end' title='";
  2430. $link .= esc_attr($title);
  2431. $link .= "' href='" . get_permalink($post) . "' />\n";
  2432. $boundary = $start ? 'start' : 'end';
  2433. return apply_filters( "{$boundary}_post_rel_link", $link );
  2434. }
  2435. /**
  2436. * Display relational link for the first post.
  2437. *
  2438. * @since 2.8.0
  2439. * @deprecated 3.3.0
  2440. *
  2441. * @param string $title Optional. Link title format.
  2442. * @param bool $in_same_cat Optional. Whether link should be in a same category.
  2443. * @param string $excluded_categories Optional. Excluded categories IDs.
  2444. */
  2445. function start_post_rel_link($title = '%title', $in_same_cat = false, $excluded_categories = '') {
  2446. _deprecated_function( __FUNCTION__, '3.3.0' );
  2447. echo get_boundary_post_rel_link($title, $in_same_cat, $excluded_categories, true);
  2448. }
  2449. /**
  2450. * Get site index relational link.
  2451. *
  2452. * @since 2.8.0
  2453. * @deprecated 3.3.0
  2454. *
  2455. * @return string
  2456. */
  2457. function get_index_rel_link() {
  2458. _deprecated_function( __FUNCTION__, '3.3.0' );
  2459. $link = "<link rel='index' title='" . esc_attr( get_bloginfo( 'name', 'display' ) ) . "' href='" . esc_url( user_trailingslashit( get_bloginfo( 'url', 'display' ) ) ) . "' />\n";
  2460. return apply_filters( "index_rel_link", $link );
  2461. }
  2462. /**
  2463. * Display relational link for the site index.
  2464. *
  2465. * @since 2.8.0
  2466. * @deprecated 3.3.0
  2467. */
  2468. function index_rel_link() {
  2469. _deprecated_function( __FUNCTION__, '3.3.0' );
  2470. echo get_index_rel_link();
  2471. }
  2472. /**
  2473. * Get parent post relational link.
  2474. *
  2475. * @since 2.8.0
  2476. * @deprecated 3.3.0
  2477. *
  2478. * @param string $title Optional. Link title format. Default '%title'.
  2479. * @return string
  2480. */
  2481. function get_parent_post_rel_link( $title = '%title' ) {
  2482. _deprecated_function( __FUNCTION__, '3.3.0' );
  2483. if ( ! empty( $GLOBALS['post'] ) && ! empty( $GLOBALS['post']->post_parent ) )
  2484. $post = get_post($GLOBALS['post']->post_parent);
  2485. if ( empty($post) )
  2486. return;
  2487. $date = mysql2date(get_option('date_format'), $post->post_date);
  2488. $title = str_replace('%title', $post->post_title, $title);
  2489. $title = str_replace('%date', $date, $title);
  2490. $title = apply_filters('the_title', $title, $post->ID);
  2491. $link = "<link rel='up' title='";
  2492. $link .= esc_attr( $title );
  2493. $link .= "' href='" . get_permalink($post) . "' />\n";
  2494. return apply_filters( "parent_post_rel_link", $link );
  2495. }
  2496. /**
  2497. * Display relational link for parent item
  2498. *
  2499. * @since 2.8.0
  2500. * @deprecated 3.3.0
  2501. *
  2502. * @param string $title Optional. Link title format. Default '%title'.
  2503. */
  2504. function parent_post_rel_link( $title = '%title' ) {
  2505. _deprecated_function( __FUNCTION__, '3.3.0' );
  2506. echo get_parent_post_rel_link($title);
  2507. }
  2508. /**
  2509. * Add the "Dashboard"/"Visit Site" menu.
  2510. *
  2511. * @since 3.2.0
  2512. * @deprecated 3.3.0
  2513. *
  2514. * @param WP_Admin_Bar $wp_admin_bar WP_Admin_Bar instance.
  2515. */
  2516. function wp_admin_bar_dashboard_view_site_menu( $wp_admin_bar ) {
  2517. _deprecated_function( __FUNCTION__, '3.3.0' );
  2518. $user_id = get_current_user_id();
  2519. if ( 0 != $user_id ) {
  2520. if ( is_admin() )
  2521. $wp_admin_bar->add_menu( array( 'id' => 'view-site', 'title' => __( 'Visit Site' ), 'href' => home_url() ) );
  2522. elseif ( is_multisite() )
  2523. $wp_admin_bar->add_menu( array( 'id' => 'dashboard', 'title' => __( 'Dashboard' ), 'href' => get_dashboard_url( $user_id ) ) );
  2524. else
  2525. $wp_admin_bar->add_menu( array( 'id' => 'dashboard', 'title' => __( 'Dashboard' ), 'href' => admin_url() ) );
  2526. }
  2527. }
  2528. /**
  2529. * Checks if the current user belong to a given site.
  2530. *
  2531. * @since MU (3.0.0)
  2532. * @deprecated 3.3.0 Use is_user_member_of_blog()
  2533. * @see is_user_member_of_blog()
  2534. *
  2535. * @param int $blog_id Site ID
  2536. * @return bool True if the current users belong to $blog_id, false if not.
  2537. */
  2538. function is_blog_user( $blog_id = 0 ) {
  2539. _deprecated_function( __FUNCTION__, '3.3.0', 'is_user_member_of_blog()' );
  2540. return is_user_member_of_blog( get_current_user_id(), $blog_id );
  2541. }
  2542. /**
  2543. * Open the file handle for debugging.
  2544. *
  2545. * @since 0.71
  2546. * @deprecated 3.4.0 Use error_log()
  2547. * @see error_log()
  2548. *
  2549. * @link https://www.php.net/manual/en/function.error-log.php
  2550. *
  2551. * @param string $filename File name.
  2552. * @param string $mode Type of access you required to the stream.
  2553. * @return false Always false.
  2554. */
  2555. function debug_fopen( $filename, $mode ) {
  2556. _deprecated_function( __FUNCTION__, '3.4.0', 'error_log()' );
  2557. return false;
  2558. }
  2559. /**
  2560. * Write contents to the file used for debugging.
  2561. *
  2562. * @since 0.71
  2563. * @deprecated 3.4.0 Use error_log()
  2564. * @see error_log()
  2565. *
  2566. * @link https://www.php.net/manual/en/function.error-log.php
  2567. *
  2568. * @param mixed $fp Unused.
  2569. * @param string $string Message to log.
  2570. */
  2571. function debug_fwrite( $fp, $string ) {
  2572. _deprecated_function( __FUNCTION__, '3.4.0', 'error_log()' );
  2573. if ( ! empty( $GLOBALS['debug'] ) )
  2574. error_log( $string );
  2575. }
  2576. /**
  2577. * Close the debugging file handle.
  2578. *
  2579. * @since 0.71
  2580. * @deprecated 3.4.0 Use error_log()
  2581. * @see error_log()
  2582. *
  2583. * @link https://www.php.net/manual/en/function.error-log.php
  2584. *
  2585. * @param mixed $fp Unused.
  2586. */
  2587. function debug_fclose( $fp ) {
  2588. _deprecated_function( __FUNCTION__, '3.4.0', 'error_log()' );
  2589. }
  2590. /**
  2591. * Retrieve list of themes with theme data in theme directory.
  2592. *
  2593. * The theme is broken, if it doesn't have a parent theme and is missing either
  2594. * style.css and, or index.php. If the theme has a parent theme then it is
  2595. * broken, if it is missing style.css; index.php is optional.
  2596. *
  2597. * @since 1.5.0
  2598. * @deprecated 3.4.0 Use wp_get_themes()
  2599. * @see wp_get_themes()
  2600. *
  2601. * @return array Theme list with theme data.
  2602. */
  2603. function get_themes() {
  2604. _deprecated_function( __FUNCTION__, '3.4.0', 'wp_get_themes()' );
  2605. global $wp_themes;
  2606. if ( isset( $wp_themes ) )
  2607. return $wp_themes;
  2608. $themes = wp_get_themes();
  2609. $wp_themes = array();
  2610. foreach ( $themes as $theme ) {
  2611. $name = $theme->get('Name');
  2612. if ( isset( $wp_themes[ $name ] ) )
  2613. $wp_themes[ $name . '/' . $theme->get_stylesheet() ] = $theme;
  2614. else
  2615. $wp_themes[ $name ] = $theme;
  2616. }
  2617. return $wp_themes;
  2618. }
  2619. /**
  2620. * Retrieve theme data.
  2621. *
  2622. * @since 1.5.0
  2623. * @deprecated 3.4.0 Use wp_get_theme()
  2624. * @see wp_get_theme()
  2625. *
  2626. * @param string $theme Theme name.
  2627. * @return array|null Null, if theme name does not exist. Theme data, if exists.
  2628. */
  2629. function get_theme( $theme ) {
  2630. _deprecated_function( __FUNCTION__, '3.4.0', 'wp_get_theme( $stylesheet )' );
  2631. $themes = get_themes();
  2632. if ( is_array( $themes ) && array_key_exists( $theme, $themes ) )
  2633. return $themes[ $theme ];
  2634. return null;
  2635. }
  2636. /**
  2637. * Retrieve current theme name.
  2638. *
  2639. * @since 1.5.0
  2640. * @deprecated 3.4.0 Use wp_get_theme()
  2641. * @see wp_get_theme()
  2642. *
  2643. * @return string
  2644. */
  2645. function get_current_theme() {
  2646. _deprecated_function( __FUNCTION__, '3.4.0', 'wp_get_theme()' );
  2647. if ( $theme = get_option( 'current_theme' ) )
  2648. return $theme;
  2649. return wp_get_theme()->get('Name');
  2650. }
  2651. /**
  2652. * Accepts matches array from preg_replace_callback in wpautop() or a string.
  2653. *
  2654. * Ensures that the contents of a `<pre>...</pre>` HTML block are not
  2655. * converted into paragraphs or line breaks.
  2656. *
  2657. * @since 1.2.0
  2658. * @deprecated 3.4.0
  2659. *
  2660. * @param array|string $matches The array or string
  2661. * @return string The pre block without paragraph/line break conversion.
  2662. */
  2663. function clean_pre($matches) {
  2664. _deprecated_function( __FUNCTION__, '3.4.0' );
  2665. if ( is_array($matches) )
  2666. $text = $matches[1] . $matches[2] . "</pre>";
  2667. else
  2668. $text = $matches;
  2669. $text = str_replace(array('<br />', '<br/>', '<br>'), array('', '', ''), $text);
  2670. $text = str_replace('<p>', "\n", $text);
  2671. $text = str_replace('</p>', '', $text);
  2672. return $text;
  2673. }
  2674. /**
  2675. * Add callbacks for image header display.
  2676. *
  2677. * @since 2.1.0
  2678. * @deprecated 3.4.0 Use add_theme_support()
  2679. * @see add_theme_support()
  2680. *
  2681. * @param callable $wp_head_callback Call on the {@see 'wp_head'} action.
  2682. * @param callable $admin_head_callback Call on custom header administration screen.
  2683. * @param callable $admin_preview_callback Output a custom header image div on the custom header administration screen. Optional.
  2684. */
  2685. function add_custom_image_header( $wp_head_callback, $admin_head_callback, $admin_preview_callback = '' ) {
  2686. _deprecated_function( __FUNCTION__, '3.4.0', 'add_theme_support( \'custom-header\', $args )' );
  2687. $args = array(
  2688. 'wp-head-callback' => $wp_head_callback,
  2689. 'admin-head-callback' => $admin_head_callback,
  2690. );
  2691. if ( $admin_preview_callback )
  2692. $args['admin-preview-callback'] = $admin_preview_callback;
  2693. return add_theme_support( 'custom-header', $args );
  2694. }
  2695. /**
  2696. * Remove image header support.
  2697. *
  2698. * @since 3.1.0
  2699. * @deprecated 3.4.0 Use remove_theme_support()
  2700. * @see remove_theme_support()
  2701. *
  2702. * @return null|bool Whether support was removed.
  2703. */
  2704. function remove_custom_image_header() {
  2705. _deprecated_function( __FUNCTION__, '3.4.0', 'remove_theme_support( \'custom-header\' )' );
  2706. return remove_theme_support( 'custom-header' );
  2707. }
  2708. /**
  2709. * Add callbacks for background image display.
  2710. *
  2711. * @since 3.0.0
  2712. * @deprecated 3.4.0 Use add_theme_support()
  2713. * @see add_theme_support()
  2714. *
  2715. * @param callable $wp_head_callback Call on the {@see 'wp_head'} action.
  2716. * @param callable $admin_head_callback Call on custom background administration screen.
  2717. * @param callable $admin_preview_callback Output a custom background image div on the custom background administration screen. Optional.
  2718. */
  2719. function add_custom_background( $wp_head_callback = '', $admin_head_callback = '', $admin_preview_callback = '' ) {
  2720. _deprecated_function( __FUNCTION__, '3.4.0', 'add_theme_support( \'custom-background\', $args )' );
  2721. $args = array();
  2722. if ( $wp_head_callback )
  2723. $args['wp-head-callback'] = $wp_head_callback;
  2724. if ( $admin_head_callback )
  2725. $args['admin-head-callback'] = $admin_head_callback;
  2726. if ( $admin_preview_callback )
  2727. $args['admin-preview-callback'] = $admin_preview_callback;
  2728. return add_theme_support( 'custom-background', $args );
  2729. }
  2730. /**
  2731. * Remove custom background support.
  2732. *
  2733. * @since 3.1.0
  2734. * @deprecated 3.4.0 Use add_custom_background()
  2735. * @see add_custom_background()
  2736. *
  2737. * @return null|bool Whether support was removed.
  2738. */
  2739. function remove_custom_background() {
  2740. _deprecated_function( __FUNCTION__, '3.4.0', 'remove_theme_support( \'custom-background\' )' );
  2741. return remove_theme_support( 'custom-background' );
  2742. }
  2743. /**
  2744. * Retrieve theme data from parsed theme file.
  2745. *
  2746. * @since 1.5.0
  2747. * @deprecated 3.4.0 Use wp_get_theme()
  2748. * @see wp_get_theme()
  2749. *
  2750. * @param string $theme_file Theme file path.
  2751. * @return array Theme data.
  2752. */
  2753. function get_theme_data( $theme_file ) {
  2754. _deprecated_function( __FUNCTION__, '3.4.0', 'wp_get_theme()' );
  2755. $theme = new WP_Theme( wp_basename( dirname( $theme_file ) ), dirname( dirname( $theme_file ) ) );
  2756. $theme_data = array(
  2757. 'Name' => $theme->get('Name'),
  2758. 'URI' => $theme->display('ThemeURI', true, false),
  2759. 'Description' => $theme->display('Description', true, false),
  2760. 'Author' => $theme->display('Author', true, false),
  2761. 'AuthorURI' => $theme->display('AuthorURI', true, false),
  2762. 'Version' => $theme->get('Version'),
  2763. 'Template' => $theme->get('Template'),
  2764. 'Status' => $theme->get('Status'),
  2765. 'Tags' => $theme->get('Tags'),
  2766. 'Title' => $theme->get('Name'),
  2767. 'AuthorName' => $theme->get('Author'),
  2768. );
  2769. foreach ( apply_filters( 'extra_theme_headers', array() ) as $extra_header ) {
  2770. if ( ! isset( $theme_data[ $extra_header ] ) )
  2771. $theme_data[ $extra_header ] = $theme->get( $extra_header );
  2772. }
  2773. return $theme_data;
  2774. }
  2775. /**
  2776. * Alias of update_post_cache().
  2777. *
  2778. * @see update_post_cache() Posts and pages are the same, alias is intentional
  2779. *
  2780. * @since 1.5.1
  2781. * @deprecated 3.4.0 Use update_post_cache()
  2782. * @see update_post_cache()
  2783. *
  2784. * @param array $pages list of page objects
  2785. */
  2786. function update_page_cache( &$pages ) {
  2787. _deprecated_function( __FUNCTION__, '3.4.0', 'update_post_cache()' );
  2788. update_post_cache( $pages );
  2789. }
  2790. /**
  2791. * Will clean the page in the cache.
  2792. *
  2793. * Clean (read: delete) page from cache that matches $id. Will also clean cache
  2794. * associated with 'all_page_ids' and 'get_pages'.
  2795. *
  2796. * @since 2.0.0
  2797. * @deprecated 3.4.0 Use clean_post_cache
  2798. * @see clean_post_cache()
  2799. *
  2800. * @param int $id Page ID to clean
  2801. */
  2802. function clean_page_cache( $id ) {
  2803. _deprecated_function( __FUNCTION__, '3.4.0', 'clean_post_cache()' );
  2804. clean_post_cache( $id );
  2805. }
  2806. /**
  2807. * Retrieve nonce action "Are you sure" message.
  2808. *
  2809. * Deprecated in 3.4.1 and 3.5.0. Backported to 3.3.3.
  2810. *
  2811. * @since 2.0.4
  2812. * @deprecated 3.4.1 Use wp_nonce_ays()
  2813. * @see wp_nonce_ays()
  2814. *
  2815. * @param string $action Nonce action.
  2816. * @return string Are you sure message.
  2817. */
  2818. function wp_explain_nonce( $action ) {
  2819. _deprecated_function( __FUNCTION__, '3.4.1', 'wp_nonce_ays()' );
  2820. return __( 'Are you sure you want to do this?' );
  2821. }
  2822. /**
  2823. * Display "sticky" CSS class, if a post is sticky.
  2824. *
  2825. * @since 2.7.0
  2826. * @deprecated 3.5.0 Use post_class()
  2827. * @see post_class()
  2828. *
  2829. * @param int $post_id An optional post ID.
  2830. */
  2831. function sticky_class( $post_id = null ) {
  2832. _deprecated_function( __FUNCTION__, '3.5.0', 'post_class()' );
  2833. if ( is_sticky( $post_id ) )
  2834. echo ' sticky';
  2835. }
  2836. /**
  2837. * Retrieve post ancestors.
  2838. *
  2839. * This is no longer needed as WP_Post lazy-loads the ancestors
  2840. * property with get_post_ancestors().
  2841. *
  2842. * @since 2.3.4
  2843. * @deprecated 3.5.0 Use get_post_ancestors()
  2844. * @see get_post_ancestors()
  2845. *
  2846. * @param WP_Post $post Post object, passed by reference (unused).
  2847. */
  2848. function _get_post_ancestors( &$post ) {
  2849. _deprecated_function( __FUNCTION__, '3.5.0' );
  2850. }
  2851. /**
  2852. * Load an image from a string, if PHP supports it.
  2853. *
  2854. * @since 2.1.0
  2855. * @deprecated 3.5.0 Use wp_get_image_editor()
  2856. * @see wp_get_image_editor()
  2857. *
  2858. * @param string $file Filename of the image to load.
  2859. * @return resource|GdImage|string The resulting image resource or GdImage instance on success,
  2860. * error string on failure.
  2861. */
  2862. function wp_load_image( $file ) {
  2863. _deprecated_function( __FUNCTION__, '3.5.0', 'wp_get_image_editor()' );
  2864. if ( is_numeric( $file ) )
  2865. $file = get_attached_file( $file );
  2866. if ( ! is_file( $file ) ) {
  2867. /* translators: %s: File name. */
  2868. return sprintf( __( 'File &#8220;%s&#8221; doesn&#8217;t exist?' ), $file );
  2869. }
  2870. if ( ! function_exists('imagecreatefromstring') )
  2871. return __('The GD image library is not installed.');
  2872. // Set artificially high because GD uses uncompressed images in memory.
  2873. wp_raise_memory_limit( 'image' );
  2874. $image = imagecreatefromstring( file_get_contents( $file ) );
  2875. if ( ! is_gd_image( $image ) ) {
  2876. /* translators: %s: File name. */
  2877. return sprintf( __( 'File &#8220;%s&#8221; is not an image.' ), $file );
  2878. }
  2879. return $image;
  2880. }
  2881. /**
  2882. * Scale down an image to fit a particular size and save a new copy of the image.
  2883. *
  2884. * The PNG transparency will be preserved using the function, as well as the
  2885. * image type. If the file going in is PNG, then the resized image is going to
  2886. * be PNG. The only supported image types are PNG, GIF, and JPEG.
  2887. *
  2888. * Some functionality requires API to exist, so some PHP version may lose out
  2889. * support. This is not the fault of WordPress (where functionality is
  2890. * downgraded, not actual defects), but of your PHP version.
  2891. *
  2892. * @since 2.5.0
  2893. * @deprecated 3.5.0 Use wp_get_image_editor()
  2894. * @see wp_get_image_editor()
  2895. *
  2896. * @param string $file Image file path.
  2897. * @param int $max_w Maximum width to resize to.
  2898. * @param int $max_h Maximum height to resize to.
  2899. * @param bool $crop Optional. Whether to crop image or resize. Default false.
  2900. * @param string $suffix Optional. File suffix. Default null.
  2901. * @param string $dest_path Optional. New image file path. Default null.
  2902. * @param int $jpeg_quality Optional. Image quality percentage. Default 90.
  2903. * @return mixed WP_Error on failure. String with new destination path.
  2904. */
  2905. function image_resize( $file, $max_w, $max_h, $crop = false, $suffix = null, $dest_path = null, $jpeg_quality = 90 ) {
  2906. _deprecated_function( __FUNCTION__, '3.5.0', 'wp_get_image_editor()' );
  2907. $editor = wp_get_image_editor( $file );
  2908. if ( is_wp_error( $editor ) )
  2909. return $editor;
  2910. $editor->set_quality( $jpeg_quality );
  2911. $resized = $editor->resize( $max_w, $max_h, $crop );
  2912. if ( is_wp_error( $resized ) )
  2913. return $resized;
  2914. $dest_file = $editor->generate_filename( $suffix, $dest_path );
  2915. $saved = $editor->save( $dest_file );
  2916. if ( is_wp_error( $saved ) )
  2917. return $saved;
  2918. return $dest_file;
  2919. }
  2920. /**
  2921. * Retrieve a single post, based on post ID.
  2922. *
  2923. * Has categories in 'post_category' property or key. Has tags in 'tags_input'
  2924. * property or key.
  2925. *
  2926. * @since 1.0.0
  2927. * @deprecated 3.5.0 Use get_post()
  2928. * @see get_post()
  2929. *
  2930. * @param int $postid Post ID.
  2931. * @param string $mode How to return result, either OBJECT, ARRAY_N, or ARRAY_A.
  2932. * @return WP_Post|null Post object or array holding post contents and information
  2933. */
  2934. function wp_get_single_post( $postid = 0, $mode = OBJECT ) {
  2935. _deprecated_function( __FUNCTION__, '3.5.0', 'get_post()' );
  2936. return get_post( $postid, $mode );
  2937. }
  2938. /**
  2939. * Check that the user login name and password is correct.
  2940. *
  2941. * @since 0.71
  2942. * @deprecated 3.5.0 Use wp_authenticate()
  2943. * @see wp_authenticate()
  2944. *
  2945. * @param string $user_login User name.
  2946. * @param string $user_pass User password.
  2947. * @return bool False if does not authenticate, true if username and password authenticates.
  2948. */
  2949. function user_pass_ok($user_login, $user_pass) {
  2950. _deprecated_function( __FUNCTION__, '3.5.0', 'wp_authenticate()' );
  2951. $user = wp_authenticate( $user_login, $user_pass );
  2952. if ( is_wp_error( $user ) )
  2953. return false;
  2954. return true;
  2955. }
  2956. /**
  2957. * Callback formerly fired on the save_post hook. No longer needed.
  2958. *
  2959. * @since 2.3.0
  2960. * @deprecated 3.5.0
  2961. */
  2962. function _save_post_hook() {}
  2963. /**
  2964. * Check if the installed version of GD supports particular image type
  2965. *
  2966. * @since 2.9.0
  2967. * @deprecated 3.5.0 Use wp_image_editor_supports()
  2968. * @see wp_image_editor_supports()
  2969. *
  2970. * @param string $mime_type
  2971. * @return bool
  2972. */
  2973. function gd_edit_image_support($mime_type) {
  2974. _deprecated_function( __FUNCTION__, '3.5.0', 'wp_image_editor_supports()' );
  2975. if ( function_exists('imagetypes') ) {
  2976. switch( $mime_type ) {
  2977. case 'image/jpeg':
  2978. return (imagetypes() & IMG_JPG) != 0;
  2979. case 'image/png':
  2980. return (imagetypes() & IMG_PNG) != 0;
  2981. case 'image/gif':
  2982. return (imagetypes() & IMG_GIF) != 0;
  2983. case 'image/webp':
  2984. return (imagetypes() & IMG_WEBP) != 0; // phpcs:ignore PHPCompatibility.Constants.NewConstants.img_webpFound
  2985. }
  2986. } else {
  2987. switch( $mime_type ) {
  2988. case 'image/jpeg':
  2989. return function_exists('imagecreatefromjpeg');
  2990. case 'image/png':
  2991. return function_exists('imagecreatefrompng');
  2992. case 'image/gif':
  2993. return function_exists('imagecreatefromgif');
  2994. case 'image/webp':
  2995. return function_exists('imagecreatefromwebp');
  2996. }
  2997. }
  2998. return false;
  2999. }
  3000. /**
  3001. * Converts an integer byte value to a shorthand byte value.
  3002. *
  3003. * @since 2.3.0
  3004. * @deprecated 3.6.0 Use size_format()
  3005. * @see size_format()
  3006. *
  3007. * @param int $bytes An integer byte value.
  3008. * @return string A shorthand byte value.
  3009. */
  3010. function wp_convert_bytes_to_hr( $bytes ) {
  3011. _deprecated_function( __FUNCTION__, '3.6.0', 'size_format()' );
  3012. $units = array( 0 => 'B', 1 => 'KB', 2 => 'MB', 3 => 'GB', 4 => 'TB' );
  3013. $log = log( $bytes, KB_IN_BYTES );
  3014. $power = (int) $log;
  3015. $size = KB_IN_BYTES ** ( $log - $power );
  3016. if ( ! is_nan( $size ) && array_key_exists( $power, $units ) ) {
  3017. $unit = $units[ $power ];
  3018. } else {
  3019. $size = $bytes;
  3020. $unit = $units[0];
  3021. }
  3022. return $size . $unit;
  3023. }
  3024. /**
  3025. * Formerly used internally to tidy up the search terms.
  3026. *
  3027. * @since 2.9.0
  3028. * @access private
  3029. * @deprecated 3.7.0
  3030. *
  3031. * @param string $t Search terms to "tidy", e.g. trim.
  3032. * @return string Trimmed search terms.
  3033. */
  3034. function _search_terms_tidy( $t ) {
  3035. _deprecated_function( __FUNCTION__, '3.7.0' );
  3036. return trim( $t, "\"'\n\r " );
  3037. }
  3038. /**
  3039. * Determine if TinyMCE is available.
  3040. *
  3041. * Checks to see if the user has deleted the tinymce files to slim down
  3042. * their WordPress installation.
  3043. *
  3044. * @since 2.1.0
  3045. * @deprecated 3.9.0
  3046. *
  3047. * @return bool Whether TinyMCE exists.
  3048. */
  3049. function rich_edit_exists() {
  3050. global $wp_rich_edit_exists;
  3051. _deprecated_function( __FUNCTION__, '3.9.0' );
  3052. if ( ! isset( $wp_rich_edit_exists ) )
  3053. $wp_rich_edit_exists = file_exists( ABSPATH . WPINC . '/js/tinymce/tinymce.js' );
  3054. return $wp_rich_edit_exists;
  3055. }
  3056. /**
  3057. * Old callback for tag link tooltips.
  3058. *
  3059. * @since 2.7.0
  3060. * @access private
  3061. * @deprecated 3.9.0
  3062. *
  3063. * @param int $count Number of topics.
  3064. * @return int Number of topics.
  3065. */
  3066. function default_topic_count_text( $count ) {
  3067. return $count;
  3068. }
  3069. /**
  3070. * Formerly used to escape strings before inserting into the DB.
  3071. *
  3072. * Has not performed this function for many, many years. Use wpdb::prepare() instead.
  3073. *
  3074. * @since 0.71
  3075. * @deprecated 3.9.0
  3076. *
  3077. * @param string $content The text to format.
  3078. * @return string The very same text.
  3079. */
  3080. function format_to_post( $content ) {
  3081. _deprecated_function( __FUNCTION__, '3.9.0' );
  3082. return $content;
  3083. }
  3084. /**
  3085. * Formerly used to escape strings before searching the DB. It was poorly documented and never worked as described.
  3086. *
  3087. * @since 2.5.0
  3088. * @deprecated 4.0.0 Use wpdb::esc_like()
  3089. * @see wpdb::esc_like()
  3090. *
  3091. * @param string $text The text to be escaped.
  3092. * @return string text, safe for inclusion in LIKE query.
  3093. */
  3094. function like_escape($text) {
  3095. _deprecated_function( __FUNCTION__, '4.0.0', 'wpdb::esc_like()' );
  3096. return str_replace( array( "%", "_" ), array( "\\%", "\\_" ), $text );
  3097. }
  3098. /**
  3099. * Determines if the URL can be accessed over SSL.
  3100. *
  3101. * Determines if the URL can be accessed over SSL by using the WordPress HTTP API to access
  3102. * the URL using https as the scheme.
  3103. *
  3104. * @since 2.5.0
  3105. * @deprecated 4.0.0
  3106. *
  3107. * @param string $url The URL to test.
  3108. * @return bool Whether SSL access is available.
  3109. */
  3110. function url_is_accessable_via_ssl( $url ) {
  3111. _deprecated_function( __FUNCTION__, '4.0.0' );
  3112. $response = wp_remote_get( set_url_scheme( $url, 'https' ) );
  3113. if ( !is_wp_error( $response ) ) {
  3114. $status = wp_remote_retrieve_response_code( $response );
  3115. if ( 200 == $status || 401 == $status ) {
  3116. return true;
  3117. }
  3118. }
  3119. return false;
  3120. }
  3121. /**
  3122. * Start preview theme output buffer.
  3123. *
  3124. * Will only perform task if the user has permissions and template and preview
  3125. * query variables exist.
  3126. *
  3127. * @since 2.6.0
  3128. * @deprecated 4.3.0
  3129. */
  3130. function preview_theme() {
  3131. _deprecated_function( __FUNCTION__, '4.3.0' );
  3132. }
  3133. /**
  3134. * Private function to modify the current template when previewing a theme
  3135. *
  3136. * @since 2.9.0
  3137. * @deprecated 4.3.0
  3138. * @access private
  3139. *
  3140. * @return string
  3141. */
  3142. function _preview_theme_template_filter() {
  3143. _deprecated_function( __FUNCTION__, '4.3.0' );
  3144. return '';
  3145. }
  3146. /**
  3147. * Private function to modify the current stylesheet when previewing a theme
  3148. *
  3149. * @since 2.9.0
  3150. * @deprecated 4.3.0
  3151. * @access private
  3152. *
  3153. * @return string
  3154. */
  3155. function _preview_theme_stylesheet_filter() {
  3156. _deprecated_function( __FUNCTION__, '4.3.0' );
  3157. return '';
  3158. }
  3159. /**
  3160. * Callback function for ob_start() to capture all links in the theme.
  3161. *
  3162. * @since 2.6.0
  3163. * @deprecated 4.3.0
  3164. * @access private
  3165. *
  3166. * @param string $content
  3167. * @return string
  3168. */
  3169. function preview_theme_ob_filter( $content ) {
  3170. _deprecated_function( __FUNCTION__, '4.3.0' );
  3171. return $content;
  3172. }
  3173. /**
  3174. * Manipulates preview theme links in order to control and maintain location.
  3175. *
  3176. * Callback function for preg_replace_callback() to accept and filter matches.
  3177. *
  3178. * @since 2.6.0
  3179. * @deprecated 4.3.0
  3180. * @access private
  3181. *
  3182. * @param array $matches
  3183. * @return string
  3184. */
  3185. function preview_theme_ob_filter_callback( $matches ) {
  3186. _deprecated_function( __FUNCTION__, '4.3.0' );
  3187. return '';
  3188. }
  3189. /**
  3190. * Formats text for the rich text editor.
  3191. *
  3192. * The {@see 'richedit_pre'} filter is applied here. If `$text` is empty the filter will
  3193. * be applied to an empty string.
  3194. *
  3195. * @since 2.0.0
  3196. * @deprecated 4.3.0 Use format_for_editor()
  3197. * @see format_for_editor()
  3198. *
  3199. * @param string $text The text to be formatted.
  3200. * @return string The formatted text after filter is applied.
  3201. */
  3202. function wp_richedit_pre($text) {
  3203. _deprecated_function( __FUNCTION__, '4.3.0', 'format_for_editor()' );
  3204. if ( empty( $text ) ) {
  3205. /**
  3206. * Filters text returned for the rich text editor.
  3207. *
  3208. * This filter is first evaluated, and the value returned, if an empty string
  3209. * is passed to wp_richedit_pre(). If an empty string is passed, it results
  3210. * in a break tag and line feed.
  3211. *
  3212. * If a non-empty string is passed, the filter is evaluated on the wp_richedit_pre()
  3213. * return after being formatted.
  3214. *
  3215. * @since 2.0.0
  3216. * @deprecated 4.3.0
  3217. *
  3218. * @param string $output Text for the rich text editor.
  3219. */
  3220. return apply_filters( 'richedit_pre', '' );
  3221. }
  3222. $output = convert_chars($text);
  3223. $output = wpautop($output);
  3224. $output = htmlspecialchars($output, ENT_NOQUOTES, get_option( 'blog_charset' ) );
  3225. /** This filter is documented in wp-includes/deprecated.php */
  3226. return apply_filters( 'richedit_pre', $output );
  3227. }
  3228. /**
  3229. * Formats text for the HTML editor.
  3230. *
  3231. * Unless $output is empty it will pass through htmlspecialchars before the
  3232. * {@see 'htmledit_pre'} filter is applied.
  3233. *
  3234. * @since 2.5.0
  3235. * @deprecated 4.3.0 Use format_for_editor()
  3236. * @see format_for_editor()
  3237. *
  3238. * @param string $output The text to be formatted.
  3239. * @return string Formatted text after filter applied.
  3240. */
  3241. function wp_htmledit_pre($output) {
  3242. _deprecated_function( __FUNCTION__, '4.3.0', 'format_for_editor()' );
  3243. if ( !empty($output) )
  3244. $output = htmlspecialchars($output, ENT_NOQUOTES, get_option( 'blog_charset' ) ); // Convert only '< > &'.
  3245. /**
  3246. * Filters the text before it is formatted for the HTML editor.
  3247. *
  3248. * @since 2.5.0
  3249. * @deprecated 4.3.0
  3250. *
  3251. * @param string $output The HTML-formatted text.
  3252. */
  3253. return apply_filters( 'htmledit_pre', $output );
  3254. }
  3255. /**
  3256. * Retrieve permalink from post ID.
  3257. *
  3258. * @since 1.0.0
  3259. * @deprecated 4.4.0 Use get_permalink()
  3260. * @see get_permalink()
  3261. *
  3262. * @param int|WP_Post $post_id Optional. Post ID or WP_Post object. Default is global $post.
  3263. * @return string|false
  3264. */
  3265. function post_permalink( $post_id = 0 ) {
  3266. _deprecated_function( __FUNCTION__, '4.4.0', 'get_permalink()' );
  3267. return get_permalink( $post_id );
  3268. }
  3269. /**
  3270. * Perform a HTTP HEAD or GET request.
  3271. *
  3272. * If $file_path is a writable filename, this will do a GET request and write
  3273. * the file to that path.
  3274. *
  3275. * @since 2.5.0
  3276. * @deprecated 4.4.0 Use WP_Http
  3277. * @see WP_Http
  3278. *
  3279. * @param string $url URL to fetch.
  3280. * @param string|bool $file_path Optional. File path to write request to. Default false.
  3281. * @param int $red Optional. The number of Redirects followed, Upon 5 being hit,
  3282. * returns false. Default 1.
  3283. * @return bool|string False on failure and string of headers if HEAD request.
  3284. */
  3285. function wp_get_http( $url, $file_path = false, $red = 1 ) {
  3286. _deprecated_function( __FUNCTION__, '4.4.0', 'WP_Http' );
  3287. @set_time_limit( 60 );
  3288. if ( $red > 5 )
  3289. return false;
  3290. $options = array();
  3291. $options['redirection'] = 5;
  3292. if ( false == $file_path )
  3293. $options['method'] = 'HEAD';
  3294. else
  3295. $options['method'] = 'GET';
  3296. $response = wp_safe_remote_request( $url, $options );
  3297. if ( is_wp_error( $response ) )
  3298. return false;
  3299. $headers = wp_remote_retrieve_headers( $response );
  3300. $headers['response'] = wp_remote_retrieve_response_code( $response );
  3301. // WP_HTTP no longer follows redirects for HEAD requests.
  3302. if ( 'HEAD' == $options['method'] && in_array($headers['response'], array(301, 302)) && isset( $headers['location'] ) ) {
  3303. return wp_get_http( $headers['location'], $file_path, ++$red );
  3304. }
  3305. if ( false == $file_path )
  3306. return $headers;
  3307. // GET request - write it to the supplied filename.
  3308. $out_fp = fopen($file_path, 'w');
  3309. if ( !$out_fp )
  3310. return $headers;
  3311. fwrite( $out_fp, wp_remote_retrieve_body( $response ) );
  3312. fclose($out_fp);
  3313. clearstatcache();
  3314. return $headers;
  3315. }
  3316. /**
  3317. * Whether SSL login should be forced.
  3318. *
  3319. * @since 2.6.0
  3320. * @deprecated 4.4.0 Use force_ssl_admin()
  3321. * @see force_ssl_admin()
  3322. *
  3323. * @param string|bool $force Optional Whether to force SSL login. Default null.
  3324. * @return bool True if forced, false if not forced.
  3325. */
  3326. function force_ssl_login( $force = null ) {
  3327. _deprecated_function( __FUNCTION__, '4.4.0', 'force_ssl_admin()' );
  3328. return force_ssl_admin( $force );
  3329. }
  3330. /**
  3331. * Retrieve path of comment popup template in current or parent template.
  3332. *
  3333. * @since 1.5.0
  3334. * @deprecated 4.5.0
  3335. *
  3336. * @return string Full path to comments popup template file.
  3337. */
  3338. function get_comments_popup_template() {
  3339. _deprecated_function( __FUNCTION__, '4.5.0' );
  3340. return '';
  3341. }
  3342. /**
  3343. * Determines whether the current URL is within the comments popup window.
  3344. *
  3345. * For more information on this and similar theme functions, check out
  3346. * the {@link https://developer.wordpress.org/themes/basics/conditional-tags/
  3347. * Conditional Tags} article in the Theme Developer Handbook.
  3348. *
  3349. * @since 1.5.0
  3350. * @deprecated 4.5.0
  3351. *
  3352. * @return false Always returns false.
  3353. */
  3354. function is_comments_popup() {
  3355. _deprecated_function( __FUNCTION__, '4.5.0' );
  3356. return false;
  3357. }
  3358. /**
  3359. * Display the JS popup script to show a comment.
  3360. *
  3361. * @since 0.71
  3362. * @deprecated 4.5.0
  3363. */
  3364. function comments_popup_script() {
  3365. _deprecated_function( __FUNCTION__, '4.5.0' );
  3366. }
  3367. /**
  3368. * Adds element attributes to open links in new tabs.
  3369. *
  3370. * @since 0.71
  3371. * @deprecated 4.5.0
  3372. *
  3373. * @param string $text Content to replace links to open in a new tab.
  3374. * @return string Content that has filtered links.
  3375. */
  3376. function popuplinks( $text ) {
  3377. _deprecated_function( __FUNCTION__, '4.5.0' );
  3378. $text = preg_replace('/<a (.+?)>/i', "<a $1 target='_blank' rel='external'>", $text);
  3379. return $text;
  3380. }
  3381. /**
  3382. * The Google Video embed handler callback.
  3383. *
  3384. * Deprecated function that previously assisted in turning Google Video URLs
  3385. * into embeds but that service has since been shut down.
  3386. *
  3387. * @since 2.9.0
  3388. * @deprecated 4.6.0
  3389. *
  3390. * @return string An empty string.
  3391. */
  3392. function wp_embed_handler_googlevideo( $matches, $attr, $url, $rawattr ) {
  3393. _deprecated_function( __FUNCTION__, '4.6.0' );
  3394. return '';
  3395. }
  3396. /**
  3397. * Retrieve path of paged template in current or parent template.
  3398. *
  3399. * @since 1.5.0
  3400. * @deprecated 4.7.0 The paged.php template is no longer part of the theme template hierarchy.
  3401. *
  3402. * @return string Full path to paged template file.
  3403. */
  3404. function get_paged_template() {
  3405. _deprecated_function( __FUNCTION__, '4.7.0' );
  3406. return get_query_template( 'paged' );
  3407. }
  3408. /**
  3409. * Removes the HTML JavaScript entities found in early versions of Netscape 4.
  3410. *
  3411. * Previously, this function was pulled in from the original
  3412. * import of kses and removed a specific vulnerability only
  3413. * existent in early version of Netscape 4. However, this
  3414. * vulnerability never affected any other browsers and can
  3415. * be considered safe for the modern web.
  3416. *
  3417. * The regular expression which sanitized this vulnerability
  3418. * has been removed in consideration of the performance and
  3419. * energy demands it placed, now merely passing through its
  3420. * input to the return.
  3421. *
  3422. * @since 1.0.0
  3423. * @deprecated 4.7.0 Officially dropped security support for Netscape 4.
  3424. *
  3425. * @param string $string
  3426. * @return string
  3427. */
  3428. function wp_kses_js_entities( $string ) {
  3429. _deprecated_function( __FUNCTION__, '4.7.0' );
  3430. return preg_replace( '%&\s*\{[^}]*(\}\s*;?|$)%', '', $string );
  3431. }
  3432. /**
  3433. * Sort categories by ID.
  3434. *
  3435. * Used by usort() as a callback, should not be used directly. Can actually be
  3436. * used to sort any term object.
  3437. *
  3438. * @since 2.3.0
  3439. * @deprecated 4.7.0 Use wp_list_sort()
  3440. * @access private
  3441. *
  3442. * @param object $a
  3443. * @param object $b
  3444. * @return int
  3445. */
  3446. function _usort_terms_by_ID( $a, $b ) {
  3447. _deprecated_function( __FUNCTION__, '4.7.0', 'wp_list_sort()' );
  3448. if ( $a->term_id > $b->term_id )
  3449. return 1;
  3450. elseif ( $a->term_id < $b->term_id )
  3451. return -1;
  3452. else
  3453. return 0;
  3454. }
  3455. /**
  3456. * Sort categories by name.
  3457. *
  3458. * Used by usort() as a callback, should not be used directly. Can actually be
  3459. * used to sort any term object.
  3460. *
  3461. * @since 2.3.0
  3462. * @deprecated 4.7.0 Use wp_list_sort()
  3463. * @access private
  3464. *
  3465. * @param object $a
  3466. * @param object $b
  3467. * @return int
  3468. */
  3469. function _usort_terms_by_name( $a, $b ) {
  3470. _deprecated_function( __FUNCTION__, '4.7.0', 'wp_list_sort()' );
  3471. return strcmp( $a->name, $b->name );
  3472. }
  3473. /**
  3474. * Sort menu items by the desired key.
  3475. *
  3476. * @since 3.0.0
  3477. * @deprecated 4.7.0 Use wp_list_sort()
  3478. * @access private
  3479. *
  3480. * @global string $_menu_item_sort_prop
  3481. *
  3482. * @param object $a The first object to compare
  3483. * @param object $b The second object to compare
  3484. * @return int -1, 0, or 1 if $a is considered to be respectively less than, equal to, or greater than $b.
  3485. */
  3486. function _sort_nav_menu_items( $a, $b ) {
  3487. global $_menu_item_sort_prop;
  3488. _deprecated_function( __FUNCTION__, '4.7.0', 'wp_list_sort()' );
  3489. if ( empty( $_menu_item_sort_prop ) )
  3490. return 0;
  3491. if ( ! isset( $a->$_menu_item_sort_prop ) || ! isset( $b->$_menu_item_sort_prop ) )
  3492. return 0;
  3493. $_a = (int) $a->$_menu_item_sort_prop;
  3494. $_b = (int) $b->$_menu_item_sort_prop;
  3495. if ( $a->$_menu_item_sort_prop == $b->$_menu_item_sort_prop )
  3496. return 0;
  3497. elseif ( $_a == $a->$_menu_item_sort_prop && $_b == $b->$_menu_item_sort_prop )
  3498. return $_a < $_b ? -1 : 1;
  3499. else
  3500. return strcmp( $a->$_menu_item_sort_prop, $b->$_menu_item_sort_prop );
  3501. }
  3502. /**
  3503. * Retrieves the Press This bookmarklet link.
  3504. *
  3505. * @since 2.6.0
  3506. * @deprecated 4.9.0
  3507. *
  3508. */
  3509. function get_shortcut_link() {
  3510. _deprecated_function( __FUNCTION__, '4.9.0' );
  3511. $link = '';
  3512. /**
  3513. * Filters the Press This bookmarklet link.
  3514. *
  3515. * @since 2.6.0
  3516. * @deprecated 4.9.0
  3517. *
  3518. * @param string $link The Press This bookmarklet link.
  3519. */
  3520. return apply_filters( 'shortcut_link', $link );
  3521. }
  3522. /**
  3523. * Ajax handler for saving a post from Press This.
  3524. *
  3525. * @since 4.2.0
  3526. * @deprecated 4.9.0
  3527. */
  3528. function wp_ajax_press_this_save_post() {
  3529. _deprecated_function( __FUNCTION__, '4.9.0' );
  3530. if ( is_plugin_active( 'press-this/press-this-plugin.php' ) ) {
  3531. include WP_PLUGIN_DIR . '/press-this/class-wp-press-this-plugin.php';
  3532. $wp_press_this = new WP_Press_This_Plugin();
  3533. $wp_press_this->save_post();
  3534. } else {
  3535. wp_send_json_error( array( 'errorMessage' => __( 'The Press This plugin is required.' ) ) );
  3536. }
  3537. }
  3538. /**
  3539. * Ajax handler for creating new category from Press This.
  3540. *
  3541. * @since 4.2.0
  3542. * @deprecated 4.9.0
  3543. */
  3544. function wp_ajax_press_this_add_category() {
  3545. _deprecated_function( __FUNCTION__, '4.9.0' );
  3546. if ( is_plugin_active( 'press-this/press-this-plugin.php' ) ) {
  3547. include WP_PLUGIN_DIR . '/press-this/class-wp-press-this-plugin.php';
  3548. $wp_press_this = new WP_Press_This_Plugin();
  3549. $wp_press_this->add_category();
  3550. } else {
  3551. wp_send_json_error( array( 'errorMessage' => __( 'The Press This plugin is required.' ) ) );
  3552. }
  3553. }
  3554. /**
  3555. * Return the user request object for the specified request ID.
  3556. *
  3557. * @since 4.9.6
  3558. * @deprecated 5.4.0 Use wp_get_user_request()
  3559. * @see wp_get_user_request()
  3560. *
  3561. * @param int $request_id The ID of the user request.
  3562. * @return WP_User_Request|false
  3563. */
  3564. function wp_get_user_request_data( $request_id ) {
  3565. _deprecated_function( __FUNCTION__, '5.4.0', 'wp_get_user_request()' );
  3566. return wp_get_user_request( $request_id );
  3567. }
  3568. /**
  3569. * Filters 'img' elements in post content to add 'srcset' and 'sizes' attributes.
  3570. *
  3571. * @since 4.4.0
  3572. * @deprecated 5.5.0
  3573. *
  3574. * @see wp_image_add_srcset_and_sizes()
  3575. *
  3576. * @param string $content The raw post content to be filtered.
  3577. * @return string Converted content with 'srcset' and 'sizes' attributes added to images.
  3578. */
  3579. function wp_make_content_images_responsive( $content ) {
  3580. _deprecated_function( __FUNCTION__, '5.5.0', 'wp_filter_content_tags()' );
  3581. // This will also add the `loading` attribute to `img` tags, if enabled.
  3582. return wp_filter_content_tags( $content );
  3583. }
  3584. /**
  3585. * Turn register globals off.
  3586. *
  3587. * @since 2.1.0
  3588. * @access private
  3589. * @deprecated 5.5.0
  3590. */
  3591. function wp_unregister_GLOBALS() { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid
  3592. // register_globals was deprecated in PHP 5.3 and removed entirely in PHP 5.4.
  3593. _deprecated_function( __FUNCTION__, '5.5.0' );
  3594. }
  3595. /**
  3596. * Does comment contain disallowed characters or words.
  3597. *
  3598. * @since 1.5.0
  3599. * @deprecated 5.5.0 Use wp_check_comment_disallowed_list() instead.
  3600. * Please consider writing more inclusive code.
  3601. *
  3602. * @param string $author The author of the comment
  3603. * @param string $email The email of the comment
  3604. * @param string $url The url used in the comment
  3605. * @param string $comment The comment content
  3606. * @param string $user_ip The comment author's IP address
  3607. * @param string $user_agent The author's browser user agent
  3608. * @return bool True if comment contains disallowed content, false if comment does not
  3609. */
  3610. function wp_blacklist_check( $author, $email, $url, $comment, $user_ip, $user_agent ) {
  3611. _deprecated_function( __FUNCTION__, '5.5.0', 'wp_check_comment_disallowed_list()' );
  3612. return wp_check_comment_disallowed_list( $author, $email, $url, $comment, $user_ip, $user_agent );
  3613. }
  3614. /**
  3615. * Filters out `register_meta()` args based on an allowed list.
  3616. *
  3617. * `register_meta()` args may change over time, so requiring the allowed list
  3618. * to be explicitly turned off is a warranty seal of sorts.
  3619. *
  3620. * @access private
  3621. * @since 4.6.0
  3622. * @deprecated 5.5.0 Use _wp_register_meta_args_allowed_list() instead.
  3623. * Please consider writing more inclusive code.
  3624. *
  3625. * @param array $args Arguments from `register_meta()`.
  3626. * @param array $default_args Default arguments for `register_meta()`.
  3627. * @return array Filtered arguments.
  3628. */
  3629. function _wp_register_meta_args_whitelist( $args, $default_args ) {
  3630. _deprecated_function( __FUNCTION__, '5.5.0', '_wp_register_meta_args_allowed_list()' );
  3631. return _wp_register_meta_args_allowed_list( $args, $default_args );
  3632. }
  3633. /**
  3634. * Adds an array of options to the list of allowed options.
  3635. *
  3636. * @since 2.7.0
  3637. * @deprecated 5.5.0 Use add_allowed_options() instead.
  3638. * Please consider writing more inclusive code.
  3639. *
  3640. * @global array $allowed_options
  3641. *
  3642. * @param array $new_options
  3643. * @param string|array $options
  3644. * @return array
  3645. */
  3646. function add_option_whitelist( $new_options, $options = '' ) {
  3647. _deprecated_function( __FUNCTION__, '5.5.0', 'add_allowed_options()' );
  3648. return add_allowed_options( $new_options, $options );
  3649. }
  3650. /**
  3651. * Removes a list of options from the allowed options list.
  3652. *
  3653. * @since 2.7.0
  3654. * @deprecated 5.5.0 Use remove_allowed_options() instead.
  3655. * Please consider writing more inclusive code.
  3656. *
  3657. * @global array $allowed_options
  3658. *
  3659. * @param array $del_options
  3660. * @param string|array $options
  3661. * @return array
  3662. */
  3663. function remove_option_whitelist( $del_options, $options = '' ) {
  3664. _deprecated_function( __FUNCTION__, '5.5.0', 'remove_allowed_options()' );
  3665. return remove_allowed_options( $del_options, $options );
  3666. }
  3667. /**
  3668. * Adds slashes to only string values in an array of values.
  3669. *
  3670. * This should be used when preparing data for core APIs that expect slashed data.
  3671. * This should not be used to escape data going directly into an SQL query.
  3672. *
  3673. * @since 5.3.0
  3674. * @deprecated 5.6.0 Use wp_slash()
  3675. *
  3676. * @see wp_slash()
  3677. *
  3678. * @param mixed $value Scalar or array of scalars.
  3679. * @return mixed Slashes $value
  3680. */
  3681. function wp_slash_strings_only( $value ) {
  3682. return map_deep( $value, 'addslashes_strings_only' );
  3683. }
  3684. /**
  3685. * Adds slashes only if the provided value is a string.
  3686. *
  3687. * @since 5.3.0
  3688. * @deprecated 5.6.0
  3689. *
  3690. * @see wp_slash()
  3691. *
  3692. * @param mixed $value
  3693. * @return mixed
  3694. */
  3695. function addslashes_strings_only( $value ) {
  3696. return is_string( $value ) ? addslashes( $value ) : $value;
  3697. }
  3698. /**
  3699. * Displays a noindex meta tag if required by the blog configuration.
  3700. *
  3701. * If a blog is marked as not being public then the noindex meta tag will be
  3702. * output to tell web robots not to index the page content. Add this to the
  3703. * {@see 'wp_head'} action.
  3704. *
  3705. * Typical usage is as a {@see 'wp_head'} callback:
  3706. *
  3707. * add_action( 'wp_head', 'noindex' );
  3708. *
  3709. * @see wp_no_robots()
  3710. *
  3711. * @since 2.1.0
  3712. * @deprecated 5.7.0 Use wp_robots_noindex() instead on 'wp_robots' filter.
  3713. */
  3714. function noindex() {
  3715. _deprecated_function( __FUNCTION__, '5.7.0', 'wp_robots_noindex()' );
  3716. // If the blog is not public, tell robots to go away.
  3717. if ( '0' == get_option( 'blog_public' ) ) {
  3718. wp_no_robots();
  3719. }
  3720. }
  3721. /**
  3722. * Display a noindex meta tag.
  3723. *
  3724. * Outputs a noindex meta tag that tells web robots not to index the page content.
  3725. * Typical usage is as a {@see 'wp_head'} callback. add_action( 'wp_head', 'wp_no_robots' );
  3726. *
  3727. * @since 3.3.0
  3728. * @since 5.3.0 Echo "noindex,nofollow" if search engine visibility is discouraged.
  3729. * @deprecated 5.7.0 Use wp_robots_no_robots() instead on 'wp_robots' filter.
  3730. */
  3731. function wp_no_robots() {
  3732. _deprecated_function( __FUNCTION__, '5.7.0', 'wp_robots_no_robots()' );
  3733. if ( get_option( 'blog_public' ) ) {
  3734. echo "<meta name='robots' content='noindex,follow' />\n";
  3735. return;
  3736. }
  3737. echo "<meta name='robots' content='noindex,nofollow' />\n";
  3738. }
  3739. /**
  3740. * Display a noindex,noarchive meta tag and referrer origin-when-cross-origin meta tag.
  3741. *
  3742. * Outputs a noindex,noarchive meta tag that tells web robots not to index or cache the page content.
  3743. * Outputs a referrer origin-when-cross-origin meta tag that tells the browser not to send the full
  3744. * url as a referrer to other sites when cross-origin assets are loaded.
  3745. *
  3746. * Typical usage is as a wp_head callback. add_action( 'wp_head', 'wp_sensitive_page_meta' );
  3747. *
  3748. * @since 5.0.1
  3749. * @deprecated 5.7.0 Use wp_robots_sensitive_page() instead on 'wp_robots' filter
  3750. * and wp_strict_cross_origin_referrer() on 'wp_head' action.
  3751. */
  3752. function wp_sensitive_page_meta() {
  3753. _deprecated_function( __FUNCTION__, '5.7.0', 'wp_robots_sensitive_page()' );
  3754. ?>
  3755. <meta name='robots' content='noindex,noarchive' />
  3756. <?php
  3757. wp_strict_cross_origin_referrer();
  3758. }
  3759. /**
  3760. * Render inner blocks from the `core/columns` block for generating an excerpt.
  3761. *
  3762. * @since 5.2.0
  3763. * @deprecated 5.8.0
  3764. *
  3765. * @access private
  3766. *
  3767. * @param array $columns The parsed columns block.
  3768. * @param array $allowed_blocks The list of allowed inner blocks.
  3769. * @return string The rendered inner blocks.
  3770. */
  3771. function _excerpt_render_inner_columns_blocks( $columns, $allowed_blocks ) {
  3772. _deprecated_function( __FUNCTION__, '5.8.0', '_excerpt_render_inner_blocks()' );
  3773. return _excerpt_render_inner_blocks( $columns, $allowed_blocks );
  3774. }