public function hide()
 {
     if (isset($_GET['wpurp_hide_getting_started'])) {
         check_admin_referer('wpurp_hide_getting_started', 'wpurp_hide_getting_started');
         update_user_meta(get_current_user_id(), '_wpurp_hide_getting_started', get_option(WPUltimateRecipe::get()->pluginName . '_version'));
     }
 }
 function index_shortcode($options)
 {
     $options = shortcode_atts(array('headers' => 'false'), $options);
     $query = WPUltimateRecipe::get()->helper('query_recipes');
     $recipes = $query->order_by('title')->order('ASC')->get();
     $out = '<div class="wpurp-index-container">';
     if ($recipes) {
         $letters = array();
         foreach ($recipes as $recipe) {
             $title = $recipe->title();
             if ($title) {
                 if ($options['headers'] != 'false') {
                     $first_letter = strtoupper(mb_substr($title, 0, 1));
                     if (!in_array($first_letter, $letters)) {
                         $letters[] = $first_letter;
                         $out .= '<h2>';
                         $out .= $first_letter;
                         $out .= '</h2>';
                     }
                 }
                 $out .= '<a href="' . $recipe->link() . '">';
                 $out .= $title;
                 $out .= '</a><br/>';
             }
         }
     } else {
         $out .= __("You have to create a recipe first, check the 'Recipes' menu on the left.", 'wp-ultimate-recipe');
     }
     $out .= '</div>';
     return $out;
 }
 public function vafpress_menu_init()
 {
     $defaults = $this->defaults;
     require_once WPUltimateRecipe::get()->coreDir . '/helpers/vafpress/vafpress_menu_whitelist.php';
     require_once WPUltimateRecipe::get()->coreDir . '/helpers/vafpress/vafpress_menu_options.php';
     new VP_Option(array('is_dev_mode' => false, 'option_key' => 'wpurp_option', 'page_slug' => 'wpurp_admin', 'template' => $admin_menu, 'menu_page' => 'edit.php?post_type=recipe', 'use_auto_group_naming' => true, 'use_exim_menu' => true, 'minimum_role' => 'manage_options', 'layout' => 'fluid', 'page_title' => __('Settings', 'wp-ultimate-recipe'), 'menu_label' => __('Settings', 'wp-ultimate-recipe')));
 }
示例#4
0
    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);
    }
示例#5
0
 public function __construct($name)
 {
     $this->addonPath = '/addons/' . $name;
     $this->addonDir = WPUltimateRecipe::get()->coreDir . $this->addonPath;
     $this->addonUrl = WPUltimateRecipe::get()->coreUrl . $this->addonPath;
     $this->addonName = $name;
 }
 public function split_shared_term($old_term_id, $new_term_id, $term_taxonomy_id, $taxonomy)
 {
     // Recipe Grid
     if (WPUltimateRecipe::is_addon_active('recipe-grid')) {
         WPUltimateRecipe::addon('recipe-grid')->updated_terms($new_term_id, 'ingredient');
     }
 }
 public function add_taxonomy()
 {
     if (!wp_verify_nonce($_POST['add_taxonomy_nonce'], 'add_taxonomy')) {
         die('Invalid nonce.' . var_export($_POST, true));
     }
     $name = $_POST['wpurp_custom_taxonomy_name'];
     $singular = $_POST['wpurp_custom_taxonomy_singular_name'];
     $slug = str_replace(' ', '-', strtolower($_POST['wpurp_custom_taxonomy_slug']));
     $edit_tag_name = $_POST['wpurp_edit'];
     $editing = false;
     if (strlen($edit_tag_name) > 0) {
         $editing = true;
     }
     if (!$editing) {
         die('There was an unexpected error. Please try again.');
     }
     if (!$editing && taxonomy_exists(strtolower($singular))) {
         die('This taxonomy already exists.');
     }
     if (strlen($name) > 1 && strlen($singular) > 1) {
         $taxonomies = WPUltimateRecipe::get()->tags();
         $name_lower = strtolower($name);
         // Cannot add tags in the basic version
         $tag_name = $edit_tag_name;
         // TODO Filter this to allow customizing
         $taxonomies[$tag_name] = array('labels' => array('name' => $name, 'singular_name' => $singular, 'search_items' => __('Search', 'wp-ultimate-recipe') . ' ' . $name, 'popular_items' => __('Popular', 'wp-ultimate-recipe') . ' ' . $name, 'all_items' => __('All', 'wp-ultimate-recipe') . ' ' . $name, 'edit_item' => __('Edit', 'wp-ultimate-recipe') . ' ' . $singular, 'update_item' => __('Update', 'wp-ultimate-recipe') . ' ' . $singular, 'add_new_item' => __('Add New', 'wp-ultimate-recipe') . ' ' . $singular, 'new_item_name' => __('New', 'wp-ultimate-recipe') . ' ' . $singular . ' ' . __('Name', 'wp-ultimate-recipe'), 'separate_items_with_commas' => __('Separate', 'wp-ultimate-recipe') . ' ' . $name_lower . ' ' . __('with commas', 'wp-ultimate-recipe'), 'add_or_remove_items' => __('Add or remove', 'wp-ultimate-recipe') . ' ' . $name_lower, 'choose_from_most_used' => __('Choose from the most used', 'wp-ultimate-recipe') . ' ' . $name_lower, 'not_found' => __('No', 'wp-ultimate-recipe') . ' ' . $name_lower . ' ' . __('found.', 'wp-ultimate-recipe'), 'menu_name' => $name), 'show_ui' => true, 'show_tagcloud' => true, 'hierarchical' => true, 'rewrite' => array('slug' => $slug, 'hierarchical' => true));
         WPUltimateRecipe::get()->helper('taxonomies')->update($taxonomies);
         WPUltimateRecipe::get()->helper('taxonomies')->check_recipe_taxonomies();
         WPUltimateRecipe::get()->helper('permalinks_flusher')->set_flush_needed();
     }
     wp_redirect($_SERVER['HTTP_REFERER']);
     exit;
 }
