Changeset 14499
- Timestamp:
- 05/07/2010 05:01:29 AM (14 years ago)
- Location:
- trunk/wp-includes
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/functions.php
r14495 r14499 193 193 $day = mktime( 0, 0, 0, $md, $mm, $my ); // The timestamp for mysqlstring day. 194 194 $weekday = date( 'w', $day ); // The day of the week from the timestamp 195 $i = 86400; // One day196 195 if ( !is_numeric($start_of_week) ) 197 196 $start_of_week = get_option( 'start_of_week' ); 198 197 199 198 if ( $weekday < $start_of_week ) 200 $weekday = 7 - $start_of_week - $weekday; 201 202 while ( $weekday > $start_of_week ) { 203 $weekday = date( 'w', $day ); 204 if ( $weekday < $start_of_week ) 205 $weekday = 7 - $start_of_week - $weekday; 206 207 $day -= 86400; 208 $i = 0; 209 } 210 $week['start'] = $day + 86400 - $i; 211 $week['end'] = $week['start'] + 604799; 212 return $week; 199 $weekday += 7; 200 201 $start = $day - 86400 * ( $weekday - $start_of_week ); // The most recent week start day on or before $day 202 $end = $start + 604799; // $start + 7 days - 1 second 203 return compact( 'start', 'end' ); 213 204 } 214 205 … … 4169 4160 } 4170 4161 4162 /** 4163 * Returns a MySQL expression for selecting the week number based on the start_of_week option. 4164 * 4165 * @internal 4166 * @since 3.0.0 4167 * @param string $column 4168 * @return string 4169 */ 4170 function _wp_mysql_week( $column ) { 4171 switch ( $start_of_week = (int) get_option( 'start_of_week' ) ) { 4172 default : 4173 case 0 : 4174 return "WEEK( $column, 0 )"; 4175 case 1 : 4176 return "WEEK( $column, 1 )"; 4177 case 2 : 4178 case 3 : 4179 case 4 : 4180 case 5 : 4181 case 6 : 4182 return "WEEK( DATE_SUB( $column, INTERVAL $start_of_week DAY ), 0 )"; 4183 } 4184 } 4185 4171 4186 ?> -
trunk/wp-includes/general-template.php
r14486 r14499 966 966 } 967 967 } elseif ( 'weekly' == $type ) { 968 $ start_of_week = get_option('start_of_week');969 $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_dateDESC $limit";968 $week = _wp_mysql_week( '`post_date`' ); 969 $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"; 970 970 $key = md5($query); 971 971 $cache = wp_cache_get( 'wp_get_archives' , 'general'); -
trunk/wp-includes/query.php
r14478 r14499 1781 1781 1782 1782 if ( $q['w'] ) 1783 $where .= " AND WEEK($wpdb->posts.post_date, 1)='" . $q['w'] . "'";1783 $where .= ' AND ' . _wp_mysql_week( "`$wpdb->posts`.`post_date`" ) . " = '" . $q['w'] . "'"; 1784 1784 1785 1785 if ( intval($q['comments_popup']) )
Note: See TracChangeset
for help on using the changeset viewer.