PluginProbe
Forumax – AI Powered Advanced Community Forum Plugin / 2.2.0
Forumax – AI Powered Advanced Community Forum Plugin v2.2.0
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
← All changes | forumax.php +272 -320 2.4.12.2.0 View file →
@@ -5,59 +5,58 @@
5 5 Description: Forumax is forum software for community discussions with public and private replies, private chats, voting, solved topics and more.
6 6 Author: spider-themes
7 7 Author URI: https://forumax.spider-themes.net/
8 8 Text Domain: forumax
9 -Version: 2.4.1
9 +Version: 2.2.0
10 10 Requires at least: 5.0
11 -Tested up to: 7.0
11 +Tested up to: 6.9
12 12 Requires PHP: 7.4
13 13 License: GPLv3 or later
14 14 License URI: https://www.gnu.org/licenses/gpl-3.0.html
15 15 */
16 16
17 -defined( 'ABSPATH' ) || exit;
17 +defined('ABSPATH') || exit;
18 18
19 19 // Load bbPress very early so other plugins (like docy-core) can detect it
20 20 // This must happen before the Forumax class to ensure proper load order
21 -if ( ! class_exists( 'bbPress' ) ) {
22 - require_once __DIR__ . '/lib/bbpress/bbpress.php';
21 +if (!class_exists('bbPress')) {
22 + require_once __DIR__ . '/vendor/bbpress/bbpress.php';
23 23 }
24 24
25 -if ( ! function_exists( 'bc_fs' ) ) {
25 +if (!function_exists('bc_fs')) {
26 26 // Create a helper function for easy SDK access.
27 - function bc_fs() {
27 + function bc_fs()
28 + {
28 29 global $bc_fs;
29 30
30 - if ( ! isset( $bc_fs ) ) {
31 + if (!isset($bc_fs)) {
31 32 // Include Freemius SDK.
32 - require_once __DIR__ . '/vendor/freemius/wordpress-sdk/start.php';
33 + require_once dirname(__FILE__) . '/vendor/fs/start.php';
33 34
34 - $bc_fs = fs_dynamic_init(
35 - array(
36 - 'id' => '10864',
37 - 'slug' => 'forumax',
38 - 'type' => 'plugin',
39 - 'public_key' => 'pk_41277ad11125f6e2a1b4e66f40164',
40 - 'is_premium' => false,
41 - 'is_premium_only' => false,
42 - 'has_addons' => false,
43 - 'has_paid_plans' => true,
44 - 'trial' => array(
45 - 'days' => 14,
46 - 'is_require_payment' => true,
47 - ),
48 - 'menu' => array(
49 - 'slug' => 'forumax',
50 - 'contact' => false,
51 - 'support' => false,
52 - 'first-path' => 'admin.php?page=forumax',
53 - ),
54 - 'parallel_activation' => array(
55 - 'enabled' => true,
56 - 'premium_version_basename' => 'forumax-premium/forumax.php',
57 - ),
58 - )
59 - );
35 + $bc_fs = fs_dynamic_init([
36 + 'id' => '10864',
37 + 'slug' => 'forumax',
38 + 'type' => 'plugin',
39 + 'public_key' => 'pk_41277ad11125f6e2a1b4e66f40164',
40 + 'is_premium' => false,
41 + 'is_premium_only' => false,
42 + 'has_addons' => false,
43 + 'has_paid_plans' => true,
44 + 'trial' => [
45 + 'days' => 14,
46 + 'is_require_payment' => true,
47 + ],
48 + 'menu' => [
49 + 'slug' => 'forumax',
50 + 'contact' => false,
51 + 'support' => false,
52 + 'first-path' => 'admin.php?page=forumax',
53 + ],
54 + 'parallel_activation' => [
55 + 'enabled' => true,
56 + 'premium_version_basename' => 'forumax-pro/forumax.php',
57 + ],
58 + ]);
60 59 }
61 60
62 61 return $bc_fs;
63 62 }
@@ -62,25 +61,22 @@
62 61 return $bc_fs;
63 62 }
64 63
65 64 // Add filter to hide the Freemius badge from the plugin page.
66 - bc_fs()->add_filter( 'hide_freemius_powered_by', '__return_true' );
65 + bc_fs()->add_filter('hide_freemius_powered_by', '__return_true');
67 66
68 67 // Suppress Freemius update row modification to avoid double notices or licensing nags on the plugins page.
69 - add_action(
70 - 'admin_init',
71 - function () {
72 - if ( function_exists( 'bc_fs' ) ) {
73 - $updater = FS_Plugin_Updater::instance( bc_fs() );
74 - $basename = bc_fs()->get_plugin_basename();
75 - remove_action( "after_plugin_row_{$basename}", array( $updater, 'catch_plugin_update_row' ), 9 );
76 - remove_action( "after_plugin_row_{$basename}", array( $updater, 'edit_and_echo_plugin_update_row' ), 11 );
77 - }
68 + add_action('admin_init', function () {
69 + if (function_exists('bc_fs')) {
70 + $updater = FS_Plugin_Updater::instance(bc_fs());
71 + $basename = bc_fs()->get_plugin_basename();
72 + remove_action("after_plugin_row_{$basename}", array($updater, 'catch_plugin_update_row'), 9);
73 + remove_action("after_plugin_row_{$basename}", array($updater, 'edit_and_echo_plugin_update_row'), 11);
78 74 }
79 - );
75 + });
80 76
81 77 // Signal that SDK was initiated.
82 - do_action( 'bc_fs_loaded' );
78 + do_action('bc_fs_loaded');
83 79 }
84 80
85 81 require_once __DIR__ . '/autoloader.php';
86 82
@@ -86,32 +82,32 @@
86 82
87 83 /**
88 84 * Plugin's heart
89 85 */
90 -final class Forumax {
86 +final class Forumax
87 +{
88 + const VERSION = '2.2.0';
91 89
92 - const VERSION = '2.4.1';
93 -
94 90 /**
95 91 * Class constructor.
96 92 */
97 - public function __construct() {
93 + public function __construct()
94 + {
98 95
99 96 $this->define_constants();
100 97 $this->core_includes();
101 98
102 - register_activation_hook( __FILE__, array( $this, 'activate' ) );
103 - register_deactivation_hook( __FILE__, array( $this, 'deactivate' ) );
104 - add_action( 'plugins_loaded', array( $this, 'init_plugin' ) );
105 - add_action( 'after_setup_theme', array( $this, 'load_csf_files' ), 20 );
106 - add_action( 'admin_init', array( $this, 'redirect_to_setup_wizard' ) );
99 + register_activation_hook(__FILE__, [$this, 'activate']);
100 + register_deactivation_hook(__FILE__, [$this, 'deactivate']);
101 + add_action('plugins_loaded', [$this, 'init_plugin']);
102 + add_action('after_setup_theme', [$this, 'load_csf_files'], 20);
107 103
108 104 // Added Documentation links to plugin row meta
109 - add_filter( 'plugin_row_meta', array( $this, 'forumax_row_meta' ), 10, 2 );
105 + add_filter('plugin_row_meta', [$this, 'forumax_row_meta'], 10, 2);
110 106
111 107 // Prevent deactivation if Forumax Pro is active
112 - add_action( 'admin_init', array( $this, 'prevent_deactivation_if_pro_active' ) );
113 - add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), array( $this, 'modify_deactivate_link' ), 10, 4 );
108 + add_action('admin_init', [$this, 'prevent_deactivation_if_pro_active']);
109 + add_filter('plugin_action_links_' . plugin_basename(__FILE__), [$this, 'modify_deactivate_link'], 10, 4);
114 110
115 111 /**
116 112 * Removes admin notices on the Forumax Forum builder page.
117 113 *
@@ -116,27 +112,24 @@
116 112 * Removes admin notices on the Forumax Forum builder page.
117 113 *
118 114 * @return void
119 115 */
120 - add_action(
121 - 'admin_head',
122 - function () {
123 - // Get the current screen
124 - $screen = get_current_screen();
116 + add_action('admin_head', function () {
117 + // Get the current screen
118 + $screen = get_current_screen();
125 119
126 - // Check if the current screen is for your plugin page
127 - if ( isset( $_GET['page'] ) && in_array( $_GET['page'], array( 'forumax', 'forumax-builder', 'forumax-settings' ), true ) ) {
128 - // Remove admin notices
129 - remove_all_actions( 'admin_notices' );
130 - remove_all_actions( 'all_admin_notices' );
120 + // Check if the current screen is for your plugin page
121 + if (isset($_GET['page']) && in_array($_GET['page'], ['forumax', 'forumax-builder'], true)) {
122 + // Remove admin notices
123 + remove_all_actions('admin_notices');
124 + remove_all_actions('all_admin_notices');
131 125
132 - // Re-add a specific notice
133 - if ( ! forumax_is_premium() && forumax_is_plugin_installed_for_days( 12 ) ) {
134 - add_action( 'admin_notices', 'forumax_offer_notice' );
135 - }
126 + // Re-add a specific notice
127 + if (!forumax_is_premium() && forumax_is_plugin_installed_for_days(12)) {
128 + add_action('admin_notices', 'forumax_offer_notice');
136 129 }
137 130 }
138 - );
131 + });
139 132 }
140 133
141 134 /**
142 135 * Define Plugin Constants.
@@ -142,26 +135,27 @@
142 135 * Define Plugin Constants.
143 136 *
144 137 * @return void
145 138 */
146 - public function define_constants() {
147 - define( 'FORUMAX_VERSION', self::VERSION );
148 - define( 'FORUMAX_FILE', __FILE__ );
149 - define( 'FORUMAX_DIR', __DIR__ . '/' );
150 - define( 'FORUMAX_PATH', FORUMAX_DIR );
151 - define( 'FORUMAX_URL', plugins_url( '/', __FILE__ ) );
152 - define( 'FORUMAX_ASSETS', FORUMAX_URL . 'assets/' );
153 - define( 'FORUMAX_FRONT_ASS', FORUMAX_URL . 'assets/frontend/' );
154 - define( 'FORUMAX_ADMIN_ASS', FORUMAX_ASSETS . 'admin/' );
155 - define( 'FORUMAX_STYLES', FORUMAX_URL . 'build/styles/' );
156 - define( 'FORUMAX_IMG', FORUMAX_ASSETS . 'img/' );
157 - define( 'FORUMAX_VEND', FORUMAX_ASSETS . 'vendors/' );
139 + public function define_constants()
140 + {
141 + define('FORUMAX_VERSION', self::VERSION);
142 + define('FORUMAX_FILE', __FILE__);
143 + define('FORUMAX_DIR', __DIR__ . '/');
144 + define('FORUMAX_PATH', FORUMAX_DIR);
145 + define('FORUMAX_URL', plugins_url('/', __FILE__));
146 + define('FORUMAX_ASSETS', FORUMAX_URL . 'assets/');
147 + define('FORUMAX_FRONT_ASS', FORUMAX_URL . 'assets/frontend/');
148 + define('FORUMAX_ADMIN_ASS', FORUMAX_ASSETS . 'admin/');
149 + define('FORUMAX_IMG', FORUMAX_ASSETS . 'img/');
150 + define('FORUMAX_VEND', FORUMAX_ASSETS . 'vendors/');
158 151 }
159 152
160 153 /**
161 154 * File includes.
162 155 */
163 - public function core_includes() {
156 + public function core_includes()
157 + {
164 158 // Smart bbPress nVerify compatibility layer
165 159 require_once __DIR__ . '/includes/sbv-compatibility.php';
166 160
167 161 // Docy Core compatibility layer (fixes Forums widget class not found error)
@@ -171,11 +165,8 @@
171 165
172 166 require_once __DIR__ . '/includes/template-functions.php';
173 167 require_once __DIR__ . '/includes/bbpress-config.php';
174 168
175 - // Full Site Editing (block theme) compatibility – fixes blank page with Twenty Twenty-Five etc.
176 - require_once __DIR__ . '/includes/fse-compatibility.php';
177 -
178 169 require_once __DIR__ . '/includes/admin/menu/Approve_Topic.php';
179 170 require_once __DIR__ . '/includes/admin/menu/Create_Forum.php';
180 171 require_once __DIR__ . '/includes/admin/menu/Create_Topic.php';
181 172 require_once __DIR__ . '/includes/admin/menu/Delete_Forum.php';
@@ -181,9 +172,9 @@
181 172 require_once __DIR__ . '/includes/admin/menu/Delete_Forum.php';
182 173 require_once __DIR__ . '/includes/admin/menu/Delete_Topic.php';
183 174 require_once __DIR__ . '/includes/Elementor/Forumax_Widgets.php';
184 175 require_once __DIR__ . '/includes/ajax_actions.php';
185 - include_once ABSPATH . 'wp-admin/includes/plugin.php';
176 + include_once(ABSPATH . 'wp-admin/includes/plugin.php');
186 177
187 178 require_once __DIR__ . '/widgets/widgets.php';
188 179 require_once __DIR__ . '/includes/Blocks/Blocks_Register.php';
189 180 new \admin\Blocks\Blocks_Register();
@@ -191,12 +182,12 @@
191 182
192 183 // Core installer notice
193 184 require_once __DIR__ . '/includes/admin/notices/_notices.php';
194 185
195 - // Register Pro Widgets
186 + //Register Pro Widgets
196 187 $theme = wp_get_theme();
197 188
198 - if ( 'Ama' !== $theme->get( 'Name' ) || ! forumax_is_premium() ) {
189 + if ('Ama' !== $theme->get('Name') || !forumax_is_premium()) {
199 190 require_once __DIR__ . '/includes/admin/Pro_El_Widget_Map.php';
200 191 require_once __DIR__ . '/includes/admin/Pro_El_Widget_Service.php';
201 192 }
202 193
@@ -212,12 +203,13 @@
212 203 * Initializing Forumax class.
213 204 *
214 205 * @return \Forumax
215 206 */
216 - static function init() {
207 + static function init()
208 + {
217 209 static $instance = false;
218 210
219 - if ( ! $instance ) {
211 + if (!$instance) {
220 212 $instance = new self();
221 213 }
222 214 }
223 215
@@ -225,31 +217,29 @@
225 217 * Actions on plugin activation.
226 218 *
227 219 * @return void
228 220 */
229 - public function activate() {
230 - $installed = get_option( 'bbpc_installed' );
231 - if ( ! $installed ) {
232 - update_option( 'bbpc_installed', time() );
221 + public function activate()
222 + {
223 + $installed = get_option('bbpc_installed');
224 + if (!$installed) {
225 + update_option('bbpc_installed', time());
233 226 }
234 227
235 - update_option( 'bbpc_version', FORUMAX_VERSION );
236 -
228 + update_option('bbpc_version', FORUMAX_VERSION);
229 +
237 230 // Ensure default option for forumax_settings
238 - $defaults = array(
231 + $defaults = [
239 232 'is_bbpc_insert_media' => false,
240 - );
233 + ];
241 234
242 - $current = get_option( 'bbp_core_settings', array() );
243 - $updated = wp_parse_args( $current, $defaults );
235 + $current = get_option('bbp_core_settings', []);
236 + $updated = wp_parse_args($current, $defaults);
244 237
245 - update_option( 'bbp_core_settings', $updated );
246 -
238 + update_option('bbp_core_settings', $updated);
239 +
247 240 // Migrate old docy-core widgets to Forumax widgets
248 241 $this->migrate_docy_core_widgets();
249 -
250 - // Set transient to redirect to setup wizard
251 - set_transient( 'forumax_activation_redirect', true, 30 );
252 242 }
253 243
254 244 /**
255 245 * Actions on plugin deactivation.
@@ -255,114 +245,73 @@
255 245 * Actions on plugin deactivation.
256 246 *
257 247 * @return void
258 248 */
259 - public function deactivate() {
260 - wp_clear_scheduled_hook( 'frmx_auto_close_stale_topics' );
249 + public function deactivate()
250 + {
251 + wp_clear_scheduled_hook('frmx_auto_close_stale_topics');
261 252 }
262 253
263 254 /**
264 - * Redirect to setup wizard after plugin activation.
265 - *
266 - * @return void
267 - */
268 - public function redirect_to_setup_wizard() {
269 - // Check if we should redirect
270 - if ( ! get_transient( 'forumax_activation_redirect' ) ) {
271 - return;
272 - }
273 -
274 - // Don't redirect if activating multiple plugins or doing ajax
275 - if ( isset( $_GET['activate-multi'] ) || wp_doing_ajax() ) {
276 - delete_transient( 'forumax_activation_redirect' );
277 - return;
278 - }
279 -
280 - // Don't redirect if user doesn't have permission
281 - if ( ! current_user_can( 'manage_options' ) ) {
282 - delete_transient( 'forumax_activation_redirect' );
283 - return;
284 - }
285 -
286 - // Don't redirect while Freemius SDK is in activation/opt-in mode.
287 - // Freemius removes all submenu pages during activation mode, so
288 - // redirecting to forumax-setup would hit a non-existent page and
289 - // trigger "Sorry, you are not allowed to access this page."
290 - // The transient is preserved so the redirect fires after the
291 - // user completes or skips the Freemius opt-in.
292 - if ( function_exists( 'bc_fs' ) && bc_fs()->is_activation_mode() ) {
293 - return;
294 - }
295 -
296 - // Delete the transient so we don't redirect again
297 - delete_transient( 'forumax_activation_redirect' );
298 -
299 - // Redirect to setup wizard
300 - wp_safe_redirect( admin_url( 'admin.php?page=forumax-setup' ) );
301 - exit;
302 - }
303 -
304 - /**
305 255 * Migrate old Docy Core Forums widgets to Forumax widgets
306 - *
256 + *
307 257 * This function automatically converts any existing docy-core Forums widgets
308 258 * to the new Forumax Forums List widgets to ensure seamless transition.
309 259 *
310 260 * @return void
311 261 */
312 - private function migrate_docy_core_widgets() {
262 + private function migrate_docy_core_widgets()
263 + {
313 264 // Get all sidebars and their widgets
314 - $sidebars_widgets = get_option( 'sidebars_widgets', array() );
315 - $widget_migrated = false;
265 + $sidebars_widgets = get_option('sidebars_widgets', []);
266 + $widget_migrated = false;
316 267
317 268 // Get old docy-core widget settings
318 269 // WordPress stores widget settings with lowercase class name and hyphens
319 270 $old_widget_option_key = 'widget_docycore-wpwidgets-forums';
320 - $old_widget_options = get_option( $old_widget_option_key, array() );
321 -
271 + $old_widget_options = get_option($old_widget_option_key, []);
272 +
322 273 // New Forumax widget option key
323 274 $new_widget_option_key = 'widget_forumax-wpwidgets-forumax_forums_list';
324 - $new_widget_options = get_option( $new_widget_option_key, array() );
275 + $new_widget_options = get_option($new_widget_option_key, []);
325 276
326 277 // Loop through each sidebar
327 - foreach ( $sidebars_widgets as $sidebar_id => $widgets ) {
328 - if ( $sidebar_id === 'wp_inactive_widgets' || $sidebar_id === 'array_version' || ! is_array( $widgets ) ) {
278 + foreach ($sidebars_widgets as $sidebar_id => $widgets) {
279 + if ($sidebar_id === 'wp_inactive_widgets' || $sidebar_id === 'array_version' || !is_array($widgets)) {
329 280 continue;
330 281 }
331 282
332 283 // Loop through widgets in this sidebar
333 - foreach ( $widgets as $key => $widget_id ) {
284 + foreach ($widgets as $key => $widget_id) {
334 285 // WordPress widget ID format: {widget_base_id}-{instance_number}
335 286 // Example: docycore-wpwidgets-forums-2
336 -
287 +
337 288 // Check if this is an old docy-core Forums widget
338 289 // Possible formats:
339 290 // - docycore-wpwidgets-forums-{number}
340 291 // - widget_docycore-wpwidgets-forums-{number}
341 - if ( preg_match( '/^(widget_)?docycore-wpwidgets-forums-(\d+)$/', $widget_id, $matches ) ) {
292 + if (preg_match('/^(widget_)?docycore-wpwidgets-forums-(\d+)$/', $widget_id, $matches)) {
342 293 $instance_number = $matches[2];
343 -
294 +
344 295 // Check if old widget has settings
345 - if ( isset( $old_widget_options[ $instance_number ] ) ) {
296 + if (isset($old_widget_options[$instance_number])) {
346 297 // Copy settings to new Forumax widget
347 - $new_widget_options[ $instance_number ] = $old_widget_options[ $instance_number ];
348 -
298 + $new_widget_options[$instance_number] = $old_widget_options[$instance_number];
299 +
349 300 // Update the widget ID in sidebar
350 301 // New format: forumax-wpwidgets-forumax_forums_list-{number}
351 - $new_widget_id = 'forumax-wpwidgets-forumax_forums_list-' . $instance_number;
352 - $sidebars_widgets[ $sidebar_id ][ $key ] = $new_widget_id;
353 -
302 + $new_widget_id = 'forumax-wpwidgets-forumax_forums_list-' . $instance_number;
303 + $sidebars_widgets[$sidebar_id][$key] = $new_widget_id;
304 +
354 305 $widget_migrated = true;
355 -
306 +
356 307 // Log migration (for debugging)
357 - error_log(
358 - sprintf(
359 - 'Forumax: Migrated widget from "%s" to "%s" in sidebar "%s"',
360 - $widget_id,
361 - $new_widget_id,
362 - $sidebar_id
363 - )
364 - );
308 + error_log(sprintf(
309 + 'Forumax: Migrated widget from "%s" to "%s" in sidebar "%s"',
310 + $widget_id,
311 + $new_widget_id,
312 + $sidebar_id
313 + ));
365 314 }
366 315 }
367 316 }
368 317 }
@@ -367,14 +316,14 @@
367 316 }
368 317 }
369 318
370 319 // Save updated widget options and sidebars if any widget was migrated
371 - if ( $widget_migrated ) {
372 - update_option( $new_widget_option_key, $new_widget_options );
373 - update_option( 'sidebars_widgets', $sidebars_widgets );
374 -
320 + if ($widget_migrated) {
321 + update_option($new_widget_option_key, $new_widget_options);
322 + update_option('sidebars_widgets', $sidebars_widgets);
323 +
375 324 // Log successful migration
376 - error_log( 'Forumax: Widget migration completed successfully' );
325 + error_log('Forumax: Widget migration completed successfully');
377 326 }
378 327 }
379 328
380 329
@@ -382,25 +331,26 @@
382 331 * Initialize the plugin functionality.
383 332 *
384 333 * @return void
385 334 */
386 - public function init_plugin() {
335 + public function init_plugin()
336 + {
387 337
388 338 $this->load_features();
389 339
390 - if ( is_admin() ) {
340 + if (is_admin()) {
391 341 new Admin();
392 342 new admin\Admin_Assets();
393 -
343 +
394 344 // Check for widget migration on every admin load (once per session)
395 345 // This catches cases where plugins were updated in wrong order
396 - add_action( 'admin_init', array( $this, 'check_widget_migration' ), 5 );
397 - } elseif ( ! is_admin() ) {
346 + add_action('admin_init', [$this, 'check_widget_migration'], 5);
347 + } elseif (!is_admin()) {
398 348 new Frontend\Frontend_Assets();
399 349 }
400 350
401 351 // If bbPress is not active, don't load assets and widgets.
402 - if ( ! class_exists( 'bbPress' ) || ! class_exists( 'Forumax' ) ) {
352 + if (!class_exists('bbPress') || !class_exists('Forumax')) {
403 353 return;
404 354 }
405 355
406 356 new admin\Elementor\Forumax_Widgets();
@@ -407,9 +357,9 @@
407 357 }
408 358
409 359 /**
410 360 * Check and run widget migration if needed
411 - *
361 + *
412 362 * This runs on admin_init to catch widgets that need migration
413 363 * even if the plugin was updated in the wrong order.
414 364 *
415 365 * @return void
@@ -417,81 +367,84 @@
417 367 public function check_widget_migration() {
418 368
419 369 /**
420 370 * forumax list widget id update
421 - *
422 371 * @var mixed
423 372 */
373 +
374 + $new_id = 'forumax_forums_list';
375 + $new_option_name = 'widget_' . $new_id;
376 + $new_data = get_option($new_option_name);
377 +
378 + if ( empty($new_data) || (is_array($new_data) && count($new_data) <= 1) ) {
379 +
380 +
381 + $docy_data = get_option('widget_forums');
382 +
383 +
384 + $docly_data = get_option('widget_doclycore\\wpwidgets\\forums_widget');
385 +
386 +
387 + $ama_data = get_option('widget_amacore\\wpwidgets\\forums_widget');
424 388
425 - $new_id = 'forumax_forums_list';
426 - $new_option_name = 'widget_' . $new_id;
427 - $new_data = get_option( $new_option_name );
428 -
429 - if ( empty( $new_data ) || ( is_array( $new_data ) && count( $new_data ) <= 1 ) ) {
430 -
431 - $docy_data = get_option( 'widget_forums' );
432 -
433 - $docly_data = get_option( 'widget_doclycore\\wpwidgets\\forums_widget' );
434 -
435 - $ama_data = get_option( 'widget_amacore\\wpwidgets\\forums_widget' );
436 -
437 - if ( ! empty( $docy_data ) && is_array( $docy_data ) && count( $docy_data ) > 1 ) {
438 - update_option( $new_option_name, $docy_data );
439 - } elseif ( ! empty( $docly_data ) && is_array( $docly_data ) && count( $docly_data ) > 1 ) {
440 - update_option( $new_option_name, $docly_data );
441 - } elseif ( ! empty( $ama_data ) && is_array( $ama_data ) && count( $ama_data ) > 1 ) {
442 - update_option( $new_option_name, $ama_data );
389 +
390 + if ( !empty($docy_data) && is_array($docy_data) && count($docy_data) > 1 ) {
391 + update_option($new_option_name, $docy_data);
392 + }
393 + elseif ( !empty($docly_data) && is_array($docly_data) && count($docly_data) > 1 ) {
394 + update_option($new_option_name, $docly_data);
443 395 }
396 + elseif ( !empty($ama_data) && is_array($ama_data) && count($ama_data) > 1 ) {
397 + update_option($new_option_name, $ama_data);
398 + }
444 399 }
445 400
401 +
446 402 // Check if migration has already been done
447 - $migration_done = get_option( 'forumax_widget_migration_done', false );
448 -
449 - if ( $migration_done ) {
403 + $migration_done = get_option('forumax_widget_migration_done', false);
404 +
405 + if ($migration_done) {
450 406 return; // Already migrated
451 407 }
452 -
408 +
453 409 // Check if there are any old docy-core widgets that need migration
454 - $sidebars_widgets = get_option( 'sidebars_widgets', array() );
455 - $needs_migration = false;
456 -
457 - foreach ( $sidebars_widgets as $sidebar_id => $widgets ) {
458 - if ( $sidebar_id === 'wp_inactive_widgets' || $sidebar_id === 'array_version' || ! is_array( $widgets ) ) {
410 + $sidebars_widgets = get_option('sidebars_widgets', []);
411 + $needs_migration = false;
412 +
413 + foreach ($sidebars_widgets as $sidebar_id => $widgets) {
414 + if ($sidebar_id === 'wp_inactive_widgets' || $sidebar_id === 'array_version' || !is_array($widgets)) {
459 415 continue;
460 416 }
461 -
462 - foreach ( $widgets as $widget_id ) {
463 - if ( preg_match( '/^(widget_)?docycore-wpwidgets-forums-(\d+)$/', $widget_id ) ) {
417 +
418 + foreach ($widgets as $widget_id) {
419 + if (preg_match('/^(widget_)?docycore-wpwidgets-forums-(\d+)$/', $widget_id)) {
464 420 $needs_migration = true;
465 421 break 2; // Break out of both loops
466 422 }
467 423 }
468 424 }
469 -
470 - if ( $needs_migration ) {
425 +
426 + if ($needs_migration) {
471 427 // Run migration
472 428 $this->migrate_docy_core_widgets();
473 -
429 +
474 430 // Mark as done
475 - update_option( 'forumax_widget_migration_done', true );
476 -
431 + update_option('forumax_widget_migration_done', true);
432 +
477 433 // Add admin notice
478 - add_action(
479 - 'admin_notices',
480 - function () {
481 - ?>
434 + add_action('admin_notices', function() {
435 + ?>
482 436 <div class="notice notice-success is-dismissible">
483 437 <p>
484 - <strong><?php esc_html_e( 'Forumax:', 'forumax' ); ?></strong>
485 - <?php esc_html_e( 'Your widgets have been automatically migrated from Docy Core to Forumax.', 'forumax' ); ?>
438 + <strong><?php esc_html_e('Forumax:', 'forumax'); ?></strong>
439 + <?php esc_html_e('Your widgets have been automatically migrated from Docy Core to Forumax.', 'forumax'); ?>
486 440 </p>
487 441 </div>
488 - <?php
489 - }
490 - );
442 + <?php
443 + });
491 444 } else {
492 445 // No migration needed, mark as done
493 - update_option( 'forumax_widget_migration_done', true );
446 + update_option('forumax_widget_migration_done', true);
494 447 }
495 448 }
496 449
497 450
@@ -497,10 +450,11 @@
497 450
498 451 /**
499 452 * Include CSF files include
500 453 */
501 - public function load_csf_files() {
502 - require FORUMAX_DIR . 'lib/csf/classes/setup.class.php';
454 + public function load_csf_files()
455 + {
456 + require FORUMAX_DIR . 'vendor/csf/classes/setup.class.php';
503 457 require FORUMAX_DIR . 'includes/admin/options/settings.php';
504 458 }
505 459
506 460 /**
@@ -507,12 +461,13 @@
507 461 * Load different features.
508 462 *
509 463 * @return void
510 464 */
511 - public function load_features() {
512 - define( 'FORUMAX_FEAT_PATH', plugin_dir_path( __FILE__ ) . 'includes/features/' );
465 + public function load_features()
466 + {
467 + define('FORUMAX_FEAT_PATH', plugin_dir_path(__FILE__) . 'includes/features/');
513 468
514 - if ( forumax_get_opt( 'is_solved_topics', true ) ) {
469 + if (forumax_get_opt('is_solved_topics', true)) {
515 470 require FORUMAX_FEAT_PATH . 'bbp_solved_topic.php';
516 471 }
517 472
518 473 // Auto Close Stale Topics
@@ -517,110 +472,106 @@
517 472
518 473 // Auto Close Stale Topics
519 474 require FORUMAX_FEAT_PATH . 'forumax_auto_close.php';
520 475
521 - if ( forumax_get_opt( 'is_private_replies', true ) ) {
476 + if (forumax_get_opt('is_private_replies', true)) {
522 477 require FORUMAX_FEAT_PATH . 'bbp-private-replies.php';
523 478 }
524 479
525 - if ( forumax_get_opt( 'is_votes', true ) ) {
480 + if (forumax_is_premium() || class_exists('BBPC_GEO_ROLES')) {
481 + if (forumax_get_opt('agree_disagree_voting')) {
482 + require FORUMAX_FEAT_PATH . 'bbp_voting/agree-disagree/init.php';
483 + require FORUMAX_FEAT_PATH . 'bbp_voting/agree-disagree/actions.php';
484 + }
485 + }
486 +
487 + if (forumax_get_opt('is_votes', true)) {
526 488 new features\bbp_voting();
527 489 }
528 490
529 - if ( forumax_get_opt( 'is_attachment', true ) ) {
491 + if (forumax_get_opt('is_attachment', true)) {
530 492 new features\bbp_attachments();
531 493 }
532 -
533 - /**
534 - * Action hook for Forumax premium plugin to load
535 - * premium-only features (Gamification, Nested Replies,
536 - * Agree/Disagree Voting, etc.).
537 - *
538 - * @since 2.3.0
539 - */
540 - do_action( 'forumax_load_premium_features' );
541 -
542 - // Custom Profile Avatar Upload.
543 - require_once FORUMAX_FEAT_PATH . 'frmx-profile-avatar.php';
544 -
545 - // Inline AJAX editing for topics.
546 - require_once FORUMAX_FEAT_PATH . 'frmx-inline-edit.php';
547 494 }
548 495
549 496 /**
550 497 * Documentation links to plugin row meta
551 498 */
552 - public function forumax_row_meta( $links, $file ) {
499 + public function forumax_row_meta($links, $file)
500 + {
553 501 // Check if this is your plugin
554 - if ( plugin_basename( __FILE__ ) === $file ) {
502 + if (plugin_basename(__FILE__) === $file) {
555 503 // Add your custom links
556 - $plugin_links = array(
557 - '<a href="https://helpdesk.spider-themes.net/docs/forumax-wordpress-plugin/" target="_blank">' . esc_html__( 'Documentation', 'forumax' ) . '</a>',
558 - );
504 + $plugin_links = [
505 + '<a href="https://helpdesk.spider-themes.net/docs/forumax-wordpress-plugin/" target="_blank">' . esc_html__('Documentation', 'forumax') . '</a>'
506 + ];
559 507 // Merge the custom links with the existing links
560 - $links = array_merge( $links, $plugin_links );
508 + $links = array_merge($links, $plugin_links);
561 509 }
562 510
563 511 return $links;
564 512 }
565 513
566 - /**
567 - * Prevent deactivation of Forumax if Forumax Pro is active
568 - * Users must deactivate Forumax Pro first before deactivating Forumax
569 - *
570 - * @return void
571 - */
572 - public function prevent_deactivation_if_pro_active() {
573 - // Check if we're on the plugins page
574 - if ( ! isset( $_SERVER['REQUEST_URI'] ) || strpos( $_SERVER['REQUEST_URI'], 'plugins.php' ) === false ) {
575 - return;
576 - }
514 +/**
515 + * Prevent deactivation of Forumax if Forumax Pro is active
516 + * Users must deactivate Forumax Pro first before deactivating Forumax
517 + *
518 + * @return void
519 + */
520 +public function prevent_deactivation_if_pro_active()
521 +{
522 + // Check if we're on the plugins page
523 + if (!isset($_SERVER['REQUEST_URI']) || strpos($_SERVER['REQUEST_URI'], 'plugins.php') === false) {
524 + return;
525 + }
577 526
578 - // Check if user is trying to deactivate this plugin
579 - if ( isset( $_GET['action'] ) && $_GET['action'] === 'deactivate' &&
580 - isset( $_GET['plugin'] ) && $_GET['plugin'] === plugin_basename( __FILE__ ) ) {
581 -
582 - // Check if Forumax Pro is active
583 - if ( is_plugin_active( 'forumax-premium/forumax.php' ) ) {
584 - // Prevent deactivation
585 - wp_die(
586 - '<h1>' . esc_html__( 'Cannot Deactivate Forumax', 'forumax' ) . '</h1>' .
587 - '<p>' . esc_html__( 'You cannot deactivate Forumax while Forumax Pro is active.', 'forumax' ) . '</p>' .
588 - '<p>' . esc_html__( 'Please deactivate Forumax Pro first, then you can deactivate Forumax.', 'forumax' ) . '</p>',
589 - esc_html__( 'Plugin Dependency Error', 'forumax' ),
590 - array( 'back_link' => true )
591 - );
592 - }
527 + // Check if user is trying to deactivate this plugin
528 + if (isset($_GET['action']) && $_GET['action'] === 'deactivate' &&
529 + isset($_GET['plugin']) && $_GET['plugin'] === plugin_basename(__FILE__)) {
530 +
531 + // Check if Forumax Pro is active
532 + if (is_plugin_active('forumax-pro/forumax.php')) {
533 + // Prevent deactivation
534 + wp_die(
535 + '<h1>' . esc_html__('Cannot Deactivate Forumax', 'forumax') . '</h1>' .
536 + '<p>' . esc_html__('You cannot deactivate Forumax while Forumax Pro is active.', 'forumax') . '</p>' .
537 + '<p>' . esc_html__('Please deactivate Forumax Pro first, then you can deactivate Forumax.', 'forumax') . '</p>',
538 + esc_html__('Plugin Dependency Error', 'forumax'),
539 + array('back_link' => true)
540 + );
593 541 }
594 542 }
543 +}
595 544
596 - /**
597 - * Modify the deactivate link to show a disabled state when Forumax Pro is active
598 - *
599 - * @param array $actions An array of plugin action links.
600 - * @param string $plugin_file Path to the plugin file relative to the plugins directory.
601 - * @param array $plugin_data An array of plugin data.
602 - * @param string $context The plugin context (active, inactive, etc).
603 - * @return array Modified action links
604 - */
605 - public function modify_deactivate_link( $actions, $plugin_file, $plugin_data, $context ) {
606 - // Check if Forumax Pro is active
607 - if ( is_plugin_active( 'forumax-premium/forumax.php' ) ) {
608 - // Remove the default deactivate link
609 - if ( isset( $actions['deactivate'] ) ) {
610 - unset( $actions['deactivate'] );
611 -
612 - // Add a disabled deactivate message
613 - $actions['deactivate_disabled'] = '<span style="color: #a0a5aa; cursor: not-allowed;" title="' .
614 - esc_attr__( 'Please deactivate Forumax Pro first', 'forumax' ) . '">' .
615 - esc_html__( 'Deactivate', 'forumax' ) .
616 - '</span>';
617 - }
545 +/**
546 + * Modify the deactivate link to show a disabled state when Forumax Pro is active
547 + *
548 + * @param array $actions An array of plugin action links.
549 + * @param string $plugin_file Path to the plugin file relative to the plugins directory.
550 + * @param array $plugin_data An array of plugin data.
551 + * @param string $context The plugin context (active, inactive, etc).
552 + * @return array Modified action links
553 + */
554 +public function modify_deactivate_link($actions, $plugin_file, $plugin_data, $context)
555 +{
556 + // Check if Forumax Pro is active
557 + if (is_plugin_active('forumax-pro/forumax.php')) {
558 + // Remove the default deactivate link
559 + if (isset($actions['deactivate'])) {
560 + unset($actions['deactivate']);
561 +
562 + // Add a disabled deactivate message
563 + $actions['deactivate_disabled'] = '<span style="color: #a0a5aa; cursor: not-allowed;" title="' .
564 + esc_attr__('Please deactivate Forumax Pro first', 'forumax') . '">' .
565 + esc_html__('Deactivate', 'forumax') .
566 + '</span>';
618 567 }
619 -
620 - return $actions;
621 568 }
569 +
570 + return $actions;
622 571 }
572 +
573 +}
623 574
624 575 /**
625 576 * Initialize the Forumax plugin.
626 577 *
@@ -625,9 +576,10 @@
625 576 * Initialize the Forumax plugin.
626 577 *
627 578 * @return \Forumax
628 579 */
629 -function forumax() {
580 +function forumax()
581 +{
630 582 return Forumax::init();
631 583 }
632 584
633 -forumax();
585 +forumax();