简体   繁体   English

WordPress在iframe中登录

[英]WordPress Login inside an iframe

I'm trying to build a mobile app out of a wordpress site, and I've got the site loading via an iframe. 我正在尝试从wordpress网站构建一个移动应用程序,我通过iframe加载了网站。 Everything is working nicely so far, but I'm getting this error when I go to the login page: 到目前为止,一切都运行良好,但是当我进入登录页面时,我收到此错误:

"Refused to display ' http://example.com/wp-login.php ' in a frame because it set 'X-Frame-Options' to 'SAMEORIGIN'." “拒绝在一个框架中显示' http://example.com/wp-login.php ',因为它将'X-Frame-Options'设置为'SAMEORIGIN'。”

I've done some Googling and I found another person who had a similar problem here - Embed wordpress admin inside an iframe . 我做了一些谷歌搜索,我发现另一个人在这里有类似的问题 - 在iframe中嵌入wordpress管理员 The solution was to use 解决方案是使用

remove_action( 'login_init', 'send_frame_options_header', 10, 0 );
remove_action( 'admin_init', 'send_frame_options_header', 10, 0 );

But I've honestly got no clue where to put that code. 但我老老实实地不清楚在哪里放置代码。 Some more Googling pointed me towards the “./wp-includes/default-filters.php” file, but wouldn't that get overwritten with each WP update? 还有一些Googling向我指出了“./wp-includes/default-filters.php”文件,但是不会被每个WP更新覆盖掉吗? Where can I put that code so it doesn't get overwritten and I can load my WP login inside an iframe? 我在哪里可以放置该代码,以免被覆盖,我可以在iframe中加载我的WP登录?

I figured it out :) Thanks to this post - Can't access WordPress Dashboard in an iframe . 我想通了:)感谢这篇文章 - 无法访问iframe中的WordPress仪表板 The solution was to put 解决方案是

remove_action( 'login_init', 'send_frame_options_header' );
remove_action( 'admin_init', 'send_frame_options_header' );

in the functions.php file. 在functions.php文件中。 Worked like a charm. 工作就像一个魅力。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM