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


PHP add_rewrite_tag函数代码示例

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


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

示例1: 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

示例2: add_endpoint

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

示例3: thirstyRegisterPostType

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');
}
开发者ID:linhtrinh,项目名称:MyCode,代码行数:27,代码来源:thirstyaffiliates.php

示例4: authorRewriteRules

 /**
  * Change the 'author' slug from the URL base (for each author) to the type of User.
  *
  * Remeber: Manually flush your permalink structure to reflect these changes:
  * 1) Settings -> Permalinks -> choose default -> Save
  * 2) Revert the settings to original.
  */
 protected static function authorRewriteRules()
 {
     $AUTHOR_TYPE = '%author_type%';
     add_action('init', function () use($AUTHOR_TYPE) {
         global $wp_rewrite;
         $authorLevels = User::getValidTypes();
         // Define the tag and use it in the rewrite rule
         add_rewrite_tag($AUTHOR_TYPE, '(' . implode('|', $authorLevels) . ')');
         $wp_rewrite->author_base = $AUTHOR_TYPE;
     });
     add_filter('author_rewrite_rules', function ($author_rewrite_rules) {
         foreach ($author_rewrite_rules as $pattern => $substitution) {
             if (false === strpos($substitution, 'author_name')) {
                 unset($author_rewrite_rules[$pattern]);
             }
         }
         return $author_rewrite_rules;
     });
     add_filter('author_link', function ($link, $author_id) use($AUTHOR_TYPE) {
         $user = User::find($author_id);
         if (!$user) {
             return;
         }
         return str_replace($AUTHOR_TYPE, $user->getType(), $link);
     }, 100, 2);
 }
开发者ID:NuevaMetal,项目名称:nuevametal-template,代码行数:33,代码来源:Filters.php

示例5: 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

示例6: add_endpoints

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

示例7: _action_init_permalinks

 public function _action_init_permalinks($args)
 {
     add_rewrite_tag('%wpsc_min_price%', '([\\d\\.]+)', 'post_type=wpsc-product&wpsc_min_price=');
     add_rewrite_tag('%wpsc_max_price%', '([\\d\\.]+)', 'wpsc_max_price=');
     add_permastruct('wpsc_price_range', $args['has_archive'] . '/%wpsc_min_price%/%wpsc_max_price%', array());
     return $args;
 }
开发者ID:RJHanson292,项目名称:WP-e-Commerce,代码行数:7,代码来源:price-range.php

示例8: 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

示例9: mp_stacks_rewrite_tags

/**
 * Add Rewrite Tags for MP Stacks
 * Parameter: $rules the current rewrite rules from WP
 */
function mp_stacks_rewrite_tags()
{
    add_rewrite_tag('%mp_stack_only_page%', '([^/]*)');
    add_rewrite_tag('%mp_stacks_page_slug%', '([^/]*)');
    add_rewrite_tag('%mp_brick_pagination_slugs%', '([^/]*)');
    add_rewrite_tag('%mp_brick_pagination_page_numbers%', '([^/]*)');
}
开发者ID:arrezende,项目名称:promillus,代码行数:11,代码来源:stack-only-page.php

示例10: add_rewrite_tags

 function add_rewrite_tags()
 {
     add_rewrite_tag('%' . self::ARG_API . '%', 'true');
     add_rewrite_tag('%' . self::ARG_LICENSE . '%', '([^&]+)');
     add_rewrite_tag('%' . self::ARG_ACTION . '%', '([^&]+)');
     add_rewrite_tag('%' . self::ARG_ARGS . '%', '([^&]+)');
 }
开发者ID:brianlayman,项目名称:fooLicensing,代码行数:7,代码来源:rewrite_rules.php

示例11: admin_init

 /**
  *
  * @from 1.0
  */
 function admin_init()
 {
     add_rewrite_tag('%nodepage_type%', '([^&]+)');
     add_rewrite_tag('%nodepage_parent%', '([^&]+)');
     add_rewrite_tag('%nodepage_path%', '([^&]+)');
     add_rewrite_tag('%nodepage%', '([^&]+)');
 }
开发者ID:Blueprint-Marketing,项目名称:sublanguage,代码行数:11,代码来源:admin-pagenode.php

示例12: 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

示例13: jeg_post_type_portfolio

