【问题标题】:Wordpress newbie, keeping getters the following errors when installing themes and pluginsWordpress 新手,在安装主题和插件时让 getter 出现以下错误
【发布时间】:2018-07-15 17:50:36
【问题描述】:

我目前正在使用 Wordpress 开发 2 个网站,并由一个共享主机托管,该主机是由几个不同的 WP 狂热者推荐给我的。

站点 1 将是一个中高容量的博客。通过我的共享主机的一键安装,它附带了插件 W3 Total Cache,就我所读的所有内容而言,它是最好的。

2 个问题。首先,每次我上传主题时,我都会在管理员中收到以下错误:

每当我尝试更改 W3 Total Cache 中的设置时,我都会在管理员中收到大约 15 到 20 个以下错误:

Notice: get_theme is deprecated since version 3.4! Use wp_get_theme( $stylesheet ) 
instead. in /home/jpweber/public_html/wp-includes/functions.php on line 2824

Notice: get_themes is deprecated since version 3.4! Use wp_get_themes() instead. in 
/home/jpweber/public_html/wp-includes/functions.php on line 2824

无论我安装什么主题,网站上每个页面的顶部都会出现以下 3 个错误:

Notice: add_custom_background is deprecated since version 3.4! Use add_theme_support( 
'custom-background', $args ) instead. in /home/jpweber/public_html/wp-includes  
/functions.php on line 2824

Notice: get_theme_data is deprecated since version 3.4! Use wp_get_theme() instead. in 
/home/jpweber/public_html/wp-includes/functions.php on line 2824

Notice: Undefined variable: output in /home/jpweber/public_html/wp-content/themes/respo
/functions/theme-actions.php on line 138

我没有对functions.php进行任何更改,我已经下载了functions.php的新副本,我已经检查了functions.php文件以查看作者主页上的任何答案是否适用,但是我没有找到答案。

更新:

作为参考,这是我在functions.php中的第2821-2828行:

// Allow plugin to filter the output error trigger
if ( WP_DEBUG && apply_filters( 'deprecated_function_trigger_error', true ) ) {
    if ( ! is_null($replacement) )
        trigger_error( sprintf( __('%1$s is <strong>deprecated</strong> 
      since version %2$s! Use %3$s instead.'), $function, $version, $replacement ) );
    else
        trigger_error( sprintf( __('%1$s is <strong>deprecated</strong> 
    since version %2$s with no alternative available.'), $function, $version ) );
    }
    }

在我的 theme_actions.php 文件中,这是第 138 行:

$output .= ' {font:'.$font_nav["style"].' '.$font_nav["size"].'px/1.5em 
    '.stripslashes($font_nav["face"]).';color:'.$font_nav["color"].'}' . "\n";

【问题讨论】:

  • 这就是为什么 WP 网站总是很烂的原因。

标签: wordpress wordpress-theming


【解决方案1】:

通知有点告诉你该怎么做,它们非常具有描述性。 要么跟进通知,要么将错误级别设置为低于通知,这样消息就不会再显示(虽然不推荐)

【讨论】:

  • 抱歉,花了一段时间才找到问题。问题在于调用已弃用函数的 W3 总缓存。我更担心未定义的输出。我认为您必须按照 wordpress 的建议浏览源代码并解决问题...
  • 报告的行是触发弃用消息的行,而不是调用弃用函数的行。我查看了 W3,发现在最新版本中出现了 52 次。您应该能够使用 WP 管理界面中的插件编辑器来编辑这些内容。
  • 删除 .在 .= 中,它应该会更好。可以肯定的是,检查上面的代码是否不包含 $output。
  • 不,只是 '.'在 $output 后​​面的 '.=' 运算符中。这样就变成了 $output = {.... .= 运算符是字符串连接,但是如果没有字符串,则无法连接。
  • 我的错,应该返回 = 和 { 之间的单引号 ('),这样你就会得到 $output = '{ 等。抱歉。
猜你喜欢
  • 2018-10-20
  • 2021-09-27
  • 2017-12-28
  • 2020-04-13
  • 1970-01-01
  • 2015-09-11
  • 1970-01-01
  • 2015-07-14
  • 1970-01-01
相关资源
最近更新 更多