PluginProbe
UiCore Elements – Free widgets and templates for Elementor / 1.2.3
UiCore Elements – Free widgets and templates for Elementor v1.2.3
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
uicore-elements / includes / class-admin.php

class-admin.php in UiCore Elements – Free widgets and templates for Elementor 1.2.3, at includes/class-admin.php

239 lines 7.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace UiCoreElements;
4
5 /**
6 * Admin Pages Handler
7 */
8 class Admin
9 {
10 /**
11 * Constructor function to initialize hooks
12 *
13 * @return void
14 * @author Andrei Voica <andrei@uicore.co>
15 * @since 1.0.0
16 */
17 public function __construct()
18 {
19 $this->elementor_style();
20
21 add_action('admin_menu', [$this, 'admin_menu']);
22 add_action('admin_init', [$this, 'init_hooks']);
23 }
24
25 /**
26 * Add admin menu page
27 *
28 * @return void
29 * @author Andrei Voica <andrei@uicore.co>
30 * @since 1.0.5
31 */
32 public function admin_menu()
33 {
34 // Settings page (only required if uicore framework is not active)
35 // 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 );
44
45 // }
46
47 // 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 // );
56 }
57
58 /**
59 * Initialize hooks for settings fields and sections
60 *
61 * @return void
62 * @author Andrei Voica <andrei@uicore.co>
63 * @since 1.0.5
64 */
65 public function init_hooks()
66 {
67 register_setting('uicore_elements_recaptcha', 'uicore_elements_recaptcha_site_key', ['sanitize_callback' => 'sanitize_text_field']);
68 register_setting('uicore_elements_recaptcha', 'uicore_elements_recaptcha_secret_key', ['sanitize_callback' => 'sanitize_text_field']);
69 register_setting('uicore_elements_mailchimp', 'uicore_elements_mailchimp_secret_key', ['sanitize_callback' => 'sanitize_text_field']);
70
71 add_settings_section('uicore_elements_recaptcha_section', 'reCAPTCHA Keys', [$this, 'recaptcha_section'], 'uicore_elements_recaptcha');
72 add_settings_section('uicore_elements_mailchimp_section', 'Mailchimp Key', [$this, 'mailchimp_section'], 'uicore_elements_mailchimp');
73
74 add_settings_field('uicore_elements_recaptcha_site_key', 'Site Key', [$this, 'site_key'], 'uicore_elements_recaptcha', 'uicore_elements_recaptcha_section');
75 add_settings_field('uicore_elements_recaptcha_secret_key', 'Secret Key', [$this, 'secret_key'], 'uicore_elements_recaptcha', 'uicore_elements_recaptcha_section');
76 add_settings_field('uicore_elements_mailchimp_secret_key', 'API Key', [$this, 'mailchimp_key'], 'uicore_elements_mailchimp', 'uicore_elements_mailchimp_section');
77 }
78
79 /**
80 * Render plugin page
81 *
82 * @return void
83 * @author Andrei Voica <andrei@uicore.co>
84 * @since 1.0.5
85 */
86 public function plugin_page()
87 {
88 // check user capabilities
89 if (!current_user_can('manage_options')) {
90 return;
91 }
92
93
94 // show error/update messages
95 settings_errors('uicoreelements_messages');
96
97 // display plugin page
98 ?>
99 <div class="wrap">
100 <h1>UiCore Elements Settings</h1>
101
102 <form method="post" action="options.php" style="margin-top:40px">
103 <?php
104 settings_fields('uicore_elements_recaptcha');
105 do_settings_sections('uicore_elements_recaptcha');
106 submit_button();
107 ?>
108 </form>
109
110 <form method="post" action="options.php" style="margin-top:40px">
111 <?php
112 settings_fields('uicore_elements_mailchimp');
113 do_settings_sections('uicore_elements_mailchimp');
114 submit_button();
115 ?>
116 </form>
117
118 </div>
119 <?php
120 }
121
122 /**
123 * Render reCAPTCHA section description
124 *
125 * @return void
126 * @author Andrei Voica <andrei@uicore.co>
127 * @since 1.0.5
128 */
129 public function recaptcha_section()
130 {
131 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>';
132 }
133 /**
134 * Render Mailchimp section description
135 *
136 * @return void
137 * @author Lucas Marini Falbo <lucas@uicore.co>
138 * @since 1.0.7
139 */
140 public function mailchimp_section()
141 {
142 echo "<p class='description'>If you don't have one yet, go to your <a href='https://admin.mailchimp.com/account/api/' target='_blank'>Mailchimp Dashboard</a> and create a new API key</p>";
143 }
144
145 /**
146 * Render reCAPTCHA Site Key field
147 *
148 * @return void
149 * @author Andrei Voica <andrei@uicore.co>
150 * @since 1.0.5
151 */
152 public function site_key()
153 {
154 $site_key = get_option('uicore_elements_recaptcha_site_key');
155 echo '<input type="text" name="uicore_elements_recaptcha_site_key" value="' . esc_attr($site_key) . '" class="regular-text" />';
156 }
157
158 /**
159 * Render reCAPTCHA Secret Key field
160 *
161 * @return void
162 * @author Andrei Voica <andrei@uicore.co>
163 * @since 1.0.5
164 */
165 public function secret_key()
166 {
167 $secret_key = get_option('uicore_elements_recaptcha_secret_key');
168 echo '<input type="text" name="uicore_elements_recaptcha_secret_key" value="' . esc_attr($secret_key) . '" class="regular-text" />';
169 }
170
171 /**
172 * Render Mailchimp API Key
173 *
174 * @return void
175 * @author Lucas Marini Falbo <lucas@uicore.co>
176 * @since 1.0.5
177 */
178 public function mailchimp_key()
179 {
180 $secret_key = get_option('uicore_elements_mailchimp_secret_key');
181 echo '<input type="text" name="uicore_elements_mailchimp_secret_key" value="' . esc_attr($secret_key) . '" class="regular-text" />';
182 }
183
184
185 /**
186 * Elementor Editor Style, Fonts and Scripts
187 *
188 * @return void
189 * @author Andrei Voica <andrei@uicore.co
190 * @since 1.0.0
191 */
192 public function elementor_style()
193 {
194 add_action('elementor/editor/before_enqueue_scripts', function () {
195
196 echo '<style id="uicore-csss" >
197 .elementor-element .icon .ui-e-widget:after {
198 height: 28px;
199 width: 28px;
200 margin-right: 10px;
201 border-radius: 3px;
202 background-color: #532df5;
203 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");
204 background-size: 16px;
205 background-position: center;
206 background-repeat: no-repeat;
207 }
208
209 .elementor-element .icon .ui-e-widget:after {
210 content: "";
211 position: absolute;
212 right: 5px;
213 top: 5px;
214 margin-right: 0;
215 width: 16px;
216 height: 16px;
217 background-size: 9px;
218 background-color: #656c7196;
219 transition: background-color .3s ease-in-out;
220 }
221 .elementor-element:hover .icon .ui-e-widget:after {
222 background-color: #532df5;
223 transition: background-color .3s ease-in-out;
224 }
225 #elementor-panel-categories{
226 display: flex;
227 flex-direction: column;
228 }
229 #elementor-panel-category-basic,
230 #elementor-panel-category-layout,
231 #elementor-panel-category-favorites,
232 #elementor-panel-category-uicore{
233 order: -1;
234 }
235 </style>';
236 });
237 }
238 }
239