Example #1
0
 /**
  * Register the rewrite rule
  *
  * @return void
  */
 function register_rule()
 {
     foreach ($this->query_vars as $var) {
         add_rewrite_endpoint($var, EP_PAGES);
     }
     $permalinks = get_option('woocommerce_permalinks', array());
     if (isset($permalinks['product_base'])) {
         $base = substr($permalinks['product_base'], 1);
     }
     if (!empty($base)) {
         // special treatment for product cat
         if (stripos($base, 'product_cat')) {
             // get the category base. usually: shop
             $base_array = explode('/', ltrim($base, '/'));
             // remove first '/' and explode
             $cat_base = isset($base_array[0]) ? $base_array[0] : 'shop';
             add_rewrite_rule($cat_base . '/(.+?)/([^/]+)(/[0-9]+)?/edit?$', 'index.php?product_cat=$matches[1]&product=$matches[2]&page=$matches[3]&edit=true', 'top');
         } else {
             add_rewrite_rule($base . '/([^/]+)(/[0-9]+)?/edit/?$', 'index.php?product=$matches[1]&page=$matches[2]&edit=true', 'top');
         }
     }
     add_rewrite_rule('store/([^/]+)/?$', 'index.php?store=$matches[1]', 'top');
     add_rewrite_rule('store/([^/]+)/page/?([0-9]{1,})/?$', 'index.php?store=$matches[1]&paged=$matches[2]', 'top');
     add_rewrite_rule('store/([^/]+)/section/?([0-9]{1,})/?$', 'index.php?store=$matches[1]&term=$matches[2]&term_section=true', 'top');
     add_rewrite_rule('store/([^/]+)/section/?([0-9]{1,})/page/?([0-9]{1,})/?$', 'index.php?store=$matches[1]&term=$matches[2]&paged=$matches[3]&term_section=true', 'top');
 }
Example #2
0
 /**
  * Initialize sitemaps. Add sitemap rewrite rules and query var
  */
 function init()
 {
     $GLOBALS['wp']->add_query_var('sitemap');
     $GLOBALS['wp']->add_query_var('sitemap_n');
     add_rewrite_rule('sitemap_index\\.xml$', 'index.php?sitemap=1', 'top');
     add_rewrite_rule('([^/]+?)-sitemap([0-9]+)?\\.xml$', 'index.php?sitemap=$matches[1]&sitemap_n=$matches[2]', 'top');
 }
 /**
  * Creates rewrites based on our app's url base - http://pong.roccotripaldi.com/games/
  */
 function create_main_route()
 {
     add_rewrite_rule('^games/?$', 'index.php?pingopongo=/', 'top');
     add_rewrite_rule('^games(.*)?', 'index.php?pingopongo=$matches[1]', 'top');
     global $wp;
     $wp->add_query_var('pingopongo');
 }
function skelet_add_endpoint()
{
    $rules = array('tinyMCE\\.js' => 'tinyMCE_js', 'tinyMCE\\.php/([a-zA-Z_][a-zA-Z0-9_-]*)' => 'tinyMCE_php&tag=$matches[1]');
    foreach ($rules as $regex => $redirect) {
        add_rewrite_rule(sprintf('^skelet/%s$', $regex), sprintf('index.php?skelet=%s', $redirect), 'top');
    }
}
Example #5
0
 /**
  * Register the rewrite rule
  *
  * @return void
  */
 function register_rule()
 {
     $this->query_vars = apply_filters('dokan_query_var_filter', array('products', 'new-product', 'orders', 'coupons', 'reports', 'reviews', 'withdraw', 'announcement', 'single-announcement', 'settings', 'account-migration'));
     foreach ($this->query_vars as $var) {
         add_rewrite_endpoint($var, EP_PAGES);
     }
     $permalinks = get_option('woocommerce_permalinks', array());
     if (isset($permalinks['product_base'])) {
         $base = substr($permalinks['product_base'], 1);
     }
     if (!empty($base)) {
         // special treatment for product cat
         if (stripos($base, 'product_cat')) {
             // get the category base. usually: shop
             $base_array = explode('/', ltrim($base, '/'));
             // remove first '/' and explode
             $cat_base = isset($base_array[0]) ? $base_array[0] : 'shop';
             add_rewrite_rule($cat_base . '/(.+?)/([^/]+)(/[0-9]+)?/edit?$', 'index.php?product_cat=$matches[1]&product=$matches[2]&page=$matches[3]&edit=true', 'top');
         } else {
             add_rewrite_rule($base . '/([^/]+)(/[0-9]+)?/edit/?$', 'index.php?product=$matches[1]&page=$matches[2]&edit=true', 'top');
         }
     }
     add_rewrite_rule($this->custom_store_url . '/([^/]+)/?$', 'index.php?' . $this->custom_store_url . '=$matches[1]', 'top');
     add_rewrite_rule($this->custom_store_url . '/([^/]+)/page/?([0-9]{1,})/?$', 'index.php?' . $this->custom_store_url . '=$matches[1]&paged=$matches[2]', 'top');
     add_rewrite_rule($this->custom_store_url . '/([^/]+)/reviews?$', 'index.php?' . $this->custom_store_url . '=$matches[1]&store_review=true', 'top');
     add_rewrite_rule($this->custom_store_url . '/([^/]+)/reviews/page/?([0-9]{1,})/?$', 'index.php?' . $this->custom_store_url . '=$matches[1]&paged=$matches[2]&store_review=true', 'top');
     add_rewrite_rule($this->custom_store_url . '/([^/]+)/section/?([0-9]{1,})/?$', 'index.php?' . $this->custom_store_url . '=$matches[1]&term=$matches[2]&term_section=true', 'top');
     add_rewrite_rule($this->custom_store_url . '/([^/]+)/section/?([0-9]{1,})/page/?([0-9]{1,})/?$', 'index.php?' . $this->custom_store_url . '=$matches[1]&term=$matches[2]&paged=$matches[3]&term_section=true', 'top');
     add_rewrite_rule($this->custom_store_url . '/([^/]+)/toc?$', 'index.php?' . $this->custom_store_url . '=$matches[1]&toc=true', 'top');
     add_rewrite_rule($this->custom_store_url . '/([^/]+)/toc/page/?([0-9]{1,})/?$', 'index.php?' . $this->custom_store_url . '=$matches[1]&paged=$matches[2]&toc=true', 'top');
     do_action('dokan_rewrite_rules_loaded');
 }
Example #6
0
function setup_rewrite()
{
    if (!($views = option('views'))) {
        return;
    }
    // Cycle through each template to add rewrite tags and rules
    foreach ($views as $view => $data) {
        add_rewrite_tag('%' . $view . '%', '');
        // Regex is currently blank; if we want to capture: '([^/]+)'
        // Root rewrite rules; this allows us to swap views on the homepage and such
        add_rewrite_rule($view . '/page/?([0-9]{1,})/?$', 'index.php?&' . $view . '=&paged=$matches[1]', 'top');
        add_rewrite_rule($view . '/?$', 'index.php?&' . $view . '=', 'top');
        // Cycle through each taxonomy to apply additional rules
        if ($taxonomies = option('taxonomies')) {
            foreach ($taxonomies as $taxonomy) {
                // Clear existing variables from the last run through the loop
                unset($tax, $slug, $query_var);
                // Only proceed if we have a match
                if ($tax = get_taxonomy($taxonomy)) {
                    $slug = $tax->rewrite['slug'];
                    $query_var = $tax->query_var;
                    // Add rewrite rules for taxonomy archives
                    if ($slug && $query_var) {
                        add_rewrite_rule($slug . '/(.+?)/' . $view . '/page/?([0-9]{1,})/?$', 'index.php?&' . $query_var . '=$matches[1]&' . $view . '=&paged=$matches[2]', 'top');
                        add_rewrite_rule($slug . '/(.+?)/' . $view . '/?$', 'index.php?&' . $query_var . '=$matches[1]&' . $view . '=', 'top');
                    }
                }
            }
        }
    }
}
Example #7
0
 /**
  * add_endpoint function.
  *
  * @since 4.1
  * @return void
  */
 public function add_endpoint()
 {
     // REST API
     add_rewrite_rule('^fue-api/v1/?$', 'index.php?fue-api-version=1&fue-api-route=/', 'top');
     add_rewrite_rule('^fue-api/v1(.*)?', 'index.php?fue-api-version=1&fue-api-route=$matches[1]', 'top');
     add_rewrite_endpoint('fue-api', EP_ALL);
 }
