• Resolved duckpindesign

    (@duckpindesign)


    I want to add something “after” ALL existing and/or future fields of type “WYSIWYG”.

    I could manually add the “after” attribute to every field when it gets created like:

    ‘after’ => ‘test_123’

    but would prefer if there was a way to apply it globally to all WYSIWYG fields one time. Is there a way to do that?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    No way that I can presently see for that topic. One alternative idea would be to pass a callback function instead of a hardcoded string. The reason for this idea would be that you don’t need to go into each parameter and update, you could update in one spot and have the changes reflect in all of them.

    'after' => 'my_callback'
    
    function my_callback() {
        return 'test_123';
    }
    

    Just a quick thought.

    Thread Starter duckpindesign

    (@duckpindesign)

    @tw2113

    Thanks. I was imagining test_123 to be the callback function – I could have done a better job of describing/labeling that.

    To expand on my goal – although it does sound like it won’t be possible, I am referencing this:
    https://github.com/CMB2/CMB2/issues/1141

    User “jsternberg” setup a great snippet for adding a word counter to a wysiwyg field via the “after” parameter.
    https://github.com/CMB2/CMB2-Snippet-Library/blob/master/misc/adding-wordcount-to-cmb2-wysiwyg-field.php

    But, the downside is that it doesn’t simply apply to all wysiwyg fields – it needs to be added manually to each wysiwyg field where created.

    So my overall goal was to force all wysiwyg fields to make use of the callback that “jsternberg” wrote: cmb2_wysiwyg_word_counter

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Noted, regarding what Justin provided there. I know that was a really recent GH issue as well.

    Other than that, I’m not aware of any global solution for this.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘“after” for all fields of type “wysiwyg”’ is closed to new replies.