PluginProbe
Forumax – AI Powered Advanced Community Forum Plugin / 1.3.1
Forumax – AI Powered Advanced Community Forum Plugin v1.3.1
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.1, at bbp-core.php

292 lines 7.7 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://bbp-core.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://bbp-core.spider-themes.net
8 Text Domain: bbp-core
9 Version: 1.4.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 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 'parallel_activation' => array(
48 'enabled' => true,
49 'premium_version_basename' => 'bbp-core-pro/bbp-core.php',
50 ),
51 ] );
52 }
53
54 return $bc_fs;
55 }
56
57 // Add filter to hide the Freemius badge from the plugin page.
58 bc_fs()->add_filter( 'hide_freemius_powered_by', '__return_true' );
59
60 // Signal that SDK was initiated.
61 do_action( 'bc_fs_loaded' );
62 }
63
64
65 require_once __DIR__ . '/autoloader.php';
66
67 /**
68 * Plugin's heart
69 */
70 final class BBP_Core {
71 const VERSION = '1.4.0';
72
73 /**
74 * Class constructor.
75 */
76 public function __construct() {
77
78 $this->define_constants();
79 $this->core_includes();
80
81 register_activation_hook( __FILE__, [ $this, 'activate' ] );
82 add_action( 'plugins_loaded', [ $this, 'init_plugin' ] );
83 add_action( 'after_setup_theme', [ $this, 'load_csf_files' ], 20 );
84
85 // Added Documentation links to plugin row meta
86 add_filter( 'plugin_row_meta', [ $this, 'bbpc_row_meta' ], 10, 2 );
87
88 /**
89 * Removes admin notices on the BBP Core Forum builder page.
90 *
91 * @return void
92 */
93 add_action( 'admin_head', function () {
94 // Get the current screen
95 $screen = get_current_screen();
96
97 // Check if the current screen is for your plugin page
98 if ( isset( $_GET['page'] ) && in_array( $_GET['page'], [ 'bbp-core' ] ) ) {
99 // Remove admin notices
100 remove_all_actions( 'admin_notices' );
101 remove_all_actions( 'all_admin_notices' );
102
103 // Re-add a specific notice
104 if ( ! bbpc_is_premium() && bbpc_is_plugin_installed_for_days( 12 ) ) {
105 add_action( 'admin_notices', 'bbpc_offer_notice' );
106 }
107 }
108 } );
109 }
110
111 /**
112 * Define Plugin Constants.
113 *
114 * @return void
115 */
116 public function define_constants() {
117 define( 'BBPC_VERSION', self::VERSION );
118 define( 'BBPC_FILE', __FILE__ );
119 define( 'BBPC_DIR', __DIR__ . '/' );
120 define( 'BBPC_URL', plugins_url( '/', __FILE__ ) );
121 define( 'BBPC_ASSETS', BBPC_URL . 'assets/' );
122 define( 'BBPC_FRONT_ASS', BBPC_URL . 'assets/frontend/' );
123 define( 'BBPC_ADMIN_ASS', BBPC_ASSETS . 'admin/' );
124 define( 'BBPC_IMG', BBPC_ASSETS . 'img/' );
125 define( 'BBPC_VEND', BBPC_ASSETS . 'vendors/' );
126 }
127
128 /**
129 * File includes.
130 */
131 public function core_includes() {
132 require_once __DIR__ . '/includes/functions.php';
133 require_once __DIR__ . '/includes/admin/menu/Approve_Topic.php';
134 require_once __DIR__ . '/includes/admin/menu/Create_Forum.php';
135 require_once __DIR__ . '/includes/admin/menu/Create_Topic.php';
136 require_once __DIR__ . '/includes/admin/menu/Delete_Forum.php';
137 require_once __DIR__ . '/includes/admin/menu/Delete_Topic.php';
138 require_once __DIR__ . '/includes/Elementor/BBP_Widgets.php';
139 require_once __DIR__ . '/includes/ajax_actions.php';
140 include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
141 require_once __DIR__ . '/includes/Frontend/Assets.php';
142
143 require_once __DIR__ . '/widgets/widgets.php';
144 require_once __DIR__ . '/includes/Elementor/inc/forum-ajax.php';
145
146 // Core installer notice
147 require_once __DIR__ . '/includes/admin/notices/_notices.php';
148
149 //Register Pro Widgets
150 $theme = wp_get_theme();
151
152 if ( $theme->get( 'Name' ) != 'Ama' || ! bbpc_is_premium() ) {
153 require_once __DIR__ . '/includes/admin/Pro_Widget_Map.php';
154 require_once __DIR__ . '/includes/admin/Pro_Widget_Service.php';
155 }
156
157 // Hooks
158 require BBPC_DIR . 'includes/hooks/actions.php';
159 require BBPC_DIR . 'includes/hooks/image_sizes.php';
160 }
161
162 /**
163 * Initializing Bbp_core class.
164 *
165 * @return \Bbp_core
166 */
167 static function init() {
168 static $instance = false;
169
170 if ( ! $instance ) {
171 $instance = new self();
172 }
173 }
174
175 /**
176 * Actions on plugin activation.
177 *
178 * @return void
179 */
180 public function activate() {
181 $installed = get_option( 'bbpc_installed' );
182 if ( ! $installed ) {
183 update_option( 'bbpc_installed', time() );
184 }
185
186 update_option( 'bbpc_version', BBPC_VERSION );
187 // Ensure default option for bbp_core_settings
188 $defaults = array(
189 'is_bbpc_insert_media' => true,
190 );
191
192 $current = get_option( 'bbp_core_settings', array() );
193 $updated = wp_parse_args( $current, $defaults );
194
195 update_option( 'bbp_core_settings', $updated );
196 }
197
198 /**
199 * Initialize the plugin functionality.
200 *
201 * @return void
202 */
203 public function init_plugin() {
204
205 $this->load_features();
206
207 if ( is_admin() ) {
208 new Admin();
209 new admin\Assets();
210 } elseif ( ! is_admin() ) {
211 new Frontend\Assets();
212 }
213
214 // If bbPress is not active, don't load assets and widgets.
215 if ( ! class_exists( 'bbPress' ) ) {
216 return;
217 }
218
219 new admin\Elementor\BBP_Widgets();
220 }
221
222 /**
223 * Include CSF files include
224 */
225 public function load_csf_files(){
226 require BBPC_DIR . 'vendor/csf/classes/setup.class.php';
227 require BBPC_DIR . 'includes/admin/options/settings.php';
228 }
229
230 /**
231 * Load different features.
232 *
233 * @return void
234 */
235 public function load_features() {
236 define( 'BBPC_FEAT_PATH', plugin_dir_path( __FILE__ ) . 'includes/features/' );
237
238 if ( bbpc_get_opt( 'is_solved_topics', true ) ) {
239 require BBPC_FEAT_PATH . 'bbp_solved_topic.php';
240 }
241
242 if ( bbpc_get_opt( 'is_private_replies', true ) ) {
243 require BBPC_FEAT_PATH . 'bbp-private-replies.php';
244 }
245
246 if ( bbpc_is_premium() || class_exists( 'BBPC_GEO_ROLES' ) ) {
247 if ( bbpc_get_opt( 'agree_disagree_voting' ) ) {
248 require BBPC_FEAT_PATH . 'bbp_voting/agree-disagree/init.php';
249 require BBPC_FEAT_PATH . 'bbp_voting/agree-disagree/actions.php';
250 }
251 }
252
253 if ( bbpc_get_opt( 'is_votes', true ) ) {
254 new features\bbp_voting();
255 }
256
257 if ( bbpc_get_opt( 'is_attachment', true ) ) {
258 new features\bbp_attachments();
259 }
260 }
261
262 /**
263 * Documentation links to plugin row meta
264 */
265 public function bbpc_row_meta( $links, $file ) {
266 // Check if this is your plugin
267 if ( plugin_basename( __FILE__ ) === $file ) {
268 // Add your custom links
269 $plugin_links = array(
270 '<a href="https://helpdesk.spider-themes.net/docs/bbp-core-wordpress-plugin/" target="_blank">' . esc_html__('Documentation', 'bbp-core') . '</a>'
271 );
272 // Merge the custom links with the existing links
273 $links = array_merge( $links, $plugin_links );
274 }
275
276 return $links;
277 }
278 // end
279
280 }
281
282 /**
283 * Initialize the bbp core plugin.
284 *
285 * @return \Bbp_core
286 */
287 function bbp_core() {
288 return Bbp_core::init();
289 }
290
291 bbp_core();
292