Jump to content

lxc022

New Members
  • Posts

    5
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

lxc022's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Can you please show me in coding? Thank you.
  2. Hello I'm having an error saying Fatal error: Class 'WP_Rewrite' not found in /home1/thewriw3/public_html/wp-settings.php on line 219. However there is no such file called WP_Rewrite. There is a file called rewrite.php located in another folder. The code looks like this, can you please tell me exactly in coding how to relocate the file to rewrite.php? /** * Holds the WordPress Rewrite object for creating pretty URLs * @global object $wp_rewrite * @since 1.5.0 */ $wp_rewrite =& new WP_Rewrite(); That's what the current code looks like. Thanks for your help.
  3. Where would I input that code and would that solve the issue?
  4. Please help me, I have a Parse error: syntax error, unexpected $end, expecting T_FUNCTION on line 748 which is the last line of the code. Can you please tell me what's wrong with the code? <?php /** * WordPress Rewrite API * * @package WordPress * @subpackage Rewrite */ /** * Add a straight rewrite rule. * * @see WP_Rewrite::add_rule() for long description. * @since 2.1.0 * * @param string $regex Regular Expression to match request against. * @param string $redirect Page to redirect to. * @param string $after Optional, default is 'bottom'. Where to add rule, can also be 'top'. */ function add_rewrite_rule($regex, $redirect, $after = 'bottom') { global $wp_rewrite; $wp_rewrite->add_rule($regex, $redirect, $after); } /** * Add a new tag (like %postname%). * * Warning: you must call this on init or earlier, otherwise the query var * addition stuff won't work. * * @since 2.1.0 * * @param string $tagname * @param string $regex */ function add_rewrite_tag($tagname, $regex) { //validation if ( strlen($tagname) < 3 || $tagname{0} != '%' || $tagname{strlen($tagname)-1} != '%' ) return; $qv = trim($tagname, '%'); global $wp_rewrite, $wp; $wp->add_query_var($qv); $wp_rewrite->add_rewrite_tag($tagname, $regex, $qv . '='); } /** * Add permalink structure. * * @see WP_Rewrite::add_permastruct() * @since 3.0.0 * * @param string $name Name for permalink structure. * @param string $struct Permalink structure. * @param bool $with_front Prepend front base to permalink structure. */ function add_permastruct( $name, $struct, $with_front = true, $ep_mask = EP_NONE ) { global $wp_rewrite; return $wp_rewrite->add_permastruct( $name, $struct, $with_front, $ep_mask ); } /** * Add a new feed type like /atom1/. * * @since 2.1.0 * * @param string $feedname * @param callback $function Callback to run on feed display. * @return string Feed action name. */ function add_feed($feedname, $function) { global $wp_rewrite; if ( ! in_array($feedname, $wp_rewrite->feeds) ) //override the file if it is $wp_rewrite->feeds[] = $feedname; $hook = 'do_feed_' . $feedname; // Remove default function hook remove_action($hook, $hook, 10, 1); add_action($hook, $function, 10, 1); return $hook; } /** * Remove rewrite rules and then recreate rewrite rules. * * @see WP_Rewrite::flush_rules() * @since 3.0.0 * * @param bool $hard Whether to update .htaccess (hard flush) or just update * rewrite_rules transient (soft flush). Default is true (hard). */ function flush_rewrite_rules( $hard = true ) { global $wp_rewrite; $wp_rewrite->flush_rules( $hard ); } //pseudo-places /** * Endpoint Mask for default, which is nothing. * * @since 2.1.0 */ define('EP_NONE', 0); /** * Endpoint Mask for Permalink. * * @since 2.1.0 */ define('EP_PERMALINK', 1); /** * Endpoint Mask for Attachment. * * @since 2.1.0 */ define('EP_ATTACHMENT', 2); /** * Endpoint Mask for date. * * @since 2.1.0 */ define('EP_DATE', 4); /** * Endpoint Mask for year * * @since 2.1.0 */ define('EP_YEAR',; /** * Endpoint Mask for month. * * @since 2.1.0 */ define('EP_MONTH', 16); /** * Endpoint Mask for day. * * @since 2.1.0 */ define('EP_DAY', 32); /** * Endpoint Mask for root. * * @since 2.1.0 */ define('EP_ROOT', 64); /** * Endpoint Mask for comments. * * @since 2.1.0 */ define('EP_COMMENTS', 128); /** * Endpoint Mask for searches. * * @since 2.1.0 */ define('EP_SEARCH', 256); /** * Endpoint Mask for categories. * * @since 2.1.0 */ define('EP_CATEGORIES', 512); /** * Endpoint Mask for tags. * * @since 2.3.0 */ define('EP_TAGS', 1024); /** * Endpoint Mask for authors. * * @since 2.1.0 */ define('EP_AUTHORS', 2048); /** * Endpoint Mask for pages. * * @since 2.1.0 */ define('EP_PAGES', 4096); /** * Endpoint Mask for everything. * * @since 2.1.0 */ define('EP_ALL', 8191); /** * Add an endpoint, like /trackback/. * * The endpoints are added to the end of the request. So a request matching * "/2008/10/14/my_post/myep/", the endpoint will be "/myep/". * * Be sure to flush the rewrite rules (wp_rewrite->flush()) when your plugin gets * activated (register_activation_hook()) and deactivated (register_deactivation_hook()) * * @since 2.1.0 * @see WP_Rewrite::add_endpoint() Parameters and more description. * @uses $wp_rewrite * * @param unknown_type $name * @param unknown_type $places */ function add_rewrite_endpoint($name, $places) { global $wp_rewrite; $wp_rewrite->add_endpoint($name, $places); } /** * Filter the URL base for taxonomies. * * To remove any manually prepended /index.php/. * * @access private * @since 2.6.0 * * @param string $base The taxonomy base that we're going to filter * @return string */ function _wp_filter_taxonomy_base( $base ) { if ( !empty( $base ) ) { $base = preg_replace( '|^/index\.php/|', '', $base ); $base = trim( $base, '/' ); } return $base; } /** * Examine a url and try to determine the post ID it represents. * * Checks are supposedly from the hosted site blog. * * @since 1.0.0 * * @param string $url Permalink to check. * @return int Post ID, or 0 on failure. */ function url_to_postid($url) { global $wp_rewrite; $url = apply_filters('url_to_postid', $url); // First, check to see if there is a 'p=N' or 'page_id=N' to match against if ( preg_match('#[?&](p|page_id|attachment_id)=(\d+)#', $url, $values) ) { $id = absint($values[2]); if ( $id ) return $id; } // Check to see if we are using rewrite rules $rewrite = $wp_rewrite->wp_rewrite_rules(); // Not using rewrite rules, and 'p=N' and 'page_id=N' methods failed, so we're out of options if ( empty($rewrite) ) return 0; // $url cleanup by Mark Jaquith // This fixes things like #anchors, ?query=strings, missing 'www.', // added 'www.', or added 'index.php/' that will mess up our WP_Query // and return a false negative // Get rid of the #anchor $url_split = explode('#', $url); $url = $url_split[0]; // Get rid of URL ?query=string $url_split = explode('?', $url); $url = $url_split[0]; // Add 'www.' if it is absent and should be there if ( false !== strpos(home_url(), '://www.') && false === strpos($url, '://www.') ) $url = str_replace('://', '://www.', $url); // Strip 'www.' if it is present and shouldn't be if ( false === strpos(home_url(), '://www.') ) $url = str_replace('://www.', '://', $url); // Strip 'index.php/' if we're not using path info permalinks if ( !$wp_rewrite->using_index_permalinks() ) $url = str_replace('index.php/', '', $url); if ( false !== strpos($url, home_url()) ) { // Chop off http://domain.com $url = str_replace(home_url(), '', $url); } else { // Chop off /path/to/blog $home_path = parse_url(home_url()); $home_path = $home_path['path']; $url = str_replace($home_path, '', $url); } // Trim leading and lagging slashes $url = trim($url, '/'); $request = $url; // Done with cleanup // Look for matches. $request_match = $request; foreach ( (array)$rewrite as $match => $query) { // If the requesting file is the anchor of the match, prepend it // to the path info. if ( !empty($url) && ($url != $request) && (strpos($match, $url) === 0) ) $request_match = $url . '/' . $request; if ( preg_match("!^$match!", $request_match, $matches) ) { // Got a match. // Trim the query of everything up to the '?'. $query = preg_replace("!^.+\?!", '', $query); // Substitute the substring matches into the query. $query = addslashes(WP_MatchesMapRegex::apply($query, $matches)); // Filter out non-public query vars global $wp; parse_str($query, $query_vars); $query = array(); foreach ( (array) $query_vars as $key => $value ) { if ( in_array($key, $wp->public_query_vars) ) $query[$key] = $value; } // Do the query $query = new WP_Query($query); if ( $query->is_single || $query->is_page ) return $query->post->ID; else return 0; } } return 0; } /** * WordPress Rewrite Component. * * The WordPress Rewrite class writes the rewrite module rules to the .htaccess * file. It also handles parsing the request to get the correct setup for the * WordPress Query class. * * The Rewrite along with WP class function as a front controller for WordPress. * You can add rules to trigger your page view and processing using this * component. The full functionality of a front controller does not exist, * meaning you can't define how the template files load based on the rewrite * rules. * * @since 1.5.0 */ class WP_Rewrite { /** * Default permalink structure for WordPress. * * @since 1.5.0 * @access private * @var string */ var $permalink_structure; /** * Whether to add trailing slashes. * * @since 2.2.0 * @access private * @var bool */ var $use_trailing_slashes; /** * Customized or default category permalink base ( example.com/xx/tagname ). * * @since 1.5.0 * @access private * @var string */ var $category_base; /** * Customized or default tag permalink base ( example.com/xx/tagname ). * * @since 2.3.0 * @access private * @var string */ var $tag_base; /** * Permalink request structure for categories. * * @since 1.5.0 * @access private * @var string */ var $category_structure; /** * Permalink request structure for tags. * * @since 2.3.0 * @access private * @var string */ var $tag_structure; /** * Permalink author request base ( example.com/author/authorname ). * * @since 1.5.0 * @access private * @var string */ var $author_base = 'author'; /** * Permalink request structure for author pages. * * @since 1.5.0 * @access private * @var string */ var $author_structure; /** * Permalink request structure for dates. * * @since 1.5.0 * @access private * @var string */ var $date_structure; /** * Permalink request structure for pages. * * @since 1.5.0 * @access private * @var string */ var $page_structure; /** * Search permalink base ( example.com/search/query ). * * @since 1.5.0 * @access private * @var string */ var $search_base = 'search'; /** * Permalink request structure for searches. * * @since 1.5.0 * @access private * @var string */ var $search_structure; /** * Comments permalink base. * * @since 1.5.0 * @access private * @var string */ var $comments_base = 'comments'; /** * Feed permalink base. * * @since 1.5.0 * @access private * @var string */ var $feed_base = 'feed'; /** * Comments feed request structure permalink. * * @since 1.5.0 * @access private * @var string */ var $comments_feed_structure; /** * Feed request structure permalink. * * @since 1.5.0 * @access private * @var string */ var $feed_structure; /** * Front URL path. * * The difference between the root property is that WordPress might be * located at example/WordPress/index.php, if permalinks are turned off. The * WordPress/index.php will be the front portion. If permalinks are turned * on, this will most likely be empty or not set. * * @since 1.5.0 * @access private * @var string */ var $front; /** * Root URL path to WordPress (without domain). * * The difference between front property is that WordPress might be located * at example.com/WordPress/. The root is the 'WordPress/' portion. * * @since 1.5.0 * @access private * @var string */ var $root = ''; /** * Permalink to the home page. * * @since 1.5.0 * @access public * @var string */ var $index = 'index.php'; /** * Request match string. * * @since 1.5.0 * @access private * @var string */ var $matches = ''; /** * Rewrite rules to match against the request to find the redirect or query. * * @since 1.5.0 * @access private * @var array */ var $rules; /** * Additional rules added external to the rewrite class. * * Those not generated by the class, see add_rewrite_rule(). * * @since 2.1.0 * @access private * @var array */ var $extra_rules = array(); // /** * Additional rules that belong at the beginning to match first. * * Those not generated by the class, see add_rewrite_rule(). * * @since 2.3.0 * @access private * @var array */ var $extra_rules_top = array(); // /** * Rules that don't redirect to WP's index.php. * * These rules are written to the mod_rewrite portion of the .htaccess. * * @since 2.1.0 * @access private * @var array */ var $non_wp_rules = array(); // /** * Extra permalink structures. * * @since 2.1.0 * @access private * @var array */ var $extra_permastructs = array(); /** * Endpoints permalinks * * @since unknown * @access private * @var array */ var $endpoints; /** * Whether to write every mod_rewrite rule for WordPress. * * This is off by default, turning it on might print a lot of rewrite rules * to the .htaccess file. * * @since 2.0.0 * @access public * @var bool */ var $use_verbose_rules = false; /** * Whether to write every mod_rewrite rule for WordPress pages. * * @since 2.5.0 * @access public * @var bool */ var $use_verbose_page_rules = true; /** * Permalink structure search for preg_replace. * * @since 1.5.0 * @access private * @var array */ var $rewritecode = array( '%year%', '%monthnum%', '%day%', '%hour%', '%minute%', '%second%', '%postname%', '%post_id%', '%category%', '%tag%', '%author%', '%pagename%', '%search%' ); /** * Preg_replace values for the search, see {@link WP_Rewrite::$rewritecode}. * * @since 1.5.0 * @access private * @var array */ var $rewritereplace = array( '([0-9]{4})', '([0-9]{1,2})', '([0-9]{1,2})', '([0-9]{1,2})', '([0-9]{1,2})', '([0-9]{1,2})', '([^/]+)', '([0-9]+)', '(.+?)', '(.+?)', '([^/]+)', '([^/]+?)', '(.+)' ); /** * Search for the query to look for replacing. * * @since 1.5.0 * @access private * @var array */ var $queryreplace = array ( 'year=', 'monthnum=', 'day=', 'hour=', 'minute=', 'second=', 'name=', 'p=', 'category_name=', 'tag=', 'author_name=', 'pagename=', 's=' ); /** * Supported default feeds. * * @since 1.5.0 * @access private * @var array */ var $feeds = array ( 'feed', 'rdf', 'rss', 'rss2', 'atom' ); /** * Whether permalinks are being used. * * This can be either rewrite module or permalink in the HTTP query string. * * @since 1.5.0 * @access public * * @return bool True, if permalinks are enabled. */ function using_permalinks() { return ! empty($this->permalink_structure); } /** * Whether permalinks are being used and rewrite module is not enabled. * * Means that permalink links are enabled and index.php is in the URL. * * @since 1.5.0 * @access public * * @return bool */ function using_index_permalinks() { if ( empty($this->permalink_structure) ) return false; // If the index is not in the permalink, we're using mod_rewrite. if ( preg_match('#^/*' . $this->index . '#', $this->permalink_structure) ) return true; return false; } MOD EDIT: code tags added.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.