PluginProbe
Post Grid Gutenberg Blocks – PostX / 2.7.9
Post Grid Gutenberg Blocks – PostX v2.7.9
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.7.9, at classes/options/Settings.php

233 lines 11.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 Import Button', 'ultimate-post'),
79 'default' => '',
80 'desc' => __('Hide Import Layout Button from 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 )
95 )
96 ));
97 }
98
99
100 /**
101 * Settings page output
102 */
103 public function get_settings_data( $data ) {
104 $option_data = ultimate_post()->get_setting();
105 foreach ($data as $key => $value) {
106 if ($value['type'] == 'hidden') {
107 echo '<input type="hidden" name="'.esc_attr($key).'" value="'.esc_attr($value['value']).'"/>';
108 } else {
109 if ($value['type'] == 'heading') {
110 echo '<h2 class="ultp-settings-heading">'.esc_html($value['label']).'</h2>';
111 if ( isset($value['desc']) ) {
112 echo '<div class="ultp-settings-subheading">'.esc_html($value['desc']).'</div>';
113 }
114 }
115 if($value['type'] != 'heading' && $value['type'] != 'hidden'){
116 echo '<div class="ultp-settings-wrap">';
117 if (isset($value['label'])) {
118 echo '<strong>'.esc_html($value['label']).'</strong>';
119 }
120 echo '<div class="ultp-settings-field-wrap">';
121 switch ($value['type']) {
122 case 'select':
123 echo '<div class="ultp-settings-field">';
124 $val = isset($option_data[$key]) ? $option_data[$key] : (isset($value['default']) ? $value['default'] : '');
125 echo '<select name="'.esc_attr($key).'">';
126 foreach ( $value['options'] as $id => $label ) {
127 echo '<option value="'.esc_attr($id).'" '.( $val == $id ? ' selected="selected"':'').'>';
128 echo esc_html( $label );
129 echo '</option>';
130 }
131 echo '</select>';
132 echo '<p class="description">'.esc_html($value['desc']).'</p>';
133 echo '</div>';
134 break;
135
136 case 'color':
137 echo '<div class="ultp-settings-field">';
138 $val = isset($option_data[$key]) ? $option_data[$key] : (isset($value['default']) ? $value['default'] : '');
139 echo '<input value="'.esc_attr($val).'" class="ultp-color-picker" />';
140 echo '<span class="ultp-settings-input-field"><input name="'.esc_attr($key).'" class="ultp-color-code" value="'.esc_attr($val).'"/></span>';
141 echo '<p class="description">'.esc_html($value['desc']).'</p>';
142 echo '</div>';
143 break;
144
145 case 'number':
146 echo '<div class="ultp-settings-field ultp-settings-input-field">';
147 $val = isset($option_data[$key]) ? $option_data[$key] : (isset($value['default']) ? $value['default'] : '');
148 echo '<input type="number" name="'.esc_attr($key).'" value="'.esc_attr($val).'"/>';
149 echo '<p class="description">'.esc_html($value['desc']).'</p>';
150 echo '</div>';
151 break;
152
153 case 'switch':
154 echo '<div class="ultp-settings-field ultp-settings-field-inline">';
155 $val = isset($option_data[$key]) ? $option_data[$key] : (isset($value['default']) ? $value['default'] : '');
156 echo '<input type="checkbox" value="yes" name="'.esc_attr($key).'" '.($val == 'yes' ? 'checked' : '').' />';
157 echo '<p class="description">'.esc_html($value['desc']).'</p>';
158 echo '</div>';
159 break;
160
161 case 'multiselect':
162 echo '<div class="ultp-settings-field">';
163 $saved_val = isset($option_data[$key]) ? $option_data[$key] : (isset($value['default']) ? $value['default'] : []);
164 echo '<select name="'.esc_attr($key).'[]" multiple>';
165 if (!empty($value['options'])) {
166 foreach ($value['options'] as $val) {
167 if (!empty($saved_val) && is_array($saved_val)) {
168 echo '<option value="'.esc_attr($val).'" '.(in_array( $val , $saved_val ) ? 'selected' : '' ).'>'.esc_html($val).'</option>';
169 } else {
170 echo '<option value="'.esc_attr($val).'">'.esc_html($val).'</option>';
171 }
172 }
173 }
174 echo ' </select>';
175 echo '</div>';
176 break;
177
178 default:
179 # code...
180 break;
181 };
182 echo '</div>';
183 echo '</div>';
184 }
185 }
186 }
187 }
188
189 /**
190 * Settings page output
191 */
192 public function create_admin_page() {
193 $data = self::get_option_settings();?>
194 <div class="ultp-dashboard-container">
195 <div class="ultp-dashboard-body ultp-card ultp-getstart-body">
196 <div class="ultp-container-grid">
197 <form method="post" action="#">
198 <div class="ultp-settings ultp-submit-button ultp-card ultp-p40">
199 <?php
200 if (isset($data['general']['attr'])) {
201 $this->get_settings_data( $data['general']['attr'] );
202 }
203 ?>
204 <div class="ultp-data-message"></div>
205 <button class="button button-primary button-large"><?php esc_html_e('Save Settings', 'ultimate-post'); ?></button>
206 </div>
207 </form>
208 <div>
209 <?php
210 require_once ULTP_PATH.'classes/options/Banner.php';
211 $obj = new \ULTP\Banner();
212 $obj->premium_feature_sidebar();
213 ?>
214 <div class="ultp-aside-content ultp-card ultp-p25 ultp-aside-content-rate">
215 <div class="ultp-aside-heading ultp-sm-heading">
216 <span class="dashicons dashicons-star-filled"></span>
217 <?php esc_html_e('Show your love', 'ultimate-post'); ?>
218 </div>
219 <p class="ultp-support-desc">
220 <?php esc_html_e('Enjoying PostX? Give us a review to support our endless work.', 'ultimate-post'); ?>
221 </p>
222 <a href="https://wordpress.org/plugins/ultimate-post/#reviews" class="ultp-btn ultp-btn-warning" target="_blank">
223 <?php esc_html_e('Rate it now', 'ultimate-post'); ?>
224 </a>
225 </div>
226 </div>
227 </div>
228 </div>
229 </div>
230
231 <?php }
232
233 }