Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ authors:
given-names: Justin
- family-names: Tresova
given-names: Armand
version: 1.11.1
version: 1.11.2
doi: 10.5281/zenodo.1171250
date-released: 2017-05-08
url: "https://github.com/XjSv/cooked"
4 changes: 2 additions & 2 deletions SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ Versions that are currently being supported with security updates.

| Version | Supported |
| ----------- | ------------------ |
| 1.11.1 | :white_check_mark: |
| <= 1.11.0 | :x: |
| 1.11.2 | :white_check_mark: |
| <= 1.11.1 | :x: |

## Reporting a Vulnerability

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"recipe"
],
"homepage": "https://wordpress.org/plugins/cooked/",
"version": "1.11.1",
"version": "1.11.2",
"type": "wordpress-plugin",
"license": "GPL-3.0-or-later",
"prefer-stable": true,
Expand Down
2 changes: 1 addition & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 14 additions & 2 deletions cooked.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
Description: A recipe plugin for WordPress.
Author: Gora Tech
Author URI: https://goratech.dev
Version: 1.11.1
Version: 1.11.2
Text Domain: cooked
Domain Path: languages
License: GPL2
Expand All @@ -30,7 +30,7 @@

require_once __DIR__ . '/vendor/autoload.php';

define( 'COOKED_VERSION', '1.11.1' );
define( 'COOKED_VERSION', '1.11.2' );
define( 'COOKED_DEV', false );

if ( ! class_exists( 'Cooked_Plugin' ) ) :
Expand Down Expand Up @@ -96,6 +96,14 @@ final class Cooked_Plugin {
*/
public $migration;

/**
* Cooked Updates Object.
*
* @var object|Cooked_Updates
* @since 1.0.0
*/
public $updates;

/**
* Cooked Post Types Object.
*
Expand Down Expand Up @@ -243,6 +251,7 @@ public static function instance() {

self::$instance->admin_settings = new Cooked_Settings();
self::$instance->migration = new Cooked_Migration();
self::$instance->updates = new Cooked_Updates();
self::$instance->post_types = new Cooked_Post_Types();
self::$instance->recipe_meta = new Cooked_Recipe_Meta();
self::$instance->recipe_meta = new Cooked_Measurements();
Expand All @@ -259,6 +268,8 @@ public static function instance() {
self::$instance->module_setup();

add_action( 'init', [self::$instance, 'initialize_plugin_support'], 10 );

do_action('cooked_loaded');
}

return self::$instance;
Expand Down Expand Up @@ -446,6 +457,7 @@ private function includes() {
require_once COOKED_DIR . 'includes/class.cooked-admin-menus.php';
require_once COOKED_DIR . 'includes/class.cooked-settings.php';
require_once COOKED_DIR . 'includes/class.cooked-migration.php';
require_once COOKED_DIR . 'includes/class.cooked-updates.php';
require_once COOKED_DIR . 'includes/class.cooked-ajax.php';
require_once COOKED_DIR . 'includes/class.cooked-functions.php';
require_once COOKED_DIR . 'includes/class.cooked-widgets.php';
Expand Down
16 changes: 9 additions & 7 deletions includes/class.cooked-ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,15 @@ public function get_import_ids() {
];
} elseif ($import_type === 'wp_recipe_maker') {
$args = [
'post_type' => 'recipe',
'post_type' => 'wprm_recipe',
'posts_per_page' => -1,
'post_status' => 'any',
'fields' => 'ids',
'meta_query' => [
[
'key' => 'recipe_maker_metadata',
'compare' => 'EXISTS',
'key' => 'wprm_type',
'value' => 'food',
'compare' => '=',
],
],
];
Expand Down Expand Up @@ -204,6 +205,7 @@ public function import_recipes() {
}

require_once COOKED_DIR . 'includes/class.cooked-delicious-recipes.php';
require_once COOKED_DIR . 'includes/class.cooked-recipe-maker.php';

$bulk_amount = 10;

Expand Down Expand Up @@ -233,9 +235,9 @@ public function import_recipes() {
foreach ( $recipe_ids as $rid ) {
if ($import_type === 'delicious_recipes') {
Cooked_Delicious_Recipes::import_recipe( $rid );
} /* elseif ($import_type === 'wp_recipe_maker') {
} elseif ($import_type === 'wp_recipe_maker') {
Cooked_Recipe_Maker_Recipes::import_recipe( $rid );
} */
}
}

