How to change the editor buttons when it is loaded by Ajax in 3.0.0

5.81K viewsIssues
0

Hi

I had a hook that changed the editor icons to how I liked it in version 2.4.8

Now the editor is loaded by ajax, and the hook is not called.

Is there an action I can hook into so I can overwrite the editor icons when the editor is loaded from ajax?

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

commented on answer

Thanks for detailed bug report. I will check and make sure it works with default behavior

Hi Rahul..

Do you have an update on this matter?

Hi Rahul.

Are there any news regarding this topic?

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.