Make WordPress Core

Ticket #36244: 36244-with-filter.patch

File 36244-with-filter.patch, 7.2 KB (added by pbearne, 3 years ago)

with filter

  • src/wp-includes/general-template.php

     
    17681768         */
    17691769        return apply_filters( 'get_archives_link', $link_html, $url, $text, $format, $before, $after, $selected );
    17701770}
    1771 
    17721771/**
    17731772 * Display archive links based on type and format.
    17741773 *
     
    17841783 * @param string|array $args {
    17851784 *     Default archive links arguments. Optional.
    17861785 *
    1787  *     @type string     $type            Type of archive to retrieve. Accepts 'daily', 'weekly', 'monthly',
    1788  *                                       'yearly', 'postbypost', or 'alpha'. Both 'postbypost' and 'alpha'
    1789  *                                       display the same archive link list as well as post titles instead
    1790  *                                       of displaying dates. The difference between the two is that 'alpha'
    1791  *                                       will order by post title and 'postbypost' will order by post date.
    1792  *                                       Default 'monthly'.
    1793  *     @type string|int $limit           Number of links to limit the query to. Default empty (no limit).
    1794  *     @type string     $format          Format each link should take using the $before and $after args.
    1795  *                                       Accepts 'link' (`<link>` tag), 'option' (`<option>` tag), 'html'
    1796  *                                       (`<li>` tag), or a custom format, which generates a link anchor
    1797  *                                       with $before preceding and $after succeeding. Default 'html'.
    1798  *     @type string     $before          Markup to prepend to the beginning of each link. Default empty.
    1799  *     @type string     $after           Markup to append to the end of each link. Default empty.
    1800  *     @type bool       $show_post_count Whether to display the post count alongside the link. Default false.
    1801  *     @type bool|int   $echo            Whether to echo or return the links list. Default 1|true to echo.
    1802  *     @type string     $order           Whether to use ascending or descending order. Accepts 'ASC', or 'DESC'.
    1803  *                                       Default 'DESC'.
    1804  *     @type string     $post_type       Post type. Default 'post'.
    1805  *     @type string     $year            Year. Default current year.
    1806  *     @type string     $monthnum        Month number. Default current month number.
    1807  *     @type string     $day             Day. Default current day.
    1808  *     @type string     $w               Week. Default current week.
     1786 *     @type string     $type                    Type of archive to retrieve. Accepts 'daily', 'weekly', 'monthly',
     1787 *                                               'yearly', 'postbypost', or 'alpha'. Both 'postbypost' and 'alpha'
     1788 *                                               display the same archive link list as well as post titles instead
     1789 *                                               of displaying dates. The difference between the two is that 'alpha'
     1790 *                                               will order by post title and 'postbypost' will order by post date.
     1791 *                                               Default 'monthly'.
     1792 *     @type string|int $limit                   Number of links to limit the query to. Default empty (no limit).
     1793 *     @type string     $format                  Format each link should take using the $before and $after args.
     1794 *                                               Accepts 'link' (`<link>` tag), 'option' (`<option>` tag), 'html'
     1795 *                                               (`<li>` tag), or a custom format, which generates a link anchor
     1796 *                                               with $before preceding and $after succeeding. Default 'html'.
     1797 *     @type string     $before                  Markup to prepend to the beginning of each link. Default empty.
     1798 *     @type string     $after                   Markup to append to the end of each link. Default empty.
     1799 *     @type bool       $show_post_count         Whether to display the post count alongside the link. Default false.
     1800 *     @type bool|int   $echo                    Whether to echo or return the links list. Default 1|true to echo.
     1801 *     @type string     $order                   Whether to use ascending or descending order. Accepts 'ASC', or 'DESC'.
     1802 *                                               Default 'DESC'.
     1803 *     @type string     $post_type               Post type. Default 'post'.
     1804 *     @type string     $year                    Year. Default current year.
     1805 *     @type string     $monthnum                Month number. Default current month number.
     1806 *     @type string     $day                     Day. Default current day.
     1807 *     @type string     $w                       Week. Default current week.
     1808 *     @type string     $archive_week_separator  The symbol used separate dates on weekly archive links Default '&#8211;';
    18091809 * }
    18101810 * @return void|string Void if 'echo' argument is true, archive links if 'echo' is false.
    18111811 */
     
    18131813        global $wpdb, $wp_locale;
    18141814
    18151815        $defaults = array(
    1816                 'type'            => 'monthly',
    1817                 'limit'           => '',
    1818                 'format'          => 'html',
    1819                 'before'          => '',
    1820                 'after'           => '',
    1821                 'show_post_count' => false,
    1822                 'echo'            => 1,
    1823                 'order'           => 'DESC',
    1824                 'post_type'       => 'post',
    1825                 'year'            => get_query_var( 'year' ),
    1826                 'monthnum'        => get_query_var( 'monthnum' ),
    1827                 'day'             => get_query_var( 'day' ),
    1828                 'w'               => get_query_var( 'w' ),
     1816                'type'                   => 'monthly',
     1817                'limit'                  => '',
     1818                'format'                 => 'html',
     1819                'before'                 => '',
     1820                'after'                  => '',
     1821                'show_post_count'        => false,
     1822                'echo'                   => 1,
     1823                'order'                  => 'DESC',
     1824                'post_type'              => 'post',
     1825                'year'                   => get_query_var( 'year' ),
     1826                'monthnum'               => get_query_var( 'monthnum' ),
     1827                'day'                    => get_query_var( 'day' ),
     1828                'w'                      => get_query_var( 'w' ),
     1829                /**
     1830                * Filter what will separate dates on weekly archive links.
     1831                *
     1832                * @since 5.4
     1833                *
     1834                * @param string '-' (&#8211;) used to split the start and end dates of a week.
     1835                */
     1836                'archive_week_separator' => apply_filters( 'wp_get_archives_week_separator', '&#8211;' ),
    18291837        );
    18301838
    18311839        $parsed_args = wp_parse_args( $args, $defaults );
     
    18501858                $order = 'DESC';
    18511859        }
    18521860
    1853         // this is what will separate dates on weekly archive links
    1854         $archive_week_separator = '&#8211;';
    1855 
    18561861        $sql_where = $wpdb->prepare( "WHERE post_type = %s AND post_status = 'publish'", $parsed_args['post_type'] );
    18571862
    18581863        /**
     
    19851990                                        if ( 'post' !== $parsed_args['post_type'] ) {
    19861991                                                $url = add_query_arg( 'post_type', $parsed_args['post_type'], $url );
    19871992                                        }
    1988                                         $text = $arc_week_start . $archive_week_separator . $arc_week_end;
     1993                                        $text = $arc_week_start . $parsed_args['archive_week_separator'] . $arc_week_end;
    19891994                                        if ( $parsed_args['show_post_count'] ) {
    19901995                                                $parsed_args['after'] = '&nbsp;(' . $result->posts . ')' . $after;
    19911996                                        }
     
    20282033        }
    20292034}
    20302035
     2036
    20312037/**
    20322038 * Get number of days since the start of the week.
    20332039 *