示例#8
0
 public function check_manual_reset()
 {
     if (isset($_GET['wpurp_reset_cache'])) {
         $this->reset();
         WPUltimateRecipe::get()->helper('notices')->add_admin_notice('<strong>WP Ultimate Recipe</strong> The cache has been reset');
     }
 }
示例#9
0
 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';
 }
示例#10
0
 public function custom_css()
 {
     if (WPUltimateRecipe::option('custom_code_public_css', '') !== '') {
         echo '<style type="text/css">';
         echo WPUltimateRecipe::option('custom_code_public_css', '');
         echo '</style>';
     }
 }
    public function output($recipe, $args = array())
    {
        if (!$this->output_block($recipe, $args)) {
            return '';
        }
        $icon = '<i class="fa ' . esc_attr($this->icon) . '"></i>';
        $classes = array();
        $shopping_list_recipes = array();
        if (isset($_COOKIE['WPURP_Shopping_List_Recipes_v2'])) {
            $shopping_list_recipes = explode(';', stripslashes($_COOKIE['WPURP_Shopping_List_Recipes_v2']));
        }
        $in_shopping_list = in_array($recipe->ID(), $shopping_list_recipes);
        if ($in_shopping_list) {
            $classes[] = 'in-shopping-list';
        }
        $tooltip_text = WPUltimateRecipe::option('add_to_shopping_list_tooltip_text', __('Add to Shopping List', 'wp-ultimate-recipe'));
        $tooltip_alt_text = WPUltimateRecipe::option('added_to_shopping_list_tooltip_text', __('This recipe is in your Shopping List', 'wp-ultimate-recipe'));
        if ($tooltip_text && $tooltip_alt_text) {
            $classes[] = 'recipe-tooltip';
        }
        if ($in_shopping_list) {
            $tooltip_text_backup = $tooltip_text;
            $tooltip_text = $tooltip_alt_text;
            $tooltip_alt_text = $tooltip_text_backup;
        }
        $this->classes = $classes;
        $output = $this->before_output();
        ob_start();
        ?>
<a href="#"<?php 
        echo $this->style();
        ?>
 data-recipe-id="<?php 
        echo $recipe->ID();
        ?>
"><?php 
        echo $icon;
        ?>
</a>
<?php 
        if ($tooltip_text && $tooltip_alt_text) {
            ?>
    <div class="recipe-tooltip-content">
        <div class="tooltip-shown"><?php 
            echo $tooltip_text;
            ?>
</div>
        <div class="tooltip-alt"><?php 
            echo $tooltip_alt_text;
            ?>
</div>
    </div>
<?php 
        }
        $output .= ob_get_contents();
        ob_end_clean();
        return $this->after_output($output, $recipe);
    }
    public function output($recipe, $args = array())
    {
        if (!$this->output_block($recipe, $args)) {
            return '';
        }
        $icon = '<i class="fa ' . esc_attr($this->icon) . '"></i>';
        $classes = array();
        $tooltip_text = WPUltimateRecipe::option('add_to_meal_plan_tooltip_text', __('Add to Meal Plan:', 'wp-ultimate-recipe'));
        $tooltip_alt_text = WPUltimateRecipe::option('added_to_meal_plan_tooltip_text', __('This recipe has been added to your Meal Plan', 'wp-ultimate-recipe'));
        $classes[] = 'recipe-tooltip';
        $this->classes = $classes;
        $output = $this->before_output();
        ob_start();
        ?>
<a href="#"<?php 
        echo $this->style();
        ?>
 data-recipe-id="<?php 
        echo $recipe->ID();
        ?>
"><?php 
        echo $icon;
        ?>
</a>
<div class="recipe-tooltip-content">
    <div class="tooltip-shown">
        <span class="wpurp-meal-plan-button-text"><?php 
        echo $tooltip_text;
        ?>
</span>
        <input type="text" class="wpurp-meal-plan-button-date" value="<?php 
        $today = new DateTime('today', WPUltimateRecipe::get()->timezone());
        echo $today->format('m/d/Y');
        ?>
">
        <select class="wpurp-meal-plan-button-course">
            <option value="0"><?php 
        _e('Select Course to Add:', 'wp-ultimate-recipe');
        ?>
</option>
            <?php 
        $meal_plan = WPUltimateRecipe::addon('meal-planner')->get_meal_plan();
        foreach ($meal_plan['courses'] as $course) {
            echo '<option value="' . esc_attr($course) . '">' . $course . '</option>';
        }
        ?>
        </select>
    </div>
    <div class="tooltip-alt"><?php 
        echo $tooltip_alt_text;
        ?>
</div>
</div>
<?php 
        $output .= ob_get_contents();
        ob_end_clean();
        return $this->after_output($output, $recipe);
    }
