~canonical-sysadmins/wordpress/4.9.4

« back to all changes in this revision

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

  • Committer: Barry Price
  • Date: 2017-11-17 04:49:02 UTC
  • mfrom: (1.1.30 upstream)
  • Revision ID: barry.price@canonical.com-20171117044902-5frux4ycbq6g9fyf
Merge WP4.9 from upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
43
43
         * Base for the author permalink structure (example.com/$author_base/authorname).
44
44
         *
45
45
         * @since 1.5.0
46
 
         * @access private
47
46
         * @var string
48
47
         */
49
48
        var $author_base = 'author';
52
51
         * Permalink structure for author archives.
53
52
         *
54
53
         * @since 1.5.0
55
 
         * @access private
56
54
         * @var string
57
55
         */
58
56
        var $author_structure;
61
59
         * Permalink structure for date archives.
62
60
         *
63
61
         * @since 1.5.0
64
 
         * @access private
65
62
         * @var string
66
63
         */
67
64
        var $date_structure;
70
67
         * Permalink structure for pages.
71
68
         *
72
69
         * @since 1.5.0
73
 
         * @access private
74
70
         * @var string
75
71
         */
76
72
        var $page_structure;
79
75
         * Base of the search permalink structure (example.com/$search_base/query).
80
76
         *
81
77
         * @since 1.5.0
82
 
         * @access private
83
78
         * @var string
84
79
         */
85
80
        var $search_base = 'search';
88
83
         * Permalink structure for searches.
89
84
         *
90
85
         * @since 1.5.0
91
 
         * @access private
92
86
         * @var string
93
87
         */
94
88
        var $search_structure;
97
91
         * Comments permalink base.
98
92
         *
99
93
         * @since 1.5.0
100
 
         * @access private
101
94
         * @var string
102
95
         */
103
96
        var $comments_base = 'comments';
114
107
         * Comments pagination permalink base.
115
108
         *
116
109
         * @since 4.2.0
117
 
         * @access private
118
110
         * @var string
119
111
         */
120
112
        var $comments_pagination_base = 'comment-page';
123
115
         * Feed permalink base.
124
116
         *
125
117
         * @since 1.5.0
126
 
         * @access private
127
118
         * @var string
128
119
         */
129
120
        var $feed_base = 'feed';
132
123
         * Comments feed permalink structure.
133
124
         *
134
125
         * @since 1.5.0
135
 
         * @access private
136
126
         * @var string
137
127
         */
138
128
        var $comment_feed_structure;
141
131
         * Feed request permalink structure.
142
132
         *
143
133
         * @since 1.5.0
144
 
         * @access private
145
134
         * @var string
146
135
         */
147
136
        var $feed_structure;
154
143
         * then the front is "/".
155
144
         *
156
145
         * @since 1.5.0
157
 
         * @access public
158
146
         * @var string
159
147
         *
160
148
         * @see WP_Rewrite::init()
169
157
         * will be empty.
170
158
         *
171
159
         * @since 1.5.0
172
 
         * @access public
173
160
         * @var string
174
161
         *
175
162
         * @see WP_Rewrite::init()
181
168
         * The name of the index file which is the entry point to all requests.
182
169
         *
183
170
         * @since 1.5.0
184
 
         * @access public
185
171
         * @var string
186
172
         */
187
173
        public $index = 'index.php';
190
176
         * Variable name to use for regex matches in the rewritten query.
191
177
         *
192
178
         * @since 1.5.0
193
 
         * @access private
194
179
         * @var string
195
180
         */
196
181
        var $matches = '';
199
184
         * Rewrite rules to match against the request to find the redirect or query.
200
185
         *
201
186
         * @since 1.5.0
202
 
         * @access private
203
187
         * @var array
204
188
         */
205
189
        var $rules;
210
194
         * Those not generated by the class, see add_rewrite_rule().
211
195
         *
212
196
         * @since 2.1.0
213
 
         * @access private
214
197
         * @var array
215
198
         */
216
199
        var $extra_rules = array();
