Make WordPress Core

Ticket #11512: add_editor_style.4.diff

File add_editor_style.4.diff, 3.1 KB (added by nacin, 15 years ago)

Less work being done

  • wp-admin/includes/post.php

     
    13051305 * @param mixed $settings optional An array that can add to or overwrite the default TinyMCE settings.
    13061306 */
    13071307function wp_tiny_mce( $teeny = false, $settings = false ) {
    1308         global $concatenate_scripts, $compress_scripts, $tinymce_version;
     1308        global $concatenate_scripts, $compress_scripts, $tinymce_version, $editor_styles;
    13091309
    13101310        if ( ! user_can_richedit() )
    13111311                return;
     
    14671467                'plugins' => $plugins
    14681468        );
    14691469
    1470         $mce_css = trim(apply_filters('mce_css', ''), ' ,');
     1470        if ( ! empty( $editor_styles ) && is_array( $editor_styles ) ) {
     1471                $mce_css = array();
     1472                $style_uri = get_stylesheet_directory_uri();
     1473                if ( TEMPLATEPATH == STYLESHEETPATH ) {
     1474                        foreach ( $editor_styles as $file )
     1475                                $mce_css[] = "$style_uri/$file";
     1476                } else {
     1477                        $style_dir    = get_stylesheet_directory();
     1478                        $template_uri = get_template_directory_uri();
     1479                        $template_dir = get_template_directory();
     1480                        foreach ( $editor_styles as $file ) {
     1481                                if ( file_exists( "$style_dir/$file" ) )
     1482                                        $mce_css[] = "$style_uri/$file";
     1483                                if ( file_exists( "$template_dir/$file" ) )
     1484                                        $mce_css[] = "$template_uri/$file";
     1485                        }
     1486                }
     1487                $mce_css = implode( ',', $mce_css );
     1488        } else {
     1489                $mce_css = '';
     1490        }
    14711491
     1492        $mce_css = trim( apply_filters( 'mce_css', $mce_css ), ' ,' );
     1493
    14721494        if ( ! empty($mce_css) )
    14731495                $initArray['content_css'] = $mce_css;
    14741496
  • wp-includes/theme.php

     
    14651465        if ( ! is_admin() )
    14661466                return;
    14671467
    1468         global $editor_style;
    1469         $editor_style = (array) $editor_style;
    1470         $stylesheet   = (array) $stylesheet;
    1471         foreach ( $stylesheet as $file ) {
    1472                 if ( file_exists( get_stylesheet_directory() . "/$file" )
    1473                         && ( $uri = get_stylesheet_directory_uri() . "/$file" )
    1474                         && ! in_array( $uri, $editor_style ) )
    1475                         $editor_style[] = $uri;
    1476                 elseif ( TEMPLATEPATH !== STYLESHEETPATH
    1477                         && file_exists( get_template_directory() . "/$file" )
    1478                         && ( $uri = get_template_directory_uri() . "/$file" )
    1479                         && ! in_array( $uri, $editor_style ) )
    1480                         $editor_style[] = $uri;
    1481         }
    1482         add_filter( 'mce_css', '_editor_style_cb' );
     1468        global $editor_styles;
     1469        $editor_styles = (array) $editor_styles;
     1470        $stylesheet    = (array) $stylesheet;
     1471        $editor_styles = array_merge( $editor_styles, $stylesheet );
    14831472}
    14841473
    14851474/**
    1486  * Callback for custom editor stylesheet support.
    1487  *
    1488  * @since 3.0.0
    1489  * @see add_editor_style()
    1490  * @access protected
    1491  */
    1492 function _editor_style_cb( $url ) {
    1493         global $editor_style;
    1494         if ( ! empty( $url ) )
    1495                 $url .= ',';
    1496         return $url . implode( ',', $editor_style );
    1497 }
    1498 
    1499 /**
    15001475 * Allows a theme to register its support of a certain feature
    15011476 *
    15021477 * Must be called in the themes functions.php file to work.
     
    15201495 * @param string $feature the feature being checked
    15211496 * @return boolean
    15221497 */
    1523 
    15241498function current_theme_supports( $feature ) {
    15251499        global $_wp_theme_features;
    15261500