My plugin makes an interactive image and I want to share it via iframe. Is there a right way to implement a special page with unique url for a wordpress plugin. At the moment I use a page templates, but it's not so friendly. I want something like www.site.com/myplugin/id=123¶m=123 - shows me a special page that renders my plugin in frontend.
1条回答 默认 最新
- dongtaigan1594 2017-09-02 14:55关注
You can hook into the
parse_request
action before WordPress renders any page like so:function so_46014733( $query ) { if ( isset( $_GET['id'] ) && isset( $_GET['param'] ) && '123' === $_GET['id'] && '123' === $_GET['param'] ) { include_once 'my_custom_page.html'; exit; } return $query; } add_action( 'parse_request', 'so_46014733' );
A few things to note:
- This will immediately return the default
$query
if theid
orparam
are empty (almost no performance impact on this check). - This assumes you want to render your own HTML page (or even a PHP page with your own code) if the
id
andparam
match your keys. -
If you plan to use the
$_GET
variables for anything, be sure to sanitize them first like so:$id = absint( wp_unslash( $_GET['id'] ) );
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报 - This will immediately return the default
悬赏问题
- ¥15 根据以下文字信息,做EA模型图
- ¥15 删除虚拟显示器驱动 删除所有 Xorg 配置文件 删除显示器缓存文件 重启系统 可是依旧无法退出虚拟显示器
- ¥15 vscode程序一直报同样的错,如何解决?
- ¥15 关于使用unity中遇到的问题
- ¥15 开放世界如何写线性关卡的用例(类似原神)
- ¥15 关于并联谐振电磁感应加热
- ¥60 请查询全国几个煤炭大省近十年的煤炭铁路及公路的货物周转量
- ¥15 请帮我看看我这道c语言题到底漏了哪种情况吧!
- ¥60 关机时蓝屏并显示KMODE_EXCEPTION_NOT_HANDLED,怎么修?
- ¥66 如何制作支付宝扫码跳转到发红包界面