221
204
         * Those not generated by the class, see add_rewrite_rule().
222
205
         *
223
206
         * @since 2.3.0
224
 
         * @access private
225
207
         * @var array
226
208
         */
227
209
        var $extra_rules_top = array();
233
215
         * and are added by add_external_rule().
234
216
         *
235
217
         * @since 2.1.0
236
 
         * @access private
237
218
         * @var array
238
219
         */
239
220
        var $non_wp_rules = array();
242
223
         * Extra permalink structures, e.g. categories, added by add_permastruct().
243
224
         *
244
225
         * @since 2.1.0
245
 
         * @access private
246
226
         * @var array
247
227
         */
248
228
        var $extra_permastructs = array();
251
231
         * Endpoints (like /trackback/) added by add_rewrite_endpoint().
252
232
         *
253
233
         * @since 2.1.0
254
 
         * @access private
255
234
         * @var array
256
235
         */
257
236
        var $endpoints;
263
242
         * to the .htaccess file.
264
243
         *
265
244
         * @since 2.0.0
266
 
         * @access public
267
245
         * @var bool
268
246
         *
269
247
         * @see WP_Rewrite::mod_rewrite_rules()
281
259
         * permastruct is actually a page before accepting it.
282
260
         *
283
261
         * @since 2.5.0
284
 
         * @access public
285
262
         * @var bool
286
263
         *
287
264
         * @see WP_Rewrite::init()
298
275
         * Additional tags can be added with add_rewrite_tag().
299
276
         *
300
277
         * @since 1.5.0
301
 
         * @access private
302
278
         * @var array
303
279
         */
