Diff: STRATO-apps/wordpress_03/app/wp-content/plugins/tutor-pro/addons/tutor-report/classes/Init.php

Keine Baseline-Datei – Diff nur gegen leer.
Zur Liste
1 -
1 + <?php
2 + /**
3 + * Report Addon Init
4 + *
5 + * @package TutorPro\Addons
6 + * @subpackage Report
7 + * @author Themeum <support@themeum.com>
8 + * @link https://themeum.com
9 + * @since 2.0.0
10 + */
11 +
12 + namespace TUTOR_REPORT;
13 +
14 + use TUTOR\Permalink;
15 +
16 + if ( ! defined( 'ABSPATH' ) ) {
17 + exit;
18 + }
19 +
20 + /**
21 + * Class Init
22 + */
23 + class Init {
24 + //phpcs:disable
25 + public $version = TUTOR_REPORT_VERSION;
26 + public $path;
27 + public $url;
28 + public $basename;
29 +
30 + public $report;
31 + public $analytics;
32 + public $course_analytics;
33 + public $export_analytics;
34 +
35 + public static $_instance = null;
36 + //phpcs:enable
37 +
38 + /**
39 + * Constructor
40 + */
41 + public function __construct() {
42 + if ( ! function_exists( 'tutor' ) ) {
43 + return;
44 + }
45 +
46 + add_action( 'tutor_addon_before_enable_tutor-pro/addons/tutor-report/tutor-report.php', array( $this, 'update_permalink' ) );
47 +
48 + $addon_config = tutor_utils()->get_addon_config( TUTOR_REPORT()->basename );
49 + $is_enable = (bool) tutor_utils()->avalue_dot( 'is_enable', $addon_config );
50 + if ( ! $is_enable ) {
51 + return;
52 + }
53 +
54 + $this->path = plugin_dir_path( TUTOR_REPORT_FILE );
55 + $this->url = plugin_dir_url( TUTOR_REPORT_FILE );
56 + $this->basename = plugin_basename( TUTOR_REPORT_FILE );
57 +
58 + $this->load_tutor_report();
59 + }
60 +
61 + /**
62 + * Update permalink during addon enable.
63 + *
64 + * @since 2.6.0
65 + *
66 + * @return void
67 + */
68 + public function update_permalink() {
69 + Permalink::set_permalink_flag();
70 + }
71 +
72 + /**
73 + * Load report addon
74 + *
75 + * @return void
76 + */
77 + public function load_tutor_report() {
78 + /**
79 + * Loading Autoloader
80 + */
81 +
82 + spl_autoload_register( array( $this, 'loader' ) );
83 +
84 + $this->report = new Report();
85 + /**
86 + * Analytics class
87 + *
88 + * @since 1.9.8
89 + */
90 + $this->analytics = new Analytics();
91 + $this->course_analytics = new CourseAnalytics();
92 + $this->export_analytics = new ExportAnalytics();
93 + }
94 +
95 + /**
96 + * Auto Load class and the files
97 + *
98 + * @param string $class_name class name.
99 + *
100 + * @return void
101 + */
102 + private function loader( $class_name ) {
103 + if ( ! class_exists( $class_name ) ) {
104 + $class_name = preg_replace(
105 + array( '/([a-z])([A-Z])/', '/\\\/' ),
106 + array( '$1$2', DIRECTORY_SEPARATOR ),
107 + $class_name
108 + );
109 +
110 + $class_name = str_replace( 'TUTOR_REPORT' . DIRECTORY_SEPARATOR, 'classes' . DIRECTORY_SEPARATOR, $class_name );
111 + $file_name = $this->path . $class_name . '.php';
112 +
113 + if ( file_exists( $file_name ) && is_readable( $file_name ) ) {
114 + require_once $file_name;
115 + }
116 + }
117 + }
118 +
119 + /**
120 + * Single instance of tutor report
121 + *
122 + * @since 1.9.8
123 + */
124 + public static function instance() {
125 + if ( is_null( self::$_instance ) ) {
126 + self::$_instance = new self();
127 + }
128 + return self::$_instance;
129 + }
130 +
131 + }
132 +