public function print_recipe($recipe, $parameters) { // Get Serving Size preg_match("/[0-9\\.,]+/", $parameters, $servings); $servings = empty($servings) ? 0.0 : floatval(str_replace(',', '.', $servings[0])); if ($servings <= 0) { $servings = $recipe->servings_normalized(); } if (WPUltimateRecipe::is_premium_active()) { // Get Unit System $unit_system = false; $requested_systems = explode('/', $parameters); $systems = WPUltimateRecipe::get()->helper('ingredient_units')->get_active_systems(); foreach ($systems as $id => $options) { foreach ($requested_systems as $requested_system) { if ($requested_system == $this->convertToSlug($options['name'])) { $unit_system = $id; } } } } // Get Template $template = WPUltimateRecipe::get()->template('print', 'default'); $fonts = false; if (isset($template->fonts) && count($template->fonts) > 0) { $fonts = 'http://fonts.googleapis.com/css?family=' . implode('|', $template->fonts); } include 'print_template.php'; }
public function output($recipe, $args = array()) { if (!$this->output_block($recipe, $args)) { return ''; } if (WPUltimateRecipe::is_premium_active()) { $text = WPUltimateRecipe::option('recipe_sharing_twitter', '%title% - Powered by @WPUltimRecipe'); } else { $text = '%title% - Powered by @WPUltimRecipe'; } $text = str_ireplace('%title%', $recipe->title(), $text); $output = $this->before_output(); ob_start(); ?> <div data-url="<?php echo $recipe->link(); ?> " data-text="<?php echo esc_attr($text); ?> " data-layout="<?php echo $this->layout; ?> "<?php echo $this->style(); ?> ></div> <?php $output .= ob_get_contents(); ob_end_clean(); return $this->after_output($output, $recipe); }
private function condition($recipe, $condition, $args = array()) { $show = true; if ($condition['condition_type'] == 'field') { $present = $recipe->is_present($condition['field']); if (isset($condition['when']) && $condition['when'] == 'present') { $show = $show && !$present; // Hide when present } else { $show = $show && $present; // Hide when missing } } else { if ($condition['condition_type'] == 'sub_field' && isset($args[$condition['field']])) { $present = $args[$condition['field']] == '' ? false : true; if (isset($condition['when']) && $condition['when'] == 'present') { $show = $show && !$present; // Hide when present } else { $show = $show && $present; // Hide when missing } } else { if ($condition['condition_type'] == 'setting') { if ($condition['setting'] == 'meal_planner_add_to_meal_plan' || $condition['setting'] == 'user_menus_add_to_shopping_list') { if (!WPUltimateRecipe::is_premium_active()) { $val = false; } else { $setting = WPUltimateRecipe::option($condition['setting'], 'off'); if ($setting == 'guests' || $setting == 'registered' && is_user_logged_in()) { $val = true; } else { $val = false; } } } else { if ($condition['setting'] == 'favorite_recipes_enabled') { if (!WPUltimateRecipe::is_premium_active()) { $val = false; } else { $val = WPUltimateRecipe::option('favorite_recipes_enabled', '0'); } } else { if (in_array($condition['setting'], array('recipe_linkback', 'partners_integrations_yummly_enable', 'partners_integrations_foodfanatic_enable', 'partners_integrations_chicory_enable', 'partners_integrations_bigoven_enable'))) { // Default 0 $val = WPUltimateRecipe::option($condition['setting'], '0'); } else { // Default 1 $val = WPUltimateRecipe::option($condition['setting'], '1'); } } } if ($condition['setting'] == 'recipe_adjustable_units' && !WPUltimateRecipe::is_premium_active()) { return false; // Hide unit conversion block if we're not Premium } if (isset($condition['when']) && $condition['when'] == 'enabled') { $show = $show && $val != '1'; } else { $show = $show && $val == '1'; } } else { if ($condition['condition_type'] == 'tag') { if (has_term($condition['term'], $condition['taxonomy'], $recipe->ID())) { $show = $condition['when'] == 'in' ? false : true; } else { $show = $condition['when'] == 'in' ? true : false; } } } } } return $show; }
function wpurp_admin_premium_installed() { return WPUltimateRecipe::is_premium_active(); }
public function get_template($type, $template) { $mapping = $this->get_mapping(); // Only return non-default templates for WP Ultimate Recipe Premium if ($template !== 'default' && isset($mapping[$template]) && WPUltimateRecipe::is_premium_active()) { return $this->get_template_code($template); } else { switch ($type) { case 'print': $default_template = WPUltimateRecipe::option('recipe_template_print_template', 1); break; case 'user_menus': $default_template = WPUltimateRecipe::option('user_menus_recipe_print_template', 1); break; case 'grid': $default_template = WPUltimateRecipe::option('recipe_template_recipegrid_template', 2); break; case 'feed': $default_template = WPUltimateRecipe::option('recipe_template_feed_template', 99); break; case 'metadata': // Empty Recipe Container, but includes Recipe metadata return unserialize(base64_decode('TzoxNDoiV1BVUlBfVGVtcGxhdGUiOjM6e3M6NjoiYmxvY2tzIjthOjE6e2k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oZXJpdCI7czoxMzoidmVydGljYWxBbGlnbiI7czo3OiJpbmhlcml0IjtzOjg6ImZvbnRCb2xkIjtiOjA7czoxMzoiZm9udFNtYWxsQ2FwcyI7YjowO3M6ODoiZm9udFNpemUiO3M6MDoiIjtzOjEyOiJmb250U2l6ZVVuaXQiO3M6MjoicHgiO3M6MTA6ImxpbmVIZWlnaHQiO3M6MDoiIjtzOjE0OiJsaW5lSGVpZ2h0VW5pdCI7czoyOiJweCI7czo5OiJmb250Q29sb3IiO3M6MDoiIjtzOjE0OiJmb250RmFtaWx5VHlwZSI7czowOiIiO3M6MTM6ImZvbnRGYW1pbHlHV0YiO3M6OToiT3BlbitTYW5zIjtzOjExOiJjdXN0b21DbGFzcyI7czowOiIiO3M6MTE6ImN1c3RvbVN0eWxlIjtzOjA6IiI7czo1OiJ3aWR0aCI7czowOiIiO3M6NjoiaGVpZ2h0IjtzOjA6IiI7fXM6NToic3R5bGUiO2E6MTp7czo3OiJkZWZhdWx0IjthOjI6e3M6ODoicG9zaXRpb24iO3M6Njoic3RhdGljIjtzOjE0OiJ2ZXJ0aWNhbC1hbGlnbiI7czo3OiJpbmhlcml0Ijt9fXM6MTA6ImNvbmRpdGlvbnMiO2E6MDp7fXM6NjoicGFyZW50IjtpOi0xO3M6Mzoicm93IjtpOjA7czo2OiJjb2x1bW4iO2k6MDtzOjU6Im9yZGVyIjtpOjA7czoxODoiACoAc2hvd19vbl9kZXNrdG9wIjtiOjE7czoxNzoiACoAc2hvd19vbl9tb2JpbGUiO2I6MTtzOjEzOiIAKgBsaW5rX2NvbG9yIjtiOjA7czoyMDoiACoAYmFja2dyb3VuZF9wcmVzZXQiO2I6MDt9fXM6OToiY29udGFpbmVyIjtyOjM7czo1OiJmb250cyI7YTowOnt9fQ==')); break; default: $default_template = WPUltimateRecipe::option('recipe_template_recipe_template', 0); break; } return $this->get_template_code($default_template); } }
echo intval(WPUltimateRecipe::option('recipe_adjustable_servings_precision', 2)); ?> }; jQuery(document).ready(function() { var old_servings = <?php echo $recipe->servings_normalized(); ?> ; var new_servings = <?php echo $servings; ?> ; <?php if (WPUltimateRecipe::is_premium_active()) { ?> wpurp_unit_conversion = { alias_to_unit: <?php echo json_encode(WPUltimateRecipe::get()->helper('ingredient_units')->get_alias_to_unit()); ?> , unit_to_type: <?php echo json_encode(WPUltimateRecipe::get()->helper('ingredient_units')->get_unit_to_type()); ?> , universal_units: <?php echo json_encode(WPUltimateRecipe::get()->helper('ingredient_units')->get_universal_units()); ?> , systems: <?php
<?php /* * -> 2.0.5 * * Show warning */ // Successfully migrated to 2.0.0 $migrate_version = '2.0.5'; update_option('wpurp_migrate_version', $migrate_version); if ($notices && WPUltimateRecipe::is_premium_active()) { WPUltimateRecipe::get()->helper('notices')->add_admin_notice('<strong>WP Ultimate Recipe</strong> Recipe Grid settings have moved to the shortcode itself. Please check to see if you need to make any changes!'); }
private function enqueue_js($assets, $use_minify, $js_to_enqueue_data_only, $js_names, $js_dependencies) { if ($use_minify) { if (WPUltimateRecipe::is_premium_active()) { $external_deps = array_unique(array_diff($js_dependencies, $js_names)); //var_dump( $external_deps ); } else { $external_deps = array('jquery', 'jquery-ui-sortable', 'jquery-ui-droppable', 'suggest'); } wp_enqueue_script('wpurp_script_minified', WPUltimateRecipe::get()->coreUrl . '/assets/wpurp-public.js', $external_deps, WPURP_VERSION, true); foreach ($js_to_enqueue_data_only as $asset) { $data_name = $asset['data']['name']; unset($asset['data']['name']); wp_localize_script('wpurp_script_minified', $data_name, $asset['data']); } } $i = 1; foreach ($assets as $asset) { $name = isset($asset['name']) ? $asset['name'] : 'wpurp_script' . $i; $deps = isset($asset['deps']) ? $asset['deps'] : ''; wp_enqueue_script($name, $asset['url'], $deps, WPURP_VERSION, true); if (isset($asset['data']) && isset($asset['data']['name'])) { $data_name = $asset['data']['name']; unset($asset['data']['name']); wp_localize_script($name, $data_name, $asset['data']); } $i++; } }
public function output($recipe, $args = array()) { if (!$this->output_block($recipe, $args)) { return ''; } $output = $this->before_output(); // Backwards compatibility $this->add_style('text-align', 'center'); $this->add_style('text-align', 'center', 'td'); $this->add_style('vertical-align', 'top', 'td'); $this->columns = 4; $widths = array('25%', '25%', '25%', 'auto'); $this->widths = $widths; foreach ($widths as $column => $width) { $this->add_style('width', $width, 'col-' . $column); } if (WPUltimateRecipe::is_premium_active()) { $twitter_text = WPUltimateRecipe::option('recipe_sharing_twitter', '%title% - Powered by @WPUltimRecipe'); $pinterest_text = WPUltimateRecipe::option('recipe_sharing_pinterest', '%title% - Powered by @ultimaterecipe'); } else { $twitter_text = '%title% - Powered by @WPUltimRecipe'; $pinterest_text = '%title% - Powered by @ultimaterecipe'; } $twitter_text = str_ireplace('%title%', $recipe->title(), $twitter_text); $pinterest_text = str_ireplace('%title%', $recipe->title(), $pinterest_text); ob_start(); ?> <table<?php echo $this->style(); ?> > <tbody> <tr> <td<?php echo $this->style(array('td', 'col-0')); ?> > <div data-url="<?php echo $recipe->link(); ?> " data-text="<?php echo esc_attr($twitter_text); ?> " data-layout="vertical" class="wpurp-twitter"></div> </td> <td<?php echo $this->style(array('td', 'col-1')); ?> > <div data-url="<?php echo $recipe->link(); ?> " data-layout="box_count" class="wpurp-facebook"></div> </td> <td<?php echo $this->style(array('td', 'col-2')); ?> > <div data-url="<?php echo $recipe->link(); ?> " data-layout="tall" data-annotation="bubble" class="wpurp-google"></div> </td> <td<?php echo $this->style(array('td', 'col-3')); ?> ><?php if (!is_null($recipe->image_url('full'))) { ?> <div data-url="<?php echo $recipe->link(); ?> " data-media="<?php echo $recipe->image_url('full'); ?> " data-description="<?php echo esc_attr($pinterest_text); ?> " data-layout="above" class="wpurp-pinterest"></div> <?php } else { ?> <?php } ?> </td> </tr> </tbody> </table> <?php $output .= ob_get_contents(); ob_end_clean(); return $this->after_output($output, $recipe); }