我正在尝试向面板中添加一个部分,以为延迟加载图像选项添加一个部分。我不断收到此错误
致命错误:在第91行的null上调用成员函数add_section()。
我在其他文件中具有面板设置。
$wp_customize->add_panel(
'aviation_theme_options',
array(
'priority' => 7,
'capability' => 'edit_theme_options',
'theme_supports' => '',
'title' => esc_html__('Theme Option', 'aviation'),
)
);
出现此错误的文件在该部分中。
/**
* 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' );