about-widget.php
6 years ago
accordion-widget.php
6 years ago
accordion.php
6 years ago
attachment-url.php
6 years ago
audio.php
6 years ago
before-after.php
6 years ago
button.php
6 years ago
code.php
6 years ago
contact-box.php
6 years ago
contact-form.php
6 years ago
custom-list.php
6 years ago
divider.php
6 years ago
dropcap.php
6 years ago
facebook.php
6 years ago
flickr.php
6 years ago
gallery.php
6 years ago
general-element-fields.php
6 years ago
gmap.php
6 years ago
highlight.php
6 years ago
image.php
6 years ago
instagram-feed.php
6 years ago
latest-items.php
8 years ago
latest-posts-slider.php
6 years ago
popular-posts-widget.php
6 years ago
quote.php
6 years ago
recent-posts-grid-carousel.php
6 years ago
recent-posts-land-style.php
6 years ago
recent-posts-masonry.php
6 years ago
recent-posts-tiles-carousel.php
6 years ago
recent-posts-tiles.php
6 years ago
recent-posts-timeline.php
6 years ago
recent-posts-widget.php
6 years ago
recent-products.php
6 years ago
related-posts.php
8 years ago
sample-element.php
6 years ago
search.php
6 years ago
socials-list.php
6 years ago
staff.php
6 years ago
tab-widget.php
6 years ago
tabs.php
6 years ago
testimonial.php
6 years ago
text.php
6 years ago
touch-slider.php
6 years ago
video.php
6 years ago
recent-posts-widget.php
304 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-2020 averta |
| 11 | */ |
| 12 | |
| 13 | function auxin_get_recent_post_widget_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_post_widget'] = array( |
| 29 | 'name' => __('Recent Posts Widget', 'auxin-elements' ), |
| 30 | 'auxin_output_callback' => 'auxin_widget_recent_post_widget_callback', |
| 31 | 'base' => 'aux_recent_post_widget', |
| 32 | 'description' => __('Shows recent posts with thumbnail.', 'auxin-elements' ), |
| 33 | 'class' => 'aux-widget-recent-post-widget', |
| 34 | 'show_settings_on_create' => true, |
| 35 | 'weight' => 1, |
| 36 | 'is_widget' => true, |
| 37 | 'is_shortcode' => false, |
| 38 | 'is_so' => false, |
| 39 | 'is_vc' => false, |
| 40 | 'category' => THEME_NAME, |
| 41 | 'group' => '', |
| 42 | 'admin_enqueue_js' => '', |
| 43 | 'admin_enqueue_css' => '', |
| 44 | 'front_enqueue_js' => '', |
| 45 | 'front_enqueue_css' => '', |
| 46 | 'icon' => 'aux-element aux-pb-icons-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 | 'heading' => __('Title','auxin-elements' ), |
| 57 | 'description' => '', |
| 58 | 'param_name' => 'title', |
| 59 | 'type' => 'textfield', |
| 60 | 'std' => '', |
| 61 | 'value' => '', |
| 62 | 'holder' => 'textfield', |
| 63 | 'class' => 'title', |
| 64 | 'admin_label' => true, |
| 65 | 'dependency' => '', |
| 66 | 'weight' => '', |
| 67 | 'group' => '' , |
| 68 | 'edit_field_class' => '' |
| 69 | ), |
| 70 | array( |
| 71 | 'heading' => __('Number of posts to show', 'auxin-elements'), |
| 72 | 'description' => '', |
| 73 | 'param_name' => 'num', |
| 74 | 'type' => 'dropdown', |
| 75 | 'def_value' => '4', |
| 76 | 'holder' => '', |
| 77 | 'class' => 'num', |
| 78 | 'value' => array( |
| 79 | '1' => '1' , '2' => '2' , '3' => '3' , |
| 80 | '4' => '4' , '5' => '5' , '6' => '6', |
| 81 | '7' => '7' , '8' => '8' , '9' => '9' , |
| 82 | '10' => '10','11' => '11' ,'12' => '12' |
| 83 | ), |
| 84 | 'admin_label' => true, |
| 85 | 'dependency' => '', |
| 86 | 'weight' => '', |
| 87 | 'group' => '' , |
| 88 | 'edit_field_class' => '' |
| 89 | ), |
| 90 | array( |
| 91 | 'heading' => __('Display image', 'auxin-elements' ), |
| 92 | 'description' => __('Enable it to display images as well.','auxin-elements' ), |
| 93 | 'param_name' => 'show_media', |
| 94 | 'type' => 'aux_switch', |
| 95 | 'def_value' => '', |
| 96 | 'value' => '1', |
| 97 | 'holder' => '', |
| 98 | 'class' => 'show_media', |
| 99 | 'admin_label' => true, |
| 100 | 'dependency' => '', |
| 101 | 'weight' => '', |
| 102 | 'group' => '' , |
| 103 | 'edit_field_class' => '' |
| 104 | ), |
| 105 | array( |
| 106 | 'heading' => __('Display excerpt','auxin-elements' ), |
| 107 | 'description' => __('Enable it to display post summary instead of full content.','auxin-elements' ), |
| 108 | 'param_name' => 'show_excerpt', |
| 109 | 'type' => 'aux_switch', |
| 110 | 'def_value' => '', |
| 111 | 'value' => '1', |
| 112 | 'holder' => '', |
| 113 | 'class' => 'show_excerpt', |
| 114 | 'admin_label' => 1, |
| 115 | 'dependency' => '', |
| 116 | 'weight' => '', |
| 117 | 'group' => '' , |
| 118 | 'edit_field_class' => '' |
| 119 | ), |
| 120 | array( |
| 121 | 'heading' => __('Display post date','auxin-elements' ), |
| 122 | 'param_name' => 'show_date', |
| 123 | 'type' => 'aux_switch', |
| 124 | 'def_value' => '', |
| 125 | 'value' => '1', |
| 126 | 'holder' => '', |
| 127 | 'class' => 'show_date', |
| 128 | 'admin_label' => 1, |
| 129 | 'dependency' => '', |
| 130 | 'weight' => '', |
| 131 | 'group' => '' , |
| 132 | 'edit_field_class' => '' |
| 133 | ), |
| 134 | array( |
| 135 | 'heading' => __('Excerpt length','auxin-elements' ), |
| 136 | 'description' => __('Specify summary content in character','auxin-elements' ), |
| 137 | 'param_name' => 'excerpt_len', |
| 138 | 'type' => 'textfield', |
| 139 | 'value' => '60', |
| 140 | 'holder' => 'textfield', |
| 141 | 'class' => 'excerpt_len', |
| 142 | 'admin_label' => 1, |
| 143 | 'dependency' => '', |
| 144 | 'weight' => '', |
| 145 | 'group' => '' , |
| 146 | 'edit_field_class' => '' |
| 147 | ), |
| 148 | array( |
| 149 | 'heading' => __('Order by', 'auxin-elements'), |
| 150 | 'description' => '', |
| 151 | 'param_name' => 'order_by', |
| 152 | 'type' => 'dropdown', |
| 153 | 'def_value' => 'date', |
| 154 | 'holder' => 'dropdown', |
| 155 | 'class' => 'order_by', |
| 156 | 'value' => array ( |
| 157 | 'date' => __('Date', 'auxin-elements'), |
| 158 | 'menu_order date' => __('Menu Order', 'auxin-elements'), |
| 159 | 'title' => __('Title', 'auxin-elements'), |
| 160 | 'ID' => __('ID', 'auxin-elements'), |
| 161 | 'rand' => __('Random', 'auxin-elements'), |
| 162 | 'comment_count' => __('Comments', 'auxin-elements'), |
| 163 | 'modified' => __('Date Modified', 'auxin-elements'), |
| 164 | 'author' => __('Author', 'auxin-elements'), |
| 165 | ), |
| 166 | 'admin_label' => true, |
| 167 | 'dependency' => '', |
| 168 | 'weight' => '', |
| 169 | 'group' => '' , |
| 170 | 'edit_field_class' => '' |
| 171 | ), |
| 172 | array( |
| 173 | 'heading' => __('Order', 'auxin-elements'), |
| 174 | 'description' => '', |
| 175 | 'param_name' => 'order', |
| 176 | 'type' => 'dropdown', |
| 177 | 'def_value' => 'DESC', |
| 178 | 'holder' => 'dropdown', |
| 179 | 'class' => 'order', |
| 180 | 'value' =>array ( |
| 181 | 'DESC' => __('Descending', 'auxin-elements'), |
| 182 | 'ASC' => __('Ascending', 'auxin-elements'), |
| 183 | ), |
| 184 | 'admin_label' => true, |
| 185 | 'dependency' => '', |
| 186 | 'weight' => '', |
| 187 | 'group' => '' , |
| 188 | 'edit_field_class' => '' |
| 189 | ), |
| 190 | array( |
| 191 | 'heading' => __('Categories', 'auxin-elements'), |
| 192 | 'description' => __('Specifies a category that you want to show posts from it.', 'auxin-elements' ), |
| 193 | 'param_name' => 'cat', |
| 194 | 'type' => 'dropdown', |
| 195 | 'def_value' => 'default', |
| 196 | 'holder' => 'dropdown', |
| 197 | 'class' => 'cat', |
| 198 | 'value' => $categories_list, |
| 199 | 'admin_label' => true, |
| 200 | 'dependency' => '', |
| 201 | 'weight' => '', |
| 202 | 'group' => '' , |
| 203 | 'edit_field_class' => '' |
| 204 | ), |
| 205 | // array( |
| 206 | // 'param_name' => 'tag', |
| 207 | // 'type' => 'dropdown', |
| 208 | // 'def_value' => '', |
| 209 | // 'holder' => '', |
| 210 | // 'class' => 'tag', |
| 211 | // 'heading' => __('Tags', 'auxin-elements'), |
| 212 | // 'description' => __('specify a tags that you want.', 'auxin-elements' ), |
| 213 | // 'value' => $tags_list, |
| 214 | // 'admin_label' => true, |
| 215 | // 'dependency' => '', |
| 216 | // 'weight' => '', |
| 217 | // 'group' => '' , |
| 218 | // 'edit_field_class' => '' |
| 219 | // ), |
| 220 | array( |
| 221 | 'heading' => __('Extra class name','auxin-elements' ), |
| 222 | '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' ), |
| 223 | 'param_name' => 'extra_classes', |
| 224 | 'type' => 'textfield', |
| 225 | 'value' => '', |
| 226 | 'def_value' => '', |
| 227 | 'holder' => 'textfield', |
| 228 | 'class' => 'extra_classes', |
| 229 | 'admin_label' => true, |
| 230 | 'dependency' => '', |
| 231 | 'weight' => '', |
| 232 | 'group' => '', |
| 233 | 'edit_field_class' => '' |
| 234 | ) |
| 235 | ) |
| 236 | ); |
| 237 | |
| 238 | return $master_array; |
| 239 | } |
| 240 | |
| 241 | add_filter( 'auxin_master_array_shortcodes', 'auxin_get_recent_post_widget_master_array', 10, 1 ); |
| 242 | |
| 243 | |
| 244 | |
| 245 | |
| 246 | /** |
| 247 | * Element without loop and column |
| 248 | * The front-end output of this element is returned by the following function |
| 249 | * |
| 250 | * @param array $atts The array containing the parsed values from shortcode, it should be same as defined params above. |
| 251 | * @param string $shortcode_content The shorcode content |
| 252 | * @return string The output of element markup |
| 253 | */ |
| 254 | function auxin_widget_recent_post_widget_callback( $atts, $shortcode_content = null ){ |
| 255 | |
| 256 | // Defining default attributes |
| 257 | $default_atts = array( |
| 258 | 'title' => '', // header title |
| 259 | 'num' => '4', |
| 260 | 'show_media' => 1, |
| 261 | 'show_excerpt' => 1, |
| 262 | 'show_date' => 1, |
| 263 | 'excerpt_len' => '60', |
| 264 | 'order' => 'desc', |
| 265 | 'order_by' => 'date', |
| 266 | 'cat' => '', |
| 267 | 'tag' => '', |
| 268 | 'extra_classes' => '', |
| 269 | 'custom_el_id' => '', |
| 270 | 'base_class' => 'aux-widget-recent-post-widget' |
| 271 | ); |
| 272 | |
| 273 | // the parsed widget params |
| 274 | $result = auxin_get_widget_scafold( $atts, $default_atts, $shortcode_content ); |
| 275 | $output = ''; |
| 276 | |
| 277 | // create wp_query to get latest items ----------- |
| 278 | $recent_args = array( |
| 279 | 'post_type' => 'post', |
| 280 | 'orderby' => $result['parsed_atts']['order_by'], |
| 281 | 'order' => $result['parsed_atts']['order'], |
| 282 | 'post_status' => 'publish', |
| 283 | 'posts_per_page' => $result['parsed_atts']['num'], |
| 284 | 'cat' => $result['parsed_atts']['cat'], |
| 285 | // 'tag_id' => $tag, |
| 286 | 'ignore_sticky_posts' => 1 |
| 287 | ); |
| 288 | |
| 289 | // @TODO |
| 290 | $result['parsed_atts']['show_format'] = false; |
| 291 | |
| 292 | // widget header ------------------------------ |
| 293 | |
| 294 | $output .= $result['widget_header']; |
| 295 | $output .= $result['widget_title']; |
| 296 | |
| 297 | $output .= auxin_get_post_type_markup( $recent_args, 'templates/theme-parts/entry/widget-recent-post.php', $result['parsed_atts'] ); |
| 298 | |
| 299 | // widget footer ------------------------------ |
| 300 | $output .= $result['widget_footer']; |
| 301 | |
| 302 | return $output; |
| 303 | } |
| 304 |