@captain_planet
So I managed to add tinymce plugins by adding them to the wpforo plugins folder, and editing the class-template.php file... that was really easy.
Trying to do that via the functions file and I am struggling for some reason... have literally spent hours trying to work out why what you had don't was not working and I believe I have worked it out.
The filter does not work because the array is being reinitialised, effectively making the filter absolutely pointless.
add_filter( 'mce_external_plugins', 'custom_mce_plugins');
function custom_mce_plugins( $plugin_array ) {
$plugin_array['image'] = get_stylesheet_directory_uri() . '/tinymce-plugins/image/plugin.js';
return $plugin_array;
};
The above is my fairly basic filter to load the plugin - basically the same as yours.
I added some logging in wpForo's class-template.php file to output the return $plugin_array for the add_mce_external_plugins function - the below is the output and clearly out filter has not worked:
Array
(
[wpforo_pre_button] => https://staging.abcde.xyz/wp-content/plugins/wpforo/wpf-assets/js/tinymce-pre.js
[wpforo_link_button] => https://staging.abcde.xyz/wp-content/plugins/wpforo/wpf-assets/js/tinymce-link.js
[wpforo_spoiler_button] => https://staging.abcde.xyz/wp-content/plugins/wpforo/wpf-assets/js/tinymce-spoiler.js
[wpforo_source_code_button] => https://staging.abcde.xyz/wp-content/plugins/wpforo/wpf-assets/js/tinymce-code.js
[emoticons] => https://staging.abcde.xyz/wp-content/plugins/wpforo/wpf-assets/js/tinymce-emoji.js
)
Below is a screenshot of the function, in which you can see the logging I added. You will also notice that the function starts by reinitialising the array:
If I comment out just that one line and refresh the page, the log output now shows:
Array
(
[image] => https://staging.abcde.xyz/wp-content/themes/airi-child/tinymce-plugins/image/plugin.js
[wpforo_pre_button] => https://staging.abcde.xyz/wp-content/plugins/wpforo/wpf-assets/js/tinymce-pre.js
[wpforo_link_button] => https://staging.abcde.xyz/wp-content/plugins/wpforo/wpf-assets/js/tinymce-link.js
[wpforo_spoiler_button] => https://staging.abcde.xyz/wp-content/plugins/wpforo/wpf-assets/js/tinymce-spoiler.js
[wpforo_source_code_button] => https://staging.abcde.xyz/wp-content/plugins/wpforo/wpf-assets/js/tinymce-code.js
[emoticons] => https://staging.abcde.xyz/wp-content/plugins/wpforo/wpf-assets/js/tinymce-emoji.js
)
I had already implemented this filter to add the Image button to the toolbar (as well as enable Paste as Text by default), so when I refreshed the page, I had an amazing Image button. I had just appended it to the end of the string, so it actually pushed the Full Screen button to the left next to the others, took its place on the far right - only a minor thing and can be sorted out later.
add_filter( 'wpforo_editor_settings', function( $settings ){
$settings['tinymce']['toolbar1'] .= ',image';
$settings['tinymce']['paste_as_text'] = 'true';
return $settings;
} );
I have already read elsewhere that a few additional lines of code are needed to display the File Browser button next to the Source field, and that is something I will probably look into next.
@robert / @Sofy
So when this was said:
restriction is made by wpForo developers
Is this what you meant? The functions for the other filters you have do not reinitialise the arrays, so any particular reason why this does? If for some reason you need to reset it, then your filter is the wrong way around, because in that scenario you would