WordPress 插件语法错误:意外的标记

问题描述 投票:0回答:1

当我尝试激活 WordPress 插件时,出现以下错误。

解析错误:语法错误,意外的标记“function”,期望“)” 在/home/bcombd/outbox.com.bd/wp-content/plugins/edhub-core/index.php 245号线

define('TUTOR_BASE_DIR', plugin_dir_path(__FILE__));
define('TUTOR_BASE_URL', plugin_dir_url(__FILE__));

define('TUTOR_TAXONOMY', 'course-category');

include_once ABSPATH . 'wp-admin/includes/plugin.php';
require_once TUTOR_BASE_DIR . 'inc/demo-users/user-importer.php';

$elementor_active = is_plugin_active('elementor/elementor.php');
$tutor_active     = is_plugin_active('tutor/tutor.php');
$woo_active       = is_plugin_active('woocommerce/woocommerce.php');

define('TUTOR_ACTIVE', $tutor_active);
define('WOO_ACTIVE', $woo_active);

class EdHub_Core
{
    public function __construct()
    {
        add_action('init', [ $this, 'include_files' ]);
        add_action( 'plugins_loaded', array( $this, 'load_textdomain' ), 16 );
        add_action('wp_enqueue_scripts', [ $this, 'tutor_enqueue_scripts' ], 99);
        add_action('widgets_init', [ $this, 'edhub_widgets_init' ]);
        add_filter('tutor_get_template_path', [ $this, 'tutor_template_load' ], 10, 2);
        add_filter('template_include', [ $this, 'load_course_tag_archive_template' ], 99);
        add_filter('tutor_get_template_path', [ $this, 'tutor_event_template_load' ], 10, 2);
        add_filter('template_include', [ $this, 'load_course_event' ], 99);

        add_action( 'show_user_profile', [ $this, 'edhub_user_social_profile_fields' ] );
        add_action( 'edit_user_profile', [ $this, 'edhub_user_social_profile_fields' ] );

        add_action( 'personal_options_update', [ $this, 'edhub_extra_profile_fields' ] );
        add_action( 'edit_user_profile_update', [ $this, 'edhub_extra_profile_fields' ] );
        add_action('wp_head', function(){
            $ppp = get_option('tutor_option')['courses_per_page'];
            ?>
            <script>
                window.edhubTutor = {
                    ppp: <?php echo esc_attr($ppp) ?>,
                }
            </script>
            <?
        });
    }

    public function tutor_template_load($template_location, $template)
    {
        $location = __DIR__ . "/tutor/{$template}.php";
        if (file_exists($location)) {
            return $location;
        } else {
            return $template_location;
        }
    }

