PluginProbe
Post Grid Gutenberg Blocks – PostX / 1.0.2
Post Grid Gutenberg Blocks – PostX v1.0.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.php

Options.php in Post Grid Gutenberg Blocks – PostX 1.0.2, at classes/Options.php

491 lines 19.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 Options{
7 public function __construct() {
8 add_action( 'admin_menu', array( $this, 'menu_page_callback' ) );
9 add_action( 'admin_init', array( $this, 'register_settings' ) );
10 }
11
12 public static function menu_page_callback() {
13 add_menu_page(
14 esc_html__( 'Ultimate Post', 'ultimate-post' ),
15 esc_html__( 'Ultimate Post', 'ultimate-post' ),
16 'manage_options',
17 'ultp-settings',
18 array( self::class, 'create_admin_page' ),
19 ULTP_URL.'assets/img/menu-panel.svg'
20 );
21 }
22
23 /**
24 * Register a setting and its sanitization callback.
25 */
26 public static function register_settings() {
27 register_setting( 'ultp_options', 'ultp_options', array( self::class, 'sanitize' ) );
28 }
29
30 /**
31 * Sanitization callback
32 */
33 public static function sanitize( $options ) {
34 if ($options) {
35 $settings = self::get_option_settings();
36 foreach ($settings as $key => $setting) {
37 if (!empty($key)) {
38 $options[$key] = sanitize_text_field($options[$key]);
39 }
40 }
41 }
42 return $options;
43 }
44
45 public static function get_option_settings(){
46 return array(
47 'css_save_as' => array(
48 'type' => 'select',
49 'label' => __('CSS Save Method', 'ultimate-post'),
50 'options' => array(
51 'wp_head' => __( 'Header','ultimate-post' ),
52 'filesystem' => __( 'File System','ultimate-post' ),
53 ),
54 'default' => 'wp_head',
55 'desc' => __('Select where you want to save CSS.', 'ultimate-post')
56 ),
57 'preloader_style' => array(
58 'type' => 'select',
59 'label' => __('Preloader Style', 'ultimate-post'),
60 'options' => array(
61 'style1' => __( 'Preloader Style 1','ultimate-post' ),
62 'style2' => __( 'Preloader Style 2','ultimate-post' ),
63 ),
64 'default' => 'style1',
65 'desc' => __('Select Preloader Style.', 'ultimate-post')
66 ),
67 // 'preloader_color' => array(
68 // 'type' => 'color',
69 // 'label' => __('Preloader Color', 'ultimate-post'),
70 // 'default' => '#1740f5',
71 // 'desc' => __('Select Preloader Color.', 'ultimate-post')
72 // ),
73 'container_width' => array(
74 'type' => 'number',
75 'label' => __('Container Width', 'ultimate-post'),
76 'default' => '1140',
77 'desc' => __('Change Container Width.', 'ultimate-post')
78 ),
79 );
80 }
81
82 public static function get_recommended_themes(){
83 $recommended_themes = array(
84 'twentynineteen' => array(
85 'name' => 'Twenty Twenty',
86 'slug' => 'twentytwenty',
87 'url' => 'https://wordpress.org/themes/twentytwenty/',
88 'logo' => ULTP_URL.'assets/img/WordPress.png'
89 ),
90 'twentynineteen2' => array(
91 'name' => 'Twenty Nineteen',
92 'slug' => 'twentynineteen',
93 'url' => 'https://wordpress.org/themes/twentynineteen/',
94 'logo' => ULTP_URL.'assets/img/WordPress.png'
95 )
96 );
97
98 $html = '';
99 foreach ($recommended_themes as $key => $value) {
100 $html .= '<div class="ultp-recommended-theme">';
101 $html .= '<div class="ultp-recommended-image">';
102 $html .= '<img src="'.$value['logo'].'" alt="'.$value['name'].'" />';
103 $html .= '</div>';
104 $html .= '<div class="ultp-recommended-name">'.$value['name'].'</div>';
105 $html .= '<div class="ultp-recommended-button">';
106 $html .= '<a target="_blank" href="'.$value['url'].'">'.__('Download Now').'</a>';
107 $html .= '</div>';
108 $html .= '</div>';
109 }
110 echo $html;
111 }
112
113 public static function get_changelog_data() {
114 $html = '';
115 $resource_data = file_get_contents(ULTP_PATH.'/readme.txt', "r");
116 $data = array();
117 if ($resource_data) {
118 $resource_data = explode('== Changelog ==', $resource_data);
119 if (isset($resource_data[1])) {
120 $resource_data = $resource_data[1];
121 $resource_data = explode("\n", $resource_data);
122 $inner = false;
123 $count = -1;
124
125 foreach ($resource_data as $element) {
126 if ($element){
127 if (substr_count($element, '=') > 1) {
128 $count++;
129 $temp = trim(str_replace('=', '', $element));
130 if (strpos($temp, '-') !== false) {
131 $temp = explode('-', $temp);
132 $data[$count]['date'] = trim($temp[1]);
133 $data[$count]['version'] = trim($temp[0]);
134 }
135 }
136 if (strpos($element, '* New:') !== false) {
137 $data[$count]['new'][] = trim(str_replace('* New:', '', $element));
138 }
139 if (strpos($element, '* Fix:') !== false) {
140 $data[$count]['fix'][] = trim(str_replace('* Fix:', '', $element));
141 }
142 if (strpos($element, '* Update:') !== false) {
143 $data[$count]['update'][] = trim(str_replace('* Update:', '', $element));
144 }
145 }
146 }
147 }
148 }
149 if (!empty($data)) {
150 foreach ($data as $k => $inner_data) {
151 $html .= '<div class="ultp-changelog-wrap">';
152 foreach ($inner_data as $key => $changelog) {
153 if ($key == 'date') {
154 $html .= '<div class="ultp-changelog-date">'.__('Released on ', 'ultimate-post').' '.$changelog.'</div>';
155 } elseif($key == 'version') {
156 $html .= '<div class="ultp-changelog-version">'.__('Version', 'ultimate-post').' : '.$changelog.'</div>';
157 } else {
158 foreach ($changelog as $keyword => $val) {
159 $html .= '<div class="ultp-changelog-title"><span class="changelog-'.$key.'">'.$key.'</span>'.$val.'</div>';
160 }
161 }
162 }
163 $html .= '</div>';
164 }
165 }
166 echo $html;
167 }
168
169 public static function get_settings_data() {
170 $html = '';
171 $option_data = get_option( 'ultp_options' );
172 $data = self::get_option_settings();
173 $html .= '<div class="ultp-settings">';
174 $html .= '<input type="hidden" name="option_page" value="ultp_options" />';
175 $html .= '<input type="hidden" name="action" value="update" />';
176 $html .= wp_nonce_field( "ultp_options-options" );
177 foreach ($data as $key => $value) {
178 $html .= '<div class="ultp-settings-wrap">';
179 $html .= '<div class="ultp-settings-label">'.$value['label'].'</div>';
180 $html .= '<div class="ultp-settings-field-wrap">';
181 switch ($value['type']) {
182
183 case 'select':
184 $html .= '<div class="ultp-settings-field">';
185 $val = isset($option_data[$key]) ? $option_data[$key] : (isset($value['default']) ? $value['default'] : '');
186 $html .= '<select name="ultp_options['.$key.']">';
187 foreach ( $value['options'] as $id => $label ) {
188 $html .= '<option value="'.$id.'" '.( $val == $id ? ' selected="selected"':'').'>';
189 $html .= strip_tags( $label );
190 $html .= '</option>';
191 }
192 $html .= '</select>';
193 $html .= '<p class="description">'.$value['desc'].'</p>';
194 $html .= '</div>';
195 break;
196
197 case 'color':
198 $html .= '<div class="ultp-settings-field">';
199 $val = isset($option_data[$key]) ? $option_data[$key] : (isset($value['default']) ? $value['default'] : '');
200 $html .= '<input name="ultp_options['.$key.']" value="'.$val.'" class="ultp-color-picker" />';
201 $html .= '<p class="description">'.$value['desc'].'</p>';
202 $html .= '</div>';
203 break;
204
205 case 'number':
206 $html .= '<div class="ultp-settings-field">';
207 $val = isset($option_data[$key]) ? $option_data[$key] : (isset($value['default']) ? $value['default'] : '');
208 $html .= '<input type="number" name="ultp_options['.$key.']" value="'.$val.'"/>';
209 $html .= '<p class="description">'.$value['desc'].'</p>';
210 $html .= '</div>';
211 break;
212
213 default:
214 # code...
215 break;
216
217 }
218 $html .= '</div>';
219 $html .= '</div>';
220 }
221 $html .= '<div class="ultp-settings-wrap">';
222 $html .= '<div></div>'.get_submit_button();
223 $html .= '</div>';
224
225 $html .= '</div>';
226
227
228
229 echo '<form method="post" action="options.php">'.$html.'</form>';
230 }
231
232
233 public static function get_support_data() {
234 $html = '';
235 $html .= '<div class="ultp-settings-support-wrap">';
236 $html .= '<div class="ultp-setting-header">';
237 $html .= '<h2><span class="dashicons dashicons-megaphone"></span>'.__('Support', 'ultimate-post').'</h2>';
238 $html .= '<p>'.esc_html__('Need help with Ultimate Post Block? Ask a question and get help from the support staff. Don not forget to read the documentation first.', 'ultimate-post').'</p>';
239 $html .= '<a target="_blank" href="https://www.wpxpo.com/docs/"><span class="dashicons dashicons-book"></span> '.__('Documentation', 'ultimate-post').'</a>';
240 // $html .= '<a target="_blank" href="https://www.facebook.com/"><span class="dashicons dashicons-facebook"></span> '.__('Facebook Group', 'ultimate-post').'</a>';
241 $html .= '<a target="_blank" href="https://www.wpxpo.com/support/"><span class="dashicons dashicons-format-chat"></span> '.__('Submit a Ticket', 'ultimate-post').'</a>';
242 $html .= '</div>';
243 $html .= '</div>';
244 echo $html;
245 }
246
247 /**
248 * Settings page output
249 */
250 public static function create_admin_page() { ?>
251 <style>
252 /* ----Common--- */
253 #wpbody-content, #wpwrap{
254 background-color: #ffffff;
255 }
256 #wpcontent {
257 padding-left: 0px;
258 }
259 .wrap{
260 margin: 0;
261 margin-top: -17px;
262 }
263
264 /* ----Header--- */
265 .ultp-setting-header{
266 text-align: center;
267 background-color: #f5f7f9;
268 padding: 50px 0;
269 }
270 .ultp-setting-header h2{
271 font-size: 28px;
272 color: #3e5667;
273 }
274 .ultp-setting-header h2 span{
275 font-size: 30px;
276 margin-right: 15px;
277 line-height: 20px;
278 }
279 .ultp-setting-header a{
280 padding: 10px 20px;
281 color: rgba(46,68,83,0.8);
282 background: #fff;
283 border-color: #e2e6eb;
284 box-shadow: 0 1px 3px rgba(0,0,0,0.07);
285 margin-top: 25px;
286 display: inline-block;
287 border-radius: 3px;
288 text-decoration: none;
289 font-size: 14px;
290 transition: 100ms;
291 margin-right: 10px;
292 }
293 .ultp-setting-header a:hover{
294 color: #fff;
295 background: #0591c9;
296 border-color: rgba(1,118,165,0.85);
297 box-shadow: 0 1px 4px rgba(1,96,134,0.4);
298 }
299 .ultp-setting-header img{
300 width: 31px;
301 border-radius: 50%;
302 border: 2px solid #1740f5;
303 position: relative;
304 bottom: -7px;
305 }
306 .ultp-setting-header p{
307 color: #687c93;
308 font-size: 16px;
309 max-width: 550px;
310 margin: 0 auto;
311 line-height: 28px;
312 }
313 /* ----Tab--- */
314 .ultp-tab-wrap{
315 background-color: #ffffff;
316 }
317 .ultp-tab-title-wrap{
318 background-color: #f5f7f9;
319 text-align: center;
320 }
321 .ultp-tab-title{
322 color: #3e5566;
323 font-size: 15px;
324 display: inline-block;
325 padding: 16px 23px;
326 border-radius: 3px 3px 0 0;
327 }
328 .ultp-tab-title:hover{
329 cursor: pointer;
330 }
331 .ultp-tab-title.active{
332 background-color: #ffffff;
333 }
334 .ultp-tab-content{
335 display: none;
336 }
337 .ultp-tab-content.active{
338 display: block;
339 }
340
341 /* ----Settings--- */
342 .ultp-settings{
343 max-width: 500px;
344 margin: 50px auto;
345 }
346 .ultp-settings-wrap {
347 margin-bottom: 20px;
348 display: grid;
349 grid-template-columns: 0.4fr 1fr;
350 }
351
352
353 /* ----Recomended--- */
354 .ultp-recommended-theme{
355 max-width: 500px;
356 background-color: #ececec;
357 margin: 50px auto;
358 border-radius: 3px;
359 }
360 .ultp-recommended-image, .ultp-recommended-name, .ultp-recommended-button {
361 display: inline-block;
362 vertical-align: middle;
363 }
364 .ultp-recommended-name{
365 font-size: 18px;
366 margin-left: 20px;
367 color: #3e5566;
368 }
369 .ultp-recommended-image img {
370 width: 70px;
371 }
372 .ultp-recommended-button {
373 float: right;
374 margin: 20px 20px 0 0;
375 position: relative;
376 }
377 .ultp-recommended-button a{
378 float: right;
379 padding: 7px 15px;
380 border-radius: 3px;
381 color: #ffffff;
382 background-color: #1640f5;
383 transition: 200ms;
384 text-decoration: none;
385 }
386 .ultp-recommended-button a:hover{
387 cursor: pointer;
388 background-color: #0931e0;
389 }
390
391 /* ---Changelog--- */
392 .ultp-changelog-wrap {
393 max-width: 600px;
394 background-color: #f5f7f9;
395 margin: 50px auto;
396 border-radius: 3px;
397 padding: 25px 30px;
398 position: relative;
399 }
400 .ultp-changelog-date{
401 font-size: 14px;
402 display: inline-block;
403 right: 30px;
404 position: absolute;
405 color: #989898;
406 }
407 .ultp-changelog-version{
408 font-size: 20px;
409 color: #5f6265;
410 font-weight: 700;
411 margin-bottom: 15px;
412 }
413 .ultp-changelog-title {
414 text-transform: capitalize;
415 font-size: 14px;
416 color: #3e5465;
417 line-height: 28px;
418 }
419 .ultp-changelog-title > span {
420 padding: 1px 10px;
421 border-radius: 3px;
422 margin-right: 10px;
423 }
424 .changelog-fix{
425 color: #721c24;
426 background-color: #f8d7da;
427 border-color: #f5c6cb;
428 }
429 .changelog-update{
430 color: #856404;
431 background-color: #fff3cd;
432 border-color: #ffeeba;
433 }
434 .changelog-new{
435 color: #155724;
436 background-color: #d4edda;
437 border-color: #c3e6cb;
438 }
439
440 /* ----Support--- */
441 .ultp-settings-support-wrap{
442 max-width: 800px;
443 margin: 0 auto;
444 border-radius: 4px;
445 overflow: hidden;
446 margin-bottom: 50px;
447 }
448
449 </style>
450 <div class="wrap">
451 <div class="ultp-option-body">
452 <div class="ultp-setting-header">
453 <h2>
454 <img src="<?php echo ULTP_URL.'assets/img/menu-panel.svg'; ?>" alt="<?php _e('Ultimate Post blocks', 'ultimate-post'); ?>">
455 <?php _e('Ultimate Post blocks', 'ultimate-post'); ?>
456 </h2>
457 <p><?php esc_html_e('Best Gutenberg Post Listing/Grid plugin. Build a fast and supercharged WordPress post blog easily and perfectly.', 'ultimate-post'); ?></p>
458 </div>
459 <div class="ultp-tab-wrap">
460 <div class="ultp-tab-title-wrap">
461 <div class="ultp-tab-title active"><?php _e('Settings', 'ultimate-post'); ?></div>
462 <div class="ultp-tab-title"><?php _e('Recommended Theme', 'ultimate-post'); ?></div>
463 <div class="ultp-tab-title"><?php _e('Changelog', 'ultimate-post'); ?></div>
464 </div>
465 <div class="ultp-tab-content-wrap">
466 <div class="ultp-tab-content active"><!-- #Settings Content -->
467 <?php self::get_settings_data(); ?>
468 </div>
469 <div class="ultp-tab-content"><!-- #Recommended Theme Content -->
470 <?php self::get_recommended_themes(); ?>
471 </div>
472 <div class="ultp-tab-content"><!-- #Changelog Content -->
473 <?php self::get_changelog_data(); ?>
474 </div>
475 </div>
476 </div>
477 <?php self::get_support_data(); ?>
478 <script type="text/javascript">
479 jQuery( document ).ready(function() {
480 jQuery( document ).on( "click", '.ultp-tab-title', function(e){
481 jQuery(this).closest('.ultp-tab-wrap').find('.ultp-tab-title').removeClass('active').eq(jQuery(this).index()).addClass('active')
482 jQuery(this).closest('.ultp-tab-wrap').find('.ultp-tab-content').removeClass('active').eq(jQuery(this).index()).addClass('active');
483 });
484 });
485 </script>
486 </div>
487 </div>
488 <?php }
489 }
490
491