X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/8f374b7233bc2815ccc387e448d208c5434eb961..0f684a09c03e547d3132bddc970cbeafcd1102f4:/wp-admin/custom-header.php diff --git a/wp-admin/custom-header.php b/wp-admin/custom-header.php index fc9d4f12..1c9971f5 100644 --- a/wp-admin/custom-header.php +++ b/wp-admin/custom-header.php @@ -43,7 +43,7 @@ class Custom_Image_Header { var $default_headers = array(); /** - * Holds custom headers uploaded by the user + * Holds custom headers uploaded by the user. * * @var array * @since 3.2.0 @@ -73,6 +73,11 @@ class Custom_Image_Header { $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' ) ); } /** @@ -84,21 +89,16 @@ class Custom_Image_Header { 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); - if ( isset( $_REQUEST['context'] ) && $_REQUEST['context'] == 'custom-header' ) { - add_filter( 'attachment_fields_to_edit', array( $this, 'attachment_fields_to_edit' ), 10, 2 ); - add_filter( 'media_upload_tabs', array( $this, 'filter_upload_tabs' ) ); - add_filter( 'media_upload_mime_type_links', '__return_empty_array' ); - } } /** @@ -130,14 +130,14 @@ class Custom_Image_Header { 'title' => __('Header Text'), 'content' => '

' . sprintf( __( 'For most themes, the header text is your Site Title and Tagline, as defined in the General Settings section.' ), admin_url( 'options-general.php' ) ) . '

' . - '

' . __( 'In the Header Text section of this page, you can choose whether to display this text or hide it. You can also choose a color for the text by typing in a legitimate HTML hex value (eg: “#ff0000” for red) or by clicking “Select a Color” and dialing in a color using the color picker.') . '

' . - '

' . __( 'Don’t forget to Save Changes when you’re done!') . '

' + '

' . __( 'In the Header Text section of this page, you can choose whether to display this text or hide it. You can also choose a color for the text by clicking the Select Color button and either typing in a legitimate HTML hex value, e.g. “#ff0000” for red, or by choosing a color using the color picker.' ) . '

' . + '

' . __( 'Don’t forget to click “Save Changes” when you’re done!') . '

' ) ); get_current_screen()->set_help_sidebar( '

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

' . '

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

' . - '

' . __( 'Support Forums' ) . '

' + '

' . __( 'Support Forums' ) . '

' ); } @@ -171,11 +171,10 @@ class Custom_Image_Header { $step = $this->step(); if ( ( 1 == $step || 3 == $step ) ) { - add_thickbox(); - wp_enqueue_script( 'media-upload' ); + wp_enqueue_media(); wp_enqueue_script( 'custom-header' ); if ( current_theme_supports( 'custom-header', 'header-text' ) ) - wp_enqueue_script('farbtastic'); + wp_enqueue_script( 'wp-color-picker' ); } elseif ( 2 == $step ) { wp_enqueue_script('imgareaselect'); } @@ -184,13 +183,13 @@ class Custom_Image_Header { /** * Set up the enqueue for the CSS files * - * @since 2.7 + * @since 2.7.0 */ function css_includes() { $step = $this->step(); if ( ( 1 == $step || 3 == $step ) && current_theme_supports( 'custom-header', 'header-text' ) ) - wp_enqueue_style('farbtastic'); + wp_enqueue_style( 'wp-color-picker' ); elseif ( 2 == $step ) wp_enqueue_style('imgareaselect'); } @@ -215,12 +214,6 @@ class Custom_Image_Header { return; } - if ( isset( $_POST['resettext'] ) ) { - check_admin_referer( 'custom-header-options', '_wpnonce-custom-header-options' ); - remove_theme_mod('header_textcolor'); - return; - } - if ( isset( $_POST['removeheader'] ) ) { check_admin_referer( 'custom-header-options', '_wpnonce-custom-header-options' ); $this->remove_header_image(); @@ -261,6 +254,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(); @@ -268,7 +265,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 ); } - } /** @@ -332,7 +328,6 @@ class Custom_Image_Header { function js_1() { ?>