2013-02-04 26 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 +圈子中。我相信我會弄明白的。感謝您花時間回答! –

相關問題