private function printRecipe($postID, $recipeIX) { /** @var $wpdb wpdb */ global $wpdb; $post = get_post($postID); if (!$post) { return; } /** * Process the [br] shortcodes and remove the spurious <br>'s that wp_auto() inserts */ $content = str_replace("[br]", "<br>", $post->post_content); $content = preg_replace('%</div>\\s*</p></div>%im', '</div></div>', $content); $postDOM = new EasyRecipeDocument($content); if (!$postDOM->isEasyRecipe) { return; } /** * If the post is formatted already then it came from the Object cache * If that's the case we need to re-read the original */ if ($postDOM->isFormatted) { $post = $wpdb->get_row("SELECT * FROM " . $wpdb->prefix . "posts WHERE ID = {$postID}"); $postDOM = new EasyRecipeDocument($post->post_content); if (!$postDOM->isEasyRecipe) { return; } } $this->settings = EasyRecipeSettings::getInstance(); if (isset($_GET['style'])) { $this->styleName = $_GET['style']; } else { $this->styleName = $this->settings->printStyle; } // $this->printStyleData = call_user_func(array($this->stylesClass, 'getStyleData'), $this->styleName, $this->settings->get('customTemplates'), true); $this->printStyleData = EasyRecipeStyles::getStyleData($this->styleName, $this->settings->customTemplates, true); if (get_locale() != 'en_US') { EasyRecipeTemplate::setTranslate('easyrecipe'); } /** * Fix possibly broken times in older posts * Fix the Cholesterol oops in early versions */ if ($postDOM->recipeVersion < '3') { $postDOM->fixTimes("preptime"); $postDOM->fixTimes("cooktime"); $postDOM->fixTimes("duration"); $postDOM->setParentValueByClassName("cholestrol", $this->settings->lblCholesterol, "Cholestrol"); } $postDOM->setSettings($this->settings); $data = new stdClass(); $data->hasRating = false; $data->convertFractions = $this->settings->convertFractions; $this->settings->getLabels($data); $data->hasLinkback = $this->settings->allowLink; $data->title = $post->post_title; $data->blogname = get_option("blogname"); $data->recipeurl = get_permalink($post->ID); $data->customCSS = $this->getCSS('Print'); $data->extraPrintHeader = $this->settings->extraPrintHeader; $data->easyrecipeURL = self::$EasyRecipeURL; $recipe = $postDOM->getRecipe($recipeIX); $photoURL = $postDOM->findPhotoURL($recipe); $data->hasPhoto = !empty($photoURL); $data->jqueryjs = self::JQUERYJS; $data->jqueryuijs = self::JQUERYUIJS; $data->jqueryuicss = self::JQUERYUICSS; if (current_user_can('edit_posts')) { $data->isAdmin = true; $data->formatDialog = $this->getFormatDialog(true); } else { $data->formatDialog = ''; } $data->style = $this->styleName; if ($data->style[0] == '_') { } else { $data->css = self::$EasyRecipeURL . "/printstyles/{$data->style}"; $templateFile = self::$EasyRecipeDir . "/printstyles/{$data->style}/style.html"; } $data->css .= "/style.css?version=" . self::$pluginVersion . ".{$this->printStyleData->version}"; $template = new EasyRecipeTemplate($templateFile); /** * Brain dead IE shows "friendly" error pages (i.e. it's non-compliant) so we need to force a 200 */ header("HTTP/1.1 200 OK"); echo $postDOM->formatRecipe($recipe, $template, $data); exit; }