| [ Index ] |
PHP Cross Reference of WordPress Trunk (Updated Daily) |
[Summary view] [Print] [Text view]
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 /* 12 * Deprecated functions come here to die. 13 */ 14 15 /** 16 * Retrieves all post data for a given post. 17 * 18 * @since 0.71 19 * @deprecated 1.5.1 Use get_post() 20 * @see get_post() 21 * 22 * @param int $postid Post ID. 23 * @return array Post data. 24 */ 25 function get_postdata($postid) { 26 _deprecated_function( __FUNCTION__, '1.5.1', 'get_post()' ); 27 28 $post = get_post($postid); 29 30 $postdata = array ( 31 'ID' => $post->ID, 32 'Author_ID' => $post->post_author, 33 'Date' => $post->post_date, 34 'Content' => $post->post_content, 35 'Excerpt' => $post->post_excerpt, 36 'Title' => $post->post_title, 37 'Category' => $post->post_category, 38 'post_status' => $post->post_status, 39 'comment_status' => $post->comment_status, 40 'ping_status' => $post->ping_status, 41 'post_password' => $post->post_password, 42 'to_ping' => $post->to_ping, 43 'pinged' => $post->pinged, 44 'post_type' => $post->post_type, 45 'post_name' => $post->post_name 46 ); 47 48 return $postdata; 49 } 50 51 /** 52 * Sets up the WordPress Loop. 53 * 54 * Use The Loop instead. 55 * 56 * @link https://developer.wordpress.org/themes/basics/the-loop/ 57 * 58 * @since 1.0.1 59 * @deprecated 1.5.0 60 * 61 * @global WP_Query $wp_query WordPress Query object. 62 */ 63 function start_wp() { 64 global $wp_query; 65 66 _deprecated_function( __FUNCTION__, '1.5.0', __('new WordPress Loop') ); 67 68 // Since the old style loop is being used, advance the query iterator here. 69 $wp_query->next_post(); 70 71 setup_postdata( get_post() ); 72 } 73 74 /** 75 * Returns or prints a category ID. 76 * 77 * @since 0.71 78 * @deprecated 0.71 Use get_the_category() 79 * @see get_the_category() 80 * 81 * @param bool $display Optional. Whether to display the output. Default true. 82 * @return int Category ID. 83 */ 84 function the_category_ID($display = true) { 85 _deprecated_function( __FUNCTION__, '0.71', 'get_the_category()' ); 86 87 // Grab the first cat in the list. 88 $categories = get_the_category(); 89 $cat = $categories[0]->term_id; 90 91 if ( $display ) 92 echo $cat; 93 94 return $cat; 95 } 96 97 /** 98 * Prints a category with optional text before and after. 99 * 100 * @since 0.71 101 * @deprecated 0.71 Use get_the_category_by_ID() 102 * @see get_the_category_by_ID() 103 * 104 * @param string $before Optional. Text to display before the category. Default empty. 105 * @param string $after Optional. Text to display after the category. Default empty. 106 */ 107 function the_category_head( $before = '', $after = '' ) { 108 global $currentcat, $previouscat; 109 110 _deprecated_function( __FUNCTION__, '0.71', 'get_the_category_by_ID()' ); 111 112 // Grab the first cat in the list. 113 $categories = get_the_category(); 114 $currentcat = $categories[0]->category_id; 115 if ( $currentcat != $previouscat ) { 116 echo $before; 117 echo get_the_category_by_ID($currentcat); 118 echo $after; 119 $previouscat = $currentcat; 120 } 121 } 122 123 /** 124 * Prints a link to the previous post. 125 * 126 * @since 1.5.0 127 * @deprecated 2.0.0 Use previous_post_link() 128 * @see previous_post_link() 129 * 130 * @param string $format 131 * @param string $previous 132 * @param string $title 133 * @param string $in_same_cat 134 * @param int $limitprev 135 * @param string $excluded_categories 136 */ 137 function previous_post($format='%', $previous='previous post: ', $title='yes', $in_same_cat='no', $limitprev=1, $excluded_categories='') { 138 139 _deprecated_function( __FUNCTION__, '2.0.0', 'previous_post_link()' ); 140 141 if ( empty($in_same_cat) || 'no' == $in_same_cat ) 142 $in_same_cat = false; 143 else 144 $in_same_cat = true; 145 146 $post = get_previous_post($in_same_cat, $excluded_categories); 147 148 if ( !$post ) 149 return; 150 151 $string = '<a href="'.get_permalink($post->ID).'">'.$previous; 152 if ( 'yes' == $title ) 153 /** This filter is documented in wp-includes/post-template.php */ 154 $string .= apply_filters('the_title', $post->post_title, $post->ID); 155 $string .= '</a>'; 156 $format = str_replace('%', $string, $format); 157 echo $format; 158 } 159 160 /** 161 * Prints link to the next post. 162 * 163 * @since 0.71 164 * @deprecated 2.0.0 Use next_post_link() 165 * @see next_post_link() 166 * 167 * @param string $format 168 * @param string $next 169 * @param string $title 170 * @param string $in_same_cat 171 * @param int $limitnext 172 * @param string $excluded_categories 173 */ 174 function next_post($format='%', $next='next post: ', $title='yes', $in_same_cat='no', $limitnext=1, $excluded_categories='') { 175 _deprecated_function( __FUNCTION__, '2.0.0', 'next_post_link()' ); 176 177 if ( empty($in_same_cat) || 'no' == $in_same_cat ) 178 $in_same_cat = false; 179 else 180 $in_same_cat = true; 181 182 $post = get_next_post($in_same_cat, $excluded_categories); 183 184 if ( !$post ) 185 return; 186 187 $string = '<a href="'.get_permalink($post->ID).'">'.$next; 188 if ( 'yes' == $title ) 189 /** This filter is documented in wp-includes/post-template.php */ 190 $string .= apply_filters('the_title', $post->post_title, $post->ID); 191 $string .= '</a>'; 192 $format = str_replace('%', $string, $format); 193 echo $format; 194 } 195 196 /** 197 * Whether user can create a post. 198 * 199 * @since 1.5.0 200 * @deprecated 2.0.0 Use current_user_can() 201 * @see current_user_can() 202 * 203 * @param int $user_id 204 * @param int $blog_id Not Used 205 * @param int $category_id Not Used 206 * @return bool 207 */ 208 function user_can_create_post($user_id, $blog_id = 1, $category_id = 'None') { 209 _deprecated_function( __FUNCTION__, '2.0.0', 'current_user_can()' ); 210 211 $author_data = get_userdata($user_id); 212 return ($author_data->user_level > 1); 213 } 214 215 /** 216 * Whether user can create a post. 217 * 218 * @since 1.5.0 219 * @deprecated 2.0.0 Use current_user_can() 220 * @see current_user_can() 221 * 222 * @param int $user_id 223 * @param int $blog_id Not Used 224 * @param int $category_id Not Used 225 * @return bool 226 */ 227 function user_can_create_draft($user_id, $blog_id = 1, $category_id = 'None') { 228 _deprecated_function( __FUNCTION__, '2.0.0', 'current_user_can()' ); 229 230 $author_data = get_userdata($user_id); 231 return ($author_data->user_level >= 1); 232 } 233 234 /** 235 * Whether user can edit a post. 236 * 237 * @since 1.5.0 238 * @deprecated 2.0.0 Use current_user_can() 239 * @see current_user_can() 240 * 241 * @param int $user_id 242 * @param int $post_id 243 * @param int $blog_id Not Used 244 * @return bool 245 */ 246 function user_can_edit_post($user_id, $post_id, $blog_id = 1) { 247 _deprecated_function( __FUNCTION__, '2.0.0', 'current_user_can()' ); 248 249 $author_data = get_userdata($user_id); 250 $post = get_post($post_id); 251 $post_author_data = get_userdata($post->post_author); 252 253 if ( (($user_id == $post_author_data->ID) && !($post->post_status == 'publish' && $author_data->user_level < 2)) 254 || ($author_data->user_level > $post_author_data->user_level) 255 || ($author_data->user_level >= 10) ) { 256 return true; 257 } else { 258 return false; 259 } 260 } 261 262 /** 263 * Whether user can delete a post. 264 * 265 * @since 1.5.0 266 * @deprecated 2.0.0 Use current_user_can() 267 * @see current_user_can() 268 * 269 * @param int $user_id 270 * @param int $post_id 271 * @param int $blog_id Not Used 272 * @return bool 273 */ 274 function user_can_delete_post($user_id, $post_id, $blog_id = 1) { 275 _deprecated_function( __FUNCTION__, '2.0.0', 'current_user_can()' ); 276 277 // Right now if one can edit, one can delete. 278 return user_can_edit_post($user_id, $post_id, $blog_id); 279 } 280 281 /** 282 * Whether user can set new posts' dates. 283 * 284 * @since 1.5.0 285 * @deprecated 2.0.0 Use current_user_can() 286 * @see current_user_can() 287 * 288 * @param int $user_id 289 * @param int $blog_id Not Used 290 * @param int $category_id Not Used 291 * @return bool 292 */ 293 function user_can_set_post_date($user_id, $blog_id = 1, $category_id = 'None') { 294 _deprecated_function( __FUNCTION__, '2.0.0', 'current_user_can()' ); 295 296 $author_data = get_userdata($user_id); 297 return (($author_data->user_level > 4) && user_can_create_post($user_id, $blog_id, $category_id)); 298 } 299 300 /** 301 * Whether user can delete a post. 302 * 303 * @since 1.5.0 304 * @deprecated 2.0.0 Use current_user_can() 305 * @see current_user_can() 306 * 307 * @param int $user_id 308 * @param int $post_id 309 * @param int $blog_id Not Used 310 * @return bool returns true if $user_id can edit $post_id's date 311 */ 312 function user_can_edit_post_date($user_id, $post_id, $blog_id = 1) { 313 _deprecated_function( __FUNCTION__, '2.0.0', 'current_user_can()' ); 314 315 $author_data = get_userdata($user_id); 316 return (($author_data->user_level > 4) && user_can_edit_post($user_id, $post_id, $blog_id)); 317 } 318 319 /** 320 * Whether user can delete a post. 321 * 322 * @since 1.5.0 323 * @deprecated 2.0.0 Use current_user_can() 324 * @see current_user_can() 325 * 326 * @param int $user_id 327 * @param int $post_id 328 * @param int $blog_id Not Used 329 * @return bool returns true if $user_id can edit $post_id's comments 330 */ 331 function user_can_edit_post_comments($user_id, $post_id, $blog_id = 1) { 332 _deprecated_function( __FUNCTION__, '2.0.0', 'current_user_can()' ); 333 334 // Right now if one can edit a post, one can edit comments made on it. 335 return user_can_edit_post($user_id, $post_id, $blog_id); 336 } 337 338 /** 339 * Whether user can delete a post. 340 * 341 * @since 1.5.0 342 * @deprecated 2.0.0 Use current_user_can() 343 * @see current_user_can() 344 * 345 * @param int $user_id 346 * @param int $post_id 347 * @param int $blog_id Not Used 348 * @return bool returns true if $user_id can delete $post_id's comments 349 */ 350 function user_can_delete_post_comments($user_id, $post_id, $blog_id = 1) { 351 _deprecated_function( __FUNCTION__, '2.0.0', 'current_user_can()' ); 352 353 // Right now if one can edit comments, one can delete comments. 354 return user_can_edit_post_comments($user_id, $post_id, $blog_id); 355 } 356 357 /** 358 * Can user can edit other user. 359 * 360 * @since 1.5.0 361 * @deprecated 2.0.0 Use current_user_can() 362 * @see current_user_can() 363 * 364 * @param int $user_id 365 * @param int $other_user 366 * @return bool 367 */ 368 function user_can_edit_user($user_id, $other_user) { 369 _deprecated_function( __FUNCTION__, '2.0.0', 'current_user_can()' ); 370 371 $user = get_userdata($user_id); 372 $other = get_userdata($other_user); 373 if ( $user->user_level > $other->user_level || $user->user_level > 8 || $user->ID == $other->ID ) 374 return true; 375 else 376 return false; 377 } 378 379 /** 380 * Gets the links associated with category $cat_name. 381 * 382 * @since 0.71 383 * @deprecated 2.1.0 Use get_bookmarks() 384 * @see get_bookmarks() 385 * 386 * @param string $cat_name Optional. The category name to use. If no match is found, uses all. 387 * Default 'noname'. 388 * @param string $before Optional. The HTML to output before the link. Default empty. 389 * @param string $after Optional. The HTML to output after the link. Default '<br />'. 390 * @param string $between Optional. The HTML to output between the link/image and its description. 391 * Not used if no image or $show_images is true. Default ' '. 392 * @param bool $show_images Optional. Whether to show images (if defined). Default true. 393 * @param string $orderby Optional. The order to output the links. E.g. 'id', 'name', 'url', 394 * 'description', 'rating', or 'owner'. Default 'id'. 395 * If you start the name with an underscore, the order will be reversed. 396 * Specifying 'rand' as the order will return links in a random order. 397 * @param bool $show_description Optional. Whether to show the description if show_images=false/not defined. 398 * Default true. 399 * @param bool $show_rating Optional. Show rating stars/chars. Default false. 400 * @param int $limit Optional. Limit to X entries. If not specified, all entries are shown. 401 * Default -1. 402 * @param int $show_updated Optional. Whether to show last updated timestamp. Default 0. 403 */ 404 function get_linksbyname($cat_name = "noname", $before = '', $after = '<br />', $between = " ", $show_images = true, $orderby = 'id', 405 $show_description = true, $show_rating = false, 406 $limit = -1, $show_updated = 0) { 407 _deprecated_function( __FUNCTION__, '2.1.0', 'get_bookmarks()' ); 408 409 $cat_id = -1; 410 $cat = get_term_by('name', $cat_name, 'link_category'); 411 if ( $cat ) 412 $cat_id = $cat->term_id; 413 414 get_links($cat_id, $before, $after, $between, $show_images, $orderby, $show_description, $show_rating, $limit, $show_updated); 415 } 416 417 /** 418 * Gets the links associated with the named category. 419 * 420 * @since 1.0.1 421 * @deprecated 2.1.0 Use wp_list_bookmarks() 422 * @see wp_list_bookmarks() 423 * 424 * @param string $category The category to use. 425 * @param string $args 426 * @return string|null 427 */ 428 function wp_get_linksbyname($category, $args = '') { 429 _deprecated_function(__FUNCTION__, '2.1.0', 'wp_list_bookmarks()'); 430 431 $defaults = array( 432 'after' => '<br />', 433 'before' => '', 434 'categorize' => 0, 435 'category_after' => '', 436 'category_before' => '', 437 'category_name' => $category, 438 'show_description' => 1, 439 'title_li' => '', 440 ); 441 442 $parsed_args = wp_parse_args( $args, $defaults ); 443 444 return wp_list_bookmarks($parsed_args); 445 } 446 447 /** 448 * Gets an array of link objects associated with category $cat_name. 449 * 450 * $links = get_linkobjectsbyname( 'fred' ); 451 * foreach ( $links as $link ) { 452 * echo '<li>' . $link->link_name . '</li>'; 453 * } 454 * 455 * @since 1.0.1 456 * @deprecated 2.1.0 Use get_bookmarks() 457 * @see get_bookmarks() 458 * 459 * @param string $cat_name Optional. The category name to use. If no match is found, uses all. 460 * Default 'noname'. 461 * @param string $orderby Optional. The order to output the links. E.g. 'id', 'name', 'url', 462 * 'description', 'rating', or 'owner'. Default 'name'. 463 * If you start the name with an underscore, the order will be reversed. 464 * Specifying 'rand' as the order will return links in a random order. 465 * @param int $limit Optional. Limit to X entries. If not specified, all entries are shown. 466 * Default -1. 467 * @return array 468 */ 469 function get_linkobjectsbyname($cat_name = "noname" , $orderby = 'name', $limit = -1) { 470 _deprecated_function( __FUNCTION__, '2.1.0', 'get_bookmarks()' ); 471 472 $cat_id = -1; 473 $cat = get_term_by('name', $cat_name, 'link_category'); 474 if ( $cat ) 475 $cat_id = $cat->term_id; 476 477 return get_linkobjects($cat_id, $orderby, $limit); 478 } 479 480 /** 481 * Gets an array of link objects associated with category n. 482 * 483 * Usage: 484 * 485 * $links = get_linkobjects(1); 486 * if ($links) { 487 * foreach ($links as $link) { 488 * echo '<li>'.$link->link_name.'<br />'.$link->link_description.'</li>'; 489 * } 490 * } 491 * 492 * Fields are: 493 * 494 * - link_id 495 * - link_url 496 * - link_name 497 * - link_image 498 * - link_target 499 * - link_category 500 * - link_description 501 * - link_visible 502 * - link_owner 503 * - link_rating 504 * - link_updated 505 * - link_rel 506 * - link_notes 507 * 508 * @since 1.0.1 509 * @deprecated 2.1.0 Use get_bookmarks() 510 * @see get_bookmarks() 511 * 512 * @param int $category Optional. The category to use. If no category supplied, uses all. 513 * Default 0. 514 * @param string $orderby Optional. The order to output the links. E.g. 'id', 'name', 'url', 515 * 'description', 'rating', or 'owner'. Default 'name'. 516 * If you start the name with an underscore, the order will be reversed. 517 * Specifying 'rand' as the order will return links in a random order. 518 * @param int $limit Optional. Limit to X entries. If not specified, all entries are shown. 519 * Default 0. 520 * @return array 521 */ 522 function get_linkobjects($category = 0, $orderby = 'name', $limit = 0) { 523 _deprecated_function( __FUNCTION__, '2.1.0', 'get_bookmarks()' ); 524 525 $links = get_bookmarks( array( 'category' => $category, 'orderby' => $orderby, 'limit' => $limit ) ) ; 526 527 $links_array = array(); 528 foreach ($links as $link) 529 $links_array[] = $link; 530 531 return $links_array; 532 } 533 534 /** 535 * Gets the links associated with category 'cat_name' and display rating stars/chars. 536 * 537 * @since 0.71 538 * @deprecated 2.1.0 Use get_bookmarks() 539 * @see get_bookmarks() 540 * 541 * @param string $cat_name Optional. The category name to use. If no match is found, uses all. 542 * Default 'noname'. 543 * @param string $before Optional. The HTML to output before the link. Default empty. 544 * @param string $after Optional. The HTML to output after the link. Default '<br />'. 545 * @param string $between Optional. The HTML to output between the link/image and its description. 546 * Not used if no image or $show_images is true. Default ' '. 547 * @param bool $show_images Optional. Whether to show images (if defined). Default true. 548 * @param string $orderby Optional. The order to output the links. E.g. 'id', 'name', 'url', 549 * 'description', 'rating', or 'owner'. Default 'id'. 550 * If you start the name with an underscore, the order will be reversed. 551 * Specifying 'rand' as the order will return links in a random order. 552 * @param bool $show_description Optional. Whether to show the description if show_images=false/not defined. 553 * Default true. 554 * @param int $limit Optional. Limit to X entries. If not specified, all entries are shown. 555 * Default -1. 556 * @param int $show_updated Optional. Whether to show last updated timestamp. Default 0. 557 */ 558 function get_linksbyname_withrating($cat_name = "noname", $before = '', $after = '<br />', $between = " ", 559 $show_images = true, $orderby = 'id', $show_description = true, $limit = -1, $show_updated = 0) { 560 _deprecated_function( __FUNCTION__, '2.1.0', 'get_bookmarks()' ); 561 562 get_linksbyname($cat_name, $before, $after, $between, $show_images, $orderby, $show_description, true, $limit, $show_updated); 563 } 564 565 /** 566 * Gets the links associated with category n and display rating stars/chars. 567 * 568 * @since 0.71 569 * @deprecated 2.1.0 Use get_bookmarks() 570 * @see get_bookmarks() 571 * 572 * @param int $category Optional. The category to use. If no category supplied, uses all. 573 * Default 0. 574 * @param string $before Optional. The HTML to output before the link. Default empty. 575 * @param string $after Optional. The HTML to output after the link. Default '<br />'. 576 * @param string $between Optional. The HTML to output between the link/image and its description. 577 * Not used if no image or $show_images is true. Default ' '. 578 * @param bool $show_images Optional. Whether to show images (if defined). Default true. 579 * @param string $orderby Optional. The order to output the links. E.g. 'id', 'name', 'url', 580 * 'description', 'rating', or 'owner'. Default 'id'. 581 * If you start the name with an underscore, the order will be reversed. 582 * Specifying 'rand' as the order will return links in a random order. 583 * @param bool $show_description Optional. Whether to show the description if show_images=false/not defined. 584 * Default true. 585 * @param int $limit Optional. Limit to X entries. If not specified, all entries are shown. 586 * Default -1. 587 * @param int $show_updated Optional. Whether to show last updated timestamp. Default 0. 588 */ 589 function get_links_withrating($category = -1, $before = '', $after = '<br />', $between = " ", $show_images = true, 590 $orderby = 'id', $show_description = true, $limit = -1, $show_updated = 0) { 591 _deprecated_function( __FUNCTION__, '2.1.0', 'get_bookmarks()' ); 592 593 get_links($category, $before, $after, $between, $show_images, $orderby, $show_description, true, $limit, $show_updated); 594 } 595 596 /** 597 * Gets the auto_toggle setting. 598 * 599 * @since 0.71 600 * @deprecated 2.1.0 601 * 602 * @param int $id The category to get. If no category supplied uses 0 603 * @return int Only returns 0. 604 */ 605 function get_autotoggle($id = 0) { 606 _deprecated_function( __FUNCTION__, '2.1.0' ); 607 return 0; 608 } 609 610 /** 611 * Lists categories. 612 * 613 * @since 0.71 614 * @deprecated 2.1.0 Use wp_list_categories() 615 * @see wp_list_categories() 616 * 617 * @param int $optionall 618 * @param string $all 619 * @param string $sort_column 620 * @param string $sort_order 621 * @param string $file 622 * @param bool $list 623 * @param int $optiondates 624 * @param int $optioncount 625 * @param int $hide_empty 626 * @param int $use_desc_for_title 627 * @param bool $children 628 * @param int $child_of 629 * @param int $categories 630 * @param int $recurse 631 * @param string $feed 632 * @param string $feed_image 633 * @param string $exclude 634 * @param bool $hierarchical 635 * @return null|false 636 */ 637 function list_cats($optionall = 1, $all = 'All', $sort_column = 'ID', $sort_order = 'asc', $file = '', $list = true, $optiondates = 0, 638 $optioncount = 0, $hide_empty = 1, $use_desc_for_title = 1, $children=false, $child_of=0, $categories=0, 639 $recurse=0, $feed = '', $feed_image = '', $exclude = '', $hierarchical=false) { 640 _deprecated_function( __FUNCTION__, '2.1.0', 'wp_list_categories()' ); 641 642 $query = compact('optionall', 'all', 'sort_column', 'sort_order', 'file', 'list', 'optiondates', 'optioncount', 'hide_empty', 'use_desc_for_title', 'children', 643 'child_of', 'categories', 'recurse', 'feed', 'feed_image', 'exclude', 'hierarchical'); 644 return wp_list_cats($query); 645 } 646 647 /** 648 * Lists categories. 649 * 650 * @since 1.2.0 651 * @deprecated 2.1.0 Use wp_list_categories() 652 * @see wp_list_categories() 653 * 654 * @param string|array $args 655 * @return null|string|false 656 */ 657 function wp_list_cats($args = '') { 658 _deprecated_function( __FUNCTION__, '2.1.0', 'wp_list_categories()' ); 659 660 $parsed_args = wp_parse_args( $args ); 661 662 // Map to new names. 663 if ( isset($parsed_args['optionall']) && isset($parsed_args['all'])) 664 $parsed_args['show_option_all'] = $parsed_args['all']; 665 if ( isset($parsed_args['sort_column']) ) 666 $parsed_args['orderby'] = $parsed_args['sort_column']; 667 if ( isset($parsed_args['sort_order']) ) 668 $parsed_args['order'] = $parsed_args['sort_order']; 669 if ( isset($parsed_args['optiondates']) ) 670 $parsed_args['show_last_update'] = $parsed_args['optiondates']; 671 if ( isset($parsed_args['optioncount']) ) 672 $parsed_args['show_count'] = $parsed_args['optioncount']; 673 if ( isset($parsed_args['list']) ) 674 $parsed_args['style'] = $parsed_args['list'] ? 'list' : 'break'; 675 $parsed_args['title_li'] = ''; 676 677 return wp_list_categories($parsed_args); 678 } 679 680 /** 681 * Deprecated method for generating a drop-down of categories. 682 * 683 * @since 0.71 684 * @deprecated 2.1.0 Use wp_dropdown_categories() 685 * @see wp_dropdown_categories() 686 * 687 * @param int $optionall 688 * @param string $all 689 * @param string $orderby 690 * @param string $order 691 * @param int $show_last_update 692 * @param int $show_count 693 * @param int $hide_empty 694 * @param bool $optionnone 695 * @param int $selected 696 * @param int $exclude 697 * @return string 698 */ 699 function dropdown_cats($optionall = 1, $all = 'All', $orderby = 'ID', $order = 'asc', 700 $show_last_update = 0, $show_count = 0, $hide_empty = 1, $optionnone = false, 701 $selected = 0, $exclude = 0) { 702 _deprecated_function( __FUNCTION__, '2.1.0', 'wp_dropdown_categories()' ); 703 704 $show_option_all = ''; 705 if ( $optionall ) 706 $show_option_all = $all; 707 708 $show_option_none = ''; 709 if ( $optionnone ) 710 $show_option_none = _x( 'None', 'Categories dropdown (show_option_none parameter)' ); 711 712 $vars = compact('show_option_all', 'show_option_none', 'orderby', 'order', 713 'show_last_update', 'show_count', 'hide_empty', 'selected', 'exclude'); 714 $query = add_query_arg($vars, ''); 715 return wp_dropdown_categories($query); 716 } 717 718 /** 719 * Lists authors. 720 * 721 * @since 1.2.0 722 * @deprecated 2.1.0 Use wp_list_authors() 723 * @see wp_list_authors() 724 * 725 * @param bool $optioncount 726 * @param bool $exclude_admin 727 * @param bool $show_fullname 728 * @param bool $hide_empty 729 * @param string $feed 730 * @param string $feed_image 731 * @return null|string 732 */ 733 function list_authors($optioncount = false, $exclude_admin = true, $show_fullname = false, $hide_empty = true, $feed = '', $feed_image = '') { 734 _deprecated_function( __FUNCTION__, '2.1.0', 'wp_list_authors()' ); 735 736 $args = compact('optioncount', 'exclude_admin', 'show_fullname', 'hide_empty', 'feed', 'feed_image'); 737 return wp_list_authors($args); 738 } 739 740 /** 741 * Retrieves a list of post categories. 742 * 743 * @since 1.0.1 744 * @deprecated 2.1.0 Use wp_get_post_categories() 745 * @see wp_get_post_categories() 746 * 747 * @param int $blogid Not Used 748 * @param int $post_id 749 * @return array 750 */ 751 function wp_get_post_cats($blogid = '1', $post_id = 0) { 752 _deprecated_function( __FUNCTION__, '2.1.0', 'wp_get_post_categories()' ); 753 return wp_get_post_categories($post_id); 754 } 755 756 /** 757 * Sets the categories that the post ID belongs to. 758 * 759 * @since 1.0.1 760 * @deprecated 2.1.0 761 * @deprecated Use wp_set_post_categories() 762 * @see wp_set_post_categories() 763 * 764 * @param int $blogid Not used 765 * @param int $post_id 766 * @param array $post_categories 767 * @return bool|mixed 768 */ 769 function wp_set_post_cats($blogid = '1', $post_id = 0, $post_categories = array()) { 770 _deprecated_function( __FUNCTION__, '2.1.0', 'wp_set_post_categories()' ); 771 return wp_set_post_categories($post_id, $post_categories); 772 } 773 774 /** 775 * Retrieves a list of archives. 776 * 777 * @since 0.71 778 * @deprecated 2.1.0 Use wp_get_archives() 779 * @see wp_get_archives() 780 * 781 * @param string $type 782 * @param string $limit 783 * @param string $format 784 * @param string $before 785 * @param string $after 786 * @param bool $show_post_count 787 * @return string|null 788 */ 789 function get_archives($type='', $limit='', $format='html', $before = '', $after = '', $show_post_count = false) { 790 _deprecated_function( __FUNCTION__, '2.1.0', 'wp_get_archives()' ); 791 $args = compact('type', 'limit', 'format', 'before', 'after', 'show_post_count'); 792 return wp_get_archives($args); 793 } 794 795 /** 796 * Returns or Prints link to the author's posts. 797 * 798 * @since 1.2.0 799 * @deprecated 2.1.0 Use get_author_posts_url() 800 * @see get_author_posts_url() 801 * 802 * @param bool $display 803 * @param int $author_id 804 * @param string $author_nicename Optional. 805 * @return string|null 806 */ 807 function get_author_link($display, $author_id, $author_nicename = '') { 808 _deprecated_function( __FUNCTION__, '2.1.0', 'get_author_posts_url()' ); 809 810 $link = get_author_posts_url($author_id, $author_nicename); 811 812 if ( $display ) 813 echo $link; 814 return $link; 815 } 816 817 /** 818 * Print list of pages based on arguments. 819 * 820 * @since 0.71 821 * @deprecated 2.1.0 Use wp_link_pages() 822 * @see wp_link_pages() 823 * 824 * @param string $before 825 * @param string $after 826 * @param string $next_or_number 827 * @param string $nextpagelink 828 * @param string $previouspagelink 829 * @param string $pagelink 830 * @param string $more_file 831 * @return string 832 */ 833 function link_pages($before='<br />', $after='<br />', $next_or_number='number', $nextpagelink='next page', $previouspagelink='previous page', 834 $pagelink='%', $more_file='') { 835 _deprecated_function( __FUNCTION__, '2.1.0', 'wp_link_pages()' ); 836 837 $args = compact('before', 'after', 'next_or_number', 'nextpagelink', 'previouspagelink', 'pagelink', 'more_file'); 838 return wp_link_pages($args); 839 } 840 841 /** 842 * Get value based on option. 843 * 844 * @since 0.71 845 * @deprecated 2.1.0 Use get_option() 846 * @see get_option() 847 * 848 * @param string $option 849 * @return string 850 */ 851 function get_settings($option) { 852 _deprecated_function( __FUNCTION__, '2.1.0', 'get_option()' ); 853 854 return get_option($option); 855 } 856 857 /** 858 * Print the permalink of the current post in the loop. 859 * 860 * @since 0.71 861 * @deprecated 1.2.0 Use the_permalink() 862 * @see the_permalink() 863 */ 864 function permalink_link() { 865 _deprecated_function( __FUNCTION__, '1.2.0', 'the_permalink()' ); 866 the_permalink(); 867 } 868 869 /** 870 * Print the permalink to the RSS feed. 871 * 872 * @since 0.71 873 * @deprecated 2.3.0 Use the_permalink_rss() 874 * @see the_permalink_rss() 875 * 876 * @param string $deprecated 877 */ 878 function permalink_single_rss($deprecated = '') { 879 _deprecated_function( __FUNCTION__, '2.3.0', 'the_permalink_rss()' ); 880 the_permalink_rss(); 881 } 882 883 /** 884 * Gets the links associated with category. 885 * 886 * @since 1.0.1 887 * @deprecated 2.1.0 Use wp_list_bookmarks() 888 * @see wp_list_bookmarks() 889 * 890 * @param string $args a query string 891 * @return null|string 892 */ 893 function wp_get_links($args = '') { 894 _deprecated_function( __FUNCTION__, '2.1.0', 'wp_list_bookmarks()' ); 895 896 if ( ! str_contains( $args, '=' ) ) { 897 $cat_id = $args; 898 $args = add_query_arg( 'category', $cat_id, $args ); 899 } 900 901 $defaults = array( 902 'after' => '<br />', 903 'before' => '', 904 'between' => ' ', 905 'categorize' => 0, 906 'category' => '', 907 'echo' => true, 908 'limit' => -1, 909 'orderby' => 'name', 910 'show_description' => true, 911 'show_images' => true, 912 'show_rating' => false, 913 'show_updated' => true, 914 'title_li' => '', 915 ); 916 917 $parsed_args = wp_parse_args( $args, $defaults ); 918 919 return wp_list_bookmarks($parsed_args); 920 } 921 922 /** 923 * Gets the links associated with category by ID. 924 * 925 * @since 0.71 926 * @deprecated 2.1.0 Use get_bookmarks() 927 * @see get_bookmarks() 928 * 929 * @param int $category Optional. The category to use. If no category supplied uses all. 930 * Default 0. 931 * @param string $before Optional. The HTML to output before the link. Default empty. 932 * @param string $after Optional. The HTML to output after the link. Default '<br />'. 933 * @param string $between Optional. The HTML to output between the link/image and its description. 934 * Not used if no image or $show_images is true. Default ' '. 935 * @param bool $show_images Optional. Whether to show images (if defined). Default true. 936 * @param string $orderby Optional. The order to output the links. E.g. 'id', 'name', 'url', 937 * 'description', 'rating', or 'owner'. Default 'name'. 938 * If you start the name with an underscore, the order will be reversed. 939 * Specifying 'rand' as the order will return links in a random order. 940 * @param bool $show_description Optional. Whether to show the description if show_images=false/not defined. 941 * Default true. 942 * @param bool $show_rating Optional. Show rating stars/chars. Default false. 943 * @param int $limit Optional. Limit to X entries. If not specified, all entries are shown. 944 * Default -1. 945 * @param int $show_updated Optional. Whether to show last updated timestamp. Default 1. 946 * @param bool $display Whether to display the results, or return them instead. 947 * @return null|string 948 */ 949 function get_links($category = -1, $before = '', $after = '<br />', $between = ' ', $show_images = true, $orderby = 'name', 950 $show_description = true, $show_rating = false, $limit = -1, $show_updated = 1, $display = true) { 951 _deprecated_function( __FUNCTION__, '2.1.0', 'get_bookmarks()' ); 952 953 $order = 'ASC'; 954 if ( str_starts_with($orderby, '_') ) { 955 $order = 'DESC'; 956 $orderby = substr($orderby, 1); 957 } 958 959 if ( $category == -1 ) // get_bookmarks() uses '' to signify all categories. 960 $category = ''; 961 962 $results = get_bookmarks(array('category' => $category, 'orderby' => $orderby, 'order' => $order, 'show_updated' => $show_updated, 'limit' => $limit)); 963 964 if ( !$results ) 965 return; 966 967 $output = ''; 968 969 foreach ( (array) $results as $row ) { 970 if ( !isset($row->recently_updated) ) 971 $row->recently_updated = false; 972 $output .= $before; 973 if ( $show_updated && $row->recently_updated ) 974 $output .= get_option('links_recently_updated_prepend'); 975 $the_link = '#'; 976 if ( !empty($row->link_url) ) 977 $the_link = esc_url($row->link_url); 978 $rel = $row->link_rel; 979 if ( '' != $rel ) 980 $rel = ' rel="' . $rel . '"'; 981 982 $desc = esc_attr(sanitize_bookmark_field('link_description', $row->link_description, $row->link_id, 'display')); 983 $name = esc_attr(sanitize_bookmark_field('link_name', $row->link_name, $row->link_id, 'display')); 984 $title = $desc; 985 986 if ( $show_updated ) 987 if ( !str_starts_with($row->link_updated_f, '00') ) 988 $title .= ' ('.__('Last updated') . ' ' . gmdate(get_option('links_updated_date_format'), $row->link_updated_f + (get_option('gmt_offset') * HOUR_IN_SECONDS)) . ')'; 989 990 if ( '' != $title ) 991 $title = ' title="' . $title . '"'; 992 993 $alt = ' alt="' . $name . '"'; 994 995 $target = $row->link_target; 996 if ( '' != $target ) 997 $target = ' target="' . $target . '"'; 998 999 $output .= '<a href="' . $the_link . '"' . $rel . $title . $target. '>'; 1000 1001 if ( '' != $row->link_image && $show_images ) { 1002 if ( str_contains( $row->link_image, 'http' ) ) 1003 $output .= '<img src="' . $row->link_image . '"' . $alt . $title . ' />'; 1004 else // If it's a relative path. 1005 $output .= '<img src="' . get_option('siteurl') . $row->link_image . '"' . $alt . $title . ' />'; 1006 } else { 1007 $output .= $name; 1008 } 1009 1010 $output .= '</a>'; 1011 1012 if ( $show_updated && $row->recently_updated ) 1013 $output .= get_option('links_recently_updated_append'); 1014 1015 if ( $show_description && '' != $desc ) 1016 $output .= $between . $desc; 1017 1018 if ($show_rating) { 1019 $output .= $between . get_linkrating($row); 1020 } 1021 1022 $output .= "$after\n"; 1023 } // End while. 1024 1025 if ( !$display ) 1026 return $output; 1027 echo $output; 1028 } 1029 1030 /** 1031 * Output entire list of links by category. 1032 * 1033 * Output a list of all links, listed by category, using the settings in 1034 * $wpdb->linkcategories and output it as a nested HTML unordered list. 1035 * 1036 * @since 1.0.1 1037 * @deprecated 2.1.0 Use wp_list_bookmarks() 1038 * @see wp_list_bookmarks() 1039 * 1040 * @param string $order Sort link categories by 'name' or 'id' 1041 */ 1042 function get_links_list($order = 'name') { 1043 _deprecated_function( __FUNCTION__, '2.1.0', 'wp_list_bookmarks()' ); 1044 1045 $order = strtolower($order); 1046 1047 // Handle link category sorting. 1048 $direction = 'ASC'; 1049 if ( str_starts_with( $order, '_' ) ) { 1050 $direction = 'DESC'; 1051 $order = substr($order,1); 1052 } 1053 1054 if ( !isset($direction) ) 1055 $direction = ''; 1056 1057 $cats = get_categories(array('type' => 'link', 'orderby' => $order, 'order' => $direction, 'hierarchical' => 0)); 1058 1059 // Display each category. 1060 if ( $cats ) { 1061 foreach ( (array) $cats as $cat ) { 1062 // Handle each category. 1063 1064 // Display the category name. 1065 /** This filter is documented in wp-includes/bookmark-template.php */ 1066 echo ' <li id="linkcat-' . $cat->term_id . '" class="linkcat"><h2>' . apply_filters('link_category', $cat->name ) . "</h2>\n\t<ul>\n"; 1067 // Call get_links() with all the appropriate params. 1068 get_links($cat->term_id, '<li>', "</li>", "\n", true, 'name', false); 1069 1070 // Close the last category. 1071 echo "\n\t</ul>\n</li>\n"; 1072 } 1073 } 1074 } 1075 1076 /** 1077 * Show the link to the links popup and the number of links. 1078 * 1079 * @since 0.71 1080 * @deprecated 2.1.0 1081 * 1082 * @param string $text the text of the link 1083 * @param int $width the width of the popup window 1084 * @param int $height the height of the popup window 1085 * @param string $file the page to open in the popup window 1086 * @param bool $count the number of links in the db 1087 */ 1088 function links_popup_script($text = 'Links', $width=400, $height=400, $file='links.all.php', $count = true) { 1089 _deprecated_function( __FUNCTION__, '2.1.0' ); 1090 } 1091 1092 /** 1093 * Legacy function that retrieved the value of a link's link_rating field. 1094 * 1095 * @since 1.0.1 1096 * @deprecated 2.1.0 Use sanitize_bookmark_field() 1097 * @see sanitize_bookmark_field() 1098 * 1099 * @param object $link Link object. 1100 * @return mixed Value of the 'link_rating' field, false otherwise. 1101 */ 1102 function get_linkrating( $link ) { 1103 _deprecated_function( __FUNCTION__, '2.1.0', 'sanitize_bookmark_field()' ); 1104 return sanitize_bookmark_field('link_rating', $link->link_rating, $link->link_id, 'display'); 1105 } 1106 1107 /** 1108 * Gets the name of category by ID. 1109 * 1110 * @since 0.71 1111 * @deprecated 2.1.0 Use get_category() 1112 * @see get_category() 1113 * 1114 * @param int $id The category to get. If no category supplied uses 0 1115 * @return string 1116 */ 1117 function get_linkcatname($id = 0) { 1118 _deprecated_function( __FUNCTION__, '2.1.0', 'get_category()' ); 1119 1120 $id = (int) $id; 1121 1122 if ( empty($id) ) 1123 return ''; 1124 1125 $cats = wp_get_link_cats($id); 1126 1127 if ( empty($cats) || ! is_array($cats) ) 1128 return ''; 1129 1130 $cat_id = (int) $cats[0]; // Take the first cat. 1131 1132 $cat = get_category($cat_id); 1133 return $cat->name; 1134 } 1135 1136 /** 1137 * Print RSS comment feed link. 1138 * 1139 * @since 1.0.1 1140 * @deprecated 2.5.0 Use post_comments_feed_link() 1141 * @see post_comments_feed_link() 1142 * 1143 * @param string $link_text 1144 */ 1145 function comments_rss_link($link_text = 'Comments RSS') { 1146 _deprecated_function( __FUNCTION__, '2.5.0', 'post_comments_feed_link()' ); 1147 post_comments_feed_link($link_text); 1148 } 1149 1150 /** 1151 * Print/Return link to category RSS2 feed. 1152 * 1153 * @since 1.2.0 1154 * @deprecated 2.5.0 Use get_category_feed_link() 1155 * @see get_category_feed_link() 1156 * 1157 * @param bool $display 1158 * @param int $cat_id 1159 * @return string 1160 */ 1161 function get_category_rss_link($display = false, $cat_id = 1) { 1162 _deprecated_function( __FUNCTION__, '2.5.0', 'get_category_feed_link()' ); 1163 1164 $link = get_category_feed_link($cat_id, 'rss2'); 1165 1166 if ( $display ) 1167 echo $link; 1168 return $link; 1169 } 1170 1171 /** 1172 * Print/Return link to author RSS feed. 1173 * 1174 * @since 1.2.0 1175 * @deprecated 2.5.0 Use get_author_feed_link() 1176 * @see get_author_feed_link() 1177 * 1178 * @param bool $display 1179 * @param int $author_id 1180 * @return string 1181 */ 1182 function get_author_rss_link($display = false, $author_id = 1) { 1183 _deprecated_function( __FUNCTION__, '2.5.0', 'get_author_feed_link()' ); 1184 1185 $link = get_author_feed_link($author_id); 1186 if ( $display ) 1187 echo $link; 1188 return $link; 1189 } 1190 1191 /** 1192 * Return link to the post RSS feed. 1193 * 1194 * @since 1.5.0 1195 * @deprecated 2.2.0 Use get_post_comments_feed_link() 1196 * @see get_post_comments_feed_link() 1197 * 1198 * @return string 1199 */ 1200 function comments_rss() { 1201 _deprecated_function( __FUNCTION__, '2.2.0', 'get_post_comments_feed_link()' ); 1202 return esc_url( get_post_comments_feed_link() ); 1203 } 1204 1205 /** 1206 * An alias of wp_create_user(). 1207 * 1208 * @since 2.0.0 1209 * @deprecated 2.0.0 Use wp_create_user() 1210 * @see wp_create_user() 1211 * 1212 * @param string $username The user's username. 1213 * @param string $password The user's password. 1214 * @param string $email The user's email. 1215 * @return int The new user's ID. 1216 */ 1217 function create_user($username, $password, $email) { 1218 _deprecated_function( __FUNCTION__, '2.0.0', 'wp_create_user()' ); 1219 return wp_create_user($username, $password, $email); 1220 } 1221 1222 /** 1223 * Unused function. 1224 * 1225 * @deprecated 2.5.0 1226 */ 1227 function gzip_compression() { 1228 _deprecated_function( __FUNCTION__, '2.5.0' ); 1229 return false; 1230 } 1231 1232 /** 1233 * Retrieve an array of comment data about comment $comment_id. 1234 * 1235 * @since 0.71 1236 * @deprecated 2.7.0 Use get_comment() 1237 * @see get_comment() 1238 * 1239 * @param int $comment_id The ID of the comment 1240 * @param int $no_cache Whether to use the cache (cast to bool) 1241 * @param bool $include_unapproved Whether to include unapproved comments 1242 * @return array The comment data 1243 */ 1244 function get_commentdata( $comment_id, $no_cache = 0, $include_unapproved = false ) { 1245 _deprecated_function( __FUNCTION__, '2.7.0', 'get_comment()' ); 1246 return get_comment($comment_id, ARRAY_A); 1247 } 1248 1249 /** 1250 * Retrieve the category name by the category ID. 1251 * 1252 * @since 0.71 1253 * @deprecated 2.8.0 Use get_cat_name() 1254 * @see get_cat_name() 1255 * 1256 * @param int $cat_id Category ID 1257 * @return string category name 1258 */ 1259 function get_catname( $cat_id ) { 1260 _deprecated_function( __FUNCTION__, '2.8.0', 'get_cat_name()' ); 1261 return get_cat_name( $cat_id ); 1262 } 1263 1264 /** 1265 * Retrieve category children list separated before and after the term IDs. 1266 * 1267 * @since 1.2.0 1268 * @deprecated 2.8.0 Use get_term_children() 1269 * @see get_term_children() 1270 * 1271 * @param int $id Category ID to retrieve children. 1272 * @param string $before Optional. Prepend before category term ID. Default '/'. 1273 * @param string $after Optional. Append after category term ID. Default empty string. 1274 * @param array $visited Optional. Category Term IDs that have already been added. 1275 * Default empty array. 1276 * @return string 1277 */ 1278 function get_category_children( $id, $before = '/', $after = '', $visited = array() ) { 1279 _deprecated_function( __FUNCTION__, '2.8.0', 'get_term_children()' ); 1280 if ( 0 == $id ) 1281 return ''; 1282 1283 $chain = ''; 1284 /** TODO: Consult hierarchy */ 1285 $cat_ids = get_all_category_ids(); 1286 foreach ( (array) $cat_ids as $cat_id ) { 1287 if ( $cat_id == $id ) 1288 continue; 1289 1290 $category = get_category( $cat_id ); 1291 if ( is_wp_error( $category ) ) 1292 return $category; 1293 if ( $category->parent == $id && !in_array( $category->term_id, $visited ) ) { 1294 $visited[] = $category->term_id; 1295 $chain .= $before.$category->term_id.$after; 1296 $chain .= get_category_children( $category->term_id, $before, $after ); 1297 } 1298 } 1299 return $chain; 1300 } 1301 1302 /** 1303 * Retrieves all category IDs. 1304 * 1305 * @since 2.0.0 1306 * @deprecated 4.0.0 Use get_terms() 1307 * @see get_terms() 1308 * 1309 * @link https://developer.wordpress.org/reference/functions/get_all_category_ids/ 1310 * 1311 * @return int[] List of all of the category IDs. 1312 */ 1313 function get_all_category_ids() { 1314 _deprecated_function( __FUNCTION__, '4.0.0', 'get_terms()' ); 1315 1316 $cat_ids = get_terms( 1317 array( 1318 'taxonomy' => 'category', 1319 'fields' => 'ids', 1320 'get' => 'all', 1321 ) 1322 ); 1323 1324 return $cat_ids; 1325 } 1326 1327 /** 1328 * Retrieve the description of the author of the current post. 1329 * 1330 * @since 1.5.0 1331 * @deprecated 2.8.0 Use get_the_author_meta() 1332 * @see get_the_author_meta() 1333 * 1334 * @return string The author's description. 1335 */ 1336 function get_the_author_description() { 1337 _deprecated_function( __FUNCTION__, '2.8.0', 'get_the_author_meta(\'description\')' ); 1338 return get_the_author_meta('description'); 1339 } 1340 1341 /** 1342 * Display the description of the author of the current post. 1343 * 1344 * @since 1.0.0 1345 * @deprecated 2.8.0 Use the_author_meta() 1346 * @see the_author_meta() 1347 */ 1348 function the_author_description() { 1349 _deprecated_function( __FUNCTION__, '2.8.0', 'the_author_meta(\'description\')' ); 1350 the_author_meta('description'); 1351 } 1352 1353 /** 1354 * Retrieve the login name of the author of the current post. 1355 * 1356 * @since 1.5.0 1357 * @deprecated 2.8.0 Use get_the_author_meta() 1358 * @see get_the_author_meta() 1359 * 1360 * @return string The author's login name (username). 1361 */ 1362 function get_the_author_login() { 1363 _deprecated_function( __FUNCTION__, '2.8.0', 'get_the_author_meta(\'login\')' ); 1364 return get_the_author_meta('login'); 1365 } 1366 1367 /** 1368 * Display the login name of the author of the current post. 1369 * 1370 * @since 0.71 1371 * @deprecated 2.8.0 Use the_author_meta() 1372 * @see the_author_meta() 1373 */ 1374 function the_author_login() { 1375 _deprecated_function( __FUNCTION__, '2.8.0', 'the_author_meta(\'login\')' ); 1376 the_author_meta('login'); 1377 } 1378 1379 /** 1380 * Retrieve the first name of the author of the current post. 1381 * 1382 * @since 1.5.0 1383 * @deprecated 2.8.0 Use get_the_author_meta() 1384 * @see get_the_author_meta() 1385 * 1386 * @return string The author's first name. 1387 */ 1388 function get_the_author_firstname() { 1389 _deprecated_function( __FUNCTION__, '2.8.0', 'get_the_author_meta(\'first_name\')' ); 1390 return get_the_author_meta('first_name'); 1391 } 1392 1393 /** 1394 * Display the first name of the author of the current post. 1395 * 1396 * @since 0.71 1397 * @deprecated 2.8.0 Use the_author_meta() 1398 * @see the_author_meta() 1399 */ 1400 function the_author_firstname() { 1401 _deprecated_function( __FUNCTION__, '2.8.0', 'the_author_meta(\'first_name\')' ); 1402 the_author_meta('first_name'); 1403 } 1404 1405 /** 1406 * Retrieve the last name of the author of the current post. 1407 * 1408 * @since 1.5.0 1409 * @deprecated 2.8.0 Use get_the_author_meta() 1410 * @see get_the_author_meta() 1411 * 1412 * @return string The author's last name. 1413 */ 1414 function get_the_author_lastname() { 1415 _deprecated_function( __FUNCTION__, '2.8.0', 'get_the_author_meta(\'last_name\')' ); 1416 return get_the_author_meta('last_name'); 1417 } 1418 1419 /** 1420 * Display the last name of the author of the current post. 1421 * 1422 * @since 0.71 1423 * @deprecated 2.8.0 Use the_author_meta() 1424 * @see the_author_meta() 1425 */ 1426 function the_author_lastname() { 1427 _deprecated_function( __FUNCTION__, '2.8.0', 'the_author_meta(\'last_name\')' ); 1428 the_author_meta('last_name'); 1429 } 1430 1431 /** 1432 * Retrieve the nickname of the author of the current post. 1433 * 1434 * @since 1.5.0 1435 * @deprecated 2.8.0 Use get_the_author_meta() 1436 * @see get_the_author_meta() 1437 * 1438 * @return string The author's nickname. 1439 */ 1440 function get_the_author_nickname() { 1441 _deprecated_function( __FUNCTION__, '2.8.0', 'get_the_author_meta(\'nickname\')' ); 1442 return get_the_author_meta('nickname'); 1443 } 1444 1445 /** 1446 * Display the nickname of the author of the current post. 1447 * 1448 * @since 0.71 1449 * @deprecated 2.8.0 Use the_author_meta() 1450 * @see the_author_meta() 1451 */ 1452 function the_author_nickname() { 1453 _deprecated_function( __FUNCTION__, '2.8.0', 'the_author_meta(\'nickname\')' ); 1454 the_author_meta('nickname'); 1455 } 1456 1457 /** 1458 * Retrieve the email of the author of the current post. 1459 * 1460 * @since 1.5.0 1461 * @deprecated 2.8.0 Use get_the_author_meta() 1462 * @see get_the_author_meta() 1463 * 1464 * @return string The author's username. 1465 */ 1466 function get_the_author_email() { 1467 _deprecated_function( __FUNCTION__, '2.8.0', 'get_the_author_meta(\'email\')' ); 1468 return get_the_author_meta('email'); 1469 } 1470 1471 /** 1472 * Display the email of the author of the current post. 1473 * 1474 * @since 0.71 1475 * @deprecated 2.8.0 Use the_author_meta() 1476 * @see the_author_meta() 1477 */ 1478 function the_author_email() { 1479 _deprecated_function( __FUNCTION__, '2.8.0', 'the_author_meta(\'email\')' ); 1480 the_author_meta('email'); 1481 } 1482 1483 /** 1484 * Retrieve the ICQ number of the author of the current post. 1485 * 1486 * @since 1.5.0 1487 * @deprecated 2.8.0 Use get_the_author_meta() 1488 * @see get_the_author_meta() 1489 * 1490 * @return string The author's ICQ number. 1491 */ 1492 function get_the_author_icq() { 1493 _deprecated_function( __FUNCTION__, '2.8.0', 'get_the_author_meta(\'icq\')' ); 1494 return get_the_author_meta('icq'); 1495 } 1496 1497 /** 1498 * Display the ICQ number of the author of the current post. 1499 * 1500 * @since 0.71 1501 * @deprecated 2.8.0 Use the_author_meta() 1502 * @see the_author_meta() 1503 */ 1504 function the_author_icq() { 1505 _deprecated_function( __FUNCTION__, '2.8.0', 'the_author_meta(\'icq\')' ); 1506 the_author_meta('icq'); 1507 } 1508 1509 /** 1510 * Retrieve the Yahoo! IM name of the author of the current post. 1511 * 1512 * @since 1.5.0 1513 * @deprecated 2.8.0 Use get_the_author_meta() 1514 * @see get_the_author_meta() 1515 * 1516 * @return string The author's Yahoo! IM name. 1517 */ 1518 function get_the_author_yim() { 1519 _deprecated_function( __FUNCTION__, '2.8.0', 'get_the_author_meta(\'yim\')' ); 1520 return get_the_author_meta('yim'); 1521 } 1522 1523 /** 1524 * Display the Yahoo! IM name of the author of the current post. 1525 * 1526 * @since 0.71 1527 * @deprecated 2.8.0 Use the_author_meta() 1528 * @see the_author_meta() 1529 */ 1530 function the_author_yim() { 1531 _deprecated_function( __FUNCTION__, '2.8.0', 'the_author_meta(\'yim\')' ); 1532 the_author_meta('yim'); 1533 } 1534 1535 /** 1536 * Retrieve the MSN address of the author of the current post. 1537 * 1538 * @since 1.5.0 1539 * @deprecated 2.8.0 Use get_the_author_meta() 1540 * @see get_the_author_meta() 1541 * 1542 * @return string The author's MSN address. 1543 */ 1544 function get_the_author_msn() { 1545 _deprecated_function( __FUNCTION__, '2.8.0', 'get_the_author_meta(\'msn\')' ); 1546 return get_the_author_meta('msn'); 1547 } 1548 1549 /** 1550 * Display the MSN address of the author of the current post. 1551 * 1552 * @since 0.71 1553 * @deprecated 2.8.0 Use the_author_meta() 1554 * @see the_author_meta() 1555 */ 1556 function the_author_msn() { 1557 _deprecated_function( __FUNCTION__, '2.8.0', 'the_author_meta(\'msn\')' ); 1558 the_author_meta('msn'); 1559 } 1560 1561 /** 1562 * Retrieve the AIM address of the author of the current post. 1563 * 1564 * @since 1.5.0 1565 * @deprecated 2.8.0 Use get_the_author_meta() 1566 * @see get_the_author_meta() 1567 * 1568 * @return string The author's AIM address. 1569 */ 1570 function get_the_author_aim() { 1571 _deprecated_function( __FUNCTION__, '2.8.0', 'get_the_author_meta(\'aim\')' ); 1572 return get_the_author_meta('aim'); 1573 } 1574 1575 /** 1576 * Display the AIM address of the author of the current post. 1577 * 1578 * @since 0.71 1579 * @deprecated 2.8.0 Use the_author_meta('aim') 1580 * @see the_author_meta() 1581 */ 1582 function the_author_aim() { 1583 _deprecated_function( __FUNCTION__, '2.8.0', 'the_author_meta(\'aim\')' ); 1584 the_author_meta('aim'); 1585 } 1586 1587 /** 1588 * Retrieve the specified author's preferred display name. 1589 * 1590 * @since 1.0.0 1591 * @deprecated 2.8.0 Use get_the_author_meta() 1592 * @see get_the_author_meta() 1593 * 1594 * @param int $auth_id The ID of the author. 1595 * @return string The author's display name. 1596 */ 1597 function get_author_name( $auth_id = false ) { 1598 _deprecated_function( __FUNCTION__, '2.8.0', 'get_the_author_meta(\'display_name\')' ); 1599 return get_the_author_meta('display_name', $auth_id); 1600 } 1601 1602 /** 1603 * Retrieve the URL to the home page of the author of the current post. 1604 * 1605 * @since 1.5.0 1606 * @deprecated 2.8.0 Use get_the_author_meta() 1607 * @see get_the_author_meta() 1608 * 1609 * @return string The URL to the author's page. 1610 */ 1611 function get_the_author_url() { 1612 _deprecated_function( __FUNCTION__, '2.8.0', 'get_the_author_meta(\'url\')' ); 1613 return get_the_author_meta('url'); 1614 } 1615 1616 /** 1617 * Display the URL to the home page of the author of the current post. 1618 * 1619 * @since 0.71 1620 * @deprecated 2.8.0 Use the_author_meta() 1621 * @see the_author_meta() 1622 */ 1623 function the_author_url() { 1624 _deprecated_function( __FUNCTION__, '2.8.0', 'the_author_meta(\'url\')' ); 1625 the_author_meta('url'); 1626 } 1627 1628 /** 1629 * Retrieve the ID of the author of the current post. 1630 * 1631 * @since 1.5.0 1632 * @deprecated 2.8.0 Use get_the_author_meta() 1633 * @see get_the_author_meta() 1634 * 1635 * @return string|int The author's ID. 1636 */ 1637 function get_the_author_ID() { 1638 _deprecated_function( __FUNCTION__, '2.8.0', 'get_the_author_meta(\'ID\')' ); 1639 return get_the_author_meta('ID'); 1640 } 1641 1642 /** 1643 * Display the ID of the author of the current post. 1644 * 1645 * @since 0.71 1646 * @deprecated 2.8.0 Use the_author_meta() 1647 * @see the_author_meta() 1648 */ 1649 function the_author_ID() { 1650 _deprecated_function( __FUNCTION__, '2.8.0', 'the_author_meta(\'ID\')' ); 1651 the_author_meta('ID'); 1652 } 1653 1654 /** 1655 * Display the post content for the feed. 1656 * 1657 * For encoding the HTML or the $encode_html parameter, there are three possible values: 1658 * - '0' will make urls footnotes and use make_url_footnote(). 1659 * - '1' will encode special characters and automatically display all of the content. 1660 * - '2' will strip all HTML tags from the content. 1661 * 1662 * Also note that you cannot set the amount of words and not set the HTML encoding. 1663 * If that is the case, then the HTML encoding will default to 2, which will strip 1664 * all HTML tags. 1665 * 1666 * To restrict the amount of words of the content, you can use the cut parameter. 1667 * If the content is less than the amount, then there won't be any dots added to the end. 1668 * If there is content left over, then dots will be added and the rest of the content 1669 * will be removed. 1670 * 1671 * @since 0.71 1672 * 1673 * @deprecated 2.9.0 Use the_content_feed() 1674 * @see the_content_feed() 1675 * 1676 * @param string $more_link_text Optional. Text to display when more content is available 1677 * but not displayed. Default '(more...)'. 1678 * @param int $stripteaser Optional. Default 0. 1679 * @param string $more_file Optional. 1680 * @param int $cut Optional. Amount of words to keep for the content. 1681 * @param int $encode_html Optional. How to encode the content. 1682 */ 1683 function the_content_rss($more_link_text='(more...)', $stripteaser=0, $more_file='', $cut = 0, $encode_html = 0) { 1684 _deprecated_function( __FUNCTION__, '2.9.0', 'the_content_feed()' ); 1685 $content = get_the_content($more_link_text, $stripteaser); 1686 1687 /** 1688 * Filters the post content in the context of an RSS feed. 1689 * 1690 * @since 0.71 1691 * 1692 * @param string $content Content of the current post. 1693 */ 1694 $content = apply_filters('the_content_rss', $content); 1695 if ( $cut && !$encode_html ) 1696 $encode_html = 2; 1697 if ( 1== $encode_html ) { 1698 $content = esc_html($content); 1699 $cut = 0; 1700 } elseif ( 0 == $encode_html ) { 1701 $content = make_url_footnote($content); 1702 } elseif ( 2 == $encode_html ) { 1703 $content = strip_tags($content); 1704 } 1705 if ( $cut ) { 1706 $blah = explode(' ', $content); 1707 if ( count($blah) > $cut ) { 1708 $k = $cut; 1709 $use_dotdotdot = 1; 1710 } else { 1711 $k = count($blah); 1712 $use_dotdotdot = 0; 1713 } 1714 1715 /** @todo Check performance, might be faster to use array slice instead. */ 1716 for ( $i=0; $i<$k; $i++ ) 1717 $excerpt .= $blah[$i].' '; 1718 $excerpt .= ($use_dotdotdot) ? '...' : ''; 1719 $content = $excerpt; 1720 } 1721 $content = str_replace(']]>', ']]>', $content); 1722 echo $content; 1723 } 1724 1725 /** 1726 * Strip HTML and put links at the bottom of stripped content. 1727 * 1728 * Searches for all of the links, strips them out of the content, and places 1729 * them at the bottom of the content with numbers. 1730 * 1731 * @since 0.71 1732 * @deprecated 2.9.0 1733 * 1734 * @param string $content Content to get links. 1735 * @return string HTML stripped out of content with links at the bottom. 1736 */ 1737 function make_url_footnote( $content ) { 1738 _deprecated_function( __FUNCTION__, '2.9.0', '' ); 1739 preg_match_all( '/<a(.+?)href=\"(.+?)\"(.*?)>(.+?)<\/a>/', $content, $matches ); 1740 $links_summary = "\n"; 1741 for ( $i = 0, $c = count( $matches[0] ); $i < $c; $i++ ) { 1742 $link_match = $matches[0][$i]; 1743 $link_number = '['.($i+1).']'; 1744 $link_url = $matches[2][$i]; 1745 $link_text = $matches[4][$i]; 1746 $content = str_replace( $link_match, $link_text . ' ' . $link_number, $content ); 1747 $link_url = ( ( strtolower( substr( $link_url, 0, 7 ) ) !== 'http://' ) && ( strtolower( substr( $link_url, 0, 8 ) ) !== 'https://' ) ) ? get_option( 'home' ) . $link_url : $link_url; 1748 $links_summary .= "\n" . $link_number . ' ' . $link_url; 1749 } 1750 $content = strip_tags( $content ); 1751 $content .= $links_summary; 1752 return $content; 1753 } 1754 1755 /** 1756 * Retrieve translated string with vertical bar context 1757 * 1758 * Quite a few times, there will be collisions with similar translatable text 1759 * found in more than two places but with different translated context. 1760 * 1761 * In order to use the separate contexts, the _c() function is used and the 1762 * translatable string uses a pipe ('|') which has the context the string is in. 1763 * 1764 * When the translated string is returned, it is everything before the pipe, not 1765 * including the pipe character. If there is no pipe in the translated text then 1766 * everything is returned. 1767 * 1768 * @since 2.2.0 1769 * @deprecated 2.9.0 Use _x() 1770 * @see _x() 1771 * 1772 * @param string $text Text to translate. 1773 * @param string $domain Optional. Domain to retrieve the translated text. 1774 * @return string Translated context string without pipe. 1775 */ 1776 function _c( $text, $domain = 'default' ) { 1777 _deprecated_function( __FUNCTION__, '2.9.0', '_x()' ); 1778 return before_last_bar( translate( $text, $domain ) ); 1779 } 1780 1781 /** 1782 * Translates $text like translate(), but assumes that the text 1783 * contains a context after its last vertical bar. 1784 * 1785 * @since 2.5.0 1786 * @deprecated 3.0.0 Use _x() 1787 * @see _x() 1788 * 1789 * @param string $text Text to translate. 1790 * @param string $domain Domain to retrieve the translated text. 1791 * @return string Translated text. 1792 */ 1793 function translate_with_context( $text, $domain = 'default' ) { 1794 _deprecated_function( __FUNCTION__, '2.9.0', '_x()' ); 1795 return before_last_bar( translate( $text, $domain ) ); 1796 } 1797 1798 /** 1799 * Legacy version of _n(), which supports contexts. 1800 * 1801 * Strips everything from the translation after the last bar. 1802 * 1803 * @since 2.7.0 1804 * @deprecated 3.0.0 Use _nx() 1805 * @see _nx() 1806 * 1807 * @param string $single The text to be used if the number is singular. 1808 * @param string $plural The text to be used if the number is plural. 1809 * @param int $number The number to compare against to use either the singular or plural form. 1810 * @param string $domain Optional. Text domain. Unique identifier for retrieving translated strings. 1811 * Default 'default'. 1812 * @return string The translated singular or plural form. 1813 */ 1814 function _nc( $single, $plural, $number, $domain = 'default' ) { 1815 _deprecated_function( __FUNCTION__, '2.9.0', '_nx()' ); 1816 return before_last_bar( _n( $single, $plural, $number, $domain ) ); 1817 } 1818 1819 /** 1820 * Retrieve the plural or single form based on the amount. 1821 * 1822 * @since 1.2.0 1823 * @deprecated 2.8.0 Use _n() 1824 * @see _n() 1825 */ 1826 function __ngettext( ...$args ) { 1827 _deprecated_function( __FUNCTION__, '2.8.0', '_n()' ); 1828 return _n( ...$args ); 1829 } 1830 1831 /** 1832 * Register plural strings in POT file, but don't translate them. 1833 * 1834 * @since 2.5.0 1835 * @deprecated 2.8.0 Use _n_noop() 1836 * @see _n_noop() 1837 */ 1838 function __ngettext_noop( ...$args ) { 1839 _deprecated_function( __FUNCTION__, '2.8.0', '_n_noop()' ); 1840 return _n_noop( ...$args ); 1841 1842 } 1843 1844 /** 1845 * Retrieve all autoload options, or all options if no autoloaded ones exist. 1846 * 1847 * @since 1.0.0 1848 * @deprecated 3.0.0 Use wp_load_alloptions()) 1849 * @see wp_load_alloptions() 1850 * 1851 * @return array List of all options. 1852 */ 1853 function get_alloptions() { 1854 _deprecated_function( __FUNCTION__, '3.0.0', 'wp_load_alloptions()' ); 1855 return wp_load_alloptions(); 1856 } 1857 1858 /** 1859 * Retrieve HTML content of attachment image with link. 1860 * 1861 * @since 2.0.0 1862 * @deprecated 2.5.0 Use wp_get_attachment_link() 1863 * @see wp_get_attachment_link() 1864 * 1865 * @param int $id Optional. Post ID. 1866 * @param bool $fullsize Optional. Whether to use full size image. Default false. 1867 * @param array $max_dims Optional. Max image dimensions. 1868 * @param bool $permalink Optional. Whether to include permalink to image. Default false. 1869 * @return string 1870 */ 1871 function get_the_attachment_link($id = 0, $fullsize = false, $max_dims = false, $permalink = false) { 1872 _deprecated_function( __FUNCTION__, '2.5.0', 'wp_get_attachment_link()' ); 1873 $id = (int) $id; 1874 $_post = get_post($id); 1875 1876 if ( ('attachment' != $_post->post_type) || !$url = wp_get_attachment_url($_post->ID) ) 1877 return __('Missing Attachment'); 1878 1879 if ( $permalink ) 1880 $url = get_attachment_link($_post->ID); 1881 1882 $post_title = esc_attr($_post->post_title); 1883 1884 $innerHTML = get_attachment_innerHTML($_post->ID, $fullsize, $max_dims); 1885 return "<a href='$url' title='$post_title'>$innerHTML</a>"; 1886 } 1887 1888 /** 1889 * Retrieve icon URL and Path. 1890 * 1891 * @since 2.1.0 1892 * @deprecated 2.5.0 Use wp_get_attachment_image_src() 1893 * @see wp_get_attachment_image_src() 1894 * 1895 * @param int $id Optional. Post ID. 1896 * @param bool $fullsize Optional. Whether to have full image. Default false. 1897 * @return array Icon URL and full path to file, respectively. 1898 */ 1899 function get_attachment_icon_src( $id = 0, $fullsize = false ) { 1900 _deprecated_function( __FUNCTION__, '2.5.0', 'wp_get_attachment_image_src()' ); 1901 $id = (int) $id; 1902 if ( !$post = get_post($id) ) 1903 return false; 1904 1905 $file = get_attached_file( $post->ID ); 1906 1907 if ( !$fullsize && $src = wp_get_attachment_thumb_url( $post->ID ) ) { 1908 // We have a thumbnail desired, specified and existing. 1909 1910 $src_file = wp_basename($src); 1911 } elseif ( wp_attachment_is_image( $post->ID ) ) { 1912 // We have an image without a thumbnail. 1913 1914 $src = wp_get_attachment_url( $post->ID ); 1915 $src_file = & $file; 1916 } elseif ( $src = wp_mime_type_icon( $post->ID, '.svg' ) ) { 1917 // No thumb, no image. We'll look for a mime-related icon instead. 1918 1919 /** This filter is documented in wp-includes/post.php */ 1920 $icon_dir = apply_filters( 'icon_dir', get_template_directory() . '/images' ); 1921 $src_file = $icon_dir . '/' . wp_basename($src); 1922 } 1923 1924 if ( !isset($src) || !$src ) 1925 return false; 1926 1927 return array($src, $src_file); 1928 } 1929 1930 /** 1931 * Retrieve HTML content of icon attachment image element. 1932 * 1933 * @since 2.0.0 1934 * @deprecated 2.5.0 Use wp_get_attachment_image() 1935 * @see wp_get_attachment_image() 1936 * 1937 * @param int $id Optional. Post ID. 1938 * @param bool $fullsize Optional. Whether to have full size image. Default false. 1939 * @param array $max_dims Optional. Dimensions of image. 1940 * @return string|false HTML content. 1941 */ 1942 function get_attachment_icon( $id = 0, $fullsize = false, $max_dims = false ) { 1943 _deprecated_function( __FUNCTION__, '2.5.0', 'wp_get_attachment_image()' ); 1944 $id = (int) $id; 1945 if ( !$post = get_post($id) ) 1946 return false; 1947 1948 if ( !$src = get_attachment_icon_src( $post->ID, $fullsize ) ) 1949 return false; 1950 1951 list($src, $src_file) = $src; 1952 1953 // Do we need to constrain the image? 1954 if ( ($max_dims = apply_filters('attachment_max_dims', $max_dims)) && file_exists($src_file) ) { 1955 1956 $imagesize = wp_getimagesize($src_file); 1957 1958 if (($imagesize[0] > $max_dims[0]) || $imagesize[1] > $max_dims[1] ) { 1959 $actual_aspect = $imagesize[0] / $imagesize[1]; 1960 $desired_aspect = $max_dims[0] / $max_dims[1]; 1961 1962 if ( $actual_aspect >= $desired_aspect ) { 1963 $height = $actual_aspect * $max_dims[0]; 1964 $constraint = "width='{$max_dims[0]}' "; 1965 $post->iconsize = array($max_dims[0], $height); 1966 } else { 1967 $width = $max_dims[1] / $actual_aspect; 1968 $constraint = "height='{$max_dims[1]}' "; 1969 $post->iconsize = array($width, $max_dims[1]); 1970 } 1971 } else { 1972 $post->iconsize = array($imagesize[0], $imagesize[1]); 1973 $constraint = ''; 1974 } 1975 } else { 1976 $constraint = ''; 1977 } 1978 1979 $post_title = esc_attr($post->post_title); 1980 1981 $icon = "<img src='$src' title='$post_title' alt='$post_title' $constraint/>"; 1982 1983 return apply_filters( 'attachment_icon', $icon, $post->ID ); 1984 } 1985 1986 /** 1987 * Retrieve HTML content of image element. 1988 * 1989 * @since 2.0.0 1990 * @deprecated 2.5.0 Use wp_get_attachment_image() 1991 * @see wp_get_attachment_image() 1992 * 1993 * @param int $id Optional. Post ID. 1994 * @param bool $fullsize Optional. Whether to have full size image. Default false. 1995 * @param array $max_dims Optional. Dimensions of image. 1996 * @return string|false 1997 */ 1998 function get_attachment_innerHTML($id = 0, $fullsize = false, $max_dims = false) { 1999 _deprecated_function( __FUNCTION__, '2.5.0', 'wp_get_attachment_image()' ); 2000 $id = (int) $id; 2001 if ( !$post = get_post($id) ) 2002 return false; 2003 2004 if ( $innerHTML = get_attachment_icon($post->ID, $fullsize, $max_dims)) 2005 return $innerHTML; 2006 2007 $innerHTML = esc_attr($post->post_title); 2008 2009 return apply_filters('attachment_innerHTML', $innerHTML, $post->ID); 2010 } 2011 2012 /** 2013 * Retrieves bookmark data based on ID. 2014 * 2015 * @since 2.0.0 2016 * @deprecated 2.1.0 Use get_bookmark() 2017 * @see get_bookmark() 2018 * 2019 * @param int $bookmark_id ID of link 2020 * @param string $output Optional. Type of output. Accepts OBJECT, ARRAY_N, or ARRAY_A. 2021 * Default OBJECT. 2022 * @param string $filter Optional. How to filter the link for output. Accepts 'raw', 'edit', 2023 * 'attribute', 'js', 'db', or 'display'. Default 'raw'. 2024 * @return object|array|null Bookmark object or array, depending on the type specified by `$output`. 2025 * Null if the bookmark does not exist. 2026 * 2027 * @phpstan-param 'OBJECT'|'ARRAY_A'|'ARRAY_N' $output 2028 * @phpstan-return null|( 2029 * $output is 'ARRAY_A' ? array<string, mixed> : ( 2030 * $output is 'ARRAY_N' ? array<int, mixed> : stdClass 2031 * ) 2032 * ) 2033 */ 2034 function get_link( $bookmark_id, $output = OBJECT, $filter = 'raw' ) { 2035 _deprecated_function( __FUNCTION__, '2.1.0', 'get_bookmark()' ); 2036 return get_bookmark($bookmark_id, $output, $filter); 2037 } 2038 2039 /** 2040 * Checks and cleans a URL. 2041 * 2042 * A number of characters are removed from the URL. If the URL is for displaying 2043 * (the default behavior) ampersands are also replaced. The 'clean_url' filter 2044 * is applied to the returned cleaned URL. 2045 * 2046 * @since 1.2.0 2047 * @deprecated 3.0.0 Use esc_url() 2048 * @see esc_url() 2049 * 2050 * @param string $url The URL to be cleaned. 2051 * @param array $protocols Optional. An array of acceptable protocols. 2052 * @param string $context Optional. How the URL will be used. Default is 'display'. 2053 * @return string The cleaned $url after the {@see 'clean_url'} filter is applied. 2054 */ 2055 function clean_url( $url, $protocols = null, $context = 'display' ) { 2056 if ( $context == 'db' ) 2057 _deprecated_function( 'clean_url( $context = \'db\' )', '3.0.0', 'sanitize_url()' ); 2058 else 2059 _deprecated_function( __FUNCTION__, '3.0.0', 'esc_url()' ); 2060 return esc_url( $url, $protocols, $context ); 2061 } 2062 2063 /** 2064 * Escape single quotes, specialchar double quotes, and fix line endings. 2065 * 2066 * The filter {@see 'js_escape'} is also applied by esc_js(). 2067 * 2068 * @since 2.0.4 2069 * @deprecated 2.8.0 Use esc_js() 2070 * @see esc_js() 2071 * 2072 * @param string $text The text to be escaped. 2073 * @return string Escaped text. 2074 */ 2075 function js_escape( $text ) { 2076 _deprecated_function( __FUNCTION__, '2.8.0', 'esc_js()' ); 2077 return esc_js( $text ); 2078 } 2079 2080 /** 2081 * Legacy escaping for HTML blocks. 2082 * 2083 * @deprecated 2.8.0 Use esc_html() 2084 * @see esc_html() 2085 * 2086 * @param string $text Text to escape. 2087 * @param string $quote_style Unused. 2088 * @param false|string $charset Unused. 2089 * @param false $double_encode Whether to double encode. Unused. 2090 * @return string Escaped `$text`. 2091 */ 2092 function wp_specialchars( $text, $quote_style = ENT_NOQUOTES, $charset = false, $double_encode = false ) { 2093 _deprecated_function( __FUNCTION__, '2.8.0', 'esc_html()' ); 2094 if ( func_num_args() > 1 ) { // Maintain back-compat for people passing additional arguments. 2095 return _wp_specialchars( $text, $quote_style, $charset, $double_encode ); 2096 } else { 2097 return esc_html( $text ); 2098 } 2099 } 2100 2101 /** 2102 * Escaping for HTML attributes. 2103 * 2104 * @since 2.0.6 2105 * @deprecated 2.8.0 Use esc_attr() 2106 * @see esc_attr() 2107 * 2108 * @param string $text 2109 * @return string 2110 */ 2111 function attribute_escape( $text ) { 2112 _deprecated_function( __FUNCTION__, '2.8.0', 'esc_attr()' ); 2113 return esc_attr( $text ); 2114 } 2115 2116 /** 2117 * Register widget for sidebar with backward compatibility. 2118 * 2119 * Allows $name to be an array that accepts either three elements to grab the 2120 * first element and the third for the name or just uses the first element of 2121 * the array for the name. 2122 * 2123 * Passes to wp_register_sidebar_widget() after argument list and backward 2124 * compatibility is complete. 2125 * 2126 * @since 2.2.0 2127 * @deprecated 2.8.0 Use wp_register_sidebar_widget() 2128 * @see wp_register_sidebar_widget() 2129 * 2130 * @param string|int $name Widget ID. 2131 * @param callable $output_callback Run when widget is called. 2132 * @param string $classname Optional. Classname widget option. Default empty. 2133 * @param mixed ...$params Widget parameters. 2134 */ 2135 function register_sidebar_widget($name, $output_callback, $classname = '', ...$params) { 2136 _deprecated_function( __FUNCTION__, '2.8.0', 'wp_register_sidebar_widget()' ); 2137 // Compat. 2138 if ( is_array( $name ) ) { 2139 if ( count( $name ) === 3 ) { 2140 $name = sprintf( $name[0], $name[2] ); 2141 } else { 2142 $name = $name[0]; 2143 } 2144 } 2145 2146 $id = sanitize_title( $name ); 2147 $options = array(); 2148 if ( ! empty( $classname ) && is_string( $classname ) ) { 2149 $options['classname'] = $classname; 2150 } 2151 2152 wp_register_sidebar_widget( $id, $name, $output_callback, $options, ...$params ); 2153 } 2154 2155 /** 2156 * Serves as an alias of wp_unregister_sidebar_widget(). 2157 * 2158 * @since 2.2.0 2159 * @deprecated 2.8.0 Use wp_unregister_sidebar_widget() 2160 * @see wp_unregister_sidebar_widget() 2161 * 2162 * @param int|string $id Widget ID. 2163 */ 2164 function unregister_sidebar_widget($id) { 2165 _deprecated_function( __FUNCTION__, '2.8.0', 'wp_unregister_sidebar_widget()' ); 2166 return wp_unregister_sidebar_widget($id); 2167 } 2168 2169 /** 2170 * Registers widget control callback for customizing options. 2171 * 2172 * Allows $name to be an array that accepts either three elements to grab the 2173 * first element and the third for the name or just uses the first element of 2174 * the array for the name. 2175 * 2176 * Passes to wp_register_widget_control() after the argument list has 2177 * been compiled. 2178 * 2179 * @since 2.2.0 2180 * @deprecated 2.8.0 Use wp_register_widget_control() 2181 * @see wp_register_widget_control() 2182 * 2183 * @param int|string $name Sidebar ID. 2184 * @param callable $control_callback Widget control callback to display and process form. 2185 * @param int $width Widget width. 2186 * @param int $height Widget height. 2187 * @param mixed ...$params Widget parameters. 2188 */ 2189 function register_widget_control($name, $control_callback, $width = '', $height = '', ...$params) { 2190 _deprecated_function( __FUNCTION__, '2.8.0', 'wp_register_widget_control()' ); 2191 // Compat. 2192 if ( is_array( $name ) ) { 2193 if ( count( $name ) === 3 ) { 2194 $name = sprintf( $name[0], $name[2] ); 2195 } else { 2196 $name = $name[0]; 2197 } 2198 } 2199 2200 $id = sanitize_title( $name ); 2201 $options = array(); 2202 if ( ! empty( $width ) ) { 2203 $options['width'] = $width; 2204 } 2205 if ( ! empty( $height ) ) { 2206 $options['height'] = $height; 2207 } 2208 2209 wp_register_widget_control( $id, $name, $control_callback, $options, ...$params ); 2210 } 2211 2212 /** 2213 * Alias of wp_unregister_widget_control(). 2214 * 2215 * @since 2.2.0 2216 * @deprecated 2.8.0 Use wp_unregister_widget_control() 2217 * @see wp_unregister_widget_control() 2218 * 2219 * @param int|string $id Widget ID. 2220 */ 2221 function unregister_widget_control($id) { 2222 _deprecated_function( __FUNCTION__, '2.8.0', 'wp_unregister_widget_control()' ); 2223 return wp_unregister_widget_control($id); 2224 } 2225 2226 /** 2227 * Remove user meta data. 2228 * 2229 * @since 2.0.0 2230 * @deprecated 3.0.0 Use delete_user_meta() 2231 * @see delete_user_meta() 2232 * 2233 * @global wpdb $wpdb WordPress database abstraction object. 2234 * 2235 * @param int $user_id User ID. 2236 * @param string $meta_key Metadata key. 2237 * @param mixed $meta_value Optional. Metadata value. Default empty. 2238 * @return bool True deletion completed and false if user_id is not a number. 2239 */ 2240 function delete_usermeta( $user_id, $meta_key, $meta_value = '' ) { 2241 _deprecated_function( __FUNCTION__, '3.0.0', 'delete_user_meta()' ); 2242 global $wpdb; 2243 if ( !is_numeric( $user_id ) ) 2244 return false; 2245 $meta_key = preg_replace('|[^a-z0-9_]|i', '', $meta_key); 2246 2247 if ( is_array($meta_value) || is_object($meta_value) ) 2248 $meta_value = serialize($meta_value); 2249 $meta_value = trim( $meta_value ); 2250 2251 $cur = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->usermeta WHERE user_id = %d AND meta_key = %s", $user_id, $meta_key) ); 2252 2253 if ( $cur && $cur->umeta_id ) 2254 do_action( 'delete_usermeta', $cur->umeta_id, $user_id, $meta_key, $meta_value ); 2255 2256 if ( ! empty($meta_value) ) 2257 $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) ); 2258 else 2259 $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE user_id = %d AND meta_key = %s", $user_id, $meta_key) ); 2260 2261 clean_user_cache( $user_id ); 2262 wp_cache_delete( $user_id, 'user_meta' ); 2263 2264 if ( $cur && $cur->umeta_id ) 2265 do_action( 'deleted_usermeta', $cur->umeta_id, $user_id, $meta_key, $meta_value ); 2266 2267 return true; 2268 } 2269 2270 /** 2271 * Retrieve user metadata. 2272 * 2273 * If $user_id is not a number, then the function will fail over with a 'false' 2274 * boolean return value. Other returned values depend on whether there is only 2275 * one item to be returned, which be that single item type. If there is more 2276 * than one metadata value, then it will be list of metadata values. 2277 * 2278 * @since 2.0.0 2279 * @deprecated 3.0.0 Use get_user_meta() 2280 * @see get_user_meta() 2281 * 2282 * @global wpdb $wpdb WordPress database abstraction object. 2283 * 2284 * @param int $user_id User ID 2285 * @param string $meta_key Optional. Metadata key. Default empty. 2286 * @return mixed 2287 */ 2288 function get_usermeta( $user_id, $meta_key = '' ) { 2289 _deprecated_function( __FUNCTION__, '3.0.0', 'get_user_meta()' ); 2290 global $wpdb; 2291 $user_id = (int) $user_id; 2292 2293 if ( !$user_id ) 2294 return false; 2295 2296 if ( !empty($meta_key) ) { 2297 $meta_key = preg_replace('|[^a-z0-9_]|i', '', $meta_key); 2298 $user = wp_cache_get($user_id, 'users'); 2299 // Check the cached user object. 2300 if ( false !== $user && isset($user->$meta_key) ) 2301 $metas = array($user->$meta_key); 2302 else 2303 $metas = $wpdb->get_col( $wpdb->prepare("SELECT meta_value FROM $wpdb->usermeta WHERE user_id = %d AND meta_key = %s", $user_id, $meta_key) ); 2304 } else { 2305 $metas = $wpdb->get_col( $wpdb->prepare("SELECT meta_value FROM $wpdb->usermeta WHERE user_id = %d", $user_id) ); 2306 } 2307 2308 if ( empty($metas) ) { 2309 if ( empty($meta_key) ) 2310 return array(); 2311 else 2312 return ''; 2313 } 2314 2315 $metas = array_map('maybe_unserialize', $metas); 2316 2317 if ( count($metas) === 1 ) 2318 return $metas[0]; 2319 else 2320 return $metas; 2321 } 2322 2323 /** 2324 * Update metadata of user. 2325 * 2326 * There is no need to serialize values, they will be serialized if it is 2327 * needed. The metadata key can only be a string with underscores. All else will 2328 * be removed. 2329 * 2330 * Will remove the metadata, if the meta value is empty. 2331 * 2332 * @since 2.0.0 2333 * @deprecated 3.0.0 Use update_user_meta() 2334 * @see update_user_meta() 2335 * 2336 * @global wpdb $wpdb WordPress database abstraction object. 2337 * 2338 * @param int $user_id User ID 2339 * @param string $meta_key Metadata key. 2340 * @param mixed $meta_value Metadata value. 2341 * @return bool True on successful update, false on failure. 2342 */ 2343 function update_usermeta( $user_id, $meta_key, $meta_value ) { 2344 _deprecated_function( __FUNCTION__, '3.0.0', 'update_user_meta()' ); 2345 global $wpdb; 2346 if ( !is_numeric( $user_id ) ) 2347 return false; 2348 $meta_key = preg_replace('|[^a-z0-9_]|i', '', $meta_key); 2349 2350 /** @todo Might need fix because usermeta data is assumed to be already escaped */ 2351 if ( is_string($meta_value) ) 2352 $meta_value = stripslashes($meta_value); 2353 $meta_value = maybe_serialize($meta_value); 2354 2355 if (empty($meta_value)) { 2356 return delete_usermeta($user_id, $meta_key); 2357 } 2358 2359 $cur = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->usermeta WHERE user_id = %d AND meta_key = %s", $user_id, $meta_key) ); 2360 2361 if ( $cur ) 2362 do_action( 'update_usermeta', $cur->umeta_id, $user_id, $meta_key, $meta_value ); 2363 2364 if ( !$cur ) 2365 $wpdb->insert($wpdb->usermeta, compact('user_id', 'meta_key', 'meta_value') ); 2366 elseif ( $cur->meta_value != $meta_value ) 2367 $wpdb->update($wpdb->usermeta, compact('meta_value'), compact('user_id', 'meta_key') ); 2368 else 2369 return false; 2370 2371 clean_user_cache( $user_id ); 2372 wp_cache_delete( $user_id, 'user_meta' ); 2373 2374 if ( !$cur ) 2375 do_action( 'added_usermeta', $wpdb->insert_id, $user_id, $meta_key, $meta_value ); 2376 else 2377 do_action( 'updated_usermeta', $cur->umeta_id, $user_id, $meta_key, $meta_value ); 2378 2379 return true; 2380 } 2381 2382 /** 2383 * Get users for the site. 2384 * 2385 * For setups that use the multisite feature. Can be used outside of the 2386 * multisite feature. 2387 * 2388 * @since 2.2.0 2389 * @deprecated 3.1.0 Use get_users() 2390 * @see get_users() 2391 * 2392 * @global wpdb $wpdb WordPress database abstraction object. 2393 * 2394 * @param int $id Site ID. 2395 * @return array List of users that are part of that site ID 2396 */ 2397 function get_users_of_blog( $id = '' ) { 2398 _deprecated_function( __FUNCTION__, '3.1.0', 'get_users()' ); 2399 2400 global $wpdb; 2401 if ( empty( $id ) ) { 2402 $id = get_current_blog_id(); 2403 } 2404 $blog_prefix = $wpdb->get_blog_prefix($id); 2405 $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" ); 2406 return $users; 2407 } 2408 2409 /** 2410 * Enable/disable automatic general feed link outputting. 2411 * 2412 * @since 2.8.0 2413 * @deprecated 3.0.0 Use add_theme_support() 2414 * @see add_theme_support() 2415 * 2416 * @param bool $add Optional. Add or remove links. Default true. 2417 */ 2418 function automatic_feed_links( $add = true ) { 2419 _deprecated_function( __FUNCTION__, '3.0.0', "add_theme_support( 'automatic-feed-links' )" ); 2420 2421 if ( $add ) 2422 add_theme_support( 'automatic-feed-links' ); 2423 else 2424 remove_action( 'wp_head', 'feed_links_extra', 3 ); // Just do this yourself in 3.0+. 2425 } 2426 2427 /** 2428 * Retrieve user data based on field. 2429 * 2430 * @since 1.5.0 2431 * @deprecated 3.0.0 Use get_the_author_meta() 2432 * @see get_the_author_meta() 2433 * 2434 * @param string $field User meta field. 2435 * @param false|int $user Optional. User ID to retrieve the field for. Default false (current user). 2436 * @return string The author's field from the current author's DB object. 2437 */ 2438 function get_profile( $field, $user = false ) { 2439 _deprecated_function( __FUNCTION__, '3.0.0', 'get_the_author_meta()' ); 2440 if ( $user ) { 2441 $user = get_user_by( 'login', $user ); 2442 $user = $user->ID; 2443 } 2444 return get_the_author_meta( $field, $user ); 2445 } 2446 2447 /** 2448 * Retrieves the number of posts a user has written. 2449 * 2450 * @since 0.71 2451 * @deprecated 3.0.0 Use count_user_posts() 2452 * @see count_user_posts() 2453 * 2454 * @param int $userid User to count posts for. 2455 * @return int Number of posts the given user has written. 2456 */ 2457 function get_usernumposts( $userid ) { 2458 _deprecated_function( __FUNCTION__, '3.0.0', 'count_user_posts()' ); 2459 return count_user_posts( $userid ); 2460 } 2461 2462 /** 2463 * Callback used to change %uXXXX to &#YYY; syntax 2464 * 2465 * @since 2.8.0 2466 * @access private 2467 * @deprecated 3.0.0 2468 * 2469 * @param array $matches Single Match 2470 * @return string An HTML entity 2471 */ 2472 function funky_javascript_callback($matches) { 2473 return "&#".base_convert($matches[1],16,10).";"; 2474 } 2475 2476 /** 2477 * Fixes JavaScript bugs in browsers. 2478 * 2479 * Converts unicode characters to HTML numbered entities. 2480 * 2481 * @since 1.5.0 2482 * @deprecated 3.0.0 2483 * 2484 * @global $is_macIE 2485 * @global $is_winIE 2486 * 2487 * @param string $text Text to be made safe. 2488 * @return string Fixed text. 2489 */ 2490 function funky_javascript_fix($text) { 2491 _deprecated_function( __FUNCTION__, '3.0.0' ); 2492 // Fixes for browsers' JavaScript bugs. 2493 global $is_macIE, $is_winIE; 2494 2495 if ( $is_winIE || $is_macIE ) 2496 $text = preg_replace_callback("/\%u([0-9A-F]{4,4})/", 2497 "funky_javascript_callback", 2498 $text); 2499 2500 return $text; 2501 } 2502 2503 /** 2504 * Checks that the taxonomy name exists. 2505 * 2506 * @since 2.3.0 2507 * @deprecated 3.0.0 Use taxonomy_exists() 2508 * @see taxonomy_exists() 2509 * 2510 * @param string $taxonomy Name of taxonomy object 2511 * @return bool Whether the taxonomy exists. 2512 */ 2513 function is_taxonomy( $taxonomy ) { 2514 _deprecated_function( __FUNCTION__, '3.0.0', 'taxonomy_exists()' ); 2515 return taxonomy_exists( $taxonomy ); 2516 } 2517 2518 /** 2519 * Check if Term exists. 2520 * 2521 * @since 2.3.0 2522 * @deprecated 3.0.0 Use term_exists() 2523 * @see term_exists() 2524 * 2525 * @param int|string $term The term to check 2526 * @param string $taxonomy The taxonomy name to use 2527 * @param int $parent ID of parent term under which to confine the exists search. 2528 * @return mixed Get the term ID or term object, if exists. 2529 * 2530 * @phpstan-return ( 2531 * $term is 0 2532 * ? 0 2533 * : ( 2534 * $term is '' 2535 * ? null 2536 * : ( $taxonomy is '' ? string|null : array{ term_id: string, term_taxonomy_id: string }|null ) 2537 * ) 2538 * ) 2539 */ 2540 function is_term( $term, $taxonomy = '', $parent = 0 ) { 2541 _deprecated_function( __FUNCTION__, '3.0.0', 'term_exists()' ); 2542 return term_exists( $term, $taxonomy, $parent ); 2543 } 2544 2545 /** 2546 * Determines whether the current admin page is generated by a plugin. 2547 * 2548 * Use global $plugin_page and/or get_plugin_page_hookname() hooks. 2549 * 2550 * For more information on this and similar theme functions, check out 2551 * the {@link https://developer.wordpress.org/themes/basics/conditional-tags/ 2552 * Conditional Tags} article in the Theme Developer Handbook. 2553 * 2554 * @since 1.5.0 2555 * @deprecated 3.1.0 2556 * 2557 * @global $plugin_page 2558 * 2559 * @return bool 2560 */ 2561 function is_plugin_page() { 2562 _deprecated_function( __FUNCTION__, '3.1.0' ); 2563 2564 global $plugin_page; 2565 2566 if ( isset($plugin_page) ) 2567 return true; 2568 2569 return false; 2570 } 2571 2572 /** 2573 * Update the categories cache. 2574 * 2575 * This function does not appear to be used anymore or does not appear to be 2576 * needed. It might be a legacy function left over from when there was a need 2577 * for updating the category cache. 2578 * 2579 * @since 1.5.0 2580 * @deprecated 3.1.0 2581 * 2582 * @return bool Always return True 2583 */ 2584 function update_category_cache() { 2585 _deprecated_function( __FUNCTION__, '3.1.0' ); 2586 2587 return true; 2588 } 2589 2590 /** 2591 * Check for PHP timezone support 2592 * 2593 * @since 2.9.0 2594 * @deprecated 3.2.0 2595 * 2596 * @return bool 2597 */ 2598 function wp_timezone_supported() { 2599 _deprecated_function( __FUNCTION__, '3.2.0' ); 2600 2601 return true; 2602 } 2603 2604 /** 2605 * Displays an editor: TinyMCE, HTML, or both. 2606 * 2607 * @since 2.1.0 2608 * @deprecated 3.3.0 Use wp_editor() 2609 * @see wp_editor() 2610 * 2611 * @param string $content Textarea content. 2612 * @param string $id Optional. HTML ID attribute value. Default 'content'. 2613 * @param string $prev_id Optional. Unused. 2614 * @param bool $media_buttons Optional. Whether to display media buttons. Default true. 2615 * @param int $tab_index Optional. Unused. 2616 * @param bool $extended Optional. Unused. 2617 */ 2618 function the_editor($content, $id = 'content', $prev_id = 'title', $media_buttons = true, $tab_index = 2, $extended = true) { 2619 _deprecated_function( __FUNCTION__, '3.3.0', 'wp_editor()' ); 2620 2621 wp_editor( $content, $id, array( 'media_buttons' => $media_buttons ) ); 2622 } 2623 2624 /** 2625 * Perform the query to get the $metavalues array(s) needed by _fill_user and _fill_many_users 2626 * 2627 * @since 3.0.0 2628 * @deprecated 3.3.0 2629 * 2630 * @param array $ids User ID numbers list. 2631 * @return array of arrays. The array is indexed by user_id, containing $metavalues object arrays. 2632 */ 2633 function get_user_metavalues($ids) { 2634 _deprecated_function( __FUNCTION__, '3.3.0' ); 2635 2636 $objects = array(); 2637 2638 $ids = array_map('intval', $ids); 2639 foreach ( $ids as $id ) 2640 $objects[$id] = array(); 2641 2642 $metas = update_meta_cache('user', $ids); 2643 2644 foreach ( $metas as $id => $meta ) { 2645 foreach ( $meta as $key => $metavalues ) { 2646 foreach ( $metavalues as $value ) { 2647 $objects[$id][] = (object)array( 'user_id' => $id, 'meta_key' => $key, 'meta_value' => $value); 2648 } 2649 } 2650 } 2651 2652 return $objects; 2653 } 2654 2655 /** 2656 * Sanitize every user field. 2657 * 2658 * If the context is 'raw', then the user object or array will get minimal sanitization of the int fields. 2659 * 2660 * @since 2.3.0 2661 * @deprecated 3.3.0 2662 * 2663 * @param object|array $user The user object or array. 2664 * @param string $context Optional. How to sanitize user fields. Default 'display'. 2665 * @return object|array The now sanitized user object or array (will be the same type as $user). 2666 */ 2667 function sanitize_user_object($user, $context = 'display') { 2668 _deprecated_function( __FUNCTION__, '3.3.0' ); 2669 2670 if ( is_object($user) ) { 2671 if ( !isset($user->ID) ) 2672 $user->ID = 0; 2673 if ( ! ( $user instanceof WP_User ) ) { 2674 $vars = get_object_vars($user); 2675 foreach ( array_keys($vars) as $field ) { 2676 if ( is_string($user->$field) || is_numeric($user->$field) ) 2677 $user->$field = sanitize_user_field($field, $user->$field, $user->ID, $context); 2678 } 2679 } 2680 $user->filter = $context; 2681 } else { 2682 if ( !isset($user['ID']) ) 2683 $user['ID'] = 0; 2684 foreach ( array_keys($user) as $field ) 2685 $user[$field] = sanitize_user_field($field, $user[$field], $user['ID'], $context); 2686 $user['filter'] = $context; 2687 } 2688 2689 return $user; 2690 } 2691 2692 /** 2693 * Get boundary post relational link. 2694 * 2695 * Can either be start or end post relational link. 2696 * 2697 * @since 2.8.0 2698 * @deprecated 3.3.0 2699 * 2700 * @param string $title Optional. Link title format. Default '%title'. 2701 * @param bool $in_same_cat Optional. Whether link should be in a same category. 2702 * Default false. 2703 * @param string $excluded_categories Optional. Excluded categories IDs. Default empty. 2704 * @param bool $start Optional. Whether to display link to first or last post. 2705 * Default true. 2706 * @return string 2707 */ 2708 function get_boundary_post_rel_link($title = '%title', $in_same_cat = false, $excluded_categories = '', $start = true) { 2709 _deprecated_function( __FUNCTION__, '3.3.0' ); 2710 2711 $posts = get_boundary_post($in_same_cat, $excluded_categories, $start); 2712 // If there is no post, stop. 2713 if ( empty($posts) ) 2714 return; 2715 2716 // Even though we limited get_posts() to return only 1 item it still returns an array of objects. 2717 $post = $posts[0]; 2718 2719 if ( empty($post->post_title) ) 2720 $post->post_title = $start ? __('First Post') : __('Last Post'); 2721 2722 $date = mysql2date(get_option('date_format'), $post->post_date); 2723 2724 $title = str_replace('%title', $post->post_title, $title); 2725 $title = str_replace('%date', $date, $title); 2726 /** This filter is documented in wp-includes/post-template.php */ 2727 $title = apply_filters('the_title', $title, $post->ID); 2728 2729 $link = $start ? "<link rel='start' title='" : "<link rel='end' title='"; 2730 $link .= esc_attr($title); 2731 $link .= "' href='" . get_permalink($post) . "' />\n"; 2732 2733 $boundary = $start ? 'start' : 'end'; 2734 return apply_filters( "{$boundary}_post_rel_link", $link ); 2735 } 2736 2737 /** 2738 * Display relational link for the first post. 2739 * 2740 * @since 2.8.0 2741 * @deprecated 3.3.0 2742 * 2743 * @param string $title Optional. Link title format. 2744 * @param bool $in_same_cat Optional. Whether link should be in a same category. 2745 * @param string $excluded_categories Optional. Excluded categories IDs. 2746 */ 2747 function start_post_rel_link($title = '%title', $in_same_cat = false, $excluded_categories = '') { 2748 _deprecated_function( __FUNCTION__, '3.3.0' ); 2749 2750 echo get_boundary_post_rel_link($title, $in_same_cat, $excluded_categories, true); 2751 } 2752 2753 /** 2754 * Get site index relational link. 2755 * 2756 * @since 2.8.0 2757 * @deprecated 3.3.0 2758 * 2759 * @return string 2760 */ 2761 function get_index_rel_link() { 2762 _deprecated_function( __FUNCTION__, '3.3.0' ); 2763 2764 $link = "<link rel='index' title='" . esc_attr( get_bloginfo( 'name', 'display' ) ) . "' href='" . esc_url( user_trailingslashit( get_bloginfo( 'url', 'display' ) ) ) . "' />\n"; 2765 return apply_filters( "index_rel_link", $link ); 2766 } 2767 2768 /** 2769 * Display relational link for the site index. 2770 * 2771 * @since 2.8.0 2772 * @deprecated 3.3.0 2773 */ 2774 function index_rel_link() { 2775 _deprecated_function( __FUNCTION__, '3.3.0' ); 2776 2777 echo get_index_rel_link(); 2778 } 2779 2780 /** 2781 * Get parent post relational link. 2782 * 2783 * @since 2.8.0 2784 * @deprecated 3.3.0 2785 * 2786 * @global WP_Post $post Global post object. 2787 * 2788 * @param string $title Optional. Link title format. Default '%title'. 2789 * @return string 2790 */ 2791 function get_parent_post_rel_link( $title = '%title' ) { 2792 _deprecated_function( __FUNCTION__, '3.3.0' ); 2793 2794 if ( ! empty( $GLOBALS['post'] ) && ! empty( $GLOBALS['post']->post_parent ) ) 2795 $post = get_post($GLOBALS['post']->post_parent); 2796 2797 if ( empty($post) ) 2798 return; 2799 2800 $date = mysql2date(get_option('date_format'), $post->post_date); 2801 2802 $title = str_replace('%title', $post->post_title, $title); 2803 $title = str_replace('%date', $date, $title); 2804 /** This filter is documented in wp-includes/post-template.php */ 2805 $title = apply_filters('the_title', $title, $post->ID); 2806 2807 $link = "<link rel='up' title='"; 2808 $link .= esc_attr( $title ); 2809 $link .= "' href='" . get_permalink($post) . "' />\n"; 2810 2811 return apply_filters( "parent_post_rel_link", $link ); 2812 } 2813 2814 /** 2815 * Display relational link for parent item 2816 * 2817 * @since 2.8.0 2818 * @deprecated 3.3.0 2819 * 2820 * @param string $title Optional. Link title format. Default '%title'. 2821 */ 2822 function parent_post_rel_link( $title = '%title' ) { 2823 _deprecated_function( __FUNCTION__, '3.3.0' ); 2824 2825 echo get_parent_post_rel_link($title); 2826 } 2827 2828 /** 2829 * Add the "Dashboard"/"Visit Site" menu. 2830 * 2831 * @since 3.2.0 2832 * @deprecated 3.3.0 2833 * 2834 * @param WP_Admin_Bar $wp_admin_bar WP_Admin_Bar instance. 2835 */ 2836 function wp_admin_bar_dashboard_view_site_menu( $wp_admin_bar ) { 2837 _deprecated_function( __FUNCTION__, '3.3.0' ); 2838 2839 $user_id = get_current_user_id(); 2840 2841 if ( 0 != $user_id ) { 2842 if ( is_admin() ) 2843 $wp_admin_bar->add_menu( array( 'id' => 'view-site', 'title' => __( 'Visit Site' ), 'href' => home_url() ) ); 2844 elseif ( is_multisite() ) 2845 $wp_admin_bar->add_menu( array( 'id' => 'dashboard', 'title' => __( 'Dashboard' ), 'href' => get_dashboard_url( $user_id ) ) ); 2846 else 2847 $wp_admin_bar->add_menu( array( 'id' => 'dashboard', 'title' => __( 'Dashboard' ), 'href' => admin_url() ) ); 2848 } 2849 } 2850 2851 /** 2852 * Checks if the current user belong to a given site. 2853 * 2854 * @since MU (3.0.0) 2855 * @deprecated 3.3.0 Use is_user_member_of_blog() 2856 * @see is_user_member_of_blog() 2857 * 2858 * @param int $blog_id Site ID 2859 * @return bool True if the current users belong to $blog_id, false if not. 2860 */ 2861 function is_blog_user( $blog_id = 0 ) { 2862 _deprecated_function( __FUNCTION__, '3.3.0', 'is_user_member_of_blog()' ); 2863 2864 return is_user_member_of_blog( get_current_user_id(), $blog_id ); 2865 } 2866 2867 /** 2868 * Open the file handle for debugging. 2869 * 2870 * @since 0.71 2871 * @deprecated 3.4.0 Use error_log() 2872 * @see error_log() 2873 * 2874 * @link https://www.php.net/manual/en/function.error-log.php 2875 * 2876 * @param string $filename File name. 2877 * @param string $mode Type of access you required to the stream. 2878 * @return false Always false. 2879 */ 2880 function debug_fopen( $filename, $mode ) { 2881 _deprecated_function( __FUNCTION__, '3.4.0', 'error_log()' ); 2882 return false; 2883 } 2884 2885 /** 2886 * Write contents to the file used for debugging. 2887 * 2888 * @since 0.71 2889 * @deprecated 3.4.0 Use error_log() 2890 * @see error_log() 2891 * 2892 * @link https://www.php.net/manual/en/function.error-log.php 2893 * 2894 * @param mixed $fp Unused. 2895 * @param string $message Message to log. 2896 */ 2897 function debug_fwrite( $fp, $message ) { 2898 _deprecated_function( __FUNCTION__, '3.4.0', 'error_log()' ); 2899 if ( ! empty( $GLOBALS['debug'] ) ) 2900 error_log( $message ); 2901 } 2902 2903 /** 2904 * Close the debugging file handle. 2905 * 2906 * @since 0.71 2907 * @deprecated 3.4.0 Use error_log() 2908 * @see error_log() 2909 * 2910 * @link https://www.php.net/manual/en/function.error-log.php 2911 * 2912 * @param mixed $fp Unused. 2913 */ 2914 function debug_fclose( $fp ) { 2915 _deprecated_function( __FUNCTION__, '3.4.0', 'error_log()' ); 2916 } 2917 2918 /** 2919 * Retrieve list of themes with theme data in theme directory. 2920 * 2921 * The theme is broken, if it doesn't have a parent theme and is missing either 2922 * style.css and, or index.php. If the theme has a parent theme then it is 2923 * broken, if it is missing style.css; index.php is optional. 2924 * 2925 * @since 1.5.0 2926 * @deprecated 3.4.0 Use wp_get_themes() 2927 * @see wp_get_themes() 2928 * 2929 * @return array Theme list with theme data. 2930 */ 2931 function get_themes() { 2932 _deprecated_function( __FUNCTION__, '3.4.0', 'wp_get_themes()' ); 2933 2934 global $wp_themes; 2935 if ( isset( $wp_themes ) ) 2936 return $wp_themes; 2937 2938 $themes = wp_get_themes(); 2939 $wp_themes = array(); 2940 2941 foreach ( $themes as $theme ) { 2942 $name = $theme->get('Name'); 2943 if ( isset( $wp_themes[ $name ] ) ) 2944 $wp_themes[ $name . '/' . $theme->get_stylesheet() ] = $theme; 2945 else 2946 $wp_themes[ $name ] = $theme; 2947 } 2948 2949 return $wp_themes; 2950 } 2951 2952 /** 2953 * Retrieve theme data. 2954 * 2955 * @since 1.5.0 2956 * @deprecated 3.4.0 Use wp_get_theme() 2957 * @see wp_get_theme() 2958 * 2959 * @param string $theme Theme name. 2960 * @return array|null Null, if theme name does not exist. Theme data, if exists. 2961 */ 2962 function get_theme( $theme ) { 2963 _deprecated_function( __FUNCTION__, '3.4.0', 'wp_get_theme( $stylesheet )' ); 2964 2965 $themes = get_themes(); 2966 if ( is_array( $themes ) && array_key_exists( $theme, $themes ) ) 2967 return $themes[ $theme ]; 2968 return null; 2969 } 2970 2971 /** 2972 * Retrieve current theme name. 2973 * 2974 * @since 1.5.0 2975 * @deprecated 3.4.0 Use wp_get_theme() 2976 * @see wp_get_theme() 2977 * 2978 * @return string 2979 */ 2980 function get_current_theme() { 2981 _deprecated_function( __FUNCTION__, '3.4.0', 'wp_get_theme()' ); 2982 2983 if ( $theme = get_option( 'current_theme' ) ) 2984 return $theme; 2985 2986 return wp_get_theme()->get('Name'); 2987 } 2988 2989 /** 2990 * Accepts matches array from preg_replace_callback in wpautop() or a string. 2991 * 2992 * Ensures that the contents of a `<pre>...</pre>` HTML block are not 2993 * converted into paragraphs or line breaks. 2994 * 2995 * @since 1.2.0 2996 * @deprecated 3.4.0 2997 * 2998 * @param array|string $matches The array or string 2999 * @return string The pre block without paragraph/line break conversion. 3000 */ 3001 function clean_pre($matches) { 3002 _deprecated_function( __FUNCTION__, '3.4.0' ); 3003 3004 if ( is_array($matches) ) 3005 $text = $matches[1] . $matches[2] . "</pre>"; 3006 else 3007 $text = $matches; 3008 3009 $text = str_replace(array('<br />', '<br/>', '<br>'), array('', '', ''), $text); 3010 $text = str_replace('<p>', "\n", $text); 3011 $text = str_replace('</p>', '', $text); 3012 3013 return $text; 3014 } 3015 3016 3017 /** 3018 * Add callbacks for image header display. 3019 * 3020 * @since 2.1.0 3021 * @deprecated 3.4.0 Use add_theme_support() 3022 * @see add_theme_support() 3023 * 3024 * @param callable $wp_head_callback Call on the {@see 'wp_head'} action. 3025 * @param callable $admin_head_callback Call on custom header administration screen. 3026 * @param callable $admin_preview_callback Output a custom header image div on the custom header administration screen. Optional. 3027 */ 3028 function add_custom_image_header( $wp_head_callback, $admin_head_callback, $admin_preview_callback = '' ) { 3029 _deprecated_function( __FUNCTION__, '3.4.0', 'add_theme_support( \'custom-header\', $args )' ); 3030 $args = array( 3031 'wp-head-callback' => $wp_head_callback, 3032 'admin-head-callback' => $admin_head_callback, 3033 ); 3034 if ( $admin_preview_callback ) 3035 $args['admin-preview-callback'] = $admin_preview_callback; 3036 return add_theme_support( 'custom-header', $args ); 3037 } 3038 3039 /** 3040 * Remove image header support. 3041 * 3042 * @since 3.1.0 3043 * @deprecated 3.4.0 Use remove_theme_support() 3044 * @see remove_theme_support() 3045 * 3046 * @return null|bool Whether support was removed. 3047 */ 3048 function remove_custom_image_header() { 3049 _deprecated_function( __FUNCTION__, '3.4.0', 'remove_theme_support( \'custom-header\' )' ); 3050 return remove_theme_support( 'custom-header' ); 3051 } 3052 3053 /** 3054 * Add callbacks for background image display. 3055 * 3056 * @since 3.0.0 3057 * @deprecated 3.4.0 Use add_theme_support() 3058 * @see add_theme_support() 3059 * 3060 * @param callable $wp_head_callback Call on the {@see 'wp_head'} action. 3061 * @param callable $admin_head_callback Call on custom background administration screen. 3062 * @param callable $admin_preview_callback Output a custom background image div on the custom background administration screen. Optional. 3063 */ 3064 function add_custom_background( $wp_head_callback = '', $admin_head_callback = '', $admin_preview_callback = '' ) { 3065 _deprecated_function( __FUNCTION__, '3.4.0', 'add_theme_support( \'custom-background\', $args )' ); 3066 $args = array(); 3067 if ( $wp_head_callback ) 3068 $args['wp-head-callback'] = $wp_head_callback; 3069 if ( $admin_head_callback ) 3070 $args['admin-head-callback'] = $admin_head_callback; 3071 if ( $admin_preview_callback ) 3072 $args['admin-preview-callback'] = $admin_preview_callback; 3073 return add_theme_support( 'custom-background', $args ); 3074 } 3075 3076 /** 3077 * Remove custom background support. 3078 * 3079 * @since 3.1.0 3080 * @deprecated 3.4.0 Use add_custom_background() 3081 * @see add_custom_background() 3082 * 3083 * @return null|bool Whether support was removed. 3084 */ 3085 function remove_custom_background() { 3086 _deprecated_function( __FUNCTION__, '3.4.0', 'remove_theme_support( \'custom-background\' )' ); 3087 return remove_theme_support( 'custom-background' ); 3088 } 3089 3090 /** 3091 * Retrieve theme data from parsed theme file. 3092 * 3093 * @since 1.5.0 3094 * @deprecated 3.4.0 Use wp_get_theme() 3095 * @see wp_get_theme() 3096 * 3097 * @param string $theme_file Theme file path. 3098 * @return array Theme data. 3099 */ 3100 function get_theme_data( $theme_file ) { 3101 _deprecated_function( __FUNCTION__, '3.4.0', 'wp_get_theme()' ); 3102 $theme = new WP_Theme( wp_basename( dirname( $theme_file ) ), dirname( dirname( $theme_file ) ) ); 3103 3104 $theme_data = array( 3105 'Name' => $theme->get('Name'), 3106 'URI' => $theme->display('ThemeURI', true, false), 3107 'Description' => $theme->display('Description', true, false), 3108 'Author' => $theme->display('Author', true, false), 3109 'AuthorURI' => $theme->display('AuthorURI', true, false), 3110 'Version' => $theme->get('Version'), 3111 'Template' => $theme->get('Template'), 3112 'Status' => $theme->get('Status'), 3113 'Tags' => $theme->get('Tags'), 3114 'Title' => $theme->get('Name'), 3115 'AuthorName' => $theme->get('Author'), 3116 ); 3117 3118 foreach ( apply_filters( 'extra_theme_headers', array() ) as $extra_header ) { 3119 if ( ! isset( $theme_data[ $extra_header ] ) ) 3120 $theme_data[ $extra_header ] = $theme->get( $extra_header ); 3121 } 3122 3123 return $theme_data; 3124 } 3125 3126 /** 3127 * Alias of update_post_cache(). 3128 * 3129 * @see update_post_cache() Posts and pages are the same, alias is intentional 3130 * 3131 * @since 1.5.1 3132 * @deprecated 3.4.0 Use update_post_cache() 3133 * @see update_post_cache() 3134 * 3135 * @param array $pages list of page objects 3136 */ 3137 function update_page_cache( &$pages ) { 3138 _deprecated_function( __FUNCTION__, '3.4.0', 'update_post_cache()' ); 3139 3140 update_post_cache( $pages ); 3141 } 3142 3143 /** 3144 * Will clean the page in the cache. 3145 * 3146 * Clean (read: delete) page from cache that matches $id. Will also clean cache 3147 * associated with 'all_page_ids' and 'get_pages'. 3148 * 3149 * @since 2.0.0 3150 * @deprecated 3.4.0 Use clean_post_cache 3151 * @see clean_post_cache() 3152 * 3153 * @param int $id Page ID to clean 3154 */ 3155 function clean_page_cache( $id ) { 3156 _deprecated_function( __FUNCTION__, '3.4.0', 'clean_post_cache()' ); 3157 3158 clean_post_cache( $id ); 3159 } 3160 3161 /** 3162 * Retrieve nonce action "Are you sure" message. 3163 * 3164 * Deprecated in 3.4.1 and 3.5.0. Backported to 3.3.3. 3165 * 3166 * @since 2.0.4 3167 * @deprecated 3.4.1 Use wp_nonce_ays() 3168 * @see wp_nonce_ays() 3169 * 3170 * @param string $action Nonce action. 3171 * @return string Are you sure message. 3172 */ 3173 function wp_explain_nonce( $action ) { 3174 _deprecated_function( __FUNCTION__, '3.4.1', 'wp_nonce_ays()' ); 3175 return __( 'Are you sure you want to do this?' ); 3176 } 3177 3178 /** 3179 * Display "sticky" CSS class, if a post is sticky. 3180 * 3181 * @since 2.7.0 3182 * @deprecated 3.5.0 Use post_class() 3183 * @see post_class() 3184 * 3185 * @param int $post_id An optional post ID. 3186 */ 3187 function sticky_class( $post_id = null ) { 3188 _deprecated_function( __FUNCTION__, '3.5.0', 'post_class()' ); 3189 if ( is_sticky( $post_id ) ) 3190 echo ' sticky'; 3191 } 3192 3193 /** 3194 * Retrieve post ancestors. 3195 * 3196 * This is no longer needed as WP_Post lazy-loads the ancestors 3197 * property with get_post_ancestors(). 3198 * 3199 * @since 2.3.4 3200 * @deprecated 3.5.0 Use get_post_ancestors() 3201 * @see get_post_ancestors() 3202 * 3203 * @param WP_Post $post Post object, passed by reference (unused). 3204 */ 3205 function _get_post_ancestors( &$post ) { 3206 _deprecated_function( __FUNCTION__, '3.5.0' ); 3207 } 3208 3209 /** 3210 * Load an image from a string, if PHP supports it. 3211 * 3212 * @since 2.1.0 3213 * @deprecated 3.5.0 Use wp_get_image_editor() 3214 * @see wp_get_image_editor() 3215 * 3216 * @param string $file Filename of the image to load. 3217 * @return resource|GdImage|string The resulting image resource or GdImage instance on success, 3218 * error string on failure. 3219 */ 3220 function wp_load_image( $file ) { 3221 _deprecated_function( __FUNCTION__, '3.5.0', 'wp_get_image_editor()' ); 3222 3223 if ( is_numeric( $file ) ) 3224 $file = get_attached_file( $file ); 3225 3226 if ( ! is_file( $file ) ) { 3227 /* translators: %s: File name. */ 3228 return sprintf( __( 'File “%s” does not exist?' ), $file ); 3229 } 3230 3231 if ( ! function_exists('imagecreatefromstring') ) 3232 return __('The GD image library is not installed.'); 3233 3234 // Set artificially high because GD uses uncompressed images in memory. 3235 wp_raise_memory_limit( 'image' ); 3236 3237 $image = imagecreatefromstring( file_get_contents( $file ) ); 3238 3239 if ( ! is_gd_image( $image ) ) { 3240 /* translators: %s: File name. */ 3241 return sprintf( __( 'File “%s” is not an image.' ), $file ); 3242 } 3243 3244 return $image; 3245 } 3246 3247 /** 3248 * Scale down an image to fit a particular size and save a new copy of the image. 3249 * 3250 * The PNG transparency will be preserved using the function, as well as the 3251 * image type. If the file going in is PNG, then the resized image is going to 3252 * be PNG. The only supported image types are PNG, GIF, and JPEG. 3253 * 3254 * Some functionality requires API to exist, so some PHP version may lose out 3255 * support. This is not the fault of WordPress (where functionality is 3256 * downgraded, not actual defects), but of your PHP version. 3257 * 3258 * @since 2.5.0 3259 * @deprecated 3.5.0 Use wp_get_image_editor() 3260 * @see wp_get_image_editor() 3261 * 3262 * @param string $file Image file path. 3263 * @param int $max_w Maximum width to resize to. 3264 * @param int $max_h Maximum height to resize to. 3265 * @param bool $crop Optional. Whether to crop image or resize. Default false. 3266 * @param string $suffix Optional. File suffix. Default null. 3267 * @param string $dest_path Optional. New image file path. Default null. 3268 * @param int $jpeg_quality Optional. Image quality percentage. Default 90. 3269 * @return mixed WP_Error on failure. String with new destination path. 3270 */ 3271 function image_resize( $file, $max_w, $max_h, $crop = false, $suffix = null, $dest_path = null, $jpeg_quality = 90 ) { 3272 _deprecated_function( __FUNCTION__, '3.5.0', 'wp_get_image_editor()' ); 3273 3274 $editor = wp_get_image_editor( $file ); 3275 if ( is_wp_error( $editor ) ) 3276 return $editor; 3277 $editor->set_quality( $jpeg_quality ); 3278 3279 $resized = $editor->resize( $max_w, $max_h, $crop ); 3280 if ( is_wp_error( $resized ) ) 3281 return $resized; 3282 3283 $dest_file = $editor->generate_filename( $suffix, $dest_path ); 3284 $saved = $editor->save( $dest_file ); 3285 3286 if ( is_wp_error( $saved ) ) 3287 return $saved; 3288 3289 return $dest_file; 3290 } 3291 3292 /** 3293 * Retrieve a single post, based on post ID. 3294 * 3295 * Has categories in 'post_category' property or key. Has tags in 'tags_input' 3296 * property or key. 3297 * 3298 * @since 1.0.0 3299 * @deprecated 3.5.0 Use get_post() 3300 * @see get_post() 3301 * 3302 * @param int $postid Post ID. 3303 * @param string $mode How to return result, either OBJECT, ARRAY_N, or ARRAY_A. 3304 * @return WP_Post|null Post object or array holding post contents and information 3305 */ 3306 function wp_get_single_post( $postid = 0, $mode = OBJECT ) { 3307 _deprecated_function( __FUNCTION__, '3.5.0', 'get_post()' ); 3308 return get_post( $postid, $mode ); 3309 } 3310 3311 /** 3312 * Check that the user login name and password is correct. 3313 * 3314 * @since 0.71 3315 * @deprecated 3.5.0 Use wp_authenticate() 3316 * @see wp_authenticate() 3317 * 3318 * @param string $user_login User name. 3319 * @param string $user_pass User password. 3320 * @return bool False if does not authenticate, true if username and password authenticates. 3321 */ 3322 function user_pass_ok($user_login, $user_pass) { 3323 _deprecated_function( __FUNCTION__, '3.5.0', 'wp_authenticate()' ); 3324 $user = wp_authenticate( $user_login, $user_pass ); 3325 if ( is_wp_error( $user ) ) 3326 return false; 3327 3328 return true; 3329 } 3330 3331 /** 3332 * Callback formerly fired on the save_post hook. No longer needed. 3333 * 3334 * @since 2.3.0 3335 * @deprecated 3.5.0 3336 */ 3337 function _save_post_hook() {} 3338 3339 /** 3340 * Check if the installed version of GD supports particular image type 3341 * 3342 * @since 2.9.0 3343 * @deprecated 3.5.0 Use wp_image_editor_supports() 3344 * @see wp_image_editor_supports() 3345 * 3346 * @param string $mime_type 3347 * @return bool 3348 */ 3349 function gd_edit_image_support($mime_type) { 3350 _deprecated_function( __FUNCTION__, '3.5.0', 'wp_image_editor_supports()' ); 3351 3352 if ( function_exists('imagetypes') ) { 3353 switch( $mime_type ) { 3354 case 'image/jpeg': 3355 return (imagetypes() & IMG_JPG) != 0; 3356 case 'image/png': 3357 return (imagetypes() & IMG_PNG) != 0; 3358 case 'image/gif': 3359 return (imagetypes() & IMG_GIF) != 0; 3360 case 'image/webp': 3361 return (imagetypes() & IMG_WEBP) != 0; 3362 case 'image/avif': 3363 return (imagetypes() & IMG_AVIF) != 0; 3364 } 3365 } else { 3366 switch( $mime_type ) { 3367 case 'image/jpeg': 3368 return function_exists('imagecreatefromjpeg'); 3369 case 'image/png': 3370 return function_exists('imagecreatefrompng'); 3371 case 'image/gif': 3372 return function_exists('imagecreatefromgif'); 3373 case 'image/webp': 3374 return function_exists('imagecreatefromwebp'); 3375 case 'image/avif': 3376 return function_exists('imagecreatefromavif'); 3377 } 3378 } 3379 return false; 3380 } 3381 3382 /** 3383 * Converts an integer byte value to a shorthand byte value. 3384 * 3385 * @since 2.3.0 3386 * @deprecated 3.6.0 Use size_format() 3387 * @see size_format() 3388 * 3389 * @param int $bytes An integer byte value. 3390 * @return string A shorthand byte value. 3391 */ 3392 function wp_convert_bytes_to_hr( $bytes ) { 3393 _deprecated_function( __FUNCTION__, '3.6.0', 'size_format()' ); 3394 3395 $units = array( 0 => 'B', 1 => 'KB', 2 => 'MB', 3 => 'GB', 4 => 'TB' ); 3396 $log = log( $bytes, KB_IN_BYTES ); 3397 $power = ! is_nan( $log ) && ! is_infinite( $log ) ? (int) $log : 0; 3398 $size = KB_IN_BYTES ** ( $log - $power ); 3399 3400 if ( ! is_nan( $size ) && array_key_exists( $power, $units ) ) { 3401 $unit = $units[ $power ]; 3402 } else { 3403 $size = $bytes; 3404 $unit = $units[0]; 3405 } 3406 3407 return $size . $unit; 3408 } 3409 3410 /** 3411 * Formerly used internally to tidy up the search terms. 3412 * 3413 * @since 2.9.0 3414 * @access private 3415 * @deprecated 3.7.0 3416 * 3417 * @param string $t Search terms to "tidy", e.g. trim. 3418 * @return string Trimmed search terms. 3419 */ 3420 function _search_terms_tidy( $t ) { 3421 _deprecated_function( __FUNCTION__, '3.7.0' ); 3422 return trim( $t, "\"'\n\r " ); 3423 } 3424 3425 /** 3426 * Determine if TinyMCE is available. 3427 * 3428 * Checks to see if the user has deleted the tinymce files to slim down 3429 * their WordPress installation. 3430 * 3431 * @since 2.1.0 3432 * @deprecated 3.9.0 3433 * 3434 * @return bool Whether TinyMCE exists. 3435 */ 3436 function rich_edit_exists() { 3437 global $wp_rich_edit_exists; 3438 _deprecated_function( __FUNCTION__, '3.9.0' ); 3439 3440 if ( ! isset( $wp_rich_edit_exists ) ) 3441 $wp_rich_edit_exists = file_exists( ABSPATH . WPINC . '/js/tinymce/tinymce.js' ); 3442 3443 return $wp_rich_edit_exists; 3444 } 3445 3446 /** 3447 * Old callback for tag link tooltips. 3448 * 3449 * @since 2.7.0 3450 * @access private 3451 * @deprecated 3.9.0 3452 * 3453 * @param int $count Number of topics. 3454 * @return int Number of topics. 3455 */ 3456 function default_topic_count_text( $count ) { 3457 return $count; 3458 } 3459 3460 /** 3461 * Formerly used to escape strings before inserting into the DB. 3462 * 3463 * Has not performed this function for many, many years. Use wpdb::prepare() instead. 3464 * 3465 * @since 0.71 3466 * @deprecated 3.9.0 3467 * 3468 * @param string $content The text to format. 3469 * @return string The very same text. 3470 */ 3471 function format_to_post( $content ) { 3472 _deprecated_function( __FUNCTION__, '3.9.0' ); 3473 return $content; 3474 } 3475 3476 /** 3477 * Formerly used to escape strings before searching the DB. It was poorly documented and never worked as described. 3478 * 3479 * @since 2.5.0 3480 * @deprecated 4.0.0 Use wpdb::esc_like() 3481 * @see wpdb::esc_like() 3482 * 3483 * @param string $text The text to be escaped. 3484 * @return string text, safe for inclusion in LIKE query. 3485 */ 3486 function like_escape($text) { 3487 _deprecated_function( __FUNCTION__, '4.0.0', 'wpdb::esc_like()' ); 3488 return str_replace( array( "%", "_" ), array( "\\%", "\\_" ), $text ); 3489 } 3490 3491 /** 3492 * Determines if the URL can be accessed over SSL. 3493 * 3494 * Determines if the URL can be accessed over SSL by using the WordPress HTTP API to access 3495 * the URL using https as the scheme. 3496 * 3497 * @since 2.5.0 3498 * @deprecated 4.0.0 3499 * 3500 * @param string $url The URL to test. 3501 * @return bool Whether SSL access is available. 3502 */ 3503 function url_is_accessable_via_ssl( $url ) { 3504 _deprecated_function( __FUNCTION__, '4.0.0' ); 3505 3506 $response = wp_remote_get( set_url_scheme( $url, 'https' ) ); 3507 3508 if ( !is_wp_error( $response ) ) { 3509 $status = wp_remote_retrieve_response_code( $response ); 3510 if ( 200 == $status || 401 == $status ) { 3511 return true; 3512 } 3513 } 3514 3515 return false; 3516 } 3517 3518 /** 3519 * Start preview theme output buffer. 3520 * 3521 * Will only perform task if the user has permissions and template and preview 3522 * query variables exist. 3523 * 3524 * @since 2.6.0 3525 * @deprecated 4.3.0 3526 */ 3527 function preview_theme() { 3528 _deprecated_function( __FUNCTION__, '4.3.0' ); 3529 } 3530 3531 /** 3532 * Private function to modify the current template when previewing a theme 3533 * 3534 * @since 2.9.0 3535 * @deprecated 4.3.0 3536 * @access private 3537 * 3538 * @return string 3539 */ 3540 function _preview_theme_template_filter() { 3541 _deprecated_function( __FUNCTION__, '4.3.0' ); 3542 return ''; 3543 } 3544 3545 /** 3546 * Private function to modify the current stylesheet when previewing a theme 3547 * 3548 * @since 2.9.0 3549 * @deprecated 4.3.0 3550 * @access private 3551 * 3552 * @return string 3553 */ 3554 function _preview_theme_stylesheet_filter() { 3555 _deprecated_function( __FUNCTION__, '4.3.0' ); 3556 return ''; 3557 } 3558 3559 /** 3560 * Callback function for ob_start() to capture all links in the theme. 3561 * 3562 * @since 2.6.0 3563 * @deprecated 4.3.0 3564 * @access private 3565 * 3566 * @param string $content 3567 * @return string 3568 */ 3569 function preview_theme_ob_filter( $content ) { 3570 _deprecated_function( __FUNCTION__, '4.3.0' ); 3571 return $content; 3572 } 3573 3574 /** 3575 * Manipulates preview theme links in order to control and maintain location. 3576 * 3577 * Callback function for preg_replace_callback() to accept and filter matches. 3578 * 3579 * @since 2.6.0 3580 * @deprecated 4.3.0 3581 * @access private 3582 * 3583 * @param array $matches 3584 * @return string 3585 */ 3586 function preview_theme_ob_filter_callback( $matches ) { 3587 _deprecated_function( __FUNCTION__, '4.3.0' ); 3588 return ''; 3589 } 3590 3591 /** 3592 * Formats text for the rich text editor. 3593 * 3594 * The {@see 'richedit_pre'} filter is applied here. If `$text` is empty the filter will 3595 * be applied to an empty string. 3596 * 3597 * @since 2.0.0 3598 * @deprecated 4.3.0 Use format_for_editor() 3599 * @see format_for_editor() 3600 * 3601 * @param string $text The text to be formatted. 3602 * @return string The formatted text after filter is applied. 3603 */ 3604 function wp_richedit_pre($text) { 3605 _deprecated_function( __FUNCTION__, '4.3.0', 'format_for_editor()' ); 3606 3607 if ( empty( $text ) ) { 3608 /** 3609 * Filters text returned for the rich text editor. 3610 * 3611 * This filter is first evaluated, and the value returned, if an empty string 3612 * is passed to wp_richedit_pre(). If an empty string is passed, it results 3613 * in a break tag and line feed. 3614 * 3615 * If a non-empty string is passed, the filter is evaluated on the wp_richedit_pre() 3616 * return after being formatted. 3617 * 3618 * @since 2.0.0 3619 * @deprecated 4.3.0 3620 * 3621 * @param string $output Text for the rich text editor. 3622 */ 3623 return apply_filters( 'richedit_pre', '' ); 3624 } 3625 3626 $output = convert_chars($text); 3627 $output = wpautop($output); 3628 $output = htmlspecialchars($output, ENT_NOQUOTES, get_option( 'blog_charset' ) ); 3629 3630 /** This filter is documented in wp-includes/deprecated.php */ 3631 return apply_filters( 'richedit_pre', $output ); 3632 } 3633 3634 /** 3635 * Formats text for the HTML editor. 3636 * 3637 * Unless $output is empty it will pass through htmlspecialchars before the 3638 * {@see 'htmledit_pre'} filter is applied. 3639 * 3640 * @since 2.5.0 3641 * @deprecated 4.3.0 Use format_for_editor() 3642 * @see format_for_editor() 3643 * 3644 * @param string $output The text to be formatted. 3645 * @return string Formatted text after filter applied. 3646 */ 3647 function wp_htmledit_pre($output) { 3648 _deprecated_function( __FUNCTION__, '4.3.0', 'format_for_editor()' ); 3649 3650 if ( !empty($output) ) 3651 $output = htmlspecialchars($output, ENT_NOQUOTES, get_option( 'blog_charset' ) ); // Convert only '< > &'. 3652 3653 /** 3654 * Filters the text before it is formatted for the HTML editor. 3655 * 3656 * @since 2.5.0 3657 * @deprecated 4.3.0 3658 * 3659 * @param string $output The HTML-formatted text. 3660 */ 3661 return apply_filters( 'htmledit_pre', $output ); 3662 } 3663 3664 /** 3665 * Retrieve permalink from post ID. 3666 * 3667 * @since 1.0.0 3668 * @deprecated 4.4.0 Use get_permalink() 3669 * @see get_permalink() 3670 * 3671 * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global $post. 3672 * @return string|false 3673 */ 3674 function post_permalink( $post = 0 ) { 3675 _deprecated_function( __FUNCTION__, '4.4.0', 'get_permalink()' ); 3676 3677 return get_permalink( $post ); 3678 } 3679 3680 /** 3681 * Perform a HTTP HEAD or GET request. 3682 * 3683 * If $file_path is a writable filename, this will do a GET request and write 3684 * the file to that path. 3685 * 3686 * @since 2.5.0 3687 * @deprecated 4.4.0 Use WP_Http 3688 * @see WP_Http 3689 * 3690 * @param string $url URL to fetch. 3691 * @param string|bool $file_path Optional. File path to write request to. Default false. 3692 * @param int $red Optional. The number of Redirects followed, Upon 5 being hit, 3693 * returns false. Default 1. 3694 * @return \WpOrg\Requests\Utility\CaseInsensitiveDictionary|false Headers on success, false on failure. 3695 */ 3696 function wp_get_http( $url, $file_path = false, $red = 1 ) { 3697 _deprecated_function( __FUNCTION__, '4.4.0', 'WP_Http' ); 3698 3699 // Add 60 seconds to the script timeout to ensure the remote request has enough time. 3700 if ( function_exists( 'set_time_limit' ) ) { 3701 @set_time_limit( 60 ); 3702 } 3703 3704 if ( $red > 5 ) 3705 return false; 3706 3707 $options = array(); 3708 $options['redirection'] = 5; 3709 3710 if ( false == $file_path ) 3711 $options['method'] = 'HEAD'; 3712 else 3713 $options['method'] = 'GET'; 3714 3715 $response = wp_safe_remote_request( $url, $options ); 3716 3717 if ( is_wp_error( $response ) ) 3718 return false; 3719 3720 $headers = wp_remote_retrieve_headers( $response ); 3721 $headers['response'] = wp_remote_retrieve_response_code( $response ); 3722 3723 // WP_HTTP no longer follows redirects for HEAD requests. 3724 if ( 'HEAD' == $options['method'] && in_array($headers['response'], array(301, 302)) && isset( $headers['location'] ) ) { 3725 return wp_get_http( $headers['location'], $file_path, ++$red ); 3726 } 3727 3728 if ( false == $file_path ) 3729 return $headers; 3730 3731 // GET request - write it to the supplied filename. 3732 $out_fp = fopen($file_path, 'w'); 3733 if ( !$out_fp ) 3734 return $headers; 3735 3736 fwrite( $out_fp, wp_remote_retrieve_body( $response ) ); 3737 fclose($out_fp); 3738 clearstatcache(); 3739 3740 return $headers; 3741 } 3742 3743 /** 3744 * Whether SSL login should be forced. 3745 * 3746 * @since 2.6.0 3747 * @deprecated 4.4.0 Use force_ssl_admin() 3748 * @see force_ssl_admin() 3749 * 3750 * @param string|bool $force Optional Whether to force SSL login. Default null. 3751 * @return bool True if forced, false if not forced. 3752 */ 3753 function force_ssl_login( $force = null ) { 3754 _deprecated_function( __FUNCTION__, '4.4.0', 'force_ssl_admin()' ); 3755 return force_ssl_admin( $force ); 3756 } 3757 3758 /** 3759 * Retrieve path of comment popup template in current or parent template. 3760 * 3761 * @since 1.5.0 3762 * @deprecated 4.5.0 3763 * 3764 * @return string Full path to comments popup template file. 3765 */ 3766 function get_comments_popup_template() { 3767 _deprecated_function( __FUNCTION__, '4.5.0' ); 3768 3769 return ''; 3770 } 3771 3772 /** 3773 * Determines whether the current URL is within the comments popup window. 3774 * 3775 * For more information on this and similar theme functions, check out 3776 * the {@link https://developer.wordpress.org/themes/basics/conditional-tags/ 3777 * Conditional Tags} article in the Theme Developer Handbook. 3778 * 3779 * @since 1.5.0 3780 * @deprecated 4.5.0 3781 * 3782 * @return false Always returns false. 3783 */ 3784 function is_comments_popup() { 3785 _deprecated_function( __FUNCTION__, '4.5.0' ); 3786 3787 return false; 3788 } 3789 3790 /** 3791 * Display the JS popup script to show a comment. 3792 * 3793 * @since 0.71 3794 * @deprecated 4.5.0 3795 */ 3796 function comments_popup_script() { 3797 _deprecated_function( __FUNCTION__, '4.5.0' ); 3798 } 3799 3800 /** 3801 * Adds element attributes to open links in new tabs. 3802 * 3803 * @since 0.71 3804 * @deprecated 4.5.0 3805 * 3806 * @param string $text Content to replace links to open in a new tab. 3807 * @return string Content that has filtered links. 3808 */ 3809 function popuplinks( $text ) { 3810 _deprecated_function( __FUNCTION__, '4.5.0' ); 3811 $text = preg_replace('/<a (.+?)>/i', "<a $1 target='_blank' rel='external'>", $text); 3812 return $text; 3813 } 3814 3815 /** 3816 * The Google Video embed handler callback. 3817 * 3818 * Deprecated function that previously assisted in turning Google Video URLs 3819 * into embeds but that service has since been shut down. 3820 * 3821 * @since 2.9.0 3822 * @deprecated 4.6.0 3823 * 3824 * @return string An empty string. 3825 */ 3826 function wp_embed_handler_googlevideo( $matches, $attr, $url, $rawattr ) { 3827 _deprecated_function( __FUNCTION__, '4.6.0' ); 3828 3829 return ''; 3830 } 3831 3832 /** 3833 * Retrieve path of paged template in current or parent template. 3834 * 3835 * @since 1.5.0 3836 * @deprecated 4.7.0 The paged.php template is no longer part of the theme template hierarchy. 3837 * 3838 * @return string Full path to paged template file. 3839 */ 3840 function get_paged_template() { 3841 _deprecated_function( __FUNCTION__, '4.7.0' ); 3842 3843 return get_query_template( 'paged' ); 3844 } 3845 3846 /** 3847 * Handles parsing errors in `wp_kses_hair()`. 3848 * 3849 * The general plan is to remove everything to and including some whitespace, 3850 * but it deals with quotes and apostrophes as well. 3851 * 3852 * Note: This was previously used in certain cases when {@see \wp_kses_hair()} 3853 * struggled to recognize HTML syntax. Since 7.0.0 when that function was 3854 * rewritten to rely on the HTML API, those ambiguous situations no longer 3855 * exist, and this function is no longer relevant. 3856 * 3857 * @since 1.0.0 3858 * @deprecated 7.2.0 This was only meant to be used internally and the calling 3859 * function has been updated and no-longer needs it. 3860 * 3861 * @param string $attr 3862 * @return string 3863 */ 3864 function wp_kses_html_error( $attr ) { 3865 _deprecated_function( __FUNCTION__, '7.2.0' ); 3866 3867 return preg_replace( '/^("[^"]*("|$)|\'[^\']*(\'|$)|\S)*\s*/', '', $attr ); 3868 } 3869 3870 /** 3871 * Removes the HTML JavaScript entities found in early versions of Netscape 4. 3872 * 3873 * Previously, this function was pulled in from the original 3874 * import of kses and removed a specific vulnerability only 3875 * existent in early version of Netscape 4. However, this 3876 * vulnerability never affected any other browsers and can 3877 * be considered safe for the modern web. 3878 * 3879 * The regular expression which sanitized this vulnerability 3880 * has been removed in consideration of the performance and 3881 * energy demands it placed, now merely passing through its 3882 * input to the return. 3883 * 3884 * @since 1.0.0 3885 * @deprecated 4.7.0 Officially dropped security support for Netscape 4. 3886 * 3887 * @param string $content 3888 * @return string 3889 */ 3890 function wp_kses_js_entities( $content ) { 3891 _deprecated_function( __FUNCTION__, '4.7.0' ); 3892 3893 return preg_replace( '%&\s*\{[^}]*(\}\s*;?|$)%', '', $content ); 3894 } 3895 3896 /** 3897 * Sort categories by ID. 3898 * 3899 * Used by usort() as a callback, should not be used directly. Can actually be 3900 * used to sort any term object. 3901 * 3902 * @since 2.3.0 3903 * @deprecated 4.7.0 Use wp_list_sort() 3904 * @access private 3905 * 3906 * @param object $a 3907 * @param object $b 3908 * @return int 3909 */ 3910 function _usort_terms_by_ID( $a, $b ) { 3911 _deprecated_function( __FUNCTION__, '4.7.0', 'wp_list_sort()' ); 3912 3913 if ( $a->term_id > $b->term_id ) 3914 return 1; 3915 elseif ( $a->term_id < $b->term_id ) 3916 return -1; 3917 else 3918 return 0; 3919 } 3920 3921 /** 3922 * Sort categories by name. 3923 * 3924 * Used by usort() as a callback, should not be used directly. Can actually be 3925 * used to sort any term object. 3926 * 3927 * @since 2.3.0 3928 * @deprecated 4.7.0 Use wp_list_sort() 3929 * @access private 3930 * 3931 * @param object $a 3932 * @param object $b 3933 * @return int 3934 */ 3935 function _usort_terms_by_name( $a, $b ) { 3936 _deprecated_function( __FUNCTION__, '4.7.0', 'wp_list_sort()' ); 3937 3938 return strcmp( $a->name, $b->name ); 3939 } 3940 3941 /** 3942 * Sort menu items by the desired key. 3943 * 3944 * @since 3.0.0 3945 * @deprecated 4.7.0 Use wp_list_sort() 3946 * @access private 3947 * 3948 * @global string $_menu_item_sort_prop 3949 * 3950 * @param object $a The first object to compare 3951 * @param object $b The second object to compare 3952 * @return int -1, 0, or 1 if $a is considered to be respectively less than, equal to, or greater than $b. 3953 */ 3954 function _sort_nav_menu_items( $a, $b ) { 3955 global $_menu_item_sort_prop; 3956 3957 _deprecated_function( __FUNCTION__, '4.7.0', 'wp_list_sort()' ); 3958 3959 if ( empty( $_menu_item_sort_prop ) ) 3960 return 0; 3961 3962 if ( ! isset( $a->$_menu_item_sort_prop ) || ! isset( $b->$_menu_item_sort_prop ) ) 3963 return 0; 3964 3965 $_a = (int) $a->$_menu_item_sort_prop; 3966 $_b = (int) $b->$_menu_item_sort_prop; 3967 3968 if ( $a->$_menu_item_sort_prop == $b->$_menu_item_sort_prop ) 3969 return 0; 3970 elseif ( $_a == $a->$_menu_item_sort_prop && $_b == $b->$_menu_item_sort_prop ) 3971 return $_a < $_b ? -1 : 1; 3972 else 3973 return strcmp( $a->$_menu_item_sort_prop, $b->$_menu_item_sort_prop ); 3974 } 3975 3976 /** 3977 * Retrieves the Press This bookmarklet link. 3978 * 3979 * @since 2.6.0 3980 * @deprecated 4.9.0 3981 * @return string 3982 */ 3983 function get_shortcut_link() { 3984 _deprecated_function( __FUNCTION__, '4.9.0' ); 3985 3986 $link = ''; 3987 3988 /** 3989 * Filters the Press This bookmarklet link. 3990 * 3991 * @since 2.6.0 3992 * @deprecated 4.9.0 3993 * 3994 * @param string $link The Press This bookmarklet link. 3995 */ 3996 return apply_filters( 'shortcut_link', $link ); 3997 } 3998 3999 /** 4000 * Ajax handler for saving a post from Press This. 4001 * 4002 * @since 4.2.0 4003 * @deprecated 4.9.0 4004 */ 4005 function wp_ajax_press_this_save_post() { 4006 _deprecated_function( __FUNCTION__, '4.9.0' ); 4007 if ( is_plugin_active( 'press-this/press-this-plugin.php' ) ) { 4008 include WP_PLUGIN_DIR . '/press-this/class-wp-press-this-plugin.php'; 4009 $wp_press_this = new WP_Press_This_Plugin(); 4010 $wp_press_this->save_post(); 4011 } else { 4012 wp_send_json_error( array( 'errorMessage' => __( 'The Press This plugin is required.' ) ) ); 4013 } 4014 } 4015 4016 /** 4017 * Ajax handler for creating new category from Press This. 4018 * 4019 * @since 4.2.0 4020 * @deprecated 4.9.0 4021 */ 4022 function wp_ajax_press_this_add_category() { 4023 _deprecated_function( __FUNCTION__, '4.9.0' ); 4024 if ( is_plugin_active( 'press-this/press-this-plugin.php' ) ) { 4025 include WP_PLUGIN_DIR . '/press-this/class-wp-press-this-plugin.php'; 4026 $wp_press_this = new WP_Press_This_Plugin(); 4027 $wp_press_this->add_category(); 4028 } else { 4029 wp_send_json_error( array( 'errorMessage' => __( 'The Press This plugin is required.' ) ) ); 4030 } 4031 } 4032 4033 /** 4034 * Return the user request object for the specified request ID. 4035 * 4036 * @since 4.9.6 4037 * @deprecated 5.4.0 Use wp_get_user_request() 4038 * @see wp_get_user_request() 4039 * 4040 * @param int $request_id The ID of the user request. 4041 * @return WP_User_Request|false 4042 */ 4043 function wp_get_user_request_data( $request_id ) { 4044 _deprecated_function( __FUNCTION__, '5.4.0', 'wp_get_user_request()' ); 4045 return wp_get_user_request( $request_id ); 4046 } 4047 4048 /** 4049 * Filters 'img' elements in post content to add 'srcset' and 'sizes' attributes. 4050 * 4051 * @since 4.4.0 4052 * @deprecated 5.5.0 4053 * 4054 * @see wp_image_add_srcset_and_sizes() 4055 * 4056 * @param string $content The raw post content to be filtered. 4057 * @return string Converted content with 'srcset' and 'sizes' attributes added to images. 4058 */ 4059 function wp_make_content_images_responsive( $content ) { 4060 _deprecated_function( __FUNCTION__, '5.5.0', 'wp_filter_content_tags()' ); 4061 4062 // This will also add the `loading` attribute to `img` tags, if enabled. 4063 return wp_filter_content_tags( $content ); 4064 } 4065 4066 /** 4067 * Turn register globals off. 4068 * 4069 * @since 2.1.0 4070 * @access private 4071 * @deprecated 5.5.0 4072 */ 4073 function wp_unregister_GLOBALS() { 4074 // register_globals was deprecated in PHP 5.3 and removed entirely in PHP 5.4. 4075 _deprecated_function( __FUNCTION__, '5.5.0' ); 4076 } 4077 4078 /** 4079 * Does comment contain disallowed characters or words. 4080 * 4081 * @since 1.5.0 4082 * @deprecated 5.5.0 Use wp_check_comment_disallowed_list() instead. 4083 * Please consider writing more inclusive code. 4084 * 4085 * @param string $author The author of the comment 4086 * @param string $email The email of the comment 4087 * @param string $url The url used in the comment 4088 * @param string $comment The comment content 4089 * @param string $user_ip The comment author's IP address 4090 * @param string $user_agent The author's browser user agent 4091 * @return bool True if comment contains disallowed content, false if comment does not 4092 */ 4093 function wp_blacklist_check( $author, $email, $url, $comment, $user_ip, $user_agent ) { 4094 _deprecated_function( __FUNCTION__, '5.5.0', 'wp_check_comment_disallowed_list()' ); 4095 4096 return wp_check_comment_disallowed_list( $author, $email, $url, $comment, $user_ip, $user_agent ); 4097 } 4098 4099 /** 4100 * Filters out `register_meta()` args based on an allowed list. 4101 * 4102 * `register_meta()` args may change over time, so requiring the allowed list 4103 * to be explicitly turned off is a warranty seal of sorts. 4104 * 4105 * @access private 4106 * @since 4.6.0 4107 * @deprecated 5.5.0 Use _wp_register_meta_args_allowed_list() instead. 4108 * Please consider writing more inclusive code. 4109 * 4110 * @param array $args Arguments from `register_meta()`. 4111 * @param array $default_args Default arguments for `register_meta()`. 4112 * @return array Filtered arguments. 4113 */ 4114 function _wp_register_meta_args_whitelist( $args, $default_args ) { 4115 _deprecated_function( __FUNCTION__, '5.5.0', '_wp_register_meta_args_allowed_list()' ); 4116 4117 return _wp_register_meta_args_allowed_list( $args, $default_args ); 4118 } 4119 4120 /** 4121 * Adds an array of options to the list of allowed options. 4122 * 4123 * @since 2.7.0 4124 * @deprecated 5.5.0 Use add_allowed_options() instead. 4125 * Please consider writing more inclusive code. 4126 * 4127 * @param array $new_options 4128 * @param string|array $options 4129 * @return array 4130 */ 4131 function add_option_whitelist( $new_options, $options = '' ) { 4132 _deprecated_function( __FUNCTION__, '5.5.0', 'add_allowed_options()' ); 4133 4134 return add_allowed_options( $new_options, $options ); 4135 } 4136 4137 /** 4138 * Removes a list of options from the allowed options list. 4139 * 4140 * @since 2.7.0 4141 * @deprecated 5.5.0 Use remove_allowed_options() instead. 4142 * Please consider writing more inclusive code. 4143 * 4144 * @param array $del_options 4145 * @param string|array $options 4146 * @return array 4147 */ 4148 function remove_option_whitelist( $del_options, $options = '' ) { 4149 _deprecated_function( __FUNCTION__, '5.5.0', 'remove_allowed_options()' ); 4150 4151 return remove_allowed_options( $del_options, $options ); 4152 } 4153 4154 /** 4155 * Adds slashes to only string values in an array of values. 4156 * 4157 * This should be used when preparing data for core APIs that expect slashed data. 4158 * This should not be used to escape data going directly into an SQL query. 4159 * 4160 * @since 5.3.0 4161 * @deprecated 5.6.0 Use wp_slash() 4162 * 4163 * @see wp_slash() 4164 * 4165 * @param mixed $value Scalar or array of scalars. 4166 * @return mixed Slashes $value 4167 */ 4168 function wp_slash_strings_only( $value ) { 4169 return map_deep( $value, 'addslashes_strings_only' ); 4170 } 4171 4172 /** 4173 * Adds slashes only if the provided value is a string. 4174 * 4175 * @since 5.3.0 4176 * @deprecated 5.6.0 4177 * 4178 * @see wp_slash() 4179 * 4180 * @param mixed $value 4181 * @return mixed 4182 */ 4183 function addslashes_strings_only( $value ) { 4184 return is_string( $value ) ? addslashes( $value ) : $value; 4185 } 4186 4187 /** 4188 * Displays a `noindex` meta tag if required by the blog configuration. 4189 * 4190 * If a blog is marked as not being public then the `noindex` meta tag will be 4191 * output to tell web robots not to index the page content. 4192 * 4193 * Typical usage is as a {@see 'wp_head'} callback: 4194 * 4195 * add_action( 'wp_head', 'noindex' ); 4196 * 4197 * @see wp_no_robots() 4198 * 4199 * @since 2.1.0 4200 * @deprecated 5.7.0 Use wp_robots_noindex() instead on 'wp_robots' filter. 4201 */ 4202 function noindex() { 4203 _deprecated_function( __FUNCTION__, '5.7.0', 'wp_robots_noindex()' ); 4204 4205 // If the blog is not public, tell robots to go away. 4206 if ( '0' == get_option( 'blog_public' ) ) { 4207 wp_no_robots(); 4208 } 4209 } 4210 4211 /** 4212 * Display a `noindex` meta tag. 4213 * 4214 * Outputs a `noindex` meta tag that tells web robots not to index the page content. 4215 * 4216 * Typical usage is as a {@see 'wp_head'} callback: 4217 * 4218 * add_action( 'wp_head', 'wp_no_robots' ); 4219 * 4220 * @since 3.3.0 4221 * @since 5.3.0 Echo `noindex,nofollow` if search engine visibility is discouraged. 4222 * @deprecated 5.7.0 Use wp_robots_no_robots() instead on 'wp_robots' filter. 4223 */ 4224 function wp_no_robots() { 4225 _deprecated_function( __FUNCTION__, '5.7.0', 'wp_robots_no_robots()' ); 4226 4227 if ( get_option( 'blog_public' ) ) { 4228 echo "<meta name='robots' content='noindex,follow' />\n"; 4229 return; 4230 } 4231 4232 echo "<meta name='robots' content='noindex,nofollow' />\n"; 4233 } 4234 4235 /** 4236 * Display a `noindex,noarchive` meta tag and referrer `strict-origin-when-cross-origin` meta tag. 4237 * 4238 * Outputs a `noindex,noarchive` meta tag that tells web robots not to index or cache the page content. 4239 * Outputs a referrer `strict-origin-when-cross-origin` meta tag that tells the browser not to send 4240 * the full URL as a referrer to other sites when cross-origin assets are loaded. 4241 * 4242 * Typical usage is as a {@see 'wp_head'} callback: 4243 * 4244 * add_action( 'wp_head', 'wp_sensitive_page_meta' ); 4245 * 4246 * @since 5.0.1 4247 * @deprecated 5.7.0 Use wp_robots_sensitive_page() instead on 'wp_robots' filter 4248 * and wp_strict_cross_origin_referrer() on 'wp_head' action. 4249 * 4250 * @see wp_robots_sensitive_page() 4251 */ 4252 function wp_sensitive_page_meta() { 4253 _deprecated_function( __FUNCTION__, '5.7.0', 'wp_robots_sensitive_page()' ); 4254 4255 ?> 4256 <meta name='robots' content='noindex,noarchive' /> 4257 <?php 4258 wp_strict_cross_origin_referrer(); 4259 } 4260 4261 /** 4262 * Render inner blocks from the `core/columns` block for generating an excerpt. 4263 * 4264 * @since 5.2.0 4265 * @access private 4266 * @deprecated 5.8.0 Use _excerpt_render_inner_blocks() introduced in 5.8.0. 4267 * 4268 * @see _excerpt_render_inner_blocks() 4269 * 4270 * @param array $columns The parsed columns block. 4271 * @param array $allowed_blocks The list of allowed inner blocks. 4272 * @return string The rendered inner blocks. 4273 */ 4274 function _excerpt_render_inner_columns_blocks( $columns, $allowed_blocks ) { 4275 _deprecated_function( __FUNCTION__, '5.8.0', '_excerpt_render_inner_blocks()' ); 4276 4277 return _excerpt_render_inner_blocks( $columns, $allowed_blocks ); 4278 } 4279 4280 /** 4281 * Renders the duotone filter SVG and returns the CSS filter property to 4282 * reference the rendered SVG. 4283 * 4284 * @since 5.9.0 4285 * @deprecated 5.9.1 Use wp_get_duotone_filter_property() introduced in 5.9.1. 4286 * 4287 * @see wp_get_duotone_filter_property() 4288 * 4289 * @param array $preset Duotone preset value as seen in theme.json. 4290 * @return string Duotone CSS filter property. 4291 */ 4292 function wp_render_duotone_filter_preset( $preset ) { 4293 _deprecated_function( __FUNCTION__, '5.9.1', 'wp_get_duotone_filter_property()' ); 4294 4295 return wp_get_duotone_filter_property( $preset ); 4296 } 4297 4298 /** 4299 * Checks whether serialization of the current block's border properties should occur. 4300 * 4301 * @since 5.8.0 4302 * @access private 4303 * @deprecated 6.0.0 Use wp_should_skip_block_supports_serialization() introduced in 6.0.0. 4304 * 4305 * @see wp_should_skip_block_supports_serialization() 4306 * 4307 * @param WP_Block_Type $block_type Block type. 4308 * @return bool Whether serialization of the current block's border properties 4309 * should occur. 4310 */ 4311 function wp_skip_border_serialization( $block_type ) { 4312 _deprecated_function( __FUNCTION__, '6.0.0', 'wp_should_skip_block_supports_serialization()' ); 4313 4314 $border_support = $block_type->supports['__experimentalBorder'] ?? false; 4315 4316 return is_array( $border_support ) && 4317 array_key_exists( '__experimentalSkipSerialization', $border_support ) && 4318 $border_support['__experimentalSkipSerialization']; 4319 } 4320 4321 /** 4322 * Checks whether serialization of the current block's dimensions properties should occur. 4323 * 4324 * @since 5.9.0 4325 * @access private 4326 * @deprecated 6.0.0 Use wp_should_skip_block_supports_serialization() introduced in 6.0.0. 4327 * 4328 * @see wp_should_skip_block_supports_serialization() 4329 * 4330 * @param WP_Block_type $block_type Block type. 4331 * @return bool Whether to serialize spacing support styles & classes. 4332 */ 4333 function wp_skip_dimensions_serialization( $block_type ) { 4334 _deprecated_function( __FUNCTION__, '6.0.0', 'wp_should_skip_block_supports_serialization()' ); 4335 4336 $dimensions_support = $block_type->supports['__experimentalDimensions'] ?? false; 4337 4338 return is_array( $dimensions_support ) && 4339 array_key_exists( '__experimentalSkipSerialization', $dimensions_support ) && 4340 $dimensions_support['__experimentalSkipSerialization']; 4341 } 4342 4343 /** 4344 * Checks whether serialization of the current block's spacing properties should occur. 4345 * 4346 * @since 5.9.0 4347 * @access private 4348 * @deprecated 6.0.0 Use wp_should_skip_block_supports_serialization() introduced in 6.0.0. 4349 * 4350 * @see wp_should_skip_block_supports_serialization() 4351 * 4352 * @param WP_Block_Type $block_type Block type. 4353 * @return bool Whether to serialize spacing support styles & classes. 4354 */ 4355 function wp_skip_spacing_serialization( $block_type ) { 4356 _deprecated_function( __FUNCTION__, '6.0.0', 'wp_should_skip_block_supports_serialization()' ); 4357 4358 $spacing_support = $block_type->supports['spacing'] ?? false; 4359 4360 return is_array( $spacing_support ) && 4361 array_key_exists( '__experimentalSkipSerialization', $spacing_support ) && 4362 $spacing_support['__experimentalSkipSerialization']; 4363 } 4364 4365 /** 4366 * Inject the block editor assets that need to be loaded into the editor's iframe as an inline script. 4367 * 4368 * @since 5.8.0 4369 * @deprecated 6.0.0 4370 */ 4371 function wp_add_iframed_editor_assets_html() { 4372 _deprecated_function( __FUNCTION__, '6.0.0' ); 4373 } 4374 4375 /** 4376 * Retrieves thumbnail for an attachment. 4377 * Note that this works only for the (very) old image metadata style where 'thumb' was set, 4378 * and the 'sizes' array did not exist. This function returns false for the newer image metadata style 4379 * despite that 'thumbnail' is present in the 'sizes' array. 4380 * 4381 * @since 2.1.0 4382 * @deprecated 6.1.0 4383 * 4384 * @param int $post_id Optional. Attachment ID. Default is the ID of the global `$post`. 4385 * @return string|false Thumbnail file path on success, false on failure. 4386 */ 4387 function wp_get_attachment_thumb_file( $post_id = 0 ) { 4388 _deprecated_function( __FUNCTION__, '6.1.0' ); 4389 4390 $post_id = (int) $post_id; 4391 $post = get_post( $post_id ); 4392 4393 if ( ! $post ) { 4394 return false; 4395 } 4396 4397 // Use $post->ID rather than $post_id as get_post() may have used the global $post object. 4398 $imagedata = wp_get_attachment_metadata( $post->ID ); 4399 4400 if ( ! is_array( $imagedata ) ) { 4401 return false; 4402 } 4403 4404 $file = get_attached_file( $post->ID ); 4405 4406 if ( ! empty( $imagedata['thumb'] ) ) { 4407 $thumbfile = str_replace( wp_basename( $file ), $imagedata['thumb'], $file ); 4408 if ( file_exists( $thumbfile ) ) { 4409 /** 4410 * Filters the attachment thumbnail file path. 4411 * 4412 * @since 2.1.0 4413 * 4414 * @param string $thumbfile File path to the attachment thumbnail. 4415 * @param int $post_id Attachment ID. 4416 */ 4417 return apply_filters( 'wp_get_attachment_thumb_file', $thumbfile, $post->ID ); 4418 } 4419 } 4420 4421 return false; 4422 } 4423 4424 /** 4425 * Gets the path to a translation file for loading a textdomain just in time. 4426 * 4427 * Caches the retrieved results internally. 4428 * 4429 * @since 4.7.0 4430 * @deprecated 6.1.0 4431 * @access private 4432 * 4433 * @see _load_textdomain_just_in_time() 4434 * 4435 * @param string $domain Text domain. Unique identifier for retrieving translated strings. 4436 * @param bool $reset Whether to reset the internal cache. Used by the switch to locale functionality. 4437 * @return string|false The path to the translation file or false if no translation file was found. 4438 */ 4439 function _get_path_to_translation( $domain, $reset = false ) { 4440 _deprecated_function( __FUNCTION__, '6.1.0', 'WP_Textdomain_Registry' ); 4441 4442 static $available_translations = array(); 4443 4444 if ( true === $reset ) { 4445 $available_translations = array(); 4446 } 4447 4448 if ( ! isset( $available_translations[ $domain ] ) ) { 4449 $available_translations[ $domain ] = _get_path_to_translation_from_lang_dir( $domain ); 4450 } 4451 4452 return $available_translations[ $domain ]; 4453 } 4454 4455 /** 4456 * Gets the path to a translation file in the languages directory for the current locale. 4457 * 4458 * Holds a cached list of available .mo files to improve performance. 4459 * 4460 * @since 4.7.0 4461 * @deprecated 6.1.0 4462 * @access private 4463 * 4464 * @see _get_path_to_translation() 4465 * 4466 * @param string $domain Text domain. Unique identifier for retrieving translated strings. 4467 * @return string|false The path to the translation file or false if no translation file was found. 4468 */ 4469 function _get_path_to_translation_from_lang_dir( $domain ) { 4470 _deprecated_function( __FUNCTION__, '6.1.0', 'WP_Textdomain_Registry' ); 4471 4472 static $cached_mofiles = null; 4473 4474 if ( null === $cached_mofiles ) { 4475 $cached_mofiles = array(); 4476 4477 $locations = array( 4478 WP_LANG_DIR . '/plugins', 4479 WP_LANG_DIR . '/themes', 4480 ); 4481 4482 foreach ( $locations as $location ) { 4483 $mofiles = glob( $location . '/*.mo' ); 4484 if ( $mofiles ) { 4485 $cached_mofiles = array_merge( $cached_mofiles, $mofiles ); 4486 } 4487 } 4488 } 4489 4490 $locale = determine_locale(); 4491 $mofile = "{$domain}-{$locale}.mo"; 4492 4493 $path = WP_LANG_DIR . '/plugins/' . $mofile; 4494 if ( in_array( $path, $cached_mofiles, true ) ) { 4495 return $path; 4496 } 4497 4498 $path = WP_LANG_DIR . '/themes/' . $mofile; 4499 if ( in_array( $path, $cached_mofiles, true ) ) { 4500 return $path; 4501 } 4502 4503 return false; 4504 } 4505 4506 /** 4507 * Allows multiple block styles. 4508 * 4509 * @since 5.9.0 4510 * @deprecated 6.1.0 4511 * 4512 * @param array $metadata Metadata for registering a block type. 4513 * @return array Metadata for registering a block type. 4514 */ 4515 function _wp_multiple_block_styles( $metadata ) { 4516 _deprecated_function( __FUNCTION__, '6.1.0' ); 4517 return $metadata; 4518 } 4519 4520 /** 4521 * Generates an inline style for a typography feature e.g. text decoration, 4522 * text transform, and font style. 4523 * 4524 * @since 5.8.0 4525 * @access private 4526 * @deprecated 6.1.0 Use wp_style_engine_get_styles() introduced in 6.1.0. 4527 * 4528 * @see wp_style_engine_get_styles() 4529 * 4530 * @param array $attributes Block's attributes. 4531 * @param string $feature Key for the feature within the typography styles. 4532 * @param string $css_property Slug for the CSS property the inline style sets. 4533 * @return string CSS inline style. 4534 */ 4535 function wp_typography_get_css_variable_inline_style( $attributes, $feature, $css_property ) { 4536 _deprecated_function( __FUNCTION__, '6.1.0', 'wp_style_engine_get_styles()' ); 4537 4538 // Retrieve current attribute value or skip if not found. 4539 $style_value = _wp_array_get( $attributes, array( 'style', 'typography', $feature ), false ); 4540 if ( ! $style_value ) { 4541 return; 4542 } 4543 4544 // If we don't have a preset CSS variable, we'll assume it's a regular CSS value. 4545 if ( ! str_contains( $style_value, "var:preset|{$css_property}|" ) ) { 4546 return sprintf( '%s:%s;', $css_property, $style_value ); 4547 } 4548 4549 /* 4550 * We have a preset CSS variable as the style. 4551 * Get the style value from the string and return CSS style. 4552 */ 4553 $index_to_splice = strrpos( $style_value, '|' ) + 1; 4554 $slug = substr( $style_value, $index_to_splice ); 4555 4556 // Return the actual CSS inline style e.g. `text-decoration:var(--wp--preset--text-decoration--underline);`. 4557 return sprintf( '%s:var(--wp--preset--%s--%s);', $css_property, $css_property, $slug ); 4558 } 4559 4560 /** 4561 * Determines whether global terms are enabled. 4562 * 4563 * @since 3.0.0 4564 * @since 6.1.0 This function now always returns false. 4565 * @deprecated 6.1.0 4566 * 4567 * @return bool Always returns false. 4568 */ 4569 function global_terms_enabled() { 4570 _deprecated_function( __FUNCTION__, '6.1.0' ); 4571 4572 return false; 4573 } 4574 4575 /** 4576 * Filter the SQL clauses of an attachment query to include filenames. 4577 * 4578 * @since 4.7.0 4579 * @deprecated 6.0.3 4580 * @access private 4581 * 4582 * @param array $clauses An array including WHERE, GROUP BY, JOIN, ORDER BY, 4583 * DISTINCT, fields (SELECT), and LIMITS clauses. 4584 * @return array The unmodified clauses. 4585 */ 4586 function _filter_query_attachment_filenames( $clauses ) { 4587 _deprecated_function( __FUNCTION__, '6.0.3', 'add_filter( "wp_allow_query_attachment_by_filename", "__return_true" )' ); 4588 remove_filter( 'posts_clauses', __FUNCTION__ ); 4589 return $clauses; 4590 } 4591 4592 /** 4593 * Retrieves a page given its title. 4594 * 4595 * If more than one post uses the same title, the post with the smallest ID will be returned. 4596 * Be careful: in case of more than one post having the same title, it will check the oldest 4597 * publication date, not the smallest ID. 4598 * 4599 * Because this function uses the MySQL '=' comparison, $page_title will usually be matched 4600 * as case-insensitive with default collation. 4601 * 4602 * @since 2.1.0 4603 * @since 3.0.0 The `$post_type` parameter was added. 4604 * @deprecated 6.2.0 Use WP_Query. 4605 * 4606 * @global wpdb $wpdb WordPress database abstraction object. 4607 * 4608 * @param string $page_title Page title. 4609 * @param string $output Optional. The required return type. One of OBJECT, ARRAY_A, or ARRAY_N, which 4610 * correspond to a WP_Post object, an associative array, or a numeric array, 4611 * respectively. Default OBJECT. 4612 * @param string|array $post_type Optional. Post type or array of post types. Default 'page'. 4613 * @return WP_Post|array|null WP_Post (or array) on success, or null on failure. 4614 * 4615 * @phpstan-param 'OBJECT'|'ARRAY_A'|'ARRAY_N' $output 4616 * @phpstan-return ( 4617 * $output is 'ARRAY_A' ? non-empty-array<string, mixed>|null : ( 4618 * $output is 'ARRAY_N' ? non-empty-array<int, mixed>|null : WP_Post|null 4619 * ) 4620 * ) 4621 */ 4622 function get_page_by_title( $page_title, $output = OBJECT, $post_type = 'page' ) { 4623 _deprecated_function( __FUNCTION__, '6.2.0', 'WP_Query' ); 4624 global $wpdb; 4625 4626 if ( is_array( $post_type ) ) { 4627 $post_type = esc_sql( $post_type ); 4628 $post_type_in_string = "'" . implode( "','", $post_type ) . "'"; 4629 $sql = $wpdb->prepare( 4630 "SELECT ID 4631 FROM $wpdb->posts 4632 WHERE post_title = %s 4633 AND post_type IN ($post_type_in_string)", 4634 $page_title 4635 ); 4636 } else { 4637 $sql = $wpdb->prepare( 4638 "SELECT ID 4639 FROM $wpdb->posts 4640 WHERE post_title = %s 4641 AND post_type = %s", 4642 $page_title, 4643 $post_type 4644 ); 4645 } 4646 4647 $page = $wpdb->get_var( $sql ); 4648 4649 if ( $page ) { 4650 return get_post( $page, $output ); 4651 } 4652 4653 return null; 4654 } 4655 4656 /** 4657 * Returns the correct template for the site's home page. 4658 * 4659 * @access private 4660 * @since 6.0.0 4661 * @deprecated 6.2.0 Site Editor's server-side redirect for missing postType and postId 4662 * query args is removed. Thus, this function is no longer used. 4663 * 4664 * @return array|null A template object, or null if none could be found. 4665 */ 4666 function _resolve_home_block_template() { 4667 _deprecated_function( __FUNCTION__, '6.2.0' ); 4668 4669 $show_on_front = get_option( 'show_on_front' ); 4670 $front_page_id = get_option( 'page_on_front' ); 4671 4672 if ( 'page' === $show_on_front && $front_page_id ) { 4673 return array( 4674 'postType' => 'page', 4675 'postId' => $front_page_id, 4676 ); 4677 } 4678 4679 $hierarchy = array( 'front-page', 'home', 'index' ); 4680 $template = resolve_block_template( 'home', $hierarchy, '' ); 4681 4682 if ( ! $template ) { 4683 return null; 4684 } 4685 4686 return array( 4687 'postType' => 'wp_template', 4688 'postId' => $template->id, 4689 ); 4690 } 4691 4692 /** 4693 * Displays the link to the Windows Live Writer manifest file. 4694 * 4695 * @link https://msdn.microsoft.com/en-us/library/bb463265.aspx 4696 * @since 2.3.1 4697 * @deprecated 6.3.0 WLW manifest is no longer in use and no longer included in core, 4698 * so the output from this function is removed. 4699 */ 4700 function wlwmanifest_link() { 4701 _deprecated_function( __FUNCTION__, '6.3.0' ); 4702 } 4703 4704 /** 4705 * Queues comments for metadata lazy-loading. 4706 * 4707 * @since 4.5.0 4708 * @deprecated 6.3.0 Use wp_lazyload_comment_meta() instead. 4709 * 4710 * @param WP_Comment[] $comments Array of comment objects. 4711 */ 4712 function wp_queue_comments_for_comment_meta_lazyload( $comments ) { 4713 _deprecated_function( __FUNCTION__, '6.3.0', 'wp_lazyload_comment_meta()' ); 4714 // Don't use `wp_list_pluck()` to avoid by-reference manipulation. 4715 $comment_ids = array(); 4716 if ( is_array( $comments ) ) { 4717 foreach ( $comments as $comment ) { 4718 if ( $comment instanceof WP_Comment ) { 4719 $comment_ids[] = $comment->comment_ID; 4720 } 4721 } 4722 } 4723 4724 wp_lazyload_comment_meta( $comment_ids ); 4725 } 4726 4727 /** 4728 * Gets the default value to use for a `loading` attribute on an element. 4729 * 4730 * This function should only be called for a tag and context if lazy-loading is generally enabled. 4731 * 4732 * The function usually returns 'lazy', but uses certain heuristics to guess whether the current element is likely to 4733 * appear above the fold, in which case it returns a boolean `false`, which will lead to the `loading` attribute being 4734 * omitted on the element. The purpose of this refinement is to avoid lazy-loading elements that are within the initial 4735 * viewport, which can have a negative performance impact. 4736 * 4737 * Under the hood, the function uses {@see wp_increase_content_media_count()} every time it is called for an element 4738 * within the main content. If the element is the very first content element, the `loading` attribute will be omitted. 4739 * This default threshold of 3 content elements to omit the `loading` attribute for can be customized using the 4740 * {@see 'wp_omit_loading_attr_threshold'} filter. 4741 * 4742 * @since 5.9.0 4743 * @deprecated 6.3.0 Use wp_get_loading_optimization_attributes() instead. 4744 * @see wp_get_loading_optimization_attributes() 4745 * 4746 * @global WP_Query $wp_query WordPress Query object. 4747 * 4748 * @param string $context Context for the element for which the `loading` attribute value is requested. 4749 * @return string|bool The default `loading` attribute value. Either 'lazy', 'eager', or a boolean `false`, to indicate 4750 * that the `loading` attribute should be skipped. 4751 */ 4752 function wp_get_loading_attr_default( $context ) { 4753 _deprecated_function( __FUNCTION__, '6.3.0', 'wp_get_loading_optimization_attributes()' ); 4754 global $wp_query; 4755 4756 // Skip lazy-loading for the overall block template, as it is handled more granularly. 4757 if ( 'template' === $context ) { 4758 return false; 4759 } 4760 4761 /* 4762 * Do not lazy-load images in the header block template part, as they are likely above the fold. 4763 * For classic themes, this is handled in the condition below using the 'get_header' action. 4764 */ 4765 $header_area = WP_TEMPLATE_PART_AREA_HEADER; 4766 if ( "template_part_{$header_area}" === $context ) { 4767 return false; 4768 } 4769 4770 // Special handling for programmatically created image tags. 4771 if ( 'the_post_thumbnail' === $context || 'wp_get_attachment_image' === $context ) { 4772 /* 4773 * Skip programmatically created images within post content as they need to be handled together with the other 4774 * images within the post content. 4775 * Without this clause, they would already be counted below which skews the number and can result in the first 4776 * post content image being lazy-loaded only because there are images elsewhere in the post content. 4777 */ 4778 if ( doing_filter( 'the_content' ) ) { 4779 return false; 4780 } 4781 4782 // Conditionally skip lazy-loading on images before the loop. 4783 if ( 4784 // Only apply for main query but before the loop. 4785 $wp_query->before_loop && $wp_query->is_main_query() 4786 /* 4787 * Any image before the loop, but after the header has started should not be lazy-loaded, 4788 * except when the footer has already started which can happen when the current template 4789 * does not include any loop. 4790 */ 4791 && did_action( 'get_header' ) && ! did_action( 'get_footer' ) 4792 ) { 4793 return false; 4794 } 4795 } 4796 4797 /* 4798 * The first elements in 'the_content' or 'the_post_thumbnail' should not be lazy-loaded, 4799 * as they are likely above the fold. 4800 */ 4801 if ( 'the_content' === $context || 'the_post_thumbnail' === $context ) { 4802 // Only elements within the main query loop have special handling. 4803 if ( is_admin() || ! in_the_loop() || ! is_main_query() ) { 4804 return 'lazy'; 4805 } 4806 4807 // Increase the counter since this is a main query content element. 4808 $content_media_count = wp_increase_content_media_count(); 4809 4810 // If the count so far is below the threshold, return `false` so that the `loading` attribute is omitted. 4811 if ( $content_media_count <= wp_omit_loading_attr_threshold() ) { 4812 return false; 4813 } 4814 4815 // For elements after the threshold, lazy-load them as usual. 4816 return 'lazy'; 4817 } 4818 4819 // Lazy-load by default for any unknown context. 4820 return 'lazy'; 4821 } 4822 4823 /** 4824 * Adds `loading` attribute to an `img` HTML tag. 4825 * 4826 * @since 5.5.0 4827 * @deprecated 6.3.0 Use wp_img_tag_add_loading_optimization_attrs() instead. 4828 * @see wp_img_tag_add_loading_optimization_attrs() 4829 * 4830 * @param string $image The HTML `img` tag where the attribute should be added. 4831 * @param string $context Additional context to pass to the filters. 4832 * @return string Converted `img` tag with `loading` attribute added. 4833 */ 4834 function wp_img_tag_add_loading_attr( $image, $context ) { 4835 _deprecated_function( __FUNCTION__, '6.3.0', 'wp_img_tag_add_loading_optimization_attrs()' ); 4836 /* 4837 * Get loading attribute value to use. This must occur before the conditional check below so that even images that 4838 * are ineligible for being lazy-loaded are considered. 4839 */ 4840 $value = wp_get_loading_attr_default( $context ); 4841 4842 // Images should have source and dimension attributes for the `loading` attribute to be added. 4843 if ( ! str_contains( $image, ' src="' ) || ! str_contains( $image, ' width="' ) || ! str_contains( $image, ' height="' ) ) { 4844 return $image; 4845 } 4846 4847 /** This filter is documented in wp-includes/media.php */ 4848 $value = apply_filters( 'wp_img_tag_add_loading_attr', $value, $image, $context ); 4849 4850 if ( $value ) { 4851 if ( ! in_array( $value, array( 'lazy', 'eager' ), true ) ) { 4852 $value = 'lazy'; 4853 } 4854 4855 return str_replace( '<img', '<img loading="' . esc_attr( $value ) . '"', $image ); 4856 } 4857 4858 return $image; 4859 } 4860 4861 /** 4862 * Takes input from [0, n] and returns it as [0, 1]. 4863 * 4864 * Direct port of TinyColor's function, lightly simplified to maintain 4865 * consistency with TinyColor. 4866 * 4867 * @link https://github.com/bgrins/TinyColor 4868 * 4869 * @since 5.8.0 4870 * @deprecated 6.3.0 4871 * 4872 * @access private 4873 * 4874 * @param mixed $n Number of unknown type. 4875 * @param int $max Upper value of the range to bound to. 4876 * @return float Value in the range [0, 1]. 4877 */ 4878 function wp_tinycolor_bound01( $n, $max ) { 4879 _deprecated_function( __FUNCTION__, '6.3.0' ); 4880 if ( 'string' === gettype( $n ) && str_contains( $n, '.' ) && 1 === (float) $n ) { 4881 $n = '100%'; 4882 } 4883 4884 $n = min( $max, max( 0, (float) $n ) ); 4885 4886 // Automatically convert percentage into number. 4887 if ( 'string' === gettype( $n ) && str_contains( $n, '%' ) ) { 4888 $n = (int) ( $n * $max ) / 100; 4889 } 4890 4891 // Handle floating point rounding errors. 4892 if ( ( abs( $n - $max ) < 0.000001 ) ) { 4893 return 1.0; 4894 } 4895 4896 // Convert into [0, 1] range if it isn't already. 4897 return ( $n % $max ) / (float) $max; 4898 } 4899 4900 /** 4901 * Direct port of tinycolor's boundAlpha function to maintain consistency with 4902 * how tinycolor works. 4903 * 4904 * @link https://github.com/bgrins/TinyColor 4905 * 4906 * @since 5.9.0 4907 * @deprecated 6.3.0 4908 * 4909 * @access private 4910 * 4911 * @param mixed $n Number of unknown type. 4912 * @return float Value in the range [0,1]. 4913 */ 4914 function _wp_tinycolor_bound_alpha( $n ) { 4915 _deprecated_function( __FUNCTION__, '6.3.0' ); 4916 4917 if ( is_numeric( $n ) ) { 4918 $n = (float) $n; 4919 if ( $n >= 0 && $n <= 1 ) { 4920 return $n; 4921 } 4922 } 4923 return 1; 4924 } 4925 4926 /** 4927 * Rounds and converts values of an RGB object. 4928 * 4929 * Direct port of TinyColor's function, lightly simplified to maintain 4930 * consistency with TinyColor. 4931 * 4932 * @link https://github.com/bgrins/TinyColor 4933 * 4934 * @since 5.8.0 4935 * @deprecated 6.3.0 4936 * 4937 * @access private 4938 * 4939 * @param array $rgb_color RGB object. 4940 * @return array Rounded and converted RGB object. 4941 */ 4942 function wp_tinycolor_rgb_to_rgb( $rgb_color ) { 4943 _deprecated_function( __FUNCTION__, '6.3.0' ); 4944 4945 return array( 4946 'r' => wp_tinycolor_bound01( $rgb_color['r'], 255 ) * 255, 4947 'g' => wp_tinycolor_bound01( $rgb_color['g'], 255 ) * 255, 4948 'b' => wp_tinycolor_bound01( $rgb_color['b'], 255 ) * 255, 4949 ); 4950 } 4951 4952 /** 4953 * Helper function for hsl to rgb conversion. 4954 * 4955 * Direct port of TinyColor's function, lightly simplified to maintain 4956 * consistency with TinyColor. 4957 * 4958 * @link https://github.com/bgrins/TinyColor 4959 * 4960 * @since 5.8.0 4961 * @deprecated 6.3.0 4962 * 4963 * @access private 4964 * 4965 * @param float $p first component. 4966 * @param float $q second component. 4967 * @param float $t third component. 4968 * @return float R, G, or B component. 4969 */ 4970 function wp_tinycolor_hue_to_rgb( $p, $q, $t ) { 4971 _deprecated_function( __FUNCTION__, '6.3.0' ); 4972 4973 if ( $t < 0 ) { 4974 ++$t; 4975 } 4976 if ( $t > 1 ) { 4977 --$t; 4978 } 4979 if ( $t < 1 / 6 ) { 4980 return $p + ( $q - $p ) * 6 * $t; 4981 } 4982 if ( $t < 1 / 2 ) { 4983 return $q; 4984 } 4985 if ( $t < 2 / 3 ) { 4986 return $p + ( $q - $p ) * ( 2 / 3 - $t ) * 6; 4987 } 4988 return $p; 4989 } 4990 4991 /** 4992 * Converts an HSL object to an RGB object with converted and rounded values. 4993 * 4994 * Direct port of TinyColor's function, lightly simplified to maintain 4995 * consistency with TinyColor. 4996 * 4997 * @link https://github.com/bgrins/TinyColor 4998 * 4999 * @since 5.8.0 5000 * @deprecated 6.3.0 5001 * 5002 * @access private 5003 * 5004 * @param array $hsl_color HSL object. 5005 * @return array Rounded and converted RGB object. 5006 */ 5007 function wp_tinycolor_hsl_to_rgb( $hsl_color ) { 5008 _deprecated_function( __FUNCTION__, '6.3.0' ); 5009 5010 $h = wp_tinycolor_bound01( $hsl_color['h'], 360 ); 5011 $s = wp_tinycolor_bound01( $hsl_color['s'], 100 ); 5012 $l = wp_tinycolor_bound01( $hsl_color['l'], 100 ); 5013 5014 if ( 0 === $s ) { 5015 // Achromatic. 5016 $r = $l; 5017 $g = $l; 5018 $b = $l; 5019 } else { 5020 $q = $l < 0.5 ? $l * ( 1 + $s ) : $l + $s - $l * $s; 5021 $p = 2 * $l - $q; 5022 $r = wp_tinycolor_hue_to_rgb( $p, $q, $h + 1 / 3 ); 5023 $g = wp_tinycolor_hue_to_rgb( $p, $q, $h ); 5024 $b = wp_tinycolor_hue_to_rgb( $p, $q, $h - 1 / 3 ); 5025 } 5026 5027 return array( 5028 'r' => $r * 255, 5029 'g' => $g * 255, 5030 'b' => $b * 255, 5031 ); 5032 } 5033 5034 /** 5035 * Parses hex, hsl, and rgb CSS strings using the same regex as TinyColor v1.4.2 5036 * used in the JavaScript. Only colors output from react-color are implemented. 5037 * 5038 * Direct port of TinyColor's function, lightly simplified to maintain 5039 * consistency with TinyColor. 5040 * 5041 * @link https://github.com/bgrins/TinyColor 5042 * @link https://github.com/casesandberg/react-color/ 5043 * 5044 * @since 5.8.0 5045 * @since 5.9.0 Added alpha processing. 5046 * @deprecated 6.3.0 5047 * 5048 * @access private 5049 * 5050 * @param string $color_str CSS color string. 5051 * @return array RGB object. 5052 */ 5053 function wp_tinycolor_string_to_rgb( $color_str ) { 5054 _deprecated_function( __FUNCTION__, '6.3.0' ); 5055 5056 $color_str = strtolower( trim( $color_str ) ); 5057 5058 $css_integer = '[-\\+]?\\d+%?'; 5059 $css_number = '[-\\+]?\\d*\\.\\d+%?'; 5060 5061 $css_unit = '(?:' . $css_number . ')|(?:' . $css_integer . ')'; 5062 5063 $permissive_match3 = '[\\s|\\(]+(' . $css_unit . ')[,|\\s]+(' . $css_unit . ')[,|\\s]+(' . $css_unit . ')\\s*\\)?'; 5064 $permissive_match4 = '[\\s|\\(]+(' . $css_unit . ')[,|\\s]+(' . $css_unit . ')[,|\\s]+(' . $css_unit . ')[,|\\s]+(' . $css_unit . ')\\s*\\)?'; 5065 5066 $rgb_regexp = '/^rgb' . $permissive_match3 . '$/'; 5067 if ( preg_match( $rgb_regexp, $color_str, $match ) ) { 5068 $rgb = wp_tinycolor_rgb_to_rgb( 5069 array( 5070 'r' => $match[1], 5071 'g' => $match[2], 5072 'b' => $match[3], 5073 ) 5074 ); 5075 5076 $rgb['a'] = 1; 5077 5078 return $rgb; 5079 } 5080 5081 $rgba_regexp = '/^rgba' . $permissive_match4 . '$/'; 5082 if ( preg_match( $rgba_regexp, $color_str, $match ) ) { 5083 $rgb = wp_tinycolor_rgb_to_rgb( 5084 array( 5085 'r' => $match[1], 5086 'g' => $match[2], 5087 'b' => $match[3], 5088 ) 5089 ); 5090 5091 $rgb['a'] = _wp_tinycolor_bound_alpha( $match[4] ); 5092 5093 return $rgb; 5094 } 5095 5096 $hsl_regexp = '/^hsl' . $permissive_match3 . '$/'; 5097 if ( preg_match( $hsl_regexp, $color_str, $match ) ) { 5098 $rgb = wp_tinycolor_hsl_to_rgb( 5099 array( 5100 'h' => $match[1], 5101 's' => $match[2], 5102 'l' => $match[3], 5103 ) 5104 ); 5105 5106 $rgb['a'] = 1; 5107 5108 return $rgb; 5109 } 5110 5111 $hsla_regexp = '/^hsla' . $permissive_match4 . '$/'; 5112 if ( preg_match( $hsla_regexp, $color_str, $match ) ) { 5113 $rgb = wp_tinycolor_hsl_to_rgb( 5114 array( 5115 'h' => $match[1], 5116 's' => $match[2], 5117 'l' => $match[3], 5118 ) 5119 ); 5120 5121 $rgb['a'] = _wp_tinycolor_bound_alpha( $match[4] ); 5122 5123 return $rgb; 5124 } 5125 5126 $hex8_regexp = '/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/'; 5127 if ( preg_match( $hex8_regexp, $color_str, $match ) ) { 5128 $rgb = wp_tinycolor_rgb_to_rgb( 5129 array( 5130 'r' => base_convert( $match[1], 16, 10 ), 5131 'g' => base_convert( $match[2], 16, 10 ), 5132 'b' => base_convert( $match[3], 16, 10 ), 5133 ) 5134 ); 5135 5136 $rgb['a'] = _wp_tinycolor_bound_alpha( 5137 base_convert( $match[4], 16, 10 ) / 255 5138 ); 5139 5140 return $rgb; 5141 } 5142 5143 $hex6_regexp = '/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/'; 5144 if ( preg_match( $hex6_regexp, $color_str, $match ) ) { 5145 $rgb = wp_tinycolor_rgb_to_rgb( 5146 array( 5147 'r' => base_convert( $match[1], 16, 10 ), 5148 'g' => base_convert( $match[2], 16, 10 ), 5149 'b' => base_convert( $match[3], 16, 10 ), 5150 ) 5151 ); 5152 5153 $rgb['a'] = 1; 5154 5155 return $rgb; 5156 } 5157 5158 $hex4_regexp = '/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/'; 5159 if ( preg_match( $hex4_regexp, $color_str, $match ) ) { 5160 $rgb = wp_tinycolor_rgb_to_rgb( 5161 array( 5162 'r' => base_convert( $match[1] . $match[1], 16, 10 ), 5163 'g' => base_convert( $match[2] . $match[2], 16, 10 ), 5164 'b' => base_convert( $match[3] . $match[3], 16, 10 ), 5165 ) 5166 ); 5167 5168 $rgb['a'] = _wp_tinycolor_bound_alpha( 5169 base_convert( $match[4] . $match[4], 16, 10 ) / 255 5170 ); 5171 5172 return $rgb; 5173 } 5174 5175 $hex3_regexp = '/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/'; 5176 if ( preg_match( $hex3_regexp, $color_str, $match ) ) { 5177 $rgb = wp_tinycolor_rgb_to_rgb( 5178 array( 5179 'r' => base_convert( $match[1] . $match[1], 16, 10 ), 5180 'g' => base_convert( $match[2] . $match[2], 16, 10 ), 5181 'b' => base_convert( $match[3] . $match[3], 16, 10 ), 5182 ) 5183 ); 5184 5185 $rgb['a'] = 1; 5186 5187 return $rgb; 5188 } 5189 5190 /* 5191 * The JS color picker considers the string "transparent" to be a hex value, 5192 * so we need to handle it here as a special case. 5193 */ 5194 if ( 'transparent' === $color_str ) { 5195 return array( 5196 'r' => 0, 5197 'g' => 0, 5198 'b' => 0, 5199 'a' => 0, 5200 ); 5201 } 5202 } 5203 5204 /** 5205 * Returns the prefixed id for the duotone filter for use as a CSS id. 5206 * 5207 * @since 5.9.1 5208 * @deprecated 6.3.0 5209 * 5210 * @access private 5211 * 5212 * @param array $preset Duotone preset value as seen in theme.json. 5213 * @return string Duotone filter CSS id. 5214 */ 5215 function wp_get_duotone_filter_id( $preset ) { 5216 _deprecated_function( __FUNCTION__, '6.3.0' ); 5217 return WP_Duotone::get_filter_id_from_preset( $preset ); 5218 } 5219 5220 /** 5221 * Returns the CSS filter property url to reference the rendered SVG. 5222 * 5223 * @since 5.9.0 5224 * @since 6.1.0 Allow unset for preset colors. 5225 * @deprecated 6.3.0 5226 * 5227 * @access private 5228 * 5229 * @param array $preset Duotone preset value as seen in theme.json. 5230 * @return string Duotone CSS filter property url value. 5231 */ 5232 function wp_get_duotone_filter_property( $preset ) { 5233 _deprecated_function( __FUNCTION__, '6.3.0' ); 5234 return WP_Duotone::get_filter_css_property_value_from_preset( $preset ); 5235 } 5236 5237 /** 5238 * Returns the duotone filter SVG string for the preset. 5239 * 5240 * @since 5.9.1 5241 * @deprecated 6.3.0 Use WP_Duotone::get_filter_svg_from_preset() instead. 5242 * 5243 * @access private 5244 * 5245 * @param array $preset Duotone preset value as seen in theme.json. 5246 * @return string Duotone SVG filter. 5247 */ 5248 function wp_get_duotone_filter_svg( $preset ) { 5249 _deprecated_function( __FUNCTION__, '6.3.0', 'WP_Duotone::get_filter_svg_from_preset()' ); 5250 return WP_Duotone::get_filter_svg_from_preset( $preset ); 5251 } 5252 5253 /** 5254 * Registers the style and colors block attributes for block types that support it. 5255 * 5256 * @since 5.8.0 5257 * @deprecated 6.3.0 Use WP_Duotone::register_duotone_support() instead. 5258 * 5259 * @access private 5260 * 5261 * @param WP_Block_Type $block_type Block Type. 5262 */ 5263 function wp_register_duotone_support( $block_type ) { 5264 _deprecated_function( __FUNCTION__, '6.3.0', 'WP_Duotone::register_duotone_support()' ); 5265 return WP_Duotone::register_duotone_support( $block_type ); 5266 } 5267 5268 /** 5269 * Renders out the duotone stylesheet and SVG. 5270 * 5271 * @since 5.8.0 5272 * @since 6.1.0 Allow unset for preset colors. 5273 * @deprecated 6.3.0 Use WP_Duotone::render_duotone_support() instead. 5274 * 5275 * @access private 5276 * 5277 * @param string $block_content Rendered block content. 5278 * @param array $block Block object. 5279 * @return string Filtered block content. 5280 */ 5281 function wp_render_duotone_support( $block_content, $block ) { 5282 _deprecated_function( __FUNCTION__, '6.3.0', 'WP_Duotone::render_duotone_support()' ); 5283 $wp_block = new WP_Block( $block ); 5284 return WP_Duotone::render_duotone_support( $block_content, $block, $wp_block ); 5285 } 5286 5287 /** 5288 * Returns a string containing the SVGs to be referenced as filters (duotone). 5289 * 5290 * @since 5.9.1 5291 * @deprecated 6.3.0 SVG generation is handled on a per-block basis in block supports. 5292 * 5293 * @return string 5294 */ 5295 function wp_get_global_styles_svg_filters() { 5296 _deprecated_function( __FUNCTION__, '6.3.0' ); 5297 5298 /* 5299 * Ignore cache when the development mode is set to 'theme', so it doesn't interfere with the theme 5300 * developer's workflow. 5301 */ 5302 $can_use_cached = ! wp_is_development_mode( 'theme' ); 5303 $cache_group = 'theme_json'; 5304 $cache_key = 'wp_get_global_styles_svg_filters'; 5305 if ( $can_use_cached ) { 5306 $cached = wp_cache_get( $cache_key, $cache_group ); 5307 if ( $cached ) { 5308 return $cached; 5309 } 5310 } 5311 5312 $supports_theme_json = wp_theme_has_theme_json(); 5313 5314 $origins = array( 'default', 'theme', 'custom' ); 5315 if ( ! $supports_theme_json ) { 5316 $origins = array( 'default' ); 5317 } 5318 5319 $tree = WP_Theme_JSON_Resolver::get_merged_data(); 5320 $svgs = $tree->get_svg_filters( $origins ); 5321 5322 if ( $can_use_cached ) { 5323 wp_cache_set( $cache_key, $svgs, $cache_group ); 5324 } 5325 5326 return $svgs; 5327 } 5328 5329 /** 5330 * Renders the SVG filters supplied by theme.json. 5331 * 5332 * Note that this doesn't render the per-block user-defined 5333 * filters which are handled by wp_render_duotone_support, 5334 * but it should be rendered before the filtered content 5335 * in the body to satisfy Safari's rendering quirks. 5336 * 5337 * @since 5.9.1 5338 * @deprecated 6.3.0 SVG generation is handled on a per-block basis in block supports. 5339 */ 5340 function wp_global_styles_render_svg_filters() { 5341 _deprecated_function( __FUNCTION__, '6.3.0' ); 5342 5343 /* 5344 * When calling via the in_admin_header action, we only want to render the 5345 * SVGs on block editor pages. 5346 */ 5347 if ( 5348 is_admin() && 5349 ! get_current_screen()->is_block_editor() 5350 ) { 5351 return; 5352 } 5353 5354 $filters = wp_get_global_styles_svg_filters(); 5355 if ( ! empty( $filters ) ) { 5356 echo $filters; 5357 } 5358 } 5359 5360 /** 5361 * Build an array with CSS classes and inline styles defining the colors 5362 * which will be applied to the navigation markup in the front-end. 5363 * 5364 * @since 5.9.0 5365 * @deprecated 6.3.0 This was removed from the Navigation Submenu block in favour of `wp_apply_colors_support()`. 5366 * `wp_apply_colors_support()` returns an array with similar class and style values, 5367 * but with different keys: `class` and `style`. 5368 * 5369 * @param array $context Navigation block context. 5370 * @param array $attributes Block attributes. 5371 * @param bool $is_sub_menu Whether the block is a sub-menu. 5372 * @return array Colors CSS classes and inline styles. 5373 */ 5374 function block_core_navigation_submenu_build_css_colors( $context, $attributes, $is_sub_menu = false ) { 5375 _deprecated_function( __FUNCTION__, '6.3.0' ); 5376 $colors = array( 5377 'css_classes' => array(), 5378 'inline_styles' => '', 5379 ); 5380 5381 // Text color. 5382 $named_text_color = null; 5383 $custom_text_color = null; 5384 5385 if ( $is_sub_menu && array_key_exists( 'customOverlayTextColor', $context ) ) { 5386 $custom_text_color = $context['customOverlayTextColor']; 5387 } elseif ( $is_sub_menu && array_key_exists( 'overlayTextColor', $context ) ) { 5388 $named_text_color = $context['overlayTextColor']; 5389 } elseif ( array_key_exists( 'customTextColor', $context ) ) { 5390 $custom_text_color = $context['customTextColor']; 5391 } elseif ( array_key_exists( 'textColor', $context ) ) { 5392 $named_text_color = $context['textColor']; 5393 } elseif ( isset( $context['style']['color']['text'] ) ) { 5394 $custom_text_color = $context['style']['color']['text']; 5395 } 5396 5397 // If has text color. 5398 if ( ! is_null( $named_text_color ) ) { 5399 // Add the color class. 5400 array_push( $colors['css_classes'], 'has-text-color', sprintf( 'has-%s-color', $named_text_color ) ); 5401 } elseif ( ! is_null( $custom_text_color ) ) { 5402 // Add the custom color inline style. 5403 $colors['css_classes'][] = 'has-text-color'; 5404 $colors['inline_styles'] .= sprintf( 'color: %s;', $custom_text_color ); 5405 } 5406 5407 // Background color. 5408 $named_background_color = null; 5409 $custom_background_color = null; 5410 5411 if ( $is_sub_menu && array_key_exists( 'customOverlayBackgroundColor', $context ) ) { 5412 $custom_background_color = $context['customOverlayBackgroundColor']; 5413 } elseif ( $is_sub_menu && array_key_exists( 'overlayBackgroundColor', $context ) ) { 5414 $named_background_color = $context['overlayBackgroundColor']; 5415 } elseif ( array_key_exists( 'customBackgroundColor', $context ) ) { 5416 $custom_background_color = $context['customBackgroundColor']; 5417 } elseif ( array_key_exists( 'backgroundColor', $context ) ) { 5418 $named_background_color = $context['backgroundColor']; 5419 } elseif ( isset( $context['style']['color']['background'] ) ) { 5420 $custom_background_color = $context['style']['color']['background']; 5421 } 5422 5423 // If has background color. 5424 if ( ! is_null( $named_background_color ) ) { 5425 // Add the background-color class. 5426 array_push( $colors['css_classes'], 'has-background', sprintf( 'has-%s-background-color', $named_background_color ) ); 5427 } elseif ( ! is_null( $custom_background_color ) ) { 5428 // Add the custom background-color inline style. 5429 $colors['css_classes'][] = 'has-background'; 5430 $colors['inline_styles'] .= sprintf( 'background-color: %s;', $custom_background_color ); 5431 } 5432 5433 return $colors; 5434 } 5435 5436 /** 5437 * Runs the theme.json webfonts handler. 5438 * 5439 * Using `WP_Theme_JSON_Resolver`, it gets the fonts defined 5440 * in the `theme.json` for the current selection and style 5441 * variations, validates the font-face properties, generates 5442 * the '@font-face' style declarations, and then enqueues the 5443 * styles for both the editor and front-end. 5444 * 5445 * Design Notes: 5446 * This is not a public API, but rather an internal handler. 5447 * A future public Webfonts API will replace this stopgap code. 5448 * 5449 * This code design is intentional. 5450 * a. It hides the inner-workings. 5451 * b. It does not expose API ins or outs for consumption. 5452 * c. It only works with a theme's `theme.json`. 5453 * 5454 * Why? 5455 * a. To avoid backwards-compatibility issues when 5456 * the Webfonts API is introduced in Core. 5457 * b. To make `fontFace` declarations in `theme.json` work. 5458 * 5459 * @link https://github.com/WordPress/gutenberg/issues/40472 5460 * 5461 * @since 6.0.0 5462 * @deprecated 6.4.0 Use wp_print_font_faces() instead. 5463 * @access private 5464 */ 5465 function _wp_theme_json_webfonts_handler() { 5466 _deprecated_function( __FUNCTION__, '6.4.0', 'wp_print_font_faces' ); 5467 5468 // Block themes are unavailable during installation. 5469 if ( wp_installing() ) { 5470 return; 5471 } 5472 5473 if ( ! wp_theme_has_theme_json() ) { 5474 return; 5475 } 5476 5477 // Webfonts to be processed. 5478 $registered_webfonts = array(); 5479 5480 /** 5481 * Gets the webfonts from theme.json. 5482 * 5483 * @since 6.0.0 5484 * 5485 * @return array Array of defined webfonts. 5486 */ 5487 $fn_get_webfonts_from_theme_json = static function() { 5488 // Get settings from theme.json. 5489 $settings = WP_Theme_JSON_Resolver::get_merged_data()->get_settings(); 5490 5491 // If in the editor, add webfonts defined in variations. 5492 if ( is_admin() || wp_is_rest_endpoint() ) { 5493 $variations = WP_Theme_JSON_Resolver::get_style_variations(); 5494 foreach ( $variations as $variation ) { 5495 // Skip if fontFamilies are not defined in the variation. 5496 if ( empty( $variation['settings']['typography']['fontFamilies'] ) ) { 5497 continue; 5498 } 5499 5500 // Initialize the array structure. 5501 if ( empty( $settings['typography'] ) ) { 5502 $settings['typography'] = array(); 5503 } 5504 if ( empty( $settings['typography']['fontFamilies'] ) ) { 5505 $settings['typography']['fontFamilies'] = array(); 5506 } 5507 if ( empty( $settings['typography']['fontFamilies']['theme'] ) ) { 5508 $settings['typography']['fontFamilies']['theme'] = array(); 5509 } 5510 5511 // Combine variations with settings. Remove duplicates. 5512 $settings['typography']['fontFamilies']['theme'] = array_merge( $settings['typography']['fontFamilies']['theme'], $variation['settings']['typography']['fontFamilies']['theme'] ); 5513 $settings['typography']['fontFamilies'] = array_unique( $settings['typography']['fontFamilies'] ); 5514 } 5515 } 5516 5517 // Bail out early if there are no settings for webfonts. 5518 if ( empty( $settings['typography']['fontFamilies'] ) ) { 5519 return array(); 5520 } 5521 5522 $webfonts = array(); 5523 5524 // Look for fontFamilies. 5525 foreach ( $settings['typography']['fontFamilies'] as $font_families ) { 5526 foreach ( $font_families as $font_family ) { 5527 5528 // Skip if fontFace is not defined. 5529 if ( empty( $font_family['fontFace'] ) ) { 5530 continue; 5531 } 5532 5533 // Skip if fontFace is not an array of webfonts. 5534 if ( ! is_array( $font_family['fontFace'] ) ) { 5535 continue; 5536 } 5537 5538 $webfonts = array_merge( $webfonts, $font_family['fontFace'] ); 5539 } 5540 } 5541 5542 return $webfonts; 5543 }; 5544 5545 /** 5546 * Transforms each 'src' into an URI by replacing 'file:./' 5547 * placeholder from theme.json. 5548 * 5549 * The absolute path to the webfont file(s) cannot be defined in 5550 * theme.json. `file:./` is the placeholder which is replaced by 5551 * the theme's URL path to the theme's root. 5552 * 5553 * @since 6.0.0 5554 * 5555 * @param array $src Webfont file(s) `src`. 5556 * @return array Webfont's `src` in URI. 5557 */ 5558 $fn_transform_src_into_uri = static function( array $src ) { 5559 foreach ( $src as $key => $url ) { 5560 // Tweak the URL to be relative to the theme root. 5561 if ( ! str_starts_with( $url, 'file:./' ) ) { 5562 continue; 5563 } 5564 5565 $src[ $key ] = get_theme_file_uri( str_replace( 'file:./', '', $url ) ); 5566 } 5567 5568 return $src; 5569 }; 5570 5571 /** 5572 * Converts the font-face properties (i.e. keys) into kebab-case. 5573 * 5574 * @since 6.0.0 5575 * 5576 * @param array $font_face Font face to convert. 5577 * @return array Font faces with each property in kebab-case format. 5578 */ 5579 $fn_convert_keys_to_kebab_case = static function( array $font_face ) { 5580 foreach ( $font_face as $property => $value ) { 5581 $kebab_case = _wp_to_kebab_case( $property ); 5582 $font_face[ $kebab_case ] = $value; 5583 if ( $kebab_case !== $property ) { 5584 unset( $font_face[ $property ] ); 5585 } 5586 } 5587 5588 return $font_face; 5589 }; 5590 5591 /** 5592 * Validates a webfont. 5593 * 5594 * @since 6.0.0 5595 * 5596 * @param array $webfont The webfont arguments. 5597 * @return array|false The validated webfont arguments, or false if the webfont is invalid. 5598 */ 5599 $fn_validate_webfont = static function( $webfont ) { 5600 $webfont = wp_parse_args( 5601 $webfont, 5602 array( 5603 'font-family' => '', 5604 'font-style' => 'normal', 5605 'font-weight' => '400', 5606 'font-display' => 'fallback', 5607 'src' => array(), 5608 ) 5609 ); 5610 5611 // Check the font-family. 5612 if ( empty( $webfont['font-family'] ) || ! is_string( $webfont['font-family'] ) ) { 5613 trigger_error( __( 'Webfont font family must be a non-empty string.' ) ); 5614 5615 return false; 5616 } 5617 5618 // Check that the `src` property is defined and a valid type. 5619 if ( empty( $webfont['src'] ) || ( ! is_string( $webfont['src'] ) && ! is_array( $webfont['src'] ) ) ) { 5620 trigger_error( __( 'Webfont src must be a non-empty string or an array of strings.' ) ); 5621 5622 return false; 5623 } 5624 5625 // Validate the `src` property. 5626 foreach ( (array) $webfont['src'] as $src ) { 5627 if ( ! is_string( $src ) || '' === trim( $src ) ) { 5628 trigger_error( __( 'Each webfont src must be a non-empty string.' ) ); 5629 5630 return false; 5631 } 5632 } 5633 5634 // Check the font-weight. 5635 if ( ! is_string( $webfont['font-weight'] ) && ! is_int( $webfont['font-weight'] ) ) { 5636 trigger_error( __( 'Webfont font weight must be a properly formatted string or integer.' ) ); 5637 5638 return false; 5639 } 5640 5641 // Check the font-display. 5642 if ( ! in_array( $webfont['font-display'], array( 'auto', 'block', 'fallback', 'optional', 'swap' ), true ) ) { 5643 $webfont['font-display'] = 'fallback'; 5644 } 5645 5646 $valid_props = array( 5647 'ascend-override', 5648 'descend-override', 5649 'font-display', 5650 'font-family', 5651 'font-stretch', 5652 'font-style', 5653 'font-weight', 5654 'font-variant', 5655 'font-feature-settings', 5656 'font-variation-settings', 5657 'line-gap-override', 5658 'size-adjust', 5659 'src', 5660 'unicode-range', 5661 ); 5662 5663 foreach ( $webfont as $prop => $value ) { 5664 if ( ! in_array( $prop, $valid_props, true ) ) { 5665 unset( $webfont[ $prop ] ); 5666 } 5667 } 5668 5669 return $webfont; 5670 }; 5671 5672 /** 5673 * Registers webfonts declared in theme.json. 5674 * 5675 * @since 6.0.0 5676 * 5677 * @uses $registered_webfonts To access and update the registered webfonts registry (passed by reference). 5678 * @uses $fn_get_webfonts_from_theme_json To run the function that gets the webfonts from theme.json. 5679 * @uses $fn_convert_keys_to_kebab_case To run the function that converts keys into kebab-case. 5680 * @uses $fn_validate_webfont To run the function that validates each font-face (webfont) from theme.json. 5681 */ 5682 $fn_register_webfonts = static function() use ( &$registered_webfonts, $fn_get_webfonts_from_theme_json, $fn_convert_keys_to_kebab_case, $fn_validate_webfont, $fn_transform_src_into_uri ) { 5683 $registered_webfonts = array(); 5684 5685 foreach ( $fn_get_webfonts_from_theme_json() as $webfont ) { 5686 if ( ! is_array( $webfont ) ) { 5687 continue; 5688 } 5689 5690 $webfont = $fn_convert_keys_to_kebab_case( $webfont ); 5691 5692 $webfont = $fn_validate_webfont( $webfont ); 5693 5694 $webfont['src'] = $fn_transform_src_into_uri( (array) $webfont['src'] ); 5695 5696 // Skip if not valid. 5697 if ( empty( $webfont ) ) { 5698 continue; 5699 } 5700 5701 $registered_webfonts[] = $webfont; 5702 } 5703 }; 5704 5705 /** 5706 * Orders 'src' items to optimize for browser support. 5707 * 5708 * @since 6.0.0 5709 * 5710 * @param array $webfont Webfont to process. 5711 * @return array Ordered `src` items. 5712 */ 5713 $fn_order_src = static function( array $webfont ) { 5714 $src = array(); 5715 $src_ordered = array(); 5716 5717 foreach ( $webfont['src'] as $url ) { 5718 // Add data URIs first. 5719 if ( str_starts_with( trim( $url ), 'data:' ) ) { 5720 $src_ordered[] = array( 5721 'url' => $url, 5722 'format' => 'data', 5723 ); 5724 continue; 5725 } 5726 $format = pathinfo( $url, PATHINFO_EXTENSION ); 5727 $src[ $format ] = $url; 5728 } 5729 5730 // Add woff2. 5731 if ( ! empty( $src['woff2'] ) ) { 5732 $src_ordered[] = array( 5733 'url' => sanitize_url( $src['woff2'] ), 5734 'format' => 'woff2', 5735 ); 5736 } 5737 5738 // Add woff. 5739 if ( ! empty( $src['woff'] ) ) { 5740 $src_ordered[] = array( 5741 'url' => sanitize_url( $src['woff'] ), 5742 'format' => 'woff', 5743 ); 5744 } 5745 5746 // Add ttf. 5747 if ( ! empty( $src['ttf'] ) ) { 5748 $src_ordered[] = array( 5749 'url' => sanitize_url( $src['ttf'] ), 5750 'format' => 'truetype', 5751 ); 5752 } 5753 5754 // Add eot. 5755 if ( ! empty( $src['eot'] ) ) { 5756 $src_ordered[] = array( 5757 'url' => sanitize_url( $src['eot'] ), 5758 'format' => 'embedded-opentype', 5759 ); 5760 } 5761 5762 // Add otf. 5763 if ( ! empty( $src['otf'] ) ) { 5764 $src_ordered[] = array( 5765 'url' => sanitize_url( $src['otf'] ), 5766 'format' => 'opentype', 5767 ); 5768 } 5769 $webfont['src'] = $src_ordered; 5770 5771 return $webfont; 5772 }; 5773 5774 /** 5775 * Compiles the 'src' into valid CSS. 5776 * 5777 * @since 6.0.0 5778 * @since 6.2.0 Removed local() CSS. 5779 * 5780 * @param string $font_family Font family. 5781 * @param array $value Value to process. 5782 * @return string The CSS. 5783 */ 5784 $fn_compile_src = static function( $font_family, array $value ) { 5785 $src = ''; 5786 5787 foreach ( $value as $item ) { 5788 $src .= ( 'data' === $item['format'] ) 5789 ? ", url({$item['url']})" 5790 : ", url('{$item['url']}') format('{$item['format']}')"; 5791 } 5792 5793 $src = ltrim( $src, ', ' ); 5794 5795 return $src; 5796 }; 5797 5798 /** 5799 * Compiles the font variation settings. 5800 * 5801 * @since 6.0.0 5802 * 5803 * @param array $font_variation_settings Array of font variation settings. 5804 * @return string The CSS. 5805 */ 5806 $fn_compile_variations = static function( array $font_variation_settings ) { 5807 $variations = ''; 5808 5809 foreach ( $font_variation_settings as $key => $value ) { 5810 $variations .= "$key $value"; 5811 } 5812 5813 return $variations; 5814 }; 5815 5816 /** 5817 * Builds the font-family's CSS. 5818 * 5819 * @since 6.0.0 5820 * 5821 * @uses $fn_compile_src To run the function that compiles the src. 5822 * @uses $fn_compile_variations To run the function that compiles the variations. 5823 * 5824 * @param array $webfont Webfont to process. 5825 * @return string This font-family's CSS. 5826 */ 5827 $fn_build_font_face_css = static function( array $webfont ) use ( $fn_compile_src, $fn_compile_variations ) { 5828 $css = ''; 5829 5830 // Wrap font-family in quotes if it contains spaces. 5831 if ( 5832 str_contains( $webfont['font-family'], ' ' ) && 5833 ! str_contains( $webfont['font-family'], '"' ) && 5834 ! str_contains( $webfont['font-family'], "'" ) 5835 ) { 5836 $webfont['font-family'] = '"' . $webfont['font-family'] . '"'; 5837 } 5838 5839 foreach ( $webfont as $key => $value ) { 5840 /* 5841 * Skip "provider", since it's for internal API use, 5842 * and not a valid CSS property. 5843 */ 5844 if ( 'provider' === $key ) { 5845 continue; 5846 } 5847 5848 // Compile the "src" parameter. 5849 if ( 'src' === $key ) { 5850 $value = $fn_compile_src( $webfont['font-family'], $value ); 5851 } 5852 5853 // If font-variation-settings is an array, convert it to a string. 5854 if ( 'font-variation-settings' === $key && is_array( $value ) ) { 5855 $value = $fn_compile_variations( $value ); 5856 } 5857 5858 if ( ! empty( $value ) ) { 5859 $css .= "$key:$value;"; 5860 } 5861 } 5862 5863 return $css; 5864 }; 5865 5866 /** 5867 * Gets the '@font-face' CSS styles for locally-hosted font files. 5868 * 5869 * @since 6.0.0 5870 * 5871 * @uses $registered_webfonts To access and update the registered webfonts registry (passed by reference). 5872 * @uses $fn_order_src To run the function that orders the src. 5873 * @uses $fn_build_font_face_css To run the function that builds the font-face CSS. 5874 * 5875 * @return string The `@font-face` CSS. 5876 */ 5877 $fn_get_css = static function() use ( &$registered_webfonts, $fn_order_src, $fn_build_font_face_css ) { 5878 $css = ''; 5879 5880 foreach ( $registered_webfonts as $webfont ) { 5881 // Order the webfont's `src` items to optimize for browser support. 5882 $webfont = $fn_order_src( $webfont ); 5883 5884 // Build the @font-face CSS for this webfont. 5885 $css .= '@font-face{' . $fn_build_font_face_css( $webfont ) . '}'; 5886 } 5887 5888 return $css; 5889 }; 5890 5891 /** 5892 * Generates and enqueues webfonts styles. 5893 * 5894 * @since 6.0.0 5895 * 5896 * @uses $fn_get_css To run the function that gets the CSS. 5897 */ 5898 $fn_generate_and_enqueue_styles = static function() use ( $fn_get_css ) { 5899 // Generate the styles. 5900 $styles = $fn_get_css(); 5901 5902 // Bail out if there are no styles to enqueue. 5903 if ( '' === $styles ) { 5904 return; 5905 } 5906 5907 // Enqueue the stylesheet. 5908 wp_register_style( 'wp-webfonts', '' ); 5909 wp_enqueue_style( 'wp-webfonts' ); 5910 5911 // Add the styles to the stylesheet. 5912 wp_add_inline_style( 'wp-webfonts', $styles ); 5913 }; 5914 5915 /** 5916 * Generates and enqueues editor styles. 5917 * 5918 * @since 6.0.0 5919 * 5920 * @uses $fn_get_css To run the function that gets the CSS. 5921 */ 5922 $fn_generate_and_enqueue_editor_styles = static function() use ( $fn_get_css ) { 5923 // Generate the styles. 5924 $styles = $fn_get_css(); 5925 5926 // Bail out if there are no styles to enqueue. 5927 if ( '' === $styles ) { 5928 return; 5929 } 5930 5931 wp_add_inline_style( 'wp-block-library', $styles ); 5932 }; 5933 5934 add_action( 'wp_loaded', $fn_register_webfonts ); 5935 add_action( 'wp_enqueue_scripts', $fn_generate_and_enqueue_styles ); 5936 add_action( 'admin_init', $fn_generate_and_enqueue_editor_styles ); 5937 } 5938 5939 /** 5940 * Prints the CSS in the embed iframe header. 5941 * 5942 * @since 4.4.0 5943 * @deprecated 6.4.0 Use wp_enqueue_embed_styles() instead. 5944 */ 5945 function print_embed_styles() { 5946 _deprecated_function( __FUNCTION__, '6.4.0', 'wp_enqueue_embed_styles' ); 5947 5948 $suffix = SCRIPT_DEBUG ? '' : '.min'; 5949 ?> 5950 <style> 5951 <?php echo file_get_contents( ABSPATH . WPINC . "/css/wp-embed-template$suffix.css" ); ?> 5952 </style> 5953 <?php 5954 } 5955 5956 /** 5957 * Prints the important emoji-related styles. 5958 * 5959 * @since 4.2.0 5960 * @deprecated 6.4.0 Use wp_enqueue_emoji_styles() instead. 5961 */ 5962 function print_emoji_styles() { 5963 _deprecated_function( __FUNCTION__, '6.4.0', 'wp_enqueue_emoji_styles' ); 5964 static $printed = false; 5965 5966 if ( $printed ) { 5967 return; 5968 } 5969 5970 $printed = true; 5971 5972 ?> 5973 <style> 5974 img.wp-smiley, 5975 img.emoji { 5976 display: inline !important; 5977 border: none !important; 5978 box-shadow: none !important; 5979 height: 1em !important; 5980 width: 1em !important; 5981 margin: 0 0.07em !important; 5982 vertical-align: -0.1em !important; 5983 background: none !important; 5984 padding: 0 !important; 5985 } 5986 </style> 5987 <?php 5988 } 5989 5990 /** 5991 * Prints style and scripts for the admin bar. 5992 * 5993 * @since 3.1.0 5994 * @deprecated 6.4.0 Use wp_enqueue_admin_bar_header_styles() instead. 5995 */ 5996 function wp_admin_bar_header() { 5997 _deprecated_function( __FUNCTION__, '6.4.0', 'wp_enqueue_admin_bar_header_styles' ); 5998 ?> 5999 <style media="print">#wpadminbar { display:none; }</style> 6000 <?php 6001 } 6002 6003 /** 6004 * Prints default admin bar callback. 6005 * 6006 * @since 3.1.0 6007 * @deprecated 6.4.0 Use wp_enqueue_admin_bar_bump_styles() instead. 6008 */ 6009 function _admin_bar_bump_cb() { 6010 _deprecated_function( __FUNCTION__, '6.4.0', 'wp_enqueue_admin_bar_bump_styles' ); 6011 ?> 6012 <style media="screen"> 6013 html { margin-top: 32px !important; } 6014 @media screen and ( max-width: 782px ) { 6015 html { margin-top: 46px !important; } 6016 } 6017 </style> 6018 <?php 6019 } 6020 6021 /** 6022 * Runs a remote HTTPS request to detect whether HTTPS supported, and stores potential errors. 6023 * 6024 * This internal function is called by a regular Cron hook to ensure HTTPS support is detected and maintained. 6025 * 6026 * @since 5.7.0 6027 * @deprecated 6.4.0 The `wp_update_https_detection_errors()` function is no longer used and has been replaced by 6028 * `wp_get_https_detection_errors()`. Previously the function was called by a regular Cron hook to 6029 * update the `https_detection_errors` option, but this is no longer necessary as the errors are 6030 * retrieved directly in Site Health and no longer used outside of Site Health. 6031 * @access private 6032 */ 6033 function wp_update_https_detection_errors() { 6034 _deprecated_function( __FUNCTION__, '6.4.0' ); 6035 6036 /** 6037 * Short-circuits the process of detecting errors related to HTTPS support. 6038 * 6039 * Returning a `WP_Error` from the filter will effectively short-circuit the default logic of trying a remote 6040 * request to the site over HTTPS, storing the errors array from the returned `WP_Error` instead. 6041 * 6042 * @since 5.7.0 6043 * @deprecated 6.4.0 The `wp_update_https_detection_errors` filter is no longer used and has been replaced by `pre_wp_get_https_detection_errors`. 6044 * 6045 * @param null|WP_Error $pre Error object to short-circuit detection, 6046 * or null to continue with the default behavior. 6047 */ 6048 $support_errors = apply_filters( 'pre_wp_update_https_detection_errors', null ); 6049 if ( is_wp_error( $support_errors ) ) { 6050 update_option( 'https_detection_errors', $support_errors->errors, false ); 6051 return; 6052 } 6053 6054 $support_errors = wp_get_https_detection_errors(); 6055 6056 update_option( 'https_detection_errors', $support_errors ); 6057 } 6058 6059 /** 6060 * Adds `decoding` attribute to an `img` HTML tag. 6061 * 6062 * The `decoding` attribute allows developers to indicate whether the 6063 * browser can decode the image off the main thread (`async`), on the 6064 * main thread (`sync`) or as determined by the browser (`auto`). 6065 * 6066 * By default WordPress adds `decoding="async"` to images but developers 6067 * can use the {@see 'wp_img_tag_add_decoding_attr'} filter to modify this 6068 * to remove the attribute or set it to another accepted value. 6069 * 6070 * @since 6.1.0 6071 * @deprecated 6.4.0 Use wp_img_tag_add_loading_optimization_attrs() instead. 6072 * @see wp_img_tag_add_loading_optimization_attrs() 6073 * 6074 * @param string $image The HTML `img` tag where the attribute should be added. 6075 * @param string $context Additional context to pass to the filters. 6076 * @return string Converted `img` tag with `decoding` attribute added. 6077 */ 6078 function wp_img_tag_add_decoding_attr( $image, $context ) { 6079 _deprecated_function( __FUNCTION__, '6.4.0', 'wp_img_tag_add_loading_optimization_attrs()' ); 6080 6081 /* 6082 * Only apply the decoding attribute to images that have a src attribute that 6083 * starts with a double quote, ensuring escaped JSON is also excluded. 6084 */ 6085 if ( ! str_contains( $image, ' src="' ) ) { 6086 return $image; 6087 } 6088 6089 /** This action is documented in wp-includes/media.php */ 6090 $value = apply_filters( 'wp_img_tag_add_decoding_attr', 'async', $image, $context ); 6091 6092 if ( in_array( $value, array( 'async', 'sync', 'auto' ), true ) ) { 6093 $image = str_replace( '<img ', '<img decoding="' . esc_attr( $value ) . '" ', $image ); 6094 } 6095 6096 return $image; 6097 } 6098 6099 /** 6100 * Parses wp_template content and injects the active theme's 6101 * stylesheet as a theme attribute into each wp_template_part 6102 * 6103 * @since 5.9.0 6104 * @deprecated 6.4.0 Use traverse_and_serialize_blocks( parse_blocks( $template_content ), '_inject_theme_attribute_in_template_part_block' ) instead. 6105 * @access private 6106 * 6107 * @param string $template_content serialized wp_template content. 6108 * @return string Updated 'wp_template' content. 6109 */ 6110 function _inject_theme_attribute_in_block_template_content( $template_content ) { 6111 _deprecated_function( 6112 __FUNCTION__, 6113 '6.4.0', 6114 'traverse_and_serialize_blocks( parse_blocks( $template_content ), "_inject_theme_attribute_in_template_part_block" )' 6115 ); 6116 6117 $has_updated_content = false; 6118 $new_content = ''; 6119 $template_blocks = parse_blocks( $template_content ); 6120 6121 $blocks = _flatten_blocks( $template_blocks ); 6122 foreach ( $blocks as &$block ) { 6123 if ( 6124 'core/template-part' === $block['blockName'] && 6125 ! isset( $block['attrs']['theme'] ) 6126 ) { 6127 $block['attrs']['theme'] = get_stylesheet(); 6128 $has_updated_content = true; 6129 } 6130 } 6131 6132 if ( $has_updated_content ) { 6133 foreach ( $template_blocks as &$block ) { 6134 $new_content .= serialize_block( $block ); 6135 } 6136 6137 return $new_content; 6138 } 6139 6140 return $template_content; 6141 } 6142 6143 /** 6144 * Parses a block template and removes the theme attribute from each template part. 6145 * 6146 * @since 5.9.0 6147 * @deprecated 6.4.0 Use traverse_and_serialize_blocks( parse_blocks( $template_content ), '_remove_theme_attribute_from_template_part_block' ) instead. 6148 * @access private 6149 * 6150 * @param string $template_content Serialized block template content. 6151 * @return string Updated block template content. 6152 */ 6153 function _remove_theme_attribute_in_block_template_content( $template_content ) { 6154 _deprecated_function( 6155 __FUNCTION__, 6156 '6.4.0', 6157 'traverse_and_serialize_blocks( parse_blocks( $template_content ), "_remove_theme_attribute_from_template_part_block" )' 6158 ); 6159 6160 $has_updated_content = false; 6161 $new_content = ''; 6162 $template_blocks = parse_blocks( $template_content ); 6163 6164 $blocks = _flatten_blocks( $template_blocks ); 6165 foreach ( $blocks as $key => $block ) { 6166 if ( 'core/template-part' === $block['blockName'] && isset( $block['attrs']['theme'] ) ) { 6167 unset( $blocks[ $key ]['attrs']['theme'] ); 6168 $has_updated_content = true; 6169 } 6170 } 6171 6172 if ( ! $has_updated_content ) { 6173 return $template_content; 6174 } 6175 6176 foreach ( $template_blocks as $block ) { 6177 $new_content .= serialize_block( $block ); 6178 } 6179 6180 return $new_content; 6181 } 6182 6183 /** 6184 * Prints the skip-link script & styles. 6185 * 6186 * @since 5.8.0 6187 * @access private 6188 * @deprecated 6.4.0 Use wp_enqueue_block_template_skip_link() instead. 6189 * 6190 * @global string $_wp_current_template_content 6191 */ 6192 function the_block_template_skip_link() { 6193 _deprecated_function( __FUNCTION__, '6.4.0', 'wp_enqueue_block_template_skip_link()' ); 6194 6195 global $_wp_current_template_content; 6196 6197 // Early exit if not a block theme. 6198 if ( ! current_theme_supports( 'block-templates' ) ) { 6199 return; 6200 } 6201 6202 // Early exit if not a block template. 6203 if ( ! $_wp_current_template_content ) { 6204 return; 6205 } 6206 ?> 6207 6208 <?php 6209 /** 6210 * Print the skip-link styles. 6211 */ 6212 ?> 6213 <style id="skip-link-styles"> 6214 .skip-link.screen-reader-text { 6215 border: 0; 6216 clip-path: inset(50%); 6217 height: 1px; 6218 margin: -1px; 6219 overflow: hidden; 6220 padding: 0; 6221 position: absolute !important; 6222 width: 1px; 6223 /* Many screen reader and browser combinations announce broken words as they would appear visually. */ 6224 word-wrap: normal !important; 6225 word-break: normal !important; 6226 } 6227 6228 .skip-link.screen-reader-text:focus { 6229 background-color: #eee; 6230 clip-path: none; 6231 color: #444; 6232 display: block; 6233 font-size: 1em; 6234 height: auto; 6235 left: 5px; 6236 line-height: normal; 6237 padding: 15px 23px 14px; 6238 text-decoration: none; 6239 top: 5px; 6240 width: auto; 6241 z-index: 100000; 6242 } 6243 </style> 6244 <?php 6245 /** 6246 * Print the skip-link script. 6247 */ 6248 ?> 6249 <script> 6250 ( function() { 6251 var skipLinkTarget = document.querySelector( 'main' ), 6252 sibling, 6253 skipLinkTargetID, 6254 skipLink; 6255 6256 // Early exit if a skip-link target can't be located. 6257 if ( ! skipLinkTarget ) { 6258 return; 6259 } 6260 6261 /* 6262 * Get the site wrapper. 6263 * The skip-link will be injected in the beginning of it. 6264 */ 6265 sibling = document.querySelector( '.wp-site-blocks' ); 6266 6267 // Early exit if the root element was not found. 6268 if ( ! sibling ) { 6269 return; 6270 } 6271 6272 // Get the skip-link target's ID, and generate one if it doesn't exist. 6273 skipLinkTargetID = skipLinkTarget.id; 6274 if ( ! skipLinkTargetID ) { 6275 skipLinkTargetID = 'wp--skip-link--target'; 6276 skipLinkTarget.id = skipLinkTargetID; 6277 } 6278 6279 // Create the skip link. 6280 skipLink = document.createElement( 'a' ); 6281 skipLink.classList.add( 'skip-link', 'screen-reader-text' ); 6282 skipLink.href = '#' + skipLinkTargetID; 6283 skipLink.innerHTML = '<?php /* translators: Hidden accessibility text. */ esc_html_e( 'Skip to content' ); ?>'; 6284 6285 // Inject the skip link. 6286 sibling.parentElement.insertBefore( skipLink, sibling ); 6287 }() ); 6288 </script> 6289 <?php 6290 } 6291 6292 /** 6293 * Ensure that the view script has the `wp-interactivity` dependency. 6294 * 6295 * @since 6.4.0 6296 * @deprecated 6.5.0 6297 */ 6298 function block_core_query_ensure_interactivity_dependency() { 6299 _deprecated_function( __FUNCTION__, '6.5.0', 'wp_register_script_module' ); 6300 } 6301 6302 /** 6303 * Ensure that the view script has the `wp-interactivity` dependency. 6304 * 6305 * @since 6.4.0 6306 * @deprecated 6.5.0 6307 */ 6308 function block_core_file_ensure_interactivity_dependency() { 6309 _deprecated_function( __FUNCTION__, '6.5.0', 'wp_register_script_module' ); 6310 } 6311 6312 /** 6313 * Ensures that the view script has the `wp-interactivity` dependency. 6314 * 6315 * @since 6.4.0 6316 * @deprecated 6.5.0 6317 */ 6318 function block_core_image_ensure_interactivity_dependency() { 6319 _deprecated_function( __FUNCTION__, '6.5.0', 'wp_register_script_module' ); 6320 } 6321 6322 /** 6323 * Updates the block content with elements class names. 6324 * 6325 * @deprecated 6.6.0 Generation of element class name is handled via `render_block_data` filter. 6326 * 6327 * @since 5.8.0 6328 * @since 6.4.0 Added support for button and heading element styling. 6329 * @access private 6330 * 6331 * @param string $block_content Rendered block content. 6332 * @param array $block Block object. 6333 * @return string Filtered block content. 6334 */ 6335 function wp_render_elements_support( $block_content, $block ) { 6336 _deprecated_function( __FUNCTION__, '6.6.0', 'wp_render_elements_class_name' ); 6337 return $block_content; 6338 } 6339 6340 /** 6341 * Processes the directives on the rendered HTML of the interactive blocks. 6342 * 6343 * This processes only one root interactive block at a time because the 6344 * rendered HTML of that block contains the rendered HTML of all its inner 6345 * blocks, including any interactive block. It does so by ignoring all the 6346 * interactive inner blocks until the root interactive block is processed. 6347 * 6348 * @since 6.5.0 6349 * @deprecated 6.6.0 6350 * 6351 * @param array $parsed_block The parsed block. 6352 * @return array The same parsed block. 6353 */ 6354 function wp_interactivity_process_directives_of_interactive_blocks( array $parsed_block ): array { 6355 _deprecated_function( __FUNCTION__, '6.6.0' ); 6356 return $parsed_block; 6357 } 6358 6359 /** 6360 * Gets the global styles custom CSS from theme.json. 6361 * 6362 * @since 6.2.0 6363 * @deprecated 6.7.0 Use {@see 'wp_get_global_stylesheet'} instead for top-level custom CSS, or {@see 'WP_Theme_JSON::get_styles_for_block'} for block-level custom CSS. 6364 * 6365 * @return string The global styles custom CSS. 6366 */ 6367 function wp_get_global_styles_custom_css() { 6368 _deprecated_function( __FUNCTION__, '6.7.0', 'wp_get_global_stylesheet' ); 6369 if ( ! wp_theme_has_theme_json() ) { 6370 return ''; 6371 } 6372 /* 6373 * Ignore cache when the development mode is set to 'theme', so it doesn't interfere with the theme 6374 * developer's workflow. 6375 */ 6376 $can_use_cached = ! wp_is_development_mode( 'theme' ); 6377 6378 /* 6379 * By using the 'theme_json' group, this data is marked to be non-persistent across requests. 6380 * @see `wp_cache_add_non_persistent_groups()`. 6381 * 6382 * The rationale for this is to make sure derived data from theme.json 6383 * is always fresh from the potential modifications done via hooks 6384 * that can use dynamic data (modify the stylesheet depending on some option, 6385 * settings depending on user permissions, etc.). 6386 * See some of the existing hooks to modify theme.json behavior: 6387 * @see https://make.wordpress.org/core/2022/10/10/filters-for-theme-json-data/ 6388 * 6389 * A different alternative considered was to invalidate the cache upon certain 6390 * events such as options add/update/delete, user meta, etc. 6391 * It was judged not enough, hence this approach. 6392 * @see https://github.com/WordPress/gutenberg/pull/45372 6393 */ 6394 $cache_key = 'wp_get_global_styles_custom_css'; 6395 $cache_group = 'theme_json'; 6396 if ( $can_use_cached ) { 6397 $cached = wp_cache_get( $cache_key, $cache_group ); 6398 if ( $cached ) { 6399 return $cached; 6400 } 6401 } 6402 6403 $tree = WP_Theme_JSON_Resolver::get_merged_data(); 6404 $stylesheet = $tree->get_custom_css(); 6405 6406 if ( $can_use_cached ) { 6407 wp_cache_set( $cache_key, $stylesheet, $cache_group ); 6408 } 6409 6410 return $stylesheet; 6411 } 6412 6413 /** 6414 * Enqueues the global styles custom css defined via theme.json. 6415 * 6416 * @since 6.2.0 6417 * @deprecated 6.7.0 Use {@see 'wp_enqueue_global_styles'} instead. 6418 */ 6419 function wp_enqueue_global_styles_custom_css() { 6420 _deprecated_function( __FUNCTION__, '6.7.0', 'wp_enqueue_global_styles' ); 6421 if ( ! wp_is_block_theme() ) { 6422 return; 6423 } 6424 6425 // Don't enqueue Customizer's custom CSS separately. 6426 remove_action( 'wp_head', 'wp_custom_css_cb', 101 ); 6427 6428 $custom_css = wp_get_custom_css(); 6429 $custom_css .= wp_get_global_styles_custom_css(); 6430 6431 if ( ! empty( $custom_css ) ) { 6432 wp_add_inline_style( 'global-styles', $custom_css ); 6433 } 6434 } 6435 6436 /** 6437 * Generate block style variation instance name. 6438 * 6439 * @since 6.6.0 6440 * @deprecated 6.7.0 Use `wp_unique_id( $variation . '--' )` instead. 6441 * 6442 * @access private 6443 * 6444 * @param array $block Block object. 6445 * @param string $variation Slug for the block style variation. 6446 * @return string The unique variation name. 6447 */ 6448 function wp_create_block_style_variation_instance_name( $block, $variation ) { 6449 _deprecated_function( __FUNCTION__, '6.7.0', 'wp_unique_id' ); 6450 return $variation . '--' . md5( serialize( $block ) ); 6451 } 6452 6453 /** 6454 * Returns whether the current user has the specified capability for a given site. 6455 * 6456 * @since 3.0.0 6457 * @since 5.3.0 Formalized the existing and already documented `...$args` parameter 6458 * by adding it to the function signature. 6459 * @since 5.8.0 Wraps current_user_can() after switching to blog. 6460 * @deprecated 6.7.0 Use current_user_can_for_site() instead. 6461 * 6462 * @param int $blog_id Site ID. 6463 * @param string $capability Capability name. 6464 * @param mixed ...$args Optional further parameters, typically starting with an object ID. 6465 * @return bool Whether the user has the given capability. 6466 */ 6467 function current_user_can_for_blog( $blog_id, $capability, ...$args ) { 6468 return current_user_can_for_site( $blog_id, $capability, ...$args ); 6469 } 6470 6471 /** 6472 * Loads classic theme styles on classic themes in the editor. 6473 * 6474 * This is used for backwards compatibility for Button and File blocks specifically. 6475 * 6476 * @since 6.1.0 6477 * @since 6.2.0 Added File block styles. 6478 * @deprecated 6.8.0 Styles are enqueued, not printed in the body element. 6479 * 6480 * @param array $editor_settings The array of editor settings. 6481 * @return array A filtered array of editor settings. 6482 */ 6483 function wp_add_editor_classic_theme_styles( $editor_settings ) { 6484 _deprecated_function( __FUNCTION__, '6.8.0', 'wp_enqueue_classic_theme_styles' ); 6485 6486 if ( wp_theme_has_theme_json() ) { 6487 return $editor_settings; 6488 } 6489 6490 $suffix = wp_scripts_get_suffix(); 6491 $classic_theme_styles = ABSPATH . WPINC . "/css/classic-themes$suffix.css"; 6492 6493 /* 6494 * This follows the pattern of get_block_editor_theme_styles, 6495 * but we can't use get_block_editor_theme_styles directly as it 6496 * only handles external files or theme files. 6497 */ 6498 $classic_theme_styles_settings = array( 6499 'css' => file_get_contents( $classic_theme_styles ), 6500 '__unstableType' => 'core', 6501 'isGlobalStyles' => false, 6502 ); 6503 6504 // Add these settings to the start of the array so that themes can override them. 6505 array_unshift( $editor_settings['styles'], $classic_theme_styles_settings ); 6506 6507 return $editor_settings; 6508 } 6509 6510 /** 6511 * Prints a CSS rule to fix potential visual issues with images using `sizes=auto`. 6512 * 6513 * This rule overrides the similar rule in the default user agent stylesheet, to avoid images that use e.g. 6514 * `width: auto` or `width: fit-content` to appear smaller. 6515 * 6516 * @since 6.7.1 6517 * @deprecated 6.9.0 Use wp_enqueue_img_auto_sizes_contain_css_fix() instead. 6518 * @see wp_enqueue_img_auto_sizes_contain_css_fix() 6519 * 6520 * @see https://html.spec.whatwg.org/multipage/rendering.html#img-contain-size 6521 * @see https://core.trac.wordpress.org/ticket/62413 6522 * @see https://core.trac.wordpress.org/ticket/62731 6523 */ 6524 function wp_print_auto_sizes_contain_css_fix() { 6525 _deprecated_function( __FUNCTION__, '6.9.0', 'wp_enqueue_img_auto_sizes_contain_css_fix' ); 6526 6527 /** This filter is documented in wp-includes/media.php */ 6528 $add_auto_sizes = apply_filters( 'wp_img_tag_add_auto_sizes', true ); 6529 if ( ! $add_auto_sizes ) { 6530 return; 6531 } 6532 6533 ?> 6534 <style>img:is([sizes="auto" i], [sizes^="auto," i]) { contain-intrinsic-size: 3000px 1500px }</style> 6535 <?php 6536 } 6537 6538 /** 6539 * Adds slashes to a string or recursively adds slashes to strings within an array. 6540 * 6541 * This function is just a wrapper for `wp_slash()`. It was originally related to 6542 * magic quotes functionality which was deprecated in PHP 5.3.0 and removed in PHP 5.4.0. 6543 * 6544 * @since 0.71 6545 * @deprecated 7.0.0 Use wp_slash() instead. 6546 * @see wp_slash() 6547 * 6548 * @param string|array $gpc String or array of data to slash. 6549 * @return string|array Slashed `$gpc`. 6550 * 6551 * @phpstan-return ( $gpc is string ? string : array ) 6552 */ 6553 function addslashes_gpc( $gpc ) { 6554 _deprecated_function( __FUNCTION__, '7.0.0', 'wp_slash()' ); 6555 return wp_slash( $gpc ); 6556 } 6557 6558 /** 6559 * Sanitizes an attributes array into an attributes string to be placed inside a `<script>` tag. 6560 * 6561 * This function is deprecated, use {@see wp_get_script_tag()} or {@see wp_get_inline_script_tag()} instead. 6562 * 6563 * @since 5.7.0 6564 * @deprecated 7.0.0 Use wp_get_script_tag() or wp_get_inline_script_tag(). 6565 * @see wp_get_script_tag() 6566 * @see wp_get_inline_script_tag() 6567 * 6568 * @param array<string, string|bool> $attributes Key-value pairs representing `<script>` tag attributes. 6569 * @return string String made of sanitized `<script>` tag attributes. 6570 */ 6571 function wp_sanitize_script_attributes( $attributes ) { 6572 _deprecated_function( __FUNCTION__, '7.0.0', 'wp_get_script_tag() or wp_get_inline_script_tag()' ); 6573 6574 $attributes_string = ''; 6575 foreach ( $attributes as $attribute_name => $attribute_value ) { 6576 if ( is_bool( $attribute_value ) ) { 6577 if ( $attribute_value ) { 6578 $attributes_string .= ' ' . esc_attr( $attribute_name ); 6579 } 6580 } else { 6581 $attributes_string .= sprintf( ' %1$s="%2$s"', esc_attr( $attribute_name ), esc_attr( $attribute_value ) ); 6582 } 6583 } 6584 return $attributes_string; 6585 } 6586 6587 /** 6588 * Truncates a post slug. 6589 * 6590 * @since 3.6.0 6591 * @deprecated 7.2.0 Use wp_truncate_slug() instead. 6592 * @see wp_truncate_slug() 6593 * 6594 * @param string $slug The slug to truncate. 6595 * @param int $length Optional. Max length of the slug. Default 200 (characters). 6596 * @return string The truncated slug. 6597 */ 6598 function _truncate_post_slug( $slug, $length = 200 ) { 6599 _deprecated_function( __FUNCTION__, '7.2.0', 'wp_truncate_slug()' ); 6600 6601 return wp_truncate_slug( $slug, $length ); 6602 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated : Sun Oct 4 08:20:33 2026 | Cross-referenced by PHPXref |