WordPress.org

Make WordPress Core

Ticket #9860: postbypost_filters_2.8.patch

File postbypost_filters_2.8.patch, 5.1 KB (added by kevinb, 9 years ago)

getarchives_distinct, getarchives_fields filters for postbypost archive type

  • general-template.php

     
    119119                return;
    120120
    121121        $form = '<form role="search" method="get" id="searchform" action="' . get_option('home') . '/" >
    122         <div><label class="invisible" for="s">' . __('Search for:') . '</label>
     122        <div><label class="screen-reader-text" for="s">' . __('Search for:') . '</label>
    123123        <input type="text" value="' . esc_attr(apply_filters('the_search_query', get_search_query())) . '" name="s" id="s" />
    124124        <input type="submit" id="searchsubmit" value="'. esc_attr__('Search') .'" />
    125125        </div>
     
    187187        $login_url = site_url('wp-login.php', 'login');
    188188
    189189        if ( !empty($redirect) ) {
    190                 $login_url = add_query_arg('redirect_to', $redirect, $login_url);
     190                $login_url = add_query_arg('redirect_to', urlencode($redirect), $login_url);
    191191        }
    192192
    193193        return apply_filters('login_url', $login_url, $redirect);
     
    873873                }
    874874        } elseif ( ( 'postbypost' == $type ) || ('alpha' == $type) ) {
    875875                $orderby = ('alpha' == $type) ? "post_title ASC " : "post_date DESC ";
    876                 $query = "SELECT * FROM $wpdb->posts $join $where ORDER BY $orderby $limit";
     876
     877                $distinct = apply_filters('getarchives_distinct', "", $r);
     878                $fields = apply_filters('getarchives_fields', "*", $r);
     879
     880                $query = "SELECT $distinct $fields FROM $wpdb->posts $join $where ORDER BY $orderby $limit";
     881               
    877882                $key = md5($query);
    878883                $cache = wp_cache_get( 'wp_get_archives' , 'general');
    879884                if ( !isset( $cache[ $key ] ) ) {
     
    11771182 */
    11781183function the_date_xml() {
    11791184        global $post;
    1180         echo mysql2date('Y-m-d', $post->post_date);
     1185        echo mysql2date('Y-m-d', $post->post_date, false);
    11811186}
    11821187
    11831188/**
     
    12361241 */
    12371242function get_the_modified_date($d = '') {
    12381243        if ( '' == $d )
    1239                 $the_time = get_post_modified_time(get_option('date_format'));
     1244                $the_time = get_post_modified_time(get_option('date_format'), null, null, true);
    12401245        else
    1241                 $the_time = get_post_modified_time($d);
     1246                $the_time = get_post_modified_time($d, null, null, true);
    12421247        return apply_filters('get_the_modified_date', $the_time, $d);
    12431248}
    12441249
     
    12661271        $post = get_post($post);
    12671272
    12681273        if ( '' == $d )
    1269                 $the_time = get_post_time(get_option('time_format'), false, $post);
     1274                $the_time = get_post_time(get_option('time_format'), false, $post, true);
    12701275        else
    1271                 $the_time = get_post_time($d, false, $post);
     1276                $the_time = get_post_time($d, false, $post, true);
    12721277        return apply_filters('get_the_time', $the_time, $d, $post);
    12731278}
    12741279
     
    12801285 * @param string $d Either 'G', 'U', or php date format.
    12811286 * @param bool $gmt Whether of not to return the gmt time.
    12821287 * @param int|object $post Optional post ID or object. Default is global $post object.
     1288 * @param bool $translate Whether to translate the time string or not
    12831289 * @return string
    12841290 */
    1285 function get_post_time( $d = 'U', $gmt = false, $post = null ) { // returns timestamp
     1291function get_post_time( $d = 'U', $gmt = false, $post = null, $translate = false ) { // returns timestamp
    12861292        $post = get_post($post);
    12871293
    12881294        if ( $gmt )
     
    12901296        else
    12911297                $time = $post->post_date;
    12921298
    1293         $time = mysql2date($d, $time);
     1299        $time = mysql2date($d, $time, $translate);
    12941300        return apply_filters('get_post_time', $time, $d, $gmt);
    12951301}
    12961302
     
    13151321 */
    13161322function get_the_modified_time($d = '') {
    13171323        if ( '' == $d )
    1318                 $the_time = get_post_modified_time(get_option('time_format'));
     1324                $the_time = get_post_modified_time(get_option('time_format'), null, null, true);
    13191325        else
    1320                 $the_time = get_post_modified_time($d);
     1326                $the_time = get_post_modified_time($d, null, null, true);
    13211327        return apply_filters('get_the_modified_time', $the_time, $d);
    13221328}
    13231329
     
    13281334 *
    13291335 * @param string $d Either 'G', 'U', or php date format.
    13301336 * @param bool $gmt Whether of not to return the gmt time.
     1337 * @param int|object $post A post_id or post object
     1338 * @param bool translate Whether to translate the result or not
    13311339 * @return string Returns timestamp
    13321340 */
    1333 function get_post_modified_time( $d = 'U', $gmt = false ) {
    1334         global $post;
     1341function get_post_modified_time( $d = 'U', $gmt = false, $post = null, $translate = false ) {
     1342        $post = get_post($post);
    13351343
    13361344        if ( $gmt )
    13371345                $time = $post->post_modified_gmt;
    13381346        else
    13391347                $time = $post->post_modified;
    1340         $time = mysql2date($d, $time);
     1348        $time = mysql2date($d, $time, $translate);
    13411349
    1342         return apply_filters('get_the_modified_time', $time, $d, $gmt);
     1350        return apply_filters('get_post_modified_time', $time, $d, $gmt);
    13431351}
    13441352
    13451353/**
     
    13511359 */
    13521360function the_weekday() {
    13531361        global $wp_locale, $post;
    1354         $the_weekday = $wp_locale->get_weekday(mysql2date('w', $post->post_date));
     1362        $the_weekday = $wp_locale->get_weekday(mysql2date('w', $post->post_date, false));
    13551363        $the_weekday = apply_filters('the_weekday', $the_weekday);
    13561364        echo $the_weekday;
    13571365}
     
    13721380        $the_weekday_date = '';
    13731381        if ( $day != $previousweekday ) {
    13741382                $the_weekday_date .= $before;
    1375                 $the_weekday_date .= $wp_locale->get_weekday(mysql2date('w', $post->post_date));
     1383                $the_weekday_date .= $wp_locale->get_weekday(mysql2date('w', $post->post_date, false));
    13761384                $the_weekday_date .= $after;
    13771385                $previousweekday = $day;
    13781386        }