PluginProbe
Master Addons for Elementor – Elementor Addons, Widgets, Mega Menu Builder, Popup Builder, Widget Builder & Template Kits / 3.1.9
Master Addons for Elementor – Elementor Addons, Widgets, Mega Menu Builder, Popup Builder, Widget Builder & Template Kits v3.1.9
3.2.2 3.2.3 3.2.1 3.2.0 3.1.9 3.1.8 3.1.7 3.1.6 3.1.5 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 3.0.9 trunk 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.1.1 1.1.3 1.1.4 1.1.5 All 174 releases
master-addons / inc / admin / templates / widgets / class-widgets-library.php

class-widgets-library.php in Master Addons for Elementor – Elementor Addons, Widgets, Mega Menu Builder, Popup Builder, Widget Builder & Template Kits 3.1.9, at inc/admin/templates/widgets/class-widgets-library.php

101 lines 3.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace MasterAddons\Inc\Admin\Templates\Widgets;
4
5 use MasterAddons\Inc\Classes\Helper;
6
7 defined('ABSPATH') || exit;
8
9 /**
10 * Widgets Library admin screen.
11 */
12 class Widgets_Library
13 {
14 private static $_instance = null;
15
16 public function __construct()
17 {
18 add_action('admin_menu', [$this, 'add_menu'], 19);
19 add_action('admin_enqueue_scripts', [$this, 'enqueue_assets']);
20 add_action('in_admin_header', [$this, 'suppress_admin_notices'], 1000);
21 }
22
23 /**
24 * Strip third-party notices from the Widgets Library screen.
25 *
26 * The app renders a full-bleed layout of its own, and unrelated plugin
27 * notices push it down and break the header. Runs late on in_admin_header,
28 * which is after notices are registered but before any are printed.
29 */
30 public function suppress_admin_notices()
31 {
32 if (!$this->is_library_screen()) {
33 return;
34 }
35
36 remove_all_actions('admin_notices');
37 remove_all_actions('all_admin_notices');
38 remove_all_actions('network_admin_notices');
39 remove_all_actions('user_admin_notices');
40 }
41
42 private function is_library_screen()
43 {
44 $screen = function_exists('get_current_screen') ? get_current_screen() : null;
45
46 return $screen && false !== strpos($screen->id, 'jltma-widgets-library');
47 }
48
49 public function add_menu()
50 {
51 add_submenu_page(
52 'master-addons-settings',
53 __('Widgets Library', 'master-addons'),
54 __('Widgets Library', 'master-addons'),
55 'manage_options',
56 'jltma-widgets-library',
57 [$this, 'render_page']
58 );
59 }
60
61 public function enqueue_assets($hook)
62 {
63 if (strpos($hook, 'jltma-widgets-library') === false) {
64 return;
65 }
66
67 wp_enqueue_style('jltma-page-importer');
68 wp_enqueue_style('jltma-widgets-library-app');
69 wp_enqueue_script('jltma-widgets-library-app');
70
71 wp_localize_script('jltma-widgets-library-app', 'JLTMAWidgetsLibrary', [
72 'ajaxurl' => admin_url('admin-ajax.php'),
73 'nonce' => wp_create_nonce(Widgets_Ajax::NONCE_ACTION),
74 'is_pro' => Helper::jltma_premium(),
75 'pluginUrl' => JLTMA_URL,
76 'strings' => [
77 'importSuccess' => __('Widget imported successfully!', 'master-addons'),
78 'importError' => __('Failed to import widget.', 'master-addons'),
79 'previewTemplate' => __('Preview', 'master-addons'),
80 'importTemplate' => __('Import', 'master-addons'),
81 'searchPlaceholder' => __('Search widgets...', 'master-addons'),
82 ],
83 ]);
84 }
85
86 public function render_page()
87 {
88 // Mounted bare, like the Template Library root — the app supplies its
89 // own full-bleed layout and a .wrap would add admin margins on top.
90 echo '<div id="jltma-widgets-library-app"></div>';
91 }
92
93 public static function get_instance()
94 {
95 if (is_null(self::$_instance)) {
96 self::$_instance = new self();
97 }
98 return self::$_instance;
99 }
100 }
101