PluginProbe
Themify Builder / 7.7.3
Themify Builder v7.7.3
7.8.1 7.8.0 7.7.9 7.7.8 7.7.7 7.7.6 7.7.5 7.7.4 7.7.3 7.7.2 trunk 7.6.0 7.6.1 7.6.2 7.6.3 7.6.4 7.6.5 7.6.6 7.6.7 7.6.8 7.6.9 7.7.0 7.7.1
themify-builder / plugin / classes / class-themify-builder-settings.php

class-themify-builder-settings.php in Themify Builder 7.7.3, at plugin/classes/class-themify-builder-settings.php

774 lines 38.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 if (!class_exists('Themify_Builder_Options',false)) :
4
5 /**
6 * Class Builder Options
7 */
8 class Themify_Builder_Options {
9
10 private const KEY = 'themify_builder_setting';
11 private const SLUG = 'themify-builder';
12
13 /**
14 * Constructor
15 */
16 public static function init() {
17 if (is_admin()) {
18 add_action('admin_menu', array(__CLASS__, 'add_plugin_page'));
19 add_action('wp_ajax_themify_builder_settings_save', array(__CLASS__, 'save'));
20 } else {
21 add_action('wp_head', array(__CLASS__, 'show_custom_css'));
22 }
23 }
24
25 public static function add_plugin_page() {
26 if (Themify_Access_Role::check_access_backend()) {
27 $can_manage_option = current_user_can('manage_options');
28 // This page will be under "Settings"
29 $name = __('Themify Builder', 'themify');
30 add_menu_page($name, $name, 'edit_posts', self::SLUG, $can_manage_option ? array(__CLASS__, 'create_admin_page') : '', THEMIFY_URI . '/img/favicon.svg', 50);
31 if ($can_manage_option) {
32 add_submenu_page(self::SLUG, __('Settings', 'themify'), __('Settings', 'themify'), 'manage_options', self::SLUG);
33 }
34
35 add_submenu_page('themify-builder', __('Saved Layouts', 'themify'), __('Saved Layouts', 'themify'), 'edit_posts', 'edit.php?post_type=' . Themify_Builder_Layouts::LAYOUT_SLUG);
36 add_submenu_page('themify-builder', __('Layout Parts', 'themify'), __('Layout Parts', 'themify'), 'edit_posts', 'edit.php?post_type=' . Themify_Builder_Layouts::LAYOUT_PART_SLUG);
37 add_submenu_page('themify-builder', __('Global Styles', 'themify'), __('Global Styles', 'themify'), 'edit_posts', 'themify-global-styles', array(__CLASS__, 'global_styles_page'));
38 add_submenu_page('themify-builder', __('Custom Fonts', 'themify'), __('Custom Fonts', 'themify'), 'edit_posts', 'edit.php?post_type=' . Themify_Custom_Fonts::SLUG);
39
40 if (!$can_manage_option) {
41 remove_submenu_page(self::SLUG, self::SLUG);
42 }
43 }
44 }
45
46 public static function save() {
47 check_ajax_referer('tf_nonce', 'nonce');
48 if (current_user_can('manage_options') && Themify_Access_Role::check_access_backend()) {
49 if (isset($_POST['data'])) {
50 $data = stripslashes_deep($_POST['data']);
51 } elseif (isset($_FILES['data'])) {
52 $data = file_get_contents($_FILES['data']['tmp_name']);
53 }
54 if (isset($data)) {//don't use empty, when builder is empty need to remove data
55 $results = array();
56 $exist_data = get_option(self::KEY);
57 $isExist = $exist_data !== false;
58 if (empty($exist_data)) {
59 $exist_data = array();
60 }
61 if (!empty($data)) {
62 $data = json_decode($data, true);
63 foreach ($data as $k => $v) {
64 if ($v === '' || $v === 'default') {
65 unset($data[$k]);
66 }
67 }
68 $success = maybe_serialize($exist_data) === maybe_serialize($data) ? true : update_option(self::KEY, $data, false);
69 } else {
70 $success = $isExist === true ? delete_option(self::KEY) : true;
71 $data = array();
72 }
73 if ($success === true) {
74 Themify_Enqueue_Assets::rewrite_htaccess(empty($data['performance-cache_gzip']), empty($data['performance-webp']), empty($data['performance-cache_browser']));
75 foreach (array('tablet_landscape', 'tablet', 'mobile') as $breakpoint) {
76 if (isset($data["builder_responsive_design_{$breakpoint}"], $exist_data["builder_responsive_design_{$breakpoint}"]) && $data["builder_responsive_design_{$breakpoint}"] !== $exist_data["builder_responsive_design_{$breakpoint}"]) {
77 Themify_Builder_Stylesheet::regenerate_css_files();
78 break;
79 }
80 }
81 }
82 do_action( 'themify_builder_settings_save' );
83 wp_send_json_success();
84 }
85 }
86 wp_send_json_error();
87 }
88
89 /**
90 * Display Builder Styles page content
91 * @return String
92 * @since 4.5.0
93 */
94 public static function global_styles_page() {
95 if (!current_user_can('edit_posts')) {
96 wp_die(__('You do not have sufficient permissions to update this site.', 'themify'));
97 }
98
99 return Themify_Global_Styles::page_content();
100 }
101
102 private static function get_tab_settings():array {
103 $modules=Themify_Builder_Component_Module::load_modules('all');
104 $responsive = $disableModules = $feature_sizes = $disablePosts = array();
105 $defBreakPoints = array(
106 'tablet_landscape' => 1024,
107 'tablet' => 768,
108 'mobile' => 600
109 );
110 foreach (themify_get_breakpoints('', true) as $bp => $val) {
111 $label = $bp === 'tablet_landscape' ? 'Tablet Landscape' : ($bp === 'tablet' ? 'Tablet Portrait' : ucfirst($bp));
112 $responsive[] = array(
113 'type' => 'slider',
114 'id' => 'builder_responsive_design_' . $bp,
115 'label' => sprintf(__('%s', 'themify'), $label),
116 'def' => $defBreakPoints[$bp],
117 'min' => is_array($val) ? $val[0] : 320,
118 'max' => is_array($val) ? $val[1] : $val
119 );
120 }
121 foreach ($modules as $k => $m) {
122 $name= is_string($m)?$m::get_module_name():$m->get_name();
123 $disableModules[] = array(
124 'label' => sprintf(__('"%s" module', 'themify'), $name),
125 'id' => 'builder_exclude_module_' . $k,
126 'opp' => 1,
127 'type' => 'toggle'
128 );
129 }
130 foreach (themify_get_image_sizes_list() as $opt) {
131 $feature_sizes[$opt['value']] = $opt['name'];
132 }
133 $excludes = array(Themify_Builder_Layouts::LAYOUT_PART_SLUG, Themify_Builder_Layouts::LAYOUT_SLUG, Themify_Global_Styles::SLUG, 'tbp_template');
134 $globalGutters = Themify_Builder_Model::get_gutters();
135 foreach (Themify_Builder::builder_post_types_support() as $v) {
136 if (!in_array($v, $excludes, true)) {
137 $disablePosts[] = array(
138 'label' => sprintf(__('"%s" type', 'themify'), $v),
139 'id' => 'builder_disable_tb_' . $v,
140 'opp' => 1,
141 'type' => 'toggle'
142 );
143 }
144 }
145 unset($excludes, $defBreakPoints);
146 $imageLibrary = wp_image_editor_supports() !== false;
147 return array(
148 array(
149 'type' => 'group',
150 'label' => __('Column Gutter Size', 'themify'),
151 'options' => array(
152 array(
153 'type' => 'number',
154 'step' => .1,
155 'id' => 'setting-gutter',
156 'def' => $globalGutters['gutter'],
157 'after' => __('Normal gutter (%)', 'themify')
158 ),
159 array(
160 'type' => 'number',
161 'step' => .1,
162 'id' => 'setting-narrow',
163 'def' => $globalGutters['narrow'],
164 'after' => __('Narrow gutter (%)', 'themify')
165 ),
166 array(
167 'type' => 'number',
168 'step' => .1,
169 'id' => 'setting-none',
170 'def' => $globalGutters['none'],
171 'after' => __('None gutter (%)', 'themify')
172 ),
173 )
174 ),
175 array(
176 'label' => __('Gallery Module Lightbox', 'themify'),
177 'type' => 'toggle',
178 'id' => 'builder_lightbox',
179 'value' => 'disable',
180 'opp' => 1
181 ),
182 array(
183 'label' => __('Keyboard Shortcuts', 'themify'),
184 'type' => 'toggle',
185 'id' => 'builder_disable_shortcuts',
186 'opp' => 1,
187 'help' => __('Builder shortcuts (eg. disable shortcut like Cmd+S = save)', 'themify'),
188 ),
189 array(
190 'label' => __('WordPress Classic Editor', 'themify'),
191 'type' => 'toggle',
192 'id' => 'builder_disable_wp_editor',
193 'opp' => 1,
194 'help' => __('Enable/disable WordPress Classic Editor when Builder is in use', 'themify')
195 ),
196 array(
197 'label' => __('Google Fonts List', 'themify'),
198 'type' => 'radio',
199 'id' => 'builder_google_fonts',
200 'def' => 'less',
201 'options' => array(
202 'less' => __('Show recommended Google Fonts only', 'themify'),
203 'full' => __('Show all Google Fonts (showing all fonts will take longer to load)', 'themify'),
204 )
205 ),
206 array(
207 'type' => 'group',
208 'label' => __('Download Google Fonts', 'themify'),
209 'options' => array(
210 array(
211 'type' => 'toggle',
212 'id' => 'setting-gf',
213 'desc' => __('Downloads all Google Fonts used in the Builder to your local server. Note: Google Maps, YouTube and any embeds loaded in iframe are excluded as they are loaded in the iframe.', 'themify'),
214 ),
215 array(
216 'type' => 'clear_cache',
217 'action' => 'themify_clear_gfonts',
218 'text' => __('Clear Google Fonts Cache', 'themify'),
219 'clearing' => __('Clearing...', 'themify'),
220 'done' => __('Done', 'themify')
221 ),
222 )
223 ),
224 array(
225 'type' => 'group',
226 'label' => __('Animation Effects', 'themify'),
227 'options' => array(
228 array(
229 'label' => __('Appearance Animation', 'themify'),
230 'type' => 'select',
231 'id' => 'builder_animation_appearance',
232 'options' => array(
233 '' => '',
234 'mobile' => __('Disable on mobile & tablet', 'themify'),
235 'all' => __('Disable on all devices', 'themify')
236 )
237 ),
238 array(
239 'label' => __('Parallax Background', 'themify'),
240 'type' => 'select',
241 'id' => 'builder_animation_parallax_bg',
242 'options' => array(
243 '' => '',
244 'mobile' => __('Disable on mobile & tablet', 'themify'),
245 'all' => __('Disable on all devices', 'themify')
246 )
247 ),
248 array(
249 'label' => __('Scroll Effects', 'themify'),
250 'type' => 'select',
251 'id' => 'builder_animation_scroll_effect',
252 'options' => array(
253 '' => '',
254 'mobile' => __('Disable on mobile & tablet', 'themify'),
255 'all' => __('Disable on all devices', 'themify')
256 )
257 ),
258 )
259 ),
260 array(
261 'type' => 'group',
262 'label' => __('Responsive Breakpoints', 'themify'),
263 'options' => $responsive
264 ),
265 array(
266 'type' => 'number',
267 'id' => 'builder_scrollTo',
268 'label' => __('ScrollTo Offset', 'themify'),
269 'after' => 'px',
270 'help' => __('Enter the top position where it should scrollTo', 'themify')
271 ),
272 array(
273 'type' => 'number',
274 'id' => 'builder_scrollTo_speed',
275 'label' => __('ScrollTo Speed', 'themify'),
276 'after' => 'Seconds',
277 'step' => .1,
278 'help' => __('Speed of scrolling animation. Default: 0.9 second', 'themify')
279 ),
280 array(
281 'label' => __('Image Script', 'themify'),
282 'type' => 'toggle',
283 'id' => 'image_setting-img_settings_use',
284 'opp' => 1,
285 'help' => __('Image script crops the images to the entered size. If disabled, WordPress Featured Image or original images will be used.', 'themify'),
286 'disabled' => $imageLibrary ? '' : sprintf(__('This feature requires an <a href="%s" target="_blank">image processing library</a> to be installed on the server. Please contact your hosting provider to enable this.', 'themify'), 'https://www.php.net/manual/en/refs.utilspec.image.php'),
287 'bind' => array(
288 'checked' => array(
289 'show' => 'featured_size'
290 ),
291 'not_checked' => array(
292 'hide' => 'featured_size'
293 )
294 )
295 ),
296 array(
297 'label' => __('Default Featured Image Size', 'themify'),
298 'type' => 'select',
299 'wrap_class' => $imageLibrary ? 'featured_size' : '',
300 'id' => 'image_global_size_field',
301 'options' => $feature_sizes
302 ),
303 array(
304 'label' => __('Builder For Post Types', 'themify'),
305 'type' => 'group',
306 'options' => $disablePosts
307 ),
308 array(
309 'label' => __('Builder Modules', 'themify'),
310 'type' => 'group',
311 'options' => $disableModules
312 )
313 );
314 }
315
316 private static function get_tab_performance():array {
317 $htaccess_file = Themify_Enqueue_Assets::getHtaccessFile();
318 $htaccess_msg = Themify_Filesystem::is_file($htaccess_file) && Themify_Filesystem::is_writable($htaccess_file) ? '' : sprintf(__('The htaccess file %s isn`t writable. Please allow to write to enable this feauture', 'themify'), $htaccess_file);
319 $imageLibrary = wp_image_editor_supports() !== false;
320 $options = array(
321 array(
322 'type' => 'group',
323 'label' => __('Lazy Load', 'themify'),
324 'options' => array(
325 array(
326 'label' => __('Themify Lazy Load', 'themify'),
327 'type' => 'toggle',
328 'id' => 'performance-disable-lazy',
329 'opp' => 1
330 )
331 )
332 ),
333 array(
334 'label' => __('Browser Caching', 'themify'),
335 'type' => 'toggle',
336 'help' => __("Cache static assets (CSS, JS, images, etc.) on user's browser. HTML is not cached", 'themify'),
337 'disabled' => $htaccess_msg,
338 'id' => 'performance-cache_browser',
339 ),
340 array(
341 'label' => __('Gzip Scripts', 'themify'),
342 'type' => 'toggle',
343 'id' => 'performance-cache_gzip',
344 'disabled' => $htaccess_msg,
345 'desc' => $htaccess_msg === '' ? sprintf(__('Enabling Gzip will add code to your .htaccess file %s', 'themify'), $htaccess_file) : '',
346 ),
347 array(
348 'label' => __('Enable jQuery Migrate', 'themify'),
349 'type' => 'toggle',
350 'id' => 'performance-jquery_migrate',
351 'help' => __('Enable this option if you have plugins that use deprecated jQuery versions.', 'themify')
352 ),
353 array(
354 'label' => __('WebP Images', 'themify'),
355 'type' => 'toggle',
356 'id' => 'performance-webp',
357 'help' => __('Enable WebP image (recommended)', 'themify'),
358 'disabled' => $imageLibrary ? '' : __('The GD library or Imagick extensions are not installed. Ask your host provider to enable them to use this feature.', 'themify'),
359 'bind' => array(
360 'checked' => array(
361 'show' => 'webp_group'
362 ),
363 'not_checked' => array(
364 'hide' => 'webp_group'
365 )
366 )
367 ),
368 array(
369 'type' => 'group',
370 'label' => __('WebP Image Quality', 'themify'),
371 'help' => __('Lower quality has smaller file size, but image might appear pixelated/blurry.', 'themify'),
372 'wrap_class' => 'webp_group',
373 'options' => array(
374 array(
375 'type' => 'select',
376 'disabled' => $imageLibrary ? '' : 'disable',
377 'id' => 'performance-webp_quality',
378 'def' => '5',
379 'options' => array(
380 '1' => __('Lowest', 'themify'),
381 '2' => __('Low', 'themify'),
382 '3' => __('Medium', 'themify'),
383 '4' => __('Good', 'themify'),
384 '5' => __('High', 'themify'),
385 '6' => __('Highest', 'themify'),
386 )
387 ),
388 array(
389 'type' => 'clear_cache',
390 'disabled' => $imageLibrary ? '' : 'disable',
391 'action' => 'themify_clear_all_webp',
392 'text' => __('Clear WebP Images', 'themify'),
393 'clearing' => __('Clearing...', 'themify'),
394 'done' => __('Done', 'themify')
395 ),
396 )
397 ),
398 array(
399 'label' => __('Concate CSS', 'themify'),
400 'type' => 'clear_cache',
401 'action' => 'themify_clear_all_concate',
402 'text' => __('Clear Concate CSS Cache', 'themify'),
403 'clearing' => __('Clearing...', 'themify'),
404 'done' => __('Done', 'themify'),
405 'disabled' => Themify_Enqueue_Assets::createDir() ? '' : __('It looks like the WordPress upload folder path is set wrong or have file permission issue. Please check the upload path on WP Settings > Media. Make sure the folder is set correctly and it has correct file permission.', 'themify'),
406 'network' => is_multisite() ? array('tmp_cache_concte_network' => __('Clear Concate cache in the whole network site', 'themify')) : '',
407 ),
408 );
409 if(themify_is_woocommerce_active()){
410 $options[]=array(
411 'label' => __('WooCommerce Script Defer', 'themify'),
412 'type' => 'toggle',
413 'id' => 'defer-wc',
414 'opp' => 1,
415 'help' => __('WooCommerce scripts are deferred for faster page load. If you are encountering issues with third party WooCommerce extensions, try to disable script defer.', 'themify'),
416 'desc' => __('Disable WooCommerce script defer', 'themify'),
417 );
418 }
419 return $options;
420
421 }
422
423 private static function get_tab_role_access():array {
424 global $wp_roles;
425 $defaultRoles = array(
426 'backend' => __('Builder Backend Access', 'themify'),
427 'frontend' => __('Builder Frontend Access', 'themify')
428 );
429 $role_options = array(
430 'default' => __('Default', 'themify'),
431 'enable' => __('Enable', 'themify'),
432 'disable' => __('Disable', 'themify')
433 );
434 $result = array();
435 $roles = $wp_roles->get_names();
436 $defaultRoles = apply_filters('tb_roles', $defaultRoles);
437 // Remove the adminitrator and subscriber user role from the array
438 unset($roles['administrator']);
439
440 // Remove all the user roles with no "edit_posts" capability
441 foreach ($roles as $role => $slug) {
442 if (empty($wp_roles->roles[$role]['capabilities']['edit_posts'])) {
443 unset($roles[$role]);
444 }
445 }
446
447 foreach ($defaultRoles as $k => $v) {
448 $opt = array();
449 foreach ($roles as $type => $name) {
450 $opt[] = array(
451 'type' => 'select',
452 'label' => $name,
453 'id' => 'setting-' . $k . '-' . $type,
454 'options' => $k === 'tbp' ? array_merge( $role_options, [ 'enableown' => __( 'Enable For Owned Posts', 'themify' ) ] ) : $role_options
455 );
456 }
457 $result[] = array(
458 'type' => 'group',
459 'label' => $v,
460 'options' => $opt
461 );
462 }
463 return $result;
464 }
465
466 private static function get_tab_custom_css():array {
467 return array(
468 array(
469 'label' => __('Custom CSS', 'themify'),
470 'id' => 'custom_css-custom_css',
471 'type' => 'textarea',
472 'codeditor' => 'css'
473 )
474 );
475 }
476
477 private static function get_tab_integration():array {
478
479 include_once THEMIFY_BUILDER_INCLUDES_DIR . '/optin-services/base.php';
480 $providers = Builder_Optin_Service::get_providers('all',true);
481 $optins = array();
482 foreach ($providers as $id => $provider) {
483 $options = $provider::get_global_options();
484 if (!empty($options)) {
485 foreach ($options as &$opt) {
486 if (isset($opt['description'])) {
487 $opt['desc'] = $opt['description'];
488 unset($opt['description']);
489 }
490 $optins[] = $opt;
491 }
492 }
493 }
494 $optins[] = array(
495 'type' => 'clear_cache',
496 'action' => 'tb_optin_clear_cache',
497 'text' => __('Clear Cache', 'themify'),
498 'clearing' => __('Clearing...', 'themify'),
499 'done' => __('Done', 'themify'),
500 );
501 return array(
502 array(
503 'label' => __('Google Map API Key', 'themify'),
504 'type' => 'text',
505 'id' => 'builder_settings_google_map_key',
506 'desc' => sprintf(__('Google API key is required to use Builder Map module and Map shortcode. <a href="%s" target="_blank">Generate an API key</a> and insert it here. Also, please ensure you\'ve setup a <a href="%s" target="_blank">billing plan</a>.'), '//developers.google.com/maps/documentation/javascript/get-api-key#key', 'https://support.google.com/googleapi/answer/6158867')
507 ),
508 array(
509 'label' => __('Bing Map API Key', 'themify'),
510 'type' => 'text',
511 'id' => 'builder_settings_bing_map_key',
512 'desc' => sprintf(__('To use Bing Maps, <a href="%s" target="_blank">generate an API key</a> and insert it here.', 'themify'), 'https://msdn.microsoft.com/en-us/library/ff428642.aspx')
513 ),
514 array(
515 'label' => __('Azure Map API Key', 'themify'),
516 'type' => 'text',
517 'id' => 'builder_settings_azure_map_key',
518 'desc' => '<h4>' . __( 'To get your key:', 'themify' ) . '</h4><small><ol>'
519 . '<li>' . sprintf( __( 'Sign in to <a href="%s" target="_blank" rel="noopener">Azure portal</a>', 'themify' ), 'https://portal.azure.com/' ) . '</li>'
520 . '<li>' . sprintf( __( '<a href="%s" target="_blank" rel="noopener">Create an Azure Map resource</a> if you haven\'t already.', 'themify' ), 'https://learn.microsoft.com/en-us/azure/azure-maps/quick-demo-map-app#create-an-azure-maps-account' ) . '</li>'
521 . '<li>' . sprintf( __( 'Get your <a href="%s" target="_blank" rel="noopener">subscription key (Primary Key)</a> and paste it here.', 'themify' ), 'https://learn.microsoft.com/en-us/azure/azure-maps/quick-demo-map-app#get-the-subscription-key-for-your-account' ) . '</li>'
522 . '</ol></small>'
523 ),
524 array(
525 'label' => __('Cloudflare API', 'themify'),
526 'type' => 'group',
527 'options' => array(
528 array(
529 'type' => 'email',
530 'id' => 'builder_settings_clf_email',
531 'label' => __('Account Email', 'themify'),
532 ),
533 array(
534 'type' => 'text',
535 'id' => 'builder_settings_clf_key',
536 'label' => __('API Key', 'themify'),
537 )
538 )
539 ),
540 array(
541 'label' => __('reCaptcha API Settings', 'themify'),
542 'type' => 'group',
543 'options' => array(
544 array(
545 'type' => 'select',
546 'id' => 'builder_settings_recaptcha_version',
547 'label' => __('Version', 'themify'),
548 'options' => array('v2' => __('Version 2', 'themify'), 'v3' => __('Version 3', 'themify'))
549 ),
550 array(
551 'type' => 'text',
552 'id' => 'builder_settings_recaptcha_site_key',
553 'label' => __('Site Key', 'themify'),
554 ),
555 array(
556 'type' => 'text',
557 'id' => 'builder_settings_recaptcha_secret_key',
558 'label' => __('Secret Key', 'themify'),
559 )
560 )
561 ),
562 array(
563 'label' => __('hCaptcha API Settings','themify'),
564 'type' => 'group',
565 'options' => array(
566 array(
567 'type' =>'text',
568 'id' => 'hcaptcha_secret',
569 'label' => __('hCaptcha Secret Key','themify'),
570 ),
571 array(
572 'type' => 'text',
573 'id' => 'hcaptcha_site',
574 'label' => __('hCaptcha Site Key','themify'),
575 )
576 )
577 ),
578 array(
579 'label' => __('Cloudflare Turnstile API Settings','themify'),
580 'type' => 'group',
581 'options' => array(
582 array(
583 'type' => 'text',
584 'id' => 'turnstile_site',
585 'label' => __('Site Key','themify'),
586 ),
587 array(
588 'type' =>'text',
589 'id' => 'turnstile_secret',
590 'label' => __('Secret Key','themify'),
591 )
592 )
593 ),
594 array(
595 'label' => __('Optin', 'themify'),
596 'type' => 'group',
597 'options' => $optins
598 ),
599 );
600 }
601
602 private static function get_tab_tools():array {
603 global $wp_roles;
604 $roles = $wp_roles->get_names();
605 $role_options = [];
606 /* administrator role always has access */
607 unset($roles['administrator']);
608 foreach ($roles as $key => $label) {
609 $role_options[] = array(
610 'type' => 'toggle',
611 'id' => 'maintenance_access_' . $key,
612 'label' => $label,
613 );
614 }
615
616 return array(
617 array(
618 'label' => __('Builder CSS Files', 'themify'),
619 'type' => 'clear_cache',
620 'action' => 'themify_regenerate_css_files_ajax',
621 'text' => __('Regenerate Builder CSS Files', 'themify'),
622 'clearing' => __('Clearing...', 'themify'),
623 'done' => __('Done', 'themify'),
624 'desc' => __('Builder styling are output to the generated CSS files stored in \'wp-content/uploads\' folder. Regenerate files will update all data in the generated files (eg. correct background image paths, etc.).', 'themify'),
625 'network' => is_multisite() ? array('tmp_regenerate_all_css' => __('Regenerate CSS in the whole network site', 'themify')) : '',
626 ),
627 array(
628 'label' => __('Search & Replace URLs', 'themify'),
629 'type' => 'group',
630 'options' => array(
631 array(
632 'type' => 'replace_url',
633 'text' => __('Replace', 'themify'),
634 'clearing' => __('Searching...', 'themify'),
635 'confirm' => __('WARNING: This will replace all data in your database. It can not be undone. Please backup your database before proceeding.', 'themify'),
636 'find' => array(
637 'type' => 'text',
638 'label' => __('Search for', 'themify')
639 ),
640 'replace' => array(
641 'type' => 'text',
642 'label' => __('Replace to', 'themify')
643 ),
644 'desc' => __('Use this tool to find and replace the URLs in the Builder data. Warning: Please backup your database before replacing URLs, this can not be undone.', 'themify'),
645 )
646 )
647 ),
648 array(
649 'label' => __('Maintenance Mode', 'themify'),
650 'type' => 'group',
651 'options' => array(
652 array(
653 'type' => 'select',
654 'id' => 'tools_maintenance_mode',
655 'desc' => __('Once it is enabled, only logged-in users can see your site.', 'themify'),
656 'options' => array(
657 '' => __('Disabled', 'themify'),
658 'on' => __('Enable and display a page', 'themify'),
659 'message' => __('Enable and display a message', 'themify'),
660 ),
661 'bind' => array(
662 '' => array(
663 'hide' => ['maintenance_message', 'maintenance_page', 'maintenance_access']
664 ),
665 'on' => array(
666 'hide' => 'maintenance_message',
667 'show' => ['maintenance_page', 'maintenance_access']
668 ),
669 'message' => array(
670 'hide' => 'maintenance_page',
671 'show' => ['maintenance_message', 'maintenance_access']
672 )
673 )
674 ),
675 array(
676 'type' => 'select',
677 'id' => 'tools_maintenance_page',
678 'ajax' => 'themify_load_maintenance_pages',
679 'desc' => __('Select a page to show for public users', 'themify'),
680 'wrap_class' => 'maintenance_page'
681 ),
682 array(
683 'type' => 'textarea',
684 'wrap_class' => 'maintenance_message',
685 'id' => 'tools_maintenance_message'
686 ),
687 array(
688 'label' => __('Allow Access', 'themify'),
689 'type' => 'group',
690 'id' => 'maintenance_access',
691 'options' => $role_options,
692 'help' => __('Select the user role(s) to allow viewing when maintenance mode is enabled.', 'themify'),
693 ),
694 )
695 ),
696 );
697 }
698
699 public static function create_admin_page() {
700 $tabs = array(
701 'builder' => array(
702 'label' => __('Settings', 'themify'),
703 'icon' => 'ti-settings',
704 'options' => self::get_tab_settings()
705 ),
706 'performance' => array(
707 'label' => __('Performance', 'themify'),
708 'icon' => 'ti-bolt-alt',
709 'options' => self::get_tab_performance()
710 ),
711 'role-access' => array(
712 'label' => __('Role Access', 'themify'),
713 'icon' => 'ti-lock',
714 'options' => self::get_tab_role_access()
715 ),
716 'custom-css' => array(
717 'label' => __('Custom CSS', 'themify'),
718 'icon' => 'ti-css3',
719 'options' => self::get_tab_custom_css()
720 ),
721 'integration' => array(
722 'label' => __('Integration API', 'themify'),
723 'icon' => 'ti-key',
724 'options' => self::get_tab_integration()
725 ),
726 'tools' => array(
727 'label' => __('Tools', 'themify'),
728 'icon' => 'ti-panel',
729 'options' => self::get_tab_tools()
730 )
731 );
732 foreach ($tabs as $k => $v) {
733 themify_get_icon($v['icon'], 'ti');
734 }
735 //used icons
736 themify_get_icon('info', 'ti');
737 themify_get_icon('alert', 'ti');
738 themify_get_icon('check', 'ti');
739 themify_get_icon('ti-eraser', 'ti');
740 themify_get_icon('ti-help', 'ti');
741 themify_enque_script('themify-builder-admin-settings', THEMIFY_BUILDER_URI . '/plugin/js/themify-builder-admin-settings.js', THEMIFY_VERSION, array('themify-main-script'));
742 $options = get_option(self::KEY);
743 if (empty($options)) {
744 $options = array();
745 }
746 $options['recaptcha_version'] = Themify_Builder_Model::getReCaptchaOption('version', 'v2');
747 $options['recaptcha_site_key'] = Themify_Builder_Model::getReCaptchaOption('public_key');
748 $options['recaptcha_secret_key'] = Themify_Builder_Model::getReCaptchaOption('private_key');
749 wp_localize_script('themify-builder-admin-settings', 'tb_settings', array(
750 'data' => $options,
751 'nonce' => wp_create_nonce('tf_nonce'),
752 'labels' => array(
753 'en' => __('Enable', 'themify'),
754 'dis' => __('Disable', 'themify')
755 ),
756 'options' => $tabs
757 ));
758 include THEMIFY_BUILDER_DIR . '/plugin/tpl/tmpl-builder-plugin-settings-page.php';
759 }
760
761 public static function show_custom_css() {
762 $settings = get_option(self::KEY);
763 $custom_css = !empty($settings['custom_css-custom_css']) ? $settings['custom_css-custom_css'] : false;
764 if ($custom_css) {
765 echo PHP_EOL, '<!-- Builder Custom Style -->', PHP_EOL,
766 '<style>', PHP_EOL,
767 $custom_css, PHP_EOL,
768 '</style>', PHP_EOL, '<!-- / end builder custom style -->', PHP_EOL;
769 }
770 }
771 }
772
773 Themify_Builder_Options::init();
774 endif;