• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP get_weekstartend函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中get_weekstartend函数的典型用法代码示例。如果您正苦于以下问题:PHP get_weekstartend函数的具体用法?PHP get_weekstartend怎么用?PHP get_weekstartend使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了get_weekstartend函数的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: wp_get_archives


//.........这里部分代码省略.........
                $output .= get_archives_link($url, $text, $r['format'], $r['before'], $r['after']);
            }
        }
    } elseif ('yearly' == $r['type']) {
        $query = "SELECT YEAR(post_date) AS `year`, count(ID) as posts FROM {$wpdb->posts} {$join} {$where} GROUP BY YEAR(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) {
            $after = $r['after'];
            foreach ((array) $results as $result) {
                $url = get_year_link($result->year);
                $text = sprintf('%d', $result->year);
                if ($r['show_post_count']) {
                    $r['after'] = ' (' . $result->posts . ')' . $after;
                }
                $output .= get_archives_link($url, $text, $r['format'], $r['before'], $r['after']);
            }
        }
    } elseif ('daily' == $r['type']) {
        $query = "SELECT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, DAYOFMONTH(post_date) AS `dayofmonth`, count(ID) as posts FROM {$wpdb->posts} {$join} {$where} GROUP BY YEAR(post_date), MONTH(post_date), DAYOFMONTH(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) {
            $after = $r['after'];
            foreach ((array) $results as $result) {
                $url = get_day_link($result->year, $result->month, $result->dayofmonth);
                $date = sprintf('%1$d-%2$02d-%3$02d 00:00:00', $result->year, $result->month, $result->dayofmonth);
                $text = mysql2date($archive_day_date_format, $date);
                if ($r['show_post_count']) {
                    $r['after'] = ' (' . $result->posts . ')' . $after;
                }
                $output .= get_archives_link($url, $text, $r['format'], $r['before'], $r['after']);
            }
        }
    } elseif ('weekly' == $r['type']) {
        $week = _wp_mysql_week('`post_date`');
        $query = "SELECT DISTINCT {$week} AS `week`, YEAR( `post_date` ) AS `yr`, DATE_FORMAT( `post_date`, '%Y-%m-%d' ) AS `yyyymmdd`, count( `ID` ) AS `posts` FROM `{$wpdb->posts}` {$join} {$where} GROUP BY {$week}, YEAR( `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');
        }
        $arc_w_last = '';
        if ($results) {
            $after = $r['after'];
            foreach ((array) $results as $result) {
                if ($result->week != $arc_w_last) {
                    $arc_year = $result->yr;
                    $arc_w_last = $result->week;
                    $arc_week = get_weekstartend($result->yyyymmdd, get_option('start_of_week'));
                    $arc_week_start = date_i18n($archive_week_start_date_format, $arc_week['start']);
                    $arc_week_end = date_i18n($archive_week_end_date_format, $arc_week['end']);
                    $url = sprintf('%1$s/%2$s%3$sm%4$s%5$s%6$sw%7$s%8$d', home_url(), '', '?', '=', $arc_year, '&', '=', $result->week);
                    $text = $arc_week_start . $archive_week_separator . $arc_week_end;
                    if ($r['show_post_count']) {
                        $r['after'] = ' (' . $result->posts . ')' . $after;
                    }
                    $output .= get_archives_link($url, $text, $r['format'], $r['before'], $r['after']);
                }
            }
        }
    } elseif ('postbypost' == $r['type'] || 'alpha' == $r['type']) {
        $orderby = 'alpha' == $r['type'] ? 'post_title ASC ' : 'post_date DESC, ID DESC ';
        $query = "SELECT * FROM {$wpdb->posts} {$join} {$where} ORDER BY {$orderby} {$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) {
                if ($result->post_date != '0000-00-00 00:00:00') {
                    $url = get_permalink($result);
                    if ($result->post_title) {
                        /** This filter is documented in wp-includes/post-template.php */
                        $text = strip_tags(apply_filters('the_title', $result->post_title, $result->ID));
                    } else {
                        $text = $result->ID;
                    }
                    $output .= get_archives_link($url, $text, $r['format'], $r['before'], $r['after']);
                }
            }
        }
    }
    if ($r['echo']) {
        echo $output;
    } else {
        return $output;
    }
}
开发者ID:jenoya,项目名称:final,代码行数:101,代码来源:general-template.php


