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

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