function jeg_post_type_portfolio()
{
    $args = array('labels' => array('name' => 'Portfolio', 'singular_name' => 'Portfolio Item', 'add_new' => 'Add Portfolio', 'add_new_item' => 'Add Portfolio', 'edit_item' => 'Edit Portfolio', 'new_item' => 'New Portfolio', 'view_item' => 'View Item', 'search_items' => 'Search Portfolio Items', 'not_found' => 'No portfolio items found', 'not_found_in_trash' => 'No portfolio items found in Trash', 'parent_item_colon' => ''), 'description' => 'Portfolio Post type', 'public' => true, 'show_ui' => true, 'menu_icon' => get_template_directory_uri() . '/public/img/portfolio.png', 'menu_position' => 6, 'capability_type' => 'post', 'hierarchical' => false, 'supports' => array('title', 'editor', 'comments', 'page-attributes'), 'rewrite' => array('slug' => '%portfolio_page%', 'with_front' => true), 'taxonomies' => array(JEG_PORTFOLIO_CATEGORY));
    register_post_type(JEG_PORTFOLIO_POST_TYPE, $args);
    add_rewrite_tag('%portfolio%', '([^/]+)');
    add_permastruct('portfolio', '%portfolio_page%/%portfolio%/', false);
}
开发者ID:OpenDoorBrewCo,项目名称:odbc-wp-prod,代码行数:7,代码来源:post-type.php

示例14: shopp_register_collection

/**
 * Registers a smart collection of products
 *
 * @api
 * @since 1.2
 *
 * @param string $name Class name of the smart collection
 * @return void
 **/
function shopp_register_collection($name = '')
{
    if (empty($name)) {
        shopp_debug(__FUNCTION__ . " failed: Collection name required.");
        return false;
    }
    $Shopp = Shopp::object();
    $namespace = apply_filters('shopp_smart_collections_slug', SmartCollection::$namespace);
    $permastruct = SmartCollection::$taxon;
    $slugs = SmartCollection::slugs($name);
    $slug = $slugs[0];
    $Shopp->Collections[$slug] = $name;
    do_action('shopp_register_collection', $name, $slug);
    $slugs = SmartCollection::slugs($name);
    add_rewrite_tag("%{$permastruct}%", "([^/]+)");
    add_permastruct($permastruct, ShoppPages()->baseslug() . "/{$namespace}/%shopp_collection%", false);
    add_filter($permastruct . '_rewrite_rules', array('ProductCollection', 'pagerewrites'));
    $apicall = create_function('$result, $options, $O', 'ShoppCollection( new ' . $name . '($options) );
		return ShoppStorefrontThemeAPI::category($result, $options, $O);');
    foreach ((array) $slugs as $collection) {
        $collection = str_replace(array('-', '_'), '', $collection);
        // Sanitize slugs
        add_filter('shopp_themeapi_storefront_' . $collection . 'products', $apicall, 10, 3);
        // @deprecated
        add_filter('shopp_themeapi_storefront_' . $collection . 'collection', $apicall, 10, 3);
    }
    // Add special default permalink handling for collection URLs (only add it once)
    global $wp_rewrite;
    if (!$wp_rewrite->using_permalinks() && false === has_filter('term_link', array('SmartCollection', 'defaultlinks'))) {
        add_filter('term_link', array('SmartCollection', 'defaultlinks'), 10, 3);
    }
}
开发者ID:forthrobot,项目名称:inuvik,代码行数:41,代码来源:collection.php

示例15: woocommerce_gpf_endpoints

/**
 * Bodge ffor WPEngine.com users - provide the feed at a URL that doesn't
 * rely on query arguments as WPEngine don't support URLs with query args
 * if the requestor is a googlebot. #broken
 */
function woocommerce_gpf_endpoints()
{
    add_rewrite_tag('%woocommerce_gpf%', '([^/]+)');
    add_rewrite_tag('%gpf_start%', '([0-9]{1,})');
    add_rewrite_tag('%gpf_limit%', '([0-9]{1,})');
    add_rewrite_rule('woocommerce_gpf/([^/]+)/gpf_start/([0-9]{1,})/gpf_limit/([0-9]{1,})', 'index.php?woocommerce_gpf=$matches[1]&gpf_start=$matches[2]&gpf_limit=$matches[3]', 'top');
    add_rewrite_rule('woocommerce_gpf/([^/]+)', 'index.php?woocommerce_gpf=$matches[1]', 'top');
}
开发者ID:jmead,项目名称:trucell-cms,代码行数:13,代码来源:woocommerce-gpf.php


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