private function _meta_data($view, $params)
 {
     $defaults = array('class' => '');
     $params = wp_parse_args($params, $defaults);
     $content = '';
     // Date
     $content .= '<a href="' . get_month_link(get_the_time('Y'), get_the_time('m')) . '" class="blog_date"><i class="icon-calendar"></i>' . get_the_date('F j, Y') . '</a>';
     // Categories
     $post_categories = wp_get_post_categories(get_the_ID());
     $categories = array();
     foreach ($post_categories as $c) {
         $cat = get_category($c);
         $categories[] = '<a href="' . get_category_link($cat->term_id) . '">' . $cat->name . '</a>';
     }
     if (count($categories) > 0) {
         $content .= '<div class="blog_category"><i class="icon-tag"></i>' . implode(', ', $categories) . '</div>';
     }
     // Author
     $content .= '<span class="blog_author"><i class="icon-user"></i>' . get_the_author() . '</span>';
     $post_tags = wp_get_post_tags(get_the_ID());
     $tags = array();
     foreach ($post_tags as $tag) {
         $tags[] = '<a href="' . get_tag_link($tag->term_id) . '">' . $tag->name . '</a>';
     }
     if (count($tags) > 0) {
         $content .= '<div class="blog_category"><i class="icon-tag"></i>' . implode(', ', $tags) . '</div>';
     }
     return '<div class="' . $params['class'] . '">' . $content . '</div>';
 }
 function _b_wp_archives_monthly_show($options, $wp_num = '')
 {
     $block_style = $options[0] ? $options[0] : 0;
     $with_count = $options[1] == 0 ? false : true;
     $tpl_file = empty($options[2]) ? 'wp_archives_monthly.html' : $options[2];
     $sel_value = '';
     if (current_wp()) {
         if (!empty($_SERVER['PATH_INFO'])) {
             permlink_to_param();
         }
         init_param('GET', 'm', 'string', '');
         init_param('GET', 'year', 'integer', '');
         init_param('GET', 'monthnum', 'integer', '');
         init_param('GET', 'day', 'integer', '');
         if (strlen(get_param('m')) == 6) {
             $sel_value = get_param('m');
         } else {
             if (test_param('year') && test_param('monthnum') && !test_param('day')) {
                 $sel_value = get_param('year') . zeroise(get_param('monthnum'), 2);
             }
         }
     }
     $block['wp_num'] = $wp_num;
     $block['divid'] = 'wpArchive' . $wp_num;
     $block['siteurl'] = wp_siteurl();
     $block['style'] = block_style_get(false);
     $block['block_style'] = $block_style;
     $block['with_count'] = $with_count;
     $now = current_time('mysql');
     $postHandler =& wp_handler('Post');
     $criteria =& new CriteriaCompo(new Criteria('post_date', $now, '<'));
     $criteria->add(new Criteria('post_status', 'publish'));
     $criteria->setSort('post_date');
     $criteria->setOrder('DESC');
     $criteria->setGroupby('YEAR(post_date), MONTH(post_date)');
     $postObjects =& $postHandler->getObjects($criteria, false, 'DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, count(ID) as posts');
     $block['records'] = array();
     if ($postObjects) {
         foreach ($postObjects as $postObject) {
             $this_year = $postObject->getExtraVar('year');
             $this_month = $postObject->getExtraVar('month');
             $_record['url'] = get_month_link($this_year, $this_month);
             $_record['text'] = format_month($this_year, $GLOBALS['month'][zeroise($this_month, 2)]);
             if ($with_count) {
                 $_record['count'] = '&nbsp;(' . $postObject->getExtraVar('posts') . ')';
             } else {
                 $_record['count'] = '';
             }
             $_record['select'] = $sel_value == $this_year . zeroise($this_month, 2) ? 'selected="selected"' : '';
             $block['records'][] = $_record;
         }
     }
     $_wpTpl =& new WordPresTpl('theme');
     $_wpTpl->assign('block', $block);
     if (!$_wpTpl->tpl_exists($tpl_file)) {
         $tpl_file = 'wp_archives_monthly.html';
     }
     $block['content'] = $_wpTpl->fetch($tpl_file);
     return $block;
 }
Exemplo n.º 3
0
 function widget($args, $instance)
 {
     extract($args);
     $c = $instance['count'] ? '1' : '0';
     $archive_type = $instance['archive_type'] ? '1' : '0';
     $title = apply_filters('widget_title', __('Archives', 'unspoken'));
     echo $before_widget;
     if ($title) {
         echo $before_title . $title . $after_title;
     }
     if ($archive_type == 0) {
         $categories = get_categories();
         $output = '<ul>';
         foreach ($categories as $category) {
             $output .= sprintf('<li><a href="%1$s" title="%2$s">%3$s</a><span>%4$s</span></li>', get_category_link($category->term_id), sprintf(__('View all posts in %s', 'unspoken'), $category->name), $category->name, $c ? $category->count : '');
         }
         $output .= '</ul>';
     } else {
         global $wpdb, $wp_locale;
         // set limit for list
         $archive_limit = 0;
         // query
         $q = "SELECT YEAR(post_date) AS 'year', MONTH(post_date) AS 'month', COUNT(ID) as post_count " . "FROM {$wpdb->posts} " . "WHERE post_type = 'post' AND post_status = 'publish' " . "GROUP BY month, year " . "ORDER BY post_date DESC" . ($archive_limit == 0 ? '' : ' LIMIT ' . $archive_limit);
         // make query for result
         $months = $wpdb->get_results($q);
         $output = '<ul>';
         // looping through result
         foreach ($months as $month) {
             $output .= sprintf('<li><a href="%1$s">%2$s<span>%3$s</span></a></li>', get_month_link($month->year, $month->month), sprintf(__('%1$s %2$d'), $wp_locale->get_month($month->month), $month->year), $c ? $month->post_count : '');
         }
         $output .= '</ul>';
     }
     echo $output;
     echo $after_widget;
 }
Exemplo n.º 4
0
function blog_thumbnail_style($atts, $current)
{
    global $post, $mk_options;
    extract($atts);
    $image_height = $grid_image_height;
    if ($thumbnail_align == 'left') {
        $align_class = ' content-align-right';
    } else {
        $align_class = ' content-align-left';
    }
    if ($layout == 'full') {
        $image_width = $grid_width - 40;
    } else {
        $image_width = $content_width / 100 * $grid_width - 40;
    }
    $output = $has_image = '';
    $post_type = get_post_meta($post->ID, '_single_post_type', true);
    /*
     * Image Width : 600px
     * Image Height : 460px
     */
    $image_src_array = wp_get_attachment_image_src(get_post_thumbnail_id(), 'full', true);
    $image_output_src = bfi_thumb($image_src_array[0], array('width' => '600', 'height' => '460'));
    if ($post_type == '') {
        $post_type = 'image';
    }
    $output .= '<article id="' . get_the_ID() . '" class="mk-blog-thumbnail-item thumbnail-' . $item_id . ' mk-isotop-item ' . $post_type . '-post-type' . $align_class . '">' . "\n";
    if (has_post_thumbnail()) {
        $output .= '<div class="featured-image" ><a href="' . get_permalink() . '" title="' . get_the_title() . '">';
        $output .= '    <img alt="' . get_the_title() . '" title="' . get_the_title() . '" src="' . $image_output_src . '" itemprop="image" />';
        $output .= '    <div class="image-hover-overlay"></div>';
        $output .= '    <div class="post-type-badge" href="' . get_permalink() . '"><i class="mk-li-' . $post_type . '"></i></div>';
        $output .= '</a></div>';
    }
    $output .= '<div class="mk-thumbnail-content-container">';
    $output .= '    <div class="mk-blog-meta">';
    $output .= '        <div class="mk-blog-author">';
    ob_start();
    the_author_posts_link();
    $output .= ob_get_contents() . '</div>';
    ob_get_clean();
    $output .= '        <span class="mk-categories"> / ' . __('', 'mk_framework') . ' ' . get_the_category_list(', ') . ' </span> /
                        <time datetime="' . get_the_date() . '">
                            <a href="' . get_month_link(get_the_time("Y"), get_the_time("m")) . '">' . get_the_date() . '</a>
                        </time>';
    $output .= '        <h3 class="the-title"><a href="' . get_permalink() . '">' . get_the_title() . '</a></h3>';
    if ($excerpt_length != 0) {
        ob_start();
        the_excerpt_max_charlength($excerpt_length);
        $output .= '<div class="the-excerpt"><p>' . ob_get_clean() . '</p></div>';
    }
    $output .= '        <div class="mk-teader-button">' . do_shortcode('[mk_button dimension="outline" corner_style="pointed" outline_skin="custom" outline_active_color="#000000" outline_hover_color="#fff" margin_bottom="0" size="medium" align="left" url="' . get_permalink() . '"]' . __('READ MORE', 'mk_framework') . '[/mk_button]') . '
                            </div>';
    $output .= '        </div>';
    $output .= '    </div>';
    $output .= '<div class="clearboth"></div>';
    $output .= '</article>' . "\n\n\n";
    return $output;
}
 /**
  * This checks on which page we're and display the correct breancrumb navigation
  * @return string | void
  */
 public function output_html()
 {
     global $post, $cat, $wp_query;
     $output = '';
     $arc_year = get_the_time('Y');
     $arc_month = get_the_time('F');
     $arc_day = get_the_time('d');
     $arc_day_full = get_the_time('l');
     $url_year = get_year_link($arc_year);
     $url_month = get_month_link($arc_year, $arc_month);
     $templates = array_keys(fw_get_db_ext_settings_option('ns-breadcrumb', 'hide-bdb-templates', array()));
     $types = array_keys(fw_get_db_ext_settings_option('ns-breadcrumb', 'hide-bdb-types', array()));
     if (in_array(get_post_type(), $types)) {
         return;
     }
     if (!is_front_page()) {
         //breadcrumb for single post
         if (is_single() && !in_array('single', $templates)) {
             $output = $this->is_single_post();
         } elseif (is_category() && !in_array('category', $templates)) {
             $output = '<li>' . $this->set_opt('category') . get_category_parents($cat, true, ' &raquo; ') . '</li>';
         } elseif (is_tax() && !in_array('category', $templates)) {
             $term = $wp_query->queried_object;
             $output = '<li>' . $this->set_opt('category') . $term->name . '</li>';
         } elseif (is_tag() && !in_array('tag', $templates)) {
             $output = '<li>' . $this->set_opt('tags') . single_tag_title('', false) . '</li>';
         } elseif (is_day() && !in_array('archive', $templates)) {
             $output = '<li><a href="' . $url_year . '">' . $arc_year . '</a></li>';
             $output .= '<li><a href="' . $url_month . '">' . $arc_month . '</a></li><li>' . $arc_day . ' (' . $arc_day_full . ')</li>';
         } elseif (is_month() && !in_array('archive', $templates)) {
             $output = '<li><a href="' . $url_year . '">' . $arc_year . '</a></li><li>' . $arc_month . '</li>';
         } elseif (is_year() && !in_array('archive', $templates)) {
             $output = '<li>' . $arc_year . '</li>';
         } elseif (is_search() && !in_array('search', $templates)) {
             $output = '<li>' . $this->set_opt('search') . get_search_query() . '</li>';
         } elseif (is_page() && !$post->post_parent && !in_array('page', $templates)) {
             $output = '<li>' . get_the_title() . '</li>';
         } elseif (is_page() && $post->post_parent && !in_array('page', $templates)) {
             $output = $this->is_page_n_has_parent();
         } elseif (is_author() && !in_array('author', $templates)) {
             global $author;
             $user_info = get_userdata($author);
             $output = '<li>' . $this->set_opt('author') . $user_info->display_name . '</li>';
         } elseif (is_404() && !in_array('404', $templates)) {
             $output = '<li>' . $this->set_opt('error') . '</li>';
         } else {
             //All other cases no Breadcrumb trail.
         }
     }
     if (!empty($output)) {
         $return = '<ul class="breadcrumb">';
         $return .= $this->set_opt('el_prefix');
         $return .= $output;
         $return .= '</ul>';
         echo $return;
     }
 }
    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;
    }
