| 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://spider-themes.net/bbp-core |
| 8 |
Text Domain: bbp-core |
| 9 |
Version: 1.2.6 |
| 10 |
Requires at least: 5.0 |
| 11 |
Tested up to: 6.6.1 |
| 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__ ) . '/includes/fs/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' => 14, |
| 39 |
'is_require_payment' => true, |
| 40 |
), |
| 41 |
'menu' => array( |
| 42 |
'slug' => 'bbp-core', |
| 43 |
'contact' => false, |
| 44 |
'support' => false, |
| 45 |
'first-path' => 'admin.php?page=bbp-core', |
| 46 |
), |
| 47 |
) ); |
| 48 |
} |
| 49 |
|
| 50 |
return $bc_fs; |
| 51 |
} |
| 52 |
|
| 53 |
// Init Freemius. |
| 54 |
bc_fs()->add_filter( 'deactivate_on_activation', '__return_false' ); |
| 55 |
|
| 56 |
// Signal that SDK was initiated. |
| 57 |
do_action( 'bc_fs_loaded' ); |
| 58 |
} |
| 59 |
|
| 60 |
require_once __DIR__ . '/autoloader.php'; |
| 61 |
|
| 62 |
|
| 63 |
/** |
| 64 |
* Plugin's heart |
| 65 |
*/ |
| 66 |
final class BBP_Core { |
| 67 |
const VERSION = '1.2.6'; |
| 68 |
|
| 69 |
/** |
| 70 |
* Class constructor. |
| 71 |
*/ |
| 72 |
public function __construct() { |
| 73 |
|
| 74 |
$this->define_constants(); |
| 75 |
$this->core_includes(); |
| 76 |
|
| 77 |
register_activation_hook( __FILE__, [ $this, 'activate' ] ); |
| 78 |
add_action( 'plugins_loaded', [ $this, 'init_plugin' ] ); |
| 79 |
|
| 80 |
// Added Documentation links to plugin row meta |
| 81 |
add_filter('plugin_row_meta',[ $this, 'bbpc_row_meta' ], 10, 2); |
| 82 |
} |
| 83 |
|
| 84 |
/** |
| 85 |
* Define Plugin Constants. |
| 86 |
* |
| 87 |
* @return void |
| 88 |
*/ |
| 89 |
public function define_constants() { |
| 90 |
define( 'BBPC_VERSION', self::VERSION ); |
| 91 |
define( 'BBPC_FILE', __FILE__ ); |
| 92 |
define( 'BBPC_DIR', __DIR__ . '/' ); |
| 93 |
define( 'BBPC_URL', plugins_url( '/', __FILE__ ) ); |
| 94 |
define( 'BBPC_ASSETS', BBPC_URL . 'assets/' ); |
| 95 |
define( 'BBPC_IMG', BBPC_ASSETS . 'img/' ); |
| 96 |
} |
| 97 |
|
| 98 |
/** |
| 99 |
* File includes. |
| 100 |
*/ |
| 101 |
public function core_includes() { |
| 102 |
require_once __DIR__ . '/includes/functions.php'; |
| 103 |
require_once __DIR__ . '/includes/admin/menu/Approve_Topic.php'; |
| 104 |
require_once __DIR__ . '/includes/admin/menu/Create_Forum.php'; |
| 105 |
require_once __DIR__ . '/includes/admin/menu/Create_Topic.php'; |
| 106 |
require_once __DIR__ . '/includes/admin/menu/Delete_Forum.php'; |
| 107 |
require_once __DIR__ . '/includes/admin/menu/Delete_Topic.php'; |
| 108 |
require_once __DIR__ . '/includes/Elementor/BBP_Widgets.php'; |
| 109 |
require_once __DIR__ . '/includes/ajax_actions.php'; |
| 110 |
include_once( ABSPATH . 'wp-admin/includes/plugin.php' ); |
| 111 |
require_once __DIR__ . '/includes/Frontend/Assets.php'; |
| 112 |
|
| 113 |
require_once __DIR__ . '/includes/admin/widgets/forum-info/widgets.php'; |
| 114 |
require_once __DIR__ . '/includes/Elementor/inc/forum-ajax.php'; |
| 115 |
|
| 116 |
// Core installer notice |
| 117 |
require_once __DIR__ . '/includes/admin/notices/notices.php'; |
| 118 |
require_once __DIR__ . '/includes/admin/notices/asking-for-review.php'; |
| 119 |
|
| 120 |
//Register Pro Widgets |
| 121 |
$theme = wp_get_theme(); |
| 122 |
|
| 123 |
if ( $theme != 'Ama' || ! bbpc_is_premium() ) { |
| 124 |
require_once __DIR__ . '/includes/admin/Pro_Widget_Map.php'; |
| 125 |
require_once __DIR__ . '/includes/admin/Pro_Widget_Service.php'; |
| 126 |
} |
| 127 |
|
| 128 |
// Hooks |
| 129 |
require BBPC_DIR . 'includes/hooks/actions.php'; |
| 130 |
require BBPC_DIR . 'includes/hooks/image_sizes.php'; |
| 131 |
|
| 132 |
// Load CSF |
| 133 |
require BBPC_DIR . 'includes/admin/settings/csf/classes/setup.class.php'; |
| 134 |
require BBPC_DIR . 'includes/admin/settings/options/settings.php'; |
| 135 |
} |
| 136 |
|
| 137 |
/** |
| 138 |
* Initializing Bbp_core class. |
| 139 |
* |
| 140 |
* @return \Bbp_core |
| 141 |
*/ |
| 142 |
static function init() { |
| 143 |
static $instance = false; |
| 144 |
|
| 145 |
if ( ! $instance ) { |
| 146 |
$instance = new self(); |
| 147 |
} |
| 148 |
} |
| 149 |
|
| 150 |
/** |
| 151 |
* Actions on plugin activation. |
| 152 |
* |
| 153 |
* @return void |
| 154 |
*/ |
| 155 |
public function activate() { |
| 156 |
$installed = get_option( 'bbpc_installed' ); |
| 157 |
if ( ! $installed ) { |
| 158 |
update_option( 'bbpc_installed', time() ); |
| 159 |
} |
| 160 |
|
| 161 |
update_option( 'bbpc_version', BBPC_VERSION ); |
| 162 |
} |
| 163 |
|
| 164 |
/** |
| 165 |
* Initialize the plugin functionality. |
| 166 |
* |
| 167 |
* @return void |
| 168 |
*/ |
| 169 |
public function init_plugin() { |
| 170 |
|
| 171 |
$this->load_features(); |
| 172 |
|
| 173 |
if ( is_admin() ) { |
| 174 |
new Admin(); |
| 175 |
new admin\Assets(); |
| 176 |
}elseif ( ! is_admin() ) { |
| 177 |
new Frontend\Assets(); |
| 178 |
} |
| 179 |
|
| 180 |
// If bbPress is not active, don't load assets and widgets. |
| 181 |
if ( ! class_exists( 'bbPress' ) ) { |
| 182 |
return; |
| 183 |
} |
| 184 |
new admin\Elementor\BBP_Widgets(); |
| 185 |
} |
| 186 |
|
| 187 |
|
| 188 |
/** |
| 189 |
* Load different features. |
| 190 |
* |
| 191 |
* @return void |
| 192 |
*/ |
| 193 |
public function load_features() { |
| 194 |
$opt = get_option( 'bbp_core_settings' ); |
| 195 |
define( 'BBPC_FEAT_PATH', plugin_dir_path( __FILE__ ) . 'includes/features/' ); |
| 196 |
|
| 197 |
if ( $opt['is_solved_topics'] ?? true ) { |
| 198 |
require BBPC_FEAT_PATH . 'bbp_solved_topic.php'; |
| 199 |
} |
| 200 |
|
| 201 |
if ( $opt['is_private_replies'] ?? true ) { |
| 202 |
require BBPC_FEAT_PATH . 'bbp-private-replies.php'; |
| 203 |
} |
| 204 |
|
| 205 |
if ( bbpc_is_premium() || class_exists('BBPC_GEO_ROLES') ) { |
| 206 |
$reactions = $opt['agree_disagree_voting'] ?? ''; |
| 207 |
if ( ! empty ( $reactions ) ) { |
| 208 |
require BBPC_FEAT_PATH . 'bbp_voting/agree-disagree/init.php'; |
| 209 |
require BBPC_FEAT_PATH . 'bbp_voting/agree-disagree/actions.php'; |
| 210 |
} |
| 211 |
} |
| 212 |
|
| 213 |
if ( $opt['is_votes'] ?? true ) { |
| 214 |
new features\bbp_voting(); |
| 215 |
} |
| 216 |
|
| 217 |
if ( $opt['is_attachment'] ?? true ) { |
| 218 |
new features\bbp_attachments(); |
| 219 |
} |
| 220 |
} |
| 221 |
|
| 222 |
/** |
| 223 |
* Documentation links to plugin row meta |
| 224 |
*/ |
| 225 |
public function bbpc_row_meta($links, $file) { |
| 226 |
// Check if this is your plugin |
| 227 |
if (plugin_basename(__FILE__) === $file) { |
| 228 |
// Add your custom links |
| 229 |
$plugin_links = array( |
| 230 |
'<a href="https://helpdesk.spider-themes.net/docs/bbp-core-wordpress-plugin/" target="_blank">Documentation</a>' |
| 231 |
); |
| 232 |
// Merge the custom links with the existing links |
| 233 |
$links = array_merge($links, $plugin_links); |
| 234 |
} |
| 235 |
return $links; |
| 236 |
} |
| 237 |
// end |
| 238 |
|
| 239 |
} |
| 240 |
|
| 241 |
/** |
| 242 |
* Initialize the bbp core plugin. |
| 243 |
* |
| 244 |
* @return \Bbp_core |
| 245 |
*/ |
| 246 |
function bbp_core() { |
| 247 |
return Bbp_core::init(); |
| 248 |
} |
| 249 |
|
| 250 |
bbp_core(); |