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');
     }
 }
示例#2
0
 public function __construct($post)
 {
     // Get associated post
     if (is_object($post) && $post instanceof WP_Post) {
         $this->post = $post;
     } else {
         if (is_numeric($post)) {
             $this->post = get_post($post);
         } else {
             throw new InvalidArgumentException('Recipes can only be instantiated with a Post object or Post ID.');
         }
     }
     // Add custom fields to recipe fields if there are any
     $custom_fields_addon = WPUltimateRecipe::addon('custom-fields');
     if ($custom_fields_addon) {
         $fields = $this->fields;
         $custom_fields = $custom_fields_addon->get_custom_fields();
         foreach ($custom_fields as $key => $custom_field) {
             $fields[] = $key;
         }
         $this->fields = $fields;
     }
     // Get metadata
     $this->meta = get_post_custom($this->post->ID);
 }
示例#3
0
 public function migrate_if_needed()
 {
     // Get current migrated to version
     $migrate_version = get_option('wpurp_migrate_version', false);
     if (!$migrate_version) {
         $notices = false;
         $migrate_version = '0.0.1';
     } else {
         $notices = true;
     }
     $migrate_special = '';
     if (isset($_GET['wpurp_migrate'])) {
         $migrate_special = $_GET['wpurp_migrate'];
     }
     // Specific version migrations
     if ($migrate_version < '1.0.4') {
         require_once WPUltimateRecipe::get()->coreDir . '/helpers/migration/1_0_4_ingredient_ids.php';
     }
     if ($migrate_version < '1.0.8') {
         require_once WPUltimateRecipe::get()->coreDir . '/helpers/migration/1_0_8_amount_and_menus.php';
     }
     if ($migrate_version < '1.0.9') {
         require_once WPUltimateRecipe::get()->coreDir . '/helpers/migration/1_0_9_free_text_times.php';
     }
     if ($migrate_version < '2.0.0') {
         require_once WPUltimateRecipe::get()->coreDir . '/helpers/migration/2_0_0_recipe_terms.php';
     }
     if ($migrate_version < '2.0.5') {
         require_once WPUltimateRecipe::get()->coreDir . '/helpers/migration/2_0_5_recipe_grid_settings.php';
     }
     if ($migrate_version < '2.0.8') {
         require_once WPUltimateRecipe::get()->coreDir . '/helpers/migration/2_0_8_recipe_titles.php';
     }
     if ($migrate_version < '2.1.4') {
         require_once WPUltimateRecipe::get()->coreDir . '/helpers/migration/2_1_4_servings_problem.php';
     }
     if ($migrate_version < '2.2.1') {
         require_once WPUltimateRecipe::get()->coreDir . '/helpers/migration/2_2_1_custom_templates.php';
     }
     // Special migrations
     if ($migrate_special == 'RecipesToPosts') {
         require_once WPUltimateRecipe::get()->coreDir . '/helpers/migration/special_recipes_to_posts.php';
     }
     if ($migrate_special == 'WooCommerceIngredients') {
         require_once WPUltimateRecipe::get()->coreDir . '/helpers/migration/special_woocommerce_ingredients.php';
     }
     // Cron migrations
     $timestamp = wp_next_scheduled('wpurp_cron_migrations');
     if (!$timestamp) {
         //Schedule the event for right now, then to repeat daily using the hook 'wi_create_daily_backup'
         wp_schedule_event(time(), 'hourly', 'wpurp_cron_migrations');
     }
     // Each version update once
     if ($migrate_version < WPURP_VERSION) {
         WPUltimateRecipe::addon('custom-templates')->default_templates(true);
         // Reset default templates
         update_option('wpurp_migrate_version', WPURP_VERSION);
     }
 }
    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);
    }
