[wp-trac] [WordPress Trac] #21515: No custom header support in theme == Fatal error: Call to a member function process_default_headers() on a non-object
WordPress Trac
noreply at wordpress.org
Wed Mar 6 20:25:37 UTC 2024
#21515: No custom header support in theme == Fatal error: Call to a member function
process_default_headers() on a non-object
------------------------------+---------------------
Reporter: c3mdigital | Owner: ryan
Type: defect (bug) | Status: closed
Priority: normal | Milestone: 3.4.2
Component: Customize | Version:
Severity: normal | Resolution: fixed
Keywords: has-patch commit | Focuses:
------------------------------+---------------------
Comment (by bloomhejm):
WordPress. The error message you provided indicates that there is an issue
with the WP_Customize_Header_Image_Control class and its
process_default_headers() method being called on a non-object. This error
typically occurs when you attempt to use the Customizer with a theme that
doesn't support custom headers.
Here's a possible solution to handle this error by checking whether the
WP_Customize_Header_Image_Control object exists before calling its
methods:
{{{#!php
<?php
if ( class_exists( 'WP_Customize_Header_Image_Control' ) ) {
$custom_image_header = new WP_Customize_Header_Image_Control(
$wp_customize );
if ( is_object( $custom_image_header ) ) {
// Process custom header controls here
}
}
}}}
This code snippet checks if the WP_Customize_Header_Image_Control class
exists, and if it does, it attempts to create an instance of it. Then, it
checks if the instance is a valid object before proceeding to process
custom header controls.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/21515#comment:8>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list