Example #8
0
 public static function rewrite_rules()
 {
     global $wp_rewrite;
     /*
     		$available_languages = unserialize(get_option('carrental_available_languages'));
     		if (empty($available_languages)) {
     			$available_languages = array();
     		}
     		include dirname(realpath(__FILE__)) . '/languages.php';
     		$urlLanguages = array();
     		foreach ($available_languages as $lng_key => $lng) {
     			$urlLanguages[] = $languages[$lng_key]['country-www'];
     		}
     		$flush = false;
     		$rewrite_rules_array = (array)$wp_rewrite;
     		if (!isset($rewrite_rules_array['('.implode('|', $urlLanguages).')/([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/?$'])) {
     			$flush = true;
     		}
     		add_rewrite_rule('('.implode('|', $urlLanguages).')/([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/?$','index.php?year=$matches[2]&monthnum=$matches[3]&day=$matches[4]&lng=$matches[1]','top');
     		add_rewrite_rule('('.implode('|', $urlLanguages).')/(.+?)(/[0-9]+)?/?$','index.php?pagename=$matches[2]&page=$matches[3]&lng=$matches[1]','top');
     * 
     */
     $flush = false;
     $rewrite_rules_array = (array) $wp_rewrite;
     if (!isset($rewrite_rules_array['detail/([0-9]{1,3})-(.+?)/?$'])) {
         $flush = true;
     }
     add_rewrite_rule('detail/([0-9]{1,3})-(.+?)/?$', 'index.php?detail_id=$matches[1]&detail_url=$matches[2]', 'top');
     if ($flush) {
         $wp_rewrite->flush_rules(false);
     }
 }
 public static function generate_rewrite_rules()
 {
     $page_slug = trailingslashit(DispletRetsIdxUtilities::get_full_page_slug(self::$_options['property_details_page_id']));
     $search_slug = trailingslashit(DispletRetsIdxUtilities::get_full_page_slug(self::$_options['search_results_page_id']));
     add_rewrite_tag('%property_state%', '([^/]{1,3})');
     add_rewrite_tag('%property_city%', '([^/]+)');
     add_rewrite_tag('%property_zip%', '([^/]+)');
     add_rewrite_tag('%property_id%', '([^/]+)');
     add_rewrite_tag('%property_address%', '([^/]+)');
     add_rewrite_tag('%property_price%', '([\\d]+)');
     add_rewrite_tag('%property_update_id%', '([^/]+)');
     add_rewrite_tag('%re_user_login%', '([^/]+)');
     add_rewrite_tag('%residential_permalinks%', '([^/]+)');
     add_rewrite_rule($page_slug . '([^/]{1,3})/([^/]*)/([^/]*)/page/([0-9]+)/?$', 'index.php?page_id=' . self::$_options['property_details_page_id'] . '&property_state=$matches[1]&property_city=$matches[2]&property_zip=$matches[3]&paged=$matches[4]', 'top');
     add_rewrite_rule($page_slug . '([^/]{1,3})/([^/]*)/page/([0-9]+)/?$', 'index.php?page_id=' . self::$_options['property_details_page_id'] . '&property_state=$matches[1]&property_city=$matches[2]&paged=$matches[3]', 'top');
     add_rewrite_rule($page_slug . '([^/]{1,3})/page/([0-9]+)/?$', 'index.php?page_id=' . self::$_options['property_details_page_id'] . '&property_state=$matches[1]&paged=$matches[2]', 'top');
     add_rewrite_rule($page_slug . '([^/]{1,3})/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([\\d]*)/?$', 'index.php?page_id=' . self::$_options['property_details_page_id'] . '&property_state=$matches[1]&property_city=$matches[2]&property_zip=$matches[3]&property_id=$matches[4]&property_address=$matches[5]&property_price=$matches[6]', 'top');
     add_rewrite_rule($page_slug . '([^/]{1,3})/([^/]*)/([^/]*)/([^/]*)/([^/]*)/?$', 'index.php?page_id=' . self::$_options['property_details_page_id'] . '&property_state=$matches[1]&property_city=$matches[2]&property_zip=$matches[3]&property_id=$matches[4]&property_address=$matches[5]', 'top');
     add_rewrite_rule($page_slug . '([^/]{1,3})/([^/]*)/([^/]*)/([^/]*)/?$', 'index.php?page_id=' . self::$_options['property_details_page_id'] . '&property_state=$matches[1]&property_city=$matches[2]&property_zip=$matches[3]&property_id=$matches[4]', 'top');
     add_rewrite_rule($page_slug . '([^/]{1,3})/([^/]*)/([^/]*)/?$', 'index.php?page_id=' . self::$_options['property_details_page_id'] . '&property_state=$matches[1]&property_city=$matches[2]&property_zip=$matches[3]', 'top');
     add_rewrite_rule($page_slug . '([^/]{1,3})/([^/]*)/?$', 'index.php?page_id=' . self::$_options['property_details_page_id'] . '&property_state=$matches[1]&property_city=$matches[2]', 'top');
     add_rewrite_rule($page_slug . '([^/]{1,3})/?$', 'index.php?page_id=' . self::$_options['property_details_page_id'] . '&property_state=$matches[1]', 'top');
     if ($search_slug === 'search/' && $search_slug !== $page_slug) {
         add_rewrite_rule($search_slug . 'page/([0-9]+)/?$', 'index.php?page_id=' . self::$_options['search_results_page_id'] . '&paged=$matches[1]', 'top');
     }
     add_rewrite_rule('rets-mobile/([^/]{1,3})/?([^/]*)/?([^/]*)/?([^/]*)/?([^/]*)/?([\\d]*)/?$', 'index.php?post_type=rets-mobile&property_state=$matches[1]&property_city=$matches[2]&property_zip=$matches[3]&property_id=$matches[4]&property_address=$matches[5]&property_price=$matches[6]', 'top');
     add_rewrite_rule('displet-property-update/([^/]+)/?([^/]*)/?$', 'index.php?property_update_id=$matches[1]&re_user_login=$matches[2]', 'top');
 }
