[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 Dec 11 06:02:29 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 talhadev0080):
Replying to [comment:9 talhadev0080]:
> Replying to [comment:8 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.
>
>
> The error occurs when a theme doesn't support custom headers, and the
WP_Customize_Header_Image_Control class is called incorrectly. Use the
class_exists() function and confirm the object before processing to
resolve the issue.
This error suggests the theme lacks support for custom headers. Add a
check for class_exists( 'WP_Customize_Header_Image_Control' ) and validate
the object with is_object() before using its methods to avoid the error.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/21515#comment:10>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list