Ticket #10397: 10397.diff
File 10397.diff, 3.2 KB (added by , 14 years ago) |
---|
-
wp-includes/functions.php
192 192 $md = substr( $mysqlstring, 5, 2 ); // Mysql string day 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;199 $weekday += 7; 201 200 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; 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 215 206 /** … … 4164 4155 @header( 'X-Content-Type-Options: nosniff' ); 4165 4156 } 4166 4157 4158 /** 4159 * Returns a MySQL expression for selecting the week number based on the start_of_week option. 4160 * 4161 * @internal 4162 * @since 3.0.0 4163 * @param string $column 4164 * @return string 4165 */ 4166 function _wp_mysql_week( $column ) { 4167 switch ( $start_of_week = (int) get_option( 'start_of_week' ) ) { 4168 default : 4169 case 0 : 4170 return "WEEK( $column, 0 )"; 4171 case 1 : 4172 return "WEEK( $column, 1 )"; 4173 case 2 : 4174 case 3 : 4175 case 4 : 4176 case 5 : 4177 case 6 : 4178 return "WEEK( DATE_SUB( $column, INTERVAL $start_of_week DAY ), 0 )"; 4179 } 4180 } 4181 4167 4182 ?> -
wp-includes/query.php
1781 1781 } 1782 1782 1783 1783 if ( $q['w'] ) 1784 $where .= " AND WEEK($wpdb->posts.post_date, 1)='" . $q['w'] . "'";1784 $where .= ' AND ' . _wp_mysql_week( "`$wpdb->posts`.`post_date`" ) . " = '" . $q['w'] . "'"; 1785 1785 1786 1786 if ( intval($q['comments_popup']) ) 1787 1787 $q['p'] = absint($q['comments_popup']); -
wp-includes/general-template.php
965 965 } 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'); 972 972 if ( !isset( $cache[ $key ] ) ) {