Exemplo n.º 7
0
/**
 * Prints the date for a post with the month + date linkable to the moth archive and the year linked to the yearly archive
 * Date looks like - "September 21, 2014"
 */
function elder_linkable_date()
{
    global $year, $currentmonth;
    printf('<a href="%1$s" title="View posts from %2$s %3$s">', get_month_link($year, $currentmonth), get_the_date('F'), get_the_date('Y'));
    echo get_the_date('F') . ' ' . get_the_date('j');
    echo '</a>, ';
    printf('<a href="%1$s" title="View posts from %2$s">', get_year_link($year), get_the_date('Y'));
    echo get_the_date('Y');
    echo '</a>';
}
Exemplo n.º 8
0
 public function test_page_type_date()
 {
     $this->go_to(get_year_link('2015'));
     $this->assertTrue(is_year());
     $this->assertSame('date', Ad_Layers::instance()->get_current_page_type());
     $this->go_to(get_month_link('2015', '03'));
     $this->assertTrue(is_month());
     $this->assertSame('date', Ad_Layers::instance()->get_current_page_type());
     $this->go_to(get_day_link('2015', '03', '14'));
     $this->assertTrue(is_day());
     $this->assertSame('date', Ad_Layers::instance()->get_current_page_type());
 }
    function widget($args, $instance)
    {
        extract($args);
        echo $before_widget;
        $title = apply_filters('widget_title', empty($instance['title']) ? __('Archives', 'better-archives-widget') : $instance['title'], $instance, $this->id_base);
        if (!empty($title)) {
            echo $before_title . $title . $after_title;
        }
        // years - months
        global $wpdb;
        $prevYear = '';
        $currentYear = '';
        if ($months = $wpdb->get_results("SELECT DISTINCT DATE_FORMAT(post_date, '%b') AS month , MONTH(post_date) as numMonth, YEAR( post_date ) AS year, COUNT( id ) as post_count FROM {$wpdb->posts} WHERE post_status = 'publish' and post_date <= now() and post_type = 'post' GROUP BY month , year ORDER BY post_date DESC")) {
            echo '<ul>';
            foreach ($months as $month) {
                $currentYear = $month->year;
                if ($currentYear !== $prevYear && '' !== $prevYear) {
                    echo '</ul></li>';
                }
                if ($currentYear !== $prevYear) {
                    ?>
					<li class="baw-year">
					<a href="<?php 
                    echo esc_url(get_year_link($month->year));
                    ?>
"><?php 
                    echo esc_html($month->year);
                    ?>
</a>
					<ul class="baw-months">
					<?php 
                }
                ?>
				<li class="baw-month">
					<a href="<?php 
                echo esc_url(get_month_link($month->year, $month->numMonth));
                ?>
"><?php 
                echo esc_html($month->month . ' ' . $month->year);
                ?>
</a>
				</li>
				<?php 
                $prevYear = $month->year;
            }
        }
        ?>
		</ul></li>
		<?php 
        echo '</ul>';
        echo $after_widget;
    }
Exemplo n.º 10
0
    protected function generate_data()
    {
        global $wpdb;
        $requested = $this->requested;
        if ('monthly' == $requested) {
            $latest_post_query = '
				SELECT
					YEAR(post_date) as year,
					MONTH(post_date) as month,
					MAX(post_modified) as post_modified,
					MAX(post_modified_gmt) as post_modified_gmt,
					MAX(comment_count) as comment_count
				FROM ' . $wpdb->posts . "\n\t\t\t\tWHERE post_status = 'publish'\n\t\t\t\t\tAND post_password = ''\n\t\t\t\t\tAND post_type = 'post'" . '
				GROUP BY year, month
				ORDER BY post_modified DESC';
        } else {
            $latest_post_query = '
				SELECT
					YEAR(post_date) as year,
					MAX(post_modified) as post_modified,
					MAX(post_modified_gmt) as post_modified_gmt,
					MAX(comment_count) as comment_count
				FROM ' . $wpdb->posts . "\n\t\t\t\tWHERE post_status = 'publish'\n\t\t\t\t\tAND post_password = ''\n\t\t\t\t\tAND post_type <> 'page'" . '
				GROUP BY year
				ORDER BY post_modified DESC';
        }
        $latest_posts = $this->get_results($latest_post_query);
        if (!isset($latest_posts) || 0 == sizeof($latest_posts)) {
            return false;
        }
        $data = array();
        for ($i = 0; $i < sizeof($latest_posts); $i++) {
            $post = $latest_posts[$i];
            $data = $this->init_data($data);
            if ('monthly' == $requested) {
                $data['location'] = get_month_link($post->year, $post->month);
            } else {
                if ('yearly' == $requested) {
                    $data['location'] = get_year_link($post->year);
                }
            }
            $data['lastmod'] = $this->get_lastmod($post);
            $data['freq'] = $this->cal_frequency($post);
            $data['priority'] = $this->cal_priority($post, $data['freq']);
            $this->data[] = $data;
        }
        unset($latest_posts);
        return true;
    }
Exemplo n.º 11
0
function show_nested_archive()
{
    foreach (get_posts_by_years() as $year) {
        echo '<div class="gl-cell gl-md-4 gl-lg-3 left">';
        echo '<dl class="dropy archive-year"><dt class="dropy__title"><h2>' . $year . '<i class="icon-down-open-mini"></i></h2></dt>';
        echo '<dd class="dropy__content"><ul>';
        foreach (get_posts_by_months($year) as $month) {
            echo '<li><a href="' . get_month_link($year, $month) . '">';
            echo date_i18n('F', mktime(0, 0, 0, $month)) . '</a>';
            echo '</li>';
        }
        echo '</ul></dd><input type="hidden" name="first"></dl>';
        echo '</div>';
    }
}
Exemplo n.º 12
0
/**
 * Get all dates archives urls associated to a specific post
 *
 * @since 1.0
 *
 * @param int $post_ID The post ID
 * @return array $urls List of dates URLs
 */
function get_rocket_post_dates_urls($post_ID)
{
    // Get the day and month of the post
    $date = explode('-', get_the_time('Y-m-d', $post_ID));
    $urls = array(get_year_link($date[0]) . 'index.html', get_year_link($date[0]) . $GLOBALS['wp_rewrite']->pagination_base, get_month_link($date[0], $date[1]) . 'index.html', get_month_link($date[0], $date[1]) . $GLOBALS['wp_rewrite']->pagination_base, get_day_link($date[0], $date[1], $date[2]));
    /**
     * Filter the list of dates URLs
     *
     * @since 1.1.0
     *
     * @param array $urls List of dates URLs
     */
    $urls = apply_filters('rocket_post_dates_urls', $urls);
    return $urls;
}
Exemplo n.º 13
0
    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'))));
    }
