X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/af50974463450c98503e763a7836a50e260461a9..7f1521bf193b382565eb753043c161f4cb3fcda7:/wp-includes/general-template.php diff --git a/wp-includes/general-template.php b/wp-includes/general-template.php index 8655ceed..f9a529f0 100644 --- a/wp-includes/general-template.php +++ b/wp-includes/general-template.php @@ -346,11 +346,13 @@ function wp_login_url($redirect = '', $force_reauth = false) { * Filter the login URL. * * @since 2.8.0 + * @since 4.2.0 The `$force_reauth` parameter was added. * - * @param string $login_url The login URL. - * @param string $redirect The path to redirect to on login, if supplied. + * @param string $login_url The login URL. + * @param string $redirect The path to redirect to on login, if supplied. + * @param bool $force_reauth Whether to force reauthorization, even if a cookie is present. */ - return apply_filters( 'login_url', $login_url, $redirect ); + return apply_filters( 'login_url', $login_url, $redirect, $force_reauth ); } /** @@ -607,7 +609,13 @@ function get_bloginfo( $show = '', $filter = 'raw' ) { switch( $show ) { case 'home' : // DEPRECATED case 'siteurl' : // DEPRECATED - _deprecated_argument( __FUNCTION__, '2.2', sprintf( __('The %s option is deprecated for the family of bloginfo() functions.' ), $show ) . ' ' . sprintf( __( 'Use the %s option instead.' ), 'url' ) ); + _deprecated_argument( __FUNCTION__, '2.2', sprintf( + /* translators: 1: 'siteurl'/'home' argument, 2: bloginfo() function name, 3: 'url' argument */ + __( 'The %1$s option is deprecated for the family of %2$s functions. Use the %3$s option instead.' ), + '' . $show . '', + 'bloginfo()', + 'url' + ) ); case 'url' : $output = home_url(); break; @@ -667,7 +675,13 @@ function get_bloginfo( $show = '', $filter = 'raw' ) { $output = str_replace('_', '-', $output); break; case 'text_direction': - //_deprecated_argument( __FUNCTION__, '2.2', sprintf( __('The %s option is deprecated for the family of bloginfo() functions.' ), $show ) . ' ' . sprintf( __( 'Use the %s function instead.' ), 'is_rtl()' ) ); + _deprecated_argument( __FUNCTION__, '2.2', sprintf( + /* translators: 1: 'text_direction' argument, 2: bloginfo() function name, 3: is_rtl() function name */ + __( 'The %1$s option is deprecated for the family of %2$s functions. Use the %3$s function instead.' ), + '' . $show . '', + 'bloginfo()', + 'is_rtl()' + ) ); if ( function_exists( 'is_rtl' ) ) { $output = is_rtl() ? 'rtl' : 'ltr'; } else { @@ -716,9 +730,9 @@ function get_bloginfo( $show = '', $filter = 'raw' ) { /** * Display title tag with contents. * + * @ignore * @since 4.1.0 * @access private - * @internal * * @see wp_title() */ @@ -1312,7 +1326,7 @@ function get_archives_link($url, $text, $format = 'html', $before = '', $after = * @type string $before Markup to prepend to the beginning of each link. Default empty. * @type string $after Markup to append to the end of each link. Default empty. * @type bool $show_post_count Whether to display the post count alongside the link. Default false. - * @type bool $echo Whether to echo or return the links list. Default 1|true to echo. + * @type bool|int $echo Whether to echo or return the links list. Default 1|true to echo. * @type string $order Whether to use ascending or descending order. Accepts 'ASC', or 'DESC'. * Default 'DESC'. * } @@ -1438,7 +1452,6 @@ function wp_get_archives( $args = '' ) { $key = "wp_get_archives:$key:$last_changed"; if ( ! $results = wp_cache_get( $key, 'posts' ) ) { $results = $wpdb->get_results( $query ); - $cache[ $key ] = $results; wp_cache_set( $key, $results, 'posts' ); } if ( $results ) { @@ -1482,7 +1495,7 @@ function wp_get_archives( $args = '' ) { } } } elseif ( ( 'postbypost' == $r['type'] ) || ('alpha' == $r['type'] ) ) { - $orderby = ( 'alpha' == $r['type'] ) ? 'post_title ASC ' : 'post_date DESC '; + $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"; @@ -1657,6 +1670,8 @@ function get_calendar($initial = true, $echo = true) { '; + $daywithpost = array(); + // Get days with posts $dayswithposts = $wpdb->get_results("SELECT DISTINCT DAYOFMONTH(post_date) FROM $wpdb->posts WHERE post_date >= '{$thisyear}-{$thismonth}-01 00:00:00' @@ -1666,8 +1681,6 @@ function get_calendar($initial = true, $echo = true) { foreach ( (array) $dayswithposts as $daywith ) { $daywithpost[] = $daywith[0]; } - } else { - $daywithpost = array(); } if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false || stripos($_SERVER['HTTP_USER_AGENT'], 'camino') !== false || stripos($_SERVER['HTTP_USER_AGENT'], 'safari') !== false) @@ -1757,10 +1770,6 @@ function get_calendar($initial = true, $echo = true) { function delete_get_calendar_cache() { wp_cache_delete( 'get_calendar', 'calendar' ); } -add_action( 'save_post', 'delete_get_calendar_cache' ); -add_action( 'delete_post', 'delete_get_calendar_cache' ); -add_action( 'update_option_start_of_week', 'delete_get_calendar_cache' ); -add_action( 'update_option_gmt_offset', 'delete_get_calendar_cache' ); /** * Display all of the allowed tags in HTML format with attributes. @@ -2581,26 +2590,45 @@ function language_attributes($doctype = 'html') { * * @since 2.1.0 * - * @param string|array $args Optional. Override defaults. + * @param string|array $args { + * Optional. Array or string of arguments for generating paginated links for archives. + * + * @type string $base Base of the paginated url. Default empty. + * @type string $format Format for the pagination structure. Default empty. + * @type int $total The total amount of pages. Default is the value WP_Query's + * `max_num_pages` or 1. + * @type int $current The current page number. Default is 'paged' query var or 1. + * @type bool $show_all Whether to show all pages. Default false. + * @type int $end_size How many numbers on either the start and the end list edges. + * Default 1. + * @type int $mid_size How many numbers to either side of the current pages. Default 2. + * @type bool $prev_next Whether to include the previous and next links in the list. Default true. + * @type bool $prev_text The previous page text. Default '« Previous'. + * @type bool $next_text The next page text. Default '« Previous'. + * @type string $type Controls format of the returned value. Possible values are 'plain', + * 'array' and 'list'. Default is 'plain'. + * @type array $add_args An array of query args to add. Default false. + * @type string $add_fragment A string to append to each link. Default empty. + * @type string $before_page_number A string to appear before the page number. Default empty. + * @type string $after_page_number A string to append after the page number. Default empty. + * } * @return array|string String of page links or array of page links. */ function paginate_links( $args = '' ) { global $wp_query, $wp_rewrite; - $total = ( isset( $wp_query->max_num_pages ) ) ? $wp_query->max_num_pages : 1; - $current = ( get_query_var( 'paged' ) ) ? intval( get_query_var( 'paged' ) ) : 1; + // Setting up default values based on the current URL. $pagenum_link = html_entity_decode( get_pagenum_link() ); - $query_args = array(); $url_parts = explode( '?', $pagenum_link ); - if ( isset( $url_parts[1] ) ) { - wp_parse_str( $url_parts[1], $query_args ); - $query_args = urlencode_deep( $query_args ); - } + // Get max pages and current page out of the current query, if available. + $total = isset( $wp_query->max_num_pages ) ? $wp_query->max_num_pages : 1; + $current = get_query_var( 'paged' ) ? intval( get_query_var( 'paged' ) ) : 1; - $pagenum_link = remove_query_arg( array_keys( $query_args ), $pagenum_link ); - $pagenum_link = trailingslashit( $pagenum_link ) . '%_%'; + // Append the format placeholder to the base URL. + $pagenum_link = trailingslashit( $url_parts[0] ) . '%_%'; + // URL base depends on permalink settings. $format = $wp_rewrite->using_index_permalinks() && ! strpos( $pagenum_link, 'index.php' ) ? 'index.php/' : ''; $format .= $wp_rewrite->using_permalinks() ? user_trailingslashit( $wp_rewrite->pagination_base . '/%#%', 'paged' ) : '?paged=%#%'; @@ -2616,7 +2644,7 @@ function paginate_links( $args = '' ) { 'end_size' => 1, 'mid_size' => 2, 'type' => 'plain', - 'add_args' => $query_args, // array of query args to add + 'add_args' => array(), // array of query args to add 'add_fragment' => '', 'before_page_number' => '', 'after_page_number' => '' @@ -2624,6 +2652,21 @@ function paginate_links( $args = '' ) { $args = wp_parse_args( $args, $defaults ); + if ( ! is_array( $args['add_args'] ) ) { + $args['add_args'] = array(); + } + + // Merge additional query vars found in the original URL into 'add_args' array. + if ( isset( $url_parts[1] ) ) { + // Find the format argument. + $format_query = parse_url( str_replace( '%_%', $args['format'], $args['base'] ), PHP_URL_QUERY ); + wp_parse_str( $format_query, $format_arg ); + + // Remove the format argument from the array of query arguments, to avoid overwriting custom format. + wp_parse_str( remove_query_arg( array_keys( $format_arg ), $url_parts[1] ), $query_args ); + $args['add_args'] = array_merge( $args['add_args'], urlencode_deep( $query_args ) ); + } + // Who knows what else people pass in $args $total = (int) $args['total']; if ( $total < 2 ) { @@ -2638,7 +2681,7 @@ function paginate_links( $args = '' ) { if ( $mid_size < 0 ) { $mid_size = 2; } - $add_args = is_array( $args['add_args'] ) ? $args['add_args'] : false; + $add_args = $args['add_args']; $r = ''; $page_links = array(); $dots = false; @@ -2751,8 +2794,8 @@ function register_admin_color_schemes() { wp_admin_css_color( 'fresh', _x( 'Default', 'admin color scheme' ), false, - array( '#222', '#333', '#0074a2', '#2ea2cc' ), - array( 'base' => '#999', 'focus' => '#2ea2cc', 'current' => '#fff' ) + array( '#222', '#333', '#0073aa', '#00a0d2' ), + array( 'base' => '#999', 'focus' => '#00a0d2', 'current' => '#fff' ) ); // Other color schemes are not available when running out of src @@ -2854,8 +2897,9 @@ function wp_admin_css_uri( $file = 'wp-admin' ) { */ function wp_admin_css( $file = 'wp-admin', $force_echo = false ) { global $wp_styles; - if ( !is_a($wp_styles, 'WP_Styles') ) + if ( ! ( $wp_styles instanceof WP_Styles ) ) { $wp_styles = new WP_Styles(); + } // For backward compatibility $handle = 0 === strpos( $file, 'css/' ) ? substr( $file, 4 ) : $file;