function swsctp_handle_custompage_route()
{
    add_rewrite_rule('instructor-class-list(/page/([^/]+))?', 'index.php?class_list_var=1&page=$matches[2]', 'top');
    add_rewrite_rule('instructor-class-list/', 'index.php?class_list_var=1', 'top');
    add_rewrite_rule('event/([^/]*)/inst-view/?', 'index.php?post_type=tribe_events&name=$matches[1]&inst_view=1', 'top');
    flush_rewrite_rules();
}
Example #11
0
	public function init() {
		
		global $wpdb, $facebook;
		
		$_options = get_option('site-member-settings');

		foreach (self::rewrite() as $rule => $rewrite) {
	        add_rewrite_rule( $rule,$rewrite, 'top' );
	    }
	    
	    
	  
		add_filter('template_include', array( 'site_members', 'template_include' ),1,1);  
		//add_filter('template_redirect', array( 'site_members', 'template_include' ));  
		
		add_filter( 'query_vars', array( 'site_members', 'prefix_register_query_var'));
		account::ajax_init();
		
		if(!class_exists('Facebook')){
			require(MEMBERS_DIR_PLUG.'/ext/facebook-sdk/facebook.php');
		}
		
		$facebook = new Facebook(array(
		  'appId' => $_options['api_facebook_appID'],
		  'secret' => $_options['api_facebook_appSecret'],
		));
	}
Example #12
0
function session_check_rules()
{
    flush_rewrite_rules();
    add_rewrite_rule("sso-session/([^&]+)/([^&]+)/?", 'index.php?broker_key=$matches[1]&broker_email=$matches[2]', "top");
    add_rewrite_rule("sso-login/([^&]+)/([^&]+)/?", 'index.php?sso_session=$matches[1]&sso_redirect=$matches[2]', "top");
    add_rewrite_rule("sso-logout/([^&]+)/([^&]+)/?", 'index.php?broker_key=$matches[1]', "top");
}
Example #13
0
 function init()
 {
     /*
      * Add custom querystring variables and rewrite rules.
      * @todo: is this really necessary?
      */
     add_rewrite_tag('%wpt_month%', '.*');
     add_rewrite_tag('%wpt_day%', '.*');
     add_rewrite_tag('%wpt_category%', '.*');
     /*
      * Update the rewrite rules for the listings pages.
      * {listing_page}/today 
      * {listing_page}/tomorrow
      * {listing_page}/yesterday
      */
     if ($page = $this->page()) {
         $post_name = $page->post_name;
         // <listing_page>/2014/05
         add_rewrite_rule($post_name . '/([0-9]{4})/([0-9]{2})$', 'index.php?pagename=' . $post_name . '&wpt_month=$matches[1]-$matches[2]', 'top');
         // <listing_page>/2014/05/06
         add_rewrite_rule($post_name . '/([0-9]{4})/([0-9]{2})/([0-9]{2})$', 'index.php?pagename=' . $post_name . '&wpt_day=$matches[1]-$matches[2]-$matches[3]', 'top');
         // <listing_page>/comedy
         add_rewrite_rule($post_name . '/([a-z0-9-]+)$', 'index.php?pagename=' . $post_name . '&wpt_category=$matches[1]', 'top');
         // <listing_page>/comedy/2014/05
         add_rewrite_rule($post_name . '/([a-z0-9-]+)/([0-9]{4})/([0-9]{2})$', 'index.php?pagename=' . $post_name . '&wpt_category=$matches[1]&wpt_month=$matches[2]-$matches[3]', 'top');
         // <listing_page>/comedy/2014/05/06
         add_rewrite_rule($post_name . '/([a-z0-9-]+)/([0-9]{4})/([0-9]{2})/([0-9]{2})$', 'index.php?pagename=' . $post_name . '&wpt_category=$matches[1]&wpt_day=$matches[2]-$matches[3]-$matches[4]', 'top');
     }
 }
Example #14
0
function purely_penzance_rewrite()
{
    global $wp_rewrite;
    $wp_rewrite->add_permastruct('typename', 'typename/ â–¶ %year%/%postname%/', true, 1);
    add_rewrite_rule('typename/([0-9]{4})/(.+)/?$', 'index.php?typename=$matches[2]', 'top');
    $wp_rewrite->flush_rules();
}
 /**
  * Setup permalink structure for learner profiles
  * @since  1.4.0
  * @return void
  */
 public function setup_permastruct()
 {
     if (isset(Sensei()->settings->settings['learner_profile_enable']) && Sensei()->settings->settings['learner_profile_enable']) {
         add_rewrite_rule('^' . $this->profile_url_base . '/([^/]*)/?', 'index.php?learner_profile=$matches[1]', 'top');
         add_rewrite_tag('%learner_profile%', '([^&]+)');
     }
 }
Example #16
0
 /**
  * Add endpoints for the API
  *
  * @uses "init" action
  */
 public function add_endpoints()
 {
     //add "action" as a rewrite tag
     add_rewrite_tag('%action%', '^[a-z0-9_\\-]+$');
     //add the endpoint
     add_rewrite_rule('lasso-internal-api/^[a-z0-9_\\-]+$/?', 'index.php?action=$matches[1]', 'top');
 }
