394 lines
18 KiB
PHP
394 lines
18 KiB
PHP
<?php
|
|
/**
|
|
* Plugin Name: Upstudy Core
|
|
* Description: افزونه قالب آپ استادی.
|
|
* Plugin URI: https://www.zhaket.com/store/web/webyaran/products
|
|
* Author: وب یاران
|
|
* Author URI: https://www.zhaket.com/store/web/webyaran/products
|
|
* Version: 1.3.0
|
|
* Text Domain: upstudy-core
|
|
*/
|
|
|
|
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
|
|
|
define( 'UPSTUDY_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
|
|
define( 'UPSTUDY_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
|
|
define( 'UPSTUDY_CORE_URL', plugins_url( '/', __FILE__ ) );
|
|
define( 'UPSTUDY_ASSETS_URL', UPSTUDY_CORE_URL . 'assets/' );
|
|
define( 'UPSTUDY_CORE_VERSION', '1.3.0' );
|
|
|
|
/**
|
|
* Main Upstudy Core Class
|
|
*/
|
|
final class Upstudy_Core {
|
|
|
|
const VERSION = '1.3.0';
|
|
const MINIMUM_ELEMENTOR_VERSION = '3.1.0';
|
|
const MINIMUM_PHP_VERSION = '7.0';
|
|
|
|
public function __construct() {
|
|
add_action( 'init', array( $this, 'i18n' ) );
|
|
add_action( 'plugins_loaded', array( $this, 'init' ) );
|
|
}
|
|
|
|
public function i18n() {
|
|
load_plugin_textdomain( 'upstudy-core', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
|
|
}
|
|
|
|
public function init() {
|
|
if ( ! did_action( 'elementor/loaded' ) ) {
|
|
add_action( 'admin_notices', array( $this, 'admin_notice_missing_main_plugin' ) );
|
|
return;
|
|
}
|
|
|
|
if ( ! version_compare( ELEMENTOR_VERSION, self::MINIMUM_ELEMENTOR_VERSION, '>=' ) ) {
|
|
add_action( 'admin_notices', array( $this, 'admin_notice_minimum_elementor_version' ) );
|
|
return;
|
|
}
|
|
|
|
if ( version_compare( PHP_VERSION, self::MINIMUM_PHP_VERSION, '<' ) ) {
|
|
add_action( 'admin_notices', array( $this, 'admin_notice_minimum_php_version' ) );
|
|
return;
|
|
}
|
|
|
|
require_once( 'init.php' );
|
|
}
|
|
|
|
public function admin_notice_missing_main_plugin() {
|
|
if ( isset( $_GET['activate'] ) ) unset( $_GET['activate'] );
|
|
|
|
$message = sprintf(
|
|
esc_html__( '"%1$s" requires "%2$s" to be installed and activated.', 'upstudy-core' ),
|
|
'<strong>' . esc_html__( 'Upstudy Core', 'upstudy-core' ) . '</strong>',
|
|
'<strong>' . esc_html__( 'Elementor', 'upstudy-core' ) . '</strong>'
|
|
);
|
|
|
|
printf( '<div class="notice notice-warning is-dismissible"><p>%1$s</p></div>', $message );
|
|
}
|
|
|
|
public function admin_notice_minimum_elementor_version() {
|
|
if ( isset( $_GET['activate'] ) ) unset( $_GET['activate'] );
|
|
|
|
$message = sprintf(
|
|
esc_html__( '"%1$s" requires "%2$s" version %3$s or greater.', 'upstudy-core' ),
|
|
'<strong>' . esc_html__( 'Upstudy Core', 'upstudy-core' ) . '</strong>',
|
|
'<strong>' . esc_html__( 'Elementor', 'upstudy-core' ) . '</strong>',
|
|
self::MINIMUM_ELEMENTOR_VERSION
|
|
);
|
|
|
|
printf( '<div class="notice notice-warning is-dismissible"><p>%1$s</p></div>', $message );
|
|
}
|
|
|
|
public function admin_notice_minimum_php_version() {
|
|
if ( isset( $_GET['activate'] ) ) unset( $_GET['activate'] );
|
|
|
|
$message = sprintf(
|
|
esc_html__( '"%1$s" requires "%2$s" version %3$s or greater.', 'upstudy-core' ),
|
|
'<strong>' . esc_html__( 'Upstudy Core', 'upstudy-core' ) . '</strong>',
|
|
'<strong>' . esc_html__( 'PHP', 'upstudy-core' ) . '</strong>',
|
|
self::MINIMUM_PHP_VERSION
|
|
);
|
|
|
|
printf( '<div class="notice notice-warning is-dismissible"><p>%1$s</p></div>', $message );
|
|
}
|
|
|
|
}
|
|
|
|
// Instantiate Upstudy_Core.
|
|
new Upstudy_Core();
|
|
|
|
|
|
/*=============================================
|
|
Register language tax for LearnPress LMS
|
|
=============================================*/
|
|
// if (!class_exists('LearnPress')) {
|
|
function upstudy_register_lp_tax_language()
|
|
{
|
|
$course_post_type = 'lp_course';
|
|
|
|
$labels = array(
|
|
'name' => _x('Course Language', 'taxonomy general name', 'upstudy-core'),
|
|
'singular_name' => _x('Language', 'taxonomy singular name', 'upstudy-core'),
|
|
'search_items' => esc_html__('Search Languages', 'upstudy-core'),
|
|
'popular_items' => esc_html__('Popular Languages', 'upstudy-core'),
|
|
'all_items' => esc_html__('All Languages', 'upstudy-core'),
|
|
'parent_item' => null,
|
|
'parent_item_colon' => null,
|
|
'edit_item' => esc_html__('Edit Language', 'upstudy-core'),
|
|
'update_item' => esc_html__('Update Language', 'upstudy-core'),
|
|
'add_new_item' => esc_html__('Add New Language', 'upstudy-core'),
|
|
'new_item_name' => esc_html__('New Language Name', 'upstudy-core'),
|
|
'separate_items_with_commas' => esc_html__('Separate languages with commas', 'upstudy-core'),
|
|
'add_or_remove_items' => esc_html__('Add or remove languages', 'upstudy-core'),
|
|
'choose_from_most_used' => esc_html__('Choose from the most used languages', 'upstudy-core'),
|
|
'not_found' => esc_html__('No languages found.', 'upstudy-core'),
|
|
'menu_name' => esc_html__('Course Languages', 'upstudy-core'),
|
|
'back_to_items' => esc_html__('Back to Languages', 'upstudy-core'),
|
|
);
|
|
|
|
$args = array(
|
|
'hierarchical' => false,
|
|
'labels' => $labels,
|
|
'show_ui' => true,
|
|
'show_admin_column' => true,
|
|
'update_count_callback' => '_update_post_term_count',
|
|
'query_var' => true,
|
|
'show_in_rest' => true,
|
|
'rewrite' => array('slug' => apply_filters('upstudy_lp_course_language_slug', 'lp_course_language')),
|
|
);
|
|
|
|
register_taxonomy('lp_course_language', $course_post_type, $args);
|
|
}
|
|
add_action('init', 'upstudy_register_lp_tax_language', 1);
|
|
|
|
// }
|
|
|
|
|
|
/*=============================================
|
|
Register language tax for LearnDash LMS
|
|
=============================================*/
|
|
if (!class_exists('SFWD_LMS')) {
|
|
function upstudy_register_ld_tax_language()
|
|
{
|
|
$course_post_type = 'sfwd-courses';
|
|
|
|
$labels = array(
|
|
'name' => _x('Course Language', 'taxonomy general name', 'upstudy-core'),
|
|
'singular_name' => _x('Language', 'taxonomy singular name', 'upstudy-core'),
|
|
'search_items' => esc_html__('Search Languages', 'upstudy-core'),
|
|
'popular_items' => esc_html__('Popular Languages', 'upstudy-core'),
|
|
'all_items' => esc_html__('All Languages', 'upstudy-core'),
|
|
'parent_item' => null,
|
|
'parent_item_colon' => null,
|
|
'edit_item' => esc_html__('Edit Language', 'upstudy-core'),
|
|
'update_item' => esc_html__('Update Language', 'upstudy-core'),
|
|
'add_new_item' => esc_html__('Add New Language', 'upstudy-core'),
|
|
'new_item_name' => esc_html__('New Language Name', 'upstudy-core'),
|
|
'separate_items_with_commas' => esc_html__('Separate languages with commas', 'upstudy-core'),
|
|
'add_or_remove_items' => esc_html__('Add or remove languages', 'upstudy-core'),
|
|
'choose_from_most_used' => esc_html__('Choose from the most used languages', 'upstudy-core'),
|
|
'not_found' => esc_html__('No languages found.', 'upstudy-core'),
|
|
'menu_name' => esc_html__('Course Languages', 'upstudy-core'),
|
|
'back_to_items' => esc_html__('Back to Languages', 'upstudy-core'),
|
|
);
|
|
|
|
$args = array(
|
|
'hierarchical' => false,
|
|
'labels' => $labels,
|
|
'show_ui' => true,
|
|
'show_admin_column' => true,
|
|
'update_count_callback' => '_update_post_term_count',
|
|
'query_var' => true,
|
|
'show_in_rest' => true,
|
|
'rewrite' => array('slug' => apply_filters('upstudy_ld_course_language_slug', 'ld_course_language')),
|
|
);
|
|
|
|
register_taxonomy('ld_course_language', $course_post_type, $args);
|
|
}
|
|
add_action('init', 'upstudy_register_ld_tax_language', 1);
|
|
|
|
}
|
|
|
|
|
|
/*=============================================
|
|
Register language tax for MasterStudy LMS
|
|
=============================================*/
|
|
if (!class_exists('MasterStudy\Lms\Plugin')) {
|
|
function upstudy_register_ms_tax_language()
|
|
{
|
|
$course_post_type = 'stm-courses';
|
|
|
|
$labels = array(
|
|
'name' => _x('Course Language', 'taxonomy general name', 'upstudy-core'),
|
|
'singular_name' => _x('Language', 'taxonomy singular name', 'upstudy-core'),
|
|
'search_items' => esc_html__('Search Languages', 'upstudy-core'),
|
|
'popular_items' => esc_html__('Popular Languages', 'upstudy-core'),
|
|
'all_items' => esc_html__('All Languages', 'upstudy-core'),
|
|
'parent_item' => null,
|
|
'parent_item_colon' => null,
|
|
'edit_item' => esc_html__('Edit Language', 'upstudy-core'),
|
|
'update_item' => esc_html__('Update Language', 'upstudy-core'),
|
|
'add_new_item' => esc_html__('Add New Language', 'upstudy-core'),
|
|
'new_item_name' => esc_html__('New Language Name', 'upstudy-core'),
|
|
'separate_items_with_commas' => esc_html__('Separate languages with commas', 'upstudy-core'),
|
|
'add_or_remove_items' => esc_html__('Add or remove languages', 'upstudy-core'),
|
|
'choose_from_most_used' => esc_html__('Choose from the most used languages', 'upstudy-core'),
|
|
'not_found' => esc_html__('No languages found.', 'upstudy-core'),
|
|
'menu_name' => esc_html__('Course Languages', 'upstudy-core'),
|
|
'back_to_items' => esc_html__('Back to Languages', 'upstudy-core'),
|
|
);
|
|
|
|
$args = array(
|
|
'hierarchical' => false,
|
|
'labels' => $labels,
|
|
'show_ui' => true,
|
|
'show_admin_column' => true,
|
|
'update_count_callback' => '_update_post_term_count',
|
|
'query_var' => true,
|
|
'show_in_rest' => true,
|
|
'rewrite' => array('slug' => apply_filters('upstudy_ms_course_language_slug', 'ms_course_language')),
|
|
);
|
|
|
|
register_taxonomy('ms_course_language', $course_post_type, $args);
|
|
}
|
|
add_action('init', 'upstudy_register_ms_tax_language', 1);
|
|
|
|
}
|
|
|
|
/*=============================================
|
|
Register language tax for Tutor LMS
|
|
=============================================*/
|
|
if (function_exists('tutor')) {
|
|
function upstudy_register_tutor_tax_language()
|
|
{
|
|
$course_post_type = 'courses';
|
|
|
|
$labels = array(
|
|
'name' => _x('Course Language', 'taxonomy general name', 'upstudy-core'),
|
|
'singular_name' => _x('Language', 'taxonomy singular name', 'upstudy-core'),
|
|
'search_items' => esc_html__('Search Languages', 'upstudy-core'),
|
|
'popular_items' => esc_html__('Popular Languages', 'upstudy-core'),
|
|
'all_items' => esc_html__('All Languages', 'upstudy-core'),
|
|
'parent_item' => null,
|
|
'parent_item_colon' => null,
|
|
'edit_item' => esc_html__('Edit Language', 'upstudy-core'),
|
|
'update_item' => esc_html__('Update Language', 'upstudy-core'),
|
|
'add_new_item' => esc_html__('Add New Language', 'upstudy-core'),
|
|
'new_item_name' => esc_html__('New Language Name', 'upstudy-core'),
|
|
'separate_items_with_commas' => esc_html__('Separate languages with commas', 'upstudy-core'),
|
|
'add_or_remove_items' => esc_html__('Add or remove languages', 'upstudy-core'),
|
|
'choose_from_most_used' => esc_html__('Choose from the most used languages', 'upstudy-core'),
|
|
'not_found' => esc_html__('No languages found.', 'upstudy-core'),
|
|
'menu_name' => esc_html__('Course Languages', 'upstudy-core'),
|
|
'back_to_items' => esc_html__('Back to Languages', 'upstudy-core'),
|
|
);
|
|
|
|
$args = array(
|
|
'hierarchical' => false,
|
|
'labels' => $labels,
|
|
'show_ui' => true,
|
|
'show_admin_column' => true,
|
|
'update_count_callback' => '_update_post_term_count',
|
|
'query_var' => true,
|
|
'show_in_rest' => true,
|
|
'rewrite' => array('slug' => apply_filters('upstudy_tutor_course_language_slug', 'tutor_course_language')),
|
|
);
|
|
|
|
register_taxonomy('tutor_course_language', $course_post_type, $args);
|
|
}
|
|
add_action('init', 'upstudy_register_tutor_tax_language', 1);
|
|
|
|
/*=============================================
|
|
Add language tax submenu for Tutor LMS
|
|
=============================================*/
|
|
function upstudy_register_tutor_language_submenu(){
|
|
$course_post_type = 'courses';
|
|
add_submenu_page(
|
|
'tutor',
|
|
esc_html__('Languages', 'upstudy-core'),
|
|
esc_html__('Languages', 'upstudy-core'),
|
|
'manage_tutor',
|
|
'edit-tags.php?taxonomy=tutor_course_language&post_type=' . $course_post_type,
|
|
null,
|
|
3
|
|
);
|
|
}
|
|
|
|
add_action('admin_menu', 'upstudy_register_tutor_language_submenu', 100);
|
|
|
|
}
|
|
|
|
|
|
/*=============================================
|
|
Register language tax for Sensei LMS
|
|
=============================================*/
|
|
if (!class_exists('Sensei_Main')) {
|
|
function upstudy_register_sensei_tax_language()
|
|
{
|
|
$course_post_type = 'course';
|
|
|
|
$labels = array(
|
|
'name' => _x('Course Language', 'taxonomy general name', 'upstudy-core'),
|
|
'singular_name' => _x('Language', 'taxonomy singular name', 'upstudy-core'),
|
|
'search_items' => esc_html__('Search Languages', 'upstudy-core'),
|
|
'popular_items' => esc_html__('Popular Languages', 'upstudy-core'),
|
|
'all_items' => esc_html__('All Languages', 'upstudy-core'),
|
|
'parent_item' => null,
|
|
'parent_item_colon' => null,
|
|
'edit_item' => esc_html__('Edit Language', 'upstudy-core'),
|
|
'update_item' => esc_html__('Update Language', 'upstudy-core'),
|
|
'add_new_item' => esc_html__('Add New Language', 'upstudy-core'),
|
|
'new_item_name' => esc_html__('New Language Name', 'upstudy-core'),
|
|
'separate_items_with_commas' => esc_html__('Separate languages with commas', 'upstudy-core'),
|
|
'add_or_remove_items' => esc_html__('Add or remove languages', 'upstudy-core'),
|
|
'choose_from_most_used' => esc_html__('Choose from the most used languages', 'upstudy-core'),
|
|
'not_found' => esc_html__('No languages found.', 'upstudy-core'),
|
|
'menu_name' => esc_html__('Course Languages', 'upstudy-core'),
|
|
'back_to_items' => esc_html__('Back to Languages', 'upstudy-core'),
|
|
);
|
|
|
|
$args = array(
|
|
'hierarchical' => false,
|
|
'labels' => $labels,
|
|
'show_ui' => true,
|
|
'show_admin_column' => true,
|
|
'update_count_callback' => '_update_post_term_count',
|
|
'query_var' => true,
|
|
'show_in_rest' => true,
|
|
'rewrite' => array('slug' => apply_filters('upstudy_sensei_course_language_slug', 'sensei_course_language')),
|
|
);
|
|
|
|
register_taxonomy('sensei_course_language', $course_post_type, $args);
|
|
}
|
|
add_action('init', 'upstudy_register_sensei_tax_language', 1);
|
|
|
|
}
|
|
|
|
|
|
/*=============================================
|
|
Register language tax for LifterLMS
|
|
=============================================*/
|
|
if (!class_exists('LifterLMS')) {
|
|
function upstudy_register_lifter_tax_language()
|
|
{
|
|
|
|
$course_post_type = 'course';
|
|
|
|
$labels = array(
|
|
'name' => _x('Course Language', 'taxonomy general name', 'upstudy-core'),
|
|
'singular_name' => _x('Language', 'taxonomy singular name', 'upstudy-core'),
|
|
'search_items' => esc_html__('Search Languages', 'upstudy-core'),
|
|
'popular_items' => esc_html__('Popular Languages', 'upstudy-core'),
|
|
'all_items' => esc_html__('All Languages', 'upstudy-core'),
|
|
'parent_item' => null,
|
|
'parent_item_colon' => null,
|
|
'edit_item' => esc_html__('Edit Language', 'upstudy-core'),
|
|
'update_item' => esc_html__('Update Language', 'upstudy-core'),
|
|
'add_new_item' => esc_html__('Add New Language', 'upstudy-core'),
|
|
'new_item_name' => esc_html__('New Language Name', 'upstudy-core'),
|
|
'separate_items_with_commas' => esc_html__('Separate languages with commas', 'upstudy-core'),
|
|
'add_or_remove_items' => esc_html__('Add or remove languages', 'upstudy-core'),
|
|
'choose_from_most_used' => esc_html__('Choose from the most used languages', 'upstudy-core'),
|
|
'not_found' => esc_html__('No languages found.', 'upstudy-core'),
|
|
'menu_name' => esc_html__('Course Languages', 'upstudy-core'),
|
|
'back_to_items' => esc_html__('Back to Languages', 'upstudy-core'),
|
|
);
|
|
|
|
$args = array(
|
|
'hierarchical' => false,
|
|
'labels' => $labels,
|
|
'show_ui' => true,
|
|
'show_admin_column' => true,
|
|
'update_count_callback' => '_update_post_term_count',
|
|
'query_var' => true,
|
|
'show_in_rest' => true,
|
|
'rewrite' => array('slug' => apply_filters('upstudy_lifter_course_language_slug', 'lifter_course_language')),
|
|
);
|
|
|
|
register_taxonomy('lifter_course_language', $course_post_type, $args);
|
|
}
|
|
add_action('init', 'upstudy_register_lifter_tax_language', 1);
|
|
|
|
}
|
|
|