PluginProbe
Getwid – Gutenberg Blocks / 3.0.2
Getwid – Gutenberg Blocks v3.0.2
3.0.2 3.0.1 3.0.0 2.1.0 2.1.1 2.1.2 2.1.3 2.2.0 trunk 1.8.7 1.9.1 2.0.10 2.0.11 2.0.12 2.0.13 2.0.14 2.0.5 2.0.6 2.0.7 2.0.8 2.0.9
← All changes | includes/settings-page.php +365 -274 2.2.03.0.2 View file →
@@ -3,61 +3,56 @@
3 3 namespace Getwid;
4 4
5 5 class SettingsPage {
6 6
7 - public function __construct()
8 - {
9 - $this->addActions();
10 - }
7 + public function __construct() {
8 + $this->addActions();
9 + }
11 10
12 - protected function addActions()
13 - {
14 - add_action('admin_menu', [$this, 'registerPage']);
15 - add_action('admin_init', [$this, 'registerSettingsGroups']);
16 - add_action('admin_init', [$this, 'registerFields']);
17 - add_action('admin_init', [$this, 'checkInstagramQueryURL']);
18 - }
11 + protected function addActions() {
12 + add_action( 'admin_menu', array( $this, 'registerPage' ) );
13 + add_action( 'admin_init', array( $this, 'registerSettingsGroups' ) );
14 + add_action( 'admin_init', array( $this, 'registerFields' ) );
15 + add_action( 'admin_init', array( $this, 'checkInstagramQueryURL' ) );
16 + }
19 17
20 - public function getSettingsGroups()
21 - {
22 - return [
23 - 'general' => [
24 - 'title' => __('General', 'getwid'),
25 - 'sections' => [
26 - 'contact_from' => __('Contact Form Settings', 'getwid'),
27 - ]
28 - ],
29 - 'appearance' => [
30 - 'title' => __('Appearance', 'getwid'),
31 - 'sections' => [ ]
32 - ],
33 - 'blocks' => [
34 - 'title' => __('Blocks', 'getwid'),
35 - 'sections' => [ ]
36 - ],
37 - 'post_templates' => [
38 - 'title' => __('Post Templates', 'getwid'),
39 - 'sections' => [ ]
40 - ]
41 - ];
18 + public function getSettingsGroups() {
19 + return array(
20 + 'general' => array(
21 + 'title' => __( 'General', 'getwid' ),
22 + 'sections' => array(
23 + 'contact_from' => __( 'Contact Form Settings', 'getwid' ),
24 + ),
25 + ),
26 + 'appearance' => array(
27 + 'title' => __( 'Appearance', 'getwid' ),
28 + 'sections' => array(),
29 + ),
30 + 'blocks' => array(
31 + 'title' => __( 'Blocks', 'getwid' ),
32 + 'sections' => array(),
33 + ),
34 + 'post_templates' => array(
35 + 'title' => __( 'Post Templates', 'getwid' ),
36 + 'sections' => array(),
37 + ),
38 + );
42 39 }
43 40
44 - public function registerPage()
45 - {
41 + public function registerPage() {
46 42 add_options_page(
47 - esc_html_x('Getwid Settings' , 'Settings page title', 'getwid'),
48 - esc_html_x('Getwid', 'Settings page title(in menu)', 'getwid'),
43 + esc_html_x( 'Getwid Settings', 'Settings page title', 'getwid' ),
44 + esc_html_x( 'Getwid', 'Settings page title(in menu)', 'getwid' ),
49 45 'manage_options',
50 46 'getwid',
51 - [$this, 'renderPage']
47 + array( $this, 'renderPage' )
52 48 );
53 49 }
54 50
55 - public function registerSettingsGroups()
56 - {
51 + public function registerSettingsGroups() {
57 52 $settings_groups = $this->getSettingsGroups();
58 53
59 - foreach ($settings_groups as $id => $group) {
54 + foreach ( $settings_groups as $id => $group ) {
60 55 add_settings_section(
61 56 'getwid_' . $id,
62 57 '',
63 58 '',
@@ -63,9 +58,9 @@
63 58 '',
64 59 'getwid_' . $id
65 60 );
66 61
67 - foreach ($group['sections'] as $section_id => $section) {
62 + foreach ( $group['sections'] as $section_id => $section ) {
68 63 add_settings_section(
69 64 'getwid_' . $section_id,
70 65 $section,
71 66 '',
@@ -74,18 +69,17 @@
74 69 }
75 70 }
76 71 }
77 72
78 - public function renderPage()
79 - {
73 + public function renderPage() {
80 74 if ( ! current_user_can( 'manage_options' ) ) {
81 75 return;
82 76 }
83 77
84 - $active_tab_id = $this->getActiveTabID();
78 + $active_tab_id = $this->getActiveTabID();
85 79 $settings_groups = $this->getSettingsGroups();
86 80
87 - settings_errors('getwid_settings_errors');
81 + settings_errors( 'getwid_settings_errors' );
88 82 ?>
89 83 <div class="wrap">
90 84 <h1><?php echo esc_html( get_admin_page_title() ); ?></h1>
91 85
@@ -90,60 +84,60 @@
90 84 <h1><?php echo esc_html( get_admin_page_title() ); ?></h1>
91 85
92 86 <h2 class="nav-tab-wrapper">
93 87 <?php
94 - foreach ($settings_groups as $tab_id => $tab) :
88 + foreach ( $settings_groups as $tab_id => $tab ) :
95 89 $active_tab_class = $tab_id == $active_tab_id ? 'nav-tab-active' : '';
96 - ?>
97 - <a href="<?php echo esc_url( $this->getTabUrl($tab_id) ); ?>" class="nav-tab <?php echo esc_attr($active_tab_class); ?>">
98 - <?php echo esc_html($tab['title']); ?>
90 + ?>
91 + <a href="<?php echo esc_url( $this->getTabUrl( $tab_id ) ); ?>" class="nav-tab <?php echo esc_attr( $active_tab_class ); ?>">
92 + <?php echo esc_html( $tab['title'] ); ?>
99 93 </a>
100 - <?php
94 + <?php
101 95 endforeach;
102 96 ?>
103 97 </h2>
104 98 <?php
105 - if ( 'post_templates' == $active_tab_id ) :
99 + if ( 'post_templates' == $active_tab_id ) :
106 100
107 101 $this->renderPostTemplatesTab();
108 102
109 103 else :
110 - ?>
104 + ?>
111 105 <form action="options.php" method="post">
112 - <?php
113 - settings_fields( 'getwid_' . $active_tab_id );
114 - do_settings_sections( 'getwid_' . $active_tab_id );
106 + <?php
107 + settings_fields( 'getwid_' . $active_tab_id );
108 + do_settings_sections( 'getwid_' . $active_tab_id );
115 109
116 - submit_button( esc_html__('Save Changes', 'getwid') );
117 - ?>
110 + submit_button( esc_html__( 'Save Changes', 'getwid' ) );
111 + ?>
118 112 </form>
119 - <?php
113 + <?php
120 114 endif;
121 - ?>
115 + ?>
122 116 </div>
123 117 <?php
124 118 }
125 119
126 - public function getwid_instagram_notice_success() {
127 - ?>
128 - <div class="notice notice-success">
129 - <p><?php esc_html_e( 'Instagram: access token updated.', 'getwid' ); ?></p>
130 - </div>
131 - <?php
132 - }
120 + public function getwid_instagram_notice_success() {
121 + ?>
122 + <div class="notice notice-success">
123 + <p><?php esc_html_e( 'Instagram: access token updated.', 'getwid' ); ?></p>
124 + </div>
125 + <?php
126 + }
133 127
134 - public function getwid_instagram_notice_error() {
135 - ?>
136 - <div class="notice notice-error">
137 - <p><?php esc_html_e('Instagram: access denied.', 'getwid'); ?></p>
138 - </div>
139 - <?php
140 - }
128 + public function getwid_instagram_notice_error() {
129 + ?>
130 + <div class="notice notice-error">
131 + <p><?php esc_html_e( 'Instagram: access denied.', 'getwid' ); ?></p>
132 + </div>
133 + <?php
134 + }
141 135
142 - public function checkInstagramQueryURL() {
143 - global $pagenow;
136 + public function checkInstagramQueryURL() {
137 + global $pagenow;
144 138
145 - if ( $pagenow == 'options-general.php' && isset( $_GET['instagram-token'] ) && isset( $_GET['nonce'] ) ) {
139 + if ( $pagenow == 'options-general.php' && isset( $_GET['instagram-token'] ) && isset( $_GET['nonce'] ) ) {
146 140
147 141 if ( wp_verify_nonce( sanitize_key( $_GET['nonce'] ), 'getwid_nonce_save_instagram_token' ) && current_user_can( 'manage_options' ) ) {
148 142
149 143 // Update token
@@ -153,216 +147,341 @@
153 147 // Schedule token refresh
154 148 getwid()->instagramTokenManager()->schedule_token_refresh_event();
155 149
156 150 $redirect_url = add_query_arg(
157 - [
158 - 'getwid-instagram-success' => true
159 - ],
160 - $this->getTabUrl('general')
151 + array(
152 + 'getwid-instagram-success' => true,
153 + ),
154 + $this->getTabUrl( 'general' )
161 155 );
162 156 } else {
163 157 $redirect_url = add_query_arg(
164 - [
165 - 'instagram-error' => true
166 - ],
167 - $this->getTabUrl('general')
158 + array(
159 + 'instagram-error' => true,
160 + ),
161 + $this->getTabUrl( 'general' )
168 162 );
169 163 }
170 164
171 165 wp_redirect( $redirect_url );
172 - }
166 + }
173 167
174 - if (isset($_GET['getwid-instagram-success'])) {
175 - add_action( 'admin_notices', [$this, 'getwid_instagram_notice_success'] );
176 - }
168 + if ( isset( $_GET['getwid-instagram-success'] ) ) {
169 + add_action( 'admin_notices', array( $this, 'getwid_instagram_notice_success' ) );
170 + }
177 171
178 - if (isset($_GET['instagram-error'])) {
179 - add_action( 'admin_notices', [$this, 'getwid_instagram_notice_error'] );
180 - }
181 - }
172 + if ( isset( $_GET['instagram-error'] ) ) {
173 + add_action( 'admin_notices', array( $this, 'getwid_instagram_notice_error' ) );
174 + }
175 + }
182 176
183 - public function registerFields() {
177 + public function registerFields() {
184 178
185 - /* #region Section Content Width */
186 - add_settings_field( 'getwid_section_content_width', __( 'Section Content Width', 'getwid' ),
187 - [ $this, 'renderSectionContentWidth' ], 'getwid_appearance', 'getwid_appearance' );
188 - register_setting( 'getwid_appearance', 'getwid_section_content_width', [ 'type' => 'number', 'default' => '' ] );
189 - /* #endregion */
179 + /* #region Section Content Width */
180 + add_settings_field(
181 + 'getwid_section_content_width',
182 + __( 'Section Content Width', 'getwid' ),
183 + array( $this, 'renderSectionContentWidth' ),
184 + 'getwid_appearance',
185 + 'getwid_appearance'
186 + );
187 + register_setting(
188 + 'getwid_appearance',
189 + 'getwid_section_content_width',
190 + array(
191 + 'type' => 'number',
192 + 'default' => '',
193 + )
194 + );
195 + /* #endregion */
190 196
191 197 /* #region Animation */
192 - add_settings_field( 'getwid_animation', __( 'Animation', 'getwid' ),
193 - [ $this, 'renderAnimation' ], 'getwid_appearance', 'getwid_appearance' );
194 - register_setting( 'getwid_appearance', 'getwid_smooth_animation', [ 'type' => 'boolean', 'default' => false, 'sanitize_callback' => 'rest_sanitize_boolean' ] );
198 + add_settings_field(
199 + 'getwid_animation',
200 + __( 'Animation', 'getwid' ),
201 + array( $this, 'renderAnimation' ),
202 + 'getwid_appearance',
203 + 'getwid_appearance'
204 + );
205 + register_setting(
206 + 'getwid_appearance',
207 + 'getwid_smooth_animation',
208 + array(
209 + 'type' => 'boolean',
210 + 'default' => false,
211 + 'sanitize_callback' => 'rest_sanitize_boolean',
212 + )
213 + );
195 214 /* #endregion */
196 215
197 - /* #region AssetsOptimization */
198 - add_settings_field( 'getwid_assets_optimization', __( 'Performance Optimization', 'getwid' ),
199 - [ $this, 'renderAssetsOptimization'], 'getwid_general', 'getwid_general' );
200 - register_setting( 'getwid_general', 'getwid_load_assets_on_demand', [ 'type' => 'boolean', 'default' => false, 'sanitize_callback' => 'rest_sanitize_boolean' ] );
201 -
202 - register_setting( 'getwid_general', 'getwid_move_css_to_head', [ 'type' => 'boolean', 'default' => false, 'sanitize_callback' => 'rest_sanitize_boolean' ] );
216 + /* #region Instagram Access Token */
217 + add_settings_field(
218 + 'getwid_instagram_token',
219 + __( 'Instagram Access Token', 'getwid' ),
220 + array( $this, 'renderInstagramToken' ),
221 + 'getwid_general',
222 + 'getwid_general'
223 + );
224 + register_setting(
225 + 'getwid_general',
226 + 'getwid_instagram_token',
227 + array(
228 + 'type' => 'text',
229 + 'default' => '',
230 + )
231 + );
203 232 /* #endregion */
204 233
205 - /* #region Instagram Access Token */
206 - add_settings_field( 'getwid_instagram_token', __( 'Instagram Access Token', 'getwid' ),
207 - [ $this, 'renderInstagramToken' ], 'getwid_general', 'getwid_general' );
208 - register_setting( 'getwid_general', 'getwid_instagram_token', [ 'type' => 'text', 'default' => '' ] );
209 - /* #endregion */
210 -
211 234 /* #region Instagram Cache Timeout */
212 - add_settings_field( 'getwid_instagram_cache_timeout', __( 'Instagram Cache Timeout', 'getwid' ),
213 - [ $this, 'renderInstagramCacheTimeout' ], 'getwid_general', 'getwid_general' );
214 - register_setting( 'getwid_general', 'getwid_instagram_cache_timeout', [ 'type' => 'number', 'default' => 30 ] );
215 - /* #endregion */
235 + add_settings_field(
236 + 'getwid_instagram_cache_timeout',
237 + __( 'Instagram Cache Timeout', 'getwid' ),
238 + array( $this, 'renderInstagramCacheTimeout' ),
239 + 'getwid_general',
240 + 'getwid_general'
241 + );
242 + register_setting(
243 + 'getwid_general',
244 + 'getwid_instagram_cache_timeout',
245 + array(
246 + 'type' => 'number',
247 + 'default' => 30,
248 + )
249 + );
250 + /* #endregion */
216 251
217 - /* #region Google API Key */
218 - add_settings_field( 'getwid_google_api_key', __( 'Google Maps API Key', 'getwid' ),
219 - [ $this, 'renderGoogleApiKey' ], 'getwid_general', 'getwid_general' );
220 - register_setting( 'getwid_general', 'getwid_google_api_key', [ 'type' => 'text', 'default' => '' ] );
221 - /* #endregion */
252 + /* #region Google API Key */
253 + add_settings_field(
254 + 'getwid_google_api_key',
255 + __( 'Google Maps API Key', 'getwid' ),
256 + array( $this, 'renderGoogleApiKey' ),
257 + 'getwid_general',
258 + 'getwid_general'
259 + );
260 + register_setting(
261 + 'getwid_general',
262 + 'getwid_google_api_key',
263 + array(
264 + 'type' => 'text',
265 + 'default' => '',
266 + )
267 + );
268 + /* #endregion */
222 269
223 - /* #region Recaptcha Site Key */
224 - add_settings_field( 'getwid_contact_form_recipient_email', __( 'Recipient Email Address', 'getwid' ),
225 - [ $this, 'renderContactFormRecipientEmail' ], 'getwid_general', 'getwid_contact_from' );
226 - register_setting( 'getwid_general', 'getwid_contact_form_recipient_email', [ 'type' => 'text', 'default' => '' ] );
227 - /* #endregion */
270 + /* #region Recaptcha Site Key */
271 + add_settings_field(
272 + 'getwid_contact_form_recipient_email',
273 + __( 'Recipient Email Address', 'getwid' ),
274 + array( $this, 'renderContactFormRecipientEmail' ),
275 + 'getwid_general',
276 + 'getwid_contact_from'
277 + );
278 + register_setting(
279 + 'getwid_general',
280 + 'getwid_contact_form_recipient_email',
281 + array(
282 + 'type' => 'text',
283 + 'default' => '',
284 + )
285 + );
286 + /* #endregion */
228 287
229 - /* #region Recaptcha Site Key */
230 - add_settings_field( 'getwid_recaptcha_v2_site_key', __( 'Recaptcha Site Key', 'getwid' ),
231 - [ $this, 'renderRecaptchaSiteKey' ], 'getwid_general', 'getwid_contact_from' );
232 - register_setting( 'getwid_general', 'getwid_recaptcha_v2_site_key', [ 'type' => 'text', 'default' => '' ] );
233 - /* #endregion */
288 + /* #region Recaptcha Site Key */
289 + add_settings_field(
290 + 'getwid_recaptcha_v2_site_key',
291 + __( 'Recaptcha Site Key', 'getwid' ),
292 + array( $this, 'renderRecaptchaSiteKey' ),
293 + 'getwid_general',
294 + 'getwid_contact_from'
295 + );
296 + register_setting(
297 + 'getwid_general',
298 + 'getwid_recaptcha_v2_site_key',
299 + array(
300 + 'type' => 'text',
301 + 'default' => '',
302 + )
303 + );
304 + /* #endregion */
234 305
235 - /* #region Recaptcha Secret Key */
236 - add_settings_field( 'getwid_recaptcha_v2_secret_key', __( 'Recaptcha Secret Key', 'getwid' ),
237 - [ $this, 'renderRecaptchaSecretKey' ], 'getwid_general', 'getwid_contact_from' );
238 - register_setting( 'getwid_general', 'getwid_recaptcha_v2_secret_key', [ 'type' => 'text', 'default' => '' ] );
239 - /* #endregion */
306 + /* #region Recaptcha Secret Key */
307 + add_settings_field(
308 + 'getwid_recaptcha_v2_secret_key',
309 + __( 'Recaptcha Secret Key', 'getwid' ),
310 + array( $this, 'renderRecaptchaSecretKey' ),
311 + 'getwid_general',
312 + 'getwid_contact_from'
313 + );
314 + register_setting(
315 + 'getwid_general',
316 + 'getwid_recaptcha_v2_secret_key',
317 + array(
318 + 'type' => 'text',
319 + 'default' => '',
320 + )
321 + );
322 + /* #endregion */
240 323
241 - /* #region Mailchimp Api Key */
242 - add_settings_field( 'getwid_mailchimp_api_key', __( 'Mailchimp API Key', 'getwid' ),
243 - [ $this, 'renderMailchimpApiKey' ], 'getwid_general', 'getwid_general' );
244 - register_setting( 'getwid_general', 'getwid_mailchimp_api_key', [ 'type' => 'text', 'default' => '' ] );
245 - /* #endregion */
324 + /* #region Mailchimp Api Key */
325 + add_settings_field(
326 + 'getwid_mailchimp_api_key',
327 + __( 'Mailchimp API Key', 'getwid' ),
328 + array( $this, 'renderMailchimpApiKey' ),
329 + 'getwid_general',
330 + 'getwid_general'
331 + );
332 + register_setting(
333 + 'getwid_general',
334 + 'getwid_mailchimp_api_key',
335 + array(
336 + 'type' => 'text',
337 + 'default' => '',
338 + )
339 + );
340 + /* #endregion */
246 341
247 342 /* #region Disabled Blocks */
248 - add_settings_field( 'getwid_disabled_blocks', __( 'Disable Getwid Blocks', 'getwid' ),
249 - [ $this, 'renderDisabledBlocks' ], 'getwid_blocks', 'getwid_blocks' );
343 + add_settings_field(
344 + 'getwid_disabled_blocks',
345 + __( 'Disable Getwid Blocks', 'getwid' ),
346 + array( $this, 'renderDisabledBlocks' ),
347 + 'getwid_blocks',
348 + 'getwid_blocks'
349 + );
250 350
251 351 $blocks = getwid()->blocksManager()->getBlocks();
252 352
253 - foreach ($blocks as $name => $block) {
254 - $option_name = $block->getDisabledOptionKey();
255 - register_setting( 'getwid_blocks', $option_name, [ 'type' => 'boolean', 'default' => false, 'sanitize_callback' => 'rest_sanitize_boolean' ] );
353 + foreach ( $blocks as $name => $block ) {
354 + $option_name = $block->get_disabled_option_key();
355 + register_setting(
356 + 'getwid_blocks',
357 + $option_name,
358 + array(
359 + 'type' => 'boolean',
360 + 'default' => false,
361 + 'sanitize_callback' => 'rest_sanitize_boolean',
362 + )
363 + );
256 364 }
257 - /* #endregion */
258 - }
365 + /* #endregion */
366 + }
259 367
260 - public function renderSectionContentWidth() {
368 + public function renderSectionContentWidth() {
261 369
262 - $field_val = get_option( 'getwid_section_content_width', '' );
370 + $field_val = get_option( 'getwid_section_content_width', '' );
263 371
264 - ?>
372 + ?>
265 373 <input type="number" id="getwid_section_content_width" name="getwid_section_content_width" value="<?php echo esc_attr( $field_val ); ?>" />
266 - <?php echo esc_html_x( 'px', 'pixels', 'getwid' ); ?>
374 + <?php echo esc_html_x( 'px', 'pixels', 'getwid' ); ?>
267 375 <p class="description"><?php echo esc_html__( 'Default width of the content area in the Section block. Leave empty to use $content_width set in your theme. Set 0 to disable this option and control it via CSS.', 'getwid' ); ?></p>
268 376 <?php
269 - }
377 + }
270 378
271 - public function renderInstagramToken() {
379 + public function renderInstagramToken() {
272 380
273 381 $encryption = new StringEncryption();
274 - $field_val = $encryption->decrypt( get_option( 'getwid_instagram_token', '' ) );
382 + $field_val = $encryption->decrypt( get_option( 'getwid_instagram_token', '' ) );
275 383
276 384 $connectURL = add_query_arg(
277 - ['nonce' => wp_create_nonce('getwid_nonce_save_instagram_token') ],
385 + array( 'nonce' => wp_create_nonce( 'getwid_nonce_save_instagram_token' ) ),
278 386 admin_url( 'options-general.php' )
279 387 );
280 388
281 389 $refreshURL = add_query_arg(
282 - ['nonce' => wp_create_nonce('getwid_nonce_save_instagram_token') ],
390 + array( 'nonce' => wp_create_nonce( 'getwid_nonce_save_instagram_token' ) ),
283 391 admin_url( 'options-general.php' )
284 392 );
285 393
286 394 ?>
287 - <input type="text" id="getwid_instagram_token" name="getwid_instagram_token" class="regular-text" value="<?php echo esc_attr( $field_val ); ?>" /><?php
395 + <input type="text" id="getwid_instagram_token" name="getwid_instagram_token" class="regular-text" value="<?php echo esc_attr( $field_val ); ?>" />
396 + <?php
288 397
289 - if ( ! empty( $field_val ) ) {
398 + if ( ! empty( $field_val ) ) {
290 399
291 - try {
400 + try {
292 401
293 - $profile_data_json = wp_remote_get(
294 - 'https://graph.instagram.com/me?fields=username&access_token=' . $field_val
295 - );
402 + $profile_data_json = wp_remote_get(
403 + 'https://graph.instagram.com/me?fields=username&access_token=' . $field_val
404 + );
296 405
297 - if ( ( ! is_wp_error( $profile_data_json ) ) && ( 200 === wp_remote_retrieve_response_code( $profile_data_json ) ) ) {
406 + if ( ( ! is_wp_error( $profile_data_json ) ) && ( 200 === wp_remote_retrieve_response_code( $profile_data_json ) ) ) {
298 407
299 - $profile_data = json_decode( $profile_data_json['body'] );
408 + $profile_data = json_decode( $profile_data_json['body'] );
300 409
301 - if ( json_last_error() === JSON_ERROR_NONE ) {
410 + if ( json_last_error() === JSON_ERROR_NONE ) {
302 411
303 - if ( isset( $profile_data->username ) ) {
412 + if ( isset( $profile_data->username ) ) {
304 413
305 - echo '<p class="description">' . sprintf(
306 - //translators: %s is username or user id
307 - esc_html__('Account: %s', 'getwid'),
308 - esc_html( $profile_data->username )
309 - ) . '<p>';
414 + echo '<p class="description">' . sprintf(
415 + //translators: %s is username or user id
416 + esc_html__( 'Account: %s', 'getwid' ),
417 + esc_html( $profile_data->username )
418 + ) . '<p>';
310 419
311 - } elseif ( isset( $profile_data->id ) ) {
420 + } elseif ( isset( $profile_data->id ) ) {
312 421
313 - echo '<p class="description">' . sprintf(
314 - //translators: %s is username or user id
315 - esc_html__('Account: %s', 'getwid'),
316 - esc_html( $profile_data->id )
317 - ) . '</p>';
318 - }
422 + echo '<p class="description">' . sprintf(
423 + //translators: %s is username or user id
424 + esc_html__( 'Account: %s', 'getwid' ),
425 + esc_html( $profile_data->id )
426 + ) . '</p>';
319 427 }
320 428 }
321 - } catch ( \Exception $profile_data_exception ) {
429 + }
430 + } catch ( \Exception $profile_data_exception ) {
322 431
323 - echo esc_html( $profile_data_exception->getMessage() );
324 - }
432 + echo esc_html( $profile_data_exception->getMessage() );
325 433 }
434 + }
326 435
327 436 ?>
328 - <p><a href="<?php echo esc_url(
437 + <p><a href="
438 + <?php
439 + echo esc_url(
329 440 'https://www.instagram.com/oauth/authorize?enable_fb_login=0&force_authentication=0&client_id=1815611002603068&redirect_uri=' .
330 441 'https://api.getmotopress.com/get_instagram_token2.php&scope=instagram_business_basic&response_type=code&state=' .
331 - $connectURL ); ?>" class="button button-default"><?php echo esc_html__( 'Connect Instagram Account', 'getwid' );?></a>
442 + $connectURL
443 + );
444 + ?>
445 + " class="button button-default"><?php echo esc_html__( 'Connect Instagram Account', 'getwid' ); ?></a>
332 446 <?php
333 - if ( ! empty( $field_val) ) {
447 + if ( ! empty( $field_val ) ) {
334 448 ?>
335 - <a href="<?php echo esc_url(
449 + <a href="
450 + <?php
451 + echo esc_url(
336 452 'https://api.getmotopress.com/refresh_instagram_token2.php?access_token=' . $field_val . '&state=' .
337 - $refreshURL ); ?>" class="button button-default"><?php echo esc_html__( 'Refresh Access Token', 'getwid' );?></a>
453 + $refreshURL
454 + );
455 + ?>
456 + " class="button button-default"><?php echo esc_html__( 'Refresh Access Token', 'getwid' ); ?></a>
338 457 <?php
339 458 }
340 459 ?>
341 460 </p>
342 461 <?php
343 - }
462 + }
344 463
345 464 public function renderInstagramCacheTimeout() {
346 465
347 - $field_val = get_option('getwid_instagram_cache_timeout');
466 + $field_val = get_option( 'getwid_instagram_cache_timeout' );
348 467 ?>
349 468 <input type="number" id="getwid_instagram_cache_timeout" name="getwid_instagram_cache_timeout" value="<?php echo esc_attr( $field_val ); ?>" />
350 469 <p class="description"><?php echo esc_html__( 'Time until expiration of media data in minutes. Setting to 0 means no expiration.', 'getwid' ); ?></p>
351 470 <?php
352 - }
471 + }
353 472
354 - public function renderGoogleApiKey() {
473 + public function renderGoogleApiKey() {
355 474
356 - $field_val = get_option('getwid_google_api_key', '');
475 + $field_val = get_option( 'getwid_google_api_key', '' );
357 476 ?>
358 - <input type="text" id="getwid_google_api_key" name="getwid_google_api_key" class="regular-text" value="<?php echo esc_attr( $field_val ); ?>" />
477 + <input type="text" id="getwid_google_api_key" name="getwid_google_api_key" class="regular-text" value="<?php echo esc_attr( $field_val ); ?>" />
359 478 <?php
360 - }
479 + }
361 480
362 481 public function renderContactFormRecipientEmail() {
363 482
364 - $field_val = get_option( 'getwid_contact_form_recipient_email', '' );
483 + $field_val = get_option( 'getwid_contact_form_recipient_email', '' );
365 484 $default_email = get_option( 'admin_email' );
366 485
367 486 ?>
368 487 <input type="text" id="getwid_contact_form_recipient_email" name="getwid_contact_form_recipient_email" class="regular-text" value="<?php echo esc_attr( $field_val ); ?>" placeholder="<?php echo esc_attr( $default_email ); ?>"/>
@@ -368,35 +487,35 @@
368 487 <input type="text" id="getwid_contact_form_recipient_email" name="getwid_contact_form_recipient_email" class="regular-text" value="<?php echo esc_attr( $field_val ); ?>" placeholder="<?php echo esc_attr( $default_email ); ?>"/>
369 488 <?php
370 489 }
371 490
372 - public function renderRecaptchaSiteKey() {
491 + public function renderRecaptchaSiteKey() {
373 492
374 - $field_val = get_option( 'getwid_recaptcha_v2_site_key', '' );
493 + $field_val = get_option( 'getwid_recaptcha_v2_site_key', '' );
375 494 ?>
376 - <input type="text" id="getwid_recaptcha_v2_site_key" name="getwid_recaptcha_v2_site_key" class="regular-text" value="<?php echo esc_attr( $field_val ); ?>" />
495 + <input type="text" id="getwid_recaptcha_v2_site_key" name="getwid_recaptcha_v2_site_key" class="regular-text" value="<?php echo esc_attr( $field_val ); ?>" />
377 496 <?php
378 - }
497 + }
379 498
380 - public function renderRecaptchaSecretKey() {
499 + public function renderRecaptchaSecretKey() {
381 500
382 - $field_val = get_option( 'getwid_recaptcha_v2_secret_key', '' );
501 + $field_val = get_option( 'getwid_recaptcha_v2_secret_key', '' );
383 502 ?>
384 - <input type="text" id="getwid_recaptcha_v2_secret_key" name="getwid_recaptcha_v2_secret_key" class="regular-text" value="<?php echo esc_attr( $field_val ); ?>" />
503 + <input type="text" id="getwid_recaptcha_v2_secret_key" name="getwid_recaptcha_v2_secret_key" class="regular-text" value="<?php echo esc_attr( $field_val ); ?>" />
385 504 <?php
386 - }
505 + }
387 506
388 - public function renderMailchimpApiKey() {
507 + public function renderMailchimpApiKey() {
389 508
390 - $field_val = get_option( 'getwid_mailchimp_api_key', '' );
509 + $field_val = get_option( 'getwid_mailchimp_api_key', '' );
391 510 ?>
392 - <input type="text" id="getwid_mailchimp_api_key" name="getwid_mailchimp_api_key" class="regular-text" value="<?php echo esc_attr( $field_val ); ?>" />
511 + <input type="text" id="getwid_mailchimp_api_key" name="getwid_mailchimp_api_key" class="regular-text" value="<?php echo esc_attr( $field_val ); ?>" />
393 512 <?php
394 - }
513 + }
395 514
396 515 public function renderDisabledBlocks() {
397 516
398 - $blocks = getwid()->blocksManager()->getBlocks();
517 + $blocks = getwid()->blocksManager()->getControlledBlocks();
399 518 $disabledBlocks = getwid()->blocksManager()->getDisabledBlocks();
400 519 ksort( $blocks );
401 520 ?>
402 521 <p class="description">
@@ -402,26 +521,30 @@
402 521 <p class="description">
403 522 <?php
404 523 printf(
405 524 //translators: %1$s, %2$s is a number of total and disabled blocks
406 - esc_html__('Total: %1$s, Disabled: %2$s', 'getwid'),
407 - esc_html( sizeof($blocks) ),
408 - esc_html( sizeof($disabledBlocks) )
525 + esc_html__( 'Total: %1$s, Disabled: %2$s', 'getwid' ),
526 + esc_html( sizeof( $blocks ) ),
527 + esc_html( sizeof( $disabledBlocks ) )
409 528 );
410 - ?><br/>
411 - <input type="button" id="getwid-disabled-blocks-select-all" class="button button-link" value="<?php esc_html_e('Select All', 'getwid'); ?>" />
529 + ?>
530 + <br/>
531 + <input type="button" id="getwid-disabled-blocks-select-all" class="button button-link" value="<?php esc_html_e( 'Select All', 'getwid' ); ?>" />
412 532 &nbsp;/&nbsp;
413 - <input type="button" id="getwid-disabled-blocks-deselect-all" class="button button-link" value="<?php esc_html_e('Deselect All', 'getwid'); ?>" />
533 + <input type="button" id="getwid-disabled-blocks-deselect-all" class="button button-link" value="<?php esc_html_e( 'Deselect All', 'getwid' ); ?>" />
414 534 </p>
415 535 <fieldset id="getwid-disabled-blocks">
416 536 <?php
417 - foreach ($blocks as $name => $block) {
418 - $option_name = $block->getDisabledOptionKey();
537 + foreach ( $blocks as $name => $block ) {
538 + $option_name = $block->get_disabled_option_key();
419 539 ?>
420 540 <label for="<?php echo esc_attr( $option_name ); ?>">
421 - <input type="checkbox" id="<?php echo esc_attr( $option_name ); ?>" name="<?php echo esc_attr( $option_name ); ?>" value="1" <?php
422 - checked( '1', $block->isDisabled() ); ?> />
423 - <?php echo esc_html( $block->getLabel() ); ?>
541 + <input type="checkbox" id="<?php echo esc_attr( $option_name ); ?>" name="<?php echo esc_attr( $option_name ); ?>" value="1"
542 + <?php
543 + checked( '1', $block->is_disabled() );
544 + ?>
545 + />
546 + <?php echo esc_html( $block->get_label() ); ?>
424 547 </label><br/>
425 548 <?php
426 549 }
427 550 ?>
@@ -436,14 +559,14 @@
436 559 });
437 560 })
438 561 </script>
439 562 <?php
440 - }
563 + }
441 564
442 565 public function renderPostTemplatesTab() {
443 566 ?>
444 567 <p><?php esc_html_e( 'Post Templates are used for presenting posts in a certain format and style. You can change how a post looks by choosing a post template in the Custom Post Type and related blocks.', 'getwid' ); ?></p>
445 - <a class="button button-primary" href="<?php echo esc_url( admin_url('edit.php?post_type=getwid_template_part') ); ?>"><?php esc_html_e( 'Manage Post Templates', 'getwid' ); ?></a>
568 + <a class="button button-primary" href="<?php echo esc_url( admin_url( 'edit.php?post_type=getwid_template_part' ) ); ?>"><?php esc_html_e( 'Manage Post Templates', 'getwid' ); ?></a>
446 569 <?php
447 570 }
448 571
449 572 public function renderAnimation() {
@@ -450,66 +573,34 @@
450 573
451 574 $field_val = get_option( 'getwid_smooth_animation', false );
452 575 ?>
453 576 <label for="getwid_smooth_animation">
454 - <input type="checkbox" id="getwid_smooth_animation" name="getwid_smooth_animation" value="1" <?php
455 - checked( '1', $field_val ); ?> />
456 - <?php echo esc_html__('Enable smooth animation of blocks', 'getwid'); ?>
577 + <input type="checkbox" id="getwid_smooth_animation" name="getwid_smooth_animation" value="1"
578 + <?php
579 + checked( '1', $field_val );
580 + ?>
581 + />
582 + <?php echo esc_html__( 'Enable smooth animation of blocks', 'getwid' ); ?>
457 583 </label>
458 - <p class="description"><?php
459 - echo esc_html__('Hides block until the entrance animation starts. Prevents possible occurrence of horizontal scroll during the animation.', 'getwid');
460 - ?></p>
584 + <p class="description">
461 585 <?php
462 - }
463 -
464 - public function renderAssetsOptimization() {
465 -
466 - $getwid_load_assets_on_demand = get_option( 'getwid_load_assets_on_demand', false );
467 - $getwid_move_css_to_head = get_option( 'getwid_move_css_to_head', false );
586 + echo esc_html__( 'Hides block until the entrance animation starts. Prevents possible occurrence of horizontal scroll during the animation.', 'getwid' );
468 587 ?>
469 - <fieldset>
470 - <label for="getwid_load_assets_on_demand">
471 - <input type="checkbox" id="getwid_load_assets_on_demand" name="getwid_load_assets_on_demand" value="1" <?php
472 - checked( '1', $getwid_load_assets_on_demand ); ?> />
473 - <?php echo esc_html__('Load CSS and JS of blocks on demand', 'getwid') . ' (Recomended)'; ?>
474 - </label>
475 - <p class="description"><?php
476 - echo esc_html__('If this option is on, all CSS and JS files of blocks will be loaded on demand in footer. This will reduce the amount of heavy assets on the page.', 'getwid');
477 - ?></p>
478 - <br/>
479 - <label for="getwid_move_css_to_head">
480 - <input type="checkbox" id="getwid_move_css_to_head" name="getwid_move_css_to_head" value="1" <?php
481 - checked( '1', $getwid_move_css_to_head ); ?> />
482 - <?php echo esc_html__('Aggregate all CSS files of blocks in header', 'getwid') . ' (Recomended)'; ?>
483 - </label>
484 - <p class="description"><?php
485 - echo esc_html__('If this option is on, all CSS files of blocks will be moved to header for better theme compatibility. If your theme has custom styling for Getwid blocks, its styles will be applied first.', 'getwid');
486 - ?></p>
487 - <br/>
488 - <p class="description"><?php
489 - echo esc_html__('These settings may break some blocks in posts loaded via Ajax. These settings may not work together with optimization plugins.', 'getwid');
490 - ?></p>
491 - </fieldset>
492 - <script>
493 - jQuery(document).ready(function(){
494 - // set initial state
495 - jQuery('#getwid_move_css_to_head').toggleClass("disabled", ! jQuery('#getwid_load_assets_on_demand').prop("checked") );
496 - // bind state change
497 - jQuery('#getwid_load_assets_on_demand').change(function(e) {
498 - jQuery('#getwid_move_css_to_head').toggleClass("disabled", ! jQuery(this).prop("checked") );
499 - });
500 - })
501 - </script>
588 + </p>
502 589 <?php
503 590 }
504 591
505 - public function getTabUrl( $tab = 'general' )
506 - {
507 - return add_query_arg( [ 'page' => 'getwid', 'active_tab' => $tab ], admin_url( 'options-general.php' ) );
592 + public function getTabUrl( $tab = 'general' ) {
593 + return add_query_arg(
594 + array(
595 + 'page' => 'getwid',
596 + 'active_tab' => $tab,
597 + ),
598 + admin_url( 'options-general.php' )
599 + );
508 600 }
509 601
510 - private function getActiveTabID()
511 - {
602 + private function getActiveTabID() {
512 603 $tab_param_isset = isset( $_GET['active_tab'] ) && array_key_exists( $_GET['active_tab'], $this->getSettingsGroups() );
513 - return $tab_param_isset ? sanitize_text_field( wp_unslash( $_GET['active_tab'] ) ) : 'general';
604 + return $tab_param_isset ? sanitize_text_field( wp_unslash( $_GET['active_tab'] ) ) : 'general';
514 605 }
515 606 }