Example #17
0
 public function add_rewrite_rules()
 {
     $pages = get_pages(array('meta_key' => '_wp_page_template', 'meta_value' => 'page-ranking.php'));
     foreach ($pages as $page) {
         $url_endpoint = get_permalink($page->ID);
         $url_endpoint = parse_url($url_endpoint);
         $url_endpoint = ltrim($url_endpoint['path'], '/');
         $rule = '^' . $url_endpoint . '([^/]*)?/?([^/]*)?/?([^/]*)?/?';
         $page = 'index.php?page_id=' . $page->ID . '&league=$matches[1]&season=$matches[2]&game_day=$matches[3]';
         add_rewrite_rule($rule, $page, 'top');
     }
     $pages = get_pages(array('meta_key' => '_wp_page_template', 'meta_value' => 'page-club.php'));
     foreach ($pages as $page) {
         $url_endpoint = get_permalink($page->ID);
         $url_endpoint = parse_url($url_endpoint);
         $url_endpoint = ltrim($url_endpoint['path'], '/');
         $rule = '^' . $url_endpoint . '([^/]*)?/?';
         $page = 'index.php?page_id=' . $page->ID . '&club=$matches[1]';
         add_rewrite_rule($rule, $page, 'top');
     }
     $pages = get_pages(array('meta_key' => '_wp_page_template', 'meta_value' => 'page-schedule.php'));
     foreach ($pages as $page) {
         $url_endpoint = get_permalink($page->ID);
         $url_endpoint = parse_url($url_endpoint);
         $url_endpoint = ltrim($url_endpoint['path'], '/');
         $rule = '^' . $url_endpoint . '([^/]*)?/?([^/]*)?/?';
         $page = 'index.php?page_id=' . $page->ID . '&league=$matches[1]&season=$matches[2]';
         add_rewrite_rule($rule, $page, 'top');
     }
     flush_rewrite_rules(true);
 }
Example #18
0
 function add_endpoint()
 {
     # Custom variables
     add_rewrite_tag('%action_api%', '([^&]+)');
     add_rewrite_tag('%token_api%', '([0-9]+)');
     add_rewrite_rule('^API/([^&]+)/([^&]+)/?', 'index.php?action_api=$matches[1]&token_api=$matches[2]', 'top');
 }