function wpurp_admin_templates()
{
    $template_list = array();
    $templates = WPUltimateRecipe::addon('custom-templates')->get_mapping();
    foreach ($templates as $index => $template) {
        $template_list[] = array('value' => $index, 'label' => $template);
    }
    return $template_list;
}
function wpurp_shortcode_generator_templates()
{
    $template_list = array();
    $templates = WPUltimateRecipe::addon('custom-templates')->get_mapping();
    foreach ($templates as $index => $template) {
        $template_list[] = array('value' => $index, 'label' => $template);
    }
    $template_list[] = array('value' => 'default', 'label' => 'Default');
    return $template_list;
}
示例#7
0
 public function activate_plugin()
 {
     WPUltimateRecipe::get()->helper('recipe_post_type')->register_recipe_post_type();
     WPUltimateRecipe::get()->helper('taxonomies')->check_recipe_taxonomies();
     WPUltimateRecipe::get()->helper('permalinks_flusher')->set_flush_needed();
     WPUltimateRecipe::addon('custom-templates')->default_templates(true);
     // Reset default templates
     // Don't show the activation notice if the new user notice is displayed
     if (get_user_meta(get_current_user_id(), '_wpurp_hide_new_notice', true) != '') {
         $this->activation_notice();
     }
 }
示例#8
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);
 }
示例#9
0
 public function output($recipe, $args = array())
 {
     if (!$this->output_block($recipe, $args)) {
         return '';
     }
     if (WPUltimateRecipe::is_addon_active('user-ratings') && WPUltimateRecipe::option('user_ratings_enable', 'everyone') != 'disabled') {
         $stars = WPUltimateRecipe::addon('user-ratings')->output($recipe);
     } else {
         $stars = $this->stars_author($recipe);
     }
     $output = $this->before_output();
     $output .= '<span' . $this->style() . '>' . $stars . '</span>';
     return $this->after_output($output, $recipe);
 }
示例#10
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);
 }
示例#11
0
 protected function before_output()
 {
     $output = '';
     // Responsive
     if (!$this->show_on_desktop) {
         $output = '<div class="wpurp-responsive-mobile">';
     } else {
         if (!$this->show_on_mobile) {
             $output = '<div class="wpurp-responsive-desktop">';
         }
     }
     // Background presets
     if ($this->background_preset) {
         switch ($this->background_preset) {
             case 'default':
                 $img = WPUltimateRecipe::addon('custom-templates')->addonUrl . '/img/default.png';
                 break;
             default:
                 $img = WPUltimateRecipe::addon('template-editor')->addonUrl . '/img/' . $this->background_preset . '.png';
         }
         if (isset($img)) {
             $this->add_style('background', 'url(' . $img . ')');
         }
     }
     return $output;
 }
示例#12
0
<div class="recipe-notes-container">
    <h4><?php 
_e('Recipe notes', 'wp-ultimate-recipe');
?>
</h4>
    <?php 
$options = array('textarea_rows' => 7);
if (isset($wpurp_user_submission)) {
    $options['media_buttons'] = false;
}
wp_editor($recipe->notes(), 'recipe_notes', $options);
?>
</div>
<?php 
$custom_fields_addon = WPUltimateRecipe::addon('custom-fields');
if ($custom_fields_addon && (!isset($wpurp_user_submission) || WPUltimateRecipe::option('recipe_fields_in_user_submission', '1') == '1')) {
    $custom_fields = $custom_fields_addon->get_custom_fields();
    $custom_fields_in_user_submission = WPUltimateRecipe::option('recipe_fields_user_submission', array_keys($custom_fields));
    if (count($custom_fields) > 0) {
        ?>
<div class="recipe-custom-fields-container">
    <h4><?php 
        _e('Custom Fields', 'wp-ultimate-recipe');
        ?>
</h4>
    <table class="recipe-general-form">
        <?php 
        foreach ($custom_fields as $key => $custom_field) {
            if (isset($wpurp_user_submission) && !in_array($key, $custom_fields_in_user_submission)) {
                continue;
<?php

/*
 * -> 2.2.1
 *
 * Better way of saving custom templates
 */
$custom_templates = get_option('wpurp_custom_templates', array());
$mapping = array();
foreach ($custom_templates as $id => $custom_template) {
    $mapping[$id] = $custom_template['name'];
    add_option('wpurp_custom_template_' . intval($id), $custom_template['template']);
}
WPUltimateRecipe::addon('custom-templates')->update_mapping($mapping);
// Successfully migrated to 2.1.4
$migrate_version = '2.2.1';
update_option('wpurp_migrate_version', $migrate_version);
if ($notices) {
    WPUltimateRecipe::get()->helper('notices')->add_admin_notice('<strong>WP Ultimate Recipe</strong> Successfully migrated to 2.2.1+');
}