| 主機(jī)參考:VPS測(cè)評(píng)參考推薦/專注分享VPS服務(wù)器優(yōu)惠信息!若您是商家可以在本站進(jìn)行投稿,查看詳情!此外我們還提供軟文收錄、PayPal代付、廣告贊助等服務(wù),查看詳情! |
| 我們發(fā)布的部分優(yōu)惠活動(dòng)文章可能存在時(shí)效性,購(gòu)買時(shí)建議在本站搜索商家名稱可查看相關(guān)文章充分了解該商家!若非中文頁(yè)面可使用Edge瀏覽器同步翻譯!PayPal代付/收錄合作 |
20190815
我改了之后才發(fā)現(xiàn)訪客不能填寫我博客評(píng)論的網(wǎng)址。帶有URL的評(píng)論應(yīng)該是其他人使用wordpress界面插入的消息。只有注冊(cè)用戶才能設(shè)置網(wǎng)站,但我沒有打開注冊(cè)。使用下面的代碼后,我發(fā)現(xiàn)問題很大,因?yàn)橹挥形易约旱膇d有鏈接,其他什么都沒有。但是點(diǎn)擊我的鏈接也會(huì)跳轉(zhuǎn),這種體驗(yàn)極其糟糕。所以我修改了代碼。但我是個(gè)新手。只能簡(jiǎn)單修改。增加了是否是管理員的判斷。這里您需要在后臺(tái)檢查管理員ID。
//WordPress評(píng)論員的鏈接新建窗口打開函數(shù)get _ comment _ author _ link _ new($ return,$ author,$ comment _ id = 0){ $ comment = get _ comment($ comment _ id);$ URL = get _ comment _ author _ URL($ comment);$ author = get _ comment _ author(comment);if(empty($ URL)| |‘http://‘= = $ URL)$ return = $ author;else { if($ comment-& gt;用戶標(biāo)識(shí)!= 4){ $ return =“$ author“;$ return = str _ replace(“href =‘$ URL‘“,“href=\““。home_url()。/go/?url=$url\“,$ return);} else { $ return =“$ author“;} }//$ URL = str _ replace(“href=\“$ URL \“,“href = \““。home_url()。/go/?url=$url““,$ URL);//$ return =“$ author“;//$ return = str _ replace(“href=\“$ val \“,“href = \““。home_url()。/go/?url=$val\“,$ return);return $ return} add _ filter(‘get _ comment _ author _ link‘,get _ comment _ author _ link _ new,10,3);前段時(shí)間,網(wǎng)站的外部鏈接中添加了nofollow,并設(shè)置了一個(gè)新窗口。而且參考了張戈的go jump代碼,設(shè)置了博客go jump。這個(gè)網(wǎng)站的流量和評(píng)論都很少。只能通過輸入電子郵件和昵稱進(jìn)行評(píng)論。同時(shí),對(duì)于游客來說,也可以同時(shí)進(jìn)入自己的網(wǎng)站。最近,人們一直在博客上發(fā)表評(píng)論。我點(diǎn)開了一個(gè)評(píng)論員的用戶名,發(fā)現(xiàn)這個(gè)窗口直接打開了評(píng)論員的鏈接,體驗(yàn)極其糟糕。此外,鏈接中添加了nofollow,因此我考慮對(duì)其進(jìn)行改革。百度收集了信息并找到了解決方案。具體原理不解釋。讓我提供我的解決方案。
將以下代碼直接添加到主題function.php文件中可以解決不跟隨和打開新窗口的問題。
//WordPress評(píng)論員的鏈接新建窗口打開函數(shù)get _ comment _ author _ link _ new($ return,$ author,$ comment _ id = 0){ $ comment = get _ comment($ comment _ id);$ URL = get _ comment _ author _ URL($ comment);$ author = get _ comment _ author(comment);if(empty($ URL)| |‘http://‘= = $ URL)$ return = $ author;else $ return =“& lt;a href =‘$ URL‘target =‘_ blank‘rel =‘external no follow‘class =‘URL‘& gt。$ author & lt/a & gt;”;return $ return} add _ filter(‘get _ comment _ author _ link‘,get _ comment _ author _ link _ new,10,3);但是我感覺不好。我覺得強(qiáng)迫癥的評(píng)論區(qū)內(nèi)容和文章內(nèi)容已經(jīng)開始go jump了,那么我可以直接調(diào)用這個(gè)go jump并在評(píng)論者鏈接中添加go jump嗎?答案是肯定的,所以我研究了我的go jump代碼,并對(duì)上面的代碼進(jìn)行了以下修改。
//WordPress評(píng)論員的鏈接新建窗口打開函數(shù)get _ comment _ author _ link _ new($ return,$ author,$ comment _ id = 0){ $ comment = get _ comment($ comment _ id);$ URL = get _ comment _ author _ URL($ comment);$ author = get _ comment _ author(comment);if(empty($ URL)| |‘http://‘= = $ URL)$ return = $ author;else $ return =“& lt;a href =‘$ URL‘target =‘_ blank‘rel =‘external no follow‘class =‘URL‘& gt。$ author & lt/a & gt;”;$ return = str _ replace(“href =‘$ URL‘“,“href=\““。home_url()。/go/?url=$url\“,$ return);//add go jump return $ return;} add _ filter(‘get _ comment _ author _ link‘,get _ comment _ author _ link _ new,10,3);上面的代碼調(diào)用了該網(wǎng)站先前設(shè)置的go跳轉(zhuǎn),其中代碼意味著調(diào)用根目錄下go文件夾下的index.php文件,該index.php文件將自動(dòng)跳轉(zhuǎn)到您設(shè)置的鏈接。如果您的網(wǎng)站沒有g(shù)o跳轉(zhuǎn),您可以通過使用以下方法簡(jiǎn)單地實(shí)現(xiàn)它。在根目錄下新建一個(gè)文件夾go,將下載的index.php文件放入該目錄,使用上面的代碼實(shí)現(xiàn)go跳轉(zhuǎn)。

![]()
這個(gè)怎么樣?這不是很酷。1.添加nofollow,空白,默認(rèn)情況下轉(zhuǎn)到所有鏈接,當(dāng)然您自己的鏈接也應(yīng)該相同。
2.go jump可以根據(jù)自己的情況進(jìn)行修改。
這幾篇文章你可能也喜歡:
- 暫無相關(guān)推薦文章
本文由主機(jī)參考刊發(fā),轉(zhuǎn)載請(qǐng)注明:WordPress在評(píng)論鏈接中添加了nofollow、新窗口打開和go jump(WordPress關(guān)閉評(píng)論功能)。 http://m.k2270.com/112421.html
主機(jī)參考

















評(píng)論前必須登錄!
注冊(cè)