1

提前感谢您对此的任何帮助,错误调用成员函数 check_capabilities()

卡在这个车辙!

目录布局:

  • '主题文件夹'
    • functions.php(“主题”的主目录)
    • 索引.php
    • 样式.css
    • 功能文件夹(位于“主题文件夹”内)
      • 自定义.php

函数调用customize.php,如下所示:

<?php require_once('functions/customize.php'); ?>

定制.php:

<?php
add_action('customize_register', 'adaptive_customize_register');
function adaptive_customize_register($wp_customize) {
//logo
$wp_customize->add_section('adaptive_logo', array(
'title' => __('Add Logo', 'adaptive_framework'), 
'description' => __('Upload your main logo, this shows in the header',      'adaptive_framework'), 
'priority' => '25'
));
    $wp_customize->add_setting('adaptive_custom_settings[add_logo]', array(
    'default' => 0,
    'type' => 'option'
));

$wp_customize->add_control('adaptive_custom_settings[display_logo]', array(
    'label' => __('Display logo?','adaptive_framework'),
    'section' => 'adaptive_logo',
    'settings' => 'adaptive_custom_settings[display_top_logo]',
    'type' => 'checkbox'
    ));
}



?>

如果有人可以提供帮助,请因为我收到如下错误:

Fatal error: Call to a member function check_capabilities() on a non-object in C:\xampp\htdocs\wordpress\wp-includes\class-wp-customize-control.php on line 160
4

2 回答 2

6

add_control() 的设置参数必须与 add_setting() 中定义的设置名称相匹配。否则,控件将添加到导致功能错误的未知设置。

因此adaptive_custom_settings[display_top_logo]改为adaptive_custom_settings[add_logo]

    <?php
    add_action('customize_register', 'adaptive_customize_register');
    function adaptive_customize_register($wp_customize) {
    //logo
    $wp_customize->add_section('adaptive_logo', array(
        'title' => __('Add Logo', 'adaptive_framework'), 
        'description' => __('Upload your main logo, this shows in the header',         'adaptive_framework'), 
        'priority' => '25'
    ));
    $wp_customize->add_setting('adaptive_custom_settings[add_logo]', array(
        'default' => 0,
        'type' => 'option'
    ));

    $wp_customize->add_control('adaptive_custom_settings[display_logo]', array(
        'label' => __('Display logo?','adaptive_framework'),
        'section' => 'adaptive_logo',
        'settings' => 'adaptive_custom_settings[add_logo]',
        'type' => 'checkbox'
    ));
    }
    ?>
于 2014-04-10T07:35:18.303 回答
-3

不得不结束这个线程,因为我现在不再需要我使用的代码,我将寻求在线示例中的完成代码。

于 2013-03-23T16:59:56.270 回答