我的调试。日志中有以下消息指向/wp includes/shortcode。php第319行,这是WordPress核心的一部分,可能不是代码中真正的错误所在。
PHP Deprecated: Non-static method RSSjbClass::RSSjb_funct() should not be called statically in /.../wp-includes/shortcodes.php on line 319
我看了319行,但它并没有帮助我找到或解决问题。我搜索了代码,找到了这个类和funct,但我不知道静态调用什么是非静态的。
/**
* Add shortcode to wordpress
*/
// add_shortcode(\'RSSjb\', \'RSSjb_funct\');
add_shortcode(\'RSSjb\', array(\'RSSjbClass\', \'RSSjb_funct\'));
/**
* Shortcode Class and Function
*/
class RSSjbClass {
function RSSjb_funct($atts) {
extract(shortcode_atts(array(
// attributes for Google News
"gsearch" => \'\',
"topic" => \'\',
"location" => \'\',
"geo" => \'\',
"feed" => \'\', // required
"filter" => \'\',
"num" => \'5\',
"ltime" => \'\',
"list" => \'ul\',
"target" => \'_blank\',
"pubdate" => \'false\',
"pubtime" => \'false\',
"dformat" => get_option(\'date_format\'),
"tformat" => get_option(\'time_format\'),
"pubauthor" => \'true\',
"excerpt" => \'false\',
"charex" => \'\',
"chartle" => \'\',
"title" => \'\',
"link" => \'false\',
"sort" => \'false\',
"cachefeed" => \'3600\'
), $atts));
然后是几个“如果”,然后
// call the function to read and display the feed items list
return $tle . rssjb_List($feed, $filter, $num, $ltime, $list, $target, $pubdate, $pubtime, $dformat, $tformat, $pubauthor, $excerpt, $charex, $chartle, $sort, $cachefeed);
} else {
return \'<br>RSS or Atom Feed URL not provided. This shortcode does require the attribute feed or location (if Google News).<br /> Ex: <code>[RSSjb feed = "http://your-rss-or-atom-feed-URL-here"]</code>.\';
}
}
}
如何修改它以适应/wp includes/shortcode中的内容。php第319行,即:
$output = $m[1] . call_user_func( $shortcode_tags[ $tag ], $attr, $content, $tag ) . $m[6];
/**
* Filters the output created by a shortcode callback.
*
* @since 4.7.0
*
* @param string $output Shortcode output.
* @param string $tag Shortcode name.
* @param array|string $attr Shortcode attributes array or empty string.
* @param array $m Regular expression match array.
*/
return apply_filters( \'do_shortcode_tag\', $output, $tag, $attr, $m );
}
我搜索了PHP手册,它没有任何关于短代码的内容。