PluginProbe
Post Grid Gutenberg Blocks – PostX / 2.8.7
Post Grid Gutenberg Blocks – PostX v2.8.7
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.7, at classes/Functions.php

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