| @@ -5,11 +5,11 @@ | ||
| 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.0 | |
| 9 | +Version: 2.5.0 | |
| 10 | 10 | Requires at least: 5.0 |
| 11 | -Tested up to: 7.0 | |
| 11 | +Tested up to: 7.1.2 | |
| 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 | */ |
| @@ -21,9 +21,14 @@ | ||
| 21 | 21 | if ( ! class_exists( 'bbPress' ) ) { |
| 22 | 22 | require_once __DIR__ . '/lib/bbpress/bbpress.php'; |
| 23 | 23 | } |
| 24 | 24 | |
| 25 | -if ( ! function_exists( 'bc_fs' ) ) { | |
| 25 | +if ( function_exists( 'bc_fs' ) ) { | |
| 26 | + // Forumax Pro already booted the Freemius SDK. Register this (free) plugin's | |
| 27 | + // file with the shared instance instead of initializing a second time. This | |
| 28 | + // keeps the free/premium pairing working regardless of which plugin loads first. | |
| 29 | + bc_fs()->set_basename( false, __FILE__ ); | |
| 30 | +} else { | |
| 26 | 31 | // Create a helper function for easy SDK access. |
| 27 | 32 | function bc_fs() { |
| 28 | 33 | global $bc_fs; |
| 29 | 34 | |
| @@ -34,14 +39,20 @@ | ||
| 34 | 39 | $bc_fs = fs_dynamic_init( |
| 35 | 40 | array( |
| 36 | 41 | 'id' => '10864', |
| 37 | 42 | 'slug' => 'forumax', |
| 43 | + 'premium_slug' => 'forumax-premium', | |
| 38 | 44 | 'type' => 'plugin', |
| 39 | 45 | 'public_key' => 'pk_41277ad11125f6e2a1b4e66f40164', |
| 40 | 46 | 'is_premium' => false, |
| 41 | - 'is_premium_only' => false, | |
| 47 | + 'premium_suffix' => 'Pro', | |
| 48 | + 'has_premium_version' => true, | |
| 42 | 49 | 'has_addons' => false, |
| 43 | 50 | 'has_paid_plans' => true, |
| 51 | + 'parallel_activation' => array( | |
| 52 | + 'enabled' => true, | |
| 53 | + 'premium_version_basename' => 'forumax-premium/forumax.php', | |
| 54 | + ), | |
| 44 | 55 | 'trial' => array( |
| 45 | 56 | 'days' => 14, |
| 46 | 57 | 'is_require_payment' => true, |
| 47 | 58 | ), |
| @@ -50,12 +61,8 @@ | ||
| 50 | 61 | 'contact' => false, |
| 51 | 62 | 'support' => false, |
| 52 | 63 | 'first-path' => 'admin.php?page=forumax', |
| 53 | 64 | ), |
| 54 | - 'parallel_activation' => array( | |
| 55 | - 'enabled' => true, | |
| 56 | - 'premium_version_basename' => 'forumax-premium/forumax.php', | |
| 57 | - ), | |
| 58 | 65 | ) |
| 59 | 66 | ); |
| 60 | 67 | } |
| 61 | 68 | |
| @@ -64,8 +71,17 @@ | ||
| 64 | 71 | |
| 65 | 72 | // Add filter to hide the Freemius badge from the plugin page. |
| 66 | 73 | bc_fs()->add_filter( 'hide_freemius_powered_by', '__return_true' ); |
| 67 | 74 | |
| 75 | + // Disclose that opting in also pre-fills the in-plugin support chat | |
| 76 | + // (see the Support Assistant class). The on-update screen falls back to this filter. | |
| 77 | + bc_fs()->add_filter( 'connect_message', function ( $message ) { | |
| 78 | + return $message . '<br><br>' . esc_html__( 'Opting in also pre-fills your name and email in the Forumax support chat, so you can get help without typing them. They are only sent to our helpdesk when you open the chat.', 'forumax' ); | |
| 79 | + } ); | |
| 80 | + | |
| 81 | + // Keep the free and premium versions from auto-deactivating each other. | |
| 82 | + bc_fs()->add_filter( 'deactivate_on_activation', '__return_false' ); | |
| 83 | + | |
| 68 | 84 | // Suppress Freemius update row modification to avoid double notices or licensing nags on the plugins page. |
| 69 | 85 | add_action( |
| 70 | 86 | 'admin_init', |
| 71 | 87 | function () { |
| @@ -88,9 +104,9 @@ | ||
| 88 | 104 | * Plugin's heart |
| 89 | 105 | */ |
| 90 | 106 | final class Forumax { |
| 91 | 107 | |
| 92 | - const VERSION = '2.4.0'; | |
| 108 | + const VERSION = '2.5.0'; | |
| 93 | 109 | |
| 94 | 110 | /** |
| 95 | 111 | * Class constructor. |
| 96 | 112 | */ |
| @@ -103,8 +119,9 @@ | ||
| 103 | 119 | register_deactivation_hook( __FILE__, array( $this, 'deactivate' ) ); |
| 104 | 120 | add_action( 'plugins_loaded', array( $this, 'init_plugin' ) ); |
| 105 | 121 | add_action( 'after_setup_theme', array( $this, 'load_csf_files' ), 20 ); |
| 106 | 122 | add_action( 'admin_init', array( $this, 'redirect_to_setup_wizard' ) ); |
| 123 | + add_action( 'upgrader_process_complete', array( $this, 'migrate_plugin_basename' ), 10, 2 ); | |
| 107 | 124 | |
| 108 | 125 | // Added Documentation links to plugin row meta |
| 109 | 126 | add_filter( 'plugin_row_meta', array( $this, 'forumax_row_meta' ), 10, 2 ); |
| 110 | 127 | |
| @@ -166,8 +183,14 @@ | ||
| 166 | 183 | |
| 167 | 184 | // Docy Core compatibility layer (fixes Forums widget class not found error) |
| 168 | 185 | require_once __DIR__ . '/includes/docy-core-compatibility.php'; |
| 169 | 186 | |
| 187 | + // Keep single-topic theme-compat from loading every topic/reply. | |
| 188 | + require_once __DIR__ . '/includes/topic-render-guard.php'; | |
| 189 | + | |
| 190 | + // Stop EazyDocs is_super_admin() from recursing during author cap checks. | |
| 191 | + require_once __DIR__ . '/includes/eazydocs-compatibility.php'; | |
| 192 | + | |
| 170 | 193 | require_once __DIR__ . '/includes/functions.php'; |
| 171 | 194 | |
| 172 | 195 | require_once __DIR__ . '/includes/template-functions.php'; |
| 173 | 196 | require_once __DIR__ . '/includes/bbpress-config.php'; |
| @@ -301,8 +324,48 @@ | ||
| 301 | 324 | exit; |
| 302 | 325 | } |
| 303 | 326 | |
| 304 | 327 | /** |
| 328 | + * Migrate plugin basename if the folder name changes during update. | |
| 329 | + * | |
| 330 | + * @param WP_Upgrader $upgrader_object | |
| 331 | + * @param array $options | |
| 332 | + * @return void | |
| 333 | + */ | |
| 334 | + public function migrate_plugin_basename( $upgrader_object, $options ) { | |
| 335 | + if ( isset( $options['action'] ) && $options['action'] === 'update' && isset( $options['type'] ) && $options['type'] === 'plugin' ) { | |
| 336 | + $active_plugins = get_option( 'active_plugins' ); | |
| 337 | + if ( ! is_array( $active_plugins ) ) { | |
| 338 | + return; | |
| 339 | + } | |
| 340 | + | |
| 341 | + $changed = false; | |
| 342 | + $migrations = array( | |
| 343 | + 'bbp-core/bbp-core.php' => 'forumax/forumax.php', | |
| 344 | + 'bbp-core/forumax.php' => 'forumax/forumax.php', | |
| 345 | + 'bbp-core-pro/bbp-core.php' => 'forumax-pro/forumax.php', | |
| 346 | + 'forumax-premium/bbp-core.php' => 'forumax-pro/forumax.php', | |
| 347 | + 'forumax-premium/forumax.php' => 'forumax-pro/forumax.php', | |
| 348 | + ); | |
| 349 | + | |
| 350 | + foreach ( $migrations as $old_basename => $new_basename ) { | |
| 351 | + $key = array_search( $old_basename, $active_plugins, true ); | |
| 352 | + if ( false !== $key ) { | |
| 353 | + // Only migrate if the new file actually exists. | |
| 354 | + if ( file_exists( WP_PLUGIN_DIR . '/' . $new_basename ) ) { | |
| 355 | + $active_plugins[ $key ] = $new_basename; | |
| 356 | + $changed = true; | |
| 357 | + } | |
| 358 | + } | |
| 359 | + } | |
| 360 | + | |
| 361 | + if ( $changed ) { | |
| 362 | + update_option( 'active_plugins', array_values( $active_plugins ) ); | |
| 363 | + } | |
| 364 | + } | |
| 365 | + } | |
| 366 | + | |
| 367 | + /** | |
| 305 | 368 | * Migrate old Docy Core Forums widgets to Forumax widgets |
| 306 | 369 | * |
| 307 | 370 | * This function automatically converts any existing docy-core Forums widgets |
| 308 | 371 | * to the new Forumax Forums List widgets to ensure seamless transition. |
| @@ -389,8 +452,12 @@ | ||
| 389 | 452 | |
| 390 | 453 | if ( is_admin() ) { |
| 391 | 454 | new Admin(); |
| 392 | 455 | new admin\Admin_Assets(); |
| 456 | + | |
| 457 | + // Helpdesk docs assistant on Forumax admin pages. | |
| 458 | + require_once __DIR__ . '/includes/admin/class-support-assistant.php'; | |
| 459 | + \Forumax_Support_Assistant::get_instance(); | |
| 393 | 460 | |
| 394 | 461 | // Check for widget migration on every admin load (once per session) |
| 395 | 462 | // This catches cases where plugins were updated in wrong order |
| 396 | 463 | add_action( 'admin_init', array( $this, 'check_widget_migration' ), 5 ); |