示例2: get_items

 /**
  * @api
  * @param array|string $args
  * @return array|string
  */
 function get_items($args = null)
 {
     global $wpdb;
     $defaults = array('type' => 'monthly-nested', 'limit' => '', 'show_post_count' => false, 'order' => 'DESC', 'post_type' => 'post', 'show_year' => false, 'nested' => false);
     $args = wp_parse_args($args, $defaults);
     $post_type = $args['post_type'];
     $order = $args['order'];
     $nested = $args['nested'];
     $type = $args['type'];
     $limit = '';
     if ($type == 'yearlymonthly' || $type == 'yearmonth') {
         $type = 'monthly-nested';
     }
     if ($type == 'monthly-nested') {
         $nested = true;
     }
     if (!empty($args['limit'])) {
         $limit = absint($limit);
         $limit = ' LIMIT ' . $limit;
     }
     $order = strtoupper($order);
     if ($order !== 'ASC') {
         $order = 'DESC';
     }
     // this is what will separate dates on weekly archive links
     $archive_week_separator = '–';
     // over-ride general date format ? 0 = no: use the date format set in Options, 1 = yes: over-ride
     $archive_date_format_over_ride = 0;
     // options for daily archive (only if you over-ride the general date format)
     $archive_day_date_format = 'Y/m/d';
     // options for weekly archive (only if you over-ride the general date format)
     $archive_week_start_date_format = 'Y/m/d';
     $archive_week_end_date_format = 'Y/m/d';
     if (!$archive_date_format_over_ride) {
         $archive_day_date_format = get_option('date_format');
         $archive_week_start_date_format = get_option('date_format');
         $archive_week_end_date_format = get_option('date_format');
     }
     $where = $wpdb->prepare('WHERE post_type = "%s" AND post_status = "publish"', $post_type);
     $where = apply_filters('getarchives_where', $where, $args);
     $join = apply_filters('getarchives_join', '', $args);
     $output = array();
     $last_changed = wp_cache_get('last_changed', 'posts');
     if (!$last_changed) {
         $last_changed = microtime();
         wp_cache_set('last_changed', $last_changed, 'posts');
     }
     if ('monthly' == $type) {
         $output = $this->get_items_monthly($args, $last_changed, $join, $where, $order, $limit, $nested);
     } elseif ('yearly' == $type) {
         $output = $this->get_items_yearly($args, $last_changed, $join, $where, $order, $limit);
     } elseif ('monthly-nested' == $type) {
         $years = $this->get_items_yearly($args, $last_changed, $join, $where, $order, $limit);
         foreach ($years as &$year) {
             $args = array('show_year' => false);
             $year['children'] = $this->get_items_monthly($args, $last_changed, $join, $where, $order, $limit);
         }
         $output = $years;
     } elseif ('daily' == $type) {
         $query = "SELECT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, DAYOFMONTH(post_date) AS `dayofmonth`, count(ID) as posts FROM {$wpdb->posts} {$join} {$where} GROUP BY YEAR(post_date), MONTH(post_date), DAYOFMONTH(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);
             $cache = array();
             $cache[$key] = $results;
             wp_cache_set($key, $results, 'posts');
         }
         if ($results) {
             foreach ((array) $results as $result) {
                 $url = get_day_link($result->year, $result->month, $result->dayofmonth);
                 $date = sprintf('%1$d-%2$02d-%3$02d 00:00:00', $result->year, $result->month, $result->dayofmonth);
                 $text = mysql2date($archive_day_date_format, $date);
                 $output[] = $this->get_archives_link($url, $text);
             }
         }
     } elseif ('weekly' == $type) {
         $week = _wp_mysql_week('`post_date`');
         $query = "SELECT DISTINCT {$week} AS `week`, YEAR( `post_date` ) AS `yr`, DATE_FORMAT( `post_date`, '%Y-%m-%d' ) AS `yyyymmdd`, " . "count( `ID` ) AS `posts` FROM `{$wpdb->posts}` {$join} {$where} GROUP BY {$week}, YEAR( `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');
         }
         $arc_w_last = '';
         if ($results) {
             foreach ((array) $results as $result) {
                 if ($result->week != $arc_w_last) {
                     $arc_year = $result->yr;
                     $arc_w_last = $result->week;
                     $arc_week = get_weekstartend($result->yyyymmdd, get_option('start_of_week'));
                     $arc_week_start = date_i18n($archive_week_start_date_format, $arc_week['start']);
                     $arc_week_end = date_i18n($archive_week_end_date_format, $arc_week['end']);
                     $url = sprintf('%1$s/%2$s%3$sm%4$s%5$s%6$sw%7$s%8$d', home_url(), '', '?', '=', $arc_year, '&', '=', $result->week);
//.........这里部分代码省略.........
开发者ID:sdunham,项目名称:sustainable,代码行数:101,代码来源:timber-archives.php


示例3: wp_get_archives


//.........这里部分代码省略.........
        } else {
            $arcresults = $cache[$key];
        }
        if ($arcresults) {
            $afterafter = $after;
            foreach ((array) $arcresults as $arcresult) {
                $url = get_year_link($arcresult->year);
                $text = sprintf('%d', $arcresult->year);
                if ($show_post_count) {
                    $after = ' (' . $arcresult->posts . ')' . $afterafter;
                }
                $output .= get_archives_link($url, $text, $format, $before, $after);
            }
        }
    } elseif ('daily' == $type) {
        $query = "SELECT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, DAYOFMONTH(post_date) AS `dayofmonth`, count(ID) as posts FROM {$wpdb->posts} {$join} {$where} GROUP BY YEAR(post_date), MONTH(post_date), DAYOFMONTH(post_date) ORDER BY post_date DESC {$limit}";
        $key = md5($query);
        $cache = wp_cache_get('wp_get_archives', 'general');
        if (!isset($cache[$key])) {
            $arcresults = $wpdb->get_results($query);
            $cache[$key] = $arcresults;
            wp_cache_set('wp_get_archives', $cache, 'general');
        } else {
            $arcresults = $cache[$key];
        }
        if ($arcresults) {
            $afterafter = $after;
            foreach ((array) $arcresults as $arcresult) {
                $url = get_day_link($arcresult->year, $arcresult->month, $arcresult->dayofmonth);
                $date = sprintf('%1$d-%2$02d-%3$02d 00:00:00', $arcresult->year, $arcresult->month, $arcresult->dayofmonth);
                $text = mysql2date($archive_day_date_format, $date);
                if ($show_post_count) {
                    $after = ' (' . $arcresult->posts . ')' . $afterafter;
                }
                $output .= get_archives_link($url, $text, $format, $before, $after);
            }
        }
    } elseif ('weekly' == $type) {
        $week = _wp_mysql_week('`post_date`');
        $query = "SELECT DISTINCT {$week} AS `week`, YEAR( `post_date` ) AS `yr`, DATE_FORMAT( `post_date`, '%Y-%m-%d' ) AS `yyyymmdd`, count( `ID` ) AS `posts` FROM `{$wpdb->posts}` {$join} {$where} GROUP BY {$week}, YEAR( `post_date` ) ORDER BY `post_date` DESC {$limit}";
        $key = md5($query);
        $cache = wp_cache_get('wp_get_archives', 'general');
        if (!isset($cache[$key])) {
            $arcresults = $wpdb->get_results($query);
            $cache[$key] = $arcresults;
            wp_cache_set('wp_get_archives', $cache, 'general');
        } else {
            $arcresults = $cache[$key];
        }
        $arc_w_last = '';
        $afterafter = $after;
        if ($arcresults) {
            foreach ((array) $arcresults as $arcresult) {
                if ($arcresult->week != $arc_w_last) {
                    $arc_year = $arcresult->yr;
                    $arc_w_last = $arcresult->week;
                    $arc_week = get_weekstartend($arcresult->yyyymmdd, get_option('start_of_week'));
                    $arc_week_start = date_i18n($archive_week_start_date_format, $arc_week['start']);
                    $arc_week_end = date_i18n($archive_week_end_date_format, $arc_week['end']);
                    $url = sprintf('%1$s/%2$s%3$sm%4$s%5$s%6$sw%7$s%8$d', home_url(), '', '?', '=', $arc_year, '&', '=', $arcresult->week);
                    $text = $arc_week_start . $archive_week_separator . $arc_week_end;
                    if ($show_post_count) {
                        $after = ' (' . $arcresult->posts . ')' . $afterafter;
                    }
                    $output .= get_archives_link($url, $text, $format, $before, $after);
                }
            }
        }
    } elseif ('postbypost' == $type || 'alpha' == $type) {
        $orderby = 'alpha' == $type ? 'post_title ASC ' : 'post_date DESC ';
        $query = "SELECT * FROM {$wpdb->posts} {$join} {$where} ORDER BY {$orderby} {$limit}";
        $key = md5($query);
        $cache = wp_cache_get('wp_get_archives', 'general');
        if (!isset($cache[$key])) {
            $arcresults = $wpdb->get_results($query);
            $cache[$key] = $arcresults;
            wp_cache_set('wp_get_archives', $cache, 'general');
        } else {
            $arcresults = $cache[$key];
        }
        if ($arcresults) {
            foreach ((array) $arcresults as $arcresult) {
                if ($arcresult->post_date != '0000-00-00 00:00:00') {
                    $url = get_permalink($arcresult);
                    if ($arcresult->post_title) {
                        $text = strip_tags(apply_filters('the_title', $arcresult->post_title, $arcresult->ID));
                    } else {
                        $text = $arcresult->ID;
                    }
                    $output .= get_archives_link($url, $text, $format, $before, $after);
                }
            }
        }
    }
    if ($echo) {
        echo $output;
    } else {
        return $output;
    }
}
开发者ID:batruji,项目名称:metareading,代码行数:101,代码来源:general-template.php