示例#13
0
 public function faq_page()
 {
     if (!current_user_can('edit_posts')) {
         wp_die('You do not have sufficient permissions to access this page.');
     }
     // Hide the new user notice
     update_user_meta(get_current_user_id(), '_wpurp_hide_new_notice', get_option(WPUltimateRecipe::get()->pluginName . '_version'));
     include WPUltimateRecipe::get()->coreDir . '/static/faq.php';
 }
示例#14
0
 public function cron_migrations()
 {
     $cron_migrate_version = get_option('wpurp_cron_migrate_version', '0.0.1');
     if ($cron_migrate_version < '2.3.3') {
         require_once WPUltimateRecipe::get()->coreDir . '/helpers/migration/cron_2_3_3_recipe_search.php';
     } elseif ($cron_migrate_version < '2.4') {
         // Example cron migration for 2.4
     }
 }
 public function output($recipe, $args = array())
 {
     if (!$this->output_block($recipe, $args) || !isset($args['ingredient_quantity']) || !$args['ingredient_quantity']) {
         return '';
     }
     $output = $this->before_output();
     $fraction = WPUltimateRecipe::option('recipe_adjustable_servings_fractions', '0') == '1' ? true : false;
     $fraction = strpos($args['ingredient_quantity'], '/') === false ? $fraction : true;
     $output .= '<span data-normalized="' . $args['ingredient_quantity_normalized'] . '" data-fraction="' . $fraction . '" data-original="' . $args['ingredient_quantity'] . '"' . $this->style() . '>' . $args['ingredient_quantity'] . '</span>';
     return $this->after_output($output, $recipe);
 }
