diff -rNup examples_CLEAN/wysiwyg_plugin_example/plugins/foo/foo.css examples/wysiwyg_plugin_example/plugins/foo/foo.css
--- examples/wysiwyg_plugin_example/plugins/foo/foo.css	1970-01-01 01:00:00.000000000 +0100
+++ examples/wysiwyg_plugin_example/plugins/foo/foo.css	2010-12-21 17:45:10.265049511 +0000
@@ -0,0 +1,5 @@
+/** $Id$ **/
+/**
+ * @file
+ * Add CSS required by the plugin here.
+ */
diff -rNup examples_CLEAN/wysiwyg_plugin_example/plugins/foo/foo.js examples/wysiwyg_plugin_example/plugins/foo/foo.js
--- examples/wysiwyg_plugin_example/plugins/foo/foo.js	1970-01-01 01:00:00.000000000 +0100
+++ examples/wysiwyg_plugin_example/plugins/foo/foo.js	2010-12-21 17:45:10.265049511 +0000
@@ -0,0 +1,65 @@
+// $Id$
+
+(function ($) {
+
+Drupal.wysiwyg.plugins['foo'] = {
+
+  /**
+   * Return whether the passed node belongs to this plugin (note that "node" in this context is a JQuery node, not a Drupal node).
+   *
+   * We identify code managed by this FOO plugin by giving it the HTML class
+   * 'wysiwyg_plugin_example-foo'.
+   */
+  isNode: function(node) {
+    res = $(node).is('img.wysiwyg_plugin_example-foo');
+    return ($(node).is('img.wysiwyg_plugin_example-foo'));
+  },
+
+  /**
+   * Invoke is called when the toolbar button is clicked.
+   */
+  invoke: function(data, settings, instanceId) {
+     // Typically, an icon might be added to the WYSIWYG, which HTML gets added
+     // to the plain-text version.
+     if (data.format == 'html') {
+       var content = this._getPlaceholder(settings);
+     }
+     else {
+       var content = '<!--wysiwyg_example_plugin-->';
+     }
+     if (typeof content != 'undefined') {
+       Drupal.wysiwyg.instances[instanceId].insert(content);
+     }
+   },
+
+  /**
+   * Replace all <!--wysiwyg_example_plugin--> tags with the icon.
+   */
+  attach: function(content, settings, instanceId) {
+    content = content.replace(/<!--wysiwyg_example_plugin-->/g, this._getPlaceholder(settings));
+    return content;
+  },
+
+  /**
+   * Replace the icons with <!--wysiwyg_example_plugin--> tags in content upon detaching editor.
+   */
+  detach: function(content, settings, instanceId) {
+    var $content = $('<div>' + content + '</div>');
+    $.each($('img.wysiwyg_plugin_example-foo', $content), function (i, elem) {
+      elem.parentNode.insertBefore(document.createComment('wysiwyg_example_plugin'), elem);
+      elem.parentNode.removeChild(elem);
+    });
+    return $content.html();
+  },
+
+  /**
+   * Helper function to return a HTML placeholder.
+   *
+   * Here we provide an image to visually represent the hidden HTML in the Wysiwyg editor.
+   */
+  _getPlaceholder: function (settings) {
+    return '<img src="' + settings.path + '/images/foo.content_icon.gif" alt="&lt;--wysiwyg_example_plugin-&gt;" title="&lt;--wysiwyg_example_plugin--&gt;" class="wysiwyg_plugin_example-foo drupal-content" />';
+  }
+};
+
+})(jQuery);
Binary files examples_CLEAN/wysiwyg_plugin_example/plugins/foo/images/foo.content_icon.gif and examples/wysiwyg_plugin_example/plugins/foo/images/foo.content_icon.gif differ
Binary files examples_CLEAN/wysiwyg_plugin_example/plugins/foo/images/foo.toolbar_icon.gif and examples/wysiwyg_plugin_example/plugins/foo/images/foo.toolbar_icon.gif differ
diff -rNup examples_CLEAN/wysiwyg_plugin_example/plugins/foo/langs/en.js examples/wysiwyg_plugin_example/plugins/foo/langs/en.js
--- examples/wysiwyg_plugin_example/plugins/foo/langs/en.js	1970-01-01 01:00:00.000000000 +0100
+++ examples/wysiwyg_plugin_example/plugins/foo/langs/en.js	2010-12-21 17:45:10.265049511 +0000
@@ -0,0 +1,7 @@
+// $Id$
+
+tinyMCE.addToLang('foo', {
+  title: 'Insert example comment',
+  desc: 'Insert a comment from the example wysiwyg plugin'
+});
+
diff -rNup examples_CLEAN/wysiwyg_plugin_example/plugins/foo.inc examples/wysiwyg_plugin_example/plugins/foo.inc
--- examples/wysiwyg_plugin_example/plugins/foo.inc	1970-01-01 01:00:00.000000000 +0100
+++ examples/wysiwyg_plugin_example/plugins/foo.inc	2010-12-21 17:45:10.265049511 +0000
@@ -0,0 +1,23 @@
+<?php
+// $Id$
+
+/**
+ * @file
+ * Example Wysiwyg API integration plugin.
+ */
+
+/**
+ * Specially named implementation of hook_wysiwyg_plugin().
+ *
+ * Should be named {$module}_{$plugin}_plugin().
+ */
+function wysiwyg_plugin_example_foo_plugin() {
+  $plugins['foo'] = array(
+    'title' => t('Foo: an example wysiwyg plugin'),
+    // The 'icon file' is the icon that appears in the Wysiwyg toolbar.
+    'icon file' => 'foo.toolbar_icon.gif',
+    'icon title' => t('An example wysiwyg plugin'),
+    'settings' => array(),
+  );
+  return $plugins;
+}
diff -rNup examples_CLEAN/wysiwyg_plugin_example/wysiwyg_plugin_example.info examples/wysiwyg_plugin_example/wysiwyg_plugin_example.info
--- examples/wysiwyg_plugin_example/wysiwyg_plugin_example.info	1970-01-01 01:00:00.000000000 +0100
+++ examples/wysiwyg_plugin_example/wysiwyg_plugin_example.info	2010-12-21 17:45:10.265049511 +0000
@@ -0,0 +1,4 @@
+; $Id$
+name = Example Wysiwyg Plugin
+description = Demonstrates how to integrate a plugin with the Wysiwyg module, to provide a button in the Wysiwyg toolbar.
+core = 6.x
diff -rNup examples_CLEAN/wysiwyg_plugin_example/wysiwyg_plugin_example.module examples/wysiwyg_plugin_example/wysiwyg_plugin_example.module
--- examples/wysiwyg_plugin_example/wysiwyg_plugin_example.module	1970-01-01 01:00:00.000000000 +0100
+++ examples/wysiwyg_plugin_example/wysiwyg_plugin_example.module	2010-12-21 17:45:10.265049511 +0000
@@ -0,0 +1,27 @@
+<?php
+// $Id$
+
+/**
+ * @file
+ * Example module to demonstrate how to integrate a Wysiwyg plugin, and provide
+ * a button in the Wysiwyg's toolbar.
+ */
+
+/**
+ * Implementation of hook_wysiwyg_include_directory().
+ *
+ * This tells the Wysiwyg module to search within the 'plugins' directory for
+ * Wysiwyg plugins.
+ *
+ * @param String $type
+ * The type of plugin being checked. One of:
+ * - editor: for WYSIWYG editors such as TinyMCE, CKEditor, Nice Edit, etc.
+ * - plugin: for toolbar buttons such as bold, add-image, strike-through, etc.
+ *
+ * @return String
+ * The path to the plugin directory (relative to this module). This is usually
+ * simply the plugin-type: e.g. "plugin" or "editor".
+ */
+function wysiwyg_plugin_example_wysiwyg_include_directory($type) {
+  return $type;
+}
