| @@ -1,23 +1,310 @@ | ||
| 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 | + $GLOBALS['ultp_settings']['date_format'] = get_option('date_format'); | |
| 27 | + $GLOBALS['ultp_settings']['time_format'] = get_option('time_format'); | |
| 28 | + } | |
| 10 | 29 | } |
| 11 | 30 | |
| 12 | - public function reusable_id($post_id){ | |
| 31 | + /** | |
| 32 | + * ID for the Builder Post or Normal Post | |
| 33 | + * | |
| 34 | + * @since v.2.3.1 | |
| 35 | + * @return NUMBER | is Builder or not | |
| 36 | + */ | |
| 37 | + public function get_ID() { | |
| 38 | + $id = $this->is_builder(); | |
| 39 | + return $id ? $id : (function_exists('is_shop') ? (is_shop() ? wc_get_page_id('shop') : get_the_ID()) : get_the_ID() ); | |
| 40 | + } | |
| 41 | + | |
| 42 | + /** | |
| 43 | + * Checking Statement of Dynamic Site Builder | |
| 44 | + * | |
| 45 | + * @since v.2.3.1 | |
| 46 | + * @return BOOLEAN | is Builder or not | |
| 47 | + */ | |
| 48 | + public function is_archive_builder() { | |
| 49 | + $id = get_the_ID(); | |
| 50 | + return get_post_type( $id ) == 'ultp_builder' ? get_post_meta( $id, '__ultp_builder_type', true ) : false; | |
| 51 | + } | |
| 52 | + | |
| 53 | + | |
| 54 | + /** | |
| 55 | + * Set Link with the Parameters | |
| 56 | + * | |
| 57 | + * @since v.1.1.0 | |
| 58 | + * @return STRING | URL with Arg | |
| 59 | + */ | |
| 60 | + public function get_premium_link( $url = '', $tag = 'go_premium' ) { | |
| 61 | + $url = $url ? $url : 'https://www.wpxpo.com/postx/pricing/'; | |
| 62 | + $affiliate_id = apply_filters( 'ultp_affiliate_id', FALSE ); | |
| 63 | + $arg = array( 'utm_source' => $tag ); | |
| 64 | + if ( ! empty( $affiliate_id ) ) { | |
| 65 | + $arg[ 'ref' ] = esc_attr( $affiliate_id ); | |
| 66 | + } | |
| 67 | + return add_query_arg( $arg, $url ); | |
| 68 | + } | |
| 69 | + | |
| 70 | + | |
| 71 | + /** | |
| 72 | + * Get Width and Height of the Image | |
| 73 | + * | |
| 74 | + * @since v.1.1.0 | |
| 75 | + * @return STRING | Image Size | |
| 76 | + */ | |
| 77 | + public function get_size($name = '') { | |
| 78 | + global $_wp_additional_image_sizes; | |
| 79 | + $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]; | |
| 80 | + | |
| 81 | + return ' width="'.$image_size['width'].'" height="'.$image_size['height'].'" '; | |
| 82 | + } | |
| 83 | + | |
| 84 | + | |
| 85 | + /** | |
| 86 | + * Image Placeholder | |
| 87 | + * | |
| 88 | + * @since v.1.1.0 | |
| 89 | + * @return STRING | Image Placeholder | |
| 90 | + */ | |
| 91 | + public function img_placeholder($type = 'small') { | |
| 92 | + switch ($type) { | |
| 93 | + case 'small': | |
| 94 | + return 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAG4AAABLAQMAAACr9CA9AAAAA1BMVEX///+nxBvIAAAAAXRSTlMAQObYZgAAABZJREFUOI1jYMADmEe5o9xR7iiXQi4A4BsA388WUyMAAAAASUVORK5CYII='; | |
| 95 | + break; | |
| 96 | + | |
| 97 | + case 'wide': | |
| 98 | + return 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAKCAYAAADVTVykAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAB9JREFUeNpi/P//P8NAAiaGAQajDhh1wKgDRh0AEGAAQTcDEcKDrpMAAAAASUVORK5CYII='; | |
| 99 | + break; | |
| 100 | + | |
| 101 | + case 'square': | |
| 102 | + return 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABAQMAAAAl21bKAAAAA1BMVEX///+nxBvIAAAAAXRSTlMAQObYZgAAAApJREFUCJljYAAAAAIAAfRxZKYAAAAASUVORK5CYII='; | |
| 103 | + break; | |
| 104 | + | |
| 105 | + case 'slider': | |
| 106 | + return 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAKYAAABkCAMAAAA7drv6AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAAZQTFRF////AAAAVcLTfgAAAAF0Uk5TAEDm2GYAAAAqSURBVHja7MEBDQAAAMKg909tDjegAAAAAAAAAAAAAAAAAAAAAH5NgAEAQTwAAWZtItYAAAAASUVORK5CYII='; | |
| 107 | + break; | |
| 108 | + | |
| 109 | + default: | |
| 110 | + return 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAYYAAADcAQMAAABOLJSDAAAAA1BMVEUAAACnej3aAAAAAXRSTlMAQObYZgAAACJJREFUaIHtwTEBAAAAwqD1T20ND6AAAAAAAAAAAAAA4N8AKvgAAUFIrrEAAAAASUVORK5CYII='; | |
| 111 | + break; | |
| 112 | + } | |
| 113 | + } | |
| 114 | + | |
| 115 | + | |
| 116 | + /** | |
| 117 | + * Quick Query | |
| 118 | + * | |
| 119 | + * @since v.1.1.0 | |
| 120 | + * @return ARRAY | Query Arg | |
| 121 | + */ | |
| 122 | + public function get_quick_query($prams, $args) { | |
| 123 | + switch ($prams['queryQuick']) { | |
| 124 | + case 'related_posts': | |
| 125 | + global $post; | |
| 126 | + $p_id = isset($post->ID) && $post->ID ? $post->ID : (isset($_POST['postId']) ? $_POST['postId'] : ''); | |
| 127 | + if ($p_id) { | |
| 128 | + $args['post__not_in'] = array($p_id); | |
| 129 | + } | |
| 130 | + break; | |
| 131 | + case 'related_tag': | |
| 132 | + global $post; | |
| 133 | + $p_id = isset($post->ID) && $post->ID ? $post->ID : (isset($_POST['postId']) ? $_POST['postId'] : ''); | |
| 134 | + if ($p_id) { | |
| 135 | + $args['tax_query'] = array( | |
| 136 | + array( | |
| 137 | + 'taxonomy' => 'post_tag', | |
| 138 | + 'terms' => $this->get_terms_id($p_id, 'post_tag'), | |
| 139 | + 'field' => 'term_id', | |
| 140 | + ) | |
| 141 | + ); | |
| 142 | + $args['post__not_in'] = array($p_id); | |
| 143 | + } | |
| 144 | + break; | |
| 145 | + case 'related_category': | |
| 146 | + global $post; | |
| 147 | + $p_id = isset($post->ID) && $post->ID ? $post->ID : (isset($_POST['postId']) ? $_POST['postId'] : ''); | |
| 148 | + if ($p_id) { | |
| 149 | + $args['tax_query'] = array( | |
| 150 | + array( | |
| 151 | + 'taxonomy' => 'category', | |
| 152 | + 'terms' => $this->get_terms_id($p_id, 'category'), | |
| 153 | + 'field' => 'term_id', | |
| 154 | + ) | |
| 155 | + ); | |
| 156 | + $args['post__not_in'] = array($p_id); | |
| 157 | + } | |
| 158 | + break; | |
| 159 | + case 'related_cat_tag': | |
| 160 | + global $post; | |
| 161 | + $p_id = isset($post->ID) && $post->ID ? $post->ID : (isset($_POST['postId']) ? $_POST['postId'] : ''); | |
| 162 | + if ($p_id) { | |
| 163 | + $args['tax_query'] = array( | |
| 164 | + array( | |
| 165 | + 'taxonomy' => 'post_tag', | |
| 166 | + 'terms' => $this->get_terms_id($p_id, 'post_tag'), | |
| 167 | + 'field' => 'term_id', | |
| 168 | + ), | |
| 169 | + array( | |
| 170 | + 'taxonomy' => 'category', | |
| 171 | + 'terms' => $this->get_terms_id($p_id, 'category'), | |
| 172 | + 'field' => 'term_id', | |
| 173 | + ) | |
| 174 | + ); | |
| 175 | + $args['post__not_in'] = array($p_id); | |
| 176 | + } | |
| 177 | + break; | |
| 178 | + case 'sticky_posts': | |
| 179 | + $sticky = get_option('sticky_posts'); | |
| 180 | + if (is_array($sticky)) { | |
| 181 | + rsort($sticky); | |
| 182 | + $sticky = array_slice($sticky, 0, $args['posts_per_page']); | |
| 183 | + } | |
| 184 | + $args['ignore_sticky_posts'] = 1; | |
| 185 | + $args['post__in'] = $sticky; | |
| 186 | + break; | |
| 187 | + case 'latest_post_published': | |
| 188 | + $args['orderby'] = 'date'; | |
| 189 | + $args['order'] = 'DESC'; | |
| 190 | + $args['ignore_sticky_posts'] = 1; | |
| 191 | + break; | |
| 192 | + case 'latest_post_modified': | |
| 193 | + $args['orderby'] = 'modified'; | |
| 194 | + $args['order'] = 'DESC'; | |
| 195 | + $args['ignore_sticky_posts'] = 1; | |
| 196 | + break; | |
| 197 | + case 'oldest_post_published': | |
| 198 | + $args['orderby'] = 'date'; | |
| 199 | + $args['order'] = 'ASC'; | |
| 200 | + break; | |
| 201 | + case 'oldest_post_modified': | |
| 202 | + $args['orderby'] = 'modified'; | |
| 203 | + $args['order'] = 'ASC'; | |
| 204 | + break; | |
| 205 | + case 'alphabet_asc': | |
| 206 | + $args['orderby'] = 'title'; | |
| 207 | + $args['order'] = 'ASC'; | |
| 208 | + break; | |
| 209 | + case 'alphabet_desc': | |
| 210 | + $args['orderby'] = 'title'; | |
| 211 | + $args['order'] = 'DESC'; | |
| 212 | + break; | |
| 213 | + case 'random_post': | |
| 214 | + $args['orderby'] = 'rand'; | |
| 215 | + $args['order'] = 'ASC'; | |
| 216 | + break; | |
| 217 | + case 'random_post_7_days': | |
| 218 | + $args['orderby'] = 'rand'; | |
| 219 | + $args['order'] = 'ASC'; | |
| 220 | + $args['date_query'] = array( array( 'after' => '1 week ago') ); | |
| 221 | + break; | |
| 222 | + case 'random_post_30_days': | |
| 223 | + $args['orderby'] = 'rand'; | |
| 224 | + $args['order'] = 'ASC'; | |
| 225 | + $args['date_query'] = array( array( 'after' => '1 month ago') ); | |
| 226 | + break; | |
| 227 | + case 'most_comment': | |
| 228 | + $args['orderby'] = 'comment_count'; | |
| 229 | + $args['order'] = 'DESC'; | |
| 230 | + break; | |
| 231 | + case 'most_comment_1_day': | |
| 232 | + $args['orderby'] = 'comment_count'; | |
| 233 | + $args['order'] = 'DESC'; | |
| 234 | + $args['date_query'] = array( array( 'after' => '1 day ago') ); | |
| 235 | + break; | |
| 236 | + case 'most_comment_7_days': | |
| 237 | + $args['orderby'] = 'comment_count'; | |
| 238 | + $args['order'] = 'DESC'; | |
| 239 | + $args['date_query'] = array( array( 'after' => '1 week ago') ); | |
| 240 | + break; | |
| 241 | + case 'most_comment_30_days': | |
| 242 | + $args['orderby'] = 'comment_count'; | |
| 243 | + $args['order'] = 'DESC'; | |
| 244 | + $args['date_query'] = array( array( 'after' => '1 month ago') ); | |
| 245 | + break; | |
| 246 | + case 'popular_post_1_day_view': | |
| 247 | + $args['meta_key'] = '__post_views_count'; | |
| 248 | + $args['orderby'] = 'meta_value_num'; | |
| 249 | + $args['order'] = 'DESC'; | |
| 250 | + $args['date_query'] = array( array( 'after' => '1 day ago') ); | |
| 251 | + break; | |
| 252 | + case 'popular_post_7_days_view': | |
| 253 | + $args['meta_key'] = '__post_views_count'; | |
| 254 | + $args['orderby'] = 'meta_value_num'; | |
| 255 | + $args['order'] = 'DESC'; | |
| 256 | + $args['date_query'] = array( array( 'after' => '1 week ago') ); | |
| 257 | + break; | |
| 258 | + case 'popular_post_30_days_view': | |
| 259 | + $args['meta_key'] = '__post_views_count'; | |
| 260 | + $args['orderby'] = 'meta_value_num'; | |
| 261 | + $args['order'] = 'DESC'; | |
| 262 | + $args['date_query'] = array( array( 'after' => '1 month ago') ); | |
| 263 | + break; | |
| 264 | + case 'popular_post_all_times_view': | |
| 265 | + $args['meta_key'] = '__post_views_count'; | |
| 266 | + $args['orderby'] = 'meta_value_num'; | |
| 267 | + $args['order'] = 'DESC'; | |
| 268 | + break; | |
| 269 | + default: | |
| 270 | + # code... | |
| 271 | + break; | |
| 272 | + } | |
| 273 | + return $args; | |
| 274 | + } | |
| 275 | + | |
| 276 | + /** | |
| 277 | + * Get All Term ID as Array | |
| 278 | + * | |
| 279 | + * @since v.2.4.12 | |
| 280 | + * @return ARRAY | Query Arg | |
| 281 | + */ | |
| 282 | + public function get_terms_id($id, $type) { | |
| 283 | + $data = array(); | |
| 284 | + $arr = get_the_terms($id, $type); | |
| 285 | + if (is_array($arr)) { | |
| 286 | + foreach ($arr as $key => $val) { | |
| 287 | + $data[] = $val->term_id; | |
| 288 | + } | |
| 289 | + } | |
| 290 | + return $data; | |
| 291 | + } | |
| 292 | + | |
| 293 | + /** | |
| 294 | + * Get All Reusable ID | |
| 295 | + * | |
| 296 | + * @since v.1.1.0 | |
| 297 | + * @return ARRAY | Query Arg | |
| 298 | + */ | |
| 299 | + public function reusable_id($post_id) { | |
| 13 | 300 | $reusable_id = array(); |
| 14 | - if($post_id){ | |
| 301 | + if ($post_id) { | |
| 15 | 302 | $post = get_post($post_id); |
| 16 | 303 | if (has_blocks($post->post_content)) { |
| 17 | 304 | $blocks = parse_blocks($post->post_content); |
| 18 | 305 | foreach ($blocks as $key => $value) { |
| 19 | - if(isset($value['attrs']['ref'])) { | |
| 306 | + if (isset($value['attrs']['ref'])) { | |
| 20 | 307 | $reusable_id[] = $value['attrs']['ref']; |
| 21 | 308 | } |
| 22 | 309 | } |
| 23 | 310 | } |
| @@ -24,10 +311,17 @@ | ||
| 24 | 311 | } |
| 25 | 312 | return $reusable_id; |
| 26 | 313 | } |
| 27 | 314 | |
| 28 | - public function set_css_style($post_id){ | |
| 29 | - if( $post_id ){ | |
| 315 | + | |
| 316 | + /** | |
| 317 | + * Set CSS Style | |
| 318 | + * | |
| 319 | + * @since v.1.1.0 | |
| 320 | + * @return ARRAY | Query Arg | |
| 321 | + */ | |
| 322 | + public function set_css_style($post_id, $shortcode = false) { | |
| 323 | + if ($post_id) { | |
| 30 | 324 | $upload_dir_url = wp_get_upload_dir(); |
| 31 | 325 | $upload_css_dir_url = trailingslashit( $upload_dir_url['basedir'] ); |
| 32 | 326 | $css_dir_path = $upload_css_dir_url . "ultimate-post/ultp-css-{$post_id}.css"; |
| 33 | 327 | |
| @@ -41,30 +335,42 @@ | ||
| 41 | 335 | foreach ( $reusable_id as $id ) { |
| 42 | 336 | $reusable_dir_path = $upload_css_dir_url."ultimate-post/ultp-css-{$id}.css"; |
| 43 | 337 | if (file_exists( $reusable_dir_path )) { |
| 44 | 338 | $css_url = $css_dir_url . "ultimate-post/ultp-css-{$id}.css"; |
| 45 | - wp_enqueue_style( "ultp-post-{$id}", $css_url, array(), ULTP_VER, 'all' ); | |
| 339 | + wp_enqueue_style( "ultp-post-{$id}", $css_url, array(), ultimate_post()->get_setting('save_version'), 'all' ); | |
| 46 | 340 | }else{ |
| 47 | 341 | $css = get_post_meta($id, '_ultp_css', true); |
| 48 | 342 | if( $css ) { |
| 49 | - wp_enqueue_style("ultp-post-{$id}", $css, false, ULTP_VER); | |
| 343 | + ultimate_post()->set_inline($css); | |
| 50 | 344 | } |
| 51 | 345 | } |
| 52 | 346 | } |
| 53 | 347 | |
| 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 | - } | |
| 348 | + if (isset($_GET['et_fb']) || (isset($_GET['action']) && sanitize_key($_GET['action']) == 'elementor') || $shortcode) { | |
| 349 | + return ultimate_post()->set_inline(get_post_meta($post_id, '_ultp_css', true)); | |
| 350 | + } else { | |
| 351 | + if (file_exists( $css_dir_path ) ) { | |
| 352 | + $css_url = $css_dir_url . "ultimate-post/ultp-css-{$post_id}.css"; | |
| 353 | + wp_enqueue_style( "ultp-post-{$post_id}", $css_url, array(), ultimate_post()->get_setting('save_version'), 'all' ); | |
| 354 | + } else { | |
| 355 | + $css = get_post_meta($post_id, '_ultp_css', true); | |
| 356 | + if( $css ) { | |
| 357 | + ultimate_post()->set_inline($css); | |
| 358 | + } | |
| 359 | + } | |
| 360 | + } | |
| 63 | 361 | } |
| 64 | 362 | } |
| 65 | 363 | |
| 66 | - public function get_setting($key = ''){ | |
| 364 | + | |
| 365 | + /** | |
| 366 | + * Get Global Plugin Settings | |
| 367 | + * | |
| 368 | + * @since v.1.0.0 | |
| 369 | + * @param STRING | Key of the Option | |
| 370 | + * @return ARRAY | STRING | |
| 371 | + */ | |
| 372 | + public function get_setting($key = '') { | |
| 67 | 373 | $data = $GLOBALS['ultp_settings']; |
| 68 | 374 | if ($key != '') { |
| 69 | 375 | return isset($data[$key]) ? $data[$key] : ''; |
| 70 | 376 | } else { |
| @@ -71,10 +377,18 @@ | ||
| 71 | 377 | return $data; |
| 72 | 378 | } |
| 73 | 379 | } |
| 74 | 380 | |
| 381 | + | |
| 382 | + /** | |
| 383 | + * Set Option Settings | |
| 384 | + * | |
| 385 | + * @since v.1.0.0 | |
| 386 | + * @param STRING | Key of the Option (STRING), Value (STRING) | |
| 387 | + * @return NULL | |
| 388 | + */ | |
| 75 | 389 | public function set_setting($key = '', $val = '') { |
| 76 | - if($key != ''){ | |
| 390 | + if ($key != '') { | |
| 77 | 391 | $data = $GLOBALS['ultp_settings']; |
| 78 | 392 | $data[$key] = $val; |
| 79 | 393 | update_option('ultp_options', $data); |
| 80 | 394 | $GLOBALS['ultp_settings'] = $data; |
| @@ -80,58 +394,103 @@ | ||
| 80 | 394 | $GLOBALS['ultp_settings'] = $data; |
| 81 | 395 | } |
| 82 | 396 | } |
| 83 | 397 | |
| 84 | - public function get_image_html($url = '', $size = 'full', $class = '', $alt = ''){ | |
| 398 | + | |
| 399 | + /** | |
| 400 | + * Get Image HTML | |
| 401 | + * | |
| 402 | + * @since v.1.0.0 | |
| 403 | + * @param | URL (STRING) | size (STRING) | class (STRING) | alt (STRING) | |
| 404 | + * @return STRING | |
| 405 | + */ | |
| 406 | + public function get_image_html($url = '', $size = 'full', $class = '', $alt = '', $lazy = '') { | |
| 85 | 407 | $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 | - } | |
| 408 | + $lazy_data = $lazy ? ' loading="lazy"' : ''; | |
| 409 | + $class = $class ? ' class="'.$class.'" ' : ''; | |
| 410 | + return '<img '.$lazy_data.$class.$alt.' src="'.$url.'" />'; | |
| 99 | 411 | } |
| 100 | 412 | |
| 101 | - public function get_image($attach_id, $size = 'full', $class = '', $alt = ''){ | |
| 413 | + | |
| 414 | + /** | |
| 415 | + * Get Image HTML | |
| 416 | + * | |
| 417 | + * @since v.1.0.0 | |
| 418 | + * @param | Attach ID (STRING) | size (STRING) | class (STRING) | alt (STRING) | |
| 419 | + * @return STRING | |
| 420 | + */ | |
| 421 | + public function get_image($attach_id, $size = 'full', $class = '', $alt = '', $srcset = '', $lazy = '') { | |
| 102 | 422 | $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 | - } | |
| 423 | + $class = $class ? ' class="'.$class.'" ' : ''; | |
| 424 | + $size = ( ultimate_post()->get_setting('disable_image_size') == 'yes' && strpos($size, 'ultp_layout_') !== false ) ? 'full' : $size; | |
| 425 | + $lazy_data = $lazy ? ' loading="lazy"' : ''; | |
| 426 | + $srcset_data = $srcset ? ' srcset="'.esc_attr(wp_get_attachment_image_srcset($attach_id)).'"' : ''; | |
| 427 | + return '<img '.$srcset_data.$lazy_data.$class.$alt.' src="'.wp_get_attachment_image_url( $attach_id, $size ).'" />'; | |
| 116 | 428 | } |
| 117 | 429 | |
| 118 | - // Init data | |
| 119 | - public function init_set_data(){ | |
| 430 | + | |
| 431 | + /** | |
| 432 | + * Setup Initial Data Set | |
| 433 | + * | |
| 434 | + * @since v.1.0.0 | |
| 435 | + * @return NULL | |
| 436 | + */ | |
| 437 | + public function init_set_data() { | |
| 120 | 438 | $data = get_option( 'ultp_options', array() ); |
| 121 | 439 | $init_data = array( |
| 122 | 440 | 'css_save_as' => 'wp_head', |
| 123 | 441 | 'preloader_style' => 'style1', |
| 124 | - 'preloader_color' => '#1740f5', | |
| 442 | + 'preloader_color' => '#037fff', | |
| 125 | 443 | 'container_width' => '1140', |
| 126 | - 'editor_container' => 'full_width', | |
| 127 | 444 | 'hide_import_btn' => '', |
| 445 | + 'disable_image_size'=> '', | |
| 446 | + 'disable_view_cookies' => '', | |
| 128 | 447 | 'ultp_templates' => 'true', |
| 129 | - 'ultp_elementor' => 'true' | |
| 448 | + 'ultp_elementor' => 'true', | |
| 449 | + 'ultp_table_of_content'=> 'true', | |
| 450 | + 'ultp_builder' => 'true', | |
| 451 | + 'post_grid_1' => 'yes', | |
| 452 | + 'post_grid_2' => 'yes', | |
| 453 | + 'post_grid_3' => 'yes', | |
| 454 | + 'post_grid_4' => 'yes', | |
| 455 | + 'post_grid_5' => 'yes', | |
| 456 | + 'post_grid_6' => 'yes', | |
| 457 | + 'post_grid_7' => 'yes', | |
| 458 | + 'post_list_1' => 'yes', | |
| 459 | + 'post_list_2' => 'yes', | |
| 460 | + 'post_list_3' => 'yes', | |
| 461 | + 'post_list_4' => 'yes', | |
| 462 | + 'post_module_1' => 'yes', | |
| 463 | + 'post_module_2' => 'yes', | |
| 464 | + 'post_slider_1' => 'yes', | |
| 465 | + 'heading' => 'yes', | |
| 466 | + 'image' => 'yes', | |
| 467 | + 'taxonomy' => 'yes', | |
| 468 | + 'wrapper' => 'yes', | |
| 469 | + 'news_ticker' => 'yes', | |
| 470 | + 'builder_advance_post_meta' => 'yes', | |
| 471 | + 'builder_archive_title' => 'yes', | |
| 472 | + 'builder_author_box' => 'yes', | |
| 473 | + 'builder_post_next_previous'=> 'yes', | |
| 474 | + 'builder_post_author_meta' => 'yes', | |
| 475 | + 'builder_post_breadcrumb' => 'yes', | |
| 476 | + 'builder_post_category' => 'yes', | |
| 477 | + 'builder_post_comment_count'=> 'yes', | |
| 478 | + 'builder_post_comments' => 'yes', | |
| 479 | + 'builder_post_content' => 'yes', | |
| 480 | + 'builder_post_date_meta' => 'yes', | |
| 481 | + 'builder_post_excerpt' => 'yes', | |
| 482 | + 'builder_post_featured_image'=> 'yes', | |
| 483 | + 'builder_post_reading_time' => 'yes', | |
| 484 | + 'builder_post_social_share' => 'yes', | |
| 485 | + 'builder_post_tag' => 'yes', | |
| 486 | + 'builder_post_title' => 'yes', | |
| 487 | + 'builder_post_view_count' => 'yes', | |
| 488 | + 'save_version' => rand(1, 1000) | |
| 130 | 489 | ); |
| 131 | 490 | if (empty($data)) { |
| 132 | 491 | update_option('ultp_options', $init_data); |
| 133 | - $GLOBALS['wopb_settings'] = $init_data; | |
| 492 | + $GLOBALS['ultp_settings'] = $init_data; | |
| 134 | 493 | } else { |
| 135 | 494 | foreach ($init_data as $key => $single) { |
| 136 | 495 | if (!isset($data[$key])) { |
| 137 | 496 | $data[$key] = $single; |
| @@ -137,22 +496,260 @@ | ||
| 137 | 496 | $data[$key] = $single; |
| 138 | 497 | } |
| 139 | 498 | } |
| 140 | 499 | update_option('ultp_options', $data); |
| 141 | - $GLOBALS['wopb_settings'] = $data; | |
| 500 | + $GLOBALS['ultp_settings'] = $data; | |
| 142 | 501 | } |
| 143 | 502 | } |
| 144 | 503 | |
| 145 | - // Excerpt | |
| 504 | + | |
| 505 | + /** | |
| 506 | + * Get Excerpt Text | |
| 507 | + * | |
| 508 | + * @since v.1.0.0 | |
| 509 | + * @param | Post ID (STRING) | Limit (NUMBER) | |
| 510 | + * @return STRING | |
| 511 | + */ | |
| 146 | 512 | public function excerpt( $post_id, $limit = 55 ) { |
| 147 | 513 | return apply_filters( 'the_excerpt', wp_trim_words( get_the_content( $post_id ) , $limit ) ); |
| 148 | 514 | } |
| 149 | 515 | |
| 150 | - // Query Builder | |
| 516 | + /** | |
| 517 | + * Builder Attributes | |
| 518 | + * | |
| 519 | + * @since v.1.0.0 | |
| 520 | + * @param STRING type | |
| 521 | + * @return STRING | |
| 522 | + */ | |
| 523 | + public function get_builder_attr($type) { | |
| 524 | + $builder_data = ''; | |
| 525 | + if ($type == 'archiveBuilder') { | |
| 526 | + if (is_archive()) { | |
| 527 | + if (is_date()) { | |
| 528 | + if (is_year()) { | |
| 529 | + $builder_data = 'date###'.get_the_date('Y'); | |
| 530 | + } else if (is_month() ) { | |
| 531 | + $builder_data = 'date###'.get_the_date('Y-n'); | |
| 532 | + } else if (is_day() ) { | |
| 533 | + $builder_data = 'date###'.get_the_date('Y-n-j'); | |
| 534 | + } | |
| 535 | + } else if (is_author()) { | |
| 536 | + $builder_data = 'author###'.get_the_author_meta('ID'); | |
| 537 | + } else { | |
| 538 | + $obj = get_queried_object(); | |
| 539 | + if (isset($obj->taxonomy)) { | |
| 540 | + $builder_data = 'taxonomy###'.$obj->taxonomy.'###'.$obj->slug; | |
| 541 | + } | |
| 542 | + } | |
| 543 | + } else if (is_search()) { | |
| 544 | + $builder_data = 'search###'.get_search_query(true); | |
| 545 | + } | |
| 546 | + } | |
| 547 | + return $builder_data ? 'data-builder="'.$builder_data.'"' : ''; | |
| 548 | + } | |
| 549 | + | |
| 550 | + | |
| 551 | + public function is_builder($builder = '') { | |
| 552 | + $id = ''; | |
| 553 | + $page_id = ultimate_post()->conditions('return'); | |
| 554 | + if ($page_id && ultimate_post()->get_setting('ultp_builder')) { | |
| 555 | + $id = $page_id; | |
| 556 | + } | |
| 557 | + return $id; | |
| 558 | + } | |
| 559 | + | |
| 560 | + | |
| 561 | + /** | |
| 562 | + * Get Post Number Depending On Device | |
| 563 | + * | |
| 564 | + * @since v.2.5.4 | |
| 565 | + * @param MULTIPLE | Attribute of Posts | |
| 566 | + * @return STRING | |
| 567 | + */ | |
| 568 | + public function get_post_number($preDef, $prev, $current) { | |
| 569 | + | |
| 570 | + $current = is_object($current)?json_decode(json_encode($current), true):$current; | |
| 571 | + if (['lg'=>$preDef,'sm'=>$preDef,'xs'=>$preDef] == $current) { | |
| 572 | + if ($preDef != $prev) { | |
| 573 | + return $prev; | |
| 574 | + } | |
| 575 | + } | |
| 576 | + if ($this->isDevice() == 'mobile') { | |
| 577 | + return $current['xs']; | |
| 578 | + } else if ($this->isDevice() == 'tablet') { | |
| 579 | + return $current['sm']; | |
| 580 | + } else { | |
| 581 | + return $current['lg']; | |
| 582 | + } | |
| 583 | + } | |
| 584 | + | |
| 585 | + | |
| 586 | + /** | |
| 587 | + * Get Post Number Depending On Device | |
| 588 | + * | |
| 589 | + * @since v.2.5.4 | |
| 590 | + * @param NULL | |
| 591 | + * @return STRING | Device Type | |
| 592 | + */ | |
| 593 | + public function isDevice(){ | |
| 594 | + $useragent = isset($_SERVER['HTTP_USER_AGENT']) ? sanitize_key($_SERVER['HTTP_USER_AGENT']) : ''; | |
| 595 | + if ($useragent) { | |
| 596 | + 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))) { | |
| 597 | + return 'mobile'; | |
| 598 | + } else if (preg_match('/(tablet|ipad|playbook)|(android(?!.*(mobi|opera mini)))/i', strtolower($useragent))) { | |
| 599 | + return 'tablet'; | |
| 600 | + } else { | |
| 601 | + return 'desktop'; | |
| 602 | + } | |
| 603 | + } | |
| 604 | + return 'desktop'; | |
| 605 | + } | |
| 606 | + | |
| 607 | + | |
| 608 | + /** | |
| 609 | + * Get Raw Value from Objects | |
| 610 | + * | |
| 611 | + * @since v.2.5.3 | |
| 612 | + * @param NULL | |
| 613 | + * @return STRING | Device Type | |
| 614 | + */ | |
| 615 | + public function get_value($attr) { | |
| 616 | + $data = []; | |
| 617 | + if (is_array($attr)) { | |
| 618 | + foreach ($attr as $val) { | |
| 619 | + $data[] = $val->value; | |
| 620 | + } | |
| 621 | + } | |
| 622 | + return $data; | |
| 623 | + } | |
| 624 | + | |
| 625 | + | |
| 626 | + /** | |
| 627 | + * Query Builder | |
| 628 | + * | |
| 629 | + * @since v.1.0.0 | |
| 630 | + * @param ARRAY | Attribute of the Query | |
| 631 | + * @return ARRAY | |
| 632 | + */ | |
| 151 | 633 | public function get_query($attr) { |
| 634 | + $builder = isset($attr['builder']) ? $attr['builder'] : ''; | |
| 635 | + $post_type = isset($attr['queryType']) ? $attr['queryType'] : 'post'; | |
| 636 | + if ( $post_type == 'archiveBuilder' && ($builder || $this->is_builder($builder)) ) { | |
| 637 | + $archive_query = array(); | |
| 638 | + if ($builder) { | |
| 639 | + $str = explode('###', $builder); | |
| 640 | + if (isset($str[0])) { | |
| 641 | + if ($str[0] == 'taxonomy') { | |
| 642 | + if (isset($str[1]) && isset($str[2])) { | |
| 643 | + $archive_query['tax_query'] = array( | |
| 644 | + array( | |
| 645 | + 'taxonomy' => $str[1], | |
| 646 | + 'field' => 'slug', | |
| 647 | + 'terms' => $str[2] | |
| 648 | + ) | |
| 649 | + ); | |
| 650 | + } | |
| 651 | + } else if ($str[0] == 'author') { | |
| 652 | + if (isset($str[1])) { | |
| 653 | + $archive_query['author'] = $str[1]; | |
| 654 | + } | |
| 655 | + } else if ($str[0] == 'search') { | |
| 656 | + if (isset($str[1])) { | |
| 657 | + $archive_query['s'] = $str[1]; | |
| 658 | + } | |
| 659 | + } else if ($str[0] == 'date') { | |
| 660 | + if (isset($str[1])) { | |
| 661 | + $all_date = explode('-', $str[1]); | |
| 662 | + if (!empty($all_date)) { | |
| 663 | + $arg = array(); | |
| 664 | + if (isset($all_date[0])) { $arg['year'] = $all_date[0]; } | |
| 665 | + if (isset($all_date[1])) { $arg['month'] = $all_date[1]; } | |
| 666 | + if (isset($all_date[2])) { $arg['day'] = $all_date[2]; } | |
| 667 | + $archive_query['date_query'][] = $arg; | |
| 668 | + } | |
| 669 | + } | |
| 670 | + } | |
| 671 | + } | |
| 672 | + } else { | |
| 673 | + global $wp_query; | |
| 674 | + $archive_query = $wp_query->query_vars; | |
| 675 | + } | |
| 676 | + $archive_query['posts_per_page'] = isset($attr['queryNumber']) ? $attr['queryNumber'] : 3; | |
| 677 | + $archive_query['paged'] = isset($attr['paged']) ? $attr['paged'] : 1; | |
| 678 | + if (isset($attr['queryOffset']) && $attr['queryOffset'] ) { | |
| 679 | + $offset = $this->get_offset($attr['queryOffset'], $archive_query); | |
| 680 | + $archive_query = array_merge($archive_query, $offset); | |
| 681 | + } | |
| 682 | + | |
| 683 | + // Include Remove from Version 2.5.4 | |
| 684 | + if (isset($attr['queryInclude']) && $attr['queryInclude']) { | |
| 685 | + $_include = explode(',', $attr['queryInclude']); | |
| 686 | + if (is_array($_include) && count($_include)) { | |
| 687 | + $archive_query['post__in'] = isset($archive_query['post__in']) ? array_merge($archive_query['post__in'], $_include) : $_include; | |
| 688 | + $archive_query['ignore_sticky_posts'] = 1; | |
| 689 | + $archive_query['orderby'] = 'post__in'; | |
| 690 | + } | |
| 691 | + } | |
| 692 | + | |
| 693 | + if (isset($attr['queryExclude']) && $attr['queryExclude']) { | |
| 694 | + $_exclude = (substr($attr['queryExclude'], 0, 1) === "[") ? $this->get_value(json_decode($attr['queryExclude'])) : explode(',', $attr['queryExclude']); | |
| 695 | + if (is_array($_exclude) && count($_exclude)) { | |
| 696 | + $archive_query['post__not_in'] = isset($archive_query['post__not_in']) ? array_merge($archive_query['post__not_in'], $_exclude) : $_exclude; | |
| 697 | + } | |
| 698 | + } | |
| 699 | + | |
| 700 | + | |
| 701 | + if(isset($attr['querySticky']) && $attr['querySticky']) { | |
| 702 | + if (filter_var($attr['querySticky'], FILTER_VALIDATE_BOOLEAN)) { | |
| 703 | + $sticky = get_option( 'sticky_posts', [] ); | |
| 704 | + $archive_query['post__not_in'] = isset($archive_query['post__not_in']) ? array_merge($archive_query['post__not_in'], $sticky) : $sticky; | |
| 705 | + } | |
| 706 | + } | |
| 707 | + | |
| 708 | + $archive_query['post_status'] = 'publish'; | |
| 709 | + if (is_user_logged_in()) { | |
| 710 | + if( current_user_can('editor') || current_user_can('administrator') ) { | |
| 711 | + $archive_query['post_status'] = array('publish', 'private'); | |
| 712 | + } | |
| 713 | + } | |
| 714 | + | |
| 715 | + if(!isset($archive_query['orderby'])) { | |
| 716 | + $archive_query['orderby'] = isset($attr['queryOrderBy']) ? $attr['queryOrderBy'] : 'date'; | |
| 717 | + } | |
| 718 | + | |
| 719 | + // Quick Query Support for Builder | |
| 720 | + if (isset($attr['queryQuick'])) { | |
| 721 | + if ($attr['queryQuick'] != '') { | |
| 722 | + $archive_query = ultimate_post()->get_quick_query($attr, $archive_query); | |
| 723 | + } | |
| 724 | + } | |
| 725 | + | |
| 726 | + if (!isset($attr['ajaxCall'])) { | |
| 727 | + if(isset($attr['filterShow']) && $attr['filterShow']) { | |
| 728 | + if(isset($attr['filterType']) && isset($attr['filterValue'])) { | |
| 729 | + $filterValue = strlen($attr['filterValue']) > 2 ? $attr['filterValue'] : []; | |
| 730 | + $filterValue = is_array($filterValue) ? $filterValue : json_decode($filterValue); | |
| 731 | + if (count($filterValue) > 0 && $attr['filterType']) { | |
| 732 | + $final = array('relation' => 'OR'); | |
| 733 | + foreach ($filterValue as $key => $val) { | |
| 734 | + $final[] = array( | |
| 735 | + 'taxonomy' => $attr['filterType'], | |
| 736 | + 'field' => 'slug', | |
| 737 | + 'terms' => $val, | |
| 738 | + ); | |
| 739 | + } | |
| 740 | + $archive_query['tax_query'] = $final; | |
| 741 | + } | |
| 742 | + } | |
| 743 | + } | |
| 744 | + } | |
| 745 | + | |
| 746 | + return apply_filters('ultp_archive_query', $archive_query); | |
| 747 | + } | |
| 748 | + | |
| 152 | 749 | $query_args = array( |
| 153 | 750 | 'posts_per_page' => isset($attr['queryNumber']) ? $attr['queryNumber'] : 3, |
| 154 | - 'post_type' => isset($attr['queryType']) ? $attr['queryType'] : 'post', | |
| 751 | + 'post_type' => $post_type == 'archiveBuilder' ? 'post' : $post_type, | |
| 155 | 752 | 'orderby' => isset($attr['queryOrderBy']) ? $attr['queryOrderBy'] : 'date', |
| 156 | 753 | 'order' => isset($attr['queryOrder']) ? $attr['queryOrder'] : 'desc', |
| 157 | 754 | 'paged' => isset($attr['paged']) ? $attr['paged'] : 1, |
| 158 | 755 | 'post_status' => 'publish' |
| @@ -157,79 +754,237 @@ | ||
| 157 | 754 | 'paged' => isset($attr['paged']) ? $attr['paged'] : 1, |
| 158 | 755 | 'post_status' => 'publish' |
| 159 | 756 | ); |
| 160 | 757 | |
| 161 | - if(isset($attr['queryOrderBy']) && isset($attr['metaKey'])){ | |
| 162 | - if($attr['queryOrderBy'] == 'meta_value_num') { | |
| 758 | + // For Private Post 'private' | |
| 759 | + if (is_user_logged_in()) { | |
| 760 | + if( current_user_can('editor') || current_user_can('administrator') ) { | |
| 761 | + $query_args['post_status'] = array('publish', 'private'); | |
| 762 | + } | |
| 763 | + } | |
| 764 | + | |
| 765 | + if ($attr['queryType'] == 'posts') { | |
| 766 | + if (isset($attr['queryPosts']) && $attr['queryPosts']) { | |
| 767 | + unset($query_args['post_type']); | |
| 768 | + $data = json_decode(isset($attr['queryPosts'])?$attr['queryPosts']:'[]'); | |
| 769 | + $final = $this->get_value($data); | |
| 770 | + if (count($final) > 0) { | |
| 771 | + $query_args['post__in'] = $final; | |
| 772 | + $query_args['posts_per_page'] = -1; | |
| 773 | + } | |
| 774 | + $query_args['ignore_sticky_posts'] = 1; | |
| 775 | + return $query_args; | |
| 776 | + } | |
| 777 | + } else if ($attr['queryType'] == 'customPosts') { | |
| 778 | + if (isset($attr['queryCustomPosts']) && $attr['queryCustomPosts']) { | |
| 779 | + $query_args['post_type'] = $this->get_post_type(); | |
| 780 | + $data = json_decode(isset($attr['queryCustomPosts'])?$attr['queryCustomPosts']:'[]'); | |
| 781 | + $final = $this->get_value($data); | |
| 782 | + if (count($final) > 0) { | |
| 783 | + $query_args['post__in'] = $final; | |
| 784 | + $query_args['posts_per_page'] = -1; | |
| 785 | + } | |
| 786 | + $query_args['ignore_sticky_posts'] = 1; | |
| 787 | + return $query_args; | |
| 788 | + } | |
| 789 | + } | |
| 790 | + | |
| 791 | + if (isset($attr['queryExcludeAuthor']) && $attr['queryExcludeAuthor']) { | |
| 792 | + $data = json_decode(isset($attr['queryExcludeAuthor'])?$attr['queryExcludeAuthor']:'[]'); | |
| 793 | + $final = $this->get_value($data); | |
| 794 | + if (count($final) > 0) { | |
| 795 | + $query_args['author__not_in'] = $final; | |
| 796 | + } | |
| 797 | + } | |
| 798 | + | |
| 799 | + | |
| 800 | + if (isset($attr['queryOrderBy']) && isset($attr['metaKey'])) { | |
| 801 | + if ($attr['queryOrderBy'] == 'meta_value_num') { | |
| 163 | 802 | $query_args['meta_key'] = $attr['metaKey']; |
| 164 | 803 | } |
| 165 | 804 | } |
| 166 | 805 | |
| 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'; | |
| 806 | + // Include Remove from Version 2.5.4 | |
| 807 | + if (isset($attr['queryInclude']) && $attr['queryInclude']) { | |
| 808 | + $_include = explode(',', $attr['queryInclude']); | |
| 809 | + if (is_array($_include) && count($_include)) { | |
| 810 | + $query_args['post__in'] = isset($query_args['post__in']) ? array_merge($query_args['post__in'], $_include) : $_include; | |
| 811 | + $query_args['ignore_sticky_posts'] = 1; | |
| 812 | + $query_args['orderby'] = 'post__in'; | |
| 813 | + } | |
| 171 | 814 | } |
| 172 | 815 | |
| 173 | - if(isset($attr['queryExclude']) && $attr['queryExclude']){ | |
| 174 | - $query_args['post__not_in'] = explode(',', $attr['queryExclude']); | |
| 175 | - } | |
| 176 | 816 | |
| 177 | - 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 ); | |
| 817 | + if (isset($attr['queryTax'])) { | |
| 818 | + if (isset($attr['queryTaxValue'])) { | |
| 819 | + $tax_value = (strlen($attr['queryTaxValue']) > 2) ? $attr['queryTaxValue'] : []; | |
| 820 | + $tax_value = is_array($tax_value) ? $tax_value : json_decode($tax_value); | |
| 821 | + | |
| 822 | + $tax_value = (isset($tax_value[0]) && is_object($tax_value[0])) ? $this->get_value($tax_value) : $tax_value; | |
| 823 | + | |
| 824 | + if (is_array($tax_value) && count($tax_value) > 0) { | |
| 825 | + $relation = isset($attr['queryRelation']) ? $attr['queryRelation'] : 'OR'; | |
| 826 | + $var = array('relation'=>$relation); | |
| 827 | + foreach ($tax_value as $val) { | |
| 828 | + $tax_name = $attr['queryTax']; | |
| 829 | + // For Custom Terms | |
| 830 | + if ($attr['queryTax'] == 'multiTaxonomy') { | |
| 831 | + $temp = explode('###', $val); | |
| 832 | + if (isset($temp[1])) { | |
| 833 | + $val = $temp[1]; | |
| 834 | + $tax_name = $temp[0]; | |
| 835 | + } | |
| 836 | + } | |
| 837 | + | |
| 838 | + $var[] = array('taxonomy'=> $tax_name, 'field' => 'slug', 'terms' => $val ); | |
| 183 | 839 | } |
| 184 | - if(count($var) > 1){ | |
| 840 | + if (count($var) > 1) { | |
| 185 | 841 | $query_args['tax_query'] = $var; |
| 186 | 842 | } |
| 187 | 843 | } |
| 188 | 844 | } |
| 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 ); | |
| 845 | + } | |
| 846 | + | |
| 847 | + | |
| 848 | + if (isset($attr['queryExcludeTerm']) && $attr['queryExcludeTerm']) { | |
| 849 | + $temp = json_decode($attr['queryExcludeTerm']); | |
| 850 | + $_term = []; | |
| 851 | + foreach ($temp as $val) { | |
| 852 | + $temp = explode('###', $val->value); | |
| 853 | + if (isset($temp[1])) { | |
| 854 | + if (array_key_exists($temp[0], $_term)) { | |
| 855 | + $_term[$temp[0]][] = $temp[1]; | |
| 856 | + } else { | |
| 857 | + $_term[$temp[0]] = array($temp[1]); | |
| 194 | 858 | } |
| 195 | - $query_args['tax_query'] = $var; | |
| 196 | 859 | } |
| 197 | 860 | } |
| 861 | + if (count($_term) > 0) { | |
| 862 | + $final = array('relation' => 'AND'); | |
| 863 | + foreach ($_term as $key => $val) { | |
| 864 | + $final[] = array( | |
| 865 | + 'taxonomy' => $key, | |
| 866 | + 'field' => 'slug', | |
| 867 | + 'terms' => $val, | |
| 868 | + 'operator' => 'NOT IN', | |
| 869 | + ); | |
| 870 | + } | |
| 871 | + | |
| 872 | + if (array_key_exists('tax_query', $query_args)) { | |
| 873 | + $query_args['tax_query'] = array( | |
| 874 | + 'relation' => 'AND', | |
| 875 | + $query_args['tax_query'] | |
| 876 | + ); | |
| 877 | + $query_args['tax_query'][] = $final; | |
| 878 | + } else { | |
| 879 | + $query_args['tax_query'] = $final; | |
| 880 | + } | |
| 881 | + } | |
| 198 | 882 | } |
| 199 | 883 | |
| 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 | - } | |
| 884 | + if (isset($attr['queryExclude']) && $attr['queryExclude']) { | |
| 885 | + $_exclude = (substr($attr['queryExclude'], 0, 1) === "[") ? $this->get_value(json_decode($attr['queryExclude'])) : explode(',', $attr['queryExclude']); | |
| 886 | + if (is_array($_exclude) && count($_exclude)) { | |
| 887 | + $query_args['post__not_in'] = isset($query_args['post__not_in']) ? array_merge($query_args['post__not_in'], $_exclude) : $_exclude; | |
| 205 | 888 | } |
| 206 | 889 | } |
| 207 | 890 | |
| 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; | |
| 891 | + if (isset($attr['queryUnique']) && $attr['queryUnique']) { | |
| 892 | + global $unique_ID; | |
| 893 | + if (isset($unique_ID[$attr['queryUnique']])) { | |
| 894 | + $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']]; | |
| 895 | + } | |
| 896 | + } | |
| 897 | + | |
| 898 | + if (isset($attr['queryQuick'])) { | |
| 899 | + if ($attr['queryQuick'] != '' && $post_type != 'archiveBuilder') { | |
| 900 | + $query_args = ultimate_post()->get_quick_query($attr, $query_args); | |
| 901 | + } | |
| 902 | + } | |
| 903 | + | |
| 904 | + if (isset($attr['queryOffset']) && $attr['queryOffset'] ) { | |
| 905 | + $offset = $this->get_offset($attr['queryOffset'], $query_args); | |
| 906 | + $query_args = array_merge($query_args, $offset); | |
| 907 | + } | |
| 908 | + | |
| 909 | + if (isset($attr['queryAuthor']) && $attr['queryAuthor'] ) { | |
| 910 | + $_include = (substr($attr['queryAuthor'], 0, 1) === "[") ? $this->get_value(json_decode($attr['queryAuthor'])) : explode(',', $attr['queryAuthor']); | |
| 911 | + if (is_array($_include) && count($_include)) { | |
| 912 | + $query_args['author__in'] = $_include; | |
| 913 | + } | |
| 914 | + } | |
| 915 | + | |
| 916 | + if(isset($attr['querySticky']) && $attr['querySticky']) { | |
| 917 | + if (filter_var($attr['querySticky'], FILTER_VALIDATE_BOOLEAN)) { | |
| 918 | + $sticky = get_option( 'sticky_posts', [] ); | |
| 919 | + $query_args['post__not_in'] = isset($query_args['post__not_in']) ? array_merge($query_args['post__not_in'], $sticky) : $sticky; | |
| 920 | + } | |
| 921 | + } | |
| 922 | + | |
| 923 | + if (!isset($attr['ajaxCall'])) { | |
| 924 | + if(isset($attr['filterShow']) && $attr['filterShow']) { | |
| 925 | + if(isset($attr['filterType']) && isset($attr['filterValue'])) { | |
| 926 | + $filterValue = strlen($attr['filterValue']) > 2 ? $attr['filterValue'] : []; | |
| 927 | + $filterValue = is_array($filterValue) ? $filterValue : json_decode($filterValue); | |
| 928 | + if (is_array($filterValue) && count($filterValue) > 0 && $attr['filterType']) { | |
| 929 | + $final = array('relation' => 'OR'); | |
| 930 | + foreach ($filterValue as $key => $val) { | |
| 931 | + $final[] = array( | |
| 932 | + 'taxonomy' => $attr['filterType'], | |
| 933 | + 'field' => 'slug', | |
| 934 | + 'terms' => $val, | |
| 935 | + // 'operator' => '=', | |
| 936 | + ); | |
| 937 | + } | |
| 938 | + $query_args['tax_query'] = $final; | |
| 215 | 939 | } |
| 216 | - $query_args['post__not_in'] = $offset; | |
| 217 | 940 | } |
| 218 | - }else{ | |
| 219 | - $query_args['offset'] = isset($attr['queryOffset']) ? $attr['queryOffset'] : 0; | |
| 220 | 941 | } |
| 221 | 942 | } |
| 222 | 943 | |
| 223 | 944 | $query_args['wpnonce'] = wp_create_nonce( 'ultp-nonce' ); |
| 224 | 945 | |
| 225 | - return $query_args; | |
| 946 | + return apply_filters('ultp_frontend_query', $query_args); | |
| 226 | 947 | } |
| 227 | 948 | |
| 949 | + /** | |
| 950 | + * Get Page Offset | |
| 951 | + * | |
| 952 | + * @since v.1.0.0 | |
| 953 | + * @param | Offset Number(NUMBER) | Query Arg(ARRAY) | |
| 954 | + * @return ARRAY | |
| 955 | + */ | |
| 956 | + function get_offset($queryOffset, $query_args) { | |
| 957 | + $query = array(); | |
| 958 | + if ($query_args['paged'] > 1) { | |
| 959 | + $offset_post = wp_get_recent_posts($query_args, OBJECT); | |
| 960 | + if (count($offset_post) > 0 ) { | |
| 961 | + $offset = array(); | |
| 962 | + for($x = count($offset_post); $x > count($offset_post) - $queryOffset; $x--) { | |
| 963 | + $offset[] = $offset_post[$x-1]->ID; | |
| 964 | + } | |
| 965 | + $query['post__not_in'] = $offset; | |
| 966 | + } | |
| 967 | + } else { | |
| 968 | + $query['offset'] = isset($queryOffset) ? $queryOffset : 0; | |
| 969 | + } | |
| 970 | + return $query; | |
| 971 | + } | |
| 228 | 972 | |
| 973 | + | |
| 974 | + /** | |
| 975 | + * Get Page Number | |
| 976 | + * | |
| 977 | + * @since v.1.0.0 | |
| 978 | + * @param | Attribute of the Query(ARRAY) | Post Number(ARRAY) | |
| 979 | + * @return ARRAY | |
| 980 | + */ | |
| 229 | 981 | public function get_page_number($attr, $post_number) { |
| 230 | - if($post_number > 0){ | |
| 231 | - $post_per_page = isset($attr['queryNumber']) ? $attr['queryNumber'] : 3; | |
| 982 | + if ($post_number > 0) { | |
| 983 | + if (isset($attr['queryOffset']) && $attr['queryOffset']) { | |
| 984 | + $post_number = $post_number - (int)$attr['queryOffset']; | |
| 985 | + } | |
| 986 | + $post_per_page = isset($attr['queryNumber']) ? ($attr['queryNumber'] ? $attr['queryNumber'] : 1) : 3; | |
| 232 | 987 | $pages = ceil($post_number/$post_per_page); |
| 233 | 988 | return $pages ? $pages : 1; |
| 234 | 989 | }else{ |
| 235 | 990 | return 1; |
| @@ -235,64 +990,117 @@ | ||
| 235 | 990 | return 1; |
| 236 | 991 | } |
| 237 | 992 | } |
| 238 | 993 | |
| 994 | + | |
| 995 | + /** | |
| 996 | + * Get Image Size | |
| 997 | + * | |
| 998 | + * @since v.1.0.0 | |
| 999 | + * @param | Attribute of the Query(ARRAY) | Post Number(ARRAY) | |
| 1000 | + * @return ARRAY | |
| 1001 | + */ | |
| 239 | 1002 | public function get_image_size() { |
| 240 | 1003 | $sizes = get_intermediate_image_sizes(); |
| 241 | 1004 | $filter = array('full' => 'Full'); |
| 242 | 1005 | foreach ($sizes as $value) { |
| 243 | - $filter[$value] = ucwords(str_replace(array('_', '-'), array(' ', ' '), $value)); | |
| 1006 | + $title = ucwords(str_replace(array('_', '-'), array(' ', ' '), $value)); | |
| 1007 | + switch ($value) { | |
| 1008 | + case 'thumbnail': | |
| 1009 | + $title = $title.' [150x150]'; | |
| 1010 | + break; | |
| 1011 | + case 'medium': | |
| 1012 | + $title = $title.' [300x300]'; | |
| 1013 | + break; | |
| 1014 | + case 'large': | |
| 1015 | + $title = $title.' [1024x1024]'; | |
| 1016 | + break; | |
| 1017 | + case 'ultp_layout_landscape_large': | |
| 1018 | + $title = $title.' [1200x800]'; | |
| 1019 | + break; | |
| 1020 | + case 'ultp_layout_landscape': | |
| 1021 | + $title = $title.' [870x570]'; | |
| 1022 | + break; | |
| 1023 | + case 'ultp_layout_portrait': | |
| 1024 | + $title = $title.' [600x900]'; | |
| 1025 | + break; | |
| 1026 | + case 'ultp_layout_square': | |
| 1027 | + $title = $title.' [600x600]'; | |
| 1028 | + break; | |
| 1029 | + default: | |
| 1030 | + break; | |
| 1031 | + } | |
| 1032 | + $filter[$value] = $title; | |
| 244 | 1033 | } |
| 245 | 1034 | return $filter; |
| 246 | 1035 | } |
| 247 | 1036 | |
| 248 | 1037 | |
| 1038 | + /** | |
| 1039 | + * Get All PostType Registered | |
| 1040 | + * | |
| 1041 | + * @since v.1.0.0 | |
| 1042 | + * @param | Attribute of the Query(ARRAY) | Post Number(ARRAY) | |
| 1043 | + * @return ARRAY | |
| 1044 | + */ | |
| 249 | 1045 | 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' )); | |
| 1046 | + $filter = apply_filters('ultp_public_post_type', true); | |
| 1047 | + $post_type = get_post_types( ($filter ? ['public' => true] : ''), 'names' ); | |
| 1048 | + return array_diff($post_type, array( 'attachment' )); | |
| 252 | 1049 | } |
| 253 | 1050 | |
| 254 | 1051 | |
| 255 | - // Pagination | |
| 256 | - public function pagination($pages = '', $paginationNav, $range = 1) { | |
| 1052 | + /** | |
| 1053 | + * Get Pagination HTML | |
| 1054 | + * | |
| 1055 | + * @since v.1.0.0 | |
| 1056 | + * @param | pages (NUMBER) | Pagination Nav (STRING) | Pagination Text | | |
| 1057 | + * @return STRING | |
| 1058 | + */ | |
| 1059 | + public function pagination($pages = '', $paginationNav = '', $paginationText = '') { | |
| 257 | 1060 | $html = ''; |
| 258 | 1061 | $showitems = 3; |
| 259 | - $paged = get_query_var('paged') ? get_query_var('paged') : 1; | |
| 260 | - if($pages == '') { | |
| 1062 | + $paged = is_front_page() ? get_query_var('page') : get_query_var('paged'); | |
| 1063 | + $paged = $paged ? $paged : 1; | |
| 1064 | + if ($pages == '') { | |
| 261 | 1065 | global $wp_query; |
| 262 | 1066 | $pages = $wp_query->max_num_pages; |
| 263 | - if(!$pages) { | |
| 1067 | + if (!$pages) { | |
| 264 | 1068 | $pages = 1; |
| 265 | 1069 | } |
| 266 | 1070 | } |
| 267 | 1071 | $data = ($paged>=3?[($paged-1),$paged,$paged+1]:[1,2,3]); |
| 268 | 1072 | |
| 1073 | + $paginationText = explode('|', $paginationText); | |
| 1074 | + | |
| 1075 | + $prev_text = isset($paginationText[0]) ? $paginationText[0] : __("Previous", "ultimate-post"); | |
| 1076 | + $next_text = isset($paginationText[1]) ? $paginationText[1] : __("Next", "ultimate-post"); | |
| 269 | 1077 | |
| 270 | - if(1 != $pages) { | |
| 1078 | + if (1 != $pages) { | |
| 271 | 1079 | $html .= '<ul class="ultp-pagination">'; |
| 272 | 1080 | $display_none = 'style="display:none"'; |
| 273 | - 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>'; | |
| 1081 | + if ($pages > 4) { | |
| 1082 | + $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 | 1083 | } |
| 276 | - if($pages > 4){ | |
| 1084 | + if ($pages > 4) { | |
| 277 | 1085 | $html .= '<li class="ultp-first-pages" '.($paged<2?$display_none:"").' data-current="1"><a href="'.get_pagenum_link(1).'">1</a></li>'; |
| 278 | 1086 | } |
| 279 | - if($pages > 4){ | |
| 1087 | + if ($pages > 4) { | |
| 280 | 1088 | $html .= '<li class="ultp-first-dot" '.($paged<2? $display_none : "").'><a href="#">...</a></li>'; |
| 281 | 1089 | } |
| 282 | 1090 | foreach ($data as $i) { |
| 283 | - if($pages >= $i){ | |
| 1091 | + if ($pages >= $i) { | |
| 284 | 1092 | $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>'; |
| 285 | 1093 | } |
| 286 | 1094 | } |
| 287 | - if($pages > 4){ | |
| 1095 | + if ($pages > 4) { | |
| 288 | 1096 | $html .= '<li class="ultp-last-dot" '.($pages<=$paged+1?$display_none:"").'><a href="#">...</a></li>'; |
| 289 | 1097 | } |
| 290 | - if($pages > 4){ | |
| 1098 | + if ($pages > 4) { | |
| 291 | 1099 | $html .= '<li class="ultp-last-pages" '.($pages<=$paged+1?$display_none:"").' data-current="'.$pages.'"><a href="'.get_pagenum_link($pages).'">'.$pages.'</a></li>'; |
| 292 | 1100 | } |
| 293 | 1101 | 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>'; | |
| 1102 | + $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 | 1103 | } |
| 296 | 1104 | $html .= '</ul>'; |
| 297 | 1105 | } |
| 298 | 1106 | return $html; |
| @@ -297,17 +1105,123 @@ | ||
| 297 | 1105 | } |
| 298 | 1106 | return $html; |
| 299 | 1107 | } |
| 300 | 1108 | |
| 1109 | + /** | |
| 1110 | + * Svg Icon Source | |
| 1111 | + * | |
| 1112 | + * @since v.1.0.0 | |
| 1113 | + * @param STRING | String Name | |
| 1114 | + * @return STRING | |
| 1115 | + */ | |
| 1116 | + public function svg_icon($ultp_icons = '') { | |
| 1117 | + $ultp_icon_lists = array( | |
| 1118 | + 'eye' => file_get_contents(ULTP_PATH.'assets/img/setting/eye.svg'), | |
| 1119 | + 'user' => file_get_contents(ULTP_PATH.'assets/img/setting/user.svg'), | |
| 1120 | + 'calendar' => file_get_contents(ULTP_PATH.'assets/img/setting/calendar.svg'), | |
| 1121 | + 'comment' => file_get_contents(ULTP_PATH.'assets/img/setting/comment.svg'), | |
| 1122 | + 'book' => file_get_contents(ULTP_PATH.'assets/img/setting/book.svg'), | |
| 1123 | + 'tag' => file_get_contents(ULTP_PATH.'assets/img/setting/tag.svg'), | |
| 1124 | + 'clock' => file_get_contents(ULTP_PATH.'assets/img/setting/clock.svg'), | |
| 1125 | + 'leftAngle' => file_get_contents(ULTP_PATH.'assets/img/setting/leftAngle.svg'), | |
| 1126 | + 'rightAngle' => file_get_contents(ULTP_PATH.'assets/img/setting/rightAngle.svg'), | |
| 1127 | + 'leftAngle2' => file_get_contents(ULTP_PATH.'assets/img/setting/leftAngle2.svg'), | |
| 1128 | + 'rightAngle2' => file_get_contents(ULTP_PATH.'assets/img/setting/rightAngle2.svg'), | |
| 1129 | + 'leftArrowLg' => file_get_contents(ULTP_PATH.'assets/img/setting/leftArrowLg.svg'), | |
| 1130 | + 'rightArrowLg' => file_get_contents(ULTP_PATH.'assets/img/setting/rightArrowLg.svg'), | |
| 1131 | + 'refresh' => file_get_contents(ULTP_PATH.'assets/img/setting/refresh.svg'), | |
| 1132 | + 'upArrow' => file_get_contents(ULTP_PATH.'assets/img/setting/upArrow.svg'), | |
| 1133 | + 'downArrow' => file_get_contents(ULTP_PATH.'assets/img/setting/downArrow.svg'), | |
| 1134 | + 'arrowUp2' => file_get_contents(ULTP_PATH.'assets/img/setting/arrowUp2.svg'), | |
| 1135 | + 'longArrowUp2' => file_get_contents(ULTP_PATH.'assets/img/setting/longArrowUp2.svg'), | |
| 1136 | + 'caretArrow' => file_get_contents(ULTP_PATH.'assets/img/setting/caretArrow.svg'), | |
| 1137 | + 'left' => file_get_contents(ULTP_PATH.'assets/img/setting/left.svg'), | |
| 1138 | + 'center' => file_get_contents(ULTP_PATH.'assets/img/setting/center.svg'), | |
| 1139 | + 'right' => file_get_contents(ULTP_PATH.'assets/img/setting/right.svg'), | |
| 1140 | + 'justify' => file_get_contents(ULTP_PATH.'assets/img/setting/justify.svg'), | |
| 1141 | + 'desktop' => file_get_contents(ULTP_PATH.'assets/img/setting/desktop.svg'), | |
| 1142 | + 'laptop' => file_get_contents(ULTP_PATH.'assets/img/setting/laptop.svg'), | |
| 1143 | + 'tablet' => file_get_contents(ULTP_PATH.'assets/img/setting/tablet.svg'), | |
| 1144 | + 'mobile' => file_get_contents(ULTP_PATH.'assets/img/setting/mobile.svg'), | |
| 1145 | + 'dimension' => file_get_contents(ULTP_PATH.'assets/img/setting/dimension.svg'), | |
| 1146 | + 'setting' => file_get_contents(ULTP_PATH.'assets/img/setting/setting.svg'), | |
| 1147 | + 'plus' => file_get_contents(ULTP_PATH.'assets/img/setting/plus.svg'), | |
| 1148 | + // Builder | |
| 1149 | + 'commentCount1' => file_get_contents(ULTP_PATH.'assets/img/blocks/builder/comments_meta/commentCount1.svg'), | |
| 1150 | + 'commentCount2' => file_get_contents(ULTP_PATH.'assets/img/blocks/builder/comments_meta/commentCount2.svg'), | |
| 1151 | + 'commentCount3' => file_get_contents(ULTP_PATH.'assets/img/blocks/builder/comments_meta/commentCount3.svg'), | |
| 1152 | + 'commentCount4' => file_get_contents(ULTP_PATH.'assets/img/blocks/builder/comments_meta/commentCount4.svg'), | |
| 1153 | + 'commentCount5' => file_get_contents(ULTP_PATH.'assets/img/blocks/builder/comments_meta/commentCount5.svg'), | |
| 1154 | + 'commentCount6' => file_get_contents(ULTP_PATH.'assets/img/blocks/builder/comments_meta/commentCount6.svg'), | |
| 1155 | + 'date1' => file_get_contents(ULTP_PATH.'assets/img/blocks/builder/date_meta/date1.svg'), | |
| 1156 | + 'date2' => file_get_contents(ULTP_PATH.'assets/img/blocks/builder/date_meta/date2.svg'), | |
| 1157 | + 'date3' => file_get_contents(ULTP_PATH.'assets/img/blocks/builder/date_meta/date3.svg'), | |
| 1158 | + 'date4' => file_get_contents(ULTP_PATH.'assets/img/blocks/builder/date_meta/date4.svg'), | |
| 1159 | + 'date5' => file_get_contents(ULTP_PATH.'assets/img/blocks/builder/date_meta/date5.svg'), | |
| 1160 | + 'author1' => file_get_contents(ULTP_PATH.'assets/img/blocks/builder/author_meta/author1.svg'), | |
| 1161 | + 'author2' => file_get_contents(ULTP_PATH.'assets/img/blocks/builder/author_meta/author2.svg'), | |
| 1162 | + 'author3' => file_get_contents(ULTP_PATH.'assets/img/blocks/builder/author_meta/author3.svg'), | |
| 1163 | + 'author4' => file_get_contents(ULTP_PATH.'assets/img/blocks/builder/author_meta/author4.svg'), | |
| 1164 | + 'author5' => file_get_contents(ULTP_PATH.'assets/img/blocks/builder/author_meta/author5.svg'), | |
| 1165 | + 'readingTime1' => file_get_contents(ULTP_PATH. | |
| 1166 | + '/assets/img/blocks/builder/reading_time/readingTime1.svg'), | |
| 1167 | + 'readingTime2' => file_get_contents(ULTP_PATH.'assets/img/blocks/builder/reading_time/readingTime2.svg'), | |
| 1168 | + 'readingTime3' => file_get_contents(ULTP_PATH.'assets/img/blocks/builder/reading_time/readingTime3.svg'), | |
| 1169 | + 'readingTime4' => file_get_contents(ULTP_PATH.'assets/img/blocks/builder/reading_time/readingTime4.svg'), | |
| 1170 | + 'readingTime5' => file_get_contents(ULTP_PATH.'assets/img/blocks/builder/reading_time/readingTime5.svg'), | |
| 1171 | + 'viewCount1' => file_get_contents(ULTP_PATH.'assets/img/blocks/builder/viewCount/viewCount1.svg'), | |
| 1172 | + 'viewCount2' => file_get_contents(ULTP_PATH.'assets/img/blocks/builder/viewCount/viewCount2.svg'), | |
| 1173 | + 'viewCount3' => file_get_contents(ULTP_PATH.'assets/img/blocks/builder/viewCount/viewCount3.svg'), | |
| 1174 | + 'viewCount4' => file_get_contents(ULTP_PATH.'assets/img/blocks/builder/viewCount/viewCount4.svg'), | |
| 1175 | + 'viewCount5' => file_get_contents(ULTP_PATH.'assets/img/blocks/builder/viewCount/viewCount5.svg'), | |
| 1176 | + 'viewCount6' => file_get_contents(ULTP_PATH.'assets/img/blocks/builder/viewCount/viewCount6.svg'), | |
| 1177 | + 'cat1' => file_get_contents(ULTP_PATH.'assets/img/blocks/builder/category/cat1.svg'), | |
| 1178 | + 'cat2' => file_get_contents(ULTP_PATH.'assets/img/blocks/builder/category/cat2.svg'), | |
| 1179 | + 'cat3' => file_get_contents(ULTP_PATH.'assets/img/blocks/builder/category/cat3.svg'), | |
| 1180 | + 'cat4' => file_get_contents(ULTP_PATH.'assets/img/blocks/builder/category/cat4.svg'), | |
| 1181 | + 'cat5' => file_get_contents(ULTP_PATH.'assets/img/blocks/builder/category/cat5.svg'), | |
| 1182 | + 'cat6' => file_get_contents(ULTP_PATH.'assets/img/blocks/builder/category/cat6.svg'), | |
| 1183 | + 'cat7' => file_get_contents(ULTP_PATH.'assets/img/blocks/builder/category/cat7.svg'), | |
| 1184 | + 'tag1' => file_get_contents(ULTP_PATH.'assets/img/blocks/builder/tag/tag1.svg'), | |
| 1185 | + 'tag2' => file_get_contents(ULTP_PATH.'assets/img/blocks/builder/tag/tag2.svg'), | |
| 1186 | + 'tag3' => file_get_contents(ULTP_PATH.'assets/img/blocks/builder/tag/tag3.svg'), | |
| 1187 | + 'tag4' => file_get_contents(ULTP_PATH.'assets/img/blocks/builder/tag/tag4.svg'), | |
| 1188 | + 'tag5' => file_get_contents(ULTP_PATH.'assets/img/blocks/builder/tag/tag5.svg'), | |
| 1189 | + 'tag6' => file_get_contents(ULTP_PATH.'assets/img/blocks/builder/tag/tag6.svg'), | |
| 1190 | + 'rightArrowLg' => file_get_contents(ULTP_PATH.'assets/img/svg/rightArrowLg.svg'), | |
| 1191 | + 'share' => file_get_contents(ULTP_PATH.'assets/img/svg/share.svg'), | |
| 1192 | + 'facebook' => file_get_contents(ULTP_PATH.'assets/img/svg/facebookIcon.svg'), | |
| 1193 | + 'linkedin' => file_get_contents(ULTP_PATH.'assets/img/svg/linkedinIcon.svg'), | |
| 1194 | + 'mail' => file_get_contents(ULTP_PATH.'assets/img/svg/mailIcon.svg'), | |
| 1195 | + 'messenger' => file_get_contents(ULTP_PATH.'assets/img/svg/messengerIcon.svg'), | |
| 1196 | + 'reddit' => file_get_contents(ULTP_PATH.'assets/img/svg/redditIcon.svg'), | |
| 1197 | + 'twitter' => file_get_contents(ULTP_PATH.'assets/img/svg/twitterIcon.svg'), | |
| 1198 | + 'whatsapp' => file_get_contents(ULTP_PATH.'assets/img/svg/whatsappIcon.svg'), | |
| 1199 | + 'pinterest' => file_get_contents(ULTP_PATH.'assets/img/svg/pinIcon.svg'), | |
| 1200 | + 'skype' => file_get_contents(ULTP_PATH.'assets/img/svg/skype.svg'), | |
| 1201 | + ); | |
| 1202 | + if ($ultp_icons) { | |
| 1203 | + return $ultp_icon_lists[ $ultp_icons ]; | |
| 1204 | + } | |
| 1205 | + } | |
| 1206 | + | |
| 1207 | + | |
| 1208 | + /** | |
| 1209 | + * Get Excerpt Word | |
| 1210 | + * | |
| 1211 | + * @since v.1.0.0 | |
| 1212 | + * @param NUMBER | Character Length | |
| 1213 | + * @return STRING | |
| 1214 | + */ | |
| 301 | 1215 | public function excerpt_word($charlength = 200) { |
| 302 | 1216 | $html = ''; |
| 303 | 1217 | $charlength++; |
| 304 | 1218 | $excerpt = get_the_excerpt(); |
| 305 | - if ( mb_strlen( $excerpt ) > $charlength ) { | |
| 306 | - $subex = mb_substr( $excerpt, 0, $charlength - 5 ); | |
| 1219 | + if (mb_strlen( $excerpt ) > $charlength ) { | |
| 1220 | + $subex = mb_substr( $excerpt, 0, $charlength ); | |
| 307 | 1221 | $exwords = explode( ' ', $subex ); |
| 308 | 1222 | $excut = - ( mb_strlen( $exwords[ count( $exwords ) - 1 ] ) ); |
| 309 | - if ( $excut < 0 ) { | |
| 1223 | + if ($excut < 0 ) { | |
| 310 | 1224 | $html = mb_substr( $subex, 0, $excut ); |
| 311 | 1225 | } else { |
| 312 | 1226 | $html = $subex; |
| 313 | 1227 | } |
| @@ -318,16 +1232,23 @@ | ||
| 318 | 1232 | return $html; |
| 319 | 1233 | } |
| 320 | 1234 | |
| 321 | 1235 | |
| 1236 | + /** | |
| 1237 | + * Get Taxonomy Lists | |
| 1238 | + * | |
| 1239 | + * @since v.1.0.0 | |
| 1240 | + * @param STRING | Taxonomy Slug | |
| 1241 | + * @return ARRAY | |
| 1242 | + */ | |
| 322 | 1243 | public function taxonomy( $prams = 'category' ) { |
| 323 | 1244 | $data = array(); |
| 324 | 1245 | $terms = get_terms( $prams, array( |
| 325 | - 'hide_empty' => true, | |
| 1246 | + 'hide_empty' => false, | |
| 326 | 1247 | )); |
| 327 | - if( !empty($terms) ){ | |
| 1248 | + if (!is_wp_error($terms)) { | |
| 328 | 1249 | foreach ($terms as $val) { |
| 329 | - $data[$val->slug] = $val->name; | |
| 1250 | + $data[urldecode_deep($val->slug)] = $val->name; | |
| 330 | 1251 | } |
| 331 | 1252 | } |
| 332 | 1253 | return $data; |
| 333 | 1254 | } |
| @@ -332,19 +1253,96 @@ | ||
| 332 | 1253 | return $data; |
| 333 | 1254 | } |
| 334 | 1255 | |
| 335 | 1256 | |
| 1257 | + /** | |
| 1258 | + * Get Taxonomy Data Lists | |
| 1259 | + * | |
| 1260 | + * @since v.1.0.0 | |
| 1261 | + * @param OBJECT | Taxonomy Object | |
| 1262 | + * @return ARRAY | |
| 1263 | + */ | |
| 1264 | + public function get_tax_data($terms) { | |
| 1265 | + $temp = array(); | |
| 1266 | + $image = ''; | |
| 1267 | + $thumbnail_id = get_term_meta( $terms->term_id, 'ultp_category_image', true ); | |
| 1268 | + if ($thumbnail_id) { | |
| 1269 | + $image = wp_get_attachment_url( $thumbnail_id ); | |
| 1270 | + } | |
| 1271 | + $temp['url'] = get_term_link($terms); | |
| 1272 | + $temp['name'] = $terms->name; | |
| 1273 | + $temp['desc'] = $terms->description; | |
| 1274 | + $temp['count'] = $terms->count; | |
| 1275 | + $temp['image'] = $image; | |
| 1276 | + $color = get_term_meta($terms->term_id, 'ultp_category_color', true); | |
| 1277 | + $temp['color'] = $color ? $color : '#037fff'; | |
| 1278 | + return $temp; | |
| 1279 | + } | |
| 1280 | + | |
| 1281 | + public function get_category_data($catSlug, $number = 40, $type = '', $tax_slug = 'category') { | |
| 1282 | + $data = array(); | |
| 1283 | + if ($type == 'child') { | |
| 1284 | + $image = ''; | |
| 1285 | + if (!empty($catSlug)) { | |
| 1286 | + foreach ($catSlug as $cat) { | |
| 1287 | + $parent_term = get_term_by('slug', $cat, $tax_slug); | |
| 1288 | + if (!empty($parent_term)) { | |
| 1289 | + $term_data = get_terms($tax_slug, array( | |
| 1290 | + 'hide_empty' => true, | |
| 1291 | + 'parent' => $parent_term->term_id | |
| 1292 | + )); | |
| 1293 | + if (!empty($term_data)) { | |
| 1294 | + foreach ($term_data as $terms) { | |
| 1295 | + $data[] = $this->get_tax_data($terms); | |
| 1296 | + } | |
| 1297 | + } | |
| 1298 | + } | |
| 1299 | + } | |
| 1300 | + } | |
| 1301 | + } else if ($type == 'parent') { | |
| 1302 | + $term_data = get_terms( $tax_slug, array( 'hide_empty' => true, 'number' => $number, 'parent' => 0 ) ); | |
| 1303 | + if (!empty($term_data)) { | |
| 1304 | + foreach ($term_data as $terms) { | |
| 1305 | + $data[] = $this->get_tax_data($terms); | |
| 1306 | + } | |
| 1307 | + } | |
| 1308 | + } else if ($type == 'custom') { | |
| 1309 | + foreach ($catSlug as $cat) { | |
| 1310 | + $terms = get_term_by('slug', $cat, $tax_slug); | |
| 1311 | + if (!empty($terms)) { | |
| 1312 | + $data[] = $this->get_tax_data($terms); | |
| 1313 | + } | |
| 1314 | + } | |
| 1315 | + } else { | |
| 1316 | + $term_data = get_terms($tax_slug, array('hide_empty' => true, 'number' => $number)); | |
| 1317 | + if (!empty($term_data)) { | |
| 1318 | + foreach ($term_data as $terms) { | |
| 1319 | + $data[] = $this->get_tax_data($terms); | |
| 1320 | + } | |
| 1321 | + } | |
| 1322 | + } | |
| 1323 | + return $data; | |
| 1324 | + } | |
| 1325 | + | |
| 1326 | + | |
| 1327 | + /** | |
| 1328 | + * Get Next Previous HTML | |
| 1329 | + * | |
| 1330 | + * @since v.1.0.0 | |
| 1331 | + * @param OBJECT | Taxonomy Object | |
| 1332 | + * @return STRING | |
| 1333 | + */ | |
| 336 | 1334 | public function next_prev() { |
| 337 | 1335 | $html = ''; |
| 338 | 1336 | $html .= '<ul>'; |
| 339 | 1337 | $html .= '<li>'; |
| 340 | 1338 | $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>'; | |
| 1339 | + $html .= ultimate_post()->svg_icon('leftAngle2').'<span class="screen-reader-text">'.esc_html__("Previous", "ultimate-post").'</span>'; | |
| 342 | 1340 | $html .= '</a>'; |
| 343 | 1341 | $html .= '</li>'; |
| 344 | 1342 | $html .= '<li>'; |
| 345 | 1343 | $html .= '<a class="ultp-next-action">'; |
| 346 | - $html .= ultimate_post()->svg_icon('rightAngle2').'<span class="screen-reader-text">'.__("Next", "ultimate-post").'</span>'; | |
| 1344 | + $html .= ultimate_post()->svg_icon('rightAngle2').'<span class="screen-reader-text">'.esc_html__("Next", "ultimate-post").'</span>'; | |
| 347 | 1345 | $html .= '</a>'; |
| 348 | 1346 | $html .= '</li>'; |
| 349 | 1347 | $html .= '</ul>'; |
| 350 | 1348 | return $html; |
| @@ -349,16 +1347,20 @@ | ||
| 349 | 1347 | $html .= '</ul>'; |
| 350 | 1348 | return $html; |
| 351 | 1349 | } |
| 352 | 1350 | |
| 353 | - public function loading(){ | |
| 1351 | + | |
| 1352 | + /** | |
| 1353 | + * Get Loading HTML | |
| 1354 | + * | |
| 1355 | + * @since v.1.0.0 | |
| 1356 | + * @param NULL | |
| 1357 | + * @return STRING | |
| 1358 | + */ | |
| 1359 | + public function loading() { | |
| 354 | 1360 | $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 | - } | |
| 360 | - if( $style == 'style2' ){ | |
| 1361 | + $style = ultimate_post()->get_setting('preloader_style'); | |
| 1362 | + if ($style == 'style2') { | |
| 361 | 1363 | $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 | 1364 | } else { |
| 363 | 1365 | $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 | 1366 | } |
| @@ -364,52 +1366,724 @@ | ||
| 364 | 1366 | } |
| 365 | 1367 | return '<div class="ultp-loading">'.$html.'</div>'; |
| 366 | 1368 | } |
| 367 | 1369 | |
| 368 | - public function filter($filterText = '', $filterType = '', $filterCat = '[]', $filterTag = '[]'){ | |
| 1370 | + | |
| 1371 | + /** | |
| 1372 | + * Get Filter HTML | |
| 1373 | + * | |
| 1374 | + * @since v.1.0.0 | |
| 1375 | + * @param | Filter Text (STRING) | Filter Type (STRING) | Filter Value (ARRAY) | Filter Cat (ARRAY) | Filter Tag (ARRAY) | | |
| 1376 | + * @return STRING | |
| 1377 | + */ | |
| 1378 | + public function filter($filterText = '', $filterType = '', $filterValue = '[]', $filterMobileText = '...', $filterMobile = true) { | |
| 369 | 1379 | $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>'; | |
| 1380 | + $html .= '<ul '.($filterMobile ? 'class="ultp-flex-menu"' : '').' data-name="'.($filterMobileText ? $filterMobileText : ' ').'">'; | |
| 1381 | + $cat = $this->taxonomy($filterType); | |
| 1382 | + if ($filterText) { | |
| 1383 | + $html .= '<li class="filter-item"><a class="filter-active" data-taxonomy="" href="#">'.$filterText.'</a></li>'; | |
| 1384 | + } | |
| 1385 | + | |
| 1386 | + if ($filterValue) { | |
| 1387 | + $filterValue = strlen($filterValue) > 2 ? $filterValue : []; | |
| 1388 | + $filterValue = is_array($filterValue) ? $filterValue : json_decode($filterValue); | |
| 1389 | + if (is_array($filterValue) && count($filterValue)) { | |
| 1390 | + foreach ($filterValue as $val) { | |
| 1391 | + $html .= '<li class="filter-item"><a data-taxonomy="'.$val.'" href="#">'.(isset($cat[$val]) ? $cat[$val] : $val).'</a></li>'; | |
| 1392 | + } | |
| 375 | 1393 | } |
| 376 | - foreach (json_decode($filterCat) as $val) { | |
| 377 | - $html .= '<li class="filter-item"><a data-taxonomy="'.$val.'" href="#">'.(isset($cat[$val]) ? $cat[$val] : $val).'</a></li>'; | |
| 1394 | + } | |
| 1395 | + $html .= '</ul>'; | |
| 1396 | + return $html; | |
| 1397 | + } | |
| 1398 | + | |
| 1399 | + | |
| 1400 | + /** | |
| 1401 | + * Check License Status | |
| 1402 | + * | |
| 1403 | + * @since v.2.4.2 | |
| 1404 | + * @return BOOLEAN | Is pro license active or not | |
| 1405 | + */ | |
| 1406 | + public function is_lc_active() { | |
| 1407 | + if (function_exists('ultimate_post_pro')) { | |
| 1408 | + return get_option('edd_ultp_license_status') == 'valid' ? true : false; | |
| 1409 | + } | |
| 1410 | + if (get_transient( 'ulpt_theme_enable' ) == 'integration') { | |
| 1411 | + return true; | |
| 1412 | + } | |
| 1413 | + return false; | |
| 1414 | + } | |
| 1415 | + | |
| 1416 | + | |
| 1417 | + /** | |
| 1418 | + * Get SEO Meta | |
| 1419 | + * | |
| 1420 | + * @since v.2.4.3 | |
| 1421 | + * @param NUMBER | Post ID | |
| 1422 | + * @return STRING | SEO Meta Description or Excerpt | |
| 1423 | + */ | |
| 1424 | + public function get_excerpt($post_id = 0, $showSeoMeta = 0, $showFullExcerpt = 0, $excerptLimit = 55) { | |
| 1425 | + $html = ''; | |
| 1426 | + if ($showSeoMeta) { | |
| 1427 | + $str = ''; | |
| 1428 | + if (function_exists('ultimate_post_pro') ) { | |
| 1429 | + if (ultimate_post()->get_setting('ultp_yoast') == 'true') { | |
| 1430 | + $str = method_exists( ultimate_post_pro(), 'get_yoast_meta' ) ? ultimate_post_pro()->get_yoast_meta($post_id) : ''; | |
| 1431 | + } else if (ultimate_post()->get_setting('ultp_rankmath') == 'true') { | |
| 1432 | + $str = method_exists( ultimate_post_pro(), 'get_rankmath_meta' ) ? ultimate_post_pro()->get_rankmath_meta($post_id) : ''; | |
| 1433 | + } else if (ultimate_post()->get_setting('ultp_aioseo') == 'true') { | |
| 1434 | + $str = method_exists( ultimate_post_pro(), 'get_aioseo_meta' ) ? ultimate_post_pro()->get_aioseo_meta($post_id) : ''; | |
| 1435 | + } else if (ultimate_post()->get_setting('ultp_seopress') == 'true') { | |
| 1436 | + $str = method_exists( ultimate_post_pro(), 'get_seopress_meta' ) ? ultimate_post_pro()->get_seopress_meta($post_id) : ''; | |
| 1437 | + } else if (ultimate_post()->get_setting('ultp_squirrly') == 'true') { | |
| 1438 | + $str = method_exists( ultimate_post_pro(), 'get_squirrly_meta' ) ? ultimate_post_pro()->get_squirrly_meta($post_id) : ''; | |
| 378 | 1439 | } |
| 1440 | + } | |
| 1441 | + $html = $str ? $str : ultimate_post()->excerpt($post_id, $excerptLimit); | |
| 1442 | + } else { | |
| 1443 | + if ($showFullExcerpt == 0 ) { | |
| 1444 | + $html = ultimate_post()->excerpt($post_id, $excerptLimit); | |
| 379 | 1445 | } else { |
| 380 | - $tag = $this->taxonomy('post_tag'); | |
| 381 | - if($filterText){ | |
| 382 | - $html .= '<li class="filter-item"><a data-taxonomy="" href="#">'.$filterText.'</a></li>'; | |
| 1446 | + $html = get_the_excerpt(); | |
| 1447 | + } | |
| 1448 | + } | |
| 1449 | + return $html; | |
| 1450 | + } | |
| 1451 | + | |
| 1452 | + /** | |
| 1453 | + * Set Inline CSS | |
| 1454 | + * | |
| 1455 | + * @since v.2.5.8 | |
| 1456 | + * @param STRING | CSS | |
| 1457 | + * @return STRING | CSS with Style | |
| 1458 | + */ | |
| 1459 | + public function set_inline($css) { | |
| 1460 | + return '<style type="text/css">'.wp_strip_all_tags($css).'</style>'; | |
| 1461 | + } | |
| 1462 | + | |
| 1463 | + /** | |
| 1464 | + * Array Sanitize Function | |
| 1465 | + * | |
| 1466 | + * @since v.2.6.0 | |
| 1467 | + * @param ARRAY | |
| 1468 | + * @return ARRAY | Array of Sanitize | |
| 1469 | + */ | |
| 1470 | + public function recursive_sanitize_text_field($array) { | |
| 1471 | + foreach ($array as $key => &$value) { | |
| 1472 | + if (is_array($value)) { | |
| 1473 | + $value = $this->recursive_sanitize_text_field($value); | |
| 1474 | + } else { | |
| 1475 | + $value = sanitize_text_field($value); | |
| 1476 | + } | |
| 1477 | + } | |
| 1478 | + return $array; | |
| 1479 | + } | |
| 1480 | + | |
| 1481 | + | |
| 1482 | + public function get_embeded_video($url, $autoPlay, $loop, $mute, $playback, $preload, $poster, $inline, $size) { | |
| 1483 | + $vidAutoPlay = $vidloop = $vidloop = $vidmute = $vidplayback = $vidPoster = $vidInline = ""; | |
| 1484 | + | |
| 1485 | + if($autoPlay){ | |
| 1486 | + $vidAutoPlay = "autoplay"; | |
| 1487 | + } | |
| 1488 | + if($poster){ | |
| 1489 | + $vidPoster = 'poster="'.$poster["url"].'"'; | |
| 1490 | + } | |
| 1491 | + if($loop){ | |
| 1492 | + $vidloop = "loop"; | |
| 1493 | + } | |
| 1494 | + if($mute){ | |
| 1495 | + $vidmute = "muted"; | |
| 1496 | + } | |
| 1497 | + if($playback){ | |
| 1498 | + $vidplayback = "controls"; | |
| 1499 | + } | |
| 1500 | + if($inline){ | |
| 1501 | + $vidInline = "playsinline"; | |
| 1502 | + } | |
| 1503 | + if (!empty($url)) { | |
| 1504 | + $embeded = wp_oembed_get($url, $size); | |
| 1505 | + if ($embeded == false) { | |
| 1506 | + $format = ''; | |
| 1507 | + $url = strtolower($url); | |
| 1508 | + if (strpos($url, '.mp4')) { | |
| 1509 | + $format = 'mp4'; | |
| 1510 | + } elseif (strpos($url, '.ogg')) { | |
| 1511 | + $format = 'ogg'; | |
| 1512 | + } elseif (strpos($url, '.webm')) { | |
| 1513 | + $format = 'WebM'; | |
| 383 | 1514 | } |
| 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>'; | |
| 1515 | + $embeded = '<video | |
| 1516 | + '.$vidloop.' | |
| 1517 | + '.$vidmute.' | |
| 1518 | + '.$vidplayback.' | |
| 1519 | + preload="'.$preload.'" | |
| 1520 | + '.$vidAutoPlay.' | |
| 1521 | + '.$vidPoster.' | |
| 1522 | + '.$vidInline.' | |
| 1523 | + ><source src="' . $url . '" type="video/' . $format . '">' . __('Your browser does not support the video tag.', 'ultimate-post') . '</video>'; | |
| 1524 | + return '<div class="ultp-video-wrapper">'.$embeded.'</div>'; | |
| 1525 | + } | |
| 1526 | + return '<div class="ultp-video-wrapper ultp-embaded-video">'.$embeded.'</div>'; | |
| 1527 | + } else { | |
| 1528 | + return false; | |
| 1529 | + } | |
| 1530 | + } | |
| 1531 | + | |
| 1532 | + /** | |
| 1533 | + * Get Public taxonomy Lists | |
| 1534 | + * | |
| 1535 | + * @since v.2.7.0 | |
| 1536 | + * @param NULL | |
| 1537 | + * @return ARRAY | Taxonomy Lists as array | |
| 1538 | + */ | |
| 1539 | + public function get_taxonomy_list() { | |
| 1540 | + $taxonomy = get_taxonomies(array('public' => true)); | |
| 1541 | + return empty($taxonomy) ? [] : array_keys($taxonomy); | |
| 1542 | + } | |
| 1543 | + | |
| 1544 | + /** | |
| 1545 | + * Content Print | |
| 1546 | + * | |
| 1547 | + * @since v.2.7.0 | |
| 1548 | + * @param NUMBER | Post ID | |
| 1549 | + * @return STRING | Content of the Post | |
| 1550 | + */ | |
| 1551 | + public function content($post_id) { | |
| 1552 | + $content_post = get_post($post_id); | |
| 1553 | + $content = $content_post->post_content; | |
| 1554 | + $content = apply_filters('the_content', $content); | |
| 1555 | + $content = str_replace(']]>', ']]>', $content); | |
| 1556 | + echo $content; | |
| 1557 | + } | |
| 1558 | + | |
| 1559 | + | |
| 1560 | + /** | |
| 1561 | + * String Part finder inside array | |
| 1562 | + * | |
| 1563 | + * @since v.2.7.0 | |
| 1564 | + * @return ARRAY | String Part | |
| 1565 | + */ | |
| 1566 | + public function in_string_part($part, $data, $isValue = false) { | |
| 1567 | + $return = false; | |
| 1568 | + foreach ($data as $val) { | |
| 1569 | + if (strpos($val, $part) !== false) { | |
| 1570 | + $return = $isValue ? $val : true; | |
| 1571 | + break; | |
| 1572 | + } | |
| 1573 | + } | |
| 1574 | + return $return; | |
| 1575 | + } | |
| 1576 | + | |
| 1577 | + /** | |
| 1578 | + * Builder Conditions | |
| 1579 | + * | |
| 1580 | + * @since v.2.7.0 | |
| 1581 | + * @param STRING | Type of Return | |
| 1582 | + * @return MIXED || ID or Path | |
| 1583 | + */ | |
| 1584 | + public function conditions( $type = 'return' ) { | |
| 1585 | + $page_id = ''; | |
| 1586 | + | |
| 1587 | + $conditions = get_option('ultp_builder_conditions', array()); | |
| 1588 | + if (isset($conditions['archive'])) { | |
| 1589 | + if (!empty($conditions['archive'])) { | |
| 1590 | + $taxonomy = (is_category() || is_tag() || is_tax()) ? get_queried_object() : (object)[]; | |
| 1591 | + foreach ($conditions['archive'] as $key => $val) { | |
| 1592 | + if (is_archive()) { | |
| 1593 | + if (in_array('include/archive', $val)) { | |
| 1594 | + if ('publish' == get_post_status($key)) { | |
| 1595 | + $page_id = $key; | |
| 1596 | + } | |
| 1597 | + } | |
| 1598 | + if (in_array('exclude/archive', $val)) { | |
| 1599 | + if ('publish' == get_post_status($key)) { | |
| 1600 | + $page_id = ''; | |
| 1601 | + } | |
| 1602 | + } | |
| 1603 | + if (is_category()) { | |
| 1604 | + if (in_array('include/archive/category', $val)) { | |
| 1605 | + if ('publish' == get_post_status($key)) { | |
| 1606 | + $page_id = $key; | |
| 1607 | + } | |
| 1608 | + } | |
| 1609 | + if (in_array('exclude/archive/category', $val)) { | |
| 1610 | + if ('publish' == get_post_status($key)) { | |
| 1611 | + $page_id = ''; | |
| 1612 | + } | |
| 1613 | + } | |
| 1614 | + if (in_array('include/archive/category/'.$taxonomy->term_id, $val)) { | |
| 1615 | + if ('publish' == get_post_status($key)) { | |
| 1616 | + $page_id = $key; | |
| 1617 | + } | |
| 1618 | + } | |
| 1619 | + if (in_array('exclude/archive/category/'.$taxonomy->term_id, $val)) { | |
| 1620 | + if ('publish' == get_post_status($key)) { | |
| 1621 | + $page_id = ''; | |
| 1622 | + } | |
| 1623 | + } | |
| 1624 | + if ($this->in_string_part('any_child_of', $val)) { | |
| 1625 | + if (in_array('include/archive/any_child_of_category', $val)) { | |
| 1626 | + if ('publish' == get_post_status($key)) { | |
| 1627 | + $page_id = $key; | |
| 1628 | + } | |
| 1629 | + } | |
| 1630 | + if (in_array('exclude/archive/any_child_of_category', $val)) { | |
| 1631 | + if ('publish' == get_post_status($key)) { | |
| 1632 | + $page_id = ''; | |
| 1633 | + } | |
| 1634 | + } | |
| 1635 | + $data = $this->in_string_part('/archive/any_child_of_category/', $val, true); | |
| 1636 | + if ($data) { | |
| 1637 | + $data = explode("/",$data); | |
| 1638 | + if (isset($data[3]) && $data[3]) { | |
| 1639 | + if (term_is_ancestor_of($data[3], $taxonomy->term_id, 'category')) { | |
| 1640 | + if ('publish' == get_post_status($key)) { | |
| 1641 | + $page_id = $data[0] == 'exclude' ? '' : $key; | |
| 1642 | + } | |
| 1643 | + } | |
| 1644 | + } | |
| 1645 | + } | |
| 1646 | + } else { | |
| 1647 | + if ($this->in_string_part('child_of', $val)) { | |
| 1648 | + if (in_array('include/archive/child_of_category', $val)) { | |
| 1649 | + if ('publish' == get_post_status($key)) { | |
| 1650 | + $page_id = $key; | |
| 1651 | + } | |
| 1652 | + } | |
| 1653 | + if (in_array('exclude/archive/child_of_category', $val)) { | |
| 1654 | + if ('publish' == get_post_status($key)) { | |
| 1655 | + $page_id = ''; | |
| 1656 | + } | |
| 1657 | + } | |
| 1658 | + if (in_array('include/archive/child_of_category/'.$taxonomy->parent, $val)) { | |
| 1659 | + if ('publish' == get_post_status($key)) { | |
| 1660 | + $page_id = $key; | |
| 1661 | + } | |
| 1662 | + } | |
| 1663 | + if (in_array('exclude/archive/child_of_category/'.$taxonomy->parent, $val)) { | |
| 1664 | + if ('publish' == get_post_status($key)) { | |
| 1665 | + $page_id = ''; | |
| 1666 | + } | |
| 1667 | + } | |
| 1668 | + } | |
| 1669 | + } | |
| 1670 | + } else if (is_tag()) { | |
| 1671 | + if (in_array('include/archive/post_tag', $val)) { | |
| 1672 | + if ('publish' == get_post_status($key)) { | |
| 1673 | + $page_id = $key; | |
| 1674 | + } | |
| 1675 | + } | |
| 1676 | + if (in_array('exclude/archive/post_tag', $val)) { | |
| 1677 | + if ('publish' == get_post_status($key)) { | |
| 1678 | + $page_id = ''; | |
| 1679 | + } | |
| 1680 | + } | |
| 1681 | + if (in_array('include/archive/post_tag/'.$taxonomy->term_id, $val)) { | |
| 1682 | + if ('publish' == get_post_status($key)) { | |
| 1683 | + $page_id = $key; | |
| 1684 | + } | |
| 1685 | + } | |
| 1686 | + if (in_array('exclude/archive/post_tag/'.$taxonomy->term_id, $val)) { | |
| 1687 | + if ('publish' == get_post_status($key)) { | |
| 1688 | + $page_id = ''; | |
| 1689 | + } | |
| 1690 | + } | |
| 1691 | + } else if (is_tax()) { | |
| 1692 | + if (in_array('include/archive/'.$taxonomy->taxonomy, $val)) { | |
| 1693 | + if ('publish' == get_post_status($key)) { | |
| 1694 | + $page_id = $key; | |
| 1695 | + } | |
| 1696 | + } | |
| 1697 | + if (in_array('exclude/archive/'.$taxonomy->taxonomy, $val)) { | |
| 1698 | + if ('publish' == get_post_status($key)) { | |
| 1699 | + $page_id = ''; | |
| 1700 | + } | |
| 1701 | + } | |
| 1702 | + if (in_array('include/archive/'.$taxonomy->taxonomy.'/'.$taxonomy->term_id, $val)) { | |
| 1703 | + if ('publish' == get_post_status($key)) { | |
| 1704 | + $page_id = $key; | |
| 1705 | + } | |
| 1706 | + } | |
| 1707 | + if (in_array('exclude/archive/'.$taxonomy->taxonomy.'/'.$taxonomy->term_id, $val)) { | |
| 1708 | + if ('publish' == get_post_status($key)) { | |
| 1709 | + $page_id = ''; | |
| 1710 | + } | |
| 1711 | + } | |
| 1712 | + if ($this->in_string_part('any_child_of', $val)) { | |
| 1713 | + if (in_array('include/archive/any_child_of_'.$taxonomy->taxonomy, $val)) { | |
| 1714 | + if ('publish' == get_post_status($key)) { | |
| 1715 | + $page_id = $key; | |
| 1716 | + } | |
| 1717 | + } | |
| 1718 | + if (in_array('exclude/archive/any_child_of_'.$taxonomy->taxonomy, $val)) { | |
| 1719 | + if ('publish' == get_post_status($key)) { | |
| 1720 | + $page_id = ''; | |
| 1721 | + } | |
| 1722 | + } | |
| 1723 | + $data = $this->in_string_part('/archive/any_child_of_'.$taxonomy->taxonomy.'/', $val, true); | |
| 1724 | + if ($data) { | |
| 1725 | + $data = explode("/",$data); | |
| 1726 | + if (isset($data[3]) && $data[3]) { | |
| 1727 | + if (term_is_ancestor_of($data[3], $taxonomy->term_id, $taxonomy->taxonomy)) { | |
| 1728 | + if ('publish' == get_post_status($key)) { | |
| 1729 | + $page_id = $data[0] == 'exclude' ? '' : $key; | |
| 1730 | + } | |
| 1731 | + } | |
| 1732 | + } | |
| 1733 | + } | |
| 1734 | + } else { | |
| 1735 | + if ($this->in_string_part('child_of', $val)) { | |
| 1736 | + if (in_array('include/archive/child_of_'.$taxonomy->taxonomy, $val)) { | |
| 1737 | + if ('publish' == get_post_status($key)) { | |
| 1738 | + $page_id = $key; | |
| 1739 | + } | |
| 1740 | + } | |
| 1741 | + if (in_array('exclude/archive/child_of_'.$taxonomy->taxonomy, $val)) { | |
| 1742 | + if ('publish' == get_post_status($key)) { | |
| 1743 | + $page_id = ''; | |
| 1744 | + } | |
| 1745 | + } | |
| 1746 | + if (in_array('include/archive/child_of_'.$taxonomy->taxonomy.'/'.$taxonomy->parent, $val)) { | |
| 1747 | + if ('publish' == get_post_status($key)) { | |
| 1748 | + $page_id = $key; | |
| 1749 | + } | |
| 1750 | + } | |
| 1751 | + if (in_array('exclude/archive/child_of_'.$taxonomy->taxonomy.'/'.$taxonomy->parent, $val)) { | |
| 1752 | + if ('publish' == get_post_status($key)) { | |
| 1753 | + $page_id = ''; | |
| 1754 | + } | |
| 1755 | + } | |
| 1756 | + } | |
| 1757 | + } | |
| 1758 | + } else if (is_date()) { | |
| 1759 | + if (in_array('include/archive/date', $val)) { | |
| 1760 | + if ('publish' == get_post_status($key)) { | |
| 1761 | + $page_id = $key; | |
| 1762 | + } | |
| 1763 | + } | |
| 1764 | + if (in_array('exclude/archive/date', $val)) { | |
| 1765 | + if ('publish' == get_post_status($key)) { | |
| 1766 | + $page_id = ''; | |
| 1767 | + } | |
| 1768 | + } | |
| 1769 | + } else if (is_author()) { | |
| 1770 | + if (in_array('include/archive/author', $val)) { | |
| 1771 | + if ('publish' == get_post_status($key)) { | |
| 1772 | + $page_id = $key; | |
| 1773 | + } | |
| 1774 | + } | |
| 1775 | + if (in_array('exclude/archive/author', $val)) { | |
| 1776 | + if ('publish' == get_post_status($key)) { | |
| 1777 | + $page_id = ''; | |
| 1778 | + } | |
| 1779 | + } | |
| 1780 | + $author_id = get_the_author_meta('ID'); | |
| 1781 | + if (in_array('include/archive/author/'.$author_id, $val)) { | |
| 1782 | + if ('publish' == get_post_status($key)) { | |
| 1783 | + $page_id = $key; | |
| 1784 | + } | |
| 1785 | + } | |
| 1786 | + if (in_array('exclude/archive/author/'.$author_id, $val)) { | |
| 1787 | + if ('publish' == get_post_status($key)) { | |
| 1788 | + $page_id = ''; | |
| 1789 | + } | |
| 1790 | + } | |
| 1791 | + } | |
| 1792 | + } else if (is_search()) { | |
| 1793 | + if (in_array('include/archive/search', $val)) { | |
| 1794 | + if ('publish' == get_post_status($key)) { | |
| 1795 | + $page_id = $key; | |
| 1796 | + } | |
| 1797 | + } | |
| 1798 | + if (in_array('exclude/archive/search', $val)) { | |
| 1799 | + if ('publish' == get_post_status($key)) { | |
| 1800 | + $page_id = ''; | |
| 1801 | + } | |
| 1802 | + } | |
| 1803 | + } | |
| 386 | 1804 | } |
| 1805 | + } | |
| 1806 | + } | |
| 1807 | + // Singular | |
| 1808 | + if (isset($conditions['singular'])) { | |
| 1809 | + if (!empty($conditions['singular'])) { | |
| 1810 | + $obj = get_queried_object(); | |
| 1811 | + $tax_list = $this->get_taxonomy_list(); | |
| 1812 | + foreach ($conditions['singular'] as $key => $val) { | |
| 1813 | + if (is_singular()) { | |
| 1814 | + // Front Page | |
| 1815 | + if (is_front_page()) { | |
| 1816 | + if (in_array('include/singular/front_page', $val)) { | |
| 1817 | + if ('publish' == get_post_status($key)) { | |
| 1818 | + $page_id = $key; | |
| 1819 | + } | |
| 1820 | + } | |
| 1821 | + if (in_array('exclude/singular/front_page', $val)) { | |
| 1822 | + if ('publish' == get_post_status($key)) { | |
| 1823 | + $page_id = ''; | |
| 1824 | + } | |
| 1825 | + } | |
| 1826 | + } | |
| 1827 | + // Author check | |
| 1828 | + if (in_array('singular/post_by_author', $val)) { | |
| 1829 | + $author_id = get_the_author_meta('ID'); | |
| 1830 | + if (in_array('include/singular/post_by_author', $val)) { | |
| 1831 | + if ('publish' == get_post_status($key)) { | |
| 1832 | + $page_id = $key; | |
| 1833 | + } | |
| 1834 | + } | |
| 1835 | + if (in_array('exclude/singular/post_by_author', $val)) { | |
| 1836 | + if ('publish' == get_post_status($key)) { | |
| 1837 | + $page_id = ''; | |
| 1838 | + } | |
| 1839 | + } | |
| 1840 | + if (in_array('include/singular/post_by_author/'.$obj->post_author, $val)) { | |
| 1841 | + if ('publish' == get_post_status($key)) { | |
| 1842 | + $page_id = $key; | |
| 1843 | + } | |
| 1844 | + } | |
| 1845 | + if (in_array('exclude/singular/post_by_author/'.$obj->post_author, $val)) { | |
| 1846 | + if ('publish' == get_post_status($key)) { | |
| 1847 | + $page_id = ''; | |
| 1848 | + } | |
| 1849 | + } | |
| 1850 | + } | |
| 1851 | + // All Taxonomy | |
| 1852 | + if($this->in_string_part('/singular/in_', $val)) { | |
| 1853 | + foreach ($tax_list as $tax) { | |
| 1854 | + if ($this->in_string_part('singular/in_'.$tax.'_children', $val)) { | |
| 1855 | + // In Taxonomy Children | |
| 1856 | + if (in_array('include/singular/in_'.$tax.'_children', $val)) { | |
| 1857 | + if ('publish' == get_post_status($key)) { | |
| 1858 | + $page_id = $key; | |
| 1859 | + } | |
| 1860 | + } | |
| 1861 | + if (in_array('exclude/singular/in_'.$tax.'_children', $val)) { | |
| 1862 | + if ('publish' == get_post_status($key)) { | |
| 1863 | + $page_id = ''; | |
| 1864 | + } | |
| 1865 | + } | |
| 1866 | + $data = $this->in_string_part('/singular/in_'.$tax.'_children/', $val, true); | |
| 1867 | + if ($data) { | |
| 1868 | + $data = explode("/", $data); | |
| 1869 | + if (isset($data[3]) && $data[3]) { | |
| 1870 | + if (is_object_in_term($obj->ID , $tax, $data[3] )) { | |
| 1871 | + if ('publish' == get_post_status($key)) { | |
| 1872 | + $page_id = $data[0] == 'exclude' ? '' : $key; | |
| 1873 | + } | |
| 1874 | + } | |
| 1875 | + } | |
| 1876 | + } | |
| 1877 | + } else { | |
| 1878 | + // IN Taxonomy | |
| 1879 | + if (in_array('include/singular/in_'.$tax, $val)) { | |
| 1880 | + if ('publish' == get_post_status($key)) { | |
| 1881 | + $page_id = $key; | |
| 1882 | + } | |
| 1883 | + } | |
| 1884 | + if (in_array('exclude/singular/in_'.$tax, $val)) { | |
| 1885 | + if ('publish' == get_post_status($key)) { | |
| 1886 | + $page_id = ''; | |
| 1887 | + } | |
| 1888 | + } | |
| 1889 | + $data = $this->in_string_part('/singular/in_'.$tax.'/', $val, true); | |
| 1890 | + if ($data) { | |
| 1891 | + $data = explode("/",$data); | |
| 1892 | + if (isset($data[3]) && $data[3]) { | |
| 1893 | + if (is_object_in_term($obj->ID , $tax, $data[3] )) { | |
| 1894 | + if ('publish' == get_post_status($key)) { | |
| 1895 | + $page_id = $data[0] == 'exclude' ? '' : $key; | |
| 1896 | + } | |
| 1897 | + } | |
| 1898 | + } | |
| 1899 | + } | |
| 1900 | + } | |
| 1901 | + } | |
| 1902 | + } | |
| 1903 | + // All Post Type | |
| 1904 | + if (in_array('include/singular/'.$obj->post_type, $val)) { | |
| 1905 | + if ('publish' == get_post_status($key)) { | |
| 1906 | + $page_id = $key; | |
| 1907 | + } | |
| 1908 | + } | |
| 1909 | + if (in_array('exclude/singular/'.$obj->post_type, $val)) { | |
| 1910 | + if ('publish' == get_post_status($key)) { | |
| 1911 | + $page_id = ''; | |
| 1912 | + } | |
| 1913 | + } | |
| 1914 | + if ($this->in_string_part('include/singular/'.$obj->post_type.'/'.$obj->ID, $val)) { | |
| 1915 | + if ('publish' == get_post_status($key)) { | |
| 1916 | + $page_id = $key; | |
| 1917 | + } | |
| 1918 | + } | |
| 1919 | + if ($this->in_string_part('exclude/singular/'.$obj->post_type.'/'.$obj->ID, $val)) { | |
| 1920 | + if ('publish' == get_post_status($key)) { | |
| 1921 | + $page_id = ''; | |
| 1922 | + } | |
| 1923 | + } | |
| 1924 | + } | |
| 1925 | + } | |
| 387 | 1926 | } |
| 388 | - $html .= '</ul>'; | |
| 389 | - return $html; | |
| 1927 | + } | |
| 1928 | + | |
| 1929 | + if ($type == 'return') { | |
| 1930 | + return $page_id; | |
| 1931 | + } | |
| 1932 | + if ($type == 'includes') { | |
| 1933 | + return $page_id ? ULTP_PATH.'addons/builder/Archive_Template.php' : ''; | |
| 1934 | + } | |
| 390 | 1935 | } |
| 391 | 1936 | |
| 392 | - public function svg_icon($icons = ''){ | |
| 1937 | + | |
| 1938 | + /** | |
| 1939 | + * Get Add Default Condition Data | |
| 1940 | + * | |
| 1941 | + * @since v.2.7.0 | |
| 1942 | + * @return ARRAY | Default Data | |
| 1943 | + */ | |
| 1944 | + public function builder_data() { | |
| 1945 | + $archive_data = [ | |
| 1946 | + [ | |
| 1947 | + 'label' => 'All Archive', | |
| 1948 | + 'value' => '', | |
| 1949 | + ], | |
| 1950 | + [ | |
| 1951 | + 'label' => 'Author Archive', | |
| 1952 | + 'value' => 'author', | |
| 1953 | + 'search' => 'author###' | |
| 1954 | + ], | |
| 1955 | + [ | |
| 1956 | + 'label' => 'Date Archive', | |
| 1957 | + 'value' => 'date', | |
| 1958 | + ], | |
| 1959 | + [ | |
| 1960 | + 'label' => 'Search Results', | |
| 1961 | + 'value' => 'search', | |
| 1962 | + ], | |
| 1963 | + ]; | |
| 1964 | + $single_data = [ | |
| 1965 | + [ | |
| 1966 | + 'label' => 'Front Page', | |
| 1967 | + 'value' => 'front_page', | |
| 1968 | + ] | |
| 1969 | + ]; | |
| 1970 | + | |
| 1971 | + $post_type = get_post_types( ['public' => true], 'objects' ); | |
| 1972 | + foreach ($post_type as $key => $type) { | |
| 1973 | + // Post Type | |
| 1974 | + $single_temp = [ | |
| 1975 | + 'label' => $type->label, | |
| 1976 | + 'value' => $type->name, | |
| 1977 | + 'search' => 'type###'.$type->name | |
| 1978 | + ]; | |
| 1979 | + $archive_temp = []; | |
| 393 | 1980 | |
| 394 | - $icon_lists = array( | |
| 395 | - 'eye' => file_get_contents(ULTP_PATH.'assets/img/svg/eye.svg'), | |
| 396 | - 'user' => file_get_contents(ULTP_PATH.'assets/img/svg/user.svg'), | |
| 397 | - 'calendar' => file_get_contents(ULTP_PATH.'assets/img/svg/calendar.svg'), | |
| 398 | - 'comment' => file_get_contents(ULTP_PATH.'assets/img/svg/comment.svg'), | |
| 399 | - 'book' => file_get_contents(ULTP_PATH.'assets/img/svg/book.svg'), | |
| 400 | - 'tag' => file_get_contents(ULTP_PATH.'assets/img/svg/tag.svg'), | |
| 401 | - 'clock' => file_get_contents(ULTP_PATH.'assets/img/svg/clock.svg'), | |
| 402 | - 'leftAngle' => file_get_contents(ULTP_PATH.'assets/img/svg/leftAngle.svg'), | |
| 403 | - 'rightAngle' => file_get_contents(ULTP_PATH.'assets/img/svg/rightAngle.svg'), | |
| 404 | - 'leftAngle2' => file_get_contents(ULTP_PATH.'assets/img/svg/leftAngle2.svg'), | |
| 405 | - 'rightAngle2' => file_get_contents(ULTP_PATH.'assets/img/svg/rightAngle2.svg'), | |
| 406 | - 'leftArrowLg' => file_get_contents(ULTP_PATH.'assets/img/svg/leftArrowLg.svg'), | |
| 407 | - 'refresh' => file_get_contents(ULTP_PATH.'assets/img/svg/refresh.svg'), | |
| 408 | - 'rightArrowLg' => file_get_contents(ULTP_PATH.'assets/img/svg/rightArrowLg.svg'), | |
| 409 | - ); | |
| 410 | - if($icons){ | |
| 411 | - return $icon_lists[ $icons ]; | |
| 1981 | + // Taxonomy | |
| 1982 | + $taxonomy = get_object_taxonomies( $type->name, 'objects' ); | |
| 1983 | + if (!empty($taxonomy)) { | |
| 1984 | + $single_tax = $archive_tax = []; | |
| 1985 | + $single_tax[] = $single_temp; | |
| 1986 | + | |
| 1987 | + $archive_temp = [ | |
| 1988 | + 'label' => $type->label . ' Archive', | |
| 1989 | + 'value' => $type->name . '_archive', | |
| 1990 | + ]; | |
| 1991 | + // $archive_tax[] = $archive_temp; | |
| 1992 | + foreach ($taxonomy as $key => $val) { | |
| 1993 | + if ($val->public) { | |
| 1994 | + $single_tax[] = [ | |
| 1995 | + 'label' => 'In ' . $val->label, | |
| 1996 | + 'value' => 'in_' . $val->name, | |
| 1997 | + 'search' => 'term###'.$val->name | |
| 1998 | + ]; | |
| 1999 | + $archive_tax[] = [ | |
| 2000 | + 'label' => $val->label, | |
| 2001 | + 'value' => $val->name, | |
| 2002 | + 'search' => 'term###'.$val->name | |
| 2003 | + ]; | |
| 2004 | + | |
| 2005 | + if ($val->hierarchical) { | |
| 2006 | + // Hierarchical | |
| 2007 | + $single_tax[] = [ | |
| 2008 | + 'label' => 'In Child ' . $val->label, | |
| 2009 | + 'value' => 'in_' . $val->name . '_children', | |
| 2010 | + 'search' => 'term###'.$val->name | |
| 2011 | + ]; | |
| 2012 | + $archive_tax[] = [ | |
| 2013 | + 'label' => 'Direct Child ' . $val->label . ' Of', | |
| 2014 | + 'value' => 'child_of_' . $val->name, | |
| 2015 | + 'search' => 'term###'.$val->name | |
| 2016 | + ]; | |
| 2017 | + $archive_tax[] = [ | |
| 2018 | + 'label' => 'Any Child ' . $val->label . ' Of', | |
| 2019 | + 'value' => 'any_child_of_' . $val->name, | |
| 2020 | + 'search' => 'term###'.$val->name | |
| 2021 | + ]; | |
| 2022 | + } | |
| 2023 | + } | |
| 2024 | + } | |
| 2025 | + // Author | |
| 2026 | + $single_tax[] = [ | |
| 2027 | + 'label' => 'Posts By Author', | |
| 2028 | + 'value' => 'post_by_author', | |
| 2029 | + 'search' => 'author###' | |
| 2030 | + ]; | |
| 2031 | + $single_temp['attr'] = $single_tax; | |
| 2032 | + $archive_temp['attr'] = $archive_tax; | |
| 2033 | + } | |
| 2034 | + $single_data[] = $single_temp; | |
| 2035 | + if (!empty($archive_temp)) { | |
| 2036 | + $archive_data[] = $archive_temp; | |
| 2037 | + } | |
| 412 | 2038 | } |
| 2039 | + | |
| 2040 | + return ['singular' => $single_data, 'archive' => $archive_data]; | |
| 413 | 2041 | } |
| 414 | - | |
| 2042 | + | |
| 2043 | + /** | |
| 2044 | + * Get Date Default Format | |
| 2045 | + * | |
| 2046 | + * @since v.2.7.2 | |
| 2047 | + * @return ARRAY | Default Data | |
| 2048 | + */ | |
| 2049 | + public function get_format($format) { | |
| 2050 | + if ($format == 'default_date') { | |
| 2051 | + return $this->get_setting('date_format'); | |
| 2052 | + } else if ($format == 'default_date_time') { | |
| 2053 | + return $this->get_setting('date_format').' '.$this->get_setting('time_format'); | |
| 2054 | + } else { | |
| 2055 | + return $format; | |
| 2056 | + } | |
| 2057 | + } | |
| 2058 | + | |
| 2059 | + public function pro_popup_html() { ?> | |
| 2060 | + <div class="ultp-popup-container popup-center"> | |
| 2061 | + <div class="ultp-unlock-popup ultp-unlock-modal"> | |
| 2062 | + <img src="<?php echo esc_url(ULTP_URL . '/assets/img/admin/dashboard/unlock-super-icon.svg'); ?>" alt="lock icon"> | |
| 2063 | + <h4 class="ultp-md-heading ultp-mt25 ultp-mb25"><?php esc_html_e('Unlock 11+ Addons', 'ultimate-post'); ?></h4> | |
| 2064 | + <div class="ultp-popup-desc"> | |
| 2065 | + <?php esc_html_e('We’re sorry, PostX Addons are not available on PostX free. Please upgrade to a PRO plan to unlock the add ons of your choice.', 'ultimate-post'); ?> | |
| 2066 | + </div> | |
| 2067 | + <a href="<?php echo esc_url(ultimate_post()->get_premium_link('', 'postx_dashboard_addons_popup')); ?>" class="ultp-popup-planbtn ultp-btn ultp-btn-warning ultp-mt25"><?php esc_html_e('Upgrade Plan', 'ultimate-post'); ?></a> | |
| 2068 | + <button class="ultp-popup-close"></button> | |
| 2069 | + </div> | |
| 2070 | + </div> | |
| 2071 | + <?php } | |
| 2072 | + | |
| 2073 | + /** | |
| 2074 | + * Common Frontend and Backend CSS and JS Scripts | |
| 2075 | + * | |
| 2076 | + * @since v.1.0.0 | |
| 2077 | + * @return NULL | |
| 2078 | + */ | |
| 2079 | + public function register_scripts_common() { | |
| 2080 | + wp_enqueue_style('ultp-style', ULTP_URL.'assets/css/style.min.css', array(), ULTP_VER ); | |
| 2081 | + wp_enqueue_script('ultp-script', ULTP_URL.'assets/js/ultp.min.js', array('jquery'), ULTP_VER, true); | |
| 2082 | + wp_localize_script('ultp-script', 'ultp_data_frontend', array( | |
| 2083 | + 'url' => ULTP_URL, | |
| 2084 | + 'ajax' => admin_url('admin-ajax.php'), | |
| 2085 | + 'security' => wp_create_nonce('ultp-nonce') | |
| 2086 | + )); | |
| 2087 | + } | |
| 2088 | + | |
| 415 | 2089 | } |