Custom_Image_Header
- Since
- 2.1.0
- Source
wp-admin/includes/class-custom-image-header.php:14
The custom header image class.
Compatibility
- WordPress
- since 2.1.0
- 6.7.7
- 6.8.8
- 6.9.7
- 7.0.4
- 7.1.0
Present in every tracked release (6.7.7 to 7.1.0).
Hooks and filters fired · 6
Every hook that fires from inside Custom_Image_Header, in the order it appears in the class, grouped by the method that fires it.
Custom_Image_Header::step_2()
- apply_filters( wp_create_file_in_uploads )filter line 896
- apply_filters( wp_create_file_in_uploads )filter line 919
Properties · 4
$admin_header_callbackcallablepublic- Callback for administration header.
$admin_image_div_callbackcallablepublic- Callback for header div.
$default_headersarraypublic- Holds default headers.
$updatedboolprivate- Used to trigger a success message when settings updated and set to true.
Methods · 33
- __construct()Constructor - Registers administration header callback.
- init()Sets up the hooks for the Custom Header admin page.
- help()Adds contextual help.
- step()Gets the current step.
- js_includes()Sets up the enqueue for the JavaScript files.
- css_includes()Sets up the enqueue for the CSS files.
- take_action()Executes custom header modification.
- process_default_headers()Processes the default headers.
- show_header_selector()Displays UI for selecting one of several default headers.
- js()Executes JavaScript depending on step.
- js_1()Displays JavaScript based on Step 1 and 3.
- js_2()Displays JavaScript based on Step 2.
- step_1()Displays first step of custom header image page.
- step_2()Displays second step of custom header image page.
- step_2_manage_upload()Uploads the file to be cropped in the second step.
- step_3()Displays third step of custom header image page.
- finished()Displays last step of custom header image page.
- admin_page()Displays the page based on the current step.
- attachment_fields_to_edit()Unused since 3.5.0.
- filter_upload_tabs()Unused since 3.5.0.
- set_header_image()Chooses a header image, selected from existing uploaded and default headers, or provides an array of uploaded header data (either new, or from media library).
- remove_header_image()Removes a header image.
- reset_header_image()Resets a header image to the default image for the theme.
- get_header_dimensions()Calculates width and height based on what the currently selected theme supports.
- create_attachment_object()Creates an attachment 'object'.
- insert_attachment()Inserts an attachment and its metadata.
- ajax_header_crop()Gets attachment uploaded by Media Manager, crops it, then saves it as a new object. Returns JSON-encoded object details.
- ajax_header_add()Given an attachment ID for a header image, updates its "last used" timestamp to now.
- ajax_header_remove()Given an attachment ID for a header image, unsets it as a user-uploaded header image for the active theme.
- customize_set_last_used()Updates the last-used postmeta on a header image attachment after saving a new header image via the Customizer.
- get_default_header_images()Gets the details of default header images if defined.
- get_uploaded_header_images()Gets the previously uploaded header images.
- get_previous_crop()Gets the ID of a previous crop from the same base image.
Source code
#[AllowDynamicProperties]class Custom_Image_Header { /** * Callback for administration header. * * @since 2.1.0 * @var callable */ public $admin_header_callback; /** * Callback for header div. * * @since 3.0.0 * @var callable */ public $admin_image_div_callback; /** * Holds default headers. * * @since 3.0.0 * @var array */ public $default_headers = array(); /** * Used to trigger a success message when settings updated and set to true. * * @since 3.0.0 * @var bool */ private $updated; /** * Constructor - Registers administration header callback. * * @since 2.1.0 * * @param callable $admin_header_callback Administration header callback. * @param callable $admin_image_div_callback Optional. Custom image div output callback. * Default empty string. */ 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' ) ); } /** * Sets up the hooks for the Custom Header admin page. * * @since 2.1.0 */ public function init() { $page = add_theme_page( _x( 'Header', 'custom image header' ), _x( 'Header', 'custom image header' ), 'edit_theme_options', 'custom-header', array( $this, 'admin_page' ) ); if ( ! $page ) { return; } 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 );Changelog
Introduced in 2.1.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 6.9.7 tag, from
src/wp-admin/includes/class-custom-image-header.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it. - Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.