PluginProbe
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder / 2.11.0
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder v2.11.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.11.0, at includes/admin/settings/base.php

235 lines 9.0 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 // Design system lock: authors may only use the global typography /
28 // colour presets, so nobody can hand-pick a one-off value by mistake.
29 'lock_global_typography' => false,
30 // Escalates the typography lock from 'no picking a typeface' to 'no
31 // custom typography at all'. Off by default: adjusting a size is normal
32 // design work, picking a stray typeface is the mistake.
33 'lock_global_typography_strict' => false,
34 'lock_global_colors' => false,
35 'enabled_load_google_font_locally' => false,
36 'enabled_only_selected_fonts' => false,
37 'selected_fonts' => [],
38 // Emit a metric-adjusted local fallback face per font, so text does not
39 // reflow when the web font finishes loading (CLS).
40 'font_metric_fallback' => true,
41 // Performance Suite — platform optimizations (opt-in; default off so
42 // existing sites are unchanged until the user enables them).
43 'perf_disable_emojis' => false,
44 'perf_disable_embeds' => false,
45 'perf_disable_dashicons' => false,
46 'perf_disable_jquery_migrate' => false,
47 'perf_control_heartbeat' => false,
48 'perf_heartbeat_frequency' => 60,
49 // Performance Suite — delay JS until interaction.
50 'perf_delay_js' => false,
51 'perf_delay_js_timeout' => 5000,
52 // Performance Suite — image loading (safe: on by default).
53 'perf_lazy_images' => true,
54 'perf_lcp_eager_count' => 1,
55 'perf_image_dimensions' => true,
56 'perf_responsive_images' => true,
57 'perf_preload_lcp' => true,
58 'perf_touch_targets' => false,
59 // Performance Suite — inline small page CSS (safe: on by default).
60 'perf_inline_css' => true,
61 'perf_async_css' => false,
62 'perf_critical_css' => false,
63 'perf_defer_js' => false,
64 // Performance Suite — full-page HTML cache. Off by default: unlike
65 // the toggles above it changes what every visitor receives, so it
66 // needs a deliberate decision rather than inheriting a default.
67 // See docs/PAGE-CACHE-PLAN.md.
68 'perf_page_cache' => false,
69 // 'all' | 'ablocks_only'
70 'perf_page_cache_scope' => 'all',
71 // Hours; 0 = keep until something invalidates it.
72 'perf_page_cache_ttl' => 0,
73 'perf_page_cache_gzip' => true,
74 'perf_page_cache_prewarm' => true,
75 'perf_page_cache_mobile_variant' => false,
76 // Empty allowlist means any query string bypasses the cache, so
77 // ?utm_source=x can never overwrite the canonical entry for a URL.
78 // Background crawler: tops the cache up with pages no visitor has
79 // requested yet, a small batch at a time.
80 'perf_page_cache_crawler' => false,
81 'perf_page_cache_crawl_batch' => 20,
82 'perf_page_cache_query_args' => [],
83 'perf_page_cache_exclusions' => [],
84 // Performance Suite — move render-blocking inline CSS into cached
85 // files so the browser can reuse it across navigations. Off by
86 // default: it changes how every page's CSS is delivered.
87 'perf_consolidate_css' => false,
88 // Runs smaller than this stay inline — below a couple of KB the
89 // extra request costs more than the bytes saved.
90 'perf_consolidate_css_min' => 2048,
91 // Performance Suite — cache rendered FSE template parts (header,
92 // footer). Off by default: replaying a cached render's side effects
93 // is the delicate part, so it wants per-site verification.
94 'perf_fragment_cache' => false,
95 'perf_fragment_cache_ttl' => 43200,
96 // Performance Suite — memoise block template resolution. Measured at
97 // 11-14ms and 7-10 queries per request on a block theme.
98 'perf_template_cache' => false,
99 'perf_template_cache_ttl' => 43200,
100 // Image tools — recompress files on disk. Every part opt-in: unlike
101 // the delivery options above, these rewrite the user's media.
102 'perf_image_optimize_on_upload' => false,
103 // '1x' gentle | '2x' balanced | '5x' aggressive
104 'perf_image_level' => '2x',
105 'perf_image_webp' => true,
106 'perf_image_quarantine_autodelete' => false,
107 'perf_image_quarantine_days' => 30,
108 // Upload standards. Filenames can be blocked outright; alt text cannot
109 // be required at upload time, so it gates use instead. See UploadGuard.
110 'perf_image_require_filename' => false,
111 'perf_image_require_alt' => false,
112 // Marketing — carry incoming affiliate/UTM query params onto tagged
113 // links so a visitor who lands on ?ref=xyz keeps that param as they
114 // click through. Opt-in; inert unless a tagged link is present AND a
115 // tracked param exists in the current URL.
116 'param_passthrough_enabled' => false,
117 'param_passthrough_keys' => 'ref,utm_source,utm_medium,utm_campaign,utm_term,utm_content',
118 // Which links receive the params: 'class' (only links tagged with the
119 // CSS class), 'all' (every same-site link), or 'keyword' (links whose
120 // URL contains one of the configured words).
121 'param_passthrough_match' => 'class',
122 'param_passthrough_class' => 'aff-link',
123 'param_passthrough_keyword' => '',
124 // Remember the incoming params in a cookie so they keep being applied
125 // even after the visitor lands on a page whose URL no longer carries
126 // them (e.g. after clicking an untagged menu link).
127 'param_passthrough_persist' => true,
128 'param_passthrough_cookie_days' => 30,
129 'enabled_coming_soon_page' => false,
130 'coming_soon_page' => '',
131 'enabled_maintenance_page' => false,
132 'maintenance_page' => '',
133 'frontend_dashboard_page' => '',
134 'login_page' => '',
135 'registration_page' => '',
136 'forget_password_page' => '',
137 'global_color' => [
138 [
139 'id' => 'primary',
140 'label' => 'Primary Color',
141 'value' => '#6EC1E4',
142 'is_system' => true,
143 ],
144 [
145 'id' => 'secondary',
146 'label' => 'Secondary',
147 'value' => '#54595F',
148 'is_system' => true,
149 ],
150 [
151 'id' => 'text',
152 'label' => 'Text',
153 'value' => '#7A7A7A',
154 'is_system' => true,
155 ],
156 [
157 'id' => 'accent',
158 'label' => 'Accent',
159 'value' => '#61CE70',
160 'is_system' => true,
161 ],
162 ],
163 'global_typography' => [
164 [
165 'id' => 'primary',
166 'label' => 'Primary',
167 'value' => Typography::get_attribute_default_value( true, [] ),
168 'is_system' => true,
169 ],
170 [
171 'id' => 'secondary',
172 'label' => 'Secondary',
173 'value' => Typography::get_attribute_default_value( true, [] ),
174 'is_system' => true,
175 ],
176 [
177 'id' => 'text',
178 'label' => 'Text',
179 'value' => Typography::get_attribute_default_value( true, [] ),
180 'is_system' => true,
181 ],
182 [
183 'id' => 'accent',
184 'label' => 'Accent',
185 'value' => Typography::get_attribute_default_value( true, [] ),
186 'is_system' => true,
187 ],
188 ],
189 'global_font_family_fallback' => 'Sans-serif',
190 // Global Typography and color
191 'global_body_text_color' => '',
192 'global_body_typography' => Typography::get_attribute_default_value( true, [] ),
193 'global_body_paragraph_space' => Range::get_attribute_default_value( [
194 'isResponsive' => true,
195 'defaultValue' => '',
196 'defaultValueTablet' => '',
197 'defaultValueMobile' => '',
198 'hasUnit' => true,
199 'unitDefaultValue' => 'px',
200 'attributeObjectKey' => 'value',
201 ] ),
202 'global_link_color' => '',
203 'global_link_hover_color' => '',
204 'global_link_typography' => Typography::get_attribute_default_value( true, [] ),
205 'global_link_hover_typography' => Typography::get_attribute_default_value( true, [] ),
206 'global_h1_color' => '',
207 'global_h1_typography' => Typography::get_attribute_default_value( true, [] ),
208 'global_h2_color' => '',
209 'global_h2_typography' => Typography::get_attribute_default_value( true, [] ),
210 'global_h3_color' => '',
211 'global_h3_typography' => Typography::get_attribute_default_value( true, [] ),
212 'global_h4_color' => '',
213 'global_h4_typography' => Typography::get_attribute_default_value( true, [] ),
214 'global_h5_color' => '',
215 'global_h5_typography' => Typography::get_attribute_default_value( true, [] ),
216 'global_h6_color' => '',
217 'global_h6_typography' => Typography::get_attribute_default_value( true, [] ),
218 ]);
219 }
220
221 public static function save_settings( $form_data = false ) {
222 $default_data = self::get_default_data();
223 $saved_data = self::get_saved_data();
224 $settings_data = wp_parse_args( $saved_data, $default_data );
225 if ( $form_data ) {
226 $settings_data = wp_parse_args( $form_data, $settings_data );
227 }
228 // if settings already saved, then update it
229 if ( count( $saved_data ) ) {
230 return update_option( ABLOCKS_SETTINGS_NAME, wp_json_encode( $settings_data ) );
231 }
232 return add_option( ABLOCKS_SETTINGS_NAME, wp_json_encode( $settings_data ) );
233 }
234 }
235