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

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