Exemplo n.º 14
0
function archives_cloud($smallest = 50, $largest = 200, $unit = "%", $cold = "", $hot = "", $before = '', $after = '', $exclude = '')
{
    global $month, $wpdb;
    $now = current_time('mysql');
    $results = $wpdb->get_results('SELECT DISTINCT YEAR(post_date) AS `year`,' . ' MONTH(post_date) AS `month`,' . ' count(ID) AS `posts` ' . ' FROM ' . $wpdb->posts . ' WHERE post_date < "' . $now . '" AND post_status = "publish"' . ' GROUP BY YEAR(post_date), MONTH(post_date)' . ' ORDER BY post_date DESC');
    $content = array();
    foreach ($results as $key => $val) {
        # normalize the values to fit into KingCloud Class content var
        $content[$key]['url'] = get_month_link($val->year, $val->month);
        $content[$key]['text'] = sprintf('%s %d', $month[zeroise($val->month, 2)], $val->year);
        $content[$key]['title'] = $val->posts . ' Artikel';
        $content[$key]['count'] = $val->posts;
    }
    $cloud = new KingCloud($content, $smallest, $largest, $unit, $cold, $hot, $before, $after);
    $cloud->output();
}
Exemplo n.º 15
0
function get_blix_archive($show_comment_count = 0, $before = '<h4>', $after = '</h4>', $year = 0, $post_type = 'post', $limit = 100)
{
    global $month, $wpdb;
    $result = '';
    if ($year) {
        $AND_year = " AND YEAR(post_date)='{$year}'";
    }
    if ($limit) {
        $LIMIT = " LIMIT {$limit}";
    }
    $arcresults = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS year, MONTH(post_date) AS month, count(ID) as posts FROM " . $wpdb->posts . " WHERE post_type='{$post_type}' {$AND_year} AND post_status='publish' GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date DESC");
    if ($arcresults) {
        foreach ($arcresults as $arcresult) {
            $url = get_month_link($arcresult->year, $arcresult->month);
            $text = sprintf('%s %d', $month[zeroise($arcresult->month, 2)], $arcresult->year);
            $result .= get_archives_link($url, $text, '', $before, $after);
            $thismonth = zeroise($arcresult->month, 2);
            $thisyear = $arcresult->year;
            $arcresults2 = $wpdb->get_results("SELECT ID, post_date, post_title, comment_status, guid, comment_count FROM " . $wpdb->posts . " WHERE post_date LIKE '{$thisyear}-{$thismonth}-%' AND post_status='publish' AND post_type='{$post_type}' AND post_password='' ORDER BY post_date DESC {$LIMIT}");
            if ($arcresults2) {
                $result .= "<ul class=\"postspermonth\">\n";
                foreach ($arcresults2 as $arcresult2) {
                    if ($arcresult2->post_date != '0000-00-00 00:00:00') {
                        $url = get_permalink($arcresult2->ID);
                        //$arcresult2->guid;
                        $arc_title = $arcresult2->post_title;
                        if ($arc_title) {
                            $text = strip_tags($arc_title);
                        } else {
                            $text = $arcresult2->ID;
                        }
                        $result .= "<li>" . get_archives_link($url, $text, '');
                        if ($show_comment_count) {
                            $cc = $arcresult2->comment_count;
                            if ($arcresult2->comment_status == "open" or $comments_count > 0) {
                                $result .= " ({$cc})";
                            }
                        }
                        $result .= "</li>\n";
                    }
                }
                $result .= "</ul>\n";
            }
        }
    }
    return $result;
}
Exemplo n.º 16
0
/**
 * get meta information for current post
 */
function teaberry_entry_meta()
{
    /* used between list items */
    $cats = get_the_category_list(', ');
    $tags = get_the_tag_list('', ', ');
    $date = sprintf('<a href="%1$s" title="%2$s" rel="bookmark"><time class="entry-date" datetime="%3$s">%4$s</time></a>', esc_url(get_month_link(get_post_time('Y'), get_post_time('m'))), esc_attr(get_the_time()), esc_attr(get_the_date('c')), esc_html(get_the_date()));
    $name = sprintf('<span class="author vcard"><a class="url fn n" href="%1$s" title="%2$s" rel="author">%3$s</a></span>', esc_url(get_author_posts_url(get_the_author_meta('ID'))), esc_attr(sprintf(__('View all posts by %s', 'teaberry'), get_the_author())), get_the_author());
    /* make meta text */
    if ($tags) {
        $text = __('Added in %1$s and tagged %2$s on %3$s<span class="by-author"> by %4$s</span>. ', 'teaberry');
    } elseif ($cats) {
        $text = __('Added in %1$s on %3$s<span class="by-author"> by %4$s</span>. ', 'teaberry');
    } else {
        $text = __('Added on %3$s<span class="by-author"> by %4$s</span>. ', 'teaberry');
    }
    printf($text, $cats, $tags, $date, $name);
}
Exemplo n.º 17
0
function otat_month_archives()
{
    global $wpdb;
    $where = "WHERE post_type = 'post' AND post_status = 'publish'";
    $query = "SELECT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, count(ID) as posts FROM {$wpdb->posts} {$where} GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY YEAR DESC, MONTH ASC";
    $_archive = $wpdb->get_results($query);
    $last_year = (int) $_archive[0]->year;
    $first_year = (int) $_archive[count($_archive) - 1]->year;
    $archive = array();
    $max = 0;
    $year_total = array();
    foreach ($_archive as $data) {
        if (!isset($year_total[$data->year])) {
            $year_total[$data->year] = 0;
        }
        $archive[$data->year][$data->month] = $data->posts;
        $year_total[$data->year] += $data->posts;
        $max = max($max, $data->posts);
    }
    unset($_archive);
    for ($year = $last_year; $year >= $first_year; $year--) {
        echo '<div class="archive_year">';
        echo '<span class="archive_year_label">' . $year;
        if (isset($year_total[$year])) {
            echo '<span class="archive_year_count">' . $year_total[$year] . ' tweets</span>';
        }
        echo '</span>';
        echo '<ol>';
        for ($month = 1; $month <= 12; $month++) {
            $num = isset($archive[$year][$month]) ? $archive[$year][$month] : 0;
            $empty = $num ? 'not_empty' : 'empty';
            echo "<li class='{$empty}'>";
            $height = 100 - max(floor($num / $max * 100), 20);
            if ($num) {
                $url = get_month_link($year, $month);
                $m = str_pad($month, 2, "0", STR_PAD_LEFT);
                echo "<a href='{$url}' title='{$m}/{$year} : {$num} tweets'><span class='bar_wrap'><span class='bar' style='height:{$height}%'></span></span>";
                echo "<span class='label'>" . $m . "</span>";
                echo "</a>";
            }
            echo '</li>';
        }
        echo '</ol>';
        echo "</div>";
    }
}
Exemplo n.º 18
0
function dt_archives_shortcode()
{
    global $month, $wpdb, $wp_version;
    // a mysql query to get the list of distinct years and months that posts have been created
    $sql = 'SELECT
			DISTINCT YEAR(post_date) AS year,
			MONTH(post_date) AS month,
			count(ID) as posts
		FROM ' . $wpdb->posts . '
		WHERE post_status="publish"
			AND post_type="post"
			AND post_password=""
		GROUP BY YEAR(post_date),
			MONTH(post_date)
		ORDER BY post_date DESC';
    // use get_results to do a query directly on the database
    $archiveSummary = $wpdb->get_results($sql);
    // if there are any posts
    if ($archiveSummary) {
        $output = '<div class="archives">';
        // loop through the posts
        foreach ($archiveSummary as $date) {
            // reset the query variable
            unset($bmWp);
            // create a new query variable for the current month and year combination
            $bmWp = new WP_Query('year=' . $date->year . '&monthnum=' . zeroise($date->month, 2) . '&posts_per_page=-1');
            // if there are any posts for that month display them
            if ($bmWp->have_posts()) {
                // display the archives heading
                $url = get_month_link($date->year, $date->month);
                $text = $month[zeroise($date->month, 2)] . ' ' . $date->year;
                $output .= get_archives_link($url, $text, '', '<h3>', '</h3>');
                $output .= '<ul class="postspermonth">';
                // display an unordered list of posts for the current month
                while ($bmWp->have_posts()) {
                    $bmWp->the_post();
                    $output .= '<li><a href="' . get_permalink($bmWp->post) . '" title="' . esc_html($text, 1) . '">' . wptexturize($bmWp->post->post_title) . '</a></li>';
                }
                $output .= '</ul>';
            }
        }
        $output .= '</div><!-- .archives -->';
        return $output;
    }
}
Exemplo n.º 19
0
 function _exitingDir($directory = null, $file = null)
 {
     $y = $this->_year;
     if ($mos =& $this->_months) {
         sort($mos);
         $list = '';
         $linearlist = array();
         foreach ($mos as $mth) {
             $lnk = get_month_link($y, $mth);
             $the_month = theme_date_format(mktime(0, 0, 0, $mth, 1, 0), '%B');
             $list = "<li class=\"archive-month archive-m{$mth}\"><a href=\"{$lnk}\">" . $the_month . ' </a></li>' . $list;
             $linearlist["{$the_month} 20{$this->_year}"] = $lnk;
         }
         $list = '<ul>' . $list . '</ul>';
     }
     $mos = array();
     // we close year's li
     $this->_list[$y] = $linearlist;
     $this->_htmllist[$y] .= $list . '</li>';
 }
 function get_items_montly($args, $last_changed, $join, $where, $order, $limit, $nested = true)
 {
     global $wpdb, $wp_locale;
     $output = array();
     $defaults = array('show_year' => true);
     $r = wp_parse_args($args, $defaults);
     extract($r, EXTR_SKIP);
     $where = $where;
     //will need to specify which year we're looking for
     $query = "SELECT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, count(ID) as posts FROM {$wpdb->posts} {$join} {$where} GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date {$order} {$limit}";
     $key = md5($query);
     $key = "wp_get_archives:{$key}:{$last_changed}";
     if (!($results = wp_cache_get($key, 'posts'))) {
         $results = $wpdb->get_results($query);
         wp_cache_set($key, $results, 'posts');
     }
     if ($results) {
         foreach ((array) $results as $result) {
             $url = get_month_link($result->year, $result->month);
             /* translators: 1: month name, 2: 4-digit year */
             if ($show_year && !$nested) {
                 $text = sprintf(__('%1$s %2$d'), $wp_locale->get_month($result->month), $result->year);
             } else {
                 $text = sprintf(__('%1$s'), $wp_locale->get_month($result->month));
             }
             if ($nested) {
                 $output[$result->year][] = $this->get_archives_link($url, $text);
             } else {
                 $output[] = $this->get_archives_link($url, $text);
             }
         }
     }
     if ($nested) {
         $out2 = array();
         foreach ($output as $year => $months) {
             $out2[] = array('name' => $year, 'children' => $months);
         }
         return $out2;
     }
     return $output;
 }
 function blog_multimeta($instance)
 {
     global $post;
     if ($instance["mdate"] == 'true') {
         $mshowtime = isset($instance['mshowtime']) ? $instance['mshowtime'] : '';
         if ($mshowtime) {
             $mtime = the_time();
         }
         $out[] = '<span class="date"><a href="' . get_month_link(get_the_time('Y'), get_the_time('m')) . '">' . get_the_date() . ' ' . $mtime . '</a></span>';
     }
     if ($instance["mauthor"] == 'true') {
         $out[] = '<span class="author">' . __('By: ', THEME_LANG_DOMAIN) . '<a href="' . esc_url(get_author_posts_url(get_the_author_meta('ID'))) . '">' . get_the_author() . '</a></span>';
     }
     if ($instance["mcomments"] == "true" && ($post->comment_count > 0 || comments_open())) {
         ob_start();
         comments_popup_link(__('No Comments', THEME_LANG_DOMAIN), __('1 Comment', THEME_LANG_DOMAIN), __('% Comments', THEME_LANG_DOMAIN), '');
         $out[] = '<span class="comments">' . ob_get_clean() . '</span>';
     }
     if (count($out) != 0) {
         $output = '<div class="post-meta">';
         $output .= join(' ' . $instance["mmseperator"] . ' ', $out) . '</div>';
     }
     unset($out);
     $tax = '';
     if ($instance["mcats"] == 'ameta') {
         $_tax = get_the_taxonomies();
         if (empty($_tax)) {
         } else {
             foreach ($_tax as $key => $value) {
                 preg_match('/(.+?): /i', $value, $matches);
                 $tax[] = '<span class="entry-tax-' . $key . '">' . str_replace($matches[0], '<span class="entry-tax-meta">' . $matches[1] . ':</span> ', $value) . '</span>';
             }
         }
         if (count($tax) != 0) {
             $output .= '<div class="post-taxonomy">' . join('<br />', $tax) . '</div>';
         }
         unset($_tax);
     }
     return $output;
 }
