PluginProbe
Forumax – AI Powered Advanced Community Forum Plugin / 2.0.0
Forumax – AI Powered Advanced Community Forum Plugin v2.0.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
bbp-core / forumax.php

forumax.php in Forumax – AI Powered Advanced Community Forum Plugin 2.0.0, at forumax.php

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