Example #19
0
function add_location_to_directory_cat()
{
    global $wp, $wp_rewrite;
    $wp->add_query_var('directory_location');
    add_rewrite_rule('directory-category/([^/]+)/location/([^/]+)?$', 'index.php?directory_category=$matches[1]&directory_location=$matches[2]', 'top');
    add_rewrite_rule('directory-category/([^/]+)/location/([^/]+)/page/([0-9]+)?$', 'index.php?directory_category=$matches[1]&directory_location=$matches[2]&paged=$matches[3]', 'top');
}
Example #20
0
 public static function init()
 {
     global $wp_rewrite;
     $post_types = apply_filters('cpt_apd_list', get_post_types(array('exclude_from_search' => false)));
     foreach ($post_types as $post_type) {
         //Exclude Attachment
         if ($post_type === 'attachment') {
             continue;
         }
         // Get prefix CPT
         $cpt_obj = get_post_type_object($post_type);
         $cpt_query_var = $cpt_obj->query_var;
         if (!empty($cpt_obj->has_archive) && $cpt_obj->has_archive !== true) {
             $cpt_query_var = $cpt_obj->has_archive;
         }
         add_rewrite_rule($wp_rewrite->root . $cpt_query_var . "/([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/feed/(feed|rdf|rss|rss2|atom)/?\$", 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&feed=$matches[4]' . '&post_type=' . $post_type, 'top');
         add_rewrite_rule($wp_rewrite->root . $cpt_query_var . "/([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/(feed|rdf|rss|rss2|atom)/?\$", 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&feed=$matches[4]' . '&post_type=' . $post_type, 'top');
         add_rewrite_rule($wp_rewrite->root . $cpt_query_var . "/([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/page/?([0-9]{1,})/?\$", 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&paged=$matches[4]' . '&post_type=' . $post_type, 'top');
         add_rewrite_rule($wp_rewrite->root . $cpt_query_var . "/([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/?\$", 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]' . '&post_type=' . $post_type, 'top');
         add_rewrite_rule($wp_rewrite->root . $cpt_query_var . "/([0-9]{4})/([0-9]{1,2})/feed/(feed|rdf|rss|rss2|atom)/?\$", 'index.php?year=$matches[1]&monthnum=$matches[2]&feed=$matches[3]' . '&post_type=' . $post_type, 'top');
         add_rewrite_rule($wp_rewrite->root . $cpt_query_var . "/([0-9]{4})/([0-9]{1,2})/(feed|rdf|rss|rss2|atom)/?\$", 'index.php?year=$matches[1]&monthnum=$matches[2]&feed=$matches[3]' . '&post_type=' . $post_type, 'top');
         add_rewrite_rule($wp_rewrite->root . $cpt_query_var . "/([0-9]{4})/([0-9]{1,2})/page/?([0-9]{1,})/?\$", 'index.php?year=$matches[1]&monthnum=$matches[2]&paged=$matches[3]' . '&post_type=' . $post_type, 'top');
         add_rewrite_rule($wp_rewrite->root . $cpt_query_var . "/([0-9]{4})/([0-9]{1,2})/?\$", 'index.php?year=$matches[1]&monthnum=$matches[2]' . '&post_type=' . $post_type, 'top');
         add_rewrite_rule($wp_rewrite->root . $cpt_query_var . "/([0-9]{4})/feed/(feed|rdf|rss|rss2|atom)/?\$", 'index.php?year=$matches[1]&feed=$matches[2]' . '&post_type=' . $post_type, 'top');
         add_rewrite_rule($wp_rewrite->root . $cpt_query_var . "/([0-9]{4})/(feed|rdf|rss|rss2|atom)/?\$", 'index.php?year=$matches[1]&feed=$matches[2]' . '&post_type=' . $post_type, 'top');
         add_rewrite_rule($wp_rewrite->root . $cpt_query_var . "/([0-9]{4})/page/?([0-9]{1,})/?\$", 'index.php?year=$matches[1]&paged=$matches[2]' . '&post_type=' . $post_type, 'top');
         add_rewrite_rule($wp_rewrite->root . $cpt_query_var . "/([0-9]{4})/?\$", 'index.php?year=$matches[1]' . '&post_type=' . $post_type, 'top');
     }
 }
Example #21
0
 public static function activate_site()
 {
     global $wpdb;
     $charset_collate = '';
     if (!empty($wpdb->charset)) {
         $charset_collate = "DEFAULT CHARACTER SET {$wpdb->charset}";
     }
     if (!empty($wpdb->collate)) {
         $charset_collate .= " COLLATE {$wpdb->collate}";
     }
     $tables = AmberInstall::get_tables();
     require_once ABSPATH . 'wp-admin/includes/upgrade.php';
     foreach ($tables as $name => $table) {
         $table_name = $wpdb->prefix . $name;
         $sql = "CREATE TABLE {$table_name} {$table} {$charset_collate}";
         dbDelta($sql);
     }
     $options = get_option('amber_options');
     if (empty($options)) {
         /* Set default options */
         $options = array('amber_max_file' => 1000, 'amber_max_disk' => 1000, 'amber_available_action' => AMBER_ACTION_NONE, 'amber_unavailable_action' => AMBER_ACTION_HOVER, 'amber_available_action_hover' => 2, 'amber_unavailable_action_hover' => 2, 'amber_storage_location' => 'amber', 'amber_update_strategy' => 0, 'amber_country_id' => '', 'amber_excluded_sites' => parse_url(home_url(), PHP_URL_HOST));
         update_option('amber_options', $options);
     }
     /* The hook name needs to be a string, it can't be a reference to a class function */
     if (!wp_next_scheduled('amber_cron_event_hook')) {
         wp_schedule_event(time(), 'fiveminutes', 'amber_cron_event_hook');
     }
     add_rewrite_rule('^.*amber/cache/([a-f0-9]+)/?$', '/index.php?amber_cache=$1', "top");
     add_rewrite_rule('^.*amber/cacheframe/([a-f0-9]+)/?$', '/index.php?amber_cacheframe=$1', "top");
     add_rewrite_rule('^.*amber/cacheframe/([a-f0-9]+)/assets/(.*)/?$', '/index.php?amber_cacheframe=$1&amber_asset=$2', "top");
     flush_rewrite_rules();
 }
Example #22
0
function thirstyRegisterPostType()
{
    $thirstyOptions = get_option('thirstyOptions');
    $slug = thirstyGetCurrentSlug();
    /* Register the taxonomy for the affiliate links */
    register_taxonomy('thirstylink-category', 'thirstylink', array('labels' => array('name' => __('Link Categories', 'thirstyaffiliates'), 'singular_name' => __('Link Category', 'thirstyaffiliates')), 'public' => true, 'show_ui' => true, 'hierarchical' => true, 'show_tagcloud' => false, 'rewrite' => false));
    /* Register the post type */
    register_post_type('thirstylink', array('labels' => array('name' => __('Affiliate Links', 'thirstyaffiliates'), 'singular_name' => __('Affiliate Link', 'thirstyaffiliates'), 'add_new_item' => __('Add New Affiliate Link', 'thirstyaffiliates'), 'edit_item' => __('Edit Affiliate Link', 'thirstyaffiliates'), 'view_item' => __('View Affiliate Link', 'thirstyaffiliates'), 'search_items' => __('Search Affiliate Links', 'thirstyaffiliates'), 'not_found' => __('No Affiliate Links found!', 'thirstyaffiliates'), 'not_found_in_trash' => __('No Affiliate Links found in trash', 'thirstyaffiliates'), 'menu_name' => __('Affiliate Links', 'thirstyaffiliates'), 'all_items' => __('All Affiliate Links', 'thirstyaffiliates')), 'description' => __('ThirstyAffiliates affiliate links', 'thirstyaffiliates'), 'public' => true, 'menu_position' => 20, 'hierarchical' => true, 'supports' => array('title' => false, 'editor' => false, 'author' => false, 'thumbnail' => false, 'excerpt' => false, 'trackbacks' => false, 'comments' => false, 'revisions' => false, 'page-attributes' => false, 'post-formats' => false), 'show_in_menu' => true, 'show_in_nav_menus' => true, 'can_export' => true, 'has_archive' => false, 'rewrite' => array('slug' => $slug, 'with_front' => false, 'pages' => false), 'menu_icon' => plugins_url('thirstyaffiliates/images/icon-aff.png'), 'exclude_from_search' => true));
    add_rewrite_tag('%' . $slug . '%', '([^&]+)');
    if (!empty($thirstyOptions['showcatinslug']) && $thirstyOptions['showcatinslug'] == 'on') {
        add_rewrite_tag('%thirstylink-category%', '([^&]+)');
        add_rewrite_rule("{$slug}/([^/]+)?/?\$", 'index.php?thirstylink=$matches[1]', 'top');
        // 2.4.5: still match links that don't have category in the url
        add_rewrite_rule("{$slug}/([^/]+)?/?([^/]+)?/?", 'index.php?thirstylink=$matches[2]&thirstylink-category=$matches[1]', 'top');
    }
    /* Set the list page columns */
    //custom code add filter and action to display 2nd dest link in listing page
    add_filter('manage_thirstylink_posts_columns', 'thirstyAddDestinationColumnToList');
    add_filter('manage_thirstylink_posts_columns', 'thirstyAdd2ndDestinationColumnToList');
    add_filter('manage_thirstylink_posts_columns', 'thirstyAddCategoryColumnToList');
    add_action('manage_pages_custom_column', 'thirstyShowCategoryColumnInList');
    add_action('manage_pages_custom_column', 'thirstyShowDestinationColumnInList');
    add_action('manage_pages_custom_column', 'thirstyShow2ndDestinationColumnInList');
    /* Setup the filter drop down */
    add_action('restrict_manage_posts', 'thirstyRestrictLinksByCategory');
    add_filter('parse_query', 'thirstyConvertLinkCatIdToSlugInQuery');
}
 public function _do_rewrite()
 {
     //        add_rewrite_tag('%ucm_faq%','([^&]+)');
     //        add_rewrite_rule('support/faq-knowledge-base/faq_item/faq-([^/]*)$','index.php?pagename=faq-item&ucm_faq=$matches[1]','top');
     global $wp, $wp_rewrite;
     $rule = '.*faq-item/(\\d+)/.*';
     //        if(!isset($wp_rewrite->rules[$rule]) && !isset($wp_rewrite->extra_rules_top[$rule])){
     //        $wp->add_query_var('ucm_faq_id');
     //        echo get_permalink(get_queried_object_id());exit;
     //$page = get_page_by_path('faq-item');print_r($page);exit;
     //            print_r($wp_rewrite->rules);
     //            print_r($wp_rewrite->extra_rules_top);
     $args = array('name' => 'faq-item', 'post_type' => 'page');
     $posts_from_slug = get_posts($args);
     // echo fetched content
     //print_r($posts_from_slug[0]);exit;
     add_rewrite_rule($rule, 'index.php?page_id=' . $posts_from_slug[0]->ID . '&ucm_faq_id=$matches[1]', 'top');
     //$wp_rewrite->add_rule('.*faq-item/faq-(\d+)/', 'index.php?ucm_faq_id=$matches[1]&name=faq-item', 'top');
     // Once you get working, remove this next line
     //            $wp_rewrite->flush_rules(false);
     //            echo "Added rule!";exit;
     //        }
     if (isset($_REQUEST['dtbakerdebug'])) {
         global $wp_rewrite, $wp;
         print_r($wp_rewrite);
         print_r($wp);
     }
 }
 function custom_admin_url()
 {
     if (isset($_POST['custom_wpadmin_slug'])) {
         // sanitize input
         $wpadmin_slug = trim(sanitize_key(wp_strip_all_tags($_POST['custom_wpadmin_slug'])));
         $home_path = get_home_path();
         // check if permalinks are turned off, if so force push rules to .htaccess
         if (isset($_POST['selection']) && $_POST['selection'] == '' && $wpadmin_slug != '') {
             // check if .htaccess is writable
             if (!file_exists($home_path . '.htaccess') && is_writable($home_path) || is_writable($home_path . '.htaccess')) {
                 // taken from wp-includes/rewrite.php
                 $home_root = parse_url(home_url());
                 if (isset($home_root['path'])) {
                     $home_root = trailingslashit($home_root['path']);
                 } else {
                     $home_root = '/';
                 }
                 // create rules
                 $rules = "<IfModule mod_rewrite.c>\n";
                 $rules .= "RewriteEngine On\n";
                 $rules .= "RewriteRule ^{$wpadmin_slug}/?\$ " . $home_root . "wp-login.php [QSA,L]\n";
                 $rules .= "</IfModule>";
                 // write to .htaccess
                 insert_with_markers($home_path . '.htaccess', 'WPAdminURL', explode("\n", $rules));
             }
         } else {
             if (isset($_POST['selection']) || isset($_POST['selection']) && $_POST['selection'] == '' && $wpadmin_slug == '') {
                 // remove rules if permalinks were enabled
                 $markerdata = explode("\n", implode('', file($home_path . '.htaccess')));
                 $found = false;
                 $newdata = '';
                 foreach ($markerdata as $line) {
                     if ($line == '# BEGIN WPAdminURL') {
                         $found = true;
                     }
                     if (!$found) {
                         $newdata .= "{$line}\n";
                     }
                     if ($line == '# END WPAdminURL') {
                         $found = false;
                     }
                 }
                 // write back
                 $f = @fopen($home_path . '.htaccess', 'w');
                 fwrite($f, $newdata);
             }
         }
         // save to db
         update_option('custom_wpadmin_slug', $wpadmin_slug);
         // write rewrite rules right away
         if ($wpadmin_slug != '') {
             add_rewrite_rule($wpadmin_slug . '/?$', 'wp-login.php', 'top');
         } else {
             flush_rewrite_rules();
         }
     }
     add_settings_field('custom_wpadmin_slug', 'WP-Admin slug', array($this, 'options_page'), 'permalink', 'optional', array('label_for' => 'custom_wpadmin_slug'));
     register_setting('permalink', 'custom_wpadmin_slug', 'strval');
 }
Example #25
0
 /**
  * add_endpoint function.
  *
  * @access public
  * @since 2.0
  * @return void
  */
 public function add_endpoint()
 {
     // REST API
     add_rewrite_rule('^wc-api\\/v' . self::VERSION . '/?$', 'index.php?wc-api-route=/', 'top');
     add_rewrite_rule('^wc-api\\/v' . self::VERSION . '(.*)?', 'index.php?wc-api-route=$matches[1]', 'top');
     // legacy API for payment gateway IPNs
     add_rewrite_endpoint('wc-api', EP_ALL);
 }
Example #26
0
 public function initRewriteRule()
 {
     add_rewrite_rule('^minecraftjp/(.*)?', 'index.php?minecraftjp_action=$matches[1]', 'top');
     if (Configure::read('rewrite_version') < self::REWRITE_VERSION) {
         flush_rewrite_rules();
         Configure::write('rewrite_version', self::REWRITE_VERSION);
     }
 }
Example #27
0
 /**
  * We're not using a true endpoint permalink, since that registers the rewrite rule
  * too far down the rewrite hierarchy; functionally, it's the same, though.
  *
  * @since 0.1
  */
 public function register_endpoint()
 {
     global $wp;
     $wp->add_query_var('seoslides-embed');
     $wp->add_query_var('seoslides-embed-slide');
     add_rewrite_rule('^embed-script/([^/]+)(/(.*))?/?$', 'index.php?seoslides-slideset=$matches[1]&seoslides-embed-slide=$matches[3]&seoslides-embed=script', 'top');
     add_rewrite_rule('^embeds/([^/]+)(/(.*))?/?$', 'index.php?seoslides-slideset=$matches[1]&seoslides-embed-slide=$matches[3]&seoslides-embed=1', 'top');
 }
Example #28
0
 function init()
 {
     add_rewrite_tag('%' . AJAXFLOW_TAG . '%', '([^&]+)');
     add_rewrite_rule(AJAXFLOW_TAG . '/(.+?)/?$', 'index.php?' . AJAXFLOW_TAG . '=$matches[1]', 'top');
     if (isset($_REQUEST['q']) && strpos($_REQUEST['q'], AJAXFLOW_TAG) == 1) {
         $this->ajax(str_replace('/' . AJAXFLOW_TAG . '/', '', $_REQUEST['q']));
     }
 }
	public static function cppp_add_rewrites()
	{
		add_rewrite_rule(
			'^printpage/?([0-9]*)/([a-z0-9]*)/?$',
			'index.php?cppp_post_id=$matches[1]&cppp_nonce=$matches[2]',
			'top'
		);
	}
Example #30
0
 /**
  * add_endpoint function.
  *
  * @access public
  * @since 2.0
  * @return void
  */
 public static function add_endpoint()
 {
     // REST API
     add_rewrite_rule('^wc-api/v([1-2]{1})/?$', 'index.php?wc-api-version=$matches[1]&wc-api-route=/', 'top');
     add_rewrite_rule('^wc-api/v([1-2]{1})(.*)?', 'index.php?wc-api-version=$matches[1]&wc-api-route=$matches[2]', 'top');
     // WC API for payment gateway IPNs, etc
     add_rewrite_endpoint('wc-api', EP_ALL);
 }