if ( !empty( $leftover_recipe_ids ) ) {
Expand All @@ -244,9 +246,9 @@ public function import_recipes() {
} else {
if ($import_type === 'delicious_recipes') {
update_option( 'cooked_delicious_recipes_imported', true );
} /* elseif ($import_type === 'wp_recipe_maker') {
} elseif ($import_type === 'wp_recipe_maker') {
update_option( 'cooked_wp_recipe_maker_imported', true );
} */
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion includes/class.cooked-delicious-recipes.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public static function import_recipe($id) {
if (is_wp_error($new_recipe_id)) {
return [
'status' => false,
'message' => __('Error importing recipe.', 'cooked'),
'message' => __('Error importing WP Delicious recipe.', 'cooked'),
];
}

Expand Down
32 changes: 28 additions & 4 deletions includes/class.cooked-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@

class Cooked_Functions {

/**
* Guest message ID
*
* @var string
*/
private static $guest_message_id = false;

public static function sanitize_text_field( $text ) {
$text = htmlentities( stripslashes( $text ) );
$text = sanitize_text_field( $text );
Expand Down Expand Up @@ -223,26 +230,43 @@ function update_print_options( printOpt ) {
}

</script><?php

}

// Store the message
public static function set_transient_message($message) {
$user_id = get_current_user_id();
if ( !empty( $user_id ) && !empty( $message ) ) {
set_transient('cooked_user_' . $user_id . '_message', $message, 60); // Expires in 60 seconds
if ( !empty( $message )) {
if ( !empty( $user_id ) ) {
set_transient('cooked_user_' . $user_id . '_message', $message, 60); // Expires in 60 seconds
} else {
// For guests
self::$guest_message_id = uniqid();
set_transient('cooked_guest_' . self::$guest_message_id . '_message', $message, 60); // Expires in 60 seconds
return self::$guest_message_id;
}
}
}

// Retrieve and delete the message
public static function get_and_delete_transient_message() {
public static function get_and_delete_transient_message($guest_message_id = false) {
$user_id = get_current_user_id();
if ( !empty( $user_id ) ) {
$message = get_transient('cooked_user_' . $user_id . '_message');
if ( !empty( $message ) ) {
delete_transient('cooked_user_' . $user_id . '_message');
return $message;
}
} else {
// For guests - use provided guest_message_id or fall back to static property
$message_id = $guest_message_id ?: self::$guest_message_id;
if ( $message_id ) {
$message = get_transient('cooked_guest_' . $message_id . '_message');
if ( !empty( $message ) ) {
delete_transient('cooked_guest_' . $message_id . '_message');
self::$guest_message_id = false;
return $message;
}
}
}
return false;
}
Expand Down
61 changes: 60 additions & 1 deletion includes/class.cooked-import.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ public static function tabs_fields() {
$delicious_recipes = $Cooked_Delicious_Recipes::get_recipes();
$cooked_delicious_recipes_imported = get_option( 'cooked_delicious_recipes_imported', false );

$Cooked_Recipe_Maker_Recipes = new Cooked_Recipe_Maker_Recipes();
$wp_recipe_maker_recipes = $Cooked_Recipe_Maker_Recipes::get_recipes();
$cooked_wp_recipe_maker_imported = get_option( 'cooked_wp_recipe_maker_imported', false );

$import_tabs = [];
if (!empty($delicious_recipes)) {
$total = count($delicious_recipes);
Expand Down Expand Up @@ -89,11 +93,66 @@ public static function tabs_fields() {
];
}

if (!empty($wp_recipe_maker_recipes)) {
$total = count($wp_recipe_maker_recipes);

/* translators: for displaying singular or plural versions depending on the number of recipes. */
$html_desc = sprintf( esc_html( _n( 'There is %1$s recipe that should be imported from %2$s.', 'There are %1$s recipes that should be imported from %2$s.', $total, 'cooked' ) ), '<strong>' . number_format( $total ) . '</strong>', '<strong>WP Recipe Maker</strong>' );
$html_desc .= '<br>';
$html_desc .= __( 'Before you begin, please make sure you <b>backup your database</b> in case something goes wrong.', 'cooked' );
$html_desc .= '<br>';
$html_desc .= __( 'Click the button below to import these recipes. Here is what will happen to your recipes:', 'cooked' );
$html_desc .= '<ul class="cooked-admin-ul">';
$html_desc .= '<li>' . __( 'Recipes will be imported with the <b>\'Draft\'</b> status.', 'cooked' ) . '</li>';
$html_desc .= '<li>' . __( 'Comments and ratings data will also be imported (ratings are available in Cooked Pro).', 'cooked' ) . '</li>';
$html_desc .= '<li>' . __( 'The difficulty level will be set to <b>Beginner</b> since it is not supported by WP Recipe Maker.', 'cooked' ) . '</li>';
$html_desc .= '<li>' . __( 'After the import is complete, you can bulk edit the recipes and change their status to <b>\'Published\'</b>.', 'cooked' ) . '</li>';
$html_desc .= '<li>' . __( 'The existing WP Recipe Maker and data will not be modified or deleted.', 'cooked' ) . '</li>';
$html_desc .= '<li>' . __( 'Certain data that is not suppoted by Cooked will not be imported (such as Cooking Temp, Estimated Cost, Recipe Keywords, etc).', 'cooked' ) . '</li>';
$html_desc .= '<li>' . __( 'You can run the import multiple times, but keep in mind that duplicate recipes will be created.', 'cooked' ) . '</li>';
$html_desc .= '</ul>';

if ($total > 2000) {
$html_desc .= '<p class="cooked-import-note"><strong>' . __( 'Wow, you have a lot of recipes!', 'cooked' ) . '</strong><br><em style="color:#333;">' . __( 'It is definitely recommended that you get yourself a cup of coffee or tea after clicking this button.', 'cooked' ) . '</em></p>';
} else {
$html_desc .= '<p class="cooked-import-note"><strong>' . __( 'Note:', 'cooked' ) . '</strong> ' . __( 'The more recipes you have, the longer this will take.', 'cooked' ) . '</p>';
}

if ($total > 0) {
$import_tabs['wp_recipe_maker_import'] = [
'name' => __('WP Recipe Maker - Import', 'cooked'),
'icon' => 'migrate',
'fields' => [
'cooked_import_button' => [
'title' => 'WP Recipe Maker&nbsp;&nbsp;<i class="cooked-icon cooked-icon-angle-right"></i>&nbsp;&nbsp;Cooked',
'desc' => $html_desc,
'type' => 'import_button',
'total' => $total,
'import_type' => $Cooked_Recipe_Maker_Recipes->import_type,
]
]
];
}
} else {
$import_tabs['no_wp_recipe_maker_recipes'] = [
'name' => __('WP Recipe Maker - Import', 'cooked'),
'icon' => 'migrate',
'fields' => [
'cooked_no_wp_recipe_maker_recipes' => [
'title' => 'WP Recipe Maker',
'desc' => '',
'type' => 'message',
'message' => 'There are no recipes to import from WP Recipe Maker.',
]
]
];
}

$import_tabs['more_imports_coming_soon'] = [
'name' => __('More Imports are Coming Soon...', 'cooked'),
'icon' => 'migrate',
'fields' => [
'cooked_no_delicious_recipes' => [
'cooked_more_imports_coming_soon' => [
'title' => 'More Imports are Coming Soon...',
'desc' => '',
'type' => 'message',
Expand Down
Loading