You are here

function tinymce_wysiwyg_plugin_settings in TinyMCE 7

Build a JS settings array of native external plugins that need to be loaded separately.

1 string reference to 'tinymce_wysiwyg_plugin_settings'
tinymce_tinymce_extended_editor in includes/tinymce_extended.inc
Plugin implementation of hook_editor().

File

includes/tinymce_extended.inc, line 81
Editor integration functions for TinyMCE.

Code

function tinymce_wysiwyg_plugin_settings($editor, $profile, $plugins) {
  $settings = array();

  // Pull the list of required plugins from the TinyMCE JS settings.
  // TODO: Abstract the list of enabled plugins so we can get at this
  // information more easily?
  $editor_js_settings = tinymce_wysiwyg_settings($editor, $profile->settings, NULL);
  $plugins = explode(',', $editor_js_settings['extraPlugins']);
  $plugin_info = tinymce_plugins();
  foreach ($plugins as $name) {

    // Skip plugins that are no longer available.
    if (!isset($plugin_info[$name])) {
      continue;
    }
    $plugin = $plugin_info[$name];

    // Register all plugins that need to be loaded.
    $settings[$name] = array();

    // Add path for native external plugins.
    if (empty($plugin['internal']) && isset($plugin['path'])) {
      $settings[$name]['path'] = base_path() . $plugin['path'] . '/';
    }

    // TinyMCE defaults to 'plugin.js' on its own when filename is not set.
    if (!empty($plugin['file'])) {
      $settings[$name]['fileName'] = $plugin['file'];
    }
  }
  return $settings;
}