首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >.wp-的第160行中的wordpress错误包括\class-wp-定制-Control.php,同时添加额外函数的钩子

.wp-的第160行中的wordpress错误包括\class-wp-定制-Control.php,同时添加额外函数的钩子
EN

Stack Overflow用户
提问于 2013-03-09 13:34:42
回答 2查看 1.8K关注 0票数 1

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

卡在这个车辙里了!

目录布局:

  • ‘主位文件夹’
    • functions.php (“主题”的主目录)
    • index.php
    • style.css
    • 函数文件夹(位于“主题文件夹”内)
      • customize.php

函数像这样调用customize.php:

代码语言:javascript
复制
<?php require_once('functions/customize.php'); ?>

customize.php:

代码语言:javascript
复制
<?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'
    ));
}



?>

如果有人能帮忙,请在我收到错误时,如下所示:

代码语言:javascript
复制
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
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2013-03-23 16:59:56

必须结束这个线程,因为我现在使用的代码已经不再需要了,我将在一个在线示例中找到完成的代码。

票数 -3
EN

Stack Overflow用户

发布于 2014-04-10 07:35:18

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

因此,将adaptive_custom_settings[display_top_logo]更改为adaptive_custom_settings[add_logo]

代码语言:javascript
复制
    <?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'
    ));
    }
    ?>
票数 6
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/15311266

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档