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