You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

3881 lines
109 KiB

  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://codex.wordpress.org/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. $r = wp_parse_args( $args, $defaults );
  382. return wp_list_bookmarks($r);
  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. $r = wp_parse_args( $args );
  570. // Map to new names.
  571. if ( isset($r['optionall']) && isset($r['all']))
  572. $r['show_option_all'] = $r['all'];
  573. if ( isset($r['sort_column']) )
  574. $r['orderby'] = $r['sort_column'];
  575. if ( isset($r['sort_order']) )
  576. $r['order'] = $r['sort_order'];
  577. if ( isset($r['optiondates']) )
  578. $r['show_last_update'] = $r['optiondates'];
  579. if ( isset($r['optioncount']) )
  580. $r['show_count'] = $r['optioncount'];
  581. if ( isset($r['list']) )
  582. $r['style'] = $r['list'] ? 'list' : 'break';
  583. $r['title_li'] = '';
  584. return wp_list_categories($r);
  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. $r = wp_parse_args( $args, $defaults );
  803. return wp_list_bookmarks($r);
  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') . ' ' . date(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://codex.wordpress.org/Function_Reference/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( 'category', array('fields' => 'ids', 'get' => 'all') );
  1144. wp_cache_add( 'all_category_ids', $cat_ids, 'category' );
  1145. }
  1146. return $cat_ids;
  1147. }
  1148. /**
  1149. * Retrieve the description of the author of the current post.
  1150. *
  1151. * @since 1.5.0
  1152. * @deprecated 2.8.0 Use get_the_author_meta()
  1153. * @see get_the_author_meta()
  1154. *
  1155. * @return string The author's description.
  1156. */
  1157. function get_the_author_description() {
  1158. _deprecated_function( __FUNCTION__, '2.8.0', 'get_the_author_meta(\'description\')' );
  1159. return get_the_author_meta('description');
  1160. }
  1161. /**
  1162. * Display the description of the author of the current post.
  1163. *
  1164. * @since 1.0.0
  1165. * @deprecated 2.8.0 Use the_author_meta()
  1166. * @see the_author_meta()
  1167. */
  1168. function the_author_description() {
  1169. _deprecated_function( __FUNCTION__, '2.8.0', 'the_author_meta(\'description\')' );
  1170. the_author_meta('description');
  1171. }
  1172. /**
  1173. * Retrieve the login name of the author of the current post.
  1174. *
  1175. * @since 1.5.0
  1176. * @deprecated 2.8.0 Use get_the_author_meta()
  1177. * @see get_the_author_meta()
  1178. *
  1179. * @return string The author's login name (username).
  1180. */
  1181. function get_the_author_login() {
  1182. _deprecated_function( __FUNCTION__, '2.8.0', 'get_the_author_meta(\'login\')' );
  1183. return get_the_author_meta('login');
  1184. }
  1185. /**
  1186. * Display the login name of the author of the current post.
  1187. *
  1188. * @since 0.71
  1189. * @deprecated 2.8.0 Use the_author_meta()
  1190. * @see the_author_meta()
  1191. */
  1192. function the_author_login() {
  1193. _deprecated_function( __FUNCTION__, '2.8.0', 'the_author_meta(\'login\')' );
  1194. the_author_meta('login');
  1195. }
  1196. /**
  1197. * Retrieve the first name of the author of the current post.
  1198. *
  1199. * @since 1.5.0
  1200. * @deprecated 2.8.0 Use get_the_author_meta()
  1201. * @see get_the_author_meta()
  1202. *
  1203. * @return string The author's first name.
  1204. */
  1205. function get_the_author_firstname() {
  1206. _deprecated_function( __FUNCTION__, '2.8.0', 'get_the_author_meta(\'first_name\')' );
  1207. return get_the_author_meta('first_name');
  1208. }
  1209. /**
  1210. * Display the first name of the author of the current post.
  1211. *
  1212. * @since 0.71
  1213. * @deprecated 2.8.0 Use the_author_meta()
  1214. * @see the_author_meta()
  1215. */
  1216. function the_author_firstname() {
  1217. _deprecated_function( __FUNCTION__, '2.8.0', 'the_author_meta(\'first_name\')' );
  1218. the_author_meta('first_name');
  1219. }
  1220. /**
  1221. * Retrieve the last name of the author of the current post.
  1222. *
  1223. * @since 1.5.0
  1224. * @deprecated 2.8.0 Use get_the_author_meta()
  1225. * @see get_the_author_meta()
  1226. *
  1227. * @return string The author's last name.
  1228. */
  1229. function get_the_author_lastname() {
  1230. _deprecated_function( __FUNCTION__, '2.8.0', 'get_the_author_meta(\'last_name\')' );
  1231. return get_the_author_meta('last_name');
  1232. }
  1233. /**
  1234. * Display the last name of the author of the current post.
  1235. *
  1236. * @since 0.71
  1237. * @deprecated 2.8.0 Use the_author_meta()
  1238. * @see the_author_meta()
  1239. */
  1240. function the_author_lastname() {
  1241. _deprecated_function( __FUNCTION__, '2.8.0', 'the_author_meta(\'last_name\')' );
  1242. the_author_meta('last_name');
  1243. }
  1244. /**
  1245. * Retrieve the nickname of the author of the current post.
  1246. *
  1247. * @since 1.5.0
  1248. * @deprecated 2.8.0 Use get_the_author_meta()
  1249. * @see get_the_author_meta()
  1250. *
  1251. * @return string The author's nickname.
  1252. */
  1253. function get_the_author_nickname() {
  1254. _deprecated_function( __FUNCTION__, '2.8.0', 'get_the_author_meta(\'nickname\')' );
  1255. return get_the_author_meta('nickname');
  1256. }
  1257. /**
  1258. * Display the nickname of the author of the current post.
  1259. *
  1260. * @since 0.71
  1261. * @deprecated 2.8.0 Use the_author_meta()
  1262. * @see the_author_meta()
  1263. */
  1264. function the_author_nickname() {
  1265. _deprecated_function( __FUNCTION__, '2.8.0', 'the_author_meta(\'nickname\')' );
  1266. the_author_meta('nickname');
  1267. }
  1268. /**
  1269. * Retrieve the email of the author of the current post.
  1270. *
  1271. * @since 1.5.0
  1272. * @deprecated 2.8.0 Use get_the_author_meta()
  1273. * @see get_the_author_meta()
  1274. *
  1275. * @return string The author's username.
  1276. */
  1277. function get_the_author_email() {
  1278. _deprecated_function( __FUNCTION__, '2.8.0', 'get_the_author_meta(\'email\')' );
  1279. return get_the_author_meta('email');
  1280. }
  1281. /**
  1282. * Display the email of the author of the current post.
  1283. *
  1284. * @since 0.71
  1285. * @deprecated 2.8.0 Use the_author_meta()
  1286. * @see the_author_meta()
  1287. */
  1288. function the_author_email() {
  1289. _deprecated_function( __FUNCTION__, '2.8.0', 'the_author_meta(\'email\')' );
  1290. the_author_meta('email');
  1291. }
  1292. /**
  1293. * Retrieve the ICQ number of the author of the current post.
  1294. *
  1295. * @since 1.5.0
  1296. * @deprecated 2.8.0 Use get_the_author_meta()
  1297. * @see get_the_author_meta()
  1298. *
  1299. * @return string The author's ICQ number.
  1300. */
  1301. function get_the_author_icq() {
  1302. _deprecated_function( __FUNCTION__, '2.8.0', 'get_the_author_meta(\'icq\')' );
  1303. return get_the_author_meta('icq');
  1304. }
  1305. /**
  1306. * Display the ICQ number of the author of the current post.
  1307. *
  1308. * @since 0.71
  1309. * @deprecated 2.8.0 Use the_author_meta()
  1310. * @see the_author_meta()
  1311. */
  1312. function the_author_icq() {
  1313. _deprecated_function( __FUNCTION__, '2.8.0', 'the_author_meta(\'icq\')' );
  1314. the_author_meta('icq');
  1315. }
  1316. /**
  1317. * Retrieve the Yahoo! IM name of the author of the current post.
  1318. *
  1319. * @since 1.5.0
  1320. * @deprecated 2.8.0 Use get_the_author_meta()
  1321. * @see get_the_author_meta()
  1322. *
  1323. * @return string The author's Yahoo! IM name.
  1324. */
  1325. function get_the_author_yim() {
  1326. _deprecated_function( __FUNCTION__, '2.8.0', 'get_the_author_meta(\'yim\')' );
  1327. return get_the_author_meta('yim');
  1328. }
  1329. /**
  1330. * Display the Yahoo! IM name of the author of the current post.
  1331. *
  1332. * @since 0.71
  1333. * @deprecated 2.8.0 Use the_author_meta()
  1334. * @see the_author_meta()
  1335. */
  1336. function the_author_yim() {
  1337. _deprecated_function( __FUNCTION__, '2.8.0', 'the_author_meta(\'yim\')' );
  1338. the_author_meta('yim');
  1339. }
  1340. /**
  1341. * Retrieve the MSN address of the author of the current post.
  1342. *
  1343. * @since 1.5.0
  1344. * @deprecated 2.8.0 Use get_the_author_meta()
  1345. * @see get_the_author_meta()
  1346. *
  1347. * @return string The author's MSN address.
  1348. */
  1349. function get_the_author_msn() {
  1350. _deprecated_function( __FUNCTION__, '2.8.0', 'get_the_author_meta(\'msn\')' );
  1351. return get_the_author_meta('msn');
  1352. }
  1353. /**
  1354. * Display the MSN address of the author of the current post.
  1355. *
  1356. * @since 0.71
  1357. * @deprecated 2.8.0 Use the_author_meta()
  1358. * @see the_author_meta()
  1359. */
  1360. function the_author_msn() {
  1361. _deprecated_function( __FUNCTION__, '2.8.0', 'the_author_meta(\'msn\')' );
  1362. the_author_meta('msn');
  1363. }
  1364. /**
  1365. * Retrieve the AIM address of the author of the current post.
  1366. *
  1367. * @since 1.5.0
  1368. * @deprecated 2.8.0 Use get_the_author_meta()
  1369. * @see get_the_author_meta()
  1370. *
  1371. * @return string The author's AIM address.
  1372. */
  1373. function get_the_author_aim() {
  1374. _deprecated_function( __FUNCTION__, '2.8.0', 'get_the_author_meta(\'aim\')' );
  1375. return get_the_author_meta('aim');
  1376. }
  1377. /**
  1378. * Display the AIM address of the author of the current post.
  1379. *
  1380. * @since 0.71
  1381. * @deprecated 2.8.0 Use the_author_meta('aim')
  1382. * @see the_author_meta()
  1383. */
  1384. function the_author_aim() {
  1385. _deprecated_function( __FUNCTION__, '2.8.0', 'the_author_meta(\'aim\')' );
  1386. the_author_meta('aim');
  1387. }
  1388. /**
  1389. * Retrieve the specified author's preferred display name.
  1390. *
  1391. * @since 1.0.0
  1392. * @deprecated 2.8.0 Use get_the_author_meta()
  1393. * @see get_the_author_meta()
  1394. *
  1395. * @param int $auth_id The ID of the author.
  1396. * @return string The author's display name.
  1397. */
  1398. function get_author_name( $auth_id = false ) {
  1399. _deprecated_function( __FUNCTION__, '2.8.0', 'get_the_author_meta(\'display_name\')' );
  1400. return get_the_author_meta('display_name', $auth_id);
  1401. }
  1402. /**
  1403. * Retrieve the URL to the home page of the author of the current post.
  1404. *
  1405. * @since 1.5.0
  1406. * @deprecated 2.8.0 Use get_the_author_meta()
  1407. * @see get_the_author_meta()
  1408. *
  1409. * @return string The URL to the author's page.
  1410. */
  1411. function get_the_author_url() {
  1412. _deprecated_function( __FUNCTION__, '2.8.0', 'get_the_author_meta(\'url\')' );
  1413. return get_the_author_meta('url');
  1414. }
  1415. /**
  1416. * Display the URL to the home page of the author of the current post.
  1417. *
  1418. * @since 0.71
  1419. * @deprecated 2.8.0 Use the_author_meta()
  1420. * @see the_author_meta()
  1421. */
  1422. function the_author_url() {
  1423. _deprecated_function( __FUNCTION__, '2.8.0', 'the_author_meta(\'url\')' );
  1424. the_author_meta('url');
  1425. }
  1426. /**
  1427. * Retrieve the ID of the author of the current post.
  1428. *
  1429. * @since 1.5.0
  1430. * @deprecated 2.8.0 Use get_the_author_meta()
  1431. * @see get_the_author_meta()
  1432. *
  1433. * @return string|int The author's ID.
  1434. */
  1435. function get_the_author_ID() {
  1436. _deprecated_function( __FUNCTION__, '2.8.0', 'get_the_author_meta(\'ID\')' );
  1437. return get_the_author_meta('ID');
  1438. }
  1439. /**
  1440. * Display the ID of the author of the current post.
  1441. *
  1442. * @since 0.71
  1443. * @deprecated 2.8.0 Use the_author_meta()
  1444. * @see the_author_meta()
  1445. */
  1446. function the_author_ID() {
  1447. _deprecated_function( __FUNCTION__, '2.8.0', 'the_author_meta(\'ID\')' );
  1448. the_author_meta('ID');
  1449. }
  1450. /**
  1451. * Display the post content for the feed.
  1452. *
  1453. * For encoding the html or the $encode_html parameter, there are three possible
  1454. * values. '0' will make urls footnotes and use make_url_footnote(). '1' will
  1455. * encode special characters and automatically display all of the content. The
  1456. * value of '2' will strip all HTML tags from the content.
  1457. *
  1458. * Also note that you cannot set the amount of words and not set the html
  1459. * encoding. If that is the case, then the html encoding will default to 2,
  1460. * which will strip all HTML tags.
  1461. *
  1462. * To restrict the amount of words of the content, you can use the cut
  1463. * parameter. If the content is less than the amount, then there won't be any
  1464. * dots added to the end. If there is content left over, then dots will be added
  1465. * and the rest of the content will be removed.
  1466. *
  1467. * @since 0.71
  1468. *
  1469. * @deprecated 2.9.0 Use the_content_feed()
  1470. * @see the_content_feed()
  1471. *
  1472. * @param string $more_link_text Optional. Text to display when more content is available but not displayed.
  1473. * @param int $stripteaser Optional. Default is 0.
  1474. * @param string $more_file Optional.
  1475. * @param int $cut Optional. Amount of words to keep for the content.
  1476. * @param int $encode_html Optional. How to encode the content.
  1477. */
  1478. function the_content_rss($more_link_text='(more...)', $stripteaser=0, $more_file='', $cut = 0, $encode_html = 0) {
  1479. _deprecated_function( __FUNCTION__, '2.9.0', 'the_content_feed' );
  1480. $content = get_the_content($more_link_text, $stripteaser);
  1481. $content = apply_filters('the_content_rss', $content);
  1482. if ( $cut && !$encode_html )
  1483. $encode_html = 2;
  1484. if ( 1== $encode_html ) {
  1485. $content = esc_html($content);
  1486. $cut = 0;
  1487. } elseif ( 0 == $encode_html ) {
  1488. $content = make_url_footnote($content);
  1489. } elseif ( 2 == $encode_html ) {
  1490. $content = strip_tags($content);
  1491. }
  1492. if ( $cut ) {
  1493. $blah = explode(' ', $content);
  1494. if ( count($blah) > $cut ) {
  1495. $k = $cut;
  1496. $use_dotdotdot = 1;
  1497. } else {
  1498. $k = count($blah);
  1499. $use_dotdotdot = 0;
  1500. }
  1501. /** @todo Check performance, might be faster to use array slice instead. */
  1502. for ( $i=0; $i<$k; $i++ )
  1503. $excerpt .= $blah[$i].' ';
  1504. $excerpt .= ($use_dotdotdot) ? '...' : '';
  1505. $content = $excerpt;
  1506. }
  1507. $content = str_replace(']]>', ']]&gt;', $content);
  1508. echo $content;
  1509. }
  1510. /**
  1511. * Strip HTML and put links at the bottom of stripped content.
  1512. *
  1513. * Searches for all of the links, strips them out of the content, and places
  1514. * them at the bottom of the content with numbers.
  1515. *
  1516. * @since 0.71
  1517. * @deprecated 2.9.0
  1518. *
  1519. * @param string $content Content to get links
  1520. * @return string HTML stripped out of content with links at the bottom.
  1521. */
  1522. function make_url_footnote( $content ) {
  1523. _deprecated_function( __FUNCTION__, '2.9.0', '' );
  1524. preg_match_all( '/<a(.+?)href=\"(.+?)\"(.*?)>(.+?)<\/a>/', $content, $matches );
  1525. $links_summary = "\n";
  1526. for ( $i = 0, $c = count( $matches[0] ); $i < $c; $i++ ) {
  1527. $link_match = $matches[0][$i];
  1528. $link_number = '['.($i+1).']';
  1529. $link_url = $matches[2][$i];
  1530. $link_text = $matches[4][$i];
  1531. $content = str_replace( $link_match, $link_text . ' ' . $link_number, $content );
  1532. $link_url = ( ( strtolower( substr( $link_url, 0, 7 ) ) != 'http://' ) && ( strtolower( substr( $link_url, 0, 8 ) ) != 'https://' ) ) ? get_option( 'home' ) . $link_url : $link_url;
  1533. $links_summary .= "\n" . $link_number . ' ' . $link_url;
  1534. }
  1535. $content = strip_tags( $content );
  1536. $content .= $links_summary;
  1537. return $content;
  1538. }
  1539. /**
  1540. * Retrieve translated string with vertical bar context
  1541. *
  1542. * Quite a few times, there will be collisions with similar translatable text
  1543. * found in more than two places but with different translated context.
  1544. *
  1545. * In order to use the separate contexts, the _c() function is used and the
  1546. * translatable string uses a pipe ('|') which has the context the string is in.
  1547. *
  1548. * When the translated string is returned, it is everything before the pipe, not
  1549. * including the pipe character. If there is no pipe in the translated text then
  1550. * everything is returned.
  1551. *
  1552. * @since 2.2.0
  1553. * @deprecated 2.9.0 Use _x()
  1554. * @see _x()
  1555. *
  1556. * @param string $text Text to translate
  1557. * @param string $domain Optional. Domain to retrieve the translated text
  1558. * @return string Translated context string without pipe
  1559. */
  1560. function _c( $text, $domain = 'default' ) {
  1561. _deprecated_function( __FUNCTION__, '2.9.0', '_x()' );
  1562. return before_last_bar( translate( $text, $domain ) );
  1563. }
  1564. /**
  1565. * Translates $text like translate(), but assumes that the text
  1566. * contains a context after its last vertical bar.
  1567. *
  1568. * @since 2.5.0
  1569. * @deprecated 3.0.0 Use _x()
  1570. * @see _x()
  1571. *
  1572. * @param string $text Text to translate
  1573. * @param string $domain Domain to retrieve the translated text
  1574. * @return string Translated text
  1575. */
  1576. function translate_with_context( $text, $domain = 'default' ) {
  1577. _deprecated_function( __FUNCTION__, '2.9.0', '_x()' );
  1578. return before_last_bar( translate( $text, $domain ) );
  1579. }
  1580. /**
  1581. * Legacy version of _n(), which supports contexts.
  1582. *
  1583. * Strips everything from the translation after the last bar.
  1584. *
  1585. * @since 2.7.0
  1586. * @deprecated 3.0.0 Use _nx()
  1587. * @see _nx()
  1588. *
  1589. * @param string $single The text to be used if the number is singular.
  1590. * @param string $plural The text to be used if the number is plural.
  1591. * @param int $number The number to compare against to use either the singular or plural form.
  1592. * @param string $domain Optional. Text domain. Unique identifier for retrieving translated strings.
  1593. * Default 'default'.
  1594. * @return string The translated singular or plural form.
  1595. */
  1596. function _nc( $single, $plural, $number, $domain = 'default' ) {
  1597. _deprecated_function( __FUNCTION__, '2.9.0', '_nx()' );
  1598. return before_last_bar( _n( $single, $plural, $number, $domain ) );
  1599. }
  1600. /**
  1601. * Retrieve the plural or single form based on the amount.
  1602. *
  1603. * @since 1.2.0
  1604. * @deprecated 2.8.0 Use _n()
  1605. * @see _n()
  1606. */
  1607. function __ngettext() {
  1608. _deprecated_function( __FUNCTION__, '2.8.0', '_n()' );
  1609. $args = func_get_args();
  1610. return call_user_func_array('_n', $args);
  1611. }
  1612. /**
  1613. * Register plural strings in POT file, but don't translate them.
  1614. *
  1615. * @since 2.5.0
  1616. * @deprecated 2.8.0 Use _n_noop()
  1617. * @see _n_noop()
  1618. */
  1619. function __ngettext_noop() {
  1620. _deprecated_function( __FUNCTION__, '2.8.0', '_n_noop()' );
  1621. $args = func_get_args();
  1622. return call_user_func_array('_n_noop', $args);
  1623. }
  1624. /**
  1625. * Retrieve all autoload options, or all options if no autoloaded ones exist.
  1626. *
  1627. * @since 1.0.0
  1628. * @deprecated 3.0.0 Use wp_load_alloptions())
  1629. * @see wp_load_alloptions()
  1630. *
  1631. * @return array List of all options.
  1632. */
  1633. function get_alloptions() {
  1634. _deprecated_function( __FUNCTION__, '3.0.0', 'wp_load_alloptions()' );
  1635. return wp_load_alloptions();
  1636. }
  1637. /**
  1638. * Retrieve HTML content of attachment image with link.
  1639. *
  1640. * @since 2.0.0
  1641. * @deprecated 2.5.0 Use wp_get_attachment_link()
  1642. * @see wp_get_attachment_link()
  1643. *
  1644. * @param int $id Optional. Post ID.
  1645. * @param bool $fullsize Optional, default is false. Whether to use full size image.
  1646. * @param array $max_dims Optional. Max image dimensions.
  1647. * @param bool $permalink Optional, default is false. Whether to include permalink to image.
  1648. * @return string
  1649. */
  1650. function get_the_attachment_link($id = 0, $fullsize = false, $max_dims = false, $permalink = false) {
  1651. _deprecated_function( __FUNCTION__, '2.5.0', 'wp_get_attachment_link()' );
  1652. $id = (int) $id;
  1653. $_post = get_post($id);
  1654. if ( ('attachment' != $_post->post_type) || !$url = wp_get_attachment_url($_post->ID) )
  1655. return __('Missing Attachment');
  1656. if ( $permalink )
  1657. $url = get_attachment_link($_post->ID);
  1658. $post_title = esc_attr($_post->post_title);
  1659. $innerHTML = get_attachment_innerHTML($_post->ID, $fullsize, $max_dims);
  1660. return "<a href='$url' title='$post_title'>$innerHTML</a>";
  1661. }
  1662. /**
  1663. * Retrieve icon URL and Path.
  1664. *
  1665. * @since 2.1.0
  1666. * @deprecated 2.5.0 Use wp_get_attachment_image_src()
  1667. * @see wp_get_attachment_image_src()
  1668. *
  1669. * @param int $id Optional. Post ID.
  1670. * @param bool $fullsize Optional, default to false. Whether to have full image.
  1671. * @return array Icon URL and full path to file, respectively.
  1672. */
  1673. function get_attachment_icon_src( $id = 0, $fullsize = false ) {
  1674. _deprecated_function( __FUNCTION__, '2.5.0', 'wp_get_attachment_image_src()' );
  1675. $id = (int) $id;
  1676. if ( !$post = get_post($id) )
  1677. return false;
  1678. $file = get_attached_file( $post->ID );
  1679. if ( !$fullsize && $src = wp_get_attachment_thumb_url( $post->ID ) ) {
  1680. // We have a thumbnail desired, specified and existing
  1681. $src_file = basename($src);
  1682. } elseif ( wp_attachment_is_image( $post->ID ) ) {
  1683. // We have an image without a thumbnail
  1684. $src = wp_get_attachment_url( $post->ID );
  1685. $src_file = & $file;
  1686. } elseif ( $src = wp_mime_type_icon( $post->ID ) ) {
  1687. // No thumb, no image. We'll look for a mime-related icon instead.
  1688. $icon_dir = apply_filters( 'icon_dir', get_template_directory() . '/images' );
  1689. $src_file = $icon_dir . '/' . basename($src);
  1690. }
  1691. if ( !isset($src) || !$src )
  1692. return false;
  1693. return array($src, $src_file);
  1694. }
  1695. /**
  1696. * Retrieve HTML content of icon attachment image element.
  1697. *
  1698. * @since 2.0.0
  1699. * @deprecated 2.5.0 Use wp_get_attachment_image()
  1700. * @see wp_get_attachment_image()
  1701. *
  1702. * @param int $id Optional. Post ID.
  1703. * @param bool $fullsize Optional, default to false. Whether to have full size image.
  1704. * @param array $max_dims Optional. Dimensions of image.
  1705. * @return false|string HTML content.
  1706. */
  1707. function get_attachment_icon( $id = 0, $fullsize = false, $max_dims = false ) {
  1708. _deprecated_function( __FUNCTION__, '2.5.0', 'wp_get_attachment_image()' );
  1709. $id = (int) $id;
  1710. if ( !$post = get_post($id) )
  1711. return false;
  1712. if ( !$src = get_attachment_icon_src( $post->ID, $fullsize ) )
  1713. return false;
  1714. list($src, $src_file) = $src;
  1715. // Do we need to constrain the image?
  1716. if ( ($max_dims = apply_filters('attachment_max_dims', $max_dims)) && file_exists($src_file) ) {
  1717. $imagesize = getimagesize($src_file);
  1718. if (($imagesize[0] > $max_dims[0]) || $imagesize[1] > $max_dims[1] ) {
  1719. $actual_aspect = $imagesize[0] / $imagesize[1];
  1720. $desired_aspect = $max_dims[0] / $max_dims[1];
  1721. if ( $actual_aspect >= $desired_aspect ) {
  1722. $height = $actual_aspect * $max_dims[0];
  1723. $constraint = "width='{$max_dims[0]}' ";
  1724. $post->iconsize = array($max_dims[0], $height);
  1725. } else {
  1726. $width = $max_dims[1] / $actual_aspect;
  1727. $constraint = "height='{$max_dims[1]}' ";
  1728. $post->iconsize = array($width, $max_dims[1]);
  1729. }
  1730. } else {
  1731. $post->iconsize = array($imagesize[0], $imagesize[1]);
  1732. $constraint = '';
  1733. }
  1734. } else {
  1735. $constraint = '';
  1736. }
  1737. $post_title = esc_attr($post->post_title);
  1738. $icon = "<img src='$src' title='$post_title' alt='$post_title' $constraint/>";
  1739. return apply_filters( 'attachment_icon', $icon, $post->ID );
  1740. }
  1741. /**
  1742. * Retrieve HTML content of image element.
  1743. *
  1744. * @since 2.0.0
  1745. * @deprecated 2.5.0 Use wp_get_attachment_image()
  1746. * @see wp_get_attachment_image()
  1747. *
  1748. * @param int $id Optional. Post ID.
  1749. * @param bool $fullsize Optional, default to false. Whether to have full size image.
  1750. * @param array $max_dims Optional. Dimensions of image.
  1751. * @return false|string
  1752. */
  1753. function get_attachment_innerHTML($id = 0, $fullsize = false, $max_dims = false) {
  1754. _deprecated_function( __FUNCTION__, '2.5.0', 'wp_get_attachment_image()' );
  1755. $id = (int) $id;
  1756. if ( !$post = get_post($id) )
  1757. return false;
  1758. if ( $innerHTML = get_attachment_icon($post->ID, $fullsize, $max_dims))
  1759. return $innerHTML;
  1760. $innerHTML = esc_attr($post->post_title);
  1761. return apply_filters('attachment_innerHTML', $innerHTML, $post->ID);
  1762. }
  1763. /**
  1764. * Retrieves bookmark data based on ID.
  1765. *
  1766. * @since 2.0.0
  1767. * @deprecated 2.1.0 Use get_bookmark()
  1768. * @see get_bookmark()
  1769. *
  1770. * @param int $bookmark_id ID of link
  1771. * @param string $output Optional. Type of output. Accepts OBJECT, ARRAY_N, or ARRAY_A.
  1772. * Default OBJECT.
  1773. * @param string $filter Optional. How to filter the link for output. Accepts 'raw', 'edit',
  1774. * 'attribute', 'js', 'db', or 'display'. Default 'raw'.
  1775. * @return object|array Bookmark object or array, depending on the type specified by `$output`.
  1776. */
  1777. function get_link( $bookmark_id, $output = OBJECT, $filter = 'raw' ) {
  1778. _deprecated_function( __FUNCTION__, '2.1.0', 'get_bookmark()' );
  1779. return get_bookmark($bookmark_id, $output, $filter);
  1780. }
  1781. /**
  1782. * Performs esc_url() for database or redirect usage.
  1783. *
  1784. * @since 2.3.1
  1785. * @deprecated 2.8.0 Use esc_url_raw()
  1786. * @see esc_url_raw()
  1787. *
  1788. * @param string $url The URL to be cleaned.
  1789. * @param array $protocols An array of acceptable protocols.
  1790. * @return string The cleaned URL.
  1791. */
  1792. function sanitize_url( $url, $protocols = null ) {
  1793. _deprecated_function( __FUNCTION__, '2.8.0', 'esc_url_raw()' );
  1794. return esc_url_raw( $url, $protocols );
  1795. }
  1796. /**
  1797. * Checks and cleans a URL.
  1798. *
  1799. * A number of characters are removed from the URL. If the URL is for displaying
  1800. * (the default behaviour) ampersands are also replaced. The 'clean_url' filter
  1801. * is applied to the returned cleaned URL.
  1802. *
  1803. * @since 1.2.0
  1804. * @deprecated 3.0.0 Use esc_url()
  1805. * @see esc_url()
  1806. *
  1807. * @param string $url The URL to be cleaned.
  1808. * @param array $protocols Optional. An array of acceptable protocols.
  1809. * @param string $context Optional. How the URL will be used. Default is 'display'.
  1810. * @return string The cleaned $url after the {@see 'clean_url'} filter is applied.
  1811. */
  1812. function clean_url( $url, $protocols = null, $context = 'display' ) {
  1813. if ( $context == 'db' )
  1814. _deprecated_function( 'clean_url( $context = \'db\' )', '3.0.0', 'esc_url_raw()' );
  1815. else
  1816. _deprecated_function( __FUNCTION__, '3.0.0', 'esc_url()' );
  1817. return esc_url( $url, $protocols, $context );
  1818. }
  1819. /**
  1820. * Escape single quotes, specialchar double quotes, and fix line endings.
  1821. *
  1822. * The filter {@see 'js_escape'} is also applied by esc_js().
  1823. *
  1824. * @since 2.0.4
  1825. * @deprecated 2.8.0 Use esc_js()
  1826. * @see esc_js()
  1827. *
  1828. * @param string $text The text to be escaped.
  1829. * @return string Escaped text.
  1830. */
  1831. function js_escape( $text ) {
  1832. _deprecated_function( __FUNCTION__, '2.8.0', 'esc_js()' );
  1833. return esc_js( $text );
  1834. }
  1835. /**
  1836. * Legacy escaping for HTML blocks.
  1837. *
  1838. * @deprecated 2.8.0 Use esc_html()
  1839. * @see esc_html()
  1840. *
  1841. * @param string $string String to escape.
  1842. * @param string $quote_style Unused.
  1843. * @param false|string $charset Unused.
  1844. * @param false $double_encode Whether to double encode. Unused.
  1845. * @return string Escaped `$string`.
  1846. */
  1847. function wp_specialchars( $string, $quote_style = ENT_NOQUOTES, $charset = false, $double_encode = false ) {
  1848. _deprecated_function( __FUNCTION__, '2.8.0', 'esc_html()' );
  1849. if ( func_num_args() > 1 ) { // Maintain back-compat for people passing additional arguments.
  1850. $args = func_get_args();
  1851. return call_user_func_array( '_wp_specialchars', $args );
  1852. } else {
  1853. return esc_html( $string );
  1854. }
  1855. }
  1856. /**
  1857. * Escaping for HTML attributes.
  1858. *
  1859. * @since 2.0.6
  1860. * @deprecated 2.8.0 Use esc_attr()
  1861. * @see esc_attr()
  1862. *
  1863. * @param string $text
  1864. * @return string
  1865. */
  1866. function attribute_escape( $text ) {
  1867. _deprecated_function( __FUNCTION__, '2.8.0', 'esc_attr()' );
  1868. return esc_attr( $text );
  1869. }
  1870. /**
  1871. * Register widget for sidebar with backward compatibility.
  1872. *
  1873. * Allows $name to be an array that accepts either three elements to grab the
  1874. * first element and the third for the name or just uses the first element of
  1875. * the array for the name.
  1876. *
  1877. * Passes to wp_register_sidebar_widget() after argument list and backward
  1878. * compatibility is complete.
  1879. *
  1880. * @since 2.2.0
  1881. * @deprecated 2.8.0 Use wp_register_sidebar_widget()
  1882. * @see wp_register_sidebar_widget()
  1883. *
  1884. * @param string|int $name Widget ID.
  1885. * @param callable $output_callback Run when widget is called.
  1886. * @param string $classname Optional. Classname widget option. Default empty.
  1887. * @param mixed $params ,... Widget parameters.
  1888. */
  1889. function register_sidebar_widget($name, $output_callback, $classname = '') {
  1890. _deprecated_function( __FUNCTION__, '2.8.0', 'wp_register_sidebar_widget()' );
  1891. // Compat
  1892. if ( is_array($name) ) {
  1893. if ( count($name) == 3 )
  1894. $name = sprintf($name[0], $name[2]);
  1895. else
  1896. $name = $name[0];
  1897. }
  1898. $id = sanitize_title($name);
  1899. $options = array();
  1900. if ( !empty($classname) && is_string($classname) )
  1901. $options['classname'] = $classname;
  1902. $params = array_slice(func_get_args(), 2);
  1903. $args = array($id, $name, $output_callback, $options);
  1904. if ( !empty($params) )
  1905. $args = array_merge($args, $params);
  1906. call_user_func_array('wp_register_sidebar_widget', $args);
  1907. }
  1908. /**
  1909. * Serves as an alias of wp_unregister_sidebar_widget().
  1910. *
  1911. * @since 2.2.0
  1912. * @deprecated 2.8.0 Use wp_unregister_sidebar_widget()
  1913. * @see wp_unregister_sidebar_widget()
  1914. *
  1915. * @param int|string $id Widget ID.
  1916. */
  1917. function unregister_sidebar_widget($id) {
  1918. _deprecated_function( __FUNCTION__, '2.8.0', 'wp_unregister_sidebar_widget()' );
  1919. return wp_unregister_sidebar_widget($id);
  1920. }
  1921. /**
  1922. * Registers widget control callback for customizing options.
  1923. *
  1924. * Allows $name to be an array that accepts either three elements to grab the
  1925. * first element and the third for the name or just uses the first element of
  1926. * the array for the name.
  1927. *
  1928. * Passes to wp_register_widget_control() after the argument list has
  1929. * been compiled.
  1930. *
  1931. * @since 2.2.0
  1932. * @deprecated 2.8.0 Use wp_register_widget_control()
  1933. * @see wp_register_widget_control()
  1934. *
  1935. * @param int|string $name Sidebar ID.
  1936. * @param callable $control_callback Widget control callback to display and process form.
  1937. * @param int $width Widget width.
  1938. * @param int $height Widget height.
  1939. */
  1940. function register_widget_control($name, $control_callback, $width = '', $height = '') {
  1941. _deprecated_function( __FUNCTION__, '2.8.0', 'wp_register_widget_control()' );
  1942. // Compat
  1943. if ( is_array($name) ) {
  1944. if ( count($name) == 3 )
  1945. $name = sprintf($name[0], $name[2]);
  1946. else
  1947. $name = $name[0];
  1948. }
  1949. $id = sanitize_title($name);
  1950. $options = array();
  1951. if ( !empty($width) )
  1952. $options['width'] = $width;
  1953. if ( !empty($height) )
  1954. $options['height'] = $height;
  1955. $params = array_slice(func_get_args(), 4);
  1956. $args = array($id, $name, $control_callback, $options);
  1957. if ( !empty($params) )
  1958. $args = array_merge($args, $params);
  1959. call_user_func_array('wp_register_widget_control', $args);
  1960. }
  1961. /**
  1962. * Alias of wp_unregister_widget_control().
  1963. *
  1964. * @since 2.2.0
  1965. * @deprecated 2.8.0 Use wp_unregister_widget_control()
  1966. * @see wp_unregister_widget_control()
  1967. *
  1968. * @param int|string $id Widget ID.
  1969. */
  1970. function unregister_widget_control($id) {
  1971. _deprecated_function( __FUNCTION__, '2.8.0', 'wp_unregister_widget_control()' );
  1972. return wp_unregister_widget_control($id);
  1973. }
  1974. /**
  1975. * Remove user meta data.
  1976. *
  1977. * @since 2.0.0
  1978. * @deprecated 3.0.0 Use delete_user_meta()
  1979. * @see delete_user_meta()
  1980. *
  1981. * @param int $user_id User ID.
  1982. * @param string $meta_key Metadata key.
  1983. * @param mixed $meta_value Metadata value.
  1984. * @return bool True deletion completed and false if user_id is not a number.
  1985. */
  1986. function delete_usermeta( $user_id, $meta_key, $meta_value = '' ) {
  1987. _deprecated_function( __FUNCTION__, '3.0.0', 'delete_user_meta()' );
  1988. global $wpdb;
  1989. if ( !is_numeric( $user_id ) )
  1990. return false;
  1991. $meta_key = preg_replace('|[^a-z0-9_]|i', '', $meta_key);
  1992. if ( is_array($meta_value) || is_object($meta_value) )
  1993. $meta_value = serialize($meta_value);
  1994. $meta_value = trim( $meta_value );
  1995. $cur = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->usermeta WHERE user_id = %d AND meta_key = %s", $user_id, $meta_key) );
  1996. if ( $cur && $cur->umeta_id )
  1997. do_action( 'delete_usermeta', $cur->umeta_id, $user_id, $meta_key, $meta_value );
  1998. if ( ! empty($meta_value) )
  1999. $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) );
  2000. else
  2001. $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE user_id = %d AND meta_key = %s", $user_id, $meta_key) );
  2002. clean_user_cache( $user_id );
  2003. wp_cache_delete( $user_id, 'user_meta' );
  2004. if ( $cur && $cur->umeta_id )
  2005. do_action( 'deleted_usermeta', $cur->umeta_id, $user_id, $meta_key, $meta_value );
  2006. return true;
  2007. }
  2008. /**
  2009. * Retrieve user metadata.
  2010. *
  2011. * If $user_id is not a number, then the function will fail over with a 'false'
  2012. * boolean return value. Other returned values depend on whether there is only
  2013. * one item to be returned, which be that single item type. If there is more
  2014. * than one metadata value, then it will be list of metadata values.
  2015. *
  2016. * @since 2.0.0
  2017. * @deprecated 3.0.0 Use get_user_meta()
  2018. * @see get_user_meta()
  2019. *
  2020. * @param int $user_id User ID
  2021. * @param string $meta_key Optional. Metadata key.
  2022. * @return mixed
  2023. */
  2024. function get_usermeta( $user_id, $meta_key = '' ) {
  2025. _deprecated_function( __FUNCTION__, '3.0.0', 'get_user_meta()' );
  2026. global $wpdb;
  2027. $user_id = (int) $user_id;
  2028. if ( !$user_id )
  2029. return false;
  2030. if ( !empty($meta_key) ) {
  2031. $meta_key = preg_replace('|[^a-z0-9_]|i', '', $meta_key);
  2032. $user = wp_cache_get($user_id, 'users');
  2033. // Check the cached user object
  2034. if ( false !== $user && isset($user->$meta_key) )
  2035. $metas = array($user->$meta_key);
  2036. else
  2037. $metas = $wpdb->get_col( $wpdb->prepare("SELECT meta_value FROM $wpdb->usermeta WHERE user_id = %d AND meta_key = %s", $user_id, $meta_key) );
  2038. } else {
  2039. $metas = $wpdb->get_col( $wpdb->prepare("SELECT meta_value FROM $wpdb->usermeta WHERE user_id = %d", $user_id) );
  2040. }
  2041. if ( empty($metas) ) {
  2042. if ( empty($meta_key) )
  2043. return array();
  2044. else
  2045. return '';
  2046. }
  2047. $metas = array_map('maybe_unserialize', $metas);
  2048. if ( count($metas) == 1 )
  2049. return $metas[0];
  2050. else
  2051. return $metas;
  2052. }
  2053. /**
  2054. * Update metadata of user.
  2055. *
  2056. * There is no need to serialize values, they will be serialized if it is
  2057. * needed. The metadata key can only be a string with underscores. All else will
  2058. * be removed.
  2059. *
  2060. * Will remove the metadata, if the meta value is empty.
  2061. *
  2062. * @since 2.0.0
  2063. * @deprecated 3.0.0 Use update_user_meta()
  2064. * @see update_user_meta()
  2065. *
  2066. * @param int $user_id User ID
  2067. * @param string $meta_key Metadata key.
  2068. * @param mixed $meta_value Metadata value.
  2069. * @return bool True on successful update, false on failure.
  2070. */
  2071. function update_usermeta( $user_id, $meta_key, $meta_value ) {
  2072. _deprecated_function( __FUNCTION__, '3.0.0', 'update_user_meta()' );
  2073. global $wpdb;
  2074. if ( !is_numeric( $user_id ) )
  2075. return false;
  2076. $meta_key = preg_replace('|[^a-z0-9_]|i', '', $meta_key);
  2077. /** @todo Might need fix because usermeta data is assumed to be already escaped */
  2078. if ( is_string($meta_value) )
  2079. $meta_value = stripslashes($meta_value);
  2080. $meta_value = maybe_serialize($meta_value);
  2081. if (empty($meta_value)) {
  2082. return delete_usermeta($user_id, $meta_key);
  2083. }
  2084. $cur = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->usermeta WHERE user_id = %d AND meta_key = %s", $user_id, $meta_key) );
  2085. if ( $cur )
  2086. do_action( 'update_usermeta', $cur->umeta_id, $user_id, $meta_key, $meta_value );
  2087. if ( !$cur )
  2088. $wpdb->insert($wpdb->usermeta, compact('user_id', 'meta_key', 'meta_value') );
  2089. elseif ( $cur->meta_value != $meta_value )
  2090. $wpdb->update($wpdb->usermeta, compact('meta_value'), compact('user_id', 'meta_key') );
  2091. else
  2092. return false;
  2093. clean_user_cache( $user_id );
  2094. wp_cache_delete( $user_id, 'user_meta' );
  2095. if ( !$cur )
  2096. do_action( 'added_usermeta', $wpdb->insert_id, $user_id, $meta_key, $meta_value );
  2097. else
  2098. do_action( 'updated_usermeta', $cur->umeta_id, $user_id, $meta_key, $meta_value );
  2099. return true;
  2100. }
  2101. /**
  2102. * Get users for the site.
  2103. *
  2104. * For setups that use the multisite feature. Can be used outside of the
  2105. * multisite feature.
  2106. *
  2107. * @since 2.2.0
  2108. * @deprecated 3.1.0 Use get_users()
  2109. * @see get_users()
  2110. *
  2111. * @global wpdb $wpdb WordPress database abstraction object.
  2112. *
  2113. * @param int $id Site ID.
  2114. * @return array List of users that are part of that site ID
  2115. */
  2116. function get_users_of_blog( $id = '' ) {
  2117. _deprecated_function( __FUNCTION__, '3.1.0', 'get_users()' );
  2118. global $wpdb;
  2119. if ( empty( $id ) ) {
  2120. $id = get_current_blog_id();
  2121. }
  2122. $blog_prefix = $wpdb->get_blog_prefix($id);
  2123. $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" );
  2124. return $users;
  2125. }
  2126. /**
  2127. * Enable/disable automatic general feed link outputting.
  2128. *
  2129. * @since 2.8.0
  2130. * @deprecated 3.0.0 Use add_theme_support()
  2131. * @see add_theme_support()
  2132. *
  2133. * @param bool $add Optional, default is true. Add or remove links. Defaults to true.
  2134. */
  2135. function automatic_feed_links( $add = true ) {
  2136. _deprecated_function( __FUNCTION__, '3.0.0', "add_theme_support( 'automatic-feed-links' )" );
  2137. if ( $add )
  2138. add_theme_support( 'automatic-feed-links' );
  2139. else
  2140. remove_action( 'wp_head', 'feed_links_extra', 3 ); // Just do this yourself in 3.0+
  2141. }
  2142. /**
  2143. * Retrieve user data based on field.
  2144. *
  2145. * @since 1.5.0
  2146. * @deprecated 3.0.0 Use get_the_author_meta()
  2147. * @see get_the_author_meta()
  2148. *
  2149. * @param string $field User meta field.
  2150. * @param false|int $user Optional. User ID to retrieve the field for. Default false (current user).
  2151. * @return string The author's field from the current author's DB object.
  2152. */
  2153. function get_profile( $field, $user = false ) {
  2154. _deprecated_function( __FUNCTION__, '3.0.0', 'get_the_author_meta()' );
  2155. if ( $user ) {
  2156. $user = get_user_by( 'login', $user );
  2157. $user = $user->ID;
  2158. }
  2159. return get_the_author_meta( $field, $user );
  2160. }
  2161. /**
  2162. * Retrieves the number of posts a user has written.
  2163. *
  2164. * @since 0.71
  2165. * @deprecated 3.0.0 Use count_user_posts()
  2166. * @see count_user_posts()
  2167. *
  2168. * @param int $userid User to count posts for.
  2169. * @return int Number of posts the given user has written.
  2170. */
  2171. function get_usernumposts( $userid ) {
  2172. _deprecated_function( __FUNCTION__, '3.0.0', 'count_user_posts()' );
  2173. return count_user_posts( $userid );
  2174. }
  2175. /**
  2176. * Callback used to change %uXXXX to &#YYY; syntax
  2177. *
  2178. * @since 2.8.0
  2179. * @access private
  2180. * @deprecated 3.0.0
  2181. *
  2182. * @param array $matches Single Match
  2183. * @return string An HTML entity
  2184. */
  2185. function funky_javascript_callback($matches) {
  2186. return "&#".base_convert($matches[1],16,10).";";
  2187. }
  2188. /**
  2189. * Fixes JavaScript bugs in browsers.
  2190. *
  2191. * Converts unicode characters to HTML numbered entities.
  2192. *
  2193. * @since 1.5.0
  2194. * @deprecated 3.0.0
  2195. *
  2196. * @global $is_macIE
  2197. * @global $is_winIE
  2198. *
  2199. * @param string $text Text to be made safe.
  2200. * @return string Fixed text.
  2201. */
  2202. function funky_javascript_fix($text) {
  2203. _deprecated_function( __FUNCTION__, '3.0.0' );
  2204. // Fixes for browsers' JavaScript bugs.
  2205. global $is_macIE, $is_winIE;
  2206. if ( $is_winIE || $is_macIE )
  2207. $text = preg_replace_callback("/\%u([0-9A-F]{4,4})/",
  2208. "funky_javascript_callback",
  2209. $text);
  2210. return $text;
  2211. }
  2212. /**
  2213. * Checks that the taxonomy name exists.
  2214. *
  2215. * @since 2.3.0
  2216. * @deprecated 3.0.0 Use taxonomy_exists()
  2217. * @see taxonomy_exists()
  2218. *
  2219. * @param string $taxonomy Name of taxonomy object
  2220. * @return bool Whether the taxonomy exists.
  2221. */
  2222. function is_taxonomy( $taxonomy ) {
  2223. _deprecated_function( __FUNCTION__, '3.0.0', 'taxonomy_exists()' );
  2224. return taxonomy_exists( $taxonomy );
  2225. }
  2226. /**
  2227. * Check if Term exists.
  2228. *
  2229. * @since 2.3.0
  2230. * @deprecated 3.0.0 Use term_exists()
  2231. * @see term_exists()
  2232. *
  2233. * @param int|string $term The term to check
  2234. * @param string $taxonomy The taxonomy name to use
  2235. * @param int $parent ID of parent term under which to confine the exists search.
  2236. * @return mixed Get the term id or Term Object, if exists.
  2237. */
  2238. function is_term( $term, $taxonomy = '', $parent = 0 ) {
  2239. _deprecated_function( __FUNCTION__, '3.0.0', 'term_exists()' );
  2240. return term_exists( $term, $taxonomy, $parent );
  2241. }
  2242. /**
  2243. * Is the current admin page generated by a plugin?
  2244. *
  2245. * Use global $plugin_page and/or get_plugin_page_hookname() hooks.
  2246. *
  2247. * @since 1.5.0
  2248. * @deprecated 3.1.0
  2249. *
  2250. * @global $plugin_page
  2251. *
  2252. * @return bool
  2253. */
  2254. function is_plugin_page() {
  2255. _deprecated_function( __FUNCTION__, '3.1.0' );
  2256. global $plugin_page;
  2257. if ( isset($plugin_page) )
  2258. return true;
  2259. return false;
  2260. }
  2261. /**
  2262. * Update the categories cache.
  2263. *
  2264. * This function does not appear to be used anymore or does not appear to be
  2265. * needed. It might be a legacy function left over from when there was a need
  2266. * for updating the category cache.
  2267. *
  2268. * @since 1.5.0
  2269. * @deprecated 3.1.0
  2270. *
  2271. * @return bool Always return True
  2272. */
  2273. function update_category_cache() {
  2274. _deprecated_function( __FUNCTION__, '3.1.0' );
  2275. return true;
  2276. }
  2277. /**
  2278. * Check for PHP timezone support
  2279. *
  2280. * @since 2.9.0
  2281. * @deprecated 3.2.0
  2282. *
  2283. * @return bool
  2284. */
  2285. function wp_timezone_supported() {
  2286. _deprecated_function( __FUNCTION__, '3.2.0' );
  2287. return true;
  2288. }
  2289. /**
  2290. * Displays an editor: TinyMCE, HTML, or both.
  2291. *
  2292. * @since 2.1.0
  2293. * @deprecated 3.3.0 Use wp_editor()
  2294. * @see wp_editor()
  2295. *
  2296. * @param string $content Textarea content.
  2297. * @param string $id Optional. HTML ID attribute value. Default 'content'.
  2298. * @param string $prev_id Optional. Unused.
  2299. * @param bool $media_buttons Optional. Whether to display media buttons. Default true.
  2300. * @param int $tab_index Optional. Unused.
  2301. * @param bool $extended Optional. Unused.
  2302. */
  2303. function the_editor($content, $id = 'content', $prev_id = 'title', $media_buttons = true, $tab_index = 2, $extended = true) {
  2304. _deprecated_function( __FUNCTION__, '3.3.0', 'wp_editor()' );
  2305. wp_editor( $content, $id, array( 'media_buttons' => $media_buttons ) );
  2306. }
  2307. /**
  2308. * Perform the query to get the $metavalues array(s) needed by _fill_user and _fill_many_users
  2309. *
  2310. * @since 3.0.0
  2311. * @deprecated 3.3.0
  2312. *
  2313. * @param array $ids User ID numbers list.
  2314. * @return array of arrays. The array is indexed by user_id, containing $metavalues object arrays.
  2315. */
  2316. function get_user_metavalues($ids) {
  2317. _deprecated_function( __FUNCTION__, '3.3.0' );
  2318. $objects = array();
  2319. $ids = array_map('intval', $ids);
  2320. foreach ( $ids as $id )
  2321. $objects[$id] = array();
  2322. $metas = update_meta_cache('user', $ids);
  2323. foreach ( $metas as $id => $meta ) {
  2324. foreach ( $meta as $key => $metavalues ) {
  2325. foreach ( $metavalues as $value ) {
  2326. $objects[$id][] = (object)array( 'user_id' => $id, 'meta_key' => $key, 'meta_value' => $value);
  2327. }
  2328. }
  2329. }
  2330. return $objects;
  2331. }
  2332. /**
  2333. * Sanitize every user field.
  2334. *
  2335. * If the context is 'raw', then the user object or array will get minimal santization of the int fields.
  2336. *
  2337. * @since 2.3.0
  2338. * @deprecated 3.3.0
  2339. *
  2340. * @param object|array $user The User Object or Array
  2341. * @param string $context Optional, default is 'display'. How to sanitize user fields.
  2342. * @return object|array The now sanitized User Object or Array (will be the same type as $user)
  2343. */
  2344. function sanitize_user_object($user, $context = 'display') {
  2345. _deprecated_function( __FUNCTION__, '3.3.0' );
  2346. if ( is_object($user) ) {
  2347. if ( !isset($user->ID) )
  2348. $user->ID = 0;
  2349. if ( ! ( $user instanceof WP_User ) ) {
  2350. $vars = get_object_vars($user);
  2351. foreach ( array_keys($vars) as $field ) {
  2352. if ( is_string($user->$field) || is_numeric($user->$field) )
  2353. $user->$field = sanitize_user_field($field, $user->$field, $user->ID, $context);
  2354. }
  2355. }
  2356. $user->filter = $context;
  2357. } else {
  2358. if ( !isset($user['ID']) )
  2359. $user['ID'] = 0;
  2360. foreach ( array_keys($user) as $field )
  2361. $user[$field] = sanitize_user_field($field, $user[$field], $user['ID'], $context);
  2362. $user['filter'] = $context;
  2363. }
  2364. return $user;
  2365. }
  2366. /**
  2367. * Get boundary post relational link.
  2368. *
  2369. * Can either be start or end post relational link.
  2370. *
  2371. * @since 2.8.0
  2372. * @deprecated 3.3.0
  2373. *
  2374. * @param string $title Optional. Link title format.
  2375. * @param bool $in_same_cat Optional. Whether link should be in a same category.
  2376. * @param string $excluded_categories Optional. Excluded categories IDs.
  2377. * @param bool $start Optional, default is true. Whether to display link to first or last post.
  2378. * @return string
  2379. */
  2380. function get_boundary_post_rel_link($title = '%title', $in_same_cat = false, $excluded_categories = '', $start = true) {
  2381. _deprecated_function( __FUNCTION__, '3.3.0' );
  2382. $posts = get_boundary_post($in_same_cat, $excluded_categories, $start);
  2383. // If there is no post stop.
  2384. if ( empty($posts) )
  2385. return;
  2386. // Even though we limited get_posts to return only 1 item it still returns an array of objects.
  2387. $post = $posts[0];
  2388. if ( empty($post->post_title) )
  2389. $post->post_title = $start ? __('First Post') : __('Last Post');
  2390. $date = mysql2date(get_option('date_format'), $post->post_date);
  2391. $title = str_replace('%title', $post->post_title, $title);
  2392. $title = str_replace('%date', $date, $title);
  2393. $title = apply_filters('the_title', $title, $post->ID);
  2394. $link = $start ? "<link rel='start' title='" : "<link rel='end' title='";
  2395. $link .= esc_attr($title);
  2396. $link .= "' href='" . get_permalink($post) . "' />\n";
  2397. $boundary = $start ? 'start' : 'end';
  2398. return apply_filters( "{$boundary}_post_rel_link", $link );
  2399. }
  2400. /**
  2401. * Display relational link for the first post.
  2402. *
  2403. * @since 2.8.0
  2404. * @deprecated 3.3.0
  2405. *
  2406. * @param string $title Optional. Link title format.
  2407. * @param bool $in_same_cat Optional. Whether link should be in a same category.
  2408. * @param string $excluded_categories Optional. Excluded categories IDs.
  2409. */
  2410. function start_post_rel_link($title = '%title', $in_same_cat = false, $excluded_categories = '') {
  2411. _deprecated_function( __FUNCTION__, '3.3.0' );
  2412. echo get_boundary_post_rel_link($title, $in_same_cat, $excluded_categories, true);
  2413. }
  2414. /**
  2415. * Get site index relational link.
  2416. *
  2417. * @since 2.8.0
  2418. * @deprecated 3.3.0
  2419. *
  2420. * @return string
  2421. */
  2422. function get_index_rel_link() {
  2423. _deprecated_function( __FUNCTION__, '3.3.0' );
  2424. $link = "<link rel='index' title='" . esc_attr( get_bloginfo( 'name', 'display' ) ) . "' href='" . esc_url( user_trailingslashit( get_bloginfo( 'url', 'display' ) ) ) . "' />\n";
  2425. return apply_filters( "index_rel_link", $link );
  2426. }
  2427. /**
  2428. * Display relational link for the site index.
  2429. *
  2430. * @since 2.8.0
  2431. * @deprecated 3.3.0
  2432. */
  2433. function index_rel_link() {
  2434. _deprecated_function( __FUNCTION__, '3.3.0' );
  2435. echo get_index_rel_link();
  2436. }
  2437. /**
  2438. * Get parent post relational link.
  2439. *
  2440. * @since 2.8.0
  2441. * @deprecated 3.3.0
  2442. *
  2443. * @param string $title Optional. Link title format. Default '%title'.
  2444. * @return string
  2445. */
  2446. function get_parent_post_rel_link( $title = '%title' ) {
  2447. _deprecated_function( __FUNCTION__, '3.3.0' );
  2448. if ( ! empty( $GLOBALS['post'] ) && ! empty( $GLOBALS['post']->post_parent ) )
  2449. $post = get_post($GLOBALS['post']->post_parent);
  2450. if ( empty($post) )
  2451. return;
  2452. $date = mysql2date(get_option('date_format'), $post->post_date);
  2453. $title = str_replace('%title', $post->post_title, $title);
  2454. $title = str_replace('%date', $date, $title);
  2455. $title = apply_filters('the_title', $title, $post->ID);
  2456. $link = "<link rel='up' title='";
  2457. $link .= esc_attr( $title );
  2458. $link .= "' href='" . get_permalink($post) . "' />\n";
  2459. return apply_filters( "parent_post_rel_link", $link );
  2460. }
  2461. /**
  2462. * Display relational link for parent item
  2463. *
  2464. * @since 2.8.0
  2465. * @deprecated 3.3.0
  2466. *
  2467. * @param string $title Optional. Link title format. Default '%title'.
  2468. */
  2469. function parent_post_rel_link( $title = '%title' ) {
  2470. _deprecated_function( __FUNCTION__, '3.3.0' );
  2471. echo get_parent_post_rel_link($title);
  2472. }
  2473. /**
  2474. * Add the "Dashboard"/"Visit Site" menu.
  2475. *
  2476. * @since 3.2.0
  2477. * @deprecated 3.3.0
  2478. *
  2479. * @param WP_Admin_Bar $wp_admin_bar WP_Admin_Bar instance.
  2480. */
  2481. function wp_admin_bar_dashboard_view_site_menu( $wp_admin_bar ) {
  2482. _deprecated_function( __FUNCTION__, '3.3.0' );
  2483. $user_id = get_current_user_id();
  2484. if ( 0 != $user_id ) {
  2485. if ( is_admin() )
  2486. $wp_admin_bar->add_menu( array( 'id' => 'view-site', 'title' => __( 'Visit Site' ), 'href' => home_url() ) );
  2487. elseif ( is_multisite() )
  2488. $wp_admin_bar->add_menu( array( 'id' => 'dashboard', 'title' => __( 'Dashboard' ), 'href' => get_dashboard_url( $user_id ) ) );
  2489. else
  2490. $wp_admin_bar->add_menu( array( 'id' => 'dashboard', 'title' => __( 'Dashboard' ), 'href' => admin_url() ) );
  2491. }
  2492. }
  2493. /**
  2494. * Checks if the current user belong to a given site.
  2495. *
  2496. * @since MU
  2497. * @deprecated 3.3.0 Use is_user_member_of_blog()
  2498. * @see is_user_member_of_blog()
  2499. *
  2500. * @param int $blog_id Site ID
  2501. * @return bool True if the current users belong to $blog_id, false if not.
  2502. */
  2503. function is_blog_user( $blog_id = 0 ) {
  2504. _deprecated_function( __FUNCTION__, '3.3.0', 'is_user_member_of_blog()' );
  2505. return is_user_member_of_blog( get_current_user_id(), $blog_id );
  2506. }
  2507. /**
  2508. * Open the file handle for debugging.
  2509. *
  2510. * @since 0.71
  2511. * @deprecated 3.4.0 Use error_log()
  2512. * @see error_log()
  2513. *
  2514. * @link https://secure.php.net/manual/en/function.error-log.php
  2515. *
  2516. * @param string $filename File name.
  2517. * @param string $mode Type of access you required to the stream.
  2518. * @return false Always false.
  2519. */
  2520. function debug_fopen( $filename, $mode ) {
  2521. _deprecated_function( __FUNCTION__, 'error_log()' );
  2522. return false;
  2523. }
  2524. /**
  2525. * Write contents to the file used for debugging.
  2526. *
  2527. * @since 0.71
  2528. * @deprecated 3.4.0 Use error_log()
  2529. * @see error_log()
  2530. *
  2531. * @link https://secure.php.net/manual/en/function.error-log.php
  2532. *
  2533. * @param mixed $fp Unused.
  2534. * @param string $string Message to log.
  2535. */
  2536. function debug_fwrite( $fp, $string ) {
  2537. _deprecated_function( __FUNCTION__, 'error_log()' );
  2538. if ( ! empty( $GLOBALS['debug'] ) )
  2539. error_log( $string );
  2540. }
  2541. /**
  2542. * Close the debugging file handle.
  2543. *
  2544. * @since 0.71
  2545. * @deprecated 3.4.0 Use error_log()
  2546. * @see error_log()
  2547. *
  2548. * @link https://secure.php.net/manual/en/function.error-log.php
  2549. *
  2550. * @param mixed $fp Unused.
  2551. */
  2552. function debug_fclose( $fp ) {
  2553. _deprecated_function( __FUNCTION__, 'error_log()' );
  2554. }
  2555. /**
  2556. * Retrieve list of themes with theme data in theme directory.
  2557. *
  2558. * The theme is broken, if it doesn't have a parent theme and is missing either
  2559. * style.css and, or index.php. If the theme has a parent theme then it is
  2560. * broken, if it is missing style.css; index.php is optional.
  2561. *
  2562. * @since 1.5.0
  2563. * @deprecated 3.4.0 Use wp_get_themes()
  2564. * @see wp_get_themes()
  2565. *
  2566. * @return array Theme list with theme data.
  2567. */
  2568. function get_themes() {
  2569. _deprecated_function( __FUNCTION__, '3.4.0', 'wp_get_themes()' );
  2570. global $wp_themes;
  2571. if ( isset( $wp_themes ) )
  2572. return $wp_themes;
  2573. $themes = wp_get_themes();
  2574. $wp_themes = array();
  2575. foreach ( $themes as $theme ) {
  2576. $name = $theme->get('Name');
  2577. if ( isset( $wp_themes[ $name ] ) )
  2578. $wp_themes[ $name . '/' . $theme->get_stylesheet() ] = $theme;
  2579. else
  2580. $wp_themes[ $name ] = $theme;
  2581. }
  2582. return $wp_themes;
  2583. }
  2584. /**
  2585. * Retrieve theme data.
  2586. *
  2587. * @since 1.5.0
  2588. * @deprecated 3.4.0 Use wp_get_theme()
  2589. * @see wp_get_theme()
  2590. *
  2591. * @param string $theme Theme name.
  2592. * @return array|null Null, if theme name does not exist. Theme data, if exists.
  2593. */
  2594. function get_theme( $theme ) {
  2595. _deprecated_function( __FUNCTION__, '3.4.0', 'wp_get_theme( $stylesheet )' );
  2596. $themes = get_themes();
  2597. if ( is_array( $themes ) && array_key_exists( $theme, $themes ) )
  2598. return $themes[ $theme ];
  2599. return null;
  2600. }
  2601. /**
  2602. * Retrieve current theme name.
  2603. *
  2604. * @since 1.5.0
  2605. * @deprecated 3.4.0 Use wp_get_theme()
  2606. * @see wp_get_theme()
  2607. *
  2608. * @return string
  2609. */
  2610. function get_current_theme() {
  2611. _deprecated_function( __FUNCTION__, '3.4.0', 'wp_get_theme()' );
  2612. if ( $theme = get_option( 'current_theme' ) )
  2613. return $theme;
  2614. return wp_get_theme()->get('Name');
  2615. }
  2616. /**
  2617. * Accepts matches array from preg_replace_callback in wpautop() or a string.
  2618. *
  2619. * Ensures that the contents of a `<pre>...</pre>` HTML block are not
  2620. * converted into paragraphs or line-breaks.
  2621. *
  2622. * @since 1.2.0
  2623. * @deprecated 3.4.0
  2624. *
  2625. * @param array|string $matches The array or string
  2626. * @return string The pre block without paragraph/line-break conversion.
  2627. */
  2628. function clean_pre($matches) {
  2629. _deprecated_function( __FUNCTION__, '3.4.0' );
  2630. if ( is_array($matches) )
  2631. $text = $matches[1] . $matches[2] . "</pre>";
  2632. else
  2633. $text = $matches;
  2634. $text = str_replace(array('<br />', '<br/>', '<br>'), array('', '', ''), $text);
  2635. $text = str_replace('<p>', "\n", $text);
  2636. $text = str_replace('</p>', '', $text);
  2637. return $text;
  2638. }
  2639. /**
  2640. * Add callbacks for image header display.
  2641. *
  2642. * @since 2.1.0
  2643. * @deprecated 3.4.0 Use add_theme_support()
  2644. * @see add_theme_support()
  2645. *
  2646. * @param callable $wp_head_callback Call on the {@see 'wp_head'} action.
  2647. * @param callable $admin_head_callback Call on custom header administration screen.
  2648. * @param callable $admin_preview_callback Output a custom header image div on the custom header administration screen. Optional.
  2649. */
  2650. function add_custom_image_header( $wp_head_callback, $admin_head_callback, $admin_preview_callback = '' ) {
  2651. _deprecated_function( __FUNCTION__, '3.4.0', 'add_theme_support( \'custom-header\', $args )' );
  2652. $args = array(
  2653. 'wp-head-callback' => $wp_head_callback,
  2654. 'admin-head-callback' => $admin_head_callback,
  2655. );
  2656. if ( $admin_preview_callback )
  2657. $args['admin-preview-callback'] = $admin_preview_callback;
  2658. return add_theme_support( 'custom-header', $args );
  2659. }
  2660. /**
  2661. * Remove image header support.
  2662. *
  2663. * @since 3.1.0
  2664. * @deprecated 3.4.0 Use remove_theme_support()
  2665. * @see remove_theme_support()
  2666. *
  2667. * @return null|bool Whether support was removed.
  2668. */
  2669. function remove_custom_image_header() {
  2670. _deprecated_function( __FUNCTION__, '3.4.0', 'remove_theme_support( \'custom-header\' )' );
  2671. return remove_theme_support( 'custom-header' );
  2672. }
  2673. /**
  2674. * Add callbacks for background image display.
  2675. *
  2676. * @since 3.0.0
  2677. * @deprecated 3.4.0 Use add_theme_support()
  2678. * @see add_theme_support()
  2679. *
  2680. * @param callable $wp_head_callback Call on the {@see 'wp_head'} action.
  2681. * @param callable $admin_head_callback Call on custom background administration screen.
  2682. * @param callable $admin_preview_callback Output a custom background image div on the custom background administration screen. Optional.
  2683. */
  2684. function add_custom_background( $wp_head_callback = '', $admin_head_callback = '', $admin_preview_callback = '' ) {
  2685. _deprecated_function( __FUNCTION__, '3.4.0', 'add_theme_support( \'custom-background\', $args )' );
  2686. $args = array();
  2687. if ( $wp_head_callback )
  2688. $args['wp-head-callback'] = $wp_head_callback;
  2689. if ( $admin_head_callback )
  2690. $args['admin-head-callback'] = $admin_head_callback;
  2691. if ( $admin_preview_callback )
  2692. $args['admin-preview-callback'] = $admin_preview_callback;
  2693. return add_theme_support( 'custom-background', $args );
  2694. }
  2695. /**
  2696. * Remove custom background support.
  2697. *
  2698. * @since 3.1.0
  2699. * @deprecated 3.4.0 Use add_custom_background()
  2700. * @see add_custom_background()
  2701. *
  2702. * @return null|bool Whether support was removed.
  2703. */
  2704. function remove_custom_background() {
  2705. _deprecated_function( __FUNCTION__, '3.4.0', 'remove_theme_support( \'custom-background\' )' );
  2706. return remove_theme_support( 'custom-background' );
  2707. }
  2708. /**
  2709. * Retrieve theme data from parsed theme file.
  2710. *
  2711. * @since 1.5.0
  2712. * @deprecated 3.4.0 Use wp_get_theme()
  2713. * @see wp_get_theme()
  2714. *
  2715. * @param string $theme_file Theme file path.
  2716. * @return array Theme data.
  2717. */
  2718. function get_theme_data( $theme_file ) {
  2719. _deprecated_function( __FUNCTION__, '3.4.0', 'wp_get_theme()' );
  2720. $theme = new WP_Theme( basename( dirname( $theme_file ) ), dirname( dirname( $theme_file ) ) );
  2721. $theme_data = array(
  2722. 'Name' => $theme->get('Name'),
  2723. 'URI' => $theme->display('ThemeURI', true, false),
  2724. 'Description' => $theme->display('Description', true, false),
  2725. 'Author' => $theme->display('Author', true, false),
  2726. 'AuthorURI' => $theme->display('AuthorURI', true, false),
  2727. 'Version' => $theme->get('Version'),
  2728. 'Template' => $theme->get('Template'),
  2729. 'Status' => $theme->get('Status'),
  2730. 'Tags' => $theme->get('Tags'),
  2731. 'Title' => $theme->get('Name'),
  2732. 'AuthorName' => $theme->get('Author'),
  2733. );
  2734. foreach ( apply_filters( 'extra_theme_headers', array() ) as $extra_header ) {
  2735. if ( ! isset( $theme_data[ $extra_header ] ) )
  2736. $theme_data[ $extra_header ] = $theme->get( $extra_header );
  2737. }
  2738. return $theme_data;
  2739. }
  2740. /**
  2741. * Alias of update_post_cache().
  2742. *
  2743. * @see update_post_cache() Posts and pages are the same, alias is intentional
  2744. *
  2745. * @since 1.5.1
  2746. * @deprecated 3.4.0 Use update_post_cache()
  2747. * @see update_post_cache()
  2748. *
  2749. * @param array $pages list of page objects
  2750. */
  2751. function update_page_cache( &$pages ) {
  2752. _deprecated_function( __FUNCTION__, '3.4.0', 'update_post_cache()' );
  2753. update_post_cache( $pages );
  2754. }
  2755. /**
  2756. * Will clean the page in the cache.
  2757. *
  2758. * Clean (read: delete) page from cache that matches $id. Will also clean cache
  2759. * associated with 'all_page_ids' and 'get_pages'.
  2760. *
  2761. * @since 2.0.0
  2762. * @deprecated 3.4.0 Use clean_post_cache
  2763. * @see clean_post_cache()
  2764. *
  2765. * @param int $id Page ID to clean
  2766. */
  2767. function clean_page_cache( $id ) {
  2768. _deprecated_function( __FUNCTION__, '3.4.0', 'clean_post_cache()' );
  2769. clean_post_cache( $id );
  2770. }
  2771. /**
  2772. * Retrieve nonce action "Are you sure" message.
  2773. *
  2774. * Deprecated in 3.4.1 and 3.5.0. Backported to 3.3.3.
  2775. *
  2776. * @since 2.0.4
  2777. * @deprecated 3.4.1 Use wp_nonce_ays()
  2778. * @see wp_nonce_ays()
  2779. *
  2780. * @param string $action Nonce action.
  2781. * @return string Are you sure message.
  2782. */
  2783. function wp_explain_nonce( $action ) {
  2784. _deprecated_function( __FUNCTION__, '3.4.1', 'wp_nonce_ays()' );
  2785. return __( 'Are you sure you want to do this?' );
  2786. }
  2787. /**
  2788. * Display "sticky" CSS class, if a post is sticky.
  2789. *
  2790. * @since 2.7.0
  2791. * @deprecated 3.5.0 Use post_class()
  2792. * @see post_class()
  2793. *
  2794. * @param int $post_id An optional post ID.
  2795. */
  2796. function sticky_class( $post_id = null ) {
  2797. _deprecated_function( __FUNCTION__, '3.5.0', 'post_class()' );
  2798. if ( is_sticky( $post_id ) )
  2799. echo ' sticky';
  2800. }
  2801. /**
  2802. * Retrieve post ancestors.
  2803. *
  2804. * This is no longer needed as WP_Post lazy-loads the ancestors
  2805. * property with get_post_ancestors().
  2806. *
  2807. * @since 2.3.4
  2808. * @deprecated 3.5.0 Use get_post_ancestors()
  2809. * @see get_post_ancestors()
  2810. *
  2811. * @param WP_Post &$post Post object, passed by reference (unused).
  2812. */
  2813. function _get_post_ancestors( &$post ) {
  2814. _deprecated_function( __FUNCTION__, '3.5.0' );
  2815. }
  2816. /**
  2817. * Load an image from a string, if PHP supports it.
  2818. *
  2819. * @since 2.1.0
  2820. * @deprecated 3.5.0 Use wp_get_image_editor()
  2821. * @see wp_get_image_editor()
  2822. *
  2823. * @param string $file Filename of the image to load.
  2824. * @return resource The resulting image resource on success, Error string on failure.
  2825. */
  2826. function wp_load_image( $file ) {
  2827. _deprecated_function( __FUNCTION__, '3.5.0', 'wp_get_image_editor()' );
  2828. if ( is_numeric( $file ) )
  2829. $file = get_attached_file( $file );
  2830. if ( ! is_file( $file ) ) {
  2831. /* translators: %s: file name */
  2832. return sprintf( __( 'File &#8220;%s&#8221; doesn&#8217;t exist?' ), $file );
  2833. }
  2834. if ( ! function_exists('imagecreatefromstring') )
  2835. return __('The GD image library is not installed.');
  2836. // Set artificially high because GD uses uncompressed images in memory.
  2837. wp_raise_memory_limit( 'image' );
  2838. $image = imagecreatefromstring( file_get_contents( $file ) );
  2839. if ( ! is_resource( $image ) ) {
  2840. /* translators: %s: file name */
  2841. return sprintf( __( 'File &#8220;%s&#8221; is not an image.' ), $file );
  2842. }
  2843. return $image;
  2844. }
  2845. /**
  2846. * Scale down an image to fit a particular size and save a new copy of the image.
  2847. *
  2848. * The PNG transparency will be preserved using the function, as well as the
  2849. * image type. If the file going in is PNG, then the resized image is going to
  2850. * be PNG. The only supported image types are PNG, GIF, and JPEG.
  2851. *
  2852. * Some functionality requires API to exist, so some PHP version may lose out
  2853. * support. This is not the fault of WordPress (where functionality is
  2854. * downgraded, not actual defects), but of your PHP version.
  2855. *
  2856. * @since 2.5.0
  2857. * @deprecated 3.5.0 Use wp_get_image_editor()
  2858. * @see wp_get_image_editor()
  2859. *
  2860. * @param string $file Image file path.
  2861. * @param int $max_w Maximum width to resize to.
  2862. * @param int $max_h Maximum height to resize to.
  2863. * @param bool $crop Optional. Whether to crop image or resize.
  2864. * @param string $suffix Optional. File suffix.
  2865. * @param string $dest_path Optional. New image file path.
  2866. * @param int $jpeg_quality Optional, default is 90. Image quality percentage.
  2867. * @return mixed WP_Error on failure. String with new destination path.
  2868. */
  2869. function image_resize( $file, $max_w, $max_h, $crop = false, $suffix = null, $dest_path = null, $jpeg_quality = 90 ) {
  2870. _deprecated_function( __FUNCTION__, '3.5.0', 'wp_get_image_editor()' );
  2871. $editor = wp_get_image_editor( $file );
  2872. if ( is_wp_error( $editor ) )
  2873. return $editor;
  2874. $editor->set_quality( $jpeg_quality );
  2875. $resized = $editor->resize( $max_w, $max_h, $crop );
  2876. if ( is_wp_error( $resized ) )
  2877. return $resized;
  2878. $dest_file = $editor->generate_filename( $suffix, $dest_path );
  2879. $saved = $editor->save( $dest_file );
  2880. if ( is_wp_error( $saved ) )
  2881. return $saved;
  2882. return $dest_file;
  2883. }
  2884. /**
  2885. * Retrieve a single post, based on post ID.
  2886. *
  2887. * Has categories in 'post_category' property or key. Has tags in 'tags_input'
  2888. * property or key.
  2889. *
  2890. * @since 1.0.0
  2891. * @deprecated 3.5.0 Use get_post()
  2892. * @see get_post()
  2893. *
  2894. * @param int $postid Post ID.
  2895. * @param string $mode How to return result, either OBJECT, ARRAY_N, or ARRAY_A.
  2896. * @return WP_Post|null Post object or array holding post contents and information
  2897. */
  2898. function wp_get_single_post( $postid = 0, $mode = OBJECT ) {
  2899. _deprecated_function( __FUNCTION__, '3.5.0', 'get_post()' );
  2900. return get_post( $postid, $mode );
  2901. }
  2902. /**
  2903. * Check that the user login name and password is correct.
  2904. *
  2905. * @since 0.71
  2906. * @deprecated 3.5.0 Use wp_authenticate()
  2907. * @see wp_authenticate()
  2908. *
  2909. * @param string $user_login User name.
  2910. * @param string $user_pass User password.
  2911. * @return bool False if does not authenticate, true if username and password authenticates.
  2912. */
  2913. function user_pass_ok($user_login, $user_pass) {
  2914. _deprecated_function( __FUNCTION__, '3.5.0', 'wp_authenticate()' );
  2915. $user = wp_authenticate( $user_login, $user_pass );
  2916. if ( is_wp_error( $user ) )
  2917. return false;
  2918. return true;
  2919. }
  2920. /**
  2921. * Callback formerly fired on the save_post hook. No longer needed.
  2922. *
  2923. * @since 2.3.0
  2924. * @deprecated 3.5.0
  2925. */
  2926. function _save_post_hook() {}
  2927. /**
  2928. * Check if the installed version of GD supports particular image type
  2929. *
  2930. * @since 2.9.0
  2931. * @deprecated 3.5.0 Use wp_image_editor_supports()
  2932. * @see wp_image_editor_supports()
  2933. *
  2934. * @param string $mime_type
  2935. * @return bool
  2936. */
  2937. function gd_edit_image_support($mime_type) {
  2938. _deprecated_function( __FUNCTION__, '3.5.0', 'wp_image_editor_supports()' );
  2939. if ( function_exists('imagetypes') ) {
  2940. switch( $mime_type ) {
  2941. case 'image/jpeg':
  2942. return (imagetypes() & IMG_JPG) != 0;
  2943. case 'image/png':
  2944. return (imagetypes() & IMG_PNG) != 0;
  2945. case 'image/gif':
  2946. return (imagetypes() & IMG_GIF) != 0;
  2947. }
  2948. } else {
  2949. switch( $mime_type ) {
  2950. case 'image/jpeg':
  2951. return function_exists('imagecreatefromjpeg');
  2952. case 'image/png':
  2953. return function_exists('imagecreatefrompng');
  2954. case 'image/gif':
  2955. return function_exists('imagecreatefromgif');
  2956. }
  2957. }
  2958. return false;
  2959. }
  2960. /**
  2961. * Converts an integer byte value to a shorthand byte value.
  2962. *
  2963. * @since 2.3.0
  2964. * @deprecated 3.6.0 Use size_format()
  2965. * @see size_format()
  2966. *
  2967. * @param int $bytes An integer byte value.
  2968. * @return string A shorthand byte value.
  2969. */
  2970. function wp_convert_bytes_to_hr( $bytes ) {
  2971. _deprecated_function( __FUNCTION__, '3.6.0', 'size_format()' );
  2972. $units = array( 0 => 'B', 1 => 'KB', 2 => 'MB', 3 => 'GB', 4 => 'TB' );
  2973. $log = log( $bytes, KB_IN_BYTES );
  2974. $power = (int) $log;
  2975. $size = pow( KB_IN_BYTES, $log - $power );
  2976. if ( ! is_nan( $size ) && array_key_exists( $power, $units ) ) {
  2977. $unit = $units[ $power ];
  2978. } else {
  2979. $size = $bytes;
  2980. $unit = $units[0];
  2981. }
  2982. return $size . $unit;
  2983. }
  2984. /**
  2985. * Formerly used internally to tidy up the search terms.
  2986. *
  2987. * @since 2.9.0
  2988. * @access private
  2989. * @deprecated 3.7.0
  2990. *
  2991. * @param string $t Search terms to "tidy", e.g. trim.
  2992. * @return string Trimmed search terms.
  2993. */
  2994. function _search_terms_tidy( $t ) {
  2995. _deprecated_function( __FUNCTION__, '3.7.0' );
  2996. return trim( $t, "\"'\n\r " );
  2997. }
  2998. /**
  2999. * Determine if TinyMCE is available.
  3000. *
  3001. * Checks to see if the user has deleted the tinymce files to slim down
  3002. * their WordPress install.
  3003. *
  3004. * @since 2.1.0
  3005. * @deprecated 3.9.0
  3006. *
  3007. * @return bool Whether TinyMCE exists.
  3008. */
  3009. function rich_edit_exists() {
  3010. global $wp_rich_edit_exists;
  3011. _deprecated_function( __FUNCTION__, '3.9.0' );
  3012. if ( ! isset( $wp_rich_edit_exists ) )
  3013. $wp_rich_edit_exists = file_exists( ABSPATH . WPINC . '/js/tinymce/tinymce.js' );
  3014. return $wp_rich_edit_exists;
  3015. }
  3016. /**
  3017. * Old callback for tag link tooltips.
  3018. *
  3019. * @since 2.7.0
  3020. * @access private
  3021. * @deprecated 3.9.0
  3022. *
  3023. * @param int $count Number of topics.
  3024. * @return int Number of topics.
  3025. */
  3026. function default_topic_count_text( $count ) {
  3027. return $count;
  3028. }
  3029. /**
  3030. * Formerly used to escape strings before inserting into the DB.
  3031. *
  3032. * Has not performed this function for many, many years. Use wpdb::prepare() instead.
  3033. *
  3034. * @since 0.71
  3035. * @deprecated 3.9.0
  3036. *
  3037. * @param string $content The text to format.
  3038. * @return string The very same text.
  3039. */
  3040. function format_to_post( $content ) {
  3041. _deprecated_function( __FUNCTION__, '3.9.0' );
  3042. return $content;
  3043. }
  3044. /**
  3045. * Formerly used to escape strings before searching the DB. It was poorly documented and never worked as described.
  3046. *
  3047. * @since 2.5.0
  3048. * @deprecated 4.0.0 Use wpdb::esc_like()
  3049. * @see wpdb::esc_like()
  3050. *
  3051. * @param string $text The text to be escaped.
  3052. * @return string text, safe for inclusion in LIKE query.
  3053. */
  3054. function like_escape($text) {
  3055. _deprecated_function( __FUNCTION__, '4.0.0', 'wpdb::esc_like()' );
  3056. return str_replace( array( "%", "_" ), array( "\\%", "\\_" ), $text );
  3057. }
  3058. /**
  3059. * Determines if the URL can be accessed over SSL.
  3060. *
  3061. * Determines if the URL can be accessed over SSL by using the WordPress HTTP API to access
  3062. * the URL using https as the scheme.
  3063. *
  3064. * @since 2.5.0
  3065. * @deprecated 4.0.0
  3066. *
  3067. * @param string $url The URL to test.
  3068. * @return bool Whether SSL access is available.
  3069. */
  3070. function url_is_accessable_via_ssl( $url ) {
  3071. _deprecated_function( __FUNCTION__, '4.0.0' );
  3072. $response = wp_remote_get( set_url_scheme( $url, 'https' ) );
  3073. if ( !is_wp_error( $response ) ) {
  3074. $status = wp_remote_retrieve_response_code( $response );
  3075. if ( 200 == $status || 401 == $status ) {
  3076. return true;
  3077. }
  3078. }
  3079. return false;
  3080. }
  3081. /**
  3082. * Start preview theme output buffer.
  3083. *
  3084. * Will only perform task if the user has permissions and template and preview
  3085. * query variables exist.
  3086. *
  3087. * @since 2.6.0
  3088. * @deprecated 4.3.0
  3089. */
  3090. function preview_theme() {
  3091. _deprecated_function( __FUNCTION__, '4.3.0' );
  3092. }
  3093. /**
  3094. * Private function to modify the current template when previewing a theme
  3095. *
  3096. * @since 2.9.0
  3097. * @deprecated 4.3.0
  3098. * @access private
  3099. *
  3100. * @return string
  3101. */
  3102. function _preview_theme_template_filter() {
  3103. _deprecated_function( __FUNCTION__, '4.3.0' );
  3104. return '';
  3105. }
  3106. /**
  3107. * Private function to modify the current stylesheet when previewing a theme
  3108. *
  3109. * @since 2.9.0
  3110. * @deprecated 4.3.0
  3111. * @access private
  3112. *
  3113. * @return string
  3114. */
  3115. function _preview_theme_stylesheet_filter() {
  3116. _deprecated_function( __FUNCTION__, '4.3.0' );
  3117. return '';
  3118. }
  3119. /**
  3120. * Callback function for ob_start() to capture all links in the theme.
  3121. *
  3122. * @since 2.6.0
  3123. * @deprecated 4.3.0
  3124. * @access private
  3125. *
  3126. * @param string $content
  3127. * @return string
  3128. */
  3129. function preview_theme_ob_filter( $content ) {
  3130. _deprecated_function( __FUNCTION__, '4.3.0' );
  3131. return $content;
  3132. }
  3133. /**
  3134. * Manipulates preview theme links in order to control and maintain location.
  3135. *
  3136. * Callback function for preg_replace_callback() to accept and filter matches.
  3137. *
  3138. * @since 2.6.0
  3139. * @deprecated 4.3.0
  3140. * @access private
  3141. *
  3142. * @param array $matches
  3143. * @return string
  3144. */
  3145. function preview_theme_ob_filter_callback( $matches ) {
  3146. _deprecated_function( __FUNCTION__, '4.3.0' );
  3147. return '';
  3148. }
  3149. /**
  3150. * Formats text for the rich text editor.
  3151. *
  3152. * The {@see 'richedit_pre'} filter is applied here. If $text is empty the filter will
  3153. * be applied to an empty string.
  3154. *
  3155. * @since 2.0.0
  3156. * @deprecated 4.3.0
  3157. *
  3158. * @param string $text The text to be formatted.
  3159. * @return string The formatted text after filter is applied.
  3160. */
  3161. function wp_richedit_pre($text) {
  3162. _deprecated_function( __FUNCTION__, '4.3.0', 'format_for_editor()' );
  3163. if ( empty( $text ) ) {
  3164. /**
  3165. * Filters text returned for the rich text editor.
  3166. *
  3167. * This filter is first evaluated, and the value returned, if an empty string
  3168. * is passed to wp_richedit_pre(). If an empty string is passed, it results
  3169. * in a break tag and line feed.
  3170. *
  3171. * If a non-empty string is passed, the filter is evaluated on the wp_richedit_pre()
  3172. * return after being formatted.
  3173. *
  3174. * @since 2.0.0
  3175. * @deprecated 4.3.0
  3176. *
  3177. * @param string $output Text for the rich text editor.
  3178. */
  3179. return apply_filters( 'richedit_pre', '' );
  3180. }
  3181. $output = convert_chars($text);
  3182. $output = wpautop($output);
  3183. $output = htmlspecialchars($output, ENT_NOQUOTES, get_option( 'blog_charset' ) );
  3184. /** This filter is documented in wp-includes/deprecated.php */
  3185. return apply_filters( 'richedit_pre', $output );
  3186. }
  3187. /**
  3188. * Formats text for the HTML editor.
  3189. *
  3190. * Unless $output is empty it will pass through htmlspecialchars before the
  3191. * {@see 'htmledit_pre'} filter is applied.
  3192. *
  3193. * @since 2.5.0
  3194. * @deprecated 4.3.0 Use format_for_editor()
  3195. * @see format_for_editor()
  3196. *
  3197. * @param string $output The text to be formatted.
  3198. * @return string Formatted text after filter applied.
  3199. */
  3200. function wp_htmledit_pre($output) {
  3201. _deprecated_function( __FUNCTION__, '4.3.0', 'format_for_editor()' );
  3202. if ( !empty($output) )
  3203. $output = htmlspecialchars($output, ENT_NOQUOTES, get_option( 'blog_charset' ) ); // convert only < > &
  3204. /**
  3205. * Filters the text before it is formatted for the HTML editor.
  3206. *
  3207. * @since 2.5.0
  3208. * @deprecated 4.3.0
  3209. *
  3210. * @param string $output The HTML-formatted text.
  3211. */
  3212. return apply_filters( 'htmledit_pre', $output );
  3213. }
  3214. /**
  3215. * Retrieve permalink from post ID.
  3216. *
  3217. * @since 1.0.0
  3218. * @deprecated 4.4.0 Use get_permalink()
  3219. * @see get_permalink()
  3220. *
  3221. * @param int|WP_Post $post_id Optional. Post ID or WP_Post object. Default is global $post.
  3222. * @return string|false
  3223. */
  3224. function post_permalink( $post_id = 0 ) {
  3225. _deprecated_function( __FUNCTION__, '4.4.0', 'get_permalink()' );
  3226. return get_permalink( $post_id );
  3227. }
  3228. /**
  3229. * Perform a HTTP HEAD or GET request.
  3230. *
  3231. * If $file_path is a writable filename, this will do a GET request and write
  3232. * the file to that path.
  3233. *
  3234. * @since 2.5.0
  3235. * @deprecated 4.4.0 Use WP_Http
  3236. * @see WP_Http
  3237. *
  3238. * @param string $url URL to fetch.
  3239. * @param string|bool $file_path Optional. File path to write request to. Default false.
  3240. * @param int $red Optional. The number of Redirects followed, Upon 5 being hit,
  3241. * returns false. Default 1.
  3242. * @return bool|string False on failure and string of headers if HEAD request.
  3243. */
  3244. function wp_get_http( $url, $file_path = false, $red = 1 ) {
  3245. _deprecated_function( __FUNCTION__, '4.4.0', 'WP_Http' );
  3246. @set_time_limit( 60 );
  3247. if ( $red > 5 )
  3248. return false;
  3249. $options = array();
  3250. $options['redirection'] = 5;
  3251. if ( false == $file_path )
  3252. $options['method'] = 'HEAD';
  3253. else
  3254. $options['method'] = 'GET';
  3255. $response = wp_safe_remote_request( $url, $options );
  3256. if ( is_wp_error( $response ) )
  3257. return false;
  3258. $headers = wp_remote_retrieve_headers( $response );
  3259. $headers['response'] = wp_remote_retrieve_response_code( $response );
  3260. // WP_HTTP no longer follows redirects for HEAD requests.
  3261. if ( 'HEAD' == $options['method'] && in_array($headers['response'], array(301, 302)) && isset( $headers['location'] ) ) {
  3262. return wp_get_http( $headers['location'], $file_path, ++$red );
  3263. }
  3264. if ( false == $file_path )
  3265. return $headers;
  3266. // GET request - write it to the supplied filename
  3267. $out_fp = fopen($file_path, 'w');
  3268. if ( !$out_fp )
  3269. return $headers;
  3270. fwrite( $out_fp, wp_remote_retrieve_body( $response ) );
  3271. fclose($out_fp);
  3272. clearstatcache();
  3273. return $headers;
  3274. }
  3275. /**
  3276. * Whether SSL login should be forced.
  3277. *
  3278. * @since 2.6.0
  3279. * @deprecated 4.4.0 Use force_ssl_admin()
  3280. * @see force_ssl_admin()
  3281. *
  3282. * @param string|bool $force Optional Whether to force SSL login. Default null.
  3283. * @return bool True if forced, false if not forced.
  3284. */
  3285. function force_ssl_login( $force = null ) {
  3286. _deprecated_function( __FUNCTION__, '4.4.0', 'force_ssl_admin()' );
  3287. return force_ssl_admin( $force );
  3288. }
  3289. /**
  3290. * Retrieve path of comment popup template in current or parent template.
  3291. *
  3292. * @since 1.5.0
  3293. * @deprecated 4.5.0
  3294. *
  3295. * @return string Full path to comments popup template file.
  3296. */
  3297. function get_comments_popup_template() {
  3298. _deprecated_function( __FUNCTION__, '4.5.0' );
  3299. return '';
  3300. }
  3301. /**
  3302. * Whether the current URL is within the comments popup window.
  3303. *
  3304. * @since 1.5.0
  3305. * @deprecated 4.5.0
  3306. *
  3307. * @return bool
  3308. */
  3309. function is_comments_popup() {
  3310. _deprecated_function( __FUNCTION__, '4.5.0' );
  3311. return false;
  3312. }
  3313. /**
  3314. * Display the JS popup script to show a comment.
  3315. *
  3316. * @since 0.71
  3317. * @deprecated 4.5.0
  3318. */
  3319. function comments_popup_script() {
  3320. _deprecated_function( __FUNCTION__, '4.5.0' );
  3321. }
  3322. /**
  3323. * Adds element attributes to open links in new windows.
  3324. *
  3325. * @since 0.71
  3326. * @deprecated 4.5.0
  3327. *
  3328. * @param string $text Content to replace links to open in a new window.
  3329. * @return string Content that has filtered links.
  3330. */
  3331. function popuplinks( $text ) {
  3332. _deprecated_function( __FUNCTION__, '4.5.0' );
  3333. $text = preg_replace('/<a (.+?)>/i', "<a $1 target='_blank' rel='external'>", $text);
  3334. return $text;
  3335. }
  3336. /**
  3337. * The Google Video embed handler callback.
  3338. *
  3339. * Deprecated function that previously assisted in turning Google Video URLs
  3340. * into embeds but that service has since been shut down.
  3341. *
  3342. * @since 2.9.0
  3343. * @deprecated 4.6.0
  3344. *
  3345. * @return string An empty string.
  3346. */
  3347. function wp_embed_handler_googlevideo( $matches, $attr, $url, $rawattr ) {
  3348. _deprecated_function( __FUNCTION__, '4.6.0' );
  3349. return '';
  3350. }
  3351. /**
  3352. * Retrieve path of paged template in current or parent template.
  3353. *
  3354. * @since 1.5.0
  3355. * @deprecated 4.7.0 The paged.php template is no longer part of the theme template hierarchy.
  3356. *
  3357. * @return string Full path to paged template file.
  3358. */
  3359. function get_paged_template() {
  3360. _deprecated_function( __FUNCTION__, '4.7.0' );
  3361. return get_query_template( 'paged' );
  3362. }
  3363. /**
  3364. * Removes the HTML JavaScript entities found in early versions of Netscape 4.
  3365. *
  3366. * Previously, this function was pulled in from the original
  3367. * import of kses and removed a specific vulnerability only
  3368. * existent in early version of Netscape 4. However, this
  3369. * vulnerability never affected any other browsers and can
  3370. * be considered safe for the modern web.
  3371. *
  3372. * The regular expression which sanitized this vulnerability
  3373. * has been removed in consideration of the performance and
  3374. * energy demands it placed, now merely passing through its
  3375. * input to the return.
  3376. *
  3377. * @since 1.0.0
  3378. * @deprecated deprecated since 4.7
  3379. *
  3380. * @param string $string
  3381. * @return string
  3382. */
  3383. function wp_kses_js_entities( $string ) {
  3384. _deprecated_function( __FUNCTION__, '4.7.0' );
  3385. return preg_replace( '%&\s*\{[^}]*(\}\s*;?|$)%', '', $string );
  3386. }
  3387. /**
  3388. * Sort categories by ID.
  3389. *
  3390. * Used by usort() as a callback, should not be used directly. Can actually be
  3391. * used to sort any term object.
  3392. *
  3393. * @since 2.3.0
  3394. * @deprecated 4.7.0 Use wp_list_sort()
  3395. * @access private
  3396. *
  3397. * @param object $a
  3398. * @param object $b
  3399. * @return int
  3400. */
  3401. function _usort_terms_by_ID( $a, $b ) {
  3402. _deprecated_function( __FUNCTION__, '4.7.0', 'wp_list_sort' );
  3403. if ( $a->term_id > $b->term_id )
  3404. return 1;
  3405. elseif ( $a->term_id < $b->term_id )
  3406. return -1;
  3407. else
  3408. return 0;
  3409. }
  3410. /**
  3411. * Sort categories by name.
  3412. *
  3413. * Used by usort() as a callback, should not be used directly. Can actually be
  3414. * used to sort any term object.
  3415. *
  3416. * @since 2.3.0
  3417. * @deprecated 4.7.0 Use wp_list_sort()
  3418. * @access private
  3419. *
  3420. * @param object $a
  3421. * @param object $b
  3422. * @return int
  3423. */
  3424. function _usort_terms_by_name( $a, $b ) {
  3425. _deprecated_function( __FUNCTION__, '4.7.0', 'wp_list_sort' );
  3426. return strcmp( $a->name, $b->name );
  3427. }
  3428. /**
  3429. * Sort menu items by the desired key.
  3430. *
  3431. * @since 3.0.0
  3432. * @deprecated 4.7.0 Use wp_list_sort()
  3433. * @access private
  3434. *
  3435. * @global string $_menu_item_sort_prop
  3436. *
  3437. * @param object $a The first object to compare
  3438. * @param object $b The second object to compare
  3439. * @return int -1, 0, or 1 if $a is considered to be respectively less than, equal to, or greater than $b.
  3440. */
  3441. function _sort_nav_menu_items( $a, $b ) {
  3442. global $_menu_item_sort_prop;
  3443. _deprecated_function( __FUNCTION__, '4.7.0', 'wp_list_sort' );
  3444. if ( empty( $_menu_item_sort_prop ) )
  3445. return 0;
  3446. if ( ! isset( $a->$_menu_item_sort_prop ) || ! isset( $b->$_menu_item_sort_prop ) )
  3447. return 0;
  3448. $_a = (int) $a->$_menu_item_sort_prop;
  3449. $_b = (int) $b->$_menu_item_sort_prop;
  3450. if ( $a->$_menu_item_sort_prop == $b->$_menu_item_sort_prop )
  3451. return 0;
  3452. elseif ( $_a == $a->$_menu_item_sort_prop && $_b == $b->$_menu_item_sort_prop )
  3453. return $_a < $_b ? -1 : 1;
  3454. else
  3455. return strcmp( $a->$_menu_item_sort_prop, $b->$_menu_item_sort_prop );
  3456. }