PluginProbe
King Addons for Elementor – 100+ Elementor Widgets, 4 000+ Elementor Templates, WooCommerce Builder, Mega Menu, Popup Builder / 51.1.63
King Addons for Elementor – 100+ Elementor Widgets, 4 000+ Elementor Templates, WooCommerce Builder, Mega Menu, Popup Builder v51.1.63
51.1.86 51.1.84 51.1.85 51.1.83 51.1.82 51.1.81 51.1.79 51.1.78 51.1.77 51.1.76 51.1.74 51.1.75 51.1.65 51.1.64 51.1.63 trunk 51.1.14 51.1.2 51.1.35 51.1.36 51.1.37 51.1.38 51.1.39 51.1.44 51.1.45 All 40 releases
king-addons / includes / extensions / Header_Footer_Builder / ELHF_Settings_Page.php

ELHF_Settings_Page.php in King Addons for Elementor – 100+ Elementor Widgets, 4 000+ Elementor Templates, WooCommerce Builder, Mega Menu, Popup Builder 51.1.63, at includes/extensions/Header_Footer_Builder/ELHF_Settings_Page.php

161 lines 6.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace King_Addons;
4
5 if (!defined('ABSPATH')) {
6 exit;
7 }
8
9 final class ELHF_Settings_Page
10 {
11 public static array $settings_tabs;
12
13 private static ?ELHF_Settings_Page $instance = null;
14
15 public static function instance(): ?ELHF_Settings_Page
16 {
17 if (is_null(self::$instance)) {
18 self::$instance = new self();
19 }
20 return self::$instance;
21 }
22
23 public function __construct()
24 {
25 // Settings page is now integrated into the main Header & Footer Builder admin page.
26 // The submenu registration is disabled to avoid duplicate menu items.
27 // if (is_admin() && current_user_can('manage_options')) {
28 // add_action('admin_menu', [$this, 'registerSettingsPage']);
29 // }
30 add_action('admin_init', [$this, 'initSettings']);
31 // The tab filter is no longer needed since we have our own navigation
32 // add_filter('views_edit-king-addons-el-hf', [$this, 'addTabs'], 10, 1);
33 }
34
35 public function registerSettingsPage()
36 {
37 add_submenu_page(
38 'edit.php?post_type=king-addons-el-hf',
39 esc_html__('Display Settings', 'king-addons'),
40 esc_html__('Display Settings', 'king-addons'),
41 'manage_options',
42 'king-addons-el-hf-settings',
43 [$this, 'renderSettingsPage']
44 );
45 }
46
47 function renderSettingsPage()
48 {
49 echo '<div class="wrap">';
50 echo '<div class="header-wrap">';
51
52 echo '<h1 class="wp-heading-inline">';
53 echo esc_html__('Elementor Header & Footer Builder ', 'king-addons');
54 echo '</h1>';
55
56 $this->renderTabs();
57 echo '</div>';
58
59 if (isset($_GET['page'])) { // PHPCS:Ignore WordPress.Security.NonceVerification.Recommended
60 switch ($_GET['page']) { // PHPCS:Ignore WordPress.Security.NonceVerification.Recommended
61 case 'king-addons-el-hf-settings':
62 $this->renderSettingsTab();
63 break;
64 case 'default':
65 break;
66 }
67 }
68
69 echo '</div>';
70 }
71
72 function renderTabs()
73 {
74 echo '<div class="nav-tab-wrapper">';
75
76 if (!isset(self::$settings_tabs)) {
77 self::$settings_tabs['king_addons_el_hf_templates'] = [
78 'name' => esc_html__('All Templates', 'king-addons'),
79 'url' => admin_url('edit.php?post_type=king-addons-el-hf'),
80 ];
81 }
82
83 $tabs = apply_filters('king_addons_el_hf_settings_tabs', self::$settings_tabs);
84
85 foreach ($tabs as $tab_id => $tab) {
86
87 $active_tab = ((isset($_GET['page']) && (str_replace('_', '-', $tab_id)) == $_GET['page']) || (!isset($_GET['page']) && 'king_addons_el_hf_templates' == $tab_id)) ? $tab_id : ''; // PHPCS:Ignore WordPress.Security.NonceVerification.Recommended
88
89 $active = ($active_tab == $tab_id) ? ' nav-tab-active' : '';
90
91 echo '<a href="' . esc_url($tab['url']) . '" class="nav-tab' . esc_attr($active) . '">';
92 echo esc_html($tab['name']);
93 echo '</a>';
94 }
95
96 echo '</div>';
97 }
98
99 function renderSettingsTab()
100 {
101 echo '<form action="options.php" method="post">';
102 settings_fields('king-addons-el-hf-ext-options');
103 do_settings_sections('king-addons-el-hf-settings');
104 submit_button();
105 echo '</form>';
106 }
107
108 function initSettings()
109 {
110 register_setting('king-addons-el-hf-ext-options', 'king_addons_el_hf_compatibility_option');
111 add_settings_section('king-addons-el-hf-options', esc_html__('Display Settings', 'king-addons'), [$this, 'renderCompatibilityOptionsDescription'], 'king-addons-el-hf-settings');
112 add_settings_field('king-addons-el-hf-methods', esc_html__('Methods to display header and footer', 'king-addons'), [$this, 'renderCompatibilityOptionsForm'], 'king-addons-el-hf-settings', 'king-addons-el-hf-options');
113 }
114
115 function renderCompatibilityOptionsDescription()
116 {
117 echo esc_html__('To ensure compatibility with the current theme, three methods are available:', 'king-addons');
118 }
119
120 function renderCompatibilityOptionsForm()
121 {
122 $chosen_option = get_option('king_addons_el_hf_compatibility_option', '3');
123 wp_enqueue_style('king-addons-el-hf-admin', KING_ADDONS_URL . 'includes/extensions/Header_Footer_Builder/admin.css', '', KING_ADDONS_VERSION);
124 ?>
125 <label style="display: block; margin-bottom: 20px;">
126 <input type="radio" name="king_addons_el_hf_compatibility_option"
127 value="3" <?php checked($chosen_option, '3'); ?>>
128 <!--suppress HtmlUnknownTag -->
129 <strong class="king-addons-el-hf-radio-options"><?php esc_html_e('Method 3 - Universal (Recommended)', 'king-addons'); ?></strong>
130 <!--suppress HtmlUnknownTag -->
131 <p class="description"><?php esc_html_e('This method combines multiple approaches for maximum theme compatibility. It uses hooks, output buffering, CSS hiding of native theme headers/footers, and JavaScript fallback to ensure headers and footers display correctly on all themes.', 'king-addons'); ?></p>
132 </label>
133 <label style="display: block; margin-bottom: 20px;">
134 <input type="radio" name="king_addons_el_hf_compatibility_option"
135 value="1" <?php checked($chosen_option, '1'); ?>>
136 <!--suppress HtmlUnknownTag -->
137 <strong class="king-addons-el-hf-radio-options"><?php esc_html_e('Method 1 - Replace Theme Templates', 'king-addons'); ?></strong>
138 <!--suppress HtmlUnknownTag -->
139 <p class="description"><?php esc_html_e('This method replaces the theme header (header.php) and footer (footer.php) templates with custom templates. Works well with classic themes that use standard WordPress template structure.', 'king-addons'); ?></p>
140 </label>
141 <label style="display: block; margin-bottom: 20px;">
142 <input type="radio" name="king_addons_el_hf_compatibility_option"
143 value="2" <?php checked($chosen_option, '2'); ?>>
144 <!--suppress HtmlUnknownTag -->
145 <strong class="king-addons-el-hf-radio-options"><?php esc_html_e('Method 2 - CSS Hide + Inject', 'king-addons'); ?></strong>
146 <!--suppress HtmlUnknownTag -->
147 <p class="description">
148 <?php echo esc_html__('This method hides the theme header and footer using CSS (display: none;) and injects custom templates via wp_body_open and wp_footer hooks.', 'king-addons'); ?>
149 </p>
150 </label>
151 <?php
152 }
153
154 function addTabs($views)
155 {
156 $this->renderTabs();
157 return $views;
158 }
159 }
160
161 new ELHF_Settings_Page();