/**
 * Function BX_archive
 * ------------------------------------------------------
 * This function is based on WP's built-in get_archives()
 * It outputs the following:
 *
 * <h3><a href="link">Month Year</a></h3>
 * <ul class="postspermonth">
 *     <li><a href="link">Post title</a> (Comment count)</li>
 *     [..]
 * </ul>
 */
function BX_archive()
{
    global $month, $wpdb;
    $now = current_time('mysql');
    $arcresults = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS year, MONTH(post_date) AS month, count(ID) as posts FROM " . $wpdb->posts . " WHERE post_date <'" . $now . "' AND post_status='publish' AND post_password='' GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date DESC");
    if ($arcresults) {
        foreach ($arcresults as $arcresult) {
            $url = get_month_link($arcresult->year, $arcresult->month);
            $text = sprintf('%s %d', $month[zeroise($arcresult->month, 2)], $arcresult->year);
            echo get_archives_link($url, $text, '', '<h3>', '</h3>');
            $thismonth = zeroise($arcresult->month, 2);
            $thisyear = $arcresult->year;
            $arcresults2 = $wpdb->get_results("SELECT ID, post_date, post_title, comment_status FROM " . $wpdb->posts . " WHERE post_date LIKE '{$thisyear}-{$thismonth}-%' AND post_status='publish' AND post_password='' ORDER BY post_date DESC");
            if ($arcresults2) {
                echo "<ul class=\"postspermonth\">\n";
                foreach ($arcresults2 as $arcresult2) {
                    if ($arcresult2->post_date != '0000-00-00 00:00:00') {
                        $url = get_permalink($arcresult2->ID);
                        $arc_title = $arcresult2->post_title;
                        if ($arc_title) {
                            $text = strip_tags($arc_title);
                        } else {
                            $text = $arcresult2->ID;
                        }
                        echo "<li>" . get_archives_link($url, $text, '');
                        $comments = mysql_query("SELECT * FROM " . $wpdb->comments . " WHERE comment_post_ID=" . $arcresult2->ID);
                        $comments_count = mysql_num_rows($comments);
                        if ($arcresult2->comment_status == "open" or $comments_count > 0) {
                            echo '&nbsp;(' . $comments_count . ')';
                        }
                        echo "</li>\n";
                    }
                }
                echo "</ul>\n";
            }
        }
    }
}
function get_monthly_archives()
{
    $monthly_archives_l = '';
    $monthly_archives_r = '';
    $now = date('Y-m-d H:i:s');
    $yr_mths = $wpdb->get_col("SELECT YEAR(post_date) AS year, MONTH(post_date) AS month, COUNT(post_id) AS cnt FROM {$wpdb->posts} WHERE post_status = 'publish' AND post_type = 'post' ORDER BY post_date DESC");
    $size = count($yr_mths);
    $count = 1;
    $monthly_archives_l .= "<ul class=\"archlist-left\">\n";
    foreach ($yr_mths as $yr_mth) {
        if ($count & 1) {
            $month = substr('0' . $yr_mth->month, -2, 2);
            $monthly_archives_l .= '<li><a href="' . get_month_link($yr_mth->year, $month->month) . '" title="View entries in ' . "{$yr_mth->month_name()}, {$yr_mth->year}" . '">' . "{$yr_mth->year}, {$yr_mth->month_name()}</a></li>\n";
        }
        $count++;
    }
    if ($count == 1) {
        $monthly_archives_r .= "<li></li>\n</ul>\n";
    } else {
        $monthly_archives_r .= "</ul>\n";
    }
    reset($yr_mths);
    $count = 1;
    $monthly_archives_r .= "<ul class=\"archlist-right\">\n";
    foreach ($yr_mths as $yr_mth) {
        if (!($count & 1)) {
            $month = substr('0' . $yr_mth->month, -2, 2);
            $monthly_archives_r .= '<li><a href="' . URL::get('display_entries_by_date', array('year' => $yr_mth->year, 'month' => $month)) . '" title="View entries in ' . "{$yr_mth->month_name}, {$yr_mth->year}" . '">' . "{$yr_mth->month_name} :: {$yr_mth->year}</a></li>\n";
        }
        $count++;
    }
    if ($count == 2) {
        $monthly_archives_r .= "<li></li>\n</ul>\n";
    } else {
        $monthly_archives_r .= "</ul>\n";
    }
    return "<div id=\"archives\">" . $monthly_archives_l . "\n" . $monthly_archives_r . "<br class=\"clear\" />\n</div>";
}
Exemplo n.º 24
0
 function waves_breadcrumbs()
 {
     /* === OPTIONS === */
     $text['home'] = __('<i class="fa fa-home"></i>', 'waves');
     // text for the 'Home' link
     $text['category'] = __('Archive by Category "%s"', 'waves');
     // text for a category page
     $text['search'] = __('Search Results for "%s" Query', 'waves');
     // text for a search results page
     $text['tag'] = __('Posts Tagged "%s"', 'waves');
     // text for a tag page
     $text['author'] = __('Articles Posted by %s', 'waves');
     // text for an author page
     $text['404'] = __('Error 404', 'waves');
     // text for the 404 page
     $showCurrent = 1;
     // 1 - show current post/page title in breadcrumbs, 0 - don't show
     $showOnHome = 0;
     // 1 - show breadcrumbs on the homepage, 0 - don't show
     $breadcrumb_char = get_theme_mod('breadcrumb_char', '1');
     if ($breadcrumb_char) {
         switch ($breadcrumb_char) {
             case '2':
                 $delimiter = ' // ';
                 break;
             case '3':
                 $delimiter = ' > ';
                 break;
             case '1':
             default:
                 $delimiter = ' &raquo; ';
                 break;
         }
     }
     $before = '<span class="current">';
     // tag before the current crumb
     $after = '</span>';
     // tag after the current crumb
     /* === END OF OPTIONS === */
     global $post;
     $homeLink = home_url() . '/';
     $linkBefore = '<span typeof="v:Breadcrumb">';
     $linkAfter = '</span>';
     $linkAttr = ' rel="v:url" property="v:title"';
     $link = $linkBefore . '<a' . $linkAttr . ' href="%1$s">%2$s</a>' . $linkAfter;
     if (is_home() || is_front_page()) {
         if ($showOnHome == 1) {
             echo '<div id="crumbs"><a href="' . $homeLink . '">' . $text['home'] . '</a></div>';
         }
     } else {
         echo '<div id="crumbs" xmlns:v="http://rdf.data-vocabulary.org/#">' . sprintf($link, $homeLink, $text['home']) . $delimiter;
         if (is_category()) {
             $thisCat = get_category(get_query_var('cat'), false);
             if ($thisCat->parent != 0) {
                 $cats = get_category_parents($thisCat->parent, TRUE, $delimiter);
                 $cats = str_replace('<a', $linkBefore . '<a' . $linkAttr, $cats);
                 $cats = str_replace('</a>', '</a>' . $linkAfter, $cats);
                 echo $cats;
             }
             echo $before . sprintf($text['category'], single_cat_title('', false)) . $after;
         } elseif (is_search()) {
             echo $before . sprintf($text['search'], get_search_query()) . $after;
         } elseif (is_day()) {
             echo sprintf($link, get_year_link(get_the_time('Y')), get_the_time('Y')) . $delimiter;
             echo sprintf($link, get_month_link(get_the_time('Y'), get_the_time('m')), get_the_time('F')) . $delimiter;
             echo $before . get_the_time('d') . $after;
         } elseif (is_month()) {
             echo sprintf($link, get_year_link(get_the_time('Y')), get_the_time('Y')) . $delimiter;
             echo $before . get_the_time('F') . $after;
         } elseif (is_year()) {
             echo $before . get_the_time('Y') . $after;
         } elseif (is_single() && !is_attachment()) {
             if (get_post_type() != 'post') {
                 $post_type = get_post_type_object(get_post_type());
                 $slug = $post_type->rewrite;
                 printf($link, $homeLink . '/' . $slug['slug'] . '/', $post_type->labels->singular_name);
                 if ($showCurrent == 1) {
                     echo $delimiter . $before . get_the_title() . $after;
                 }
             } else {
                 $cat = get_the_category();
                 $cat = $cat[0];
                 $cats = get_category_parents($cat, TRUE, $delimiter);
                 if ($showCurrent == 0) {
                     $cats = preg_replace("#^(.+){$delimiter}\$#", "\$1", $cats);
                 }
                 $cats = str_replace('<a', $linkBefore . '<a' . $linkAttr, $cats);
                 $cats = str_replace('</a>', '</a>' . $linkAfter, $cats);
                 echo $cats;
                 if ($showCurrent == 1) {
                     echo $before . get_the_title() . $after;
                 }
             }
         } elseif (!is_single() && !is_page() && get_post_type() != 'post' && !is_404()) {
             $post_type = get_post_type_object(get_post_type());
             echo $before . $post_type->labels->singular_name . $after;
         } elseif (is_attachment()) {
             $parent = get_post($post->post_parent);
             $cat = get_the_category($parent->ID);
             $cat = $cat[0];
             $cats = get_category_parents($cat, TRUE, $delimiter);
             $cats = str_replace('<a', $linkBefore . '<a' . $linkAttr, $cats);
             $cats = str_replace('</a>', '</a>' . $linkAfter, $cats);
             echo $cats;
             printf($link, get_permalink($parent), $parent->post_title);
             if ($showCurrent == 1) {
                 echo $delimiter . $before . get_the_title() . $after;
             }
         } elseif (is_page() && !$post->post_parent) {
             if ($showCurrent == 1) {
                 echo $before . get_the_title() . $after;
             }
         } elseif (is_page() && $post->post_parent) {
             $parent_id = $post->post_parent;
             $breadcrumbs = array();
             while ($parent_id) {
                 $page = get_page($parent_id);
                 $breadcrumbs[] = sprintf($link, get_permalink($page->ID), get_the_title($page->ID));
                 $parent_id = $page->post_parent;
             }
             $breadcrumbs = array_reverse($breadcrumbs);
             for ($i = 0; $i < count($breadcrumbs); $i++) {
                 echo $breadcrumbs[$i];
                 if ($i != count($breadcrumbs) - 1) {
                     echo $delimiter;
                 }
             }
             if ($showCurrent == 1) {
                 echo $delimiter . $before . get_the_title() . $after;
             }
         } elseif (is_tag()) {
             echo $before . sprintf($text['tag'], single_tag_title('', false)) . $after;
         } elseif (is_author()) {
             global $author;
             $userdata = get_userdata($author);
             echo $before . sprintf($text['author'], $userdata->display_name) . $after;
         } elseif (is_404()) {
             echo $before . $text['404'] . $after;
         }
         if (get_query_var('paged')) {
             if (is_category() || is_day() || is_month() || is_year() || is_search() || is_tag() || is_author()) {
                 echo ' (';
             }
             echo __('Page', 'waves') . ' ' . get_query_var('paged');
             if (is_category() || is_day() || is_month() || is_year() || is_search() || is_tag() || is_author()) {
                 echo ')';
             }
         }
         echo '</div>';
     }
 }
