douhui1630 2015-10-09 20:24
浏览 51
已采纳

Wordpress中的PHP不会在IE中编码/解码生成的标题(删除/更改引号)

So, our site has news stories that can be shared in Twitter and Facebook. In both FF and Chrome, the twitter link works fine, no problem. However, IE decided that it doesn't like the quotation marks and will send an HTML 400 Bad Request every time we try to share a story via our site that has quotation marks inside of it. What breaks in particular is related to the_title() and not the_permalink().

The code section in question:

<a href="https://twitter.com/home?status=<?php the_title(); ?> - <?php the_permalink(); ?>" target="_blank" onclick="return !window.open(this.href, 'Share on Twitter', 'width=500,height=500')"><img src="<?php echo get_template_directory_uri(); ?>/img/share-tw1.png" width="28" height="28" /></a>

I've tried to wrap the_title() in parens and apply urlencode or htmlspecialchars or anything else like it and have had no luck encoding a generated URL. (It generates based on the title of the story and the URL linking to it).

Can anyone help or provide insight as to what needs to happen in order for IE to accept quotation marks?

  • 写回答

1条回答 默认 最新

  • dongqu4443 2015-10-09 20:29
    关注

    I would try using esc_url(), using the returned title (which means you need to pass get_the_title() to esc_url()).

    ?status=<?php echo esc_url( get_the_title() ); ?>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 想问一下树莓派接上显示屏后出现如图所示画面,是什么问题导致的
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号