示例4: get_archives

function get_archives($type='', $limit='', $format='html', $before = '', $after = '', $show_post_count = false) {
    global $month, $wpdb;

    if ('' == $type) {
        $type = 'monthly';
    }

    if ('' != $limit) {
        $limit = (int) $limit;
        $limit = ' LIMIT '.$limit;
    }
    // this is what will separate dates on weekly archive links
    $archive_week_separator = '–';

    // over-ride general date format ? 0 = no: use the date format set in Options, 1 = yes: over-ride
    $archive_date_format_over_ride = 0;

    // options for daily archive (only if you over-ride the general date format)
    $archive_day_date_format = 'Y/m/d';

    // options for weekly archive (only if you over-ride the general date format)
    $archive_week_start_date_format = 'Y/m/d';
    $archive_week_end_date_format   = 'Y/m/d';

    if (!$archive_date_format_over_ride) {
        $archive_day_date_format = get_settings('date_format');
        $archive_week_start_date_format = get_settings('date_format');
        $archive_week_end_date_format = get_settings('date_format');
    }

    $add_hours = intval(get_settings('gmt_offset'));
    $add_minutes = intval(60 * (get_settings('gmt_offset') - $add_hours));

    $now = current_time('mysql');

    if ('monthly' == $type) {
        $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' GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date DESC" . $limit);
        if ($arcresults) {
            $afterafter = $after;
            foreach ($arcresults as $arcresult) {
                $url  = get_month_link($arcresult->year,   $arcresult->month);
                if ($show_post_count) {
                    $text = sprintf('%s %d', $month[zeroise($arcresult->month,2)], $arcresult->year);
                    $after = '&nbsp;('.$arcresult->posts.')' . $afterafter;
                } else {
                    $text = sprintf('%s %d', $month[zeroise($arcresult->month,2)], $arcresult->year);
                }
                echo get_archives_link($url, $text, $format, $before, $after);
            }
        }
    } elseif ('daily' == $type) {
        $arcresults = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, DAYOFMONTH(post_date) AS `dayofmonth` FROM $wpdb->posts WHERE post_date < '$now' AND post_status = 'publish' ORDER BY post_date DESC" . $limit);
        if ($arcresults) {
            foreach ($arcresults as $arcresult) {
                $url  = get_day_link($arcresult->year, $arcresult->month, $arcresult->dayofmonth);
                $date = sprintf("%d-%02d-%02d 00:00:00", $arcresult->year, $arcresult->month, $arcresult->dayofmonth);
                $text = mysql2date($archive_day_date_format, $date);
                echo get_archives_link($url, $text, $format, $before, $after);
            }
        }
    } elseif ('weekly' == $type) {
	$start_of_week = get_settings('start_of_week');
        $arcresults = $wpdb->get_results("SELECT DISTINCT WEEK(post_date, $start_of_week) AS `week`, YEAR(post_date) AS yr, DATE_FORMAT(post_date, '%Y-%m-%d') AS yyyymmdd FROM $wpdb->posts WHERE post_date < '$now' AND post_status = 'publish' ORDER BY post_date DESC" . $limit);
        $arc_w_last = '';
        if ($arcresults) {
            foreach ($arcresults as $arcresult) {
                if ($arcresult->week != $arc_w_last) {
                    $arc_year = $arcresult->yr;
                    $arc_w_last = $arcresult->week;
                    $arc_week = get_weekstartend($arcresult->yyyymmdd, get_settings('start_of_week'));
                    $arc_week_start = date_i18n($archive_week_start_date_format, $arc_week['start']);
                    $arc_week_end = date_i18n($archive_week_end_date_format, $arc_week['end']);
                    $url  = sprintf('%s/%s%sm%s%s%sw%s%d', get_settings('home'), '', '?',
                                    '=', $arc_year, '&amp;',
                                    '=', $arcresult->week);
                    $text = $arc_week_start . $archive_week_separator . $arc_week_end;
                    echo get_archives_link($url, $text, $format, $before, $after);
                }
            }
        }
    } elseif ('postbypost' == $type) {
        $arcresults = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_date < '$now' AND post_status = 'publish' ORDER BY post_date DESC" . $limit);
        if ($arcresults) {
            foreach ($arcresults as $arcresult) {
                if ($arcresult->post_date != '0000-00-00 00:00:00') {
                    $url  = get_permalink($arcresult);
                    $arc_title = $arcresult->post_title;
                    if ($arc_title) {
                        $text = strip_tags($arc_title);
                    } else {
                        $text = $arcresult->ID;
                    }
                    echo get_archives_link($url, $text, $format, $before, $after);
                }
            }
        }
    }
}
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:98,代码来源:template-functions-general.php


示例5: wp_dropdown_weekly

    function wp_dropdown_weekly($current)
    {
        $archive_week_start_date_format = "Y/m/d";
        $archive_week_end_date_format = "Y/m/d";
        $archive_week_separator = " - ";
        $arc_result = $GLOBALS['wpdb']->geT_results("SELECT DISTINCT YEAR(post_date), MONTH(post_date), DAYOFMONTH(post_date), WEEK(post_date) FROM " . wp_table('posts') . " ORDER BY post_date DESC", ARRAY_A);
        $arc_w_last = '';
        foreach ($arc_result as $arc_row) {
            $arc_year = $arc_row["YEAR(post_date)"];
            $arc_w = $arc_row["WEEK(post_date)"];
            if ($arc_w != $arc_w_last) {
                $arc_w_last = $arc_w;
                $arc_ymd = $arc_year . "-" . zeroise($arc_row["MONTH(post_date)"], 2) . "-" . zeroise($arc_row["DAYOFMONTH(post_date)"], 2);
                $arc_week = get_weekstartend($arc_ymd, get_settings('start_of_week'));
                $arc_week_start = date($archive_week_start_date_format, $arc_week['start']);
                $arc_week_end = date($archive_week_end_date_format, $arc_week['end']);
                $week_str = $arc_week_start . $archive_week_separator . $arc_week_end;
                ?>
				<option value="<?php 
                echo $arc_w;
                ?>
"<?php 
                selected($current, $arc_w);
                ?>
><?php 
                echo $week_str;
                ?>
</option>
<?php 
            }
        }
    }
开发者ID:BackupTheBerlios,项目名称:nobunobuxoops-svn,代码行数:32,代码来源:admin-functions.php


示例6: test_start_of_week_should_fall_back_on_sunday_when_option_is_missing

 public function test_start_of_week_should_fall_back_on_sunday_when_option_is_missing()
 {
     delete_option('start_of_week');
     $expected = array('start' => 1454803200, 'end' => 1455407999);
     $this->assertEquals($expected, get_weekstartend('2016-02-12'));
 }
开发者ID:atimmer,项目名称:wordpress-develop-mirror,代码行数:6,代码来源:getWeekstartend.php


示例7: wp_get_archives


