|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Module Name: WordPress.com Compose |
|
4
|
|
|
* Module Description: Allow new block editor posts to be composed on WordPress.com. |
|
5
|
|
|
* Jumpstart Description: Allow new block editor posts to be composed on WordPress.com. |
|
6
|
|
|
* Sort Order: 15 |
|
7
|
|
|
* First Introduced: 7.2 |
|
8
|
|
|
* Requires Connection: Yes |
|
9
|
|
|
* Auto Activate: No |
|
10
|
|
|
* Module Tags: Writing |
|
11
|
|
|
* Feature: Writing |
|
12
|
|
|
* Additional Search Queries: iframes, allow, compose, WordPress.com, block |
|
13
|
|
|
*/ |
|
14
|
|
|
|
|
15
|
|
|
function jetpack_disable_send_frame_options_header() { |
|
16
|
|
|
if ( jetpack_framing_allowed() ) { |
|
17
|
|
|
remove_action( 'admin_init', 'send_frame_options_header' ); |
|
18
|
|
|
} |
|
19
|
|
|
} |
|
20
|
|
|
add_action( 'admin_init', 'jetpack_disable_send_frame_options_header', 1 ); // High priority to get ahead of send_frame_options_header |
|
21
|
|
|
|
|
22
|
|
|
function jetpack_get_frame_nonce() { |
|
23
|
|
|
return wp_create_nonce( 'frame-' . Jetpack_Options::get_option( 'id' ) ); |
|
24
|
|
|
} |
|
25
|
|
|
|
|
26
|
|
|
function jetpack_framing_allowed() { |
|
27
|
|
|
if ( empty( $_GET['frame-nonce'] ) ) { |
|
28
|
|
|
return false; |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
$verified = wp_verify_nonce( $_GET['frame-nonce'], 'frame-' . Jetpack_Options::get_option( 'id' ) ); |
|
32
|
|
|
|
|
33
|
|
|
if ( $verified ) { |
|
34
|
|
|
define( 'IFRAME_REQUEST', true ); |
|
35
|
|
|
return true; |
|
36
|
|
|
} |
|
37
|
|
|
return false; |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* Automatically add frame-nonce to any admin_url() calls when the current page is framed. |
|
42
|
|
|
*/ |
|
43
|
|
|
function jetpack_auto_frame_nonce( $url ) { |
|
44
|
|
|
if ( jetpack_framing_allowed() ) { |
|
45
|
|
|
$url = add_query_arg( array( 'frame-nonce' => jetpack_get_frame_nonce() ), $url ); |
|
46
|
|
|
} |
|
47
|
|
|
return $url; |
|
48
|
|
|
} |
|
49
|
|
|
add_filter( 'admin_url', 'jetpack_auto_frame_nonce' ); |
|
50
|
|
|
|
|
51
|
|
|
function jetpack_add_iframed_body_class( $classes ) { |
|
52
|
|
|
if ( jetpack_framing_allowed() ) { |
|
53
|
|
|
$classes .= ' is-iframed '; |
|
54
|
|
|
} |
|
55
|
|
|
return $classes; |
|
56
|
|
|
} |
|
57
|
|
|
add_filter( 'admin_body_class', 'jetpack_add_iframed_body_class' ); |
|
58
|
|
|
|