classes
6 months ago
compatibility
11 months ago
elementor
6 months ago
elements
6 months ago
define.php
6 months ago
general-functions.php
11 months ago
general-hooks.php
1 year ago
general-shortcodes.php
2 years ago
index.php
3 years ago
general-shortcodes.php
415 lines
| 1 | <?php |
| 2 | |
| 3 | /*-----------------------------------------------------------------------------------*/ |
| 4 | /* Latest from Blog |
| 5 | /*-----------------------------------------------------------------------------------*/ |
| 6 | |
| 7 | add_shortcode( 'aux_timeline' , 'auxin_shortcode_timeline' ); |
| 8 | |
| 9 | function auxin_shortcode_timeline( $atts, $content = null ) { |
| 10 | |
| 11 | // extract attrs to vars |
| 12 | extract( shortcode_atts( |
| 13 | array( |
| 14 | 'size' => 100, // section size |
| 15 | 'title' => '', // widget header title |
| 16 | 'col' => '33', // one .. six-column |
| 17 | 'view_more' => 'yes', |
| 18 | 'more_label' => 'view all', |
| 19 | 'num' => 5, // fetch num |
| 20 | 'excerpt_len' => '120', |
| 21 | 'cat_id' => '', // cat id to display. '' gets all cats |
| 22 | 'view_thumb' => 'yes', // display thumbnail or not |
| 23 | 'thumb_mode' => 'left', // 'top': normal thumb on top , 'left': normal thumb on left, 'icon': icon size thumb |
| 24 | 'date_type' => 'big', |
| 25 | 'orderby' => '', |
| 26 | 'order' => '', |
| 27 | 'layout' => 'center' |
| 28 | ) |
| 29 | , $atts, 'aux_timeline' ) |
| 30 | ); |
| 31 | |
| 32 | // sanitize sql order and orderby |
| 33 | $orderby = $orderby ? sanitize_sql_orderby( $orderby ) : 'date'; |
| 34 | $order = $order ? auxin_sanitize_sql_order( $order ) : 'DESC'; |
| 35 | |
| 36 | // validate number fetched items |
| 37 | $num = is_numeric( $num ) ? $num : -1; |
| 38 | |
| 39 | // get thumbnail diemntion -------------------------------------- |
| 40 | $vimeo_height = 273; |
| 41 | |
| 42 | // chane thumbnail size to 60x60 if it is mini mode |
| 43 | if($thumb_mode == "mini") { |
| 44 | $dimentions[0] = 60; |
| 45 | $dimentions[1] = 60; |
| 46 | }else{ |
| 47 | // actual col size |
| 48 | // get number of grid column |
| 49 | $wrapper_size = empty($size)?100:$size; |
| 50 | $col_actual = ($wrapper_size / 100) * (int)$col; |
| 51 | $col_num = floor(100 / $col_actual); |
| 52 | $col_num = $col_num > 4?4:$col_num; // max column num is 4 |
| 53 | // get thumbnsil size name |
| 54 | $image_size_name = "i".$col_num; |
| 55 | |
| 56 | // get suite thumb size |
| 57 | $thumb_size = $image_size_name; |
| 58 | $dimentions = auxin_get_image_size( $thumb_size.'_1' ); |
| 59 | |
| 60 | // the left mode is half size of top mode, so for making image retina |
| 61 | // bigger size is not needed |
| 62 | if($thumb_mode == "top"){ |
| 63 | // retinafy thumbnail |
| 64 | $dimentions[0] = 1.5 * $dimentions[0]; |
| 65 | $dimentions[1] = 1.5 * ($dimentions[1] - 10); |
| 66 | |
| 67 | }else{ // if the image is on left |
| 68 | $dimentions[1] -= 10; |
| 69 | } |
| 70 | |
| 71 | } |
| 72 | |
| 73 | |
| 74 | // just view custom taxonomies if tax id is set ---------------- |
| 75 | $tax_args = array('taxonomy' => 'category', 'terms' => $cat_id ); |
| 76 | if(empty($cat_id) || $cat_id == "all" ) $tax_args = ""; |
| 77 | |
| 78 | // create wp_query to get latest items |
| 79 | $args = array( |
| 80 | 'post_type' => 'post', |
| 81 | 'orderby' => $orderby, |
| 82 | 'order' => $order, |
| 83 | 'post_status' => 'publish', |
| 84 | 'posts_per_page' => $num, |
| 85 | 'ignore_sticky_posts'=> 1, |
| 86 | 'tax_query' => array($tax_args) |
| 87 | ); |
| 88 | |
| 89 | $th_query = null; |
| 90 | $th_query = new WP_Query($args); |
| 91 | |
| 92 | |
| 93 | |
| 94 | ob_start(); |
| 95 | ?> |
| 96 | |
| 97 | <section class="widget-blog widget-container widget-timeline" > |
| 98 | |
| 99 | <?php |
| 100 | |
| 101 | if( ! empty($title) ) |
| 102 | echo auxin_kses( get_widget_title( $title ) ); ?> |
| 103 | |
| 104 | |
| 105 | <div class="widget-inner"> |
| 106 | <div class="aux-timeline aux-<?php echo esc_attr( $layout ); ?>" data-layout="<?php echo esc_attr( $layout ); ?>" > |
| 107 | |
| 108 | <?php if( $th_query->have_posts() ): while ($th_query->have_posts()) : $th_query->the_post(); ?> |
| 109 | |
| 110 | |
| 111 | |
| 112 | |
| 113 | <?php |
| 114 | $post_format = get_post_format($th_query->post->ID); |
| 115 | $has_attach = FALSE; |
| 116 | $the_attach = ""; |
| 117 | $show_title = true; |
| 118 | |
| 119 | switch ($post_format) { |
| 120 | case 'aside': |
| 121 | |
| 122 | break; |
| 123 | case 'gallery': |
| 124 | |
| 125 | // if the mode is not mini size |
| 126 | if($thumb_mode != "mini") { |
| 127 | // if post has featured image, use featured image instead of gallery images |
| 128 | $has_attach = has_post_thumbnail($th_query->post->ID); |
| 129 | if($has_attach) { |
| 130 | $the_attach = auxin_get_the_post_thumbnail($th_query->post->ID, $dimentions[0], $dimentions[1], true, 75); |
| 131 | |
| 132 | $the_media = '<div class="imgHolder">'. |
| 133 | '<a href="'.auxin_get_the_attachment_url($th_query->post->ID, "full").'" data-rel="prettyPhoto">'. |
| 134 | $the_attach. |
| 135 | '</a>'. |
| 136 | '</div>'; |
| 137 | |
| 138 | // display gallery images as slider if featured image is not set |
| 139 | } else { |
| 140 | |
| 141 | $slider = '[flexslider slideshow="no" effect="slide" nav_type="none" easing="easeInOutQuad" ]'; |
| 142 | $has_attach = false; |
| 143 | |
| 144 | for ($i=1; $i <= 5; $i++) { |
| 145 | $img_url = get_post_meta($th_query->post->ID, "axi_gallery_image".$i, true); |
| 146 | if(!empty($img_url) ){ |
| 147 | $has_attach = true; |
| 148 | $img_url = auxin_get_the_absolute_image_url($img_url); |
| 149 | $slider .= '[simple_slide src="'.auxin_get_the_resized_image_src($img_url, $dimentions[0], $dimentions[1], true, 75 ).'" ]'; |
| 150 | } |
| 151 | } |
| 152 | |
| 153 | $slider .= '[/flexslider]'; |
| 154 | if(!$has_attach) break; |
| 155 | |
| 156 | $the_media = do_shortcode($slider); |
| 157 | } |
| 158 | |
| 159 | break; |
| 160 | |
| 161 | // if thumb mode is mini, just echo small image intead of slider |
| 162 | }else { |
| 163 | $has_attach = has_post_thumbnail($th_query->post->ID); |
| 164 | // if post has featured image, use featured image instead of gallery image |
| 165 | if( $has_attach ) { |
| 166 | $the_attach = auxin_get_the_post_thumbnail_src($th_query->post->ID, $dimentions[0], $dimentions[1], true, 75); |
| 167 | |
| 168 | // display first gallery image as slider if featured image is not set |
| 169 | }else { |
| 170 | $the_attach = get_post_meta($th_query->post->ID, "axi_gallery_image1", true); |
| 171 | $has_attach = !empty($the_attach); |
| 172 | if(!$has_attach) break; |
| 173 | $the_attach = auxin_get_the_absolute_image_url($the_attach); |
| 174 | } |
| 175 | |
| 176 | $the_media = '<div class="imgHolder">'. |
| 177 | '<a href="'.get_permalink().'" >'. |
| 178 | '<img src="'.$the_attach.'" alt="" />'. |
| 179 | '</a>'. |
| 180 | '</div>'; |
| 181 | break; |
| 182 | } |
| 183 | |
| 184 | break; |
| 185 | case 'image': |
| 186 | $has_attach = has_post_thumbnail(); |
| 187 | if(!$has_attach) break; |
| 188 | $the_attach = auxin_get_the_post_thumbnail($th_query->post->ID, $dimentions[0], $dimentions[1], true, 75); |
| 189 | |
| 190 | $the_media = '<div class="imgHolder">'. |
| 191 | '<a href="'.auxin_get_the_attachment_url($th_query->post->ID, "full").'" data-rel="prettyPhoto">'. |
| 192 | $the_attach. |
| 193 | '</a>'. |
| 194 | '</div>'; |
| 195 | break; |
| 196 | |
| 197 | case 'link': |
| 198 | $the_link = get_post_meta($th_query->post->ID, "the_link", true); |
| 199 | $show_title = TRUE; |
| 200 | $has_attach = false; |
| 201 | if(!$has_attach) break; |
| 202 | break; |
| 203 | |
| 204 | case 'video': |
| 205 | $video_link = get_post_meta($th_query->post->ID, "youtube", true); |
| 206 | $mp4 = get_post_meta($th_query->post->ID, "mp4" , true); |
| 207 | $ogg = get_post_meta($th_query->post->ID, "ogg" , true); |
| 208 | $webm = get_post_meta($th_query->post->ID, "webm", true); |
| 209 | $flv = get_post_meta($th_query->post->ID, "flv" , true); |
| 210 | $poster = get_post_meta($th_query->post->ID, "poster", true); |
| 211 | $skin = get_post_meta($th_query->post->ID, "skin" , true); |
| 212 | |
| 213 | // if it is mini size just display a thumbnail |
| 214 | if($thumb_mode == "mini") { |
| 215 | if(has_post_thumbnail()){ |
| 216 | $the_attach = auxin_get_the_post_thumbnail($th_query->post->ID, $dimentions[0], $dimentions[1], true, 75); |
| 217 | $the_media = '<div class="imgHolder">'. |
| 218 | '<a href="'.get_permalink().'">'. |
| 219 | $the_attach. |
| 220 | '</a>'. |
| 221 | '</div>'; |
| 222 | } |
| 223 | break; |
| 224 | } |
| 225 | |
| 226 | // if the feature image is set, display feature image instead |
| 227 | $has_attach = has_post_thumbnail(); |
| 228 | if($has_attach) { |
| 229 | $the_attach = auxin_get_the_post_thumbnail($th_query->post->ID, $dimentions[0], $dimentions[1], true, 75); |
| 230 | |
| 231 | $the_media = '<div class="imgHolder">'. |
| 232 | '<a href="'.get_permalink().'" >'. |
| 233 | $the_attach. |
| 234 | '</a>'. |
| 235 | '</div>'; |
| 236 | break; |
| 237 | } |
| 238 | |
| 239 | $has_attach = (!empty($video_link) || !empty($mp4) || !empty($ogg) || !empty($webm) || !empty($flv)); |
| 240 | if(!$has_attach) break; |
| 241 | |
| 242 | $the_attach = do_shortcode('[video_element fit="yes" height="'.$vimeo_height.'" url="'.$video_link.'" mp4="'.$mp4.'" ogg="'.$ogg.'" webm="'.$webm.'" flv="'.$flv.'" poster="'.$poster.'" skin="'.$skin.'" uid="axi_vid'.$th_query->post->ID.'" size="0" ]'); |
| 243 | |
| 244 | $the_media = $the_attach; |
| 245 | echo '<style type="text/css"> div.jp-video div.jp-jplayer { min-height: '.(($dimentions[1]/2)-75).'px; }</style>'; |
| 246 | unset($video_link, $mp4,$ogg,$webm,$flv,$poster); |
| 247 | break; |
| 248 | |
| 249 | case 'audio': |
| 250 | $mp3 = get_post_meta($th_query->post->ID, "mp3" , true); |
| 251 | $oga = get_post_meta($th_query->post->ID, "oga" , true); |
| 252 | $skin = get_post_meta($th_query->post->ID, "audio_skin" , true); |
| 253 | $soundcloud = get_post_meta($th_query->post->ID, "soundcloud" , true); |
| 254 | |
| 255 | if($thumb_mode == "mini") { |
| 256 | if(has_post_thumbnail()){ |
| 257 | $the_attach = auxin_get_the_post_thumbnail($th_query->post->ID, $dimentions[0], $dimentions[1], true, 75); |
| 258 | $the_media = '<div class="imgHolder">'. |
| 259 | '<a href="'.get_permalink().'">'. |
| 260 | $the_attach. |
| 261 | '</a>'. |
| 262 | '</div>'; |
| 263 | } |
| 264 | break; |
| 265 | } |
| 266 | |
| 267 | $has_attach = (!empty($mp3) || !empty($oga) || !empty($soundcloud)); |
| 268 | if(!$has_attach) break; |
| 269 | if(!empty($mp3) || !empty($oga)) |
| 270 | $the_attach = do_shortcode('[audio mp3="'.$mp3.'" ogg="'.$oga.'" skin="'.$skin.'" uid="axi_au'.$th_query->post->ID.'" size="0" ]'); |
| 271 | else |
| 272 | $the_attach = do_shortcode($soundcloud); |
| 273 | $the_media = $the_attach; |
| 274 | unset($mp3,$oga,$skin, $soundcloud); |
| 275 | break; |
| 276 | |
| 277 | |
| 278 | case 'quote': |
| 279 | $quote = get_the_excerpt(); |
| 280 | $author = get_post_meta($th_query->post->ID, "the_author", true); |
| 281 | $show_title = false; |
| 282 | $has_attach = false; |
| 283 | $quote = auxin_get_trimmed_string($quote,$excerpt_len, " ..."); |
| 284 | $quote .= "<br/>- <cite>".$author."</cite>"; |
| 285 | $the_attach = do_shortcode('[blockquote size="0" indent="no" ]'.$quote.'[/blockquote]'); |
| 286 | unset($quote); |
| 287 | break; |
| 288 | |
| 289 | default: |
| 290 | $has_attach = has_post_thumbnail(); |
| 291 | if(!$has_attach) { |
| 292 | $the_attach = auxin_get_first_image_from_string(get_the_content()); |
| 293 | $has_attach = !empty($the_attach); |
| 294 | }else { |
| 295 | $the_attach = auxin_get_the_post_thumbnail($th_query->post->ID, $dimentions[0], $dimentions[1], true, 75); |
| 296 | } |
| 297 | |
| 298 | if(!$has_attach) break; |
| 299 | |
| 300 | $the_media = '<div class="imgHolder">'. |
| 301 | '<a href="'.get_permalink().'">'. |
| 302 | $the_attach. |
| 303 | '</a>'. |
| 304 | '</div>'; |
| 305 | break; |
| 306 | } |
| 307 | |
| 308 | ?> |
| 309 | |
| 310 | <article class="aux-block <?php echo "date-type-". esc_attr( $date_type ) ." "; echo ($thumb_mode != "top")? esc_attr( $thumb_mode ) : "thumb_top" ; ?>"> |
| 311 | <figure> |
| 312 | <?php if ( $has_attach && ($view_thumb == "yes") ) { |
| 313 | echo wp_kses_post( $the_media ); |
| 314 | } ?> |
| 315 | |
| 316 | |
| 317 | <figcaption> |
| 318 | <div class="entry-header"> |
| 319 | <h4 class="entry-title"><a href="<?php the_permalink(); ?>"><?php echo auxin_kses( get_the_title() ); ?></a></h4> |
| 320 | <div class="entry-format"> |
| 321 | <a href="<?php the_permalink(); ?>" class="post-format format-<?php echo get_post_format(); ?>"> </a> |
| 322 | <?php if($date_type == "big") { ?> |
| 323 | <div class="cell-date"> |
| 324 | <em> </em><em> </em> |
| 325 | <time datetime="<?php echo get_the_date( DATE_W3C ); ?>" title="<?php echo get_the_date( DATE_W3C ); ?>" > |
| 326 | <strong><?php the_time('d')?></strong> |
| 327 | <span><?php the_time('M')?></span> |
| 328 | </time> |
| 329 | </div> |
| 330 | <?php } ?> |
| 331 | </div> |
| 332 | </div> |
| 333 | |
| 334 | <div class="entry-content"> |
| 335 | <?php if($date_type == "inline" && $post_format != "quote") { ?> |
| 336 | <time datetime="<?php echo get_the_date( DATE_W3C ); ?>" title="<?php echo get_the_date( DATE_W3C ); ?>" ><?php the_date(); ?></time> |
| 337 | <?php } ?> |
| 338 | |
| 339 | <?php if($post_format == "quote") { |
| 340 | echo wp_kses_post( $the_attach ); |
| 341 | } elseif($excerpt_len > 0) { ?> |
| 342 | <p><?php auxin_the_trimmed_string( auxin_kses( get_the_excerpt() ),$excerpt_len); ?></p> |
| 343 | <?php } ?> |
| 344 | </div> |
| 345 | </figcaption> |
| 346 | </figure> |
| 347 | </article><!-- end-timeline-block --> |
| 348 | |
| 349 | <?php endwhile; endif; |
| 350 | wp_reset_query(); |
| 351 | ?> |
| 352 | </div><!-- end-timeline-wrapper --> |
| 353 | </div><!-- widget-inner --> |
| 354 | |
| 355 | <?php if($view_more == "yes" ) { |
| 356 | $view_all_link = esc_url( auxin_get_option( 'blog_view_all_btn_link', home_url() ) ); |
| 357 | ?> |
| 358 | <a href="<?php echo esc_url( $view_all_link ); ?>" class="more right" ><?php echo auxin_kses( $more_label ); ?></a> |
| 359 | <?php } unset( $view_all_link ); ?> |
| 360 | |
| 361 | </section><!-- widget-blog --> |
| 362 | |
| 363 | <?php |
| 364 | return ob_get_clean(); |
| 365 | } |
| 366 | |
| 367 | |
| 368 | /** |
| 369 | * Adds aux_row shortcode for adding row for columns |
| 370 | */ |
| 371 | function auxin_aux_row_shortcode( $atts , $content = null ) { |
| 372 | |
| 373 | if( empty( $atts['tablet-columns'] ) && ! empty( $atts['columns'] ) ){ |
| 374 | $atts['tablet-columns'] = ceil( (int)$atts['columns'] / 2 ); |
| 375 | } |
| 376 | |
| 377 | // parse attributes |
| 378 | $parsed_atts = shortcode_atts( |
| 379 | array( |
| 380 | 'columns' => 3, |
| 381 | 'tablet-columns' => '', |
| 382 | 'mobile-columns' => 1 |
| 383 | ), |
| 384 | $atts, |
| 385 | 'aux_row' |
| 386 | ); |
| 387 | |
| 388 | // collect custom layout css classes |
| 389 | $classes = ''; |
| 390 | |
| 391 | if( $parsed_atts['columns'] ){ |
| 392 | $classes .= esc_attr( 'aux-col' . $parsed_atts['columns'] ) . ' '; |
| 393 | } |
| 394 | if( $parsed_atts['tablet-columns'] ){ |
| 395 | $classes .= esc_attr( 'aux-tb-col' . $parsed_atts['tablet-columns'] ) . ' '; |
| 396 | } |
| 397 | if( $parsed_atts['mobile-columns'] ){ |
| 398 | $classes .= esc_attr( 'aux-mb-col' . $parsed_atts['mobile-columns'] ) . ' '; |
| 399 | } |
| 400 | |
| 401 | // Return code |
| 402 | return '<div class="aux-row '. trim( $classes ) .'">'. do_shortcode( $content ) .'</div>'; |
| 403 | } |
| 404 | add_shortcode( 'aux_row', 'auxin_aux_row_shortcode' ); |
| 405 | |
| 406 | |
| 407 | /** |
| 408 | * Adds aux_col shortcode for adding simple column shortcode for layout purposes |
| 409 | */ |
| 410 | function auxin_aux_col_shortcode( $atts , $content = null ) { |
| 411 | // Return code |
| 412 | return '<div class="aux-col">'. do_shortcode( $content ) .'</div>'; |
| 413 | } |
| 414 | add_shortcode( 'aux_col', 'auxin_aux_col_shortcode' ); |
| 415 |