在插件中得到警告:不建议使用:非静态方法woo_filter_master_controller :: index()不应静态调用

时间:2019-09-18 11:33:58

标签: wordpress wordpress-plugin-creation

我正在创建自定义插件,当我检查我的页面时,可以看到警告消息Deprecated: Non-static method woo_filter_master_controller::index() should not be called statically,任何人都可以帮助我为什么收到此警告吗?在这里,我添加了我的插件控制器代码。

<?php

class woo_filter_master_controller {

    public function index() {
        ob_start();
        global $wpdb;

        include(dirname(__FILE__) . "/html/list_master_details.php");
        $s = ob_get_contents();
        ob_end_clean();
        print $s;
    }

    public function get_data() {
        global $wpdb, $wp;
    }

    function add_menu_pages() {
        add_menu_page('Woo-Filtr', 'Woo-Filter', 'manage_options', 'woo-filter', Array("woo_filter_master_controller", "index"));
    }

}

$obj_woo_filter_master = new woo_filter_master_controller();

add_action('admin_menu',array($obj_woo_filter_master, 'add_menu_pages'));

add_action('wp_ajax_woo_filter_master_controller::get_data', Array($obj_woo_filter_master, 'get_data'));
add_action('wp_ajax_nopriv_woo_filter_master_controller::get_data', array($obj_woo_filter_master, 'get_data'));

?>

0 个答案:

没有答案