【问题标题】:Wordpress - Notice: Use of undefined constant Redux_TEXT_DOMAIN - assumed 'Redux_TEXT_DOMAIN'Wordpress - 注意:使用未定义的常量 Redux_TEXT_DOMAIN - 假定为“Redux_TEXT_DOMAIN”
【发布时间】:2014-06-30 14:35:08
【问题描述】:

我正在构建我的第一个 Wordpress 网站,我刚刚下载并安装了 v3.9.1。我买了一个主题(rustik3)并尝试安装它,但我遇到了 WP_DEBUG 产生的这些错误:

Notice: Use of undefined constant Redux_TEXT_DOMAIN - assumed 'Redux_TEXT_DOMAIN' in /var/www/wp-content/themes/rustik3/admin/options.php on line 501

Notice: Use of undefined constant Redux_TEXT_DOMAIN - assumed 'Redux_TEXT_DOMAIN' in /var/www/wp-content/themes/rustik3/admin/options.php on line 502

Notice: Use of undefined constant Redux_TEXT_DOMAIN - assumed 'Redux_TEXT_DOMAIN' in /var/www/wp-content/themes/rustik3/admin/options.php on line 503

Notice: Undefined variable: item_info in /var/www/wp-content/themes/rustik3/admin/theme-functions.php on line 23

我已经做了一些谷歌搜索,我开始认为最后一次 Wordpress 更新使得 Redux 框架已被弃用并且无法使用。不过,这只是一种预感。截至目前,主题已安装,但它显示为完全空白 - 当我转到 http://localhost 或尝试在 Wordpress UI 中自定义它时。我还没有查看错误消息日志的最后一部分(第 23 行错误)......但它只是一个未定义的变量,所以我可以自己解决这个问题。有什么想法吗?

更新

这就是options.php 中的代码块的样子:

array(
            'id' => 'google_webfonts',
            'type' => 'google_webfonts',
            'title' => __('Enable Google Webfonts', Redux_TEXT_DOMAIN), 
            'sub_desc' => __('Pick from over 600 Google Webfonts to use on the site. Then select below which elements you want to apply it to.', Redux_TEXT_DOMAIN),
                'desc' => __('', Redux_TEXT_DOMAIN)
      ),

更新

我对 Redux_TEXT_DOMAIN 的所有 wordpress 文件进行了文本搜索,它出现的唯一位置是在上面的代码块中......

更新

这段代码是在我拥有的主题中加载文本域...我不熟悉文本域是什么 - 但这可能是相关的:

public function load_textdomain() {
        if ( isset( $this->textdomain_loaded ) )
            return $this->textdomain_loaded;

        $textdomain = $this->get('TextDomain');
        if ( ! $textdomain ) {
            $this->textdomain_loaded = false;
            return false;
        }

        if ( is_textdomain_loaded( $textdomain ) ) {
            $this->textdomain_loaded = true;
            return true;
        }

        $path = $this->get_stylesheet_directory();
        if ( $domainpath = $this->get('DomainPath') )
            $path .= $domainpath;
        else
            $path .= '/languages';

        $this->textdomain_loaded = load_theme_textdomain( $textdomain, $path );
        return $this->textdomain_loaded;
    }

上面的代码有问题吗?

更新

感谢以下答案 - 我现在可以看到主题(它没有显示为空白页) - 但我仍然遇到相同的错误......以及更多错误:

Notice: Use of undefined constant Redux_TEXT_DOMAIN - assumed 'Redux_TEXT_DOMAIN' in /var/www/wp-content/themes/rustik3/admin/options.php on line 501

Notice: Use of undefined constant Redux_TEXT_DOMAIN - assumed 'Redux_TEXT_DOMAIN' in /var/www/wp-content/themes/rustik3/admin/options.php on line 502

Notice: Use of undefined constant Redux_TEXT_DOMAIN - assumed 'Redux_TEXT_DOMAIN' in /var/www/wp-content/themes/rustik3/admin/options.php on line 503

Notice: Undefined index: rustik_body_img in /var/www/wp-content/themes/rustik3/admin/theme-functions.php on line 263

Notice: Undefined index: rustik_custom_favicon in /var/www/wp-content/themes/rustik3/admin/theme-functions.php on line 210

Notice: Undefined index: rustik_custom_css in /var/www/wp-content/themes/rustik3/admin/theme-functions.php on line 239

Notice: Undefined index: rustik_google_analytics in /var/www/wp-content/themes/rustik3/admin/theme-functions.php on line 224

