black-studio / black-studio-tinymce-widget

Black Studio TinyMCE Widget plugin for WordPress
https://wordpress.org/plugins/black-studio-tinymce-widget/
GNU General Public License v3.0
22 stars 13 forks source link

MMP integration example #24

Closed cfoellmann closed 5 years ago

cfoellmann commented 9 years ago

There will be a new (completely refactored :imp:) version of https://github.com/Dev7studios/media-manager-plus soon which integrates nicely with the widget if the user adds this:

<?php
/**
 * Requires Media Manager Plus >= 1.5
 * Load MMP assets on widgets and customizer page to extend Black Studio Widget
 *
 * @param array $pages
 * @return array
 */
function mmp_add_enqueue_pages( $pages ) {

    $pages[] = 'widgets.php';

    return $pages;

} // END
add_filter( 'mmp_enqueue_pages' , 'mmp_add_enqueue_pages' );

The MMP plugin is not wide-spread but I think you could add this code snippet to the readme.txt to be available on wp.org. I will let you know when the compatible version (1.5) is released. I think it will be after your 2.0 release.

marcochiesi commented 9 years ago

I think the above snippet could be integrated directly in the plugin (in the class Black_Studio_TinyMCE_Compatibility_Plugins), with no need for custom snippets. By the way it could even be extended for being used together with 3rd party plugins based on widgets (i.e. Page Builder or WP Page Widget), which use also admin pages different from 'widgets.hp'.

cfoellmann commented 9 years ago

That is your choice.


For my installation I will remove this class-compatibility-plugins.php stuff anyway. I do not use all these plugins and do not want to load this code but that is my problem. I am very, very OCD when it comes to "unneeded" code

marcochiesi commented 9 years ago

I respect your opinion and I agree that include unneeded code is not a good practice in general. At the same time I think that adding a custom snippet of code is probably beyond the ability of the average WP user. Most WP users are accustomed to things working out of the box, with no need to perform "complex" operations like editing a PHP file to let a plugin be compatible with another. I think a solution may be to provide an Options screen which allows the user to select which compatibility code should be included and which not. Default settings could be detected at plugin activation, depending on which plugin are actually present. Another option is to provide a hook to exclude compatibility code from being included. By the way, maybe it would be better to split the compatibility code in different classes, one for each 3rd party plugin.

cfoellmann commented 9 years ago
marcochiesi commented 9 years ago

Added in ab0a92bc90df34a3407805738474d3564e3789bd the ability to exclude loading of compatibility code. Example: add_filter( 'black_studio_tinymce_load_compatibility', '__return_false' ); There are also other filters giving more control on what should be loaded.