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

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