Exemplo n.º 25
0
function dimox_breadcrumbs()
{
    /* === ОПЦИИ === */
    $text['home'] = 'Home';
    // текст ссылки "Главная"
    $text['category'] = 'Archive category "%s"';
    // текст для страницы рубрики
    $text['search'] = 'Serch result "%s"';
    // текст для страницы с результатами поиска
    $text['tag'] = 'Posts with tag "%s"';
    // текст для страницы тега
    $text['author'] = 'Author posts %s';
    // текст для страницы автора
    $text['404'] = 'Error 404';
    // текст для страницы 404
    $show_current = 1;
    // 1 - показывать название текущей статьи/страницы/рубрики, 0 - не показывать
    $show_on_home = 0;
    // 1 - показывать "хлебные крошки" на главной странице, 0 - не показывать
    $show_home_link = 1;
    // 1 - показывать ссылку "Главная", 0 - не показывать
    $show_title = 1;
    // 1 - показывать подсказку (title) для ссылок, 0 - не показывать
    $delimiter = ' <span class="tr"></span> ';
    // разделить между "крошками"
    $before = '<span class="text">';
    // тег перед текущей "крошкой"
    $after = '</span>';
    // тег после текущей "крошки"
    /* === КОНЕЦ ОПЦИЙ === */
    global $post;
    $home_link = home_url('/');
    $link_before = '<span typeof="v:Breadcrumb">';
    $link_after = '</span>';
    $link_attr = ' rel="v:url" property="v:title"';
    $link = $link_before . '<a' . $link_attr . ' href="%1$s">%2$s</a>' . $link_after;
    $parent_id = $parent_id_2 = $post->post_parent;
    $frontpage_id = get_option('page_on_front');
    $style = '';
    if (function_exists('is_product')) {
        if (is_product()) {
            $style = ' style="text-align: left;"';
        }
    }
    if (is_home() || is_front_page()) {
        if ($show_on_home == 1) {
            echo '<div class="breadcrumbs" ' . $style . '><a href="' . $home_link . '">' . $text['home'] . '</a></div>';
        }
    } else {
        echo '<div class="breadcrumbs" xmlns:v="http://rdf.data-vocabulary.org/#" ' . $style . '>';
        if ($show_home_link == 1) {
            echo '<a href="' . $home_link . '" rel="v:url" property="v:title">' . $text['home'] . '</a>';
            if ($frontpage_id == 0 || $parent_id != $frontpage_id) {
                echo $delimiter;
            }
        }
        if (is_category()) {
            $this_cat = get_category(get_query_var('cat'), false);
            if ($this_cat->parent != 0) {
                $cats = get_category_parents($this_cat->parent, TRUE, $delimiter);
                if ($show_current == 0) {
                    $cats = preg_replace("#^(.+){$delimiter}\$#", "\$1", $cats);
                }
                $cats = str_replace('<a', $link_before . '<a' . $link_attr, $cats);
                $cats = str_replace('</a>', '</a>' . $link_after, $cats);
                if ($show_title == 0) {
                    $cats = preg_replace('/ title="(.*?)"/', '', $cats);
                }
                echo $cats;
            }
            if ($show_current == 1) {
                echo $before . sprintf($text['category'], single_cat_title('', false)) . $after;
            }
        } elseif (is_search()) {
            echo $before . sprintf($text['search'], get_search_query()) . $after;
        } elseif (is_day()) {
            echo sprintf($link, get_year_link(get_the_time('Y')), get_the_time('Y')) . $delimiter;
            echo sprintf($link, get_month_link(get_the_time('Y'), get_the_time('m')), get_the_time('F')) . $delimiter;
            echo $before . get_the_time('d') . $after;
        } elseif (is_month()) {
            echo sprintf($link, get_year_link(get_the_time('Y')), get_the_time('Y')) . $delimiter;
            echo $before . get_the_time('F') . $after;
        } elseif (is_year()) {
            echo $before . get_the_time('Y') . $after;
        } elseif (is_single() && !is_attachment()) {
            if (get_post_type() != 'post') {
                $post_type = get_post_type_object(get_post_type());
                $slug = $post_type->rewrite;
                //printf($link, $home_link . '/' . $slug['slug'] . '/', $post_type->labels->singular_name);
                if ($show_current == 1) {
                    echo $before . get_the_title() . $after;
                }
            } else {
                $cat = get_the_category();
                $cat = $cat[0];
                $cats = get_category_parents($cat, TRUE, $delimiter);
                if ($show_current == 0) {
                    $cats = preg_replace("#^(.+){$delimiter}\$#", "\$1", $cats);
                }
                $cats = str_replace('<a', $link_before . '<a' . $link_attr, $cats);
                $cats = str_replace('</a>', '</a>' . $link_after, $cats);
                if ($show_title == 0) {
                    $cats = preg_replace('/ title="(.*?)"/', '', $cats);
                }
                echo $cats;
                if ($show_current == 1) {
                    echo $before . get_the_title() . $after;
                }
            }
        } elseif (!is_single() && !is_page() && get_post_type() != 'post' && !is_404()) {
            $post_type = get_post_type_object(get_post_type());
            echo $before . $post_type->labels->singular_name . $after;
        } elseif (is_attachment()) {
            $parent = get_post($parent_id);
            $cat = get_the_category($parent->ID);
            $cat = $cat[0];
            $cats = get_category_parents($cat, TRUE, $delimiter);
            $cats = str_replace('<a', $link_before . '<a' . $link_attr, $cats);
            $cats = str_replace('</a>', '</a>' . $link_after, $cats);
            if ($show_title == 0) {
                $cats = preg_replace('/ title="(.*?)"/', '', $cats);
            }
            echo $cats;
            printf($link, get_permalink($parent), $parent->post_title);
            if ($show_current == 1) {
                echo $delimiter . $before . get_the_title() . $after;
            }
        } elseif (is_page() && !$parent_id) {
            if ($show_current == 1) {
                echo $before . get_the_title() . $after;
            }
        } elseif (is_page() && $parent_id) {
            if ($parent_id != $frontpage_id) {
                $breadcrumbs = array();
                while ($parent_id) {
                    $page = get_page($parent_id);
                    if ($parent_id != $frontpage_id) {
                        $breadcrumbs[] = sprintf($link, get_permalink($page->ID), get_the_title($page->ID));
                    }
                    $parent_id = $page->post_parent;
                }
                $breadcrumbs = array_reverse($breadcrumbs);
                for ($i = 0; $i < count($breadcrumbs); $i++) {
                    echo $breadcrumbs[$i];
                    if ($i != count($breadcrumbs) - 1) {
                        echo $delimiter;
                    }
                }
            }
            if ($show_current == 1) {
                if ($show_home_link == 1 || $parent_id_2 != 0 && $parent_id_2 != $frontpage_id) {
                    echo $delimiter;
                }
                echo $before . get_the_title() . $after;
            }
        } elseif (is_tag()) {
            echo $before . sprintf($text['tag'], single_tag_title('', false)) . $after;
        } elseif (is_author()) {
            global $author;
            $userdata = get_userdata($author);
            echo $before . sprintf($text['author'], $userdata->display_name) . $after;
        } elseif (is_404()) {
            echo $before . $text['404'] . $after;
        }
        if (get_query_var('paged')) {
            if (is_category() || is_day() || is_month() || is_year() || is_search() || is_tag() || is_author()) {
                echo ' (';
            }
            echo ' ' . __('Page') . ' ' . get_query_var('paged');
            if (is_category() || is_day() || is_month() || is_year() || is_search() || is_tag() || is_author()) {
                echo ')';
            }
        }
        echo '</div><!-- .breadcrumbs -->';
    }
}
Exemplo n.º 26
0
 /**
  * This function normally outputs the canonical but is also used in other places to retrieve
  * the canonical URL for the current page.
  *
  * @param bool $echo        Whether or not to output the canonical element.
  * @param bool $un_paged    Whether or not to return the canonical with or without pagination added to the URL.
  * @param bool $no_override Whether or not to return a manually overridden canonical
  *
  * @return string $canonical
  */
 public function canonical($echo = true, $un_paged = false, $no_override = false)
 {
     $canonical = false;
     $skip_pagination = false;
     // Set decent canonicals for homepage, singulars and taxonomy pages
     if (is_singular()) {
         $meta_canon = WPSEO_Meta::get_value('canonical');
         if ($no_override === false && $meta_canon !== '') {
             $canonical = $meta_canon;
             $skip_pagination = true;
         } else {
             $obj = get_queried_object();
             $canonical = get_permalink($obj->ID);
             // Fix paginated pages canonical, but only if the page is truly paginated.
             if (get_query_var('page') > 1) {
                 global $wp_rewrite;
                 $numpages = substr_count($obj->post_content, '<!--nextpage-->') + 1;
                 if ($numpages && get_query_var('page') <= $numpages) {
                     if (!$wp_rewrite->using_permalinks()) {
                         $canonical = add_query_arg('page', get_query_var('page'), $canonical);
                     } else {
                         $canonical = user_trailingslashit(trailingslashit($canonical) . get_query_var('page'));
                     }
                 }
             }
         }
         unset($meta_canon);
     } else {
         if (is_search()) {
             $canonical = get_search_link();
         } elseif (is_front_page()) {
             $canonical = home_url('/');
         } elseif ($this->is_posts_page()) {
             $canonical = get_permalink(get_option('page_for_posts'));
         } elseif (is_tax() || is_tag() || is_category()) {
             $term = get_queried_object();
             if ($no_override === false) {
                 $canonical = WPSEO_Taxonomy_Meta::get_term_meta($term, $term->taxonomy, 'canonical');
                 if (is_string($canonical) && $canonical !== '') {
                     $skip_pagination = true;
                 }
             }
             if (!is_string($canonical) || $canonical === '') {
                 $canonical = get_term_link($term, $term->taxonomy);
             }
         } elseif (is_post_type_archive()) {
             $post_type = get_query_var('post_type');
             if (is_array($post_type)) {
                 $post_type = reset($post_type);
             }
             $canonical = get_post_type_archive_link($post_type);
         } elseif (is_author()) {
             $canonical = get_author_posts_url(get_query_var('author'), get_query_var('author_name'));
         } elseif (is_archive()) {
             if (is_date()) {
                 if (is_day()) {
                     $canonical = get_day_link(get_query_var('year'), get_query_var('monthnum'), get_query_var('day'));
                 } elseif (is_month()) {
                     $canonical = get_month_link(get_query_var('year'), get_query_var('monthnum'));
                 } elseif (is_year()) {
                     $canonical = get_year_link(get_query_var('year'));
                 }
             }
         }
     }
     if ($canonical && $un_paged) {
         return $canonical;
     }
     if ($canonical && !$skip_pagination && get_query_var('paged') > 1) {
         global $wp_rewrite;
         if (!$wp_rewrite->using_permalinks()) {
             $canonical = add_query_arg('paged', get_query_var('paged'), $canonical);
         } else {
             if (is_front_page()) {
                 $base = $wp_rewrite->using_index_permalinks() ? 'index.php/' : '/';
                 $canonical = home_url($base);
             }
             $canonical = user_trailingslashit(trailingslashit($canonical) . trailingslashit($wp_rewrite->pagination_base) . get_query_var('paged'));
         }
     }
     if ($canonical && 'default' !== $this->options['force_transport']) {
         $canonical = preg_replace('`^http[s]?`', $this->options['force_transport'], $canonical);
     }
     /**
      * Filter: 'wpseo_canonical' - Allow filtering of the canonical URL put out by WP SEO
      *
      * @api string $canonical The canonical URL
      */
     $canonical = apply_filters('wpseo_canonical', $canonical);
     if (is_string($canonical) && $canonical !== '') {
         if ($echo !== false) {
             echo '<link rel="canonical" href="' . esc_url($canonical, null, 'other') . '" />' . "\n";
         } else {
             return $canonical;
         }
     } else {
         return false;
     }
 }
