You are here

function hook_wysiwyg_plugin in Wysiwyg 5

Same name and namespace in other branches
  1. 5.2 wysiwyg.api.php \hook_wysiwyg_plugin()
  2. 6.2 wysiwyg.api.php \hook_wysiwyg_plugin()
  3. 6 wysiwyg.api.php \hook_wysiwyg_plugin()
  4. 7.2 wysiwyg.api.php \hook_wysiwyg_plugin()

hook_wysiwyg_plugin(). Return an array of editor plugins.

@todo Completely outdated; rewrite necessary.

Each wysiwyg editor as well as each contrib module implementing an editor plugin has to return an associative array of available plugins. Each module can add one or more plugins and editor buttons.

Notes for TinyMCE: A module is able to override almost all TinyMCE initialization settings. However, modules should only make use of that if a plugin really needs to, because customized configuration settings may clash with overrides by another module. TinyMCE automatically assigns the baseURL of your plugin to the plugin object. If you need to load or access additional files from your plugin directory, retrieve the path via this.baseURL. tinyMCE.baseURL returns the path of TinyMCE and not your module. For example:


initInstance: function(inst) {
  tinyMCE.importCSS(inst.getDoc(), this.baseURL + '/myplugin.css');
},

@todo Move this template into hooks.php.

Parameters

string $editor: An (lowercase) editor name to return plugins for.

Return value

array An associative array having internal plugin names as keys, an array of plugin meta-information as values:

  • type: 'external' (optional); if omitted, wysiwyg editors will likely search for the plugin in their own plugins folder.
  • title: A human readable title of the plugin.
  • description: A (one-line) description of the plugin.
  • path: The patch to the javascript plugin.
  • callback: A Drupal menu callback returning the plugin UI. A plugin should return a callback *or* a path.
  • icon: An icon (usually 16x16 pixels) for the plugin button (optional).
  • ... Any other custom editor settings (optional).
1 function implements hook_wysiwyg_plugin()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

wysiwyg_wysiwyg_plugin in ./wysiwyg.plugins.inc
Implementation of hook_wysiwyg_plugin().
2 invocations of hook_wysiwyg_plugin()
wysiwyg_add_plugin_settings in ./wysiwyg.module
Add settings for external plugins.
wysiwyg_get_plugins in ./wysiwyg.module
Return plugin metadata from the plugin registry.

File

./wysiwyg.api.php, line 43

Code

function hook_wysiwyg_plugin($editor) {
  switch ($editor) {
    case 'tinymce':
      return array(
        'myplugin' => array(
          'type' => 'external',
          'title' => t('My plugin title'),
          'description' => t('My plugin title'),
          // Regular callback URL for external TinyMCE plugins.
          'path' => drupal_get_path('module', 'mymodule') . '/myplugin',
          // Wysiwyg wrapper plugin AJAX callback.
          'callback' => url('myplugin/browse'),
          'icon' => drupal_get_path('module', 'mymodule') . '/myplugin/myplugin.png',
          'extended_valid_elements' => array(
            'tag[attribute1|attribute2=default_value]',
          ),
          // Might need to be set later on; after retrieving customized editor
          // layout.
          'theme_advanced_buttons1' => array(
            t('Button title (optional)') => 'myplugin',
          ),
        ),
      );
  }
}