Introduce add_editor_style() to easily register a stylesheet for the visual editor. see #11512 see #9015
git-svn-id: http://svn.automattic.com/wordpress/trunk@13441 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
5db4b418c5
commit
45748141c0
|
@ -28,6 +28,9 @@ function twentyten_init() {
|
|||
|
||||
add_custom_background();
|
||||
|
||||
// This theme styles the visual editor with editor-style.css to match the theme style.
|
||||
add_editor_style();
|
||||
|
||||
// This theme needs post thumbnails
|
||||
add_theme_support( 'post-thumbnails' );
|
||||
|
||||
|
@ -134,20 +137,6 @@ function twentyten_comment( $comment, $args, $depth ) {
|
|||
}
|
||||
endif;
|
||||
|
||||
// Make the Visual Editor styles match the theme's styles
|
||||
if ( ! function_exists( 'twentyten_editor_style' ) ) :
|
||||
function twentyten_editor_style( $url ) {
|
||||
if ( ! empty( $url ) )
|
||||
$url .= ',';
|
||||
|
||||
// Change the path here if using sub-directory
|
||||
$url .= trailingslashit( get_stylesheet_directory_uri() ) . 'editor-style.css';
|
||||
|
||||
return $url;
|
||||
}
|
||||
endif;
|
||||
add_filter( 'mce_css', 'twentyten_editor_style' );
|
||||
|
||||
// Remove inline styles on gallery shortcode
|
||||
if ( ! function_exists( 'twentyten_remove_gallery_css' ) ) :
|
||||
function twentyten_remove_gallery_css() {
|
||||
|
|
|
@ -1446,6 +1446,43 @@ body {
|
|||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Add callback for a custom TinyMCE editor stylesheet.
|
||||
*
|
||||
* The parameter $stylesheet is the name of the stylesheet, relative to
|
||||
* the theme root. It is optional and defaults to 'editor-style.css'.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param callback $stylesheet Name of stylesheet relative to theme root.
|
||||
*/
|
||||
function add_editor_style( $stylesheet = 'editor-style.css' ) {
|
||||
if ( isset( $GLOBALS['editor_style'] ) )
|
||||
return;
|
||||
|
||||
add_theme_support( 'editor-style' );
|
||||
|
||||
if ( ! is_admin() )
|
||||
return;
|
||||
|
||||
$GLOBALS['editor_style'] = $stylesheet;
|
||||
add_filter( 'mce_css', '_editor_style_cb' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback for custom editor stylesheet.
|
||||
*
|
||||
* @since 3.0.0
|
||||
* @see add_editor_style()
|
||||
* @access protected
|
||||
*/
|
||||
function _editor_style_cb( $url ) {
|
||||
global $editor_style;
|
||||
if ( ! empty( $url ) )
|
||||
$url .= ',';
|
||||
return $url . get_stylesheet_directory_uri() . "/$editor_style";
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows a theme to register its support of a certain feature
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue