-
Notifications
You must be signed in to change notification settings - Fork 808
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add asetting to allow the JP site to be iframed by WordPress.com.
- Loading branch information
Showing
5 changed files
with
103 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<?php | ||
/** | ||
* Module Name: WordPress.com Compose | ||
* Module Description: Allow new block editor posts to be composed on WordPress.com. | ||
* Jumpstart Description: Allow new block editor posts to be composed on WordPress.com. | ||
* Sort Order: 15 | ||
* First Introduced: 7.2 | ||
* Requires Connection: Yes | ||
* Auto Activate: No | ||
* Module Tags: Writing | ||
* Feature: Writing | ||
* Additional Search Queries: iframes, allow, compose, WordPress.com, block | ||
*/ | ||
|
||
function jetpack_disable_send_frame_options_header() { | ||
if ( jetpack_framing_allowed() ) { | ||
remove_action( 'admin_init', 'send_frame_options_header' ); | ||
} | ||
} | ||
add_action( 'admin_init', 'jetpack_disable_send_frame_options_header', 1 ); // High priority to get ahead of send_frame_options_header | ||
|
||
function jetpack_get_frame_nonce() { | ||
return wp_create_nonce( 'frame-' . Jetpack_Options::get_option( 'id' ) ); | ||
} | ||
|
||
function jetpack_framing_allowed() { | ||
if ( empty( $_GET['frame-nonce'] ) ) { | ||
return false; | ||
} | ||
|
||
$verified = wp_verify_nonce( $_GET['frame-nonce'], 'frame-' . Jetpack_Options::get_option( 'id' ) ); | ||
|
||
if ( $verified ) { | ||
define( 'IFRAME_REQUEST', true ); | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
/** | ||
* Automatically add frame-nonce to any admin_url() calls when the current page is framed. | ||
*/ | ||
function jetpack_auto_frame_nonce( $url ) { | ||
if ( jetpack_framing_allowed() ) { | ||
$url = add_query_arg( array( 'frame-nonce' => jetpack_get_frame_nonce() ), $url ); | ||
} | ||
return $url; | ||
} | ||
add_filter( 'admin_url', 'jetpack_auto_frame_nonce' ); | ||
|
||
function jetpack_add_iframed_body_class( $classes ) { | ||
if ( jetpack_framing_allowed() ) { | ||
$classes .= ' is-iframed '; | ||
} | ||
return $classes; | ||
} | ||
add_filter( 'admin_body_class', 'jetpack_add_iframed_body_class' ); |