X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/6c8f14c09105d0afa4c1574215c59b5021040e76..refs/tags/wordpress-4.0:/wp-admin/custom-header.php?ds=sidebyside diff --git a/wp-admin/custom-header.php b/wp-admin/custom-header.php index 14f01dfb..76f6f746 100644 --- a/wp-admin/custom-header.php +++ b/wp-admin/custom-header.php @@ -22,7 +22,7 @@ class Custom_Image_Header { * @since 2.1.0 * @access private */ - var $admin_header_callback; + private $admin_header_callback; /** * Callback for header div. @@ -31,7 +31,7 @@ class Custom_Image_Header { * @since 3.0.0 * @access private */ - var $admin_image_div_callback; + private $admin_image_div_callback; /** * Holds default headers. @@ -40,16 +40,16 @@ class Custom_Image_Header { * @since 3.0.0 * @access private */ - var $default_headers = array(); + private $default_headers = array(); /** - * Holds custom headers uploaded by the user + * Holds custom headers uploaded by the user. * * @var array * @since 3.2.0 * @access private */ - var $uploaded_headers = array(); + private $uploaded_headers = array(); /** * Holds the page menu hook. @@ -58,7 +58,7 @@ class Custom_Image_Header { * @since 3.0.0 * @access private */ - var $page = ''; + private $page = ''; /** * Constructor - Register administration header callback. @@ -68,11 +68,68 @@ class Custom_Image_Header { * @param callback $admin_image_div_callback Optional custom image div output callback. * @return Custom_Image_Header */ - function __construct($admin_header_callback, $admin_image_div_callback = '') { + public function __construct($admin_header_callback, $admin_image_div_callback = '') { $this->admin_header_callback = $admin_header_callback; $this->admin_image_div_callback = $admin_image_div_callback; add_action( 'admin_menu', array( $this, 'init' ) ); + + add_action( 'customize_save_after', array( $this, 'customize_set_last_used' ) ); + add_action( 'wp_ajax_custom-header-crop', array( $this, 'ajax_header_crop' ) ); + add_action( 'wp_ajax_custom-header-add', array( $this, 'ajax_header_add' ) ); + add_action( 'wp_ajax_custom-header-remove', array( $this, 'ajax_header_remove' ) ); + } + + /** + * Make private properties readable for backwards compatibility. + * + * @since 4.0.0 + * @access public + * + * @param string $name Property to get. + * @return mixed Property. + */ + public function __get( $name ) { + return $this->$name; + } + + /** + * Make private properties settable for backwards compatibility. + * + * @since 4.0.0 + * @access public + * + * @param string $name Property to set. + * @param mixed $value Property value. + * @return mixed Newly-set property. + */ + public function __set( $name, $value ) { + return $this->$name = $value; + } + + /** + * Make private properties checkable for backwards compatibility. + * + * @since 4.0.0 + * @access public + * + * @param string $name Property to check if set. + * @return bool Whether the property is set. + */ + public function __isset( $name ) { + return isset( $this->$name ); + } + + /** + * Make private properties un-settable for backwards compatibility. + * + * @since 4.0.0 + * @access public + * + * @param string $name Property to unset. + */ + public function __unset( $name ) { + unset( $this->$name ); } /** @@ -80,19 +137,20 @@ class Custom_Image_Header { * * @since 2.1.0 */ - function init() { + public function init() { if ( ! current_user_can('edit_theme_options') ) return; - $this->page = $page = add_theme_page(__('Header'), __('Header'), 'edit_theme_options', 'custom-header', array(&$this, 'admin_page')); + $this->page = $page = add_theme_page(__('Header'), __('Header'), 'edit_theme_options', 'custom-header', array($this, 'admin_page')); - add_action("admin_print_scripts-$page", array(&$this, 'js_includes')); - add_action("admin_print_styles-$page", array(&$this, 'css_includes')); - add_action("admin_head-$page", array(&$this, 'help') ); - add_action("admin_head-$page", array(&$this, 'take_action'), 50); - add_action("admin_head-$page", array(&$this, 'js'), 50); + add_action("admin_print_scripts-$page", array($this, 'js_includes')); + add_action("admin_print_styles-$page", array($this, 'css_includes')); + add_action("admin_head-$page", array($this, 'help') ); + add_action("admin_head-$page", array($this, 'take_action'), 50); + add_action("admin_head-$page", array($this, 'js'), 50); if ( $this->admin_header_callback ) add_action("admin_head-$page", $this->admin_header_callback, 51); + } /** @@ -100,7 +158,7 @@ class Custom_Image_Header { * * @since 3.0.0 */ - function help() { + public function help() { get_current_screen()->add_help_tab( array( 'id' => 'overview', 'title' => __('Overview'), @@ -131,7 +189,7 @@ class Custom_Image_Header { get_current_screen()->set_help_sidebar( '

' . __( 'For more information:' ) . '

' . '

' . __( 'Documentation on Custom Header' ) . '

' . - '

' . __( 'Support Forums' ) . '

' + '

' . __( 'Support Forums' ) . '

' ); } @@ -142,7 +200,7 @@ class Custom_Image_Header { * * @return int Current step */ - function step() { + public function step() { if ( ! isset( $_GET['step'] ) ) return 1; @@ -161,7 +219,7 @@ class Custom_Image_Header { * * @since 2.1.0 */ - function js_includes() { + public function js_includes() { $step = $this->step(); if ( ( 1 == $step || 3 == $step ) ) { @@ -177,9 +235,9 @@ class Custom_Image_Header { /** * Set up the enqueue for the CSS files * - * @since 2.7 + * @since 2.7.0 */ - function css_includes() { + public function css_includes() { $step = $this->step(); if ( ( 1 == $step || 3 == $step ) && current_theme_supports( 'custom-header', 'header-text' ) ) @@ -193,7 +251,7 @@ class Custom_Image_Header { * * @since 2.6.0 */ - function take_action() { + public function take_action() { if ( ! current_user_can('edit_theme_options') ) return; @@ -239,7 +297,7 @@ class Custom_Image_Header { * * @since 3.0.0 */ - function process_default_headers() { + public function process_default_headers() { global $_wp_default_headers; if ( !empty($this->headers) ) @@ -248,6 +306,10 @@ class Custom_Image_Header { if ( !isset($_wp_default_headers) ) return; + if ( ! empty( $this->default_headers ) ) { + return; + } + $this->default_headers = $_wp_default_headers; $template_directory_uri = get_template_directory_uri(); $stylesheet_directory_uri = get_stylesheet_directory_uri(); @@ -255,7 +317,6 @@ class Custom_Image_Header { $this->default_headers[$header]['url'] = sprintf( $this->default_headers[$header]['url'], $template_directory_uri, $stylesheet_directory_uri ); $this->default_headers[$header]['thumbnail_url'] = sprintf( $this->default_headers[$header]['thumbnail_url'], $template_directory_uri, $stylesheet_directory_uri ); } - } /** @@ -266,7 +327,7 @@ class Custom_Image_Header { * * @since 3.0.0 */ - function show_header_selector( $type = 'default' ) { + public function show_header_selector( $type = 'default' ) { if ( 'default' == $type ) { $headers = $this->default_headers; } else { @@ -303,7 +364,7 @@ class Custom_Image_Header { * * @since 2.1.0 */ - function js() { + public function js() { $step = $this->step(); if ( ( 1 == $step || 3 == $step ) && current_theme_supports( 'custom-header', 'header-text' ) ) $this->js_1(); @@ -316,11 +377,20 @@ class Custom_Image_Header { * * @since 2.6.0 */ - function js_1() { ?> + public function js_1() { + $default_color = ''; + if ( current_theme_supports( 'custom-header', 'default-text-color' ) ) { + $default_color = get_theme_support( 'custom-header', 'default-text-color' ); + if ( $default_color && false === strpos( $default_color, '#' ) ) { + $default_color = '#' . $default_color; + } + } + ?> +