about-widget.php
9 years ago
accordion-api.php
9 years ago
accordion.php
9 years ago
attachment-url.php
9 years ago
audio.php
9 years ago
before-after.php
9 years ago
button.php
9 years ago
code.php
9 years ago
contact-box.php
9 years ago
contact-form.php
9 years ago
divider.php
9 years ago
dropcap.php
9 years ago
facebook.php
9 years ago
flickr.php
9 years ago
gallery.php
9 years ago
gmap.php
9 years ago
highlight.php
9 years ago
image.php
9 years ago
instagram-feed.php
9 years ago
latest-items.php
10 years ago
latest-posts-slider.php
9 years ago
popular-posts-widget.php
9 years ago
quote.php
9 years ago
recent-posts-grid-carousel.php
9 years ago
recent-posts-land-style.php
9 years ago
recent-posts-masonry.php
9 years ago
recent-posts-tiles.php
9 years ago
recent-posts-timeline.php
9 years ago
recent-posts-widget.php
9 years ago
recent-posts.php
9 years ago
related-posts.php
9 years ago
sample-element.php
9 years ago
search.php
9 years ago
slider.php
9 years ago
socials-list.php
9 years ago
tabs-api.php
9 years ago
tabs.php
9 years ago
text.php
9 years ago
touch-slider.php
9 years ago
video.php
9 years ago
recent-posts-tiles.php
521 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Code highlighter element |
| 4 | * |
| 5 | * |
| 6 | * @package Auxin |
| 7 | * @license LICENSE.txt |
| 8 | * @author |
| 9 | * @link http://averta.net/phlox/ |
| 10 | * @copyright (c) 2010-2017 |
| 11 | */ |
| 12 | |
| 13 | function auxin_get_recent_posts_tiles_master_array( $master_array ) { |
| 14 | |
| 15 | $categories = get_terms( 'category', 'orderby=count&hide_empty=0' ); |
| 16 | $categories_list = array( ' ' => __('All Categories', 'auxin-elements' ) ) ; |
| 17 | foreach ( $categories as $key => $value ) { |
| 18 | $categories_list[$value->term_id] = $value->name; |
| 19 | } |
| 20 | |
| 21 | // $tags = get_terms( 'post_tag', 'orderby=count&hide_empty=0' ); |
| 22 | // $tags_list; |
| 23 | // foreach ($tags as $key => $value) { |
| 24 | // $tags_list["$value->term_id"] = $value->name; |
| 25 | // } |
| 26 | |
| 27 | |
| 28 | $master_array['aux_recent_posts_tiles'] = array( |
| 29 | 'name' => __('[Phlox] Tiles Recent Posts', 'auxin-elements' ), |
| 30 | 'auxin_output_callback' => 'auxin_widget_recent_posts_tiles_callback', |
| 31 | 'base' => 'aux_recent_posts_tiles', |
| 32 | 'description' => __('It adds recent posts in tiles style.', 'auxin-elements' ), |
| 33 | 'class' => 'aux-widget-recent-posts-tiles', |
| 34 | 'show_settings_on_create' => true, |
| 35 | 'weight' => 1, |
| 36 | 'is_widget' => false, |
| 37 | 'is_shortcode' => true, |
| 38 | 'is_so' => true, |
| 39 | 'is_vc' => true, |
| 40 | 'category' => THEME_NAME, |
| 41 | 'group' => '', |
| 42 | 'admin_enqueue_js' => '', |
| 43 | 'admin_enqueue_css' => '', |
| 44 | 'front_enqueue_js' => '', |
| 45 | 'front_enqueue_css' => '', |
| 46 | 'icon' => 'auxin-element auxin-tile', |
| 47 | 'custom_markup' => '', |
| 48 | 'js_view' => '', |
| 49 | 'html_template' => '', |
| 50 | 'deprecated' => '', |
| 51 | 'content_element' => '', |
| 52 | 'as_parent' => '', |
| 53 | 'as_child' => '', |
| 54 | 'params' => array( |
| 55 | array( |
| 56 | 'heading' => __('Title','auxin-elements' ), |
| 57 | 'description' => __('Recent post title, leave it empty if you don`t need title.', 'auxin-elements'), |
| 58 | 'param_name' => 'title', |
| 59 | 'type' => 'textfield', |
| 60 | 'value' => '', |
| 61 | 'holder' => 'textfield', |
| 62 | 'class' => 'title', |
| 63 | 'admin_label' => false, |
| 64 | 'dependency' => '', |
| 65 | 'weight' => '', |
| 66 | 'group' => '', |
| 67 | 'edit_field_class' => '' |
| 68 | ), |
| 69 | array( |
| 70 | 'heading' => __('Categories', 'auxin-elements'), |
| 71 | 'description' => __('Specifies a category that you want to show posts from it.', 'auxin-elements' ), |
| 72 | 'param_name' => 'cat', |
| 73 | 'type' => 'aux_select2_multiple', |
| 74 | 'def_value' => ' ', |
| 75 | 'holder' => '', |
| 76 | 'class' => 'cat', |
| 77 | 'value' => $categories_list, |
| 78 | 'admin_label' => false, |
| 79 | 'dependency' => '', |
| 80 | 'weight' => '', |
| 81 | 'group' => 'Query', |
| 82 | 'edit_field_class' => '' |
| 83 | ), |
| 84 | array( |
| 85 | 'heading' => __('Number of posts to show', 'auxin-elements'), |
| 86 | 'description' => '', |
| 87 | 'param_name' => 'num', |
| 88 | 'type' => 'textfield', |
| 89 | 'value' => '8', |
| 90 | 'holder' => '', |
| 91 | 'class' => 'num', |
| 92 | 'admin_label' => false, |
| 93 | 'dependency' => '', |
| 94 | 'weight' => '', |
| 95 | 'group' => 'Query', |
| 96 | 'edit_field_class' => '' |
| 97 | ), |
| 98 | array( |
| 99 | 'heading' => __('Exclude posts without media','auxin-elements' ), |
| 100 | 'description' => '', |
| 101 | 'param_name' => 'exclude_without_media', |
| 102 | 'type' => 'aux_switch', |
| 103 | 'value' => '1', |
| 104 | 'class' => '', |
| 105 | 'admin_label' => false, |
| 106 | 'dependency' => '', |
| 107 | 'weight' => '', |
| 108 | 'group' => 'Query', |
| 109 | 'edit_field_class' => '' |
| 110 | ), |
| 111 | array( |
| 112 | 'heading' => __('Exclude custom post formats','auxin-elements' ), |
| 113 | 'description' => '', |
| 114 | 'param_name' => 'exclude_custom_post_formats', |
| 115 | 'type' => 'aux_switch', |
| 116 | 'value' => '1', |
| 117 | 'class' => '', |
| 118 | 'admin_label' => false, |
| 119 | 'dependency' => '', |
| 120 | 'weight' => '', |
| 121 | 'group' => 'Query', |
| 122 | 'edit_field_class' => '' |
| 123 | ), |
| 124 | array( |
| 125 | 'heading' => __('Exclude quote and link post formats','auxin-elements' ), |
| 126 | 'description' => '', |
| 127 | 'param_name' => 'exclude_quote_link', |
| 128 | 'type' => 'aux_switch', |
| 129 | 'value' => '1', |
| 130 | 'class' => '', |
| 131 | 'admin_label' => false, |
| 132 | 'dependency' => array( |
| 133 | 'element' => 'exclude_custom_post_formats', |
| 134 | 'value' => '0' |
| 135 | ), |
| 136 | 'weight' => '', |
| 137 | 'group' => 'Query', |
| 138 | 'edit_field_class' => '' |
| 139 | ), |
| 140 | array( |
| 141 | 'heading' => __('Order by', 'auxin-elements'), |
| 142 | 'description' => '', |
| 143 | 'param_name' => 'order_by', |
| 144 | 'type' => 'dropdown', |
| 145 | 'def_value' => 'date', |
| 146 | 'holder' => '', |
| 147 | 'class' => 'order_by', |
| 148 | 'value' => array ( |
| 149 | 'date' => __('Date', 'auxin-elements'), |
| 150 | 'menu_order date' => __('Menu Order', 'auxin-elements'), |
| 151 | 'title' => __('Title', 'auxin-elements'), |
| 152 | 'ID' => __('ID', 'auxin-elements'), |
| 153 | 'rand' => __('Random', 'auxin-elements'), |
| 154 | 'comment_count' => __('Comments', 'auxin-elements'), |
| 155 | 'modified' => __('Date Modified', 'auxin-elements'), |
| 156 | 'author' => __('Author', 'auxin-elements'), |
| 157 | 'post__in' => __('Inserted Post IDs', 'auxin-elements') |
| 158 | ), |
| 159 | 'admin_label' => false, |
| 160 | 'dependency' => '', |
| 161 | 'weight' => '', |
| 162 | 'group' => 'Query', |
| 163 | 'edit_field_class' => '' |
| 164 | ), |
| 165 | array( |
| 166 | 'heading' => __('Order', 'auxin-elements'), |
| 167 | 'description' => '', |
| 168 | 'param_name' => 'order', |
| 169 | 'type' => 'dropdown', |
| 170 | 'def_value' => 'DESC', |
| 171 | 'holder' => '', |
| 172 | 'class' => 'order', |
| 173 | 'value' =>array ( |
| 174 | 'DESC' => __('Descending', 'auxin-elements'), |
| 175 | 'ASC' => __('Ascending', 'auxin-elements'), |
| 176 | ), |
| 177 | 'admin_label' => false, |
| 178 | 'dependency' => '', |
| 179 | 'weight' => '', |
| 180 | 'group' => 'Query', |
| 181 | 'edit_field_class' => '' |
| 182 | ), |
| 183 | array( |
| 184 | 'heading' => __('Only posts','auxin-elements' ), |
| 185 | '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' ), |
| 186 | 'param_name' => 'only_posts__in', |
| 187 | 'type' => 'textfield', |
| 188 | 'value' => '', |
| 189 | 'holder' => '', |
| 190 | 'class' => '', |
| 191 | 'admin_label' => false, |
| 192 | 'dependency' => '', |
| 193 | 'weight' => '', |
| 194 | 'group' => 'Query', |
| 195 | 'edit_field_class' => '' |
| 196 | ), |
| 197 | array( |
| 198 | 'heading' => __('Include posts','auxin-elements' ), |
| 199 | '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' ), |
| 200 | 'param_name' => 'include', |
| 201 | 'type' => 'textfield', |
| 202 | 'value' => '', |
| 203 | 'holder' => '', |
| 204 | 'class' => '', |
| 205 | 'admin_label' => false, |
| 206 | 'dependency' => '', |
| 207 | 'weight' => '', |
| 208 | 'group' => 'Query', |
| 209 | 'edit_field_class' => '' |
| 210 | ), |
| 211 | array( |
| 212 | 'heading' => __('Exclude posts','auxin-elements' ), |
| 213 | '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' ), |
| 214 | 'param_name' => 'exclude', |
| 215 | 'type' => 'textfield', |
| 216 | 'value' => '', |
| 217 | 'holder' => '', |
| 218 | 'class' => '', |
| 219 | 'admin_label' => false, |
| 220 | 'dependency' => '', |
| 221 | 'weight' => '', |
| 222 | 'group' => 'Query', |
| 223 | 'edit_field_class' => '' |
| 224 | ), |
| 225 | array( |
| 226 | 'heading' => __('Order by', 'auxin-elements'), |
| 227 | 'description' => '', |
| 228 | 'param_name' => 'order_by', |
| 229 | 'type' => 'dropdown', |
| 230 | 'def_value' => 'date', |
| 231 | 'holder' => '', |
| 232 | 'class' => 'order_by', |
| 233 | 'value' => array ( |
| 234 | 'date' => __('Date', 'auxin-elements'), |
| 235 | 'menu_order date' => __('Menu Order', 'auxin-elements'), |
| 236 | 'title' => __('Title', 'auxin-elements'), |
| 237 | 'ID' => __('ID', 'auxin-elements'), |
| 238 | 'rand' => __('Random', 'auxin-elements'), |
| 239 | 'comment_count' => __('Comments', 'auxin-elements'), |
| 240 | 'modified' => __('Date Modified', 'auxin-elements'), |
| 241 | 'author' => __('Author', 'auxin-elements'), |
| 242 | 'post__in' => __('Inserted Post IDs', 'auxin-elements') |
| 243 | ), |
| 244 | 'admin_label' => false, |
| 245 | 'dependency' => '', |
| 246 | 'weight' => '', |
| 247 | 'group' => 'Query', |
| 248 | 'edit_field_class' => '' |
| 249 | ), |
| 250 | array( |
| 251 | 'heading' => __('Order', 'auxin-elements'), |
| 252 | 'description' => '', |
| 253 | 'param_name' => 'order', |
| 254 | 'type' => 'dropdown', |
| 255 | 'def_value' => 'DESC', |
| 256 | 'holder' => '', |
| 257 | 'class' => 'order', |
| 258 | 'value' =>array ( |
| 259 | 'DESC' => __('Descending', 'auxin-elements'), |
| 260 | 'ASC' => __('Ascending', 'auxin-elements'), |
| 261 | ), |
| 262 | 'admin_label' => false, |
| 263 | 'dependency' => '', |
| 264 | 'weight' => '', |
| 265 | 'group' => 'Query', |
| 266 | 'edit_field_class' => '' |
| 267 | ), |
| 268 | array( |
| 269 | 'heading' => __('Start offset','auxin-elements' ), |
| 270 | 'description' => __('Number of post to displace or pass over.', 'auxin-elements' ), |
| 271 | 'param_name' => 'offset', |
| 272 | 'type' => 'textfield', |
| 273 | 'value' => '', |
| 274 | 'holder' => '', |
| 275 | 'class' => '', |
| 276 | 'admin_label' => false, |
| 277 | 'dependency' => '', |
| 278 | 'weight' => '', |
| 279 | 'group' => 'Query', |
| 280 | 'edit_field_class' => '' |
| 281 | ), |
| 282 | array( |
| 283 | 'heading' => __('Post tile style','auxin-elements' ), |
| 284 | 'description' => '', |
| 285 | 'param_name' => 'tile_style', |
| 286 | 'type' => 'aux_visual_select', |
| 287 | 'def_value' => '', |
| 288 | 'holder' => '', |
| 289 | 'class' => 'tile_style', |
| 290 | 'admin_label' => false, |
| 291 | 'dependency' => '', |
| 292 | 'weight' => '', |
| 293 | 'group' => 'Style', |
| 294 | 'edit_field_class' => '', |
| 295 | 'choices' => array( |
| 296 | '' => array( |
| 297 | 'label' => __('Standard', 'auxin-elements' ), |
| 298 | 'image' => AUXIN_URL . 'images/visual-select/button-normal.svg' |
| 299 | ), |
| 300 | 'aux-overlay' => array( |
| 301 | 'label' => __('Dark', 'auxin-elements' ), |
| 302 | 'image' => AUXIN_URL . 'images/visual-select/button-curved.svg' |
| 303 | ) |
| 304 | ) |
| 305 | ), |
| 306 | array( |
| 307 | 'heading' => __('Insert post title','auxin-elements' ), |
| 308 | 'description' => '', |
| 309 | 'param_name' => 'display_title', |
| 310 | 'type' => 'aux_switch', |
| 311 | 'value' => '1', |
| 312 | 'class' => 'display_title', |
| 313 | 'admin_label' => false, |
| 314 | 'dependency' => '', |
| 315 | 'weight' => '', |
| 316 | 'group' => '' , |
| 317 | 'edit_field_class' => '' |
| 318 | ), |
| 319 | array( |
| 320 | 'heading' => __('Insert post meta','auxin-elements' ), |
| 321 | 'description' => '', |
| 322 | 'param_name' => 'show_info', |
| 323 | 'type' => 'aux_switch', |
| 324 | 'value' => '1', |
| 325 | 'class' => '', |
| 326 | 'admin_label' => false, |
| 327 | 'weight' => '', |
| 328 | 'group' => '' , |
| 329 | 'edit_field_class' => '' |
| 330 | ), |
| 331 | array( |
| 332 | 'heading' => __('Extra class name','auxin-elements' ), |
| 333 | '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' ), |
| 334 | 'param_name' => 'extra_classes', |
| 335 | 'type' => 'textfield', |
| 336 | 'value' => '', |
| 337 | 'holder' => '', |
| 338 | 'class' => 'extra_classes', |
| 339 | 'admin_label' => false, |
| 340 | 'dependency' => '', |
| 341 | 'weight' => '', |
| 342 | 'group' => '', |
| 343 | 'edit_field_class' => '' |
| 344 | ) |
| 345 | ) |
| 346 | ); |
| 347 | |
| 348 | return $master_array; |
| 349 | } |
| 350 | |
| 351 | add_filter( 'auxin_master_array_shortcodes', 'auxin_get_recent_posts_tiles_master_array', 10, 1 ); |
| 352 | |
| 353 | |
| 354 | /** |
| 355 | * Element without loop and column |
| 356 | * The front-end output of this element is returned by the following function |
| 357 | * |
| 358 | * @param array $atts The array containing the parsed values from shortcode, it should be same as defined params above. |
| 359 | * @param string $shortcode_content The shorcode content |
| 360 | * @return string The output of element markup |
| 361 | */ |
| 362 | function auxin_widget_recent_posts_tiles_callback( $atts, $shortcode_content = null ){ |
| 363 | |
| 364 | global $aux_content_width; |
| 365 | |
| 366 | // Defining default attributes |
| 367 | $default_atts = array( |
| 368 | 'title' => '', // header title |
| 369 | 'cat' => ' ', |
| 370 | 'num' => '8', // max generated entry |
| 371 | 'only_posts__in' => '', // display only these post IDs. array or string comma separated |
| 372 | 'include' => '', // include these post IDs in result too. array or string comma separated |
| 373 | 'exclude' => '', // exclude these post IDs from result. array or string comma separated |
| 374 | 'offset' => '', |
| 375 | 'paged' => '', |
| 376 | 'order_by' => 'date', |
| 377 | 'order' => 'DESC', |
| 378 | 'excerpt_len' => '160', |
| 379 | 'exclude_without_media' => '1', |
| 380 | 'exclude_custom_post_formats' => '1', |
| 381 | 'exclude_quote_link' => '1', |
| 382 | 'exclude_post_formats_in' => array(), // the list od post formats to exclude |
| 383 | 'tile_style' => '', |
| 384 | 'display_title' => '1', |
| 385 | 'show_info' => '1', |
| 386 | 'extra_classes' => '', |
| 387 | 'custom_el_id' => '', |
| 388 | 'reset_query' => true, |
| 389 | 'use_wp_query' => false, // true to use the global wp_query, false to use internal custom query |
| 390 | 'wp_query_args' => array(), // additional wp_query args |
| 391 | 'base_class' => 'aux-widget-recent-posts-tiles' |
| 392 | ); |
| 393 | |
| 394 | $result = auxin_get_widget_scafold( $atts, $default_atts, $shortcode_content ); |
| 395 | extract( $result['parsed_atts'] ); |
| 396 | |
| 397 | |
| 398 | // get content width |
| 399 | global $aux_content_width; |
| 400 | |
| 401 | // specify the post formats that should be excluded ------- |
| 402 | $exclude_post_formats_in = (array) $exclude_post_formats_in; |
| 403 | |
| 404 | if( $exclude_custom_post_formats ){ |
| 405 | $exclude_post_formats_in = array_merge( $exclude_post_formats_in, array( 'aside', 'gallery', 'image', 'link', 'quote', 'video', 'audio' ) ); |
| 406 | } |
| 407 | if( $exclude_quote_link ){ |
| 408 | $exclude_post_formats_in[] = 'quote'; |
| 409 | $exclude_post_formats_in[] = 'link'; |
| 410 | } |
| 411 | $exclude_post_formats_in = array_unique( $exclude_post_formats_in ); |
| 412 | |
| 413 | // -------------- |
| 414 | |
| 415 | ob_start(); |
| 416 | |
| 417 | global $wp_query; |
| 418 | |
| 419 | if( ! $use_wp_query ){ |
| 420 | |
| 421 | // create wp_query to get latest items ----------- |
| 422 | $args = array( |
| 423 | 'post_type' => 'post', |
| 424 | 'orderby' => $order_by, |
| 425 | 'order' => $order, |
| 426 | 'offset' => $offset, |
| 427 | 'paged' => $paged, |
| 428 | 'cat' => $cat, |
| 429 | 'post__not_in' => array_filter( explode( ',', $exclude ) ), |
| 430 | 'post__in' => array_filter( explode( ',', $include ) ), |
| 431 | 'post_status' => 'publish', |
| 432 | 'posts_per_page' => $num, |
| 433 | 'ignore_sticky_posts' => 1, |
| 434 | 'include_posts__in' => $include, // include posts in this liat |
| 435 | 'posts__not_in' => $exclude, // exclude posts in this list |
| 436 | 'posts__in' => $only_posts__in, // only posts in this list |
| 437 | |
| 438 | 'exclude_without_media' => $exclude_without_media, |
| 439 | 'exclude_post_formats_in' => $exclude_post_formats_in |
| 440 | ); |
| 441 | |
| 442 | // --------------------------------------------------------------------- |
| 443 | |
| 444 | // add the additional query args if available |
| 445 | if( $wp_query_args ){ |
| 446 | $args = wp_parse_args( $args, $wp_query_args ); |
| 447 | } |
| 448 | |
| 449 | // pass the args through the auxin query parser |
| 450 | $wp_query = new WP_Query( auxin_parse_query_args( $args ) ); |
| 451 | } |
| 452 | |
| 453 | // widget header ------------------------------ |
| 454 | echo $result['widget_header']; |
| 455 | echo $result['widget_title']; |
| 456 | |
| 457 | $phone_break_point = 767; |
| 458 | $tablet_break_point = 992; |
| 459 | |
| 460 | $show_comments = true; // shows comments icon |
| 461 | $post_counter = 0; |
| 462 | $item_class = 'aux-post-tile aux-image-box'; |
| 463 | |
| 464 | $container_class = 'aux-tiles-layout ' . $tile_style; |
| 465 | $column_media_width = auxin_get_content_column_width( 4, 0 ); |
| 466 | |
| 467 | $have_posts = $wp_query->have_posts(); |
| 468 | |
| 469 | if( $have_posts ){ |
| 470 | |
| 471 | echo sprintf( '<div class="%s">', $container_class ); |
| 472 | |
| 473 | while ( $wp_query->have_posts() ) { |
| 474 | |
| 475 | $wp_query->the_post(); |
| 476 | $post = $wp_query->post; |
| 477 | |
| 478 | $the_format = get_post_format( $post ); |
| 479 | $item_pattern_info = auxin_get_tile_pattern( 'default', $post_counter, $column_media_width ); |
| 480 | $post_counter++; |
| 481 | |
| 482 | $post_vars = auxin_get_post_format_media( |
| 483 | $post, |
| 484 | array( |
| 485 | 'request_from' => 'archive', |
| 486 | 'media_width' => $phone_break_point, |
| 487 | 'media_size' => 'large', |
| 488 | 'upscale_image' => true, |
| 489 | 'ignore_formats' => array( '*' ), |
| 490 | 'add_image_hw' => false, // whether add width and height attr or not |
| 491 | 'image_sizes' => $item_pattern_info['image_sizes'], |
| 492 | 'srcset_sizes' => $item_pattern_info['srcset_sizes'] |
| 493 | ) |
| 494 | ); |
| 495 | |
| 496 | extract( $post_vars ); |
| 497 | |
| 498 | $post_classes = $item_class .' '. $item_pattern_info['classname']; |
| 499 | |
| 500 | include( locate_template( 'templates/theme-parts/entry/post-tile.php' ) ); |
| 501 | } |
| 502 | |
| 503 | echo '</div>'; |
| 504 | } |
| 505 | |
| 506 | if( $reset_query ){ |
| 507 | wp_reset_query(); |
| 508 | } |
| 509 | |
| 510 | // return false if no result found |
| 511 | if( ! $have_posts ){ |
| 512 | ob_get_clean(); |
| 513 | return false; |
| 514 | } |
| 515 | |
| 516 | // widget footer ------------------------------ |
| 517 | echo $result['widget_footer']; |
| 518 | |
| 519 | return ob_get_clean(); |
| 520 | } |
| 521 |