Changeset 56635
- Timestamp:
- 09/20/2023 05:25:26 PM (11 months ago)
- Location:
- trunk
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/theme.php
r56571 r56635 1167 1167 */ 1168 1168 if ( ! empty( $redirect ) ) { 1169 1170 1171 1169 1172 $functions_path = ''; 1170 if ( str_contains( STYLESHEETPATH, $extension ) ) {1171 $functions_path = STYLESHEETPATH. '/functions.php';1172 } elseif ( str_contains( TEMPLATEPATH, $extension ) ) {1173 $functions_path = TEMPLATEPATH. '/functions.php';1173 if ( str_contains( , $extension ) ) { 1174 $functions_path = . '/functions.php'; 1175 } elseif ( str_contains( , $extension ) ) { 1176 $functions_path = . '/functions.php'; 1174 1177 } 1175 1178 -
trunk/src/wp-includes/comment-template.php
r56549 r56635 1382 1382 * 1383 1383 * The `$file` path is passed through a filter hook called {@see 'comments_template'}, 1384 * which includes the TEMPLATEPATHand $file combined. Tries the $filtered path1384 * which includes the and $file combined. Tries the $filtered path 1385 1385 * first and if it fails it will require the default comment template from the 1386 1386 * default theme. If either does not exist, then the WordPress process will be … … 1601 1601 } 1602 1602 1603 $theme_template = STYLESHEETPATH . $file; 1603 $stylesheet_path = get_stylesheet_directory(); 1604 $template_path = get_template_directory(); 1605 1606 $theme_template = $stylesheet_path . $file; 1604 1607 1605 1608 /** … … 1614 1617 if ( file_exists( $include ) ) { 1615 1618 require $include; 1616 } elseif ( file_exists( TEMPLATEPATH. $file ) ) {1617 require TEMPLATEPATH. $file;1619 } elseif ( file_exists( . $file ) ) { 1620 require . $file; 1618 1621 } else { // Backward compat code will be removed in a future release. 1619 1622 require ABSPATH . WPINC . '/theme-compat/comments.php'; -
trunk/src/wp-includes/default-constants.php
r56548 r56635 408 408 * 409 409 * @since 1.5.0 410 411 410 412 */ 411 413 define( 'TEMPLATEPATH', get_template_directory() ); … … 415 417 * 416 418 * @since 2.1.0 419 420 417 421 */ 418 422 define( 'STYLESHEETPATH', get_stylesheet_directory() ); -
trunk/src/wp-includes/load.php
r56548 r56635 1050 1050 } 1051 1051 1052 if ( TEMPLATEPATH !== STYLESHEETPATH ) { 1053 $themes[] = STYLESHEETPATH; 1054 } 1055 1056 $themes[] = TEMPLATEPATH; 1052 $stylesheet_path = get_stylesheet_directory(); 1053 $template_path = get_template_directory(); 1054 1055 if ( $template_path !== $stylesheet_path ) { 1056 $themes[] = $stylesheet_path; 1057 } 1058 1059 $themes[] = $template_path; 1057 1060 1058 1061 /* -
trunk/src/wp-includes/template.php
r56357 r56635 685 685 * Retrieves the name of the highest priority template file that exists. 686 686 * 687 * Searches in the STYLESHEETPATH before TEMPLATEPATH and wp-includes/theme-compat 688 * so that themes which inherit from a parent theme can just overload one file. 687 * Searches in the stylesheet directory before the template directory and 688 * wp-includes/theme-compat so that themes which inherit from a parent theme 689 * can just overload one file. 689 690 * 690 691 * @since 2.7.0 … … 700 701 */ 701 702 function locate_template( $template_names, $load = false, $load_once = true, $args = array() ) { 703 704 705 706 702 707 $located = ''; 703 708 foreach ( (array) $template_names as $template_name ) { … … 705 710 continue; 706 711 } 707 if ( file_exists( STYLESHEETPATH. '/' . $template_name ) ) {708 $located = STYLESHEETPATH. '/' . $template_name;712 if ( file_exists( . '/' . $template_name ) ) { 713 $located = . '/' . $template_name; 709 714 break; 710 } elseif ( is_child_theme() && file_exists( TEMPLATEPATH. '/' . $template_name ) ) {711 $located = TEMPLATEPATH. '/' . $template_name;715 } elseif ( . '/' . $template_name ) ) { 716 $located = . '/' . $template_name; 712 717 break; 713 718 } elseif ( file_exists( ABSPATH . WPINC . '/theme-compat/' . $template_name ) ) { -
trunk/src/wp-includes/theme.php
r56414 r56635 158 158 */ 159 159 function is_child_theme() { 160 return ( TEMPLATEPATH !== STYLESHEETPATH);160 return ); 161 161 } 162 162 … … 188 188 * 189 189 * @since 1.5.0 190 191 192 190 193 * 191 194 * @return string Path to active theme's stylesheet directory. 192 195 */ 193 196 function get_stylesheet_directory() { 194 $stylesheet = get_stylesheet(); 195 $theme_root = get_theme_root( $stylesheet ); 196 $stylesheet_dir = "$theme_root/$stylesheet"; 197 198 /** 199 * Filters the stylesheet directory path for the active theme. 200 * 201 * @since 1.5.0 202 * 203 * @param string $stylesheet_dir Absolute path to the active theme. 204 * @param string $stylesheet Directory name of the active theme. 205 * @param string $theme_root Absolute path to themes directory. 206 */ 207 return apply_filters( 'stylesheet_directory', $stylesheet_dir, $stylesheet, $theme_root ); 197 global $wp_stylesheet_path; 198 199 if ( null === $wp_stylesheet_path ) { 200 $stylesheet = get_stylesheet(); 201 $theme_root = get_theme_root( $stylesheet ); 202 $stylesheet_dir = "$theme_root/$stylesheet"; 203 204 /** 205 * Filters the stylesheet directory path for the active theme. 206 * 207 * @since 1.5.0 208 * 209 * @param string $stylesheet_dir Absolute path to the active theme. 210 * @param string $stylesheet Directory name of the active theme. 211 * @param string $theme_root Absolute path to themes directory. 212 */ 213 $stylesheet_dir = apply_filters( 'stylesheet_directory', $stylesheet_dir, $stylesheet, $theme_root ); 214 215 // If there are filter callbacks, force the logic to execute on every call. 216 if ( has_filter( 'stylesheet' ) || has_filter( 'theme_root' ) || has_filter( 'stylesheet_directory' ) ) { 217 return $stylesheet_dir; 218 } 219 220 $wp_stylesheet_path = $stylesheet_dir; 221 } 222 223 return $wp_stylesheet_path; 208 224 } 209 225 … … 322 338 * 323 339 * @since 1.5.0 340 341 342 324 343 * 325 344 * @return string Path to active theme's template directory. 326 345 */ 327 346 function get_template_directory() { 328 $template = get_template(); 329 $theme_root = get_theme_root( $template ); 330 $template_dir = "$theme_root/$template"; 331 332 /** 333 * Filters the active theme directory path. 334 * 335 * @since 1.5.0 336 * 337 * @param string $template_dir The path of the active theme directory. 338 * @param string $template Directory name of the active theme. 339 * @param string $theme_root Absolute path to the themes directory. 340 */ 341 return apply_filters( 'template_directory', $template_dir, $template, $theme_root ); 347 global $wp_template_path; 348 349 if ( null === $wp_template_path ) { 350 $template = get_template(); 351 $theme_root = get_theme_root( $template ); 352 $template_dir = "$theme_root/$template"; 353 354 /** 355 * Filters the active theme directory path. 356 * 357 * @since 1.5.0 358 * 359 * @param string $template_dir The path of the active theme directory. 360 * @param string $template Directory name of the active theme. 361 * @param string $theme_root Absolute path to the themes directory. 362 */ 363 $template_dir = apply_filters( 'template_directory', $template_dir, $template, $theme_root ); 364 365 // If there are filter callbacks, force the logic to execute on every call. 366 if ( has_filter( 'template' ) || has_filter( 'theme_root' ) || has_filter( 'template_directory' ) ) { 367 return $template_dir; 368 } 369 370 $wp_template_path = $template_dir; 371 } 372 373 return $wp_template_path; 342 374 } 343 375 … … 745 777 * @global array $sidebars_widgets 746 778 * @global array $wp_registered_sidebars 779 780 747 781 * 748 782 * @param string $stylesheet Stylesheet name. 749 783 */ 750 784 function switch_theme( $stylesheet ) { 751 global $wp_theme_directories, $wp_customize, $sidebars_widgets, $wp_registered_sidebars ;785 global $wp_theme_directories, $wp_customize, $sidebars_widgets, $wp_registered_sidebars; 752 786 753 787 $requirements = validate_theme_requirements( $stylesheet ); … … 832 866 833 867 update_option( 'theme_switched', $old_theme->get_stylesheet() ); 868 869 870 871 872 873 874 834 875 835 876 /** -
trunk/tests/phpunit/tests/comment/commentsTemplate.php
r53863 r56635 11 11 12 12 /** 13 14 15 16 17 18 19 20 13 21 * @ticket 8071 14 22 */ -
trunk/tests/phpunit/tests/comment/wpListComments.php
r53863 r56635 7 7 */ 8 8 class Tests_Comment_WpListComments extends WP_UnitTestCase { 9 10 11 12 13 14 15 16 17 9 18 /** 10 19 * @ticket 35175 -
trunk/tests/phpunit/tests/general/template.php
r54090 r56635 11 11 12 12 class Tests_General_Template extends WP_UnitTestCase { 13 13 14 protected $wp_site_icon; 14 15 public $site_icon_id; … … 42 43 parent::set_up(); 43 44 45 44 46 $this->wp_site_icon = new WP_Site_Icon(); 45 47 } -
trunk/tests/phpunit/tests/template.php
r56547 r56635 628 628 ), 629 629 ); 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 630 668 } 631 669 -
trunk/tests/phpunit/tests/theme.php
r54663 r56635 37 37 parent::set_up(); 38 38 39 39 40 $this->orig_theme_dir = $wp_theme_directories; 40 $wp_theme_directories = array( WP_CONTENT_DIR . '/themes' );41 $wp_theme_directories = array( WP_CONTENT_DIR . '/themes' ); 41 42 42 43 add_filter( 'extra_theme_headers', array( $this, 'theme_data_extra_headers' ) ); … … 283 284 for ( $i = 0; $i < 3; $i++ ) { 284 285 foreach ( $themes as $name => $theme ) { 286 287 288 289 290 285 291 // Switch to this theme. 286 292 if ( 2 === $i ) { … … 290 296 } 291 297 292 $this->assertSame( $ name, get_current_theme() );298 $this->assertSame( $, get_current_theme() ); 293 299 294 300 // Make sure the various get_* functions return the correct values. … … 296 302 $this->assertSame( $theme['Stylesheet'], get_stylesheet() ); 297 303 298 $root_fs = get_theme_root();304 $root_fs = get_theme_root(); 299 305 $this->assertTrue( is_dir( $root_fs ) ); 300 306 301 $root_uri = get_theme_root_uri();307 $root_uri = get_theme_root_uri(); 302 308 $this->assertNotEmpty( $root_uri ); 303 309 … … 310 316 $this->assertSame( $root_uri . '/' . get_template(), get_template_directory_uri() ); 311 317 312 // get_query_template() 318 // Skip block themes for get_query_template() tests since this test is focused on classic templates. 319 if ( wp_is_block_theme() && current_theme_supports( 'block-templates' ) ) { 320 continue; 321 } 313 322 314 323 // Template file that doesn't exist. … … 316 325 317 326 // Template files that do exist. 318 /*319 327 foreach ( $theme['Template Files'] as $path ) { 320 $file = basename($path, '.php'); 321 FIXME: untestable because get_query_template() uses TEMPLATEPATH. 322 $this->assertSame('', get_query_template($file)); 328 $file = basename( $path, '.php' ); 329 330 // The functions.php file is not a template. 331 if ( 'functions' === $file ) { 332 continue; 333 } 334 335 // Underscores are not supported by `locate_template()`. 336 if ( 'taxonomy-post_format' === $file ) { 337 $file = 'taxonomy'; 338 } 339 340 $child_theme_file = get_stylesheet_directory() . '/' . $file . '.php'; 341 $parent_theme_file = get_template_directory() . '/' . $file . '.php'; 342 if ( file_exists( $child_theme_file ) ) { 343 $this->assertSame( $child_theme_file, get_query_template( $file ) ); 344 } elseif ( file_exists( $parent_theme_file ) ) { 345 $this->assertSame( $parent_theme_file, get_query_template( $file ) ); 346 } else { 347 $this->assertSame( '', get_query_template( $file ) ); 348 } 323 349 } 324 */325 350 326 351 // These are kind of tautologies but at least exercise the code. … … 856 881 857 882 /** 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 858 1061 * Helper function to ensure that a block theme is available and active. 859 1062 */
Note: See TracChangeset
for help on using the changeset viewer.