• Resolved Tunn

    (@iuriem)


    When in customizer preview, WP produces a PHP Warning:

    Attempt to read property “title” on null in /home/…/wp-includes/class-wp-customize-widgets.php on line 899

    To avoid this you can add widgets support for customizer to Arke (in functions.php of your child theme).

    /** Add widgets support for Customizer **/
    if( is_customize_preview() && ! current_theme_supports( 'widgets' ) ) {
    	add_theme_support( 'widgets' );
    }
Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter Tunn

    (@iuriem)

    But better like this:

    /** Add widgets support to current theme **/
    add_filter( 'current_theme_supports-widgets', function( $supports ) {
        $supports = false ? true : $supports;
        return $supports;
    } );
    Theme Author DannyCooper

    (@dannycooper)

    Hi @iuriem,

    Why would we not do:

    /** Add widgets support to current theme **/
    add_filter( 'current_theme_supports-widgets', '__return_false' );

    Since this theme doesn’t feature any widget areas?

    • This reply was modified 2 years, 1 month ago by DannyCooper.
    Thread Starter Tunn

    (@iuriem)

    Hi @dannycooper,

    Since this theme doesn’t feature any widget areas?

    Yes, I know. But because I’m a perfectionist ?? I wanted to fix the PHP Warning that appears when we are in the customizer preview (I suppose because the widget support is not enabled). Can it be solved in another way, that is, better?

    PHP Warning: Attempt to read property “title” on null in /home/…/wp-includes/class-wp-customize-widgets.php on line 899

    P.S. And since the widget support is not enabled, there’s no need to disable it, as you suggest, don’t you think? ?? Or did I not understand something?

    BTW, for me I use:

    add_filter( 'current_theme_supports-widgets', '__return_true' );

    Theme Author DannyCooper

    (@dannycooper)

    Hi @iuriem,

    This seems like a bug with WordPress where it’s trying to load the Customizer panel even if widgets are disabled:

    PHP Warning: Attempt to read property “title” on null in /home/…/wp-includes/class-wp-customize-widgets.php on line 899

    For that reason I have simply added the add_theme_support( ‘widgets’ ); flag. By itself it doesn’t do anything detrimental so it seems like the simplest solution.

    Let me know if there is anything else I can help with.

    Thanks!

    Thread Starter Tunn

    (@iuriem)

    Thank you, @dannycooper!

    So far I haven’t discovered any other problems ?? . I like Arke specifically for its minimalism, it’s exactly what I needed for one of my projects! Thanks again!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Attempt to read property “title” on null for widgets in Customizer’ is closed to new replies.