//.........这里部分代码省略.........
	} elseif ('yearly' == $type) {
		$query = "SELECT DISTINCT YEAR(post_date) AS `year`, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY YEAR(post_date) ORDER BY post_date DESC $limit";
		$key = md5($query);
		$cache = wp_cache_get( 'wp_get_archives' , 'general');
		if ( !isset( $cache[ $key ] ) ) {
			$arcresults = $wpdb->get_results($query);
			$cache[ $key ] = $arcresults;
			wp_cache_add( 'wp_get_archives', $cache, 'general' );
		} else {
			$arcresults = $cache[ $key ];
		}
		if ($arcresults) {
			$afterafter = $after;
			foreach ($arcresults as $arcresult) {
				$url = get_year_link($arcresult->year);
				$text = sprintf('%d', $arcresult->year);
				if ($show_post_count)
					$after = '&nbsp;('.$arcresult->posts.')' . $afterafter;
				echo get_archives_link($url, $text, $format, $before, $after);
			}
		}
	} elseif ( 'daily' == $type ) {
		$query = "SELECT DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, DAYOFMONTH(post_date) AS `dayofmonth`, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY YEAR(post_date), MONTH(post_date), DAYOFMONTH(post_date) ORDER BY post_date DESC $limit";
		$key = md5($query);
		$cache = wp_cache_get( 'wp_get_archives' , 'general');
		if ( !isset( $cache[ $key ] ) ) {
			$arcresults = $wpdb->get_results($query);
			$cache[ $key ] = $arcresults;
			wp_cache_add( 'wp_get_archives', $cache, 'general' );
		} else {
			$arcresults = $cache[ $key ];
		}
		if ( $arcresults ) {
			$afterafter = $after;
			foreach ( $arcresults as $arcresult ) {
				$url	= get_day_link($arcresult->year, $arcresult->month, $arcresult->dayofmonth);
				$date = sprintf('%1$d-%2$02d-%3$02d 00:00:00', $arcresult->year, $arcresult->month, $arcresult->dayofmonth);
				$text = mysql2date($archive_day_date_format, $date);
				if ($show_post_count)
					$after = '&nbsp;('.$arcresult->posts.')'.$afterafter;
				echo get_archives_link($url, $text, $format, $before, $after);
			}
		}
	} elseif ( 'weekly' == $type ) {
		$start_of_week = get_option('start_of_week');
		$query = "SELECT DISTINCT WEEK(post_date, $start_of_week) AS `week`, YEAR(post_date) AS yr, DATE_FORMAT(post_date, '%Y-%m-%d') AS yyyymmdd, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY WEEK(post_date, $start_of_week), YEAR(post_date) ORDER BY post_date DESC $limit";
		$key = md5($query);
		$cache = wp_cache_get( 'wp_get_archives' , 'general');
		if ( !isset( $cache[ $key ] ) ) {
			$arcresults = $wpdb->get_results($query);
			$cache[ $key ] = $arcresults;
			wp_cache_add( 'wp_get_archives', $cache, 'general' );
		} else {
			$arcresults = $cache[ $key ];
		}
		$arc_w_last = '';
		$afterafter = $after;
		if ( $arcresults ) {
				foreach ( $arcresults as $arcresult ) {
					if ( $arcresult->week != $arc_w_last ) {
						$arc_year = $arcresult->yr;
						$arc_w_last = $arcresult->week;
						$arc_week = get_weekstartend($arcresult->yyyymmdd, get_option('start_of_week'));
						$arc_week_start = date_i18n($archive_week_start_date_format, $arc_week['start']);
						$arc_week_end = date_i18n($archive_week_end_date_format, $arc_week['end']);
						$url  = sprintf('%1$s/%2$s%3$sm%4$s%5$s%6$sw%7$s%8$d', get_option('home'), '', '?', '=', $arc_year, '&amp;', '=', $arcresult->week);
						$text = $arc_week_start . $archive_week_separator . $arc_week_end;
						if ($show_post_count)
							$after = '&nbsp;('.$arcresult->posts.')'.$afterafter;
						echo get_archives_link($url, $text, $format, $before, $after);
					}
				}
		}
	} elseif ( ( 'postbypost' == $type ) || ('alpha' == $type) ) {
		('alpha' == $type) ? $orderby = "post_title ASC " : $orderby = "post_date DESC ";
		$query = "SELECT * FROM $wpdb->posts $join $where ORDER BY $orderby $limit";
		$key = md5($query);
		$cache = wp_cache_get( 'wp_get_archives' , 'general');
		if ( !isset( $cache[ $key ] ) ) {
			$arcresults = $wpdb->get_results($query);
			$cache[ $key ] = $arcresults;
			wp_cache_add( 'wp_get_archives', $cache, 'general' );
		} else {
			$arcresults = $cache[ $key ];
		}
		if ( $arcresults ) {
			foreach ( $arcresults as $arcresult ) {
				if ( $arcresult->post_date != '0000-00-00 00:00:00' ) {
					$url  = get_permalink($arcresult);
					$arc_title = $arcresult->post_title;
					if ( $arc_title )
						$text = strip_tags(apply_filters('the_title', $arc_title));
					else
						$text = $arcresult->ID;
					echo get_archives_link($url, $text, $format, $before, $after);
				}
			}
		}
	}
}
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:101,代码来源:general-template.php


