function filterContent($content)
 {
     $content = EzGA::preFilter($content);
     if (EzGA::$noAds) {
         return $content;
     }
     if (!empty($this->options['force_widget']) && self::$ezCount == 0) {
         // reserve a count for the widget
         self::$ezMax--;
     }
     $plgName = EzGA::getPlgName();
     if (self::$ezCount >= self::$ezMax) {
         return $content . " <!-- {$plgName}: Unfiltered [count: " . self::$ezCount . " is not less than " . self::$ezMax . "] -->";
     }
     $adMax = self::$ezMax;
     $adCount = 0;
     if (!is_singular()) {
         if (isset(EzGA::$options['excerptNumber'])) {
             $adMax = EzGA::$options['excerptNumber'];
         }
     }
     list($content, $return) = EzGA::filterShortCode($content);
     if ($return) {
         return $content;
     }
     $this->handleDefaults();
     $wc = str_word_count($content);
     $metaOptions = EzGA::getMetaOptions();
     $show_leadin = $metaOptions['show_leadin'];
     $leadin = '';
     if ($show_leadin != 'no' && empty($this->options['header_leadin']) && $wc > $this->options['wc_leadin']) {
         if (self::$ezCount < self::$ezMax && $adCount++ < $adMax) {
             $leadin = $this->mkAdBlock("leadin");
         }
     }
     $show_midtext = $metaOptions['show_midtext'];
     $midtext = '';
     if ($show_midtext != 'no' && $wc > $this->options['wc_midtext']) {
         if (self::$ezCount < self::$ezMax && $adCount++ < $adMax) {
             if (!EzGA::$foundShortCode) {
                 $paras = EzGA::findParas($content);
                 $half = sizeof($paras);
                 while (sizeof($paras) > $half) {
                     array_pop($paras);
                 }
                 $split = 0;
                 if (!empty($paras)) {
                     $split = $paras[floor(sizeof($paras) / 2)];
                 }
                 if ($this->options['force_midad'] || $half > 10) {
                     $midtext = $this->mkAdBlock("midtext");
                     $content = substr($content, 0, $split) . $midtext . substr($content, $split);
                 }
             } else {
                 $midtext = $this->mkAdBlock("midtext");
             }
         }
     }
     $show_leadout = $metaOptions['show_leadout'];
     $leadout = '';
     if ($show_leadout != 'no' && $wc > $this->options['wc_leadout']) {
         if (self::$ezCount < self::$ezMax && $adCount++ < $adMax) {
             $leadout = $this->mkAdBlock("leadout");
             if (!EzGA::$foundShortCode && strpos($show_leadout, "float") !== false) {
                 $paras = EzGA::findParas($content);
                 $split = array_pop($paras);
                 if (!empty($split)) {
                     $content1 = substr($content, 0, $split);
                     $content2 = substr($content, $split);
                 }
             }
         }
     }
     if (!empty($this->options['header_leadin'])) {
         $this->leadin = $leadin;
         $leadin = '';
     }
     if (!empty($this->options['footer_leadout'])) {
         $this->leadout = $leadout;
         $leadout = '';
     }
     if (EzGA::$foundShortCode) {
         $content = EzGA::handleShortCode($content, $leadin, $midtext, $leadout);
     } else {
         if (empty($content1)) {
             $content = $leadin . $content . $leadout;
         } else {
             $content = $leadin . $content1 . $leadout . $content2;
         }
     }
     return $content;
 }