Edhub is one of the best LMS website WordPress theme.
Edhub Core Plugin Code:
<?php
/*
Plugin Name: Edhub Core
Plugin URI: https://www.radiustheme.com
Description: Elementor addons for Edhub theme
Version: 1.5.2
Author: RadiusTheme
Text Domain: edhub-core
Author URI: https://www.radiustheme.com
*/
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', [ $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'] ?? 6;
?>
<script>
window.edhubTutor = {
ppp: <?php echo esc_attr($ppp); ?>,
};
</script>
<?php
});
}
public function tutor_template_load($template_location, $template) {
$location = __DIR__ . "/tutor/{$template}.php";
return file_exists($location) ? $location : $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()) {
return tutor_get_template('archive-course');
}
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') {
return 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) {
return TUTOR_BASE_DIR . "events/single-course_event.php";
} elseif ($wp_query->is_archive) {
return 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);
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_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');
}
public 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">
<?php
$fields = [
'facebook' => 'Facebook',
'twitter' => 'Twitter',
'linkedin' => 'LinkedIn',
'skype' => 'Skype',
'github' => 'GitHub',
'website' => 'Website'
];
foreach ($fields as $key => $label) {
$meta_key = '_tutor_profile_' . $key;
?>
<tr>
<th><label for="<?php echo $key; ?>"><?php esc_html_e($label, 'edhub-core'); ?></label></th>
<td><input type="text" name="<?php echo $key; ?>" id="<?php echo $key; ?>"
value="<?php echo esc_attr(get_the_author_meta($meta_key, $user->ID)); ?>"
class="regular-text" /><br />
<span class="description"><?php esc_html_e("Please enter your {$label} URL.", 'edhub-core'); ?></span>
</td>
</tr>
<?php
}
?>
</table>
<?php }
public function edhub_extra_profile_fields($user_id) {
if (!current_user_can('edit_user', $user_id)) {
return false;
}
$fields = ['facebook', 'twitter', 'linkedin', 'skype', 'github', 'website'];
foreach ($fields as $field) {
update_user_meta($user_id, '_tutor_profile_' . $field, sanitize_url($_POST[$field] ?? ''));
}
update_user_meta($user_id, 'edhub_author_designation', sanitize_text_field($_POST['edhub_author_designation'] ?? ''));
}
}
new EdHub_Core();