public function showPage()
    {
        /* @var $wp_rewrite WP_Rewrite */
        global $wp_rewrite;
        global $wp_version;
        if (isset($_POST['action']) && $_POST['action'] == 'save') {
            $this->save($_POST["EasyRecipe"]);
        }
        $data = new stdClass();
        foreach (self::$defaultSettings as $setting => $default) {
            $data->{$setting} = isset($this->{$setting}) ? $this->{$setting} : $default;
        }
        $data->settingsname = 'EasyRecipe';
        $wpurl = get_bloginfo("wpurl");
        $data->fdsite = preg_replace('%^(?:http://)(.*)$%i', '$1', $wpurl);
        $isWP39 = version_compare($wp_version, '3.9.dev', '>') > 0 ? 'true' : 'false';
        $editURL = "{$wpurl}/wp-admin/edit.php";
        $data->pluginversion = EasyRecipe::$pluginVersion;
        $license = $this->licenseKey;
        /**
         * Figure out what we need to display on the Fooderific tab
         *
         * If we had MBRB enabled but this is the first run, show the welcome (firstRun = true) and hide the "retrieving" splash
         * Otherwise, show the "retrieving" splash
         */
        $data->fdFirstRun = false;
        $data->fdNotEnabled = false;
        $fdAPIKey = $this->fooderificAPIKey;
        if (!$this->enableFooderific) {
            $data->fdNotEnabled = true;
            $data->retrieveclass = 'FDDisplayNone';
            $lastScan = 0;
        } else {
            if ($this->lastScanStarted == 0) {
                $data->fdFirstRun = true;
                $data->retrieveclass = 'FDDisplayNone';
                $lastScan = 0;
            } else {
                $data->retrieveclass = '';
                $tzOffet = get_option('gmt_offset');
                $lastScan = date_i18n("j M y g:ia", $this->lastScanStarted + $tzOffet * 3600);
            }
        }
        $pluginVersion = EasyRecipe::$pluginVersion;
        $data->javascript = <<<EOD
<script type="text/javascript">
//<![CDATA[
    window.EASYRECIPE = window.EASYRECIPE || {};
    EASYRECIPE.settingsName = 'EasyRecipe';
    EASYRECIPE.editURL = '{$editURL}';
    EASYRECIPE.pluginVersion = '{$pluginVersion}';
    EASYRECIPE.wpurl = '{$wpurl}';
    EASYRECIPE.license = '{$license}';
    EASYRECIPE.lastScan = '{$lastScan}';
    EASYRECIPE.fdAPIKey = '{$fdAPIKey}';
    EASYRECIPE.isWP39 = {$isWP39};
//]]>
</script>
EOD;
        /**
         * If the site isn't using permalinks then just pass the print stuff as a qurerystring param
         */
        $data->siteDiagnosticsURL = home_url();
        if (!$wp_rewrite->using_permalinks()) {
            $data->siteDiagnosticsURL .= "?";
        }
        $data->useFeaturedImageChecked = $this->useFeaturedImage ? 'checked="checked"' : '';
        $data->displayPrintChecked = $this->displayPrint ? 'checked="checked"' : '';
        $data->filterExcerptsChecked = $this->filterExcerpts ? 'checked="checked"' : '';
        $data->displayZiplistChecked = $this->displayZiplist ? 'checked="checked"' : '';
        $data->displayRecipeCardChecked = $this->displayRecipeCard ? 'checked="checked"' : '';
        $data->displayGMCChecked = $this->displayGMC ? 'checked="checked"' : '';
        $data->displayUltimateRecipeChecked = $this->displayUltimateRecipe ? 'checked="checked"' : '';
        $data->allowLinkChecked = $this->allowLink ? 'checked="checked"' : '';
        $data->convertFractionsChecked = $this->convertFractions ? 'checked="checked"' : '';
        $data->removeMFChecked = $this->removeMicroformat ? 'checked="checked"' : '';
        $data->fdLinkChecked = $this->enableFooderific ? 'checked="checked"' : '';
        $data->enableSwoopChecked = $this->enableSwoop ? 'checked="checked"' : '';
        $data->swoopclass = $this->enableSwoop ? '' : 'ERSNoSwoop';
        $data->forcejQueryChecked = $this->forcejQuery ? 'checked="checked"' : '';
        $data->noHTMLWarnChecked = $this->noHTMLWarn ? 'checked="checked"' : '';
        $data->genesisGridChecked = $this->genesisGrid ? 'checked="checked"' : '';
        $data->saveButtonZiplistChecked = $data->saveButtonSaltyFigChecked = $data->saveButtonNoneChecked = '';
        $data->ziplistclass = $data->saltyfigclass = "ERSDisplayNone";
        switch ($data->saveButton) {
            case 'Ziplist':
                $data->saveButtonZiplistChecked = 'checked="checked"';
                $data->ziplistclass = '';
                break;
            case 'SaltyFig':
                $data->saveButtonSaltyFigChecked = 'checked="checked"';
                $data->saltyfigclass = '';
                break;
            default:
                $data->saveButtonNoneChecked = 'checked="checked"';
                break;
        }
        $data->ratingEasyRecipeChecked = $data->ratingSelfRatedChecked = $data->ratingDisabledChecked = '';
        $ratingChecked = "rating" . $this->ratings . "Checked";
        $data->{$ratingChecked} = 'checked="checked"';
        $data->erSubscribeChecked = $this->erSubscribe ? 'checked="checked"' : '';
        $data->subscribeclass = $this->erSubscribe ? '' : 'ERSNoSubscribe';
        /*
         * Set up Swoop stuff
         */
        if ($data->swoopSiteID != '') {
            $data->registerswoop = 'ERSDisplayNone';
            $data->loginswoop = '';
        } else {
            $data->registerswoop = '';
            $data->loginswoop = 'ERSDisplayNone';
        }
        /*
         * Set up the register data even if we're already registered in case we remove the current ID
         */
        $swoopData = new stdClass();
        $swoopData->email = get_bloginfo("admin_email");
        $swoopData->blog_url = get_bloginfo("wpurl");
        $swoopData->blog_title = get_bloginfo("description");
        $swoopData->rss_url = get_bloginfo("rss_url");
        $swoopData->tz = get_option('timezone_string');
        /** @noinspection PhpParamsInspection */
        $data->swoopqs = http_build_query($swoopData);
        $data->easyrecipeURL = EasyRecipe::$EasyRecipeURL;
        $data->siteurl = get_site_url();
        $data->erplus = '';
        $data->author = $this->author;
        $data->cuisines = str_replace('|', "\n", $this->cuisines);
        $data->recipeTypes = str_replace('|', "\n", $this->recipeTypes);
        $data->plus = "EasyRecipe" == "easyrecipeplus" ? "Plus" : "";
        $data->pluginName = "EasyRecipe";
        $optionsHTML = "<input type='hidden' name='option_page' value='EROptionSettings' />";
        $optionsHTML .= '<input type="hidden" name="action" value="update" />';
        $optionsHTML .= wp_nonce_field("EROptionSettings-options", '_wpnonce', true, false);
        $optionsHTML .= wp_referer_field(false);
        $styles = EasyRecipeStyles::getStyles($this->customTemplates);
        //        $styles = call_user_func(array ($this->stylesClass, 'getStyles'), $this->settings['customTemplates']);
        $data->styleDirectory = $this->style;
        $styleNum = 0;
        $styleTab = 1;
        $styleItem = false;
        $data->STYLETABS = array();
        foreach ($styles as $style) {
            if ($styleNum % 3 == 0) {
                if ($styleItem !== false) {
                    /** @noinspection PhpUndefinedFieldInspection */
                    $styleItem->styleTab = $styleTab++;
                    $data->STYLETABS[] = $styleItem;
                }
                $styleItem = new stdClass();
                $styleItem->STYLES = array();
            }
            $style->selected = $data->style == $style->directory ? 'ERSStyleSelected' : '';
            $styleItem->STYLES[] = $style;
            $styleNum++;
        }
        if ($styleItem) {
            $styleItem->styleTab = $styleTab;
            $data->STYLETABS[] = $styleItem;
        }
        $styles = EasyRecipeStyles::getStyles($this->customTemplates, EasyRecipeStyles::ISPRINT);
        //$styles = call_user_func(array ($this->stylesClass, 'getStyles'), $this->settings['customTemplates'], constant("$this->stylesClass::ISPRINT"));
        $data->printStyleDirectory = $this->printStyle;
        $styleNum = 0;
        $styleTab = 1;
        $styleItem = false;
        $data->PRINTSTYLETABS = array();
        foreach ($styles as $style) {
            if ($styleNum % 3 == 0) {
                if ($styleItem !== false) {
                    /** @noinspection PhpUndefinedFieldInspection */
                    $styleItem->styleTab = $styleTab++;
                    $data->PRINTSTYLETABS[] = $styleItem;
                }
                $styleItem = new stdClass();
                $styleItem->PRINTSTYLES = array();
            }
            $style->selected = $data->printStyle == $style->directory ? 'ERSStyleSelected' : '';
            $styleItem->PRINTSTYLES[] = $style;
            $styleNum++;
        }
        if ($styleItem) {
            $styleItem->styleTab = $styleTab;
            $data->PRINTSTYLETABS[] = $styleItem;
        }
        $data->optionsHTML = $optionsHTML;
        $data->customTemplates = $this->customTemplates;
        /*
         * We need to preserve whitespace on this template because newlines in the the textareas are significant
         */
        $template = new EasyRecipeTemplate(EasyRecipe::$EasyRecipeDir . "/templates/easyrecipe-settings.html");
        $html = $template->replace($data, EasyRecipeTemplate::PRESERVEWHITESPACE);
        echo $html;
        $data = new stdClass();
        $data->easyrecipeURL = EasyRecipe::$EasyRecipeURL;
        $template = new EasyRecipeTemplate(EasyRecipe::$EasyRecipeDir . "/templates/easyrecipe-upgrade.html");
        echo $template->replace($data);
    }
    /**
     * @param bool $isPrint
     *
     * @return string
     */
    function getFormatDialog($isPrint = false)
    {
        $data = new stdClass();
        $data->SECTIONS = array();
        $id = 0;
        $styleData = $isPrint ? $this->printStyleData : $this->styleData;
        /**
         * Get the formatting data for each formattable element
         * Add more specificity to each target in an attempt to override any specific theme CSS
         */
        $formats = @json_decode($styleData->formatting);
        if ($formats) {
            foreach ($formats as $format) {
                $item = new stdClass();
                if (stripos($format->target, ".easyrecipe") === 0) {
                    $format->target = "html body div" . $format->target;
                } else {
                    if (stripos($format->target, "div.easyrecipe") === 0) {
                        $format->target = "html body " . $format->target;
                    } else {
                        if (stripos($format->target, "html body") === false) {
                            $format->target = "html body " . $format->target;
                        }
                    }
                }
                $item->section = $format->section;
                $format->id = $item->id = $id++;
                $data->SECTIONS[] = $item;
            }
        }
        /**
         * Get all the styles we have
         */
        $styles = EasyRecipeStyles::getStyles($this->settings->customTemplates, $isPrint);
        $data->STYLES = array();
        $styleThumbs = array();
        foreach ($styles as $style) {
            $item = new stdClass();
            $item->directory = $style->directory;
            $item->selected = $item->directory == $this->styleName ? 'selected="selected"' : '';
            $item->style = $style->style;
            $styleThumbs[$style->directory] = $style->thumbnail;
            $data->STYLES[] = $item;
        }
        $data->stylethumb = $styleData->thumbnail;
        $template = new EasyRecipeTemplate(self::$EasyRecipeDir . "/templates/easyrecipe-format.html");
        $html = $template->replace($data);
        $template = new EasyRecipeTemplate(self::$EasyRecipeDir . "/templates/easyrecipe-fontchange.html");
        $fontChangeHTML = $template->replace($data);
        $fontChangeHTML = str_replace("\r", "", $fontChangeHTML);
        $fontChangeHTML = str_replace("\n", " ", $fontChangeHTML);
        $fontChangeHTML = str_replace("'", '\\0x27', $fontChangeHTML);
        $fontChangeHTML = trim(preg_replace('/> \\s+</i', '> <', $fontChangeHTML));
        $ajaxURL = admin_url('admin-ajax.php');
        $cssType = $isPrint ? 'customPrintCSS' : 'customCSS';
        /**
         * Fix extra slashes that may be hanging around from earlier versions
         * Then escape single quotes with a slash
         */
        $customCSS = str_replace("'", "\\'", stripslashes_deep($this->settings->{$cssType}));
        if ($customCSS == '') {
            $customCSS = '{}';
        }
        $formats = json_encode($formats);
        $formats = str_replace("'", '\'', $formats);
        $print = $isPrint ? 'true' : 'false';
        $thumbs = json_encode($styleThumbs);
        $url = self::$EasyRecipeURL;
        $pluginVersion = self::$pluginVersion;
        $html .= <<<EOD
<script type="text/javascript">
/* <![CDATA[ */
window.EASYRECIPE = window.EASYRECIPE || {};
EASYRECIPE.isPrint = {$print};
EASYRECIPE.formatting = '{$formats}';
EASYRECIPE.customCSS = '{$customCSS}';
EASYRECIPE.easyrecipeURL = '{$url}';
EASYRECIPE.wpVersion = '{$this->wpVersion}';
EASYRECIPE.version = '{$pluginVersion}';
EASYRECIPE.ajaxURL = '{$ajaxURL}';
EASYRECIPE.styleThumbs = '{$thumbs}';
EASYRECIPE.fontChangeHTML = '{$fontChangeHTML}';
/* ]]> */
</script>
EOD;
        /*
         * Display formatting JS is handled by enqueue scripts
         * The print page exits before enqueues get output so add the script manually now
         */
        if ($isPrint && current_user_can("edit_theme_options")) {
            $html .= sprintf('<script type="text/javascript" src="%s/js/easyrecipe-format.js?version=%s"></script>', self::$EasyRecipeURL, self::$pluginVersion);
        }
        return $html;
    }