0

我刚刚在 WP 中找到了一个我喜欢的小部件。但我不想让访问者离开我的博客。

我编辑了插件的 php 文件,但对 PHP 知之甚少,我试图弄清楚当他们访问我的 G+ 页面时如何在新窗口中打开以下链接。

我确定它来自 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>

这是当前的结果:

谷歌加小部件

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

4

1 回答 1

1

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

如果它插入 html,您总是可以在页面中添加一个 javascript/jquery 片段,强制 url 执行“target='_blank'”。

像这样的东西:

$("#widget_id a").attr("target","_blank");
于 2013-02-04T17:23:41.693 回答