Merge pull request #15 from BraadMartin/dev

Add post-id-xx or page-id-xx class to TinyMCE previews on post/page edit screens
This commit is contained in:
Braad
2015-06-23 12:32:55 -07:00
+27
View File
@@ -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.2.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.