PluginProbe
Post Grid Gutenberg Blocks – PostX / 2.8.3
Post Grid Gutenberg Blocks – PostX v2.8.3
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 / Functions.php

Functions.php in Post Grid Gutenberg Blocks – PostX 2.8.3, at classes/Functions.php

2,500 lines 113.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Common Functions.
4 *
5 * @package ULTP\Functions
6 * @since v.1.0.0
7 */
8 namespace ULTP;
9
10 defined('ABSPATH') || exit;
11
12 /**
13 * Functions class.
14 */
15
16 class Functions{
17
18 /**
19 * Setup class.
20 *
21 * @since v.1.0.0
22 */
23 public function __construct() {
24 if (!isset($GLOBALS['ultp_settings'])) {
25 $GLOBALS['ultp_settings'] = get_option('ultp_options');
26 $GLOBALS['ultp_settings']['date_format'] = get_option('date_format');
27 $GLOBALS['ultp_settings']['time_format'] = get_option('time_format');
28 }
29 }
30
31 /**
32 * ID for the Builder Post or Normal Post
33 *
34 * @since v.2.3.1
35 * @return NUMBER | is Builder or not
36 */
37 public function get_ID() {
38 $id = $this->is_builder();
39 return $id ? $id : (function_exists('is_shop') ? (is_shop() ? wc_get_page_id('shop') : get_the_ID()) : get_the_ID() );
40 }
41
42 /**
43 * Checking Statement of Dynamic Site Builder
44 *
45 * @since v.2.3.1
46 * @return BOOLEAN | is Builder or not
47 */
48 public function is_archive_builder() {
49 $id = get_the_ID();
50 return get_post_type( $id ) == 'ultp_builder' ? get_post_meta( $id, '__ultp_builder_type', true ) : false;
51 }
52
53
54 /**
55 * Set Link with the Parameters
56 *
57 * @since v.1.1.0
58 * @return STRING | URL with Arg
59 */
60 public function get_premium_link( $url = '', $tag = 'go_premium' ) {
61 $url = $url ? $url : 'https://www.wpxpo.com/postx/pricing/';
62 $affiliate_id = apply_filters( 'ultp_affiliate_id', FALSE );
63 $arg = array( 'utm_source' => $tag );
64 if ( ! empty( $affiliate_id ) ) {
65 $arg[ 'ref' ] = esc_attr( $affiliate_id );
66 }
67 return add_query_arg( $arg, $url );
68 }
69
70
71 /**
72 * Get Width and Height of the Image
73 *
74 * @since v.1.1.0
75 * @return STRING | Image Size
76 */
77 public function get_size($name = '') {
78 global $_wp_additional_image_sizes;
79 $image_size = $name ? ( isset($_wp_additional_image_sizes[$name]) ? $_wp_additional_image_sizes[$name] : array_values($_wp_additional_image_sizes)[0] ) : array_values($_wp_additional_image_sizes)[0];
80
81 return ' width="'.$image_size['width'].'" height="'.$image_size['height'].'" ';
82 }
83
84
85 /**
86 * Image Placeholder
87 *
88 * @since v.1.1.0
89 * @return STRING | Image Placeholder
90 */
91 public function img_placeholder($type = 'small') {
92 switch ($type) {
93 case 'small':
94 return 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAG4AAABLAQMAAACr9CA9AAAAA1BMVEX///+nxBvIAAAAAXRSTlMAQObYZgAAABZJREFUOI1jYMADmEe5o9xR7iiXQi4A4BsA388WUyMAAAAASUVORK5CYII=';
95 break;
96
97 case 'wide':
98 return 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAKCAYAAADVTVykAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAB9JREFUeNpi/P//P8NAAiaGAQajDhh1wKgDRh0AEGAAQTcDEcKDrpMAAAAASUVORK5CYII=';
99 break;
100
101 case 'square':
102 return 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABAQMAAAAl21bKAAAAA1BMVEX///+nxBvIAAAAAXRSTlMAQObYZgAAAApJREFUCJljYAAAAAIAAfRxZKYAAAAASUVORK5CYII=';
103 break;
104
105 case 'slider':
106 return 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAKYAAABkCAMAAAA7drv6AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAAZQTFRF////AAAAVcLTfgAAAAF0Uk5TAEDm2GYAAAAqSURBVHja7MEBDQAAAMKg909tDjegAAAAAAAAAAAAAAAAAAAAAH5NgAEAQTwAAWZtItYAAAAASUVORK5CYII=';
107 break;
108
109 default:
110 return 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAYYAAADcAQMAAABOLJSDAAAAA1BMVEUAAACnej3aAAAAAXRSTlMAQObYZgAAACJJREFUaIHtwTEBAAAAwqD1T20ND6AAAAAAAAAAAAAA4N8AKvgAAUFIrrEAAAAASUVORK5CYII=';
111 break;
112 }
113 }
114
115
116 /**
117 * Quick Query
118 *
119 * @since v.1.1.0
120 * @return ARRAY | Query Arg
121 */
122 public function get_quick_query($prams, $args) {
123 switch ($prams['queryQuick']) {
124 case 'related_posts':
125 global $post;
126 $p_id = isset($post->ID) && $post->ID ? $post->ID : (isset($_POST['postId']) ? $_POST['postId'] : '');
127 if ($p_id) {
128 $args['post__not_in'] = array($p_id);
129 }
130 break;
131 case 'related_tag':
132 global $post;
133 $p_id = isset($post->ID) && $post->ID ? $post->ID : (isset($_POST['postId']) ? $_POST['postId'] : '');
134 if ($p_id) {
135 $args['tax_query'] = array(
136 array(
137 'taxonomy' => 'post_tag',
138 'terms' => $this->get_terms_id($p_id, 'post_tag'),
139 'field' => 'term_id',
140 )
141 );
142 $args['post__not_in'] = array($p_id);
143 }
144 break;
145 case 'related_category':
146 global $post;
147 $p_id = isset($post->ID) && $post->ID ? $post->ID : (isset($_POST['postId']) ? $_POST['postId'] : '');
148 if ($p_id) {
149 $args['tax_query'] = array(
150 array(
151 'taxonomy' => 'category',
152 'terms' => $this->get_terms_id($p_id, 'category'),
153 'field' => 'term_id',
154 )
155 );
156 $args['post__not_in'] = array($p_id);
157 }
158 break;
159 case 'related_cat_tag':
160 global $post;
161 $p_id = isset($post->ID) && $post->ID ? $post->ID : (isset($_POST['postId']) ? $_POST['postId'] : '');
162 if ($p_id) {
163 $args['tax_query'] = array(
164 array(
165 'taxonomy' => 'post_tag',
166 'terms' => $this->get_terms_id($p_id, 'post_tag'),
167 'field' => 'term_id',
168 ),
169 array(
170 'taxonomy' => 'category',
171 'terms' => $this->get_terms_id($p_id, 'category'),
172 'field' => 'term_id',
173 )
174 );
175 $args['post__not_in'] = array($p_id);
176 }
177 break;
178 case 'sticky_posts':
179 $sticky = get_option('sticky_posts');
180 if (is_array($sticky)) {
181 rsort($sticky);
182 $sticky = array_slice($sticky, 0, $args['posts_per_page']);
183 }
184 $args['ignore_sticky_posts'] = 1;
185 $args['post__in'] = $sticky;
186 break;
187 case 'latest_post_published':
188 $args['orderby'] = 'date';
189 $args['order'] = 'DESC';
190 $args['ignore_sticky_posts'] = 1;
191 break;
192 case 'latest_post_modified':
193 $args['orderby'] = 'modified';
194 $args['order'] = 'DESC';
195 $args['ignore_sticky_posts'] = 1;
196 break;
197 case 'oldest_post_published':
198 $args['orderby'] = 'date';
199 $args['order'] = 'ASC';
200 break;
201 case 'oldest_post_modified':
202 $args['orderby'] = 'modified';
203 $args['order'] = 'ASC';
204 break;
205 case 'alphabet_asc':
206 $args['orderby'] = 'title';
207 $args['order'] = 'ASC';
208 break;
209 case 'alphabet_desc':
210 $args['orderby'] = 'title';
211 $args['order'] = 'DESC';
212 break;
213 case 'random_post':
214 $args['orderby'] = 'rand';
215 $args['order'] = 'ASC';
216 break;
217 case 'random_post_7_days':
218 $args['orderby'] = 'rand';
219 $args['order'] = 'ASC';
220 $args['date_query'] = array( array( 'after' => '1 week ago') );
221 break;
222 case 'random_post_30_days':
223 $args['orderby'] = 'rand';
224 $args['order'] = 'ASC';
225 $args['date_query'] = array( array( 'after' => '1 month ago') );
226 break;
227 case 'most_comment':
228 $args['orderby'] = 'comment_count';
229 $args['order'] = 'DESC';
230 break;
231 case 'most_comment_1_day':
232 $args['orderby'] = 'comment_count';
233 $args['order'] = 'DESC';
234 $args['date_query'] = array( array( 'after' => '1 day ago') );
235 break;
236 case 'most_comment_7_days':
237 $args['orderby'] = 'comment_count';
238 $args['order'] = 'DESC';
239 $args['date_query'] = array( array( 'after' => '1 week ago') );
240 break;
241 case 'most_comment_30_days':
242 $args['orderby'] = 'comment_count';
243 $args['order'] = 'DESC';
244 $args['date_query'] = array( array( 'after' => '1 month ago') );
245 break;
246 case 'popular_post_1_day_view':
247 $args['meta_key'] = '__post_views_count';
248 $args['orderby'] = 'meta_value_num';
249 $args['order'] = 'DESC';
250 $args['date_query'] = array( array( 'after' => '1 day ago') );
251 break;
252 case 'popular_post_7_days_view':
253 $args['meta_key'] = '__post_views_count';
254 $args['orderby'] = 'meta_value_num';
255 $args['order'] = 'DESC';
256 $args['date_query'] = array( array( 'after' => '1 week ago') );
257 break;
258 case 'popular_post_30_days_view':
259 $args['meta_key'] = '__post_views_count';
260 $args['orderby'] = 'meta_value_num';
261 $args['order'] = 'DESC';
262 $args['date_query'] = array( array( 'after' => '1 month ago') );
263 break;
264 case 'popular_post_all_times_view':
265 $args['meta_key'] = '__post_views_count';
266 $args['orderby'] = 'meta_value_num';
267 $args['order'] = 'DESC';
268 break;
269 default:
270 # code...
271 break;
272 }
273 return $args;
274 }
275
276 /**
277 * Get All Term ID as Array
278 *
279 * @since v.2.4.12
280 * @return ARRAY | Query Arg
281 */
282 public function get_terms_id($id, $type) {
283 $data = array();
284 $arr = get_the_terms($id, $type);
285 if (is_array($arr)) {
286 foreach ($arr as $key => $val) {
287 $data[] = $val->term_id;
288 }
289 }
290 return $data;
291 }
292
293 /**
294 * Get All Reusable ID
295 *
296 * @since v.1.1.0
297 * @return ARRAY | Query Arg
298 */
299 public function reusable_id($post_id) {
300 $reusable_id = array();
301 if ($post_id) {
302 $post = get_post($post_id);
303 if (has_blocks($post->post_content)) {
304 $blocks = parse_blocks($post->post_content);
305 foreach ($blocks as $key => $value) {
306 if (isset($value['attrs']['ref'])) {
307 $reusable_id[] = $value['attrs']['ref'];
308 }
309 }
310 }
311 }
312 return $reusable_id;
313 }
314
315
316 /**
317 * Set CSS Style
318 *
319 * @since v.1.1.0
320 * @return ARRAY | Query Arg
321 */
322 public function set_css_style($post_id, $shortcode = false) {
323 if ($post_id) {
324 $upload_dir_url = wp_get_upload_dir();
325 $upload_css_dir_url = trailingslashit( $upload_dir_url['basedir'] );
326 $css_dir_path = $upload_css_dir_url . "ultimate-post/ultp-css-{$post_id}.css";
327
328 $css_dir_url = trailingslashit( $upload_dir_url['baseurl'] );
329 if (is_ssl()) {
330 $css_dir_url = str_replace('http://', 'https://', $css_dir_url);
331 }
332
333 // Reusable CSS
334 $reusable_id = ultimate_post()->reusable_id($post_id);
335 foreach ( $reusable_id as $id ) {
336 $reusable_dir_path = $upload_css_dir_url."ultimate-post/ultp-css-{$id}.css";
337 if (file_exists( $reusable_dir_path )) {
338 $css_url = $css_dir_url . "ultimate-post/ultp-css-{$id}.css";
339 wp_enqueue_style( "ultp-post-{$id}", $css_url, array(), ultimate_post()->get_setting('save_version'), 'all' );
340 }else{
341 $css = get_post_meta($id, '_ultp_css', true);
342 if( $css ) {
343 ultimate_post()->set_inline($css);
344 }
345 }
346 }
347
348 if (isset($_GET['et_fb']) || (isset($_GET['action']) && sanitize_key($_GET['action']) == 'elementor') || $shortcode) {
349 return ultimate_post()->set_inline(get_post_meta($post_id, '_ultp_css', true));
350 } else {
351 if (file_exists( $css_dir_path ) ) {
352 $css_url = $css_dir_url . "ultimate-post/ultp-css-{$post_id}.css";
353 wp_enqueue_style( "ultp-post-{$post_id}", $css_url, array(), ultimate_post()->get_setting('save_version'), 'all' );
354 } else {
355 $css = get_post_meta($post_id, '_ultp_css', true);
356 if( $css ) {
357 ultimate_post()->set_inline($css);
358 }
359 }
360 }
361 }
362 }
363
364
365 /**
366 * Get Global Plugin Settings
367 *
368 * @since v.1.0.0
369 * @param STRING | Key of the Option
370 * @return ARRAY | STRING
371 */
372 public function get_setting($key = '') {
373 $data = $GLOBALS['ultp_settings'];
374 if ($key != '') {
375 return isset($data[$key]) ? $data[$key] : '';
376 } else {
377 return $data;
378 }
379 }
380
381
382 /**
383 * Set Option Settings
384 *
385 * @since v.1.0.0
386 * @param STRING | Key of the Option (STRING), Value (STRING)
387 * @return NULL
388 */
389 public function set_setting($key = '', $val = '') {
390 if ($key != '') {
391 $data = $GLOBALS['ultp_settings'];
392 $data[$key] = $val;
393 update_option('ultp_options', $data);
394 $GLOBALS['ultp_settings'] = $data;
395 }
396 }
397
398
399 /**
400 * Get Image HTML
401 *
402 * @since v.1.0.0
403 * @param | URL (STRING) | size (STRING) | class (STRING) | alt (STRING)
404 * @return STRING
405 */
406 public function get_image_html($url = '', $size = 'full', $class = '', $alt = '', $lazy = '') {
407 $alt = $alt ? ' alt="'.$alt.'" ' : '';
408 $lazy_data = $lazy ? ' loading="lazy"' : '';
409 $class = $class ? ' class="'.$class.'" ' : '';
410 return '<img '.$lazy_data.$class.$alt.' src="'.$url.'" />';
411 }
412
413
414 /**
415 * Get Image HTML
416 *
417 * @since v.1.0.0
418 * @param | Attach ID (STRING) | size (STRING) | class (STRING) | alt (STRING)
419 * @return STRING
420 */
421 public function get_image($attach_id, $size = 'full', $class = '', $alt = '', $srcset = '', $lazy = '') {
422 $alt = $alt ? ' alt="'.$alt.'" ' : '';
423 $class = $class ? ' class="'.$class.'" ' : '';
424 $size = ( ultimate_post()->get_setting('disable_image_size') == 'yes' && strpos($size, 'ultp_layout_') !== false ) ? 'full' : $size;
425 $lazy_data = $lazy ? ' loading="lazy"' : '';
426 $srcset_data = $srcset ? ' srcset="'.esc_attr(wp_get_attachment_image_srcset($attach_id)).'"' : '';
427 return '<img '.$srcset_data.$lazy_data.$class.$alt.' src="'.wp_get_attachment_image_url( $attach_id, $size ).'" />';
428 }
429
430
431 /**
432 * Setup Initial Data Set
433 *
434 * @since v.1.0.0
435 * @return NULL
436 */
437 public function init_set_data() {
438 $data = get_option( 'ultp_options', array() );
439 $init_data = array(
440 'css_save_as' => 'wp_head',
441 'preloader_style' => 'style1',
442 'preloader_color' => '#037fff',
443 'container_width' => '1140',
444 'hide_import_btn' => '',
445 'disable_image_size'=> '',
446 'disable_view_cookies' => '',
447 'disable_google_font' => '',
448 'ultp_templates' => 'true',
449 'ultp_elementor' => 'true',
450 'ultp_table_of_content'=> 'true',
451 'ultp_builder' => 'true',
452 'post_grid_1' => 'yes',
453 'post_grid_2' => 'yes',
454 'post_grid_3' => 'yes',
455 'post_grid_4' => 'yes',
456 'post_grid_5' => 'yes',
457 'post_grid_6' => 'yes',
458 'post_grid_7' => 'yes',
459 'post_list_1' => 'yes',
460 'post_list_2' => 'yes',
461 'post_list_3' => 'yes',
462 'post_list_4' => 'yes',
463 'post_module_1' => 'yes',
464 'post_module_2' => 'yes',
465 'post_slider_1' => 'yes',
466 'post_slider_2' => 'yes',
467 'heading' => 'yes',
468 'image' => 'yes',
469 'taxonomy' => 'yes',
470 'wrapper' => 'yes',
471 'news_ticker' => 'yes',
472 'builder_advance_post_meta' => 'yes',
473 'builder_archive_title' => 'yes',
474 'builder_author_box' => 'yes',
475 'builder_post_next_previous'=> 'yes',
476 'builder_post_author_meta' => 'yes',
477 'builder_post_breadcrumb' => 'yes',
478 'builder_post_category' => 'yes',
479 'builder_post_comment_count'=> 'yes',
480 'builder_post_comments' => 'yes',
481 'builder_post_content' => 'yes',
482 'builder_post_date_meta' => 'yes',
483 'builder_post_excerpt' => 'yes',
484 'builder_post_featured_image'=> 'yes',
485 'builder_post_reading_time' => 'yes',
486 'builder_post_social_share' => 'yes',
487 'builder_post_tag' => 'yes',
488 'builder_post_title' => 'yes',
489 'builder_post_view_count' => 'yes',
490 'save_version' => rand(1, 1000)
491 );
492 if (empty($data)) {
493 update_option('ultp_options', $init_data);
494 $GLOBALS['ultp_settings'] = $init_data;
495 } else {
496 foreach ($init_data as $key => $single) {
497 if (!isset($data[$key])) {
498 $data[$key] = $single;
499 }
500 }
501 update_option('ultp_options', $data);
502 $GLOBALS['ultp_settings'] = $data;
503 }
504 }
505
506
507 /**
508 * Get Excerpt Text
509 *
510 * @since v.1.0.0
511 * @param | Post ID (STRING) | Limit (NUMBER)
512 * @return STRING
513 */
514 public function excerpt( $post_id, $limit = 55 ) {
515 return apply_filters( 'the_excerpt', wp_trim_words( get_the_content( $post_id ) , $limit ) );
516 }
517
518 /**
519 * Builder Attributes
520 *
521 * @since v.1.0.0
522 * @param STRING type
523 * @return STRING
524 */
525 public function get_builder_attr($type) {
526 $builder_data = '';
527 if ($type == 'archiveBuilder') {
528 if (is_archive()) {
529 if (is_date()) {
530 if (is_year()) {
531 $builder_data = 'date###'.get_the_date('Y');
532 } else if (is_month() ) {
533 $builder_data = 'date###'.get_the_date('Y-n');
534 } else if (is_day() ) {
535 $builder_data = 'date###'.get_the_date('Y-n-j');
536 }
537 } else if (is_author()) {
538 $builder_data = 'author###'.get_the_author_meta('ID');
539 } else {
540 $obj = get_queried_object();
541 if (isset($obj->taxonomy)) {
542 $builder_data = 'taxonomy###'.$obj->taxonomy.'###'.$obj->slug;
543 }
544 }
545 } else if (is_search()) {
546 $builder_data = 'search###'.get_search_query(true);
547 }
548 }
549 return $builder_data ? 'data-builder="'.$builder_data.'"' : '';
550 }
551
552
553 public function is_builder($builder = '') {
554 $id = '';
555 $page_id = ultimate_post()->conditions('return');
556 if ($page_id && ultimate_post()->get_setting('ultp_builder')) {
557 $id = $page_id;
558 }
559 return $id;
560 }
561
562
563 /**
564 * Get Post Number Depending On Device
565 *
566 * @since v.2.5.4
567 * @param MULTIPLE | Attribute of Posts
568 * @return STRING
569 */
570 public function get_post_number($preDef, $prev, $current) {
571
572 $current = is_object($current)?json_decode(json_encode($current), true):$current;
573 if (['lg'=>$preDef,'sm'=>$preDef,'xs'=>$preDef] == $current) {
574 if ($preDef != $prev) {
575 return $prev;
576 }
577 }
578 if ($this->isDevice() == 'mobile') {
579 return $current['xs'];
580 } else if ($this->isDevice() == 'tablet') {
581 return $current['sm'];
582 } else {
583 return $current['lg'];
584 }
585 }
586
587
588 /**
589 * Get Post Number Depending On Device
590 *
591 * @since v.2.5.4
592 * @param NULL
593 * @return STRING | Device Type
594 */
595 public function isDevice(){
596 $useragent = isset($_SERVER['HTTP_USER_AGENT']) ? sanitize_key($_SERVER['HTTP_USER_AGENT']) : '';
597 if ($useragent) {
598 if (preg_match('/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i',$useragent)||preg_match('/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i',substr($useragent,0,4))) {
599 return 'mobile';
600 } else if (preg_match('/(tablet|ipad|playbook)|(android(?!.*(mobi|opera mini)))/i', strtolower($useragent))) {
601 return 'tablet';
602 } else {
603 return 'desktop';
604 }
605 }
606 return 'desktop';
607 }
608
609
610 /**
611 * Get Raw Value from Objects
612 *
613 * @since v.2.5.3
614 * @param NULL
615 * @return STRING | Device Type
616 */
617 public function get_value($attr) {
618 $data = [];
619 if (is_array($attr)) {
620 foreach ($attr as $val) {
621 $data[] = $val->value;
622 }
623 }
624 return $data;
625 }
626
627
628 /**
629 * Query Builder
630 *
631 * @since v.1.0.0
632 * @param ARRAY | Attribute of the Query
633 * @return ARRAY
634 */
635 public function get_query($attr) {
636 $builder = isset($attr['builder']) ? $attr['builder'] : '';
637 $post_type = isset($attr['queryType']) ? $attr['queryType'] : 'post';
638 if ( $post_type == 'archiveBuilder' && ($builder || $this->is_builder($builder)) ) {
639 $archive_query = array();
640 if ($builder) {
641 $str = explode('###', $builder);
642 if (isset($str[0])) {
643 if ($str[0] == 'taxonomy') {
644 if (isset($str[1]) && isset($str[2])) {
645 $archive_query['tax_query'] = array(
646 array(
647 'taxonomy' => $str[1],
648 'field' => 'slug',
649 'terms' => $str[2]
650 )
651 );
652 }
653 } else if ($str[0] == 'author') {
654 if (isset($str[1])) {
655 $archive_query['author'] = $str[1];
656 }
657 } else if ($str[0] == 'search') {
658 if (isset($str[1])) {
659 $archive_query['s'] = $str[1];
660 }
661 } else if ($str[0] == 'date') {
662 if (isset($str[1])) {
663 $all_date = explode('-', $str[1]);
664 if (!empty($all_date)) {
665 $arg = array();
666 if (isset($all_date[0])) { $arg['year'] = $all_date[0]; }
667 if (isset($all_date[1])) { $arg['month'] = $all_date[1]; }
668 if (isset($all_date[2])) { $arg['day'] = $all_date[2]; }
669 $archive_query['date_query'][] = $arg;
670 }
671 }
672 }
673 }
674 } else {
675 global $wp_query;
676 $archive_query = $wp_query->query_vars;
677 }
678 $archive_query['posts_per_page'] = isset($attr['queryNumber']) ? $attr['queryNumber'] : 3;
679 $archive_query['paged'] = isset($attr['paged']) ? $attr['paged'] : 1;
680 if (isset($attr['queryOffset']) && $attr['queryOffset'] ) {
681 $offset = $this->get_offset($attr['queryOffset'], $archive_query);
682 $archive_query = array_merge($archive_query, $offset);
683 }
684
685 // Include Remove from Version 2.5.4
686 if (isset($attr['queryInclude']) && $attr['queryInclude']) {
687 $_include = explode(',', $attr['queryInclude']);
688 if (is_array($_include) && count($_include)) {
689 $archive_query['post__in'] = isset($archive_query['post__in']) ? array_merge($archive_query['post__in'], $_include) : $_include;
690 $archive_query['ignore_sticky_posts'] = 1;
691 $archive_query['orderby'] = 'post__in';
692 }
693 }
694
695 if (isset($attr['queryExclude']) && $attr['queryExclude']) {
696 $_exclude = (substr($attr['queryExclude'], 0, 1) === "[") ? $this->get_value(json_decode($attr['queryExclude'])) : explode(',', $attr['queryExclude']);
697 if (is_array($_exclude) && count($_exclude)) {
698 $archive_query['post__not_in'] = isset($archive_query['post__not_in']) ? array_merge($archive_query['post__not_in'], $_exclude) : $_exclude;
699 }
700 }
701
702
703 if(isset($attr['querySticky']) && $attr['querySticky']) {
704 if (filter_var($attr['querySticky'], FILTER_VALIDATE_BOOLEAN)) {
705 $sticky = get_option( 'sticky_posts', [] );
706 $archive_query['post__not_in'] = isset($archive_query['post__not_in']) ? array_merge($archive_query['post__not_in'], $sticky) : $sticky;
707 }
708 }
709
710 $archive_query['post_status'] = 'publish';
711 if (is_user_logged_in()) {
712 if( current_user_can('editor') || current_user_can('administrator') ) {
713 $archive_query['post_status'] = array('publish', 'private');
714 }
715 }
716
717 if(!isset($archive_query['orderby'])) {
718 $archive_query['orderby'] = isset($attr['queryOrderBy']) ? $attr['queryOrderBy'] : 'date';
719 }
720
721 // Quick Query Support for Builder
722 if (isset($attr['queryQuick'])) {
723 if ($attr['queryQuick'] != '') {
724 $archive_query = ultimate_post()->get_quick_query($attr, $archive_query);
725 }
726 }
727
728 if (!isset($attr['ajaxCall'])) {
729 if(isset($attr['filterShow']) && $attr['filterShow']) {
730 if(isset($attr['filterType']) && isset($attr['filterValue'])) {
731 $filterValue = strlen($attr['filterValue']) > 2 ? $attr['filterValue'] : [];
732 $filterValue = is_array($filterValue) ? $filterValue : json_decode($filterValue);
733 if (count($filterValue) > 0 && $attr['filterType']) {
734 $final = array('relation' => 'OR');
735 foreach ($filterValue as $key => $val) {
736 $final[] = array(
737 'taxonomy' => $attr['filterType'],
738 'field' => 'slug',
739 'terms' => $val,
740 );
741 }
742 $archive_query['tax_query'] = $final;
743 }
744 }
745 }
746 }
747
748 return apply_filters('ultp_archive_query', $archive_query);
749 }
750
751 $query_args = array(
752 'posts_per_page' => isset($attr['queryNumber']) ? $attr['queryNumber'] : 3,
753 'post_type' => $post_type == 'archiveBuilder' ? 'post' : $post_type,
754 'orderby' => isset($attr['queryOrderBy']) ? $attr['queryOrderBy'] : 'date',
755 'order' => isset($attr['queryOrder']) ? $attr['queryOrder'] : 'desc',
756 'paged' => isset($attr['paged']) ? $attr['paged'] : 1,
757 'post_status' => 'publish'
758 );
759
760 // For Private Post 'private'
761 if (is_user_logged_in()) {
762 if( current_user_can('editor') || current_user_can('administrator') ) {
763 $query_args['post_status'] = array('publish', 'private');
764 }
765 }
766
767 if ($attr['queryType'] == 'posts') {
768 if (isset($attr['queryPosts']) && $attr['queryPosts']) {
769 unset($query_args['post_type']);
770 $data = json_decode(isset($attr['queryPosts'])?$attr['queryPosts']:'[]');
771 $final = $this->get_value($data);
772 if (count($final) > 0) {
773 $query_args['post__in'] = $final;
774 $query_args['posts_per_page'] = -1;
775 }
776 $query_args['ignore_sticky_posts'] = 1;
777 return $query_args;
778 }
779 } else if ($attr['queryType'] == 'customPosts') {
780 if (isset($attr['queryCustomPosts']) && $attr['queryCustomPosts']) {
781 $query_args['post_type'] = $this->get_post_type();
782 $data = json_decode(isset($attr['queryCustomPosts'])?$attr['queryCustomPosts']:'[]');
783 $final = $this->get_value($data);
784 if (count($final) > 0) {
785 $query_args['post__in'] = $final;
786 $query_args['posts_per_page'] = -1;
787 }
788 $query_args['ignore_sticky_posts'] = 1;
789 return $query_args;
790 }
791 }
792
793 if (isset($attr['queryExcludeAuthor']) && $attr['queryExcludeAuthor']) {
794 $data = json_decode(isset($attr['queryExcludeAuthor'])?$attr['queryExcludeAuthor']:'[]');
795 $final = $this->get_value($data);
796 if (count($final) > 0) {
797 $query_args['author__not_in'] = $final;
798 }
799 }
800
801
802 if (isset($attr['queryOrderBy']) && isset($attr['metaKey'])) {
803 if ($attr['queryOrderBy'] == 'meta_value_num') {
804 $query_args['meta_key'] = $attr['metaKey'];
805 }
806 }
807
808 // Include Remove from Version 2.5.4
809 if (isset($attr['queryInclude']) && $attr['queryInclude']) {
810 $_include = explode(',', $attr['queryInclude']);
811 if (is_array($_include) && count($_include)) {
812 $query_args['post__in'] = isset($query_args['post__in']) ? array_merge($query_args['post__in'], $_include) : $_include;
813 $query_args['ignore_sticky_posts'] = 1;
814 $query_args['orderby'] = 'post__in';
815 }
816 }
817
818
819 if (isset($attr['queryTax'])) {
820 if (isset($attr['queryTaxValue'])) {
821 $tax_value = (strlen($attr['queryTaxValue']) > 2) ? $attr['queryTaxValue'] : [];
822 $tax_value = is_array($tax_value) ? $tax_value : json_decode($tax_value);
823
824 $tax_value = (isset($tax_value[0]) && is_object($tax_value[0])) ? $this->get_value($tax_value) : $tax_value;
825
826 if (is_array($tax_value) && count($tax_value) > 0) {
827 $relation = isset($attr['queryRelation']) ? $attr['queryRelation'] : 'OR';
828 $var = array('relation'=>$relation);
829 foreach ($tax_value as $val) {
830 $tax_name = $attr['queryTax'];
831 // For Custom Terms
832 if ($attr['queryTax'] == 'multiTaxonomy') {
833 $temp = explode('###', $val);
834 if (isset($temp[1])) {
835 $val = $temp[1];
836 $tax_name = $temp[0];
837 }
838 }
839
840 $var[] = array('taxonomy'=> $tax_name, 'field' => 'slug', 'terms' => $val );
841 }
842 if (count($var) > 1) {
843 $query_args['tax_query'] = $var;
844 }
845 }
846 }
847 }
848
849
850 if (isset($attr['queryExcludeTerm']) && $attr['queryExcludeTerm']) {
851 $temp = json_decode($attr['queryExcludeTerm']);
852 $_term = [];
853 foreach ($temp as $val) {
854 $temp = explode('###', $val->value);
855 if (isset($temp[1])) {
856 if (array_key_exists($temp[0], $_term)) {
857 $_term[$temp[0]][] = $temp[1];
858 } else {
859 $_term[$temp[0]] = array($temp[1]);
860 }
861 }
862 }
863 if (count($_term) > 0) {
864 $final = array('relation' => 'AND');
865 foreach ($_term as $key => $val) {
866 $final[] = array(
867 'taxonomy' => $key,
868 'field' => 'slug',
869 'terms' => $val,
870 'operator' => 'NOT IN',
871 );
872 }
873
874 if (array_key_exists('tax_query', $query_args)) {
875 $query_args['tax_query'] = array(
876 'relation' => 'AND',
877 $query_args['tax_query']
878 );
879 $query_args['tax_query'][] = $final;
880 } else {
881 $query_args['tax_query'] = $final;
882 }
883 }
884 }
885
886 if (isset($attr['queryExclude']) && $attr['queryExclude']) {
887 $_exclude = (substr($attr['queryExclude'], 0, 1) === "[") ? $this->get_value(json_decode($attr['queryExclude'])) : explode(',', $attr['queryExclude']);
888 if (is_array($_exclude) && count($_exclude)) {
889 $query_args['post__not_in'] = isset($query_args['post__not_in']) ? array_merge($query_args['post__not_in'], $_exclude) : $_exclude;
890 }
891 }
892
893 if (isset($attr['queryUnique']) && $attr['queryUnique']) {
894 global $unique_ID;
895 if (isset($unique_ID[$attr['queryUnique']])) {
896 $query_args['post__not_in'] = isset($query_args['post__not_in']) ? array_merge($query_args['post__not_in'], $unique_ID[$attr['queryUnique']]) : $unique_ID[$attr['queryUnique']];
897 }
898 }
899
900 if (isset($attr['queryQuick'])) {
901 if ($attr['queryQuick'] != '' && $post_type != 'archiveBuilder') {
902 $query_args = ultimate_post()->get_quick_query($attr, $query_args);
903 }
904 }
905
906 if (isset($attr['queryOffset']) && $attr['queryOffset'] ) {
907 $offset = $this->get_offset($attr['queryOffset'], $query_args);
908 $query_args = array_merge($query_args, $offset);
909 }
910
911 if (isset($attr['queryAuthor']) && $attr['queryAuthor'] ) {
912 $_include = (substr($attr['queryAuthor'], 0, 1) === "[") ? $this->get_value(json_decode($attr['queryAuthor'])) : explode(',', $attr['queryAuthor']);
913 if (is_array($_include) && count($_include)) {
914 $query_args['author__in'] = $_include;
915 }
916 }
917
918 if(isset($attr['querySticky']) && $attr['querySticky']) {
919 if (filter_var($attr['querySticky'], FILTER_VALIDATE_BOOLEAN)) {
920 $sticky = get_option( 'sticky_posts', [] );
921 $query_args['post__not_in'] = isset($query_args['post__not_in']) ? array_merge($query_args['post__not_in'], $sticky) : $sticky;
922 }
923 }
924
925 if (!isset($attr['ajaxCall'])) {
926 if(isset($attr['filterShow']) && $attr['filterShow']) {
927 if(isset($attr['filterType']) && isset($attr['filterValue'])) {
928 $filterValue = strlen($attr['filterValue']) > 2 ? $attr['filterValue'] : [];
929 $filterValue = is_array($filterValue) ? $filterValue : json_decode($filterValue);
930 if (is_array($filterValue) && count($filterValue) > 0 && $attr['filterType']) {
931 $final = array('relation' => 'OR');
932 foreach ($filterValue as $key => $val) {
933 $final[] = array(
934 'taxonomy' => $attr['filterType'],
935 'field' => 'slug',
936 'terms' => $val,
937 // 'operator' => '=',
938 );
939 }
940 $query_args['tax_query'] = $final;
941 }
942 }
943 }
944 }
945
946 $query_args['wpnonce'] = wp_create_nonce( 'ultp-nonce' );
947
948 return apply_filters('ultp_frontend_query', $query_args);
949 }
950
951 /**
952 * Get Page Offset
953 *
954 * @since v.1.0.0
955 * @param | Offset Number(NUMBER) | Query Arg(ARRAY)
956 * @return ARRAY
957 */
958 function get_offset($queryOffset, $query_args) {
959 $query = array();
960 if ($query_args['paged'] > 1) {
961 $offset_post = wp_get_recent_posts($query_args, OBJECT);
962 if (count($offset_post) > 0 ) {
963 $offset = array();
964 for($x = count($offset_post); $x > count($offset_post) - $queryOffset; $x--) {
965 $offset[] = $offset_post[$x-1]->ID;
966 }
967 $query['post__not_in'] = $offset;
968 }
969 } else {
970 $query['offset'] = isset($queryOffset) ? $queryOffset : 0;
971 }
972 return $query;
973 }
974
975
976 /**
977 * Get Page Number
978 *
979 * @since v.1.0.0
980 * @param | Attribute of the Query(ARRAY) | Post Number(ARRAY)
981 * @return ARRAY
982 */
983 public function get_page_number($attr, $post_number) {
984 if ($post_number > 0) {
985 if (isset($attr['queryOffset']) && $attr['queryOffset']) {
986 $post_number = $post_number - (int)$attr['queryOffset'];
987 }
988 $post_per_page = isset($attr['queryNumber']) ? ($attr['queryNumber'] ? $attr['queryNumber'] : 1) : 3;
989 $pages = ceil($post_number/$post_per_page);
990 return $pages ? $pages : 1;
991 }else{
992 return 1;
993 }
994 }
995
996
997 /**
998 * Get Image Size
999 *
1000 * @since v.1.0.0
1001 * @param | Attribute of the Query(ARRAY) | Post Number(ARRAY)
1002 * @return ARRAY
1003 */
1004 public function get_image_size() {
1005 $sizes = get_intermediate_image_sizes();
1006 $filter = array('full' => 'Full');
1007 foreach ($sizes as $value) {
1008 $title = ucwords(str_replace(array('_', '-'), array(' ', ' '), $value));
1009 switch ($value) {
1010 case 'thumbnail':
1011 $title = $title.' [150x150]';
1012 break;
1013 case 'medium':
1014 $title = $title.' [300x300]';
1015 break;
1016 case 'large':
1017 $title = $title.' [1024x1024]';
1018 break;
1019 case 'ultp_layout_landscape_large':
1020 $title = $title.' [1200x800]';
1021 break;
1022 case 'ultp_layout_landscape':
1023 $title = $title.' [870x570]';
1024 break;
1025 case 'ultp_layout_portrait':
1026 $title = $title.' [600x900]';
1027 break;
1028 case 'ultp_layout_square':
1029 $title = $title.' [600x600]';
1030 break;
1031 default:
1032 break;
1033 }
1034 $filter[$value] = $title;
1035 }
1036 return $filter;
1037 }
1038
1039
1040 /**
1041 * Get All PostType Registered
1042 *
1043 * @since v.1.0.0
1044 * @param | Attribute of the Query(ARRAY) | Post Number(ARRAY)
1045 * @return ARRAY
1046 */
1047 public function get_post_type() {
1048 $filter = apply_filters('ultp_public_post_type', true);
1049 $post_type = get_post_types( ($filter ? ['public' => true] : ''), 'names' );
1050 return array_diff($post_type, array( 'attachment' ));
1051 }
1052
1053
1054 /**
1055 * Get Pagination HTML
1056 *
1057 * @since v.1.0.0
1058 * @param | pages (NUMBER) | Pagination Nav (STRING) | Pagination Text |
1059 * @return STRING
1060 */
1061 public function pagination($pages = '', $paginationNav = '', $paginationText = '') {
1062 $html = '';
1063 $showitems = 3;
1064 $paged = is_front_page() ? get_query_var('page') : get_query_var('paged');
1065 $paged = $paged ? $paged : 1;
1066 if ($pages == '') {
1067 global $wp_query;
1068 $pages = $wp_query->max_num_pages;
1069 if (!$pages) {
1070 $pages = 1;
1071 }
1072 }
1073 $data = ($paged>=3?[($paged-1),$paged,$paged+1]:[1,2,3]);
1074
1075 $paginationText = explode('|', $paginationText);
1076
1077 $prev_text = isset($paginationText[0]) ? $paginationText[0] : __("Previous", "ultimate-post");
1078 $next_text = isset($paginationText[1]) ? $paginationText[1] : __("Next", "ultimate-post");
1079
1080 if (1 != $pages) {
1081 $html .= '<ul class="ultp-pagination">';
1082 $display_none = 'style="display:none"';
1083 if ($pages > 4) {
1084 $html .= '<li class="ultp-prev-page-numbers" '.($paged==1?$display_none:"").'><a href="'.get_pagenum_link($paged-1).'">'.ultimate_post()->svg_icon('leftAngle2').' '.($paginationNav == 'textArrow' ? $prev_text : "").'</a></li>';
1085 }
1086 if ($pages > 4) {
1087 $html .= '<li class="ultp-first-pages" '.($paged<2?$display_none:"").' data-current="1"><a href="'.get_pagenum_link(1).'">1</a></li>';
1088 }
1089 if ($pages > 4) {
1090 $html .= '<li class="ultp-first-dot" '.($paged<2? $display_none : "").'><a href="#">...</a></li>';
1091 }
1092 foreach ($data as $i) {
1093 if ($pages >= $i) {
1094 $html .= ($paged == $i) ? '<li class="ultp-center-item pagination-active" data-current="'.$i.'"><a href="'.get_pagenum_link($i).'">'.$i.'</a></li>':'<li class="ultp-center-item" data-current="'.$i.'"><a href="'.get_pagenum_link($i).'">'.$i.'</a></li>';
1095 }
1096 }
1097 if ($pages > 4) {
1098 $html .= '<li class="ultp-last-dot" '.($pages<=$paged+1?$display_none:"").'><a href="#">...</a></li>';
1099 }
1100 if ($pages > 4) {
1101 $html .= '<li class="ultp-last-pages" '.($pages<=$paged+1?$display_none:"").' data-current="'.$pages.'"><a href="'.get_pagenum_link($pages).'">'.$pages.'</a></li>';
1102 }
1103 if ($paged != $pages) {
1104 $html .= '<li class="ultp-next-page-numbers"><a href="'.get_pagenum_link($paged + 1).'">'.($paginationNav == 'textArrow' ? $next_text : "").ultimate_post()->svg_icon('rightAngle2').'</a></li>';
1105 }
1106 $html .= '</ul>';
1107 }
1108 return $html;
1109 }
1110
1111 /**
1112 * Svg Icon Source
1113 *
1114 * @since v.1.0.0
1115 * @param STRING | String Name
1116 * @return STRING
1117 */
1118 public function svg_icon($ultp_icons = '') {
1119 $ultp_icon_lists = array(
1120 'eye' => file_get_contents(ULTP_PATH.'assets/img/setting/eye.svg'),
1121 'user' => file_get_contents(ULTP_PATH.'assets/img/setting/user.svg'),
1122 'calendar' => file_get_contents(ULTP_PATH.'assets/img/setting/calendar.svg'),
1123 'comment' => file_get_contents(ULTP_PATH.'assets/img/setting/comment.svg'),
1124 'book' => file_get_contents(ULTP_PATH.'assets/img/setting/book.svg'),
1125 'tag' => file_get_contents(ULTP_PATH.'assets/img/setting/tag.svg'),
1126 'clock' => file_get_contents(ULTP_PATH.'assets/img/setting/clock.svg'),
1127 'leftAngle' => file_get_contents(ULTP_PATH.'assets/img/setting/leftAngle.svg'),
1128 'rightAngle' => file_get_contents(ULTP_PATH.'assets/img/setting/rightAngle.svg'),
1129 'leftAngle2' => file_get_contents(ULTP_PATH.'assets/img/setting/leftAngle2.svg'),
1130 'rightAngle2' => file_get_contents(ULTP_PATH.'assets/img/setting/rightAngle2.svg'),
1131 'leftArrowLg' => file_get_contents(ULTP_PATH.'assets/img/setting/leftArrowLg.svg'),
1132 'rightArrowLg' => file_get_contents(ULTP_PATH.'assets/img/setting/rightArrowLg.svg'),
1133 'refresh' => file_get_contents(ULTP_PATH.'assets/img/setting/refresh.svg'),
1134 'upArrow' => file_get_contents(ULTP_PATH.'assets/img/setting/upArrow.svg'),
1135 'downArrow' => file_get_contents(ULTP_PATH.'assets/img/setting/downArrow.svg'),
1136 'arrowUp2' => file_get_contents(ULTP_PATH.'assets/img/setting/arrowUp2.svg'),
1137 'longArrowUp2' => file_get_contents(ULTP_PATH.'assets/img/setting/longArrowUp2.svg'),
1138 'caretArrow' => file_get_contents(ULTP_PATH.'assets/img/setting/caretArrow.svg'),
1139 'left' => file_get_contents(ULTP_PATH.'assets/img/setting/left.svg'),
1140 'center' => file_get_contents(ULTP_PATH.'assets/img/setting/center.svg'),
1141 'right' => file_get_contents(ULTP_PATH.'assets/img/setting/right.svg'),
1142 'justify' => file_get_contents(ULTP_PATH.'assets/img/setting/justify.svg'),
1143 'desktop' => file_get_contents(ULTP_PATH.'assets/img/setting/desktop.svg'),
1144 'laptop' => file_get_contents(ULTP_PATH.'assets/img/setting/laptop.svg'),
1145 'tablet' => file_get_contents(ULTP_PATH.'assets/img/setting/tablet.svg'),
1146 'mobile' => file_get_contents(ULTP_PATH.'assets/img/setting/mobile.svg'),
1147 'dimension' => file_get_contents(ULTP_PATH.'assets/img/setting/dimension.svg'),
1148 'setting' => file_get_contents(ULTP_PATH.'assets/img/setting/setting.svg'),
1149 'plus' => file_get_contents(ULTP_PATH.'assets/img/setting/plus.svg'),
1150 // Builder
1151 'commentCount1' => file_get_contents(ULTP_PATH.'assets/img/blocks/builder/comments_meta/commentCount1.svg'),
1152 'commentCount2' => file_get_contents(ULTP_PATH.'assets/img/blocks/builder/comments_meta/commentCount2.svg'),
1153 'commentCount3' => file_get_contents(ULTP_PATH.'assets/img/blocks/builder/comments_meta/commentCount3.svg'),
1154 'commentCount4' => file_get_contents(ULTP_PATH.'assets/img/blocks/builder/comments_meta/commentCount4.svg'),
1155 'commentCount5' => file_get_contents(ULTP_PATH.'assets/img/blocks/builder/comments_meta/commentCount5.svg'),
1156 'commentCount6' => file_get_contents(ULTP_PATH.'assets/img/blocks/builder/comments_meta/commentCount6.svg'),
1157 'date1' => file_get_contents(ULTP_PATH.'assets/img/blocks/builder/date_meta/date1.svg'),
1158 'date2' => file_get_contents(ULTP_PATH.'assets/img/blocks/builder/date_meta/date2.svg'),
1159 'date3' => file_get_contents(ULTP_PATH.'assets/img/blocks/builder/date_meta/date3.svg'),
1160 'date4' => file_get_contents(ULTP_PATH.'assets/img/blocks/builder/date_meta/date4.svg'),
1161 'date5' => file_get_contents(ULTP_PATH.'assets/img/blocks/builder/date_meta/date5.svg'),
1162 'author1' => file_get_contents(ULTP_PATH.'assets/img/blocks/builder/author_meta/author1.svg'),
1163 'author2' => file_get_contents(ULTP_PATH.'assets/img/blocks/builder/author_meta/author2.svg'),
1164 'author3' => file_get_contents(ULTP_PATH.'assets/img/blocks/builder/author_meta/author3.svg'),
1165 'author4' => file_get_contents(ULTP_PATH.'assets/img/blocks/builder/author_meta/author4.svg'),
1166 'author5' => file_get_contents(ULTP_PATH.'assets/img/blocks/builder/author_meta/author5.svg'),
1167 'readingTime1' => file_get_contents(ULTP_PATH.
1168 '/assets/img/blocks/builder/reading_time/readingTime1.svg'),
1169 'readingTime2' => file_get_contents(ULTP_PATH.'assets/img/blocks/builder/reading_time/readingTime2.svg'),
1170 'readingTime3' => file_get_contents(ULTP_PATH.'assets/img/blocks/builder/reading_time/readingTime3.svg'),
1171 'readingTime4' => file_get_contents(ULTP_PATH.'assets/img/blocks/builder/reading_time/readingTime4.svg'),
1172 'readingTime5' => file_get_contents(ULTP_PATH.'assets/img/blocks/builder/reading_time/readingTime5.svg'),
1173 'viewCount1' => file_get_contents(ULTP_PATH.'assets/img/blocks/builder/viewCount/viewCount1.svg'),
1174 'viewCount2' => file_get_contents(ULTP_PATH.'assets/img/blocks/builder/viewCount/viewCount2.svg'),
1175 'viewCount3' => file_get_contents(ULTP_PATH.'assets/img/blocks/builder/viewCount/viewCount3.svg'),
1176 'viewCount4' => file_get_contents(ULTP_PATH.'assets/img/blocks/builder/viewCount/viewCount4.svg'),
1177 'viewCount5' => file_get_contents(ULTP_PATH.'assets/img/blocks/builder/viewCount/viewCount5.svg'),
1178 'viewCount6' => file_get_contents(ULTP_PATH.'assets/img/blocks/builder/viewCount/viewCount6.svg'),
1179 'cat1' => file_get_contents(ULTP_PATH.'assets/img/blocks/builder/category/cat1.svg'),
1180 'cat2' => file_get_contents(ULTP_PATH.'assets/img/blocks/builder/category/cat2.svg'),
1181 'cat3' => file_get_contents(ULTP_PATH.'assets/img/blocks/builder/category/cat3.svg'),
1182 'cat4' => file_get_contents(ULTP_PATH.'assets/img/blocks/builder/category/cat4.svg'),
1183 'cat5' => file_get_contents(ULTP_PATH.'assets/img/blocks/builder/category/cat5.svg'),
1184 'cat6' => file_get_contents(ULTP_PATH.'assets/img/blocks/builder/category/cat6.svg'),
1185 'cat7' => file_get_contents(ULTP_PATH.'assets/img/blocks/builder/category/cat7.svg'),
1186 'tag1' => file_get_contents(ULTP_PATH.'assets/img/blocks/builder/tag/tag1.svg'),
1187 'tag2' => file_get_contents(ULTP_PATH.'assets/img/blocks/builder/tag/tag2.svg'),
1188 'tag3' => file_get_contents(ULTP_PATH.'assets/img/blocks/builder/tag/tag3.svg'),
1189 'tag4' => file_get_contents(ULTP_PATH.'assets/img/blocks/builder/tag/tag4.svg'),
1190 'tag5' => file_get_contents(ULTP_PATH.'assets/img/blocks/builder/tag/tag5.svg'),
1191 'tag6' => file_get_contents(ULTP_PATH.'assets/img/blocks/builder/tag/tag6.svg'),
1192 'rightArrowLg' => file_get_contents(ULTP_PATH.'assets/img/svg/rightArrowLg.svg'),
1193 'share' => file_get_contents(ULTP_PATH.'assets/img/svg/share.svg'),
1194 'facebook' => file_get_contents(ULTP_PATH.'assets/img/svg/facebookIcon.svg'),
1195 'linkedin' => file_get_contents(ULTP_PATH.'assets/img/svg/linkedinIcon.svg'),
1196 'mail' => file_get_contents(ULTP_PATH.'assets/img/svg/mailIcon.svg'),
1197 'messenger' => file_get_contents(ULTP_PATH.'assets/img/svg/messengerIcon.svg'),
1198 'reddit' => file_get_contents(ULTP_PATH.'assets/img/svg/redditIcon.svg'),
1199 'twitter' => file_get_contents(ULTP_PATH.'assets/img/svg/twitterIcon.svg'),
1200 'whatsapp' => file_get_contents(ULTP_PATH.'assets/img/svg/whatsappIcon.svg'),
1201 'pinterest' => file_get_contents(ULTP_PATH.'assets/img/svg/pinIcon.svg'),
1202 'skype' => file_get_contents(ULTP_PATH.'assets/img/svg/skype.svg'),
1203 );
1204 if ($ultp_icons) {
1205 return $ultp_icon_lists[ $ultp_icons ];
1206 }
1207 }
1208
1209
1210 /**
1211 * Get Excerpt Word
1212 *
1213 * @since v.1.0.0
1214 * @param NUMBER | Character Length
1215 * @return STRING
1216 */
1217 public function excerpt_word($charlength = 200) {
1218 $html = '';
1219 $charlength++;
1220 $excerpt = get_the_excerpt();
1221 if (mb_strlen( $excerpt ) > $charlength ) {
1222 $subex = mb_substr( $excerpt, 0, $charlength );
1223 $exwords = explode( ' ', $subex );
1224 $excut = - ( mb_strlen( $exwords[ count( $exwords ) - 1 ] ) );
1225 if ($excut < 0 ) {
1226 $html = mb_substr( $subex, 0, $excut );
1227 } else {
1228 $html = $subex;
1229 }
1230 $html .= '...';
1231 } else {
1232 $html = $excerpt;
1233 }
1234 return $html;
1235 }
1236
1237
1238 /**
1239 * Get Taxonomy Lists
1240 *
1241 * @since v.1.0.0
1242 * @param STRING | Taxonomy Slug
1243 * @return ARRAY
1244 */
1245 public function taxonomy( $prams = 'category' ) {
1246 $data = array();
1247 $terms = get_terms( $prams, array(
1248 'hide_empty' => false,
1249 ));
1250 if (!is_wp_error($terms)) {
1251 foreach ($terms as $val) {
1252 $data[urldecode_deep($val->slug)] = $val->name;
1253 }
1254 }
1255 return $data;
1256 }
1257
1258
1259 /**
1260 * Get Taxonomy Data Lists
1261 *
1262 * @since v.1.0.0
1263 * @param OBJECT | Taxonomy Object
1264 * @return ARRAY
1265 */
1266 public function get_tax_data($terms) {
1267 $temp = array();
1268 $image = '';
1269 $thumbnail_id = get_term_meta( $terms->term_id, 'ultp_category_image', true );
1270 if ($thumbnail_id) {
1271 $image = wp_get_attachment_url( $thumbnail_id );
1272 }
1273 $temp['url'] = get_term_link($terms);
1274 $temp['name'] = $terms->name;
1275 $temp['desc'] = $terms->description;
1276 $temp['count'] = $terms->count;
1277 $temp['image'] = $image;
1278 $color = get_term_meta($terms->term_id, 'ultp_category_color', true);
1279 $temp['color'] = $color ? $color : '#037fff';
1280 return $temp;
1281 }
1282
1283 public function get_category_data($catSlug, $number = 40, $type = '', $tax_slug = 'category') {
1284 $data = array();
1285 if ($type == 'child') {
1286 $image = '';
1287 if (!empty($catSlug)) {
1288 foreach ($catSlug as $cat) {
1289 $parent_term = get_term_by('slug', $cat, $tax_slug);
1290 if (!empty($parent_term)) {
1291 $term_data = get_terms($tax_slug, array(
1292 'hide_empty' => true,
1293 'parent' => $parent_term->term_id
1294 ));
1295 if (!empty($term_data)) {
1296 foreach ($term_data as $terms) {
1297 $data[] = $this->get_tax_data($terms);
1298 }
1299 }
1300 }
1301 }
1302 }
1303 } else if ($type == 'parent') {
1304 $term_data = get_terms( $tax_slug, array( 'hide_empty' => true, 'number' => $number, 'parent' => 0 ) );
1305 if (!empty($term_data)) {
1306 foreach ($term_data as $terms) {
1307 $data[] = $this->get_tax_data($terms);
1308 }
1309 }
1310 } else if ($type == 'custom') {
1311 foreach ($catSlug as $cat) {
1312 $terms = get_term_by('slug', $cat, $tax_slug);
1313 if (!empty($terms)) {
1314 $data[] = $this->get_tax_data($terms);
1315 }
1316 }
1317 } else {
1318 $term_data = get_terms($tax_slug, array('hide_empty' => true, 'number' => $number));
1319 if (!empty($term_data)) {
1320 foreach ($term_data as $terms) {
1321 $data[] = $this->get_tax_data($terms);
1322 }
1323 }
1324 }
1325 return $data;
1326 }
1327
1328
1329 /**
1330 * Get Next Previous HTML
1331 *
1332 * @since v.1.0.0
1333 * @param OBJECT | Taxonomy Object
1334 * @return STRING
1335 */
1336 public function next_prev() {
1337 $html = '';
1338 $html .= '<ul>';
1339 $html .= '<li>';
1340 $html .= '<a class="ultp-prev-action ultp-disable" href="#">';
1341 $html .= ultimate_post()->svg_icon('leftAngle2').'<span class="screen-reader-text">'.esc_html__("Previous", "ultimate-post").'</span>';
1342 $html .= '</a>';
1343 $html .= '</li>';
1344 $html .= '<li>';
1345 $html .= '<a class="ultp-next-action">';
1346 $html .= ultimate_post()->svg_icon('rightAngle2').'<span class="screen-reader-text">'.esc_html__("Next", "ultimate-post").'</span>';
1347 $html .= '</a>';
1348 $html .= '</li>';
1349 $html .= '</ul>';
1350 return $html;
1351 }
1352
1353
1354 /**
1355 * Get Loading HTML
1356 *
1357 * @since v.1.0.0
1358 * @param NULL
1359 * @return STRING
1360 */
1361 public function loading() {
1362 $html = '';
1363 $style = ultimate_post()->get_setting('preloader_style');
1364 if ($style == 'style2') {
1365 $html .= '<div class="ultp-loading-spinner" style="width:100%;height:100%"><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div></div>';//ultp-block-items-wrap
1366 } else {
1367 $html .= '<div class="ultp-loading-blocks" style="width:100%;height:100%;"><div style="left: 0;top: 0;animation-delay:0s;"></div><div style="left: 21px;top: 0;animation-delay:0.125s;"></div><div style="left: 42px;top: 0;animation-delay:0.25s;"></div><div style="left: 0;top: 21px;animation-delay:0.875s;"></div><div style="left: 42px;top: 21px;animation-delay:0.375s;"></div><div style="left: 0;top: 42px;animation-delay:0.75s;"></div><div style="left: 42px;top: 42px;animation-delay:0.625s;"></div><div style="left: 21px;top: 42px;animation-delay:0.5s;"></div></div>';
1368 }
1369 return '<div class="ultp-loading">'.$html.'</div>';
1370 }
1371
1372
1373 /**
1374 * Get Filter HTML
1375 *
1376 * @since v.1.0.0
1377 * @param | Filter Text (STRING) | Filter Type (STRING) | Filter Value (ARRAY) | Filter Cat (ARRAY) | Filter Tag (ARRAY) |
1378 * @return STRING
1379 */
1380 public function filter($filterText = '', $filterType = '', $filterValue = '[]', $filterMobileText = '...', $filterMobile = true) {
1381 $html = '';
1382 $html .= '<ul '.($filterMobile ? 'class="ultp-flex-menu"' : '').' data-name="'.($filterMobileText ? $filterMobileText : '&nbsp;').'">';
1383 $cat = $this->taxonomy($filterType);
1384 if ($filterText) {
1385 $html .= '<li class="filter-item"><a class="filter-active" data-taxonomy="" href="#">'.$filterText.'</a></li>';
1386 }
1387
1388 if ($filterValue) {
1389 $filterValue = strlen($filterValue) > 2 ? $filterValue : [];
1390 $filterValue = is_array($filterValue) ? $filterValue : json_decode($filterValue);
1391 if (is_array($filterValue) && count($filterValue)) {
1392 foreach ($filterValue as $val) {
1393 $html .= '<li class="filter-item"><a data-taxonomy="'.$val.'" href="#">'.(isset($cat[$val]) ? $cat[$val] : $val).'</a></li>';
1394 }
1395 }
1396 }
1397 $html .= '</ul>';
1398 return $html;
1399 }
1400
1401
1402 /**
1403 * Check License Status
1404 *
1405 * @since v.2.4.2
1406 * @return BOOLEAN | Is pro license active or not
1407 */
1408 public function is_lc_active() {
1409 if (function_exists('ultimate_post_pro')) {
1410 return get_option('edd_ultp_license_status') == 'valid' ? true : false;
1411 }
1412 if (get_transient( 'ulpt_theme_enable' ) == 'integration') {
1413 return true;
1414 }
1415 return false;
1416 }
1417
1418
1419 /**
1420 * Get SEO Meta
1421 *
1422 * @since v.2.4.3
1423 * @param NUMBER | Post ID
1424 * @return STRING | SEO Meta Description or Excerpt
1425 */
1426 public function get_excerpt($post_id = 0, $showSeoMeta = 0, $showFullExcerpt = 0, $excerptLimit = 55) {
1427 $html = '';
1428 if ($showSeoMeta) {
1429 $str = '';
1430 if (function_exists('ultimate_post_pro') ) {
1431 if (ultimate_post()->get_setting('ultp_yoast') == 'true') {
1432 $str = method_exists( ultimate_post_pro(), 'get_yoast_meta' ) ? ultimate_post_pro()->get_yoast_meta($post_id) : '';
1433 } else if (ultimate_post()->get_setting('ultp_rankmath') == 'true') {
1434 $str = method_exists( ultimate_post_pro(), 'get_rankmath_meta' ) ? ultimate_post_pro()->get_rankmath_meta($post_id) : '';
1435 } else if (ultimate_post()->get_setting('ultp_aioseo') == 'true') {
1436 $str = method_exists( ultimate_post_pro(), 'get_aioseo_meta' ) ? ultimate_post_pro()->get_aioseo_meta($post_id) : '';
1437 } else if (ultimate_post()->get_setting('ultp_seopress') == 'true') {
1438 $str = method_exists( ultimate_post_pro(), 'get_seopress_meta' ) ? ultimate_post_pro()->get_seopress_meta($post_id) : '';
1439 } else if (ultimate_post()->get_setting('ultp_squirrly') == 'true') {
1440 $str = method_exists( ultimate_post_pro(), 'get_squirrly_meta' ) ? ultimate_post_pro()->get_squirrly_meta($post_id) : '';
1441 }
1442 }
1443 $html = $str ? $str : ultimate_post()->excerpt($post_id, $excerptLimit);
1444 } else {
1445 if ($showFullExcerpt == 0 ) {
1446 $html = ultimate_post()->excerpt($post_id, $excerptLimit);
1447 } else {
1448 $html = get_the_excerpt();
1449 }
1450 }
1451 return $html;
1452 }
1453
1454 /**
1455 * Set Inline CSS
1456 *
1457 * @since v.2.5.8
1458 * @param STRING | CSS
1459 * @return STRING | CSS with Style
1460 */
1461 public function set_inline($css) {
1462 return '<style type="text/css">'.wp_strip_all_tags($css).'</style>';
1463 }
1464
1465 /**
1466 * Array Sanitize Function
1467 *
1468 * @since v.2.6.0
1469 * @param ARRAY
1470 * @return ARRAY | Array of Sanitize
1471 */
1472 public function recursive_sanitize_text_field($array) {
1473 foreach ($array as $key => &$value) {
1474 if (is_array($value)) {
1475 $value = $this->recursive_sanitize_text_field($value);
1476 } else {
1477 $value = sanitize_text_field($value);
1478 }
1479 }
1480 return $array;
1481 }
1482
1483
1484 public function get_embeded_video($url, $autoPlay, $loop, $mute, $playback, $preload, $poster, $inline, $size) {
1485 $vidAutoPlay = $vidloop = $vidloop = $vidmute = $vidplayback = $vidPoster = $vidInline = "";
1486
1487 if($autoPlay){
1488 $vidAutoPlay = "autoplay";
1489 }
1490 if($poster){
1491 $vidPoster = 'poster="'.$poster["url"].'"';
1492 }
1493 if($loop){
1494 $vidloop = "loop";
1495 }
1496 if($mute){
1497 $vidmute = "muted";
1498 }
1499 if($playback){
1500 $vidplayback = "controls";
1501 }
1502 if($inline){
1503 $vidInline = "playsinline";
1504 }
1505 if (!empty($url)) {
1506 $embeded = wp_oembed_get($url, $size);
1507 if ($embeded == false) {
1508 $format = '';
1509 $url = strtolower($url);
1510 if (strpos($url, '.mp4')) {
1511 $format = 'mp4';
1512 } elseif (strpos($url, '.ogg')) {
1513 $format = 'ogg';
1514 } elseif (strpos($url, '.webm')) {
1515 $format = 'WebM';
1516 }
1517 $embeded = '<video
1518 '.$vidloop.'
1519 '.$vidmute.'
1520 '.$vidplayback.'
1521 preload="'.$preload.'"
1522 '.$vidAutoPlay.'
1523 '.$vidPoster.'
1524 '.$vidInline.'
1525 ><source src="' . $url . '" type="video/' . $format . '">' . __('Your browser does not support the video tag.', 'ultimate-post') . '</video>';
1526 return '<div class="ultp-video-wrapper">'.$embeded.'</div>';
1527 }
1528 return '<div class="ultp-video-wrapper ultp-embaded-video">'.$embeded.'</div>';
1529 } else {
1530 return false;
1531 }
1532 }
1533
1534 /**
1535 * Get Public taxonomy Lists
1536 *
1537 * @since v.2.7.0
1538 * @param NULL
1539 * @return ARRAY | Taxonomy Lists as array
1540 */
1541 public function get_taxonomy_list() {
1542 $taxonomy = get_taxonomies(array('public' => true));
1543 return empty($taxonomy) ? [] : array_keys($taxonomy);
1544 }
1545
1546 /**
1547 * Content Print
1548 *
1549 * @since v.2.7.0
1550 * @param NUMBER | Post ID
1551 * @return STRING | Content of the Post
1552 */
1553 public function content($post_id) {
1554 $content_post = get_post($post_id);
1555 $content = $content_post->post_content;
1556 $content = apply_filters('the_content', $content);
1557 $content = str_replace(']]>', ']]&gt;', $content);
1558 echo $content;
1559 }
1560
1561
1562 /**
1563 * String Part finder inside array
1564 *
1565 * @since v.2.7.0
1566 * @return ARRAY | String Part
1567 */
1568 public function in_string_part($part, $data, $isValue = false) {
1569 $return = false;
1570 foreach ($data as $val) {
1571 if (strpos($val, $part) !== false) {
1572 $return = $isValue ? $val : true;
1573 break;
1574 }
1575 }
1576 return $return;
1577 }
1578
1579 /**
1580 * All Addons Data
1581 *
1582 * @since v.2.7.0
1583 * @return ARRAY | String Part
1584 */
1585 public static function all_addons() {
1586 $all_addons = array(
1587 'ultp_category' => array(
1588 'name' => __( 'Category', 'ultimate-post' ),
1589 'desc' => __( 'Choose your desired color and Image for categories or any taxonomy.', 'ultimate-post' ),
1590 'img' => ULTP_URL.'/assets/img/addons/category-style.svg',
1591 'is_pro' => true,
1592 'docs' => 'https://docs.wpxpo.com/docs/postx/',
1593 'live' => 'https://www.wpxpo.com/postx/addons/category/',
1594 'position' => 15
1595 ),
1596 'ultp_progressbar' => array(
1597 'name' => __( 'Progressbar', 'ultimate-post' ),
1598 'desc' => __( 'Let the users see a graphical indicator to know the reading progress of a blog post.', 'ultimate-post' ),
1599 'img' => ULTP_URL.'/assets/img/addons/progressbar.svg',
1600 'is_pro' => true,
1601 'docs' => 'https://docs.wpxpo.com/docs/postx/add-on/progress-bar/',
1602 'live' => 'https://www.wpxpo.com/postx/progress-bar/',
1603 'position' => 30
1604 ),
1605 'ultp_yoast' => array(
1606 'name' => __( 'Yoast Meta', 'ultimate-post' ),
1607 'desc' => __( 'Show Yoast meta description in the excerpt.', 'ultimate-post' ),
1608 'img' => ULTP_URL.'/assets/img/addons/yoast.svg',
1609 'is_pro' => true,
1610 'docs' => 'https://docs.wpxpo.com/docs/postx/add-on/seo-meta/',
1611 'live' => 'https://www.wpxpo.com/postx/addons/yoast/',
1612 'required' => array(
1613 'name' => 'Yoast',
1614 'slug' => 'wordpress-seo/wp-seo.php'
1615 ),
1616 'position' => 55
1617 ),
1618 'ultp_aioseo' => array(
1619 'name' => __( 'All in One SEO Meta', 'ultimate-post' ),
1620 'desc' => __( 'Show All in One SEO meta description in the excerpt.', 'ultimate-post' ),
1621 'img' => ULTP_URL.'/assets/img/addons/aioseo.svg',
1622 'is_pro' => true,
1623 'docs' => 'https://docs.wpxpo.com/docs/postx/add-on/seo-meta/',
1624 'live' => 'https://www.wpxpo.com/postx/addons/all-in-one-seo-meta/',
1625 'required' => array(
1626 'name' => 'All in One SEO',
1627 'slug' => 'all-in-one-seo-pack/all_in_one_seo_pack.php'
1628 ),
1629 'position' => 35
1630 ),
1631 'ultp_rankmath' => array(
1632 'name' => __( 'RankMath Meta', 'ultimate-post' ),
1633 'desc' => __( 'Show RankMath meta description in the excerpt.', 'ultimate-post' ),
1634 'img' => ULTP_URL.'/assets/img/addons/rankmath.svg',
1635 'is_pro' => true,
1636 'docs' => 'https://docs.wpxpo.com/docs/postx/add-on/seo-meta/',
1637 'live' => 'https://www.wpxpo.com/postx/addons/rankmath/',
1638 'required' => array(
1639 'name' => 'RankMath',
1640 'slug' => 'seo-by-rank-math/rank-math.php'
1641 ),
1642 'position' => 40
1643 ),
1644 'ultp_seopress' => array(
1645 'name' => __( 'SEOPress Meta', 'ultimate-post' ),
1646 'desc' => __( 'Show SEOPress meta description in the excerpt.', 'ultimate-post' ),
1647 'img' => ULTP_URL.'/assets/img/addons/seopress.svg',
1648 'is_pro' => true,
1649 'docs' => 'https://docs.wpxpo.com/docs/postx/add-on/seo-meta/',
1650 'live' => 'https://www.wpxpo.com/postx/addons/seopress/',
1651 'required' => array(
1652 'name' => 'SEOPress',
1653 'slug' => 'wp-seopress/seopress.php'
1654 ),
1655 'position' => 45
1656 ),
1657 'ultp_squirrly' => array(
1658 'name' => __( 'Squirrly Meta', 'ultimate-post' ),
1659 'desc' => __( 'Show Squirrly meta description in the excerpt.', 'ultimate-post' ),
1660 'img' => ULTP_URL.'/assets/img/addons/squirrly.svg',
1661 'is_pro' => true,
1662 'docs' => 'https://docs.wpxpo.com/docs/postx/add-on/seo-meta/',
1663 'live' => 'https://www.wpxpo.com/postx/addons/squirrly/',
1664 'required' => array(
1665 'name' => 'Squirrly',
1666 'slug' => 'squirrly-seo/squirrly.php'
1667 ),
1668 'position' => 50
1669 ),
1670 );
1671 return apply_filters('ultp_addons_config', $all_addons);
1672 }
1673
1674 /**
1675 * All Block Data
1676 *
1677 * @since v.2.7.0
1678 * @return ARRAY | String Part
1679 */
1680 public function get_blocks_settings() {
1681 $arr = array(
1682 'grid' => array(
1683 'label' => __('Post Grid Blocks', 'ultimate-post'),
1684 'attr' => array(
1685 'post_grid_1' => array(
1686 'label' => __('Post Grid #1', 'ultimate-post'),
1687 'default' => true,
1688 'live' => 'https://www.wpxpo.com/postx/blocks/#demoid6829',
1689 'docs' => 'https://docs.wpxpo.com/docs/postx/',
1690 'icon' => ULTP_URL.'assets/img/blocks/post-grid-1.svg'
1691 ),
1692 'post_grid_2' => array(
1693 'label' => __('Post Grid #2', 'ultimate-post'),
1694 'default' => true,
1695 'live' => 'https://www.wpxpo.com/postx/blocks/#demoid6830',
1696 'docs' => 'https://docs.wpxpo.com/docs/postx/',
1697 'icon' => ULTP_URL.'assets/img/blocks/post-grid-2.svg'
1698 ),
1699 'post_grid_3' => array(
1700 'label' => __('Post Grid #3', 'ultimate-post'),
1701 'default' => true,
1702 'live' => 'https://www.wpxpo.com/postx/blocks/#demoid6831',
1703 'docs' => 'https://docs.wpxpo.com/docs/postx/',
1704 'icon' => ULTP_URL.'assets/img/blocks/post-grid-3.svg'
1705 ),
1706 'post_grid_4' => array(
1707 'label' => __('Post Grid #4', 'ultimate-post'),
1708 'default' => true,
1709 'live' => 'https://www.wpxpo.com/postx/blocks/#demoid6832',
1710 'docs' => 'https://docs.wpxpo.com/docs/postx/',
1711 'icon' => ULTP_URL.'assets/img/blocks/post-grid-4.svg'
1712 ),
1713 'post_grid_5' => array(
1714 'label' => __('Post Grid #5', 'ultimate-post'),
1715 'default' => true,
1716 'live' => 'https://www.wpxpo.com/postx/blocks/#demoid6833',
1717 'docs' => 'https://docs.wpxpo.com/docs/postx/',
1718 'icon' => ULTP_URL.'assets/img/blocks/post-grid-5.svg'
1719 ),
1720 'post_grid_6' => array(
1721 'label' => __('Post Grid #6', 'ultimate-post'),
1722 'default' => true,
1723 'live' => 'https://www.wpxpo.com/postx/blocks/#demoid6834',
1724 'docs' => 'https://docs.wpxpo.com/docs/postx/',
1725 'icon' => ULTP_URL.'assets/img/blocks/post-grid-6.svg'
1726 ),
1727 'post_grid_7' => array(
1728 'label' => __('Post Grid #7', 'ultimate-post'),
1729 'default' => true,
1730 'live' => 'https://www.wpxpo.com/postx/blocks/#demoid6835',
1731 'docs' => 'https://docs.wpxpo.com/docs/postx/',
1732 'icon' => ULTP_URL.'assets/img/blocks/post-grid-7.svg'
1733 )
1734 )
1735 ),
1736 'list' => array(
1737 'label' => __('Post List Blocks', 'ultimate-post'),
1738 'attr' => array(
1739 'post_list_1' => array(
1740 'label' => __('Post List #1', 'ultimate-post'),
1741 'default' => true,
1742 'live' => 'https://www.wpxpo.com/postx/blocks/#demoid6836',
1743 'docs' => 'https://docs.wpxpo.com/docs/postx/',
1744 'icon' => ULTP_URL.'assets/img/blocks/post-list-1.svg'
1745 ),
1746 'post_list_2' => array(
1747 'label' => __('Post List #2', 'ultimate-post'),
1748 'default' => true,
1749 'live' => 'https://www.wpxpo.com/postx/blocks/#demoid6837',
1750 'docs' => 'https://docs.wpxpo.com/docs/postx/',
1751 'icon' => ULTP_URL.'assets/img/blocks/post-list-2.svg'
1752 ),
1753 'post_list_3' => array(
1754 'label' => __('Post List #3', 'ultimate-post'),
1755 'default' => true,
1756 'live' => 'https://www.wpxpo.com/postx/blocks/#demoid6838',
1757 'docs' => 'https://docs.wpxpo.com/docs/postx/',
1758 'icon' => ULTP_URL.'assets/img/blocks/post-list-3.svg'
1759 ),
1760 'post_list_4' => array(
1761 'label' => __('Post List #4', 'ultimate-post'),
1762 'default' => true,
1763 'live' => 'https://www.wpxpo.com/postx/blocks/#demoid6839',
1764 'docs' => 'https://docs.wpxpo.com/docs/postx/',
1765 'icon' => ULTP_URL.'assets/img/blocks/post-list-4.svg'
1766 ),
1767
1768 )
1769 ),
1770 'slider' => array(
1771 'label' => __('Post Slider', 'ultimate-post'),
1772 'attr' => array(
1773 'post_slider_1' => array(
1774 'label' => __('Post Slider #1', 'ultimate-post'),
1775 'default' => true,
1776 'live' => 'https://www.wpxpo.com/postx/blocks/#demoid6840',
1777 'docs' => 'https://docs.wpxpo.com/docs/postx/',
1778 'icon' => ULTP_URL.'/assets/img/blocks/post-slider-1.svg'
1779 ),
1780 'post_slider_2' => array(
1781 'label' => __('Post Slider #2', 'ultimate-post'),
1782 'default' => true,
1783 'live' => 'https://www.wpxpo.com/postx/blocks/#demoid7487',
1784 'docs' => 'https://docs.wpxpo.com/docs/postx/all-blocks/post-slider-2/',
1785 'icon' => ULTP_URL.'/assets/img/blocks/post-slider-2.svg'
1786 ),
1787 )
1788 ),
1789 'other' => array(
1790 'label' => __('Others Post Blocks', 'ultimate-post'),
1791 'attr' => array(
1792 'post_module_1' => array(
1793 'label' => __('Post Module #1', 'ultimate-post'),
1794 'default' => true,
1795 'live' => 'https://www.wpxpo.com/postx/blocks/#demoid6825',
1796 'docs' => 'https://docs.wpxpo.com/docs/postx/',
1797 'icon' => ULTP_URL.'/assets/img/blocks/post-module-1.svg'
1798 ),
1799 'post_module_2' => array(
1800 'label' => __('Post Module #2', 'ultimate-post'),
1801 'default' => true,
1802 'live' => 'https://www.wpxpo.com/postx/blocks/#demoid6827',
1803 'docs' => 'https://docs.wpxpo.com/docs/postx/',
1804 'icon' => ULTP_URL.'/assets/img/blocks/post-module-2.svg'
1805 ),
1806 'heading' => array(
1807 'label' => __('Heading', 'ultimate-post'),
1808 'default' => true,
1809 'live' => 'https://www.wpxpo.com/postx/blocks/#demoid6842',
1810 'docs' => 'https://docs.wpxpo.com/docs/postx/',
1811 'icon' => ULTP_URL.'/assets/img/blocks/heading.svg'
1812 ),
1813 'image' => array(
1814 'label' => __('Image', 'ultimate-post'),
1815 'default' => true,
1816 'live' => 'https://www.wpxpo.com/postx/blocks/#demoid6843',
1817 'docs' => 'https://docs.wpxpo.com/docs/postx/all-blocks/image-blocks/',
1818 'icon' => ULTP_URL.'/assets/img/blocks/image.svg'
1819 ),
1820 'taxonomy' => array(
1821 'label' => __('Taxonomy', 'ultimate-post'),
1822 'default' => true,
1823 'live' => 'https://www.wpxpo.com/postx/blocks/#demoid6841',
1824 'docs' => 'https://docs.wpxpo.com/docs/postx/all-blocks/taxonomy-style-1/',
1825 'icon' => ULTP_URL.'/assets/img/blocks/taxonomy.svg'
1826 ),
1827 'wrapper' => array(
1828 'label' => __('Wrapper', 'ultimate-post'),
1829 'default' => true,
1830 'live' => 'https://www.wpxpo.com/postx/blocks/#demoid6844',
1831 'docs' => 'https://docs.wpxpo.com/docs/postx/add-on/wrapper-blocks/',
1832 'icon' => ULTP_URL.'/assets/img/blocks/wrapper.svg'
1833 ),
1834 'news_ticker' => array(
1835 'label' => __('News Ticker', 'ultimate-post'),
1836 'default' => true,
1837 'live' => 'https://www.wpxpo.com/postx/blocks/#demoid6845',
1838 'docs' => 'https://docs.wpxpo.com/docs/postx/all-blocks/news-ticker-block/',
1839 'icon' => ULTP_URL.'/assets/img/blocks/news-ticker.svg'
1840 ),
1841 )
1842 ),
1843 'builder' => array(
1844 'label' => __('Site Builder Blocks', 'ultimate-post'),
1845 'attr' => array(
1846 'builder_post_title' => array(
1847 'label' => __('Post Title', 'ultimate-post'),
1848 'default' => true,
1849 'docs' => 'https://docs.wpxpo.com/docs/postx/dynamic-site-builder/',
1850 'icon' => ULTP_URL.'/assets/img/blocks/builder/post_title.svg'
1851 ),
1852 'builder_advance_post_meta' => array(
1853 'label' => __('Advance Post Meta', 'ultimate-post'),
1854 'default' => true,
1855 'docs' => 'https://docs.wpxpo.com/docs/postx/dynamic-site-builder/',
1856 'icon' => ULTP_URL.'/assets/img/blocks/builder/post_meta.svg'
1857 ),
1858 'builder_archive_title' => array(
1859 'label' => __('Archive Title', 'ultimate-post'),
1860 'default' => true,
1861 'docs' => 'https://docs.wpxpo.com/docs/postx/dynamic-site-builder/',
1862 'icon' => ULTP_URL.'/assets/img/blocks/archive-title.svg'
1863 ),
1864 'builder_author_box' => array(
1865 'label' => __('Post Author Box', 'ultimate-post'),
1866 'default' => true,
1867 'docs' => 'https://docs.wpxpo.com/docs/postx/dynamic-site-builder/',
1868 'icon' => ULTP_URL.'/assets/img/blocks/builder/author_box.svg'
1869 ),
1870 'builder_post_next_previous' => array(
1871 'label' => __('Post Next Previous', 'ultimate-post'),
1872 'default' => true,
1873 'docs' => 'https://docs.wpxpo.com/docs/postx/dynamic-site-builder/',
1874 'icon' => ULTP_URL.'/assets/img/blocks/builder/next_previous.svg'
1875 ),
1876 'builder_post_author_meta' => array(
1877 'label' => __('Post Author Meta', 'ultimate-post'),
1878 'default' => true,
1879 'docs' => 'https://docs.wpxpo.com/docs/postx/dynamic-site-builder/',
1880 'icon' => ULTP_URL.'/assets/img/blocks/builder/author.svg'
1881 ),
1882 'builder_post_breadcrumb' => array(
1883 'label' => __('Post Breadcrumb', 'ultimate-post'),
1884 'default' => true,
1885 'docs' => 'https://docs.wpxpo.com/docs/postx/dynamic-site-builder/',
1886 'icon' => ULTP_URL.'/assets/img/blocks/builder/breadcrumb.svg'
1887 ),
1888 'builder_post_category' => array(
1889 'label' => __('Post Category', 'ultimate-post'),
1890 'default' => true,
1891 'docs' => 'https://docs.wpxpo.com/docs/postx/dynamic-site-builder/',
1892 'icon' => ULTP_URL.'/assets/img/blocks/builder/category.svg'
1893 ),
1894 'builder_post_comment_count' => array(
1895 'label' => __('Post Comment Count', 'ultimate-post'),
1896 'default' => true,
1897 'docs' => 'https://docs.wpxpo.com/docs/postx/dynamic-site-builder/',
1898 'icon' => ULTP_URL.'/assets/img/blocks/builder/comment_count.svg'
1899 ),
1900 'builder_post_comments' => array(
1901 'label' => __('Post Comments', 'ultimate-post'),
1902 'default' => true,
1903 'docs' => 'https://docs.wpxpo.com/docs/postx/dynamic-site-builder/',
1904 'icon' => ULTP_URL.'/assets/img/blocks/builder/comments.svg'
1905 ),
1906 'builder_post_content' => array(
1907 'label' => __('Post Content', 'ultimate-post'),
1908 'default' => true,
1909 'docs' => 'https://docs.wpxpo.com/docs/postx/dynamic-site-builder/',
1910 'icon' => ULTP_URL.'/assets/img/blocks/builder/content.svg'
1911 ),
1912 'builder_post_date_meta' => array(
1913 'label' => __('Post Date Meta', 'ultimate-post'),
1914 'default' => true,
1915 'docs' => 'https://docs.wpxpo.com/docs/postx/dynamic-site-builder/',
1916 'icon' => ULTP_URL.'/assets/img/blocks/builder/post_date.svg'
1917 ),
1918 'builder_post_excerpt' => array(
1919 'label' => __('Post Excerpt', 'ultimate-post'),
1920 'default' => true,
1921 'docs' => 'https://docs.wpxpo.com/docs/postx/dynamic-site-builder/',
1922 'icon' => ULTP_URL.'/assets/img/blocks/builder/excerpt.svg'
1923 ),
1924 'builder_post_featured_image' => array(
1925 'label' => __('Post Featured Image', 'ultimate-post'),
1926 'default' => true,
1927 'docs' => 'https://docs.wpxpo.com/docs/postx/dynamic-site-builder/',
1928 'icon' => ULTP_URL.'/assets/img/blocks/builder/featured_img.svg'
1929 ),
1930 'builder_post_reading_time' => array(
1931 'label' => __('Post Reading Time', 'ultimate-post'),
1932 'default' => true,
1933 'docs' => 'https://docs.wpxpo.com/docs/postx/dynamic-site-builder/',
1934 'icon' => ULTP_URL.'/assets/img/blocks/builder/reading_time.svg'
1935 ),
1936 'builder_post_social_share' => array(
1937 'label' => __('Post Social Share', 'ultimate-post'),
1938 'default' => true,
1939 'docs' => 'https://docs.wpxpo.com/docs/postx/dynamic-site-builder/',
1940 'icon' => ULTP_URL.'/assets/img/blocks/builder/share.svg'
1941 ),
1942 'builder_post_tag' => array(
1943 'label' => __('Post Tag', 'ultimate-post'),
1944 'default' => true,
1945 'docs' => 'https://docs.wpxpo.com/docs/postx/dynamic-site-builder/',
1946 'icon' => ULTP_URL.'/assets/img/blocks/builder/post_tag.svg'
1947 ),
1948 'builder_post_view_count' => array(
1949 'label' => __('Post View Count', 'ultimate-post'),
1950 'default' => true,
1951 'docs' => 'https://docs.wpxpo.com/docs/postx/dynamic-site-builder/',
1952 'icon' => ULTP_URL.'/assets/img/blocks/builder/view_count.svg'
1953 ),
1954 )
1955 )
1956 );
1957
1958 return $arr;
1959 }
1960
1961 /**
1962 * Builder Conditions
1963 *
1964 * @since v.2.7.0
1965 * @param STRING | Type of Return
1966 * @return MIXED || ID or Path
1967 */
1968 public function conditions( $type = 'return' ) {
1969 $page_id = '';
1970
1971 $conditions = get_option('ultp_builder_conditions', array());
1972 if (isset($conditions['archive'])) {
1973 if (!empty($conditions['archive'])) {
1974 $is_search = is_search();
1975 $is_archive = is_archive();
1976 $taxonomy = (is_category() || is_tag() || is_tax()) ? get_queried_object() : (object)[];
1977
1978 if (is_archive()) {
1979 foreach ($conditions['archive'] as $key => $val) {
1980 if (in_array('include/archive', $val)) {
1981 if ('publish' == get_post_status($key)) {
1982 $page_id = $key;
1983 }
1984 }
1985 if (in_array('exclude/archive', $val)) {
1986 if ('publish' == get_post_status($key)) {
1987 $page_id = '';
1988 }
1989 }
1990 }
1991 if (is_category()) {
1992 foreach ($conditions['archive'] as $key => $val) {
1993 if (in_array('include/archive/category', $val)) {
1994 if ('publish' == get_post_status($key)) {
1995 $page_id = $key;
1996 }
1997 }
1998 if (in_array('exclude/archive/category', $val)) {
1999 if ('publish' == get_post_status($key)) {
2000 $page_id = '';
2001 }
2002 }
2003 if (in_array('include/archive/category/'.$taxonomy->term_id, $val)) {
2004 if ('publish' == get_post_status($key)) {
2005 $page_id = $key;
2006 }
2007 }
2008 if (in_array('exclude/archive/category/'.$taxonomy->term_id, $val)) {
2009 if ('publish' == get_post_status($key)) {
2010 $page_id = '';
2011 }
2012 }
2013 if ($this->in_string_part('any_child_of', $val)) {
2014 if (in_array('include/archive/any_child_of_category', $val)) {
2015 if ('publish' == get_post_status($key)) {
2016 $page_id = $key;
2017 }
2018 }
2019 if (in_array('exclude/archive/any_child_of_category', $val)) {
2020 if ('publish' == get_post_status($key)) {
2021 $page_id = '';
2022 }
2023 }
2024 foreach ($val as $v) {
2025 if (strpos($v, '/archive/any_child_of_category/') !== false) {
2026 if ($v) {
2027 $data = explode("/", $v);
2028 if (isset($data[3]) && $data[3]) {
2029 if (term_is_ancestor_of($data[3], $taxonomy->term_id, 'category')) {
2030 if ('publish' == get_post_status($key)) {
2031 $page_id = $data[0] == 'exclude' ? '' : $key;
2032 }
2033 }
2034 }
2035 }
2036 }
2037 }
2038 } else {
2039 if ($this->in_string_part('child_of', $val)) {
2040 if (in_array('include/archive/child_of_category', $val)) {
2041 if ('publish' == get_post_status($key)) {
2042 $page_id = $key;
2043 }
2044 }
2045 if (in_array('exclude/archive/child_of_category', $val)) {
2046 if ('publish' == get_post_status($key)) {
2047 $page_id = '';
2048 }
2049 }
2050 if (in_array('include/archive/child_of_category/'.$taxonomy->parent, $val)) {
2051 if ('publish' == get_post_status($key)) {
2052 $page_id = $key;
2053 }
2054 }
2055 if (in_array('exclude/archive/child_of_category/'.$taxonomy->parent, $val)) {
2056 if ('publish' == get_post_status($key)) {
2057 $page_id = '';
2058 }
2059 }
2060 }
2061 }
2062 }
2063 } else if (is_tag()) {
2064 foreach ($conditions['archive'] as $key => $val) {
2065 if (in_array('include/archive/post_tag', $val)) {
2066 if ('publish' == get_post_status($key)) {
2067 $page_id = $key;
2068 }
2069 }
2070 if (in_array('exclude/archive/post_tag', $val)) {
2071 if ('publish' == get_post_status($key)) {
2072 $page_id = '';
2073 }
2074 }
2075 if (in_array('include/archive/post_tag/'.$taxonomy->term_id, $val)) {
2076 if ('publish' == get_post_status($key)) {
2077 $page_id = $key;
2078 }
2079 }
2080 if (in_array('exclude/archive/post_tag/'.$taxonomy->term_id, $val)) {
2081 if ('publish' == get_post_status($key)) {
2082 $page_id = '';
2083 }
2084 }
2085 }
2086 } else if (is_tax()) {
2087 foreach ($conditions['archive'] as $key => $val) {
2088 if (in_array('include/archive/'.$taxonomy->taxonomy, $val)) {
2089 if ('publish' == get_post_status($key)) {
2090 $page_id = $key;
2091 }
2092 }
2093 if (in_array('exclude/archive/'.$taxonomy->taxonomy, $val)) {
2094 if ('publish' == get_post_status($key)) {
2095 $page_id = '';
2096 }
2097 }
2098 if (in_array('include/archive/'.$taxonomy->taxonomy.'/'.$taxonomy->term_id, $val)) {
2099 if ('publish' == get_post_status($key)) {
2100 $page_id = $key;
2101 }
2102 }
2103 if (in_array('exclude/archive/'.$taxonomy->taxonomy.'/'.$taxonomy->term_id, $val)) {
2104 if ('publish' == get_post_status($key)) {
2105 $page_id = '';
2106 }
2107 }
2108 if ($this->in_string_part('any_child_of', $val)) {
2109 if (in_array('include/archive/any_child_of_'.$taxonomy->taxonomy, $val)) {
2110 if ('publish' == get_post_status($key)) {
2111 $page_id = $key;
2112 }
2113 }
2114 if (in_array('exclude/archive/any_child_of_'.$taxonomy->taxonomy, $val)) {
2115 if ('publish' == get_post_status($key)) {
2116 $page_id = '';
2117 }
2118 }
2119 foreach ($val as $v) {
2120 if (strpos($v, '/archive/any_child_of_'.$taxonomy->taxonomy.'/') !== false) {
2121 if ($v) {
2122 $data = explode("/", $v);
2123 if (isset($data[3]) && $data[3]) {
2124 if (term_is_ancestor_of($data[3], $taxonomy->term_id, $taxonomy->taxonomy)) {
2125 if ('publish' == get_post_status($key)) {
2126 $page_id = $data[0] == 'exclude' ? '' : $key;
2127 }
2128 }
2129 }
2130 }
2131 }
2132 }
2133 } else {
2134 if ($this->in_string_part('child_of', $val)) {
2135 if (in_array('include/archive/child_of_'.$taxonomy->taxonomy, $val)) {
2136 if ('publish' == get_post_status($key)) {
2137 $page_id = $key;
2138 }
2139 }
2140 if (in_array('exclude/archive/child_of_'.$taxonomy->taxonomy, $val)) {
2141 if ('publish' == get_post_status($key)) {
2142 $page_id = '';
2143 }
2144 }
2145 if (in_array('include/archive/child_of_'.$taxonomy->taxonomy.'/'.$taxonomy->parent, $val)) {
2146 if ('publish' == get_post_status($key)) {
2147 $page_id = $key;
2148 }
2149 }
2150 if (in_array('exclude/archive/child_of_'.$taxonomy->taxonomy.'/'.$taxonomy->parent, $val)) {
2151 if ('publish' == get_post_status($key)) {
2152 $page_id = '';
2153 }
2154 }
2155 }
2156 }
2157 }
2158 } else if (is_date()) {
2159 foreach ($conditions['archive'] as $key => $val) {
2160 if (in_array('include/archive/date', $val)) {
2161 if ('publish' == get_post_status($key)) {
2162 $page_id = $key;
2163 }
2164 }
2165 if (in_array('exclude/archive/date', $val)) {
2166 if ('publish' == get_post_status($key)) {
2167 $page_id = '';
2168 }
2169 }
2170 }
2171 } else if (is_author()) {
2172 foreach ($conditions['archive'] as $key => $val) {
2173 if (in_array('include/archive/author', $val)) {
2174 if ('publish' == get_post_status($key)) {
2175 $page_id = $key;
2176 }
2177 }
2178 if (in_array('exclude/archive/author', $val)) {
2179 if ('publish' == get_post_status($key)) {
2180 $page_id = '';
2181 }
2182 }
2183 $author_id = get_the_author_meta('ID');
2184 if (in_array('include/archive/author/'.$author_id, $val)) {
2185 if ('publish' == get_post_status($key)) {
2186 $page_id = $key;
2187 }
2188 }
2189 if (in_array('exclude/archive/author/'.$author_id, $val)) {
2190 if ('publish' == get_post_status($key)) {
2191 $page_id = '';
2192 }
2193 }
2194 }
2195 }
2196 } else if (is_search()) {
2197 foreach ($conditions['archive'] as $key => $val) {
2198 if (in_array('include/archive/search', $val)) {
2199 if ('publish' == get_post_status($key)) {
2200 $page_id = $key;
2201 }
2202 }
2203 if (in_array('exclude/archive/search', $val)) {
2204 if ('publish' == get_post_status($key)) {
2205 $page_id = '';
2206 }
2207 }
2208 }
2209 }
2210 }
2211 }
2212 // Singular
2213 if (isset($conditions['singular'])) {
2214 if (!empty($conditions['singular']) && is_singular()) {
2215 $obj = get_queried_object();
2216 $tax_list = $this->get_taxonomy_list();
2217 foreach ($conditions['singular'] as $key => $val) {
2218 if (get_post_status($key)) {
2219 // Front Page
2220 if (is_front_page()) {
2221 if (in_array('include/singular/front_page', $val)) {
2222 if ('publish' == get_post_status($key)) {
2223 $page_id = $key;
2224 }
2225 }
2226 if (in_array('exclude/singular/front_page', $val)) {
2227 if ('publish' == get_post_status($key)) {
2228 $page_id = '';
2229 }
2230 }
2231 }
2232 // Author check
2233 if (in_array('singular/post_by_author', $val)) {
2234 if (in_array('include/singular/post_by_author', $val)) {
2235 if ('publish' == get_post_status($key)) {
2236 $page_id = $key;
2237 }
2238 }
2239 if (in_array('exclude/singular/post_by_author', $val)) {
2240 if ('publish' == get_post_status($key)) {
2241 $page_id = '';
2242 }
2243 }
2244 if (in_array('include/singular/post_by_author/'.$obj->post_author, $val)) {
2245 if ('publish' == get_post_status($key)) {
2246 $page_id = $key;
2247 }
2248 }
2249 if (in_array('exclude/singular/post_by_author/'.$obj->post_author, $val)) {
2250 if ('publish' == get_post_status($key)) {
2251 $page_id = '';
2252 }
2253 }
2254 }
2255 // All Taxonomy
2256 if($this->in_string_part('/singular/in_', $val)) {
2257 foreach ($tax_list as $tax) {
2258 if ($this->in_string_part('singular/in_'.$tax.'_children', $val)) {
2259 // In Taxonomy Children
2260 if (in_array('include/singular/in_'.$tax.'_children', $val)) {
2261 if ('publish' == get_post_status($key)) {
2262 $page_id = $key;
2263 }
2264 }
2265 if (in_array('exclude/singular/in_'.$tax.'_children', $val)) {
2266 if ('publish' == get_post_status($key)) {
2267 $page_id = '';
2268 }
2269 }
2270 foreach ($val as $v) {
2271 if (strpos($v, '/singular/in_'.$tax.'_children/') !== false) {
2272 if ($v) {
2273 $data = explode("/", $v);
2274 if (isset($data[3]) && $data[3]) {
2275 if (is_object_in_term($obj->ID , $tax, $data[3] )) {
2276 if ('publish' == get_post_status($key)) {
2277 $page_id = $data[0] == 'exclude' ? '' : $key;
2278 }
2279 }
2280 }
2281 }
2282 }
2283 }
2284 } else {
2285 // IN Taxonomy
2286 if (in_array('include/singular/in_'.$tax, $val)) {
2287 if ('publish' == get_post_status($key)) {
2288 $page_id = $key;
2289 }
2290 }
2291 if (in_array('exclude/singular/in_'.$tax, $val)) {
2292 if ('publish' == get_post_status($key)) {
2293 $page_id = '';
2294 }
2295 }
2296 foreach ($val as $v) {
2297 if (strpos($v, '/singular/in_'.$tax.'/') !== false) {
2298 if ($v) {
2299 $data = explode("/", $v);
2300 if (isset($data[3]) && $data[3]) {
2301 if (is_object_in_term($obj->ID , $tax, $data[3] )) {
2302 if ('publish' == get_post_status($key)) {
2303 $page_id = $data[0] == 'exclude' ? '' : $key;
2304 }
2305 }
2306 }
2307 }
2308 }
2309 }
2310 }
2311 }
2312 }
2313 // All Post Type
2314 if (in_array('include/singular/'.$obj->post_type, $val)) {
2315 if ('publish' == get_post_status($key)) {
2316 $page_id = $key;
2317 }
2318 }
2319 if (in_array('exclude/singular/'.$obj->post_type, $val)) {
2320 if ('publish' == get_post_status($key)) {
2321 $page_id = '';
2322 }
2323 }
2324 if ($this->in_string_part('include/singular/'.$obj->post_type.'/'.$obj->ID, $val)) {
2325 if ('publish' == get_post_status($key)) {
2326 $page_id = $key;
2327 }
2328 }
2329 if ($this->in_string_part('exclude/singular/'.$obj->post_type.'/'.$obj->ID, $val)) {
2330 if ('publish' == get_post_status($key)) {
2331 $page_id = '';
2332 }
2333 }
2334 }
2335 }
2336 }
2337 }
2338
2339 if ($type == 'return') {
2340 return $page_id;
2341 }
2342 if ($type == 'includes') {
2343 return $page_id ? ULTP_PATH.'addons/builder/Archive_Template.php' : '';
2344 }
2345 }
2346
2347
2348 /**
2349 * Get Add Default Condition Data
2350 *
2351 * @since v.2.7.0
2352 * @return ARRAY | Default Data
2353 */
2354 public function builder_data() {
2355 $archive_data = [
2356 [
2357 'label' => 'All Archive',
2358 'value' => '',
2359 ],
2360 [
2361 'label' => 'Author Archive',
2362 'value' => 'author',
2363 'search' => 'author###'
2364 ],
2365 [
2366 'label' => 'Date Archive',
2367 'value' => 'date',
2368 ],
2369 [
2370 'label' => 'Search Results',
2371 'value' => 'search',
2372 ],
2373 ];
2374 $single_data = [
2375 [
2376 'label' => 'Front Page',
2377 'value' => 'front_page',
2378 ]
2379 ];
2380
2381 $post_type = get_post_types( ['public' => true], 'objects' );
2382 foreach ($post_type as $key => $type) {
2383 // Post Type
2384 $single_temp = [
2385 'label' => $type->label,
2386 'value' => $type->name,
2387 'search' => 'type###'.$type->name
2388 ];
2389 $archive_temp = [];
2390
2391 // Taxonomy
2392 $taxonomy = get_object_taxonomies( $type->name, 'objects' );
2393 if (!empty($taxonomy)) {
2394 $single_tax = $archive_tax = [];
2395 $single_tax[] = $single_temp;
2396
2397 $archive_temp = [
2398 'label' => $type->label . ' Archive',
2399 'value' => $type->name . '_archive',
2400 ];
2401 // $archive_tax[] = $archive_temp;
2402 foreach ($taxonomy as $key => $val) {
2403 if ($val->public) {
2404 $single_tax[] = [
2405 'label' => 'In ' . $val->label,
2406 'value' => 'in_' . $val->name,
2407 'search' => 'term###'.$val->name
2408 ];
2409 $archive_tax[] = [
2410 'label' => $val->label,
2411 'value' => $val->name,
2412 'search' => 'term###'.$val->name
2413 ];
2414
2415 if ($val->hierarchical) {
2416 // Hierarchical
2417 $single_tax[] = [
2418 'label' => 'In Child ' . $val->label,
2419 'value' => 'in_' . $val->name . '_children',
2420 'search' => 'term###'.$val->name
2421 ];
2422 $archive_tax[] = [
2423 'label' => 'Direct Child ' . $val->label . ' Of',
2424 'value' => 'child_of_' . $val->name,
2425 'search' => 'term###'.$val->name
2426 ];
2427 $archive_tax[] = [
2428 'label' => 'Any Child ' . $val->label . ' Of',
2429 'value' => 'any_child_of_' . $val->name,
2430 'search' => 'term###'.$val->name
2431 ];
2432 }
2433 }
2434 }
2435 // Author
2436 $single_tax[] = [
2437 'label' => 'Posts By Author',
2438 'value' => 'post_by_author',
2439 'search' => 'author###'
2440 ];
2441 $single_temp['attr'] = $single_tax;
2442 $archive_temp['attr'] = $archive_tax;
2443 }
2444 $single_data[] = $single_temp;
2445 if (!empty($archive_temp)) {
2446 $archive_data[] = $archive_temp;
2447 }
2448 }
2449
2450 return ['singular' => $single_data, 'archive' => $archive_data];
2451 }
2452
2453 /**
2454 * Get Date Default Format
2455 *
2456 * @since v.2.7.2
2457 * @return ARRAY | Default Data
2458 */
2459 public function get_format($format) {
2460 if ($format == 'default_date') {
2461 return $this->get_setting('date_format');
2462 } else if ($format == 'default_date_time') {
2463 return $this->get_setting('date_format').' '.$this->get_setting('time_format');
2464 } else {
2465 return $format;
2466 }
2467 }
2468
2469 public function pro_popup_html() { ?>
2470 <div class="ultp-popup-container popup-center">
2471 <div class="ultp-unlock-popup ultp-unlock-modal">
2472 <img src="<?php echo esc_url(ULTP_URL . '/assets/img/admin/dashboard/unlock-super-icon.svg'); ?>" alt="lock icon">
2473 <h4 class="ultp-md-heading ultp-mt25 ultp-mb25"><?php esc_html_e('Unlock 11+ Addons', 'ultimate-post'); ?></h4>
2474 <div class="ultp-popup-desc">
2475 <?php esc_html_e('We’re sorry, PostX Addons are not available on PostX free. Please upgrade to a PRO plan to unlock the add ons of your choice.', 'ultimate-post'); ?>
2476 </div>
2477 <a href="<?php echo esc_url(ultimate_post()->get_premium_link('', 'postx_dashboard_addons_popup')); ?>" class="ultp-popup-planbtn ultp-btn ultp-btn-warning ultp-mt25"><?php esc_html_e('Upgrade Plan', 'ultimate-post'); ?></a>
2478 <button class="ultp-popup-close"></button>
2479 </div>
2480 </div>
2481 <?php }
2482
2483 /**
2484 * Common Frontend and Backend CSS and JS Scripts
2485 *
2486 * @since v.1.0.0
2487 * @return NULL
2488 */
2489 public function register_scripts_common() {
2490 wp_enqueue_style('ultp-style', ULTP_URL.'assets/css/style.min.css', array(), ULTP_VER );
2491 wp_enqueue_script('ultp-script', ULTP_URL.'assets/js/ultp.min.js', array('jquery'), ULTP_VER, true);
2492 wp_localize_script('ultp-script', 'ultp_data_frontend', array(
2493 'url' => ULTP_URL,
2494 'ajax' => admin_url('admin-ajax.php'),
2495 'security' => wp_create_nonce('ultp-nonce')
2496 ));
2497 }
2498
2499 }
2500