Changes from trunk/wp-includes/theme.php at r17316 to branches/3.0/wp-includes/theme.php at r15436
- File:
-
- 1 edited
-
branches/3.0/wp-includes/theme.php (modified) (43 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/3.0/wp-includes/theme.php
r17316 r15436 167 167 * whitelisted. The <b>'a'</b> element with the <em>href</em> and <em>title</em> 168 168 * attributes. The <b>abbr</b> element with the <em>title</em> attribute. The 169 * <b>acronym< /b> element with the <em>title</em> attribute allowed. The169 * <b>acronym<b> element with the <em>title</em> attribute allowed. The 170 170 * <b>code</b>, <b>em</b>, and <b>strong</b> elements also allowed. 171 171 * … … 240 240 $theme_data['Author'] = $theme_data['AuthorName']; 241 241 } else { 242 $theme_data['Author'] = sprintf( '<a href="%1$s" title="%2$s">%3$s</a>', $theme_data['AuthorURI'], esc_attr__( 'Visit author homepage' ), $theme_data['AuthorName'] );242 $theme_data['Author'] = sprintf( '<a href="%1$s" title="%2$s">%3$s</a>', $theme_data['AuthorURI'], __( 'Visit author homepage' ), $theme_data['AuthorName'] ); 243 243 } 244 244 } … … 267 267 if ( isset($wp_themes) ) 268 268 return $wp_themes; 269 270 /* Register the default root as a theme directory */ 271 register_theme_directory( get_theme_root() ); 269 272 270 273 if ( !$theme_files = search_theme_directories() ) … … 386 389 $stylesheet_files = array_unique($stylesheet_files); 387 390 388 $template_dir = $template_directory;389 $stylesheet_dir = $theme_root . '/' . $stylesheet;391 $template_dir = dirname($template_files[0]); 392 $stylesheet_dir = dirname($stylesheet_files[0]); 390 393 391 394 if ( empty($template_dir) ) … … 397 400 // a new theme directory and the theme header is not updated. Whichever 398 401 // theme is first keeps the name. Subsequent themes get a suffix applied. 399 // The Twenty Ten,Default and Classic themes always trump their pretenders.402 // The Default and Classic themes always trump their pretenders. 400 403 if ( isset($wp_themes[$name]) ) { 401 $trump_cards = array( 402 'classic' => 'WordPress Classic', 403 'default' => 'WordPress Default', 404 'twentyten' => 'Twenty Ten', 405 ); 406 if ( isset( $trump_cards[ $stylesheet ] ) && $name == $trump_cards[ $stylesheet ] ) { 404 if ( ('WordPress Default' == $name || 'WordPress Classic' == $name) && 405 ('default' == $stylesheet || 'classic' == $stylesheet) ) { 407 406 // If another theme has claimed to be one of our default themes, move 408 407 // them aside. … … 468 467 * @since 2.9.0 469 468 * 470 * @return array |string An arry of theme roots keyed by template/stylesheet or a single theme root if all themes have the same root.469 * @return array Theme roots 471 470 */ 472 471 function get_theme_roots() { 473 global $wp_theme_directories;474 475 if ( count($wp_theme_directories) <= 1 )476 return '/themes';477 478 472 $theme_roots = get_site_transient( 'theme_roots' ); 479 473 if ( false === $theme_roots ) { … … 520 514 $current_template = get_option('template'); 521 515 $current_stylesheet = get_option('stylesheet'); 522 $current_theme = ' Twenty Ten';516 $current_theme = 'WordPress Default'; 523 517 524 518 if ( $themes ) { … … 595 589 while ( ($theme_dir = readdir($themes_dir)) !== false ) { 596 590 if ( is_dir($theme_root . '/' . $theme_dir) && is_readable($theme_root . '/' . $theme_dir) ) { 597 if ( $theme_dir [0]== '.' || $theme_dir == 'CVS' )591 if ( $theme_dir{0} == '.' || $theme_dir == 'CVS' ) 598 592 continue; 599 593 … … 618 612 while ( ($theme_subdir = readdir($theme_subdirs)) !== false ) { 619 613 if ( is_dir( $subdir . '/' . $theme_subdir) && is_readable($subdir . '/' . $theme_subdir) ) { 620 if ( $theme_subdir [0]== '.' || $theme_subdir == 'CVS' )614 if ( $theme_subdir{0} == '.' || $theme_subdir == 'CVS' ) 621 615 continue; 622 616 … … 652 646 * 653 647 * @since 1.5.0 648 * @param $stylesheet_or_template The stylesheet or template name of the theme 654 649 * @uses apply_filters() Calls 'theme_root' filter on path. 655 650 * 656 * @param string $stylesheet_or_template The stylesheet or template name of the theme657 651 * @return string Theme path. 658 652 */ 659 653 function get_theme_root( $stylesheet_or_template = false ) { 660 if ( $stylesheet_or_template ) { 661 if ( $theme_root = get_raw_theme_root($stylesheet_or_template) ) 662 $theme_root = WP_CONTENT_DIR . $theme_root; 654 if ($stylesheet_or_template) { 655 $theme_roots = get_theme_roots(); 656 657 if ( ! empty( $theme_roots[$stylesheet_or_template] ) ) 658 $theme_root = WP_CONTENT_DIR . $theme_roots[$stylesheet_or_template]; 663 659 else 664 660 $theme_root = WP_CONTENT_DIR . '/themes'; … … 676 672 * 677 673 * @since 1.5.0 678 * 679 * @param string $stylesheet_or_template The stylesheet or template name of the theme674 * @param $stylesheet_or_template The stylesheet or template name of the theme 675 * 680 676 * @return string Themes URI. 681 677 */ 682 678 function get_theme_root_uri( $stylesheet_or_template = false ) { 683 if ( $stylesheet_or_template ) { 684 if ( $theme_root = get_raw_theme_root($stylesheet_or_template) ) 685 $theme_root_uri = content_url( $theme_root ); 686 else 687 $theme_root_uri = content_url( 'themes' ); 688 } else { 679 $theme_roots = get_theme_roots(); 680 681 if ( isset( $theme_roots[$stylesheet_or_template] ) && $theme_roots[$stylesheet_or_template] ) 682 $theme_root_uri = content_url( $theme_roots[$stylesheet_or_template] ); 683 else 689 684 $theme_root_uri = content_url( 'themes' ); 690 }691 685 692 686 return apply_filters( 'theme_root_uri', $theme_root_uri, get_option('siteurl'), $stylesheet_or_template ); … … 694 688 695 689 /** 696 * Get the raw theme root relative to the content directory with no filters applied. 697 * 698 * @since 3.1.0 699 * 700 * @param string $stylesheet_or_template The stylesheet or template name of the theme 701 * @return string Theme root 702 */ 703 function get_raw_theme_root( $stylesheet_or_template, $no_cache = false ) { 704 global $wp_theme_directories; 705 706 if ( count($wp_theme_directories) <= 1 ) 707 return '/themes'; 708 709 $theme_root = false; 710 711 // If requesting the root for the current theme, consult options to avoid calling get_theme_roots() 712 if ( !$no_cache ) { 713 if ( get_option('stylesheet') == $stylesheet_or_template ) 714 $theme_root = get_option('stylesheet_root'); 715 elseif ( get_option('template') == $stylesheet_or_template ) 716 $theme_root = get_option('template_root'); 717 } 718 719 if ( empty($theme_root) ) { 720 $theme_roots = get_theme_roots(); 721 if ( !empty($theme_roots[$stylesheet_or_template]) ) 722 $theme_root = $theme_roots[$stylesheet_or_template]; 723 } 724 725 return $theme_root; 726 } 727 728 /** 729 * Retrieve path to a template 730 * 731 * Used to quickly retrieve the path of a template without including the file 732 * extension. It will also check the parent theme, if the file exists, with 733 * the use of {@link locate_template()}. Allows for more generic template location 690 * Retrieve path to file without the use of extension. 691 * 692 * Used to quickly retrieve the path of file without including the file 693 * extension. It will also check the parent template, if the file exists, with 694 * the use of {@link locate_template()}. Allows for more generic file location 734 695 * without the use of the other get_*_template() functions. 735 696 * 697 * Can be used with include() or require() to retrieve path. 698 * <code> 699 * if( '' != get_query_template( '404' ) ) 700 * include( get_query_template( '404' ) ); 701 * </code> 702 * or the same can be accomplished with 703 * <code> 704 * if( '' != get_404_template() ) 705 * include( get_404_template() ); 706 * </code> 707 * 736 708 * @since 1.5.0 737 709 * 738 710 * @param string $type Filename without extension. 739 * @param array $templates An optional list of template candidates740 711 * @return string Full path to file. 741 712 */ 742 function get_query_template( $type, $templates = array()) {713 function get_query_template($type) { 743 714 $type = preg_replace( '|[^a-z0-9-]+|', '', $type ); 744 745 if ( empty( $templates ) ) 746 $templates = array("{$type}.php"); 747 748 return apply_filters( "{$type}_template", locate_template( $templates ) ); 715 return apply_filters("{$type}_template", locate_template(array("{$type}.php"))); 749 716 } 750 717 … … 779 746 */ 780 747 function get_archive_template() { 781 $post_type = get_query_var( 'post_type' ); 748 return get_query_template('archive'); 749 } 750 751 /** 752 * Retrieve path of author template in current or parent template. 753 * 754 * @since 1.5.0 755 * 756 * @return string 757 */ 758 function get_author_template() { 759 $author_id = absint( get_query_var( 'author' ) ); 760 $author = get_user_by( 'id', $author_id ); 761 $author = $author->user_nicename; 782 762 783 763 $templates = array(); 784 764 785 if ( $post_type ) 786 $templates[] = "archive-{$post_type}.php"; 787 $templates[] = 'archive.php'; 788 789 return get_query_template( 'archive', $templates ); 790 } 791 792 /** 793 * Retrieve path of author template in current or parent template. 794 * 795 * @since 1.5.0 796 * 797 * @return string 798 */ 799 function get_author_template() { 800 $author = get_queried_object(); 801 802 $templates = array(); 803 804 $templates[] = "author-{$author->user_nicename}.php"; 805 $templates[] = "author-{$author->ID}.php"; 765 if ( $author ) 766 $templates[] = "author-{$author}.php"; 767 if ( $author_id ) 768 $templates[] = "author-{$author_id}.php"; 806 769 $templates[] = 'author.php'; 807 770 808 return get_query_template( 'author', $templates ); 771 $template = locate_template( $templates ); 772 return apply_filters( 'author_template', $template ); 809 773 } 810 774 … … 822 786 */ 823 787 function get_category_template() { 824 $category = get_queried_object(); 788 $cat_ID = absint( get_query_var('cat') ); 789 $category = get_category( $cat_ID ); 825 790 826 791 $templates = array(); 827 792 828 $templates[] = "category-{$category->slug}.php"; 829 $templates[] = "category-{$category->term_id}.php"; 793 if ( !is_wp_error($category) ) 794 $templates[] = "category-{$category->slug}.php"; 795 796 $templates[] = "category-$cat_ID.php"; 830 797 $templates[] = "category.php"; 831 798 832 return get_query_template( 'category', $templates ); 799 $template = locate_template($templates); 800 return apply_filters('category_template', $template); 833 801 } 834 802 … … 846 814 */ 847 815 function get_tag_template() { 848 $tag = get_queried_object(); 816 $tag_id = absint( get_query_var('tag_id') ); 817 $tag_name = get_query_var('tag'); 849 818 850 819 $templates = array(); 851 820 852 $templates[] = "tag-{$tag->slug}.php"; 853 $templates[] = "tag-{$tag->term_id}.php"; 821 if ( $tag_name ) 822 $templates[] = "tag-$tag_name.php"; 823 if ( $tag_id ) 824 $templates[] = "tag-$tag_id.php"; 854 825 $templates[] = "tag.php"; 855 826 856 return get_query_template( 'tag', $templates ); 827 $template = locate_template($templates); 828 return apply_filters('tag_template', $template); 857 829 } 858 830 … … 869 841 * index.php. 870 842 * 871 * @since 2.5.0843 * @since unknown (2.6.0 most likely) 872 844 * @uses apply_filters() Calls 'taxonomy_template' filter on found path. 873 845 * … … 875 847 */ 876 848 function get_taxonomy_template() { 877 $t erm = get_queried_object();878 $t axonomy = $term->taxonomy;849 $taxonomy = get_query_var('taxonomy'); 850 $term = get_query_var('term'); 879 851 880 852 $templates = array(); 881 882 $templates[] = "taxonomy-$taxonomy-{$term->slug}.php"; 883 $templates[] = "taxonomy-$taxonomy.php"; 853 if ( $taxonomy && $term ) 854 $templates[] = "taxonomy-$taxonomy-$term.php"; 855 if ( $taxonomy ) 856 $templates[] = "taxonomy-$taxonomy.php"; 857 884 858 $templates[] = "taxonomy.php"; 885 859 886 return get_query_template( 'taxonomy', $templates ); 860 $template = locate_template($templates); 861 return apply_filters('taxonomy_template', $template); 887 862 } 888 863 … … 911 886 */ 912 887 function get_home_template() { 913 $templates = array( 'home.php', 'index.php' ); 914 915 return get_query_template( 'home', $templates ); 888 $template = locate_template(array('home.php', 'index.php')); 889 return apply_filters('home_template', $template); 916 890 } 917 891 … … 927 901 */ 928 902 function get_front_page_template() { 929 $templates = array('front-page.php'); 930 931 return get_query_template( 'front_page', $templates ); 903 return apply_filters( 'front_page_template', locate_template( array('front-page.php') ) ); 932 904 } 933 905 … … 944 916 */ 945 917 function get_page_template() { 946 $id = get_queried_object_id(); 918 global $wp_query; 919 920 $id = (int) $wp_query->get_queried_object_id(); 947 921 $template = get_post_meta($id, '_wp_page_template', true); 948 922 $pagename = get_query_var('pagename'); … … 950 924 if ( !$pagename && $id > 0 ) { 951 925 // If a static page is set as the front page, $pagename will not be set. Retrieve it from the queried object 952 $post = get_queried_object();926 $post = $wp_query->get_queried_object(); 953 927 $pagename = $post->post_name; 954 928 } … … 966 940 $templates[] = "page.php"; 967 941 968 return get_query_template( 'page', $templates);942 return apply_filters('page_template', locate_template($templates)); 969 943 } 970 944 … … 999 973 */ 1000 974 function get_single_template() { 1001 $object = get_queried_object(); 1002 1003 $templates = array(); 1004 1005 $templates[] = "single-{$object->post_type}.php"; 1006 $templates[] = "single.php"; 1007 1008 return get_query_template( 'single', $templates ); 975 global $wp_query; 976 977 $object = $wp_query->get_queried_object(); 978 $templates = array('single-' . $object->post_type . '.php', 'single.php'); 979 return apply_filters('single_template', locate_template($templates)); 1009 980 } 1010 981 … … 1049 1020 */ 1050 1021 function get_comments_popup_template() { 1051 $template = get_query_template( 'comments_popup', array( 'comments-popup.php' ));1022 $template = locate_template(array("comments-popup.php")); 1052 1023 1053 1024 // Backward compat code will be removed in a future release … … 1055 1026 $template = ABSPATH . WPINC . '/theme-compat/comments-popup.php'; 1056 1027 1057 return $template;1028 return apply_filters('comments_popup_template', $template); 1058 1029 } 1059 1030 … … 1066 1037 * @since 2.7.0 1067 1038 * 1068 * @param string|array $template_names Template file(s) to search for, inorder.1039 * @param array $template_names Array of template files to search for in priority order. 1069 1040 * @param bool $load If true the template file will be loaded if it is found. 1070 1041 * @param bool $require_once Whether to require_once or require. Default true. Has no effect if $load is false. … … 1072 1043 */ 1073 1044 function locate_template($template_names, $load = false, $require_once = true ) { 1045 if ( !is_array($template_names) ) 1046 return ''; 1047 1074 1048 $located = ''; 1075 foreach ( (array)$template_names as $template_name ) {1049 foreach ( $template_names as $template_name ) { 1076 1050 if ( !$template_name ) 1077 1051 continue; … … 1141 1115 if ( !current_user_can( 'switch_themes' ) ) 1142 1116 return; 1143 1144 // Admin Thickbox requests1145 if ( isset( $_GET['preview_iframe'] ) )1146 show_admin_bar( false );1147 1117 1148 1118 $_GET['template'] = preg_replace('|[^a-z0-9_./-]|i', '', $_GET['template']); … … 1238 1208 * Switches current theme to new template and stylesheet names. 1239 1209 * 1240 * @since 2.5.01210 * @since unknown 1241 1211 * @uses do_action() Calls 'switch_theme' action on updated theme display name. 1242 1212 * … … 1245 1215 */ 1246 1216 function switch_theme($template, $stylesheet) { 1247 global $wp_theme_directories;1248 1249 1217 update_option('template', $template); 1250 1218 update_option('stylesheet', $stylesheet); 1251 if ( count($wp_theme_directories) > 1 ) {1252 update_option('template_root', get_raw_theme_root($template, true));1253 update_option('stylesheet_root', get_raw_theme_root($stylesheet, true));1254 }1255 1219 delete_option('current_theme'); 1256 1220 $theme = get_current_theme(); 1257 if ( is_admin() && false === get_option( "theme_mods_$stylesheet" ) ) {1258 $default_theme_mods = (array) get_option( "mods_$theme" );1259 add_option( "theme_mods_$stylesheet", $default_theme_mods );1260 }1261 1221 do_action('switch_theme', $theme); 1262 1222 } … … 1290 1250 } 1291 1251 1292 if ( is_child_theme() && ! file_exists( get_stylesheet_directory() . '/style.css' ) ) {1293 switch_theme( WP_DEFAULT_THEME, WP_DEFAULT_THEME );1294 return false;1295 }1296 1297 1252 return true; 1298 }1299 1300 /**1301 * Retrieve all theme modifications.1302 *1303 * @since 3.1.01304 *1305 * @return array Theme modifications.1306 */1307 function get_theme_mods() {1308 $theme_slug = get_option( 'stylesheet' );1309 if ( false === ( $mods = get_option( "theme_mods_$theme_slug" ) ) ) {1310 $theme_name = get_current_theme();1311 $mods = get_option( "mods_$theme_name" ); // Deprecated location.1312 if ( is_admin() && false !== $mods ) {1313 update_option( "theme_mods_$theme_slug", $mods );1314 delete_option( "mods_$theme_name" );1315 }1316 }1317 return $mods;1318 1253 } 1319 1254 … … 1333 1268 * @return string 1334 1269 */ 1335 function get_theme_mod( $name, $default = false ) { 1336 $mods = get_theme_mods(); 1337 1338 if ( isset( $mods[ $name ] ) ) 1339 return apply_filters( "theme_mod_$name", $mods[ $name ] ); 1340 1341 return apply_filters( "theme_mod_$name", sprintf( $default, get_template_directory_uri(), get_stylesheet_directory_uri() ) ); 1270 function get_theme_mod($name, $default = false) { 1271 $theme = get_current_theme(); 1272 1273 $mods = get_option( "mods_$theme" ); 1274 1275 if ( isset($mods[$name]) ) 1276 return apply_filters( "theme_mod_$name", $mods[$name] ); 1277 1278 return apply_filters( "theme_mod_$name", sprintf($default, get_template_directory_uri(), get_stylesheet_directory_uri()) ); 1342 1279 } 1343 1280 … … 1350 1287 * @param string $value theme modification value. 1351 1288 */ 1352 function set_theme_mod( $name, $value ) { 1353 $mods = get_theme_mods(); 1354 1355 $mods[ $name ] = $value; 1356 1357 $theme = get_option( 'stylesheet' ); 1358 update_option( "theme_mods_$theme", $mods ); 1289 function set_theme_mod($name, $value) { 1290 $theme = get_current_theme(); 1291 1292 $mods = get_option("mods_$theme"); 1293 1294 $mods[$name] = $value; 1295 1296 update_option("mods_$theme", $mods); 1297 wp_cache_delete("mods_$theme", 'options'); 1359 1298 } 1360 1299 … … 1371 1310 */ 1372 1311 function remove_theme_mod( $name ) { 1373 $mods = get_theme_mods(); 1374 1375 if ( ! isset( $mods[ $name ] ) ) 1312 $theme = get_current_theme(); 1313 1314 $mods = get_option("mods_$theme"); 1315 1316 if ( !isset($mods[$name]) ) 1376 1317 return; 1377 1318 1378 unset( $mods[ $name ]);1379 1380 if ( empty( $mods) )1319 unset($mods[$name]); 1320 1321 if ( empty($mods) ) 1381 1322 return remove_theme_mods(); 1382 1323 1383 $theme = get_option( 'stylesheet');1384 update_option( "theme_mods_$theme", $mods);1324 update_option("mods_$theme", $mods); 1325 wp_cache_delete("mods_$theme", 'options'); 1385 1326 } 1386 1327 … … 1391 1332 */ 1392 1333 function remove_theme_mods() { 1393 delete_option( 'theme_mods_' . get_option( 'stylesheet' ) ); 1394 delete_option( 'mods_' . get_current_theme() ); 1334 $theme = get_current_theme(); 1335 1336 delete_option("mods_$theme"); 1395 1337 } 1396 1338 … … 1427 1369 */ 1428 1370 function get_header_image() { 1429 $default = defined( 'HEADER_IMAGE' ) ? HEADER_IMAGE : ''; 1430 1431 $url = get_theme_mod( 'header_image', $default ); 1432 1433 if ( is_ssl() ) 1434 $url = str_replace( 'http://', 'https://', $url ); 1435 else 1436 $url = str_replace( 'https://', 'http://', $url ); 1437 1438 return $url; 1371 $default = defined('HEADER_IMAGE') ? HEADER_IMAGE : ''; 1372 1373 return get_theme_mod('header_image', $default); 1439 1374 } 1440 1375 … … 1463 1398 * @param callback $admin_image_div_callback Output a custom header image div on the custom header administration screen. Optional. 1464 1399 */ 1465 function add_custom_image_header( $header_callback, $admin_header_callback, $admin_image_div_callback = '') {1466 if ( ! empty( $header_callback) )1400 function add_custom_image_header($header_callback, $admin_header_callback, $admin_image_div_callback = '') { 1401 if ( ! empty($header_callback) ) 1467 1402 add_action('wp_head', $header_callback); 1468 1403 1469 add_theme_support( 'custom-header', array( 'callback' => $header_callback ) ); 1470 add_theme_support( 'custom-header-uploads' ); 1404 add_theme_support( 'custom-header' ); 1471 1405 1472 1406 if ( ! is_admin() ) 1473 1407 return; 1474 1475 global $custom_image_header; 1476 1477 require_once( ABSPATH . 'wp-admin/custom-header.php' ); 1478 $custom_image_header = new Custom_Image_Header( $admin_header_callback, $admin_image_div_callback ); 1479 add_action( 'admin_menu', array( &$custom_image_header, 'init' ) ); 1480 } 1481 1482 /** 1483 * Remove image header support. 1484 * 1485 * @since 3.1.0 1486 * @see add_custom_image_header() 1487 * 1488 * @return bool Whether support was removed. 1489 */ 1490 function remove_custom_image_header() { 1491 if ( ! current_theme_supports( 'custom-header' ) ) 1492 return false; 1493 1494 $callback = get_theme_support( 'custom-header' ); 1495 remove_action( 'wp_head', $callback[0]['callback'] ); 1496 _remove_theme_support( 'custom-header' ); 1497 remove_theme_support( 'custom-header-uploads' ); 1498 1499 if ( is_admin() ) { 1500 remove_action( 'admin_menu', array( &$GLOBALS['custom_image_header'], 'init' ) ); 1501 unset( $GLOBALS['custom_image_header'] ); 1502 } 1503 1504 return true; 1408 require_once(ABSPATH . 'wp-admin/custom-header.php'); 1409 $GLOBALS['custom_image_header'] =& new Custom_Image_Header($admin_header_callback, $admin_image_div_callback); 1410 add_action('admin_menu', array(&$GLOBALS['custom_image_header'], 'init')); 1505 1411 } 1506 1412 … … 1527 1433 * @since 3.0.0 1528 1434 * 1529 * @param string|array $headerThe header string id (key of array) to remove, or an array thereof.1435 * @param string|array The header string id (key of array) to remove, or an array thereof. 1530 1436 * @return True on success, false on failure. 1531 1437 */ … … 1602 1508 * @param callback $admin_image_div_callback Output a custom background image div on the custom background administration screen. Optional. 1603 1509 */ 1604 function add_custom_background( $header_callback = '', $admin_header_callback = '', $admin_image_div_callback = '') {1605 if ( isset( $GLOBALS['custom_background']) )1510 function add_custom_background($header_callback = '', $admin_header_callback = '', $admin_image_div_callback = '') { 1511 if ( isset($GLOBALS['custom_background']) ) 1606 1512 return; 1607 1513 1608 if ( empty( $header_callback) )1514 if ( empty($header_callback) ) 1609 1515 $header_callback = '_custom_background_cb'; 1610 1516 1611 add_action( 'wp_head', $header_callback);1612 1613 add_theme_support( 'custom-background' , array( 'callback' => $header_callback ));1517 add_action('wp_head', $header_callback); 1518 1519 add_theme_support( 'custom-background' ); 1614 1520 1615 1521 if ( ! is_admin() ) 1616 1522 return; 1617 require_once( ABSPATH . 'wp-admin/custom-background.php' ); 1618 $GLOBALS['custom_background'] =& new Custom_Background( $admin_header_callback, $admin_image_div_callback ); 1619 add_action( 'admin_menu', array( &$GLOBALS['custom_background'], 'init' ) ); 1620 } 1621 1622 /** 1623 * Remove custom background support. 1624 * 1625 * @since 3.1.0 1626 * @see add_custom_background() 1627 * 1628 * @return bool Whether support was removed. 1629 */ 1630 function remove_custom_background() { 1631 if ( ! current_theme_supports( 'custom-background' ) ) 1632 return false; 1633 1634 $callback = get_theme_support( 'custom-background' ); 1635 remove_action( 'wp_head', $callback[0]['callback'] ); 1636 _remove_theme_support( 'custom-background' ); 1637 1638 if ( is_admin() ) { 1639 remove_action( 'admin_menu', array( &$GLOBALS['custom_background'], 'init' ) ); 1640 unset( $GLOBALS['custom_background'] ); 1641 } 1642 1643 return true; 1523 require_once(ABSPATH . 'wp-admin/custom-background.php'); 1524 $GLOBALS['custom_background'] =& new Custom_Background($admin_header_callback, $admin_image_div_callback); 1525 add_action('admin_menu', array(&$GLOBALS['custom_background'], 'init')); 1644 1526 } 1645 1527 … … 1693 1575 * It is optional and defaults to 'editor-style.css'. 1694 1576 * 1695 * Supports RTL stylesheets automatically by searching for the -rtl prefix, e.g.1696 * editor-style-rtl.css. If an array of stylesheets is passed to add_editor_style(),1697 * RTL is only added for the first stylesheet.1698 *1699 1577 * @since 3.0.0 1700 1578 * … … 1721 1599 1722 1600 /** 1723 * Removes all visual editor stylesheets.1724 *1725 * @since 3.1.01726 *1727 * @return bool True on success, false if there were no stylesheets to remove.1728 */1729 function remove_editor_styles() {1730 if ( ! current_theme_supports( 'editor-style' ) )1731 return false;1732 _remove_theme_support( 'editor-style' );1733 if ( is_admin() )1734 $GLOBALS['editor_styles'] = array();1735 return true;1736 }1737 1738 /**1739 1601 * Allows a theme to register its support of a certain feature 1740 1602 * … … 1753 1615 else 1754 1616 $_wp_theme_features[$feature] = array_slice( func_get_args(), 1 ); 1755 1756 if ( $feature == 'post-formats' && is_array( $_wp_theme_features[$feature][0] ) )1757 $_wp_theme_features[$feature][0] = array_intersect( $_wp_theme_features[$feature][0], array_keys( get_post_format_slugs() ) );1758 }1759 1760 /**1761 * Gets the theme support arguments passed when registering that support1762 *1763 * @since 3.11764 * @param string $feature the feature to check1765 * @return array The array of extra arguments1766 */1767 function get_theme_support( $feature ) {1768 global $_wp_theme_features;1769 if ( !isset( $_wp_theme_features[$feature] ) )1770 return false;1771 else1772 return $_wp_theme_features[$feature];1773 1617 } 1774 1618 … … 1788 1632 if ( in_array( $feature, array( 'custom-background', 'custom-header', 'editor-style', 'widgets', 'menus' ) ) ) 1789 1633 return false; 1790 return _remove_theme_support( $feature ); 1791 } 1792 1793 /** 1794 * Do not use. Removes theme support internally, ignorant of the blacklist. 1795 * 1796 * @access private 1797 * @since 3.1.0 1798 */ 1799 function _remove_theme_support( $feature ) { 1634 1800 1635 global $_wp_theme_features; 1801 1636
Note: See TracChangeset
for help on using the changeset viewer.