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

Keine Baseline-Datei – Diff nur gegen leer.
Zur Liste
1 -
1 + <?php
2 + /**
3 + * Paid Membership Pro Integration Init
4 + *
5 + * @package TutorPro\Addons
6 + * @subpackage PmPro
7 + * @author Themeum <support@themeum.com>
8 + * @link https://themeum.com
9 + * @since 1.3.5
10 + */
11 +
12 + namespace TUTOR_PMPRO;
13 +
14 + if ( ! defined( 'ABSPATH' ) ) {
15 + exit;
16 + }
17 +
18 + /**
19 + * Class Init
20 + */
21 + class Init {
22 + //phpcs:disable
23 + public $version = TUTOR_PMPRO_VERSION;
24 + public $path;
25 + public $url;
26 + public $basename;
27 + private $paid_memberships_pro;
28 + //phpcs:enable
29 +
30 + /**
31 + * Constructor
32 + */
33 + public function __construct() {
34 + if ( ! function_exists( 'tutor' ) ) {
35 + return;
36 + }
37 +
38 + // Adding monetization options to core.
39 + add_filter( 'tutor_monetization_options', array( $this, 'tutor_monetization_options' ) );
40 +
41 + $addon_config = tutor_utils()->get_addon_config( TUTOR_PMPRO()->basename );
42 + $monetize_by = tutor_utils()->get_option( 'monetize_by' );
43 + $is_enable = (bool) tutor_utils()->array_get( 'is_enable', $addon_config );
44 + $has_pmpro = tutor_utils()->has_pmpro();
45 + if ( ! $is_enable || ! $has_pmpro || 'pmpro' !== $monetize_by ) {
46 + return;
47 + }
48 +
49 + $this->path = plugin_dir_path( TUTOR_PMPRO_FILE );
50 + $this->url = plugin_dir_url( TUTOR_PMPRO_FILE );
51 + $this->basename = plugin_basename( TUTOR_PMPRO_FILE );
52 +
53 + $this->load_tutor_pmpro();
54 + }
55 +
56 + /**
57 + * Load tutor pmpro
58 + *
59 + * @return void
60 + */
61 + public function load_tutor_pmpro() {
62 + spl_autoload_register( array( $this, 'loader' ) );
63 + $this->paid_memberships_pro = new PaidMembershipsPro();
64 + }
65 +
66 + /**
67 + * Auto Load class and the files
68 + *
69 + * @param string $class_name class name.
70 + *
71 + * @return void
72 + */
73 + private function loader( $class_name ) {
74 + if ( ! class_exists( $class_name ) ) {
75 + $class_name = preg_replace(
76 + array( '/([a-z])([A-Z])/', '/\\\/' ),
77 + array( '$1$2', DIRECTORY_SEPARATOR ),
78 + $class_name
79 + );
80 +
81 + $class_name = str_replace( 'TUTOR_PMPRO' . DIRECTORY_SEPARATOR, 'classes' . DIRECTORY_SEPARATOR, $class_name );
82 + $file_name = $this->path . $class_name . '.php';
83 +
84 + if ( file_exists( $file_name ) ) {
85 + require_once $file_name;
86 + }
87 + }
88 + }
89 +
90 + /**
91 + * Paid membership pro label
92 + *
93 + * Check if main pmpro and Tutor's pmpro addons is activated or not
94 + *
95 + * @since 1.3.6
96 + *
97 + * @param array $arr attributes.
98 + *
99 + * @return mixed
100 + */
101 + public function tutor_monetization_options( $arr ) {
102 + $is_addon_enabled = tutor_utils()->is_addon_enabled( TUTOR_PMPRO()->basename );
103 + $has_pmpro = tutor_utils()->has_pmpro();
104 + if ( $has_pmpro && $is_addon_enabled ) {
105 + $arr['pmpro'] = __( 'Paid Memberships Pro', 'tutor-pro' );
106 + }
107 + return $arr;
108 + }
109 +
110 + }
111 +