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

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