示例#16
0
 public function hide_theme_thumbnail($html)
 {
     if (get_post_type() == 'recipe' && in_the_loop()) {
         $thumb = WPUltimateRecipe::option('recipe_theme_thumbnail', 'archive');
         if ($thumb == 'never' || $thumb == 'archive' && is_single() || $thumb == 'recipe' && !is_single()) {
             $html = '';
             // Hide theme thumbnail
         }
     }
     return $html;
 }
示例#17
0
 public function output($recipe, $args = array())
 {
     if (!$this->output_block($recipe, $args)) {
         return '';
     }
     if ($this->preset) {
         $this->url = WPUltimateRecipe::addon('template-editor')->addonUrl . '/img/' . $this->preset . '.png';
     }
     $output = $this->before_output();
     $output .= '<img src="' . $this->url . '"' . $this->style() . '\\>';
     return $this->after_output($output, $recipe);
 }
示例#18
0
    public function output($recipe, $args = array())
    {
        if (!$this->output_block($recipe, $args)) {
            return '';
        }
        if (!is_user_logged_in() || !WPUltimateRecipe::is_addon_active('favorite-recipes')) {
            return '';
        }
        $current_icon = WPURP_Favorite_Recipes::is_favorite_recipe($recipe->ID()) ? $this->iconAlt : $this->icon;
        $icon = '<i class="fa ' . esc_attr($current_icon) . '" data-icon="' . esc_attr($this->icon) . '" data-icon-alt="' . esc_attr($this->iconAlt) . '"></i>';
        $tooltip_text = WPUltimateRecipe::option('favorite_recipes_tooltip_text', __('Add to your Favorite Recipes', 'wp-ultimate-recipe'));
        $tooltip_alt_text = WPUltimateRecipe::option('favorited_recipes_tooltip_text', __('This recipe is in your Favorite Recipes', 'wp-ultimate-recipe'));
        if ($tooltip_text && $tooltip_alt_text) {
            $this->classes = array('recipe-tooltip');
        }
        if (WPURP_Favorite_Recipes::is_favorite_recipe($recipe->ID())) {
            $tooltip_text_backup = $tooltip_text;
            $tooltip_text = $tooltip_alt_text;
            $tooltip_alt_text = $tooltip_text_backup;
        }
        $output = $this->before_output();
        ob_start();
        ?>
<a href="#"<?php 
        echo $this->style();
        ?>
 data-recipe-id="<?php 
        echo $recipe->ID();
        ?>
"><?php 
        echo $icon;
        ?>
</a>
<?php 
        if ($tooltip_text && $tooltip_alt_text) {
            ?>
    <div class="recipe-tooltip-content">
        <div class="tooltip-shown"><?php 
            echo $tooltip_text;
            ?>
</div>
        <div class="tooltip-alt"><?php 
            echo $tooltip_alt_text;
            ?>
</div>
    </div>
<?php 
        }
        $output .= ob_get_contents();
        ob_end_clean();
        return $this->after_output($output, $recipe);
    }
 public function remove_recipe_slug_in_parse_request($query)
 {
     if (WPUltimateRecipe::option('remove_recipe_slug', '0') == '1') {
         if (!$query->is_main_query()) {
             return;
         }
         if (2 != count($query->query) || !isset($query->query['page'])) {
             return;
         }
         if (!empty($query->query['name'])) {
             $query->set('post_type', array('post', 'recipe', 'page'));
         }
     }
 }
 public function output($recipe, $args = array())
 {
     if (!$this->output_block($recipe, $args)) {
         return '';
     }
     $output = $this->before_output();
     if (WPUltimateRecipe::option('recipe_adjustable_servings', '1') == '1') {
         if (WPUltimateRecipe::is_addon_active('unit-conversion')) {
             $output .= '<span' . $this->style() . '><input type="number" class="advanced-adjust-recipe-servings" data-original="' . $recipe->servings_normalized() . '" data-start-servings="' . $recipe->servings_normalized() . '" value="' . $recipe->servings_normalized() . '"' . $this->style('input') . '/> ' . $recipe->servings_type() . '</span>';
         } else {
             $output = '<span' . $this->style() . '><input type="number" class="adjust-recipe-servings" data-original="' . $recipe->servings_normalized() . '" data-start-servings="' . $recipe->servings_normalized() . '" value="' . $recipe->servings_normalized() . '"' . $this->style('input') . '/> ' . $recipe->servings_type() . '</span>';
         }
     }
     return $this->after_output($output, $recipe);
 }
示例#21
0
 public function check_recipe_demo()
 {
     if (isset($_GET['wpurp_reset_demo_recipe'])) {
         update_option('wpurp_demo_recipe', false);
         WPUltimateRecipe::get()->helper('notices')->add_admin_notice('<strong>WP Ultimate Recipe</strong> The Recipe Demo has been reset');
     }
     if (!get_option('wpurp_demo_recipe', false)) {
         // Demo Recipe content
         $_POST = array('recipe_meta_box_nonce' => wp_create_nonce('recipe'), 'recipe_description' => __('This must be the best demo recipe I have ever seen. I could eat this every single day.', 'wp-ultimate-recipe'), 'recipe_rating' => '4', 'recipe_servings' => '2', 'recipe_servings_type' => __('people', 'wp-ultimate-recipe'), 'recipe_prep_time' => '10', 'recipe_prep_time_text' => __('minutes', 'wp-ultimate-recipe'), 'recipe_cook_time' => '20', 'recipe_cook_time_text' => __('minutes', 'wp-ultimate-recipe'), 'recipe_passive_time' => '1', 'recipe_passive_time_text' => __('hour', 'wp-ultimate-recipe'), 'recipe_ingredients' => array(array('group' => '', 'amount' => '175', 'unit' => 'g', 'ingredient' => 'tagliatelle', 'notes' => ''), array('group' => '', 'amount' => '200', 'unit' => 'g', 'ingredient' => 'bacon', 'notes' => 'tiny strips'), array('group' => 'Fresh Pesto', 'amount' => '1', 'unit' => 'clove', 'ingredient' => 'garlic', 'notes' => ''), array('group' => 'Fresh Pesto', 'amount' => '12.5', 'unit' => 'g', 'ingredient' => 'pine kernels', 'notes' => ''), array('group' => 'Fresh Pesto', 'amount' => '50', 'unit' => 'g', 'ingredient' => 'basil leaves', 'notes' => ''), array('group' => 'Fresh Pesto', 'amount' => '6.25', 'unit' => 'cl', 'ingredient' => 'olive oil', 'notes' => 'extra virgin'), array('group' => 'Fresh Pesto', 'amount' => '27.5', 'unit' => 'g', 'ingredient' => 'Parmesan cheese', 'notes' => 'freshly grated')), 'recipe_instructions' => array(array('group' => 'Fresh Pesto (you can make this in advance)', 'description' => 'We\'ll be using a food processor to make the pesto. Put the garlic, pine kernels and some salt in there and process briefly.', 'image' => ''), array('group' => 'Fresh Pesto (you can make this in advance)', 'description' => 'Add the basil leaves (but keep some for the presentation) and blend to a green paste.', 'image' => ''), array('group' => 'Fresh Pesto (you can make this in advance)', 'description' => 'While processing, gradually add the olive oil and finally add the Parmesan cheese.', 'image' => ''), array('group' => 'Finishing the dish', 'description' => 'Bring a pot of salted water to the boil and cook your tagliatelle al dente.', 'image' => ''), array('group' => 'Finishing the dish', 'description' => 'Use the cooking time of the pasta to sauté your bacon strips.', 'image' => ''), array('group' => 'Finishing the dish', 'description' => 'After about 8 to 10 minutes, the pasta should be done. Drain it and put it back in the pot to mix it with the pesto.', 'image' => ''), array('group' => 'Finishing the dish', 'description' => 'Present the dish with some fresh basil leaves on top.', 'image' => '')), 'recipe_notes' => __('Use this section for whatever you like.', 'wp-ultimate-recipe'));
         $post_content = '<p>' . __('Use this like normal post content. The recipe will automatically be included at the end of the post, or wherever you place the shortcode:', 'wp-ultimate-recipe') . '</p>[recipe]<br/><p>' . __('This text will appear below your recipe.', 'wp-ultimate-recipe');
         if (WPUltimateRecipe::is_addon_active('nutritional-information')) {
             $post_content .= ' ' . __('Followed by the nutrition label:', 'wp-ultimate-recipe') . '</p>[nutrition-label]<br/>';
         } else {
             $post_content .= '</p>';
         }
         // Insert post
         $post = array('post_title' => __('Demo Recipe', 'wp-ultimate-recipe'), 'post_content' => $post_content, 'post_type' => 'recipe', 'post_status' => 'private', 'post_author' => get_current_user_id());
         $post_id = wp_insert_post($post);
         update_option('wpurp_demo_recipe', $post_id);
         // Update post taxonomies
         $tags = array('cuisine' => array('Italian'), 'course' => array('Main Dish'));
         foreach ($tags as $tag => $terms) {
             $term_ids = array();
             foreach ($terms as $term) {
                 $existing_term = term_exists($term, $tag);
                 if ($existing_term == 0 || $existing_term == null) {
                     $new_term = wp_insert_term($term, $tag);
                     $term_ids[] = (int) $new_term['term_id'];
                 } else {
                     $term_ids[] = (int) $existing_term['term_id'];
                 }
             }
             wp_set_object_terms($post_id, $term_ids, $tag);
         }
         // Recipe image
         $url = WPUltimateRecipe::get()->coreUrl . '/img/demo-recipe.jpg';
         media_sideload_image($url, $post_id);
         $attachments = get_posts(array('numberposts' => '1', 'post_parent' => $post_id, 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC'));
         if (sizeof($attachments) > 0) {
             set_post_thumbnail($post_id, $attachments[0]->ID);
         }
         // Nutritional Information
         $nutritional = array('calories' => '1276', 'carbohydrate' => '71', 'protein' => '57', 'fat' => '85', 'saturated_fat' => '22', 'polyunsaturated_fat' => '10', 'monounsaturated_fat' => '44', 'trans_fat' => '', 'cholesterol' => '238', 'sodium' => '2548', 'potassium' => '620', 'fiber' => '4', 'sugar' => '4', 'vitamin_a' => '2', 'vitamin_c' => '0.1', 'calcium' => '16', 'iron' => '12');
         update_post_meta($post_id, 'recipe_nutritional', $nutritional);
         // Update recipe content
         WPUltimateRecipe::get()->helper('recipe_save')->save($post_id, get_post($post_id));
     }
 }
 public function output($recipe, $args = array())
 {
     if (!$this->output_block($recipe, $args)) {
         return '';
     }
     $output = $this->before_output();
     if (WPUltimateRecipe::is_addon_active('unit-conversion') && WPUltimateRecipe::option('recipe_adjustable_units', '1') == '1') {
         $output = '<span' . $this->style() . '>';
         $output .= '<select onchange="RecipeUnitConversion.recalculate(this)" class="adjust-recipe-unit"' . $this->style('select') . '>';
         $systems = WPUltimateRecipe::get()->helper('ingredient_units')->get_active_systems();
         foreach ($systems as $i => $system) {
             $output .= '<option value="' . $i . '">' . $system['name'] . '</option>';
         }
         $output .= '</select></span>';
     }
     return $this->after_output($output, $recipe);
 }
示例#23
0
 private function stars_author($recipe)
 {
     $star_full = '<img src="' . WPUltimateRecipe::get()->coreUrl . '/img/star.png" width="15" height="14">';
     $star_empty = '<img src="' . WPUltimateRecipe::get()->coreUrl . '/img/star_grey.png" width="15" height="14">';
     $rating = $recipe->rating_author();
     $stars = '';
     if ($rating != 0) {
         for ($i = 1; $i <= 5; $i++) {
             if ($i <= $rating) {
                 $stars .= $star_full;
             } else {
                 $stars .= $star_empty;
             }
         }
     }
     return $stars;
 }
示例#24
0
 public function output($recipe, $args = array())
 {
     if (!$this->output_block($recipe, $args)) {
         return '';
     }
     $output = $this->before_output();
     $notes = wpautop($recipe->notes());
     // Add !important flags to styles added by visual editor
     if (WPUltimateRecipe::option('recipe_template_force_style', '1') == '1') {
         preg_match_all('/style="[^"]+/', $notes, $styles);
         foreach ($styles[0] as $style) {
             $new_style = preg_replace("/([^;]+)/", "\$1 !important", $style);
             $notes = str_ireplace($style, $new_style, $notes);
         }
     }
     $output .= '<div' . $this->style() . '>' . $this->cut_off($notes) . '</div>';
     return $this->after_output($output, $recipe);
 }
    public function output($recipe, $args = array())
    {
        if (!$this->output_block($recipe, $args)) {
            return '';
        }
        if (!$this->icon) {
            $icon = '<img src="' . WPUltimateRecipe::get()->coreUrl . '/img/printer.png">';
        } else {
            $icon = '<i class="fa ' . esc_attr($this->icon) . '"></i>';
        }
        $tooltip_text = WPUltimateRecipe::option('print_tooltip_text', __('Print Recipe', 'wp-ultimate-recipe'));
        if ($tooltip_text) {
            $this->classes = array('recipe-tooltip');
        }
        $recipe_id = WPUltimateRecipe::option('print_version_legacy_code', '0') == '1' ? ' data-recipe-id="' . $recipe->ID() . '"' : '';
        $output = $this->before_output();
        ob_start();
        ?>
<a href="<?php 
        echo $recipe->link_print();
        ?>
" target="_blank"<?php 
        echo $recipe_id . $this->style();
        ?>
><?php 
        echo $icon;
        ?>
</a>
<?php 
        if ($tooltip_text) {
            ?>
<div class="recipe-tooltip-content">
    <?php 
            echo $tooltip_text;
            ?>
</div>
<?php 
        }
        $output .= ob_get_contents();
        ob_end_clean();
        return $this->after_output($output, $recipe);
    }
 function recipe_shortcode($options)
 {
     $options = shortcode_atts(array('id' => 'random', 'template' => 'default'), $options);
     $recipe_post = null;
     if ($options['id'] == 'random') {
         $posts = get_posts(array('post_type' => 'recipe', 'nopaging' => true));
         $recipe_post = $posts[array_rand($posts)];
     } else {
         $recipe_post = get_post(intval($options['id']));
     }
     if (!is_null($recipe_post) && $recipe_post->post_type == 'recipe' && (!is_feed() || WPUltimateRecipe::option('recipe_rss_feed_shortcode', '1') == '1')) {
         $recipe = new WPURP_Recipe($recipe_post);
         $type = is_feed() ? 'feed' : 'recipe';
         $template = is_feed() ? null : $options['template'];
         $output = apply_filters('wpurp_output_recipe', $recipe->output_string($type, $template), $recipe);
     } else {
         $output = '';
     }
     return do_shortcode($output);
 }
 public function content_filter($content)
 {
     $api_request = defined('REST_REQUEST');
     $ignore_query = apply_filters('wpurp_recipe_content_loop_check', !in_the_loop() || !is_main_query());
     if (!$api_request && !is_feed() && $ignore_query) {
         return $content;
     }
     if (get_post_type() == 'recipe') {
         remove_filter('the_content', array($this, 'content_filter'), 10);
         $recipe = new WPURP_Recipe(get_post());
         if (!post_password_required() && (is_single() || WPUltimateRecipe::option('recipe_archive_display', 'full') == 'full' || is_feed() && WPUltimateRecipe::option('recipe_rss_feed_display', 'full') == 'full')) {
             $taxonomies = WPUltimateRecipe::get()->tags();
             unset($taxonomies['ingredient']);
             $type = is_feed() ? 'feed' : 'recipe';
             $recipe_box = apply_filters('wpurp_output_recipe', $recipe->output_string($type), $recipe);
             if (strpos($content, '[recipe]') !== false) {
                 $content = str_replace('[recipe]', $recipe_box, $content);
             } else {
                 if (preg_match("/<!--\\s*nextpage.*-->/", $recipe->post_content(), $out)) {
                     // Add metadata if there is a 'nextpage' tag and there wasn't a '[recipe]' tag on this specific page
                     $content .= $recipe->output_string('metadata');
                 } else {
                     if (is_single() || !preg_match("/<!--\\s*more.*-->/", $recipe->post_content(), $out)) {
                         // Add recipe box to the end of single pages or excerpts (unless there's a 'more' tag
                         $content .= $recipe_box;
                     }
                 }
             }
         } else {
             $content = str_replace('[recipe]', '', $content);
             // Remove shortcode from excerpt
             $content = $this->excerpt_filter($content);
         }
         // Remove searchable part
         $content = preg_replace("/\\[wpurp-searchable-recipe\\][^\\[]*\\[\\/wpurp-searchable-recipe\\]/", "", $content);
         add_filter('the_content', array($this, 'content_filter'), 10);
     }
     return $content;
 }
    public function output($recipe, $args = array())
    {
        if (!$this->output_block($recipe, $args)) {
            return '';
        }
        $url = urlencode($recipe->link());
        $img = WPUltimateRecipe::get()->coreUrl . '/img/foodfanatic.png';
        $output = $this->before_output();
        ob_start();
        ?>
<a href="http://www.foodfanatic.com/recipe-box/add/?url=<?php 
        echo $url;
        ?>
" target="_blank"><img src="<?php 
        echo $img;
        ?>
"/></a>
<?php 
        $output .= ob_get_contents();
        ob_end_clean();
        return $this->after_output($output, $recipe);
    }
 public function output($recipe, $args = array())
 {
     if (!$this->output_block($recipe, $args) || !isset($args['ingredient_name'])) {
         return '';
     }
     $taxonomy = get_term_by('name', $args['ingredient_name'], 'ingredient');
     $taxonomy_slug = is_object($taxonomy) ? $taxonomy->slug : $args['ingredient_name'];
     $ingredient_links = WPUltimateRecipe::option('recipe_ingredient_links', 'archive_custom');
     $output = $this->before_output();
     $plural = WPURP_Taxonomy_MetaData::get('ingredient', $taxonomy_slug, 'plural');
     $plural = is_array($plural) ? false : $plural;
     $plural_data = $plural ? ' data-singular="' . esc_attr($args['ingredient_name']) . '" data-plural="' . esc_attr($plural) . '"' : '';
     $output .= '<span' . $this->style() . $plural_data . '>';
     $closing_tag = '';
     if (!empty($taxonomy) && $ingredient_links != 'disabled') {
         if ($ingredient_links == 'archive_custom' || $ingredient_links == 'custom') {
             $custom_link = WPURP_Taxonomy_MetaData::get('ingredient', $taxonomy_slug, 'link');
         } else {
             $custom_link = false;
         }
         if (WPURP_Taxonomy_MetaData::get('ingredient', $taxonomy_slug, 'hide_link') !== '1') {
             if ($custom_link !== false && $custom_link !== '') {
                 $nofollow = WPUltimateRecipe::option('recipe_ingredient_custom_links_nofollow', '0') == '1' ? ' rel="nofollow"' : '';
                 $output .= '<a href="' . $custom_link . '" class="custom-ingredient-link" target="' . WPUltimateRecipe::option('recipe_ingredient_custom_links_target', '_blank') . '"' . $nofollow . '>';
                 $closing_tag = '</a>';
             } else {
                 if ($ingredient_links != 'custom') {
                     $output .= '<a href="' . get_term_link($taxonomy_slug, 'ingredient') . '">';
                     $closing_tag = '</a>';
                 }
             }
         }
     }
     $output .= $plural && $args['ingredient_quantity_normalized'] != 1 ? $plural : $args['ingredient_name'];
     $output .= $closing_tag;
     $output .= '</span>';
     return $this->after_output($output, $recipe);
 }
示例#30
0
 public function output($recipe, $args = array())
 {
     if (!$this->output_block($recipe, $args)) {
         return '';
     }
     $value = $recipe->nutritional($this->field);
     $unit = '';
     if ($this->percentage && $value != '') {
         $daily = WPUltimateRecipe::is_addon_active('nutritional-information') ? WPUltimateRecipe::addon('nutritional-information')->daily : array();
         $value = isset($daily[$this->field]) ? round(floatval($value) / $daily[$this->field] * 100) : $value;
         if ($this->unit) {
             $unit = '%';
         }
     } else {
         if ($this->unit && $value != '') {
             $fields = WPUltimateRecipe::is_addon_active('nutritional-information') ? WPUltimateRecipe::addon('nutritional-information')->fields : array();
             $unit = isset($fields[$this->field]) ? $fields[$this->field] : '';
         }
     }
     $output = $this->before_output();
     $output .= '<span' . $this->style() . '>' . $value . $unit . '</span>';
     return $this->after_output($output, $recipe);
 }