Exemplo n.º 27
0
function make_breadcrumbs($opts = array('show_on_home' => 0, 'delimiter' => '&raquo;', 'home' => 'Home', 'showCurrent' => 1, 'before' => '<span class="current">', 'after' => '</span>'))
{
    $showOnHome = $opts['show_on_home'];
    // 1 - show breadcrumbs on the homepage, 0 - don't show
    $delimiter = $opts['delimiter'];
    // delimiter between crumbs
    $home = $opts['home'];
    // text for the 'Home' link
    $showCurrent = $opts['showCurrent'];
    // 1 - show current post/page title in breadcrumbs, 0 - don't show
    $before = $opts['before'];
    // tag before the current crumb
    $after = $opts['after'];
    // tag after the current crumb
    global $post;
    $homeLink = get_bloginfo('url');
    if (is_home() || is_front_page()) {
        if ($showOnHome == 1) {
            echo '<ul><li><a href="' . $homeLink . '">' . $home . '</a></li></ul>';
        }
    } else {
        echo "<ul>\n  <li><a href=\"{$homeLink}\">{$home}</a></li>\n  {$delimiter}" . "\n";
        if (is_category()) {
            global $wp_query;
            $cat_obj = $wp_query->get_queried_object();
            $thisCat = $cat_obj->term_id;
            $thisCat = get_category($thisCat);
            $parentCat = get_category($thisCat->parent);
            if ($thisCat->parent != 0) {
                echo "  <li>" . get_category_parents($parentCat, TRUE, "</li>\n  {$delimiter}\n  <li>");
            }
            echo $before . 'Archive by category "' . single_cat_title('', false) . '"' . $after . "</li>" . "\n";
        } elseif (is_search()) {
            echo '  <li>' . $before . 'Search results for "' . get_search_query() . '"' . $after . "</li>" . "\n";
        } elseif (is_day()) {
            echo '  <li><a href="' . get_year_link(get_the_time('Y')) . '">' . get_the_time('Y') . "</a></li>\n" . $delimiter . "\n";
            echo '  <li><a href="' . get_month_link(get_the_time('Y'), get_the_time('m')) . '">' . get_the_time('F') . "</a></li>" . "\n" . $delimiter . "\n";
            echo '  <li>' . $before . get_the_time('d') . $after . "</li>\n";
        } elseif (is_month()) {
            echo '  <li><a href="' . get_year_link(get_the_time('Y')) . '">' . get_the_time('Y') . "</a></li>\n" . $delimiter . "\n";
            echo '  <li>' . $before . get_the_time('F') . $after . "</li>\n";
        } elseif (is_year()) {
            echo '  <li>' . $before . get_the_time('Y') . $after . "</li>\n";
        } elseif (is_single() && !is_attachment()) {
            if (get_post_type() != 'post') {
                $post_type = get_post_type_object(get_post_type());
                $slug = $post_type->rewrite;
                echo '  <li><a href="' . $homeLink . '/' . $slug['slug'] . '/">' . $post_type->labels->singular_name . '</a></li>' . "\n";
                if ($showCurrent == 1) {
                    echo $delimiter . "\n  <li>" . $before . get_the_title() . $after . '</li>' . "\n";
                }
            } else {
                $cat = get_the_category();
                $cat = $cat[0];
                $cats = get_category_parents($cat, TRUE, "</li>\n  " . $delimiter . "\n  <li>");
                if ($showCurrent == 0) {
                    $cats = preg_replace("/^(.+)\\s{$delimiter}\\s\$/", "\$1", $cats);
                }
                echo "<li>" . $cats;
                if ($showCurrent == 1) {
                    echo $before . get_the_title() . $after . '</li>' . "\n";
                }
            }
        } elseif (!is_single() && !is_page() && get_post_type() != 'post' && !is_404()) {
            $post_type = get_post_type_object(get_post_type());
            echo '  <li>' . $before . $post_type->labels->singular_name . $after . '</li>' . "\n";
        } elseif (is_attachment()) {
            $parent = get_post($post->post_parent);
            if (has_term('', 'category', $parent->ID)) {
                $cat = get_the_category($parent->ID);
                $cat = $cat[0];
                $cats = get_category_parents($cat, TRUE, "</li>\n  " . $delimiter . "\n  <li>");
                if ($showCurrent == 0) {
                    $cats = preg_replace("/^(.+)\\s{$delimiter}\\s\$/", "\$1", $cats);
                }
                echo "  <li>" . $cats;
                echo '  <li><a href="' . get_permalink($parent) . '">' . $parent->post_title . '</a></li>' . "\n";
                if ($showCurrent == 1) {
                    echo ' ' . $delimiter . ' ' . '  <li>' . $before . get_the_title() . $after . '</li>' . "\n";
                }
            } else {
                if ($parent->post_title != 'Home') {
                    echo '  <li><a href="' . get_permalink($parent) . '">' . $parent->post_title . '</a></li>' . "\n  " . $delimiter . "\n";
                }
                if ($showCurrent == 1) {
                    echo '  <li>' . $before . get_the_title() . $after . '</li>' . "\n";
                }
            }
        } elseif (is_page() && !$post->post_parent) {
            if ($showCurrent == 1) {
                echo '  <li>' . $before . get_the_title() . $after . '</li>' . "\n";
            }
        } elseif (is_page() && $post->post_parent) {
            $parent_id = $post->post_parent;
            $breadcrumbs = array();
            while ($parent_id) {
                $page = get_page($parent_id);
                $breadcrumbs[] = '  <li><a href="' . get_permalink($page->ID) . '">' . get_the_title($page->ID) . '</a></li>' . "\n";
                $parent_id = $page->post_parent;
            }
            $breadcrumbs = array_reverse($breadcrumbs);
            foreach ($breadcrumbs as $crumb) {
                echo $crumb;
            }
            if ($showCurrent == 1) {
                echo $delimiter . "\n  <li>" . $before . get_the_title() . $after . '</li>' . "\n";
            }
        } elseif (is_tag()) {
            echo '  <li>' . $before . 'Posts tagged "' . single_tag_title('', false) . '"' . $after . '</li>' . "\n";
        } elseif (is_author()) {
            global $author;
            $userdata = get_userdata($author);
            echo '  <li>' . $before . 'Articles posted by ' . $userdata->display_name . $after . '</li>' . "\n";
        } elseif (is_404()) {
            echo '  <li>' . $before . 'Error 404' . $after . '</li>' . "\n";
        }
        if (get_query_var('paged')) {
            if (is_category() || is_day() || is_month() || is_year() || is_search() || is_tag() || is_author()) {
                echo ' (';
            }
            echo '  <li><span>&nbsp;&nbsp;-&nbsp;&nbsp;' . __('Page') . ' ' . get_query_var('paged') . '</span></li>' . "\n";
            if (is_category() || is_day() || is_month() || is_year() || is_search() || is_tag() || is_author()) {
                echo ')';
            }
        }
        echo "</ul>\n";
    }
}
Exemplo n.º 28
0
 /**
  * Turns %tag% from permalink structures into usable links for the breadcrumb trail.  This feels kind of
  * hackish for now because we're checking for specific %tag% examples and only doing it for the 'post' 
  * post type.  In the future, maybe it'll handle a wider variety of possibilities, especially for custom post
  * types.
  *
  * @since  0.6.0
  * @access public
  * @param  int    $post_id ID of the post whose parents we want.
  * @param  string $path    Path of a potential parent page.
  * @param  array  $args    Mixed arguments for the menu.
  * @return array
  */
 public function map_rewrite_tags($post_id, $path)
 {
     /* Get the post based on the post ID. */
     $post = get_post($post_id);
     /* If no post is returned, an error is returned, or the post does not have a 'post' post type, return. */
     if (empty($post) || is_wp_error($post) || 'post' !== $post->post_type) {
         return $trail;
     }
     /* Trim '/' from both sides of the $path. */
     $path = trim($path, '/');
     /* Split the $path into an array of strings. */
     $matches = explode('/', $path);
     /* If matches are found for the path. */
     if (is_array($matches)) {
         /* Loop through each of the matches, adding each to the $trail array. */
         foreach ($matches as $match) {
             /* Trim any '/' from the $match. */
             $tag = trim($match, '/');
             /* If using the %year% tag, add a link to the yearly archive. */
             if ('%year%' == $tag) {
                 $this->items[] = '<a href="' . esc_url(get_year_link(get_the_time('Y', $post_id))) . '">' . sprintf($this->args['labels']['archive_year'], get_the_time(_x('Y', 'yearly archives date format', 'toivo-lite'))) . '</a>';
             } elseif ('%monthnum%' == $tag) {
                 $this->items[] = '<a href="' . esc_url(get_month_link(get_the_time('Y', $post_id), get_the_time('m', $post_id))) . '">' . sprintf($this->args['labels']['archive_month'], get_the_time(_x('F', 'monthly archives date format', 'toivo-lite'))) . '</a>';
             } elseif ('%day%' == $tag) {
                 $this->items[] = '<a href="' . esc_url(get_day_link(get_the_time('Y', $post_id), get_the_time('m', $post_id), get_the_time('d', $post_id))) . '">' . sprintf($this->args['labels']['archive_day'], get_the_time(_x('j', 'daily archives date format', 'toivo-lite'))) . '</a>';
             } elseif ('%author%' == $tag) {
                 $this->items[] = '<a href="' . esc_url(get_author_posts_url($post->post_author)) . '">' . get_the_author_meta('display_name', $post->post_author) . '</a>';
             } elseif ('%category%' == $tag) {
                 /* Force override terms in this post type. */
                 $this->args['post_taxonomy'][$post->post_type] = false;
                 /* Get the post categories. */
                 $terms = get_the_category($post_id);
                 /* Check that categories were returned. */
                 if ($terms) {
                     /* Sort the terms by ID and get the first category. */
                     usort($terms, '_usort_terms_by_ID');
                     $term = get_term($terms[0], 'category');
                     /* If the category has a parent, add the hierarchy to the trail. */
                     if (0 < $term->parent) {
                         $this->do_term_parents($term->parent, 'category');
                     }
                     /* Add the category archive link to the trail. */
                     $this->items[] = '<a href="' . esc_url(get_term_link($term, 'category')) . '">' . $term->name . '</a>';
                 }
             }
         }
     }
 }
