~canonical-sysadmins/wordpress/4.8.3

« back to all changes in this revision

Viewing changes to wp-includes/class-wp.php

  • Committer: Ryan Finnie
  • Date: 2015-08-31 16:09:47 UTC
  • mfrom: (1.1.9 upstream)
  • Revision ID: ryan.finnie@canonical.com-20150831160947-1h6rfxby9z1ec62u
Merge WP4.3 from upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
115
115
         *
116
116
         * @since 2.0.0
117
117
         *
 
118
         * @global WP_Rewrite $wp_rewrite
 
119
         *
118
120
         * @param array|string $extra_query_vars Set the extra query variables.
119
121
         */
120
122
        public function parse_request($extra_query_vars = '') {
157
159
                        list( $req_uri ) = explode( '?', $_SERVER['REQUEST_URI'] );
158
160
                        $self = $_SERVER['PHP_SELF'];
159
161
                        $home_path = trim( parse_url( home_url(), PHP_URL_PATH ), '/' );
 
162
                        $home_path_regex = sprintf( '|^%s|i', preg_quote( $home_path, '|' ) );
160
163
 
161
164
                        // Trim path info from the end and the leading home path from the
162
165
                        // front. For path info requests, this leaves us with the requesting
164
167
                        // requested permalink.
165
168
                        $req_uri = str_replace($pathinfo, '', $req_uri);
166
169
                        $req_uri = trim($req_uri, '/');
167
 
                        $req_uri = preg_replace("|^$home_path|i", '', $req_uri);
 
170
                        $req_uri = preg_replace( $home_path_regex, '', $req_uri );
168
171
                        $req_uri = trim($req_uri, '/');
169
172
                        $pathinfo = trim($pathinfo, '/');
170
 
                        $pathinfo = preg_replace("|^$home_path|i", '', $pathinfo);
 
173
                        $pathinfo = preg_replace( $home_path_regex, '', $pathinfo );
171
174
                        $pathinfo = trim($pathinfo, '/');
172
175
                        $self = trim($self, '/');
173
 
                        $self = preg_replace("|^$home_path|i", '', $self);
 
176
                        $self = preg_replace( $home_path_regex, '', $self );
174
177
                        $self = trim($self, '/');
175
178
 
176
179
                        // The requested permalink is in $pathinfo for path info requests and
306
309
                        }
307
310
                }
308
311
 
 
312
                // Resolve conflicts between posts with numeric slugs and date archive queries.
 
313
                $this->query_vars = wp_resolve_numeric_slug_conflicts( $this->query_vars );
 
314
 
309
315
                foreach ( (array) $this->private_query_vars as $var) {
310
316
                        if ( isset($this->extra_query_vars[$var]) )
311
317
                                $this->query_vars[$var] = $this->extra_query_vars[$var];
488
494
         * be taken when naming global variables that might interfere with the
489
495
         * WordPress environment.
490
496
         *
491
 
         * @global string $query_string Query string for the loop.
492
 
         * @global array $posts The found posts.
 
497
         * @global WP_Query     $wp_query
 
498
         * @global string       $query_string Query string for the loop.
 
499
         * @global array        $posts The found posts.
493
500
         * @global WP_Post|null $post The current post, if available.
494
 
         * @global string $request The SQL statement for the request.
495
 
         * @global int $more Only set, if single page or post.
496
 
         * @global int $single If single page or post. Only set, if single page or post.
497
 
         * @global WP_User $authordata Only set, if author archive.
 
501
         * @global string       $request The SQL statement for the request.
 
502
         * @global int          $more Only set, if single page or post.
 
503
         * @global int          $single If single page or post. Only set, if single page or post.
 
504
         * @global WP_User      $authordata Only set, if author archive.
498
505
         *
499
506
         * @since 2.0.0
500
507
         */
533
540
         * Set up the Loop based on the query variables.
534
541
         *
535
542
         * @since 2.0.0
 
543
         *
 
544
         * @global WP_Query $wp_the_query
536
545
         */
537
546
        public function query_posts() {
538
547
                global $wp_the_query;
550
559
         * Otherwise, issue a 200.
551
560
         *
552
561
         * @since 2.0.0
 
562
         *
 
563
         * @global WP_Query $wp_query
553
564
         */
554
565
        public function handle_404() {
555
566
                global $wp_query;
621
632
                 */
622
633
                do_action_ref_array( 'wp', array( &$this ) );
623
634
        }
624
 
 
625
635
}
626
636
 
627
637
/**
678
688
         *
679
689
         * static helper function to ease use
680
690
         *
 
691
         * @static
681
692
         * @access public
 
693
         *
682
694
         * @param string $subject subject
683
695
         * @param array  $matches data used for substitution
684
696
         * @return string
710
722
                $index = intval(substr($matches[0], 9, -1));
711
723
                return ( isset( $this->_matches[$index] ) ? urlencode($this->_matches[$index]) : '' );
712
724
        }
713
 
 
714
725
}