当前位置: 首页>>代码示例>>PHP>>正文


PHP add_rewrite_rule函数代码示例

本文整理汇总了PHP中add_rewrite_rule函数的典型用法代码示例。如果您正苦于以下问题:PHP add_rewrite_rule函数的具体用法?PHP add_rewrite_rule怎么用?PHP add_rewrite_rule使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了add_rewrite_rule函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: register_rule

 /**
  * 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');
 }
开发者ID:nuwe1,项目名称:dokan-lite,代码行数:31,代码来源:rewrites.php

示例2: init

 /**
  * 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');
 }
开发者ID:robjcordes,项目名称:nexnewwp,代码行数:10,代码来源:class-sitemaps.php

示例3: create_main_route

 /**
  * 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');
 }
开发者ID:roccotripaldi,项目名称:pingopongo,代码行数:10,代码来源:class.pingopongo.php

示例4: skelet_add_endpoint

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');
    }
}
开发者ID:kadimi,项目名称:external_slugified_thumbnails,代码行数:7,代码来源:core-shortcodes.php

示例5: register_rule

 /**
  * 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');
 }
开发者ID:CPHollister,项目名称:shyftmodels,代码行数:37,代码来源:rewrites.php

示例6: setup_rewrite

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');
                    }
                }
            }
        }
    }
}
开发者ID:synapticism,项目名称:ubik,代码行数:31,代码来源:views.php

示例7: add_endpoint

 /**
  * 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);
 }
开发者ID:bself,项目名称:nuimage-wp,代码行数:13,代码来源:class-fue-api.php

示例8: rewrite_rules

 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);
     }
 }
开发者ID:g14studio,项目名称:hmo,代码行数:32,代码来源:class.carrental.php

示例9: generate_rewrite_rules

 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');
 }
开发者ID:amankatoch,项目名称:wp-plugin,代码行数:28,代码来源:class-displet-rets-idx-rewrite-model.php

示例10: swsctp_handle_custompage_route

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();
}
开发者ID:csteines,项目名称:Complete-Training-Plugin,代码行数:7,代码来源:instructor-functions.php

示例11: init

	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'],
		));
	}
开发者ID:xyren,项目名称:Site-Membership,代码行数:27,代码来源:init.php

示例12: session_check_rules

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");
}
开发者ID:jontroth,项目名称:sso-passport,代码行数:7,代码来源:sso-passport.php

示例13: init

 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');
     }
 }
开发者ID:Tibwo,项目名称:wp-theatre,代码行数:29,代码来源:wpt_listing_page.php

示例14: purely_penzance_rewrite

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();
}
开发者ID:heffy,项目名称:wp-business,代码行数:7,代码来源:wp-business-cpt.php

示例15: setup_permastruct

 /**
  * 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%', '([^&]+)');
     }
 }
开发者ID:pra85,项目名称:sensei,代码行数:12,代码来源:class-sensei-learner-profiles.php


注:本文中的add_rewrite_rule函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。