PluginProbe
Post Grid Gutenberg Blocks – PostX / 1.2.6
Post Grid Gutenberg Blocks – PostX v1.2.6
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.2.6, at classes/Options.php

579 lines 22.3 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__( 'Post Blocks', 'ultimate-post' ),
15 esc_html__( 'Post Blocks', '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] = isset($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 Add Via', 'ultimate-post'),
50 'options' => array(
51 'wp_head' => __( 'Header - (Internal)','ultimate-post' ),
52 'filesystem' => __( 'File System - (External)','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 'container_width' => array(
68 'type' => 'number',
69 'label' => __('Container Width', 'ultimate-post'),
70 'default' => '1140',
71 'desc' => __('Change Container Width.', 'ultimate-post')
72 ),
73 'hide_import_btn' => array(
74 'type' => 'switch',
75 'label' => __('Hide Import Button', 'ultimate-post'),
76 'default' => '',
77 'desc' => __('Hide Import Layout Button from the Gutenberg Editor.', 'ultimate-post')
78 ),
79 );
80 }
81
82 public static function get_recommended_themes(){
83 $recommended_themes = array(
84 'coblog' => array(
85 'name' => 'Coblog',
86 'slug' => 'coblog',
87 'url' => 'https://wordpress.org/themes/coblog',
88 'logo' => ULTP_URL.'assets/img/WordPress.png'
89 ),
90 'blocksy' => array(
91 'name' => 'Blocksy',
92 'slug' => 'blocksy',
93 'url' => 'https://wordpress.org/themes/blocksy/',
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"><a target="_blank" href="'.$value['url'].'">'.$value['name'].'</a></div>';
105 $html .= '<div class="ultp-recommended-button">';
106 $html .= '<a target="_blank" href="'.$value['url'].'" class="button button-success">'.__('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 if(!$option_data){
173 $option_data = ultimate_post()->init_set_data();
174 }
175 $data = self::get_option_settings();
176 $html .= '<div class="ultp-settings">';
177 $html .= '<input type="hidden" name="option_page" value="ultp_options" />';
178 $html .= '<input type="hidden" name="action" value="update" />';
179 $html .= wp_nonce_field( "ultp_options-options" );
180 foreach ($data as $key => $value) {
181 $html .= '<div class="ultp-settings-wrap">';
182 $html .= '<div class="ultp-settings-label">'.$value['label'].'</div>';
183 $html .= '<div class="ultp-settings-field-wrap">';
184 switch ($value['type']) {
185
186 case 'select':
187 $html .= '<div class="ultp-settings-field">';
188 $val = isset($option_data[$key]) ? $option_data[$key] : (isset($value['default']) ? $value['default'] : '');
189 $html .= '<select name="ultp_options['.$key.']">';
190 foreach ( $value['options'] as $id => $label ) {
191 $html .= '<option value="'.$id.'" '.( $val == $id ? ' selected="selected"':'').'>';
192 $html .= strip_tags( $label );
193 $html .= '</option>';
194 }
195 $html .= '</select>';
196 $html .= '<p class="description">'.$value['desc'].'</p>';
197 $html .= '</div>';
198 break;
199
200 case 'color':
201 $html .= '<div class="ultp-settings-field">';
202 $val = isset($option_data[$key]) ? $option_data[$key] : (isset($value['default']) ? $value['default'] : '');
203 $html .= '<input name="ultp_options['.$key.']" value="'.$val.'" class="ultp-color-picker" />';
204 $html .= '<p class="description">'.$value['desc'].'</p>';
205 $html .= '</div>';
206 break;
207
208 case 'number':
209 $html .= '<div class="ultp-settings-field">';
210 $val = isset($option_data[$key]) ? $option_data[$key] : (isset($value['default']) ? $value['default'] : '');
211 $html .= '<input type="number" name="ultp_options['.$key.']" value="'.$val.'"/>';
212 $html .= '<p class="description">'.$value['desc'].'</p>';
213 $html .= '</div>';
214 break;
215
216 case 'switch':
217 $html .= '<div class="ultp-settings-field">';
218 $val = isset($option_data[$key]) ? $option_data[$key] : (isset($value['default']) ? $value['default'] : '');
219 $html .= '<input type="checkbox" value="yes" name="ultp_options['.$key.']" '.($val == 'yes' ? 'checked' : '').' />';
220 $html .= '<p class="description">'.$value['desc'].'</p>';
221 $html .= '</div>';
222 break;
223
224 default:
225 # code...
226 break;
227
228 }
229 $html .= '</div>';
230 $html .= '</div>';
231 }
232 $html .= '<div class="ultp-settings-wrap ultp-submit-button">';
233 $html .= '<div></div>'.get_submit_button();
234 $html .= '</div>';
235
236 $html .= '</div>';
237
238
239
240 echo '<form method="post" action="options.php">'.$html.'</form>';
241 }
242
243 /**
244 * Settings page output
245 */
246 public static function create_admin_page() { ?>
247 <style>
248 /* ----Common--- */
249 #wpbody-content, #wpwrap{
250 background-color: #f2f2f2;
251 -webkit-font-smoothing: subpixel-antialiased;
252 }
253 .error, .notice {
254 display: none;
255 }
256 #wpcontent {
257 padding-left: 0px;
258 }
259 .ultp-option-body {
260 position: relative;
261 font-size: 15px;
262 max-width: 100%;
263 display:block;
264 }
265
266 /* ----Header--- */
267 .ultp-setting-header {
268 width: 100%;
269 display: flex;
270 align-items: center;
271 padding: 20px 40px;
272 box-sizing: border-box;
273 background: #fff;
274 }
275 .ultp-setting-header img {
276 margin-left:auto;
277 }
278 .ultp-setting-header-info h1 {
279 margin: 0;
280 font-weight: 300;
281 font-size: 35px;
282 line-height: normal;
283 color: #000;
284 }
285 .ultp-setting-header-info p {
286 font-size: 14px;
287 margin-top: 5px;
288 margin-bottom: 0;
289 font-weight:300;
290 }
291 .ultp-setting-header-info p a {
292 margin-left: 5px;
293 text-decoration: none;
294 color: #007AFF;
295 }
296 .ultp-setting-header-info p a span {
297 color: #FF9920;
298 margin-left: 10px;
299 font-size: 18px;
300 letter-spacing: 4px;
301 }
302
303
304
305
306 /* ----common--- */
307
308
309
310 /* ----Sidebar--- */
311 .ultp-sidebar-card {
312 padding: 0 20px 25px;
313 margin-bottom: 30px;
314 }
315 .ultp-sidebar-title {
316 margin: 0 -20px 0;
317 background: #FAFAFA;
318 padding: 15px 20px;
319 font-size: 16px;
320 border-bottom: 1px solid #EEEEEE;
321 color: #007AFF;
322 }
323 .ultp-sidebar-card h4 {
324 color: #000;
325 margin-top: 25px;
326 }
327 .ultp-sidebar-list {
328 list-style: none;
329 padding: 0;
330 margin-bottom: 30px;
331 }
332 .ultp-sidebar-list li {
333 font-size: 13px;
334 padding: 0 20px;
335 position: relative;
336 margin-right: auto;
337 line-height: 24px;
338 }
339 .ultp-sidebar-list li:after {
340 content: "";
341 left: 0;
342 width: 8px;
343 height: 8px;
344 border-radius: 100px;
345 background: #c1c1c1;
346 position: absolute;
347 top: 50%;
348 margin-top: -4px;
349 }
350 .ultp-sidebar-content {
351 margin-top: 25px;
352 }
353
354 /* ----Tab--- */
355 .ultp-content-wrap {
356 padding: 40px;
357 display: flex;
358 width: 100%;
359 box-sizing: border-box;
360 }
361 .ultp-tab-content-wrap {
362 width: 75%;
363 margin-right: 30px;
364 -webkit-box-flex: 0;
365 -ms-flex: 0 0 75%;
366 flex: 0 0 75%;
367 max-width: 75%;
368 }
369
370 .ultp-tab-title-wrap{
371 padding: 0 40px;
372 background-color: #ffffff;
373 border-bottom: 3px solid #d5d5d5;
374 }
375 .ultp-tab-title{
376 font-weight: 300;
377 color: #555;
378 font-size: 15px;
379 display: inline-block;
380 margin-right: 25px;
381 padding: 10px 0;
382 }
383 .ultp-tab-title:hover{
384 cursor: pointer;
385 }
386 .ultp-tab-title.active{
387 border-bottom: 3px solid #007AFF;
388 color: #007AFF;
389 margin-bottom: -3px;
390 }
391 .ultp-tab-content{
392 display: none;
393 }
394 .ultp-tab-content.active{
395 display: block;
396 }
397
398 /* ----Settings--- */
399 .ultp-settings-wrap {
400 margin-bottom: 20px;
401 display: grid;
402 grid-template-columns: 0.8fr 1fr;
403 }
404
405 /* ---Changelog--- */
406 .ultp-changelog-wrap {
407 background-color: #ffffff;
408 margin: 0 auto 30px;
409 padding: 25px 30px;
410 position: relative;
411 box-shadow: 0 0 10px -5px rgba(0,0,0,0.5);
412 }
413 .ultp-changelog-date{
414 font-size: 14px;
415 display: inline-block;
416 right: 30px;
417 position: absolute;
418 font-weight: 300;
419 }
420 .ultp-changelog-version{
421 font-size: 16px;
422 color: #000000;
423 font-weight: 700;
424 margin-bottom: 20px;
425 }
426 .ultp-changelog-title {
427 text-transform: capitalize;
428 font-size: 14px;
429 color: #555555;
430 line-height: 28px;
431 font-weight: 300;
432 margin-bottom: 8px;
433 }
434 .ultp-changelog-title > span {
435 padding: 2px 10px;
436 border-radius: 3px;
437 margin-right: 10px;
438 }
439 .changelog-fix{
440 color: #721c24;
441 background-color: #f8d7da;
442 border-color: #f5c6cb;
443 }
444 .changelog-update{
445 color: #856404;
446 background-color: #fff3cd;
447 border-color: #ffeeba;
448 }
449 .changelog-new{
450 color: #155724;
451 background-color: #d4edda;
452 border-color: #c3e6cb;
453 }
454
455 /* ----Responsive--- */
456 @media (max-width: 1500px) {
457 .ultp-overview {
458 flex-wrap: wrap;
459 flex-direction: column-reverse;
460 }
461 .ultp-overview-content {
462 max-width: 100%;
463 }
464 .ultp-overview-video {
465 margin-bottom: 40px;
466 }
467 .ultp-overview-video iframe {
468 width: 640px;
469 height: 360px;
470 box-shadow: 0 0 10px -5px rgba(0,0,0,0.5);
471 }
472 .ultp-video-tutorials {
473 grid-template-columns: 1fr 1fr;
474 }
475 }
476 @media (max-width: 1400px) {
477 .ultp-sidebar-card .button.button-primary {
478 text-align: center;
479 display: block;
480 }
481 .ultp-sidebar-card .button.button-success {
482 text-align: center;
483 display: block;
484 margin-left: 0;
485 margin-top: 10px;
486 }
487 }
488 @media (max-width: 1200px) {
489 .ultp-content-wrap {
490 flex-wrap: wrap;
491 }
492 .ultp-tab-content-wrap {
493 width: 100%;
494 margin-right: 0;
495 -webkit-box-flex: 0;
496 -ms-flex: 0 0 100%;
497 flex: 0 0 100%;
498 max-width: 100%;
499 }
500 .ultp-admin-sidebar {
501 margin-top: 40px;
502 }
503 }
504 @media (max-width: 1000px) {
505 .ultp-setting-header-info h1 {
506 font-size: 28px;
507 }
508 .ultp-overview-video iframe {
509 width: 350px;
510 height: 250px;
511 }
512 .ultp-setting-header {
513 padding: 20px 30px;
514 }
515 .ultp-tab-title-wrap {
516 padding: 0 30px;
517 }
518 .ultp-overview {
519 padding: 30px;
520 }
521 .ultp-video-tutorials {
522 grid-template-columns: 1fr;
523 }
524 }
525 </style>
526
527 <div class="ultp-option-body">
528 <div class="ultp-setting-header">
529 <div class="ultp-setting-header-info">
530 <h1>
531 <?php _e('Welcome to <strong>Gutenberg Post Blocks</strong> - Version', 'ultimate-post'); ?><span> <?php echo ULTP_VER; ?></span>
532 </h1>
533 <p><?php esc_html_e('Most Powerful & Advanced Gutenberg Kit', 'ultimate-post'); ?><a href="https://wordpress.org/support/plugin/ultimate-post/reviews/#new-post"><?php esc_html_e('Rate the plugin', 'ultimate-post'); ?><span>�
534
535
536
537
538 <span></a></p>
539 </div>
540 <img src="<?php echo ULTP_URL.'assets/img/logo-option.svg'; ?>" alt="<?php _e('Gutenberg Post Blocks', 'ultimate-post'); ?>">
541 </div>
542
543 <?php $section = isset($_GET['tab']) ? $_GET['tab'] :'settings'; ?>
544 <div class="ultp-tab-wrap">
545 <div class="ultp-tab-title-wrap">
546 <div data-title="settings" class="ultp-tab-title<?php if($section == 'settings'){ echo ' active'; } ?>"><?php _e('General Settings', 'ultimate-post'); ?></div>
547 <div data-title="changelog" class="ultp-tab-title<?php if($section == 'changelog'){ echo ' active'; } ?>"><?php _e('Changelog', 'ultimate-post'); ?></div>
548 </div>
549 <div class="ultp-content-wrap">
550 <div class="ultp-tab-content-wrap">
551 <div class="ultp-tab-content<?php if($section == 'settings'){ echo ' active'; } ?>"><!-- #Settings Content -->
552 <div class="ultp-overview ultp-admin-card"><!-- #Settings Content -->
553 <?php self::get_settings_data(); ?>
554 </div>
555 </div>
556 <div class="ultp-tab-content<?php if($section == 'changelog'){ echo ' active'; } ?>"><!-- #Changelog Content -->
557 <?php self::get_changelog_data(); ?>
558 </div>
559 </div>
560 </div>
561 </div>
562
563 <script type="text/javascript">
564 jQuery( document ).ready(function() {
565 jQuery( document ).on( "click", '.ultp-tab-title', function(e){
566 jQuery(this).closest('.ultp-tab-wrap').find('.ultp-tab-title').removeClass('active').eq(jQuery(this).index()).addClass('active')
567 jQuery(this).closest('.ultp-tab-wrap').find('.ultp-tab-content').removeClass('active').eq(jQuery(this).index()).addClass('active');
568 let refresh = window.location.protocol + "//" + window.location.host + window.location.pathname + '?page=ultp-settings&tab='+jQuery(this).data('title');
569 window.history.pushState({ path: refresh }, '', refresh);
570 jQuery('input[name=_wp_http_referer]').val(window.location.pathname + '?page=ultp-settings&tab=settings');
571 });
572 });
573 </script>
574 </div>
575
576 <?php }
577 }
578
579