| 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/' ) { |
| 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 |
break; |
| 183 |
case 'latest_post_modified': |
| 184 |
$args['orderby'] = 'modified'; |
| 185 |
$args['order'] = 'DESC'; |
| 186 |
break; |
| 187 |
case 'oldest_post_published': |
| 188 |
$args['orderby'] = 'date'; |
| 189 |
$args['order'] = 'ASC'; |
| 190 |
break; |
| 191 |
case 'oldest_post_modified': |
| 192 |
$args['orderby'] = 'modified'; |
| 193 |
$args['order'] = 'ASC'; |
| 194 |
break; |
| 195 |
case 'alphabet_asc': |
| 196 |
$args['orderby'] = 'title'; |
| 197 |
$args['order'] = 'ASC'; |
| 198 |
break; |
| 199 |
case 'alphabet_desc': |
| 200 |
$args['orderby'] = 'title'; |
| 201 |
$args['order'] = 'DESC'; |
| 202 |
break; |
| 203 |
case 'random_post': |
| 204 |
$args['orderby'] = 'rand'; |
| 205 |
$args['order'] = 'ASC'; |
| 206 |
break; |
| 207 |
case 'random_post_7_days': |
| 208 |
$args['orderby'] = 'rand'; |
| 209 |
$args['order'] = 'ASC'; |
| 210 |
$args['date_query'] = array( array( 'after' => '1 week ago') ); |
| 211 |
break; |
| 212 |
case 'random_post_30_days': |
| 213 |
$args['orderby'] = 'rand'; |
| 214 |
$args['order'] = 'ASC'; |
| 215 |
$args['date_query'] = array( array( 'after' => '1 month ago') ); |
| 216 |
break; |
| 217 |
case 'most_comment': |
| 218 |
$args['orderby'] = 'comment_count'; |
| 219 |
$args['order'] = 'DESC'; |
| 220 |
break; |
| 221 |
case 'most_comment_1_day': |
| 222 |
$args['orderby'] = 'comment_count'; |
| 223 |
$args['order'] = 'DESC'; |
| 224 |
$args['date_query'] = array( array( 'after' => '1 day ago') ); |
| 225 |
break; |
| 226 |
case 'most_comment_7_days': |
| 227 |
$args['orderby'] = 'comment_count'; |
| 228 |
$args['order'] = 'DESC'; |
| 229 |
$args['date_query'] = array( array( 'after' => '1 week ago') ); |
| 230 |
break; |
| 231 |
case 'most_comment_30_days': |
| 232 |
$args['orderby'] = 'comment_count'; |
| 233 |
$args['order'] = 'DESC'; |
| 234 |
$args['date_query'] = array( array( 'after' => '1 month ago') ); |
| 235 |
break; |
| 236 |
case 'popular_post_1_day_view': |
| 237 |
$args['meta_key'] = '__post_views_count'; |
| 238 |
$args['orderby'] = 'meta_value meta_value_num'; |
| 239 |
$args['order'] = 'DESC'; |
| 240 |
$args['date_query'] = array( array( 'after' => '1 day ago') ); |
| 241 |
break; |
| 242 |
case 'popular_post_7_days_view': |
| 243 |
$args['meta_key'] = '__post_views_count'; |
| 244 |
$args['orderby'] = 'meta_value meta_value_num'; |
| 245 |
$args['order'] = 'DESC'; |
| 246 |
$args['date_query'] = array( array( 'after' => '1 week ago') ); |
| 247 |
break; |
| 248 |
case 'popular_post_30_days_view': |
| 249 |
$args['meta_key'] = '__post_views_count'; |
| 250 |
$args['orderby'] = 'meta_value meta_value_num'; |
| 251 |
$args['order'] = 'DESC'; |
| 252 |
$args['date_query'] = array( array( 'after' => '1 month ago') ); |
| 253 |
break; |
| 254 |
case 'popular_post_all_times_view': |
| 255 |
$args['meta_key'] = '__post_views_count'; |
| 256 |
$args['orderby'] = 'meta_value meta_value_num'; |
| 257 |
$args['order'] = 'DESC'; |
| 258 |
break; |
| 259 |
default: |
| 260 |
# code... |
| 261 |
break; |
| 262 |
} |
| 263 |
return $args; |
| 264 |
} |
| 265 |
|
| 266 |
/** |
| 267 |
* Get All Term ID as Array |
| 268 |
* |
| 269 |
* @since v.2.4.12 |
| 270 |
* @return ARRAY | Query Arg |
| 271 |
*/ |
| 272 |
public function get_terms_id($id, $type) { |
| 273 |
$data = array(); |
| 274 |
$arr = get_the_terms($id, $type); |
| 275 |
if (is_array($arr)) { |
| 276 |
foreach ($arr as $key => $val) { |
| 277 |
$data[] = $val->term_id; |
| 278 |
} |
| 279 |
} |
| 280 |
return $data; |
| 281 |
} |
| 282 |
|
| 283 |
/** |
| 284 |
* Get All Reusable ID |
| 285 |
* |
| 286 |
* @since v.1.1.0 |
| 287 |
* @return ARRAY | Query Arg |
| 288 |
*/ |
| 289 |
public function reusable_id($post_id){ |
| 290 |
$reusable_id = array(); |
| 291 |
if($post_id){ |
| 292 |
$post = get_post($post_id); |
| 293 |
if (has_blocks($post->post_content)) { |
| 294 |
$blocks = parse_blocks($post->post_content); |
| 295 |
foreach ($blocks as $key => $value) { |
| 296 |
if(isset($value['attrs']['ref'])) { |
| 297 |
$reusable_id[] = $value['attrs']['ref']; |
| 298 |
} |
| 299 |
} |
| 300 |
} |
| 301 |
} |
| 302 |
return $reusable_id; |
| 303 |
} |
| 304 |
|
| 305 |
|
| 306 |
/** |
| 307 |
* Set CSS Style |
| 308 |
* |
| 309 |
* @since v.1.1.0 |
| 310 |
* @return ARRAY | Query Arg |
| 311 |
*/ |
| 312 |
public function set_css_style($post_id){ |
| 313 |
if( $post_id ){ |
| 314 |
$upload_dir_url = wp_get_upload_dir(); |
| 315 |
$upload_css_dir_url = trailingslashit( $upload_dir_url['basedir'] ); |
| 316 |
$css_dir_path = $upload_css_dir_url . "ultimate-post/ultp-css-{$post_id}.css"; |
| 317 |
|
| 318 |
$css_dir_url = trailingslashit( $upload_dir_url['baseurl'] ); |
| 319 |
if (is_ssl()) { |
| 320 |
$css_dir_url = str_replace('http://', 'https://', $css_dir_url); |
| 321 |
} |
| 322 |
|
| 323 |
// Reusable CSS |
| 324 |
$reusable_id = ultimate_post()->reusable_id($post_id); |
| 325 |
foreach ( $reusable_id as $id ) { |
| 326 |
$reusable_dir_path = $upload_css_dir_url."ultimate-post/ultp-css-{$id}.css"; |
| 327 |
if (file_exists( $reusable_dir_path )) { |
| 328 |
$css_url = $css_dir_url . "ultimate-post/ultp-css-{$id}.css"; |
| 329 |
wp_enqueue_style( "ultp-post-{$id}", $css_url, array(), ULTP_VER, 'all' ); |
| 330 |
}else{ |
| 331 |
$css = get_post_meta($id, '_ultp_css', true); |
| 332 |
if( $css ) { |
| 333 |
wp_enqueue_style("ultp-post-{$id}", $css, false, ULTP_VER); |
| 334 |
} |
| 335 |
} |
| 336 |
} |
| 337 |
|
| 338 |
if ( file_exists( $css_dir_path ) ) { |
| 339 |
$css_url = $css_dir_url . "ultimate-post/ultp-css-{$post_id}.css"; |
| 340 |
wp_enqueue_style( "ultp-post-{$post_id}", $css_url, array(), ULTP_VER, 'all' ); |
| 341 |
} else { |
| 342 |
$css = get_post_meta($post_id, '_ultp_css', true); |
| 343 |
if( $css ) { |
| 344 |
wp_enqueue_style("ultp-post-{$post_id}", $css, false, ULTP_VER); |
| 345 |
} |
| 346 |
} |
| 347 |
if (isset($_GET['et_fb'])) { |
| 348 |
echo '<style type="text/css">'.get_post_meta($post_id, '_ultp_css', true).'</style>'; |
| 349 |
} |
| 350 |
} |
| 351 |
} |
| 352 |
|
| 353 |
|
| 354 |
/** |
| 355 |
* Get Global Plugin Settings |
| 356 |
* |
| 357 |
* @since v.1.0.0 |
| 358 |
* @param STRING | Key of the Option |
| 359 |
* @return ARRAY | STRING |
| 360 |
*/ |
| 361 |
public function get_setting($key = ''){ |
| 362 |
$data = $GLOBALS['ultp_settings']; |
| 363 |
if ($key != '') { |
| 364 |
return isset($data[$key]) ? $data[$key] : ''; |
| 365 |
} else { |
| 366 |
return $data; |
| 367 |
} |
| 368 |
} |
| 369 |
|
| 370 |
|
| 371 |
/** |
| 372 |
* Set Option Settings |
| 373 |
* |
| 374 |
* @since v.1.0.0 |
| 375 |
* @param STRING | Key of the Option (STRING), Value (STRING) |
| 376 |
* @return NULL |
| 377 |
*/ |
| 378 |
public function set_setting($key = '', $val = '') { |
| 379 |
if($key != ''){ |
| 380 |
$data = $GLOBALS['ultp_settings']; |
| 381 |
$data[$key] = $val; |
| 382 |
update_option('ultp_options', $data); |
| 383 |
$GLOBALS['ultp_settings'] = $data; |
| 384 |
} |
| 385 |
} |
| 386 |
|
| 387 |
|
| 388 |
/** |
| 389 |
* Get Image HTML |
| 390 |
* |
| 391 |
* @since v.1.0.0 |
| 392 |
* @param | URL (STRING) | size (STRING) | class (STRING) | alt (STRING) |
| 393 |
* @return STRING |
| 394 |
*/ |
| 395 |
public function get_image_html($url = '', $size = 'full', $class = '', $alt = '', $lazy = ''){ |
| 396 |
$alt = $alt ? ' alt="'.$alt.'" ' : ''; |
| 397 |
$lazy_data = $lazy ? ' loading="lazy"' : ''; |
| 398 |
$class = $class ? ' class="'.$class.'" ' : ''; |
| 399 |
return '<img '.$lazy_data.$class.$alt.' src="'.$url.'" />'; |
| 400 |
} |
| 401 |
|
| 402 |
|
| 403 |
/** |
| 404 |
* Get Image HTML |
| 405 |
* |
| 406 |
* @since v.1.0.0 |
| 407 |
* @param | Attach ID (STRING) | size (STRING) | class (STRING) | alt (STRING) |
| 408 |
* @return STRING |
| 409 |
*/ |
| 410 |
public function get_image($attach_id, $size = 'full', $class = '', $alt = '', $srcset = '', $lazy = ''){ |
| 411 |
$alt = $alt ? ' alt="'.$alt.'" ' : ''; |
| 412 |
$class = $class ? ' class="'.$class.'" ' : ''; |
| 413 |
$size = ( ultimate_post()->get_setting('disable_image_size') == 'yes' && strpos($size, 'ultp_layout_') !== false ) ? 'full' : $size; |
| 414 |
$lazy_data = $lazy ? ' loading="lazy"' : ''; |
| 415 |
$srcset_data = $srcset ? ' srcset="'.esc_attr(wp_get_attachment_image_srcset($attach_id)).'"' : ''; |
| 416 |
return '<img '.$srcset_data.$lazy_data.$class.$alt.' src="'.wp_get_attachment_image_url( $attach_id, $size ).'" />'; |
| 417 |
} |
| 418 |
|
| 419 |
|
| 420 |
/** |
| 421 |
* Setup Initial Data Set |
| 422 |
* |
| 423 |
* @since v.1.0.0 |
| 424 |
* @return NULL |
| 425 |
*/ |
| 426 |
public function init_set_data(){ |
| 427 |
$data = get_option( 'ultp_options', array() ); |
| 428 |
$init_data = array( |
| 429 |
'css_save_as' => 'wp_head', |
| 430 |
'preloader_style' => 'style1', |
| 431 |
'preloader_color' => '#037fff', |
| 432 |
'container_width' => '1140', |
| 433 |
'editor_container' => 'full_width', |
| 434 |
'hide_import_btn' => '', |
| 435 |
'disable_image_size'=> '', |
| 436 |
'ultp_templates' => 'true', |
| 437 |
'ultp_elementor' => 'true', |
| 438 |
'ultp_table_of_content'=> 'true', |
| 439 |
'post_grid_1' => 'yes', |
| 440 |
'post_grid_2' => 'yes', |
| 441 |
'post_grid_3' => 'yes', |
| 442 |
'post_grid_4' => 'yes', |
| 443 |
'post_grid_5' => 'yes', |
| 444 |
'post_grid_6' => 'yes', |
| 445 |
'post_grid_7' => 'yes', |
| 446 |
'post_list_1' => 'yes', |
| 447 |
'post_list_2' => 'yes', |
| 448 |
'post_list_3' => 'yes', |
| 449 |
'post_list_4' => 'yes', |
| 450 |
'post_module_1' => 'yes', |
| 451 |
'post_module_2' => 'yes', |
| 452 |
'post_slider_1' => 'yes', |
| 453 |
'heading' => 'yes', |
| 454 |
'image' => 'yes', |
| 455 |
'taxonomy' => 'yes', |
| 456 |
'wrapper' => 'yes' |
| 457 |
); |
| 458 |
if (empty($data)) { |
| 459 |
update_option('ultp_options', $init_data); |
| 460 |
$GLOBALS['ultp_settings'] = $init_data; |
| 461 |
} else { |
| 462 |
foreach ($init_data as $key => $single) { |
| 463 |
if (!isset($data[$key])) { |
| 464 |
$data[$key] = $single; |
| 465 |
} |
| 466 |
} |
| 467 |
update_option('ultp_options', $data); |
| 468 |
$GLOBALS['ultp_settings'] = $data; |
| 469 |
} |
| 470 |
} |
| 471 |
|
| 472 |
|
| 473 |
/** |
| 474 |
* Get Excerpt Text |
| 475 |
* |
| 476 |
* @since v.1.0.0 |
| 477 |
* @param | Post ID (STRING) | Limit (NUMBER) |
| 478 |
* @return STRING |
| 479 |
*/ |
| 480 |
public function excerpt( $post_id, $limit = 55 ) { |
| 481 |
return apply_filters( 'the_excerpt', wp_trim_words( get_the_content( $post_id ) , $limit ) ); |
| 482 |
} |
| 483 |
|
| 484 |
public function get_builder_attr() { |
| 485 |
$builder_data = ''; |
| 486 |
if (is_archive()) { |
| 487 |
if (is_date()) { |
| 488 |
if ( is_year() ) { |
| 489 |
$builder_data = 'date###'.get_the_date('Y'); |
| 490 |
} else if ( is_month() ) { |
| 491 |
$builder_data = 'date###'.get_the_date('Y-n'); |
| 492 |
} else if ( is_day() ) { |
| 493 |
$builder_data = 'date###'.get_the_date('Y-n-j'); |
| 494 |
} |
| 495 |
} else if (is_author()) { |
| 496 |
$builder_data = 'author###'.get_the_author_meta('ID'); |
| 497 |
} else { |
| 498 |
$obj = get_queried_object(); |
| 499 |
if (isset($obj->taxonomy)) { |
| 500 |
$builder_data = 'taxonomy###'.$obj->taxonomy.'###'.$obj->slug; |
| 501 |
} |
| 502 |
} |
| 503 |
} else if (is_search()) { |
| 504 |
$builder_data = 'search###'.get_search_query(true); |
| 505 |
} |
| 506 |
return $builder_data ? 'data-builder="'.$builder_data.'"' : ''; |
| 507 |
} |
| 508 |
|
| 509 |
|
| 510 |
public function is_builder($builder = '') { |
| 511 |
$id = ''; |
| 512 |
if (function_exists('ultimate_post_pro')) { |
| 513 |
if ($builder) { |
| 514 |
return true; |
| 515 |
} |
| 516 |
$page_id = ultimate_post_pro()->conditions('return'); |
| 517 |
if ($page_id && ultimate_post()->get_setting('ultp_builder')) { |
| 518 |
$id = $page_id; |
| 519 |
} |
| 520 |
} |
| 521 |
return $id; |
| 522 |
} |
| 523 |
|
| 524 |
/** |
| 525 |
* Query Builder |
| 526 |
* |
| 527 |
* @since v.1.0.0 |
| 528 |
* @param ARRAY | Attribute of the Query |
| 529 |
* @return ARRAY |
| 530 |
*/ |
| 531 |
public function get_query($attr) { |
| 532 |
$archive_query = array(); |
| 533 |
$builder = isset($attr['builder']) ? $attr['builder'] : ''; |
| 534 |
if ($this->is_builder($builder)) { |
| 535 |
if ($builder) { |
| 536 |
$str = explode('###', $builder); |
| 537 |
if (isset($str[0])) { |
| 538 |
if ($str[0] == 'taxonomy') { |
| 539 |
if (isset($str[1]) && isset($str[2])) { |
| 540 |
$archive_query['tax_query'] = array( |
| 541 |
array( |
| 542 |
'taxonomy' => $str[1], |
| 543 |
'field' => 'slug', |
| 544 |
'terms' => $str[2] |
| 545 |
) |
| 546 |
); |
| 547 |
} |
| 548 |
} else if ($str[0] == 'author') { |
| 549 |
if (isset($str[1])) { |
| 550 |
$archive_query['author'] = $str[1]; |
| 551 |
} |
| 552 |
} else if ($str[0] == 'search') { |
| 553 |
if (isset($str[1])) { |
| 554 |
$archive_query['s'] = $str[1]; |
| 555 |
} |
| 556 |
} else if ($str[0] == 'date') { |
| 557 |
if (isset($str[1])) { |
| 558 |
$all_date = explode('-', $str[1]); |
| 559 |
if (!empty($all_date)) { |
| 560 |
$arg = array(); |
| 561 |
if (isset($all_date[0])) { $arg['year'] = $all_date[0]; } |
| 562 |
if (isset($all_date[1])) { $arg['month'] = $all_date[1]; } |
| 563 |
if (isset($all_date[2])) { $arg['day'] = $all_date[2]; } |
| 564 |
$archive_query['date_query'][] = $arg; |
| 565 |
} |
| 566 |
} |
| 567 |
} |
| 568 |
} |
| 569 |
} else { |
| 570 |
global $wp_query; |
| 571 |
$archive_query = $wp_query->query_vars; |
| 572 |
} |
| 573 |
$archive_query['posts_per_page'] = isset($attr['queryNumber']) ? $attr['queryNumber'] : 3; |
| 574 |
$archive_query['paged'] = isset($attr['paged']) ? $attr['paged'] : 1; |
| 575 |
if (isset($attr['queryOffset']) && $attr['queryOffset'] ) { |
| 576 |
$offset = $this->get_offset($attr['queryOffset'], $archive_query); |
| 577 |
$archive_query = array_merge($archive_query, $offset); |
| 578 |
} |
| 579 |
$archive_query['post_status'] = 'publish'; |
| 580 |
return $archive_query; |
| 581 |
} |
| 582 |
|
| 583 |
$query_args = array( |
| 584 |
'posts_per_page' => isset($attr['queryNumber']) ? $attr['queryNumber'] : 3, |
| 585 |
'post_type' => isset($attr['queryType']) ? $attr['queryType'] : 'post', |
| 586 |
'orderby' => isset($attr['queryOrderBy']) ? $attr['queryOrderBy'] : 'date', |
| 587 |
'order' => isset($attr['queryOrder']) ? $attr['queryOrder'] : 'desc', |
| 588 |
'paged' => isset($attr['paged']) ? $attr['paged'] : 1, |
| 589 |
'post_status' => 'publish' |
| 590 |
); |
| 591 |
|
| 592 |
if(isset($attr['queryOrderBy']) && isset($attr['metaKey'])){ |
| 593 |
if($attr['queryOrderBy'] == 'meta_value_num') { |
| 594 |
$query_args['meta_key'] = $attr['metaKey']; |
| 595 |
} |
| 596 |
} |
| 597 |
|
| 598 |
if(isset($attr['queryInclude']) && $attr['queryInclude']){ |
| 599 |
$query_args['post__in'] = explode(',', $attr['queryInclude']); |
| 600 |
$query_args['ignore_sticky_posts'] = 1; |
| 601 |
$query_args['orderby'] = 'post__in'; |
| 602 |
} |
| 603 |
|
| 604 |
$exclude = ''; |
| 605 |
if (is_single()) { |
| 606 |
$id = get_the_ID(); |
| 607 |
$exclude = $id ? $id : ''; |
| 608 |
} |
| 609 |
if(isset($attr['queryExclude']) && $attr['queryExclude']) { |
| 610 |
$exclude = ($exclude ? $exclude.',' : '') . $attr['queryExclude']; |
| 611 |
} |
| 612 |
if ($exclude) { |
| 613 |
$query_args['post__not_in'] = explode(',', $exclude); |
| 614 |
} |
| 615 |
|
| 616 |
if(isset($attr['queryTax'])){ |
| 617 |
if(isset($attr['queryTaxValue'])){ |
| 618 |
$tax_value = (strlen($attr['queryTaxValue']) > 2) ? $attr['queryTaxValue'] : ($attr['queryTax'] == 'category' ? $attr['queryCat'] : $attr['queryTag']); |
| 619 |
$tax_value = is_array($tax_value) ? $tax_value : json_decode($tax_value); |
| 620 |
if(count($tax_value) > 0){ |
| 621 |
$relation = isset($attr['queryRelation']) ? $attr['queryRelation'] : 'OR'; |
| 622 |
$var = array('relation'=>$relation); |
| 623 |
foreach ($tax_value as $val) { |
| 624 |
$tax_name = $attr['queryTax'] == 'tag' ? 'post_tag' : $attr['queryTax']; // for compatibility |
| 625 |
$var[] = array('taxonomy'=> $tax_name, 'field' => 'slug', 'terms' => $val ); |
| 626 |
} |
| 627 |
if(count($var) > 1){ |
| 628 |
$query_args['tax_query'] = $var; |
| 629 |
} |
| 630 |
} |
| 631 |
} |
| 632 |
} |
| 633 |
|
| 634 |
if(isset($attr['queryQuick'])){ |
| 635 |
if($attr['queryQuick'] != ''){ |
| 636 |
$query_args = ultimate_post()->get_quick_query($attr, $query_args); |
| 637 |
} |
| 638 |
} |
| 639 |
|
| 640 |
if (isset($attr['queryOffset']) && $attr['queryOffset'] ) { |
| 641 |
$offset = $this->get_offset($attr['queryOffset'], $query_args); |
| 642 |
$query_args = array_merge($query_args, $offset); |
| 643 |
} |
| 644 |
|
| 645 |
if (isset($attr['queryAuthor']) && $attr['queryAuthor'] ) { |
| 646 |
$query_args['author'] = $attr['queryAuthor']; |
| 647 |
} |
| 648 |
|
| 649 |
|
| 650 |
$query_args['wpnonce'] = wp_create_nonce( 'ultp-nonce' ); |
| 651 |
|
| 652 |
return $query_args; |
| 653 |
} |
| 654 |
|
| 655 |
function get_offset($queryOffset, $query_args) { |
| 656 |
$query = array(); |
| 657 |
if ($query_args['paged'] > 1) { |
| 658 |
$offset_post = wp_get_recent_posts($query_args, OBJECT); |
| 659 |
if ( count($offset_post) > 0 ) { |
| 660 |
$offset = array(); |
| 661 |
for($x = count($offset_post); $x > count($offset_post) - $queryOffset; $x--){ |
| 662 |
$offset[] = $offset_post[$x-1]->ID; |
| 663 |
} |
| 664 |
$query['post__not_in'] = $offset; |
| 665 |
} |
| 666 |
} else { |
| 667 |
$query['offset'] = isset($queryOffset) ? $queryOffset : 0; |
| 668 |
} |
| 669 |
return $query; |
| 670 |
} |
| 671 |
|
| 672 |
|
| 673 |
/** |
| 674 |
* Get Page Number |
| 675 |
* |
| 676 |
* @since v.1.0.0 |
| 677 |
* @param | Attribute of the Query(ARRAY) | Post Number(ARRAY) |
| 678 |
* @return ARRAY |
| 679 |
*/ |
| 680 |
public function get_page_number($attr, $post_number) { |
| 681 |
if ($post_number > 0) { |
| 682 |
if (isset($attr['queryOffset']) && $attr['queryOffset']) { |
| 683 |
$post_number = $post_number - (int)$attr['queryOffset']; |
| 684 |
} |
| 685 |
$post_per_page = isset($attr['queryNumber']) ? ($attr['queryNumber'] ? $attr['queryNumber'] : 1) : 3; |
| 686 |
$pages = ceil($post_number/$post_per_page); |
| 687 |
return $pages ? $pages : 1; |
| 688 |
}else{ |
| 689 |
return 1; |
| 690 |
} |
| 691 |
} |
| 692 |
|
| 693 |
|
| 694 |
/** |
| 695 |
* Get Image Size |
| 696 |
* |
| 697 |
* @since v.1.0.0 |
| 698 |
* @param | Attribute of the Query(ARRAY) | Post Number(ARRAY) |
| 699 |
* @return ARRAY |
| 700 |
*/ |
| 701 |
public function get_image_size() { |
| 702 |
$sizes = get_intermediate_image_sizes(); |
| 703 |
$filter = array('full' => 'Full'); |
| 704 |
foreach ($sizes as $value) { |
| 705 |
$filter[$value] = ucwords(str_replace(array('_', '-'), array(' ', ' '), $value)); |
| 706 |
} |
| 707 |
return $filter; |
| 708 |
} |
| 709 |
|
| 710 |
|
| 711 |
/** |
| 712 |
* Get All PostType Registered |
| 713 |
* |
| 714 |
* @since v.1.0.0 |
| 715 |
* @param | Attribute of the Query(ARRAY) | Post Number(ARRAY) |
| 716 |
* @return ARRAY |
| 717 |
*/ |
| 718 |
public function get_post_type() { |
| 719 |
$post_type = get_post_types( '', 'names' ); |
| 720 |
return array_diff($post_type, array( 'attachment', 'revision', 'nav_menu_item', 'custom_css', 'customize_changeset', 'oembed_cache', 'user_request', 'wp_block' )); |
| 721 |
} |
| 722 |
|
| 723 |
|
| 724 |
/** |
| 725 |
* Get Pagination HTML |
| 726 |
* |
| 727 |
* @since v.1.0.0 |
| 728 |
* @param | pages (NUMBER) | Pagination Nav (STRING) | Pagination Text | |
| 729 |
* @return STRING |
| 730 |
*/ |
| 731 |
public function pagination($pages = '', $paginationNav = '', $paginationText = '') { |
| 732 |
$html = ''; |
| 733 |
$showitems = 3; |
| 734 |
$paged = is_front_page() ? get_query_var('page') : get_query_var('paged'); |
| 735 |
$paged = $paged ? $paged : 1; |
| 736 |
if($pages == '') { |
| 737 |
global $wp_query; |
| 738 |
$pages = $wp_query->max_num_pages; |
| 739 |
if(!$pages) { |
| 740 |
$pages = 1; |
| 741 |
} |
| 742 |
} |
| 743 |
$data = ($paged>=3?[($paged-1),$paged,$paged+1]:[1,2,3]); |
| 744 |
|
| 745 |
$paginationText = explode('|', $paginationText); |
| 746 |
|
| 747 |
$prev_text = isset($paginationText[0]) ? $paginationText[0] : __("Previous", "ultimate-post"); |
| 748 |
$next_text = isset($paginationText[1]) ? $paginationText[1] : __("Next", "ultimate-post"); |
| 749 |
|
| 750 |
if(1 != $pages) { |
| 751 |
$html .= '<ul class="ultp-pagination">'; |
| 752 |
$display_none = 'style="display:none"'; |
| 753 |
if($pages > 4) { |
| 754 |
$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>'; |
| 755 |
} |
| 756 |
if($pages > 4){ |
| 757 |
$html .= '<li class="ultp-first-pages" '.($paged<2?$display_none:"").' data-current="1"><a href="'.get_pagenum_link(1).'">1</a></li>'; |
| 758 |
} |
| 759 |
if($pages > 4){ |
| 760 |
$html .= '<li class="ultp-first-dot" '.($paged<2? $display_none : "").'><a href="#">...</a></li>'; |
| 761 |
} |
| 762 |
foreach ($data as $i) { |
| 763 |
if($pages >= $i){ |
| 764 |
$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>'; |
| 765 |
} |
| 766 |
} |
| 767 |
if($pages > 4){ |
| 768 |
$html .= '<li class="ultp-last-dot" '.($pages<=$paged+1?$display_none:"").'><a href="#">...</a></li>'; |
| 769 |
} |
| 770 |
if($pages > 4){ |
| 771 |
$html .= '<li class="ultp-last-pages" '.($pages<=$paged+1?$display_none:"").' data-current="'.$pages.'"><a href="'.get_pagenum_link($pages).'">'.$pages.'</a></li>'; |
| 772 |
} |
| 773 |
if ($paged != $pages) { |
| 774 |
$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>'; |
| 775 |
} |
| 776 |
$html .= '</ul>'; |
| 777 |
} |
| 778 |
return $html; |
| 779 |
} |
| 780 |
|
| 781 |
|
| 782 |
/** |
| 783 |
* Get Excerpt Word |
| 784 |
* |
| 785 |
* @since v.1.0.0 |
| 786 |
* @param NUMBER | Character Length |
| 787 |
* @return STRING |
| 788 |
*/ |
| 789 |
public function excerpt_word($charlength = 200) { |
| 790 |
$html = ''; |
| 791 |
$charlength++; |
| 792 |
$excerpt = get_the_excerpt(); |
| 793 |
if ( mb_strlen( $excerpt ) > $charlength ) { |
| 794 |
$subex = mb_substr( $excerpt, 0, $charlength - 5 ); |
| 795 |
$exwords = explode( ' ', $subex ); |
| 796 |
$excut = - ( mb_strlen( $exwords[ count( $exwords ) - 1 ] ) ); |
| 797 |
if ( $excut < 0 ) { |
| 798 |
$html = mb_substr( $subex, 0, $excut ); |
| 799 |
} else { |
| 800 |
$html = $subex; |
| 801 |
} |
| 802 |
$html .= '...'; |
| 803 |
} else { |
| 804 |
$html = $excerpt; |
| 805 |
} |
| 806 |
return $html; |
| 807 |
} |
| 808 |
|
| 809 |
|
| 810 |
/** |
| 811 |
* Get Taxonomy Lists |
| 812 |
* |
| 813 |
* @since v.1.0.0 |
| 814 |
* @param STRING | Taxonomy Slug |
| 815 |
* @return ARRAY |
| 816 |
*/ |
| 817 |
public function taxonomy( $prams = 'category' ) { |
| 818 |
$data = array(); |
| 819 |
$terms = get_terms( $prams, array( |
| 820 |
'hide_empty' => false, |
| 821 |
)); |
| 822 |
if( !is_wp_error($terms) ){ |
| 823 |
foreach ($terms as $val) { |
| 824 |
$data[urldecode_deep($val->slug)] = $val->name; |
| 825 |
} |
| 826 |
} |
| 827 |
return $data; |
| 828 |
} |
| 829 |
|
| 830 |
|
| 831 |
/** |
| 832 |
* Get Taxonomy Data Lists |
| 833 |
* |
| 834 |
* @since v.1.0.0 |
| 835 |
* @param OBJECT | Taxonomy Object |
| 836 |
* @return ARRAY |
| 837 |
*/ |
| 838 |
public function get_tax_data($terms) { |
| 839 |
$temp = array(); |
| 840 |
$image = ''; |
| 841 |
$thumbnail_id = get_term_meta( $terms->term_id, 'ultp_category_image', true ); |
| 842 |
if( $thumbnail_id ){ |
| 843 |
$image = wp_get_attachment_url( $thumbnail_id ); |
| 844 |
} |
| 845 |
$temp['url'] = get_term_link($terms); |
| 846 |
$temp['name'] = $terms->name; |
| 847 |
$temp['desc'] = $terms->description; |
| 848 |
$temp['count'] = $terms->count; |
| 849 |
$temp['image'] = $image; |
| 850 |
$color = get_term_meta($terms->term_id, 'ultp_category_color', true); |
| 851 |
$temp['color'] = $color ? $color : '#037fff'; |
| 852 |
return $temp; |
| 853 |
} |
| 854 |
|
| 855 |
public function get_category_data($catSlug, $number = 40, $type = '', $tax_slug = 'category') { |
| 856 |
$data = array(); |
| 857 |
if($type == 'child'){ |
| 858 |
$image = ''; |
| 859 |
if (!empty($catSlug)) { |
| 860 |
foreach ($catSlug as $cat) { |
| 861 |
$parent_term = get_term_by('slug', $cat, $tax_slug); |
| 862 |
if (!empty($parent_term)) { |
| 863 |
$term_data = get_terms($tax_slug, array( |
| 864 |
'hide_empty' => true, |
| 865 |
'parent' => $parent_term->term_id |
| 866 |
)); |
| 867 |
if (!empty($term_data)) { |
| 868 |
foreach ($term_data as $terms) { |
| 869 |
$data[] = $this->get_tax_data($terms); |
| 870 |
} |
| 871 |
} |
| 872 |
} |
| 873 |
} |
| 874 |
} |
| 875 |
} else if ($type == 'parent') { |
| 876 |
$term_data = get_terms( $tax_slug, array( 'hide_empty' => true, 'number' => $number, 'parent' => 0 ) ); |
| 877 |
if (!empty($term_data)) { |
| 878 |
foreach ($term_data as $terms) { |
| 879 |
$data[] = $this->get_tax_data($terms); |
| 880 |
} |
| 881 |
} |
| 882 |
} else if ($type == 'custom') { |
| 883 |
foreach ($catSlug as $cat) { |
| 884 |
$terms = get_term_by('slug', $cat, $tax_slug); |
| 885 |
if (!empty($terms)) { |
| 886 |
$data[] = $this->get_tax_data($terms); |
| 887 |
} |
| 888 |
} |
| 889 |
} else { |
| 890 |
$term_data = get_terms($tax_slug, array('hide_empty' => true, 'number' => $number)); |
| 891 |
if (!empty($term_data)) { |
| 892 |
foreach ($term_data as $terms) { |
| 893 |
$data[] = $this->get_tax_data($terms); |
| 894 |
} |
| 895 |
} |
| 896 |
} |
| 897 |
return $data; |
| 898 |
} |
| 899 |
|
| 900 |
|
| 901 |
/** |
| 902 |
* Get Next Previous HTML |
| 903 |
* |
| 904 |
* @since v.1.0.0 |
| 905 |
* @param OBJECT | Taxonomy Object |
| 906 |
* @return STRING |
| 907 |
*/ |
| 908 |
public function next_prev() { |
| 909 |
$html = ''; |
| 910 |
$html .= '<ul>'; |
| 911 |
$html .= '<li>'; |
| 912 |
$html .= '<a class="ultp-prev-action ultp-disable" href="#">'; |
| 913 |
$html .= ultimate_post()->svg_icon('leftAngle2').'<span class="screen-reader-text">'.__("Previous", "ultimate-post").'</span>'; |
| 914 |
$html .= '</a>'; |
| 915 |
$html .= '</li>'; |
| 916 |
$html .= '<li>'; |
| 917 |
$html .= '<a class="ultp-next-action">'; |
| 918 |
$html .= ultimate_post()->svg_icon('rightAngle2').'<span class="screen-reader-text">'.__("Next", "ultimate-post").'</span>'; |
| 919 |
$html .= '</a>'; |
| 920 |
$html .= '</li>'; |
| 921 |
$html .= '</ul>'; |
| 922 |
return $html; |
| 923 |
} |
| 924 |
|
| 925 |
|
| 926 |
/** |
| 927 |
* Get Loading HTML |
| 928 |
* |
| 929 |
* @since v.1.0.0 |
| 930 |
* @param NULL |
| 931 |
* @return STRING |
| 932 |
*/ |
| 933 |
public function loading(){ |
| 934 |
$html = ''; |
| 935 |
$style = ultimate_post()->get_setting('preloader_style'); |
| 936 |
if( $style == 'style2' ){ |
| 937 |
$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 |
| 938 |
} else { |
| 939 |
$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>'; |
| 940 |
} |
| 941 |
return '<div class="ultp-loading">'.$html.'</div>'; |
| 942 |
} |
| 943 |
|
| 944 |
|
| 945 |
/** |
| 946 |
* Get Filter HTML |
| 947 |
* |
| 948 |
* @since v.1.0.0 |
| 949 |
* @param | Filter Text (STRING) | Filter Type (STRING) | Filter Value (ARRAY) | Filter Cat (ARRAY) | Filter Tag (ARRAY) | |
| 950 |
* @return STRING |
| 951 |
*/ |
| 952 |
public function filter($filterText = '', $filterType = '', $filterValue = '[]', $filterCat = [], $filterTag = [], $filterMobileText = '...'){ |
| 953 |
$html = ''; |
| 954 |
$html .= '<ul class="ultp-flex-menu" data-name="'.($filterMobileText ? $filterMobileText : ' ').'">'; |
| 955 |
|
| 956 |
$filterType = $filterType == 'tag' ? 'post_tag' : $filterType; // for compatibility |
| 957 |
|
| 958 |
$cat = $this->taxonomy($filterType); |
| 959 |
if($filterText){ |
| 960 |
$html .= '<li class="filter-item"><a data-taxonomy="" href="#">'.$filterText.'</a></li>'; |
| 961 |
} |
| 962 |
|
| 963 |
if ($filterValue) { |
| 964 |
$filterValue = strlen($filterValue) > 2 ? $filterValue : ($filterType == 'category' ? $filterCat : $filterTag); |
| 965 |
$filterValue = is_array($filterValue) ? $filterValue : json_decode($filterValue); |
| 966 |
foreach ($filterValue as $val) { |
| 967 |
$html .= '<li class="filter-item"><a data-taxonomy="'.$val.'" href="#">'.(isset($cat[$val]) ? $cat[$val] : $val).'</a></li>'; |
| 968 |
} |
| 969 |
} |
| 970 |
$html .= '</ul>'; |
| 971 |
return $html; |
| 972 |
} |
| 973 |
|
| 974 |
|
| 975 |
/** |
| 976 |
* Check License Status |
| 977 |
* |
| 978 |
* @since v.2.4.2 |
| 979 |
* @return BOOLEAN | Is pro license active or not |
| 980 |
*/ |
| 981 |
public function is_lc_active() { |
| 982 |
if (function_exists('ultimate_post_pro')) { |
| 983 |
return get_option('edd_ultp_license_status') == 'valid' ? true : false; |
| 984 |
} |
| 985 |
if (get_transient( 'ulpt_theme_enable' ) == 'integration') { |
| 986 |
return true; |
| 987 |
} |
| 988 |
return false; |
| 989 |
} |
| 990 |
|
| 991 |
|
| 992 |
/** |
| 993 |
* Get SVG Icon |
| 994 |
* |
| 995 |
* @since v.1.0.0 |
| 996 |
* @param STRING | Icon Key |
| 997 |
* @return STRING | Icon SVG |
| 998 |
*/ |
| 999 |
public function svg_icon($icons = ''){ |
| 1000 |
$icon_lists = array( |
| 1001 |
'eye' => file_get_contents(ULTP_PATH.'assets/img/svg/eye.svg'), |
| 1002 |
'user' => file_get_contents(ULTP_PATH.'assets/img/svg/user.svg'), |
| 1003 |
'calendar' => file_get_contents(ULTP_PATH.'assets/img/svg/calendar.svg'), |
| 1004 |
'comment' => file_get_contents(ULTP_PATH.'assets/img/svg/comment.svg'), |
| 1005 |
'book' => file_get_contents(ULTP_PATH.'assets/img/svg/book.svg'), |
| 1006 |
'tag' => file_get_contents(ULTP_PATH.'assets/img/svg/tag.svg'), |
| 1007 |
'clock' => file_get_contents(ULTP_PATH.'assets/img/svg/clock.svg'), |
| 1008 |
'leftAngle' => file_get_contents(ULTP_PATH.'assets/img/svg/leftAngle.svg'), |
| 1009 |
'rightAngle' => file_get_contents(ULTP_PATH.'assets/img/svg/rightAngle.svg'), |
| 1010 |
'leftAngle2' => file_get_contents(ULTP_PATH.'assets/img/svg/leftAngle2.svg'), |
| 1011 |
'rightAngle2' => file_get_contents(ULTP_PATH.'assets/img/svg/rightAngle2.svg'), |
| 1012 |
'leftArrowLg' => file_get_contents(ULTP_PATH.'assets/img/svg/leftArrowLg.svg'), |
| 1013 |
'refresh' => file_get_contents(ULTP_PATH.'assets/img/svg/refresh.svg'), |
| 1014 |
'rightArrowLg' => file_get_contents(ULTP_PATH.'assets/img/svg/rightArrowLg.svg'), |
| 1015 |
); |
| 1016 |
if($icons){ |
| 1017 |
return $icon_lists[ $icons ]; |
| 1018 |
} |
| 1019 |
} |
| 1020 |
|
| 1021 |
/** |
| 1022 |
* Get SEO Meta |
| 1023 |
* |
| 1024 |
* @since v.2.4.3 |
| 1025 |
* @param NUMBER | Post ID |
| 1026 |
* @return STRING | SEO Meta Description or Excerpt |
| 1027 |
*/ |
| 1028 |
public function get_excerpt($post_id = 0, $showSeoMeta = 0, $showFullExcerpt = 0, $excerptLimit = 55) { |
| 1029 |
$html = ''; |
| 1030 |
if ($showSeoMeta) { |
| 1031 |
$str = ''; |
| 1032 |
if( function_exists('ultimate_post_pro') ) { |
| 1033 |
if (ultimate_post()->get_setting('ultp_yoast') == 'true') { |
| 1034 |
$str = method_exists( ultimate_post_pro(), 'get_yoast_meta' ) ? ultimate_post_pro()->get_yoast_meta($post_id) : ''; |
| 1035 |
} else if (ultimate_post()->get_setting('ultp_rankmath') == 'true') { |
| 1036 |
$str = method_exists( ultimate_post_pro(), 'get_rankmath_meta' ) ? ultimate_post_pro()->get_rankmath_meta($post_id) : ''; |
| 1037 |
} else if (ultimate_post()->get_setting('ultp_aioseo') == 'true') { |
| 1038 |
$str = method_exists( ultimate_post_pro(), 'get_aioseo_meta' ) ? ultimate_post_pro()->get_aioseo_meta($post_id) : ''; |
| 1039 |
} else if (ultimate_post()->get_setting('ultp_seopress') == 'true') { |
| 1040 |
$str = method_exists( ultimate_post_pro(), 'get_seopress_meta' ) ? ultimate_post_pro()->get_seopress_meta($post_id) : ''; |
| 1041 |
} else if (ultimate_post()->get_setting('ultp_squirrly') == 'true') { |
| 1042 |
$str = method_exists( ultimate_post_pro(), 'get_squirrly_meta' ) ? ultimate_post_pro()->get_squirrly_meta($post_id) : ''; |
| 1043 |
} |
| 1044 |
} |
| 1045 |
$html = $str ? $str : ultimate_post()->excerpt($post_id, $excerptLimit); |
| 1046 |
} else { |
| 1047 |
if ( $showFullExcerpt == 0 ) { |
| 1048 |
$html = ultimate_post()->excerpt($post_id, $excerptLimit); |
| 1049 |
} else { |
| 1050 |
$html = get_the_excerpt(); |
| 1051 |
} |
| 1052 |
} |
| 1053 |
return $html; |
| 1054 |
} |
| 1055 |
|
| 1056 |
} |
| 1057 |
|