2013-02-04 27 views
0

我刚刚在WP中发现了一个我喜欢的小工具。但我不想让游客离开我的博客。我编辑了插件的php文件,但对PHP有一点了解,我试图弄清楚如何在访问我的G +页面时在新窗口中打开后续链接。在PHP(Wordpress)中,如何更改此代码以使Google+链接target = blank,并在新窗口中打开?

我敢肯定,它来自的代码在php文件中的这些片段之一:

/** 
* Set the widget defaults 
*/ 
private $widget_title = "Add WHI To Your Google Plus Circles"; 
private $googleplus_username = "https://plus.google.com/101536806553649165592"; 
private $googleplus_width = "250"; 
private $googleplus_header = "true"; 

/* Our variables from the widget settings. */ 
$this->widget_title = apply_filters('widget_title', $instance['title']); 

$this->googleplus_username = $instance['page_url']; 
$this->googleplus_width = $instance['width']; 
$this->googleplus_header = ($instance['show_header'] == "1" ? "true" : "false"); 

/* Like Box */ 

?> 
<div class="g-plus" data-width="<?php echo $this->googleplus_width; ?>" 
data-href="<?php echo $this->googleplus_username ?>" 
data-rel="publisher"> 

</div> 

这里的当前结果:

Google Plus Widget

我刚才发现它与googleplus_username有关,它们是文件中的3个实例。有人知道如何配置代码在新窗口中打开吗?感谢任何人可以提供的任何指导!

+1

这是谷歌+代码创建一个小部件。我在配置变量中看不到任何选项来强制打开新窗口。 – datasage

+1

从快速搜索看起来像其他人正在遭受此, http://stackoverflow.com/questions/11440498/how-to-open-the-link-in-new-window-of-google-plus-badge 和一个请求已被提出... http://code.google.com/p/google-plus-platform/issues/detail?id=316 对不起,但它看起来像它在控制Google – Opentuned

+0

感谢Datasage,Stefan Cross,花时间阅读我的问题并作出回应。我想这不是一个问题太紧迫,但像我们许多人一样,我试着去完善事情。 G在某些事情上落后了......就像这样,以及无法从WP(和其他站点)以他们的API的方式发布到G + ......尽管有些第三方工具可以实现这一点。感谢链接,Stefan,再次感谢您花时间回复! –

回答

1

该插件是否会在您的模板中插入html代码,还是它是一个iframe?在后一种情况下,你被搞砸了,你可能不得不等待谷歌修复它。

如果它插入html,您可以随时在页面中添加一个javascript/jquery片段,强制url做一个“target ='_ blank'”。

事情是这样的:

$("#widget_id a").attr("target","_blank"); 
+0

谢谢jberculo ...我认为我搞砸了这个,除非我找到别的东西。我只是喜欢这个小部件,因为它允许其他人通过将鼠标悬停在关注按钮上来将他们添加到他们的G +圈子中。我相信我会弄明白的。感谢您花时间回答! –

相关问题