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

274 lines 8.9 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://profiles.wordpress.org/spiderdevs/
8 Text Domain: bbp-core
9 Version: 1.0.8
10 Requires at least: 5.0
11 Tested up to: 6.0.1
12 Requires PHP: 7.2
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__) . '/freemius/start.php';
27
28 $bc_fs = fs_dynamic_init( array(
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' => array(
38 'days' => 7,
39 'is_require_payment' => true,
40 ),
41 'menu' => array(
42 'slug' => 'bbp-core',
43 'support' => false,
44 'first-path' => 'admin.php?page=bbp-core',
45 ),
46 ) );
47 }
48
49 return $bc_fs;
50 }
51
52 // Init Freemius.
53 bc_fs()->add_filter( 'deactivate_on_activation', '__return_false' );
54
55 // Signal that SDK was initiated.
56 do_action( 'bc_fs_loaded' );
57 }
58
59 require_once __DIR__ . '/autoloader.php';
60
61 /**
62 * Plugin's heart
63 */
64 final class BBP_Core {
65 const VERSION = '1.0.0';
66
67 /**
68 * Class constructor.
69 */
70 public function __construct() {
71 $this->define_constants();
72 $this->core_includes();
73
74 register_activation_hook( __FILE__, [ $this, 'activate' ] );
75 add_action( 'wp_enqueue_scripts', [ $this, 'load_assets' ] );
76 add_action( 'admin_enqueue_scripts', [ $this, 'load_admin_scripts' ], 12 );
77
78 add_action( 'plugins_loaded', [ $this, 'init_plugin' ] );
79
80 $this->bbpc_hooks();
81 }
82
83 /**
84 * Define Plugin Constants.
85 *
86 * @return void
87 */
88 public function define_constants() {
89 define( 'BBPC_VERSION', self::VERSION );
90 define( 'BBPC_FILE', __FILE__ );
91 define( 'BBPC_DIR', __DIR__ . '/' );
92 define( 'BBPC_URL', plugins_url( '/', __FILE__ ) );
93 define( 'BBPC_ASSETS', BBPC_URL . 'assets/' );
94 define( 'BBPC_IMG', BBPC_ASSETS . 'img/' );
95 }
96
97 /**
98 * File includes.
99 */
100 public function core_includes() {
101 require_once BBPC_DIR . '/includes/functions.php';
102 require_once __DIR__ . '/includes/admin/menu/Approve_Topic.php';
103 require_once __DIR__ . '/includes/admin/menu/Create_Forum.php';
104 require_once __DIR__ . '/includes/admin/menu/Create_Topic.php';
105 require_once __DIR__ . '/includes/admin/menu/Delete_Forum.php';
106 require_once __DIR__ . '/includes/admin/menu/Delete_Topic.php';
107 }
108
109 /**
110 * Initializing Bbp_core class.
111 *
112 * @return \Bbp_core
113 */
114 static function init() {
115 static $instance = false;
116
117 if ( ! $instance ) {
118 $instance = new self();
119 }
120 }
121
122 /**
123 * Actions on plugin activation.
124 *
125 * @return void
126 */
127 public function activate() {
128 $installed = get_option( 'bbpc_installed' );
129 if ( ! $installed ) {
130 update_option( 'bbpc_installed', time() );
131 }
132
133 update_option( 'bbpc_version', BBPC_VERSION );
134 }
135
136 /**
137 * Initialize the plugin functionality.
138 *
139 * @return void
140 */
141 public function init_plugin() {
142 $this->load_features();
143
144 if ( is_admin() ) {
145 new Admin();
146 } else {
147 new Frontend();
148 }
149 }
150
151 /**
152 * Load different features.
153 *
154 * @return void
155 */
156 public function load_features() {
157 $opt = get_option( 'bbp_core_settings' );
158 define( 'BBPC_FEAT_PATH', plugin_dir_path( __FILE__ ) . 'includes/features/' );
159
160 if ( class_exists( 'bbPress' ) ) {
161 if ( $opt['is_solved_topics'] ?? true ) {
162 require BBPC_FEAT_PATH . 'bbp_solved_topic.php';
163 }
164
165 if ( $opt['is_private_replies'] ?? true ) {
166 require BBPC_FEAT_PATH . 'bbp-private-replies.php';
167 }
168
169 if ( $opt['is_votes'] ?? true ) {
170 new features\bbp_voting();
171 }
172
173 if ( $opt['is_attachment'] ?? true ) {
174 new features\bbp_attachments();
175 }
176 }
177 }
178
179 /**
180 * Load Necessary assets for the plugin.
181 *
182 * @return void
183 */
184 public function load_assets() {
185 wp_enqueue_style( 'bbpc', BBPC_ASSETS . 'css/bbpc.css' );
186 wp_enqueue_style( 'bbpc-voting', BBPC_ASSETS . 'css/bbpc-voting.css' );
187
188 // BBP Voting.
189 wp_enqueue_script( 'bbpc-voting', BBPC_ASSETS . 'js/bbpc-voting.js', [ 'jquery' ], BBPC_VERSION );
190 wp_localize_script( 'bbpc-voting', 'bbp_voting_ajax_object', [ 'ajax_url' => admin_url( 'admin-ajax.php' ) ] );
191 }
192
193 /**
194 * Load Admin Side styles and scripts.
195 *
196 * @return void
197 */
198 public function load_admin_scripts() {
199 wp_enqueue_style( 'bbpc-admin', BBPC_ASSETS . 'css/bbpc-admin.css' );
200 wp_enqueue_style( 'bbpc-admin-global', BBPC_ASSETS . 'css/admin-global.css' );
201
202 $current_url = ! empty( $_GET['page'] ) ? admin_url( 'admin.php?page=' ) . sanitize_text_field( wp_unslash( $_GET['page'] ) ) : '';
203 $bbp_core_url = admin_url( 'admin.php?page=bbp-core' );
204 $bbpc_settings_url = admin_url( 'admin.php?page=bbp-core-settings' );
205
206 if ( $bbp_core_url == $current_url ) {
207 wp_enqueue_style( 'normalize', BBPC_ASSETS . 'css/normalize.css' );
208 wp_enqueue_style( 'nice-select', BBPC_ASSETS . 'css/nice-select.css' );
209 wp_enqueue_style( 'jquery-ui', BBPC_ASSETS . 'css/admin-ui-style.css' );
210
211 // Scripts.
212 wp_enqueue_script( 'modernizr', BBPC_ASSETS . 'js/modernizr-3.11.2.min.js', [ 'jquery' ], '3.11.2', true );
213 wp_enqueue_script( 'jquery-ui', BBPC_ASSETS . 'js/jquery-ui.js', [ 'jquery' ], '1.12.1', true );
214 wp_enqueue_script( 'mixitup', BBPC_ASSETS . 'js/mixitup.min.js', [ 'jquery' ], '3.3.1', true );
215 wp_enqueue_script( 'mixitup-multifilter', BBPC_ASSETS . 'js/mixitup-multifilter.js', [ 'jquery' ], '3.3.1', true );
216 wp_enqueue_script( 'jquery-nice-select', BBPC_ASSETS . 'js/jquery.nice-select.min.js', [ 'jquery' ], '1.0', true );
217 wp_enqueue_script( 'tabby-polyfills', BBPC_ASSETS . 'js/tabby.polyfills.min.js', [ 'jquery' ], '1.0', true );
218 wp_enqueue_script( 'sortable', BBPC_ASSETS . 'js/Sortable.min.js', [ 'jquery' ], '1.0', true );
219 wp_enqueue_script( 'accordion', BBPC_ASSETS . 'js/accordion.min.js', [ 'jquery' ], '1.0', true );
220 wp_enqueue_script( 'bbpc-admin-main', BBPC_ASSETS . 'js/admin-main.js', [ 'jquery' ], '1.0', true );
221 wp_enqueue_script( 'sweetalert', BBPC_ASSETS . 'js/sweetalert.min.js', [ 'jquery' ], '1.0', true );
222
223 wp_localize_script(
224 'jquery',
225 'bbp_core_local_object',
226 [
227 'create_forum_title' => esc_html__( 'Enter Forum Title', 'bbp-core' ),
228 'create_topic_title' => esc_html__( 'Enter Topic Title', 'bbp-core' ),
229 'forum_delete_title' => esc_html__( 'Are you sure to delete?', 'bbp-core' ),
230 'forum_delete_desc' => esc_html__( "This forum will be deleted with all the topics and you won't be able to revert!", 'bbp-core' ),
231 'topic_delete_desc' => esc_html__( "This topic will be deleted and you won't be able to revert!", 'bbp-core' ),
232 'BBPC_ASSETS' => BBPC_ASSETS,
233 ]
234 );
235 }
236
237 if ( $bbpc_settings_url == $current_url ) {
238 wp_enqueue_style( 'sweetalert', BBPC_ASSETS . '/css/admin/sweetalert.css' );
239 wp_enqueue_script( 'sweetalert', BBPC_ASSETS . '/js/admin/sweetalert.min.js', [ 'jquery' ], true, true );
240 wp_enqueue_script( 'bbpc-admin-global', BBPC_ASSETS . 'js/admin-global.js', BBPC_VERSION );
241 }
242 }
243
244 /**
245 * Actions and filter hooks in BBP Core plugin.
246 *
247 * @return void
248 */
249 public function bbpc_hooks() {
250 require BBPC_DIR . 'includes/hooks/actions.php';
251 require BBPC_DIR . 'includes/hooks/image_sizes.php';
252 }
253 }
254
255 /**
256 * Initialize the bbp core plugin.
257 *
258 * @return \Bbp_core
259 */
260 function bbp_core() {
261 return Bbp_core::init();
262 }
263
264 bbp_core();
265
266 // TODO: Use topics, replies from gd bbpress plugin. Thumbnail, excerpt switcher in settings
267 // TODO: Move ama template designs to bbp core plugin, as forum theming, we will create multiple themeing for forums.
268 // TODO: Use pagination for topics, use bbp official pagination
269 //TODO: Design best answer of bbp core as bbp of docy
270 //TODO: When click on reply count, it will show the following replies, beside that, there will be pending replies.
271 //TODO: Test with official WordPress themes and other famous themes on worpdress repo.
272
273 //FIXME: Reply showing
274