Created
          August 19, 2019 09:30 
        
      - 
      
- 
        Save lilumi/64e822a294ad8d7ff3cfb8ba958213ac to your computer and use it in GitHub Desktop. 
    Always Fresh Editor_style in TinyMCE WYSIWYG
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | <?php | |
| add_filter( 'mce_css', 'lm_fresh_editor_style' ); | |
| /** | |
| * Adds a parameter of the last modified time to all editor stylesheets. | |
| * | |
| * @wp-hook mce_css | |
| * @param string $css Comma separated stylesheet URIs. | |
| * @return string $css Comma separated stylesheet URIs with version timestamp. | |
| */ | |
| function lm_fresh_editor_style( $css ) { | |
| global $editor_styles; | |
| if ( empty( $css ) or empty( $editor_styles ) ) { | |
| return $css; | |
| } | |
| // Modified copy of _WP_Editors::editor_settings() | |
| $mce_css = array(); | |
| $style_uri = get_stylesheet_directory_uri(); | |
| $style_dir = get_stylesheet_directory(); | |
| if ( is_child_theme() ) { | |
| $template_uri = get_template_directory_uri(); | |
| $template_dir = get_template_directory(); | |
| foreach ( $editor_styles as $file ) { | |
| if ( $file && file_exists( "$template_dir/$file" ) ) { | |
| $mce_css[] = add_query_arg( | |
| 'version', | |
| filemtime( "$template_dir/$file" ), | |
| "$template_uri/$file" | |
| ); | |
| } | |
| } | |
| } | |
| foreach ( $editor_styles as $file ) { | |
| if ( $file && file_exists( "$style_dir/$file" ) ) { | |
| $mce_css[] = add_query_arg( | |
| 'version', | |
| filemtime( "$style_dir/$file" ), | |
| "$style_uri/$file" | |
| ); | |
| } | |
| } | |
| return implode( ',', $mce_css ); | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment