mirror of
https://github.com/10h30/trestle.git
synced 2026-06-05 15:09:35 +09:00
Add post-id-xx or page-id-xx class to TinyMCE previews
This commit is contained in:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user