Example #1
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 #2
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 #3
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');
}
 /**
  * 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);
 }
 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');
 }
Example #6
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');
 }
 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;
 }
 /**
  * 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 #9
0
/**
 * 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%', '([^/]*)');
}
 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 . '%', '([^&]+)');
 }
 /**
  *
  * @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%', '([^&]+)');
 }
Example #12
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 #13
0
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);
}
Example #14
0
/**
 * 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);
    }
}
Example #15
0
/**
 * 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');
}
Example #16
0
 public static function add_rewrite_rules()
 {
     if (self::is_webhooks_active()) {
         add_rewrite_tag('%mailchimp-sync%', '([^&]+)');
         add_rewrite_tag('%mckey%', '([^&]+)');
         add_rewrite_rule('^mailchimp-sync/([^/]*)$', 'index.php?mailchimp-sync=1&mckey=$matches[1]', 'top');
     }
 }
Example #17
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']));
     }
 }
 /**
  *
  * register_post_type_rules
  *  ** add rewrite tag for Custom Post Type.
  * @version 1.1
  * @since 0.9
  *
  * @param string $post_type
  * @param object $args
  *
  */
 public function register_post_type_rules($post_type, $args)
 {
     /** @var WP_Rewrite $wp_rewrite */
     global $wp_rewrite;
     if ($args->_builtin or !$args->publicly_queryable or !$args->show_ui) {
         return;
     }
     $permalink = CPTP_Util::get_permalink_structure($post_type);
     if (!$permalink) {
         $permalink = CPTP_DEFAULT_PERMALINK;
     }
     $permalink = '%' . $post_type . '_slug%' . $permalink;
     $permalink = str_replace('%postname%', '%' . $post_type . '%', $permalink);
     add_rewrite_tag('%' . $post_type . '_slug%', '(' . $args->rewrite['slug'] . ')', 'post_type=' . $post_type . '&slug=');
     $taxonomies = CPTP_Util::get_taxonomies(true);
     foreach ($taxonomies as $taxonomy => $objects) {
         $wp_rewrite->add_rewrite_tag("%{$taxonomy}%", '(.+?)', "{$taxonomy}=");
     }
     $rewrite_args = $args->rewrite;
     if (!is_array($rewrite_args)) {
         $rewrite_args = array('with_front' => $args->rewrite);
     }
     $slug = $args->rewrite['slug'];
     if ($args->has_archive) {
         if (is_string($args->has_archive)) {
             $slug = $args->has_archive;
         }
         if ($args->rewrite['with_front']) {
             $slug = substr($wp_rewrite->front, 1) . $slug;
         }
         $date_front = CPTP_Util::get_date_front($post_type);
         add_rewrite_rule($slug . $date_front . '/([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($slug . $date_front . '/([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($slug . $date_front . '/([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($slug . $date_front . '/([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($slug . $date_front . '/([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($slug . $date_front . '/([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($slug . $date_front . '/([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($slug . $date_front . '/([0-9]{4})/([0-9]{1,2})/?$', 'index.php?year=$matches[1]&monthnum=$matches[2]&post_type=' . $post_type, 'top');
         add_rewrite_rule($slug . $date_front . '/([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($slug . $date_front . '/([0-9]{4})/(feed|rdf|rss|rss2|atom)/?$', 'index.php?year=$matches[1]&feed=$matches[2]&post_type=' . $post_type, 'top');
         add_rewrite_rule($slug . $date_front . '/([0-9]{4})/page/?([0-9]{1,})/?$', 'index.php?year=$matches[1]&paged=$matches[2]&post_type=' . $post_type, 'top');
         add_rewrite_rule($slug . $date_front . '/([0-9]{4})/?$', 'index.php?year=$matches[1]&post_type=' . $post_type, 'top');
         add_rewrite_rule($slug . '/author/([^/]+)/page/?([0-9]{1,})/?$', 'index.php?author_name=$matches[1]&paged=$matches[2]&post_type=' . $post_type, 'top');
         add_rewrite_rule($slug . '/author/([^/]+)/?$', 'index.php?author_name=$matches[1]&post_type=' . $post_type, 'top');
         if (in_array('category', $args->taxonomies)) {
             $category_base = get_option('category_base');
             if (!$category_base) {
                 $category_base = 'category';
             }
             add_rewrite_rule($slug . '/' . $category_base . '/([^/]+)/page/?([0-9]{1,})/?$', 'index.php?category_name=$matches[1]&paged=$matches[2]&post_type=' . $post_type, 'top');
             add_rewrite_rule($slug . '/' . $category_base . '/([^/]+)/?$', 'index.php?category_name=$matches[1]&post_type=' . $post_type, 'top');
         }
         do_action('CPTP_registered_' . $post_type . '_rules', $args, $slug);
     }
     $rewrite_args['walk_dirs'] = false;
     add_permastruct($post_type, $permalink, $rewrite_args);
 }
Example #19
0
function custom_rewrite_basic()
{
    add_rewrite_tag('%slug-destino%', '([^/]*)');
    add_rewrite_tag('%puerto%', '([^/]*)');
    add_rewrite_rule('^destino/([^/]*)/([^/]*)/?', 'index.php?pagename=destino&slug-destino=$matches[1]&puerto=$matches[2]', 'top');
    add_rewrite_tag('%puerto%', '([^/]*)');
    add_rewrite_tag('%excursion%', '([^/]*)');
    add_rewrite_rule('^excursiones/([^/]*)/([^/]*)/?', 'index.php?pagename=excursiones&puerto=$matches[1]&excursion=$matches[2]', 'top');
}
 /**
  * Constructor
  */
 public function __construct()
 {
     $this->slug = WC_POS_Admin_Permalink::get_slug();
     $this->regex = '^' . $this->slug . '/?$';
     add_rewrite_tag('%pos%', '([^&]+)');
     add_rewrite_rule($this->regex, 'index.php?pos=1', 'top');
     add_filter('option_rewrite_rules', array($this, 'rewrite_rules'), 1);
     add_action('template_redirect', array($this, 'template_redirect'), 1);
 }
 /**
  *
  * @from 1.0
  */
 function admin_init()
 {
     add_rewrite_tag('%nodeterm_tax%', '([^&]+)');
     add_rewrite_tag('%nodeterm_ttax%', '([^&]+)');
     add_rewrite_tag('%nodeterm_parent%', '([^&]+)');
     add_rewrite_tag('%nodeterm_path%', '([^&]+)');
     add_rewrite_tag('%nodeterm_qv%', '([^&]+)');
     add_rewrite_tag('%nodeterm%', '([^&]+)');
 }
 public function register_rewrites()
 {
     $enabled = apply_filters('anyipsum-setting-is-enabled', false, 'anyipsum-settings-api', 'api-enabled');
     $endpoint = sanitize_key(apply_filters('anyipsum-setting-get', 'api', 'anyipsum-settings-api', 'api-endpoint'));
     if ($enabled && !empty($endpoint)) {
         add_rewrite_tag('%any-ipsum-api-request%', '1');
         add_rewrite_rule($endpoint . '?', 'index.php?any-ipsum-api-request=1', 'top');
     }
 }
Example #23
0
 public static function permalinks()
 {
     $var = ShoppPages::QUERYVAR;
     $pageslugs = ShoppPages()->slugs();
     $catalog = $pageslugs['catalog'];
     unset($pageslugs['catalog']);
     add_rewrite_tag("%{$var}%", '(' . join('|', $pageslugs) . ')');
     add_permastruct($var, "{$catalog}/%{$var}%", false);
 }
 static function rewrite_tags()
 {
     add_rewrite_tag('%media_id%', '([0-9]*)');
     add_rewrite_tag('%action%', '([^/]*)');
     add_rewrite_tag('%nonce_type%', '([^/]*)');
     add_rewrite_tag('%media_type%', '([A-Za-z]*)');
     add_rewrite_tag('%pg%', '([0-9]*)');
     do_action('rtmedia_add_rewrite_tags');
 }
Example #25
0
 public static function add_rewrite_rules()
 {
     add_rewrite_rule('^names/([0-9]+)/?$', 'index.php?pagename=names&wkw_pageid=$matches[1]', 'top');
     add_rewrite_rule('^names/(.*)/?$', 'index.php?pagename=names&wkw_name=$matches[1]', 'top');
     add_rewrite_tag('%wkw_pageid%', '[0-9]+');
     add_rewrite_tag('%wkw_search%', '(json|ical)');
     add_rewrite_tag('%wkw_cache%', '[0-9]{4}');
     add_rewrite_tag('%wkw_name%', '');
 }
Example #26
0
 public function rewrite()
 {
     global $wp_rewrite;
     add_rewrite_tag("%no-admin-ajax%", "([0-9]+)");
     // The whole ajax url matching pattern can be altered with filter "no-admin-ajax/rule"
     $default_rule = "^" . $this->keyword . "/?\$";
     $rule = apply_filters("no-admin-ajax/rule", $default_rule);
     add_rewrite_rule($rule, "index.php?no-admin-ajax=true", "top");
 }
 /**
  * Registers all required hooks
  */
 public static function init()
 {
     add_rewrite_tag('%monthname%', '(' . implode('|', self::$monthnames) . ')');
     add_rewrite_tag('%monthcode%', '(' . implode('|', self::$monthcodes) . ')');
     add_rewrite_rule('^([0-9]{4})/(' . implode('|', self::$monthnames) . ')/([0-9]{1,2})/(.*)?', 'index.php?name=$matches[4]', 'top');
     add_rewrite_rule('^([0-9]{4})/(' . implode('|', self::$monthcodes) . ')/([0-9]{1,2})/(.*)?', 'index.php?name=$matches[4]', 'top');
     add_rewrite_rule('^([^/]*)/([0-9]+)/?', 'index.php?p=$matches[2]', 'top');
     add_rewrite_rule('^([0-9]+)/([^/]*)/?', 'index.php?p=$matches[1]', 'top');
 }
Example #28
0
function moxie_press_endpoint()
{
    add_rewrite_tag('%json%', '([^&]+)');
    // rewrite rule to allow single movies to be retrieved using /movies.json/movie-slug
    add_rewrite_rule('movies.json/([^&]+)', 'index.php?json=true&post_type=movie&name=$matches[1]', 'top');
    // rewrite rule to allow movie archive to be retrieved using /movies.json
    add_rewrite_rule('movies.json', 'index.php?post_type=movie&json=true', 'top');
    // todo: consider more params
}
Example #29
0
function tc_rewrite_tag()
{
    add_rewrite_tag('%content-type%', '([^&]+)');
    add_rewrite_tag('%country%', '([^&]+)');
    add_rewrite_tag('%org%', '([^&]+)');
    add_rewrite_tag('%technology%', '([^&]+)');
    add_rewrite_tag('%topic%', '([^&]+)');
    add_rewrite_tag('%page%', '([^&]+)');
}
Example #30
0
function hashed_id()
{
    global $wp_rewrite;
    add_rewrite_tag('%hashed_id%', '([^/]+)');
    $permalink = $wp_rewrite->permalink_structure;
    if (!empty($permalink) && false !== strpos($permalink, '%hashed_id%')) {
        add_filter('pre_post_link', '_hashed_id_post_link', 37, 2);
        add_filter('parse_request', '_hashed_id_parse_request');
    }
}