PluginProbe
Post Grid Gutenberg Blocks – PostX / 2.9.2
Post Grid Gutenberg Blocks – PostX v2.9.2
5.0.39 5.0.38 5.0.37 5.0.36 5.0.35 5.0.34 5.0.33 5.0.32 5.0.31 5.0.30 5.0.29 5.0.28 5.0.27 5.0.26 5.0.25 5.0.23 5.0.24 5.0.22 5.0.21 5.0.20 5.0.19 5.0.18 5.0.17 2.1.1 2.1.2 All 237 releases
ultimate-post / classes / options / Settings.php

Settings.php in Post Grid Gutenberg Blocks – PostX 2.9.2, at classes/options/Settings.php

245 lines 12.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace ULTP;
3
4 defined('ABSPATH') || exit;
5
6 class Option_Settings{
7 /**
8 * Sanitization callback
9 */
10 public function sanitize( $options ) {
11 if ($options) {
12 $settings = $this->get_option_settings_keys();
13 foreach ($settings as $key) {
14 $options[$key] = isset($options[$key]) ? $options[$key] : '';
15 }
16 $old_data = ultimate_post()->get_setting();
17 $options = array_merge($old_data, $options);
18 }
19 return $options;
20 }
21
22
23 /**
24 * Settings Fields Key Return
25 */
26 public function get_option_settings_keys() {
27 $attr = array();
28 $data = $this->get_option_settings();
29 if (!empty($data)) {
30 foreach ($data as $key => $inner_data) {
31 if (isset($inner_data['attr'])) {
32 foreach ($inner_data['attr'] as $k => $val) {
33 $attr[] = $k;
34 }
35 }
36 }
37 }
38 return $attr;
39 }
40
41
42 /**
43 * Settings Field Return
44 */
45 public function get_option_settings() {
46 return apply_filters('ultp_settings', array(
47 'general' => array(
48 'label' => __('General Settings', 'ultimate-post'),
49 'attr' => array(
50 'css_save_as' => array(
51 'type' => 'select',
52 'label' => __('CSS Add Via', 'ultimate-post'),
53 'options' => array(
54 'wp_head' => __( 'Header - (Internal)','ultimate-post' ),
55 'filesystem' => __( 'File System - (External)','ultimate-post' ),
56 ),
57 'default' => 'wp_head',
58 'desc' => __('Select where you want to save CSS.', 'ultimate-post')
59 ),
60 'preloader_style' => array(
61 'type' => 'select',
62 'label' => __('Preloader Style', 'ultimate-post'),
63 'options' => array(
64 'style1' => __( 'Preloader Style 1','ultimate-post' ),
65 'style2' => __( 'Preloader Style 2','ultimate-post' ),
66 ),
67 'default' => 'style1',
68 'desc' => __('Select Preloader Style.', 'ultimate-post')
69 ),
70 'container_width' => array(
71 'type' => 'number',
72 'label' => __('Container Width', 'ultimate-post'),
73 'default' => '1140',
74 'desc' => __('Change Container Width of the Page Template(PostX Template).', 'ultimate-post')
75 ),
76 'hide_import_btn' => array(
77 'type' => 'switch',
78 'label' => __('Hide Template Kits Button', 'ultimate-post'),
79 'default' => '',
80 'desc' => __('Hide Template Kits Button from toolbar of the Gutenberg Editor.', 'ultimate-post')
81 ),
82 'disable_image_size' => array(
83 'type' => 'switch',
84 'label' => __('Disable Image Size', 'ultimate-post'),
85 'default' => '',
86 'desc' => __('Disable Image Size of the Plugins.', 'ultimate-post')
87 ),
88 'disable_view_cookies' => array(
89 'type' => 'switch',
90 'label' => __('Disable All Cookies', 'ultimate-post'),
91 'default' => '',
92 'desc' => __('Disable All Frontend Cookies (Cookies Used for Post View Count).', 'ultimate-post')
93 ),
94 'disable_google_font' => array(
95 'type' => 'switchButton',
96 'label' => __('Disable All Google Fonts', 'ultimate-post'),
97 'default' => '',
98 'desc' => __('Disable All Google Fonts From Frontend and Backend PostX Blocks.', 'ultimate-post')
99 ),
100 )
101 )
102 ));
103 }
104
105
106 /**
107 * Settings page output
108 */
109 public function get_settings_data( $data ) {
110 $option_data = ultimate_post()->get_setting();
111 foreach ($data as $key => $value) {
112 if ($value['type'] == 'hidden') {
113 echo '<input type="hidden" name="'.esc_attr($key).'" value="'.esc_attr($value['value']).'"/>';
114 } else {
115 if ($value['type'] == 'heading') {
116 echo '<h2 class="ultp-settings-heading">'.esc_html($value['label']).'</h2>';
117 if ( isset($value['desc']) ) {
118 echo '<div class="ultp-settings-subheading">'.esc_html($value['desc']).'</div>';
119 }
120 }
121 if($value['type'] != 'heading' && $value['type'] != 'hidden'){
122 echo '<div class="ultp-settings-wrap">';
123 if (isset($value['label'])) {
124 echo '<strong>'.esc_html($value['label']).'</strong>';
125 }
126 echo '<div class="ultp-settings-field-wrap">';
127 switch ($value['type']) {
128 case 'select':
129 echo '<div class="ultp-settings-field">';
130 $val = isset($option_data[$key]) ? $option_data[$key] : (isset($value['default']) ? $value['default'] : '');
131 echo '<select name="'.esc_attr($key).'">';
132 foreach ( $value['options'] as $id => $label ) {
133 echo '<option value="'.esc_attr($id).'" '.( $val == $id ? ' selected="selected"':'').'>';
134 echo esc_html( $label );
135 echo '</option>';
136 }
137 echo '</select>';
138 echo '<p class="description">'.esc_html($value['desc']).'</p>';
139 echo '</div>';
140 break;
141
142 case 'color':
143 echo '<div class="ultp-settings-field">';
144 $val = isset($option_data[$key]) ? $option_data[$key] : (isset($value['default']) ? $value['default'] : '');
145 echo '<input value="'.esc_attr($val).'" class="ultp-color-picker" />';
146 echo '<span class="ultp-settings-input-field"><input name="'.esc_attr($key).'" class="ultp-color-code" value="'.esc_attr($val).'"/></span>';
147 echo '<p class="description">'.esc_html($value['desc']).'</p>';
148 echo '</div>';
149 break;
150
151 case 'number':
152 echo '<div class="ultp-settings-field ultp-settings-input-field">';
153 $val = isset($option_data[$key]) ? $option_data[$key] : (isset($value['default']) ? $value['default'] : '');
154 echo '<input type="number" name="'.esc_attr($key).'" value="'.esc_attr($val).'"/>';
155 echo '<p class="description">'.esc_html($value['desc']).'</p>';
156 echo '</div>';
157 break;
158
159 case 'switch':
160 case 'switchButton':
161 echo '<div class="ultp-settings-field ultp-settings-field-inline">';
162 $val = isset($option_data[$key]) ? $option_data[$key] : (isset($value['default']) ? $value['default'] : '');
163 echo '<input type="checkbox" value="yes" name="'.esc_attr($key).'" '.($val == 'yes' ? 'checked' : '').' />';
164 echo '<p class="description">'.esc_html($value['desc']).'</p>';
165 if ($value['type'] == 'switchButton') {
166 echo '<div><span id="postx-regenerate-css" class="ultp-btn ultp-btn-warning '.($val=='yes'?'active':'').'"><span class="dashicons dashicons-admin-generic"></span><span class="ultp-text">';
167 echo __('Re-Generate Font Files', 'ultimate-post');
168 echo '</span></span></div>';
169 }
170 echo '</div>';
171 break;
172
173 case 'multiselect':
174 echo '<div class="ultp-settings-field">';
175 $saved_val = isset($option_data[$key]) ? $option_data[$key] : (isset($value['default']) ? $value['default'] : []);
176 echo '<select name="'.esc_attr($key).'[]" multiple>';
177 if (!empty($value['options'])) {
178 foreach ($value['options'] as $val) {
179 if (!empty($saved_val) && is_array($saved_val)) {
180 echo '<option value="'.esc_attr($val).'" '.(in_array( $val , $saved_val ) ? 'selected' : '' ).'>'.esc_html($val).'</option>';
181 } else {
182 echo '<option value="'.esc_attr($val).'">'.esc_html($val).'</option>';
183 }
184 }
185 }
186 echo ' </select>';
187 echo '</div>';
188 break;
189
190 default:
191 # code...
192 break;
193 };
194 echo '</div>';
195 echo '</div>';
196 }
197 }
198 }
199 }
200
201 /**
202 * Settings page output
203 */
204 public function create_admin_page() {
205 $data = self::get_option_settings();?>
206 <div class="ultp-dashboard-container">
207 <div class="ultp-dashboard-body ultp-card ultp-getstart-body">
208 <div class="ultp-container-grid">
209 <form method="post" action="#">
210 <div class="ultp-settings ultp-submit-button ultp-card ultp-p40">
211 <?php
212 if (isset($data['general']['attr'])) {
213 $this->get_settings_data( $data['general']['attr'] );
214 }
215 ?>
216 <div class="ultp-data-message"></div>
217 <button class="button button-primary button-large"><?php esc_html_e('Save Settings', 'ultimate-post'); ?></button>
218 </div>
219 </form>
220 <div>
221 <?php
222 require_once ULTP_PATH.'classes/options/Banner.php';
223 $obj = new \ULTP\Banner();
224 $obj->premium_feature_sidebar('settings');
225 ?>
226 <div class="ultp-aside-content ultp-card ultp-p25 ultp-aside-content-rate">
227 <div class="ultp-aside-heading ultp-sm-heading">
228 <span class="dashicons dashicons-star-filled"></span>
229 <?php esc_html_e('Show your love', 'ultimate-post'); ?>
230 </div>
231 <p class="ultp-support-desc">
232 <?php esc_html_e('Enjoying PostX? Give us a review to support our endless work.', 'ultimate-post'); ?>
233 </p>
234 <a href="https://wordpress.org/plugins/ultimate-post/#reviews" class="ultp-btn ultp-btn-warning" target="_blank">
235 <?php esc_html_e('Rate it now', 'ultimate-post'); ?>
236 </a>
237 </div>
238 </div>
239 </div>
240 </div>
241 </div>
242
243 <?php }
244
245 }