    public function load_textdomain() {
        load_plugin_textdomain( 'edhub-core' , false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
    }

    public function load_course_tag_archive_template($template)
    {
        global $wp_query;
        $post_type  = get_query_var('post_type');
        $course_tag = get_query_var('course-tag');

        if (( $post_type === 'courses' || ! empty($course_tag) ) && $wp_query->is_archive()) {
            $template = tutor_get_template('archive-course');

            return $template;
        }

        return $template;
    }

    public function tutor_event_template_load($template_location, $template)
    {
        global $wp_query;
        if ( !empty( $wp_query->query_vars['post_type'] ) &&  $wp_query->query_vars['post_type'] === 'course_event') {
            $template_location = TUTOR_BASE_DIR . "events/{$template}.php";
        }

        return $template_location;
    }

    public function load_course_event($template)
    {
        global $wp_query;
        if (! empty($wp_query->query_vars['post_type']) && $wp_query->query_vars['post_type'] === "course_event") {
            if ($wp_query->is_single) {
                $template = TUTOR_BASE_DIR . "events/single-course_event.php";
            } elseif ($wp_query->is_archive) {
                $template = TUTOR_BASE_DIR . "events/archive_course_event.php";
            }
        }

        return $template;
    }

    public function tutor_enqueue_scripts()
    {
        wp_enqueue_style('tutor-elementor', TUTOR_BASE_URL . 'assets/css/tutor-elementor.css');
        wp_enqueue_script('isotope-library', TUTOR_BASE_URL . 'dependencies/isotope/isotope.pkgd.min.js', ['jquery']);
        wp_enqueue_script('tutor-elementor-core-js', TUTOR_BASE_URL . 'assets/js/tutor-lementor-addons-core.js', '', true);
        wp_enqueue_script('tutor-common-js', TUTOR_BASE_URL . 'assets/js/tutor-common.js', '', time(), true);
        wp_enqueue_script('tutor-wow-js', TUTOR_BASE_URL . 'dependencies/wow/js/wow.min.js', '', true);
        wp_enqueue_script('parallaxie-js', TUTOR_BASE_URL . 'dependencies/parallaxie/parallaxie.js', '', true);
        wp_enqueue_script('tween-max-js', TUTOR_BASE_URL . 'dependencies/tween-max/tween-max.min.js', '', true);
        wp_enqueue_script('waypoints-js', TUTOR_BASE_URL . 'dependencies/waypoints/jquery.waypoints.min.js', '', true);
        wp_enqueue_script('counter-up-js', TUTOR_BASE_URL . 'dependencies/counter-up/jquery.counterup.min.js', '', true);
        wp_enqueue_script('custom-tweenmax-parllexie', TUTOR_BASE_URL . 'assets/js/custom-tweenmax-parllexie.js', '', true);
        //ajax scripts
        wp_enqueue_script('ajax_script', TUTOR_BASE_URL . 'assets/js/ajax-filter.js', '', true);
        wp_enqueue_script('wishlist_ajax_script', TUTOR_BASE_URL . 'assets/js/wishlist.js', '', true);
        wp_enqueue_script('event_ajax_filter', TUTOR_BASE_URL . 'assets/js/event_filter_ajax.js', '', true);
        wp_enqueue_script('review_pagination_ajax', TUTOR_BASE_URL . 'assets/js/instructor_review.js', '', true);
        wp_enqueue_script('enrolled_course_pagination_ajax', TUTOR_BASE_URL . 'assets/js/enrolled_course_ajax.js', '', true);
        wp_enqueue_script('common_js_for_ajax', TUTOR_BASE_URL . 'assets/js/app.js', '', true);
    }

    public function include_files()
    {
        require_once 'inc/demo-importer.php';
        require_once 'inc/post-meta.php';
        require_once 'inc/rt-post-views.php';
        require_once 'inc/rt-post-share.php';
        include_once 'events/init.php';
        include_once 'ajax_handler.php';
        include_once 'helper/tutor/filter.php';

        require_once 'elementor/init.php';
    }

    public function edhub_widgets_init()
    {
        require_once 'widget/course_information.php';
        require_once 'widget/course_category.php';
        require_once 'widget/social-widget.php';
        require_once 'widget/rt-recent-post-widget.php';
        require_once 'widget/rt-post-box.php';
        require_once 'widget/rt-post-tag.php';
        require_once 'widget/course_related.php';
        require_once 'widget/rt-widget-cta.php';
        require_once 'widget/rt-product-box.php';
        require_once 'events/init.php';

        // Register Custom Widgets
        register_widget('Edhub_Course_Information');
        register_widget('Edhub_Course_Category');
        register_widget('EdhubTheme_Social_Widget');
        register_widget('EdhubTheme_Recent_Posts_With_Image_Widget');
        register_widget('EdhubTheme_Post_Box');
        register_widget('Edhub_Widget_Tags');
        register_widget('Edhub_Related_Course');
        register_widget('Edhub_Widget_CTA');
        register_widget('EdhubTheme_Product_Box');
    }

    /*social link to author profile page*/
    function edhub_user_social_profile_fields( $user ) { ?>

        <h3><?php esc_html_e( 'User Designation', 'edhub-core' ); ?></h3>

        <table class="form-table">
            <tr>
                <th><label for="edhub_author_designation"><?php esc_html_e( 'Author Designation', 'edhub-core' ); ?></label>
                </th>
                <td><input type="text" name="edhub_author_designation" id="edhub_author_designation"
                           value="<?php echo esc_attr( get_the_author_meta( 'edhub_author_designation', $user->ID ) ); ?>"
                           class="regular-text"/><br/><span
                            class="description"><?php esc_html_e( 'Please enter your Author Designation', 'edhub-core' ); ?></span>
                </td>
            </tr>
        </table>

        <h3><?php esc_html_e( 'Social profile information', 'edhub-core' ); ?></h3>

        <table class="form-table">
            <tr>
                <th><label for="facebook"><?php esc_html_e( 'Facebook', 'edhub-core' ); ?></label></th>
                <td><input type="text" name="facebook" id="facebook"
                           value="<?php echo esc_attr( get_the_author_meta( '_tutor_profile_facebook', $user->ID ) ); ?>"
                           class="regular-text"/><br/><span
                            class="description"><?php esc_html_e( 'Please enter your facebook URL.', 'edhub-core' ); ?></span>
                </td>
            </tr>
            <tr>
                <th><label for="twitter"><?php esc_html_e( 'Twitter', 'edhub-core' ); ?></label></th>
                <td><input type="text" name="twitter" id="twitter"
                           value="<?php echo esc_attr( get_the_author_meta( '_tutor_profile_twitter', $user->ID ) ); ?>"
                           class="regular-text"/><br/><span
                            class="description"><?php esc_html_e( 'Please enter your Twitter username.', 'edhub-core' ); ?></span>
                </td>
            </tr>
            <tr>
                <th><label for="linkedin"><?php esc_html_e( 'LinkedIn', 'edhub-core' ); ?></label></th>
                <td><input type="text" name="linkedin" id="linkedin"
                           value="<?php echo esc_attr( get_the_author_meta( '_tutor_profile_linkedin', $user->ID ) ); ?>"
                           class="regular-text"/><br/><span
                            class="description"><?php esc_html_e( 'Please enter your LinkedIn Profile', 'edhub-core' ); ?></span>
                </td>
            </tr>
            <tr>
                <th><label for="skype"><?php esc_html_e( 'Skype', 'edhub-core' ); ?></label></th>
                <td><input type="text" name="skype" id="skype"
                           value="<?php echo esc_attr( get_the_author_meta( '_tutor_profile_skype', $user->ID ) ); ?>"
                           class="regular-text"/><br/><span
                            class="description"><?php esc_html_e( 'Please enter your skype Profile', 'edhub-core' ); ?></span>
                </td>
            </tr>
            <tr>
                <th><label for="github"><?php esc_html_e( 'GitHub', 'edhub-core' ); ?></label></th>
                <td><input type="text" name="github" id="github"
                           value="<?php echo esc_attr( get_the_author_meta( '_tutor_profile_github', $user->ID ) ); ?>"
                           class="regular-text"/><br/><span
                            class="description"><?php esc_html_e( 'Please enter your github Profile', 'edhub-core' ); ?></span>
                </td>
            </tr>
            <tr>
                <th><label for="website"><?php esc_html_e( 'Website', 'edhub-core' ); ?></label></th>
                <td><input type="text" name="website" id="website"
                           value="<?php echo esc_attr( get_the_author_meta( '_tutor_profile_website', $user->ID ) ); ?>"
                           class="regular-text"/><br/><span
                            class="description"><?php esc_html_e( 'Please enter your website', 'edhub-core' ); ?></span>
                </td>
            </tr>
        </table>
    <?php }

    
    function edhub_extra_profile_fields( $user_id ) {
        if ( ! current_user_can( 'edit_user', $user_id ) ) {
            return false;
        }
    

        update_user_meta( $user_id, '_tutor_profile_facebook', sanitize_url( $_POST['facebook'] ) );
        update_user_meta( $user_id, '_tutor_profile_twitter', sanitize_url( $_POST['twitter'] ) );
        update_user_meta( $user_id, '_tutor_profile_linkedin', sanitize_url( $_POST['linkedin'] ) );
        update_user_meta( $user_id, '_tutor_profile_skype', sanitize_url( $_POST['skype'] ) );
        update_user_meta( $user_id, '_tutor_profile_github', sanitize_url( $_POST['github'] ) );
        update_user_meta( $user_id, '_tutor_profile_website', sanitize_url( $_POST['website'] ) );
        update_user_meta( $user_id, 'edhub_author_designation', sanitize_text_field( $_POST['edhub_author_designation'] ) );
    }
}

new EdHub_Core;
wordpress function plugins fatal-error
1个回答
0
投票

第 54 行 php 缺失,输入

?>
<script>
    window.edhubTutor = {
        ppp: <?php echo esc_attr($ppp) ?>,
    }
</script>
<?  // <--- here
© www.soinside.com 2019 - 2024. All rights reserved.