PluginProbe
King Addons for Elementor – 100+ Elementor Widgets, 4 000+ Elementor Templates, WooCommerce Builder, Mega Menu, Popup Builder / 51.1.36
King Addons for Elementor – 100+ Elementor Widgets, 4 000+ Elementor Templates, WooCommerce Builder, Mega Menu, Popup Builder v51.1.36
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.36, at includes/extensions/Header_Footer_Builder/ELHF_Settings_Page.php

151 lines 5.5 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 if (is_admin() && current_user_can('manage_options')) {
26 add_action('admin_menu', [$this, 'registerSettingsPage']);
27 }
28 add_action('admin_init', [$this, 'initSettings']);
29 add_filter('views_edit-king-addons-el-hf', [$this, 'addTabs'], 10, 1);
30 }
31
32 public function registerSettingsPage()
33 {
34 add_submenu_page(
35 'edit.php?post_type=king-addons-el-hf',
36 esc_html__('Display Settings', 'king-addons'),
37 esc_html__('Display Settings', 'king-addons'),
38 'manage_options',
39 'king-addons-el-hf-settings',
40 [$this, 'renderSettingsPage']
41 );
42 }
43
44 function renderSettingsPage()
45 {
46 echo '<div class="wrap">';
47 echo '<div class="header-wrap">';
48
49 echo '<h1 class="wp-heading-inline">';
50 echo esc_html__('Elementor Header & Footer Builder ', 'king-addons');
51 echo '</h1>';
52
53 $this->renderTabs();
54 echo '</div>';
55
56 if (isset($_GET['page'])) { // PHPCS:Ignore WordPress.Security.NonceVerification.Recommended
57 switch ($_GET['page']) { // PHPCS:Ignore WordPress.Security.NonceVerification.Recommended
58 case 'king-addons-el-hf-settings':
59 $this->renderSettingsTab();
60 break;
61 case 'default':
62 break;
63 }
64 }
65
66 echo '</div>';
67 }
68
69 function renderTabs()
70 {
71 echo '<div class="nav-tab-wrapper">';
72
73 if (!isset(self::$settings_tabs)) {
74 self::$settings_tabs['king_addons_el_hf_templates'] = [
75 'name' => esc_html__('All Templates', 'king-addons'),
76 'url' => admin_url('edit.php?post_type=king-addons-el-hf'),
77 ];
78 }
79
80 $tabs = apply_filters('king_addons_el_hf_settings_tabs', self::$settings_tabs);
81
82 foreach ($tabs as $tab_id => $tab) {
83
84 $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
85
86 $active = ($active_tab == $tab_id) ? ' nav-tab-active' : '';
87
88 echo '<a href="' . esc_url($tab['url']) . '" class="nav-tab' . esc_attr($active) . '">';
89 echo esc_html($tab['name']);
90 echo '</a>';
91 }
92
93 echo '</div>';
94 }
95
96 function renderSettingsTab()
97 {
98 echo '<form action="options.php" method="post">';
99 settings_fields('king-addons-el-hf-ext-options');
100 do_settings_sections('king-addons-el-hf-settings');
101 submit_button();
102 echo '</form>';
103 }
104
105 function initSettings()
106 {
107 register_setting('king-addons-el-hf-ext-options', 'king_addons_el_hf_compatibility_option');
108 add_settings_section('king-addons-el-hf-options', esc_html__('Display Settings', 'king-addons'), [$this, 'renderCompatibilityOptionsDescription'], 'king-addons-el-hf-settings');
109 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');
110 }
111
112 function renderCompatibilityOptionsDescription()
113 {
114 echo esc_html__('To ensure compatibility with the current theme, two methods are available:', 'king-addons');
115 }
116
117 function renderCompatibilityOptionsForm()
118 {
119 $chosen_option = get_option('king_addons_el_hf_compatibility_option', '1');
120 wp_enqueue_style('king-addons-el-hf-admin', KING_ADDONS_URL . 'includes/extensions/Header_Footer_Builder/admin.css', '', KING_ADDONS_VERSION);
121 ?>
122 <label>
123 <input type="radio" name="king_addons_el_hf_compatibility_option"
124 value=1 <?php checked($chosen_option, 1); ?>>
125 <!--suppress HtmlUnknownTag -->
126 <div class="king-addons-el-hf-radio-options"><?php esc_html_e('Method 1 (Recommended)', 'king-addons'); ?></div>
127 <!--suppress HtmlUnknownTag -->
128 <p class="description"><?php esc_html_e('This method replaces the theme header (header.php) and footer (footer.php) templates with custom templates. This option works well with most themes by default.', 'king-addons'); ?></p>
129 <br>
130 </label>
131 <label>
132 <input type="radio" name="king_addons_el_hf_compatibility_option"
133 value=2 <?php checked($chosen_option, 2); ?>>
134 <!--suppress HtmlUnknownTag -->
135 <div class="king-addons-el-hf-radio-options"><?php esc_html_e('Method 2', 'king-addons'); ?></div>
136 <!--suppress HtmlUnknownTag -->
137 <p class="description">
138 <?php echo esc_html__('If there are issues with the header or footer templates, this alternative method can be used. It hides the theme header and footer using CSS (display: none;) and displays custom templates instead.', 'king-addons'); ?>
139 </p>
140 </label>
141 <?php
142 }
143
144 function addTabs($views)
145 {
146 $this->renderTabs();
147 return $views;
148 }
149 }
150
151 new ELHF_Settings_Page();