doulun0651 2015-10-15 11:48
浏览 29
已采纳

覆盖WordPress中的插件功能

I have a Plugin installed on my WordPress site.

I'd like to override a function within the Plugin. Do I override this in my theme's functions.php and if so, how do I do this?

Here's the original function in my plugin:

    /**
     * sensei_start_course_form function.
     *
     * @access public
     * @param mixed $course_id
     * @return void
     */
    function sensei_start_course_form( $course_id ) {

        $prerequisite_complete = sensei_check_prerequisite_course( $course_id );

        if ( $prerequisite_complete ) {
        ?><form method="POST" action="<?php echo esc_url( get_permalink() ); ?>">

                <input type="hidden" name="<?php echo esc_attr( 'woothemes_sensei_start_course_noonce' ); ?>" id="<?php echo esc_attr( 'woothemes_sensei_start_course_noonce' ); ?>" value="<?php echo esc_attr( wp_create_nonce( 'woothemes_sensei_start_course_noonce' ) ); ?>" />

                <span><input name="course_start" type="submit" class="course-start" value="<?php echo apply_filters( 'sensei_start_course_text', __( 'Start taking this Course', 'woothemes-sensei' ) ); ?>"/></span>

            </form><?php
        } // End If Statement
    } // End sensei_start_course_form()
  • 写回答

3条回答 默认 最新

  • dongritan5654 2015-10-15 12:30
    关注

    You can't really "override" a function. If a function is defined, you can't redefine or change it. Your best option is to create a copy of the plugin and change the function directly. Of course you will have to repeat this everytime the plugin is updated.

    Give the plugin a different name to distinguish them in the plugin listing. Disable the original, enable your copy.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 划分vlan后不通了
  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大