Viewing 3 replies - 1 through 3 (of 3 total)
  • raytri

    (@raytri)

    I’d like to second this question. Since upgrading to WordPress 3.9, I can’t get style_formats to work. I do the following:

    Option name:
    style_formats

    Value:

    [
    {title: 'Dashed border', classes: 'green-border'}
    ]

    The “Dashed border” text shows up in the “Formats” dropdown, but it doesn’t apply the “green-border” class to selected elements.

    zmalik

    (@zmalik)

    Bear with me the long story but it might help 🙂

    For me style_formats were working by manually adding related code to my theme function file but I wanted tinymce cool features + custom format. Somehow I first tried tweaking the main plugin but it didn’t work. Settings got loaded properly as per tinymce instructions but they were not taking effect. Then I stumbled upon this utility again the same. I was able to add style_formats via backend interface but still not effects. My format dropdown just loaded styles for editor_css. No custom defined styles!

    At the very last moment i just noticed an option in main tinymce advance plugin “Load the CSS classes used in editor-style.css and replace the Formats button and sub-menu.” And for me it was check ! Poor bad mistake but it really caused me to abandon this gr8 utility. It was straight forward my tinymce advance was intentionally not loading style_formats as defined. After disabling this option custom formats worked like a charm. It worked via all ways i-e Adding code in theme funtion.php , tweaking parent plugin init method or defining it via configuration plugin.

    All hail for TINYMCE creators and TINYMCE WordPress Plugin developer 🙂

    raytri

    (@raytri)

    Okay, I figured out what the problem was. When using style_formats, you apparently have to specify a selector — there’s no default “apply to everything”.

    So the following worked for me:

    [
    {title: 'Dashed border', selector:'p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li,img,table', classes: 'green-border'}
    ]
Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘How do you add custom CSS classes’ is closed to new replies.