PluginProbe
Forumax – AI Powered Advanced Community Forum Plugin / 1.3.3
Forumax – AI Powered Advanced Community Forum Plugin v1.3.3
2.4.4 2.4.3 2.4.2 2.4.1 2.4.0 trunk 1.0.8 1.1.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.3.3 1.4.0 1.4.1 2.0.0 2.1.0 All 29 releases
bbp-core / bbp-core.php

bbp-core.php in Forumax – AI Powered Advanced Community Forum Plugin 1.3.3, at bbp-core.php

288 lines 7.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /*
3 Plugin Name: BBP Core
4 Plugin URI: https://spider-themes.net/bbp-core
5 Description: Expand bbPress powered forums with useful features like - private reply, solved topics ...
6 Author: spider-themes
7 Author URI: https://spider-themes.net/bbp-core
8 Text Domain: bbp-core
9 Version: 1.3.3
10 Requires at least: 5.0
11 Tested up to: 6.8
12 Requires PHP: 7.4
13 License: GPLv3 or later
14 License URI: https://www.gnu.org/licenses/gpl-3.0.html
15 */
16
17 defined( 'ABSPATH' ) || exit;
18
19 if ( ! function_exists( 'bc_fs' ) ) {
20 // Create a helper function for easy SDK access.
21 function bc_fs() {
22 global $bc_fs;
23
24 if ( ! isset( $bc_fs ) ) {
25 // Include Freemius SDK.
26 require_once dirname( __FILE__ ) . '/vendor/fs/start.php';
27
28 $bc_fs = fs_dynamic_init( [
29 'id' => '10864',
30 'slug' => 'bbp-core',
31 'type' => 'plugin',
32 'public_key' => 'pk_41277ad11125f6e2a1b4e66f40164',
33 'is_premium' => false,
34 'is_premium_only' => false,
35 'has_addons' => false,
36 'has_paid_plans' => true,
37 'trial' => [
38 'days' => 14,
39 'is_require_payment' => true,
40 ],
41 'menu' => [
42 'slug' => 'bbp-core',
43 'contact' => false,
44 'support' => false,
45 'first-path' => 'admin.php?page=bbp-core',
46 ],
47 ] );
48 }
49
50 return $bc_fs;
51 }
52
53 // Init Freemius.
54 bc_fs()->add_filter( 'deactivate_on_activation', '__return_false' );
55
56 // Signal that SDK was initiated.
57 do_action( 'bc_fs_loaded' );
58 }
59
60
61 require_once __DIR__ . '/autoloader.php';
62
63 /**
64 * Plugin's heart
65 */
66 final class BBP_Core {
67 const VERSION = '1.3.3';
68
69 /**
70 * Class constructor.
71 */
72 public function __construct() {
73
74 $this->define_constants();
75 $this->core_includes();
76
77 register_activation_hook( __FILE__, [ $this, 'activate' ] );
78 add_action( 'plugins_loaded', [ $this, 'init_plugin' ] );
79 add_action( 'after_setup_theme', [ $this, 'load_csf_files' ], 20 );
80
81 // Added Documentation links to plugin row meta
82 add_filter( 'plugin_row_meta', [ $this, 'bbpc_row_meta' ], 10, 2 );
83
84 /**
85 * Removes admin notices on the BBP Core Forum builder page.
86 *
87 * @return void
88 */
89 add_action( 'admin_head', function () {
90 // Get the current screen
91 $screen = get_current_screen();
92
93 // Check if the current screen is for your plugin page
94 if ( isset( $_GET['page'] ) && in_array( $_GET['page'], [ 'bbp-core' ] ) ) {
95 // Remove admin notices
96 remove_all_actions( 'admin_notices' );
97 remove_all_actions( 'all_admin_notices' );
98
99 // Re-add a specific notice
100 if ( ! bbpc_is_premium() && bbpc_is_plugin_installed_for_days( 12 ) ) {
101 add_action( 'admin_notices', 'bbpc_offer_notice' );
102 }
103 }
104 } );
105 }
106
107 /**
108 * Define Plugin Constants.
109 *
110 * @return void
111 */
112 public function define_constants() {
113 define( 'BBPC_VERSION', self::VERSION );
114 define( 'BBPC_FILE', __FILE__ );
115 define( 'BBPC_DIR', __DIR__ . '/' );
116 define( 'BBPC_URL', plugins_url( '/', __FILE__ ) );
117 define( 'BBPC_ASSETS', BBPC_URL . 'assets/' );
118 define( 'BBPC_FRONT_ASS', BBPC_URL . 'assets/frontend/' );
119 define( 'BBPC_ADMIN_ASS', BBPC_ASSETS . 'admin/' );
120 define( 'BBPC_IMG', BBPC_ASSETS . 'img/' );
121 define( 'BBPC_VEND', BBPC_ASSETS . 'vendors/' );
122 }
123
124 /**
125 * File includes.
126 */
127 public function core_includes() {
128 require_once __DIR__ . '/includes/functions.php';
129 require_once __DIR__ . '/includes/admin/menu/Approve_Topic.php';
130 require_once __DIR__ . '/includes/admin/menu/Create_Forum.php';
131 require_once __DIR__ . '/includes/admin/menu/Create_Topic.php';
132 require_once __DIR__ . '/includes/admin/menu/Delete_Forum.php';
133 require_once __DIR__ . '/includes/admin/menu/Delete_Topic.php';
134 require_once __DIR__ . '/includes/Elementor/BBP_Widgets.php';
135 require_once __DIR__ . '/includes/ajax_actions.php';
136 include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
137 require_once __DIR__ . '/includes/Frontend/Assets.php';
138
139 require_once __DIR__ . '/widgets/widgets.php';
140 require_once __DIR__ . '/includes/Elementor/inc/forum-ajax.php';
141
142 // Core installer notice
143 require_once __DIR__ . '/includes/admin/notices/_notices.php';
144
145 //Register Pro Widgets
146 $theme = wp_get_theme();
147
148 if ( $theme->get( 'Name' ) != 'Ama' || ! bbpc_is_premium() ) {
149 require_once __DIR__ . '/includes/admin/Pro_Widget_Map.php';
150 require_once __DIR__ . '/includes/admin/Pro_Widget_Service.php';
151 }
152
153 // Hooks
154 require BBPC_DIR . 'includes/hooks/actions.php';
155 require BBPC_DIR . 'includes/hooks/image_sizes.php';
156 }
157
158 /**
159 * Initializing Bbp_core class.
160 *
161 * @return \Bbp_core
162 */
163 static function init() {
164 static $instance = false;
165
166 if ( ! $instance ) {
167 $instance = new self();
168 }
169 }
170
171 /**
172 * Actions on plugin activation.
173 *
174 * @return void
175 */
176 public function activate() {
177 $installed = get_option( 'bbpc_installed' );
178 if ( ! $installed ) {
179 update_option( 'bbpc_installed', time() );
180 }
181
182 update_option( 'bbpc_version', BBPC_VERSION );
183 // Ensure default option for bbp_core_settings
184 $defaults = array(
185 'is_bbpc_insert_media' => true,
186 );
187
188 $current = get_option( 'bbp_core_settings', array() );
189 $updated = wp_parse_args( $current, $defaults );
190
191 update_option( 'bbp_core_settings', $updated );
192 }
193
194 /**
195 * Initialize the plugin functionality.
196 *
197 * @return void
198 */
199 public function init_plugin() {
200
201 $this->load_features();
202
203 if ( is_admin() ) {
204 new Admin();
205 new admin\Assets();
206 } elseif ( ! is_admin() ) {
207 new Frontend\Assets();
208 }
209
210 // If bbPress is not active, don't load assets and widgets.
211 if ( ! class_exists( 'bbPress' ) ) {
212 return;
213 }
214
215 new admin\Elementor\BBP_Widgets();
216 }
217
218 /**
219 * Include CSF files include
220 */
221 public function load_csf_files(){
222 require BBPC_DIR . 'vendor/csf/classes/setup.class.php';
223 require BBPC_DIR . 'includes/admin/options/settings.php';
224 }
225
226 /**
227 * Load different features.
228 *
229 * @return void
230 */
231 public function load_features() {
232 define( 'BBPC_FEAT_PATH', plugin_dir_path( __FILE__ ) . 'includes/features/' );
233
234 if ( bbpc_get_opt( 'is_solved_topics', true ) ) {
235 require BBPC_FEAT_PATH . 'bbp_solved_topic.php';
236 }
237
238 if ( bbpc_get_opt( 'is_private_replies', true ) ) {
239 require BBPC_FEAT_PATH . 'bbp-private-replies.php';
240 }
241
242 if ( bbpc_is_premium() || class_exists( 'BBPC_GEO_ROLES' ) ) {
243 if ( bbpc_get_opt( 'agree_disagree_voting' ) ) {
244 require BBPC_FEAT_PATH . 'bbp_voting/agree-disagree/init.php';
245 require BBPC_FEAT_PATH . 'bbp_voting/agree-disagree/actions.php';
246 }
247 }
248
249 if ( bbpc_get_opt( 'is_votes', true ) ) {
250 new features\bbp_voting();
251 }
252
253 if ( bbpc_get_opt( 'is_attachment', true ) ) {
254 new features\bbp_attachments();
255 }
256 }
257
258 /**
259 * Documentation links to plugin row meta
260 */
261 public function bbpc_row_meta( $links, $file ) {
262 // Check if this is your plugin
263 if ( plugin_basename( __FILE__ ) === $file ) {
264 // Add your custom links
265 $plugin_links = array(
266 '<a href="https://helpdesk.spider-themes.net/docs/bbp-core-wordpress-plugin/" target="_blank">' . esc_html__('Documentation', 'bbp-core') . '</a>'
267 );
268 // Merge the custom links with the existing links
269 $links = array_merge( $links, $plugin_links );
270 }
271
272 return $links;
273 }
274 // end
275
276 }
277
278 /**
279 * Initialize the bbp core plugin.
280 *
281 * @return \Bbp_core
282 */
283 function bbp_core() {
284 return Bbp_core::init();
285 }
286
287 bbp_core();
288