Changeset 48189 for trunk/src/wp-includes/theme.php
- Timestamp:
- 06/27/2020 12:00:48 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/theme.php
r48171 r48189 20 20 * Optional. The search arguments. 21 21 * 22 * @type mixed $errors True to return themes with errors, false to return themes without errors, null to return all themes. 23 * Defaults to false. 24 * @type mixed $allowed (Multisite) True to return only allowed themes for a site. False to return only disallowed themes for a site. 25 * 'site' to return only site-allowed themes. 'network' to return only network-allowed themes. 26 * Null to return all themes. Defaults to null. 27 * @type int $blog_id (Multisite) The blog ID used to calculate which themes are allowed. 28 * Defaults to 0, synonymous for the current blog. 22 * @type mixed $errors True to return themes with errors, false to return 23 * themes without errors, null to return all themes. 24 * Default false. 25 * @type mixed $allowed (Multisite) True to return only allowed themes for a site. 26 * False to return only disallowed themes for a site. 27 * 'site' to return only site-allowed themes. 28 * 'network' to return only network-allowed themes. 29 * Null to return all themes. Default null. 30 * @type int $blog_id (Multisite) The blog ID used to calculate which themes 31 * are allowed. Default 0, synonymous for the current blog. 29 32 * } 30 33 * @return WP_Theme[] Array of WP_Theme objects. … … 103 106 * @global array $wp_theme_directories 104 107 * 105 * @param string $stylesheet Directory name for the theme. Optional. Defaults to current theme. 106 * @param string $theme_root Absolute path of the theme root to look in. Optional. If not specified, get_raw_theme_root() 107 * is used to calculate the theme root for the $stylesheet provided (or current theme). 108 * @return WP_Theme Theme object. Be sure to check the object's exists() method if you need to confirm the theme's existence. 108 * @param string $stylesheet Optional. Directory name for the theme. Defaults to current theme. 109 * @param string $theme_root Optional. Absolute path of the theme root to look in. 110 * If not specified, get_raw_theme_root() is used to calculate 111 * the theme root for the $stylesheet provided (or current theme). 112 * @return WP_Theme Theme object. Be sure to check the object's exists() method 113 * if you need to confirm the theme's existence. 109 114 */ 110 115 function wp_get_theme( $stylesheet = '', $theme_root = '' ) { … … 131 136 * 132 137 * @since 3.5.0 133 * @param bool $clear_update_cache Whether to clear the Theme updates cache138 * @param bool $clear_update_cache Whether to clear the theme updates cache. 134 139 */ 135 140 function wp_clean_themes_cache( $clear_update_cache = true ) { … … 148 153 * @since 3.0.0 149 154 * 150 * @return bool true if a child theme is in use, false otherwise.155 * @return bool True if a child theme is in use, false otherwise. 151 156 */ 152 157 function is_child_theme() { … … 157 162 * Retrieves name of the current stylesheet. 158 163 * 159 * The theme name that the administrator has currently set the front end theme 160 * as. 161 * 162 * For all intents and purposes, the template name and the stylesheet name are 163 * going to be the same for most cases. 164 * The theme name that is currently set as the front end theme. 165 * 166 * For all intents and purposes, the template name and the stylesheet name 167 * are going to be the same for most cases. 164 168 * 165 169 * @since 1.5.0 … … 361 365 362 366 /** 363 * Retrieve theme roots.367 * Retrieves theme roots. 364 368 * 365 369 * @since 2.9.0 … … 367 371 * @global array $wp_theme_directories 368 372 * 369 * @return array|string An array of theme roots keyed by template/stylesheet or a single theme root if all themes have the same root. 373 * @return array|string An array of theme roots keyed by template/stylesheet 374 * or a single theme root if all themes have the same root. 370 375 */ 371 376 function get_theme_roots() { … … 385 390 386 391 /** 387 * Register a directory that contains themes.392 * Registers a directory that contains themes. 388 393 * 389 394 * @since 2.9.0 … … 391 396 * @global array $wp_theme_directories 392 397 * 393 * @param string $directory Either the full filesystem path to a theme folder or a folder within WP_CONTENT_DIR 398 * @param string $directory Either the full filesystem path to a theme folder 399 * or a folder within WP_CONTENT_DIR. 394 400 * @return bool 395 401 */ … … 419 425 420 426 /** 421 * Search all registered theme directories for complete and valid themes.427 * Searches all registered theme directories for complete and valid themes. 422 428 * 423 429 * @since 2.9.0 … … 425 431 * @global array $wp_theme_directories 426 432 * 427 * @param bool $force Optional. Whether to force a new directory scan. Default s tofalse.428 * @return array|false Valid themes found 433 * @param bool $force Optional. Whether to force a new directory scan. Default false. 434 * @return array|false Valid themes found on success, false on failure. 429 435 */ 430 436 function search_theme_directories( $force = false ) { … … 464 470 * 465 471 * @param bool $cache_expiration Whether to get the cache of the theme directories. Default false. 466 * @param string $c ache_directory Directory to be searched for the cache.472 * @param string $context The class or function name calling the filter. 467 473 */ 468 474 $cache_expiration = apply_filters( 'wp_cache_themes_persistently', false, 'search_theme_directories' ); 475 469 476 if ( $cache_expiration ) { 470 477 $cached_roots = get_site_transient( 'theme_roots' ); … … 560 567 561 568 /** 562 * Retrieve path to themes directory.569 * Retrieves path to themes directory. 563 570 * 564 571 * Does not have trailing slash. … … 603 610 604 611 /** 605 * Retrieve URI for themes directory.612 * Retrieves URI for themes directory. 606 613 * 607 614 * Does not have trailing slash. … … 656 663 657 664 /** 658 * Get the raw theme root relative to the content directory with no filters applied.665 * Gets the raw theme root relative to the content directory with no filters applied. 659 666 * 660 667 * @since 3.1.0 … … 696 703 697 704 /** 698 * Display localized stylesheet link element.705 * Displays localized stylesheet link element. 699 706 * 700 707 * @since 2.1.0 … … 727 734 * @global array $sidebars_widgets 728 735 * 729 * @param string $stylesheet Stylesheet name 736 * @param string $stylesheet Stylesheet name. 730 737 */ 731 738 function switch_theme( $stylesheet ) { … … 829 836 * Will switch theme to the fallback theme if current theme does not validate. 830 837 * 831 * You can use the {@see 'validate_current_theme'} filter to return false to 832 * disablethis functionality.838 * You can use the {@see 'validate_current_theme'} filter to return false to disable 839 * this functionality. 833 840 * 834 841 * @since 1.5.0 … … 870 877 * If we're in an invalid state but WP_DEFAULT_THEME doesn't exist, 871 878 * switch to the latest core default theme that's installed. 879 * 872 880 * If it turns out that this latest core default theme is our current 873 881 * theme, then there's nothing we can do about that, so we have to bail, … … 958 966 959 967 /** 960 * Retrieve all theme modifications.968 * Retrieves all theme modifications. 961 969 * 962 970 * @since 3.1.0 … … 982 990 983 991 /** 984 * Retrieve theme modification value for the current theme.992 * Retrieves theme modification value for the current theme. 985 993 * 986 994 * If the modification name does not exist, then the $default will be passed … … 1025 1033 1026 1034 /** 1027 * Update theme modification value for the current theme.1035 * Updates theme modification value for the current theme. 1028 1036 * 1029 1037 * @since 2.1.0 … … 1055 1063 1056 1064 /** 1057 * Remove theme modification name from current theme list.1058 * 1059 * If removing the name also removes all elements, then the entire option will1060 * be removed.1065 * Removes theme modification name from current theme list. 1066 * 1067 * If removing the name also removes all elements, then the entire option 1068 * will be removed. 1061 1069 * 1062 1070 * @since 2.1.0 … … 1082 1090 1083 1091 /** 1084 * Remove theme modifications option for current theme.1092 * Removes theme modifications option for current theme. 1085 1093 * 1086 1094 * @since 2.1.0 … … 1134 1142 1135 1143 /** 1136 * Check whether a header image is set or not.1144 * Checks whether a header image is set or not. 1137 1145 * 1138 1146 * @since 4.2.0 … … 1147 1155 1148 1156 /** 1149 * Retrieve header image for custom header.1157 * Retrieves header image for custom header. 1150 1158 * 1151 1159 * @since 2.1.0 … … 1168 1176 1169 1177 /** 1170 * Create image tag markup for a custom header image.1178 * Creates image tag markup for a custom header image. 1171 1179 * 1172 1180 * @since 4.4.0 … … 1235 1243 1236 1244 /** 1237 * Display the image markup for a custom header image.1245 * Displays the image markup for a custom header image. 1238 1246 * 1239 1247 * @since 4.4.0 … … 1246 1254 1247 1255 /** 1248 * Get random header image data from registered images in theme.1256 * Gets random header image data from registered images in theme. 1249 1257 * 1250 1258 * @since 3.4.0 … … 1252 1260 * @access private 1253 1261 * 1254 * @global array 1262 * @global array $_wp_default_headers 1255 1263 * 1256 1264 * @return object … … 1290 1298 1291 1299 /** 1292 * Get random header image urlfrom registered images in theme.1300 * Gets random header image URL from registered images in theme. 1293 1301 * 1294 1302 * @since 3.2.0 1295 1303 * 1296 * @return string Path to header image 1304 * @return string Path to header image. 1297 1305 */ 1298 1306 function get_random_header_image() { … … 1307 1315 1308 1316 /** 1309 * Check if random header image is in use.1317 * Checks if random header image is in use. 1310 1318 * 1311 1319 * Always true if user expressly chooses the option in Appearance > Header. … … 1315 1323 * @since 3.2.0 1316 1324 * 1317 * @param string $type The random pool to use. any|default|uploaded 1325 * @param string $type The random pool to use. Possible values include 'any', 1326 * 'default', 'uploaded'. Default 'any'. 1318 1327 * @return bool 1319 1328 */ … … 1340 1349 1341 1350 /** 1342 * Display header image URL.1351 * Displays header image URL. 1343 1352 * 1344 1353 * @since 2.1.0 … … 1353 1362 1354 1363 /** 1355 * Get the header images uploaded for the current theme.1364 * Gets the header images uploaded for the current theme. 1356 1365 * 1357 1366 * @since 3.2.0 … … 1401 1410 1402 1411 /** 1403 * Get the header image data.1412 * Gets the header image data. 1404 1413 * 1405 1414 * @since 3.4.0 … … 1446 1455 1447 1456 /** 1448 * Register a selection of default headers to be displayed by the custom header admin UI.1457 * Registers a selection of default headers to be displayed by the custom header admin UI. 1449 1458 * 1450 1459 * @since 3.0.0 … … 1462 1471 1463 1472 /** 1464 * Unregister default headers.1473 * Unregisters default headers. 1465 1474 * 1466 1475 * This function must be called after register_default_headers() has already added the … … 1489 1498 1490 1499 /** 1491 * Check whether a header video is set or not.1500 * Checks whether a header video is set or not. 1492 1501 * 1493 1502 * @since 4.7.0 … … 1502 1511 1503 1512 /** 1504 * Retrieve header video URL for custom header.1513 * Retrieves header video URL for custom header. 1505 1514 * 1506 1515 * Uses a local video if present, or falls back to an external video. … … 1537 1546 1538 1547 /** 1539 * Display header video URL.1548 * Displays header video URL. 1540 1549 * 1541 1550 * @since 4.7.0 … … 1550 1559 1551 1560 /** 1552 * Retrieve header video settings.1561 * Retrieves header video settings. 1553 1562 * 1554 1563 * @since 4.7.0 … … 1594 1603 1595 1604 /** 1596 * Check whether a custom header is set or not.1605 * Checks whether a custom header is set or not. 1597 1606 * 1598 1607 * @since 4.7.0 … … 1629 1638 1630 1639 /** 1631 * Modifywhether the custom header video is eligible to show on the current page.1640 * Filters whether the custom header video is eligible to show on the current page. 1632 1641 * 1633 1642 * @since 4.7.0 … … 1641 1650 1642 1651 /** 1643 * Retrieve the markup for a custom header.1652 * Retrieves the markup for a custom header. 1644 1653 * 1645 1654 * The container div will always be returned in the Customizer preview. … … 1661 1670 1662 1671 /** 1663 * Print the markup for a custom header.1672 * Prints the markup for a custom header. 1664 1673 * 1665 1674 * A container div will always be printed in the Customizer preview. … … 1682 1691 1683 1692 /** 1684 * Retrieve background image for custom background.1693 * Retrieves background image for custom background. 1685 1694 * 1686 1695 * @since 3.0.0 … … 1693 1702 1694 1703 /** 1695 * Display background image path.1704 * Displays background image path. 1696 1705 * 1697 1706 * @since 3.0.0 … … 1702 1711 1703 1712 /** 1704 * Retrieve value for custom background color.1713 * Retrieves value for custom background color. 1705 1714 * 1706 1715 * @since 3.0.0 … … 1713 1722 1714 1723 /** 1715 * Display background color value.1724 * Displays background color value. 1716 1725 * 1717 1726 * @since 3.0.0 … … 1803 1812 1804 1813 /** 1805 * Render the Custom CSS style element.1814 * Renders the Custom CSS style element. 1806 1815 * 1807 1816 * @since 4.7.0 … … 1820 1829 1821 1830 /** 1822 * Fetch the `custom_css` post for a given theme.1831 * Fetches the `custom_css` post for a given theme. 1823 1832 * 1824 1833 * @since 4.7.0 … … 1871 1880 1872 1881 /** 1873 * Fetch the saved Custom CSS content for rendering.1882 * Fetches the saved Custom CSS content for rendering. 1874 1883 * 1875 1884 * @since 4.7.0 … … 1904 1913 1905 1914 /** 1906 * Update the `custom_css` post for a given theme.1915 * Updates the `custom_css` post for a given theme. 1907 1916 * 1908 1917 * Inserts a `custom_css` post when one doesn't yet exist. … … 2004 2013 2005 2014 /** 2006 * Add callback for custom TinyMCE editor stylesheets.2015 * Adds callback for custom TinyMCE editor stylesheets. 2007 2016 * 2008 2017 * The parameter $stylesheet is the name of the stylesheet, relative to … … 2062 2071 2063 2072 /** 2064 * Retrieve any registered editor stylesheet URLs.2073 * Retrieves any registered editor stylesheet URLs. 2065 2074 * 2066 2075 * @since 4.0.0 … … 2118 2127 2119 2128 /** 2120 * Expand a theme's starter content configuration using core-provided data.2129 * Expands a theme's starter content configuration using core-provided data. 2121 2130 * 2122 2131 * @since 4.7.0 … … 2834 2843 2835 2844 /** 2836 * Do not use. Removes theme support internally without knowledge of those not used by2837 * themes directly.2845 * Do not use. Removes theme support internally without knowledge of those not used 2846 * by themes directly. 2838 2847 * 2839 2848 * @access private … … 2995 3004 2996 3005 /** 2997 * Registers a theme feature for use in {@see add_theme_support}. 2998 * 2999 * This does not indicate that the current theme supports the feature, it only describes the feature's supported options. 3006 * Registers a theme feature for use in add_theme_support(). 3007 * 3008 * This does not indicate that the current theme supports the feature, it only describes 3009 * the feature's supported options. 3000 3010 * 3001 3011 * @since 5.5.0 3012 * 3013 * @see add_theme_support() 3002 3014 * 3003 3015 * @global $_wp_registered_theme_features … … 3005 3017 * @param string $feature The name uniquely identifying the feature. 3006 3018 * @param array $args { 3007 * Data used to describe the theme 3008 * 3009 * @type string $type The type of data associated with this feature. Defaults to 'boolean'. 3010 * Valid values are 'string', 'boolean', 'integer', 'number', 'array', and 'object'. 3011 * @type boolean $variadic Does this feature utilize the variadic support of {@see add_theme_support()}, 3012 * or are all arguments specified as the second parameter. Must be used with the "array" type. 3013 * @type string $description A short description of the feature. Included in the Themes REST API schema. Intended for developers. 3019 * Data used to describe the theme. 3020 * 3021 * @type string $type The type of data associated with this feature. 3022 * Valid values are 'string', 'boolean', 'integer', 3023 * 'number', 'array', and 'object'. Defaults to 'boolean'. 3024 * @type boolean $variadic Does this feature utilize the variadic support 3025 * of add_theme_support(), or are all arguments specified 3026 * as the second parameter. Must be used with the "array" type. 3027 * @type string $description A short description of the feature. Included in 3028 * the Themes REST API schema. Intended for developers. 3014 3029 * @type bool|array $show_in_rest { 3015 * Whether this feature should be included in the Themes REST API endpoint. Defaults to not being included. 3016 * When registering an 'array' or 'object' type, this argument must be an array with the 'schema' key. 3017 * 3018 * @type array $schema Specifies the JSON Schema definition describing the feature. If any objects in the schema 3019 * do not include the 'additionalProperties' keyword, it is set to false. 3020 * @type string $name An alternate name to be use as the property name in the REST API. 3021 * @type callable $prepare_callback A function used to format the theme support in the REST API. Receives the raw theme support value. 3030 * Whether this feature should be included in the Themes REST API endpoint. 3031 * Defaults to not being included. When registering an 'array' or 'object' type, 3032 * this argument must be an array with the 'schema' key. 3033 * 3034 * @type array $schema Specifies the JSON Schema definition describing 3035 * the feature. If any objects in the schema do not include 3036 * the 'additionalProperties' keyword, it is set to false. 3037 * @type string $name An alternate name to be used as the property name 3038 * in the REST API. 3039 * @type callable $prepare_callback A function used to format the theme support in the REST API. 3040 * Receives the raw theme support value. 3022 3041 * } 3023 3042 * } … … 3056 3075 3057 3076 if ( ! in_array( $args['type'], array( 'string', 'boolean', 'integer', 'number', 'array', 'object' ), true ) ) { 3058 return new WP_Error( 'invalid_type', __( 'The feature "type" is not valid JSON Schema type.' ) ); 3077 return new WP_Error( 3078 'invalid_type', 3079 __( 'The feature "type" is not valid JSON Schema type.' ) 3080 ); 3059 3081 } 3060 3082 3061 3083 if ( true === $args['variadic'] && 'array' !== $args['type'] ) { 3062 return new WP_Error( 'variadic_must_be_array', __( 'When registering a "variadic" theme feature, the "type" must be an "array".' ) ); 3084 return new WP_Error( 3085 'variadic_must_be_array', 3086 __( 'When registering a "variadic" theme feature, the "type" must be an "array".' ) 3087 ); 3063 3088 } 3064 3089 3065 3090 if ( false !== $args['show_in_rest'] && in_array( $args['type'], array( 'array', 'object' ), true ) ) { 3066 3091 if ( ! is_array( $args['show_in_rest'] ) || empty( $args['show_in_rest']['schema'] ) ) { 3067 return new WP_Error( 'missing_schema', __( 'When registering an "array" or "object" feature to show in the REST API, the feature\'s schema must also be defined.' ) ); 3092 return new WP_Error( 3093 'missing_schema', 3094 __( 'When registering an "array" or "object" feature to show in the REST API, the feature\'s schema must also be defined.' ) 3095 ); 3068 3096 } 3069 3097 3070 3098 if ( 'array' === $args['type'] && ! isset( $args['show_in_rest']['schema']['items'] ) ) { 3071 return new WP_Error( 'missing_schema_items', __( 'When registering an "array" feature, the feature\'s schema must include the "items" keyword.' ) ); 3099 return new WP_Error( 3100 'missing_schema_items', 3101 __( 'When registering an "array" feature, the feature\'s schema must include the "items" keyword.' ) 3102 ); 3072 3103 } 3073 3104 3074 3105 if ( 'object' === $args['type'] && ! isset( $args['show_in_rest']['schema']['properties'] ) ) { 3075 return new WP_Error( 'missing_schema_properties', __( 'When registering an "object" feature, the feature\'s schema must include the "properties" keyword.' ) ); 3106 return new WP_Error( 3107 'missing_schema_properties', 3108 __( 'When registering an "object" feature, the feature\'s schema must include the "properties" keyword.' ) 3109 ); 3076 3110 } 3077 3111 } … … 3079 3113 if ( is_array( $args['show_in_rest'] ) ) { 3080 3114 if ( isset( $args['show_in_rest']['prepare_callback'] ) && ! is_callable( $args['show_in_rest']['prepare_callback'] ) ) { 3081 return new WP_Error( 'invalid_rest_prepare_callback', __( 'The prepare_callback must be a callable function.' ) ); 3115 return new WP_Error( 3116 'invalid_rest_prepare_callback', 3117 __( 'The prepare_callback must be a callable function.' ) 3118 ); 3082 3119 } 3083 3120 … … 3091 3128 ); 3092 3129 3093 if ( is_bool( $args['show_in_rest']['schema']['default'] ) && ! in_array( 'boolean', (array) $args['show_in_rest']['schema']['type'], true ) ) { 3130 if ( is_bool( $args['show_in_rest']['schema']['default'] ) 3131 && ! in_array( 'boolean', (array) $args['show_in_rest']['schema']['type'], true ) 3132 ) { 3094 3133 // Automatically include the "boolean" type when the default value is a boolean. 3095 3134 $args['show_in_rest']['schema']['type'] = (array) $args['show_in_rest']['schema']['type']; … … 3523 3562 3524 3563 /** 3525 * Make sure that auto-draft posts get their post_date bumped or status changed to draft to prevent premature garbage-collection.3564 * Makes sure that auto-draft posts get their post_date bumped or status changed to draft to prevent premature garbage-collection. 3526 3565 * 3527 3566 * When a changeset is updated but remains an auto-draft, ensure the post_date
Note: See TracChangeset
for help on using the changeset viewer.