| @@ -1,15 +1,295 @@ | ||
| 1 | 1 | <?php |
| 2 | +/** | |
| 3 | + * Common Functions. | |
| 4 | + * | |
| 5 | + * @package ULTP\Functions | |
| 6 | + * @since v.1.0.0 | |
| 7 | + */ | |
| 2 | 8 | namespace ULTP; |
| 3 | 9 | |
| 4 | 10 | defined('ABSPATH') || exit; |
| 5 | 11 | |
| 12 | +/** | |
| 13 | + * Functions class. | |
| 14 | + */ | |
| 15 | + | |
| 6 | 16 | class Functions{ |
| 7 | 17 | |
| 8 | - public function __construct(){ | |
| 9 | - $GLOBALS['ultp_settings'] = get_option('ultp_options'); | |
| 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 | + } | |
| 10 | 27 | } |
| 11 | 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 | + */ | |
| 12 | 292 | public function reusable_id($post_id){ |
| 13 | 293 | $reusable_id = array(); |
| 14 | 294 | if($post_id){ |
| 15 | 295 | $post = get_post($post_id); |
| @@ -24,9 +304,16 @@ | ||
| 24 | 304 | } |
| 25 | 305 | return $reusable_id; |
| 26 | 306 | } |
| 27 | 307 | |
| 28 | - public function set_css_style($post_id){ | |
| 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){ | |
| 29 | 316 | if( $post_id ){ |
| 30 | 317 | $upload_dir_url = wp_get_upload_dir(); |
| 31 | 318 | $upload_css_dir_url = trailingslashit( $upload_dir_url['basedir'] ); |
| 32 | 319 | $css_dir_path = $upload_css_dir_url . "ultimate-post/ultp-css-{$post_id}.css"; |
| @@ -41,29 +328,41 @@ | ||
| 41 | 328 | foreach ( $reusable_id as $id ) { |
| 42 | 329 | $reusable_dir_path = $upload_css_dir_url."ultimate-post/ultp-css-{$id}.css"; |
| 43 | 330 | if (file_exists( $reusable_dir_path )) { |
| 44 | 331 | $css_url = $css_dir_url . "ultimate-post/ultp-css-{$id}.css"; |
| 45 | - wp_enqueue_style( "ultp-post-{$id}", $css_url, array(), ULTP_VER, 'all' ); | |
| 332 | + wp_enqueue_style( "ultp-post-{$id}", $css_url, array(), ultimate_post()->get_setting('save_version'), 'all' ); | |
| 46 | 333 | }else{ |
| 47 | 334 | $css = get_post_meta($id, '_ultp_css', true); |
| 48 | 335 | if( $css ) { |
| 49 | - wp_enqueue_style("ultp-post-{$id}", $css, false, ULTP_VER); | |
| 336 | + wp_enqueue_style("ultp-post-{$id}", $css, false, ultimate_post()->get_setting('save_version')); | |
| 50 | 337 | } |
| 51 | 338 | } |
| 52 | 339 | } |
| 53 | 340 | |
| 54 | - if ( file_exists( $css_dir_path ) ) { | |
| 55 | - $css_url = $css_dir_url . "ultimate-post/ultp-css-{$post_id}.css"; | |
| 56 | - wp_enqueue_style( "ultp-post-{$post_id}", $css_url, array(), ULTP_VER, 'all' ); | |
| 57 | - } else { | |
| 58 | - $css = get_post_meta($post_id, '_ultp_css', true); | |
| 59 | - if( $css ) { | |
| 60 | - wp_enqueue_style("ultp-post-{$post_id}", $css, false, ULTP_VER); | |
| 61 | - } | |
| 62 | - } | |
| 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 | + } | |
| 63 | 354 | } |
| 64 | 355 | } |
| 65 | 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 | + */ | |
| 66 | 365 | public function get_setting($key = ''){ |
| 67 | 366 | $data = $GLOBALS['ultp_settings']; |
| 68 | 367 | if ($key != '') { |
| 69 | 368 | return isset($data[$key]) ? $data[$key] : ''; |
| @@ -71,8 +370,16 @@ | ||
| 71 | 370 | return $data; |
| 72 | 371 | } |
| 73 | 372 | } |
| 74 | 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 | + */ | |
| 75 | 382 | public function set_setting($key = '', $val = '') { |
| 76 | 383 | if($key != ''){ |
| 77 | 384 | $data = $GLOBALS['ultp_settings']; |
| 78 | 385 | $data[$key] = $val; |
| @@ -80,58 +387,85 @@ | ||
| 80 | 387 | $GLOBALS['ultp_settings'] = $data; |
| 81 | 388 | } |
| 82 | 389 | } |
| 83 | 390 | |
| 84 | - public function get_image_html($url = '', $size = 'full', $class = '', $alt = ''){ | |
| 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 = ''){ | |
| 85 | 400 | $alt = $alt ? ' alt="'.$alt.'" ' : ''; |
| 86 | - if( function_exists('ultimate_post_pro') ){ | |
| 87 | - $addon_enable = ultimate_post()->get_setting(); | |
| 88 | - if(isset($addon_enable['addons_imageloading']) && $addon_enable['addons_imageloading'] == 'true'){ | |
| 89 | - $class = $class ? ' class="ultp-lazy '.$class.'" ' : ' class="ultp-lazy" '; | |
| 90 | - return '<img loading="lazy" loading="lazy" '.$class.$alt.' '.ultimate_post_pro()->get_size($size).' src="'.ultimate_post_pro()->img_placeholder($size).'" data-src="'.$url.'"/>'; | |
| 91 | - }else{ | |
| 92 | - $class = $class ? ' class="'.$class.'" ' : ''; | |
| 93 | - return '<img loading="lazy" '.$class.$alt.' src="'.$url.'" />'; | |
| 94 | - } | |
| 95 | - } else { | |
| 96 | - $class = $class ? ' class="'.$class.'" ' : ''; | |
| 97 | - return '<img loading="lazy" '.$class.$alt.' src="'.$url.'" />'; | |
| 98 | - } | |
| 401 | + $lazy_data = $lazy ? ' loading="lazy"' : ''; | |
| 402 | + $class = $class ? ' class="'.$class.'" ' : ''; | |
| 403 | + return '<img '.$lazy_data.$class.$alt.' src="'.$url.'" />'; | |
| 99 | 404 | } |
| 100 | 405 | |
| 101 | - public function get_image($attach_id, $size = 'full', $class = '', $alt = ''){ | |
| 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 = ''){ | |
| 102 | 415 | $alt = $alt ? ' alt="'.$alt.'" ' : ''; |
| 103 | - if( function_exists('ultimate_post_pro') ){ | |
| 104 | - $addon_enable = ultimate_post()->get_setting(); | |
| 105 | - if(isset($addon_enable['addons_imageloading']) && $addon_enable['addons_imageloading'] == 'true'){ | |
| 106 | - $class = $class ? ' class="ultp-lazy '.$class.'" ' : ' class="ultp-lazy" '; | |
| 107 | - return '<img loading="lazy" '.$class.$alt.' '.ultimate_post_pro()->get_size($size).' src="'.ultimate_post_pro()->img_placeholder($size).'" data-src="'.wp_get_attachment_image_url( $attach_id, $size ).'"/>'; | |
| 108 | - }else{ | |
| 109 | - $class = $class ? ' class="'.$class.'" ' : ''; | |
| 110 | - return '<img loading="lazy" '.$class.$alt.' src="'.wp_get_attachment_image_url( $attach_id, $size ).'" />'; | |
| 111 | - } | |
| 112 | - } else { | |
| 113 | - $class = $class ? ' class="'.$class.'" ' : ''; | |
| 114 | - return '<img loading="lazy" '.$class.$alt.' src="'.wp_get_attachment_image_url( $attach_id, $size ).'" />'; | |
| 115 | - } | |
| 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 ).'" />'; | |
| 116 | 421 | } |
| 117 | 422 | |
| 118 | - // Init data | |
| 423 | + | |
| 424 | + /** | |
| 425 | + * Setup Initial Data Set | |
| 426 | + * | |
| 427 | + * @since v.1.0.0 | |
| 428 | + * @return NULL | |
| 429 | + */ | |
| 119 | 430 | public function init_set_data(){ |
| 120 | 431 | $data = get_option( 'ultp_options', array() ); |
| 121 | 432 | $init_data = array( |
| 122 | 433 | 'css_save_as' => 'wp_head', |
| 123 | 434 | 'preloader_style' => 'style1', |
| 124 | - 'preloader_color' => '#1740f5', | |
| 435 | + 'preloader_color' => '#037fff', | |
| 125 | 436 | 'container_width' => '1140', |
| 126 | - 'editor_container' => 'full_width', | |
| 127 | 437 | 'hide_import_btn' => '', |
| 438 | + 'disable_image_size'=> '', | |
| 439 | + 'disable_view_cookies' => '', | |
| 128 | 440 | 'ultp_templates' => 'true', |
| 129 | - 'ultp_elementor' => '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) | |
| 130 | 464 | ); |
| 131 | 465 | if (empty($data)) { |
| 132 | 466 | update_option('ultp_options', $init_data); |
| 133 | - $GLOBALS['wopb_settings'] = $init_data; | |
| 467 | + $GLOBALS['ultp_settings'] = $init_data; | |
| 134 | 468 | } else { |
| 135 | 469 | foreach ($init_data as $key => $single) { |
| 136 | 470 | if (!isset($data[$key])) { |
| 137 | 471 | $data[$key] = $single; |
| @@ -137,19 +471,247 @@ | ||
| 137 | 471 | $data[$key] = $single; |
| 138 | 472 | } |
| 139 | 473 | } |
| 140 | 474 | update_option('ultp_options', $data); |
| 141 | - $GLOBALS['wopb_settings'] = $data; | |
| 475 | + $GLOBALS['ultp_settings'] = $data; | |
| 142 | 476 | } |
| 143 | 477 | } |
| 144 | 478 | |
| 145 | - // Excerpt | |
| 479 | + | |
| 480 | + /** | |
| 481 | + * Get Excerpt Text | |
| 482 | + * | |
| 483 | + * @since v.1.0.0 | |
| 484 | + * @param | Post ID (STRING) | Limit (NUMBER) | |
| 485 | + * @return STRING | |
| 486 | + */ | |
| 146 | 487 | public function excerpt( $post_id, $limit = 55 ) { |
| 147 | 488 | return apply_filters( 'the_excerpt', wp_trim_words( get_the_content( $post_id ) , $limit ) ); |
| 148 | 489 | } |
| 149 | 490 | |
| 150 | - // Query Builder | |
| 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 | + */ | |
| 151 | 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 | + $archive_query['posts_per_page'] = isset($attr['queryNumber']) ? $attr['queryNumber'] : 3; | |
| 647 | + $archive_query['paged'] = isset($attr['paged']) ? $attr['paged'] : 1; | |
| 648 | + if (isset($attr['queryOffset']) && $attr['queryOffset'] ) { | |
| 649 | + $offset = $this->get_offset($attr['queryOffset'], $archive_query); | |
| 650 | + $archive_query = array_merge($archive_query, $offset); | |
| 651 | + } | |
| 652 | + | |
| 653 | + // Include Remove from Version 2.5.4 | |
| 654 | + if (isset($attr['queryInclude']) && $attr['queryInclude']) { | |
| 655 | + $_include = explode(',', $attr['queryInclude']); | |
| 656 | + if (is_array($_include) && count($_include)) { | |
| 657 | + $archive_query['post__in'] = isset($archive_query['post__in']) ? array_merge($archive_query['post__in'], $_include) : $_include; | |
| 658 | + $archive_query['ignore_sticky_posts'] = 1; | |
| 659 | + $archive_query['orderby'] = 'post__in'; | |
| 660 | + } | |
| 661 | + } | |
| 662 | + | |
| 663 | + if (isset($attr['queryExclude']) && $attr['queryExclude']) { | |
| 664 | + $_exclude = (substr($attr['queryExclude'], 0, 1) === "[") ? $this->get_value(json_decode($attr['queryExclude'])) : explode(',', $attr['queryExclude']); | |
| 665 | + if (is_array($_exclude) && count($_exclude)) { | |
| 666 | + $archive_query['post__not_in'] = isset($archive_query['post__not_in']) ? array_merge($archive_query['post__not_in'], $_exclude) : $_exclude; | |
| 667 | + } | |
| 668 | + } | |
| 669 | + | |
| 670 | + | |
| 671 | + if(isset($attr['querySticky']) && $attr['querySticky']) { | |
| 672 | + if (filter_var($attr['querySticky'], FILTER_VALIDATE_BOOLEAN)) { | |
| 673 | + $sticky = get_option( 'sticky_posts', [] ); | |
| 674 | + $archive_query['post__not_in'] = isset($archive_query['post__not_in']) ? array_merge($archive_query['post__not_in'], $sticky) : $sticky; | |
| 675 | + } | |
| 676 | + } | |
| 677 | + | |
| 678 | + $archive_query['post_status'] = 'publish'; | |
| 679 | + | |
| 680 | + if(!isset($archive_query['orderby'])) { | |
| 681 | + $archive_query['orderby'] = isset($attr['queryOrderBy']) ? $attr['queryOrderBy'] : 'date'; | |
| 682 | + } | |
| 683 | + | |
| 684 | + // Quick Query Support for Builder | |
| 685 | + if (isset($attr['queryQuick'])) { | |
| 686 | + if ($attr['queryQuick'] != '') { | |
| 687 | + $archive_query = ultimate_post()->get_quick_query($attr, $archive_query); | |
| 688 | + } | |
| 689 | + } | |
| 690 | + | |
| 691 | + if (!isset($attr['ajaxCall'])) { | |
| 692 | + if(isset($attr['filterShow']) && $attr['filterShow']) { | |
| 693 | + if(isset($attr['filterType']) && isset($attr['filterValue'])) { | |
| 694 | + $filterValue = strlen($attr['filterValue']) > 2 ? $attr['filterValue'] : []; | |
| 695 | + $filterValue = is_array($filterValue) ? $filterValue : json_decode($filterValue); | |
| 696 | + if (count($filterValue) > 0 && $attr['filterType']) { | |
| 697 | + $final = array('relation' => 'OR'); | |
| 698 | + foreach ($filterValue as $key => $val) { | |
| 699 | + $final[] = array( | |
| 700 | + 'taxonomy' => $attr['filterType'], | |
| 701 | + 'field' => 'slug', | |
| 702 | + 'terms' => $val, | |
| 703 | + ); | |
| 704 | + } | |
| 705 | + $archive_query['tax_query'] = $final; | |
| 706 | + } | |
| 707 | + } | |
| 708 | + } | |
| 709 | + } | |
| 710 | + | |
| 711 | + return apply_filters('ultp_archive_query', $archive_query); | |
| 712 | + } | |
| 713 | + | |
| 152 | 714 | $query_args = array( |
| 153 | 715 | 'posts_per_page' => isset($attr['queryNumber']) ? $attr['queryNumber'] : 3, |
| 154 | 716 | 'post_type' => isset($attr['queryType']) ? $attr['queryType'] : 'post', |
| 155 | 717 | 'orderby' => isset($attr['queryOrderBy']) ? $attr['queryOrderBy'] : 'date', |
| @@ -157,8 +719,44 @@ | ||
| 157 | 719 | 'paged' => isset($attr['paged']) ? $attr['paged'] : 1, |
| 158 | 720 | 'post_status' => 'publish' |
| 159 | 721 | ); |
| 160 | 722 | |
| 723 | + | |
| 724 | + if ($attr['queryType'] == 'posts') { | |
| 725 | + if (isset($attr['queryPosts']) && $attr['queryPosts']) { | |
| 726 | + unset($query_args['post_type']); | |
| 727 | + $data = json_decode(isset($attr['queryPosts'])?$attr['queryPosts']:'[]'); | |
| 728 | + $final = $this->get_value($data); | |
| 729 | + if (count($final) > 0) { | |
| 730 | + $query_args['post__in'] = $final; | |
| 731 | + $query_args['posts_per_page'] = -1; | |
| 732 | + } | |
| 733 | + $query_args['ignore_sticky_posts'] = 1; | |
| 734 | + return $query_args; | |
| 735 | + } | |
| 736 | + } else if ($attr['queryType'] == 'customPosts') { | |
| 737 | + if (isset($attr['queryCustomPosts']) && $attr['queryCustomPosts']) { | |
| 738 | + $query_args['post_type'] = $this->get_post_type(); | |
| 739 | + $data = json_decode(isset($attr['queryCustomPosts'])?$attr['queryCustomPosts']:'[]'); | |
| 740 | + $final = $this->get_value($data); | |
| 741 | + if (count($final) > 0) { | |
| 742 | + $query_args['post__in'] = $final; | |
| 743 | + $query_args['posts_per_page'] = -1; | |
| 744 | + } | |
| 745 | + $query_args['ignore_sticky_posts'] = 1; | |
| 746 | + return $query_args; | |
| 747 | + } | |
| 748 | + } | |
| 749 | + | |
| 750 | + if(isset($attr['queryExcludeAuthor']) && $attr['queryExcludeAuthor']){ | |
| 751 | + $data = json_decode(isset($attr['queryExcludeAuthor'])?$attr['queryExcludeAuthor']:'[]'); | |
| 752 | + $final = $this->get_value($data); | |
| 753 | + if (count($final) > 0) { | |
| 754 | + $query_args['author__not_in'] = $final; | |
| 755 | + } | |
| 756 | + } | |
| 757 | + | |
| 758 | + | |
| 161 | 759 | if(isset($attr['queryOrderBy']) && isset($attr['metaKey'])){ |
| 162 | 760 | if($attr['queryOrderBy'] == 'meta_value_num') { |
| 163 | 761 | $query_args['meta_key'] = $attr['metaKey']; |
| 164 | 762 | } |
| @@ -163,24 +761,41 @@ | ||
| 163 | 761 | $query_args['meta_key'] = $attr['metaKey']; |
| 164 | 762 | } |
| 165 | 763 | } |
| 166 | 764 | |
| 167 | - if(isset($attr['queryInclude']) && $attr['queryInclude']){ | |
| 168 | - $query_args['post__in'] = explode(',', $attr['queryInclude']); | |
| 169 | - $query_args['ignore_sticky_posts'] = 1; | |
| 170 | - $query_args['orderby'] = 'post__in'; | |
| 765 | + // Include Remove from Version 2.5.4 | |
| 766 | + if (isset($attr['queryInclude']) && $attr['queryInclude']) { | |
| 767 | + $_include = explode(',', $attr['queryInclude']); | |
| 768 | + if (is_array($_include) && count($_include)) { | |
| 769 | + $query_args['post__in'] = isset($query_args['post__in']) ? array_merge($query_args['post__in'], $_include) : $_include; | |
| 770 | + $query_args['ignore_sticky_posts'] = 1; | |
| 771 | + $query_args['orderby'] = 'post__in'; | |
| 772 | + } | |
| 171 | 773 | } |
| 172 | 774 | |
| 173 | - if(isset($attr['queryExclude']) && $attr['queryExclude']){ | |
| 174 | - $query_args['post__not_in'] = explode(',', $attr['queryExclude']); | |
| 175 | - } | |
| 176 | 775 | |
| 177 | 776 | if(isset($attr['queryTax'])){ |
| 178 | - if(isset($attr['queryCat'])){ | |
| 179 | - if($attr['queryTax'] == 'category' && !empty($attr['queryCat'])){ | |
| 180 | - $var = array('relation'=>'OR'); | |
| 181 | - foreach (json_decode($attr['queryCat']) as $val) { | |
| 182 | - $var[] = array('taxonomy'=>'category', 'field' => 'slug', 'terms' => $val ); | |
| 777 | + if(isset($attr['queryTaxValue'])){ | |
| 778 | + $tax_value = (strlen($attr['queryTaxValue']) > 2) ? $attr['queryTaxValue'] : []; | |
| 779 | + $tax_value = is_array($tax_value) ? $tax_value : json_decode($tax_value); | |
| 780 | + | |
| 781 | + $tax_value = (isset($tax_value[0]) && is_object($tax_value[0])) ? $this->get_value($tax_value) : $tax_value; | |
| 782 | + | |
| 783 | + if(count($tax_value) > 0){ | |
| 784 | + $relation = isset($attr['queryRelation']) ? $attr['queryRelation'] : 'OR'; | |
| 785 | + $var = array('relation'=>$relation); | |
| 786 | + foreach ($tax_value as $val) { | |
| 787 | + $tax_name = $attr['queryTax']; | |
| 788 | + // For Custom Terms | |
| 789 | + if ($attr['queryTax'] == 'multiTaxonomy') { | |
| 790 | + $temp = explode('###', $val); | |
| 791 | + if (isset($temp[1])) { | |
| 792 | + $val = $temp[1]; | |
| 793 | + $tax_name = $temp[0]; | |
| 794 | + } | |
| 795 | + } | |
| 796 | + | |
| 797 | + $var[] = array('taxonomy'=> $tax_name, 'field' => 'slug', 'terms' => $val ); | |
| 183 | 798 | } |
| 184 | 799 | if(count($var) > 1){ |
| 185 | 800 | $query_args['tax_query'] = $var; |
| 186 | 801 | } |
| @@ -185,51 +800,143 @@ | ||
| 185 | 800 | $query_args['tax_query'] = $var; |
| 186 | 801 | } |
| 187 | 802 | } |
| 188 | 803 | } |
| 189 | - if(isset($attr['queryTag'])){ | |
| 190 | - if($attr['queryTax'] == 'post_tag' && !empty($attr['queryTag'])){ | |
| 191 | - $var = array('relation'=>'OR'); | |
| 192 | - foreach (json_decode($attr['queryTag']) as $val) { | |
| 193 | - $var[] = array('taxonomy'=>'post_tag', 'field' => 'slug', 'terms' => $val ); | |
| 804 | + } | |
| 805 | + | |
| 806 | + | |
| 807 | + if (isset($attr['queryExcludeTerm']) && $attr['queryExcludeTerm']) { | |
| 808 | + $temp = json_decode($attr['queryExcludeTerm']); | |
| 809 | + $_term = []; | |
| 810 | + foreach ($temp as $val) { | |
| 811 | + $temp = explode('###', $val->value); | |
| 812 | + if (isset($temp[1])) { | |
| 813 | + if (array_key_exists($temp[0], $_term)) { | |
| 814 | + $_term[$temp[0]][] = $temp[1]; | |
| 815 | + } else { | |
| 816 | + $_term[$temp[0]] = array($temp[1]); | |
| 194 | 817 | } |
| 195 | - $query_args['tax_query'] = $var; | |
| 196 | 818 | } |
| 197 | 819 | } |
| 820 | + if (count($_term) > 0) { | |
| 821 | + $final = array('relation' => 'AND'); | |
| 822 | + foreach ($_term as $key => $val) { | |
| 823 | + $final[] = array( | |
| 824 | + 'taxonomy' => $key, | |
| 825 | + 'field' => 'slug', | |
| 826 | + 'terms' => $val, | |
| 827 | + 'operator' => 'NOT IN', | |
| 828 | + ); | |
| 829 | + } | |
| 830 | + | |
| 831 | + if (array_key_exists('tax_query', $query_args)) { | |
| 832 | + $query_args['tax_query'] = array( | |
| 833 | + 'relation' => 'AND', | |
| 834 | + $query_args['tax_query'] | |
| 835 | + ); | |
| 836 | + $query_args['tax_query'][] = $final; | |
| 837 | + } else { | |
| 838 | + $query_args['tax_query'] = $final; | |
| 839 | + } | |
| 840 | + } | |
| 198 | 841 | } |
| 199 | 842 | |
| 200 | - if(isset($attr['queryQuick'])){ | |
| 201 | - if($attr['queryQuick'] != ''){ | |
| 202 | - if(function_exists('ultimate_post_pro')){ | |
| 203 | - $query_args = ultimate_post_pro()->get_quick_query($attr, $query_args); | |
| 204 | - } | |
| 843 | + if (isset($attr['queryExclude']) && $attr['queryExclude']) { | |
| 844 | + $_exclude = (substr($attr['queryExclude'], 0, 1) === "[") ? $this->get_value(json_decode($attr['queryExclude'])) : explode(',', $attr['queryExclude']); | |
| 845 | + if (is_array($_exclude) && count($_exclude)) { | |
| 846 | + $query_args['post__not_in'] = isset($query_args['post__not_in']) ? array_merge($query_args['post__not_in'], $_exclude) : $_exclude; | |
| 205 | 847 | } |
| 206 | 848 | } |
| 207 | 849 | |
| 208 | - if(isset($attr['queryOffset']) && $attr['queryOffset'] ){ | |
| 209 | - if($query_args['paged'] > 1){ | |
| 210 | - $offset_post = wp_get_recent_posts($query_args, OBJECT); | |
| 211 | - if( count($offset_post) > 0 ){ | |
| 212 | - $offset = array(); | |
| 213 | - for($x = count($offset_post); $x > count($offset_post) - $attr['queryOffset']; $x--){ | |
| 214 | - $offset[] = $offset_post[$x-1]->ID; | |
| 850 | + if (isset($attr['queryUnique']) && $attr['queryUnique']) { | |
| 851 | + global $unique_ID; | |
| 852 | + if (isset($unique_ID[$attr['queryUnique']])) { | |
| 853 | + $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']]; | |
| 854 | + } | |
| 855 | + } | |
| 856 | + | |
| 857 | + if (isset($attr['queryQuick'])) { | |
| 858 | + if ($attr['queryQuick'] != '') { | |
| 859 | + $query_args = ultimate_post()->get_quick_query($attr, $query_args); | |
| 860 | + } | |
| 861 | + } | |
| 862 | + | |
| 863 | + if (isset($attr['queryOffset']) && $attr['queryOffset'] ) { | |
| 864 | + $offset = $this->get_offset($attr['queryOffset'], $query_args); | |
| 865 | + $query_args = array_merge($query_args, $offset); | |
| 866 | + } | |
| 867 | + | |
| 868 | + if (isset($attr['queryAuthor']) && $attr['queryAuthor'] ) { | |
| 869 | + $_include = (substr($attr['queryAuthor'], 0, 1) === "[") ? $this->get_value(json_decode($attr['queryAuthor'])) : explode(',', $attr['queryAuthor']); | |
| 870 | + if (is_array($_include) && count($_include)) { | |
| 871 | + $query_args['author__in'] = $_include; | |
| 872 | + } | |
| 873 | + } | |
| 874 | + | |
| 875 | + if(isset($attr['querySticky']) && $attr['querySticky']) { | |
| 876 | + if (filter_var($attr['querySticky'], FILTER_VALIDATE_BOOLEAN)) { | |
| 877 | + $sticky = get_option( 'sticky_posts', [] ); | |
| 878 | + $query_args['post__not_in'] = isset($query_args['post__not_in']) ? array_merge($query_args['post__not_in'], $sticky) : $sticky; | |
| 879 | + } | |
| 880 | + } | |
| 881 | + | |
| 882 | + if (!isset($attr['ajaxCall'])) { | |
| 883 | + if(isset($attr['filterShow']) && $attr['filterShow']) { | |
| 884 | + if(isset($attr['filterType']) && isset($attr['filterValue'])) { | |
| 885 | + $filterValue = strlen($attr['filterValue']) > 2 ? $attr['filterValue'] : []; | |
| 886 | + $filterValue = is_array($filterValue) ? $filterValue : json_decode($filterValue); | |
| 887 | + if (count($filterValue) > 0 && $attr['filterType']) { | |
| 888 | + $final = array('relation' => 'OR'); | |
| 889 | + foreach ($filterValue as $key => $val) { | |
| 890 | + $final[] = array( | |
| 891 | + 'taxonomy' => $attr['filterType'], | |
| 892 | + 'field' => 'slug', | |
| 893 | + 'terms' => $val, | |
| 894 | + // 'operator' => '=', | |
| 895 | + ); | |
| 896 | + } | |
| 897 | + $query_args['tax_query'] = $final; | |
| 215 | 898 | } |
| 216 | - $query_args['post__not_in'] = $offset; | |
| 217 | 899 | } |
| 218 | - }else{ | |
| 219 | - $query_args['offset'] = isset($attr['queryOffset']) ? $attr['queryOffset'] : 0; | |
| 220 | 900 | } |
| 221 | 901 | } |
| 222 | 902 | |
| 223 | 903 | $query_args['wpnonce'] = wp_create_nonce( 'ultp-nonce' ); |
| 224 | 904 | |
| 225 | - return $query_args; | |
| 905 | + return apply_filters('ultp_frontend_query', $query_args); | |
| 226 | 906 | } |
| 227 | 907 | |
| 908 | + function get_offset($queryOffset, $query_args) { | |
| 909 | + $query = array(); | |
| 910 | + if ($query_args['paged'] > 1) { | |
| 911 | + $offset_post = wp_get_recent_posts($query_args, OBJECT); | |
| 912 | + if ( count($offset_post) > 0 ) { | |
| 913 | + $offset = array(); | |
| 914 | + for($x = count($offset_post); $x > count($offset_post) - $queryOffset; $x--){ | |
| 915 | + $offset[] = $offset_post[$x-1]->ID; | |
| 916 | + } | |
| 917 | + $query['post__not_in'] = $offset; | |
| 918 | + } | |
| 919 | + } else { | |
| 920 | + $query['offset'] = isset($queryOffset) ? $queryOffset : 0; | |
| 921 | + } | |
| 922 | + return $query; | |
| 923 | + } | |
| 228 | 924 | |
| 925 | + | |
| 926 | + /** | |
| 927 | + * Get Page Number | |
| 928 | + * | |
| 929 | + * @since v.1.0.0 | |
| 930 | + * @param | Attribute of the Query(ARRAY) | Post Number(ARRAY) | |
| 931 | + * @return ARRAY | |
| 932 | + */ | |
| 229 | 933 | public function get_page_number($attr, $post_number) { |
| 230 | - if($post_number > 0){ | |
| 231 | - $post_per_page = isset($attr['queryNumber']) ? $attr['queryNumber'] : 3; | |
| 934 | + if ($post_number > 0) { | |
| 935 | + if (isset($attr['queryOffset']) && $attr['queryOffset']) { | |
| 936 | + $post_number = $post_number - (int)$attr['queryOffset']; | |
| 937 | + } | |
| 938 | + $post_per_page = isset($attr['queryNumber']) ? ($attr['queryNumber'] ? $attr['queryNumber'] : 1) : 3; | |
| 232 | 939 | $pages = ceil($post_number/$post_per_page); |
| 233 | 940 | return $pages ? $pages : 1; |
| 234 | 941 | }else{ |
| 235 | 942 | return 1; |
| @@ -235,29 +942,77 @@ | ||
| 235 | 942 | return 1; |
| 236 | 943 | } |
| 237 | 944 | } |
| 238 | 945 | |
| 946 | + | |
| 947 | + /** | |
| 948 | + * Get Image Size | |
| 949 | + * | |
| 950 | + * @since v.1.0.0 | |
| 951 | + * @param | Attribute of the Query(ARRAY) | Post Number(ARRAY) | |
| 952 | + * @return ARRAY | |
| 953 | + */ | |
| 239 | 954 | public function get_image_size() { |
| 240 | 955 | $sizes = get_intermediate_image_sizes(); |
| 241 | 956 | $filter = array('full' => 'Full'); |
| 242 | 957 | foreach ($sizes as $value) { |
| 243 | - $filter[$value] = ucwords(str_replace(array('_', '-'), array(' ', ' '), $value)); | |
| 958 | + $title = ucwords(str_replace(array('_', '-'), array(' ', ' '), $value)); | |
| 959 | + switch ($value) { | |
| 960 | + case 'thumbnail': | |
| 961 | + $title = $title.' [150x150]'; | |
| 962 | + break; | |
| 963 | + case 'medium': | |
| 964 | + $title = $title.' [300x300]'; | |
| 965 | + break; | |
| 966 | + case 'large': | |
| 967 | + $title = $title.' [1024x1024]'; | |
| 968 | + break; | |
| 969 | + case 'ultp_layout_landscape_large': | |
| 970 | + $title = $title.' [1200x800]'; | |
| 971 | + break; | |
| 972 | + case 'ultp_layout_landscape': | |
| 973 | + $title = $title.' [870x570]'; | |
| 974 | + break; | |
| 975 | + case 'ultp_layout_portrait': | |
| 976 | + $title = $title.' [600x900]'; | |
| 977 | + break; | |
| 978 | + case 'ultp_layout_square': | |
| 979 | + $title = $title.' [600x600]'; | |
| 980 | + break; | |
| 981 | + default: | |
| 982 | + break; | |
| 983 | + } | |
| 984 | + $filter[$value] = $title; | |
| 244 | 985 | } |
| 245 | 986 | return $filter; |
| 246 | 987 | } |
| 247 | 988 | |
| 248 | 989 | |
| 990 | + /** | |
| 991 | + * Get All PostType Registered | |
| 992 | + * | |
| 993 | + * @since v.1.0.0 | |
| 994 | + * @param | Attribute of the Query(ARRAY) | Post Number(ARRAY) | |
| 995 | + * @return ARRAY | |
| 996 | + */ | |
| 249 | 997 | public function get_post_type() { |
| 250 | - $post_type = get_post_types( '', 'names' ); | |
| 251 | - return array_diff($post_type, array( 'attachment', 'revision', 'nav_menu_item', 'custom_css', 'customize_changeset', 'oembed_cache', 'user_request', 'wp_block' )); | |
| 998 | + $post_type = get_post_types( ['public' => true], 'names' ); | |
| 999 | + return array_diff($post_type, array( 'attachment' )); | |
| 252 | 1000 | } |
| 253 | 1001 | |
| 254 | 1002 | |
| 255 | - // Pagination | |
| 256 | - public function pagination($pages = '', $paginationNav, $range = 1) { | |
| 1003 | + /** | |
| 1004 | + * Get Pagination HTML | |
| 1005 | + * | |
| 1006 | + * @since v.1.0.0 | |
| 1007 | + * @param | pages (NUMBER) | Pagination Nav (STRING) | Pagination Text | | |
| 1008 | + * @return STRING | |
| 1009 | + */ | |
| 1010 | + public function pagination($pages = '', $paginationNav = '', $paginationText = '') { | |
| 257 | 1011 | $html = ''; |
| 258 | 1012 | $showitems = 3; |
| 259 | - $paged = get_query_var('paged') ? get_query_var('paged') : 1; | |
| 1013 | + $paged = is_front_page() ? get_query_var('page') : get_query_var('paged'); | |
| 1014 | + $paged = $paged ? $paged : 1; | |
| 260 | 1015 | if($pages == '') { |
| 261 | 1016 | global $wp_query; |
| 262 | 1017 | $pages = $wp_query->max_num_pages; |
| 263 | 1018 | if(!$pages) { |
| @@ -265,14 +1020,18 @@ | ||
| 265 | 1020 | } |
| 266 | 1021 | } |
| 267 | 1022 | $data = ($paged>=3?[($paged-1),$paged,$paged+1]:[1,2,3]); |
| 268 | 1023 | |
| 1024 | + $paginationText = explode('|', $paginationText); | |
| 1025 | + | |
| 1026 | + $prev_text = isset($paginationText[0]) ? $paginationText[0] : __("Previous", "ultimate-post"); | |
| 1027 | + $next_text = isset($paginationText[1]) ? $paginationText[1] : __("Next", "ultimate-post"); | |
| 269 | 1028 | |
| 270 | 1029 | if(1 != $pages) { |
| 271 | 1030 | $html .= '<ul class="ultp-pagination">'; |
| 272 | 1031 | $display_none = 'style="display:none"'; |
| 273 | 1032 | if($pages > 4) { |
| 274 | - $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'?__("Previous", "ultimate-post"):"").'</a></li>'; | |
| 1033 | + $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>'; | |
| 275 | 1034 | } |
| 276 | 1035 | if($pages > 4){ |
| 277 | 1036 | $html .= '<li class="ultp-first-pages" '.($paged<2?$display_none:"").' data-current="1"><a href="'.get_pagenum_link(1).'">1</a></li>'; |
| 278 | 1037 | } |
| @@ -290,9 +1049,9 @@ | ||
| 290 | 1049 | if($pages > 4){ |
| 291 | 1050 | $html .= '<li class="ultp-last-pages" '.($pages<=$paged+1?$display_none:"").' data-current="'.$pages.'"><a href="'.get_pagenum_link($pages).'">'.$pages.'</a></li>'; |
| 292 | 1051 | } |
| 293 | 1052 | if ($paged != $pages) { |
| 294 | - $html .= '<li class="ultp-next-page-numbers"><a href="'.get_pagenum_link($paged + 1).'">'.($paginationNav == 'textArrow' ? __("Next", "ultimate-post") : "").ultimate_post()->svg_icon('rightAngle2').'</a></li>'; | |
| 1053 | + $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>'; | |
| 295 | 1054 | } |
| 296 | 1055 | $html .= '</ul>'; |
| 297 | 1056 | } |
| 298 | 1057 | return $html; |
| @@ -297,8 +1056,16 @@ | ||
| 297 | 1056 | } |
| 298 | 1057 | return $html; |
| 299 | 1058 | } |
| 300 | 1059 | |
| 1060 | + | |
| 1061 | + /** | |
| 1062 | + * Get Excerpt Word | |
| 1063 | + * | |
| 1064 | + * @since v.1.0.0 | |
| 1065 | + * @param NUMBER | Character Length | |
| 1066 | + * @return STRING | |
| 1067 | + */ | |
| 301 | 1068 | public function excerpt_word($charlength = 200) { |
| 302 | 1069 | $html = ''; |
| 303 | 1070 | $charlength++; |
| 304 | 1071 | $excerpt = get_the_excerpt(); |
| @@ -318,16 +1085,23 @@ | ||
| 318 | 1085 | return $html; |
| 319 | 1086 | } |
| 320 | 1087 | |
| 321 | 1088 | |
| 1089 | + /** | |
| 1090 | + * Get Taxonomy Lists | |
| 1091 | + * | |
| 1092 | + * @since v.1.0.0 | |
| 1093 | + * @param STRING | Taxonomy Slug | |
| 1094 | + * @return ARRAY | |
| 1095 | + */ | |
| 322 | 1096 | public function taxonomy( $prams = 'category' ) { |
| 323 | 1097 | $data = array(); |
| 324 | 1098 | $terms = get_terms( $prams, array( |
| 325 | - 'hide_empty' => true, | |
| 1099 | + 'hide_empty' => false, | |
| 326 | 1100 | )); |
| 327 | - if( !empty($terms) ){ | |
| 1101 | + if( !is_wp_error($terms) ){ | |
| 328 | 1102 | foreach ($terms as $val) { |
| 329 | - $data[$val->slug] = $val->name; | |
| 1103 | + $data[urldecode_deep($val->slug)] = $val->name; | |
| 330 | 1104 | } |
| 331 | 1105 | } |
| 332 | 1106 | return $data; |
| 333 | 1107 | } |
| @@ -332,19 +1106,96 @@ | ||
| 332 | 1106 | return $data; |
| 333 | 1107 | } |
| 334 | 1108 | |
| 335 | 1109 | |
| 1110 | + /** | |
| 1111 | + * Get Taxonomy Data Lists | |
| 1112 | + * | |
| 1113 | + * @since v.1.0.0 | |
| 1114 | + * @param OBJECT | Taxonomy Object | |
| 1115 | + * @return ARRAY | |
| 1116 | + */ | |
| 1117 | + public function get_tax_data($terms) { | |
| 1118 | + $temp = array(); | |
| 1119 | + $image = ''; | |
| 1120 | + $thumbnail_id = get_term_meta( $terms->term_id, 'ultp_category_image', true ); | |
| 1121 | + if( $thumbnail_id ){ | |
| 1122 | + $image = wp_get_attachment_url( $thumbnail_id ); | |
| 1123 | + } | |
| 1124 | + $temp['url'] = get_term_link($terms); | |
| 1125 | + $temp['name'] = $terms->name; | |
| 1126 | + $temp['desc'] = $terms->description; | |
| 1127 | + $temp['count'] = $terms->count; | |
| 1128 | + $temp['image'] = $image; | |
| 1129 | + $color = get_term_meta($terms->term_id, 'ultp_category_color', true); | |
| 1130 | + $temp['color'] = $color ? $color : '#037fff'; | |
| 1131 | + return $temp; | |
| 1132 | + } | |
| 1133 | + | |
| 1134 | + public function get_category_data($catSlug, $number = 40, $type = '', $tax_slug = 'category') { | |
| 1135 | + $data = array(); | |
| 1136 | + if($type == 'child'){ | |
| 1137 | + $image = ''; | |
| 1138 | + if (!empty($catSlug)) { | |
| 1139 | + foreach ($catSlug as $cat) { | |
| 1140 | + $parent_term = get_term_by('slug', $cat, $tax_slug); | |
| 1141 | + if (!empty($parent_term)) { | |
| 1142 | + $term_data = get_terms($tax_slug, array( | |
| 1143 | + 'hide_empty' => true, | |
| 1144 | + 'parent' => $parent_term->term_id | |
| 1145 | + )); | |
| 1146 | + if (!empty($term_data)) { | |
| 1147 | + foreach ($term_data as $terms) { | |
| 1148 | + $data[] = $this->get_tax_data($terms); | |
| 1149 | + } | |
| 1150 | + } | |
| 1151 | + } | |
| 1152 | + } | |
| 1153 | + } | |
| 1154 | + } else if ($type == 'parent') { | |
| 1155 | + $term_data = get_terms( $tax_slug, array( 'hide_empty' => true, 'number' => $number, 'parent' => 0 ) ); | |
| 1156 | + if (!empty($term_data)) { | |
| 1157 | + foreach ($term_data as $terms) { | |
| 1158 | + $data[] = $this->get_tax_data($terms); | |
| 1159 | + } | |
| 1160 | + } | |
| 1161 | + } else if ($type == 'custom') { | |
| 1162 | + foreach ($catSlug as $cat) { | |
| 1163 | + $terms = get_term_by('slug', $cat, $tax_slug); | |
| 1164 | + if (!empty($terms)) { | |
| 1165 | + $data[] = $this->get_tax_data($terms); | |
| 1166 | + } | |
| 1167 | + } | |
| 1168 | + } else { | |
| 1169 | + $term_data = get_terms($tax_slug, array('hide_empty' => true, 'number' => $number)); | |
| 1170 | + if (!empty($term_data)) { | |
| 1171 | + foreach ($term_data as $terms) { | |
| 1172 | + $data[] = $this->get_tax_data($terms); | |
| 1173 | + } | |
| 1174 | + } | |
| 1175 | + } | |
| 1176 | + return $data; | |
| 1177 | + } | |
| 1178 | + | |
| 1179 | + | |
| 1180 | + /** | |
| 1181 | + * Get Next Previous HTML | |
| 1182 | + * | |
| 1183 | + * @since v.1.0.0 | |
| 1184 | + * @param OBJECT | Taxonomy Object | |
| 1185 | + * @return STRING | |
| 1186 | + */ | |
| 336 | 1187 | public function next_prev() { |
| 337 | 1188 | $html = ''; |
| 338 | 1189 | $html .= '<ul>'; |
| 339 | 1190 | $html .= '<li>'; |
| 340 | 1191 | $html .= '<a class="ultp-prev-action ultp-disable" href="#">'; |
| 341 | - $html .= ultimate_post()->svg_icon('leftAngle2').'<span class="screen-reader-text">'.__("Previous", "ultimate-post").'</span>'; | |
| 1192 | + $html .= ultimate_post()->svg_icon('leftAngle2').'<span class="screen-reader-text">'.esc_html__("Previous", "ultimate-post").'</span>'; | |
| 342 | 1193 | $html .= '</a>'; |
| 343 | 1194 | $html .= '</li>'; |
| 344 | 1195 | $html .= '<li>'; |
| 345 | 1196 | $html .= '<a class="ultp-next-action">'; |
| 346 | - $html .= ultimate_post()->svg_icon('rightAngle2').'<span class="screen-reader-text">'.__("Next", "ultimate-post").'</span>'; | |
| 1197 | + $html .= ultimate_post()->svg_icon('rightAngle2').'<span class="screen-reader-text">'.esc_html__("Next", "ultimate-post").'</span>'; | |
| 347 | 1198 | $html .= '</a>'; |
| 348 | 1199 | $html .= '</li>'; |
| 349 | 1200 | $html .= '</ul>'; |
| 350 | 1201 | return $html; |
| @@ -349,15 +1200,19 @@ | ||
| 349 | 1200 | $html .= '</ul>'; |
| 350 | 1201 | return $html; |
| 351 | 1202 | } |
| 352 | 1203 | |
| 1204 | + | |
| 1205 | + /** | |
| 1206 | + * Get Loading HTML | |
| 1207 | + * | |
| 1208 | + * @since v.1.0.0 | |
| 1209 | + * @param NULL | |
| 1210 | + * @return STRING | |
| 1211 | + */ | |
| 353 | 1212 | public function loading(){ |
| 354 | 1213 | $html = ''; |
| 355 | - $style = 'style1'; | |
| 356 | - $option_data = ultimate_post()->get_setting(); | |
| 357 | - if( isset($option_data['preloader_style']) ){ | |
| 358 | - $style = $option_data['preloader_style']; | |
| 359 | - } | |
| 1214 | + $style = ultimate_post()->get_setting('preloader_style'); | |
| 360 | 1215 | if( $style == 'style2' ){ |
| 361 | 1216 | $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 |
| 362 | 1217 | } else { |
| 363 | 1218 | $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>'; |
| @@ -364,34 +1219,61 @@ | ||
| 364 | 1219 | } |
| 365 | 1220 | return '<div class="ultp-loading">'.$html.'</div>'; |
| 366 | 1221 | } |
| 367 | 1222 | |
| 368 | - public function filter($filterText = '', $filterType = '', $filterCat = '[]', $filterTag = '[]'){ | |
| 1223 | + | |
| 1224 | + /** | |
| 1225 | + * Get Filter HTML | |
| 1226 | + * | |
| 1227 | + * @since v.1.0.0 | |
| 1228 | + * @param | Filter Text (STRING) | Filter Type (STRING) | Filter Value (ARRAY) | Filter Cat (ARRAY) | Filter Tag (ARRAY) | | |
| 1229 | + * @return STRING | |
| 1230 | + */ | |
| 1231 | + public function filter($filterText = '', $filterType = '', $filterValue = '[]', $filterMobileText = '...', $filterMobile = true){ | |
| 369 | 1232 | $html = ''; |
| 370 | - $html .= '<ul class="ultp-flex-menu">'; | |
| 371 | - if ($filterType == 'category') { | |
| 372 | - $cat = $this->taxonomy('category'); | |
| 373 | - if($filterText){ | |
| 374 | - $html .= '<li class="filter-item"><a data-taxonomy="" href="#">'.$filterText.'</a></li>'; | |
| 375 | - } | |
| 376 | - foreach (json_decode($filterCat) as $val) { | |
| 1233 | + $html .= '<ul '.($filterMobile ? 'class="ultp-flex-menu"' : '').' data-name="'.($filterMobileText ? $filterMobileText : ' ').'">'; | |
| 1234 | + $cat = $this->taxonomy($filterType); | |
| 1235 | + if($filterText){ | |
| 1236 | + $html .= '<li class="filter-item"><a class="filter-active" data-taxonomy="" href="#">'.$filterText.'</a></li>'; | |
| 1237 | + } | |
| 1238 | + | |
| 1239 | + if ($filterValue) { | |
| 1240 | + $filterValue = strlen($filterValue) > 2 ? $filterValue : []; | |
| 1241 | + $filterValue = is_array($filterValue) ? $filterValue : json_decode($filterValue); | |
| 1242 | + foreach ($filterValue as $val) { | |
| 377 | 1243 | $html .= '<li class="filter-item"><a data-taxonomy="'.$val.'" href="#">'.(isset($cat[$val]) ? $cat[$val] : $val).'</a></li>'; |
| 378 | 1244 | } |
| 379 | - } else { | |
| 380 | - $tag = $this->taxonomy('post_tag'); | |
| 381 | - if($filterText){ | |
| 382 | - $html .= '<li class="filter-item"><a data-taxonomy="" href="#">'.$filterText.'</a></li>'; | |
| 383 | - } | |
| 384 | - foreach (json_decode($filterTag) as $val) { | |
| 385 | - $html .= '<li class="filter-item"><a data-taxonomy="'.$val.'" href="#">'.(isset($tag[$val]) ? $tag[$val] : $val).'</a></li>'; | |
| 386 | - } | |
| 387 | 1245 | } |
| 388 | 1246 | $html .= '</ul>'; |
| 389 | 1247 | return $html; |
| 390 | 1248 | } |
| 391 | 1249 | |
| 1250 | + | |
| 1251 | + /** | |
| 1252 | + * Check License Status | |
| 1253 | + * | |
| 1254 | + * @since v.2.4.2 | |
| 1255 | + * @return BOOLEAN | Is pro license active or not | |
| 1256 | + */ | |
| 1257 | + public function is_lc_active() { | |
| 1258 | + if (function_exists('ultimate_post_pro')) { | |
| 1259 | + return get_option('edd_ultp_license_status') == 'valid' ? true : false; | |
| 1260 | + } | |
| 1261 | + if (get_transient( 'ulpt_theme_enable' ) == 'integration') { | |
| 1262 | + return true; | |
| 1263 | + } | |
| 1264 | + return false; | |
| 1265 | + } | |
| 1266 | + | |
| 1267 | + | |
| 1268 | + /** | |
| 1269 | + * Get SVG Icon | |
| 1270 | + * | |
| 1271 | + * @since v.1.0.0 | |
| 1272 | + * @param STRING | Icon Key | |
| 1273 | + * @return STRING | Icon SVG | |
| 1274 | + */ | |
| 392 | 1275 | public function svg_icon($icons = ''){ |
| 393 | - | |
| 394 | 1276 | $icon_lists = array( |
| 395 | 1277 | 'eye' => file_get_contents(ULTP_PATH.'assets/img/svg/eye.svg'), |
| 396 | 1278 | 'user' => file_get_contents(ULTP_PATH.'assets/img/svg/user.svg'), |
| 397 | 1279 | 'calendar' => file_get_contents(ULTP_PATH.'assets/img/svg/calendar.svg'), |
| @@ -409,7 +1291,71 @@ | ||
| 409 | 1291 | ); |
| 410 | 1292 | if($icons){ |
| 411 | 1293 | return $icon_lists[ $icons ]; |
| 412 | 1294 | } |
| 1295 | + } | |
| 1296 | + | |
| 1297 | + /** | |
| 1298 | + * Get SEO Meta | |
| 1299 | + * | |
| 1300 | + * @since v.2.4.3 | |
| 1301 | + * @param NUMBER | Post ID | |
| 1302 | + * @return STRING | SEO Meta Description or Excerpt | |
| 1303 | + */ | |
| 1304 | + public function get_excerpt($post_id = 0, $showSeoMeta = 0, $showFullExcerpt = 0, $excerptLimit = 55) { | |
| 1305 | + $html = ''; | |
| 1306 | + if ($showSeoMeta) { | |
| 1307 | + $str = ''; | |
| 1308 | + if( function_exists('ultimate_post_pro') ) { | |
| 1309 | + if (ultimate_post()->get_setting('ultp_yoast') == 'true') { | |
| 1310 | + $str = method_exists( ultimate_post_pro(), 'get_yoast_meta' ) ? ultimate_post_pro()->get_yoast_meta($post_id) : ''; | |
| 1311 | + } else if (ultimate_post()->get_setting('ultp_rankmath') == 'true') { | |
| 1312 | + $str = method_exists( ultimate_post_pro(), 'get_rankmath_meta' ) ? ultimate_post_pro()->get_rankmath_meta($post_id) : ''; | |
| 1313 | + } else if (ultimate_post()->get_setting('ultp_aioseo') == 'true') { | |
| 1314 | + $str = method_exists( ultimate_post_pro(), 'get_aioseo_meta' ) ? ultimate_post_pro()->get_aioseo_meta($post_id) : ''; | |
| 1315 | + } else if (ultimate_post()->get_setting('ultp_seopress') == 'true') { | |
| 1316 | + $str = method_exists( ultimate_post_pro(), 'get_seopress_meta' ) ? ultimate_post_pro()->get_seopress_meta($post_id) : ''; | |
| 1317 | + } else if (ultimate_post()->get_setting('ultp_squirrly') == 'true') { | |
| 1318 | + $str = method_exists( ultimate_post_pro(), 'get_squirrly_meta' ) ? ultimate_post_pro()->get_squirrly_meta($post_id) : ''; | |
| 1319 | + } | |
| 1320 | + } | |
| 1321 | + $html = $str ? $str : ultimate_post()->excerpt($post_id, $excerptLimit); | |
| 1322 | + } else { | |
| 1323 | + if ( $showFullExcerpt == 0 ) { | |
| 1324 | + $html = ultimate_post()->excerpt($post_id, $excerptLimit); | |
| 1325 | + } else { | |
| 1326 | + $html = get_the_excerpt(); | |
| 1327 | + } | |
| 1328 | + } | |
| 1329 | + return $html; | |
| 1330 | + } | |
| 1331 | + | |
| 1332 | + /** | |
| 1333 | + * Set Inline CSS | |
| 1334 | + * | |
| 1335 | + * @since v.2.5.8 | |
| 1336 | + * @param STRING | CSS | |
| 1337 | + * @return STRING | CSS with Style | |
| 1338 | + */ | |
| 1339 | + public function set_inline($css) { | |
| 1340 | + return '<style type="text/css">'.wp_strip_all_tags($css).'</style>'; | |
| 1341 | + } | |
| 1342 | + | |
| 1343 | + /** | |
| 1344 | + * Array Sanitize Function | |
| 1345 | + * | |
| 1346 | + * @since v.2.6.0 | |
| 1347 | + * @param ARRAY | |
| 1348 | + * @return ARRAY | Array of Sanitize | |
| 1349 | + */ | |
| 1350 | + public function recursive_sanitize_text_field($array) { | |
| 1351 | + foreach ($array as $key => &$value) { | |
| 1352 | + if (is_array($value)) { | |
| 1353 | + $value = $this->recursive_sanitize_text_field($value); | |
| 1354 | + } else { | |
| 1355 | + $value = sanitize_text_field($value); | |
| 1356 | + } | |
| 1357 | + } | |
| 1358 | + return $array; | |
| 413 | 1359 | } |
| 414 | 1360 | |
| 415 | 1361 | } |