这是设置$item_info的唯一其他地方:

    $item_info = '<div class="rustik-opts-section-desc"><div style="float: left; margin-right: 20px;"><img width="300px" alt="Current theme preview" src="'.get_option('home').'/wp-content/themes/rustik3/screenshot.png"></div><div style="float: left;">';
    $item_info .= '<p class="rustik-opts-item-data description item-uri">' . __('<strong>Theme URL:</strong> ', Rustik_TEXT_DOMAIN) . '<a href="' . $item_uri . '" target="_blank">' . $item_uri . '</a></p>';
    $item_info .= '<p class="rustik-opts-item-data description item-author">' . __('<strong>Author:</strong> ', Rustik_TEXT_DOMAIN) . ($author_uri ? '<a href="' . $author_uri . '" target="_blank">' . $author . '</a>' : $author) . '</p>';
    $item_info .= '<p class="rustik-opts-item-data description item-version">' . __('<strong>Version:</strong> ', Rustik_TEXT_DOMAIN) . $version . '</p>';
    $item_info .= '<p class="rustik-opts-item-data description item-description">' . $description . '</p>';
    $item_info .= '<p class="rustik-opts-item-data description item-tags">' . __('<strong>Tags:</strong> ', Rustik_TEXT_DOMAIN) . implode(', ', $tags) . '</p>';
    $item_info .= '</div></div>';

【问题讨论】:

标签: php wordpress themes undefined constants


【解决方案1】:

根据:http://www.mojo-themes.com/item/rustik-minimalist-e-commerce-ready-theme/

该主题可在 wordpress 3.9 上运行,但也需要 WooCommerce 2.1 插件。你有那个安装吗? http://wordpress.org/plugins/woocommerce/

定义的常量可能在依赖项中。

【讨论】:

  • 谢谢!生病检查一下 - 看看这是不是问题
  • 我现在可以看到主题了!!!所以谢谢你!但我仍然遇到同样的错误......我现在正在更新我的问题......添加我看到的错误 - 还没有 50 分 :) (仍然需要修复这些东西)。
  • 好的,我建议您也重新下载主题并确保所有内容都正确移动到主题文件夹。只是要确定。必须缺少某些东西,因为您应该能够找到未定义常量的定义语句。
  • 我想我已经解决了 - 我在 wordpress 特定网站上问了一个问题 wordpress.stackexchange.com/questions/152506/… 这个问题...只剩下一个错误...我发布了相关代码 - 我会给你帮助您所说的要点(使我的主题可见)-但请先查看链接...并阅读我在问题中的更新。
  • 哈哈好笑,我刚刚找到你的其他帖子...尝试在 item_info 的前面添加全局。如果您删除点,它会起作用,但自然会丢失添加到变量中的早期字符串。
【解决方案2】:
public function load_textdomain() {
    if ( isset( $this->textdomain_loaded ) )
        return $this->textdomain_loaded;

    $textdomain = $this->get('TextDomain');
    if ( ! $textdomain ) {
        $this->textdomain_loaded = false;
        return false;
    }

    if ( is_textdomain_loaded( $textdomain ) ) {
        $this->textdomain_loaded = true;
        return true;
    }

    $path = $this->get_stylesheet_directory();
    if ( $domainpath = $this->get('DomainPath') )
        $path .= $domainpath;
    else
        $path .= '/languages';

    define('redux_TEXT_DOMAIN', $textdomain);
    $this->textdomain_loaded = load_theme_textdomain( $textdomain, $path );
    return $this->textdomain_loaded;
}

【讨论】:

  • 我已经用Redux_TEXT_DOMAIN 解决了这些错误...但是您认为按照上面的方式进行操作有什么好处吗?
  • 如上所述:您可以删除 .在 = 之前,在函数内是其本地命名空间,因此您的选项中的 $user_info 对其没有影响。此外,它只是一个管理员通知,因此请注册一些电子邮件,这样即使有其他内容,也可以!
  • 酷 - 所以你说我不必担心最后一个错误,因为它与管理员(不是用户将使用的站点)有关......你认为 @ 987654323@ 不起作用,因为该变量在限制其范围的函数内使用,因此当在 options.php 中设置 $item_info 时 - 当它在其中时,无法在 theme-functions.php 中看到它功能?谢谢!
猜你喜欢
  • 2013-07-20
  • 2017-01-12
  • 1970-01-01
  • 2019-02-19
  • 2018-12-17
  • 1970-01-01
  • 2018-07-02
  • 1970-01-01
  • 2017-09-27
相关资源
最近更新 更多