| 1 |
<?php |
| 2 |
namespace admin\Elementor; |
| 3 |
|
| 4 |
use admin\Pro_Widget_Map; |
| 5 |
|
| 6 |
class BBP_Widgets { |
| 7 |
|
| 8 |
public function __construct() { |
| 9 |
|
| 10 |
// Register Widgets |
| 11 |
add_action( 'elementor/widgets/widgets_registered', [ $this, 'register_widgets' ] ); |
| 12 |
|
| 13 |
// Register Category |
| 14 |
add_action( 'elementor/elements/categories_registered', [ $this, 'register_category' ] ); |
| 15 |
add_action( 'elementor/editor/before_enqueue_scripts', [ $this, 'register_elementor_editor_assets' ] ); |
| 16 |
|
| 17 |
// Register Elementor Preview Editor Scripts |
| 18 |
$currentTheme = wp_get_theme() == 'Ama' ? true : false; |
| 19 |
$returnType = bbpc_is_premium() == true ? true : $currentTheme; |
| 20 |
if ( $returnType != 1 ) { |
| 21 |
add_action('elementor/editor/after_enqueue_scripts', [$this, 'enqueue_editor_scripts']); |
| 22 |
} |
| 23 |
} |
| 24 |
|
| 25 |
|
| 26 |
/** |
| 27 |
* @return void |
| 28 |
* |
| 29 |
*/ |
| 30 |
public function enqueue_editor_scripts() { |
| 31 |
|
| 32 |
wp_enqueue_script('bbpc-el-editor', BBPC_ASSETS . 'admin/js/bbpc-el-editor.js', [], '1.0.0', true); |
| 33 |
|
| 34 |
$localize_data = []; |
| 35 |
$pro_widget_map = new Pro_Widget_Map(); |
| 36 |
$localize_data['promotional_widgets'] = $pro_widget_map->get_pro_widget_map(); |
| 37 |
wp_localize_script('bbpc-el-editor', 'BbpcConfig', $localize_data); |
| 38 |
} |
| 39 |
|
| 40 |
|
| 41 |
// Register Widgets |
| 42 |
public function register_widgets( $widgets_manager ) { |
| 43 |
|
| 44 |
$theme = wp_get_theme(); |
| 45 |
|
| 46 |
// Include Widget files |
| 47 |
if ( $theme == 'Ama' || bbpc_is_premium() ) { |
| 48 |
require_once( __DIR__ . '/Single_forum.php' ); |
| 49 |
require_once( __DIR__ . '/Forum_Ajax.php' ); |
| 50 |
require_once( __DIR__ . '/Forum_posts.php' ); |
| 51 |
require_once( __DIR__ . '/Forums.php' ); |
| 52 |
require_once( __DIR__ . '/Forum_Tab.php' ); |
| 53 |
require_once( __DIR__ . '/Search.php' ); |
| 54 |
|
| 55 |
$widgets_manager->register( new Single_forum() ); |
| 56 |
$widgets_manager->register( new Forum_Ajax() ); |
| 57 |
$widgets_manager->register( new Forum_posts() ); |
| 58 |
$widgets_manager->register( new Forums() ); |
| 59 |
$widgets_manager->register( new Forum_Tab() ); |
| 60 |
$widgets_manager->register( new Search() ); |
| 61 |
} |
| 62 |
} |
| 63 |
|
| 64 |
// Register category |
| 65 |
public function register_category( $elements_manager ) { |
| 66 |
$elements_manager->add_category( |
| 67 |
'bbp-core', [ |
| 68 |
'title' => __( 'BBP Core', 'bbp-core' ), |
| 69 |
] |
| 70 |
); |
| 71 |
} |
| 72 |
|
| 73 |
function register_elementor_editor_assets() { |
| 74 |
wp_enqueue_style( 'bbpc-el-editor', BBPC_ASSETS . 'css/elementor-editor.css' ); |
| 75 |
} |
| 76 |
} |