PluginProbe
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder / 2.8.0
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder v2.8.0
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 1.2.0 1.2.1 All 78 releases
ablocks / includes / admin / settings / base.php

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

136 lines 4.1 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 'enabled_coming_soon_page' => false,
31 'coming_soon_page' => '',
32 'enabled_maintenance_page' => false,
33 'maintenance_page' => '',
34 'frontend_dashboard_page' => '',
35 'login_page' => '',
36 'registration_page' => '',
37 'forget_password_page' => '',
38 'global_color' => [
39 [
40 'id' => 'primary',
41 'label' => 'Primary Color',
42 'value' => '#6EC1E4',
43 'is_system' => true,
44 ],
45 [
46 'id' => 'secondary',
47 'label' => 'Secondary',
48 'value' => '#54595F',
49 'is_system' => true,
50 ],
51 [
52 'id' => 'text',
53 'label' => 'Text',
54 'value' => '#7A7A7A',
55 'is_system' => true,
56 ],
57 [
58 'id' => 'accent',
59 'label' => 'Accent',
60 'value' => '#61CE70',
61 'is_system' => true,
62 ],
63 ],
64 'global_typography' => [
65 [
66 'id' => 'primary',
67 'label' => 'Primary',
68 'value' => Typography::get_attribute_default_value( true, [] ),
69 'is_system' => true,
70 ],
71 [
72 'id' => 'secondary',
73 'label' => 'Secondary',
74 'value' => Typography::get_attribute_default_value( true, [] ),
75 'is_system' => true,
76 ],
77 [
78 'id' => 'text',
79 'label' => 'Text',
80 'value' => Typography::get_attribute_default_value( true, [] ),
81 'is_system' => true,
82 ],
83 [
84 'id' => 'accent',
85 'label' => 'Accent',
86 'value' => Typography::get_attribute_default_value( true, [] ),
87 'is_system' => true,
88 ],
89 ],
90 'global_font_family_fallback' => 'Sans-serif',
91 // Global Typography and color
92 'global_body_text_color' => '',
93 'global_body_typography' => Typography::get_attribute_default_value( true, [] ),
94 'global_body_paragraph_space' => Range::get_attribute_default_value( [
95 'isResponsive' => true,
96 'defaultValue' => '',
97 'defaultValueTablet' => '',
98 'defaultValueMobile' => '',
99 'hasUnit' => true,
100 'unitDefaultValue' => 'px',
101 'attributeObjectKey' => 'value',
102 ] ),
103 'global_link_color' => '',
104 'global_link_hover_color' => '',
105 'global_link_typography' => Typography::get_attribute_default_value( true, [] ),
106 'global_link_hover_typography' => Typography::get_attribute_default_value( true, [] ),
107 'global_h1_color' => '',
108 'global_h1_typography' => Typography::get_attribute_default_value( true, [] ),
109 'global_h2_color' => '',
110 'global_h2_typography' => Typography::get_attribute_default_value( true, [] ),
111 'global_h3_color' => '',
112 'global_h3_typography' => Typography::get_attribute_default_value( true, [] ),
113 'global_h4_color' => '',
114 'global_h4_typography' => Typography::get_attribute_default_value( true, [] ),
115 'global_h5_color' => '',
116 'global_h5_typography' => Typography::get_attribute_default_value( true, [] ),
117 'global_h6_color' => '',
118 'global_h6_typography' => Typography::get_attribute_default_value( true, [] ),
119 ]);
120 }
121
122 public static function save_settings( $form_data = false ) {
123 $default_data = self::get_default_data();
124 $saved_data = self::get_saved_data();
125 $settings_data = wp_parse_args( $saved_data, $default_data );
126 if ( $form_data ) {
127 $settings_data = wp_parse_args( $form_data, $settings_data );
128 }
129 // if settings already saved, then update it
130 if ( count( $saved_data ) ) {
131 return update_option( ABLOCKS_SETTINGS_NAME, wp_json_encode( $settings_data ) );
132 }
133 return add_option( ABLOCKS_SETTINGS_NAME, wp_json_encode( $settings_data ) );
134 }
135 }
136