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

232 lines 11.5 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 '<div class="ultp-settings-label">'.esc_html($value['label']).'</div>';
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 name="'.esc_attr($key).'" value="'.esc_attr($val).'" class="ultp-color-picker" />';
140 echo '<p class="description">'.esc_html($value['desc']).'</p>';
141 echo '</div>';
142 break;
143
144 case 'number':
145 echo '<div class="ultp-settings-field ultp-settings-input-field">';
146 $val = isset($option_data[$key]) ? $option_data[$key] : (isset($value['default']) ? $value['default'] : '');
147 echo '<input type="number" name="'.esc_attr($key).'" value="'.esc_attr($val).'"/>';
148 echo '<p class="description">'.esc_html($value['desc']).'</p>';
149 echo '</div>';
150 break;
151
152 case 'switch':
153 echo '<div class="ultp-settings-field ultp-settings-field-inline">';
154 $val = isset($option_data[$key]) ? $option_data[$key] : (isset($value['default']) ? $value['default'] : '');
155 echo '<input type="checkbox" value="yes" name="'.esc_attr($key).'" '.($val == 'yes' ? 'checked' : '').' />';
156 echo '<p class="description">'.esc_html($value['desc']).'</p>';
157 echo '</div>';
158 break;
159
160 case 'multiselect':
161 echo '<div class="ultp-settings-field">';
162 $saved_val = isset($option_data[$key]) ? $option_data[$key] : (isset($value['default']) ? $value['default'] : []);
163 echo '<select name="'.esc_attr($key).'[]" multiple>';
164 if (!empty($value['options'])) {
165 foreach ($value['options'] as $val) {
166 if (!empty($saved_val) && is_array($saved_val)) {
167 echo '<option value="'.esc_attr($val).'" '.(in_array( $val , $saved_val ) ? 'selected' : '' ).'>'.esc_html($val).'</option>';
168 } else {
169 echo '<option value="'.esc_attr($val).'">'.esc_html($val).'</option>';
170 }
171 }
172 }
173 echo ' </select>';
174 echo '</div>';
175 break;
176
177 default:
178 # code...
179 break;
180 };
181 echo '</div>';
182 echo '</div>';
183 }
184 }
185 }
186 }
187
188 /**
189 * Settings page output
190 */
191 public function create_admin_page() {
192 $data = self::get_option_settings();?>
193 <div class="ultp-dashboard-container">
194 <div class="ultp-dashboard-body ultp-getstart-body">
195 <div class="ultp-container-grid">
196 <form method="post" action="#">
197 <div class="ultp-settings ultp-submit-button">
198 <?php
199 if (isset($data['general']['attr'])) {
200 $this->get_settings_data( $data['general']['attr'] );
201 }
202 ?>
203 <div class="ultp-data-message"></div>
204 <button class="button button-primary button-large"><?php esc_html_e('Sava Settings', 'ultimate-post'); ?></button>
205 </div>
206 </form>
207 <div>
208 <?php
209 require_once ULTP_PATH.'classes/options/Banner.php';
210 $obj = new \ULTP\Banner();
211 $obj->premium_feature_sidebar();
212 ?>
213 <div class="ultp-aside-content ultp-aside-content-rate">
214 <div class="ultp-aside-heading ultp-getstart-title">
215 <span class="dashicons dashicons-star-filled"></span>
216 <?php esc_html_e('Show your love', 'ultimate-post'); ?>
217 </div>
218 <p class="ultp-support-desc">
219 <?php esc_html_e('Enjoying PostX? Give us a review to support our endless work.', 'ultimate-post'); ?>
220 </p>
221 <a href="https://wordpress.org/plugins/ultimate-post/#reviews" class="ultp-start-btn" target="_blank">
222 <?php esc_html_e('Rate it now', 'ultimate-post'); ?>
223 </a>
224 </div>
225 </div>
226 </div>
227 </div>
228 </div>
229
230 <?php }
231
232 }