deprecated.php 111 KB

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