Home › Forums › Feature Requests › Add $field to wysiwyg_tinymce_settings hook
current implementation is:
mceInit = acf.apply_filters('wysiwyg_tinymce_settings', mceInit, mceInit.id);
could it be changed to include $field like this:
mceInit = acf.apply_filters('wysiwyg_tinymce_settings', mceInit, mceInit.id, $field);
i can get $field by jumping through some jquery hoops .. but it would be easier if it was just passed into the filter
The best place to submit this request would be here https://support.advancedcustomfields.com/new-ticket/
In the mean time, what are you looking to do that you need $field for? Maybe there’s a way to do it.
i’m trying to add a class to the ‘body_class’ setting of the tinymce editor before it gets initialized … i need to be able to add custom styles to different WYSIWYG ACF fields and the moment there is no way to differentiate them if there is more than one on a page
by including the $field i could then add a field specific class to each editor instance
I’m not familiar with this hook, what is the value of mceInit.id
ignore the comment that I deleted, I was looking at the wrong hook.
You can get the field key of the field if that helps you.
acf.add_filter('wysiwyg_tinymce_settings', function( mceInit, id ){
// do something to mceInit
console.log(id);
console.log($('#'+id).closest('.acf-field').data('key'));
// return
return mceInit;
});
thanks . .yeah i’m doing something like that .. but it’s not very intuitive .. seems like it could make it easier for everyone if a reference to $field was just passed through
Like I said, you should open a new ticket on this. $field is passed in the wysiwyg_tinymce_init
action and I’d think that Elliot would be probably add it to the wysiwyg_tinymce_settings
filter, but the best way for him to get the request is to open a support ticket.
I actually write a lot of custom JS for ACF lately and .closest('.acf-field').
is becoming something that I can type without thinking even needing to think, it’s programmed into my fingers at this point.
The topic ‘Add $field to wysiwyg_tinymce_settings hook’ is closed to new replies.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.