X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/0461a5f2e55c8d5f1fde96ca2e83117152573c7d..9e77185fafaf4e60e2b73821e0e4b9b1a11fb85f:/wp-includes/theme.php diff --git a/wp-includes/theme.php b/wp-includes/theme.php index 00b3c39d..85119eda 100644 --- a/wp-includes/theme.php +++ b/wp-includes/theme.php @@ -137,7 +137,7 @@ function is_child_theme() { * The theme name that the administrator has currently set the front end theme * as. * - * For all extensive purposes, the template name and the stylesheet name are + * For all intents and purposes, the template name and the stylesheet name are * going to be the same for most cases. * * @since 1.5.0 @@ -370,11 +370,19 @@ function register_theme_directory( $directory ) { // Try prepending as the theme directory could be relative to the content directory $directory = WP_CONTENT_DIR . '/' . $directory; // If this directory does not exist, return and do not register - if ( ! file_exists( $directory ) ) + if ( ! file_exists( $directory ) ) { return false; + } } - $wp_theme_directories[] = $directory; + if ( ! is_array( $wp_theme_directories ) ) { + $wp_theme_directories = array(); + } + + $untrailed = untrailingslashit( $directory ); + if ( ! empty( $untrailed ) && ! in_array( $untrailed, $wp_theme_directories ) ) { + $wp_theme_directories[] = $untrailed; + } return true; } @@ -1394,6 +1402,54 @@ function remove_editor_styles() { return true; } +/** + * Retrieve any registered editor stylesheets + * + * @since 4.0.0 + * + * @global $editor_styles Registered editor stylesheets + * + * @return array If registered, a list of editor stylesheet URLs. + */ +function get_editor_stylesheets() { + $stylesheets = array(); + // load editor_style.css if the current theme supports it + if ( ! empty( $GLOBALS['editor_styles'] ) && is_array( $GLOBALS['editor_styles'] ) ) { + $editor_styles = $GLOBALS['editor_styles']; + + $editor_styles = array_unique( array_filter( $editor_styles ) ); + $style_uri = get_stylesheet_directory_uri(); + $style_dir = get_stylesheet_directory(); + + // Support externally referenced styles (like, say, fonts). + foreach ( $editor_styles as $key => $file ) { + if ( preg_match( '~^(https?:)?//~', $file ) ) { + $stylesheets[] = esc_url_raw( $file ); + unset( $editor_styles[ $key ] ); + } + } + + // Look in a parent theme first, that way child theme CSS overrides. + if ( is_child_theme() ) { + $template_uri = get_template_directory_uri(); + $template_dir = get_template_directory(); + + foreach ( $editor_styles as $key => $file ) { + if ( $file && file_exists( "$template_dir/$file" ) ) { + $stylesheets[] = "$template_uri/$file"; + } + } + } + + foreach ( $editor_styles as $file ) { + if ( $file && file_exists( "$style_dir/$file" ) ) { + $stylesheets[] = "$style_uri/$file"; + } + } + } + return $stylesheets; +} + /** * Allows a theme to register its support of a certain feature * @@ -1437,7 +1493,6 @@ function add_theme_support( $feature ) { case 'custom-header-uploads' : return add_theme_support( 'custom-header', array( 'uploads' => true ) ); - break; case 'custom-header' : if ( ! is_array( $args ) ) @@ -1618,10 +1673,9 @@ function get_theme_support( $feature ) { if ( isset( $_wp_theme_features[ $feature ][0][ $args[0] ] ) ) return $_wp_theme_features[ $feature ][0][ $args[0] ]; return false; - break; + default : return $_wp_theme_features[ $feature ]; - break; } } @@ -1720,7 +1774,6 @@ function current_theme_supports( $feature ) { return true; $content_type = $args[0]; return in_array( $content_type, $_wp_theme_features[$feature][0] ); - break; case 'html5': case 'post-formats': @@ -1731,7 +1784,6 @@ function current_theme_supports( $feature ) { $type = $args[0]; return in_array( $type, $_wp_theme_features[$feature][0] ); - break; case 'custom-header': case 'custom-background' : @@ -1739,7 +1791,6 @@ function current_theme_supports( $feature ) { // an array to add_theme_support() $header_support = $args[0]; return ( isset( $_wp_theme_features[$feature][0][$header_support] ) && $_wp_theme_features[$feature][0][$header_support] ); - break; } /** @@ -1879,6 +1930,9 @@ function _wp_customize_loader_settings() { 'url' => esc_url( admin_url( 'customize.php' ) ), 'isCrossDomain' => $cross_domain, 'browser' => $browser, + 'l10n' => array( + 'saveAlert' => __( 'The changes you made will be lost if you navigate away from this page.' ), + ), ); $script = 'var _wpCustomizeLoaderSettings = ' . json_encode( $settings ) . ';'; @@ -1943,3 +1997,18 @@ function wp_customize_support_script() { is_preview(); +}