PluginProbe
UiCore Elements – Free widgets and templates for Elementor / 1.3.17
UiCore Elements – Free widgets and templates for Elementor v1.3.17
1.3.17 1.3.16 trunk 1.0.0 1.0.1 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.15 1.0.16 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 All 41 releases
← All changes | includes/class-admin.php +71 -86 1.0.61.3.17 View file →
@@ -1,8 +1,10 @@
1 1 <?php
2 2
3 3 namespace UiCoreElements;
4 4
5 +use UiCoreElements\Utils\Newsletter_Services as Services;
6 +
5 7 /**
6 8 * Admin Pages Handler
7 9 */
8 10 class Admin
@@ -15,12 +17,21 @@
15 17 * @since 1.0.0
16 18 */
17 19 public function __construct()
18 20 {
19 - $this->elementor_style();
20 -
21 21 add_action('admin_menu', [$this, 'admin_menu']);
22 22 add_action('admin_init', [$this, 'init_hooks']);
23 +
24 + // TODO: Remove this after, at least, 5 releases or 1 year from 1.3.3
25 + // Mailchimp to generic api key fields migration
26 + if (
27 + get_option('uicore_elements_mailchimp_secret_key')
28 + && !get_option('uicore_elements_newsletter_service_key')
29 + ) {
30 + $value = get_option('uicore_elements_mailchimp_secret_key');
31 + update_option('uicore_elements_newsletter_service_key', $value);
32 + delete_option('uicore_elements_mailchimp_secret_key');
33 + }
23 34 }
24 35
25 36 /**
26 37 * Add admin menu page
@@ -32,28 +43,28 @@
32 43 public function admin_menu()
33 44 {
34 45 // Settings page (only required if uicore framework is not active)
35 46 // if (!\class_exists('\UiCore\Helper')) {
36 - $hook = add_submenu_page(
37 - 'options-general.php',
38 - 'UiCore Elements',
39 - 'UiCore Elements',
40 - 'manage_options',
41 - 'uicore-elements',
42 - [$this, 'plugin_page']
43 - );
47 + $hook = add_submenu_page(
48 + 'options-general.php',
49 + 'UiCore Elements',
50 + 'UiCore Elements',
51 + 'manage_options',
52 + 'uicore-elements',
53 + [$this, 'plugin_page']
54 + );
44 55
45 56 // }
46 57
47 58 // Connect handle
48 - add_submenu_page(
49 - null,
50 - 'UiCore Connect',
51 - 'UiCore Connect',
52 - 'manage_options',
53 - 'uicore_connect_free',
54 - [$this, 'connect_page_callback']
55 - );
59 + // add_submenu_page(
60 + // null,
61 + // 'UiCore Connect',
62 + // 'UiCore Connect',
63 + // 'manage_options',
64 + // 'uicore_connect_free',
65 + // [$this, 'connect_page_callback']
66 + // );
56 67 }
57 68
58 69 /**
59 70 * Initialize hooks for settings fields and sections
@@ -63,15 +74,23 @@
63 74 * @since 1.0.5
64 75 */
65 76 public function init_hooks()
66 77 {
78 + // Register settings for reCAPTCHA
67 79 register_setting('uicore_elements_recaptcha', 'uicore_elements_recaptcha_site_key', ['sanitize_callback' => 'sanitize_text_field']);
68 80 register_setting('uicore_elements_recaptcha', 'uicore_elements_recaptcha_secret_key', ['sanitize_callback' => 'sanitize_text_field']);
69 81
82 + // Register settings for Mailchimp
83 + register_setting('uicore_elements_newsletter_service', 'uicore_elements_newsletter_service_key', ['sanitize_callback' => 'sanitize_text_field']);
84 +
85 + // Add settings sections
70 86 add_settings_section('uicore_elements_recaptcha_section', 'reCAPTCHA Keys', [$this, 'recaptcha_section'], 'uicore_elements_recaptcha');
87 + add_settings_section('uicore_elements_newsletter_service_section', 'Newsletter Service Key', [$this, 'newsletter_service_section'], 'uicore_elements_newsletter_service');
71 88
89 + // Add settings fields
72 90 add_settings_field('uicore_elements_recaptcha_site_key', 'Site Key', [$this, 'site_key'], 'uicore_elements_recaptcha', 'uicore_elements_recaptcha_section');
73 91 add_settings_field('uicore_elements_recaptcha_secret_key', 'Secret Key', [$this, 'secret_key'], 'uicore_elements_recaptcha', 'uicore_elements_recaptcha_section');
92 + add_settings_field('uicore_elements_newsletter_service_key', 'API Key', [$this, 'newsletter_service_key'], 'uicore_elements_newsletter_service', 'uicore_elements_newsletter_service_section');
74 93 }
75 94
76 95 /**
77 96 * Render plugin page
@@ -91,13 +110,12 @@
91 110 // show error/update messages
92 111 settings_errors('uicoreelements_messages');
93 112
94 113 // display plugin page
95 - ?>
114 +?>
96 115 <div class="wrap">
97 116 <h1>UiCore Elements Settings</h1>
98 117
99 -
100 118 <form method="post" action="options.php" style="margin-top:40px">
101 119 <?php
102 120 settings_fields('uicore_elements_recaptcha');
103 121 do_settings_sections('uicore_elements_recaptcha');
@@ -104,101 +122,68 @@
104 122 submit_button();
105 123 ?>
106 124 </form>
107 125
126 + <form method="post" action="options.php" style="margin-top:40px">
127 + <?php
128 + settings_fields('uicore_elements_newsletter_service');
129 + do_settings_sections('uicore_elements_newsletter_service');
130 + submit_button();
131 + ?>
132 + </form>
133 +
108 134 </div>
109 - <?php
135 +<?php
110 136 }
111 137
112 138 /**
113 - * Render reCAPTCHA section description
139 + * Newsletter Services sections
114 140 *
115 141 * @return void
116 142 * @author Andrei Voica <andrei@uicore.co>
117 - * @since 1.0.5
143 + *
144 + * recaptcha @since 1.0.5
145 + * mailchimp @since 1.0.7
146 + * constant contact, brevo, a, c @since 1.3.3
118 147 */
148 +
119 149 public function recaptcha_section()
120 150 {
121 151 echo '<p class="description">Go to your Google <a href="https://www.google.com/recaptcha/admin/create" target="_blank">reCAPTCHA</a>, choose between V2 or V3 versions and create your API keys</p>';
122 152 }
153 + public function newsletter_service_section()
154 + {
155 + $services = '<strong>' . implode('</strong>, <strong>', Services::get_services_list('names')) . '</strong>';
156 + printf(
157 + '<p class="description">%s %s.</p>',
158 + esc_html__('Set your newsletter service provider API key. We support the following services:', 'uicore-elements'),
159 + Helper::esc_string($services) //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
160 + );
161 + }
123 162
124 163 /**
125 - * Render Site Key field
164 + * Render Uicore Elements settings fields
126 165 *
127 166 * @return void
128 167 * @author Andrei Voica <andrei@uicore.co>
129 - * @since 1.0.5
168 + *
169 + * site key, secret key @since 1.0.5
170 + * mailchimp key @since 1.0.7
171 + * mailchim update for XX @since 1.3.3
130 172 */
173 +
131 174 public function site_key()
132 175 {
133 176 $site_key = get_option('uicore_elements_recaptcha_site_key');
134 177 echo '<input type="text" name="uicore_elements_recaptcha_site_key" value="' . esc_attr($site_key) . '" class="regular-text" />';
135 178 }
136 -
137 - /**
138 - * Render Secret Key field
139 - *
140 - * @return void
141 - * @author Andrei Voica <andrei@uicore.co>
142 - * @since 1.0.5
143 - */
144 179 public function secret_key()
145 180 {
146 181 $secret_key = get_option('uicore_elements_recaptcha_secret_key');
147 182 echo '<input type="text" name="uicore_elements_recaptcha_secret_key" value="' . esc_attr($secret_key) . '" class="regular-text" />';
148 183 }
149 -
150 -
151 - /**
152 - * Elementor Editor Style, Fonts and Scripts
153 - *
154 - * @return void
155 - * @author Andrei Voica <andrei@uicore.co
156 - * @since 1.0.0
157 - */
158 - public function elementor_style()
184 + public function newsletter_service_key()
159 185 {
160 - add_action('elementor/editor/before_enqueue_scripts', function () {
161 -
162 - echo '<style id="uicore-csss" >
163 - .elementor-element .icon .ui-e-widget:after {
164 - height: 28px;
165 - width: 28px;
166 - margin-right: 10px;
167 - border-radius: 3px;
168 - background-color: #532df5;
169 - background-image: url("data:image/svg+xml,%3Csvg xmlns=\'http://www.w3.org/2000/svg\' width=\'16\' height=\'16\' viewBox=\'0 0 16 16\' xml:space=\'preserve\'%3E%3Cpath d=\'M5.383 15.217c3.1 0 5.4-2.3 5.4-5.3v-7.9h-2.9v7.9c0 1.4-1.1 2.5-2.5 2.5s-2.5-1.1-2.5-2.5v-7.9h-2.9v7.9c0 3 2.3 5.3 5.4 5.3zM14.283 4.117c1 0 1.7-.7 1.7-1.7s-.7-1.7-1.7-1.7-1.7.7-1.7 1.7.7 1.7 1.7 1.7zM15.683 15.017v-9.6h-2.8v9.6z\' fill=\'%23fff\'/%3E%3C/svg%3E");
170 - background-size: 16px;
171 - background-position: center;
172 - background-repeat: no-repeat;
173 - }
174 -
175 - .elementor-element .icon .ui-e-widget:after {
176 - content: "";
177 - position: absolute;
178 - right: 5px;
179 - top: 5px;
180 - margin-right: 0;
181 - width: 16px;
182 - height: 16px;
183 - background-size: 9px;
184 - background-color: #656c7196;
185 - transition: background-color .3s ease-in-out;
186 - }
187 - .elementor-element:hover .icon .ui-e-widget:after {
188 - background-color: #532df5;
189 - transition: background-color .3s ease-in-out;
190 - }
191 - #elementor-panel-categories{
192 - display: flex;
193 - flex-direction: column;
194 - }
195 - #elementor-panel-category-basic,
196 - #elementor-panel-category-layout,
197 - #elementor-panel-category-favorites,
198 - #elementor-panel-category-uicore{
199 - order: -1;
200 - }
201 - </style>';
202 - });
186 + $secret_key = get_option('uicore_elements_newsletter_service_key');
187 + echo '<input type="text" name="uicore_elements_newsletter_service_key" value="' . esc_attr($secret_key) . '" class="regular-text" />';
203 188 }
204 189 }