簡體   English   中英

PHP嚴格錯誤

[英]PHP Strict Errors

我一直在error_log中收到這些PHP錯誤,無法解決該問題:

錯誤:

PHP Strict Standards:  Non-static method wf_gmap::check_wp_footer() should not be called statically in /home/USERNAME/public_html/WEBSITE/wp-content/plugins/5sec-google-maps/5sec-gmaps.php on line 25

PHP Notice:  Use of undefined constant is_admin - assumed 'is_admin' in /home/USERNAME/public_html/WEBSITE/wp-content/plugins/5sec-google-maps/5sec-gmaps.php on line 21

PHP Strict Standards:  call_user_func_array() expects parameter 1 to be a valid callback, non-static method wf_gmap::init() should not be called statically in /home/USERNAME/public_html/WEBSITE/wp-includes/plugin.php on line 429

和5sec-gmaps.php文件從17到44的行是這樣的:

class wf_gmap {
  static $js_functions = '';

public function init() {
if(is_admin) {
  add_filter('plugin_row_meta', array(__CLASS__, 'plugin_meta_links'), 10, 2);
}
// check wp_footer()
self::check_wp_footer();

// add shortcode
global $shortcode_tags;
if (isset($shortcode_tags[GMAP_SHORTCODE])) {
  add_action('admin_footer', array(__CLASS__, 'warning'));
} else {
  add_shortcode(GMAP_SHORTCODE, array(__CLASS__, 'shortcode'));
}

// add JS include files
add_action('wp_footer', array(__CLASS__, 'footer'), 2);

// add shortcode support in sidebar text widget
if (has_filter('widget_text', 'do_shortcode') === false) {
  add_filter('widget_text', 'do_shortcode');
}

return;

和plugin.php的代碼行從418到434:

    // Sort
if ( !isset( $merged_filters[ $tag ] ) ) {
    ksort($wp_filter[$tag]);
    $merged_filters[ $tag ] = true;
}

reset( $wp_filter[ $tag ] );

do {
    foreach ( (array) current($wp_filter[$tag]) as $the_ )
        if ( !is_null($the_['function']) )
            call_user_func_array($the_['function'], array_slice($args, 0, (int) $the_['accepted_args']));

} while ( next($wp_filter[$tag]) !== false );

array_pop($wp_current_filter);

任何幫助,將不勝感激。

您正在使用靜態上下文調用成員方法。

self::check_wp_footer(); 應該是$this->check_wp_footer();

同樣,任何$the_['function']必須引用靜態方法。

PHP嚴格標准:非靜態方法wf_gmap :: check_wp_footer()應該

表示函數check_wp_footer不是靜態方法,因此您不能像這樣調用

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM