本文整理汇总了PHP中add_permastruct函数的典型用法代码示例。如果您正苦于以下问题:PHP add_permastruct函数的具体用法?PHP add_permastruct怎么用?PHP add_permastruct使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了add_permastruct函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: register_post_type
//.........这里部分代码省略.........
if (null === $args->map_meta_cap) {
$args->map_meta_cap = false;
}
// If there's no specified edit link and no UI, remove the edit link.
if (!$args->show_ui && !$has_edit_link) {
$args->_edit_link = '';
}
$args->cap = get_post_type_capabilities($args);
unset($args->capabilities);
if (is_array($args->capability_type)) {
$args->capability_type = $args->capability_type[0];
}
if (!empty($args->supports)) {
add_post_type_support($post_type, $args->supports);
unset($args->supports);
} elseif (false !== $args->supports) {
// Add default features
add_post_type_support($post_type, array('title', 'editor'));
}
if (false !== $args->query_var) {
if (true === $args->query_var) {
$args->query_var = $post_type;
} else {
$args->query_var = sanitize_title_with_dashes($args->query_var);
}
if ($wp && is_post_type_viewable($args)) {
$wp->add_query_var($args->query_var);
}
}
if (false !== $args->rewrite && (is_admin() || '' != get_option('permalink_structure'))) {
if (!is_array($args->rewrite)) {
$args->rewrite = array();
}
if (empty($args->rewrite['slug'])) {
$args->rewrite['slug'] = $post_type;
}
if (!isset($args->rewrite['with_front'])) {
$args->rewrite['with_front'] = true;
}
if (!isset($args->rewrite['pages'])) {
$args->rewrite['pages'] = true;
}
if (!isset($args->rewrite['feeds']) || !$args->has_archive) {
$args->rewrite['feeds'] = (bool) $args->has_archive;
}
if (!isset($args->rewrite['ep_mask'])) {
if (isset($args->permalink_epmask)) {
$args->rewrite['ep_mask'] = $args->permalink_epmask;
} else {
$args->rewrite['ep_mask'] = EP_PERMALINK;
}
}
if ($args->hierarchical) {
add_rewrite_tag("%{$post_type}%", '(.+?)', $args->query_var ? "{$args->query_var}=" : "post_type={$post_type}&pagename=");
} else {
add_rewrite_tag("%{$post_type}%", '([^/]+)', $args->query_var ? "{$args->query_var}=" : "post_type={$post_type}&name=");
}
if ($args->has_archive) {
$archive_slug = $args->has_archive === true ? $args->rewrite['slug'] : $args->has_archive;
if ($args->rewrite['with_front']) {
$archive_slug = substr($wp_rewrite->front, 1) . $archive_slug;
} else {
$archive_slug = $wp_rewrite->root . $archive_slug;
}
add_rewrite_rule("{$archive_slug}/?\$", "index.php?post_type={$post_type}", 'top');
if ($args->rewrite['feeds'] && $wp_rewrite->feeds) {
$feeds = '(' . trim(implode('|', $wp_rewrite->feeds)) . ')';
add_rewrite_rule("{$archive_slug}/feed/{$feeds}/?\$", "index.php?post_type={$post_type}" . '&feed=$matches[1]', 'top');
add_rewrite_rule("{$archive_slug}/{$feeds}/?\$", "index.php?post_type={$post_type}" . '&feed=$matches[1]', 'top');
}
if ($args->rewrite['pages']) {
add_rewrite_rule("{$archive_slug}/{$wp_rewrite->pagination_base}/([0-9]{1,})/?\$", "index.php?post_type={$post_type}" . '&paged=$matches[1]', 'top');
}
}
$permastruct_args = $args->rewrite;
$permastruct_args['feed'] = $permastruct_args['feeds'];
add_permastruct($post_type, "{$args->rewrite['slug']}/%{$post_type}%", $permastruct_args);
}
// Register the post type meta box if a custom callback was specified.
if ($args->register_meta_box_cb) {
add_action('add_meta_boxes_' . $post_type, $args->register_meta_box_cb, 10, 1);
}
$args->labels = get_post_type_labels($args);
$args->label = $args->labels->name;
$wp_post_types[$post_type] = $args;
add_action('future_' . $post_type, '_future_post_hook', 5, 2);
foreach ($args->taxonomies as $taxonomy) {
register_taxonomy_for_object_type($taxonomy, $post_type);
}
/**
* Fires after a post type is registered.
*
* @since 3.3.0
*
* @param string $post_type Post type.
* @param object $args Arguments used to register the post type.
*/
do_action('registered_post_type', $post_type, $args);
return $args;
}
示例2: _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;
}
示例3: 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);
}
示例4: 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);
}
}
示例5: test_remove_permastruct
public function test_remove_permastruct()
{
global $wp_rewrite;
add_permastruct('foo', 'bar/%foo%');
$this->assertInternalType('array', $wp_rewrite->extra_permastructs['foo']);
$this->assertSame('/bar/%foo%', $wp_rewrite->extra_permastructs['foo']['struct']);
remove_permastruct('foo');
$this->assertFalse(isset($wp_rewrite->extra_permastructs['foo']));
}
示例6: permalinks
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);
}
示例7: set_gallery_permastruct
function set_gallery_permastruct()
{
$permalink_structure = get_option('permalink_structure');
$gallery_structure = get_option('gallery_structure');
if ($gallery_structure) {
// false is important in add_permastruct so that it does not append the general blog structure our gallery structure
add_permastruct('gallery', $gallery_structure, false);
} else {
add_permastruct('gallery', "", false);
}
}
示例8: init
/**
* @global WP $wp
*/
public static function init()
{
global $wp;
add_rewrite_rule('wpmsm-manifest\\.json$', 'index.php?wpmsmm=1', 'top');
add_rewrite_tag('%wpmsmaction%', '(.+)');
add_permastruct('wpmsmendpoint', '/wpmsm-endpoint/%wpmsmaction%', false);
$wp->add_query_var('wpmsmm');
if (!wp_next_scheduled('wpmsm_create_new_keys')) {
wp_schedule_event(time(), 'monthly', 'wpmsm_create_new_keys');
}
}
示例9: mb_forum_rewrite_tags
function mb_forum_rewrite_tags($post_type, $args)
{
if (mb_get_forum_post_type() !== $post_type) {
return;
}
add_rewrite_tag("%{$post_type}%", '([^/]+)', $args->query_var ? "{$args->query_var}=" : "post_type={$post_type}&pagename=");
// add_rewrite_tag("%{$post_type}%", '([^/]+)', "post_type=$post_type&pagename=");
$permastruct_args = $args->rewrite;
$permastruct_args['feed'] = $permastruct_args['feeds'];
add_permastruct($post_type, mb_get_forum_slug() . "/%{$post_type}%", $permastruct_args);
}
示例10: registered_post_type
/**
*
* registered_post_type
* ** add rewrite tag for Custom Post Type.
* @version 1.1
* @since 0.9
*
*/
public function registered_post_type($post_type, $args)
{
global $wp_post_types, $wp_rewrite;
if ($args->_builtin or !$args->publicly_queryable or !$args->show_ui) {
return false;
}
$permalink = get_option($post_type . '_structure');
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);
}
$rewrite_args["walk_dirs"] = false;
add_permastruct($post_type, $permalink, $rewrite_args);
$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;
}
add_rewrite_rule($slug . '/date/([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/([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/([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/([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/([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/([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/([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/([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/([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/([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/([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/([0-9]{4})/?$', 'index.php?year=$matches[1]&post_type=' . $post_type, 'top');
add_rewrite_rule($slug . '/author/([^/]+)/?$', 'index.php?author_name=$matches[1]&post_type=' . $post_type, 'top');
}
}
示例11: post_type_portfolio
function post_type_portfolio() {
global $wpdb;
register_post_type('portfolio', array( 'label' => 'Portfolio Items','description' => '','public' => true,'show_ui' => true,'show_in_menu' => true,'show_in_nav_menus' => true,'capability_type' => 'post','hierarchical' => false,'rewrite' => array('slug' => '%portfolio_page%','with_front'=>true),'query_var' => true,'supports' => array('title','editor','trackbacks','revisions','thumbnail'),'labels' => array (
'name' => 'Portfolio Items',
'singular_name' => 'Portfolio Item',
'menu_name' => 'Portfolio Items',
'add_new' => 'Add Portfolio Item',
'add_new_item' => 'Add New Portfolio Item',
'edit' => 'Edit',
'edit_item' => 'Edit Portfolio Item',
'new_item' => 'New Portfolio Item',
'view' => 'View Portfolio Item',
'view_item' => 'View Portfolio Item',
'search_items' => 'Search Portfolio Items',
'not_found' => 'No Portfolio Items Found',
'not_found_in_trash' => 'No Portfolio Items Found in Trash',
'parent' => 'Parent Portfolio Item',
),) );
add_rewrite_tag( '%portfolio%', '([^/]+)' );
add_permastruct('portfolio', '%portfolio_page%/%portfolio%/', false );
$querystr = "
SELECT $wpdb->posts.*
FROM $wpdb->posts, $wpdb->postmeta
WHERE $wpdb->posts.ID = $wpdb->postmeta.post_id
AND $wpdb->postmeta.meta_key = '_wp_page_template'
AND $wpdb->postmeta.meta_value = 'templates/portfolio.php'
AND $wpdb->posts.post_status = 'publish'
AND $wpdb->posts.post_type = 'page'";
$pageposts = $wpdb->get_results($querystr, OBJECT);
foreach ($pageposts as $pagepost){
add_rewrite_rule($pagepost->post_name.'/([^/]*)/?$','index.php?portfolio=$matches[1]','top');
add_rewrite_rule($pagepost->post_name.'/([^/]+)/page/?([0-9]{1,})/?$','index.php?portfolio=$matches[1]&paged=$matches[2]','top');
}
flush_rewrite_rules();
}
示例12: eventorganiser_cpt_register
/**
* Registers the event custom post type
* Hooked onto init
*
* @ignore
* @access private
* @since 1.0
*/
function eventorganiser_cpt_register()
{
$labels = array('name' => __('Events', 'eventorganiser'), 'singular_name' => __('Event', 'eventorganiser'), 'add_new' => _x('Add New', 'post'), 'add_new_item' => __('Add New Event', 'eventorganiser'), 'edit_item' => __('Edit Event', 'eventorganiser'), 'new_item' => __('New Event', 'eventorganiser'), 'all_items' => __('All events', 'eventorganiser'), 'view_item' => __('View Event', 'eventorganiser'), 'search_items' => __('Search events', 'eventorganiser'), 'not_found' => __('No events found', 'eventorganiser'), 'not_found_in_trash' => __('No events found in Trash', 'eventorganiser'), 'parent_item_colon' => '', 'menu_name' => __('Events', 'eventorganiser'));
$exclude_from_search = eventorganiser_get_option('excludefromsearch') == 0 ? false : true;
if (!eventorganiser_get_option('prettyurl')) {
$event_rewrite = false;
$events_slug = true;
} else {
$event_slug = trim(eventorganiser_get_option('url_event', 'events/event'), "/");
$events_slug = trim(eventorganiser_get_option('url_events', 'events/event'), "/");
$event_rewrite = array('slug' => $event_slug, 'with_front' => false, 'feeds' => true, 'pages' => true);
/* Workaround for http://core.trac.wordpress.org/ticket/19871 */
global $wp_rewrite;
$wp_rewrite->add_rewrite_tag('%event_ondate%', '([0-9]{4}(?:/[0-9]{2}(?:/[0-9]{2})?)?)', 'post_type=event&ondate=');
add_permastruct('event_archive', $events_slug . '/on/%event_ondate%', array('with_front' => false));
}
$args = array('labels' => $labels, 'public' => true, 'publicly_queryable' => true, 'exclude_from_search' => $exclude_from_search, 'show_ui' => true, 'show_in_menu' => true, 'query_var' => true, 'capability_type' => 'event', 'rewrite' => $event_rewrite, 'capabilities' => array('publish_posts' => 'publish_events', 'edit_posts' => 'edit_events', 'edit_others_posts' => 'edit_others_events', 'delete_posts' => 'delete_events', 'delete_others_posts' => 'delete_others_events', 'read_private_posts' => 'read_private_events', 'edit_post' => 'edit_event', 'delete_post' => 'delete_event', 'read_post' => 'read_event'), 'has_archive' => $events_slug, 'hierarchical' => false, 'menu_icon' => defined('MP6') && MP6 ? false : EVENT_ORGANISER_URL . 'css/images/eoicon-16.png', 'menu_position' => apply_filters('eventorganiser_menu_position', 5), 'supports' => eventorganiser_get_option('supports'));
register_post_type('event', apply_filters('eventorganiser_event_properties', $args));
}
示例13: update_term_rewrite_rules
function update_term_rewrite_rules()
{
//add rewrite for question taxonomy
global $wp_rewrite;
$options = get_option('dwqa_options');
$page_id = $options['pages']['archive-question'];
$question_list_page = get_page($page_id);
$rewrite_category = isset($options['question-category-rewrite']) ? sanitize_title($options['question-category-rewrite']) : 'question-category';
$rewrite_tag = isset($options['question-tag-rewrite']) ? sanitize_title($options['question-tag-rewrite']) : 'question-tag';
if ($question_list_page) {
$dwqa_rewrite_rules = array('^' . $question_list_page->post_name . '/' . $rewrite_category . '/([^/]*)' => 'index.php?page_id=' . $page_id . '&taxonomy=dwqa-question_category&dwqa-question_category=$matches[1]', '^' . $question_list_page->post_name . '/' . $rewrite_tag . '/([^/]*)' => 'index.php?page_id=' . $page_id . '&taxonomy=dwqa-question_tag&dwqa-question_tag=$matches[1]');
foreach ($dwqa_rewrite_rules as $regex => $redirect) {
add_rewrite_rule($regex, $redirect, 'top');
}
// Add permastruct for pretty link
add_permastruct('dwqa-question_category', "{$question_list_page->post_name}/{$rewrite_category}/%dwqa-question_category%", array('with_front' => false));
add_permastruct('dwqa-question_tag', "{$question_list_page->post_name}/{$rewrite_tag}/%dwqa-question_tag%", array('with_front' => false));
}
}
示例14: gp_portfolio_init
/**
* Initialize Portolio
*/
function gp_portfolio_init()
{
add_image_size('gp-portfolio-thumbnail', 90, 90, true);
$portfolio_base = gp_portfolio_base_slug();
/**
* Cache $portfolio_base, if it has changed, then we need to flush rules.
*/
$flush = false;
$cached_portfolio_base = get_transient('gp_portfolio_slug');
if ($cached_portfolio_base) {
if ($portfolio_base != $cached_portfolio_base) {
$flush = true;
}
} else {
$flush = true;
}
/**
* First we register taxonomy, then custom post type.
* The order is important, because of rewrite rules.
*/
$args = array('label' => 'Project Types', 'singular_label' => 'Project Type', 'query_var' => true, 'show_in_nav_menus' => true, 'show_ui' => true, 'show_tagcloud' => false, 'hierarchical' => true, 'rewrite' => array('slug' => $portfolio_base));
register_taxonomy('gp-project-type', 'gp_portfolio', $args);
/**
* Register portfolio_project custom post type.
*/
$args = array('label' => __(' Portfolio', 'gp'), 'singular_label' => __('Project', 'gp'), 'public' => true, 'show_ui' => true, 'capability_type' => 'page', 'hierarchical' => false, 'rewrite' => false, 'query_var' => true, 'taxonomy' => 'gp-project-type', 'has_archive' => true, 'menu_icon' => get_template_directory_uri() . '/images/wp-admin/portfolio.png', 'supports' => array('title', 'editor', 'thumbnail', 'excerpt', 'page-attributes'));
register_post_type('gp_portfolio', $args);
/**
* Register portfolio Project Media File
*/
$args = array('label' => __(' Project Media', 'gp'), 'singular_label' => __('Project Media File', 'gp'), 'public' => false, 'supports' => array('title'));
register_post_type('gp_portfolio_project_media', $args);
$portfolio_structure = '/' . $portfolio_base . '/%projecttype%/%gp_portfolio%';
add_rewrite_tag('%projecttype%', '([^&/]+)', 'gp_project_type=');
add_rewrite_tag('%gp_portfolio%', '([^&/]+)', 'gp_portfolio=');
add_permastruct('gp_portfolio', $portfolio_structure, false);
if ($flush) {
it_flush_rewrite_rules();
set_transient('gp_portfolio_slug', $portfolio_base, 60 * 60 * 24);
}
}
示例15: replace_permastruct
/**
* Replace "permastruct", for single.
*
* This code simulate the code used in WordPress function "register_post_type"
* and execute it for each language.
*/
private function replace_permastruct()
{
global $wp_rewrite;
$post_type = $this->post_type_object->name;
// remove the original permastructs
unset($wp_rewrite->extra_permastructs[$post_type]);
// add the translated permastructs for each languages
foreach ($this->translated_slugs as $lang => $translated_slug) {
$args = $translated_slug;
if ($args->rewrite !== false && (is_admin() || get_option('permalink_structure') != '')) {
$permastruct_args = $args->rewrite;
$permastruct_args['feed'] = $permastruct_args['feeds'];
// set the walk_dirs to false to avoid conflict with has_archive = false and the %language%
// in the rewrite directive. Without it the archive page redirect to the frontpage if has_archive is false
$permastruct_args['walk_dirs'] = false;
// if "Hide URL language information for default language" option is
// set to true the rules has to be different for the default language
if ($this->plugin === 'Polylang') {
global $polylang;
// if "The language is set from content" is enabled
if ((bool) $polylang->options['force_lang'] === false) {
add_permastruct($post_type . '_' . $lang, "{$args->rewrite['slug']}/%{$post_type}%", $permastruct_args);
} else {
if ($polylang->options['hide_default'] && $lang == pll_default_language()) {
add_permastruct($post_type . '_' . $lang, "{$args->rewrite['slug']}/%{$post_type}%", $permastruct_args);
} else {
// if "Keep /language/ in pretty permalinks" is enabled
if ($polylang->options['rewrite'] == 0 && !($polylang->options['hide_default'] && $lang == pll_default_language())) {
add_permastruct($post_type . '_' . $lang, 'language/' . "%language%/{$args->rewrite['slug']}/%{$post_type}%", $permastruct_args);
} else {
add_permastruct($post_type . '_' . $lang, "%language%/{$args->rewrite['slug']}/%{$post_type}%", $permastruct_args);
}
}
}
} elseif ($this->plugin === 'WPML') {
add_permastruct($post_type . '_' . $lang, "{$args->rewrite['slug']}/%{$post_type}%", $permastruct_args);
}
do_action('wpml_translated_post_type_replace_permastruct', $post_type, $lang, $translated_slug);
}
}
}