archives_shortcode

The Jetpack by WordPress.com archives shortcode function.

Description

archives_shortcode( $attr ); 

Parameters (1)

0. $attr
The attr.

Usage

  1. if ( !function_exists( 'archives_shortcode' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'jetpack-by-wordpress-com/modules/shortcodes/archives.php'; 
  3.  
  4. // The attr. 
  5. $attr = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = archives_shortcode($attr); 
  9.  

Defined (1)

The function is defined in the following location(s).

/modules/shortcodes/archives.php  
  1. function archives_shortcode( $attr ) { 
  2. if ( is_feed() ) 
  3. return '[archives]'; 
  4.  
  5. global $allowedposttags; 
  6.  
  7. $default_atts = array( 
  8. 'type' => 'postbypost',  
  9. 'limit' => '',  
  10. 'format' => 'html',  
  11. 'showcount' => false,  
  12. 'before' => '',  
  13. 'after' => '',  
  14. 'order' => 'desc',  
  15. ); 
  16. extract( shortcode_atts( $default_atts, $attr, 'archives' ) ); 
  17.  
  18. if ( ! in_array( $type, array( 'yearly', 'monthly', 'daily', 'weekly', 'postbypost' ) ) ) 
  19. $type = 'postbypost'; 
  20.  
  21. if ( ! in_array( $format, array( 'html', 'option', 'custom' ) ) ) 
  22. $format = 'html'; 
  23.  
  24. if ( '' != $limit ) { 
  25. $limit = (int) $limit; 
  26. // A Limit of 0 makes no sense so revert back to the default. 
  27. if ( 0 == $limit ) { 
  28. $limit = ''; 
  29.  
  30.  
  31. $showcount = (bool) $showcount; 
  32. $before = wp_kses( $before, $allowedposttags ); 
  33. $after = wp_kses( $after, $allowedposttags ); 
  34.  
  35. // Get the archives 
  36. $archives = wp_get_archives( array( 
  37. 'type' => $type,  
  38. 'limit' => $limit,  
  39. 'format' => $format,  
  40. 'echo' => false,  
  41. 'show_post_count' => $showcount,  
  42. 'before' => $before,  
  43. 'after' => $after 
  44. ) ); 
  45.  
  46. if ( 'asc' == $order ) 
  47. $archives = implode( "\n", array_reverse( explode( "\n", $archives ) ) ); 
  48.  
  49.  
  50. // Check to see if there are any archives 
  51. if ( empty( $archives ) ) 
  52. $archives = '<p>' . __( 'Your blog does not currently have any published posts.' , jetpack ) . '</p>'; 
  53. elseif ( 'option' == $format ) 
  54. $archives = "<select name='archive-dropdown' onchange='document.location.href=this.options[this.selectedIndex].value;'><option value='" . get_permalink() . "'>--</option>" . $archives . "</select>"; 
  55. elseif ( 'html' == $format ) 
  56. $archives = '<ul>' . $archives . '</ul>'; 
  57.  
  58. return $archives;