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
$this->date_structure = '';
[500] Fix | Delete
return false;
[501] Fix | Delete
}
[502] Fix | Delete
[503] Fix | Delete
// The date permalink must have year, month, and day separated by slashes.
[504] Fix | Delete
$endians = array( '%year%/%monthnum%/%day%', '%day%/%monthnum%/%year%', '%monthnum%/%day%/%year%' );
[505] Fix | Delete
[506] Fix | Delete
$this->date_structure = '';
[507] Fix | Delete
$date_endian = '';
[508] Fix | Delete
[509] Fix | Delete
foreach ( $endians as $endian ) {
[510] Fix | Delete
if ( str_contains( $this->permalink_structure, $endian ) ) {
[511] Fix | Delete
$date_endian = $endian;
[512] Fix | Delete
break;
[513] Fix | Delete
}
[514] Fix | Delete
}
[515] Fix | Delete
[516] Fix | Delete
if ( empty( $date_endian ) ) {
[517] Fix | Delete
$date_endian = '%year%/%monthnum%/%day%';
[518] Fix | Delete
}
[519] Fix | Delete
[520] Fix | Delete
/*
[521] Fix | Delete
* Do not allow the date tags and %post_id% to overlap in the permalink
[522] Fix | Delete
* structure. If they do, move the date tags to $front/date/.
[523] Fix | Delete
*/
[524] Fix | Delete
$front = $this->front;
[525] Fix | Delete
preg_match_all( '/%.+?%/', $this->permalink_structure, $tokens );
[526] Fix | Delete
$tok_index = 1;
[527] Fix | Delete
foreach ( (array) $tokens[0] as $token ) {
[528] Fix | Delete
if ( '%post_id%' === $token && ( $tok_index <= 3 ) ) {
[529] Fix | Delete
$front = $front . 'date/';
[530] Fix | Delete
break;
[531] Fix | Delete
}
[532] Fix | Delete
++$tok_index;
[533] Fix | Delete
}
[534] Fix | Delete
[535] Fix | Delete
$this->date_structure = $front . $date_endian;
[536] Fix | Delete
[537] Fix | Delete
return $this->date_structure;
[538] Fix | Delete
}
[539] Fix | Delete
[540] Fix | Delete
/**
[541] Fix | Delete
* Retrieves the year permalink structure without month and day.
[542] Fix | Delete
*
[543] Fix | Delete
* Gets the date permalink structure and strips out the month and day
[544] Fix | Delete
* permalink structures.
[545] Fix | Delete
*
[546] Fix | Delete
* @since 1.5.0
[547] Fix | Delete
*
[548] Fix | Delete
* @return string|false Year permalink structure on success, false on failure.
[549] Fix | Delete
*/
[550] Fix | Delete
public function get_year_permastruct() {
[551] Fix | Delete
$structure = $this->get_date_permastruct();
[552] Fix | Delete
[553] Fix | Delete
if ( empty( $structure ) ) {
[554] Fix | Delete
return false;
[555] Fix | Delete
}
[556] Fix | Delete
[557] Fix | Delete
$structure = str_replace( '%monthnum%', '', $structure );
[558] Fix | Delete
$structure = str_replace( '%day%', '', $structure );
[559] Fix | Delete
$structure = preg_replace( '#/+#', '/', $structure );
[560] Fix | Delete
[561] Fix | Delete
return $structure;
[562] Fix | Delete
}
[563] Fix | Delete
[564] Fix | Delete
/**
[565] Fix | Delete
* Retrieves the month permalink structure without day and with year.
[566] Fix | Delete
*
[567] Fix | Delete
* Gets the date permalink structure and strips out the day permalink
[568] Fix | Delete
* structures. Keeps the year permalink structure.
[569] Fix | Delete
*
[570] Fix | Delete
* @since 1.5.0
[571] Fix | Delete
*
[572] Fix | Delete
* @return string|false Year/Month permalink structure on success, false on failure.
[573] Fix | Delete
*/
[574] Fix | Delete
public function get_month_permastruct() {
[575] Fix | Delete
$structure = $this->get_date_permastruct();
[576] Fix | Delete
[577] Fix | Delete
if ( empty( $structure ) ) {
[578] Fix | Delete
return false;
[579] Fix | Delete
}
[580] Fix | Delete
[581] Fix | Delete
$structure = str_replace( '%day%', '', $structure );
[582] Fix | Delete
$structure = preg_replace( '#/+#', '/', $structure );
[583] Fix | Delete
[584] Fix | Delete
return $structure;
[585] Fix | Delete
}
[586] Fix | Delete
[587] Fix | Delete
/**
[588] Fix | Delete
* Retrieves the day permalink structure with month and year.
[589] Fix | Delete
*
[590] Fix | Delete
* Keeps date permalink structure with all year, month, and day.
[591] Fix | Delete
*
[592] Fix | Delete
* @since 1.5.0
[593] Fix | Delete
*
[594] Fix | Delete
* @return string|false Year/Month/Day permalink structure on success, false on failure.
[595] Fix | Delete
*/
[596] Fix | Delete
public function get_day_permastruct() {
[597] Fix | Delete
return $this->get_date_permastruct();
[598] Fix | Delete
}
[599] Fix | Delete
[600] Fix | Delete
/**
[601] Fix | Delete
* Retrieves the permalink structure for categories.
[602] Fix | Delete
*
[603] Fix | Delete
* If the category_base property has no value, then the category structure
[604] Fix | Delete
* will have the front property value, followed by 'category', and finally
[605] Fix | Delete
* '%category%'. If it does, then the root property will be used, along with
[606] Fix | Delete
* the category_base property value.
[607] Fix | Delete
*
[608] Fix | Delete
* @since 1.5.0
[609] Fix | Delete
*
[610] Fix | Delete
* @return string|false Category permalink structure on success, false on failure.
[611] Fix | Delete
*/
[612] Fix | Delete
public function get_category_permastruct() {
[613] Fix | Delete
return $this->get_extra_permastruct( 'category' );
[614] Fix | Delete
}
[615] Fix | Delete
[616] Fix | Delete
/**
[617] Fix | Delete
* Retrieves the permalink structure for tags.
[618] Fix | Delete
*
[619] Fix | Delete
* If the tag_base property has no value, then the tag structure will have
[620] Fix | Delete
* the front property value, followed by 'tag', and finally '%tag%'. If it
[621] Fix | Delete
* does, then the root property will be used, along with the tag_base
[622] Fix | Delete
* property value.
[623] Fix | Delete
*
[624] Fix | Delete
* @since 2.3.0
[625] Fix | Delete
*
[626] Fix | Delete
* @return string|false Tag permalink structure on success, false on failure.
[627] Fix | Delete
*/
[628] Fix | Delete
public function get_tag_permastruct() {
[629] Fix | Delete
return $this->get_extra_permastruct( 'post_tag' );
[630] Fix | Delete
}
[631] Fix | Delete
[632] Fix | Delete
/**
[633] Fix | Delete
* Retrieves an extra permalink structure by name.
[634] Fix | Delete
*
[635] Fix | Delete
* @since 2.5.0
[636] Fix | Delete
*
[637] Fix | Delete
* @param string $name Permalink structure name.
[638] Fix | Delete
* @return string|false Permalink structure string on success, false on failure.
[639] Fix | Delete
*/
[640] Fix | Delete
public function get_extra_permastruct( $name ) {
[641] Fix | Delete
if ( empty( $this->permalink_structure ) ) {
[642] Fix | Delete
return false;
[643] Fix | Delete
}
[644] Fix | Delete
[645] Fix | Delete
if ( isset( $this->extra_permastructs[ $name ] ) ) {
[646] Fix | Delete
return $this->extra_permastructs[ $name ]['struct'];
[647] Fix | Delete
}
[648] Fix | Delete
[649] Fix | Delete
return false;
[650] Fix | Delete
}
[651] Fix | Delete
[652] Fix | Delete
/**
[653] Fix | Delete
* Retrieves the author permalink structure.
[654] Fix | Delete
*
[655] Fix | Delete
* The permalink structure is front property, author base, and finally
[656] Fix | Delete
* '/%author%'. Will set the author_structure property and then return it
[657] Fix | Delete
* without attempting to set the value again.
[658] Fix | Delete
*
[659] Fix | Delete
* @since 1.5.0
[660] Fix | Delete
*
[661] Fix | Delete
* @return string|false Author permalink structure on success, false on failure.
[662] Fix | Delete
*/
[663] Fix | Delete
public function get_author_permastruct() {
[664] Fix | Delete
if ( isset( $this->author_structure ) ) {
[665] Fix | Delete
return $this->author_structure;
[666] Fix | Delete
}
[667] Fix | Delete
[668] Fix | Delete
if ( empty( $this->permalink_structure ) ) {
[669] Fix | Delete
$this->author_structure = '';
[670] Fix | Delete
return false;
[671] Fix | Delete
}
[672] Fix | Delete
[673] Fix | Delete
$this->author_structure = $this->front . $this->author_base . '/%author%';
[674] Fix | Delete
[675] Fix | Delete
return $this->author_structure;
[676] Fix | Delete
}
[677] Fix | Delete
[678] Fix | Delete
/**
[679] Fix | Delete
* Retrieves the search permalink structure.
[680] Fix | Delete
*
[681] Fix | Delete
* The permalink structure is root property, search base, and finally
[682] Fix | Delete
* '/%search%'. Will set the search_structure property and then return it
[683] Fix | Delete
* without attempting to set the value again.
[684] Fix | Delete
*
[685] Fix | Delete
* @since 1.5.0
[686] Fix | Delete
*
[687] Fix | Delete
* @return string|false Search permalink structure on success, false on failure.
[688] Fix | Delete
*/
[689] Fix | Delete
public function get_search_permastruct() {
[690] Fix | Delete
if ( isset( $this->search_structure ) ) {
[691] Fix | Delete
return $this->search_structure;
[692] Fix | Delete
}
[693] Fix | Delete
[694] Fix | Delete
if ( empty( $this->permalink_structure ) ) {
[695] Fix | Delete
$this->search_structure = '';
[696] Fix | Delete
return false;
[697] Fix | Delete
}
[698] Fix | Delete
[699] Fix | Delete
$this->search_structure = $this->root . $this->search_base . '/%search%';
[700] Fix | Delete
[701] Fix | Delete
return $this->search_structure;
[702] Fix | Delete
}
[703] Fix | Delete
[704] Fix | Delete
/**
[705] Fix | Delete
* Retrieves the page permalink structure.
[706] Fix | Delete
*
[707] Fix | Delete
* The permalink structure is root property, and '%pagename%'. Will set the
[708] Fix | Delete
* page_structure property and then return it without attempting to set the
[709] Fix | Delete
* value again.
[710] Fix | Delete
*
[711] Fix | Delete
* @since 1.5.0
[712] Fix | Delete
*
[713] Fix | Delete
* @return string|false Page permalink structure on success, false on failure.
[714] Fix | Delete
*/
[715] Fix | Delete
public function get_page_permastruct() {
[716] Fix | Delete
if ( isset( $this->page_structure ) ) {
[717] Fix | Delete
return $this->page_structure;
[718] Fix | Delete
}
[719] Fix | Delete
[720] Fix | Delete
if ( empty( $this->permalink_structure ) ) {
[721] Fix | Delete
$this->page_structure = '';
[722] Fix | Delete
return false;
[723] Fix | Delete
}
[724] Fix | Delete
[725] Fix | Delete
$this->page_structure = $this->root . '%pagename%';
[726] Fix | Delete
[727] Fix | Delete
return $this->page_structure;
[728] Fix | Delete
}
[729] Fix | Delete
[730] Fix | Delete
/**
[731] Fix | Delete
* Retrieves the feed permalink structure.
[732] Fix | Delete
*
[733] Fix | Delete
* The permalink structure is root property, feed base, and finally
[734] Fix | Delete
* '/%feed%'. Will set the feed_structure property and then return it
[735] Fix | Delete
* without attempting to set the value again.
[736] Fix | Delete
*
[737] Fix | Delete
* @since 1.5.0
[738] Fix | Delete
*
[739] Fix | Delete
* @return string|false Feed permalink structure on success, false on failure.
[740] Fix | Delete
*/
[741] Fix | Delete
public function get_feed_permastruct() {
[742] Fix | Delete
if ( isset( $this->feed_structure ) ) {
[743] Fix | Delete
return $this->feed_structure;
[744] Fix | Delete
}
[745] Fix | Delete
[746] Fix | Delete
if ( empty( $this->permalink_structure ) ) {
[747] Fix | Delete
$this->feed_structure = '';
[748] Fix | Delete
return false;
[749] Fix | Delete
}
[750] Fix | Delete
[751] Fix | Delete
$this->feed_structure = $this->root . $this->feed_base . '/%feed%';
[752] Fix | Delete
[753] Fix | Delete
return $this->feed_structure;
[754] Fix | Delete
}
[755] Fix | Delete
[756] Fix | Delete
/**
[757] Fix | Delete
* Retrieves the comment feed permalink structure.
[758] Fix | Delete
*
[759] Fix | Delete
* The permalink structure is root property, comment base property, feed
[760] Fix | Delete
* base and finally '/%feed%'. Will set the comment_feed_structure property
[761] Fix | Delete
* and then return it without attempting to set the value again.
[762] Fix | Delete
*
[763] Fix | Delete
* @since 1.5.0
[764] Fix | Delete
*
[765] Fix | Delete
* @return string|false Comment feed permalink structure on success, false on failure.
[766] Fix | Delete
*/
[767] Fix | Delete
public function get_comment_feed_permastruct() {
[768] Fix | Delete
if ( isset( $this->comment_feed_structure ) ) {
[769] Fix | Delete
return $this->comment_feed_structure;
[770] Fix | Delete
}
[771] Fix | Delete
[772] Fix | Delete
if ( empty( $this->permalink_structure ) ) {
[773] Fix | Delete
$this->comment_feed_structure = '';
[774] Fix | Delete
return false;
[775] Fix | Delete
}
[776] Fix | Delete
[777] Fix | Delete
$this->comment_feed_structure = $this->root . $this->comments_base . '/' . $this->feed_base . '/%feed%';
[778] Fix | Delete
[779] Fix | Delete
return $this->comment_feed_structure;
[780] Fix | Delete
}
[781] Fix | Delete
[782] Fix | Delete
/**
[783] Fix | Delete
* Adds or updates existing rewrite tags (e.g. %postname%).
[784] Fix | Delete
*
[785] Fix | Delete
* If the tag already exists, replace the existing pattern and query for
[786] Fix | Delete
* that tag, otherwise add the new tag.
[787] Fix | Delete
*
[788] Fix | Delete
* @since 1.5.0
[789] Fix | Delete
*
[790] Fix | Delete
* @see WP_Rewrite::$rewritecode
[791] Fix | Delete
* @see WP_Rewrite::$rewritereplace
[792] Fix | Delete
* @see WP_Rewrite::$queryreplace
[793] Fix | Delete
*
[794] Fix | Delete
* @param string $tag Name of the rewrite tag to add or update.
[795] Fix | Delete
* @param string $regex Regular expression to substitute the tag for in rewrite rules.
[796] Fix | Delete
* @param string $query String to append to the rewritten query. Must end in '='.
[797] Fix | Delete
*/
[798] Fix | Delete
public function add_rewrite_tag( $tag, $regex, $query ) {
[799] Fix | Delete
$position = array_search( $tag, $this->rewritecode, true );
[800] Fix | Delete
if ( false !== $position && null !== $position ) {
[801] Fix | Delete
$this->rewritereplace[ $position ] = $regex;
[802] Fix | Delete
$this->queryreplace[ $position ] = $query;
[803] Fix | Delete
} else {
[804] Fix | Delete
$this->rewritecode[] = $tag;
[805] Fix | Delete
$this->rewritereplace[] = $regex;
[806] Fix | Delete
$this->queryreplace[] = $query;
[807] Fix | Delete
}
[808] Fix | Delete
}
[809] Fix | Delete
[810] Fix | Delete
[811] Fix | Delete
/**
[812] Fix | Delete
* Removes an existing rewrite tag.
[813] Fix | Delete
*
[814] Fix | Delete
* @since 4.5.0
[815] Fix | Delete
*
[816] Fix | Delete
* @see WP_Rewrite::$rewritecode
[817] Fix | Delete
* @see WP_Rewrite::$rewritereplace
[818] Fix | Delete
* @see WP_Rewrite::$queryreplace
[819] Fix | Delete
*
[820] Fix | Delete
* @param string $tag Name of the rewrite tag to remove.
[821] Fix | Delete
*/
[822] Fix | Delete
public function remove_rewrite_tag( $tag ) {
[823] Fix | Delete
$position = array_search( $tag, $this->rewritecode, true );
[824] Fix | Delete
if ( false !== $position && null !== $position ) {
[825] Fix | Delete
unset( $this->rewritecode[ $position ] );
[826] Fix | Delete
unset( $this->rewritereplace[ $position ] );
[827] Fix | Delete
unset( $this->queryreplace[ $position ] );
[828] Fix | Delete
}
[829] Fix | Delete
}
[830] Fix | Delete
[831] Fix | Delete
/**
[832] Fix | Delete
* Generates rewrite rules from a permalink structure.
[833] Fix | Delete
*
[834] Fix | Delete
* The main WP_Rewrite function for building the rewrite rule list. The
[835] Fix | Delete
* contents of the function is a mix of black magic and regular expressions,
[836] Fix | Delete
* so best just ignore the contents and move to the parameters.
[837] Fix | Delete
*
[838] Fix | Delete
* @since 1.5.0
[839] Fix | Delete
*
[840] Fix | Delete
* @param string $permalink_structure The permalink structure.
[841] Fix | Delete
* @param int $ep_mask Optional. Endpoint mask defining what endpoints are added to the structure.
[842] Fix | Delete
* Accepts a mask of:
[843] Fix | Delete
* - `EP_ALL`
[844] Fix | Delete
* - `EP_NONE`
[845] Fix | Delete
* - `EP_ALL_ARCHIVES`
[846] Fix | Delete
* - `EP_ATTACHMENT`
[847] Fix | Delete
* - `EP_AUTHORS`
[848] Fix | Delete
* - `EP_CATEGORIES`
[849] Fix | Delete
* - `EP_COMMENTS`
[850] Fix | Delete
* - `EP_DATE`
[851] Fix | Delete
* - `EP_DAY`
[852] Fix | Delete
* - `EP_MONTH`
[853] Fix | Delete
* - `EP_PAGES`
[854] Fix | Delete
* - `EP_PERMALINK`
[855] Fix | Delete
* - `EP_ROOT`
[856] Fix | Delete
* - `EP_SEARCH`
[857] Fix | Delete
* - `EP_TAGS`
[858] Fix | Delete
* - `EP_YEAR`
[859] Fix | Delete
* Default `EP_NONE`.
[860] Fix | Delete
* @param bool $paged Optional. Whether archive pagination rules should be added for the structure.
[861] Fix | Delete
* Default true.
[862] Fix | Delete
* @param bool $feed Optional. Whether feed rewrite rules should be added for the structure.
[863] Fix | Delete
* Default true.
[864] Fix | Delete
* @param bool $forcomments Optional. Whether the feed rules should be a query for a comments feed.
[865] Fix | Delete
* Default false.
[866] Fix | Delete
* @param bool $walk_dirs Optional. Whether the 'directories' making up the structure should be walked
[867] Fix | Delete
* over and rewrite rules built for each in-turn. Default true.
[868] Fix | Delete
* @param bool $endpoints Optional. Whether endpoints should be applied to the generated rewrite rules.
[869] Fix | Delete
* Default true.
[870] Fix | Delete
* @return string[] Array of rewrite rules keyed by their regex pattern.
[871] Fix | Delete
*/
[872] Fix | Delete
public function generate_rewrite_rules( $permalink_structure, $ep_mask = EP_NONE, $paged = true, $feed = true, $forcomments = false, $walk_dirs = true, $endpoints = true ) {
[873] Fix | Delete
// Build a regex to match the feed section of URLs, something like (feed|atom|rss|rss2)/?
[874] Fix | Delete
$feedregex2 = '';
[875] Fix | Delete
foreach ( (array) $this->feeds as $feed_name ) {
[876] Fix | Delete
$feedregex2 .= $feed_name . '|';
[877] Fix | Delete
}
[878] Fix | Delete
$feedregex2 = '(' . trim( $feedregex2, '|' ) . ')/?$';
[879] Fix | Delete
[880] Fix | Delete
/*
[881] Fix | Delete
* $feedregex is identical but with /feed/ added on as well, so URLs like <permalink>/feed/atom
[882] Fix | Delete
* and <permalink>/atom are both possible
[883] Fix | Delete
*/
[884] Fix | Delete
$feedregex = $this->feed_base . '/' . $feedregex2;
[885] Fix | Delete
[886] Fix | Delete
// Build a regex to match the trackback and page/xx parts of URLs.
[887] Fix | Delete
$trackbackregex = 'trackback/?$';
[888] Fix | Delete
$pageregex = $this->pagination_base . '/?([0-9]{1,})/?$';
[889] Fix | Delete
$commentregex = $this->comments_pagination_base . '-([0-9]{1,})/?$';
[890] Fix | Delete
$embedregex = 'embed/?$';
[891] Fix | Delete
[892] Fix | Delete
// Build up an array of endpoint regexes to append => queries to append.
[893] Fix | Delete
if ( $endpoints ) {
[894] Fix | Delete
$ep_query_append = array();
[895] Fix | Delete
foreach ( (array) $this->endpoints as $endpoint ) {
[896] Fix | Delete
// Match everything after the endpoint name, but allow for nothing to appear there.
[897] Fix | Delete
$epmatch = $endpoint[1] . '(/(.*))?/?$';
[898] Fix | Delete
[899] Fix | Delete
// This will be appended on to the rest of the query for each dir.
[900] Fix | Delete
$epquery = '&' . $endpoint[2] . '=';
[901] Fix | Delete
$ep_query_append[ $epmatch ] = array( $endpoint[0], $epquery );
[902] Fix | Delete
}
[903] Fix | Delete
}
[904] Fix | Delete
[905] Fix | Delete
// Get everything up to the first rewrite tag.
[906] Fix | Delete
$front = substr( $permalink_structure, 0, strpos( $permalink_structure, '%' ) );
[907] Fix | Delete
[908] Fix | Delete
// Build an array of the tags (note that said array ends up being in $tokens[0]).
[909] Fix | Delete
preg_match_all( '/%.+?%/', $permalink_structure, $tokens );
[910] Fix | Delete
[911] Fix | Delete
$num_tokens = count( $tokens[0] );
[912] Fix | Delete
[913] Fix | Delete
$index = $this->index; // Probably 'index.php'.
[914] Fix | Delete
$feedindex = $index;
[915] Fix | Delete
$trackbackindex = $index;
[916] Fix | Delete
$embedindex = $index;
[917] Fix | Delete
[918] Fix | Delete
/*
[919] Fix | Delete
* Build a list from the rewritecode and queryreplace arrays, that will look something
[920] Fix | Delete
* like tagname=$matches[i] where i is the current $i.
[921] Fix | Delete
*/
[922] Fix | Delete
$queries = array();
[923] Fix | Delete
for ( $i = 0; $i < $num_tokens; ++$i ) {
[924] Fix | Delete
if ( 0 < $i ) {
[925] Fix | Delete
$queries[ $i ] = $queries[ $i - 1 ] . '&';
[926] Fix | Delete
} else {
[927] Fix | Delete
$queries[ $i ] = '';
[928] Fix | Delete
}
[929] Fix | Delete
[930] Fix | Delete
$query_token = str_replace( $this->rewritecode, $this->queryreplace, $tokens[0][ $i ] ) . $this->preg_index( $i + 1 );
[931] Fix | Delete
$queries[ $i ] .= $query_token;
[932] Fix | Delete
}
[933] Fix | Delete
[934] Fix | Delete
// Get the structure, minus any cruft (stuff that isn't tags) at the front.
[935] Fix | Delete
$structure = $permalink_structure;
[936] Fix | Delete
if ( '/' !== $front ) {
[937] Fix | Delete
$structure = str_replace( $front, '', $structure );
[938] Fix | Delete
}
[939] Fix | Delete
[940] Fix | Delete
/*
[941] Fix | Delete
* Create a list of dirs to walk over, making rewrite rules for each level
[942] Fix | Delete
* so for example, a $structure of /%year%/%monthnum%/%postname% would create
[943] Fix | Delete
* rewrite rules for /%year%/, /%year%/%monthnum%/ and /%year%/%monthnum%/%postname%
[944] Fix | Delete
*/
[945] Fix | Delete
$structure = trim( $structure, '/' );
[946] Fix | Delete
$dirs = $walk_dirs ? explode( '/', $structure ) : array( $structure );
[947] Fix | Delete
$num_dirs = count( $dirs );
[948] Fix | Delete
[949] Fix | Delete
// Strip slashes from the front of $front.
[950] Fix | Delete
$front = preg_replace( '|^/+|', '', $front );
[951] Fix | Delete
[952] Fix | Delete
// The main workhorse loop.
[953] Fix | Delete
$post_rewrite = array();
[954] Fix | Delete
$struct = $front;
[955] Fix | Delete
for ( $j = 0; $j < $num_dirs; ++$j ) {
[956] Fix | Delete
// Get the struct for this dir, and trim slashes off the front.
[957] Fix | Delete
$struct .= $dirs[ $j ] . '/'; // Accumulate. see comment near explode('/', $structure) above.
[958] Fix | Delete
$struct = ltrim( $struct, '/' );
[959] Fix | Delete
[960] Fix | Delete
// Replace tags with regexes.
[961] Fix | Delete
$match = str_replace( $this->rewritecode, $this->rewritereplace, $struct );
[962] Fix | Delete
[963] Fix | Delete
// Make a list of tags, and store how many there are in $num_toks.
[964] Fix | Delete
$num_toks = preg_match_all( '/%.+?%/', $struct, $toks );
[965] Fix | Delete
[966] Fix | Delete
// Get the 'tagname=$matches[i]'.
[967] Fix | Delete
$query = ( ! empty( $num_toks ) && isset( $queries[ $num_toks - 1 ] ) ) ? $queries[ $num_toks - 1 ] : '';
[968] Fix | Delete
[969] Fix | Delete
// Set up $ep_mask_specific which is used to match more specific URL types.
[970] Fix | Delete
switch ( $dirs[ $j ] ) {
[971] Fix | Delete
case '%year%':
[972] Fix | Delete
$ep_mask_specific = EP_YEAR;
[973] Fix | Delete
break;
[974] Fix | Delete
case '%monthnum%':
[975] Fix | Delete
$ep_mask_specific = EP_MONTH;
[976] Fix | Delete
break;
[977] Fix | Delete
case '%day%':
[978] Fix | Delete
$ep_mask_specific = EP_DAY;
[979] Fix | Delete
break;
[980] Fix | Delete
default:
[981] Fix | Delete
$ep_mask_specific = EP_NONE;
[982] Fix | Delete
}
[983] Fix | Delete
[984] Fix | Delete
// Create query for /page/xx.
[985] Fix | Delete
$pagematch = $match . $pageregex;
[986] Fix | Delete
$pagequery = $index . '?' . $query . '&paged=' . $this->preg_index( $num_toks + 1 );
[987] Fix | Delete
[988] Fix | Delete
// Create query for /comment-page-xx.
[989] Fix | Delete
$commentmatch = $match . $commentregex;
[990] Fix | Delete
$commentquery = $index . '?' . $query . '&cpage=' . $this->preg_index( $num_toks + 1 );
[991] Fix | Delete
[992] Fix | Delete
if ( get_option( 'page_on_front' ) ) {
[993] Fix | Delete
// Create query for Root /comment-page-xx.
[994] Fix | Delete
$rootcommentmatch = $match . $commentregex;
[995] Fix | Delete
$rootcommentquery = $index . '?' . $query . '&page_id=' . get_option( 'page_on_front' ) . '&cpage=' . $this->preg_index( $num_toks + 1 );
[996] Fix | Delete
}
[997] Fix | Delete
[998] Fix | Delete
// Create query for /feed/(feed|atom|rss|rss2|rdf).
[999] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function