Custom_Background
- Since
- 3.0.0
- Source
wp-admin/includes/class-custom-background.php:14
The custom background class.
Compatibility
- WordPress
- since 3.0.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 · 2
Every hook that fires from inside Custom_Background, in the order it appears in the class, grouped by the method that fires it.
Properties · 3
$admin_header_callbackcallablepublic- Callback for administration header.
$admin_image_div_callbackcallablepublic- Callback for header div.
$updatedboolprivate- Used to trigger a success message when settings updated and set to true.
Methods · 10
- __construct()Constructor - Registers administration header callback.
- init()Sets up the hooks for the Custom Background admin page.
- admin_load()Sets up the enqueue for the CSS & JavaScript files.
- take_action()Executes custom background modification.
- admin_page()Displays the custom background page.
- handle_upload()Handles an Image upload for the background image.
- ajax_background_add()Handles Ajax request for adding custom background context to an attachment.
- attachment_fields_to_edit()
- filter_upload_tabs()
- wp_set_background_image()
Source code
#[AllowDynamicProperties]class Custom_Background { /** * Callback for administration header. * * @since 3.0.0 * @var callable */ public $admin_header_callback; /** * Callback for header div. * * @since 3.0.0 * @var callable */ public $admin_image_div_callback; /** * 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 3.0.0 * * @param callable $admin_header_callback Optional. Administration header callback. * Default empty string. * @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( 'wp_ajax_custom-background-add', array( $this, 'ajax_background_add' ) ); // Unused since 3.5.0. add_action( 'wp_ajax_set-background-image', array( $this, 'wp_set_background_image' ) ); } /** * Sets up the hooks for the Custom Background admin page. * * @since 3.0.0 */ public function init() { $page = add_theme_page( _x( 'Background', 'custom background' ), _x( 'Background', 'custom background' ), 'edit_theme_options', 'custom-background', array( $this, 'admin_page' ) ); if ( ! $page ) { return; } add_action( "load-{$page}", array( $this, 'admin_load' ) ); add_action( "load-{$page}", array( $this, 'take_action' ), 49 ); add_action( "load-{$page}", array( $this, 'handle_upload' ), 49 ); if ( $this->admin_header_callback ) { add_action( "admin_head-{$page}", $this->admin_header_callback, 51 ); } } /** * Sets up the enqueue for the CSS & JavaScript files. * * @since 3.0.0Changelog
Introduced in 3.0.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-background.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.