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-masonry.php
693 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_masonry_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_masonry'] = array( |
| 33 | 'name' => __('Masonry Recent Posts', 'auxin-elements' ), |
| 34 | 'auxin_output_callback' => 'auxin_widget_recent_posts_masonry_callback', |
| 35 | 'base' => 'aux_recent_posts_masonry', |
| 36 | 'description' => __('It adds recent posts in masonry style.', 'auxin-elements' ), |
| 37 | 'class' => 'aux-widget-recent-posts-masonry aux-column-post-entry', |
| 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-masonry', |
| 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 | 'std' => '', |
| 63 | 'value' => '', |
| 64 | 'holder' => 'textfield', |
| 65 | 'class' => 'title', |
| 66 | 'admin_label' => false, |
| 67 | 'dependency' => '', |
| 68 | 'weight' => '', |
| 69 | 'group' => '', |
| 70 | 'edit_field_class' => '' |
| 71 | ), |
| 72 | array( |
| 73 | 'heading' => __('Categories', 'auxin-elements'), |
| 74 | 'description' => __('Specifies a category that you want to show posts from it.', 'auxin-elements' ), |
| 75 | 'param_name' => 'cat', |
| 76 | 'type' => 'aux_select2_multiple', |
| 77 | 'def_value' => ' ', |
| 78 | 'holder' => '', |
| 79 | 'class' => 'cat', |
| 80 | 'value' => $categories_list, |
| 81 | 'admin_label' => false, |
| 82 | 'dependency' => '', |
| 83 | 'weight' => '', |
| 84 | 'group' => __( 'Query', 'auxin-elements' ), |
| 85 | 'edit_field_class' => '' |
| 86 | ), |
| 87 | array( |
| 88 | 'heading' => __('Number of posts to show', 'auxin-elements'), |
| 89 | 'description' => '', |
| 90 | 'param_name' => 'num', |
| 91 | 'type' => 'textfield', |
| 92 | 'value' => '8', |
| 93 | 'holder' => '', |
| 94 | 'class' => 'num', |
| 95 | 'admin_label' => false, |
| 96 | 'dependency' => '', |
| 97 | 'weight' => '', |
| 98 | 'group' => __( 'Query', 'auxin-elements' ), |
| 99 | 'edit_field_class' => '' |
| 100 | ), |
| 101 | array( |
| 102 | 'heading' => __('Exclude posts without media','auxin-elements' ), |
| 103 | 'description' => '', |
| 104 | 'param_name' => 'exclude_without_media', |
| 105 | 'type' => 'aux_switch', |
| 106 | 'value' => '0', |
| 107 | 'class' => '', |
| 108 | 'admin_label' => false, |
| 109 | 'dependency' => '', |
| 110 | 'weight' => '', |
| 111 | 'group' => __( 'Query', 'auxin-elements' ), |
| 112 | 'edit_field_class' => '' |
| 113 | ), |
| 114 | array( |
| 115 | 'heading' => __('Exclude custom post formats','auxin-elements' ), |
| 116 | 'description' => '', |
| 117 | 'param_name' => 'exclude_custom_post_formats', |
| 118 | 'type' => 'aux_switch', |
| 119 | 'value' => '0', |
| 120 | 'class' => '', |
| 121 | 'admin_label' => false, |
| 122 | 'dependency' => '', |
| 123 | 'weight' => '', |
| 124 | 'group' => __( 'Query', 'auxin-elements' ), |
| 125 | 'edit_field_class' => '' |
| 126 | ), |
| 127 | array( |
| 128 | 'heading' => __('Exclude quote and link post formats','auxin-elements' ), |
| 129 | 'description' => '', |
| 130 | 'param_name' => 'exclude_quote_link', |
| 131 | 'type' => 'aux_switch', |
| 132 | 'value' => '0', |
| 133 | 'class' => '', |
| 134 | 'admin_label' => false, |
| 135 | 'dependency' => array( |
| 136 | 'element' => 'exclude_custom_post_formats', |
| 137 | 'value' => array('0', 'false') |
| 138 | ), |
| 139 | 'weight' => '', |
| 140 | 'group' => '', |
| 141 | 'edit_field_class' => '' |
| 142 | ), |
| 143 | array( |
| 144 | 'heading' => __('Order by', 'auxin-elements'), |
| 145 | 'description' => '', |
| 146 | 'param_name' => 'order_by', |
| 147 | 'type' => 'dropdown', |
| 148 | 'def_value' => 'date', |
| 149 | 'holder' => '', |
| 150 | 'class' => 'order_by', |
| 151 | 'value' => array ( |
| 152 | 'date' => __('Date', 'auxin-elements'), |
| 153 | 'menu_order date' => __('Menu Order', 'auxin-elements'), |
| 154 | 'title' => __('Title', 'auxin-elements'), |
| 155 | 'ID' => __('ID', 'auxin-elements'), |
| 156 | 'rand' => __('Random', 'auxin-elements'), |
| 157 | 'comment_count' => __('Comments', 'auxin-elements'), |
| 158 | 'modified' => __('Date Modified', 'auxin-elements'), |
| 159 | 'author' => __('Author', 'auxin-elements'), |
| 160 | 'post__in' => __('Inserted Post IDs', 'auxin-elements') |
| 161 | ), |
| 162 | 'admin_label' => false, |
| 163 | 'dependency' => '', |
| 164 | 'weight' => '', |
| 165 | 'group' => __( 'Query', 'auxin-elements' ), |
| 166 | 'edit_field_class' => '' |
| 167 | ), |
| 168 | array( |
| 169 | 'heading' => __('Order', 'auxin-elements'), |
| 170 | 'description' => '', |
| 171 | 'param_name' => 'order', |
| 172 | 'type' => 'dropdown', |
| 173 | 'def_value' => 'DESC', |
| 174 | 'holder' => '', |
| 175 | 'class' => 'order', |
| 176 | 'value' =>array ( |
| 177 | 'DESC' => __('Descending', 'auxin-elements'), |
| 178 | 'ASC' => __('Ascending', 'auxin-elements'), |
| 179 | ), |
| 180 | 'admin_label' => false, |
| 181 | 'dependency' => '', |
| 182 | 'weight' => '', |
| 183 | 'group' => __( 'Query', 'auxin-elements' ), |
| 184 | 'edit_field_class' => '' |
| 185 | ), |
| 186 | array( |
| 187 | 'heading' => __('Only posts','auxin-elements' ), |
| 188 | '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' ), |
| 189 | 'param_name' => 'only_posts__in', |
| 190 | 'type' => 'textfield', |
| 191 | 'value' => '', |
| 192 | 'holder' => '', |
| 193 | 'class' => '', |
| 194 | 'admin_label' => false, |
| 195 | 'dependency' => '', |
| 196 | 'weight' => '', |
| 197 | 'group' => __( 'Query', 'auxin-elements' ), |
| 198 | 'edit_field_class' => '' |
| 199 | ), |
| 200 | array( |
| 201 | 'heading' => __('Include posts','auxin-elements' ), |
| 202 | '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' ), |
| 203 | 'param_name' => 'include', |
| 204 | 'type' => 'textfield', |
| 205 | 'value' => '', |
| 206 | 'holder' => '', |
| 207 | 'class' => '', |
| 208 | 'admin_label' => false, |
| 209 | 'dependency' => '', |
| 210 | 'weight' => '', |
| 211 | 'group' => __( 'Query', 'auxin-elements' ), |
| 212 | 'edit_field_class' => '' |
| 213 | ), |
| 214 | array( |
| 215 | 'heading' => __('Exclude posts','auxin-elements' ), |
| 216 | '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' ), |
| 217 | 'param_name' => 'exclude', |
| 218 | 'type' => 'textfield', |
| 219 | 'value' => '', |
| 220 | 'holder' => '', |
| 221 | 'class' => '', |
| 222 | 'admin_label' => false, |
| 223 | 'dependency' => '', |
| 224 | 'weight' => '', |
| 225 | 'group' => __( 'Query', 'auxin-elements' ), |
| 226 | 'edit_field_class' => '' |
| 227 | ), |
| 228 | array( |
| 229 | 'heading' => __('Start offset','auxin-elements' ), |
| 230 | 'description' => __('Number of post to displace or pass over.', 'auxin-elements' ), |
| 231 | 'param_name' => 'offset', |
| 232 | 'type' => 'textfield', |
| 233 | 'value' => '', |
| 234 | 'holder' => '', |
| 235 | 'class' => '', |
| 236 | 'admin_label' => false, |
| 237 | 'dependency' => '', |
| 238 | 'weight' => '', |
| 239 | 'group' => __( 'Query', 'auxin-elements' ), |
| 240 | 'edit_field_class' => '' |
| 241 | ), |
| 242 | array( |
| 243 | 'heading' => __('Display post media (image, video, etc)', 'auxin-elements' ), |
| 244 | 'param_name' => 'show_media', |
| 245 | 'type' => 'aux_switch', |
| 246 | 'def_value' => '', |
| 247 | 'value' => '1', |
| 248 | 'holder' => '', |
| 249 | 'class' => 'show_media', |
| 250 | 'admin_label' => false, |
| 251 | 'dependency' => '', |
| 252 | 'weight' => '', |
| 253 | 'group' => '', |
| 254 | 'edit_field_class' => '' |
| 255 | ), |
| 256 | array( |
| 257 | 'heading' => __('Display post title','auxin-elements' ), |
| 258 | 'description' => '', |
| 259 | 'param_name' => 'display_title', |
| 260 | 'type' => 'aux_switch', |
| 261 | 'value' => '1', |
| 262 | 'class' => 'display_title', |
| 263 | 'admin_label' => false, |
| 264 | 'dependency' => '', |
| 265 | 'weight' => '', |
| 266 | 'group' => '', |
| 267 | 'edit_field_class' => '' |
| 268 | ), |
| 269 | array( |
| 270 | 'heading' => __('Display post meta','auxin-elements' ), |
| 271 | 'description' => '', |
| 272 | 'param_name' => 'show_info', |
| 273 | 'type' => 'aux_switch', |
| 274 | 'value' => '1', |
| 275 | 'class' => '', |
| 276 | 'admin_label' => false, |
| 277 | 'weight' => '', |
| 278 | 'group' => '', |
| 279 | 'edit_field_class' => '' |
| 280 | ), |
| 281 | array( |
| 282 | 'heading' => __('Display like button','auxin-elements' ), |
| 283 | 'description' => sprintf(__('Enable it to display %s like button%s on gride template blog. Please note WP Ulike plugin needs to be activaited to use this option.', 'auxin-elements'), '<strong>', '</strong>'), |
| 284 | 'param_name' => 'display_like', |
| 285 | 'type' => 'aux_switch', |
| 286 | 'value' => '1', |
| 287 | 'holder' => '', |
| 288 | 'class' => 'display_like', |
| 289 | 'admin_label' => false, |
| 290 | 'dependency' => '', |
| 291 | 'weight' => '', |
| 292 | 'group' => '', |
| 293 | 'edit_field_class' => '' |
| 294 | ), |
| 295 | array( |
| 296 | 'heading' => __('Load More Type','auxin-elements' ), |
| 297 | 'description' => '', |
| 298 | 'param_name' => 'loadmore_type', |
| 299 | 'type' => 'aux_visual_select', |
| 300 | 'value' => 'scroll', |
| 301 | 'class' => 'loadmore_type', |
| 302 | 'admin_label' => false, |
| 303 | 'dependency' => '', |
| 304 | 'weight' => '', |
| 305 | 'group' => '' , |
| 306 | 'edit_field_class' => '', |
| 307 | 'choices' => array( |
| 308 | '' => array( |
| 309 | 'label' => __('None', 'auxin-elements' ), |
| 310 | 'image' => AUXIN_URL . 'images/visual-select/load-more-none.svg' |
| 311 | ), |
| 312 | 'scroll' => array( |
| 313 | 'label' => __('Infinite Scroll', 'auxin-elements' ), |
| 314 | 'image' => AUXIN_URL . 'images/visual-select/load-more-infinite.svg' |
| 315 | ), |
| 316 | 'next' => array( |
| 317 | 'label' => __('Next Button', 'auxin-elements' ), |
| 318 | 'image' => AUXIN_URL . 'images/visual-select/load-more-button.svg' |
| 319 | ), |
| 320 | 'next-prev' => array( |
| 321 | 'label' => __('Next Prev', 'auxin-elements' ), |
| 322 | 'image' => AUXIN_URL . 'images/visual-select/load-more-next-prev.svg' |
| 323 | ) |
| 324 | ) |
| 325 | ), |
| 326 | array( |
| 327 | 'heading' => __('Excerpt length','auxin-elements' ), |
| 328 | 'description' => __('Specify summary content in character.','auxin-elements' ), |
| 329 | 'param_name' => 'excerpt_len', |
| 330 | 'type' => 'textfield', |
| 331 | 'value' => '160', |
| 332 | 'holder' => '', |
| 333 | 'class' => 'excerpt_len', |
| 334 | 'admin_label' => false, |
| 335 | 'dependency' => '', |
| 336 | 'weight' => '', |
| 337 | 'group' => '', |
| 338 | 'edit_field_class' => '' |
| 339 | ), |
| 340 | array( |
| 341 | 'heading' => __('Display author or read more', 'auxin-elements'), |
| 342 | 'description' => __('Specifies whether to show author or read more on each post.', 'auxin-elements'), |
| 343 | 'param_name' => 'author_or_readmore', |
| 344 | 'type' => 'dropdown', |
| 345 | 'def_value' => 'readmore', |
| 346 | 'holder' => '', |
| 347 | 'class' => 'author_or_readmore', |
| 348 | 'value' => array ( |
| 349 | 'readmore' => __('Read More', 'auxin-elements'), |
| 350 | 'author' => __('Author Name', 'auxin-elements'), |
| 351 | ), |
| 352 | 'admin_label' => false, |
| 353 | 'dependency' => '', |
| 354 | 'weight' => '', |
| 355 | 'group' => '', |
| 356 | 'edit_field_class' => '' |
| 357 | ), |
| 358 | array( |
| 359 | 'heading' => __('Number of columns', 'auxin-elements'), |
| 360 | 'description' => '', |
| 361 | 'param_name' => 'desktop_cnum', |
| 362 | 'type' => 'dropdown', |
| 363 | 'def_value' => '4', |
| 364 | 'holder' => '', |
| 365 | 'class' => 'desktop_cnum', |
| 366 | 'value' => array( |
| 367 | '1' => '1', '2' => '2', '3' => '3', |
| 368 | '4' => '4', '5' => '5', '6' => '6' |
| 369 | ), |
| 370 | 'admin_label' => false, |
| 371 | 'dependency' => '', |
| 372 | 'weight' => '', |
| 373 | 'group' => __( 'Layout', 'auxin-elements' ), |
| 374 | 'edit_field_class' => '' |
| 375 | ), |
| 376 | array( |
| 377 | 'heading' => __('Number of columns in tablet size', 'auxin-elements'), |
| 378 | 'description' => '', |
| 379 | 'param_name' => 'tablet_cnum', |
| 380 | 'type' => 'dropdown', |
| 381 | 'value' => 'inherit', |
| 382 | 'holder' => '', |
| 383 | 'class' => 'tablet_cnum', |
| 384 | 'value' => array( |
| 385 | 'inherit' => 'Inherited from larger', |
| 386 | '1' => '1', '2' => '2', '3' => '3', |
| 387 | '4' => '4', '5' => '5', '6' => '6' |
| 388 | ), |
| 389 | 'admin_label' => false, |
| 390 | 'dependency' => '', |
| 391 | 'weight' => '', |
| 392 | 'group' => __( 'Layout', 'auxin-elements' ), |
| 393 | 'edit_field_class' => '' |
| 394 | ), |
| 395 | array( |
| 396 | 'heading' => __('Number of columns in phone size', 'auxin-elements'), |
| 397 | 'description' => '', |
| 398 | 'param_name' => 'phone_cnum', |
| 399 | 'type' => 'dropdown', |
| 400 | 'def_value' => '1', |
| 401 | 'holder' => '', |
| 402 | 'class' => 'phone_cnum', |
| 403 | 'value' => array( |
| 404 | '1' => '1' , '2' => '2', '3' => '3' |
| 405 | ), |
| 406 | 'admin_label' => false, |
| 407 | 'dependency' => '', |
| 408 | 'weight' => '', |
| 409 | 'group' => __( 'Layout', 'auxin-elements' ), |
| 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 | 'def_value' => '', |
| 419 | 'holder' => '', |
| 420 | 'class' => 'extra_classes', |
| 421 | 'admin_label' => false, |
| 422 | 'dependency' => '', |
| 423 | 'weight' => '', |
| 424 | 'group' => '', |
| 425 | 'edit_field_class' => '' |
| 426 | ) |
| 427 | ) |
| 428 | ); |
| 429 | |
| 430 | return $master_array; |
| 431 | } |
| 432 | |
| 433 | add_filter( 'auxin_master_array_shortcodes', 'auxin_get_recent_posts_masonry_master_array', 10, 1 ); |
| 434 | |
| 435 | |
| 436 | |
| 437 | |
| 438 | /** |
| 439 | * Element without loop and column |
| 440 | * The front-end output of this element is returned by the following function |
| 441 | * |
| 442 | * @param array $atts The array containing the parsed values from shortcode, it should be same as defined params above. |
| 443 | * @param string $shortcode_content The shorcode content |
| 444 | * @return string The output of element markup |
| 445 | */ |
| 446 | function auxin_widget_recent_posts_masonry_callback( $atts, $shortcode_content = null ){ |
| 447 | |
| 448 | // Defining default attributes |
| 449 | $default_atts = array( |
| 450 | 'title' => '', // header title |
| 451 | 'cat' => ' ', |
| 452 | 'num' => '8', // max generated entry |
| 453 | 'only_posts__in' => '', // display only these post IDs. array or string comma separated |
| 454 | 'include' => '', // include these post IDs in result too. array or string comma separated |
| 455 | 'exclude' => '', // exclude these post IDs from result. array or string comma separated |
| 456 | 'offset' => '', |
| 457 | 'paged' => '', |
| 458 | 'order_by' => 'date', |
| 459 | 'order' => 'DESC', |
| 460 | 'exclude_without_media' => 0, |
| 461 | 'exclude_custom_post_formats' => 0, |
| 462 | 'exclude_quote_link' => 0, |
| 463 | 'exclude_post_formats_in' => array(), // the list od post formats to exclude |
| 464 | 'show_media' => true, |
| 465 | 'display_like' => true, |
| 466 | 'display_comments' => true, |
| 467 | 'display_categories' => true, |
| 468 | 'max_taxonomy_num' => '', |
| 469 | 'content_layout' => '', // entry-boxed |
| 470 | 'post_info_position' => 'after-title', // entry-boxed |
| 471 | 'excerpt_len' => '160', |
| 472 | 'excerpt_length' => '', |
| 473 | 'display_title' => true, |
| 474 | 'show_excerpt' => true, |
| 475 | 'show_content' => true, |
| 476 | 'show_info' => true, |
| 477 | 'show_date' => true, |
| 478 | 'author_or_readmore' => 'readmore', |
| 479 | 'display_author_header' => true, |
| 480 | 'display_author_footer' => false, |
| 481 | // 'image_aspect_ratio' => 0.75, |
| 482 | 'desktop_cnum' => 4, |
| 483 | 'tablet_cnum' => 'inherit', |
| 484 | 'phone_cnum' => '1', |
| 485 | 'tag' => '', |
| 486 | |
| 487 | 'crop' => false, |
| 488 | 'preloadable' => false, |
| 489 | 'preload_preview' => true, |
| 490 | 'preload_bgcolor' => '', |
| 491 | |
| 492 | 'extra_classes' => '', |
| 493 | 'extra_column_classes' => '', |
| 494 | 'custom_el_id' => '', |
| 495 | 'taxonomy_name' => 'category', |
| 496 | |
| 497 | 'template_part_file' => 'theme-parts/entry/post-column', |
| 498 | 'extra_template_path' => '', |
| 499 | |
| 500 | 'universal_id' => '', |
| 501 | 'reset_query' => true, |
| 502 | 'use_wp_query' => false, // true to use the global wp_query, false to use internal custom query |
| 503 | 'wp_query_args' => array(), // additional wp_query args |
| 504 | 'loadmore_type' => '', // 'next' (more button), 'scroll', 'next-prev' |
| 505 | 'loadmore_per_page' => '', |
| 506 | 'base' => 'aux_recent_posts_masonry', |
| 507 | 'base_class' => 'aux-widget-recent-posts-masonry aux-column-post-entry' |
| 508 | ); |
| 509 | |
| 510 | $result = auxin_get_widget_scafold( $atts, $default_atts, $shortcode_content ); |
| 511 | extract( $result['parsed_atts'] ); |
| 512 | |
| 513 | $acceptedTemplateFiles = apply_filters( 'auxin_recent_posts_masonry_accepted_template_files', [ |
| 514 | 'theme-parts/entry/post-column', |
| 515 | 'theme-parts/entry/post-flip', |
| 516 | 'theme-parts/entry/post-land', |
| 517 | 'theme-parts/entry/post-tile', |
| 518 | 'theme-parts/entry/post', |
| 519 | ]); |
| 520 | |
| 521 | if ( ! in_array( $template_part_file, $acceptedTemplateFiles ) ) { |
| 522 | return; |
| 523 | } |
| 524 | |
| 525 | $display_author_footer = auxin_is_true( $display_author_footer ); |
| 526 | $display_author_header = auxin_is_true( $display_author_header ); |
| 527 | |
| 528 | // specify the post formats that should be excluded ------- |
| 529 | $exclude_post_formats_in = (array) $exclude_post_formats_in; |
| 530 | |
| 531 | if( $exclude_custom_post_formats ){ |
| 532 | $exclude_post_formats_in = array_merge( $exclude_post_formats_in, array( 'aside', 'gallery', 'image', 'link', 'quote', 'video', 'audio' ) ); |
| 533 | } |
| 534 | if( $exclude_quote_link ){ |
| 535 | $exclude_post_formats_in[] = 'quote'; |
| 536 | $exclude_post_formats_in[] = 'link'; |
| 537 | } |
| 538 | $exclude_post_formats_in = array_unique( $exclude_post_formats_in ); |
| 539 | |
| 540 | // -------------- |
| 541 | |
| 542 | ob_start(); |
| 543 | |
| 544 | $tax_args = array(); |
| 545 | if( ! empty( $cat ) && $cat != " " && ( ! is_array( $cat ) || ! in_array( " ", $cat ) ) ) { |
| 546 | $tax_args = array( |
| 547 | array( |
| 548 | 'taxonomy' => $taxonomy_name, |
| 549 | 'field' => 'term_id', |
| 550 | 'terms' => ! is_array( $cat ) ? explode( ",", $cat ) : $cat |
| 551 | ) |
| 552 | ); |
| 553 | } |
| 554 | |
| 555 | global $wp_query; |
| 556 | |
| 557 | if( ! $use_wp_query ){ |
| 558 | |
| 559 | // create wp_query to get latest items ----------- |
| 560 | $args = array( |
| 561 | 'post_type' => 'post', |
| 562 | 'orderby' => $order_by, |
| 563 | 'order' => $order, |
| 564 | 'offset' => $offset, |
| 565 | 'paged' => $paged, |
| 566 | 'tax_query' => $tax_args, |
| 567 | 'post_status' => 'publish', |
| 568 | 'posts_per_page' => $num, |
| 569 | 'ignore_sticky_posts' => 1, |
| 570 | |
| 571 | 'include_posts__in' => $include, // include posts in this list |
| 572 | 'posts__not_in' => $exclude, // exclude posts in this list |
| 573 | 'posts__in' => $only_posts__in, // only posts in this list |
| 574 | |
| 575 | 'exclude_without_media' => $exclude_without_media, |
| 576 | 'exclude_post_formats_in' => $exclude_post_formats_in |
| 577 | ); |
| 578 | |
| 579 | // --------------------------------------------------------------------- |
| 580 | |
| 581 | // add the additional query args if available |
| 582 | if( $wp_query_args ){ |
| 583 | $args = wp_parse_args( $args, $wp_query_args ); |
| 584 | } |
| 585 | |
| 586 | // pass the args through the auxin query parser |
| 587 | $wp_query = new WP_Query( auxin_parse_query_args( $args ) ); |
| 588 | } |
| 589 | |
| 590 | // widget header ------------------------------ |
| 591 | echo wp_kses_post( $result['widget_header'] ); |
| 592 | echo wp_kses_post( $result['widget_title'] ); |
| 593 | |
| 594 | |
| 595 | $phone_break_point = 767; |
| 596 | $tablet_break_point = 1025; |
| 597 | |
| 598 | $show_comments = true; // shows comments icon |
| 599 | $post_counter = 0; |
| 600 | $post_classes = ''; |
| 601 | $column_class = ''; |
| 602 | $item_class = 'aux-col aux-post-masonry'; |
| 603 | $carousel_attrs = ''; |
| 604 | $container_class = 'aux-masonry-layout '; |
| 605 | |
| 606 | if( ! empty( $loadmore_type ) ) { |
| 607 | $item_class .= ' aux-ajax-item'; |
| 608 | } |
| 609 | |
| 610 | // generate columns class |
| 611 | $column_class = $container_class . ' aux-de-col' . $desktop_cnum; |
| 612 | $tablet_cnum = ('inherit' == $tablet_cnum ) ? $desktop_cnum : $tablet_cnum ; |
| 613 | $column_class .= ' aux-tb-col'.$tablet_cnum . ' aux-mb-col'.$phone_cnum; |
| 614 | $column_class .= 'entry-boxed' == $content_layout ? ' aux-entry-boxed' : ''; |
| 615 | |
| 616 | $column_class .= ' aux-ajax-view ' . $extra_column_classes; |
| 617 | |
| 618 | $column_media_width = auxin_get_content_column_width( $desktop_cnum, 15, $content_width ); |
| 619 | |
| 620 | $have_posts = $wp_query->have_posts(); |
| 621 | |
| 622 | if( $have_posts ){ |
| 623 | |
| 624 | echo ! $skip_wrappers ? sprintf( '<div data-element-id="%s" class="%s">', esc_attr( $universal_id ), esc_attr( $column_class ) ) : ''; |
| 625 | |
| 626 | while ( $wp_query->have_posts() ) { |
| 627 | |
| 628 | $wp_query->the_post(); |
| 629 | $post = $wp_query->post; |
| 630 | |
| 631 | $post_vars = auxin_get_post_format_media( |
| 632 | $post, |
| 633 | array( |
| 634 | 'request_from' => 'archive', |
| 635 | 'media_width' => $phone_break_point, |
| 636 | 'media_size' => 'large',//array( 'width' => $column_media_width, 'height' => $column_media_width * $image_aspect_ratio ), |
| 637 | 'upscale_image' => true, |
| 638 | 'crop' => $crop, |
| 639 | 'image_from_content' => ! $exclude_without_media, // whether to try to get image from content or not |
| 640 | 'no_gallery' => false, |
| 641 | 'add_image_hw' => false, // whether add width and height attr or not |
| 642 | 'preloadable' => $preloadable, |
| 643 | 'preload_preview' => $preload_preview, |
| 644 | 'preload_bgcolor' => $preload_bgcolor, |
| 645 | 'image_sizes' => 'auto', |
| 646 | 'srcset_sizes' => 'auto' |
| 647 | ) |
| 648 | ); |
| 649 | |
| 650 | extract( $post_vars ); |
| 651 | |
| 652 | $the_format = get_post_format( $post ); |
| 653 | |
| 654 | // add specific class to current classes for each column |
| 655 | $post_classes = $has_attach && $show_media ? 'post column-entry' : 'post column-entry no-media'; |
| 656 | |
| 657 | printf( '<div class="%s post-%s">', esc_attr( $item_class ), esc_attr( $post->ID ) ); |
| 658 | include auxin_get_template_file( $template_part_file, '', $extra_template_path ); |
| 659 | echo '</div>'; |
| 660 | } |
| 661 | |
| 662 | if( ! $skip_wrappers ) { |
| 663 | // End tag for aux-ajax-view wrapper |
| 664 | echo '</div>'; |
| 665 | // Execute load more functionality |
| 666 | if( $wp_query->found_posts > $loadmore_per_page ) { |
| 667 | echo auxin_get_load_more_controller( $loadmore_type ); |
| 668 | } |
| 669 | |
| 670 | } else { |
| 671 | // Get post counter in the query |
| 672 | echo '<span class="aux-post-count hidden">'. esc_html( $wp_query->post_count ) .'</span>'; |
| 673 | echo '<span class="aux-all-posts-count hidden">'. esc_html( $wp_query->found_posts ) .'</span>'; |
| 674 | } |
| 675 | |
| 676 | } |
| 677 | |
| 678 | if( $reset_query ){ |
| 679 | wp_reset_query(); |
| 680 | } |
| 681 | |
| 682 | // return false if no result found |
| 683 | if( ! $have_posts ){ |
| 684 | ob_get_clean(); |
| 685 | return false; |
| 686 | } |
| 687 | |
| 688 | // widget footer ------------------------------ |
| 689 | echo wp_kses_post( $result['widget_footer'] ); |
| 690 | |
| 691 | return ob_get_clean(); |
| 692 | } |
| 693 |