]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-includes/theme.php
WordPress 4.2.4-scripts
[autoinstalls/wordpress.git] / wp-includes / theme.php
index f8539e9f8f37113098f68131a6b6ed62f3f42845..6abf1dc1debc4c21438eb873c54473cac5fcf4fd 100644 (file)
@@ -406,6 +406,7 @@ function search_theme_directories( $force = false ) {
        $found_themes = array();
 
        $wp_theme_directories = (array) $wp_theme_directories;
+       $relative_theme_roots = array();
 
        // Set up maybe-relative, maybe-absolute array of theme directories.
        // We always want to return absolute, but we need to cache relative
@@ -672,10 +673,7 @@ function preview_theme() {
 
        // Prevent theme mods to current theme being used on theme being previewed
        add_filter( 'pre_option_theme_mods_' . get_option( 'stylesheet' ), '__return_empty_array' );
-
-       ob_start( 'preview_theme_ob_filter' );
 }
-add_action('setup_theme', 'preview_theme');
 
 /**
  * Private function to modify the current template when previewing a theme
@@ -711,7 +709,7 @@ function _preview_theme_stylesheet_filter() {
  * @return string
  */
 function preview_theme_ob_filter( $content ) {
-       return preg_replace_callback( "|(<a.*?href=([\"']))(.*?)([\"'].*?>)|", 'preview_theme_ob_filter_callback', $content );
+       return $content;
 }
 
 /**
@@ -726,26 +724,7 @@ function preview_theme_ob_filter( $content ) {
  * @return string
  */
 function preview_theme_ob_filter_callback( $matches ) {
-       if ( strpos($matches[4], 'onclick') !== false )
-               $matches[4] = preg_replace('#onclick=([\'"]).*?(?<!\\\)\\1#i', '', $matches[4]); //Strip out any onclicks from rest of <a>. (?<!\\\) means to ignore the '" if it's escaped by \  to prevent breaking mid-attribute.
-       if (
-               ( false !== strpos($matches[3], '/wp-admin/') )
-       ||
-               ( false !== strpos( $matches[3], '://' ) && 0 !== strpos( $matches[3], home_url() ) )
-       ||
-               ( false !== strpos($matches[3], '/feed/') )
-       ||
-               ( false !== strpos($matches[3], '/trackback/') )
-       )
-               return $matches[1] . "#$matches[2] onclick=$matches[2]return false;" . $matches[4];
-
-       $stylesheet = isset( $_GET['stylesheet'] ) ? $_GET['stylesheet'] : '';
-       $template   = isset( $_GET['template'] )   ? $_GET['template']   : '';
-
-       $link = add_query_arg( array( 'preview' => 1, 'template' => $template, 'stylesheet' => $stylesheet, 'preview_iframe' => 1 ), $matches[3] );
-       if ( 0 === strpos($link, 'preview=1') )
-               $link = "?$link";
-       return $matches[1] . esc_attr( $link ) . $matches[4];
+       return $matches[0];
 }
 
 /**
@@ -934,7 +913,7 @@ function get_theme_mod( $name, $default = false ) {
  * @since 2.1.0
  *
  * @param string $name Theme modification name.
- * @param string $value theme modification value.
+ * @param mixed  $value theme modification value.
  */
 function set_theme_mod( $name, $value ) {
        $mods = get_theme_mods();
@@ -1034,12 +1013,25 @@ function display_header_text() {
        return 'blank' != $text_color;
 }
 
+/**
+ * Check whether a header image is set or not.
+ *
+ * @since 4.2.0
+ *
+ * @see get_header_image()
+ *
+ * @return bool Whether a header image is set or not.
+ */
+function has_header_image() {
+       return (bool) get_header_image();
+}
+
 /**
  * Retrieve header image for custom header.
  *
  * @since 2.1.0
  *
- * @return string
+ * @return string|false
  */
 function get_header_image() {
        $url = get_theme_mod( 'header_image', get_theme_support( 'custom-header', 'default-image' ) );
@@ -1142,7 +1134,10 @@ function is_random_header_image( $type = 'any' ) {
  * @since 2.1.0
  */
 function header_image() {
-       echo esc_url( get_header_image() );
+       $image = get_header_image();
+       if ( $image ) {
+               echo esc_url( $image );
+       }
 }
 
 /**
@@ -1662,7 +1657,6 @@ function _custom_header_background_just_in_time() {
                }
        }
 }
-add_action( 'wp_loaded', '_custom_header_background_just_in_time' );
 
 /**
  * Gets the theme support arguments passed when registering that support
@@ -1871,8 +1865,6 @@ function _delete_attachment_theme_mod( $id ) {
                remove_theme_mod( 'background_image' );
 }
 
-add_action( 'delete_attachment', '_delete_attachment_theme_mod' );
-
 /**
  * Checks if a theme has been changed and runs 'after_switch_theme' hook on the next WP load
  *
@@ -1929,7 +1921,6 @@ function _wp_customize_include() {
        // Init Customize class
        $GLOBALS['wp_customize'] = new WP_Customize_Manager;
 }
-add_action( 'plugins_loaded', '_wp_customize_include' );
 
 /**
  * Adds settings for the customize-loader script.
@@ -1953,7 +1944,8 @@ function _wp_customize_loader_settings() {
                'isCrossDomain' => $cross_domain,
                'browser'       => $browser,
                'l10n'          => array(
-                       'saveAlert' => __( 'The changes you made will be lost if you navigate away from this page.' ),
+                       'saveAlert'       => __( 'The changes you made will be lost if you navigate away from this page.' ),
+                       'mainIframeTitle' => __( 'Customizer' ),
                ),
        );
 
@@ -1965,7 +1957,6 @@ function _wp_customize_loader_settings() {
 
        $wp_scripts->add_data( 'customize-loader', 'data', $script );
 }
-add_action( 'admin_enqueue_scripts', '_wp_customize_loader_settings' );
 
 /**
  * Returns a URL to load the Customizer.
@@ -2032,5 +2023,5 @@ function wp_customize_support_script() {
 function is_customize_preview() {
        global $wp_customize;
 
-       return is_a( $wp_customize, 'WP_Customize_Manager' ) && $wp_customize->is_preview();
+       return ( $wp_customize instanceof WP_Customize_Manager ) && $wp_customize->is_preview();
 }