Ticket #33755: 33755.16.diff
File 33755.16.diff, 7.0 KB (added by , 9 years ago) |
---|
-
src/wp-admin/includes/admin.php
72 72 /** WordPress Site Icon API */ 73 73 require_once(ABSPATH . 'wp-admin/includes/class-wp-site-icon.php'); 74 74 75 /** WordPress Custom Logo API */76 require_once(ABSPATH . 'wp-admin/includes/class-wp-custom-logo.php');77 78 75 /** WordPress Update Administration API */ 79 76 require_once(ABSPATH . 'wp-admin/includes/update.php'); 80 77 -
src/wp-admin/includes/class-wp-custom-logo.php
1 <?php2 /**3 * Administration API: WP_Custom_Logo class4 *5 * @package WordPress6 * @subpackage Administration7 * @since 4.5.08 */9 10 /**11 * Core class used to implement custom logo functionality.12 *13 * @since 4.5.014 */15 class WP_Custom_Logo {16 17 /**18 * Get current logo settings stored in theme mod.19 *20 * @since 4.5.021 * @access public22 */23 public function __construct() {24 add_action( 'wp_head', array( $this, 'head_text_styles' ) );25 add_action( 'delete_attachment', array( $this, 'delete_attachment_data' ) );26 }27 28 /**29 * Hides header text on the front end if necessary.30 *31 * @since 4.5.032 * @access public33 */34 public function head_text_styles() {35 // Bail if our theme supports custom headers.36 if ( current_theme_supports( 'custom-header' ) || get_theme_mod( 'custom_logo_header_text', true ) ) {37 return;38 }39 40 // Is Display Header Text unchecked? If so, hide the header text.41 ?>42 <!-- Custom Logo: hide header text -->43 <style type="text/css">44 <?php echo sanitize_html_class( $this->header_text_classes() ); ?> {45 position: absolute;46 clip: rect(1px, 1px, 1px, 1px);47 }48 </style>49 <?php50 }51 52 /**53 * Reset the custom logo if the current logo is deleted in the media manager.54 *55 * @since 4.5.056 * @access public57 *58 * @param int $post_id Post ID.59 */60 public function delete_attachment_data( $post_id ) {61 $custom_logo_id = get_theme_mod( 'custom_logo' );62 63 if ( $custom_logo_id && $custom_logo_id == $post_id ) {64 remove_theme_mod( 'custom_logo' );65 }66 }67 68 /**69 * Retrieves the header text classes.70 *71 * If not defined in add_theme_support(), defaults from Underscores will be used.72 *73 * @since 4.5.074 * @access protected75 *76 * @return string String of classes to hide.77 */78 protected function header_text_classes() {79 $args = get_theme_support( 'custom-logo' );80 81 if ( isset( $args[0]['header-text'] ) ) {82 // Use any classes defined in add_theme_support().83 $classes = $args[0]['header-text'];84 } else {85 // Otherwise, use these defaults, which will work with any Underscores-based theme.86 $classes = array(87 'site-title',88 'site-description',89 );90 }91 92 // If there's an array of classes, reduce them to a string for output.93 if ( is_array( $classes ) ) {94 $classes = array_map( 'sanitize_html_class', $classes );95 $classes = (string) '.' . implode( ', .', $classes );96 } else {97 $classes = (string) '.' . $classes;98 }99 100 return $classes;101 }102 }103 104 /**105 * WP_Custom_Logo instance.106 *107 * @global WP_Custom_Logo $wp_custom_logo108 */109 $GLOBALS['wp_custom_logo'] = new WP_Custom_Logo; -
src/wp-includes/class-wp-customize-manager.php
1922 1922 'section' => 'title_tagline', 1923 1923 ) ); 1924 1924 1925 // Add a setting to hide header text if the theme isn't supporting the feature itself. 1926 // @todo 1927 if ( ! current_theme_supports( 'custom-header' ) ) { 1925 // Add a setting to hide header text if the theme doesn't support custom headers. 1926 if ( ! current_theme_supports( 'custom-header', 'header-text' ) ) { 1928 1927 $this->add_setting( 'header_text', array( 1928 'theme_supports' => array( 'custom-logo', 'header-text' ), 1929 1929 'default' => 1, 1930 1930 'sanitize_callback' => 'absint', 1931 'transport' => 'postMessage',1932 1931 ) ); 1933 1932 1934 1933 $this->add_control( 'header_text', array( -
src/wp-includes/default-filters.php
371 371 */ 372 372 // Theme 373 373 add_action( 'wp_loaded', '_custom_header_background_just_in_time' ); 374 add_action( 'wp_head', '_custom_logo_just_in_time' ); 374 375 add_action( 'plugins_loaded', '_wp_customize_include' ); 375 376 add_action( 'admin_enqueue_scripts', '_wp_customize_loader_settings' ); 376 377 add_action( 'delete_attachment', '_delete_attachment_theme_mod' ); -
src/wp-includes/general-template.php
880 880 if ( is_multisite() && ms_is_switched() ) { 881 881 restore_current_blog(); 882 882 } 883 $size = get_theme_support( 'custom-logo' ); 884 $size = $size[0]['size']; 883 $size = get_theme_support( 'custom-logo', 'size' ); 885 884 886 885 // We have a logo. Logo is go. 887 886 if ( $custom_logo_id ) { -
src/wp-includes/theme.php
1732 1732 } 1733 1733 1734 1734 /** 1735 * Registers the internal custom header and background routines. 1736 * 1737 * @since 4.5.0 1738 * @access private 1739 */ 1740 function _custom_logo_just_in_time() { 1741 if ( ! current_theme_supports( 'custom-header' ) && get_theme_support( 'custom-logo', 'header-text' ) && ! get_theme_mod( 'header_text', true ) ) { 1742 $classes = (array) get_theme_support( 'custom-logo', 'header-text' ); 1743 $classes = array_map( 'sanitize_html_class', $classes ); 1744 $classes = '.' . implode( ', .', $classes ); 1745 1746 ?> 1747 <!-- Custom Logo: hide header text --> 1748 <style type="text/css"> 1749 <?php echo $classes; ?> { 1750 position: absolute; 1751 clip: rect(1px, 1px, 1px, 1px); 1752 } 1753 </style> 1754 <?php 1755 } 1756 } 1757 1758 /** 1735 1759 * Gets the theme support arguments passed when registering that support 1736 1760 * 1737 1761 * @since 3.1.0 … … 1927 1951 * @access private 1928 1952 * @since 3.0.0 1929 1953 * @since 4.3.0 Also removes `header_image_data`. 1954 * @since 4.5.0 Also removes custom logo theme mods. 1930 1955 * 1931 1956 * @param int $id The attachment id. 1932 1957 */ … … 1934 1959 $attachment_image = wp_get_attachment_url( $id ); 1935 1960 $header_image = get_header_image(); 1936 1961 $background_image = get_background_image(); 1962 $custom_logo_id = get_theme_mod( 'custom_logo' ); 1963 1964 if ( $custom_logo_id && $custom_logo_id == $id ) { 1965 remove_theme_mod( 'custom_logo' ); 1966 remove_theme_mod( 'header_text' ); 1967 } 1937 1968 1938 1969 if ( $header_image && $header_image == $attachment_image ) { 1939 1970 remove_theme_mod( 'header_image' );