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

2,732 lines 117.7 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
1039 if (isset($attr['queryQuick'])) {
1040 if ($attr['queryQuick'] != '' && $post_type != 'archiveBuilder') {
1041 $query_args = ultimate_post()->get_quick_query($attr, $query_args);
1042 }
1043 }
1044
1045 if (isset($attr['queryOffset']) && $attr['queryOffset'] ) {
1046 $offset = $this->get_offset($attr['queryOffset'], $query_args);
1047 $query_args = array_merge($query_args, $offset);
1048 }
1049
1050 if (isset($attr['queryAuthor']) && $attr['queryAuthor'] ) {
1051 $_include = (substr($attr['queryAuthor'], 0, 1) === "[") ? $this->get_value(json_decode($attr['queryAuthor'])) : explode(',', $attr['queryAuthor']);
1052 if (is_array($_include) && count($_include)) {
1053 $query_args['author__in'] = $_include;
1054 }
1055 }
1056
1057 if(isset($attr['querySticky']) && $attr['querySticky']) {
1058 if (filter_var($attr['querySticky'], FILTER_VALIDATE_BOOLEAN)) {
1059 $sticky = get_option( 'sticky_posts', [] );
1060 $query_args['post__not_in'] = isset($query_args['post__not_in']) ? array_merge($query_args['post__not_in'], $sticky) : $sticky;
1061 }
1062 }
1063
1064 if (!isset($attr['ajaxCall'])) {
1065 if(isset($attr['filterShow']) && $attr['filterShow']) {
1066 if(isset($attr['checkFilter']) && isset($attr['queryTax']) && isset($attr['queryTaxValue']) ) {
1067 $var = $this->getFilterQueryArgs($attr);
1068 if (isset($var) && count($var) > 1) {
1069 $query_args['tax_query'] = $var;
1070 }
1071 }
1072 else if(isset($attr['filterType']) && isset($attr['filterValue'])) {
1073 $filterValue = strlen($attr['filterValue']) > 2 ? $attr['filterValue'] : [];
1074 $filterValue = is_array($filterValue) ? $filterValue : json_decode($filterValue);
1075 if (is_array($filterValue) && count($filterValue) > 0 && $attr['filterType']) {
1076 $final = array('relation' => 'OR');
1077 foreach ($filterValue as $key => $val) {
1078 $final[] = array(
1079 'taxonomy' => $attr['filterType'],
1080 'field' => 'slug',
1081 'terms' => $val,
1082 // 'operator' => '=',
1083 );
1084 }
1085 $query_args['tax_query'] = $final;
1086 }
1087 }
1088 }
1089 }
1090
1091 $query_args['wpnonce'] = wp_create_nonce( 'ultp-nonce' );
1092
1093 return apply_filters('ultp_frontend_query', $query_args);
1094 }
1095
1096 /**
1097 * Get Page Offset
1098 *
1099 * @since v.1.0.0
1100 * @param | Offset Number(NUMBER) | Query Arg(ARRAY)
1101 * @return ARRAY
1102 */
1103 function get_offset($queryOffset, $query_args) {
1104 $query = array();
1105 if ($query_args['paged'] > 1) {
1106 $offset_post = wp_get_recent_posts($query_args, OBJECT);
1107 if (count($offset_post) > 0 ) {
1108 $offset = array();
1109 for($x = count($offset_post); $x > count($offset_post) - $queryOffset; $x--) {
1110 $offset[] = $offset_post[$x-1]->ID;
1111 }
1112 $query['post__not_in'] = $offset;
1113 }
1114 } else {
1115 $query['offset'] = isset($queryOffset) ? $queryOffset : 0;
1116 }
1117 return $query;
1118 }
1119
1120
1121 /**
1122 * Get Page Number
1123 *
1124 * @since v.1.0.0
1125 * @param | Attribute of the Query(ARRAY) | Post Number(ARRAY)
1126 * @return ARRAY
1127 */
1128 public function get_page_number($attr, $post_number) {
1129 if ($post_number > 0) {
1130 if (isset($attr['queryOffset']) && $attr['queryOffset']) {
1131 $post_number = $post_number - (int)$attr['queryOffset'];
1132 }
1133 $post_per_page = isset($attr['queryNumber']) ? ($attr['queryNumber'] ? $attr['queryNumber'] : 1) : 3;
1134 $pages = ceil($post_number/$post_per_page);
1135 return $pages ? $pages : 1;
1136 }else{
1137 return 1;
1138 }
1139 }
1140
1141
1142 /**
1143 * Get Image Size
1144 *
1145 * @since v.1.0.0
1146 * @param | Attribute of the Query(ARRAY) | Post Number(ARRAY)
1147 * @return ARRAY
1148 */
1149 public function get_image_size() {
1150 $sizes = get_intermediate_image_sizes();
1151 $filter = array('full' => 'Full');
1152 foreach ($sizes as $value) {
1153 $title = ucwords(str_replace(array('_', '-', 'ultp'), array(' ', ' ', 'PostX'), $value));
1154 switch ($value) {
1155 case 'thumbnail':
1156 $title = $title.' [150x150]';
1157 break;
1158 case 'medium':
1159 $title = $title.' [300x300]';
1160 break;
1161 case 'large':
1162 $title = $title.' [1024x1024]';
1163 break;
1164 case 'ultp_layout_landscape_large':
1165 $title = $title.' [1200x800]';
1166 break;
1167 case 'ultp_layout_landscape':
1168 $title = $title.' [870x570]';
1169 break;
1170 case 'ultp_layout_portrait':
1171 $title = $title.' [600x900]';
1172 break;
1173 case 'ultp_layout_square':
1174 $title = $title.' [600x600]';
1175 break;
1176 default:
1177 break;
1178 }
1179 $filter[$value] = $title;
1180 }
1181 return $filter;
1182 }
1183
1184
1185 /**
1186 * Get All PostType Registered
1187 *
1188 * @since v.1.0.0
1189 * @param | Attribute of the Query(ARRAY) | Post Number(ARRAY)
1190 * @return ARRAY
1191 */
1192 public function get_post_type() {
1193 $filter = apply_filters('ultp_public_post_type', true);
1194 $post_type = get_post_types( ($filter ? ['public' => true] : ''), 'names' );
1195 return array_diff($post_type, array( 'attachment' ));
1196 }
1197
1198 /**
1199 * Get Pagination Url
1200 *
1201 * @since v.2.8.9
1202 * @param | pageNo (NUMBER) | baseUrl (STRING)
1203 * @return STRING
1204 */
1205 public function generatePaginationUrl($pageNo , $baseUrl) {
1206 if($baseUrl) {
1207 $url = $baseUrl.($pageNo == 1? '' : "page/".$pageNo);
1208 }
1209 else {
1210 $url = get_pagenum_link($pageNo);
1211 }
1212 return $url;
1213 }
1214 /**
1215 * Get Pagination HTML
1216 *
1217 * @since v.1.0.0
1218 * @param | pages (NUMBER) | Pagination Nav (STRING) | Pagination Text |
1219 * @return STRING
1220 */
1221 public function pagination($pages = '', $paginationNav = '', $paginationText = '', $paginationAjax = true, $baseUrl = '') {
1222 $html = '';
1223 $showitems = 3;
1224 $paged = is_front_page() ? get_query_var('page') : get_query_var('paged');
1225 $paged = $paged ? $paged : 1;
1226 if ($pages == '') {
1227 global $wp_query;
1228 $pages = $wp_query->max_num_pages;
1229 if (!$pages) {
1230 $pages = 1;
1231 }
1232 }
1233
1234 $data = ($paged>=3?[($paged-1),$paged,$paged+1]:[1,2,3]);
1235
1236 $paginationText = explode('|', $paginationText);
1237
1238 $prev_text = isset($paginationText[0]) ? $paginationText[0] : __("Previous", "ultimate-post");
1239 $next_text = isset($paginationText[1]) ? $paginationText[1] : __("Next", "ultimate-post");
1240
1241 if (1 != $pages) {
1242 $html .= '<ul class="ultp-pagination">';
1243 $display_none = 'style="display:none"';
1244 if ($pages > 4) {
1245 $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>';
1246 }
1247 if ($pages > 4) {
1248 $html .= '<li class="ultp-first-pages" '.($paged<2?$display_none:"").' data-current="1"><a href="'.$this->generatePaginationUrl(1, $baseUrl).'">1</a></li>';
1249 }
1250 if ($pages > 4) {
1251 $html .= '<li class="ultp-first-dot" '.($paged<2? $display_none : "").'><a href="#">...</a></li>';
1252 }
1253 foreach ($data as $i) {
1254 if ($pages >= $i) {
1255 $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>';
1256 }
1257 }
1258 if ($pages > 4) {
1259 $html .= '<li class="ultp-last-dot" '.($pages<=$paged+1?$display_none:"").'><a href="#">...</a></li>';
1260 }
1261 if ($pages > 4) {
1262 $html .= '<li class="ultp-last-pages" '.($pages<=$paged+1?$display_none:"").' data-current="'.$pages.'"><a href="'.$this->generatePaginationUrl($pages, $baseUrl).'">'.$pages.'</a></li>';
1263 }
1264 if ($paged != $pages) {
1265 $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>';
1266 }
1267 $html .= '</ul>';
1268 }
1269 return $html;
1270 }
1271
1272 /**
1273 * Svg Icon Source
1274 *
1275 * @since v.1.0.0
1276 * @param STRING | String Name
1277 * @return STRING
1278 */
1279 public function svg_icon($ultp_icons = '') {
1280 if ($ultp_icons) {
1281 if (file_exists(ULTP_PATH.'assets/img/iconpack/'.$ultp_icons.'.svg')) {
1282 return file_get_contents(ULTP_PATH.'assets/img/iconpack/'.$ultp_icons.'.svg');
1283 }
1284 return '';
1285 }
1286 return '';
1287 }
1288
1289
1290 /**
1291 * Get Excerpt Word
1292 *
1293 * @since v.1.0.0
1294 * @param NUMBER | Character Length
1295 * @return STRING
1296 */
1297 public function excerpt_word($charlength = 200) {
1298 $html = '';
1299 $charlength++;
1300 $excerpt = get_the_excerpt();
1301 if (mb_strlen( $excerpt ) > $charlength ) {
1302 $subex = mb_substr( $excerpt, 0, $charlength );
1303 $exwords = explode( ' ', $subex );
1304 $excut = - ( mb_strlen( $exwords[ count( $exwords ) - 1 ] ) );
1305 if ($excut < 0 ) {
1306 $html = mb_substr( $subex, 0, $excut );
1307 } else {
1308 $html = $subex;
1309 }
1310 $html .= '...';
1311 } else {
1312 $html = $excerpt;
1313 }
1314 return $html;
1315 }
1316
1317
1318 /**
1319 * Get Taxonomy Lists
1320 *
1321 * @since v.1.0.0
1322 * @param STRING | Taxonomy Slug
1323 * @return ARRAY
1324 */
1325 public function taxonomy( $prams = 'category' ) {
1326 $data = array();
1327 $terms = get_terms( $prams, array(
1328 'hide_empty' => false,
1329 ));
1330 if (!is_wp_error($terms)) {
1331 foreach ($terms as $val) {
1332 $data[urldecode_deep($val->slug)] = $val->name;
1333 }
1334 }
1335 return $data;
1336 }
1337
1338
1339 /**
1340 * Get Taxonomy Lists
1341 *
1342 * @since v.2.9.0
1343 * @param STRING | Taxonomy Slug
1344 * @return ARRAY
1345 */
1346 public function builder_preview( $tax_slug, $number ) {
1347 $data = array();
1348 $term_data = get_terms( $tax_slug, array( 'hide_empty' => true, 'number' => $number, 'parent' => 0 ) );
1349 if (!empty($term_data)) {
1350 foreach ($term_data as $terms) {
1351 $data[] = $this->get_tax_data($terms);
1352 }
1353 }
1354 return $data;
1355 }
1356
1357 /**
1358 * Get Taxonomy Data Lists
1359 *
1360 * @since v.1.0.0
1361 * @param OBJECT | Taxonomy Object
1362 * @return ARRAY
1363 */
1364 public function get_tax_data($terms) {
1365 $temp = array();
1366 $thumbnail_id = get_term_meta( $terms->term_id, 'ultp_category_image', true );
1367 $image_src = array();
1368 if ($thumbnail_id) {
1369 $image_sizes = ultimate_post()->get_image_size();
1370 foreach ($image_sizes as $key => $value) {
1371 $image_src[$key] = wp_get_attachment_image_src($thumbnail_id, $key, false)[0];
1372 }
1373 }
1374 $temp['url'] = get_term_link($terms);
1375 $temp['thumbnail_id'] = $thumbnail_id;
1376 $temp['name'] = $terms->name;
1377 $temp['desc'] = $terms->description;
1378 $temp['count'] = $terms->count;
1379 $temp['image'] = $image_src;
1380 $color = get_term_meta($terms->term_id, 'ultp_category_color', true);
1381 $temp['color'] = $color ? $color : '#037fff';
1382 return $temp;
1383 }
1384
1385 public function get_category_data($catSlug, $number = 40, $type = '', $tax_slug = 'category', $archiveBuilder = '') {
1386 $data = array();
1387 if ($type == 'child') {
1388 if($archiveBuilder) {
1389 $data = $this->builder_preview( $tax_slug, $number );
1390 }
1391 else {
1392 if(is_category()) {
1393 $catSlug = array(get_queried_object()->slug);
1394 }
1395 $image = '';
1396 if (!empty($catSlug)) {
1397 foreach ($catSlug as $cat) {
1398 $parent_term = get_term_by('slug', $cat, $tax_slug);
1399 if (!empty($parent_term)) {
1400 $term_data = get_terms($tax_slug, array(
1401 'hide_empty' => true,
1402 'number' => $number,
1403 'parent' => $parent_term->term_id
1404 ));
1405 if (!empty($term_data)) {
1406 foreach ($term_data as $terms) {
1407 $data[] = $this->get_tax_data($terms);
1408 }
1409 }
1410 }
1411 }
1412 }
1413 }
1414 } else if ($type == 'parent') {
1415 $term_data = is_category() ? array(get_term(get_queried_object()->parent, 'category')) : get_terms( $tax_slug, array( 'hide_empty' => true, 'number' => $number, 'parent' => 0 ) );
1416 if($archiveBuilder && !empty($term_data)) {
1417 $term_data = array($term_data[0]);
1418 }
1419 if (!empty($term_data)) {
1420 foreach ($term_data as $terms) {
1421 if (!empty($terms->term_id)) {
1422 $data[] = $this->get_tax_data($terms);
1423 }
1424 }
1425 }
1426 } else if ($type == 'custom') {
1427 foreach ($catSlug as $cat) {
1428 $terms = get_term_by('slug', $cat, $tax_slug);
1429 if (!empty($terms)) {
1430 $data[] = $this->get_tax_data($terms);
1431 }
1432 }
1433 } else if ($type == 'immediate_child') {
1434 if($archiveBuilder) {
1435 $data = $this->builder_preview( $tax_slug, $number );
1436 } else {
1437 $id_ = get_queried_object();
1438 if (isset($id_->term_id)) {
1439 $term_data = get_terms( $tax_slug, array( 'hide_empty' => true, 'number' => 100, 'parent' => $id_->term_id) );
1440 if (!empty($term_data)) {
1441 foreach ($term_data as $terms) {
1442 $data[] = $this->get_tax_data($terms);
1443 }
1444 }
1445 }
1446 }
1447 } else if ($type == 'allchild') {
1448 if($archiveBuilder) {
1449 $data = $this->builder_preview( $tax_slug, $number );
1450 } else {
1451 $id_ = get_queried_object();
1452 if (isset($id_->term_taxonomy_id)) {
1453 $termchildren = get_term_children( $id_->term_taxonomy_id, $tax_slug );
1454 foreach ($termchildren as $key => $value) {
1455 $terms = get_term_by('id', $value, $tax_slug);
1456 $data[] = $this->get_tax_data($terms);
1457 }
1458 }
1459 }
1460 } else if ($type == 'current_level') {
1461 if($archiveBuilder) {
1462 $data = $this->builder_preview( $tax_slug, $number );
1463 } else {
1464 $id_ = get_queried_object();
1465 if (isset($id_->parent)) {
1466 $term_data = get_terms( $tax_slug, array( 'hide_empty' => true, 'number' => $number, 'parent' => $id_->parent ) );
1467 if (!empty($term_data)) {
1468 foreach ($term_data as $terms) {
1469 if ($terms->term_id != $id_->term_id) {
1470 $data[] = $this->get_tax_data($terms);
1471 }
1472 }
1473 }
1474 }
1475 }
1476 } else {
1477 $term_data = get_terms($tax_slug, array('hide_empty' => true, 'number' => $number));
1478 if (!empty($term_data)) {
1479 foreach ($term_data as $terms) {
1480 $data[] = $this->get_tax_data($terms);
1481 }
1482 }
1483 }
1484 return $data;
1485 }
1486
1487
1488 /**
1489 * Get Next Previous HTML
1490 *
1491 * @since v.1.0.0
1492 * @param OBJECT | Taxonomy Object
1493 * @return STRING
1494 */
1495 public function next_prev() {
1496 $html = '';
1497 $html .= '<ul>';
1498 $html .= '<li>';
1499 $html .= '<a class="ultp-prev-action ultp-disable" href="#">';
1500 $html .= ultimate_post()->svg_icon('leftAngle2').'<span class="screen-reader-text">'.esc_html__("Previous", "ultimate-post").'</span>';
1501 $html .= '</a>';
1502 $html .= '</li>';
1503 $html .= '<li>';
1504 $html .= '<a class="ultp-next-action">';
1505 $html .= ultimate_post()->svg_icon('rightAngle2').'<span class="screen-reader-text">'.esc_html__("Next", "ultimate-post").'</span>';
1506 $html .= '</a>';
1507 $html .= '</li>';
1508 $html .= '</ul>';
1509 return $html;
1510 }
1511
1512
1513 /**
1514 * Get Loading HTML
1515 *
1516 * @since v.1.0.0
1517 * @param NULL
1518 * @return STRING
1519 */
1520 public function loading() {
1521 $html = '';
1522 $style = ultimate_post()->get_setting('preloader_style');
1523 if ($style == 'style2') {
1524 $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
1525 } else {
1526 $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>';
1527 }
1528 return '<div class="ultp-loading">'.$html.'</div>';
1529 }
1530
1531
1532 /**
1533 * Get Filter HTML
1534 *
1535 * @since v.1.0.0
1536 * @param | Filter Text (STRING) | Filter Type (STRING) | Filter Value (ARRAY) | Filter Cat (ARRAY) | Filter Tag (ARRAY) |
1537 * @return STRING
1538 */
1539 public function filter($filterText = '', $filterType = '', $filterValue = '[]', $filterMobileText = '...', $filterMobile = true) {
1540 $html = '';
1541 $html .= '<ul '.($filterMobile ? 'class="ultp-flex-menu"' : '').' data-name="'.($filterMobileText ? $filterMobileText : '&nbsp;').'">';
1542 $cat = $this->taxonomy($filterType);
1543 if ($filterText) {
1544 $html .= '<li class="filter-item"><a class="filter-active" data-taxonomy="" href="#">'.$filterText.'</a></li>';
1545 }
1546
1547 if ($filterValue) {
1548 $filterValue = strlen($filterValue) > 2 ? $filterValue : [];
1549 $filterValue = is_array($filterValue) ? $filterValue : json_decode($filterValue);
1550 if (is_array($filterValue) && count($filterValue)) {
1551 foreach ($filterValue as $val) {
1552 $val = isset($val->value) ? $val->value : $val;
1553 $html .= '<li class="filter-item"><a data-taxonomy="'.$val.'" href="#">'.(isset($cat[$val]) ? $cat[$val] : $val).'</a></li>';
1554 }
1555 }
1556 }
1557 $html .= '</ul>';
1558 return $html;
1559 }
1560
1561
1562 /**
1563 * Check License Status
1564 *
1565 * @since v.2.4.2
1566 * @return BOOLEAN | Is pro license active or not
1567 */
1568 public function is_lc_active() {
1569 if (function_exists('ultimate_post_pro')) {
1570 return get_option('edd_ultp_license_status') == 'valid' ? true : false;
1571 }
1572 if (get_transient( 'ulpt_theme_enable' ) == 'integration') {
1573 return true;
1574 }
1575 return false;
1576 }
1577
1578
1579 /**
1580 * Get SEO Meta
1581 *
1582 * @since v.2.4.3
1583 * @param NUMBER | Post ID
1584 * @return STRING | SEO Meta Description or Excerpt
1585 */
1586 public function get_excerpt($post_id = 0, $showSeoMeta = 0, $showFullExcerpt = 0, $excerptLimit = 55) {
1587 $html = '';
1588 if ($showSeoMeta) {
1589 $str = '';
1590 if (function_exists('ultimate_post_pro') ) {
1591 if (ultimate_post()->get_setting('ultp_yoast') == 'true') {
1592 $str = method_exists( ultimate_post_pro(), 'get_yoast_meta' ) ? ultimate_post_pro()->get_yoast_meta($post_id) : '';
1593 } else if (ultimate_post()->get_setting('ultp_rankmath') == 'true') {
1594 $str = method_exists( ultimate_post_pro(), 'get_rankmath_meta' ) ? ultimate_post_pro()->get_rankmath_meta($post_id) : '';
1595 } else if (ultimate_post()->get_setting('ultp_aioseo') == 'true') {
1596 $str = method_exists( ultimate_post_pro(), 'get_aioseo_meta' ) ? ultimate_post_pro()->get_aioseo_meta($post_id) : '';
1597 } else if (ultimate_post()->get_setting('ultp_seopress') == 'true') {
1598 $str = method_exists( ultimate_post_pro(), 'get_seopress_meta' ) ? ultimate_post_pro()->get_seopress_meta($post_id) : '';
1599 } else if (ultimate_post()->get_setting('ultp_squirrly') == 'true') {
1600 $str = method_exists( ultimate_post_pro(), 'get_squirrly_meta' ) ? ultimate_post_pro()->get_squirrly_meta($post_id) : '';
1601 }
1602 }
1603 $html = $str ? $str : ultimate_post()->excerpt($post_id, $excerptLimit);
1604 } else {
1605 if ($showFullExcerpt == 0 ) {
1606 $html = ultimate_post()->excerpt($post_id, $excerptLimit);
1607 } else {
1608 $html = get_the_excerpt();
1609 }
1610 }
1611 return $html;
1612 }
1613
1614 /**
1615 * Set Inline CSS
1616 *
1617 * @since v.2.5.8
1618 * @param STRING | CSS
1619 * @return STRING | CSS with Style
1620 */
1621 public function set_inline($css) {
1622 return '<style type="text/css">'.wp_strip_all_tags($css).'</style>';
1623 }
1624
1625 /**
1626 * Array Sanitize Function
1627 *
1628 * @since v.2.6.0
1629 * @param ARRAY
1630 * @return ARRAY | Array of Sanitize
1631 */
1632 public function recursive_sanitize_text_field($array) {
1633 foreach ($array as $key => &$value) {
1634 if (is_array($value)) {
1635 $value = $this->recursive_sanitize_text_field($value);
1636 } else {
1637 $value = sanitize_text_field($value);
1638 }
1639 }
1640 return $array;
1641 }
1642
1643
1644 public function get_embeded_video($url, $autoPlay, $loop, $mute, $playback, $preload, $poster, $inline, $size) {
1645 $vidAutoPlay = $vidloop = $vidloop = $vidmute = $vidplayback = $vidPoster = $vidInline = "";
1646
1647 if($autoPlay){
1648 $vidAutoPlay = "autoplay";
1649 }
1650 if($poster){
1651 $vidPoster = 'poster="'.$poster["url"].'"';
1652 }
1653 if($loop){
1654 $vidloop = "loop";
1655 }
1656 if($mute){
1657 $vidmute = "muted";
1658 }
1659 if($playback){
1660 $vidplayback = "controls";
1661 }
1662 if($inline){
1663 $vidInline = "playsinline";
1664 }
1665 if (!empty($url)) {
1666 $embeded = wp_oembed_get($url, $size);
1667 if ($embeded == false) {
1668 $format = '';
1669 $url = strtolower($url);
1670 if (strpos($url, '.mp4')) {
1671 $format = 'mp4';
1672 } elseif (strpos($url, '.ogg')) {
1673 $format = 'ogg';
1674 } elseif (strpos($url, '.webm')) {
1675 $format = 'WebM';
1676 }
1677 $embeded = '<video
1678 '.$vidloop.'
1679 '.$vidmute.'
1680 '.$vidplayback.'
1681 preload="'.$preload.'"
1682 '.$vidAutoPlay.'
1683 '.$vidPoster.'
1684 '.$vidInline.'
1685 ><source src="' . $url . '" type="video/' . $format . '">' . __('Your browser does not support the video tag.', 'ultimate-post') . '</video>';
1686 return '<div class="ultp-video-wrapper">'.$embeded.'</div>';
1687 }
1688 return '<div class="ultp-video-wrapper ultp-embaded-video">'.$embeded.'</div>';
1689 } else {
1690 return false;
1691 }
1692 }
1693
1694 /**
1695 * Get Public taxonomy Lists
1696 *
1697 * @since v.2.7.0
1698 * @param NULL
1699 * @return ARRAY | Taxonomy Lists as array
1700 */
1701 public function get_taxonomy_list() {
1702 $taxonomy = get_taxonomies(array('public' => true));
1703 return empty($taxonomy) ? [] : array_keys($taxonomy);
1704 }
1705
1706 /**
1707 * Content Print
1708 *
1709 * @since v.2.7.0
1710 * @param NUMBER | Post ID
1711 * @return STRING | Content of the Post
1712 */
1713 public function content($post_id) {
1714 $content_post = get_post($post_id);
1715 $content = $content_post->post_content;
1716 $content = apply_filters('the_content', $content);
1717 $content = str_replace(']]>', ']]&gt;', $content);
1718 echo $content;
1719 }
1720
1721
1722 /**
1723 * String Part finder inside array
1724 *
1725 * @since v.2.7.0
1726 * @return ARRAY | String Part
1727 */
1728 public function in_string_part($part, $data, $isValue = false) {
1729 $return = false;
1730 foreach ($data as $val) {
1731 if (strpos($val, $part) !== false) {
1732 $return = $isValue ? $val : true;
1733 break;
1734 }
1735 }
1736 return $return;
1737 }
1738
1739 /**
1740 * All Addons Data
1741 *
1742 * @since v.2.7.0
1743 * @return ARRAY | String Part
1744 */
1745 public static function all_addons() {
1746 $all_addons = array(
1747 'ultp_category' => array(
1748 'name' => __( 'Category', 'ultimate-post' ),
1749 'desc' => __( 'Choose your desired color and Image for categories or any taxonomy.', 'ultimate-post' ),
1750 'img' => ULTP_URL.'/assets/img/addons/category-style.svg',
1751 'is_pro' => true,
1752 'docs' => 'https://docs.wpxpo.com/docs/postx/',
1753 'live' => 'https://www.wpxpo.com/postx/addons/category/',
1754 'position' => 15
1755 ),
1756 'ultp_progressbar' => array(
1757 'name' => __( 'Progressbar', 'ultimate-post' ),
1758 'desc' => __( 'Let the users see a graphical indicator to know the reading progress of a blog post.', 'ultimate-post' ),
1759 'img' => ULTP_URL.'/assets/img/addons/progressbar.svg',
1760 'is_pro' => true,
1761 'docs' => 'https://docs.wpxpo.com/docs/postx/add-on/progress-bar/',
1762 'live' => 'https://www.wpxpo.com/postx/progress-bar/',
1763 'position' => 30
1764 ),
1765 'ultp_yoast' => array(
1766 'name' => __( 'Yoast Meta', 'ultimate-post' ),
1767 'desc' => __( 'Show Yoast meta description in the excerpt.', 'ultimate-post' ),
1768 'img' => ULTP_URL.'/assets/img/addons/yoast.svg',
1769 'is_pro' => true,
1770 'docs' => 'https://docs.wpxpo.com/docs/postx/add-on/seo-meta/',
1771 'live' => 'https://www.wpxpo.com/postx/addons/yoast/',
1772 'required' => array(
1773 'name' => 'Yoast',
1774 'slug' => 'wordpress-seo/wp-seo.php'
1775 ),
1776 'position' => 55
1777 ),
1778 'ultp_aioseo' => array(
1779 'name' => __( 'All in One SEO Meta', 'ultimate-post' ),
1780 'desc' => __( 'Show All in One SEO meta description in the excerpt.', 'ultimate-post' ),
1781 'img' => ULTP_URL.'/assets/img/addons/aioseo.svg',
1782 'is_pro' => true,
1783 'docs' => 'https://docs.wpxpo.com/docs/postx/add-on/seo-meta/',
1784 'live' => 'https://www.wpxpo.com/postx/addons/all-in-one-seo-meta/',
1785 'required' => array(
1786 'name' => 'All in One SEO',
1787 'slug' => 'all-in-one-seo-pack/all_in_one_seo_pack.php'
1788 ),
1789 'position' => 35
1790 ),
1791 'ultp_rankmath' => array(
1792 'name' => __( 'RankMath Meta', 'ultimate-post' ),
1793 'desc' => __( 'Show RankMath meta description in the excerpt.', 'ultimate-post' ),
1794 'img' => ULTP_URL.'/assets/img/addons/rankmath.svg',
1795 'is_pro' => true,
1796 'docs' => 'https://docs.wpxpo.com/docs/postx/add-on/seo-meta/',
1797 'live' => 'https://www.wpxpo.com/postx/addons/rankmath/',
1798 'required' => array(
1799 'name' => 'RankMath',
1800 'slug' => 'seo-by-rank-math/rank-math.php'
1801 ),
1802 'position' => 40
1803 ),
1804 'ultp_seopress' => array(
1805 'name' => __( 'SEOPress Meta', 'ultimate-post' ),
1806 'desc' => __( 'Show SEOPress meta description in the excerpt.', 'ultimate-post' ),
1807 'img' => ULTP_URL.'/assets/img/addons/seopress.svg',
1808 'is_pro' => true,
1809 'docs' => 'https://docs.wpxpo.com/docs/postx/add-on/seo-meta/',
1810 'live' => 'https://www.wpxpo.com/postx/addons/seopress/',
1811 'required' => array(
1812 'name' => 'SEOPress',
1813 'slug' => 'wp-seopress/seopress.php'
1814 ),
1815 'position' => 45
1816 ),
1817 'ultp_squirrly' => array(
1818 'name' => __( 'Squirrly Meta', 'ultimate-post' ),
1819 'desc' => __( 'Show Squirrly meta description in the excerpt.', 'ultimate-post' ),
1820 'img' => ULTP_URL.'/assets/img/addons/squirrly.svg',
1821 'is_pro' => true,
1822 'docs' => 'https://docs.wpxpo.com/docs/postx/add-on/seo-meta/',
1823 'live' => 'https://www.wpxpo.com/postx/addons/squirrly/',
1824 'required' => array(
1825 'name' => 'Squirrly',
1826 'slug' => 'squirrly-seo/squirrly.php'
1827 ),
1828 'position' => 50
1829 ),
1830 );
1831 return apply_filters('ultp_addons_config', $all_addons);
1832 }
1833
1834 /**
1835 * All Block Data
1836 *
1837 * @since v.2.7.0
1838 * @return ARRAY | String Part
1839 */
1840 public function get_blocks_settings() {
1841 $arr = array(
1842 'grid' => array(
1843 'label' => __('Post Grid Blocks', 'ultimate-post'),
1844 'attr' => array(
1845 'post_grid_1' => array(
1846 'label' => __('Post Grid #1', 'ultimate-post'),
1847 'default' => true,
1848 'live' => 'https://www.wpxpo.com/postx/blocks/#demoid6829',
1849 'docs' => 'https://docs.wpxpo.com/docs/postx/',
1850 'icon' => ULTP_URL.'assets/img/blocks/post-grid-1.svg'
1851 ),
1852 'post_grid_2' => array(
1853 'label' => __('Post Grid #2', 'ultimate-post'),
1854 'default' => true,
1855 'live' => 'https://www.wpxpo.com/postx/blocks/#demoid6830',
1856 'docs' => 'https://docs.wpxpo.com/docs/postx/',
1857 'icon' => ULTP_URL.'assets/img/blocks/post-grid-2.svg'
1858 ),
1859 'post_grid_3' => array(
1860 'label' => __('Post Grid #3', 'ultimate-post'),
1861 'default' => true,
1862 'live' => 'https://www.wpxpo.com/postx/blocks/#demoid6831',
1863 'docs' => 'https://docs.wpxpo.com/docs/postx/',
1864 'icon' => ULTP_URL.'assets/img/blocks/post-grid-3.svg'
1865 ),
1866 'post_grid_4' => array(
1867 'label' => __('Post Grid #4', 'ultimate-post'),
1868 'default' => true,
1869 'live' => 'https://www.wpxpo.com/postx/blocks/#demoid6832',
1870 'docs' => 'https://docs.wpxpo.com/docs/postx/',
1871 'icon' => ULTP_URL.'assets/img/blocks/post-grid-4.svg'
1872 ),
1873 'post_grid_5' => array(
1874 'label' => __('Post Grid #5', 'ultimate-post'),
1875 'default' => true,
1876 'live' => 'https://www.wpxpo.com/postx/blocks/#demoid6833',
1877 'docs' => 'https://docs.wpxpo.com/docs/postx/',
1878 'icon' => ULTP_URL.'assets/img/blocks/post-grid-5.svg'
1879 ),
1880 'post_grid_6' => array(
1881 'label' => __('Post Grid #6', 'ultimate-post'),
1882 'default' => true,
1883 'live' => 'https://www.wpxpo.com/postx/blocks/#demoid6834',
1884 'docs' => 'https://docs.wpxpo.com/docs/postx/',
1885 'icon' => ULTP_URL.'assets/img/blocks/post-grid-6.svg'
1886 ),
1887 'post_grid_7' => array(
1888 'label' => __('Post Grid #7', 'ultimate-post'),
1889 'default' => true,
1890 'live' => 'https://www.wpxpo.com/postx/blocks/#demoid6835',
1891 'docs' => 'https://docs.wpxpo.com/docs/postx/',
1892 'icon' => ULTP_URL.'assets/img/blocks/post-grid-7.svg'
1893 )
1894 )
1895 ),
1896 'list' => array(
1897 'label' => __('Post List Blocks', 'ultimate-post'),
1898 'attr' => array(
1899 'post_list_1' => array(
1900 'label' => __('Post List #1', 'ultimate-post'),
1901 'default' => true,
1902 'live' => 'https://www.wpxpo.com/postx/blocks/#demoid6836',
1903 'docs' => 'https://docs.wpxpo.com/docs/postx/',
1904 'icon' => ULTP_URL.'assets/img/blocks/post-list-1.svg'
1905 ),
1906 'post_list_2' => array(
1907 'label' => __('Post List #2', 'ultimate-post'),
1908 'default' => true,
1909 'live' => 'https://www.wpxpo.com/postx/blocks/#demoid6837',
1910 'docs' => 'https://docs.wpxpo.com/docs/postx/',
1911 'icon' => ULTP_URL.'assets/img/blocks/post-list-2.svg'
1912 ),
1913 'post_list_3' => array(
1914 'label' => __('Post List #3', 'ultimate-post'),
1915 'default' => true,
1916 'live' => 'https://www.wpxpo.com/postx/blocks/#demoid6838',
1917 'docs' => 'https://docs.wpxpo.com/docs/postx/',
1918 'icon' => ULTP_URL.'assets/img/blocks/post-list-3.svg'
1919 ),
1920 'post_list_4' => array(
1921 'label' => __('Post List #4', 'ultimate-post'),
1922 'default' => true,
1923 'live' => 'https://www.wpxpo.com/postx/blocks/#demoid6839',
1924 'docs' => 'https://docs.wpxpo.com/docs/postx/',
1925 'icon' => ULTP_URL.'assets/img/blocks/post-list-4.svg'
1926 ),
1927
1928 )
1929 ),
1930 'slider' => array(
1931 'label' => __('Post Slider', 'ultimate-post'),
1932 'attr' => array(
1933 'post_slider_1' => array(
1934 'label' => __('Post Slider #1', 'ultimate-post'),
1935 'default' => true,
1936 'live' => 'https://www.wpxpo.com/postx/blocks/#demoid6840',
1937 'docs' => 'https://docs.wpxpo.com/docs/postx/',
1938 'icon' => ULTP_URL.'/assets/img/blocks/post-slider-1.svg'
1939 ),
1940 'post_slider_2' => array(
1941 'label' => __('Post Slider #2', 'ultimate-post'),
1942 'default' => true,
1943 'live' => 'https://www.wpxpo.com/postx/blocks/#demoid7487',
1944 'docs' => 'https://docs.wpxpo.com/docs/postx/all-blocks/post-slider-2/',
1945 'icon' => ULTP_URL.'/assets/img/blocks/post-slider-2.svg'
1946 ),
1947 )
1948 ),
1949 'other' => array(
1950 'label' => __('Others Post Blocks', 'ultimate-post'),
1951 'attr' => array(
1952 'post_module_1' => array(
1953 'label' => __('Post Module #1', 'ultimate-post'),
1954 'default' => true,
1955 'live' => 'https://www.wpxpo.com/postx/blocks/#demoid6825',
1956 'docs' => 'https://docs.wpxpo.com/docs/postx/',
1957 'icon' => ULTP_URL.'/assets/img/blocks/post-module-1.svg'
1958 ),
1959 'post_module_2' => array(
1960 'label' => __('Post Module #2', 'ultimate-post'),
1961 'default' => true,
1962 'live' => 'https://www.wpxpo.com/postx/blocks/#demoid6827',
1963 'docs' => 'https://docs.wpxpo.com/docs/postx/',
1964 'icon' => ULTP_URL.'/assets/img/blocks/post-module-2.svg'
1965 ),
1966 'heading' => array(
1967 'label' => __('Heading', 'ultimate-post'),
1968 'default' => true,
1969 'live' => 'https://www.wpxpo.com/postx/blocks/#demoid6842',
1970 'docs' => 'https://docs.wpxpo.com/docs/postx/',
1971 'icon' => ULTP_URL.'/assets/img/blocks/heading.svg'
1972 ),
1973 'image' => array(
1974 'label' => __('Image', 'ultimate-post'),
1975 'default' => true,
1976 'live' => 'https://www.wpxpo.com/postx/blocks/#demoid6843',
1977 'docs' => 'https://docs.wpxpo.com/docs/postx/all-blocks/image-blocks/',
1978 'icon' => ULTP_URL.'/assets/img/blocks/image.svg'
1979 ),
1980 'taxonomy' => array(
1981 'label' => __('Taxonomy', 'ultimate-post'),
1982 'default' => true,
1983 'live' => 'https://www.wpxpo.com/postx/blocks/#demoid6841',
1984 'docs' => 'https://docs.wpxpo.com/docs/postx/all-blocks/taxonomy-style-1/',
1985 'icon' => ULTP_URL.'/assets/img/blocks/taxonomy.svg'
1986 ),
1987 'wrapper' => array(
1988 'label' => __('Wrapper', 'ultimate-post'),
1989 'default' => true,
1990 'live' => 'https://www.wpxpo.com/postx/blocks/#demoid6844',
1991 'docs' => 'https://docs.wpxpo.com/docs/postx/add-on/wrapper-blocks/',
1992 'icon' => ULTP_URL.'/assets/img/blocks/wrapper.svg'
1993 ),
1994 'news_ticker' => array(
1995 'label' => __('News Ticker', 'ultimate-post'),
1996 'default' => true,
1997 'live' => 'https://www.wpxpo.com/postx/blocks/#demoid6845',
1998 'docs' => 'https://docs.wpxpo.com/docs/postx/all-blocks/news-ticker-block/',
1999 'icon' => ULTP_URL.'/assets/img/blocks/news-ticker.svg'
2000 ),
2001 )
2002 ),
2003 'builder' => array(
2004 'label' => __('Site Builder Blocks', 'ultimate-post'),
2005 'attr' => array(
2006 'builder_post_title' => array(
2007 'label' => __('Post Title', 'ultimate-post'),
2008 'default' => true,
2009 'docs' => 'https://docs.wpxpo.com/docs/postx/dynamic-site-builder/',
2010 'icon' => ULTP_URL.'/assets/img/blocks/builder/post_title.svg'
2011 ),
2012 'builder_advance_post_meta' => array(
2013 'label' => __('Advance Post Meta', '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_meta.svg'
2017 ),
2018 'builder_archive_title' => array(
2019 'label' => __('Archive Title', 'ultimate-post'),
2020 'default' => true,
2021 'docs' => 'https://docs.wpxpo.com/docs/postx/dynamic-site-builder/',
2022 'icon' => ULTP_URL.'/assets/img/blocks/archive-title.svg'
2023 ),
2024 'builder_author_box' => array(
2025 'label' => __('Post Author Box', 'ultimate-post'),
2026 'default' => true,
2027 'docs' => 'https://docs.wpxpo.com/docs/postx/dynamic-site-builder/',
2028 'icon' => ULTP_URL.'/assets/img/blocks/builder/author_box.svg'
2029 ),
2030 'builder_post_next_previous' => array(
2031 'label' => __('Post Next Previous', 'ultimate-post'),
2032 'default' => true,
2033 'docs' => 'https://docs.wpxpo.com/docs/postx/dynamic-site-builder/',
2034 'icon' => ULTP_URL.'/assets/img/blocks/builder/next_previous.svg'
2035 ),
2036 'builder_post_author_meta' => array(
2037 'label' => __('Post Author Meta', 'ultimate-post'),
2038 'default' => true,
2039 'docs' => 'https://docs.wpxpo.com/docs/postx/dynamic-site-builder/',
2040 'icon' => ULTP_URL.'/assets/img/blocks/builder/author.svg'
2041 ),
2042 'builder_post_breadcrumb' => array(
2043 'label' => __('Post Breadcrumb', 'ultimate-post'),
2044 'default' => true,
2045 'docs' => 'https://docs.wpxpo.com/docs/postx/dynamic-site-builder/',
2046 'icon' => ULTP_URL.'/assets/img/blocks/builder/breadcrumb.svg'
2047 ),
2048 'builder_post_category' => array(
2049 'label' => __('Post Category', 'ultimate-post'),
2050 'default' => true,
2051 'docs' => 'https://docs.wpxpo.com/docs/postx/dynamic-site-builder/',
2052 'icon' => ULTP_URL.'/assets/img/blocks/builder/category.svg'
2053 ),
2054 'builder_post_comment_count' => array(
2055 'label' => __('Post Comment Count', 'ultimate-post'),
2056 'default' => true,
2057 'docs' => 'https://docs.wpxpo.com/docs/postx/dynamic-site-builder/',
2058 'icon' => ULTP_URL.'/assets/img/blocks/builder/comment_count.svg'
2059 ),
2060 'builder_post_comments' => array(
2061 'label' => __('Post Comments', 'ultimate-post'),
2062 'default' => true,
2063 'docs' => 'https://docs.wpxpo.com/docs/postx/dynamic-site-builder/',
2064 'icon' => ULTP_URL.'/assets/img/blocks/builder/comments.svg'
2065 ),
2066 'builder_post_content' => array(
2067 'label' => __('Post Content', 'ultimate-post'),
2068 'default' => true,
2069 'docs' => 'https://docs.wpxpo.com/docs/postx/dynamic-site-builder/',
2070 'icon' => ULTP_URL.'/assets/img/blocks/builder/content.svg'
2071 ),
2072 'builder_post_date_meta' => array(
2073 'label' => __('Post Date Meta', 'ultimate-post'),
2074 'default' => true,
2075 'docs' => 'https://docs.wpxpo.com/docs/postx/dynamic-site-builder/',
2076 'icon' => ULTP_URL.'/assets/img/blocks/builder/post_date.svg'
2077 ),
2078 'builder_post_excerpt' => array(
2079 'label' => __('Post Excerpt', 'ultimate-post'),
2080 'default' => true,
2081 'docs' => 'https://docs.wpxpo.com/docs/postx/dynamic-site-builder/',
2082 'icon' => ULTP_URL.'/assets/img/blocks/builder/excerpt.svg'
2083 ),
2084 'builder_post_featured_image' => array(
2085 'label' => __('Post Featured Image/Video', 'ultimate-post'),
2086 'default' => true,
2087 'docs' => 'https://docs.wpxpo.com/docs/postx/dynamic-site-builder/',
2088 'icon' => ULTP_URL.'/assets/img/blocks/builder/featured_img.svg'
2089 ),
2090 'builder_post_reading_time' => array(
2091 'label' => __('Post Reading Time', 'ultimate-post'),
2092 'default' => true,
2093 'docs' => 'https://docs.wpxpo.com/docs/postx/dynamic-site-builder/',
2094 'icon' => ULTP_URL.'/assets/img/blocks/builder/reading_time.svg'
2095 ),
2096 'builder_post_social_share' => array(
2097 'label' => __('Post Social Share', 'ultimate-post'),
2098 'default' => true,
2099 'docs' => 'https://docs.wpxpo.com/docs/postx/dynamic-site-builder/',
2100 'icon' => ULTP_URL.'/assets/img/blocks/builder/share.svg'
2101 ),
2102 'builder_post_tag' => array(
2103 'label' => __('Post Tag', 'ultimate-post'),
2104 'default' => true,
2105 'docs' => 'https://docs.wpxpo.com/docs/postx/dynamic-site-builder/',
2106 'icon' => ULTP_URL.'/assets/img/blocks/builder/post_tag.svg'
2107 ),
2108 'builder_post_view_count' => array(
2109 'label' => __('Post View Count', 'ultimate-post'),
2110 'default' => true,
2111 'docs' => 'https://docs.wpxpo.com/docs/postx/dynamic-site-builder/',
2112 'icon' => ULTP_URL.'/assets/img/blocks/builder/view_count.svg'
2113 ),
2114 )
2115 )
2116 );
2117
2118 return $arr;
2119 }
2120 /**
2121 * Builder Conditions
2122 *
2123 * @since v.2.7.0
2124 * @param STRING | Type of Return
2125 * @return MIXED || ID or Path
2126 */
2127 public function conditions( $type = 'return' ) {
2128 $page_id = '';
2129
2130 $conditions = get_option('ultp_builder_conditions', array());
2131 if (isset($conditions['archive'])) {
2132 if (!empty($conditions['archive'])) {
2133 $is_search = is_search();
2134 $is_archive = is_archive();
2135 $taxonomy = (is_category() || is_tag() || is_tax()) ? get_queried_object() : (object)[];
2136
2137 if (is_archive()) {
2138 foreach ($conditions['archive'] as $key => $val) {
2139 if (in_array('include/archive', $val)) {
2140 if ('publish' == get_post_status($key)) {
2141 $page_id = $key;
2142 }
2143 }
2144 if (in_array('exclude/archive', $val)) {
2145 if ('publish' == get_post_status($key)) {
2146 $page_id = '';
2147 }
2148 }
2149 }
2150 if (is_category()) {
2151 foreach ($conditions['archive'] as $key => $val) {
2152 if (in_array('include/archive/category', $val)) {
2153 if ('publish' == get_post_status($key)) {
2154 $page_id = $key;
2155 }
2156 }
2157 if (in_array('exclude/archive/category', $val)) {
2158 if ('publish' == get_post_status($key)) {
2159 $page_id = '';
2160 }
2161 }
2162 if (in_array('include/archive/category/'.$taxonomy->term_id, $val)) {
2163 if ('publish' == get_post_status($key)) {
2164 $page_id = $key;
2165 }
2166 }
2167 if (in_array('exclude/archive/category/'.$taxonomy->term_id, $val)) {
2168 if ('publish' == get_post_status($key)) {
2169 $page_id = '';
2170 }
2171 }
2172 if ($this->in_string_part('any_child_of', $val)) {
2173 if (in_array('include/archive/any_child_of_category', $val)) {
2174 if ('publish' == get_post_status($key)) {
2175 $page_id = $key;
2176 }
2177 }
2178 if (in_array('exclude/archive/any_child_of_category', $val)) {
2179 if ('publish' == get_post_status($key)) {
2180 $page_id = '';
2181 }
2182 }
2183 foreach ($val as $v) {
2184 if (strpos($v, '/archive/any_child_of_category/') !== false) {
2185 if ($v) {
2186 $data = explode("/", $v);
2187 if (isset($data[3]) && $data[3]) {
2188 if (term_is_ancestor_of($data[3], $taxonomy->term_id, 'category')) {
2189 if ('publish' == get_post_status($key)) {
2190 $page_id = $data[0] == 'exclude' ? '' : $key;
2191 }
2192 }
2193 }
2194 }
2195 }
2196 }
2197 } else {
2198 if ($this->in_string_part('child_of', $val)) {
2199 if (in_array('include/archive/child_of_category', $val)) {
2200 if ('publish' == get_post_status($key)) {
2201 $page_id = $key;
2202 }
2203 }
2204 if (in_array('exclude/archive/child_of_category', $val)) {
2205 if ('publish' == get_post_status($key)) {
2206 $page_id = '';
2207 }
2208 }
2209 if (in_array('include/archive/child_of_category/'.$taxonomy->parent, $val)) {
2210 if ('publish' == get_post_status($key)) {
2211 $page_id = $key;
2212 }
2213 }
2214 if (in_array('exclude/archive/child_of_category/'.$taxonomy->parent, $val)) {
2215 if ('publish' == get_post_status($key)) {
2216 $page_id = '';
2217 }
2218 }
2219 }
2220 }
2221 }
2222 } else if (is_tag()) {
2223 foreach ($conditions['archive'] as $key => $val) {
2224 if (in_array('include/archive/post_tag', $val)) {
2225 if ('publish' == get_post_status($key)) {
2226 $page_id = $key;
2227 }
2228 }
2229 if (in_array('exclude/archive/post_tag', $val)) {
2230 if ('publish' == get_post_status($key)) {
2231 $page_id = '';
2232 }
2233 }
2234 if (in_array('include/archive/post_tag/'.$taxonomy->term_id, $val)) {
2235 if ('publish' == get_post_status($key)) {
2236 $page_id = $key;
2237 }
2238 }
2239 if (in_array('exclude/archive/post_tag/'.$taxonomy->term_id, $val)) {
2240 if ('publish' == get_post_status($key)) {
2241 $page_id = '';
2242 }
2243 }
2244 }
2245 } else if (is_tax()) {
2246 foreach ($conditions['archive'] as $key => $val) {
2247 if (in_array('include/archive/'.$taxonomy->taxonomy, $val)) {
2248 if ('publish' == get_post_status($key)) {
2249 $page_id = $key;
2250 }
2251 }
2252 if (in_array('exclude/archive/'.$taxonomy->taxonomy, $val)) {
2253 if ('publish' == get_post_status($key)) {
2254 $page_id = '';
2255 }
2256 }
2257 if (in_array('include/archive/'.$taxonomy->taxonomy.'/'.$taxonomy->term_id, $val)) {
2258 if ('publish' == get_post_status($key)) {
2259 $page_id = $key;
2260 }
2261 }
2262 if (in_array('exclude/archive/'.$taxonomy->taxonomy.'/'.$taxonomy->term_id, $val)) {
2263 if ('publish' == get_post_status($key)) {
2264 $page_id = '';
2265 }
2266 }
2267 if ($this->in_string_part('any_child_of', $val)) {
2268 if (in_array('include/archive/any_child_of_'.$taxonomy->taxonomy, $val)) {
2269 if ('publish' == get_post_status($key)) {
2270 $page_id = $key;
2271 }
2272 }
2273 if (in_array('exclude/archive/any_child_of_'.$taxonomy->taxonomy, $val)) {
2274 if ('publish' == get_post_status($key)) {
2275 $page_id = '';
2276 }
2277 }
2278 foreach ($val as $v) {
2279 if (strpos($v, '/archive/any_child_of_'.$taxonomy->taxonomy.'/') !== false) {
2280 if ($v) {
2281 $data = explode("/", $v);
2282 if (isset($data[3]) && $data[3]) {
2283 if (term_is_ancestor_of($data[3], $taxonomy->term_id, $taxonomy->taxonomy)) {
2284 if ('publish' == get_post_status($key)) {
2285 $page_id = $data[0] == 'exclude' ? '' : $key;
2286 }
2287 }
2288 }
2289 }
2290 }
2291 }
2292 } else {
2293 if ($this->in_string_part('child_of', $val)) {
2294 if (in_array('include/archive/child_of_'.$taxonomy->taxonomy, $val)) {
2295 if ('publish' == get_post_status($key)) {
2296 $page_id = $key;
2297 }
2298 }
2299 if (in_array('exclude/archive/child_of_'.$taxonomy->taxonomy, $val)) {
2300 if ('publish' == get_post_status($key)) {
2301 $page_id = '';
2302 }
2303 }
2304 if (in_array('include/archive/child_of_'.$taxonomy->taxonomy.'/'.$taxonomy->parent, $val)) {
2305 if ('publish' == get_post_status($key)) {
2306 $page_id = $key;
2307 }
2308 }
2309 if (in_array('exclude/archive/child_of_'.$taxonomy->taxonomy.'/'.$taxonomy->parent, $val)) {
2310 if ('publish' == get_post_status($key)) {
2311 $page_id = '';
2312 }
2313 }
2314 }
2315 }
2316 }
2317 } else if (is_date()) {
2318 foreach ($conditions['archive'] as $key => $val) {
2319 if (in_array('include/archive/date', $val)) {
2320 if ('publish' == get_post_status($key)) {
2321 $page_id = $key;
2322 }
2323 }
2324 if (in_array('exclude/archive/date', $val)) {
2325 if ('publish' == get_post_status($key)) {
2326 $page_id = '';
2327 }
2328 }
2329 }
2330 } else if (is_author()) {
2331 foreach ($conditions['archive'] as $key => $val) {
2332 if (in_array('include/archive/author', $val)) {
2333 if ('publish' == get_post_status($key)) {
2334 $page_id = $key;
2335 }
2336 }
2337 if (in_array('exclude/archive/author', $val)) {
2338 if ('publish' == get_post_status($key)) {
2339 $page_id = '';
2340 }
2341 }
2342 $author_id = get_the_author_meta('ID');
2343 if (in_array('include/archive/author/'.$author_id, $val)) {
2344 if ('publish' == get_post_status($key)) {
2345 $page_id = $key;
2346 }
2347 }
2348 if (in_array('exclude/archive/author/'.$author_id, $val)) {
2349 if ('publish' == get_post_status($key)) {
2350 $page_id = '';
2351 }
2352 }
2353 }
2354 }
2355 } else if (is_search()) {
2356 foreach ($conditions['archive'] as $key => $val) {
2357 if (in_array('include/archive/search', $val)) {
2358 if ('publish' == get_post_status($key)) {
2359 $page_id = $key;
2360 }
2361 }
2362 if (in_array('exclude/archive/search', $val)) {
2363 if ('publish' == get_post_status($key)) {
2364 $page_id = '';
2365 }
2366 }
2367 }
2368 }
2369 }
2370 }
2371 // Singular
2372 if (isset($conditions['singular'])) {
2373 if (!empty($conditions['singular']) && ( is_singular() || is_front_page() || is_home() ) ) {
2374 $obj = get_queried_object();
2375 $tax_list = $this->get_taxonomy_list();
2376 foreach ($conditions['singular'] as $key => $val) {
2377 if (get_post_status($key)) {
2378 // Front Page
2379 if ((is_front_page() && is_home())
2380 || (is_home() && !is_object($obj))
2381 || (is_singular() && is_front_page() && is_object($obj))) {
2382 if (in_array('include/singular/front_page', $val)) {
2383 if ('publish' == get_post_status($key)) {
2384 $page_id = $key;
2385 }
2386 }
2387 if (in_array('exclude/singular/front_page', $val)) {
2388 if ('publish' == get_post_status($key)) {
2389 $page_id = '';
2390 }
2391 }
2392 }
2393 // Author check
2394 if (in_array('singular/post_by_author', $val)) {
2395 if (in_array('include/singular/post_by_author', $val)) {
2396 if ('publish' == get_post_status($key)) {
2397 $page_id = $key;
2398 }
2399 }
2400 if (in_array('exclude/singular/post_by_author', $val)) {
2401 if ('publish' == get_post_status($key)) {
2402 $page_id = '';
2403 }
2404 }
2405 if (in_array('include/singular/post_by_author/'.$obj->post_author, $val)) {
2406 if ('publish' == get_post_status($key)) {
2407 $page_id = $key;
2408 }
2409 }
2410 if (in_array('exclude/singular/post_by_author/'.$obj->post_author, $val)) {
2411 if ('publish' == get_post_status($key)) {
2412 $page_id = '';
2413 }
2414 }
2415 }
2416 // All Taxonomy
2417 if($this->in_string_part('/singular/in_', $val)) {
2418 foreach ($tax_list as $tax) {
2419 if ($this->in_string_part('singular/in_'.$tax.'_children', $val)) {
2420 // In Taxonomy Children
2421 if (in_array('include/singular/in_'.$tax.'_children', $val)) {
2422 if ('publish' == get_post_status($key)) {
2423 $page_id = $key;
2424 }
2425 }
2426 if (in_array('exclude/singular/in_'.$tax.'_children', $val)) {
2427 if ('publish' == get_post_status($key)) {
2428 $page_id = '';
2429 }
2430 }
2431 if (is_object($obj)) {
2432 foreach ($val as $v) {
2433 if (strpos($v, '/singular/in_'.$tax.'_children/') !== false) {
2434 if ($v) {
2435 $data = explode("/", $v);
2436 if (isset($data[3]) && $data[3]) {
2437 if (is_object_in_term($obj->ID , $tax, $data[3] )) {
2438 if ('publish' == get_post_status($key)) {
2439 $page_id = $data[0] == 'exclude' ? '' : $key;
2440 }
2441 }
2442 }
2443 }
2444 }
2445 }
2446 }
2447 } else {
2448 // IN Taxonomy
2449 if (in_array('include/singular/in_'.$tax, $val)) {
2450 if ('publish' == get_post_status($key)) {
2451 $page_id = $key;
2452 }
2453 }
2454 if (in_array('exclude/singular/in_'.$tax, $val)) {
2455 if ('publish' == get_post_status($key)) {
2456 $page_id = '';
2457 }
2458 }
2459 if (is_object($obj)) {
2460 foreach ($val as $v) {
2461 if (strpos($v, '/singular/in_'.$tax.'/') !== false) {
2462 if ($v) {
2463 $data = explode("/", $v);
2464 if (isset($data[3]) && $data[3]) {
2465 if (is_object_in_term($obj->ID , $tax, $data[3] )) {
2466 if ('publish' == get_post_status($key)) {
2467 $page_id = $data[0] == 'exclude' ? '' : $key;
2468 }
2469 }
2470 }
2471 }
2472 }
2473 }
2474 }
2475 }
2476 }
2477 }
2478 if (is_object($obj)) {
2479 // All Post Type
2480 if (in_array('include/singular/'.$obj->post_type, $val)) {
2481 if ('publish' == get_post_status($key)) {
2482 $page_id = $key;
2483 }
2484 }
2485 if (in_array('exclude/singular/'.$obj->post_type, $val)) {
2486 if ('publish' == get_post_status($key)) {
2487 $page_id = '';
2488 }
2489 }
2490 if ($this->in_string_part('include/singular/'.$obj->post_type.'/'.$obj->ID, $val)) {
2491 if ('publish' == get_post_status($key)) {
2492 $page_id = $key;
2493 }
2494 }
2495 if ($this->in_string_part('exclude/singular/'.$obj->post_type.'/'.$obj->ID, $val)) {
2496 if ('publish' == get_post_status($key)) {
2497 $page_id = '';
2498 }
2499 }
2500 }
2501 }
2502 }
2503 }
2504 }
2505
2506 if ($type == 'return') {
2507 return $page_id;
2508 }
2509 if ($type == 'includes') {
2510 return $page_id ? ULTP_PATH.'addons/builder/Archive_Template.php' : '';
2511 }
2512 }
2513
2514
2515 /**
2516 * Get Add Default Condition Data
2517 *
2518 * @since v.2.7.0
2519 * @return ARRAY | Default Data
2520 */
2521 public function builder_data() {
2522 $archive_data = [
2523 [
2524 'label' => 'All Archive',
2525 'value' => '',
2526 ],
2527 [
2528 'label' => 'Author Archive',
2529 'value' => 'author',
2530 'search' => 'author###'
2531 ],
2532 [
2533 'label' => 'Date Archive',
2534 'value' => 'date',
2535 ],
2536 [
2537 'label' => 'Search Results',
2538 'value' => 'search',
2539 ],
2540 ];
2541 $single_data = [
2542 [
2543 'label' => 'Front Page',
2544 'value' => 'front_page',
2545 ]
2546 ];
2547
2548 $post_type = get_post_types( ['public' => true], 'objects' );
2549 foreach ($post_type as $key => $type) {
2550 // Post Type
2551 $single_temp = [
2552 'label' => $type->label,
2553 'value' => $type->name,
2554 'search' => 'type###'.$type->name
2555 ];
2556 $archive_temp = [];
2557
2558 // Taxonomy
2559 $taxonomy = get_object_taxonomies( $type->name, 'objects' );
2560 if (!empty($taxonomy)) {
2561 $single_tax = $archive_tax = [];
2562 $single_tax[] = $single_temp;
2563
2564 $archive_temp = [
2565 'label' => $type->label . ' Archive',
2566 'value' => $type->name . '_archive',
2567 ];
2568 // $archive_tax[] = $archive_temp;
2569 foreach ($taxonomy as $key => $val) {
2570 if ($val->public) {
2571 $single_tax[] = [
2572 'label' => 'In ' . $val->label,
2573 'value' => 'in_' . $val->name,
2574 'search' => 'term###'.$val->name
2575 ];
2576 $archive_tax[] = [
2577 'label' => $val->label,
2578 'value' => $val->name,
2579 'search' => 'term###'.$val->name
2580 ];
2581
2582 if ($val->hierarchical) {
2583 // Hierarchical
2584 $single_tax[] = [
2585 'label' => 'In Child ' . $val->label,
2586 'value' => 'in_' . $val->name . '_children',
2587 'search' => 'term###'.$val->name
2588 ];
2589 $archive_tax[] = [
2590 'label' => 'Direct Child ' . $val->label . ' Of',
2591 'value' => 'child_of_' . $val->name,
2592 'search' => 'term###'.$val->name
2593 ];
2594 $archive_tax[] = [
2595 'label' => 'Any Child ' . $val->label . ' Of',
2596 'value' => 'any_child_of_' . $val->name,
2597 'search' => 'term###'.$val->name
2598 ];
2599 }
2600 }
2601 }
2602 // Author
2603 $single_tax[] = [
2604 'label' => 'Posts By Author',
2605 'value' => 'post_by_author',
2606 'search' => 'author###'
2607 ];
2608 $single_temp['attr'] = $single_tax;
2609 $archive_temp['attr'] = $archive_tax;
2610 }
2611 $single_data[] = $single_temp;
2612 if (!empty($archive_temp)) {
2613 $archive_data[] = $archive_temp;
2614 }
2615 }
2616
2617 return ['singular' => $single_data, 'archive' => $archive_data];
2618 }
2619
2620 /**
2621 * Get Date Default Format
2622 *
2623 * @since v.2.7.2
2624 * @return ARRAY | Default Data
2625 */
2626 public function get_format($format) {
2627 if ($format == 'default_date') {
2628 return $this->get_setting('date_format');
2629 } else if ($format == 'default_date_time') {
2630 return $this->get_setting('date_format').' '.$this->get_setting('time_format');
2631 } else {
2632 return $format;
2633 }
2634 }
2635
2636 public function pro_popup_html() { ?>
2637 <div class="ultp-popup-container popup-center">
2638 <div class="ultp-unlock-popup ultp-unlock-modal">
2639 <img src="<?php echo esc_url(ULTP_URL . '/assets/img/dashboard/unlock_super_icon.svg'); ?>" alt="lock icon">
2640 <h4 class="ultp-md-heading ultp-mt25 ultp-mb25"><?php esc_html_e('Unlock 11+ Addons', 'ultimate-post'); ?></h4>
2641 <div class="ultp-popup-desc">
2642 <?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'); ?>
2643 </div>
2644 <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>
2645 <button class="ultp-popup-close"></button>
2646 </div>
2647 </div>
2648 <?php }
2649
2650 /**
2651 * Common Frontend and Backend CSS and JS Scripts
2652 *
2653 * @since v.1.0.0
2654 * @return NULL
2655 */
2656 public function register_scripts_common() {
2657 wp_enqueue_style('ultp-style', ULTP_URL.'assets/css/style.min.css', array(), ULTP_VER );
2658 wp_enqueue_script('ultp-script', ULTP_URL.'assets/js/ultp.min.js', array('jquery'), ULTP_VER, true);
2659 wp_localize_script('ultp-script', 'ultp_data_frontend', array(
2660 'url' => ULTP_URL,
2661 'ajax' => admin_url('admin-ajax.php'),
2662 'security' => wp_create_nonce('ultp-nonce')
2663 ));
2664 }
2665
2666 /**
2667 * Get Page Post Id ( Kadence elemwnt )
2668 *
2669 * @since v.2.8.9
2670 * @return NULL
2671 */
2672 public function get_page_post_id($page_post_id, $blockId) {
2673 global $wpdb;
2674 $post_meta = $wpdb->get_row($wpdb->prepare("SELECT * FROM " . $wpdb->prefix . "postmeta WHERE meta_value LIKE %s", '%.ultp-block-'.$blockId.'%'));
2675 if($post_meta && isset($post_meta->post_id) && $post_meta->post_id != $page_post_id) {
2676 return $post_meta->post_id;
2677 }
2678 return $page_post_id;
2679 }
2680
2681 /**
2682 * Get Notice Data
2683 *
2684 * @since v.2.9.0
2685 * @return NULL
2686 */
2687 public function get_notice_data($type = 'banner') {
2688 if ($type == 'banner') {
2689 return array(
2690 array(
2691 'start' => '16-04-2023',
2692 'end' => '28-04-2023',
2693 'type' => 'content',
2694 '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>",
2695 'force' => true
2696 ),
2697 array(
2698 'start' => '12-2-2023', // Date format "d-m-Y" [08-02-2019]
2699 'end' => '18-2-2023',
2700 'type' => 'banner',
2701 'content' => ULTP_URL.'assets/img/banner.jpg',
2702 'force' => true
2703 ),
2704 // array(
2705 // 'start' => '17-4-2023', // Date format "d-m-Y" [08-02-2019]
2706 // 'end' => '27-4-2023',
2707 // 'type' => 'banner',
2708 // 'content' => ULTP_URL.'assets/img/eid-banner.jpg',
2709 // 'force' => true
2710 // )
2711 );
2712 } else {
2713 return array(
2714 // 'start' => '12-2-2023', // Date format "d-m-Y" [08-02-2019]
2715 // 'end' => '22-3-2023',
2716 // 'content' => 'Upgrade 30% off Sale!!!'
2717 );
2718 }
2719 }
2720 /**
2721 * Get no Result found html
2722 *
2723 * @since v.2.9.0
2724 * @param STRING | No result found text
2725 * @return STRING | Taxonomy Lists as array
2726 */
2727 public function get_no_result_found_html($text) {
2728 return $text ? '<div class="ultp-not-found-message" role="alert">'.$text.'</div>' : '';
2729 }
2730
2731 }
2732