本文整理匯總了PHP中Option::get_front_struct方法的典型用法代碼示例。如果您正苦於以下問題:PHP Option::get_front_struct方法的具體用法?PHP Option::get_front_struct怎麽用?PHP Option::get_front_struct使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Option
的用法示例。
在下文中一共展示了Option::get_front_struct方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: post_type_archive_link
/**
* Filter the post type archive permalink.
*
* @since 3.1.0
*
* @param string $link The post type archive permalink.
* @param string $post_type Post type name.
*
* @return string
*/
public function post_type_archive_link($link, $post_type)
{
$post_type_obj = get_post_type_object($post_type);
if (get_option('permalink_structure') && is_array($post_type_obj->rewrite)) {
$struct = $this->option->get_front_struct($post_type);
$link = home_url(user_trailingslashit($struct, 'post_type_archive'));
}
return $link;
}
示例2: register_rewrite_rule
/**
* after a post type is registered.
*
* @param string $post_type Post type.
* @param object $args Arguments used to register the post type.
*/
public function register_rewrite_rule($post_type, $args)
{
if ('' == get_option('permalink_structure')) {
return;
}
$permastruct_args = $args->rewrite;
$permastruct_args['feed'] = $permastruct_args['feeds'];
$queryarg = "post_type={$post_type}&p=";
$tag = "%{$post_type}_id%";
add_rewrite_tag($tag, '([0-9]+)', $queryarg);
if ($struct = $this->option->get_structure($post_type)) {
$search = array('%postname%', '%post_id%');
$replace = array("%{$post_type}%", "%{$post_type}_id%");
$struct = str_replace($search, $replace, $struct);
add_permastruct($post_type, $struct, $permastruct_args);
$slug = $this->option->get_front_struct($post_type);
if ($slug) {
add_rewrite_rule("{$slug}/page/?([0-9]{1,})/?\$", "index.php?paged=\$matches[1]&post_type={$post_type}", 'top');
add_rewrite_rule("{$slug}/?\$", "index.php?post_type={$post_type}", 'top');
}
}
}