Index: google_admanager.module
===================================================================
--- google_admanager.module	(revision 746)
+++ google_admanager.module	(working copy)
@@ -112,4 +112,56 @@
   drupal_add_js('GA_googleFetchAds();', 'inline');
     
   return '<script type="text/javascript">GA_googleFillSlot("' . $ad_slot . '");</script>';
+}
+
+/**
+ * Implementation of hook_filter().
+ *
+ * Filter option to enable Google Admanager filter [google_ad:ad_slot]
+ * @see google_admanager_nodeapi()
+ */
+function google_admanager_filter($op, $delta = 0, $format = -1, $text = '') {
+  switch ($op) {
+    case 'list':
+      return array(0 => t('Google Admanager filter'));
+
+    case 'description':
+      return t('Substitutes [google_ad:ad_slot] tags with the Google Admanager script.');
+
+    case 'prepare':
+      return $text;
+
+    case 'process':
+      return _google_admanager_substitute_tags($text);
+  }
+}
+
+/**
+ * Implementation of hook_filter_tips().
+ */
+function google_admanager_filter_tips($delta, $format, $long = FALSE) {
+  return t('You may use [google_ad:ad_slot] to display Google Admanager ads within your content.');
+}
+
+/**
+ * Replace all Admanager tags with their corresponding files or images.
+ *
+ * @param object $text
+ *   The text to process.
+ *
+ * @return string
+ *   The processed content of the given text.
+ */
+function _google_admanager_substitute_tags($text) {
+  if (preg_match_all("/\[(google_ad):([^=\\]]+)=?([^\\]]*)?\]/i", $text, $match)) {
+    $id = variable_get('google_admanager_account', '');
+    $s = $r = array();
+    foreach ($match[2] as $key => $ad_slot) {
+      $s[] = $match[0][$key];
+      $r[] = theme('google_admanager_block', $id, $ad_slot);
+    }
+    // Perform the replacements and return processed field.
+    return str_replace($s, $r, $text);
+  }
+  return $text;
 }
\ No newline at end of file
