jeudi 25 avril 2019

Fatal error: Call to a member function add_section() on null

I am trying to add a section to a panel to add a section for lazy load image option. I keep getting this error

Fatal error: Call to a member function add_section() on null on line 91.

I have the panel setup in a different file.

$wp_customize->add_panel(
    'aviation_theme_options',
    array(
        'priority' => 7,
        'capability' => 'edit_theme_options',
        'theme_supports' => '',
        'title' => esc_html__('Theme Option', 'aviation'),
    )
);

The file that I am getting the error on is in the section.

/**
     * Theme options.
     */
    $wp_customize->add_section(
        'lazy_load_options', array(
            'title'    => __( 'Lazy-load images', 'aviation' ),
                        'capability' => 'edit_theme_options',
            'panel' => 'aviation_theme_options',
            'priority' => 6,

        )
    );

    if ( function_exists( 'aviation_lazyload_images' ) ) {
        $wp_customize->add_setting(
            'lazy_load_media', array(
                'default'           => 'lazyload',
                'sanitize_callback' => 'aviation_sanitize_lazy_load_media',
                'transport'         => 'postMessage',

            )
        );

        $wp_customize->add_control(
            'lazy_load_media', array(
                'label'           => __( 'Lazy-load images', 'aviation' ),
                'section'         => 'lazy_load_options',
                                'settings'        => 'lazy_load_media',
                'type'            => 'radio',
                'description'     => __( 'Lazy-loading images means images are loaded only when they are in view. Improves performance, but can result in content jumping around on slower connections.', 'aviation' ),
                'choices'         => array(
                    'lazyload'    => __( 'Lazy-load on (default)', 'aviation' ),
                    'no-lazyload' => __( 'Lazy-load off', 'aviation' ),
                ),
            )
        );
    }

add_action( 'customize_register', 'aviation_customize_register' );




Aucun commentaire:

Enregistrer un commentaire