Changeset 32622
- Timestamp:
- 05/27/2015 07:22:59 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/rewrite.php
r32293 r32622 10 10 * Add a straight rewrite rule. 11 11 * 12 * @see WP_Rewrite::add_rule() for long description.13 12 * @since 2.1.0 14 13 * 15 * @param string $regex Regular Expression to match request against. 14 * @global WP_Rewrite $wp_rewrite 15 * 16 * @param string $regex Regular Expression to match request against. 16 17 * @param string $redirect Page to redirect to. 17 * @param string $after Optional, default is 'bottom'. Where to add rule, can also be 'top'.18 * @param string $after Optional, default is 'bottom'. Where to add rule, can also be 'top'. 18 19 */ 19 20 function add_rewrite_rule($regex, $redirect, $after = 'bottom') { … … 29 30 * to "$tag=", and for this to work a new query var has to be added. 30 31 * 31 * @see WP_Rewrite::add_rewrite_tag()32 32 * @since 2.1.0 33 33 * 34 * @param string $tag Name of the new rewrite tag. 34 * @global WP_Rewrite $wp_rewrite 35 * @global WP $wp 36 * 37 * @param string $tag Name of the new rewrite tag. 35 38 * @param string $regex Regular expression to substitute the tag for in rewrite rules. 36 39 * @param string $query String to append to the rewritten query. Must end in '='. Optional. … … 55 58 * Add permalink structure. 56 59 * 57 * @see WP_Rewrite::add_permastruct()58 60 * @since 3.0.0 59 61 * 60 * @param string $name Name for permalink structure. 62 * @global WP_Rewrite $wp_rewrite 63 * 64 * @param string $name Name for permalink structure. 61 65 * @param string $struct Permalink structure. 62 * @param array $argsOptional configuration for building the rules from the permalink structure,63 * see {@link WP_Rewrite::add_permastruct()} for full details.66 * @param array $args Optional configuration for building the rules from the permalink structure, 67 * see {@link WP_Rewrite::add_permastruct()} for full details. 64 68 */ 65 69 function add_permastruct( $name, $struct, $args = array() ) { … … 72 76 $args['ep_mask'] = func_get_arg( 3 ); 73 77 74 return$wp_rewrite->add_permastruct( $name, $struct, $args );78 $wp_rewrite->add_permastruct( $name, $struct, $args ); 75 79 } 76 80 … … 80 84 * @since 2.1.0 81 85 * 82 * @param string $feedname 86 * @global WP_Rewrite $wp_rewrite 87 * 88 * @param string $feedname 83 89 * @param callback $function Callback to run on feed display. 84 90 * @return string Feed action name. … … 98 104 * Remove rewrite rules and then recreate rewrite rules. 99 105 * 100 * @see WP_Rewrite::flush_rules()101 106 * @since 3.0.0 102 107 * 108 * @global WP_Rewrite $wp_rewrite 109 * 103 110 * @param bool $hard Whether to update .htaccess (hard flush) or just update 104 * rewrite_rules transient (soft flush). Default is true (hard).111 * rewrite_rules transient (soft flush). Default is true (hard). 105 112 */ 106 113 function flush_rewrite_rules( $hard = true ) { … … 246 253 * @since 4.3.0 Added support for skipping query var registration by passing `false` to `$query_var`. 247 254 * 248 * @see WP_Rewrite::add_endpoint() 249 * @global object $wp_rewrite 255 * @global WP_Rewrite $wp_rewrite 250 256 * 251 257 * @param string $name Name of the endpoint. … … 285 291 * @since 1.0.0 286 292 * 293 * @global WP_Rewrite $wp_rewrite 294 * @global WP $wp 295 * 287 296 * @param string $url Permalink to check. 288 297 * @return int Post ID, or 0 on failure. 289 298 */ 290 function url_to_postid( $url) {299 function url_to_postid( $url ) { 291 300 global $wp_rewrite; 292 301 … … 783 792 */ 784 793 public function using_index_permalinks() { 785 if ( empty( $this->permalink_structure) )794 if ( empty( $this->permalink_structure ) ) { 786 795 return false; 787 796 } 788 797 // If the index is not in the permalink, we're using mod_rewrite. 789 if ( preg_match('#^/*' . $this->index . '#', $this->permalink_structure) ) 790 return true; 791 792 return false; 798 return preg_match( '#^/*' . $this->index . '#', $this->permalink_structure ); 793 799 } 794 800 … … 804 810 */ 805 811 public function using_mod_rewrite_permalinks() { 806 if ( $this->using_permalinks() && ! $this->using_index_permalinks() ) 807 return true; 808 else 809 return false; 812 return $this->using_permalinks() && ! $this->using_index_permalinks(); 810 813 } 811 814 … … 846 849 * @since 2.5.0 847 850 * @access public 851 * 852 * @global wpdb $wpdb 848 853 * 849 854 * @return array Array of page URIs as first element and attachment URIs as second element. … … 980 985 $structure = str_replace('%monthnum%', '', $structure); 981 986 $structure = str_replace('%day%', '', $structure); 982 983 987 $structure = preg_replace('#/+#', '/', $structure); 984 988 … … 1004 1008 1005 1009 $structure = str_replace('%day%', '', $structure); 1006 1007 1010 $structure = preg_replace('#/+#', '/', $structure); 1008 1011 … … 1035 1038 * @access public 1036 1039 * 1037 * @return bool|stringFalse on failure. Category permalink structure.1040 * @return string|false False on failure. Category permalink structure. 1038 1041 */ 1039 1042 public function get_category_permastruct() { … … 1052 1055 * @access public 1053 1056 * 1054 * @return bool|stringFalse on failure. Tag permalink structure.1057 * @return string|false False on failure. Tag permalink structure. 1055 1058 */ 1056 1059 public function get_tag_permastruct() { … … 1065 1068 * 1066 1069 * @param string $name Permalink structure name. 1067 * @return string| boolFalse if not found. Permalink structure string.1070 * @return string|false False if not found. Permalink structure string. 1068 1071 */ 1069 1072 public function get_extra_permastruct($name) { … … 1191 1194 * @access public 1192 1195 * 1193 * @return string| boolFalse if not found. Permalink structure string.1196 * @return string|false False if not found. Permalink structure string. 1194 1197 */ 1195 1198 public function get_comment_feed_permastruct() { … … 1219 1222 * @access public 1220 1223 * 1221 * @param string $tag Name of the rewrite tag to add or update.1224 * @param string $tag Name of the rewrite tag to add or update. 1222 1225 * @param string $regex Regular expression to substitute the tag for in rewrite rules. 1223 1226 * @param string $query String to append to the rewritten query. Must end in '='. … … 1246 1249 * 1247 1250 * @param string $permalink_structure The permalink structure. 1248 * @param int $ep_maskEndpoint mask defining what endpoints are added to the structure. Default is EP_NONE.1249 * @param bool $pagedShould archive pagination rules be added for the structure? Default is true.1250 * @param bool $feedShould feed rewrite rules be added for the structure? Default is true.1251 * @param bool $forcommentsShould the feed rules be a query for a comments feed? Default is false.1252 * @param bool $walk_dirsShould the 'directories' making up the structure be walked over and rewrite rules1253 * built for each in turn? Default is true.1254 * @param bool $endpointsShould endpoints be applied to the generated rewrite rules? Default is true.1251 * @param int $ep_mask Endpoint mask defining what endpoints are added to the structure. Default is EP_NONE. 1252 * @param bool $paged Should archive pagination rules be added for the structure? Default is true. 1253 * @param bool $feed Should feed rewrite rules be added for the structure? Default is true. 1254 * @param bool $forcomments Should the feed rules be a query for a comments feed? Default is false. 1255 * @param bool $walk_dirs Should the 'directories' making up the structure be walked over and rewrite rules 1256 * built for each in turn? Default is true. 1257 * @param bool $endpoints Should endpoints be applied to the generated rewrite rules? Default is true. 1255 1258 * @return array Rewrite rule list. 1256 1259 */ … … 1523 1526 * 1524 1527 * @param string $permalink_structure The permalink structure to generate rules. 1525 * @param bool $walk_dirsOptional, default is false. Whether to create list of directories to walk over.1528 * @param bool $walk_dirs Optional, default is false. Whether to create list of directories to walk over. 1526 1529 * @return array 1527 1530 */ … … 1857 1860 * @param string $rules mod_rewrite Rewrite rules formatted for .htaccess. 1858 1861 */ 1859 $rules = apply_filters( 'rewrite_rules', $rules ); // Deprecated 1860 1861 return $rules; 1862 return apply_filters( 'rewrite_rules', $rules ); 1862 1863 } 1863 1864 … … 1874 1875 */ 1875 1876 public function iis7_url_rewrite_rules( $add_parent_tags = false ) { 1876 1877 1877 if ( ! $this->using_permalinks() ) 1878 1878 return ''; … … 1910 1910 * @param string $rules Rewrite rules formatted for IIS web.config. 1911 1911 */ 1912 $rules = apply_filters( 'iis7_url_rewrite_rules', $rules ); 1913 1914 return $rules; 1912 return apply_filters( 'iis7_url_rewrite_rules', $rules ); 1915 1913 } 1916 1914 … … 1924 1922 * @access public 1925 1923 * 1926 * @param string $regex Regular expression to match against request.1924 * @param string $regex Regular expression to match against request. 1927 1925 * @param string $redirect URL regex redirects to when regex matches request. 1928 * @param string $after Optional, default is bottom. Location to place rule.1926 * @param string $after Optional, default is bottom. Location to place rule. 1929 1927 */ 1930 1928 public function add_rule($regex, $redirect, $after = 'bottom') { … … 1951 1949 * @access public 1952 1950 * 1953 * @param string $regex Regular expression to match against request.1951 * @param string $regex Regular expression to match against request. 1954 1952 * @param string $redirect URL regex redirects to when regex matches request. 1955 1953 */ … … 1967 1965 * 1968 1966 * @see add_rewrite_endpoint() for full documentation. 1969 * @uses WP::add_query_var() 1967 * 1968 * @global WP $wp 1970 1969 * 1971 1970 * @param string $name Name of the endpoint. … … 2004 2003 * @access public 2005 2004 * 2006 * @param string $name Name for permalink structure.2005 * @param string $name Name for permalink structure. 2007 2006 * @param string $struct Permalink structure (e.g. category/%category%) 2008 * @param array $argsOptional configuration for building the rules from the permalink structure:2007 * @param array $args Optional configuration for building the rules from the permalink structure: 2009 2008 * - with_front (bool) - Should the structure be prepended with WP_Rewrite::$front? Default is true. 2010 2009 * - ep_mask (int) - Endpoint mask defining what endpoints are added to the structure. Default is EP_NONE. … … 2053 2052 * @since 2.0.1 2054 2053 * @access public 2054 * 2055 * @staticvar bool $do_hard_later 2056 * 2055 2057 * @param bool $hard Whether to update .htaccess (hard flush) or just update rewrite_rules option (soft flush). Default is true (hard). 2056 2058 */
Note: See TracChangeset
for help on using the changeset viewer.