Make WordPress Core


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/4.1/src/wp-includes/general-template.php

    r30864 r31435  
    25882588        global $wp_query, $wp_rewrite;
    25892589
    2590         $total        = ( isset( $wp_query->max_num_pages ) ) ? $wp_query->max_num_pages : 1;
    2591         $current      = ( get_query_var( 'paged' ) ) ? intval( get_query_var( 'paged' ) ) : 1;
     2590        // Setting up default values based on the current URL.
    25922591        $pagenum_link = html_entity_decode( get_pagenum_link() );
    2593         $query_args   = array();
    25942592        $url_parts    = explode( '?', $pagenum_link );
    25952593
    2596         if ( isset( $url_parts[1] ) ) {
    2597                 wp_parse_str( $url_parts[1], $query_args );
    2598                 $query_args = urlencode_deep( $query_args );
    2599         }
    2600 
    2601         $pagenum_link = remove_query_arg( array_keys( $query_args ), $pagenum_link );
    2602         $pagenum_link = trailingslashit( $pagenum_link ) . '%_%';
    2603 
     2594        // Get max pages and current page out of the current query, if available.
     2595        $total   = isset( $wp_query->max_num_pages ) ? $wp_query->max_num_pages : 1;
     2596        $current = get_query_var( 'paged' ) ? intval( get_query_var( 'paged' ) ) : 1;
     2597
     2598        // Append the format placeholder to the base URL.
     2599        $pagenum_link = trailingslashit( $url_parts[0] ) . '%_%';
     2600
     2601        // URL base depends on permalink settings.
    26042602        $format  = $wp_rewrite->using_index_permalinks() && ! strpos( $pagenum_link, 'index.php' ) ? 'index.php/' : '';
    26052603        $format .= $wp_rewrite->using_permalinks() ? user_trailingslashit( $wp_rewrite->pagination_base . '/%#%', 'paged' ) : '?paged=%#%';
    … …  
    26172615                'mid_size' => 2,
    26182616                'type' => 'plain',
    2619                 'add_args' => $query_args, // array of query args to add
     2617                'add_args' => array(), // array of query args to add
    26202618                'add_fragment' => '',
    26212619                'before_page_number' => '',
    … …  
    26252623        $args = wp_parse_args( $args, $defaults );
    26262624
     2625        if ( ! is_array( $args['add_args'] ) ) {
     2626                $args['add_args'] = array();
     2627        }
     2628
     2629        // Merge additional query vars found in the original URL into 'add_args' array.
     2630        if ( isset( $url_parts[1] ) ) {
     2631                // Find the format argument.
     2632                $format_query = parse_url( str_replace( '%_%', $args['format'], $args['base'] ), PHP_URL_QUERY );
     2633                wp_parse_str( $format_query, $format_arg );
     2634
     2635                // Remove the format argument from the array of query arguments, to avoid overwriting custom format.
     2636                wp_parse_str( remove_query_arg( array_keys( $format_arg ), $url_parts[1] ), $query_args );
     2637                $args['add_args'] = array_merge( $args['add_args'], urlencode_deep( $query_args ) );
     2638        }
     2639
    26272640        // Who knows what else people pass in $args
    26282641        $total = (int) $args['total'];
    … …  
    26392652                $mid_size = 2;
    26402653        }
    2641         $add_args = is_array( $args['add_args'] ) ? $args['add_args'] : false;
     2654        $add_args = $args['add_args'];
    26422655        $r = '';
    26432656        $page_links = array();
    … …  
    31143127        return $settings;
    31153128}
     3129
     3130/**
     3131 * Temporary function to add a missing style rule to the themes page.
     3132 * This avoids the need to ship an entirely rebuilt wp-admin.css in partial builds.
     3133 *
     3134 * @since 4.1.1
     3135 * @ignore
     3136 */
     3137function _wp_add_themesphp_notice_styling() {
     3138        global $pagenow;
     3139        if ( 'themes.php' == $pagenow ) {
     3140                echo "<style type='text/css'>.themes-php div.notice { margin: 0 0 20px 0; clear: both; }</style>\n";
     3141        }
     3142}
     3143add_action( 'admin_head', '_wp_add_themesphp_notice_styling' );
Note: See TracChangeset for help on using the changeset viewer.