Diff: STRATO-apps/wordpress_03/app/wp-content/plugins/tutor-lms-elementor-addons/classes/Base.php

Keine Baseline-Datei – Diff nur gegen leer.
Zur Liste
1 -
1 + <?php
2 +
3 + /**
4 + * Plugin Base Class
5 + *
6 + * @category Elementor
7 + * @package TutorLMS_Addons
8 + * @author Themeum <www.themeum.com>
9 + * @copyright 2020 Themeum <www.themeum.com>
10 + * @version Release: @1.0.0
11 + * @since 1.0.0
12 + */
13 +
14 + namespace TutorLMS\Elementor;
15 +
16 + use Elementor\Elements_Manager;
17 + use TUTOR\User;
18 +
19 + defined( 'ABSPATH' ) || die();
20 +
21 + class Base {
22 +
23 + private static $instance = null;
24 +
25 + public static function instance() {
26 + if ( is_null( self::$instance ) ) {
27 + self::$instance = new self();
28 + self::$instance->init();
29 + }
30 + return self::$instance;
31 + }
32 +
33 + private function __construct() {
34 + add_action( 'init', array( $this, 'i18n' ) );
35 + }
36 +
37 + public function i18n() {
38 + load_plugin_textdomain( 'tutor-lms-elementor-addons' );
39 + }
40 +
41 +
42 + public function init() {
43 +
44 + $this->load_files();
45 +
46 + // Plugin row meta.
47 + add_filter( 'plugin_row_meta', array( $this, 'plugin_row_meta' ), 10, 2 );
48 + // Register custom category.
49 + add_action( 'elementor/elements/categories_registered', array( $this, 'add_category' ) );
50 +
51 + add_filter(
52 + 'tutor_has_lesson_content',
53 + function( $bool ) {
54 + // Check if user is privileged.
55 + $roles = array( User::ADMIN, User::INSTRUCTOR );
56 + if ( ! User::has_any_role( $roles ) ) {
57 + return $bool;
58 + } else {
59 + return true;
60 + }
61 + }
62 + );
63 +
64 + AddonsManager::init();
65 + AssetsManager::init();
66 + Template::instance();
67 +
68 + do_action( 'tutor_elementor_addons_loaded' );
69 + }
70 +
71 + public function load_files() {
72 + require_once ETLMS_DIR_PATH . 'includes/functions.php';
73 + require_once ETLMS_DIR_PATH . 'classes/Template.php';
74 + require_once ETLMS_DIR_PATH . 'classes/AssetsManager.php';
75 + require_once ETLMS_DIR_PATH . 'classes/AddonsTrait.php';
76 + require_once ETLMS_DIR_PATH . 'classes/AddonsManager.php';
77 + }
78 +
79 + public function plugin_row_meta( $plugin_meta, $plugin_file ) {
80 + if ( $plugin_file === ETLMS_BASENAME ) {
81 + $plugin_meta[] = sprintf(
82 + '<a href="%s" target="_blank">%s</a>',
83 + esc_url( 'https://docs.themeum.com/tutor-lms/elementor-integration/' ),
84 + __( '<strong style="color: #03bd24">Documentation</strong>', 'tutor-lms-elementor-addons' )
85 + );
86 + $plugin_meta[] = sprintf(
87 + '<a href="%s" target="_blank">%s</a>',
88 + esc_url( 'https://www.themeum.com/support/' ),
89 + __( '<strong style="color: #03bd24">Get Support</strong>', 'tutor-lms-elementor-addons' )
90 + );
91 + }
92 + return $plugin_meta;
93 + }
94 +
95 + /**
96 + * Add custom category.
97 + *
98 + * @param $elements_manager
99 + */
100 + public function add_category( Elements_Manager $elements_manager ) {
101 + $elements_manager->add_category(
102 + 'tutor_addons_category',
103 + array(
104 + 'title' => __( 'Tutor LMS', 'tutor-lms-elementor-addons' ),
105 + 'icon' => 'fa fa-smile-o',
106 + )
107 + );
108 + }
109 + }
110 +