【问题标题】:wordpress error on line 160 of ...wp-includes\class-wp-customize-control.php whilst adding hooks for extra functions...wp-includes\class-wp-customize-control.php 的第 160 行出现 wordpress 错误,同时为额外功能添加挂钩
【发布时间】:2013-03-09 13:34:42
【问题描述】:

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

在这个问题上陷入了困境!

目录布局:

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

函数调用customize.php如下:

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

customize.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

【问题讨论】:

  • $cutomize$customize?
  • @brasofilo - 我很感激我打错了,但错误仍然存​​在,我检查了错别字并仍然在第 160 行返回错误
  • 很难调试:/ .... 我不明白它期望什么功能,也不知道我们应该把它放在哪里。 documentation 不是很完整。也许this article(链接在文档中)可以提供帮助。
  • 我已经重写了整个东西,似乎已经弄清楚了 - 但是我不小心删除了它。

标签: wordpress hook customization member-functions


【解决方案1】:

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'
    ));
    }
    ?>

【讨论】:

    【解决方案2】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-10-17
      • 1970-01-01
      • 2023-01-08
      • 1970-01-01
      • 1970-01-01
      • 2016-06-27
      • 2015-11-18
      相关资源
      最近更新 更多