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
* If the `wp_loaded` action has not occurred yet, will postpone saving to the database.
[1500] Fix | Delete
*
[1501] Fix | Delete
* @since 6.4.0
[1502] Fix | Delete
*/
[1503] Fix | Delete
private function refresh_rewrite_rules() {
[1504] Fix | Delete
$this->rules = '';
[1505] Fix | Delete
$this->matches = 'matches';
[1506] Fix | Delete
[1507] Fix | Delete
$this->rewrite_rules();
[1508] Fix | Delete
[1509] Fix | Delete
if ( ! did_action( 'wp_loaded' ) ) {
[1510] Fix | Delete
/*
[1511] Fix | Delete
* Is not safe to save the results right now, as the rules may be partial.
[1512] Fix | Delete
* Need to give all rules the chance to register.
[1513] Fix | Delete
*/
[1514] Fix | Delete
add_action( 'wp_loaded', array( $this, 'flush_rules' ) );
[1515] Fix | Delete
} else {
[1516] Fix | Delete
update_option( 'rewrite_rules', $this->rules );
[1517] Fix | Delete
}
[1518] Fix | Delete
}
[1519] Fix | Delete
[1520] Fix | Delete
/**
[1521] Fix | Delete
* Retrieves mod_rewrite-formatted rewrite rules to write to .htaccess.
[1522] Fix | Delete
*
[1523] Fix | Delete
* Does not actually write to the .htaccess file, but creates the rules for
[1524] Fix | Delete
* the process that will.
[1525] Fix | Delete
*
[1526] Fix | Delete
* Will add the non_wp_rules property rules to the .htaccess file before
[1527] Fix | Delete
* the WordPress rewrite rules one.
[1528] Fix | Delete
*
[1529] Fix | Delete
* @since 1.5.0
[1530] Fix | Delete
*
[1531] Fix | Delete
* @return string
[1532] Fix | Delete
*/
[1533] Fix | Delete
public function mod_rewrite_rules() {
[1534] Fix | Delete
if ( ! $this->using_permalinks() ) {
[1535] Fix | Delete
return '';
[1536] Fix | Delete
}
[1537] Fix | Delete
[1538] Fix | Delete
$site_root = parse_url( site_url() );
[1539] Fix | Delete
if ( isset( $site_root['path'] ) ) {
[1540] Fix | Delete
$site_root = trailingslashit( $site_root['path'] );
[1541] Fix | Delete
}
[1542] Fix | Delete
[1543] Fix | Delete
$home_root = parse_url( home_url() );
[1544] Fix | Delete
if ( isset( $home_root['path'] ) ) {
[1545] Fix | Delete
$home_root = trailingslashit( $home_root['path'] );
[1546] Fix | Delete
} else {
[1547] Fix | Delete
$home_root = '/';
[1548] Fix | Delete
}
[1549] Fix | Delete
[1550] Fix | Delete
$rules = "<IfModule mod_rewrite.c>\n";
[1551] Fix | Delete
$rules .= "RewriteEngine On\n";
[1552] Fix | Delete
$rules .= "RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]\n";
[1553] Fix | Delete
$rules .= "RewriteBase $home_root\n";
[1554] Fix | Delete
[1555] Fix | Delete
// Prevent -f checks on index.php.
[1556] Fix | Delete
$rules .= "RewriteRule ^index\.php$ - [L]\n";
[1557] Fix | Delete
[1558] Fix | Delete
// Add in the rules that don't redirect to WP's index.php (and thus shouldn't be handled by WP at all).
[1559] Fix | Delete
foreach ( (array) $this->non_wp_rules as $match => $query ) {
[1560] Fix | Delete
// Apache 1.3 does not support the reluctant (non-greedy) modifier.
[1561] Fix | Delete
$match = str_replace( '.+?', '.+', $match );
[1562] Fix | Delete
[1563] Fix | Delete
$rules .= 'RewriteRule ^' . $match . ' ' . $home_root . $query . " [QSA,L]\n";
[1564] Fix | Delete
}
[1565] Fix | Delete
[1566] Fix | Delete
if ( $this->use_verbose_rules ) {
[1567] Fix | Delete
$this->matches = '';
[1568] Fix | Delete
$rewrite = $this->rewrite_rules();
[1569] Fix | Delete
$num_rules = count( $rewrite );
[1570] Fix | Delete
$rules .= "RewriteCond %{REQUEST_FILENAME} -f [OR]\n" .
[1571] Fix | Delete
"RewriteCond %{REQUEST_FILENAME} -d\n" .
[1572] Fix | Delete
"RewriteRule ^.*$ - [S=$num_rules]\n";
[1573] Fix | Delete
[1574] Fix | Delete
foreach ( (array) $rewrite as $match => $query ) {
[1575] Fix | Delete
// Apache 1.3 does not support the reluctant (non-greedy) modifier.
[1576] Fix | Delete
$match = str_replace( '.+?', '.+', $match );
[1577] Fix | Delete
[1578] Fix | Delete
if ( str_contains( $query, $this->index ) ) {
[1579] Fix | Delete
$rules .= 'RewriteRule ^' . $match . ' ' . $home_root . $query . " [QSA,L]\n";
[1580] Fix | Delete
} else {
[1581] Fix | Delete
$rules .= 'RewriteRule ^' . $match . ' ' . $site_root . $query . " [QSA,L]\n";
[1582] Fix | Delete
}
[1583] Fix | Delete
}
[1584] Fix | Delete
} else {
[1585] Fix | Delete
$rules .= "RewriteCond %{REQUEST_FILENAME} !-f\n" .
[1586] Fix | Delete
"RewriteCond %{REQUEST_FILENAME} !-d\n" .
[1587] Fix | Delete
"RewriteRule . {$home_root}{$this->index} [L]\n";
[1588] Fix | Delete
}
[1589] Fix | Delete
[1590] Fix | Delete
$rules .= "</IfModule>\n";
[1591] Fix | Delete
[1592] Fix | Delete
/**
[1593] Fix | Delete
* Filters the list of rewrite rules formatted for output to an .htaccess file.
[1594] Fix | Delete
*
[1595] Fix | Delete
* @since 1.5.0
[1596] Fix | Delete
*
[1597] Fix | Delete
* @param string $rules mod_rewrite Rewrite rules formatted for .htaccess.
[1598] Fix | Delete
*/
[1599] Fix | Delete
$rules = apply_filters( 'mod_rewrite_rules', $rules );
[1600] Fix | Delete
[1601] Fix | Delete
/**
[1602] Fix | Delete
* Filters the list of rewrite rules formatted for output to an .htaccess file.
[1603] Fix | Delete
*
[1604] Fix | Delete
* @since 1.5.0
[1605] Fix | Delete
* @deprecated 1.5.0 Use the {@see 'mod_rewrite_rules'} filter instead.
[1606] Fix | Delete
*
[1607] Fix | Delete
* @param string $rules mod_rewrite Rewrite rules formatted for .htaccess.
[1608] Fix | Delete
*/
[1609] Fix | Delete
return apply_filters_deprecated( 'rewrite_rules', array( $rules ), '1.5.0', 'mod_rewrite_rules' );
[1610] Fix | Delete
}
[1611] Fix | Delete
[1612] Fix | Delete
/**
[1613] Fix | Delete
* Retrieves IIS7 URL Rewrite formatted rewrite rules to write to web.config file.
[1614] Fix | Delete
*
[1615] Fix | Delete
* Does not actually write to the web.config file, but creates the rules for
[1616] Fix | Delete
* the process that will.
[1617] Fix | Delete
*
[1618] Fix | Delete
* @since 2.8.0
[1619] Fix | Delete
*
[1620] Fix | Delete
* @param bool $add_parent_tags Optional. Whether to add parent tags to the rewrite rule sets.
[1621] Fix | Delete
* Default false.
[1622] Fix | Delete
* @return string IIS7 URL rewrite rule sets.
[1623] Fix | Delete
*/
[1624] Fix | Delete
public function iis7_url_rewrite_rules( $add_parent_tags = false ) {
[1625] Fix | Delete
if ( ! $this->using_permalinks() ) {
[1626] Fix | Delete
return '';
[1627] Fix | Delete
}
[1628] Fix | Delete
$rules = '';
[1629] Fix | Delete
if ( $add_parent_tags ) {
[1630] Fix | Delete
$rules .= '<configuration>
[1631] Fix | Delete
<system.webServer>
[1632] Fix | Delete
<rewrite>
[1633] Fix | Delete
<rules>';
[1634] Fix | Delete
}
[1635] Fix | Delete
[1636] Fix | Delete
$rules .= '
[1637] Fix | Delete
<rule name="WordPress: ' . esc_attr( home_url() ) . '" patternSyntax="Wildcard">
[1638] Fix | Delete
<match url="*" />
[1639] Fix | Delete
<conditions>
[1640] Fix | Delete
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
[1641] Fix | Delete
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
[1642] Fix | Delete
</conditions>
[1643] Fix | Delete
<action type="Rewrite" url="index.php" />
[1644] Fix | Delete
</rule>';
[1645] Fix | Delete
[1646] Fix | Delete
if ( $add_parent_tags ) {
[1647] Fix | Delete
$rules .= '
[1648] Fix | Delete
</rules>
[1649] Fix | Delete
</rewrite>
[1650] Fix | Delete
</system.webServer>
[1651] Fix | Delete
</configuration>';
[1652] Fix | Delete
}
[1653] Fix | Delete
[1654] Fix | Delete
/**
[1655] Fix | Delete
* Filters the list of rewrite rules formatted for output to a web.config.
[1656] Fix | Delete
*
[1657] Fix | Delete
* @since 2.8.0
[1658] Fix | Delete
*
[1659] Fix | Delete
* @param string $rules Rewrite rules formatted for IIS web.config.
[1660] Fix | Delete
*/
[1661] Fix | Delete
return apply_filters( 'iis7_url_rewrite_rules', $rules );
[1662] Fix | Delete
}
[1663] Fix | Delete
[1664] Fix | Delete
/**
[1665] Fix | Delete
* Adds a rewrite rule that transforms a URL structure to a set of query vars.
[1666] Fix | Delete
*
[1667] Fix | Delete
* Any value in the $after parameter that isn't 'bottom' will result in the rule
[1668] Fix | Delete
* being placed at the top of the rewrite rules.
[1669] Fix | Delete
*
[1670] Fix | Delete
* @since 2.1.0
[1671] Fix | Delete
* @since 4.4.0 Array support was added to the `$query` parameter.
[1672] Fix | Delete
*
[1673] Fix | Delete
* @param string $regex Regular expression to match request against.
[1674] Fix | Delete
* @param string|array $query The corresponding query vars for this rewrite rule.
[1675] Fix | Delete
* @param string $after Optional. Priority of the new rule. Accepts 'top'
[1676] Fix | Delete
* or 'bottom'. Default 'bottom'.
[1677] Fix | Delete
*/
[1678] Fix | Delete
public function add_rule( $regex, $query, $after = 'bottom' ) {
[1679] Fix | Delete
if ( is_array( $query ) ) {
[1680] Fix | Delete
$external = false;
[1681] Fix | Delete
$query = add_query_arg( $query, 'index.php' );
[1682] Fix | Delete
} else {
[1683] Fix | Delete
$index = ! str_contains( $query, '?' ) ? strlen( $query ) : strpos( $query, '?' );
[1684] Fix | Delete
$front = substr( $query, 0, $index );
[1685] Fix | Delete
[1686] Fix | Delete
$external = $front !== $this->index;
[1687] Fix | Delete
}
[1688] Fix | Delete
[1689] Fix | Delete
// "external" = it doesn't correspond to index.php.
[1690] Fix | Delete
if ( $external ) {
[1691] Fix | Delete
$this->add_external_rule( $regex, $query );
[1692] Fix | Delete
} else {
[1693] Fix | Delete
if ( 'bottom' === $after ) {
[1694] Fix | Delete
$this->extra_rules = array_merge( $this->extra_rules, array( $regex => $query ) );
[1695] Fix | Delete
} else {
[1696] Fix | Delete
$this->extra_rules_top = array_merge( $this->extra_rules_top, array( $regex => $query ) );
[1697] Fix | Delete
}
[1698] Fix | Delete
}
[1699] Fix | Delete
}
[1700] Fix | Delete
[1701] Fix | Delete
/**
[1702] Fix | Delete
* Adds a rewrite rule that doesn't correspond to index.php.
[1703] Fix | Delete
*
[1704] Fix | Delete
* @since 2.1.0
[1705] Fix | Delete
*
[1706] Fix | Delete
* @param string $regex Regular expression to match request against.
[1707] Fix | Delete
* @param string $query The corresponding query vars for this rewrite rule.
[1708] Fix | Delete
*/
[1709] Fix | Delete
public function add_external_rule( $regex, $query ) {
[1710] Fix | Delete
$this->non_wp_rules[ $regex ] = $query;
[1711] Fix | Delete
}
[1712] Fix | Delete
[1713] Fix | Delete
/**
[1714] Fix | Delete
* Adds an endpoint, like /trackback/.
[1715] Fix | Delete
*
[1716] Fix | Delete
* @since 2.1.0
[1717] Fix | Delete
* @since 3.9.0 $query_var parameter added.
[1718] Fix | Delete
* @since 4.3.0 Added support for skipping query var registration by passing `false` to `$query_var`.
[1719] Fix | Delete
*
[1720] Fix | Delete
* @see add_rewrite_endpoint() for full documentation.
[1721] Fix | Delete
* @global WP $wp Current WordPress environment instance.
[1722] Fix | Delete
*
[1723] Fix | Delete
* @param string $name Name of the endpoint.
[1724] Fix | Delete
* @param int $places Endpoint mask describing the places the endpoint should be added.
[1725] Fix | Delete
* Accepts a mask of:
[1726] Fix | Delete
* - `EP_ALL`
[1727] Fix | Delete
* - `EP_NONE`
[1728] Fix | Delete
* - `EP_ALL_ARCHIVES`
[1729] Fix | Delete
* - `EP_ATTACHMENT`
[1730] Fix | Delete
* - `EP_AUTHORS`
[1731] Fix | Delete
* - `EP_CATEGORIES`
[1732] Fix | Delete
* - `EP_COMMENTS`
[1733] Fix | Delete
* - `EP_DATE`
[1734] Fix | Delete
* - `EP_DAY`
[1735] Fix | Delete
* - `EP_MONTH`
[1736] Fix | Delete
* - `EP_PAGES`
[1737] Fix | Delete
* - `EP_PERMALINK`
[1738] Fix | Delete
* - `EP_ROOT`
[1739] Fix | Delete
* - `EP_SEARCH`
[1740] Fix | Delete
* - `EP_TAGS`
[1741] Fix | Delete
* - `EP_YEAR`
[1742] Fix | Delete
* @param string|bool $query_var Optional. Name of the corresponding query variable. Pass `false` to
[1743] Fix | Delete
* skip registering a query_var for this endpoint. Defaults to the
[1744] Fix | Delete
* value of `$name`.
[1745] Fix | Delete
*/
[1746] Fix | Delete
public function add_endpoint( $name, $places, $query_var = true ) {
[1747] Fix | Delete
global $wp;
[1748] Fix | Delete
[1749] Fix | Delete
// For backward compatibility, if null has explicitly been passed as `$query_var`, assume `true`.
[1750] Fix | Delete
if ( true === $query_var || null === $query_var ) {
[1751] Fix | Delete
$query_var = $name;
[1752] Fix | Delete
}
[1753] Fix | Delete
$this->endpoints[] = array( $places, $name, $query_var );
[1754] Fix | Delete
[1755] Fix | Delete
if ( $query_var ) {
[1756] Fix | Delete
$wp->add_query_var( $query_var );
[1757] Fix | Delete
}
[1758] Fix | Delete
}
[1759] Fix | Delete
[1760] Fix | Delete
/**
[1761] Fix | Delete
* Adds a new permalink structure.
[1762] Fix | Delete
*
[1763] Fix | Delete
* A permalink structure (permastruct) is an abstract definition of a set of rewrite rules;
[1764] Fix | Delete
* it is an easy way of expressing a set of regular expressions that rewrite to a set of
[1765] Fix | Delete
* query strings. The new permastruct is added to the WP_Rewrite::$extra_permastructs array.
[1766] Fix | Delete
*
[1767] Fix | Delete
* When the rewrite rules are built by WP_Rewrite::rewrite_rules(), all of these extra
[1768] Fix | Delete
* permastructs are passed to WP_Rewrite::generate_rewrite_rules() which transforms them
[1769] Fix | Delete
* into the regular expressions that many love to hate.
[1770] Fix | Delete
*
[1771] Fix | Delete
* The `$args` parameter gives you control over how WP_Rewrite::generate_rewrite_rules()
[1772] Fix | Delete
* works on the new permastruct.
[1773] Fix | Delete
*
[1774] Fix | Delete
* @since 2.5.0
[1775] Fix | Delete
*
[1776] Fix | Delete
* @param string $name Name for permalink structure.
[1777] Fix | Delete
* @param string $struct Permalink structure (e.g. category/%category%)
[1778] Fix | Delete
* @param array $args {
[1779] Fix | Delete
* Optional. Arguments for building rewrite rules based on the permalink structure.
[1780] Fix | Delete
* Default empty array.
[1781] Fix | Delete
*
[1782] Fix | Delete
* @type bool $with_front Whether the structure should be prepended with `WP_Rewrite::$front`.
[1783] Fix | Delete
* Default true.
[1784] Fix | Delete
* @type int $ep_mask The endpoint mask defining which endpoints are added to the structure.
[1785] Fix | Delete
* Accepts a mask of:
[1786] Fix | Delete
* - `EP_ALL`
[1787] Fix | Delete
* - `EP_NONE`
[1788] Fix | Delete
* - `EP_ALL_ARCHIVES`
[1789] Fix | Delete
* - `EP_ATTACHMENT`
[1790] Fix | Delete
* - `EP_AUTHORS`
[1791] Fix | Delete
* - `EP_CATEGORIES`
[1792] Fix | Delete
* - `EP_COMMENTS`
[1793] Fix | Delete
* - `EP_DATE`
[1794] Fix | Delete
* - `EP_DAY`
[1795] Fix | Delete
* - `EP_MONTH`
[1796] Fix | Delete
* - `EP_PAGES`
[1797] Fix | Delete
* - `EP_PERMALINK`
[1798] Fix | Delete
* - `EP_ROOT`
[1799] Fix | Delete
* - `EP_SEARCH`
[1800] Fix | Delete
* - `EP_TAGS`
[1801] Fix | Delete
* - `EP_YEAR`
[1802] Fix | Delete
* Default `EP_NONE`.
[1803] Fix | Delete
* @type bool $paged Whether archive pagination rules should be added for the structure.
[1804] Fix | Delete
* Default true.
[1805] Fix | Delete
* @type bool $feed Whether feed rewrite rules should be added for the structure. Default true.
[1806] Fix | Delete
* @type bool $forcomments Whether the feed rules should be a query for a comments feed. Default false.
[1807] Fix | Delete
* @type bool $walk_dirs Whether the 'directories' making up the structure should be walked over
[1808] Fix | Delete
* and rewrite rules built for each in-turn. Default true.
[1809] Fix | Delete
* @type bool $endpoints Whether endpoints should be applied to the generated rules. Default true.
[1810] Fix | Delete
* }
[1811] Fix | Delete
*/
[1812] Fix | Delete
public function add_permastruct( $name, $struct, $args = array() ) {
[1813] Fix | Delete
// Back-compat for the old parameters: $with_front and $ep_mask.
[1814] Fix | Delete
if ( ! is_array( $args ) ) {
[1815] Fix | Delete
$args = array( 'with_front' => $args );
[1816] Fix | Delete
}
[1817] Fix | Delete
[1818] Fix | Delete
if ( func_num_args() === 4 ) {
[1819] Fix | Delete
$args['ep_mask'] = func_get_arg( 3 );
[1820] Fix | Delete
}
[1821] Fix | Delete
[1822] Fix | Delete
$defaults = array(
[1823] Fix | Delete
'with_front' => true,
[1824] Fix | Delete
'ep_mask' => EP_NONE,
[1825] Fix | Delete
'paged' => true,
[1826] Fix | Delete
'feed' => true,
[1827] Fix | Delete
'forcomments' => false,
[1828] Fix | Delete
'walk_dirs' => true,
[1829] Fix | Delete
'endpoints' => true,
[1830] Fix | Delete
);
[1831] Fix | Delete
[1832] Fix | Delete
$args = array_intersect_key( $args, $defaults );
[1833] Fix | Delete
$args = wp_parse_args( $args, $defaults );
[1834] Fix | Delete
[1835] Fix | Delete
if ( $args['with_front'] ) {
[1836] Fix | Delete
$struct = $this->front . $struct;
[1837] Fix | Delete
} else {
[1838] Fix | Delete
$struct = $this->root . $struct;
[1839] Fix | Delete
}
[1840] Fix | Delete
[1841] Fix | Delete
$args['struct'] = $struct;
[1842] Fix | Delete
[1843] Fix | Delete
$this->extra_permastructs[ $name ] = $args;
[1844] Fix | Delete
}
[1845] Fix | Delete
[1846] Fix | Delete
/**
[1847] Fix | Delete
* Removes a permalink structure.
[1848] Fix | Delete
*
[1849] Fix | Delete
* @since 4.5.0
[1850] Fix | Delete
*
[1851] Fix | Delete
* @param string $name Name for permalink structure.
[1852] Fix | Delete
*/
[1853] Fix | Delete
public function remove_permastruct( $name ) {
[1854] Fix | Delete
unset( $this->extra_permastructs[ $name ] );
[1855] Fix | Delete
}
[1856] Fix | Delete
[1857] Fix | Delete
/**
[1858] Fix | Delete
* Removes rewrite rules and then recreate rewrite rules.
[1859] Fix | Delete
*
[1860] Fix | Delete
* Calls WP_Rewrite::wp_rewrite_rules() after removing the 'rewrite_rules' option.
[1861] Fix | Delete
* If the function named 'save_mod_rewrite_rules' exists, it will be called.
[1862] Fix | Delete
*
[1863] Fix | Delete
* @since 2.0.1
[1864] Fix | Delete
*
[1865] Fix | Delete
* @param bool $hard Whether to update .htaccess (hard flush) or just update rewrite_rules option (soft flush). Default is true (hard).
[1866] Fix | Delete
*/
[1867] Fix | Delete
public function flush_rules( $hard = true ) {
[1868] Fix | Delete
static $do_hard_later = null;
[1869] Fix | Delete
[1870] Fix | Delete
// Prevent this action from running before everyone has registered their rewrites.
[1871] Fix | Delete
if ( ! did_action( 'wp_loaded' ) ) {
[1872] Fix | Delete
add_action( 'wp_loaded', array( $this, 'flush_rules' ) );
[1873] Fix | Delete
$do_hard_later = ( isset( $do_hard_later ) ) ? $do_hard_later || $hard : $hard;
[1874] Fix | Delete
return;
[1875] Fix | Delete
}
[1876] Fix | Delete
[1877] Fix | Delete
if ( isset( $do_hard_later ) ) {
[1878] Fix | Delete
$hard = $do_hard_later;
[1879] Fix | Delete
unset( $do_hard_later );
[1880] Fix | Delete
}
[1881] Fix | Delete
[1882] Fix | Delete
$this->refresh_rewrite_rules();
[1883] Fix | Delete
[1884] Fix | Delete
/**
[1885] Fix | Delete
* Filters whether a "hard" rewrite rule flush should be performed when requested.
[1886] Fix | Delete
*
[1887] Fix | Delete
* A "hard" flush updates .htaccess (Apache) or web.config (IIS).
[1888] Fix | Delete
*
[1889] Fix | Delete
* @since 3.7.0
[1890] Fix | Delete
*
[1891] Fix | Delete
* @param bool $hard Whether to flush rewrite rules "hard". Default true.
[1892] Fix | Delete
*/
[1893] Fix | Delete
if ( ! $hard || ! apply_filters( 'flush_rewrite_rules_hard', true ) ) {
[1894] Fix | Delete
return;
[1895] Fix | Delete
}
[1896] Fix | Delete
if ( function_exists( 'save_mod_rewrite_rules' ) ) {
[1897] Fix | Delete
save_mod_rewrite_rules();
[1898] Fix | Delete
}
[1899] Fix | Delete
if ( function_exists( 'iis7_save_url_rewrite_rules' ) ) {
[1900] Fix | Delete
iis7_save_url_rewrite_rules();
[1901] Fix | Delete
}
[1902] Fix | Delete
}
[1903] Fix | Delete
[1904] Fix | Delete
/**
[1905] Fix | Delete
* Sets up the object's properties.
[1906] Fix | Delete
*
[1907] Fix | Delete
* The 'use_verbose_page_rules' object property will be set to true if the
[1908] Fix | Delete
* permalink structure begins with one of the following: '%postname%', '%category%',
[1909] Fix | Delete
* '%tag%', or '%author%'.
[1910] Fix | Delete
*
[1911] Fix | Delete
* @since 1.5.0
[1912] Fix | Delete
*/
[1913] Fix | Delete
public function init() {
[1914] Fix | Delete
$this->extra_rules = array();
[1915] Fix | Delete
$this->non_wp_rules = array();
[1916] Fix | Delete
$this->endpoints = array();
[1917] Fix | Delete
$this->permalink_structure = get_option( 'permalink_structure' );
[1918] Fix | Delete
$this->front = substr( $this->permalink_structure, 0, strpos( $this->permalink_structure, '%' ) );
[1919] Fix | Delete
$this->root = '';
[1920] Fix | Delete
[1921] Fix | Delete
if ( $this->using_index_permalinks() ) {
[1922] Fix | Delete
$this->root = $this->index . '/';
[1923] Fix | Delete
}
[1924] Fix | Delete
[1925] Fix | Delete
unset( $this->author_structure );
[1926] Fix | Delete
unset( $this->date_structure );
[1927] Fix | Delete
unset( $this->page_structure );
[1928] Fix | Delete
unset( $this->search_structure );
[1929] Fix | Delete
unset( $this->feed_structure );
[1930] Fix | Delete
unset( $this->comment_feed_structure );
[1931] Fix | Delete
[1932] Fix | Delete
$this->use_trailing_slashes = str_ends_with( $this->permalink_structure, '/' );
[1933] Fix | Delete
[1934] Fix | Delete
// Enable generic rules for pages if permalink structure doesn't begin with a wildcard.
[1935] Fix | Delete
if ( preg_match( '/^[^%]*%(?:postname|category|tag|author)%/', $this->permalink_structure ) ) {
[1936] Fix | Delete
$this->use_verbose_page_rules = true;
[1937] Fix | Delete
} else {
[1938] Fix | Delete
$this->use_verbose_page_rules = false;
[1939] Fix | Delete
}
[1940] Fix | Delete
}
[1941] Fix | Delete
[1942] Fix | Delete
/**
[1943] Fix | Delete
* Sets the main permalink structure for the site.
[1944] Fix | Delete
*
[1945] Fix | Delete
* Will update the 'permalink_structure' option, if there is a difference
[1946] Fix | Delete
* between the current permalink structure and the parameter value. Calls
[1947] Fix | Delete
* WP_Rewrite::init() after the option is updated.
[1948] Fix | Delete
*
[1949] Fix | Delete
* Fires the {@see 'permalink_structure_changed'} action once the init call has
[1950] Fix | Delete
* processed passing the old and new values
[1951] Fix | Delete
*
[1952] Fix | Delete
* @since 1.5.0
[1953] Fix | Delete
*
[1954] Fix | Delete
* @param string $permalink_structure Permalink structure.
[1955] Fix | Delete
*/
[1956] Fix | Delete
public function set_permalink_structure( $permalink_structure ) {
[1957] Fix | Delete
if ( $this->permalink_structure !== $permalink_structure ) {
[1958] Fix | Delete
$old_permalink_structure = $this->permalink_structure;
[1959] Fix | Delete
update_option( 'permalink_structure', $permalink_structure );
[1960] Fix | Delete
[1961] Fix | Delete
$this->init();
[1962] Fix | Delete
[1963] Fix | Delete
/**
[1964] Fix | Delete
* Fires after the permalink structure is updated.
[1965] Fix | Delete
*
[1966] Fix | Delete
* @since 2.8.0
[1967] Fix | Delete
*
[1968] Fix | Delete
* @param string $old_permalink_structure The previous permalink structure.
[1969] Fix | Delete
* @param string $permalink_structure The new permalink structure.
[1970] Fix | Delete
*/
[1971] Fix | Delete
do_action( 'permalink_structure_changed', $old_permalink_structure, $permalink_structure );
[1972] Fix | Delete
}
[1973] Fix | Delete
}
[1974] Fix | Delete
[1975] Fix | Delete
/**
[1976] Fix | Delete
* Sets the category base for the category permalink.
[1977] Fix | Delete
*
[1978] Fix | Delete
* Will update the 'category_base' option, if there is a difference between
[1979] Fix | Delete
* the current category base and the parameter value. Calls WP_Rewrite::init()
[1980] Fix | Delete
* after the option is updated.
[1981] Fix | Delete
*
[1982] Fix | Delete
* @since 1.5.0
[1983] Fix | Delete
*
[1984] Fix | Delete
* @param string $category_base Category permalink structure base.
[1985] Fix | Delete
*/
[1986] Fix | Delete
public function set_category_base( $category_base ) {
[1987] Fix | Delete
if ( get_option( 'category_base' ) !== $category_base ) {
[1988] Fix | Delete
update_option( 'category_base', $category_base );
[1989] Fix | Delete
$this->init();
[1990] Fix | Delete
}
[1991] Fix | Delete
}
[1992] Fix | Delete
[1993] Fix | Delete
/**
[1994] Fix | Delete
* Sets the tag base for the tag permalink.
[1995] Fix | Delete
*
[1996] Fix | Delete
* Will update the 'tag_base' option, if there is a difference between the
[1997] Fix | Delete
* current tag base and the parameter value. Calls WP_Rewrite::init() after
[1998] Fix | Delete
* the option is updated.
[1999] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function