PluginProbe
Post Grid Gutenberg Blocks – PostX / 2.6.3
Post Grid Gutenberg Blocks – PostX v2.6.3
5.0.39 5.0.38 5.0.37 5.0.36 5.0.35 5.0.34 5.0.33 5.0.32 5.0.31 5.0.30 5.0.29 5.0.28 5.0.27 5.0.26 5.0.25 5.0.23 5.0.24 5.0.22 5.0.21 5.0.20 5.0.19 5.0.18 5.0.17 2.1.1 2.1.2 All 237 releases
ultimate-post / classes / Functions.php

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

1,322 lines 51.2 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 }
27 }
28
29 /**
30 * ID for the Builder Post or Normal Post
31 *
32 * @since v.2.3.1
33 * @return NUMBER | is Builder or not
34 */
35 public function get_ID() {
36 $id = $this->is_builder();
37 return $id ? $id : (function_exists('is_shop') ? (is_shop() ? wc_get_page_id('shop') : get_the_ID()) : get_the_ID() );
38 }
39
40 /**
41 * Checking Statement of Archive Builder
42 *
43 * @since v.2.3.1
44 * @return BOOLEAN | is Builder or not
45 */
46 public function is_archive_builder() {
47 return get_post_type( get_the_ID() ) == 'ultp_builder' ? true : false;
48 }
49
50
51 /**
52 * Set Link with the Parameters
53 *
54 * @since v.1.1.0
55 * @return STRING | URL with Arg
56 */
57 public function get_premium_link( $url = '', $tag = 'go_premium' ) {
58 $url = $url ? $url : 'https://www.wpxpo.com/postx/pricing/';
59 $affiliate_id = apply_filters( 'ultp_affiliate_id', FALSE );
60 $arg = array( 'utm_source' => $tag );
61 if ( ! empty( $affiliate_id ) ) {
62 $arg[ 'ref' ] = esc_attr( $affiliate_id );
63 }
64 return add_query_arg( $arg, $url );
65 }
66
67
68 /**
69 * Get Width and Height of the Image
70 *
71 * @since v.1.1.0
72 * @return STRING | Image Size
73 */
74 public function get_size($name = ''){
75 global $_wp_additional_image_sizes;
76 $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];
77
78 return ' width="'.$image_size['width'].'" height="'.$image_size['height'].'" ';
79 }
80
81
82 /**
83 * Image Placeholder
84 *
85 * @since v.1.1.0
86 * @return STRING | Image Placeholder
87 */
88 public function img_placeholder($type = 'small') {
89 switch ($type) {
90 case 'small':
91 return 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAG4AAABLAQMAAACr9CA9AAAAA1BMVEX///+nxBvIAAAAAXRSTlMAQObYZgAAABZJREFUOI1jYMADmEe5o9xR7iiXQi4A4BsA388WUyMAAAAASUVORK5CYII=';
92 break;
93
94 case 'wide':
95 return 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAKCAYAAADVTVykAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAB9JREFUeNpi/P//P8NAAiaGAQajDhh1wKgDRh0AEGAAQTcDEcKDrpMAAAAASUVORK5CYII=';
96 break;
97
98 case 'square':
99 return 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABAQMAAAAl21bKAAAAA1BMVEX///+nxBvIAAAAAXRSTlMAQObYZgAAAApJREFUCJljYAAAAAIAAfRxZKYAAAAASUVORK5CYII=';
100 break;
101
102 case 'slider':
103 return 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAKYAAABkCAMAAAA7drv6AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAAZQTFRF////AAAAVcLTfgAAAAF0Uk5TAEDm2GYAAAAqSURBVHja7MEBDQAAAMKg909tDjegAAAAAAAAAAAAAAAAAAAAAH5NgAEAQTwAAWZtItYAAAAASUVORK5CYII=';
104 break;
105
106 default:
107 return 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAYYAAADcAQMAAABOLJSDAAAAA1BMVEUAAACnej3aAAAAAXRSTlMAQObYZgAAACJJREFUaIHtwTEBAAAAwqD1T20ND6AAAAAAAAAAAAAA4N8AKvgAAUFIrrEAAAAASUVORK5CYII=';
108 break;
109 }
110 }
111
112
113 /**
114 * Quick Query
115 *
116 * @since v.1.1.0
117 * @return ARRAY | Query Arg
118 */
119 public function get_quick_query($prams, $args) {
120 switch ($prams['queryQuick']) {
121 case 'related_posts':
122 global $post;
123 if (isset($post->ID)) {
124 $args['post__not_in'] = array($post->ID);
125 }
126 break;
127 case 'related_tag':
128 global $post;
129 if (isset($post->ID)) {
130 $args['tax_query'] = array(
131 array(
132 'taxonomy' => 'post_tag',
133 'terms' => $this->get_terms_id($post->ID, 'post_tag'),
134 'field' => 'term_id',
135 )
136 );
137 $args['post__not_in'] = array($post->ID);
138 }
139 break;
140 case 'related_category':
141 global $post;
142 if (isset($post->ID)) {
143 $args['tax_query'] = array(
144 array(
145 'taxonomy' => 'category',
146 'terms' => $this->get_terms_id($post->ID, 'category'),
147 'field' => 'term_id',
148 )
149 );
150 $args['post__not_in'] = array($post->ID);
151 }
152 break;
153 case 'related_cat_tag':
154 global $post;
155 if (isset($post->ID)) {
156 $args['tax_query'] = array(
157 array(
158 'taxonomy' => 'post_tag',
159 'terms' => $this->get_terms_id($post->ID, 'post_tag'),
160 'field' => 'term_id',
161 ),
162 array(
163 'taxonomy' => 'category',
164 'terms' => $this->get_terms_id($post->ID, 'category'),
165 'field' => 'term_id',
166 )
167 );
168 $args['post__not_in'] = array($post->ID);
169 }
170 break;
171 case 'sticky_posts':
172 $sticky = get_option('sticky_posts');
173 if (is_array($sticky)) {
174 rsort($sticky);
175 $sticky = array_slice($sticky, 0, $args['posts_per_page']);
176 }
177 $args['ignore_sticky_posts'] = 1;
178 $args['post__in'] = $sticky;
179 break;
180 case 'latest_post_published':
181 $args['orderby'] = 'date';
182 $args['order'] = 'DESC';
183 $args['ignore_sticky_posts'] = 1;
184 break;
185 case 'latest_post_modified':
186 $args['orderby'] = 'modified';
187 $args['order'] = 'DESC';
188 $args['ignore_sticky_posts'] = 1;
189 break;
190 case 'oldest_post_published':
191 $args['orderby'] = 'date';
192 $args['order'] = 'ASC';
193 break;
194 case 'oldest_post_modified':
195 $args['orderby'] = 'modified';
196 $args['order'] = 'ASC';
197 break;
198 case 'alphabet_asc':
199 $args['orderby'] = 'title';
200 $args['order'] = 'ASC';
201 break;
202 case 'alphabet_desc':
203 $args['orderby'] = 'title';
204 $args['order'] = 'DESC';
205 break;
206 case 'random_post':
207 $args['orderby'] = 'rand';
208 $args['order'] = 'ASC';
209 break;
210 case 'random_post_7_days':
211 $args['orderby'] = 'rand';
212 $args['order'] = 'ASC';
213 $args['date_query'] = array( array( 'after' => '1 week ago') );
214 break;
215 case 'random_post_30_days':
216 $args['orderby'] = 'rand';
217 $args['order'] = 'ASC';
218 $args['date_query'] = array( array( 'after' => '1 month ago') );
219 break;
220 case 'most_comment':
221 $args['orderby'] = 'comment_count';
222 $args['order'] = 'DESC';
223 break;
224 case 'most_comment_1_day':
225 $args['orderby'] = 'comment_count';
226 $args['order'] = 'DESC';
227 $args['date_query'] = array( array( 'after' => '1 day ago') );
228 break;
229 case 'most_comment_7_days':
230 $args['orderby'] = 'comment_count';
231 $args['order'] = 'DESC';
232 $args['date_query'] = array( array( 'after' => '1 week ago') );
233 break;
234 case 'most_comment_30_days':
235 $args['orderby'] = 'comment_count';
236 $args['order'] = 'DESC';
237 $args['date_query'] = array( array( 'after' => '1 month ago') );
238 break;
239 case 'popular_post_1_day_view':
240 $args['meta_key'] = '__post_views_count';
241 $args['orderby'] = 'meta_value meta_value_num';
242 $args['order'] = 'DESC';
243 $args['date_query'] = array( array( 'after' => '1 day ago') );
244 break;
245 case 'popular_post_7_days_view':
246 $args['meta_key'] = '__post_views_count';
247 $args['orderby'] = 'meta_value meta_value_num';
248 $args['order'] = 'DESC';
249 $args['date_query'] = array( array( 'after' => '1 week ago') );
250 break;
251 case 'popular_post_30_days_view':
252 $args['meta_key'] = '__post_views_count';
253 $args['orderby'] = 'meta_value meta_value_num';
254 $args['order'] = 'DESC';
255 $args['date_query'] = array( array( 'after' => '1 month ago') );
256 break;
257 case 'popular_post_all_times_view':
258 $args['meta_key'] = '__post_views_count';
259 $args['orderby'] = 'meta_value meta_value_num';
260 $args['order'] = 'DESC';
261 break;
262 default:
263 # code...
264 break;
265 }
266 return $args;
267 }
268
269 /**
270 * Get All Term ID as Array
271 *
272 * @since v.2.4.12
273 * @return ARRAY | Query Arg
274 */
275 public function get_terms_id($id, $type) {
276 $data = array();
277 $arr = get_the_terms($id, $type);
278 if (is_array($arr)) {
279 foreach ($arr as $key => $val) {
280 $data[] = $val->term_id;
281 }
282 }
283 return $data;
284 }
285
286 /**
287 * Get All Reusable ID
288 *
289 * @since v.1.1.0
290 * @return ARRAY | Query Arg
291 */
292 public function reusable_id($post_id){
293 $reusable_id = array();
294 if($post_id){
295 $post = get_post($post_id);
296 if (has_blocks($post->post_content)) {
297 $blocks = parse_blocks($post->post_content);
298 foreach ($blocks as $key => $value) {
299 if(isset($value['attrs']['ref'])) {
300 $reusable_id[] = $value['attrs']['ref'];
301 }
302 }
303 }
304 }
305 return $reusable_id;
306 }
307
308
309 /**
310 * Set CSS Style
311 *
312 * @since v.1.1.0
313 * @return ARRAY | Query Arg
314 */
315 public function set_css_style($post_id, $shortcode = false){
316 if( $post_id ){
317 $upload_dir_url = wp_get_upload_dir();
318 $upload_css_dir_url = trailingslashit( $upload_dir_url['basedir'] );
319 $css_dir_path = $upload_css_dir_url . "ultimate-post/ultp-css-{$post_id}.css";
320
321 $css_dir_url = trailingslashit( $upload_dir_url['baseurl'] );
322 if (is_ssl()) {
323 $css_dir_url = str_replace('http://', 'https://', $css_dir_url);
324 }
325
326 // Reusable CSS
327 $reusable_id = ultimate_post()->reusable_id($post_id);
328 foreach ( $reusable_id as $id ) {
329 $reusable_dir_path = $upload_css_dir_url."ultimate-post/ultp-css-{$id}.css";
330 if (file_exists( $reusable_dir_path )) {
331 $css_url = $css_dir_url . "ultimate-post/ultp-css-{$id}.css";
332 wp_enqueue_style( "ultp-post-{$id}", $css_url, array(), ultimate_post()->get_setting('save_version'), 'all' );
333 }else{
334 $css = get_post_meta($id, '_ultp_css', true);
335 if( $css ) {
336 wp_enqueue_style("ultp-post-{$id}", $css, false, ultimate_post()->get_setting('save_version'));
337 }
338 }
339 }
340
341 if (isset($_GET['et_fb']) || (isset($_GET['action']) && sanitize_key($_GET['action']) == 'elementor') || $shortcode) {
342 return ultimate_post()->set_inline(get_post_meta($post_id, '_ultp_css', true));
343 } else {
344 if ( file_exists( $css_dir_path ) ) {
345 $css_url = $css_dir_url . "ultimate-post/ultp-css-{$post_id}.css";
346 wp_enqueue_style( "ultp-post-{$post_id}", $css_url, array(), ultimate_post()->get_setting('save_version'), 'all' );
347 } else {
348 $css = get_post_meta($post_id, '_ultp_css', true);
349 if( $css ) {
350 wp_enqueue_style("ultp-post-{$post_id}", $css, false, ultimate_post()->get_setting('save_version'));
351 }
352 }
353 }
354 }
355 }
356
357
358 /**
359 * Get Global Plugin Settings
360 *
361 * @since v.1.0.0
362 * @param STRING | Key of the Option
363 * @return ARRAY | STRING
364 */
365 public function get_setting($key = ''){
366 $data = $GLOBALS['ultp_settings'];
367 if ($key != '') {
368 return isset($data[$key]) ? $data[$key] : '';
369 } else {
370 return $data;
371 }
372 }
373
374
375 /**
376 * Set Option Settings
377 *
378 * @since v.1.0.0
379 * @param STRING | Key of the Option (STRING), Value (STRING)
380 * @return NULL
381 */
382 public function set_setting($key = '', $val = '') {
383 if($key != ''){
384 $data = $GLOBALS['ultp_settings'];
385 $data[$key] = $val;
386 update_option('ultp_options', $data);
387 $GLOBALS['ultp_settings'] = $data;
388 }
389 }
390
391
392 /**
393 * Get Image HTML
394 *
395 * @since v.1.0.0
396 * @param | URL (STRING) | size (STRING) | class (STRING) | alt (STRING)
397 * @return STRING
398 */
399 public function get_image_html($url = '', $size = 'full', $class = '', $alt = '', $lazy = ''){
400 $alt = $alt ? ' alt="'.$alt.'" ' : '';
401 $lazy_data = $lazy ? ' loading="lazy"' : '';
402 $class = $class ? ' class="'.$class.'" ' : '';
403 return '<img '.$lazy_data.$class.$alt.' src="'.$url.'" />';
404 }
405
406
407 /**
408 * Get Image HTML
409 *
410 * @since v.1.0.0
411 * @param | Attach ID (STRING) | size (STRING) | class (STRING) | alt (STRING)
412 * @return STRING
413 */
414 public function get_image($attach_id, $size = 'full', $class = '', $alt = '', $srcset = '', $lazy = ''){
415 $alt = $alt ? ' alt="'.$alt.'" ' : '';
416 $class = $class ? ' class="'.$class.'" ' : '';
417 $size = ( ultimate_post()->get_setting('disable_image_size') == 'yes' && strpos($size, 'ultp_layout_') !== false ) ? 'full' : $size;
418 $lazy_data = $lazy ? ' loading="lazy"' : '';
419 $srcset_data = $srcset ? ' srcset="'.esc_attr(wp_get_attachment_image_srcset($attach_id)).'"' : '';
420 return '<img '.$srcset_data.$lazy_data.$class.$alt.' src="'.wp_get_attachment_image_url( $attach_id, $size ).'" />';
421 }
422
423
424 /**
425 * Setup Initial Data Set
426 *
427 * @since v.1.0.0
428 * @return NULL
429 */
430 public function init_set_data(){
431 $data = get_option( 'ultp_options', array() );
432 $init_data = array(
433 'css_save_as' => 'wp_head',
434 'preloader_style' => 'style1',
435 'preloader_color' => '#037fff',
436 'container_width' => '1140',
437 'hide_import_btn' => '',
438 'disable_image_size'=> '',
439 'disable_view_cookies' => '',
440 'ultp_templates' => 'true',
441 'ultp_elementor' => 'true',
442 'ultp_table_of_content'=> 'true',
443 'post_grid_1' => 'yes',
444 'post_grid_2' => 'yes',
445 'post_grid_3' => 'yes',
446 'post_grid_4' => 'yes',
447 'post_grid_5' => 'yes',
448 'post_grid_6' => 'yes',
449 'post_grid_7' => 'yes',
450 'post_list_1' => 'yes',
451 'post_list_2' => 'yes',
452 'post_list_3' => 'yes',
453 'post_list_4' => 'yes',
454 'post_module_1' => 'yes',
455 'post_module_2' => 'yes',
456 'post_slider_1' => 'yes',
457 'heading' => 'yes',
458 'image' => 'yes',
459 'taxonomy' => 'yes',
460 'wrapper' => 'yes',
461 'news_ticker' => 'yes',
462 'archive_title' => 'yes',
463 'save_version' => rand(1, 1000)
464 );
465 if (empty($data)) {
466 update_option('ultp_options', $init_data);
467 $GLOBALS['ultp_settings'] = $init_data;
468 } else {
469 foreach ($init_data as $key => $single) {
470 if (!isset($data[$key])) {
471 $data[$key] = $single;
472 }
473 }
474 update_option('ultp_options', $data);
475 $GLOBALS['ultp_settings'] = $data;
476 }
477 }
478
479
480 /**
481 * Get Excerpt Text
482 *
483 * @since v.1.0.0
484 * @param | Post ID (STRING) | Limit (NUMBER)
485 * @return STRING
486 */
487 public function excerpt( $post_id, $limit = 55 ) {
488 return apply_filters( 'the_excerpt', wp_trim_words( get_the_content( $post_id ) , $limit ) );
489 }
490
491 public function get_builder_attr() {
492 $builder_data = '';
493 if (is_archive()) {
494 if (is_date()) {
495 if ( is_year() ) {
496 $builder_data = 'date###'.get_the_date('Y');
497 } else if ( is_month() ) {
498 $builder_data = 'date###'.get_the_date('Y-n');
499 } else if ( is_day() ) {
500 $builder_data = 'date###'.get_the_date('Y-n-j');
501 }
502 } else if (is_author()) {
503 $builder_data = 'author###'.get_the_author_meta('ID');
504 } else {
505 $obj = get_queried_object();
506 if (isset($obj->taxonomy)) {
507 $builder_data = 'taxonomy###'.$obj->taxonomy.'###'.$obj->slug;
508 }
509 }
510 } else if (is_search()) {
511 $builder_data = 'search###'.get_search_query(true);
512 }
513 return $builder_data ? 'data-builder="'.$builder_data.'"' : '';
514 }
515
516
517 public function is_builder($builder = '') {
518 $id = '';
519 if (function_exists('ultimate_post_pro')) {
520 if ($builder) {
521 return true;
522 }
523 $page_id = ultimate_post_pro()->conditions('return');
524 if ($page_id && ultimate_post()->get_setting('ultp_builder')) {
525 $id = $page_id;
526 }
527 }
528 return $id;
529 }
530
531
532 /**
533 * Get Post Number Depending On Device
534 *
535 * @since v.2.5.4
536 * @param MULTIPLE | Attribute of Posts
537 * @return STRING
538 */
539 public function get_post_number($preDef, $prev, $current) {
540
541 $current = is_object($current)?json_decode(json_encode($current), true):$current;
542 if (['lg'=>$preDef,'sm'=>$preDef,'xs'=>$preDef] == $current) {
543 if ($preDef != $prev) {
544 return $prev;
545 }
546 }
547 if ($this->isDevice() == 'mobile') {
548 return $current['xs'];
549 } else if ($this->isDevice() == 'tablet') {
550 return $current['sm'];
551 } else {
552 return $current['lg'];
553 }
554 }
555
556
557 /**
558 * Get Post Number Depending On Device
559 *
560 * @since v.2.5.4
561 * @param NULL
562 * @return STRING | Device Type
563 */
564 public function isDevice(){
565 $useragent = isset($_SERVER['HTTP_USER_AGENT']) ? sanitize_key($_SERVER['HTTP_USER_AGENT']) : '';
566 if ($useragent) {
567 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))) {
568 return 'mobile';
569 } else if (preg_match('/(tablet|ipad|playbook)|(android(?!.*(mobi|opera mini)))/i', strtolower($useragent))) {
570 return 'tablet';
571 } else {
572 return 'desktop';
573 }
574 }
575 return 'desktop';
576 }
577
578
579 /**
580 * Get Raw Value from Objects
581 *
582 * @since v.2.5.3
583 * @param NULL
584 * @return STRING | Device Type
585 */
586 public function get_value($attr) {
587 $data = [];
588 if (is_array($attr)) {
589 foreach ($attr as $val) {
590 $data[] = $val->value;
591 }
592 }
593 return $data;
594 }
595
596
597 /**
598 * Query Builder
599 *
600 * @since v.1.0.0
601 * @param ARRAY | Attribute of the Query
602 * @return ARRAY
603 */
604 public function get_query($attr) {
605 $builder = isset($attr['builder']) ? $attr['builder'] : '';
606 if ($this->is_builder($builder)) {
607 $archive_query = array();
608 if ($builder) {
609 $str = explode('###', $builder);
610 if (isset($str[0])) {
611 if ($str[0] == 'taxonomy') {
612 if (isset($str[1]) && isset($str[2])) {
613 $archive_query['tax_query'] = array(
614 array(
615 'taxonomy' => $str[1],
616 'field' => 'slug',
617 'terms' => $str[2]
618 )
619 );
620 }
621 } else if ($str[0] == 'author') {
622 if (isset($str[1])) {
623 $archive_query['author'] = $str[1];
624 }
625 } else if ($str[0] == 'search') {
626 if (isset($str[1])) {
627 $archive_query['s'] = $str[1];
628 }
629 } else if ($str[0] == 'date') {
630 if (isset($str[1])) {
631 $all_date = explode('-', $str[1]);
632 if (!empty($all_date)) {
633 $arg = array();
634 if (isset($all_date[0])) { $arg['year'] = $all_date[0]; }
635 if (isset($all_date[1])) { $arg['month'] = $all_date[1]; }
636 if (isset($all_date[2])) { $arg['day'] = $all_date[2]; }
637 $archive_query['date_query'][] = $arg;
638 }
639 }
640 }
641 }
642 } else {
643 global $wp_query;
644 $archive_query = $wp_query->query_vars;
645
646 }
647 $archive_query['posts_per_page'] = isset($attr['queryNumber']) ? $attr['queryNumber'] : 3;
648 $archive_query['paged'] = isset($attr['paged']) ? $attr['paged'] : 1;
649 if (isset($attr['queryOffset']) && $attr['queryOffset'] ) {
650 $offset = $this->get_offset($attr['queryOffset'], $archive_query);
651 $archive_query = array_merge($archive_query, $offset);
652 }
653
654 // Include Remove from Version 2.5.4
655 if (isset($attr['queryInclude']) && $attr['queryInclude']) {
656 $_include = explode(',', $attr['queryInclude']);
657 if (is_array($_include) && count($_include)) {
658 $archive_query['post__in'] = isset($archive_query['post__in']) ? array_merge($archive_query['post__in'], $_include) : $_include;
659 $archive_query['ignore_sticky_posts'] = 1;
660 $archive_query['orderby'] = 'post__in';
661 }
662 }
663
664 if (isset($attr['queryExclude']) && $attr['queryExclude']) {
665 $_exclude = (substr($attr['queryExclude'], 0, 1) === "[") ? $this->get_value(json_decode($attr['queryExclude'])) : explode(',', $attr['queryExclude']);
666 if (is_array($_exclude) && count($_exclude)) {
667 $archive_query['post__not_in'] = isset($query_args['post__not_in']) ? array_merge($query_args['post__not_in'], $_exclude) : $_exclude;
668 }
669 }
670
671
672 if(isset($attr['querySticky']) && $attr['querySticky']) {
673 if (filter_var($attr['querySticky'], FILTER_VALIDATE_BOOLEAN)) {
674 $sticky = get_option( 'sticky_posts', [] );
675 $query_args['post__not_in'] = isset($query_args['post__not_in']) ? array_merge($query_args['post__not_in'], $sticky) : $sticky;
676 }
677 }
678
679 $archive_query['post_status'] = 'publish';
680
681 if(!isset($archive_query['orderby'])) {
682 $archive_query['orderby'] = isset($attr['queryOrderBy']) ? $attr['queryOrderBy'] : 'date';
683 }
684
685 // Quick Query Support for Builder
686 if (isset($attr['queryQuick'])) {
687 if ($attr['queryQuick'] != '') {
688 $archive_query = ultimate_post()->get_quick_query($attr, $archive_query);
689 }
690 }
691
692 return apply_filters('ultp_archive_query', $archive_query);
693 }
694
695 $query_args = array(
696 'posts_per_page' => isset($attr['queryNumber']) ? $attr['queryNumber'] : 3,
697 'post_type' => isset($attr['queryType']) ? $attr['queryType'] : 'post',
698 'orderby' => isset($attr['queryOrderBy']) ? $attr['queryOrderBy'] : 'date',
699 'order' => isset($attr['queryOrder']) ? $attr['queryOrder'] : 'desc',
700 'paged' => isset($attr['paged']) ? $attr['paged'] : 1,
701 'post_status' => 'publish'
702 );
703
704
705 if ($attr['queryType'] == 'posts') {
706 if (isset($attr['queryPosts']) && $attr['queryPosts']) {
707 unset($query_args['post_type']);
708 $data = json_decode(isset($attr['queryPosts'])?$attr['queryPosts']:'[]');
709 $final = $this->get_value($data);
710 if (count($final) > 0) {
711 $query_args['post__in'] = $final;
712 $query_args['posts_per_page'] = -1;
713 }
714 $query_args['ignore_sticky_posts'] = 1;
715 return $query_args;
716 }
717 } else if ($attr['queryType'] == 'customPosts') {
718 if (isset($attr['queryCustomPosts']) && $attr['queryCustomPosts']) {
719 $query_args['post_type'] = $this->get_post_type();
720 $data = json_decode(isset($attr['queryCustomPosts'])?$attr['queryCustomPosts']:'[]');
721 $final = $this->get_value($data);
722 if (count($final) > 0) {
723 $query_args['post__in'] = $final;
724 $query_args['posts_per_page'] = -1;
725 }
726 $query_args['ignore_sticky_posts'] = 1;
727 return $query_args;
728 }
729 }
730
731 if(isset($attr['queryExcludeAuthor']) && $attr['queryExcludeAuthor']){
732 $data = json_decode(isset($attr['queryExcludeAuthor'])?$attr['queryExcludeAuthor']:'[]');
733 $final = $this->get_value($data);
734 if (count($final) > 0) {
735 $query_args['author__not_in'] = $final;
736 }
737 }
738
739
740 if(isset($attr['queryOrderBy']) && isset($attr['metaKey'])){
741 if($attr['queryOrderBy'] == 'meta_value_num') {
742 $query_args['meta_key'] = $attr['metaKey'];
743 }
744 }
745
746 // Include Remove from Version 2.5.4
747 if (isset($attr['queryInclude']) && $attr['queryInclude']) {
748 $_include = explode(',', $attr['queryInclude']);
749 if (is_array($_include) && count($_include)) {
750 $query_args['post__in'] = isset($query_args['post__in']) ? array_merge($query_args['post__in'], $_include) : $_include;
751 $query_args['ignore_sticky_posts'] = 1;
752 $query_args['orderby'] = 'post__in';
753 }
754 }
755
756
757 if(isset($attr['queryTax'])){
758 if(isset($attr['queryTaxValue'])){
759 $tax_value = (strlen($attr['queryTaxValue']) > 2) ? $attr['queryTaxValue'] : [];
760 $tax_value = is_array($tax_value) ? $tax_value : json_decode($tax_value);
761
762 $tax_value = (isset($tax_value[0]) && is_object($tax_value[0])) ? $this->get_value($tax_value) : $tax_value;
763
764 if(count($tax_value) > 0){
765 $relation = isset($attr['queryRelation']) ? $attr['queryRelation'] : 'OR';
766 $var = array('relation'=>$relation);
767 foreach ($tax_value as $val) {
768 $tax_name = $attr['queryTax'];
769 // For Custom Terms
770 if ($attr['queryTax'] == 'multiTaxonomy') {
771 $temp = explode('###', $val);
772 if (isset($temp[1])) {
773 $val = $temp[1];
774 $tax_name = $temp[0];
775 }
776 }
777
778 $var[] = array('taxonomy'=> $tax_name, 'field' => 'slug', 'terms' => $val );
779 }
780 if(count($var) > 1){
781 $query_args['tax_query'] = $var;
782 }
783 }
784 }
785 }
786
787
788 if (isset($attr['queryExcludeTerm']) && $attr['queryExcludeTerm']) {
789 $temp = json_decode($attr['queryExcludeTerm']);
790 $_term = [];
791 foreach ($temp as $val) {
792 $temp = explode('###', $val->value);
793 if (isset($temp[1])) {
794 if (array_key_exists($temp[0], $_term)) {
795 $_term[$temp[0]][] = $temp[1];
796 } else {
797 $_term[$temp[0]] = array($temp[1]);
798 }
799 }
800 }
801 if (count($_term) > 0) {
802 $final = array('relation' => 'AND');
803 foreach ($_term as $key => $val) {
804 $final[] = array(
805 'taxonomy' => $key,
806 'field' => 'slug',
807 'terms' => $val,
808 'operator' => 'NOT IN',
809 );
810 }
811
812 if (array_key_exists('tax_query', $query_args)) {
813 $query_args['tax_query'] = array(
814 'relation' => 'AND',
815 $query_args['tax_query']
816 );
817 $query_args['tax_query'][] = $final;
818 } else {
819 $query_args['tax_query'] = $final;
820 }
821 }
822 }
823
824 if (isset($attr['queryExclude']) && $attr['queryExclude']) {
825 $_exclude = (substr($attr['queryExclude'], 0, 1) === "[") ? $this->get_value(json_decode($attr['queryExclude'])) : explode(',', $attr['queryExclude']);
826 if (is_array($_exclude) && count($_exclude)) {
827 $query_args['post__not_in'] = isset($query_args['post__not_in']) ? array_merge($query_args['post__not_in'], $_exclude) : $_exclude;
828 }
829 }
830
831 if (isset($attr['queryUnique']) && $attr['queryUnique']) {
832 global $unique_ID;
833 if (isset($unique_ID[$attr['queryUnique']])) {
834 $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']];
835 }
836 }
837
838 if (isset($attr['queryQuick'])) {
839 if ($attr['queryQuick'] != '') {
840 $query_args = ultimate_post()->get_quick_query($attr, $query_args);
841 }
842 }
843
844 if (isset($attr['queryOffset']) && $attr['queryOffset'] ) {
845 $offset = $this->get_offset($attr['queryOffset'], $query_args);
846 $query_args = array_merge($query_args, $offset);
847 }
848
849 if (isset($attr['queryAuthor']) && $attr['queryAuthor'] ) {
850 $_include = (substr($attr['queryAuthor'], 0, 1) === "[") ? $this->get_value(json_decode($attr['queryAuthor'])) : explode(',', $attr['queryAuthor']);
851 if (is_array($_include) && count($_include)) {
852 $query_args['author__in'] = $_include;
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 $query_args['post__not_in'] = isset($query_args['post__not_in']) ? array_merge($query_args['post__not_in'], $sticky) : $sticky;
860 }
861 }
862
863 $query_args['wpnonce'] = wp_create_nonce( 'ultp-nonce' );
864
865 return apply_filters('ultp_frontend_query', $query_args);
866 }
867
868 function get_offset($queryOffset, $query_args) {
869 $query = array();
870 if ($query_args['paged'] > 1) {
871 $offset_post = wp_get_recent_posts($query_args, OBJECT);
872 if ( count($offset_post) > 0 ) {
873 $offset = array();
874 for($x = count($offset_post); $x > count($offset_post) - $queryOffset; $x--){
875 $offset[] = $offset_post[$x-1]->ID;
876 }
877 $query['post__not_in'] = $offset;
878 }
879 } else {
880 $query['offset'] = isset($queryOffset) ? $queryOffset : 0;
881 }
882 return $query;
883 }
884
885
886 /**
887 * Get Page Number
888 *
889 * @since v.1.0.0
890 * @param | Attribute of the Query(ARRAY) | Post Number(ARRAY)
891 * @return ARRAY
892 */
893 public function get_page_number($attr, $post_number) {
894 if ($post_number > 0) {
895 if (isset($attr['queryOffset']) && $attr['queryOffset']) {
896 $post_number = $post_number - (int)$attr['queryOffset'];
897 }
898 $post_per_page = isset($attr['queryNumber']) ? ($attr['queryNumber'] ? $attr['queryNumber'] : 1) : 3;
899 $pages = ceil($post_number/$post_per_page);
900 return $pages ? $pages : 1;
901 }else{
902 return 1;
903 }
904 }
905
906
907 /**
908 * Get Image Size
909 *
910 * @since v.1.0.0
911 * @param | Attribute of the Query(ARRAY) | Post Number(ARRAY)
912 * @return ARRAY
913 */
914 public function get_image_size() {
915 $sizes = get_intermediate_image_sizes();
916 $filter = array('full' => 'Full');
917 foreach ($sizes as $value) {
918 $title = ucwords(str_replace(array('_', '-'), array(' ', ' '), $value));
919 switch ($value) {
920 case 'thumbnail':
921 $title = $title.' [150x150]';
922 break;
923 case 'medium':
924 $title = $title.' [300x300]';
925 break;
926 case 'large':
927 $title = $title.' [1024x1024]';
928 break;
929 case 'ultp_layout_landscape_large':
930 $title = $title.' [1200x800]';
931 break;
932 case 'ultp_layout_landscape':
933 $title = $title.' [870x570]';
934 break;
935 case 'ultp_layout_portrait':
936 $title = $title.' [600x900]';
937 break;
938 case 'ultp_layout_square':
939 $title = $title.' [600x600]';
940 break;
941 default:
942 break;
943 }
944 $filter[$value] = $title;
945 }
946 return $filter;
947 }
948
949
950 /**
951 * Get All PostType Registered
952 *
953 * @since v.1.0.0
954 * @param | Attribute of the Query(ARRAY) | Post Number(ARRAY)
955 * @return ARRAY
956 */
957 public function get_post_type() {
958 $post_type = get_post_types( ['public' => true], 'names' );
959 return array_diff($post_type, array( 'attachment' ));
960 }
961
962
963 /**
964 * Get Pagination HTML
965 *
966 * @since v.1.0.0
967 * @param | pages (NUMBER) | Pagination Nav (STRING) | Pagination Text |
968 * @return STRING
969 */
970 public function pagination($pages = '', $paginationNav = '', $paginationText = '') {
971 $html = '';
972 $showitems = 3;
973 $paged = is_front_page() ? get_query_var('page') : get_query_var('paged');
974 $paged = $paged ? $paged : 1;
975 if($pages == '') {
976 global $wp_query;
977 $pages = $wp_query->max_num_pages;
978 if(!$pages) {
979 $pages = 1;
980 }
981 }
982 $data = ($paged>=3?[($paged-1),$paged,$paged+1]:[1,2,3]);
983
984 $paginationText = explode('|', $paginationText);
985
986 $prev_text = isset($paginationText[0]) ? $paginationText[0] : __("Previous", "ultimate-post");
987 $next_text = isset($paginationText[1]) ? $paginationText[1] : __("Next", "ultimate-post");
988
989 if(1 != $pages) {
990 $html .= '<ul class="ultp-pagination">';
991 $display_none = 'style="display:none"';
992 if($pages > 4) {
993 $html .= '<li class="ultp-prev-page-numbers" '.($paged==1?$display_none:"").'><a href="'.get_pagenum_link($paged-1).'">'.ultimate_post()->svg_icon('leftAngle2').' '.($paginationNav == 'textArrow' ? $prev_text : "").'</a></li>';
994 }
995 if($pages > 4){
996 $html .= '<li class="ultp-first-pages" '.($paged<2?$display_none:"").' data-current="1"><a href="'.get_pagenum_link(1).'">1</a></li>';
997 }
998 if($pages > 4){
999 $html .= '<li class="ultp-first-dot" '.($paged<2? $display_none : "").'><a href="#">...</a></li>';
1000 }
1001 foreach ($data as $i) {
1002 if($pages >= $i){
1003 $html .= ($paged == $i) ? '<li class="ultp-center-item pagination-active" data-current="'.$i.'"><a href="'.get_pagenum_link($i).'">'.$i.'</a></li>':'<li class="ultp-center-item" data-current="'.$i.'"><a href="'.get_pagenum_link($i).'">'.$i.'</a></li>';
1004 }
1005 }
1006 if($pages > 4){
1007 $html .= '<li class="ultp-last-dot" '.($pages<=$paged+1?$display_none:"").'><a href="#">...</a></li>';
1008 }
1009 if($pages > 4){
1010 $html .= '<li class="ultp-last-pages" '.($pages<=$paged+1?$display_none:"").' data-current="'.$pages.'"><a href="'.get_pagenum_link($pages).'">'.$pages.'</a></li>';
1011 }
1012 if ($paged != $pages) {
1013 $html .= '<li class="ultp-next-page-numbers"><a href="'.get_pagenum_link($paged + 1).'">'.($paginationNav == 'textArrow' ? $next_text : "").ultimate_post()->svg_icon('rightAngle2').'</a></li>';
1014 }
1015 $html .= '</ul>';
1016 }
1017 return $html;
1018 }
1019
1020
1021 /**
1022 * Get Excerpt Word
1023 *
1024 * @since v.1.0.0
1025 * @param NUMBER | Character Length
1026 * @return STRING
1027 */
1028 public function excerpt_word($charlength = 200) {
1029 $html = '';
1030 $charlength++;
1031 $excerpt = get_the_excerpt();
1032 if ( mb_strlen( $excerpt ) > $charlength ) {
1033 $subex = mb_substr( $excerpt, 0, $charlength - 5 );
1034 $exwords = explode( ' ', $subex );
1035 $excut = - ( mb_strlen( $exwords[ count( $exwords ) - 1 ] ) );
1036 if ( $excut < 0 ) {
1037 $html = mb_substr( $subex, 0, $excut );
1038 } else {
1039 $html = $subex;
1040 }
1041 $html .= '...';
1042 } else {
1043 $html = $excerpt;
1044 }
1045 return $html;
1046 }
1047
1048
1049 /**
1050 * Get Taxonomy Lists
1051 *
1052 * @since v.1.0.0
1053 * @param STRING | Taxonomy Slug
1054 * @return ARRAY
1055 */
1056 public function taxonomy( $prams = 'category' ) {
1057 $data = array();
1058 $terms = get_terms( $prams, array(
1059 'hide_empty' => false,
1060 ));
1061 if( !is_wp_error($terms) ){
1062 foreach ($terms as $val) {
1063 $data[urldecode_deep($val->slug)] = $val->name;
1064 }
1065 }
1066 return $data;
1067 }
1068
1069
1070 /**
1071 * Get Taxonomy Data Lists
1072 *
1073 * @since v.1.0.0
1074 * @param OBJECT | Taxonomy Object
1075 * @return ARRAY
1076 */
1077 public function get_tax_data($terms) {
1078 $temp = array();
1079 $image = '';
1080 $thumbnail_id = get_term_meta( $terms->term_id, 'ultp_category_image', true );
1081 if( $thumbnail_id ){
1082 $image = wp_get_attachment_url( $thumbnail_id );
1083 }
1084 $temp['url'] = get_term_link($terms);
1085 $temp['name'] = $terms->name;
1086 $temp['desc'] = $terms->description;
1087 $temp['count'] = $terms->count;
1088 $temp['image'] = $image;
1089 $color = get_term_meta($terms->term_id, 'ultp_category_color', true);
1090 $temp['color'] = $color ? $color : '#037fff';
1091 return $temp;
1092 }
1093
1094 public function get_category_data($catSlug, $number = 40, $type = '', $tax_slug = 'category') {
1095 $data = array();
1096 if($type == 'child'){
1097 $image = '';
1098 if (!empty($catSlug)) {
1099 foreach ($catSlug as $cat) {
1100 $parent_term = get_term_by('slug', $cat, $tax_slug);
1101 if (!empty($parent_term)) {
1102 $term_data = get_terms($tax_slug, array(
1103 'hide_empty' => true,
1104 'parent' => $parent_term->term_id
1105 ));
1106 if (!empty($term_data)) {
1107 foreach ($term_data as $terms) {
1108 $data[] = $this->get_tax_data($terms);
1109 }
1110 }
1111 }
1112 }
1113 }
1114 } else if ($type == 'parent') {
1115 $term_data = get_terms( $tax_slug, array( 'hide_empty' => true, 'number' => $number, 'parent' => 0 ) );
1116 if (!empty($term_data)) {
1117 foreach ($term_data as $terms) {
1118 $data[] = $this->get_tax_data($terms);
1119 }
1120 }
1121 } else if ($type == 'custom') {
1122 foreach ($catSlug as $cat) {
1123 $terms = get_term_by('slug', $cat, $tax_slug);
1124 if (!empty($terms)) {
1125 $data[] = $this->get_tax_data($terms);
1126 }
1127 }
1128 } else {
1129 $term_data = get_terms($tax_slug, array('hide_empty' => true, 'number' => $number));
1130 if (!empty($term_data)) {
1131 foreach ($term_data as $terms) {
1132 $data[] = $this->get_tax_data($terms);
1133 }
1134 }
1135 }
1136 return $data;
1137 }
1138
1139
1140 /**
1141 * Get Next Previous HTML
1142 *
1143 * @since v.1.0.0
1144 * @param OBJECT | Taxonomy Object
1145 * @return STRING
1146 */
1147 public function next_prev() {
1148 $html = '';
1149 $html .= '<ul>';
1150 $html .= '<li>';
1151 $html .= '<a class="ultp-prev-action ultp-disable" href="#">';
1152 $html .= ultimate_post()->svg_icon('leftAngle2').'<span class="screen-reader-text">'.esc_html__("Previous", "ultimate-post").'</span>';
1153 $html .= '</a>';
1154 $html .= '</li>';
1155 $html .= '<li>';
1156 $html .= '<a class="ultp-next-action">';
1157 $html .= ultimate_post()->svg_icon('rightAngle2').'<span class="screen-reader-text">'.esc_html__("Next", "ultimate-post").'</span>';
1158 $html .= '</a>';
1159 $html .= '</li>';
1160 $html .= '</ul>';
1161 return $html;
1162 }
1163
1164
1165 /**
1166 * Get Loading HTML
1167 *
1168 * @since v.1.0.0
1169 * @param NULL
1170 * @return STRING
1171 */
1172 public function loading(){
1173 $html = '';
1174 $style = ultimate_post()->get_setting('preloader_style');
1175 if( $style == 'style2' ){
1176 $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
1177 } else {
1178 $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>';
1179 }
1180 return '<div class="ultp-loading">'.$html.'</div>';
1181 }
1182
1183
1184 /**
1185 * Get Filter HTML
1186 *
1187 * @since v.1.0.0
1188 * @param | Filter Text (STRING) | Filter Type (STRING) | Filter Value (ARRAY) | Filter Cat (ARRAY) | Filter Tag (ARRAY) |
1189 * @return STRING
1190 */
1191 public function filter($filterText = '', $filterType = '', $filterValue = '[]', $filterMobileText = '...', $filterMobile = true){
1192 $html = '';
1193 $html .= '<ul '.($filterMobile ? 'class="ultp-flex-menu"' : '').' data-name="'.($filterMobileText ? $filterMobileText : '&nbsp;').'">';
1194 $cat = $this->taxonomy($filterType);
1195 if($filterText){
1196 $html .= '<li class="filter-item"><a class="filter-active" data-taxonomy="" href="#">'.$filterText.'</a></li>';
1197 }
1198
1199 if ($filterValue) {
1200 $filterValue = strlen($filterValue) > 2 ? $filterValue : [];
1201 $filterValue = is_array($filterValue) ? $filterValue : json_decode($filterValue);
1202 foreach ($filterValue as $val) {
1203 $html .= '<li class="filter-item"><a data-taxonomy="'.$val.'" href="#">'.(isset($cat[$val]) ? $cat[$val] : $val).'</a></li>';
1204 }
1205 }
1206 $html .= '</ul>';
1207 return $html;
1208 }
1209
1210
1211 /**
1212 * Check License Status
1213 *
1214 * @since v.2.4.2
1215 * @return BOOLEAN | Is pro license active or not
1216 */
1217 public function is_lc_active() {
1218 if (function_exists('ultimate_post_pro')) {
1219 return get_option('edd_ultp_license_status') == 'valid' ? true : false;
1220 }
1221 if (get_transient( 'ulpt_theme_enable' ) == 'integration') {
1222 return true;
1223 }
1224 return false;
1225 }
1226
1227
1228 /**
1229 * Get SVG Icon
1230 *
1231 * @since v.1.0.0
1232 * @param STRING | Icon Key
1233 * @return STRING | Icon SVG
1234 */
1235 public function svg_icon($icons = ''){
1236 $icon_lists = array(
1237 'eye' => file_get_contents(ULTP_PATH.'assets/img/svg/eye.svg'),
1238 'user' => file_get_contents(ULTP_PATH.'assets/img/svg/user.svg'),
1239 'calendar' => file_get_contents(ULTP_PATH.'assets/img/svg/calendar.svg'),
1240 'comment' => file_get_contents(ULTP_PATH.'assets/img/svg/comment.svg'),
1241 'book' => file_get_contents(ULTP_PATH.'assets/img/svg/book.svg'),
1242 'tag' => file_get_contents(ULTP_PATH.'assets/img/svg/tag.svg'),
1243 'clock' => file_get_contents(ULTP_PATH.'assets/img/svg/clock.svg'),
1244 'leftAngle' => file_get_contents(ULTP_PATH.'assets/img/svg/leftAngle.svg'),
1245 'rightAngle' => file_get_contents(ULTP_PATH.'assets/img/svg/rightAngle.svg'),
1246 'leftAngle2' => file_get_contents(ULTP_PATH.'assets/img/svg/leftAngle2.svg'),
1247 'rightAngle2' => file_get_contents(ULTP_PATH.'assets/img/svg/rightAngle2.svg'),
1248 'leftArrowLg' => file_get_contents(ULTP_PATH.'assets/img/svg/leftArrowLg.svg'),
1249 'refresh' => file_get_contents(ULTP_PATH.'assets/img/svg/refresh.svg'),
1250 'rightArrowLg' => file_get_contents(ULTP_PATH.'assets/img/svg/rightArrowLg.svg'),
1251 );
1252 if($icons){
1253 return $icon_lists[ $icons ];
1254 }
1255 }
1256
1257 /**
1258 * Get SEO Meta
1259 *
1260 * @since v.2.4.3
1261 * @param NUMBER | Post ID
1262 * @return STRING | SEO Meta Description or Excerpt
1263 */
1264 public function get_excerpt($post_id = 0, $showSeoMeta = 0, $showFullExcerpt = 0, $excerptLimit = 55) {
1265 $html = '';
1266 if ($showSeoMeta) {
1267 $str = '';
1268 if( function_exists('ultimate_post_pro') ) {
1269 if (ultimate_post()->get_setting('ultp_yoast') == 'true') {
1270 $str = method_exists( ultimate_post_pro(), 'get_yoast_meta' ) ? ultimate_post_pro()->get_yoast_meta($post_id) : '';
1271 } else if (ultimate_post()->get_setting('ultp_rankmath') == 'true') {
1272 $str = method_exists( ultimate_post_pro(), 'get_rankmath_meta' ) ? ultimate_post_pro()->get_rankmath_meta($post_id) : '';
1273 } else if (ultimate_post()->get_setting('ultp_aioseo') == 'true') {
1274 $str = method_exists( ultimate_post_pro(), 'get_aioseo_meta' ) ? ultimate_post_pro()->get_aioseo_meta($post_id) : '';
1275 } else if (ultimate_post()->get_setting('ultp_seopress') == 'true') {
1276 $str = method_exists( ultimate_post_pro(), 'get_seopress_meta' ) ? ultimate_post_pro()->get_seopress_meta($post_id) : '';
1277 } else if (ultimate_post()->get_setting('ultp_squirrly') == 'true') {
1278 $str = method_exists( ultimate_post_pro(), 'get_squirrly_meta' ) ? ultimate_post_pro()->get_squirrly_meta($post_id) : '';
1279 }
1280 }
1281 $html = $str ? $str : ultimate_post()->excerpt($post_id, $excerptLimit);
1282 } else {
1283 if ( $showFullExcerpt == 0 ) {
1284 $html = ultimate_post()->excerpt($post_id, $excerptLimit);
1285 } else {
1286 $html = get_the_excerpt();
1287 }
1288 }
1289 return $html;
1290 }
1291
1292 /**
1293 * Set Inline CSS
1294 *
1295 * @since v.2.5.8
1296 * @param STRING | CSS
1297 * @return STRING | CSS with Style
1298 */
1299 public function set_inline($css) {
1300 return '<style type="text/css">'.wp_strip_all_tags($css).'</style>';
1301 }
1302
1303 /**
1304 * Array Sanitize Function
1305 *
1306 * @since v.2.6.0
1307 * @param ARRAY
1308 * @return ARRAY | Array of Sanitize
1309 */
1310 public function recursive_sanitize_text_field($array) {
1311 foreach ($array as $key => &$value) {
1312 if (is_array($value)) {
1313 $value = $this->recursive_sanitize_text_field($value);
1314 } else {
1315 $value = sanitize_text_field($value);
1316 }
1317 }
1318 return $array;
1319 }
1320
1321 }
1322