PluginProbe
GamiPress – Gamification plugin to reward points, badges & ranks in WordPress, now with AI / 8.0.2
GamiPress – Gamification plugin to reward points, badges & ranks in WordPress, now with AI v8.0.2
8.0.1 8.0.2 8.0.0 7.9.9.7 7.9.9.6 7.9.9.5 7.9.9.4 7.9.9.3 7.9.9.2 7.9.9.1 7.9.9 7.9.8 7.9.7 7.9.6 7.9.5 7.9.4 7.9.3 7.9.2 7.9.1 7.9.0 7.8.9 7.8.8 7.8.7 7.8.6 7.8.5 All 44 releases
gamipress / integrations / learnpress / learnpress.php

learnpress.php in GamiPress – Gamification plugin to reward points, badges & ranks in WordPress, now with AI 8.0.2, at integrations/learnpress/learnpress.php

175 lines 4.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Plugin Name: GamiPress - LearnPress integration
4 * Plugin URI: https://wordpress.org/plugins/gamipress-learnpress-integration/
5 * Description: Connect GamiPress with LearnPress.
6 * Version: 1.1.1
7 * Author: GamiPress
8 * Author URI: https://gamipress.com/
9 * Text Domain: gamipress-learnpress-integration
10 * Domain Path: /languages/
11 * Requires at least: 4.4
12 * Tested up to: 6.2
13 * License: GNU AGPL v3.0 (http://www.gnu.org/licenses/agpl.txt)
14 *
15 * @package GamiPress\LearnPress
16 * @author GamiPress
17 * @copyright Copyright (c) GamiPress
18 */
19
20 final class GamiPress_Integration_LearnPress {
21
22 /**
23 * @var GamiPress_Integration_LearnPress $instance The one true GamiPress_Integration_LearnPress
24 * @since 1.0.0
25 */
26 private static $instance;
27
28 /**
29 * Get active instance
30 *
31 * @access public
32 * @since 1.0.0
33 * @return object self::$instance The one true GamiPress_Integration_LearnPress
34 */
35 public static function instance() {
36 if( !self::$instance ) {
37 self::$instance = new GamiPress_Integration_LearnPress();
38 self::$instance->constants();
39 self::$instance->includes();
40 self::$instance->hooks();
41
42 }
43
44 return self::$instance;
45 }
46
47 /**
48 * Setup plugin constants
49 *
50 * @access private
51 * @since 1.0.0
52 * @return void
53 */
54 private function constants() {
55 // Plugin version
56 define( 'GAMIPRESS_LP_VER', '1.1.1' );
57
58 // Plugin path
59 define( 'GAMIPRESS_LP_DIR', plugin_dir_path( __FILE__ ) );
60
61 // Plugin URL
62 define( 'GAMIPRESS_LP_URL', plugin_dir_url( __FILE__ ) );
63 }
64
65 /**
66 * Include plugin files
67 *
68 * @access private
69 * @since 1.0.0
70 * @return void
71 */
72 private function includes() {
73
74 if( $this->meets_requirements() ) {
75
76 require_once GAMIPRESS_LP_DIR . 'includes/admin.php';
77
78 // Backward compatibility with old LearnPress hooks
79 if( version_compare( LEARNPRESS_VERSION, '3.0', '<' ) ) {
80 require_once GAMIPRESS_LP_DIR . 'compatibility/listeners.php';
81 } else {
82 require_once GAMIPRESS_LP_DIR . 'includes/listeners.php';
83 }
84
85 require_once GAMIPRESS_LP_DIR . 'includes/triggers.php';
86
87 }
88 }
89
90 /**
91 * Setup plugin hooks
92 *
93 * @access private
94 * @since 1.0.0
95 * @return void
96 */
97 private function hooks() {
98 // Setup our activation and deactivation hooks
99 register_activation_hook( __FILE__, array( $this, 'activate' ) );
100 register_deactivation_hook( __FILE__, array( $this, 'deactivate' ) );
101
102
103 }
104
105 /**
106 * Activation hook for the plugin.
107 *
108 * @since 1.0.0
109 */
110 function activate() {
111
112 if( $this->meets_requirements() ) {
113
114 }
115
116 }
117
118 /**
119 * Deactivation hook for the plugin.
120 *
121 * @since 1.0.0
122 */
123 function deactivate() {
124
125 }
126
127 /**
128 * Check if there are all plugin requirements
129 *
130 * @since 1.0.0
131 *
132 * @return bool True if installation meets all requirements
133 */
134 private function meets_requirements() {
135
136 if ( ! class_exists( 'GamiPress' ) ) {
137 return false;
138 }
139
140 // Multisite feature requires GamiPress 1.4.8
141 if( is_multisite() ) {
142
143 // Requirements on multisite install
144 if( is_main_site() && function_exists('gamipress_is_network_wide_active') && gamipress_is_network_wide_active() ) {
145
146 // On main site, need to check if integrated plugin is installed on any sub site to load all configuration files
147 if( gamipress_is_plugin_active_on_network( 'learnpress/learnpress.php' ) ) {
148 return true;
149 }
150
151 }
152
153 }
154
155 if ( ! class_exists( 'LearnPress' ) ) {
156 return false;
157 }
158
159 return true;
160
161 }
162
163 }
164
165 /**
166 * The main function responsible for returning the one true GamiPress_Integration_LearnPress instance to functions everywhere
167 *
168 * @since 1.0.0
169 * @return \GamiPress_Integration_LearnPress The one true GamiPress_Integration_LearnPress
170 */
171 function GamiPress_LP() {
172 return GamiPress_Integration_LearnPress::instance();
173 }
174 add_action( 'gamipress_pre_init', 'GamiPress_LP' );
175