Exemplo n.º 29
0
function clean_my_archives($attr = array())
{
    // Set up some default variables that need to be empty.
    $clean = '';
    $current_year = '';
    $current_month = '';
    $current_day = '';
    $cache = array();
    // Default arguments.
    $defaults = array('limit' => -1, 'year' => '', 'month' => '', 'post_type' => 'post');
    $attr = shortcode_atts($defaults, $attr, 'clean-my-archives');
    // Set up some arguments to pass to WP_Query.
    $args = array('posts_per_page' => intval($attr['limit']), 'year' => $attr['year'] ? absint($attr['year']) : '', 'monthnum' => $attr['month'] ? absint($attr['month']) : '', 'post_type' => is_array($attr['post_type']) ? $attr['post_type'] : explode(',', $attr['post_type']), 'ignore_sticky_posts' => true);
    // Create a unique key for this particular set of archives.
    $key = md5(serialize(array_values($args)));
    // Check for a cached archives.
    $cache = wp_cache_get('clean_my_archives');
    // If there is a cached archive, return it instead of doing all the work we've already done.
    if (is_array($cache) && !empty($cache[$key])) {
        return $cache[$key];
    }
    // Query posts from the database.
    $loop = new WP_Query($args);
    // If posts were found, format them for output.
    if ($loop->have_posts()) {
        // Loop through the individual posts.
        while ($loop->have_posts()) {
            // Set up the post.
            $loop->the_post();
            // Get the post's year and month. We need this to compare it with the previous post date.
            $year = get_the_time('Y');
            $month = get_the_time('m');
            $daynum = get_the_time('d');
            // If the current date doesn't match this post's date, we need extra formatting.
            if ($current_year !== $year || $current_month !== $month) {
                // Close the list if this isn't the first post.
                if ($current_month && $current_year) {
                    $clean .= '</ul>';
                }
                // Set the current year and month to this post's year and month.
                $current_year = $year;
                $current_month = $month;
                $current_day = '';
                // Add a heading with the month and year and link it to the monthly archive.
                $clean .= sprintf('<h2 class="month-year"><a href="%s">%s</a></h2>', esc_url(get_month_link($current_year, $current_month)), esc_html(get_the_time(__('F Y', 'clean-my-archives'))));
                // Open a new unordered list.
                $clean .= '<ul>';
            }
            // Get the post's day.
            $day = sprintf('<span class="day">%s</span>', get_the_time(esc_html__('d:', 'clean-my-archives')));
            // Translators: %d is the comment count.
            $comments_num = sprintf(esc_html__('(%d)', 'clean-my-archives'), get_comments_number());
            $comments = sprintf('<span class="comments-number">%s</span>', $comments_num);
            // Check if there's a duplicate day so we can add a class.
            $duplicate_day = $current_day && $daynum === $current_day ? ' class="day-duplicate"' : '';
            $current_day = $daynum;
            // Add the post list item to the formatted archives.
            $clean .= the_title(sprintf('<li%s>%s <a href="%s" rel="bookmark">', $duplicate_day, $day, esc_url(get_permalink())), sprintf('</a> %s</li>', $comments), false);
        }
        // Close the final unordered list.
        $clean .= '</ul>';
    }
    // Wrap the list in a `<div>`.
    if ($clean) {
        $clean = sprintf('<div class="clean-my-archives">%s</div>', $clean);
    }
    // Reset the query to the page's original query.
    wp_reset_postdata();
    // Make sure $cache is an array.
    if (!is_array($cache)) {
        $cache = array();
    }
    // Set the cache for the plugin, so caching plugins can make this super fast.
    $cache[$key] = $clean;
    wp_cache_set('clean_my_archives', $cache);
    // Return the formatted archives.
    return $clean;
}
function get_calendar($daylength = 1)
{
    global $wpdb, $wp_id, $m, $monthnum, $year, $timedifference, $month, $weekday, $posts, $wp_month_format;
    // Quick check. If we have no posts at all, abort!
    if (!$posts) {
        $gotsome = $wpdb->get_var("SELECT ID from {$wpdb->posts[$wp_id]} WHERE post_status = 'publish' ORDER BY post_date DESC LIMIT 1");
        if (!$gotsome) {
            return;
        }
    }
    if (isset($_GET['w'])) {
        $w = '' . intval($_GET['w']);
    }
    $time_difference = get_settings('time_difference');
    // Let's figure out when we are
    if (!empty($monthnum) && !empty($year)) {
        $thismonth = '' . intval($monthnum);
        $thisyear = '' . intval($year);
    } elseif (!empty($w)) {
        // We need to get the month from MySQL
        $thisyear = '' . intval(substr($m, 0, 4));
        $d = ($w - 1) * 7 + 6;
        //it seems MySQL's weeks disagree with PHP's
        $thismonth = $wpdb->get_var("SELECT DATE_FORMAT((DATE_ADD('{$thisyear}0101', INTERVAL {$d} DAY) ), '%m')");
    } elseif (!empty($m)) {
        $calendar = substr($m, 0, 6);
        $thisyear = '' . intval(substr($m, 0, 4));
        if (strlen($m) < 6) {
            $thismonth = '01';
        } else {
            $thismonth = '' . intval(substr($m, 4, 2));
        }
    } else {
        $thisyear = intval(date('Y', time() + $time_difference * 3600));
        $thismonth = intval(date('m', time() + $time_difference * 3600));
    }
    $unixmonth = mktime(0, 0, 0, $thismonth, 1, $thisyear);
    // Get the next and previous month and year with at least one post
    $previous = $wpdb->get_row("SELECT DISTINCT MONTH( post_date ) AS month, YEAR( post_date ) AS year\n\t\t\tFROM {$wpdb->posts[$wp_id]}\n\t\t\tWHERE post_date < '{$thisyear}-{$thismonth}-01'\n\t\t\tAND post_status = 'publish'\n\t\t\t\t\t\t\t  ORDER BY post_date DESC\n\t\t\t\t\t\t\t  LIMIT 1");
    $next = $wpdb->get_row("SELECT  DISTINCT MONTH( post_date ) AS month, YEAR( post_date ) AS year\n\t\t\tFROM {$wpdb->posts[$wp_id]}\n\t\t\tWHERE post_date >  '{$thisyear}-{$thismonth}-01'\n\t\t\tAND MONTH( post_date ) != MONTH( '{$thisyear}-{$thismonth}-01' )\n\t\t\tAND post_status = 'publish'\n\t\t\t\t\t\t\t  ORDER  BY post_date ASC\n\t\t\t\t\t\t\t  LIMIT 1");
    $month_str = ereg_replace('%MONTH', $month[zeroise($thismonth, 2)], $wp_month_format);
    $month_str = ereg_replace('%YEAR', date('Y', $unixmonth), $month_str);
    echo '<table id="wp-calendar">
	<caption>' . $month_str . '</caption>
	<thead>
	<tr>';
    foreach ($weekday as $wd) {
        if (function_exists('mb_substr')) {
            echo "\n\t\t<th abbr='{$wd}' scope='col' title='{$wd}'>" . mb_substr($wd, 0, $daylength) . '</th>';
        } else {
            echo "\n\t\t<th abbr='{$wd}' scope='col' title='{$wd}'>" . substr($wd, 0, $daylength) . '</th>';
        }
    }
    echo '
	</tr>
	</thead>

	<tfoot>
	<tr>';
    if ($previous) {
        if (function_exists('mb_substr')) {
            $smonth_name = mb_substr($month[zeroise($previous->month, 2)], 0, 3);
        } else {
            $smonth_name = substr($month[zeroise($previous->month, 2)], 0, 3);
        }
        $month_str = ereg_replace('%MONTH', $month[zeroise($previous->month, 2)], $wp_month_format);
        $month_str = ereg_replace('%YEAR', date('Y', mktime(0, 0, 0, $previous->month, 1, $previous->year)), $month_str);
        echo "\n\t\t" . '<td abbr="' . $month[zeroise($previous->month, 2)] . '" colspan="3" id="prev"><a href="' . get_month_link($previous->year, $previous->month) . '" title="View posts for ' . $month_str . '">&laquo; ' . $smonth_name . '</a></td>';
    } else {
        echo "\n\t\t" . '<td colspan="3" id="prev" class="pad">&nbsp;</td>';
    }
    echo "\n\t\t" . '<td class="pad">&nbsp;</td>';
    if ($next) {
        if (function_exists('mb_substr')) {
            $smonth_name = mb_substr($month[zeroise($next->month, 2)], 0, 3);
        } else {
            $smonth_name = substr($month[zeroise($next->month, 2)], 0, 3);
        }
        $month_str = ereg_replace('%MONTH', $month[zeroise($next->month, 2)], $wp_month_format);
        $month_str = ereg_replace('%YEAR', date('Y', mktime(0, 0, 0, $next->month, 1, $next->year)), $month_str);
        echo "\n\t\t" . '<td abbr="' . $month[zeroise($next->month, 2)] . '" colspan="3" id="next"><a href="' . get_month_link($next->year, $next->month) . '" title="View posts for ' . $month_str . '">' . $smonth_name . ' &raquo;</a></td>';
    } else {
        echo "\n\t\t" . '<td colspan="3" id="next" class="pad">&nbsp;</td>';
    }
    echo '
	</tr>
	</tfoot>

	<tbody>
	<tr>';
    // Get days with posts
    $dayswithposts = $wpdb->get_results("SELECT DISTINCT DAYOFMONTH(post_date)\n\t\t\tFROM {$wpdb->posts[$wp_id]} WHERE MONTH(post_date) = {$thismonth}\n\t\t\tAND YEAR(post_date) = {$thisyear}\n\t\t\tAND post_status = 'publish'\n\t\t\tAND post_date < '" . date("Y-m-d H:i:s", time() + $time_difference * 3600) . "'", ARRAY_N);
    if ($dayswithposts) {
        foreach ($dayswithposts as $daywith) {
            $daywithpost[] = $daywith[0];
        }
    } else {
        $daywithpost = array();
    }
    if (strstr($_SERVER["HTTP_USER_AGENT"], "MSIE") || strstr(strtolower($_SERVER["HTTP_USER_AGENT"]), "camino") || strstr(strtolower($_SERVER["HTTP_USER_AGENT"]), "safari")) {
        $ak_title_separator = "\n";
    } else {
        $ak_title_separator = ", ";
    }
    $ak_titles_for_day = array();
    $ak_post_titles = $wpdb->get_results("SELECT post_title, DAYOFMONTH(post_date) as dom " . "FROM {$wpdb->posts[$wp_id]} " . "WHERE YEAR(post_date) = '{$thisyear}' " . "AND MONTH(post_date) = '{$thismonth}' " . "AND post_date < '" . date("Y-m-d H:i:s", time() + $time_difference * 3600) . "' " . "AND post_status = 'publish'");
    if ($ak_post_titles) {
        foreach ($ak_post_titles as $ak_post_title) {
            if (empty($ak_titles_for_day["day_" . $ak_post_title->dom])) {
                $ak_titles_for_day["day_" . $ak_post_title->dom] = '';
            }
            if (empty($ak_titles_for_day["{$ak_post_title->dom}"])) {
                // first one
                $ak_titles_for_day["{$ak_post_title->dom}"] = htmlspecialchars(stripslashes($ak_post_title->post_title));
            } else {
                $ak_titles_for_day["{$ak_post_title->dom}"] .= $ak_title_separator . htmlspecialchars(stripslashes($ak_post_title->post_title));
            }
        }
    }
    // See how much we should pad in the beginning
    $pad = intval(date('w', $unixmonth));
    if (0 != $pad) {
        echo "\n\t\t<td colspan='{$pad}' class='pad'>&nbsp;</td>";
    }
    $daysinmonth = intval(date('t', $unixmonth));
    for ($day = 1; $day <= $daysinmonth; ++$day) {
        if (isset($newrow) && $newrow) {
            echo "\n\t</tr>\n\t<tr>\n\t\t";
        }
        $newrow = false;
        if ($day == date('j', time() + $time_difference * 3600) && $thismonth == date('m', time() + $time_difference * 3600)) {
            echo '<td id="today">';
        } else {
            echo "<td>";
        }
        if (in_array($day, $daywithpost)) {
            // any posts today?
            echo '<a href="' . get_day_link($thisyear, $thismonth, $day) . "\" title=\"{$ak_titles_for_day[$day]}\">{$day}</a>";
        } else {
            echo $day;
        }
        echo '</td>';
        if (6 == date('w', mktime(0, 0, 0, $thismonth, $day, $thisyear))) {
            $newrow = true;
        }
    }
    $pad = 7 - date('w', mktime(0, 0, 0, $thismonth, $day, $thisyear));
    if ($pad != 0 && $pad != 7) {
        echo "\n\t\t<td class='pad' colspan='{$pad}'>&nbsp;</td>";
    }
    echo "\n\t</tr>\n\t</tbody>\n\t</table>";
}