about-widget.php
9 years ago
accordion.php
9 years ago
attachment-url.php
9 years ago
audio.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
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
9 years ago
latest-posts-slider.php
9 years ago
quote.php
9 years ago
recent-posts-widget.php
9 years ago
recent-posts.php
9 years ago
sample-element.php
9 years ago
search.php
9 years ago
socials-list.php
9 years ago
tabs.php
9 years ago
text.php
9 years ago
video.php
9 years ago
recent-posts.php
709 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Code highlighter element |
| 4 | * |
| 5 | * |
| 6 | * @package auxin-elements |
| 7 | * @license LICENSE.txt |
| 8 | * @author |
| 9 | * @link https://bitbucket.org/averta/ |
| 10 | * @copyright (c) 2010-2016 |
| 11 | */ |
| 12 | |
| 13 | function auxin_get_recent_posts_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'] = array( |
| 29 | 'name' => __('[Phlox] Recent Posts', 'auxin-elements' ), |
| 30 | 'auxin_output_callback' => 'auxin_widget_recent_posts_callback', |
| 31 | 'base' => 'aux_recent_posts', |
| 32 | 'description' => __('It adds recent posts in grid or carousel mode.', 'auxin-elements' ), |
| 33 | 'class' => 'aux-widget-recent-posts', |
| 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-code', |
| 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 | 'param_name' => 'title', |
| 57 | 'type' => 'textfield', |
| 58 | 'std' => '', |
| 59 | 'value' => '', |
| 60 | 'holder' => 'textfield', |
| 61 | 'class' => 'title', |
| 62 | 'heading' => __('Title','auxin-elements' ), |
| 63 | 'description' => '', |
| 64 | 'admin_label' => true, |
| 65 | 'dependency' => '', |
| 66 | 'weight' => '', |
| 67 | 'group' => '' , |
| 68 | 'edit_field_class' => '' |
| 69 | ), |
| 70 | // array( |
| 71 | // 'param_name' => 'post_type', |
| 72 | // 'type' => 'dropdown', |
| 73 | // 'def_value' => 'post', |
| 74 | // 'value' => array( |
| 75 | // 'post' => __('Posts', 'auxin-elements' ), |
| 76 | // 'page' => __('Pages', 'auxin-elements' ), |
| 77 | // ), |
| 78 | // 'holder' => 'dropdown', |
| 79 | // 'class' => 'border', |
| 80 | // 'heading' => __('Create items from','auxin-elements' ), |
| 81 | // 'description' => '', |
| 82 | // 'admin_label' => true, |
| 83 | // 'dependency' => '', |
| 84 | // 'weight' => '', |
| 85 | // 'group' => '' , |
| 86 | // 'edit_field_class' => '' |
| 87 | // ), |
| 88 | |
| 89 | array( |
| 90 | 'param_name' => 'cat', |
| 91 | 'type' => 'dropdown', |
| 92 | 'def_value' => '', |
| 93 | 'holder' => 'dropdown', |
| 94 | 'class' => 'cat', |
| 95 | 'heading' => __('Categories', 'auxin-elements'), |
| 96 | 'description' => __('Specifies a category that you want to show posts from it.', 'auxin-elements' ), |
| 97 | 'value' => $categories_list, |
| 98 | 'admin_label' => true, |
| 99 | 'dependency' => '', |
| 100 | 'weight' => '', |
| 101 | 'group' => '' , |
| 102 | 'edit_field_class' => '' |
| 103 | ), |
| 104 | |
| 105 | array( |
| 106 | 'param_name' => 'num', |
| 107 | 'type' => 'textfield', |
| 108 | 'def_value' => '8', |
| 109 | 'holder' => 'textfield', |
| 110 | 'class' => 'num', |
| 111 | 'heading' => __('Number of posts to show', 'auxin-elements'), |
| 112 | 'description' => '', |
| 113 | 'admin_label' => true, |
| 114 | 'dependency' => '', |
| 115 | 'weight' => '', |
| 116 | 'group' => '' , |
| 117 | 'edit_field_class' => '' |
| 118 | ), |
| 119 | |
| 120 | array( |
| 121 | 'param_name' => 'exclude_without_media', |
| 122 | 'type' => 'aux_switch', |
| 123 | 'value' => '0', |
| 124 | 'class' => '', |
| 125 | 'heading' => __('Exclude posts without media','auxin-elements' ), |
| 126 | 'description' => '', |
| 127 | 'admin_label' => true, |
| 128 | 'dependency' => '', |
| 129 | 'weight' => '', |
| 130 | 'group' => '' , |
| 131 | 'edit_field_class' => '' |
| 132 | ), |
| 133 | |
| 134 | array( |
| 135 | 'param_name' => 'exclude_custom_post_formats', |
| 136 | 'type' => 'aux_switch', |
| 137 | 'value' => '0', |
| 138 | 'class' => '', |
| 139 | 'heading' => __('Exclude custom post formats','auxin-elements' ), |
| 140 | 'description' => '', |
| 141 | 'admin_label' => true, |
| 142 | 'dependency' => '', |
| 143 | 'weight' => '', |
| 144 | 'group' => '' , |
| 145 | 'edit_field_class' => '' |
| 146 | ), |
| 147 | |
| 148 | array( |
| 149 | 'param_name' => 'exclude_qoute_link', |
| 150 | 'type' => 'aux_switch', |
| 151 | 'value' => '0', |
| 152 | 'class' => '', |
| 153 | 'heading' => __('Exclude qoute and link post formats','auxin-elements' ), |
| 154 | 'description' => '', |
| 155 | 'admin_label' => true, |
| 156 | 'dependency' => array( |
| 157 | 'element' => 'exclude_custom_post_formats', |
| 158 | 'value' => '0' |
| 159 | ), |
| 160 | 'weight' => '', |
| 161 | 'group' => '' , |
| 162 | 'edit_field_class' => '' |
| 163 | ), |
| 164 | |
| 165 | array( |
| 166 | 'param_name' => 'exclude', |
| 167 | 'type' => 'textfield', |
| 168 | 'value' => '', |
| 169 | 'holder' => 'textfield', |
| 170 | 'class' => '', |
| 171 | 'heading' => __('Exclude posts','auxin-elements' ), |
| 172 | 'description' => __('Post IDs separated by comma (eg. 53,34,87,25)', 'auxin-elements' ), |
| 173 | 'admin_label' => true, |
| 174 | 'dependency' => '', |
| 175 | 'weight' => '', |
| 176 | 'group' => '' , |
| 177 | 'edit_field_class' => '' |
| 178 | ), |
| 179 | array( |
| 180 | 'param_name' => 'include', |
| 181 | 'type' => 'textfield', |
| 182 | 'value' => '', |
| 183 | 'holder' => 'textfield', |
| 184 | 'class' => '', |
| 185 | 'heading' => __('Include posts','auxin-elements' ), |
| 186 | 'description' => __('Post IDs separated by comma (eg. 53,34,87,25)', 'auxin-elements' ), |
| 187 | 'admin_label' => true, |
| 188 | 'dependency' => '', |
| 189 | 'weight' => '', |
| 190 | 'group' => '' , |
| 191 | 'edit_field_class' => '' |
| 192 | ), |
| 193 | array( |
| 194 | 'param_name' => 'order_by', |
| 195 | 'type' => 'dropdown', |
| 196 | 'def_value' => 'date', |
| 197 | 'holder' => 'dropdown', |
| 198 | 'class' => 'order_by', |
| 199 | 'heading' => __('Order By', 'auxin-elements'), |
| 200 | 'description' => '', |
| 201 | 'value' => array ( |
| 202 | 'date' => __('Date', 'auxin-elements'), |
| 203 | 'menu_order date' => __('Menu Order', 'auxin-elements'), |
| 204 | 'title' => __('Title', 'auxin-elements'), |
| 205 | 'ID' => __('ID', 'auxin-elements'), |
| 206 | 'rand' => __('Random', 'auxin-elements'), |
| 207 | 'comment_count' => __('Comments', 'auxin-elements'), |
| 208 | 'modified' => __('Date Modified', 'auxin-elements'), |
| 209 | 'author' => __('Author', 'auxin-elements'), |
| 210 | ), |
| 211 | 'admin_label' => true, |
| 212 | 'dependency' => '', |
| 213 | 'weight' => '', |
| 214 | 'group' => '' , |
| 215 | 'edit_field_class' => '' |
| 216 | ), |
| 217 | array( |
| 218 | 'param_name' => 'order', |
| 219 | 'type' => 'dropdown', |
| 220 | 'def_value' => 'DESC', |
| 221 | 'holder' => 'dropdown', |
| 222 | 'class' => 'order', |
| 223 | 'heading' => __('Order', 'auxin-elements'), |
| 224 | 'description' => '', |
| 225 | 'value' =>array ( |
| 226 | 'DESC' => __('Descending', 'auxin-elements'), |
| 227 | 'ASC' => __('Ascending', 'auxin-elements'), |
| 228 | ), |
| 229 | 'admin_label' => true, |
| 230 | 'dependency' => '', |
| 231 | 'weight' => '', |
| 232 | 'group' => '' , |
| 233 | 'edit_field_class' => '' |
| 234 | ), |
| 235 | |
| 236 | array( |
| 237 | 'param_name' => 'offset', |
| 238 | 'type' => 'textfield', |
| 239 | 'value' => '', |
| 240 | 'holder' => 'textfield', |
| 241 | 'class' => '', |
| 242 | 'heading' => __('Start offset','auxin-elements' ), |
| 243 | 'description' => __('Number of post to displace or pass over', 'auxin-elements' ), |
| 244 | 'admin_label' => true, |
| 245 | 'dependency' => '', |
| 246 | 'weight' => '', |
| 247 | 'group' => '' , |
| 248 | 'edit_field_class' => '' |
| 249 | ), |
| 250 | |
| 251 | array( |
| 252 | 'param_name' => 'show_media', |
| 253 | 'type' => 'aux_switch', |
| 254 | 'def_value' => '', |
| 255 | 'value' => '1', |
| 256 | 'holder' => 'dropdown', |
| 257 | 'class' => 'show_media', |
| 258 | 'heading' => __('Display post media (image, video, etc)', 'auxin-elements' ), |
| 259 | 'admin_label' => true, |
| 260 | 'dependency' => '', |
| 261 | 'weight' => '', |
| 262 | 'group' => '' , |
| 263 | 'edit_field_class' => '' |
| 264 | ), |
| 265 | |
| 266 | array( |
| 267 | 'param_name' => 'show_title', |
| 268 | 'type' => 'aux_switch', |
| 269 | 'value' => '1', |
| 270 | 'class' => '', |
| 271 | 'heading' => __('Insert post title','auxin-elements' ), |
| 272 | 'description' => '', |
| 273 | 'admin_label' => true, |
| 274 | 'dependency' => '', |
| 275 | 'weight' => '', |
| 276 | 'group' => '' , |
| 277 | 'edit_field_class' => '' |
| 278 | ), |
| 279 | |
| 280 | array( |
| 281 | 'param_name' => 'show_info', |
| 282 | 'type' => 'aux_switch', |
| 283 | 'value' => '1', |
| 284 | 'class' => '', |
| 285 | 'heading' => __('Insert post meta','auxin-elements' ), |
| 286 | 'description' => '', |
| 287 | 'admin_label' => true, |
| 288 | 'weight' => '', |
| 289 | 'group' => '' , |
| 290 | 'edit_field_class' => '' |
| 291 | ), |
| 292 | |
| 293 | array( |
| 294 | 'param_name' => 'show_excerpt', |
| 295 | 'type' => 'aux_switch', |
| 296 | 'def_value' => '', |
| 297 | 'value' => '1', |
| 298 | 'holder' => 'dropdown', |
| 299 | 'class' => 'show_excerpt', |
| 300 | 'heading' => __('Display Excerpt','auxin-elements' ), |
| 301 | 'description' => __('Enable it to display post summary instead of full content.','auxin-elements' ), |
| 302 | 'admin_label' => 1, |
| 303 | 'dependency' => '', |
| 304 | 'weight' => '', |
| 305 | 'group' => '' , |
| 306 | 'edit_field_class' => '' |
| 307 | ), |
| 308 | |
| 309 | array( |
| 310 | 'param_name' => 'excerpt_len', |
| 311 | 'type' => 'textfield', |
| 312 | 'value' => '160', |
| 313 | 'holder' => 'textfield', |
| 314 | 'class' => 'excerpt_len', |
| 315 | 'heading' => __('Excerpt Length','auxin-elements' ), |
| 316 | 'description' => __('Specify summary content in character','auxin-elements' ), |
| 317 | 'admin_label' => 1, |
| 318 | 'dependency' => array( |
| 319 | 'element' => 'show_excerpt', |
| 320 | 'value' => '1' |
| 321 | ), |
| 322 | 'weight' => '', |
| 323 | 'group' => '' , |
| 324 | 'edit_field_class' => '' |
| 325 | ), |
| 326 | |
| 327 | |
| 328 | array( |
| 329 | 'param_name' => 'show_readmore', |
| 330 | 'type' => 'aux_switch', |
| 331 | 'value' => '1', |
| 332 | 'class' => '', |
| 333 | 'heading' => __('Insert read more button','auxin-elements' ), |
| 334 | 'description' => '', |
| 335 | 'admin_label' => true, |
| 336 | 'weight' => '', |
| 337 | 'group' => '' , |
| 338 | 'edit_field_class' => '' |
| 339 | ), |
| 340 | |
| 341 | array( |
| 342 | 'param_name' => 'show_author_footer', |
| 343 | 'type' => 'aux_switch', |
| 344 | 'value' => '1', |
| 345 | 'class' => '', |
| 346 | 'heading' => __('Insert author name in bottom side','auxin-elements' ), |
| 347 | 'description' => '', |
| 348 | 'dependency' => array( |
| 349 | 'element' => 'show_readmore', |
| 350 | 'value' => '0' |
| 351 | ), |
| 352 | 'admin_label' => false, |
| 353 | 'weight' => '', |
| 354 | 'group' => '' , |
| 355 | 'edit_field_class' => '' |
| 356 | ), |
| 357 | |
| 358 | array( |
| 359 | 'param_name' => 'desktop_cnum', |
| 360 | 'type' => 'dropdown', |
| 361 | 'def_value' => '4', |
| 362 | 'holder' => 'dropdown', |
| 363 | 'class' => 'num', |
| 364 | 'heading' => __('Number of columns', 'auxin-elements'), |
| 365 | 'description' => '', |
| 366 | 'value' => array( |
| 367 | '1' => '1' , '2' => '2' , '3' => '3' , |
| 368 | '4' => '4' , '5' => '5' , '6' => '6' |
| 369 | ), |
| 370 | 'admin_label' => true, |
| 371 | 'dependency' => '', |
| 372 | 'weight' => '', |
| 373 | 'group' => '' , |
| 374 | 'edit_field_class' => '' |
| 375 | ), |
| 376 | |
| 377 | array( |
| 378 | 'param_name' => 'tablet_cnum', |
| 379 | 'type' => 'dropdown', |
| 380 | 'def_value' => 'inherit', |
| 381 | 'holder' => 'dropdown', |
| 382 | 'class' => 'num', |
| 383 | 'heading' => __('Number of columns in tablet size', 'auxin-elements'), |
| 384 | 'description' => '', |
| 385 | 'value' => array( |
| 386 | 'inherit' => 'Inherited from larger', |
| 387 | '1' => '1' , '2' => '2' , '3' => '3' , |
| 388 | '4' => '4' |
| 389 | ), |
| 390 | 'admin_label' => true, |
| 391 | 'dependency' => '', |
| 392 | 'weight' => '', |
| 393 | 'group' => '' , |
| 394 | 'edit_field_class' => '' |
| 395 | ), |
| 396 | |
| 397 | array( |
| 398 | 'param_name' => 'phone_cnum', |
| 399 | 'type' => 'dropdown', |
| 400 | 'def_value' => 'inherit', |
| 401 | 'holder' => 'dropdown', |
| 402 | 'class' => 'num', |
| 403 | 'heading' => __('Number of columns in phone size', 'auxin-elements'), |
| 404 | 'description' => '', |
| 405 | 'value' => array( |
| 406 | 'inherit' => 'Inherited from larger', |
| 407 | '1' => '1' , '2' => '2' |
| 408 | ), |
| 409 | 'admin_label' => true, |
| 410 | 'dependency' => '', |
| 411 | 'weight' => '', |
| 412 | 'group' => '' , |
| 413 | 'edit_field_class' => '' |
| 414 | ), |
| 415 | |
| 416 | // array( |
| 417 | // 'param_name' => 'preview_mode', |
| 418 | // 'type' => 'dropdown', |
| 419 | // 'def_value' => 'grid', |
| 420 | // 'holder' => 'dropdown', |
| 421 | // 'class' => 'num', |
| 422 | // 'heading' => __('Display items in', 'auxin-elements'), |
| 423 | // 'description' => '', |
| 424 | // 'value' => array( |
| 425 | // 'grid' => 'Grid', |
| 426 | // 'carousel' => 'Carousel' |
| 427 | // ), |
| 428 | // 'admin_label' => true, |
| 429 | // 'dependency' => '', |
| 430 | // 'weight' => '', |
| 431 | // 'group' => '' , |
| 432 | // 'edit_field_class' => '' |
| 433 | // ), |
| 434 | |
| 435 | // // Carousel Options |
| 436 | // array( |
| 437 | // 'param_name' => 'carousel_space', |
| 438 | // 'type' => 'textfield', |
| 439 | // 'value' => '30', |
| 440 | // 'holder' => 'textfield', |
| 441 | // 'class' => 'excerpt_len', |
| 442 | // 'heading' => __('Column space','auxin-elements' ), |
| 443 | // 'description' => __('Specifies space between carousel columns in pixels', 'auxin-elements' ), |
| 444 | // 'admin_label' => 1, |
| 445 | // 'dependency' => array( |
| 446 | // 'element' => 'preview_mode', |
| 447 | // 'value' => 'carousel' |
| 448 | // ), |
| 449 | // 'weight' => '', |
| 450 | // 'group' => '' , |
| 451 | // 'edit_field_class' => '' |
| 452 | // ), |
| 453 | |
| 454 | // array( |
| 455 | // 'param_name' => 'carousel_navigation', |
| 456 | // 'type' => 'dropdown', |
| 457 | // 'def_value' => 'peritem', |
| 458 | // 'holder' => 'dropdown', |
| 459 | // 'class' => 'num', |
| 460 | // 'heading' => __('Number of columns in phone size', 'auxin-elements'), |
| 461 | // 'description' => '', |
| 462 | // 'value' => array( |
| 463 | // 'peritem' => __('Move per column', 'auxin-elements'), |
| 464 | // 'perpage' => __('Move per page', 'auxin-elements'), |
| 465 | // 'scroll' => __('Smooth scroll', 'auxin-elements'), |
| 466 | // ), |
| 467 | // 'admin_label' => true, |
| 468 | // 'dependency' => array( |
| 469 | // 'element' => 'preview_mode', |
| 470 | // 'value' => 'carousel' |
| 471 | // ), |
| 472 | // 'weight' => '', |
| 473 | // 'group' => '' , |
| 474 | // 'edit_field_class' => '' |
| 475 | // ), |
| 476 | |
| 477 | // array( |
| 478 | // 'param_name' => 'carousel_loop', |
| 479 | // 'type' => 'aux_switch', |
| 480 | // 'value' => '1', |
| 481 | // 'class' => '', |
| 482 | // 'heading' => __('Loop navigation','auxin-elements' ), |
| 483 | // 'description' => '', |
| 484 | // 'dependency' => array( |
| 485 | // 'element' => 'preview_mode', |
| 486 | // 'value' => 'carousel' |
| 487 | // ), |
| 488 | // 'weight' => '', |
| 489 | // 'group' => '' , |
| 490 | // 'edit_field_class' => '' |
| 491 | // ), |
| 492 | |
| 493 | // array( |
| 494 | // 'param_name' => 'carousel_autoplay', |
| 495 | // 'type' => 'aux_switch', |
| 496 | // 'value' => '0', |
| 497 | // 'class' => '', |
| 498 | // 'heading' => __('Autoplay carousel','auxin-elements' ), |
| 499 | // 'description' => '', |
| 500 | // 'admin_label' => true, |
| 501 | // 'dependency' => array( |
| 502 | // 'element' => 'preview_mode', |
| 503 | // 'value' => 'carousel' |
| 504 | // ), |
| 505 | // 'weight' => '', |
| 506 | // 'group' => '' , |
| 507 | // 'edit_field_class' => '' |
| 508 | // ), |
| 509 | |
| 510 | // array( |
| 511 | // 'param_name' => 'carousel_autoplay_delay', |
| 512 | // 'type' => 'textfield', |
| 513 | // 'value' => '2', |
| 514 | // 'holder' => 'textfield', |
| 515 | // 'class' => 'excerpt_len', |
| 516 | // 'heading' => __('Autoplay delay','auxin-elements' ), |
| 517 | // 'description' => __('Specifies the delay between auto-forwarding in seconds', 'auxin-elements' ), |
| 518 | // 'admin_label' => 1, |
| 519 | // 'dependency' => array( |
| 520 | // array( |
| 521 | // 'element' => 'preview_mode', |
| 522 | // 'value' => 'carousel' |
| 523 | // ), |
| 524 | // array( |
| 525 | // 'element' => 'carousel_autoplay', |
| 526 | // 'value' => 1 |
| 527 | // ) |
| 528 | // ), |
| 529 | // 'weight' => '', |
| 530 | // 'group' => '' , |
| 531 | // 'edit_field_class' => '' |
| 532 | // ), |
| 533 | |
| 534 | |
| 535 | array( |
| 536 | 'param_name' => 'extra_classes', |
| 537 | 'type' => 'textfield', |
| 538 | 'value' => '', |
| 539 | 'def_value' => '', |
| 540 | 'holder' => 'textfield', |
| 541 | 'class' => 'extra_classes', |
| 542 | 'heading' => __('Extra class name','auxin-elements' ), |
| 543 | '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' ), |
| 544 | 'admin_label' => true, |
| 545 | 'dependency' => '', |
| 546 | 'weight' => '', |
| 547 | 'group' => '', |
| 548 | 'edit_field_class' => '' |
| 549 | ) |
| 550 | ) |
| 551 | ); |
| 552 | |
| 553 | return $master_array; |
| 554 | } |
| 555 | |
| 556 | add_filter( 'auxin_master_array_shortcodes', 'auxin_get_recent_posts_master_array', 10, 1 ); |
| 557 | |
| 558 | |
| 559 | |
| 560 | |
| 561 | /** |
| 562 | * Element without loop and column |
| 563 | * The front-end output of this element is returned by the following function |
| 564 | * |
| 565 | * @param array $atts The array containing the parsed values from shortcode, it should be same as defined params above. |
| 566 | * @param string $shortcode_content The shorcode content |
| 567 | * @return string The output of element markup |
| 568 | */ |
| 569 | function auxin_widget_recent_posts_callback( $atts, $shortcode_content = null ){ |
| 570 | |
| 571 | global $aux_content_width; |
| 572 | |
| 573 | // Defining default attributes |
| 574 | $default_atts = array( |
| 575 | 'title' => '', // header title |
| 576 | 'cat' => '', |
| 577 | 'num' => '4', |
| 578 | 'exclude' => '', |
| 579 | 'include' => '', |
| 580 | 'include' => '', |
| 581 | 'offset' => '', |
| 582 | 'order_by' => 'date', |
| 583 | 'order' => 'desc', |
| 584 | 'exclude_without_media' => 0, |
| 585 | 'exclude_custom_post_formats' => 0, |
| 586 | 'exclude_qoute_link' => 0, |
| 587 | 'show_media' => true, |
| 588 | 'show_excerpt' => true, |
| 589 | 'excerpt_len' => '160', |
| 590 | 'show_title' => true, |
| 591 | 'show_info' => true, |
| 592 | 'show_readmore' => true, |
| 593 | 'show_author_footer' => false, |
| 594 | 'desktop_cnum' => 4, |
| 595 | 'tablet_cnum' => 'inherit', |
| 596 | 'phone_cnum' => 'inherit', |
| 597 | 'preview_mode' => 'grid', |
| 598 | 'tag' => '', |
| 599 | 'extra_classes' => '', |
| 600 | 'custom_el_id' => '', |
| 601 | 'carousel_space' => '30', |
| 602 | 'carousel_autoplay' => false, |
| 603 | 'carousel_autoplay_delay' => '2', |
| 604 | 'carousel_navigation' => 'peritem', |
| 605 | 'carousel_loop' => 1, |
| 606 | 'base_class' => 'aux-widget-recent-posts' |
| 607 | ); |
| 608 | |
| 609 | $result = auxin_get_widget_scafold( $atts, $default_atts, $shortcode_content ); |
| 610 | extract( $result['parsed_atts'] ); |
| 611 | |
| 612 | ob_start(); |
| 613 | |
| 614 | // create wp_query to get latest items ----------- |
| 615 | $args = array( |
| 616 | 'post_type' => 'post', |
| 617 | 'orderby' => $order_by, |
| 618 | 'order' => $order, |
| 619 | 'offset' => $offset, |
| 620 | 'cat' => $cat, |
| 621 | 'post__not_in' => array_filter( explode( ',', $exclude ) ), |
| 622 | 'post__in' => array_filter( explode( ',', $include ) ), |
| 623 | 'post_status' => 'publish', |
| 624 | 'posts_per_page' => -1, |
| 625 | 'ignore_sticky_posts' => 1 |
| 626 | ); |
| 627 | |
| 628 | $th_query = new WP_Query( $args ); |
| 629 | |
| 630 | |
| 631 | // widget header ------------------------------ |
| 632 | echo $result['widget_header']; |
| 633 | echo $result['widget_title']; |
| 634 | |
| 635 | |
| 636 | $phone_break_point = 767; |
| 637 | $tablet_break_point = 992; |
| 638 | |
| 639 | $show_comments = true; // shows comments icon |
| 640 | $post_counter = 0; |
| 641 | $column_class = ''; |
| 642 | $item_class = 'aux-col'; |
| 643 | $carousel_attrs = ''; |
| 644 | |
| 645 | if ( 'grid' == $preview_mode ) { |
| 646 | // generate columns class |
| 647 | $column_class = 'aux-match-height aux-row aux-de-col' . $desktop_cnum . ( 'inherit' != $tablet_cnum ? ' aux-tb-col'.$tablet_cnum : '' ) . ( 'inherit' != $phone_cnum ? ' aux-mb-col'.$phone_cnum : '' ); |
| 648 | } elseif ( 'carousel' == $preview_mode ) { |
| 649 | $column_class = 'master-carousel'; |
| 650 | $item_class = 'aux-mc-item'; |
| 651 | // genereate the master carousel attributes |
| 652 | $carousel_attrs = 'data-columns="' . $desktop_cnum . '"'; |
| 653 | $carousel_attrs .= ' data-autoplay="' . $carousel_autoplay . '"'; |
| 654 | $carousel_attrs .= ' data-delay="' . $carousel_autoplay_delay . '"'; |
| 655 | $carousel_attrs .= ' data-navigation="' . $carousel_navigation . '"'; |
| 656 | $carousel_attrs .= ' data-space="' . $carousel_space. '"'; |
| 657 | $carousel_attrs .= ' data-loop="' . $carousel_loop. '"'; |
| 658 | |
| 659 | if ( 'inherit' != $tablet_cnum || 'inherit' != $phone_cnum ) { |
| 660 | $carousel_attrs .= ' data-responsive="'. ( 'inherit' != $tablet_cnum ? $tablet_break_point . ':' . $tablet_cnum . ',' : '' ). |
| 661 | ( 'inherit' != $phone_cnum ? $phone_break_point . ':' . $phone_cnum : '' ) . '"'; |
| 662 | } |
| 663 | |
| 664 | } |
| 665 | |
| 666 | if( $th_query->have_posts() ){ |
| 667 | ?><div class="<?php echo $column_class ?>" <?php echo $carousel_attrs ?>> <?php |
| 668 | while ( $th_query->have_posts() ) { |
| 669 | |
| 670 | // break the loop if it is reached to the limit |
| 671 | if ( $post_counter < $num ) { |
| 672 | $post_counter ++; |
| 673 | } else { |
| 674 | break; |
| 675 | } |
| 676 | |
| 677 | $th_query->the_post(); |
| 678 | $post = $th_query->post; |
| 679 | $post_vars = auxin_get_post_format_media( $post , 'archive', $phone_break_point, true ); |
| 680 | extract( $post_vars ); |
| 681 | |
| 682 | $the_format = get_post_format($post); |
| 683 | |
| 684 | if ( |
| 685 | ( $exclude_custom_post_formats && !empty( $the_format ) ) || |
| 686 | ( $exclude_qoute_link && ( 'link' == $the_format || 'quote' == $the_format ) ) || |
| 687 | ( $exclude_without_media && !$has_attach ) |
| 688 | ) { |
| 689 | $post_counter --; |
| 690 | continue; |
| 691 | } |
| 692 | |
| 693 | ?> |
| 694 | <div class="<?php echo $item_class ?>"> |
| 695 | <?php include( locate_template( 'templates/theme-parts/entry/post-column.php' ) ); ?> |
| 696 | </div> |
| 697 | <?php |
| 698 | } |
| 699 | ?> </div> <?php |
| 700 | } |
| 701 | |
| 702 | wp_reset_query(); |
| 703 | |
| 704 | // widget footer ------------------------------ |
| 705 | echo $result['widget_footer']; |
| 706 | |
| 707 | return ob_get_clean(); |
| 708 | } |
| 709 |