Add a CKeditor plugin to your Wysiwyg profile

There are many CKEditor plugins available which provide special functionality - mostly new buttons - for your editor. One is CodeSnippet, which adds a simple way to add formatted code snippets to your textfields.

To add the plugin to your editor you need to do 3 things:

  1. Download a CKEditor build which includes the plugin and its dependencies.
  2. Implement hook_wysiwyg_plugin to make the plugin visible to Drupal and the Wysiwyg module.
  3. Add the button to your Wysiwyg profile.

Implement hook_wysiwyg_plugin

function MY_MODULE_wysiwyg_plugin($editor, $version) {
  $path = wysiwyg_get_path('ckeditor');

  switch ($editor) {
    case 'ckeditor':
        return array(
          'codesnippet' => array(
            'path' => $path . '/plugins/codesnippet',
            'buttons' => array('CodeSnippet' => t('CodeSnippet')),
            'url' => '',
            'load' => TRUE,

Bonus: Use highlight.js for syntax highlighing

This one is easy, simply install the highlight_js module.