php - add_editor_style always loads old css file from my wordpress plugin -
add_editor_style
loads old css file plugin.
my code below :
function admin_add_editor_styles() { $filepath = plugins_url( 'css/style.css', __file__); add_editor_style($filepath); } add_action( 'init', 'admin_add_editor_styles' );
the css file dynamic. first time runs perfect. when add together css classes style.css
so newly added classes not include editor css. if rename style.css
style2.css
works.
on admin panel there textarea can set custom css class , content of textarea saved style.css
file.
then, should add together form of version control. like:
$filepath = plugins_url( 'css/style.css', __file__) . '?ver=' . rand(0,100); add_editor_style($filepath);
but instead of random, internal command using get_option
, update_option
whenever style saved in custom css editor. like:
// on editor, when saving modifications $old_value = get_option( 'my_css_version' ); $new_value = $old_value + 1; update_option( 'my_css_version', $new_value ); // on style load $version = get_option( 'my_css_version' ); $filepath = plugins_url( 'css/style.css', __file__) . '?ver=' . $version;
php wordpress plugins
No comments:
Post a Comment