| 1 |
<?php |
| 2 |
namespace admin\Elementor; |
| 3 |
|
| 4 |
use admin\Pro_El_Widget_Map; |
| 5 |
|
| 6 |
class Forumax_Widgets { |
| 7 |
public function __construct() { |
| 8 |
|
| 9 |
// Register Widgets |
| 10 |
add_action( 'elementor/widgets/register', [ $this, 'register_widgets' ] ); |
| 11 |
|
| 12 |
// Register Category |
| 13 |
add_action( 'elementor/elements/categories_registered', [ $this, 'register_category' ] ); |
| 14 |
add_action( 'elementor/editor/before_enqueue_scripts', [ $this, 'register_elementor_editor_assets' ] ); |
| 15 |
add_action( 'wp_enqueue_scripts', [ $this, 'register_widget_assets' ], 5 ); |
| 16 |
add_action( 'elementor/editor/before_enqueue_scripts', [ $this, 'register_widget_assets' ] ); |
| 17 |
|
| 18 |
// Register Elementor Preview Editor Scripts |
| 19 |
$current_theme = wp_get_theme()->get( 'Name' ) == 'Ama' ? true : false; |
| 20 |
$return_type = forumax_is_premium() == true ? true : $current_theme; |
| 21 |
if ($return_type != 1) { |
| 22 |
add_action( 'elementor/editor/after_enqueue_scripts', [ $this, 'enqueue_editor_scripts' ] ); |
| 23 |
} |
| 24 |
} |
| 25 |
|
| 26 |
|
| 27 |
/** |
| 28 |
* @return void |
| 29 |
* |
| 30 |
*/ |
| 31 |
public function enqueue_editor_scripts() { |
| 32 |
|
| 33 |
wp_enqueue_script( 'bbpc-el-editor', FORUMAX_ASSETS . 'admin/js/bbpc-el-editor.js', [], '1.0.0', true ); |
| 34 |
|
| 35 |
$localize_data = []; |
| 36 |
$pro_widget_map = new Pro_El_Widget_Map(); |
| 37 |
$localize_data['promotional_widgets'] = $pro_widget_map->get_pro_widget_map(); |
| 38 |
wp_localize_script( 'bbpc-el-editor', 'BbpcConfig', $localize_data ); |
| 39 |
} |
| 40 |
|
| 41 |
|
| 42 |
// Register Widgets |
| 43 |
public function register_widgets( $widgets_manager ) { |
| 44 |
|
| 45 |
$theme = wp_get_theme(); |
| 46 |
|
| 47 |
// Include Widget files |
| 48 |
if ($theme == 'Ama' || forumax_is_premium()) { |
| 49 |
require_once __DIR__ . '/Single_forum.php'; |
| 50 |
require_once __DIR__ . '/Forum_Ajax.php'; |
| 51 |
require_once __DIR__ . '/Forum_Tab.php'; |
| 52 |
require_once __DIR__ . '/Search.php'; |
| 53 |
|
| 54 |
$widgets_manager->register( new Single_forum() ); |
| 55 |
$widgets_manager->register( new Forum_Ajax() ); |
| 56 |
$widgets_manager->register( new Forum_Tab() ); |
| 57 |
$widgets_manager->register( new Search() ); |
| 58 |
} |
| 59 |
|
| 60 |
if ($theme == 'Docy') { |
| 61 |
require_once __DIR__ . '/Single_forum.php'; |
| 62 |
$widgets_manager->register( new Single_forum() ); |
| 63 |
} |
| 64 |
|
| 65 |
// Docy theme widgets - always load (work with any theme) |
| 66 |
require_once __DIR__ . '/Forumax_Forums.php'; |
| 67 |
require_once __DIR__ . '/Forumax_Topics.php'; |
| 68 |
|
| 69 |
$widgets_manager->register( new Forumax_Forums() ); |
| 70 |
$widgets_manager->register( new Forumax_Topics() ); |
| 71 |
} |
| 72 |
|
| 73 |
// Register category |
| 74 |
public function register_category( $elements_manager ) { |
| 75 |
$elements_manager->add_category( |
| 76 |
'forumax', |
| 77 |
[ |
| 78 |
'title' => __( 'Forumax', 'forumax' ), |
| 79 |
] |
| 80 |
); |
| 81 |
} |
| 82 |
|
| 83 |
public function register_elementor_editor_assets() { |
| 84 |
wp_enqueue_style( 'bbpc-el-editor', FORUMAX_ADMIN_ASS . 'css/elementor-editor.css' ); |
| 85 |
} |
| 86 |
|
| 87 |
public function register_widget_assets() { |
| 88 |
wp_register_style( 'bbpc-el-widgets', FORUMAX_STYLES . 'frontend/el-widgets.css', [], FORUMAX_VERSION ); |
| 89 |
wp_register_style( 'elegant-icon', FORUMAX_VEND . 'elegant-icon/style.css' ); |
| 90 |
wp_register_script( 'bbpc-forumTab', FORUMAX_FRONT_ASS . 'js/forumTab.js', [ 'jquery' ], FORUMAX_VERSION, true ); |
| 91 |
wp_register_script( 'bbpc-frontend', FORUMAX_FRONT_ASS . 'js/frontend.js', [ 'jquery' ], FORUMAX_VERSION, true ); |
| 92 |
wp_register_script( 'bbpc-ajax', FORUMAX_FRONT_ASS . 'js/ajax.js', [ 'jquery' ], FORUMAX_VERSION, true ); |
| 93 |
} |
| 94 |
} |
| 95 |
|