How to change the editor buttons when it is loaded by Ajax in 3.0.0
The answer is to create a hook into ap_ajax_load_tinymce_assets, and add my tinymce layout there.
add_filter('ap_ajax_load_tinymce_assets', 'myAnsPressFilterEditorbuttons', 5);
function myAnsPressFilterEditorButtons() { add_filter("mce_buttons", "myFrontEditorButtonsFirstRow",99); //targets the first line add_filter("mce_buttons_2", "myFrontEditorButtonsSecondRow",99); //targets the second line }
function myFrontEditorButtonsFirstRow($buttons) { return array( "bold", "italic", "underline", "strikethrough", "bullist", "numlist", "blockquote", "mivhak_button" // ads the mivhak plugin //"bbpre" ); } function myFrontEditorButtonsSecondRow($buttons) { //return an empty array to remove this line return array(); }
However this does not add the buttons I would like because the plugins that extends tinymce are not loaded.
This is a problem and as suggested in my question below I really think the ajax loading of the editor should be removed.
How to change the editor buttons when it is loaded by Ajax in 3.0.0
Hi Rahul..
Do you have an update on this matter?
Hi Rahul.
Are there any news regarding this topic?
Hello Henrik, Have a look at this: https://github.com/anspress/anspress/blob/b2332ed41d8f057ec2344165fe763d814b4e6738/includes/hooks.php#L589
Hi Rahul.
Your example above does not solve the issue.
When the editor is loaded via ajax, any other plugins, which extends the mce_editor with buttons and features, are not loaded. They never gets initialized because the plugins are not loaded.
So when I add a button another plugin has added to the editor row just like in your example above, the editor buttons code string is not known so it is ignored.
And I do not see how this can be any different when the editor is loaded via ajax. So this is why i beg you to change this behaviour, or at least create a setting where you can decide if the editor should be loaded via ajax, or like it used to be in version 2.4.8.
And also the user experience of not having to load the editor is better, I actually prefer how it works here at anspress.io
Hi Rahul
As I wrote above your suggestion does not work, since the editor plugin is not loaded on Ajax.
Could you please consider not loading the editor by Ajax, just like it used to be, because the ajax load does not play well with other custom code / plugins on your wordpress site?
Please give me an update.
Thanks for detailed bug report. I will check and make sure it works with default behavior