PluginProbe
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder / 2.10.0
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder v2.10.0
2.13.0 2.13.1 2.12.0 2.11.1 2.11.0 2.10.0 2.9.0 2.7.4 2.7.5 2.7.6 2.7.7 2.8.0 2.8.1 2.9.1 trunk 1.0 1.0-beta1 1.0-beta2 1.0-beta3 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.1.2 All 80 releases
ablocks / includes / admin / settings / base.php

base.php in aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder 2.10.0, at includes/admin/settings/base.php

152 lines 4.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace ABlocks\Admin\Settings;
3
4 if ( ! defined( 'ABSPATH' ) ) {
5 exit;
6 }
7
8 use ABlocks\Controls\Typography;
9 use ABlocks\Controls\Range;
10
11 class Base {
12 public static function get_saved_data() {
13 $settings = get_option( ABLOCKS_SETTINGS_NAME );
14 if ( $settings ) {
15 return json_decode( $settings, true );
16 }
17 return [];
18 }
19 public static function get_default_data() {
20 return apply_filters('ablocks/admin/settings/base_default_data', [
21 // global style
22 'default_container_width' => 1140,
23 'container_padding' => 10,
24 'container_element_gap' => 20,
25 'enabled_assets_file_generation' => false,
26 'enabled_block_copy_paste_style' => true,
27 'enabled_load_google_font_locally' => false,
28 'enabled_only_selected_fonts' => false,
29 'selected_fonts' => [],
30 // Performance Suite — platform optimizations (opt-in; default off so
31 // existing sites are unchanged until the user enables them).
32 'perf_disable_emojis' => false,
33 'perf_disable_embeds' => false,
34 'perf_disable_dashicons' => false,
35 'perf_disable_jquery_migrate' => false,
36 'perf_control_heartbeat' => false,
37 'perf_heartbeat_frequency' => 60,
38 // Performance Suite — delay JS until interaction.
39 'perf_delay_js' => false,
40 'perf_delay_js_timeout' => 5000,
41 // Performance Suite — image loading (safe: on by default).
42 'perf_lazy_images' => true,
43 'perf_lcp_eager_count' => 1,
44 // Performance Suite — inline small page CSS (safe: on by default).
45 'perf_inline_css' => true,
46 'enabled_coming_soon_page' => false,
47 'coming_soon_page' => '',
48 'enabled_maintenance_page' => false,
49 'maintenance_page' => '',
50 'frontend_dashboard_page' => '',
51 'login_page' => '',
52 'registration_page' => '',
53 'forget_password_page' => '',
54 'global_color' => [
55 [
56 'id' => 'primary',
57 'label' => 'Primary Color',
58 'value' => '#6EC1E4',
59 'is_system' => true,
60 ],
61 [
62 'id' => 'secondary',
63 'label' => 'Secondary',
64 'value' => '#54595F',
65 'is_system' => true,
66 ],
67 [
68 'id' => 'text',
69 'label' => 'Text',
70 'value' => '#7A7A7A',
71 'is_system' => true,
72 ],
73 [
74 'id' => 'accent',
75 'label' => 'Accent',
76 'value' => '#61CE70',
77 'is_system' => true,
78 ],
79 ],
80 'global_typography' => [
81 [
82 'id' => 'primary',
83 'label' => 'Primary',
84 'value' => Typography::get_attribute_default_value( true, [] ),
85 'is_system' => true,
86 ],
87 [
88 'id' => 'secondary',
89 'label' => 'Secondary',
90 'value' => Typography::get_attribute_default_value( true, [] ),
91 'is_system' => true,
92 ],
93 [
94 'id' => 'text',
95 'label' => 'Text',
96 'value' => Typography::get_attribute_default_value( true, [] ),
97 'is_system' => true,
98 ],
99 [
100 'id' => 'accent',
101 'label' => 'Accent',
102 'value' => Typography::get_attribute_default_value( true, [] ),
103 'is_system' => true,
104 ],
105 ],
106 'global_font_family_fallback' => 'Sans-serif',
107 // Global Typography and color
108 'global_body_text_color' => '',
109 'global_body_typography' => Typography::get_attribute_default_value( true, [] ),
110 'global_body_paragraph_space' => Range::get_attribute_default_value( [
111 'isResponsive' => true,
112 'defaultValue' => '',
113 'defaultValueTablet' => '',
114 'defaultValueMobile' => '',
115 'hasUnit' => true,
116 'unitDefaultValue' => 'px',
117 'attributeObjectKey' => 'value',
118 ] ),
119 'global_link_color' => '',
120 'global_link_hover_color' => '',
121 'global_link_typography' => Typography::get_attribute_default_value( true, [] ),
122 'global_link_hover_typography' => Typography::get_attribute_default_value( true, [] ),
123 'global_h1_color' => '',
124 'global_h1_typography' => Typography::get_attribute_default_value( true, [] ),
125 'global_h2_color' => '',
126 'global_h2_typography' => Typography::get_attribute_default_value( true, [] ),
127 'global_h3_color' => '',
128 'global_h3_typography' => Typography::get_attribute_default_value( true, [] ),
129 'global_h4_color' => '',
130 'global_h4_typography' => Typography::get_attribute_default_value( true, [] ),
131 'global_h5_color' => '',
132 'global_h5_typography' => Typography::get_attribute_default_value( true, [] ),
133 'global_h6_color' => '',
134 'global_h6_typography' => Typography::get_attribute_default_value( true, [] ),
135 ]);
136 }
137
138 public static function save_settings( $form_data = false ) {
139 $default_data = self::get_default_data();
140 $saved_data = self::get_saved_data();
141 $settings_data = wp_parse_args( $saved_data, $default_data );
142 if ( $form_data ) {
143 $settings_data = wp_parse_args( $form_data, $settings_data );
144 }
145 // if settings already saved, then update it
146 if ( count( $saved_data ) ) {
147 return update_option( ABLOCKS_SETTINGS_NAME, wp_json_encode( $settings_data ) );
148 }
149 return add_option( ABLOCKS_SETTINGS_NAME, wp_json_encode( $settings_data ) );
150 }
151 }
152