304
280
        var $rewritecode = array(
320
296
         * of rewrite tags, see WP_Rewrite::$rewritecode.
321
297
         *
322
298
         * @since 1.5.0
323
 
         * @access private
324
299
         * @var array
325
300
         */
326
301
        var $rewritereplace = array(
341
316
         * Query variables that rewrite tags map to, see WP_Rewrite::$rewritecode.
342
317
         *
343
318
         * @since 1.5.0
344
 
         * @access private
345
319
         * @var array
346
320
         */
347
321
        var $queryreplace = array(
372
346
         * This can be either rewrite module or permalink in the HTTP query string.
373
347
         *
374
348
         * @since 1.5.0
375
 
         * @access public
376
349
         *
377
350
         * @return bool True, if permalinks are enabled.
378
351
         */
386
359
         * Means that permalink links are enabled and index.php is in the URL.
387
360
         *
388
361
         * @since 1.5.0
389
 
         * @access public
390
362
         *
391
363
         * @return bool Whether permalink links are enabled and index.php is in the URL.
392
364
         */
405
377
         * Using permalinks and index.php is not in the URL.
406
378
         *
407
379
         * @since 1.5.0
408
 
         * @access public
409
380
         *
410
381
         * @return bool Whether permalink links are enabled and index.php is NOT in the URL.
411
382
         */
424
395
         * value of the $number parameter.
425
396
         *
426
397
         * @since 1.5.0
427
 
         * @access public
428
398
         *
429
399
         * @param int $number Index number.
430
400
         * @return string
448
418
         * retrieved.
449
419
         *
450
420
         * @since 2.5.0
451
 
         * @access public
452
421
         *
453
422
         * @global wpdb $wpdb WordPress database abstraction object.
454
423
         *
492
461
         * Retrieves all of the rewrite rules for pages.
493
462
         *
494
463
         * @since 1.5.0
495
 
         * @access public
496
464
         *
497
465
         * @return array Page rewrite rules.
498
466
         */
519
487
         * structure.
520
488
         *
521
489
         * @since 1.5.0
522
 
         * @access public
523
490
         *
524
491
         * @return string|false False on no permalink structure. Date permalink structure.
525
492
         */
575
542
         * permalink structures.
576
543
         *
577
544
         * @since 1.5.0
578
 
         * @access public
579
545
         *
580
546
         * @return false|string False on failure. Year structure on success.
581
547
         */
599
565
         * structures. Keeps the year permalink structure.
600
566
         *
601
567
         * @since 1.5.0
602
 
         * @access public
603
568
         *
604
569
         * @return false|string False on failure. Year/Month structure on success.
605
570
         */
621
586
         * Keeps date permalink structure with all year, month, and day.
622
587
         *
623
588
         * @since 1.5.0
624
 
         * @access public
625
589
         *
626
590
         * @return string|false False on failure. Year/Month/Day structure on success.
627
591
         */
638
602
         * the category_base property value.
639
603
         *
640
604
         * @since 1.5.0
641
 
         * @access public
642
605
         *
643
606
         * @return string|false False on failure. Category permalink structure.
644
607
         */
655
618
         * property value.
656
619
         *
657
620
         * @since 2.3.0
658
 
         * @access public
659
621
         *
660
622
         * @return string|false False on failure. Tag permalink structure.
661
623
         */
667
629
         * Retrieves an extra permalink structure by name.
668
630
         *
669
631
         * @since 2.5.0
670
 
         * @access public
671
632
         *
672
633
         * @param string $name Permalink structure name.
673
634
         * @return string|false False if not found. Permalink structure string.
690
651
         * without attempting to set the value again.
691
652
         *
692
653
         * @since 1.5.0
693
 
         * @access public
694
654
         *
695
655
         * @return string|false False if not found. Permalink structure string.
696
656
         */
716
676
         * without attempting to set the value again.
717
677
         *
718
678
         * @since 1.5.0
719
 
         * @access public
720
679
         *
721
680
         * @return string|false False if not found. Permalink structure string.
722
681
         */
742
701
         * value again.
743
702
         *
744
703
         * @since 1.5.0
745
 
         * @access public
746
704
         *
747
705
         * @return string|false False if not found. Permalink structure string.
748
706
         */
768
726
         * without attempting to set the value again.
769
727
         *
770
728
         * @since 1.5.0
771
 
         * @access public
772
729
         *
773
730
         * @return string|false False if not found. Permalink structure string.
774
731
         */
794
751
         * and then return it without attempting to set the value again.
795
752
         *
796
753
         * @since 1.5.0
797
 
         * @access public
798
754
         *
799
755
         * @return string|false False if not found. Permalink structure string.
800
756
         */
819
775
         * that tag, otherwise add the new tag.
820
776
         *
821
777
         * @since 1.5.0
822
 
         * @access public
823
778
         *
824
779
         * @see WP_Rewrite::$rewritecode
825
780
         * @see WP_Rewrite::$rewritereplace
846
801
         * Removes an existing rewrite tag.
847
802
         *
848
803
         * @since 4.5.0
849
 
         * @access public
850
804
         *
851
805
         * @see WP_Rewrite::$rewritecode
852
806
         * @see WP_Rewrite::$rewritereplace
871
825
         * so best just ignore the contents and move to the parameters.
872
826
         *
873
827
         * @since 1.5.0
874
 
         * @access public
875
828
         *
876
829
         * @param string $permalink_structure The permalink structure.
877
830
         * @param int    $ep_mask             Optional. Endpoint mask defining what endpoints are added to the structure.
1237
1190
         * rewrite rules does.
1238
1191
         *
1239
1192
         * @since 1.5.0
1240
 
         * @access public
1241
1193
         *
1242
1194
         * @see WP_Rewrite::generate_rewrite_rules() See for long description and rest of parameters.
1243
1195
         *
1263
1215
         * from the function.
1264
1216
         *
1265
1217
         * @since 1.5.0
1266
 
         * @access public
1267
1218
         *
1268
1219
         * @return array An associate array of matches and queries.
1269
1220
         */
1441
1392
                 *
1442
1393
                 * @since 1.5.0
1443
1394
                 *
1444
 
                 * @param WP_Rewrite $this Current WP_Rewrite instance, passed by reference.
 
1395
                 * @param WP_Rewrite $this Current WP_Rewrite instance (passed by reference).
1445
1396
                 */
1446
1397
                do_action_ref_array( 'generate_rewrite_rules', array( &$this ) );
1447
1398
 
1466
1417
         * in the form of caching.
1467
1418
         *
1468
1419
         * @since 1.5.0
1469
 
         * @access public
1470
1420
         *
1471
1421
         * @return array Rewrite rules.
1472
1422
         */
1495
1445
         * the WordPress rewrite rules one.
1496
1446
         *
1497
1447
         * @since 1.5.0
1498
 
         * @access public
1499
1448
         *
1500
1449
         * @return string
1501
1450
         */
1580
1529
         * the process that will.
1581
1530
         *
1582
1531
         * @since 2.8.0
1583
 
         * @access public
1584
1532
         *
1585
1533
         * @param bool $add_parent_tags Optional. Whether to add parent tags to the rewrite rule sets.
1586
1534
         *                              Default false.
1633
1581
         *
1634
1582
         * @since 2.1.0
1635
1583
         * @since 4.4.0 Array support was added to the `$query` parameter.
1636
 
         * @access public
1637
1584
         *
1638
1585
         * @param string       $regex Regular expression to match request against.
1639
1586
         * @param string|array $query The corresponding query vars for this rewrite rule.
1667
1614
         * Adds a rewrite rule that doesn't correspond to index.php.
1668
1615
         *
1669
1616
         * @since 2.1.0
1670
 
         * @access public
1671
1617
         *
1672
1618
         * @param string $regex Regular expression to match request against.
1673
1619
         * @param string $query The corresponding query vars for this rewrite rule.
1682
1628
         * @since 2.1.0
1683
1629
         * @since 3.9.0 $query_var parameter added.
1684
1630
         * @since 4.3.0 Added support for skipping query var registration by passing `false` to `$query_var`.
1685
 
         * @access public
1686
1631
         *
1687
1632
         * @see add_rewrite_endpoint() for full documentation.
1688
1633
         * @global WP $wp
1722
1667
         * works on the new permastruct.
1723
1668
         *
1724
1669
         * @since 2.5.0
1725
 
         * @access public
1726
1670
         *
1727
1671
         * @param string $name   Name for permalink structure.
1728
1672
         * @param string $struct Permalink structure (e.g. category/%category%)
1778
1722
         * Removes a permalink structure.
1779
1723
         *
1780
1724
         * @since 4.5.0
1781
 
         * @access public
1782
1725
         *
1783
1726
         * @param string $name Name for permalink structure.
1784
1727
         */
1793
1736
         * If the function named 'save_mod_rewrite_rules' exists, it will be called.
1794
1737
         *
1795
1738
         * @since 2.0.1
1796
 
         * @access public
1797
1739
         *
1798
1740
         * @staticvar bool $do_hard_later
1799
1741
         *
1843
1785
         * '%tag%', or '%author%'.
1844
1786
         *
1845
1787
         * @since 1.5.0
1846
 
         * @access public
1847
1788
         */
1848
1789
        public function init() {
1849
1790
                $this->extra_rules = $this->non_wp_rules = $this->endpoints = array();
1880
1821
         * processed passing the old and new values
1881
1822
         *
1882
1823
         * @since 1.5.0
1883
 
         * @access public
1884
1824
         *
1885
1825
         * @param string $permalink_structure Permalink structure.
1886
1826
         */
1911
1851
         * after the option is updated.
1912
1852
         *
1913
1853
         * @since 1.5.0
1914
 
         * @access public
1915
1854
         *
1916
1855
         * @param string $category_base Category permalink structure base.
1917
1856
         */
1930
1869
         * the option is updated.
1931
1870
         *
1932
1871
         * @since 2.3.0
1933
 
         * @access public
1934
1872
         *
1935
1873
         * @param string $tag_base Tag permalink structure base.
1936
1874
         */
1945
1883
         * Constructor - Calls init(), which runs setup.
1946
1884
         *
1947
1885
         * @since 1.5.0
1948
 
         * @access public
1949
1886
         *
1950
1887
         */
1951
1888
        public function __construct() {