fix: 在新标签页打开社团介绍页而不是直接打开
This commit is contained in:
@@ -18,6 +18,24 @@ function itstudio_theme_setup() {
|
|||||||
}
|
}
|
||||||
add_action('after_setup_theme', 'itstudio_theme_setup');
|
add_action('after_setup_theme', 'itstudio_theme_setup');
|
||||||
|
|
||||||
|
function itstudio_open_honor_menu_item_in_new_tab($atts, $item, $args) {
|
||||||
|
$href = isset($atts['href']) ? (string) $atts['href'] : '';
|
||||||
|
$host = wp_parse_url($href, PHP_URL_HOST);
|
||||||
|
|
||||||
|
if ($host !== 'honor.itouc.cn') {
|
||||||
|
return $atts;
|
||||||
|
}
|
||||||
|
|
||||||
|
$atts['target'] = '_blank';
|
||||||
|
$rel = isset($atts['rel']) ? (string) $atts['rel'] : '';
|
||||||
|
$rel_tokens = preg_split('/\s+/', trim($rel), -1, PREG_SPLIT_NO_EMPTY);
|
||||||
|
$rel_tokens = array_unique(array_merge($rel_tokens, array('noopener', 'noreferrer')));
|
||||||
|
$atts['rel'] = implode(' ', $rel_tokens);
|
||||||
|
|
||||||
|
return $atts;
|
||||||
|
}
|
||||||
|
add_filter('nav_menu_link_attributes', 'itstudio_open_honor_menu_item_in_new_tab', 10, 3);
|
||||||
|
|
||||||
function itstudio_get_site_content_defaults() {
|
function itstudio_get_site_content_defaults() {
|
||||||
return array(
|
return array(
|
||||||
'footer_links' => array(
|
'footer_links' => array(
|
||||||
|
|||||||
Reference in New Issue
Block a user