about-widget.php
1 year ago
accordion-widget.php
1 year ago
accordion.php
1 year ago
attachment-url.php
1 year ago
audio.php
1 year ago
before-after.php
1 year ago
button.php
1 year ago
code.php
1 year ago
contact-box.php
1 year ago
contact-form.php
1 year ago
custom-list.php
6 months ago
divider.php
1 year ago
dropcap.php
1 year ago
facebook.php
1 year ago
flickr.php
1 year ago
gallery.php
1 year ago
gmap.php
1 year ago
highlight.php
1 year ago
image.php
1 year ago
instagram-feed.php
1 year ago
latest-posts-slider.php
1 year ago
popular-posts-widget.php
1 year ago
products-grid.php
1 year ago
quote.php
1 year ago
recent-posts-grid-carousel.php
1 year ago
recent-posts-land-style.php
1 year ago
recent-posts-masonry.php
1 year ago
recent-posts-tiles-carousel.php
1 year ago
recent-posts-tiles.php
1 year ago
recent-posts-timeline.php
1 year ago
recent-posts-widget.php
1 year ago
recent-products.php
1 year ago
related-posts.php
8 years ago
sample-element.php
1 year ago
search.php
1 year ago
socials-list.php
1 year ago
staff.php
1 year ago
tab-widget.php
1 year ago
tabs.php
1 year ago
testimonial.php
1 year ago
text.php
1 year ago
touch-slider.php
1 year ago
video.php
1 year ago
recent-posts-tiles.php
650 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Code highlighter element |
| 4 | * |
| 5 | * |
| 6 | * @package Auxin |
| 7 | * @license LICENSE.txt |
| 8 | * @author averta |
| 9 | * @link http://phlox.pro/ |
| 10 | * @copyright (c) 2010-2025 averta |
| 11 | */ |
| 12 | |
| 13 | function auxin_get_recent_posts_tiles_master_array( $master_array ) { |
| 14 | |
| 15 | $categories = get_terms([ |
| 16 | 'taxonomy' => 'category', |
| 17 | 'orderby' => 'count', |
| 18 | 'hide_empty' => false, |
| 19 | ]); |
| 20 | $categories_list = array( ' ' => __('All Categories', 'auxin-elements' ) ) ; |
| 21 | foreach ( $categories as $key => $value ) { |
| 22 | $categories_list[$value->term_id] = $value->name; |
| 23 | } |
| 24 | |
| 25 | // $tags = get_terms( 'post_tag', 'orderby=count&hide_empty=0' ); |
| 26 | // $tags_list; |
| 27 | // foreach ($tags as $key => $value) { |
| 28 | // $tags_list["$value->term_id"] = $value->name; |
| 29 | // } |
| 30 | |
| 31 | |
| 32 | $master_array['aux_recent_posts_tiles'] = array( |
| 33 | 'name' => __('Tiles Recent Posts', 'auxin-elements' ), |
| 34 | 'auxin_output_callback' => 'auxin_widget_recent_posts_tiles_callback', |
| 35 | 'base' => 'aux_recent_posts_tiles', |
| 36 | 'description' => __('It adds recent posts in tiles style.', 'auxin-elements' ), |
| 37 | 'class' => 'aux-widget-recent-posts-tiles', |
| 38 | 'show_settings_on_create' => true, |
| 39 | 'weight' => 1, |
| 40 | 'is_widget' => false, |
| 41 | 'is_shortcode' => true, |
| 42 | 'category' => THEME_NAME, |
| 43 | 'group' => '', |
| 44 | 'admin_enqueue_js' => '', |
| 45 | 'admin_enqueue_css' => '', |
| 46 | 'front_enqueue_js' => '', |
| 47 | 'front_enqueue_css' => '', |
| 48 | 'icon' => 'aux-element aux-pb-icons-tile', |
| 49 | 'custom_markup' => '', |
| 50 | 'js_view' => '', |
| 51 | 'html_template' => '', |
| 52 | 'deprecated' => '', |
| 53 | 'content_element' => '', |
| 54 | 'as_parent' => '', |
| 55 | 'as_child' => '', |
| 56 | 'params' => array( |
| 57 | array( |
| 58 | 'heading' => __('Title','auxin-elements' ), |
| 59 | 'description' => __('Recent post title, leave it empty if you don`t need title.', 'auxin-elements'), |
| 60 | 'param_name' => 'title', |
| 61 | 'type' => 'textfield', |
| 62 | 'value' => '', |
| 63 | 'holder' => 'textfield', |
| 64 | 'class' => 'title', |
| 65 | 'admin_label' => false, |
| 66 | 'dependency' => '', |
| 67 | 'weight' => '', |
| 68 | 'group' => '', |
| 69 | 'edit_field_class' => '' |
| 70 | ), |
| 71 | array( |
| 72 | 'heading' => __('Categories', 'auxin-elements'), |
| 73 | 'description' => __('Specifies a category that you want to show posts from it.', 'auxin-elements' ), |
| 74 | 'param_name' => 'cat', |
| 75 | 'type' => 'aux_select2_multiple', |
| 76 | 'def_value' => ' ', |
| 77 | 'holder' => '', |
| 78 | 'class' => 'cat', |
| 79 | 'value' => $categories_list, |
| 80 | 'admin_label' => false, |
| 81 | 'dependency' => '', |
| 82 | 'weight' => '', |
| 83 | 'group' => __( 'Query', 'auxin-elements' ), |
| 84 | 'edit_field_class' => '' |
| 85 | ), |
| 86 | array( |
| 87 | 'heading' => __('Number of posts to show', 'auxin-elements'), |
| 88 | 'description' => '', |
| 89 | 'param_name' => 'num', |
| 90 | 'type' => 'textfield', |
| 91 | 'value' => '8', |
| 92 | 'holder' => '', |
| 93 | 'class' => 'num', |
| 94 | 'admin_label' => false, |
| 95 | 'dependency' => '', |
| 96 | 'weight' => '', |
| 97 | 'group' => __( 'Query', 'auxin-elements' ), |
| 98 | 'edit_field_class' => '' |
| 99 | ), |
| 100 | array( |
| 101 | 'heading' => __('Exclude posts without media','auxin-elements' ), |
| 102 | 'description' => '', |
| 103 | 'param_name' => 'exclude_without_media', |
| 104 | 'type' => 'aux_switch', |
| 105 | 'value' => '1', |
| 106 | 'class' => '', |
| 107 | 'admin_label' => false, |
| 108 | 'dependency' => '', |
| 109 | 'weight' => '', |
| 110 | 'group' => __( 'Query', 'auxin-elements' ), |
| 111 | 'edit_field_class' => '' |
| 112 | ), |
| 113 | array( |
| 114 | 'heading' => __('Exclude custom post formats','auxin-elements' ), |
| 115 | 'description' => '', |
| 116 | 'param_name' => 'exclude_custom_post_formats', |
| 117 | 'type' => 'aux_switch', |
| 118 | 'value' => '1', |
| 119 | 'class' => '', |
| 120 | 'admin_label' => false, |
| 121 | 'dependency' => '', |
| 122 | 'weight' => '', |
| 123 | 'group' => __( 'Query', 'auxin-elements' ), |
| 124 | 'edit_field_class' => '' |
| 125 | ), |
| 126 | array( |
| 127 | 'heading' => __('Exclude quote and link post formats','auxin-elements' ), |
| 128 | 'description' => '', |
| 129 | 'param_name' => 'exclude_quote_link', |
| 130 | 'type' => 'aux_switch', |
| 131 | 'value' => '1', |
| 132 | 'class' => '', |
| 133 | 'admin_label' => false, |
| 134 | 'dependency' => array( |
| 135 | 'element' => 'exclude_custom_post_formats', |
| 136 | 'value' => '0' |
| 137 | ), |
| 138 | 'weight' => '', |
| 139 | 'group' => __( 'Query', 'auxin-elements' ), |
| 140 | 'edit_field_class' => '' |
| 141 | ), |
| 142 | array( |
| 143 | 'heading' => __('Load More Type','auxin-elements' ), |
| 144 | 'description' => '', |
| 145 | 'param_name' => 'loadmore_type', |
| 146 | 'type' => 'aux_visual_select', |
| 147 | 'value' => 'scroll', |
| 148 | 'class' => 'loadmore_type', |
| 149 | 'admin_label' => false, |
| 150 | 'dependency' => '', |
| 151 | 'weight' => '', |
| 152 | 'group' => '' , |
| 153 | 'edit_field_class' => '', |
| 154 | 'choices' => array( |
| 155 | '' => array( |
| 156 | 'label' => __('None', 'auxin-elements' ), |
| 157 | 'image' => AUXIN_URL . 'images/visual-select/load-more-none.svg' |
| 158 | ), |
| 159 | 'scroll' => array( |
| 160 | 'label' => __('Infinite Scroll', 'auxin-elements' ), |
| 161 | 'image' => AUXIN_URL . 'images/visual-select/load-more-infinite.svg' |
| 162 | ), |
| 163 | 'next' => array( |
| 164 | 'label' => __('Next Button', 'auxin-elements' ), |
| 165 | 'image' => AUXIN_URL . 'images/visual-select/load-more-button.svg' |
| 166 | ), |
| 167 | 'next-prev' => array( |
| 168 | 'label' => __('Next Prev', 'auxin-elements' ), |
| 169 | 'image' => AUXIN_URL . 'images/visual-select/load-more-next-prev.svg' |
| 170 | ) |
| 171 | ) |
| 172 | ), |
| 173 | array( |
| 174 | 'heading' => __('Order by', 'auxin-elements'), |
| 175 | 'description' => '', |
| 176 | 'param_name' => 'order_by', |
| 177 | 'type' => 'dropdown', |
| 178 | 'def_value' => 'date', |
| 179 | 'holder' => '', |
| 180 | 'class' => 'order_by', |
| 181 | 'value' => array ( |
| 182 | 'date' => __('Date', 'auxin-elements'), |
| 183 | 'menu_order date' => __('Menu Order', 'auxin-elements'), |
| 184 | 'title' => __('Title', 'auxin-elements'), |
| 185 | 'ID' => __('ID', 'auxin-elements'), |
| 186 | 'rand' => __('Random', 'auxin-elements'), |
| 187 | 'comment_count' => __('Comments', 'auxin-elements'), |
| 188 | 'modified' => __('Date Modified', 'auxin-elements'), |
| 189 | 'author' => __('Author', 'auxin-elements'), |
| 190 | 'post__in' => __('Inserted Post IDs', 'auxin-elements') |
| 191 | ), |
| 192 | 'admin_label' => false, |
| 193 | 'dependency' => '', |
| 194 | 'weight' => '', |
| 195 | 'group' => __( 'Query', 'auxin-elements' ), |
| 196 | 'edit_field_class' => '' |
| 197 | ), |
| 198 | array( |
| 199 | 'heading' => __('Order', 'auxin-elements'), |
| 200 | 'description' => '', |
| 201 | 'param_name' => 'order', |
| 202 | 'type' => 'dropdown', |
| 203 | 'def_value' => 'DESC', |
| 204 | 'holder' => '', |
| 205 | 'class' => 'order', |
| 206 | 'value' =>array ( |
| 207 | 'DESC' => __('Descending', 'auxin-elements'), |
| 208 | 'ASC' => __('Ascending', 'auxin-elements'), |
| 209 | ), |
| 210 | 'admin_label' => false, |
| 211 | 'dependency' => '', |
| 212 | 'weight' => '', |
| 213 | 'group' => __( 'Query', 'auxin-elements' ), |
| 214 | 'edit_field_class' => '' |
| 215 | ), |
| 216 | array( |
| 217 | 'heading' => __('Only posts','auxin-elements' ), |
| 218 | 'description' => __('If you intend to display ONLY specific posts, you should specify the posts here. You have to insert the post IDs that are separated by comma (eg. 53,34,87,25).', 'auxin-elements' ), |
| 219 | 'param_name' => 'only_posts__in', |
| 220 | 'type' => 'textfield', |
| 221 | 'value' => '', |
| 222 | 'holder' => '', |
| 223 | 'class' => '', |
| 224 | 'admin_label' => false, |
| 225 | 'dependency' => '', |
| 226 | 'weight' => '', |
| 227 | 'group' => __( 'Query', 'auxin-elements' ), |
| 228 | 'edit_field_class' => '' |
| 229 | ), |
| 230 | array( |
| 231 | 'heading' => __('Include posts','auxin-elements' ), |
| 232 | 'description' => __('If you intend to include additional posts, you should specify the posts here. You have to insert the Post IDs that are separated by comma (eg. 53,34,87,25)', 'auxin-elements' ), |
| 233 | 'param_name' => 'include', |
| 234 | 'type' => 'textfield', |
| 235 | 'value' => '', |
| 236 | 'holder' => '', |
| 237 | 'class' => '', |
| 238 | 'admin_label' => false, |
| 239 | 'dependency' => '', |
| 240 | 'weight' => '', |
| 241 | 'group' => __( 'Query', 'auxin-elements' ), |
| 242 | 'edit_field_class' => '' |
| 243 | ), |
| 244 | array( |
| 245 | 'heading' => __('Exclude posts','auxin-elements' ), |
| 246 | 'description' => __('If you intend to exclude specific posts from result, you should specify the posts here. You have to insert the Post IDs that are separated by comma (eg. 53,34,87,25)', 'auxin-elements' ), |
| 247 | 'param_name' => 'exclude', |
| 248 | 'type' => 'textfield', |
| 249 | 'value' => '', |
| 250 | 'holder' => '', |
| 251 | 'class' => '', |
| 252 | 'admin_label' => false, |
| 253 | 'dependency' => '', |
| 254 | 'weight' => '', |
| 255 | 'group' => __( 'Query', 'auxin-elements' ), |
| 256 | 'edit_field_class' => '' |
| 257 | ), |
| 258 | array( |
| 259 | 'heading' => __('Order by', 'auxin-elements'), |
| 260 | 'description' => '', |
| 261 | 'param_name' => 'order_by', |
| 262 | 'type' => 'dropdown', |
| 263 | 'def_value' => 'date', |
| 264 | 'holder' => '', |
| 265 | 'class' => 'order_by', |
| 266 | 'value' => array ( |
| 267 | 'date' => __('Date', 'auxin-elements'), |
| 268 | 'menu_order date' => __('Menu Order', 'auxin-elements'), |
| 269 | 'title' => __('Title', 'auxin-elements'), |
| 270 | 'ID' => __('ID', 'auxin-elements'), |
| 271 | 'rand' => __('Random', 'auxin-elements'), |
| 272 | 'comment_count' => __('Comments', 'auxin-elements'), |
| 273 | 'modified' => __('Date Modified', 'auxin-elements'), |
| 274 | 'author' => __('Author', 'auxin-elements'), |
| 275 | 'post__in' => __('Inserted Post IDs', 'auxin-elements') |
| 276 | ), |
| 277 | 'admin_label' => false, |
| 278 | 'dependency' => '', |
| 279 | 'weight' => '', |
| 280 | 'group' => __( 'Query', 'auxin-elements' ), |
| 281 | 'edit_field_class' => '' |
| 282 | ), |
| 283 | array( |
| 284 | 'heading' => __('Order', 'auxin-elements'), |
| 285 | 'description' => '', |
| 286 | 'param_name' => 'order', |
| 287 | 'type' => 'dropdown', |
| 288 | 'def_value' => 'DESC', |
| 289 | 'holder' => '', |
| 290 | 'class' => 'order', |
| 291 | 'value' =>array ( |
| 292 | 'DESC' => __('Descending', 'auxin-elements'), |
| 293 | 'ASC' => __('Ascending', 'auxin-elements'), |
| 294 | ), |
| 295 | 'admin_label' => false, |
| 296 | 'dependency' => '', |
| 297 | 'weight' => '', |
| 298 | 'group' => __( 'Query', 'auxin-elements' ), |
| 299 | 'edit_field_class' => '' |
| 300 | ), |
| 301 | array( |
| 302 | 'heading' => __('Start offset','auxin-elements' ), |
| 303 | 'description' => __('Number of post to displace or pass over.', 'auxin-elements' ), |
| 304 | 'param_name' => 'offset', |
| 305 | 'type' => 'textfield', |
| 306 | 'value' => '', |
| 307 | 'holder' => '', |
| 308 | 'class' => '', |
| 309 | 'admin_label' => false, |
| 310 | 'dependency' => '', |
| 311 | 'weight' => '', |
| 312 | 'group' => __( 'Query', 'auxin-elements' ), |
| 313 | 'edit_field_class' => '' |
| 314 | ), |
| 315 | array( |
| 316 | 'heading' => __( 'Post Tile styles','auxin-elements' ), |
| 317 | 'description' => '', |
| 318 | 'param_name' => 'tile_style_pattern', |
| 319 | 'type' => 'aux_visual_select', |
| 320 | 'def_value' => 'default', |
| 321 | 'holder' => '', |
| 322 | 'class' => 'tile_style_pattern', |
| 323 | 'admin_label' => false, |
| 324 | 'dependency' => '', |
| 325 | 'weight' => '', |
| 326 | 'group' => __( 'Style', 'auxin-elements' ), |
| 327 | 'edit_field_class' => '', |
| 328 | 'choices' => array( |
| 329 | 'default' => array( |
| 330 | 'label' => __( 'Default', 'auxin-elements' ), |
| 331 | 'image' => AUXELS_ADMIN_URL . '/assets/images/visual-select/tile-5.svg' |
| 332 | ), |
| 333 | 'pattern-1' => array( |
| 334 | 'label' => __( 'Pattern 1', 'auxin-elements' ), |
| 335 | 'image' => AUXELS_ADMIN_URL . '/assets/images/visual-select/tile-3.svg' |
| 336 | ), |
| 337 | 'pattern-2' => array( |
| 338 | 'label' => __( 'Pattern 2', 'auxin-elements' ), |
| 339 | 'image' => AUXELS_ADMIN_URL . '/assets/images/visual-select/tile-6.svg' |
| 340 | ), |
| 341 | 'pattern-3' => array( |
| 342 | 'label' => __( 'Pattern 3', 'auxin-elements' ), |
| 343 | 'image' => AUXELS_ADMIN_URL . '/assets/images/visual-select/tile-7.svg' |
| 344 | ), |
| 345 | 'pattern-4' => array( |
| 346 | 'label' => __( 'Pattern 4', 'auxin-elements' ), |
| 347 | 'image' => AUXELS_ADMIN_URL . '/assets/images/visual-select/tile-8.svg' |
| 348 | ), |
| 349 | 'pattern-5' => array( |
| 350 | 'label' => __( 'Pattern 5', 'auxin-elements' ), |
| 351 | 'image' => AUXELS_ADMIN_URL . '/assets/images/visual-select/tile-4.svg' |
| 352 | ), |
| 353 | 'pattern-6' => array( |
| 354 | 'label' => __('Pattern 6', 'auxin-elements' ), |
| 355 | 'image' => AUXELS_ADMIN_URL . '/assets/images/visual-select/tile-1.svg' |
| 356 | ), |
| 357 | 'pattern-7' => array( |
| 358 | 'label' => __('Pattern 7', 'auxin-elements' ), |
| 359 | 'image' => AUXELS_ADMIN_URL . '/assets/images/visual-select/tile-2.svg' |
| 360 | ), |
| 361 | ) |
| 362 | ), |
| 363 | array( |
| 364 | 'heading' => __('Post tile style','auxin-elements' ), |
| 365 | 'description' => '', |
| 366 | 'param_name' => 'tile_style', |
| 367 | 'type' => 'aux_visual_select', |
| 368 | 'def_value' => '', |
| 369 | 'holder' => '', |
| 370 | 'class' => 'tile_style', |
| 371 | 'admin_label' => false, |
| 372 | 'dependency' => '', |
| 373 | 'weight' => '', |
| 374 | 'group' => __( 'Style', 'auxin-elements' ), |
| 375 | 'edit_field_class' => '', |
| 376 | 'choices' => array( |
| 377 | '' => array( |
| 378 | 'label' => __('Standard', 'auxin-elements' ), |
| 379 | 'image' => AUXIN_URL . 'images/visual-select/button-normal.svg' |
| 380 | ), |
| 381 | 'aux-overlay' => array( |
| 382 | 'label' => __('Dark', 'auxin-elements' ), |
| 383 | 'image' => AUXIN_URL . 'images/visual-select/button-curved.svg' |
| 384 | ) |
| 385 | ) |
| 386 | ), |
| 387 | array( |
| 388 | 'heading' => __('Insert post title','auxin-elements' ), |
| 389 | 'description' => '', |
| 390 | 'param_name' => 'display_title', |
| 391 | 'type' => 'aux_switch', |
| 392 | 'value' => '1', |
| 393 | 'class' => 'display_title', |
| 394 | 'admin_label' => false, |
| 395 | 'dependency' => '', |
| 396 | 'weight' => '', |
| 397 | 'group' => '' , |
| 398 | 'edit_field_class' => '' |
| 399 | ), |
| 400 | array( |
| 401 | 'heading' => __('Insert post meta','auxin-elements' ), |
| 402 | 'description' => '', |
| 403 | 'param_name' => 'show_info', |
| 404 | 'type' => 'aux_switch', |
| 405 | 'value' => '1', |
| 406 | 'class' => '', |
| 407 | 'admin_label' => false, |
| 408 | 'weight' => '', |
| 409 | 'group' => '' , |
| 410 | 'edit_field_class' => '' |
| 411 | ), |
| 412 | array( |
| 413 | 'heading' => __('Extra class name','auxin-elements' ), |
| 414 | 'description' => __('If you wish to style particular content element differently, then use this field to add a class name and then refer to it in your css file.', 'auxin-elements' ), |
| 415 | 'param_name' => 'extra_classes', |
| 416 | 'type' => 'textfield', |
| 417 | 'value' => '', |
| 418 | 'holder' => '', |
| 419 | 'class' => 'extra_classes', |
| 420 | 'admin_label' => false, |
| 421 | 'dependency' => '', |
| 422 | 'weight' => '', |
| 423 | 'group' => '', |
| 424 | 'edit_field_class' => '' |
| 425 | ) |
| 426 | ) |
| 427 | ); |
| 428 | |
| 429 | return $master_array; |
| 430 | } |
| 431 | |
| 432 | add_filter( 'auxin_master_array_shortcodes', 'auxin_get_recent_posts_tiles_master_array', 10, 1 ); |
| 433 | |
| 434 | |
| 435 | /** |
| 436 | * Element without loop and column |
| 437 | * The front-end output of this element is returned by the following function |
| 438 | * |
| 439 | * @param array $atts The array containing the parsed values from shortcode, it should be same as defined params above. |
| 440 | * @param string $shortcode_content The shorcode content |
| 441 | * @return string The output of element markup |
| 442 | */ |
| 443 | function auxin_widget_recent_posts_tiles_callback( $atts, $shortcode_content = null ){ |
| 444 | |
| 445 | global $aux_content_width; |
| 446 | |
| 447 | // Defining default attributes |
| 448 | $default_atts = array( |
| 449 | 'title' => '', // header title |
| 450 | 'cat' => ' ', |
| 451 | 'num' => '8', // max generated entry |
| 452 | 'only_posts__in' => '', // display only these post IDs. array or string comma separated |
| 453 | 'include' => '', // include these post IDs in result too. array or string comma separated |
| 454 | 'exclude' => '', // exclude these post IDs from result. array or string comma separated |
| 455 | 'posts_per_page' => -1, |
| 456 | 'offset' => '', |
| 457 | 'paged' => '', |
| 458 | 'order_by' => 'date', |
| 459 | 'order' => 'DESC', |
| 460 | 'excerpt_len' => '160', |
| 461 | 'exclude_without_media' => true, |
| 462 | 'exclude_custom_post_formats' => true, |
| 463 | 'exclude_quote_link' => true, |
| 464 | 'exclude_post_formats_in' => array(), // the list od post formats to exclude |
| 465 | 'tile_style' => '', |
| 466 | 'display_title' => true, |
| 467 | 'show_info' => true, |
| 468 | 'show_date' => true, |
| 469 | 'display_categories' => true, |
| 470 | 'tile_style_pattern' => 'default', |
| 471 | 'extra_classes' => '', |
| 472 | 'extra_column_classes' => '', |
| 473 | 'custom_el_id' => '', |
| 474 | 'taxonomy_name' => 'category', |
| 475 | |
| 476 | 'template_part_file' => 'theme-parts/entry/post-tile', |
| 477 | 'extra_template_path' => '', |
| 478 | |
| 479 | 'universal_id' => '', |
| 480 | 'reset_query' => true, |
| 481 | 'use_wp_query' => false, // true to use the global wp_query, false to use internal custom query |
| 482 | 'wp_query_args' => array(), // additional wp_query args |
| 483 | 'loadmore_type' => '', // 'next' (more button), 'scroll', 'next-prev' |
| 484 | 'loadmore_per_page' => '', |
| 485 | 'base' => 'aux_recent_posts_tiles', |
| 486 | 'base_class' => 'aux-widget-recent-posts-tiles' |
| 487 | ); |
| 488 | |
| 489 | $result = auxin_get_widget_scafold( $atts, $default_atts, $shortcode_content ); |
| 490 | extract( $result['parsed_atts'] ); |
| 491 | |
| 492 | $acceptedTemplateFiles = apply_filters( 'auxin_recent_posts_tiles_accepted_template_files', [ |
| 493 | 'theme-parts/entry/post-column', |
| 494 | 'theme-parts/entry/post-flip', |
| 495 | 'theme-parts/entry/post-land', |
| 496 | 'theme-parts/entry/post-tile', |
| 497 | 'theme-parts/entry/post', |
| 498 | ]); |
| 499 | |
| 500 | if ( ! in_array( $template_part_file, $acceptedTemplateFiles ) ) { |
| 501 | return; |
| 502 | } |
| 503 | |
| 504 | // specify the post formats that should be excluded ------- |
| 505 | $exclude_post_formats_in = (array) $exclude_post_formats_in; |
| 506 | |
| 507 | if( $exclude_custom_post_formats ){ |
| 508 | $exclude_post_formats_in = array_merge( $exclude_post_formats_in, array( 'aside', 'gallery', 'image', 'link', 'quote', 'video', 'audio' ) ); |
| 509 | } |
| 510 | if( $exclude_quote_link ){ |
| 511 | $exclude_post_formats_in[] = 'quote'; |
| 512 | $exclude_post_formats_in[] = 'link'; |
| 513 | } |
| 514 | $exclude_post_formats_in = array_unique( $exclude_post_formats_in ); |
| 515 | |
| 516 | // -------------- |
| 517 | |
| 518 | ob_start(); |
| 519 | |
| 520 | $tax_args = array(); |
| 521 | if( ! empty( $cat ) && $cat != " " && ( ! is_array( $cat ) || ! in_array( " ", $cat ) ) ) { |
| 522 | $tax_args = array( |
| 523 | array( |
| 524 | 'taxonomy' => $taxonomy_name, |
| 525 | 'field' => 'term_id', |
| 526 | 'terms' => ! is_array( $cat ) ? explode( ",", $cat ) : $cat |
| 527 | ) |
| 528 | ); |
| 529 | } |
| 530 | |
| 531 | global $wp_query; |
| 532 | |
| 533 | if( ! $use_wp_query ){ |
| 534 | |
| 535 | // create wp_query to get latest items ----------- |
| 536 | $args = array( |
| 537 | 'post_type' => 'post', |
| 538 | 'orderby' => $order_by, |
| 539 | 'order' => $order, |
| 540 | 'offset' => $offset, |
| 541 | 'paged' => $paged, |
| 542 | 'tax_query' => $tax_args, |
| 543 | 'post_status' => 'publish', |
| 544 | 'posts_per_page' => $num, |
| 545 | 'ignore_sticky_posts' => 1, |
| 546 | 'include_posts__in' => $include, // include posts in this liat |
| 547 | 'posts__not_in' => $exclude, // exclude posts in this list |
| 548 | 'posts__in' => $only_posts__in, // only posts in this list |
| 549 | |
| 550 | 'exclude_without_media' => $exclude_without_media, |
| 551 | 'exclude_post_formats_in' => $exclude_post_formats_in |
| 552 | ); |
| 553 | |
| 554 | // --------------------------------------------------------------------- |
| 555 | |
| 556 | // add the additional query args if available |
| 557 | if( $wp_query_args ){ |
| 558 | $args = wp_parse_args( $args, $wp_query_args ); |
| 559 | } |
| 560 | |
| 561 | // pass the args through the auxin query parser |
| 562 | $wp_query = new WP_Query( auxin_parse_query_args( $args ) ); |
| 563 | } |
| 564 | |
| 565 | // widget header ------------------------------ |
| 566 | echo wp_kses_post( $result['widget_header'] ); |
| 567 | echo wp_kses_post( $result['widget_title'] ); |
| 568 | |
| 569 | $phone_break_point = 767; |
| 570 | $tablet_break_point = 1025; |
| 571 | |
| 572 | $show_comments = true; // shows comments icon |
| 573 | $post_counter = 0; |
| 574 | $item_class = 'aux-post-tile aux-image-box'; |
| 575 | |
| 576 | if( ! empty( $loadmore_type ) ) { |
| 577 | $item_class .= ' aux-ajax-item'; |
| 578 | } |
| 579 | |
| 580 | $container_class = 'aux-tiles-layout aux-ajax-view ' . $tile_style; |
| 581 | |
| 582 | $have_posts = $wp_query->have_posts(); |
| 583 | |
| 584 | if( $have_posts ){ |
| 585 | |
| 586 | echo ! $skip_wrappers ? sprintf( '<div data-lazyload="true" data-element-id="%s" class="%s">', esc_attr( $universal_id ), esc_attr( $container_class ) ) : ''; |
| 587 | |
| 588 | while ( $wp_query->have_posts() ) { |
| 589 | |
| 590 | $wp_query->the_post(); |
| 591 | $post = $wp_query->post; |
| 592 | |
| 593 | $item_pattern_info = auxin_get_tile_pattern( $tile_style_pattern , $post_counter, $aux_content_width ); |
| 594 | $post_counter++; |
| 595 | |
| 596 | $post_vars = auxin_get_post_format_media( |
| 597 | $post, |
| 598 | array( |
| 599 | 'request_from' => 'archive', |
| 600 | 'media_width' => $phone_break_point, |
| 601 | 'media_size' => $item_pattern_info['size'], |
| 602 | 'upscale_image' => true, |
| 603 | 'image_from_content' => ! $exclude_without_media, |
| 604 | 'ignore_formats' => array( '*' ), |
| 605 | 'preloadable' => false, |
| 606 | 'image_sizes' => 'auto', |
| 607 | 'srcset_sizes' => 'auto' |
| 608 | ) |
| 609 | ); |
| 610 | |
| 611 | extract( $post_vars ); |
| 612 | |
| 613 | $post_classes = $item_class .' post '. $item_pattern_info['classname']; |
| 614 | |
| 615 | $the_format = get_post_format( $post ); |
| 616 | |
| 617 | include auxin_get_template_file( $template_part_file, '', $extra_template_path ); |
| 618 | } |
| 619 | |
| 620 | if( ! $skip_wrappers ) { |
| 621 | // End tag for aux-ajax-view wrapper |
| 622 | echo '</div>'; |
| 623 | // Execute load more functionality |
| 624 | if( $wp_query->found_posts > $loadmore_per_page ) { |
| 625 | echo auxin_get_load_more_controller( $loadmore_type ); |
| 626 | } |
| 627 | |
| 628 | } else { |
| 629 | // Get post counter in the query |
| 630 | echo '<span class="aux-post-count hidden">'. esc_html( $wp_query->post_count ) .'</span>'; |
| 631 | echo '<span class="aux-all-posts-count hidden">'. esc_html( $wp_query->found_posts ) .'</span>'; |
| 632 | } |
| 633 | } |
| 634 | |
| 635 | if( $reset_query ){ |
| 636 | wp_reset_query(); |
| 637 | } |
| 638 | |
| 639 | // return false if no result found |
| 640 | if( ! $have_posts ){ |
| 641 | ob_get_clean(); |
| 642 | return false; |
| 643 | } |
| 644 | |
| 645 | // widget footer ------------------------------ |
| 646 | echo wp_kses_post( $result['widget_footer'] ); |
| 647 | |
| 648 | return ob_get_clean(); |
| 649 | } |
| 650 |