/** * Widget * * @return void * @since 1.0 */ function widget($args, $instance) { if (false == ($cache = get_transient('edd_widgets_archives'))) { // get the title and apply filters $title = apply_filters('widget_title', $instance['title'] ? $instance['title'] : ''); // get show count boolean $show_count = isset($instance['show_count']) && $instance['show_count'] === 1 ? 1 : 0; // start collecting the output $out = ""; // check if there is a title if ($title) { // add the title to the ouput $out .= $args['before_title'] . $title . $args['after_title']; } $out .= "<ul>\n"; // add download post type to archives add_filter('getarchives_where', array(&$this, 'getarchives_where_filter'), 10, 2); add_filter('month_link', array($this, 'month_link'), 10, 3); // output the archives $out .= wp_get_archives(array('echo' => 0, 'show_post_count' => $show_count)); // remove filter remove_filter('getarchives_where', array(&$this, 'getarchives_where_filter'), 10, 2); remove_filter('month_link', array($this, 'month_link'), 10, 3); // finish the list $out .= "</ul>\n"; // set the widget's containers $cache = $args['before_widget'] . $out . $args['after_widget']; // store the result on a temporal transient set_transient('edd_widgets_archives', $cache); } echo $cache; }
function Grafik_Functions_Shortcode_TypeArchives($atts, $content = '') { global $wp_query; global $GRAFIK_MODE; $callback_output = ''; $a = shortcode_atts(array('type' => 'post', 'format' => 'links', 'class' => '', 'id' => ''), $atts, 'TypeArchives'); // Construct the query... $callback_query = new WP_Query(array('post_type' => $a['type'], 'posts_per_page' => -1)); // Loop the query... preg_match_all("/<li><a[\\s]*href=[\"']([^\"']*)[\"'][^>]*>([^<]*)<\\/a>[^\\(]*\\(([^\\)]*)\\)<\\/li>/i", wp_get_archives(array('post_type' => $a['type'], 'type' => 'monthly', 'show_post_count' => true, 'echo' => 0)), $callback_archives); // Restructure the array... $callback_restructured = array(); foreach ($callback_archives as $key => $val) { foreach ($val as $val_key => $val_val) { $callback_restructured[$val_key][$key] = $val_val; } } $callback_archives = $callback_restructured; // Loop the results... foreach ($callback_archives as $key => $val) { $callback_output .= '<li class="ge-typearchives-item">' . '<a href="' . esc_url($val[1]) . '" class="ge-typearchives-link">' . '<span class="ge-typearchives-name">' . $val[2] . '</span>' . '<span class="ge-typearchives-count">' . $val[3] . '</span>' . '</a>' . '</li>'; } if (empty($callback_output)) { return ''; } return '<div class="ge-typearchives-container' . (empty($a['class']) ? null : ' ' . $a['class']) . '"' . (empty($a['id']) ? null : ' id="' . $a['id'] . '"') . '>' . '<div class="ge-typearchives-content">' . $content . '</div>' . '<ul class="ge-typearchives-list' . ($a['format'] == 'dropdown' ? 'dropdown' : '') . '">' . $callback_output . '</ul>' . '</div>'; }
function widget($args, $instance) { $before_widget = $before_title = $after_title = $after_widget = ''; extract($args); $c = !empty($instance['count']) ? '1' : '0'; $d = !empty($instance['dropdown']) ? '1' : '0'; $title = apply_filters('widget_title', empty($instance['title']) ? __('Archives', 'zn_framework') : $instance['title'], $instance, $this->id_base); echo $before_widget; if ($title) { echo $before_title . $title . $after_title; } if ($d) { ?> <select name="archive-dropdown" onchange='document.location.href=this.options[this.selectedIndex].value;'> <option value=""><?php echo esc_attr(__('Select Month', 'zn_framework')); ?> </option> <?php wp_get_archives(apply_filters('widget_archives_dropdown_args', array('type' => 'monthly', 'format' => 'option', 'show_post_count' => $c))); ?> </select> <?php } else { ?> <ul class="menu"> <?php wp_get_archives(apply_filters('widget_archives_args', array('type' => 'monthly', 'show_post_count' => $c))); ?> </ul> <?php } echo $after_widget; }
function ts_sitemap_func($atts) { extract(shortcode_atts(array('sitemap' => ''), $atts)); $html = ''; ob_start(); ?> <ul class="sitemap"> <?php switch ($sitemap) { case 'pages': wp_list_pages("title_li="); break; case 'posts': $archive_query = new WP_Query('showposts=1000&cat=-8'); while ($archive_query->have_posts()) { $archive_query->the_post(); } break; case 'archives': wp_get_archives('type=monthly&show_post_count=true'); break; default: wp_list_pages("title_li="); break; } ?> </ul> <?php $output = ob_get_contents(); ob_end_clean(); return $output; }
static function getWordpressData() { /** * Get all global page data */ $blogDataParams = array( 'url', 'wpurl', 'description', 'rdf_url' , 'rss_url', 'rss2_url' , 'atom_url', 'comments_atom_url', 'comments_rss2_url', 'pingback_url' , 'stylesheet_url', 'stylesheet_directory', 'template_directory' , 'template_url', 'admin_email', 'charset', 'html_type', 'version' , 'language', 'text_direction', 'name' ); $blogData = array(); foreach($blogDataParams as $blogDataParam) { $blogData[self::toCamelCase($blogDataParam)] = get_bloginfo($blogDataParam); } $blogData = array_merge($blogData, array( 'title' => wp_title(' | ', false, 'right') . get_bloginfo('name'), 'archiveLinksHTML' => wp_get_archives('type=monthly&limit=5&format=link&echo=0'), 'bodyClasses' => self::getEchoFunctionContents('body_class'), 'posts' => array() )); /** * Get posts data */ while (have_posts()) { the_post(); $postId = get_the_ID(); // Get category data $categories = get_the_category(); $categoryNames = array(); foreach($categories as $category) { array_push($categoryNames, $category->cat_name); } // Add all relevant post data to the posts array array_push( $blogData['posts'], array_merge( get_object_vars(get_post($postId)), array( 'classes' => get_post_class(), 'comments' => get_comments(array('post_id' => $postId)), 'custom' => get_post_custom(), 'permalink' => get_permalink(), 'categories' => $categories, 'categoryNames' => $categoryNames, 'categoriesStr' => implode(',', $categoryNames) ) ) ); } return $blogData; }
/** * This function outputs sitemap-esque columns displaying all pages, * categories, authors, monthly archives, and recent posts. * * @since 1.6 */ function genesis_page_archive_content() { // Pause Exclude Pages plugin functionality. pause_exclude_pages(); ?> <h4><?php _e('Pages:', 'genesis'); ?> </h4> <ul> <?php wp_list_pages('title_li='); ?> </ul> <h4><?php _e('Categories:', 'genesis'); ?> </h4> <ul> <?php wp_list_categories('sort_column=name&title_li='); ?> </ul> <h4><?php _e('Authors:', 'genesis'); ?> </h4> <ul> <?php wp_list_authors('exclude_admin=0&optioncount=1'); ?> </ul> <h4><?php _e('Monthly:', 'genesis'); ?> </h4> <ul> <?php wp_get_archives('type=monthly'); ?> </ul> <h4><?php _e('Recent Posts:', 'genesis'); ?> </h4> <ul> <?php wp_get_archives('type=postbypost&limit=100'); ?> </ul> <?php // Resume Exclude Pages plugin functionality. resume_exclude_pages(); }
public static function archives_shortcode($atts) { $defaults = array('type' => 'monthly', 'limit' => '', 'show_post_count' => 0, 'order' => 'DESC'); extract(shortcode_atts($defaults, $atts)); $archives_args = array('type' => $type, 'limit' => $limit, 'format' => 'html', 'before' => '', 'after' => '', 'show_post_count' => $show_post_count, 'echo' => 0, 'order' => $order); return '<ul>' . "\n" . wp_get_archives($archives_args) . '</ul>' . "\n" . '<!-- Powered by Extra Shortcodes wordpress.org/plugins/extra-shortcodes/ -->'; }
function getSidebar() { $posts = $sidebar = ' <div class="container-aside quiet"> <h4 style="margin-bottom: .5em;" class="loud">Want another bite? Subscribe!</h4> <p><a href="http://feeds.feedburner.com/kennethreitz" target="_none">RSS</a>, <a href="http://feedburner.google.com/fb/a/mailverify?uri=kennethreitz&loc=en_US" target="_none">Email</a>, <a href="http://friendfeed.com/kennethreitz" target="_none">FriendFeed</a>, <a href="http://twitter.com/kennethreitz" target="_none">Twitter</a>, <a href="http://www.facebook.com/pages/KennethReitzcom/144095770952?ref=ts" target="_none">Facebook</a>.<br/> If you see something that makes you shake with excitment or surge with rage, leave a comment and <a href="javascript:var%20e=document.createElement(\'script\');e.setAttribute(\'language\',\'javascript\');e.setAttribute(\'src\',\'http://bit.ly/bookmarklet/load.js\');document.body.appendChild(e);void(0);">send a link</a> to others!</p> <hr/> <h4 class="loud">About @KennethReitz</h4> <p> <strong>Kenneth Reitz, <em>n</em></strong>: Open Mind. Open Source.<br/> <strong>Location?</strong> Winchester, Virginia. <br/> <strong>Field?</strong> Web Application Development <br/> <strong>What??</strong> I make websites.<br/> <strong>Language? </strong> Python. <em>Everything</em> else.<br/> <strong>Tools?</strong> MacBook + iPhone + Moleskine = 42.<br/> <strong>Anything Else?</strong> Life is wonderful.</p> <hr/> <h4>Latest Posts</h4>'; echo $sidebar; echo wp_get_archives('format=custom&after=… &type=postbypost&limit=15&show_post_count=false'); echo '<hr/>'; echo '<p class="extra-quiet">'; echo fortune(3000); echo '<p>'; echo '</div></div>'; }
function wp_get_cat_archives($opts, $cat) { $args = wp_parse_args($opts, array('echo' => '1')); // default echo is 1. // 与えられた $opts を解析して配列に入れ、第2引数 と結合 $echo = $args['echo'] != '0'; // remember the original echo flag. $args['echo'] = 0; $args['cat'] = $cat; $archives = wp_get_archives(build_query($args)); // アーカイブ取得 // 連想配列からページ用のクエリー文字列を作る $archs = explode('</li>', $archives); // 配列化した変数 $links = array(); foreach ($archs as $archive) { $link = preg_replace("/href='([^']+)'/", "href='\$1?cat={$cat}'", $archive); // 正規表現での置き換え array_push($links, $link); // 配列の末尾に値を追加 } $result = implode('</li>', $links); // 配列を連結して1つの文字列に if ($echo) { echo $result; } else { return $result; } }
/** * * @TODO document * */ function master_array() { $left = sprintf('<div class="widget"><div class="widget-pad"><h3 class="widget-title">%s</h3><p>%s</p>%s<br class="clear"/><p>%s</p></div></div>', __('Looking for something?', 'pagelines'), __('Use the form below to search the site:', 'pagelines'), pagelines_search_form(false), __("Still not finding what you're looking for? Drop us a note so we can take care of it!", 'pagelines')); $middle = sprintf('<div class="widget"><div class="widget-pad"><h3 class="widget-title">%s</h3><p>%s</p><ul>%s</ul></div></div>', __('Visit our friends!', 'pagelines'), __('A few highly recommended friends...', 'pagelines'), wp_list_bookmarks('title_li=&categorize=0&echo=0')); $right = sprintf('<div class="widget"><div class="widget-pad"><h3 class="widget-title">%s</h3><p>%s</p><ul>%s</ul></div></div>', __('Archives', 'pagelines'), __('All entries, chronologically...', 'pagelines'), wp_get_archives('type=monthly&limit=12&echo=0')); $this->master = array('left' => array('name' => 'MoreFoot Left', 'description' => __('Left sidebar in morefoot section.', 'pagelines'), 'default' => $left), 'middle' => array('name' => 'MoreFoot Middle', 'description' => __('Middle sidebar in morefoot section.', 'pagelines'), 'default' => $middle), 'right' => array('name' => 'MoreFoot Right', 'description' => __('Right sidebar in morefoot section.', 'pagelines'), 'default' => $right)); }
function asdf_archive() { ?> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.js" type="text/javascript"></script> <script type="text/javascript" src="<?php echo bloginfo('stylesheet_directory'); ?> /jsddm.js"></script> <div class="widget"><div class="asdf_archive"> <h1 class="widget-title">ARCHIVE</h1> <img src="<?php echo bloginfo('stylesheet_directory'); ?> /media/pfeil_hellgrau_archiv.png" > <ul class="jsddm"> <li><a href="">WÄHLE DEN MONAT</a> <ul><?php wp_get_archives('type=monthly&format=html&show_post_count=0'); ?> </ul> </li> </ul> </div></div> <?php }
function archives_shortcode($attr) { if (is_feed()) { return '[archives]'; } global $allowedposttags; $default_atts = array('type' => 'postbypost', 'limit' => '', 'format' => 'html', 'showcount' => false, 'before' => '', 'after' => '', 'order' => 'desc'); extract(shortcode_atts($default_atts, $attr)); if (!in_array($type, array('yearly', 'monthly', 'daily', 'weekly', 'postbypost'))) { $type = 'postbypost'; } if (!in_array($format, array('html', 'option', 'custom'))) { $format = 'html'; } if ('' != $limit) { $limit = (int) $limit; } $showcount = (bool) $showcount; $before = wp_kses($before, $allowedposttags); $after = wp_kses($after, $allowedposttags); // Get the archives $archives = wp_get_archives('type=' . $type . '&limit=' . $limit . '&format=' . $format . '&echo=0&show_post_count=' . $showcount . '&before=' . $before . '&after=' . $after); if ('asc' == $order) { $archives = implode("\n", array_reverse(explode("\n", $archives))); } // Check to see if there are any archives if (empty($archives)) { $archives = '<p>' . __('Your blog does not currently have any published posts.', 'jetpack') . '</p>'; } elseif ('option' == $format) { $archives = "<select name='archive-dropdown' onchange='document.location.href=this.options[this.selectedIndex].value;'><option value='" . get_permalink() . "'>--</option>" . $archives . "</select>"; } elseif ('html' == $format) { $archives = '<ul>' . $archives . '</ul>'; } return $archives; }
function ts_sitemap_func($atts) { extract(shortcode_atts(array('animation' => '', 'animation_delay' => '', 'animation_iteration' => '', 'sitemap' => ''), $atts)); $html = ''; ob_start(); ?> <ul class="sitemap <?php echo ts_get_animation_class($animation); ?> " <?php echo ts_get_animation_data_class($animation_delay, $animation_iteration); ?> > <?php switch ($sitemap) { case 'pages': wp_list_pages("title_li="); break; case 'posts': $archive_query = new WP_Query('showposts=1000&cat=-8'); while ($archive_query->have_posts()) { $archive_query->the_post(); ?> <li> <a href="<?php echo esc_url(get_the_permalink()); ?> " rel="bookmark" title="<?php echo esc_attr(get_the_title()); ?> "><?php the_title(); ?> </a> </li> <?php } break; case 'categories': wp_list_categories('sort_column=name&optioncount=1&hierarchical=0&feed=RSS'); break; case 'archives': wp_get_archives('type=monthly&show_post_count=true'); break; default: wp_list_pages("title_li="); break; } ?> </ul> <?php $output = ob_get_contents(); ob_end_clean(); return $output; }
function widget($args, $instance) { extract($args); /** This filter is documented in wp-includes/default-widgets.php */ $title = apply_filters('widget_title', empty($instance['title']) ? __('Accordion Archives') : $instance['title'], $instance, $this->id_base); echo $before_widget; if ($title) { echo $before_title . $title . $after_title; } ?> <ul> <?php /** * Filter the arguments for the Archives widget. * * @since 2.8.0 * * @see wp_get_archives() * * @param array $args An array of Archives option arguments. */ $archives = strip_tags(wp_get_archives(apply_filters('widget_accordion_archives_args', array('type' => 'monthly', 'format' => 'custom', 'echo' => 0, 'after' => ',')))); $archives = explode(',', $archives); $months = array(); $years = array(); // Grab our years first foreach ($archives as $archive) { $archive = explode(' ', $archive); if (isset($archive[1])) { array_push($years, $archive[1]); } } $years = array_values(array_unique($years)); $i = 0; foreach ($years as $year) { ?> <li class="archive-accordion-year"><a><?php echo $year; ?> </a><ul><?php foreach ($archives as $archive) { $archive = explode(' ', $archive); if (!empty($archive[1]) && $archive[1] == $year) { echo '<li class="archive-accordion-month"><a href="' . get_month_link($year, date("m", strtotime($archive[0] . '-' . $year))) . '">' . trim($archive[0]) . '</a></li>'; } } ?> </ul><?php ?> </li><?php } ?> </ul> <?php echo $after_widget; }
function avia_dummy_widget($number) { switch ($number) { case 1: $title = apply_filters('widget_title', __('Interesting links', 'avia_framework')); ?> <section class='widget'> <h3 class='widgettitle'><?php echo $title; ?> </h3> <span class='minitext'><?php _e('Here are some interesting links for you! Enjoy your stay :)', 'avia_framework'); ?> </span> </section> <?php break; case 4: $title = apply_filters('widget_title', __('Archive', 'avia_framework')); echo "<section class='widget widget_archive'>"; echo "<h3 class='widgettitle'>" . $title . "</h3>"; echo "<ul>"; wp_get_archives('type=monthly'); echo "</ul>"; echo "<span class='seperator extralight-border'></span></section>"; break; case 3: $title = apply_filters('widget_title', __('Categories', 'avia_framework')); echo "<section class='widget widget_categories'>"; echo "<h3 class='widgettitle'>" . $title . "</h3>"; echo "<ul>"; wp_list_categories('sort_column=name&optioncount=0&hierarchical=0&title_li='); echo "</ul>"; echo "<span class='seperator extralight-border'></span></section>"; break; case 2: $title = apply_filters('widget_title', __('Pages', 'avia_framework')); echo "<section class='widget widget_pages'>"; echo "<h3 class='widgettitle'>" . $title . "</h3>"; echo "<ul>"; wp_list_pages('title_li=&depth=-1'); echo "</ul>"; echo "<span class='seperator extralight-border'></span></section>"; break; case 5: $title = apply_filters('widget_title', __('Bookmarks', 'avia_framework')); echo "<section class='widget widget_archive'>"; echo "<h3 class='widgettitle'>" . $title . "</h3>"; echo "<ul>"; wp_list_bookmarks('title_li=&categorize=0'); echo "</ul>"; echo "<span class='seperator extralight-border'></span></section>"; break; } }
function thesis_archives_template() { echo "\t\t\t\t\t<h3 class=\"top\">" . __('By Month:', 'thesis') . "</h3>\n"; echo "\t\t\t\t\t<ul>\n"; wp_get_archives('type=monthly'); echo "\t\t\t\t\t</ul>\n"; echo "\t\t\t\t\t<h3>" . __('By Category:', 'thesis') . "</h3>\n"; echo "\t\t\t\t\t<ul>\n"; wp_list_categories('title_li=0'); echo "\t\t\t\t\t</ul>\n"; }
function vd_posts_volume_count($number_of_months = 6) { $a = wp_get_archives('type=monthly&show_post_count=1&format=custom&echo=0&limit=' . $number_of_months); $entries = explode(' ', $a); array_walk($entries, 'vd_post_count_from_entry'); $number_of_entries = array_sum(array_filter($entries)); $stats = array(); $stats['total_entries'] = $number_of_entries; $stats['total_months'] = $number_of_months; $stats['postvolume'] = round($number_of_entries / $number_of_months); return $stats; }
/** * How to display the widget on the screen. */ function widget($args, $instance) { extract($args); /* Our variables from the widget settings. */ $title = apply_filters('widget_title', $instance['title']); $type = $instance['type']; /* Before widget (defined by themes). */ echo $before_widget; /* Display the widget title if one was input (before and after defined by themes). */ if ($title) { echo $before_title . $title . $after_title; } ?> <div class="archive-list"> <?php if ($type == 'pages') { $page_s = explode('</li>', wp_list_pages('title_li=&echo=0&depth=1&style=none')); } elseif ($type == 'categories') { $page_s = explode('</li>', wp_list_categories('show_count=0&title_li=&echo=0&depth=-1')); } else { $page_s = explode('</li>', wp_get_archives('type=monthly&echo=0')); } $page_n = count($page_s) - 1; $page_col = round($page_n / 2); $page_left = ''; $page_right = ''; for ($i = 0; $i < $page_n; $i++) { if ($i < $page_col) { $page_left = $page_left . '' . $page_s[$i] . '</li>'; } elseif ($i >= $page_col) { $page_right = $page_right . '' . $page_s[$i] . '</li>'; } } ?> <ul class="left"> <?php echo $page_left; ?> </ul> <ul class="right"> <?php echo $page_right; ?> </ul> </div> <?php /* After widget (defined by themes). */ echo $after_widget; }
function widget_helia_archives() { ?> <li id="archives" class="minibox widget"> <h3>Archives</h3> <ul> <?php wp_get_archives('type=monthly'); ?> </ul> </li> <?php }
/** * Lists the Spotlight archives list. * * @since 1.3.0 * @access private */ function jc_spotlight_archives_list() { ?> <li class="spotlight-archives"> <h3 class="widget-title"> Archives </h3> <?php wp_get_archives(array('post_type' => 'jc-spotlight', 'type' => 'yearly')); ?> </li> <?php }
function wsm_sitemap($heading = 'h2') { // edit these functions as desired with the parameters listed in the WordPress Codex $sitemap = sprintf('<%2$s>%1$s</%2$s>', __('Pages:', 'genesis'), $heading); $sitemap .= sprintf('<ul>%s</ul>', wp_list_pages('title_li=&echo=0')); $sitemap .= sprintf('<%2$s>%1$s</%2$s>', __('Categories:', 'genesis'), $heading); $sitemap .= sprintf('<ul>%s</ul>', wp_list_categories('sort_column=name&title_li=&echo=0')); $sitemap .= sprintf('<%2$s>%1$s</%2$s>', __('Monthly:', 'genesis'), $heading); $sitemap .= sprintf('<ul>%s</ul>', wp_get_archives('type=monthly&echo=0')); $sitemap .= sprintf('<%2$s>%1$s</%2$s>', __('Recent Posts:', 'genesis'), $heading); $sitemap .= sprintf('<ul>%s</ul>', wp_get_archives('type=postbypost&limit=100&echo=0')); echo $sitemap; }
function avia_dummy_widget($number) { switch ($number) { case 1: ?> <div class='widget'> <h3 class='widgettitle'><?php _e('Interesting links', 'avia_framework'); ?> </h3> <span class='minitext'><?php _e('Besides are some interesting links for you! Enjoy your stay :)', 'avia_framework'); ?> </span> </div> <?php break; case 4: echo "<div class='widget widget_archive'>"; echo "<h3 class='widgettitle'>" . __('Archive', 'avia_framework') . "</h3>"; echo "<ul>"; wp_get_archives('type=monthly'); echo "</ul>"; echo "</div>"; break; case 3: echo "<div class='widget widget_categories'>"; echo "<h3 class='widgettitle'>" . __('Categories', 'avia_framework') . "</h3>"; echo "<ul>"; wp_list_categories('sort_column=name&optioncount=0&hierarchical=0&title_li='); echo "</ul>"; echo "</div>"; break; case 2: echo "<div class='widget widget_pages'>"; echo "<h3 class='widgettitle'>" . __('Pages', 'avia_framework') . "</h3>"; echo "<ul>"; wp_list_pages('title_li=&depth=-1'); echo "</ul>"; echo "</div>"; break; case 5: echo "<div class='widget widget_archive'>"; echo "<h3 class='widgettitle'>" . __('Bookmarks', 'avia_framework') . "</h3>"; echo "<ul>"; wp_list_bookmarks('title_li=&categorize=0'); echo "</ul>"; echo "</div>"; break; } }
function kreative_archive_widget() { ?> <div class="widgets"> <h2 class="sideheading">Archives</h2> <ul class="sidebarlist"> <p><?php wp_get_archives('type=monthly'); ?> </p> </ul> <div class="clear"></div> </div> <?php }
function getArchivesNav($postType) { ?> <h4 class = "label">Archives by Month:</h4> <ul> <?php wp_get_archives(array('type' => $postType)); ?> </ul> <?php }
function test_wp_get_archives_order() { $this->factory->post->create(array('post_type' => 'post', 'post_author' => '1', 'post_date' => '2012-10-23 19:34:42')); $date_full = date('F Y'); $oct_url = get_month_link(2012, 10); $expected['order_asc'] = <<<EOF <li><a href='{$oct_url}'>October 2012</a></li> \t<li><a href='{$this->month_url}'>{$date_full}</a></li> EOF; $this->assertEquals($expected['order_asc'], trim(wp_get_archives(array('echo' => false, 'order' => 'ASC')))); $expected['order_desc'] = <<<EOF <li><a href='{$this->month_url}'>{$date_full}</a></li> \t<li><a href='{$oct_url}'>October 2012</a></li> EOF; $this->assertEquals($expected['order_desc'], trim(wp_get_archives(array('echo' => false, 'order' => 'DESC')))); }
/** * Front-end display of widget. * * @see WP_Widget::widget() * * @param array $args Widget arguments. * @param array $instance Saved values from database. */ public function widget($args, $instance) { extract($args); $title = $instance['title']; ?> <aside class="media"> <h3><?php echo esc_html($title); ?></h3> <ul class="archives"> <?php wp_get_archives( array('type' => 'monthly' , 'show_post_count' => true)); ?> </ul> </aside> <?php }
function themeple_default_widgets($name) { if ($name == 'categories') { echo "<div class='widget widget_categories'>"; echo "<h3 class='widgettitle'>Categories</h3>"; echo "<ul>"; wp_list_categories('sort_column=name&optioncount=0&hierarchical=0&title_li='); echo "</ul>"; echo "<span class='seperator extralight-border'></span></div>"; } else { if ($name == 'archives') { echo "<div class='widget widget_archive'>"; echo "<h3 class='widgettitle'>Archive</h3>"; echo "<ul>"; wp_get_archives('type=monthly'); echo "</ul>"; echo "<span class='seperator extralight-border'></span></div>"; } else { if ($name == 'pages') { echo "<div class='widget widget_pages'>"; echo "<h3 class='widgettitle'>Pages</h3>"; echo "<ul>"; wp_list_pages('title_li=&depth=-1'); echo "</ul>"; echo "<span class='seperator extralight-border'></span></div>"; } else { if ($name == 'bookmarks') { echo "<div class='widget widget_archive'>"; echo "<h3 class='widgettitle'>Bookmarks</h3>"; echo "<ul>"; wp_list_bookmarks('title_li=&categorize=0'); echo "</ul>"; echo "<span class='seperator extralight-border'></span></div>"; } else { if ($name == 'recent_comments') { echo "<div class='widget widget_recent_comments'>"; echo "<h3 class='widgettitle'>Recent Comments</h3>"; echo "<ul>"; wp_get_recent_posts('numberposts=5'); echo "</ul>"; echo "<span class='seperator extralight-border'></span></div>"; } } } } } }
/** * Outputs the widget based on the arguments input through the widget controls. * @since 0.6 */ function widget( $args, $instance ) { extract( $args ); $args = array(); $args['type'] = $instance['type']; $args['format'] = $instance['format']; $args['before'] = $instance['before']; $args['after'] = $instance['after']; $args['show_post_count'] = isset( $instance['show_post_count'] ) ? $instance['show_post_count'] : false; $args['limit'] = !empty( $instance['limit'] ) ? intval( $instance['limit'] ) : ''; $args['echo'] = false; echo $before_widget; if ( $instance['title'] ) echo $before_title . apply_filters( 'widget_title', $instance['title'] ) . $after_title; $archives = str_replace( array( "\r", "\n", "\t" ), '', wp_get_archives( $args ) ); if ( 'option' == $args['format'] ) { if ( 'yearly' == $args['type'] ) $option_title = __( 'Select Year', $this->textdomain ); elseif ( 'monthly' == $args['type'] ) $option_title = __( 'Select Month', $this->textdomain ); elseif ( 'weekly' == $args['type'] ) $option_title = __( 'Select Week', $this->textdomain ); elseif ( 'daily' == $args['type'] ) $option_title = __( 'Select Day', $this->textdomain ); elseif ( 'postbypost' == $args['type'] || 'alpha' == $args['type'] ) $option_title = __( 'Select Post', $this->textdomain ); echo '<select name="archive-dropdown" onchange=\'document.location.href=this.options[this.selectedIndex].value;\'>'; echo '<option value="">' . esc_attr( $option_title ) . '</option>'; echo $archives; echo '</select>'; } elseif ( 'html' == $args['format'] ) { echo '<ul class="xoxo archives">' . $archives . '</ul><!-- .xoxo .archives -->'; } else { echo $archives; } echo $after_widget; }
/** * @desc Convert HTML from wp_get_archives into array of objects. * @return array */ public function getArchives() { $args = $_GET; $args['echo'] = false; $html = wp_get_archives($args); $html = DOMDocument::loadHTML($html); $anchors = $html->getElementsByTagname('a'); $blog_url = $this->getBlogInfo('url'); $blog_url = $blog_url['url']; $archives = array(); foreach ($anchors as $anchor) { $href = $anchor->getAttribute('href'); $props = array('blog_url' => $href, 'clean_uri' => '/' . str_replace($blog_url, '', $href), 'text' => $anchor->textContent); $archives[] = $props; } return $archives; }
function months_sidebar_module($args) { extract($args); echo $before_module . $before_title . $title . $after_title; ?> <ul> <?php wp_get_archives('type=monthly'); ?> </ul> <?php echo $after_module; }