示例8: elseif

        echo "</option>\n";
    }
} elseif ($archive_mode == "weekly") {
    echo "<select name=\"w\" style=\"width:120px;\">";
    $archive_week_start_date_format = "Y/m/d";
    $archive_week_end_date_format = "Y/m/d";
    $archive_week_separator = " - ";
    $arc_result = $wpdb->geT_results("SELECT DISTINCT YEAR(post_date), MONTH(post_date), DAYOFMONTH(post_date), WEEK(post_date) FROM {$wpdb->posts[$wp_id]} ORDER BY post_date DESC", ARRAY_A);
    $arc_w_last = '';
    foreach ($arc_result as $arc_row) {
        $arc_year = $arc_row["YEAR(post_date)"];
        $arc_w = $arc_row["WEEK(post_date)"];
        if ($arc_w != $arc_w_last) {
            $arc_w_last = $arc_w;
            $arc_ymd = $arc_year . "-" . zeroise($arc_row["MONTH(post_date)"], 2) . "-" . zeroise($arc_row["DAYOFMONTH(post_date)"], 2);
            $arc_week = get_weekstartend($arc_ymd, get_settings('start_of_week'));
            $arc_week_start = date($archive_week_start_date_format, $arc_week['start']);
            $arc_week_end = date($archive_week_end_date_format, $arc_week['end']);
            echo "<option value=\"{$arc_w}\">";
            echo $arc_week_start . $archive_week_separator . $arc_week_end;
            echo "</option>\n";
        }
    }
} elseif ($archive_mode == "postbypost") {
    echo '<input type="hidden" name="more" value="1" />';
    echo '<select name="p" style="width:120px;">';
    $resultarc = $wpdb->get_results("SELECT ID,post_date,post_title FROM {$wpdb->posts[$wp_id]} ORDER BY post_date DESC");
    foreach ($resultarc as $row) {
        if ($row->post_date != "0000-00-00 00:00:00") {
            echo "<option value=\"" . $row->ID . "\">";
            if (strip_tags($row->post_title)) {
开发者ID:BackupTheBerlios,项目名称:nobunobuxoops-svn,代码行数:31,代码来源:edit.php


示例9: edd_get_report_dates

/**
 * Sets up the dates used to filter graph data
 *
 * Date sent via $_GET is read first and then modified (if needed) to match the
 * selected date-range (if any)
 *
 * @since 1.3
 * @return array
*/
function edd_get_report_dates()
{
    $dates = array();
    $current_time = current_time('timestamp');
    $dates['range'] = isset($_GET['range']) ? $_GET['range'] : 'this_month';
    if ('custom' !== $dates['range']) {
        $dates['year'] = isset($_GET['year']) ? $_GET['year'] : date('Y');
        $dates['year_end'] = isset($_GET['year_end']) ? $_GET['year_end'] : date('Y');
        $dates['m_start'] = isset($_GET['m_start']) ? $_GET['m_start'] : 1;
        $dates['m_end'] = isset($_GET['m_end']) ? $_GET['m_end'] : 12;
        $dates['day'] = isset($_GET['day']) ? $_GET['day'] : 1;
        $dates['day_end'] = isset($_GET['day_end']) ? $_GET['day_end'] : cal_days_in_month(CAL_GREGORIAN, $dates['m_end'], $dates['year']);
    }
    // Modify dates based on predefined ranges
    switch ($dates['range']) {
        case 'this_month':
            $dates['m_start'] = date('n', $current_time);
            $dates['m_end'] = date('n', $current_time);
            $dates['day'] = 1;
            $dates['day_end'] = cal_days_in_month(CAL_GREGORIAN, $dates['m_end'], $dates['year']);
            $dates['year'] = date('Y');
            $dates['year_end'] = date('Y');
            break;
        case 'last_month':
            if (date('n') == 1) {
                $dates['m_start'] = 12;
                $dates['m_end'] = 12;
                $dates['year'] = date('Y', $current_time) - 1;
                $dates['year_end'] = date('Y', $current_time) - 1;
            } else {
                $dates['m_start'] = date('n') - 1;
                $dates['m_end'] = date('n') - 1;
                $dates['year_end'] = $dates['year'];
            }
            $dates['day_end'] = cal_days_in_month(CAL_GREGORIAN, $dates['m_end'], $dates['year']);
            break;
        case 'today':
            $dates['day'] = date('d', $current_time);
            $dates['m_start'] = date('n', $current_time);
            $dates['m_end'] = date('n', $current_time);
            $dates['year'] = date('Y', $current_time);
            break;
        case 'yesterday':
            $year = date('Y', $current_time);
            $month = date('n', $current_time);
            $day = date('d', $current_time);
            if ($month == 1 && $day == 1) {
                $year -= 1;
                $month = 12;
                $day = cal_days_in_month(CAL_GREGORIAN, $month, $year);
            } elseif ($month > 1 && $day == 1) {
                $month -= 1;
                $day = cal_days_in_month(CAL_GREGORIAN, $month, $year);
            } else {
                $day -= 1;
            }
            $dates['day'] = $day;
            $dates['m_start'] = $month;
            $dates['m_end'] = $month;
            $dates['year'] = $year;
            $dates['year_end'] = $year;
            $dates['day_end'] = $day;
            break;
        case 'this_week':
        case 'last_week':
            $base_time = $dates['range'] === 'this_week' ? current_time('mysql') : date('Y-m-d h:i:s', current_time('timestamp') - WEEK_IN_SECONDS);
            $start_end = get_weekstartend($base_time, get_option('start_of_week'));
            $dates['day'] = date('d', $start_end['start']);
            $dates['m_start'] = date('n', $start_end['start']);
            $dates['year'] = date('Y', $start_end['start']);
            $dates['day_end'] = date('d', $start_end['end']);
            $dates['m_end'] = date('n', $start_end['end']);
            $dates['year_end'] = date('Y', $start_end['end']);
            break;
        case 'this_quarter':
            $month_now = date('n', $current_time);
            $dates['year'] = date('Y', $current_time);
            $dates['year_end'] = $dates['year'];
            if ($month_now <= 3) {
                $dates['m_start'] = 1;
                $dates['m_end'] = 3;
            } else {
                if ($month_now <= 6) {
                    $dates['m_start'] = 4;
                    $dates['m_end'] = 6;
                } else {
                    if ($month_now <= 9) {
                        $dates['m_start'] = 7;
                        $dates['m_end'] = 9;
                    } else {
                        $dates['m_start'] = 10;
//.........这里部分代码省略.........
开发者ID:stephywells,项目名称:Easy-Digital-Downloads,代码行数:101,代码来源:graphing.php


示例10: assemble_predefined_periods_query

 /**
  * Construct the date queries for pre-defined periods in the Sales Log.
  *
  * Supports pre-defined periods for the purchase log, including today, yesterday, this week,
  * last week, this month, last month, last two months + month to date (this quarter),
  * prior 3 months, this year, last year. You can insert your own custom periods by filtering
  * either based on the $period_flag or just filter the final query setup.
  *
  * @since 4.0
  *
  * @param array $period_flag The period requested from $_REQUEST['m'].
  *
  * @return array formatted to pass to WP_Date_Query.
  */
 private function assemble_predefined_periods_query($period_flag)
 {
     // warning: period flag is unsanitized user input directly from $_REQUEST - only compare against actual values
     /**
      *	date functions
      */
     $now_string = current_time('mysql');
     $week_start_end = get_weekstartend($now_string);
     // returns array with start/end
     $blog_time_zone = get_option('timezone_string');
     if (empty($blog_time_zone)) {
         $blog_time_zone = date_default_timezone_get();
     }
     $timezone = new DateTimeZone($blog_time_zone);
     $now = new DateTime('now', $timezone);
     // Based on $_REQUEST['m']
     switch ($period_flag) {
         // Today
         case 1:
             $date_query = array('year' => $now->format('Y'), 'monthnum' => $now->format('n'), 'day' => $now->format('d'));
             break;
             // Yesterday
         // Yesterday
         case 2:
             $yesterday = new DateTime(date('Y-m-d', strtotime('yesterday')), $timezone);
             $date_query = array('year' => $yesterday->format('Y'), 'monthnum' => $yesterday->format('n'), 'day' => $yesterday->format('d'));
             break;
             // This Week-to-date
         // This Week-to-date
         case 3:
             $start_of_this_week = new DateTime(date('Y-m-d 00:00:00', $week_start_end['start']), $timezone);
             $date_query = array('date_query' => array('after' => $start_of_this_week->format('Y-m-d 00:00:00'), 'compare' => '>', 'inclusive' => true));
             break;
             // Last Week
         // Last Week
         case 4:
             $start_of_last_week = new DateTime(date('Y-m-d 00:00:00', $week_start_end['start'] - DAY_IN_SECONDS * 7), $timezone);
             $start = $start_of_last_week->format('Y-m-d 00:00:00');
             $start_of_last_week->modify('+7 days');
             $date_query = array('date_query' => array('after' => $start, 'before' => $start_of_last_week->format('Y-m-d 00:00:00'), 'inclusive' => false));
             break;
             // This Month-to-Date (Same as choosing the explicit month on selector)
         // This Month-to-Date (Same as choosing the explicit month on selector)
         case 5:
             $date_query = array('year' => $now->format('Y'), 'monthnum' => $now->format('n'));
             break;
             // Last Month (Same as choosing the explicit month on selector)
         // Last Month (Same as choosing the explicit month on selector)
         case 6:
             $now->modify('-1 month');
             $date_query = array('year' => $now->format('Y'), 'monthnum' => $now->format('n'));
             break;
             // This Quarter (last three months inclusive)
         // This Quarter (last three months inclusive)
         case 7:
             $date_query = array('date_query' => array('after' => 'first day of -2 months'), 'compare' => '>', 'inclusive' => true);
             break;
             // Prior Three Months
         // Prior Three Months
         case 8:
             $date_query = array('date_query' => array('after' => 'first day of -2 months', 'before' => 'last day of -1 month', 'inclusive' => true));
             break;
             // This Year
         // This Year
         case 9:
             $date_query = array('date_query' => array('after' => '1/1 this year', 'compare' => '>', 'inclusive' => true));
             break;
             // Last year
         // Last year
         case 10:
             $date_query = array('date_query' => array('after' => '1/1 last year', 'before' => '12/31 last year', 'inclusive' => true));
             break;
             // default - return empty where clause
         // default - return empty where clause
         default:
             /**
              * Return a custom date query for custom period_flag's.
              *
              * This filter extends the functionality allowing for custom periods if a new value
              * is passed via $_REQUEST['m']. {@see 'purchase_log_special_periods'}.
              *
              * @since 4.1.0
              *
              * @param array Empty array to be filled with a valid query {@see WP_Date_Query}.
              */
             $date_query = apply_filters('wpsc_purchase_log_predefined_periods_' . $period_flag, array());
//.........这里部分代码省略.........
开发者ID:ashik968,项目名称:digiplot,代码行数:101,代码来源:purchase-log-list-table-class.php


示例11: display

    /**
     * Display the calendar.
     *
     * @todo If a specific day (mode == month) or month (mode == year) is selected, apply another class (default to some border)
     */
    function display()
    {
        global $DB;
        global $weekday, $weekday_abbrev, $weekday_letter, $month, $month_abbrev;
        global $time_difference;
        if ($this->mode == 'month') {
            $end_of_week = (locale_startofweek() + 7) % 7;
            // fplanque>> note: I am removing the searchframe thing because 1) I don't think it's of any use
            // and 2) it's brutally inefficient! If someone needs this it should be implemented with A SINGLE
            // QUERY which gets the last available post (BTW, I think there is already a function for that somwhere)
            // walter>> As we are just counting items, the ORDER BY db_prefix . date_start doesn't matter. And a side effect
            // of that is make queries standart compatible (compatible with other databases than MySQL)
            $arc_sql = 'SELECT COUNT(DISTINCT ' . $this->dbIDname . ') AS item_count,
													EXTRACT(DAY FROM ' . $this->dbprefix . 'datestart) AS myday
									FROM (' . $this->dbtable . ' INNER JOIN T_postcats ON ' . $this->dbIDname . ' = postcat_post_ID)
										INNER JOIN T_categories ON postcat_cat_ID = cat_ID
									WHERE EXTRACT(YEAR FROM ' . $this->dbprefix . 'datestart) = \'' . $this->year . '\'
										AND EXTRACT(MONTH FROM ' . $this->dbprefix . 'datestart) = \'' . $this->month . '\'
										' . $this->ItemQuery->get_where(' AND ') . '
									GROUP BY myday ' . $this->ItemQuery->get_group_by(', ');
            // echo $this->ItemQuery->where;
            $arc_result = $DB->get_results($arc_sql, ARRAY_A);
            foreach ($arc_result as $arc_row) {
                if (!isset($daysinmonthwithposts[$arc_row['myday']])) {
                    $daysinmonthwithposts[$arc_row['myday']] = 0;
                }
                // The '+' situation actually only happens when we have a complex GROUP BY above
                // (multiple categories wcombined with "ALL")
                $daysinmonthwithposts[$arc_row['myday']] += $arc_row['item_count'];
            }
            $daysinmonth = intval(date('t', mktime(0, 0, 0, $this->month, 1, $this->year)));
            // echo 'days in month=', $daysinmonth;
            // caution: offset bug inside (??)
            $datestartofmonth = mktime(0, 0, 0, $this->month, 1, $this->year);
            // echo date( locale_datefmt(), $datestartofmonth );
            $calendarblah = get_weekstartend($datestartofmonth, locale_startofweek());
            $calendarfirst = $calendarblah['start'];
            $dateendofmonth = mktime(0, 0, 0, $this->month, $daysinmonth, $this->year);
            // echo 'end of month: '.date( 'Y-m-d H:i:s', $dateendofmonth );
            $calendarblah = get_weekstartend($dateendofmonth, locale_startofweek());
            $calendarlast = $calendarblah['end'];
            // echo date( ' Y-m-d H:i:s', $calendarlast );
            // here the offset bug is corrected
            if (intval(date('d', $calendarfirst)) > 1 && intval(date('m', $calendarfirst)) == intval($this->month)) {
                #pre_dump( 'with offset bug', date('Y-m-d', $calendarfirst) );
                $calendarfirst = $calendarfirst - 604800;
                #pre_dump( 'without offset bug', date('Y-m-d', $calendarfirst) );
            }
        } else {
            // mode is 'year'
            // Find months with posts
            $arc_sql = '
				SELECT COUNT(DISTINCT ' . $this->dbIDname . ') AS item_count, EXTRACT(MONTH FROM ' . $this->dbprefix . 'datestart) AS mymonth
				  FROM (' . $this->dbtable . ' INNER JOIN T_postcats ON ' . $this->dbIDname . ' = postcat_post_ID)
				 INNER JOIN T_categories ON postcat_cat_ID = cat_ID
				 WHERE EXTRACT(YEAR FROM ' . $this->dbprefix . 'datestart) = \'' . $this->year . '\' ' . $this->ItemQuery->get_where(' AND ') . '
				 GROUP BY mymonth ' . $this->ItemQuery->get_group_by(', ');
            $arc_result = $DB->get_results($arc_sql, ARRAY_A);
            if ($DB->num_rows > 0) {
                // OK we have a month with posts! // fp>dh why did you removed that?
                foreach ($arc_result as $arc_row) {
                    $monthswithposts[$arc_row['mymonth']] = $arc_row['item_count'];
                }
            }
        }
        // ** display everything **
        echo $this->tablestart;
        // CAPTION :
        if ($this->displaycaption) {
            // caption:
            echo $this->monthstart;
            if ($this->navigation == 'caption') {
                echo implode('&nbsp;', $this->getNavLinks('prev')) . '&nbsp;';
            }
            if ($this->mode == 'month') {
                // MONTH CAPTION:
                $text = date_i18n($this->monthformat, mktime(0, 0, 0, $this->month, 1, $this->year));
                if ($this->linktomontharchive) {
                    // chosen month with link to archives
                    echo $this->archive_link($text, T_('View monthly archive'), $this->year, $this->month);
                } else {
                    echo $text;
                }
            } else {
                // YEAR CAPTION:
                echo date_i18n('Y', mktime(0, 0, 0, 1, 1, $this->year));
                // display year
            }
            if ($this->navigation == 'caption') {
                echo '&nbsp;' . implode('&nbsp;', $this->getNavLinks('next'));
            }
            echo $this->monthend;
        }
        // HEADER :
        if (!empty($this->headerdisplay) && $this->mode == 'month') {
//.........这里部分代码省略.........
开发者ID:ldanielz,项目名称:uesp.blog,代码行数:101,代码来源:_calendar.plugin.php


示例12: get_archives

 function get_archives($type = '', $limit = '', $format = 'html', $before = "", $after = "", $show_post_count = false, $selvalue = '', $echo = true)
 {
     $get_archives = '';
     if (!$type) {
         $type = get_settings('archive_mode');
     }
     // this is what will separate dates on weekly archive links
     $archive_week_separator = '&#8211;';
     // archive link url
     $archive_link_m = wp_siteurl() . '/index.php?m=';
     # monthly archive;
     $archive_link_w = wp_siteurl() . '/index.php?w=';
     # weekly archive;
     $archive_link_p = wp_siteurl() . '/index.php?p=';
     # post-by-post archive;
     // over-ride general date format ? 0 = no: use the date format set in Options, 1 = yes: over-ride
     $archive_date_format_over_ride = 0;
     // options for daily archive (only if you over-ride the general date format)
     $archive_day_date_format = 'Y/m/d';
     // options for weekly archive (only if you over-ride the general date format)
     $archive_week_start_date_format = 'Y/m/d';
     $archive_week_end_date_format = 'Y/m/d';
     if (!$archive_date_format_over_ride) {
         $archive_day_date_format = $GLOBALS['dateformat'];
         $archive_week_start_date_format = $GLOBALS['dateformat'];
         $archive_week_end_date_format = $GLOBALS['dateformat'];
     }
     $now = current_time('mysql');
     $postHandler =& wp_handler('Post');
     if ('monthly' == $type) {
         $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)');
         if ($limit) {
             $criteria->setLimit($limit);
         }
         $postObjects =& 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP get_where_sql函数代码示例发布时间:2022-05-15
下一篇:
PHP get_webtag函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap