From 119078fc26d720af6123d435a0e0376d8e3c3220 Mon Sep 17 00:00:00 2001 From: Braad Date: Wed, 27 May 2015 14:38:05 -0700 Subject: [PATCH 1/2] Add post-id-xx or page-id-xx class to TinyMCE previews --- includes/admin/admin.php | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/includes/admin/admin.php b/includes/admin/admin.php index 9deedcd..d1412d1 100755 --- a/includes/admin/admin.php +++ b/includes/admin/admin.php @@ -95,6 +95,33 @@ function trestle_admin_actions() { } +add_filter( 'tiny_mce_before_init', 'trestle_tiny_mce_before_init' ); +/** + * Add custom classes to the body of TinyMCE previews. + * + * @since 2.1.0 + */ +function trestle_tiny_mce_before_init( $init_array ) { + + global $post; + + $screen = get_current_screen(); + + // If we're on an edit screen, add an appropriate 'post-id-XX' or 'page-id-XX'. + if ( 'edit' == $screen->parent_base ) { + + // Custom post types always use 'post', so we only need to handle pages. + $post_type = ( 'page' == $post->post_type ) ? 'page' : 'post'; + + $init_array['body_class'] .= sprintf( ' %s-id-%s', + $post_type, + $post->ID + ); + } + + return $init_array; +} + add_action( 'tgmpa_register', 'trestle_register_required_plugins' ); /** * Loads required & recommended plugins. From 2199c0709a1850de90b79e332b1518d7c5c46b94 Mon Sep 17 00:00:00 2001 From: Braad Date: Tue, 23 Jun 2015 12:32:11 -0700 Subject: [PATCH 2/2] Update @since to 2.2.0 --- includes/admin/admin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/admin/admin.php b/includes/admin/admin.php index d1412d1..eb10122 100755 --- a/includes/admin/admin.php +++ b/includes/admin/admin.php @@ -99,7 +99,7 @@ add_filter( 'tiny_mce_before_init', 'trestle_tiny_mce_before_init' ); /** * Add custom classes to the body of TinyMCE previews. * - * @since 2.1.0 + * @since 2.2.0 */ function trestle_tiny_mce_before_init( $init_array ) {