Use the global variable $editor_styles
(here are your theme’s and parent theme’s editor stylesheets stored already), add the time of the file’s last modification as a parameter and rebuild the string.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | <?php # -*- coding: utf-8 -*- /** * Plugin Name: Refresh Editor Stylesheets * Description: Enforces fresh editor stylesheets per version parameter. * Version: 2012.07.21 * Author: Fuxia * Plugin URI: http://wordpress.stackexchange.com/q/33318/73 * Author URI: https://fuxia.me * License: MIT * License URI: http://www.opensource.org/licenses/mit-license.php */ add_filter( 'mce_css', 't5_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 */ function t5_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 $key => $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 ); } |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.