覆盖wordpress中的sensei插件

时间:2017-05-22 16:41:17

标签: php wordpress

我正在使用sensei插件进行课程管理。我需要覆盖学习者管理模块,我必须在该列表中添加更多字段。我试过覆盖function.php中的类,但我不能成功这一点。

我的代码在function.php

class Custom_Sensei_Learner_Management extends Sensei_Learner_Management {

    public $name;
    public $file;
    public $page_slug;

    /**
     * Constructor
     * @since  1.6.0
     * @return  void
     */
    public function __construct($file) {

        $this->name = __('Learner Management', 'woothemes-sensei');
        $this->file = $file;
        $this->page_slug = 'sensei_learners';


        // Admin functions
        if (is_admin()) {

            add_action('admin_menu', array($this, 'learners_admin_menu'), 30);
            add_action('learners_wrapper_container', array($this, 'wrapper_container'));
            if (isset($_GET['page']) && ( $_GET['page'] == $this->page_slug )) {
                add_action('admin_print_scripts', array($this, 'enqueue_scripts'));
                add_action('admin_print_styles', array($this, 'enqueue_styles'));
            }

            add_action('admin_init', array($this, 'add_new_learners'));
            add_action('admin_notices', array($this, 'add_learner_notices'));

        } // End If Statement
        // Ajax functions
        if (is_admin()) {

            add_action('wp_ajax_get_redirect_url_learners', array($this, 'get_redirect_url'));
            add_action('wp_ajax_remove_user_from_post', array($this, 'remove_user_from_post'));
            add_action('wp_ajax_sensei_json_search_users', array($this, 'json_search_users'));

        }


    }




    /**
     * learners_admin_menu function.
     * @since  1.6.0
     * @access public
     * @return void
     */
    public function learners_admin_menu() {

        global $menu;

        if (current_user_can('manage_sensei_grades')) {
            $learners_page = add_submenu_page('sensei', $this->name, $this->name, 'manage_sensei_grades', $this->page_slug, array($this, 'learners_page'));
        }
    }

// End learners_admin_menu()




    public function learners_page() {


        // Load Learners data
        $course_id = 0;
        $lesson_id = 0;


        if (isset($_GET['course_id'])) {
            $course_id = intval($_GET['course_id']);
        }

        if (isset($_GET['lesson_id'])) {
            $lesson_id = intval($_GET['lesson_id']);
        }


        $sensei_learners_main = $this->load_data_object('Main', $course_id, $lesson_id);

        // Wrappers
        do_action('learners_before_container');
        do_action('learners_wrapper_container', 'top');

        $this->learners_headers();
        ?>
        <div id="poststuff" class="sensei-learners-wrap this_is_test">
            <div class="sensei-learners-main">
                <?php $sensei_learners_main->display(); ?>
            </div>
            <div class="sensei-learners-extra">
                <?php do_action('sensei_learners_extra'); ?>
            </div>
        </div>
        <?php
        do_action('learners_wrapper_container', 'bottom');
        do_action('learners_after_container');
    }


// End learners_default_view()
}

$t = new Custom_Sensei_Learner_Management();

我添加了图片 Admin Learner management

1 个答案:

答案 0 :(得分:0)

为了覆盖Sensei文件,只需遵循通常使用woocommerce进行的操作即可。在主题sensei的根目录内创建一个名为(/wp-content/themes/sensei/...)的文件夹(不是woothemes-sensei),并创建与插件文件夹完全相同的路径。就这么简单。

--- ALERT(UPDATE)----

它仅适用于模板(更改布局),而不适用于功能..我完全错了您的问题..