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 / bbpress / bbpress.php

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

200 lines 5.8 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 - bbPress integration
4 * Plugin URI: https://wordpress.org/plugins/gamipress-bbpress-integration/
5 * Description: Connect GamiPress with bbPress.
6 * Version: 1.2.7
7 * Author: GamiPress
8 * Author URI: https://gamipress.com/
9 * Text Domain: gamipress-bbpress-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\bbPress
16 * @author GamiPress
17 * @copyright Copyright (c) GamiPress
18 */
19
20 final class GamiPress_Integration_bbPress {
21
22 /**
23 * @var GamiPress_Integration_bbPress $instance The one true GamiPress_Integration_bbPress
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_bbPress
34 */
35 public static function instance() {
36 if( !self::$instance ) {
37 self::$instance = new GamiPress_Integration_bbPress();
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
56 if ( defined( 'BP_PLATFORM_VERSION' ) ) return;
57
58 // Plugin version
59 define( 'GAMIPRESS_BBP_VER', '1.2.7' );
60
61 // Plugin path
62 define( 'GAMIPRESS_BBP_DIR', plugin_dir_path( __FILE__ ) );
63
64 // Plugin URL
65 define( 'GAMIPRESS_BBP_URL', plugin_dir_url( __FILE__ ) );
66 }
67
68 /**
69 * Include plugin files
70 *
71 * @access private
72 * @since 1.0.0
73 * @return void
74 */
75 private function includes() {
76
77 if( $this->meets_requirements() ) {
78
79 require_once GAMIPRESS_BBP_DIR . 'includes/admin.php';
80 require_once GAMIPRESS_BBP_DIR . 'includes/filters.php';
81 require_once GAMIPRESS_BBP_DIR . 'includes/listeners.php';
82 require_once GAMIPRESS_BBP_DIR . 'includes/scripts.php';
83 require_once GAMIPRESS_BBP_DIR . 'includes/triggers.php';
84
85 }
86 }
87
88 /**
89 * Setup plugin hooks
90 *
91 * @access private
92 * @since 1.0.0
93 * @return void
94 */
95 private function hooks() {
96 // Setup our activation and deactivation hooks
97 register_activation_hook( __FILE__, array( $this, 'activate' ) );
98 register_deactivation_hook( __FILE__, array( $this, 'deactivate' ) );
99
100
101 }
102
103 /**
104 * Activation hook for the plugin.
105 */
106 function activate() {
107
108 GamiPress_Integration_bbPress::instance();
109
110 global $wpdb;
111
112 // Get stored version
113 $stored_version = get_option( 'gamipress_bbpress_integration_version', '1.0.0' );
114
115 if ( version_compare( $stored_version, '1.0.8', '<' ) ) {
116 // GamiPress bbPress 1.0.8 upgrade
117
118 // Setup default GamiPress options
119 $gamipress_settings = ( $exists = get_option( 'gamipress_settings' ) ) ? $exists : array();
120
121 // Initialize default settings to keep backward compatibility
122
123 // Label on points types
124 $gamipress_settings['bbp_points_types_label'] = 'on';
125
126 // Thumbnail, thumbnail size and link on achievements
127 $gamipress_settings['bbp_achievement_types_thumbnail'] = 'on';
128 $gamipress_settings['bbp_achievement_types_thumbnail_size'] = '25';
129 $gamipress_settings['bbp_achievement_types_link'] = 'on';
130
131 // Title on ranks
132 $gamipress_settings['bbp_rank_types_title'] = 'on';
133
134 update_option( 'gamipress_settings', $gamipress_settings );
135 }
136
137 // Updated stored version
138 update_option( 'gamipress_bbpress_integration_version', GAMIPRESS_BBP_VER );
139
140 }
141
142 /**
143 * Deactivation hook for the plugin.
144 */
145 function deactivate() {
146
147 }
148
149 /**
150 * Check if there are all plugin requirements
151 *
152 * @since 1.0.0
153 *
154 * @return bool True if installation meets all requirements
155 */
156 private function meets_requirements() {
157
158 if ( defined( 'BP_PLATFORM_VERSION' ) ) return false;
159
160
161 if ( ! class_exists( 'GamiPress' ) ) {
162 return false;
163 }
164
165 // Multisite feature requires GamiPress 1.4.8
166 if( is_multisite() ) {
167
168 // Requirements on multisite install
169 if( is_main_site() && function_exists('gamipress_is_network_wide_active') && gamipress_is_network_wide_active() ) {
170
171 // On main site, need to check if integrated plugin is installed on any sub site to load all configuration files
172 if( gamipress_is_plugin_active_on_network( 'bbpress/bbpress.php' ) ) {
173 return true;
174 }
175
176 }
177
178 }
179
180 if ( ! class_exists( 'bbPress' ) ) {
181 return false;
182 }
183
184 return true;
185
186 }
187
188 }
189
190 /**
191 * The main function responsible for returning the one true GamiPress_Integration_bbPress instance to functions everywhere
192 *
193 * @since 1.0.0
194 * @return \GamiPress_Integration_bbPress The one true GamiPress_Integration_bbPress
195 */
196 function GamiPress_Integration_bbPress() {
197 return GamiPress_Integration_bbPress::instance();
198 }
199 add_action( 'gamipress_pre_init', 'GamiPress_Integration_bbPress' );
200