如何实现目标="_“空白”;属性转换为PHP链接,以便在新选项卡中打开链接?
我有一个链接,基本上是一个“关于”页面,有指向我个人社交媒体的社交图标。在PHP中,代码如下所示:如何实现目标="_“空白”;属性转换为PHP链接,以便在新选项卡中打开链接?,php,wordpress,Php,Wordpress,我有一个链接,基本上是一个“关于”页面,有指向我个人社交媒体的社交图标。在PHP中,代码如下所示: function wp_about_author_get_socials() { $socials = array(); $socials['twitter'] = array('title'=>'Twitter', 'link'=>'http://www.twitter.com /%%username%%', 'icon'=> WPAUTHORURL_URL .'/images
function wp_about_author_get_socials() {
$socials = array();
$socials['twitter'] = array('title'=>'Twitter', 'link'=>'http://www.twitter.com
/%%username%%', 'icon'=> WPAUTHORURL_URL .'/images/twitter.png');
$socials['facebook'] = array('title'=>'Facebook', 'link'=>'http://www.facebook.com
/%%username%%', 'icon'=> WPAUTHORURL_URL .'/images/facebook.png');
我已经摆弄了一些东西,但似乎无法实现一些东西,因此链接会在一个新的选项卡/页面中打开。目前,这些链接会让用户离开网站(并不理想)。在此方面的任何指导都将不胜感激
我尝试的是更改指向以下内容的链接:
$socials['twitter'] = array('title'=>'Twitter', 'link'=>'http://www.twitter.com
/%%username%%', 'target'=>'_blank', 'icon'=> WPAUTHORURL_URL .'/images/twitter.png');
但那没用
这可能是打印链接的部分,据我所知:
// About Author Social
$wp_about_author_social .= wp_about_author_get_social_links($wp_about_author_settings);
if(isset($wp_about_author_settings['wp_author_social_images']) &&
$wp_about_author_settings['wp_author_social_images']){
$wp_about_author_content .= "<p>" .$wp_about_author_links . "</p>";
if($wp_about_author_social != ""){
$wp_about_author_content .= '<p class="wpa-nomargin">'.apply_filters(
'wp_about_author_follow_me', "Follow Me:").'<br />' . $wp_about_author_social.'</p>';
}
} else {
$wp_about_author_content .= "<p class='wpa-nomargin'>";
$wp_about_author_content .= $wp_about_author_links;
if($wp_about_author_social != ""){
$wp_about_author_content .= apply_filters( 'wp_about_author_separator', " - ") .
$wp_about_author_social;
}
$wp_about_author_content .= "</p>";
}
// Generate social icons
function wp_about_author_get_social_links($wp_about_author_settings){
$content="";
$socials = wp_about_author_get_socials();
foreach($socials as $social_key=>$social){
if (get_the_author_meta($social_key)){
if(isset($wp_about_author_settings['wp_author_social_images']) &&
$wp_about_author_settings['wp_author_social_images']){
$content .= "<a class='wpa-social-icons' href='".str_replace('%%username%%',
get_the_author_meta($social_key), $social['link'])."'><img src='". $social['icon']."'
alt='".$social['title']."'/></a>";
} else {
if($content != "")
$content .= apply_filters( 'wp_about_author_separator', " - ");
$content .= "<a href='".str_replace('%%username%%', get_the_author_meta($social_key),
$social['link'])."'>".$social['title']."</a>";
}
}
}
return $content;
}
//关于作者社交
$wp_about_author_social.=wp_about_author_get_social_链接($wp_about_author_设置);
如果(isset($wp\U关于作者设置['wp\U作者\U社会图像])&&
$wp\u关于作者设置['wp\u作者\u社交图片']{
$wp_关于作者内容。=“”$wp_关于作者链接。””;
如果($wp\u about\u author\u social!=“”){
$wp\u关于作者内容。=''。应用过滤器(
“wp_关于作者”和“跟我来:”。
。$wp_关于作者社会。”
;
}
}否则{
$wp_关于作者内容。=“”;
$wp\u关于作者内容。=$wp\u关于作者链接;
如果($wp\u about\u author\u social!=“”){
$wp\u关于作者内容。=应用过滤器('wp\u关于作者分隔符',“-”)。
$wp_关于作者社会;
}
$wp_关于作者内容。=“
”;
}
//生成社交图标
函数wp\u关于作者获取社交链接($wp\u关于作者设置){
$content=“”;
$socials=wp_关于作者_获取_社会();
foreach($socials作为$social\u key=>$social){
如果(获取作者元($social\u key)){
如果(isset($wp\U关于作者设置['wp\U作者\U社会图像])&&
$wp\u关于作者设置['wp\u作者\u社交图片']{
$content.=”;
}否则{
如果($content!=“”)
$content.=apply_过滤器('wp_about_author_separator',“-”);
$content.=”;
}
}
}
返回$content;
}
在您发布的代码中,您可以在第28行和第34行的链接中添加target=“\u blank”
第28行变成:
$content .= "<a class='wpa-social-icons' target='_blank' href='".str_replace('%%username%%',
$content.=“打印链接的部分在哪里?您的代码看起来被截断了。看起来您正在尝试自定义关于作者的WP插件?嗨,韦斯利。。。谢谢你检查这个。我在页面上添加了唯一可以找到任何关于社交链接的内容的部分,所以我认为这就是部分。谢谢你的帮助!是的,克里斯汀。。。确切地我得到了网站的一部分东西,以显示在一个新的链接,但不是社会图标。。。例如,成功了,Ryan——非常感谢!感谢您抽出时间回答这个问题!很高兴我能帮忙!有时只需要另一双眼睛。
$content .= "<a target='_blank' href='".str_replace('%%username%%', get_the_author_meta($social_key),