Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93

Warning: Undefined array key "page_file_edit_line" in /home/sportsfever/public_html/filemanger/edit_text_line.php on line 32
/home/sportsfe.../httpdocs/clone/wp-inclu...
File: class-wp-rewrite.php
$feedmatch = $match . $feedregex;
[1000] Fix | Delete
$feedquery = $feedindex . '?' . $query . '&feed=' . $this->preg_index( $num_toks + 1 );
[1001] Fix | Delete
[1002] Fix | Delete
// Create query for /(feed|atom|rss|rss2|rdf) (see comment near creation of $feedregex).
[1003] Fix | Delete
$feedmatch2 = $match . $feedregex2;
[1004] Fix | Delete
$feedquery2 = $feedindex . '?' . $query . '&feed=' . $this->preg_index( $num_toks + 1 );
[1005] Fix | Delete
[1006] Fix | Delete
// Create query and regex for embeds.
[1007] Fix | Delete
$embedmatch = $match . $embedregex;
[1008] Fix | Delete
$embedquery = $embedindex . '?' . $query . '&embed=true';
[1009] Fix | Delete
[1010] Fix | Delete
// If asked to, turn the feed queries into comment feed ones.
[1011] Fix | Delete
if ( $forcomments ) {
[1012] Fix | Delete
$feedquery .= '&withcomments=1';
[1013] Fix | Delete
$feedquery2 .= '&withcomments=1';
[1014] Fix | Delete
}
[1015] Fix | Delete
[1016] Fix | Delete
// Start creating the array of rewrites for this dir.
[1017] Fix | Delete
$rewrite = array();
[1018] Fix | Delete
[1019] Fix | Delete
// ...adding on /feed/ regexes => queries.
[1020] Fix | Delete
if ( $feed ) {
[1021] Fix | Delete
$rewrite = array(
[1022] Fix | Delete
$feedmatch => $feedquery,
[1023] Fix | Delete
$feedmatch2 => $feedquery2,
[1024] Fix | Delete
$embedmatch => $embedquery,
[1025] Fix | Delete
);
[1026] Fix | Delete
}
[1027] Fix | Delete
[1028] Fix | Delete
// ...and /page/xx ones.
[1029] Fix | Delete
if ( $paged ) {
[1030] Fix | Delete
$rewrite = array_merge( $rewrite, array( $pagematch => $pagequery ) );
[1031] Fix | Delete
}
[1032] Fix | Delete
[1033] Fix | Delete
// Only on pages with comments add ../comment-page-xx/.
[1034] Fix | Delete
if ( EP_PAGES & $ep_mask || EP_PERMALINK & $ep_mask ) {
[1035] Fix | Delete
$rewrite = array_merge( $rewrite, array( $commentmatch => $commentquery ) );
[1036] Fix | Delete
} elseif ( EP_ROOT & $ep_mask && get_option( 'page_on_front' ) ) {
[1037] Fix | Delete
$rewrite = array_merge( $rewrite, array( $rootcommentmatch => $rootcommentquery ) );
[1038] Fix | Delete
}
[1039] Fix | Delete
[1040] Fix | Delete
// Do endpoints.
[1041] Fix | Delete
if ( $endpoints ) {
[1042] Fix | Delete
foreach ( (array) $ep_query_append as $regex => $ep ) {
[1043] Fix | Delete
// Add the endpoints on if the mask fits.
[1044] Fix | Delete
if ( $ep[0] & $ep_mask || $ep[0] & $ep_mask_specific ) {
[1045] Fix | Delete
$rewrite[ $match . $regex ] = $index . '?' . $query . $ep[1] . $this->preg_index( $num_toks + 2 );
[1046] Fix | Delete
}
[1047] Fix | Delete
}
[1048] Fix | Delete
}
[1049] Fix | Delete
[1050] Fix | Delete
// If we've got some tags in this dir.
[1051] Fix | Delete
if ( $num_toks ) {
[1052] Fix | Delete
$post = false;
[1053] Fix | Delete
$page = false;
[1054] Fix | Delete
[1055] Fix | Delete
/*
[1056] Fix | Delete
* Check to see if this dir is permalink-level: i.e. the structure specifies an
[1057] Fix | Delete
* individual post. Do this by checking it contains at least one of 1) post name,
[1058] Fix | Delete
* 2) post ID, 3) page name, 4) timestamp (year, month, day, hour, second and
[1059] Fix | Delete
* minute all present). Set these flags now as we need them for the endpoints.
[1060] Fix | Delete
*/
[1061] Fix | Delete
if ( str_contains( $struct, '%postname%' )
[1062] Fix | Delete
|| str_contains( $struct, '%post_id%' )
[1063] Fix | Delete
|| str_contains( $struct, '%pagename%' )
[1064] Fix | Delete
|| ( str_contains( $struct, '%year%' )
[1065] Fix | Delete
&& str_contains( $struct, '%monthnum%' )
[1066] Fix | Delete
&& str_contains( $struct, '%day%' )
[1067] Fix | Delete
&& str_contains( $struct, '%hour%' )
[1068] Fix | Delete
&& str_contains( $struct, '%minute%' )
[1069] Fix | Delete
&& str_contains( $struct, '%second%' ) )
[1070] Fix | Delete
) {
[1071] Fix | Delete
$post = true;
[1072] Fix | Delete
if ( str_contains( $struct, '%pagename%' ) ) {
[1073] Fix | Delete
$page = true;
[1074] Fix | Delete
}
[1075] Fix | Delete
}
[1076] Fix | Delete
[1077] Fix | Delete
if ( ! $post ) {
[1078] Fix | Delete
// For custom post types, we need to add on endpoints as well.
[1079] Fix | Delete
foreach ( get_post_types( array( '_builtin' => false ) ) as $ptype ) {
[1080] Fix | Delete
if ( str_contains( $struct, "%$ptype%" ) ) {
[1081] Fix | Delete
$post = true;
[1082] Fix | Delete
[1083] Fix | Delete
// This is for page style attachment URLs.
[1084] Fix | Delete
$page = is_post_type_hierarchical( $ptype );
[1085] Fix | Delete
break;
[1086] Fix | Delete
}
[1087] Fix | Delete
}
[1088] Fix | Delete
}
[1089] Fix | Delete
[1090] Fix | Delete
// If creating rules for a permalink, do all the endpoints like attachments etc.
[1091] Fix | Delete
if ( $post ) {
[1092] Fix | Delete
// Create query and regex for trackback.
[1093] Fix | Delete
$trackbackmatch = $match . $trackbackregex;
[1094] Fix | Delete
$trackbackquery = $trackbackindex . '?' . $query . '&tb=1';
[1095] Fix | Delete
[1096] Fix | Delete
// Create query and regex for embeds.
[1097] Fix | Delete
$embedmatch = $match . $embedregex;
[1098] Fix | Delete
$embedquery = $embedindex . '?' . $query . '&embed=true';
[1099] Fix | Delete
[1100] Fix | Delete
// Trim slashes from the end of the regex for this dir.
[1101] Fix | Delete
$match = rtrim( $match, '/' );
[1102] Fix | Delete
[1103] Fix | Delete
// Get rid of brackets.
[1104] Fix | Delete
$submatchbase = str_replace( array( '(', ')' ), '', $match );
[1105] Fix | Delete
[1106] Fix | Delete
// Add a rule for at attachments, which take the form of <permalink>/some-text.
[1107] Fix | Delete
$sub1 = $submatchbase . '/([^/]+)/';
[1108] Fix | Delete
[1109] Fix | Delete
// Add trackback regex <permalink>/trackback/...
[1110] Fix | Delete
$sub1tb = $sub1 . $trackbackregex;
[1111] Fix | Delete
[1112] Fix | Delete
// And <permalink>/feed/(atom|...)
[1113] Fix | Delete
$sub1feed = $sub1 . $feedregex;
[1114] Fix | Delete
[1115] Fix | Delete
// And <permalink>/(feed|atom...)
[1116] Fix | Delete
$sub1feed2 = $sub1 . $feedregex2;
[1117] Fix | Delete
[1118] Fix | Delete
// And <permalink>/comment-page-xx
[1119] Fix | Delete
$sub1comment = $sub1 . $commentregex;
[1120] Fix | Delete
[1121] Fix | Delete
// And <permalink>/embed/...
[1122] Fix | Delete
$sub1embed = $sub1 . $embedregex;
[1123] Fix | Delete
[1124] Fix | Delete
/*
[1125] Fix | Delete
* Add another rule to match attachments in the explicit form:
[1126] Fix | Delete
* <permalink>/attachment/some-text
[1127] Fix | Delete
*/
[1128] Fix | Delete
$sub2 = $submatchbase . '/attachment/([^/]+)/';
[1129] Fix | Delete
[1130] Fix | Delete
// And add trackbacks <permalink>/attachment/trackback.
[1131] Fix | Delete
$sub2tb = $sub2 . $trackbackregex;
[1132] Fix | Delete
[1133] Fix | Delete
// Feeds, <permalink>/attachment/feed/(atom|...)
[1134] Fix | Delete
$sub2feed = $sub2 . $feedregex;
[1135] Fix | Delete
[1136] Fix | Delete
// And feeds again on to this <permalink>/attachment/(feed|atom...)
[1137] Fix | Delete
$sub2feed2 = $sub2 . $feedregex2;
[1138] Fix | Delete
[1139] Fix | Delete
// And <permalink>/comment-page-xx
[1140] Fix | Delete
$sub2comment = $sub2 . $commentregex;
[1141] Fix | Delete
[1142] Fix | Delete
// And <permalink>/embed/...
[1143] Fix | Delete
$sub2embed = $sub2 . $embedregex;
[1144] Fix | Delete
[1145] Fix | Delete
// Create queries for these extra tag-ons we've just dealt with.
[1146] Fix | Delete
$subquery = $index . '?attachment=' . $this->preg_index( 1 );
[1147] Fix | Delete
$subtbquery = $subquery . '&tb=1';
[1148] Fix | Delete
$subfeedquery = $subquery . '&feed=' . $this->preg_index( 2 );
[1149] Fix | Delete
$subcommentquery = $subquery . '&cpage=' . $this->preg_index( 2 );
[1150] Fix | Delete
$subembedquery = $subquery . '&embed=true';
[1151] Fix | Delete
[1152] Fix | Delete
// Do endpoints for attachments.
[1153] Fix | Delete
if ( ! empty( $endpoints ) ) {
[1154] Fix | Delete
foreach ( (array) $ep_query_append as $regex => $ep ) {
[1155] Fix | Delete
if ( $ep[0] & EP_ATTACHMENT ) {
[1156] Fix | Delete
$rewrite[ $sub1 . $regex ] = $subquery . $ep[1] . $this->preg_index( 3 );
[1157] Fix | Delete
$rewrite[ $sub2 . $regex ] = $subquery . $ep[1] . $this->preg_index( 3 );
[1158] Fix | Delete
}
[1159] Fix | Delete
}
[1160] Fix | Delete
}
[1161] Fix | Delete
[1162] Fix | Delete
/*
[1163] Fix | Delete
* Now we've finished with endpoints, finish off the $sub1 and $sub2 matches
[1164] Fix | Delete
* add a ? as we don't have to match that last slash, and finally a $ so we
[1165] Fix | Delete
* match to the end of the URL
[1166] Fix | Delete
*/
[1167] Fix | Delete
$sub1 .= '?$';
[1168] Fix | Delete
$sub2 .= '?$';
[1169] Fix | Delete
[1170] Fix | Delete
/*
[1171] Fix | Delete
* Post pagination, e.g. <permalink>/2/
[1172] Fix | Delete
* Previously: '(/[0-9]+)?/?$', which produced '/2' for page.
[1173] Fix | Delete
* When cast to int, returned 0.
[1174] Fix | Delete
*/
[1175] Fix | Delete
$match = $match . '(?:/([0-9]+))?/?$';
[1176] Fix | Delete
$query = $index . '?' . $query . '&page=' . $this->preg_index( $num_toks + 1 );
[1177] Fix | Delete
[1178] Fix | Delete
// Not matching a permalink so this is a lot simpler.
[1179] Fix | Delete
} else {
[1180] Fix | Delete
// Close the match and finalize the query.
[1181] Fix | Delete
$match .= '?$';
[1182] Fix | Delete
$query = $index . '?' . $query;
[1183] Fix | Delete
}
[1184] Fix | Delete
[1185] Fix | Delete
/*
[1186] Fix | Delete
* Create the final array for this dir by joining the $rewrite array (which currently
[1187] Fix | Delete
* only contains rules/queries for trackback, pages etc) to the main regex/query for
[1188] Fix | Delete
* this dir
[1189] Fix | Delete
*/
[1190] Fix | Delete
$rewrite = array_merge( $rewrite, array( $match => $query ) );
[1191] Fix | Delete
[1192] Fix | Delete
// If we're matching a permalink, add those extras (attachments etc) on.
[1193] Fix | Delete
if ( $post ) {
[1194] Fix | Delete
// Add trackback.
[1195] Fix | Delete
$rewrite = array_merge( array( $trackbackmatch => $trackbackquery ), $rewrite );
[1196] Fix | Delete
[1197] Fix | Delete
// Add embed.
[1198] Fix | Delete
$rewrite = array_merge( array( $embedmatch => $embedquery ), $rewrite );
[1199] Fix | Delete
[1200] Fix | Delete
// Add regexes/queries for attachments, attachment trackbacks and so on.
[1201] Fix | Delete
if ( ! $page ) {
[1202] Fix | Delete
// Require <permalink>/attachment/stuff form for pages because of confusion with subpages.
[1203] Fix | Delete
$rewrite = array_merge(
[1204] Fix | Delete
$rewrite,
[1205] Fix | Delete
array(
[1206] Fix | Delete
$sub1 => $subquery,
[1207] Fix | Delete
$sub1tb => $subtbquery,
[1208] Fix | Delete
$sub1feed => $subfeedquery,
[1209] Fix | Delete
$sub1feed2 => $subfeedquery,
[1210] Fix | Delete
$sub1comment => $subcommentquery,
[1211] Fix | Delete
$sub1embed => $subembedquery,
[1212] Fix | Delete
)
[1213] Fix | Delete
);
[1214] Fix | Delete
}
[1215] Fix | Delete
[1216] Fix | Delete
$rewrite = array_merge(
[1217] Fix | Delete
array(
[1218] Fix | Delete
$sub2 => $subquery,
[1219] Fix | Delete
$sub2tb => $subtbquery,
[1220] Fix | Delete
$sub2feed => $subfeedquery,
[1221] Fix | Delete
$sub2feed2 => $subfeedquery,
[1222] Fix | Delete
$sub2comment => $subcommentquery,
[1223] Fix | Delete
$sub2embed => $subembedquery,
[1224] Fix | Delete
),
[1225] Fix | Delete
$rewrite
[1226] Fix | Delete
);
[1227] Fix | Delete
}
[1228] Fix | Delete
}
[1229] Fix | Delete
// Add the rules for this dir to the accumulating $post_rewrite.
[1230] Fix | Delete
$post_rewrite = array_merge( $rewrite, $post_rewrite );
[1231] Fix | Delete
}
[1232] Fix | Delete
[1233] Fix | Delete
// The finished rules. phew!
[1234] Fix | Delete
return $post_rewrite;
[1235] Fix | Delete
}
[1236] Fix | Delete
[1237] Fix | Delete
/**
[1238] Fix | Delete
* Generates rewrite rules with permalink structure and walking directory only.
[1239] Fix | Delete
*
[1240] Fix | Delete
* Shorten version of WP_Rewrite::generate_rewrite_rules() that allows for shorter
[1241] Fix | Delete
* list of parameters. See the method for longer description of what generating
[1242] Fix | Delete
* rewrite rules does.
[1243] Fix | Delete
*
[1244] Fix | Delete
* @since 1.5.0
[1245] Fix | Delete
*
[1246] Fix | Delete
* @see WP_Rewrite::generate_rewrite_rules() See for long description and rest of parameters.
[1247] Fix | Delete
*
[1248] Fix | Delete
* @param string $permalink_structure The permalink structure to generate rules.
[1249] Fix | Delete
* @param bool $walk_dirs Optional. Whether to create list of directories to walk over.
[1250] Fix | Delete
* Default false.
[1251] Fix | Delete
* @return array An array of rewrite rules keyed by their regex pattern.
[1252] Fix | Delete
*/
[1253] Fix | Delete
public function generate_rewrite_rule( $permalink_structure, $walk_dirs = false ) {
[1254] Fix | Delete
return $this->generate_rewrite_rules( $permalink_structure, EP_NONE, false, false, false, $walk_dirs );
[1255] Fix | Delete
}
[1256] Fix | Delete
[1257] Fix | Delete
/**
[1258] Fix | Delete
* Constructs rewrite matches and queries from permalink structure.
[1259] Fix | Delete
*
[1260] Fix | Delete
* Runs the action {@see 'generate_rewrite_rules'} with the parameter that is an
[1261] Fix | Delete
* reference to the current WP_Rewrite instance to further manipulate the
[1262] Fix | Delete
* permalink structures and rewrite rules. Runs the {@see 'rewrite_rules_array'}
[1263] Fix | Delete
* filter on the full rewrite rule array.
[1264] Fix | Delete
*
[1265] Fix | Delete
* There are two ways to manipulate the rewrite rules, one by hooking into
[1266] Fix | Delete
* the {@see 'generate_rewrite_rules'} action and gaining full control of the
[1267] Fix | Delete
* object or just manipulating the rewrite rule array before it is passed
[1268] Fix | Delete
* from the function.
[1269] Fix | Delete
*
[1270] Fix | Delete
* @since 1.5.0
[1271] Fix | Delete
*
[1272] Fix | Delete
* @return string[] An associative array of matches and queries.
[1273] Fix | Delete
*/
[1274] Fix | Delete
public function rewrite_rules() {
[1275] Fix | Delete
$rewrite = array();
[1276] Fix | Delete
[1277] Fix | Delete
if ( empty( $this->permalink_structure ) ) {
[1278] Fix | Delete
return $rewrite;
[1279] Fix | Delete
}
[1280] Fix | Delete
[1281] Fix | Delete
// robots.txt -- only if installed at the root.
[1282] Fix | Delete
$home_path = parse_url( home_url() );
[1283] Fix | Delete
$robots_rewrite = ( empty( $home_path['path'] ) || '/' === $home_path['path'] ) ? array( 'robots\.txt$' => $this->index . '?robots=1' ) : array();
[1284] Fix | Delete
[1285] Fix | Delete
// favicon.ico -- only if installed at the root.
[1286] Fix | Delete
$favicon_rewrite = ( empty( $home_path['path'] ) || '/' === $home_path['path'] ) ? array( 'favicon\.ico$' => $this->index . '?favicon=1' ) : array();
[1287] Fix | Delete
[1288] Fix | Delete
// Old feed and service files.
[1289] Fix | Delete
$deprecated_files = array(
[1290] Fix | Delete
'.*wp-(atom|rdf|rss|rss2|feed|commentsrss2)\.php$' => $this->index . '?feed=old',
[1291] Fix | Delete
'.*wp-app\.php(/.*)?$' => $this->index . '?error=403',
[1292] Fix | Delete
);
[1293] Fix | Delete
[1294] Fix | Delete
// Registration rules.
[1295] Fix | Delete
$registration_pages = array();
[1296] Fix | Delete
if ( is_multisite() && is_main_site() ) {
[1297] Fix | Delete
$registration_pages['.*wp-signup.php$'] = $this->index . '?signup=true';
[1298] Fix | Delete
$registration_pages['.*wp-activate.php$'] = $this->index . '?activate=true';
[1299] Fix | Delete
}
[1300] Fix | Delete
[1301] Fix | Delete
// Deprecated.
[1302] Fix | Delete
$registration_pages['.*wp-register.php$'] = $this->index . '?register=true';
[1303] Fix | Delete
[1304] Fix | Delete
// Post rewrite rules.
[1305] Fix | Delete
$post_rewrite = $this->generate_rewrite_rules( $this->permalink_structure, EP_PERMALINK );
[1306] Fix | Delete
[1307] Fix | Delete
/**
[1308] Fix | Delete
* Filters rewrite rules used for "post" archives.
[1309] Fix | Delete
*
[1310] Fix | Delete
* @since 1.5.0
[1311] Fix | Delete
*
[1312] Fix | Delete
* @param string[] $post_rewrite Array of rewrite rules for posts, keyed by their regex pattern.
[1313] Fix | Delete
*/
[1314] Fix | Delete
$post_rewrite = apply_filters( 'post_rewrite_rules', $post_rewrite );
[1315] Fix | Delete
[1316] Fix | Delete
// Date rewrite rules.
[1317] Fix | Delete
$date_rewrite = $this->generate_rewrite_rules( $this->get_date_permastruct(), EP_DATE );
[1318] Fix | Delete
[1319] Fix | Delete
/**
[1320] Fix | Delete
* Filters rewrite rules used for date archives.
[1321] Fix | Delete
*
[1322] Fix | Delete
* Likely date archives would include `/yyyy/`, `/yyyy/mm/`, and `/yyyy/mm/dd/`.
[1323] Fix | Delete
*
[1324] Fix | Delete
* @since 1.5.0
[1325] Fix | Delete
*
[1326] Fix | Delete
* @param string[] $date_rewrite Array of rewrite rules for date archives, keyed by their regex pattern.
[1327] Fix | Delete
*/
[1328] Fix | Delete
$date_rewrite = apply_filters( 'date_rewrite_rules', $date_rewrite );
[1329] Fix | Delete
[1330] Fix | Delete
// Root-level rewrite rules.
[1331] Fix | Delete
$root_rewrite = $this->generate_rewrite_rules( $this->root . '/', EP_ROOT );
[1332] Fix | Delete
[1333] Fix | Delete
/**
[1334] Fix | Delete
* Filters rewrite rules used for root-level archives.
[1335] Fix | Delete
*
[1336] Fix | Delete
* Likely root-level archives would include pagination rules for the homepage
[1337] Fix | Delete
* as well as site-wide post feeds (e.g. `/feed/`, and `/feed/atom/`).
[1338] Fix | Delete
*
[1339] Fix | Delete
* @since 1.5.0
[1340] Fix | Delete
*
[1341] Fix | Delete
* @param string[] $root_rewrite Array of root-level rewrite rules, keyed by their regex pattern.
[1342] Fix | Delete
*/
[1343] Fix | Delete
$root_rewrite = apply_filters( 'root_rewrite_rules', $root_rewrite );
[1344] Fix | Delete
[1345] Fix | Delete
// Comments rewrite rules.
[1346] Fix | Delete
$comments_rewrite = $this->generate_rewrite_rules( $this->root . $this->comments_base, EP_COMMENTS, false, true, true, false );
[1347] Fix | Delete
[1348] Fix | Delete
/**
[1349] Fix | Delete
* Filters rewrite rules used for comment feed archives.
[1350] Fix | Delete
*
[1351] Fix | Delete
* Likely comments feed archives include `/comments/feed/` and `/comments/feed/atom/`.
[1352] Fix | Delete
*
[1353] Fix | Delete
* @since 1.5.0
[1354] Fix | Delete
*
[1355] Fix | Delete
* @param string[] $comments_rewrite Array of rewrite rules for the site-wide comments feeds, keyed by their regex pattern.
[1356] Fix | Delete
*/
[1357] Fix | Delete
$comments_rewrite = apply_filters( 'comments_rewrite_rules', $comments_rewrite );
[1358] Fix | Delete
[1359] Fix | Delete
// Search rewrite rules.
[1360] Fix | Delete
$search_structure = $this->get_search_permastruct();
[1361] Fix | Delete
$search_rewrite = $this->generate_rewrite_rules( $search_structure, EP_SEARCH );
[1362] Fix | Delete
[1363] Fix | Delete
/**
[1364] Fix | Delete
* Filters rewrite rules used for search archives.
[1365] Fix | Delete
*
[1366] Fix | Delete
* Likely search-related archives include `/search/search+query/` as well as
[1367] Fix | Delete
* pagination and feed paths for a search.
[1368] Fix | Delete
*
[1369] Fix | Delete
* @since 1.5.0
[1370] Fix | Delete
*
[1371] Fix | Delete
* @param string[] $search_rewrite Array of rewrite rules for search queries, keyed by their regex pattern.
[1372] Fix | Delete
*/
[1373] Fix | Delete
$search_rewrite = apply_filters( 'search_rewrite_rules', $search_rewrite );
[1374] Fix | Delete
[1375] Fix | Delete
// Author rewrite rules.
[1376] Fix | Delete
$author_rewrite = $this->generate_rewrite_rules( $this->get_author_permastruct(), EP_AUTHORS );
[1377] Fix | Delete
[1378] Fix | Delete
/**
[1379] Fix | Delete
* Filters rewrite rules used for author archives.
[1380] Fix | Delete
*
[1381] Fix | Delete
* Likely author archives would include `/author/author-name/`, as well as
[1382] Fix | Delete
* pagination and feed paths for author archives.
[1383] Fix | Delete
*
[1384] Fix | Delete
* @since 1.5.0
[1385] Fix | Delete
*
[1386] Fix | Delete
* @param string[] $author_rewrite Array of rewrite rules for author archives, keyed by their regex pattern.
[1387] Fix | Delete
*/
[1388] Fix | Delete
$author_rewrite = apply_filters( 'author_rewrite_rules', $author_rewrite );
[1389] Fix | Delete
[1390] Fix | Delete
// Pages rewrite rules.
[1391] Fix | Delete
$page_rewrite = $this->page_rewrite_rules();
[1392] Fix | Delete
[1393] Fix | Delete
/**
[1394] Fix | Delete
* Filters rewrite rules used for "page" post type archives.
[1395] Fix | Delete
*
[1396] Fix | Delete
* @since 1.5.0
[1397] Fix | Delete
*
[1398] Fix | Delete
* @param string[] $page_rewrite Array of rewrite rules for the "page" post type, keyed by their regex pattern.
[1399] Fix | Delete
*/
[1400] Fix | Delete
$page_rewrite = apply_filters( 'page_rewrite_rules', $page_rewrite );
[1401] Fix | Delete
[1402] Fix | Delete
// Extra permastructs.
[1403] Fix | Delete
foreach ( $this->extra_permastructs as $permastructname => $struct ) {
[1404] Fix | Delete
if ( is_array( $struct ) ) {
[1405] Fix | Delete
if ( count( $struct ) === 2 ) {
[1406] Fix | Delete
$rules = $this->generate_rewrite_rules( $struct[0], $struct[1] );
[1407] Fix | Delete
} else {
[1408] Fix | Delete
$rules = $this->generate_rewrite_rules( $struct['struct'], $struct['ep_mask'], $struct['paged'], $struct['feed'], $struct['forcomments'], $struct['walk_dirs'], $struct['endpoints'] );
[1409] Fix | Delete
}
[1410] Fix | Delete
} else {
[1411] Fix | Delete
$rules = $this->generate_rewrite_rules( $struct );
[1412] Fix | Delete
}
[1413] Fix | Delete
[1414] Fix | Delete
/**
[1415] Fix | Delete
* Filters rewrite rules used for individual permastructs.
[1416] Fix | Delete
*
[1417] Fix | Delete
* The dynamic portion of the hook name, `$permastructname`, refers
[1418] Fix | Delete
* to the name of the registered permastruct.
[1419] Fix | Delete
*
[1420] Fix | Delete
* Possible hook names include:
[1421] Fix | Delete
*
[1422] Fix | Delete
* - `category_rewrite_rules`
[1423] Fix | Delete
* - `post_format_rewrite_rules`
[1424] Fix | Delete
* - `post_tag_rewrite_rules`
[1425] Fix | Delete
*
[1426] Fix | Delete
* @since 3.1.0
[1427] Fix | Delete
*
[1428] Fix | Delete
* @param string[] $rules Array of rewrite rules generated for the current permastruct, keyed by their regex pattern.
[1429] Fix | Delete
*/
[1430] Fix | Delete
$rules = apply_filters( "{$permastructname}_rewrite_rules", $rules );
[1431] Fix | Delete
[1432] Fix | Delete
if ( 'post_tag' === $permastructname ) {
[1433] Fix | Delete
[1434] Fix | Delete
/**
[1435] Fix | Delete
* Filters rewrite rules used specifically for Tags.
[1436] Fix | Delete
*
[1437] Fix | Delete
* @since 2.3.0
[1438] Fix | Delete
* @deprecated 3.1.0 Use {@see 'post_tag_rewrite_rules'} instead.
[1439] Fix | Delete
*
[1440] Fix | Delete
* @param string[] $rules Array of rewrite rules generated for tags, keyed by their regex pattern.
[1441] Fix | Delete
*/
[1442] Fix | Delete
$rules = apply_filters_deprecated( 'tag_rewrite_rules', array( $rules ), '3.1.0', 'post_tag_rewrite_rules' );
[1443] Fix | Delete
}
[1444] Fix | Delete
[1445] Fix | Delete
$this->extra_rules_top = array_merge( $this->extra_rules_top, $rules );
[1446] Fix | Delete
}
[1447] Fix | Delete
[1448] Fix | Delete
// Put them together.
[1449] Fix | Delete
if ( $this->use_verbose_page_rules ) {
[1450] Fix | Delete
$this->rules = array_merge( $this->extra_rules_top, $robots_rewrite, $favicon_rewrite, $deprecated_files, $registration_pages, $root_rewrite, $comments_rewrite, $search_rewrite, $author_rewrite, $date_rewrite, $page_rewrite, $post_rewrite, $this->extra_rules );
[1451] Fix | Delete
} else {
[1452] Fix | Delete
$this->rules = array_merge( $this->extra_rules_top, $robots_rewrite, $favicon_rewrite, $deprecated_files, $registration_pages, $root_rewrite, $comments_rewrite, $search_rewrite, $author_rewrite, $date_rewrite, $post_rewrite, $page_rewrite, $this->extra_rules );
[1453] Fix | Delete
}
[1454] Fix | Delete
[1455] Fix | Delete
/**
[1456] Fix | Delete
* Fires after the rewrite rules are generated.
[1457] Fix | Delete
*
[1458] Fix | Delete
* @since 1.5.0
[1459] Fix | Delete
*
[1460] Fix | Delete
* @param WP_Rewrite $wp_rewrite Current WP_Rewrite instance (passed by reference).
[1461] Fix | Delete
*/
[1462] Fix | Delete
do_action_ref_array( 'generate_rewrite_rules', array( &$this ) );
[1463] Fix | Delete
[1464] Fix | Delete
/**
[1465] Fix | Delete
* Filters the full set of generated rewrite rules.
[1466] Fix | Delete
*
[1467] Fix | Delete
* @since 1.5.0
[1468] Fix | Delete
*
[1469] Fix | Delete
* @param string[] $rules The compiled array of rewrite rules, keyed by their regex pattern.
[1470] Fix | Delete
*/
[1471] Fix | Delete
$this->rules = apply_filters( 'rewrite_rules_array', $this->rules );
[1472] Fix | Delete
[1473] Fix | Delete
return $this->rules;
[1474] Fix | Delete
}
[1475] Fix | Delete
[1476] Fix | Delete
/**
[1477] Fix | Delete
* Retrieves the rewrite rules.
[1478] Fix | Delete
*
[1479] Fix | Delete
* The difference between this method and WP_Rewrite::rewrite_rules() is that
[1480] Fix | Delete
* this method stores the rewrite rules in the 'rewrite_rules' option and retrieves
[1481] Fix | Delete
* it. This prevents having to process all of the permalinks to get the rewrite rules
[1482] Fix | Delete
* in the form of caching.
[1483] Fix | Delete
*
[1484] Fix | Delete
* @since 1.5.0
[1485] Fix | Delete
*
[1486] Fix | Delete
* @return string[] Array of rewrite rules keyed by their regex pattern.
[1487] Fix | Delete
*/
[1488] Fix | Delete
public function wp_rewrite_rules() {
[1489] Fix | Delete
$this->rules = get_option( 'rewrite_rules' );
[1490] Fix | Delete
if ( empty( $this->rules ) ) {
[1491] Fix | Delete
$this->refresh_rewrite_rules();
[1492] Fix | Delete
}
[1493] Fix | Delete
[1494] Fix | Delete
return $this->rules;
[1495] Fix | Delete
}
[1496] Fix | Delete
[1497] Fix | Delete
/**
[1498] Fix | Delete
* Refreshes the rewrite rules, saving the fresh value to the database.
[1499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function