Completed
Pull Request — develop (#1581)
by
unknown
01:43
created
src/modules/food-kg/includes/admin/Main_Ingredient_List_Table.php 2 patches
Indentation   +65 added lines, -65 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
 namespace Wordlift\Modules\Food_Kg\Admin;
4 4
 
5 5
 if ( ! class_exists( 'WP_List_Table' ) ) {
6
-	require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
6
+    require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
7 7
 }
8 8
 
9 9
 use WP_List_Table;
@@ -11,74 +11,74 @@  discard block
 block discarded – undo
11 11
 
12 12
 class Main_Ingredient_List_Table extends WP_List_Table {
13 13
 
14
-	public function prepare_items() {
15
-		global $wpdb; // This is used only if making any database queries
16
-
17
-		/**
18
-		 * REQUIRED. Now we need to define our column headers. This includes a complete
19
-		 * array of columns to be displayed (slugs & titles), a list of columns
20
-		 * to keep hidden, and a list of columns that are sortable. Each of these
21
-		 * can be defined in another method (as we've done here) before being
22
-		 * used to build the value for our _column_headers property.
23
-		 */
24
-		$columns  = $this->get_columns();
25
-		$hidden   = array();
26
-		$sortable = $this->get_sortable_columns();
27
-
28
-		/**
29
-		 * REQUIRED. Finally, we build an array to be used by the class for column
30
-		 * headers. The $this->_column_headers property takes an array which contains
31
-		 * 3 other arrays. One for all columns, one for hidden columns, and one
32
-		 * for sortable columns.
33
-		 */
34
-		$this->_column_headers = array( $columns, $hidden, $sortable );
35
-
36
-		$this->items = $wpdb->get_results(
37
-			"SELECT p.ID, p.post_title, pm.meta_value
14
+    public function prepare_items() {
15
+        global $wpdb; // This is used only if making any database queries
16
+
17
+        /**
18
+         * REQUIRED. Now we need to define our column headers. This includes a complete
19
+         * array of columns to be displayed (slugs & titles), a list of columns
20
+         * to keep hidden, and a list of columns that are sortable. Each of these
21
+         * can be defined in another method (as we've done here) before being
22
+         * used to build the value for our _column_headers property.
23
+         */
24
+        $columns  = $this->get_columns();
25
+        $hidden   = array();
26
+        $sortable = $this->get_sortable_columns();
27
+
28
+        /**
29
+         * REQUIRED. Finally, we build an array to be used by the class for column
30
+         * headers. The $this->_column_headers property takes an array which contains
31
+         * 3 other arrays. One for all columns, one for hidden columns, and one
32
+         * for sortable columns.
33
+         */
34
+        $this->_column_headers = array( $columns, $hidden, $sortable );
35
+
36
+        $this->items = $wpdb->get_results(
37
+            "SELECT p.ID, p.post_title, pm.meta_value
38 38
 			FROM $wpdb->posts p
39 39
 			INNER JOIN $wpdb->postmeta pm
40 40
 			    ON pm.post_ID = p.ID
41 41
 					AND pm.meta_key = '_wl_main_ingredient_jsonld'"
42
-		);
43
-	}
44
-
45
-	public function no_items() {
46
-		esc_html_e( 'No main ingredients found.', 'wordlift' );
47
-	}
48
-
49
-	public function get_columns() {
50
-		return array(
51
-			'post_title' => __( 'Name', 'wordlift' ),
52
-			'url'        => __( 'URL', 'wordlift' ),
53
-			'actions'    => '',
54
-		);
55
-	}
56
-
57
-	public function column_post_title( $item ) {
58
-		$recipe   = WPRM_Recipe_Manager::get_recipe( $item->ID );
59
-		$edit_url = $recipe->parent_edit_url();
60
-
61
-		return empty( $edit_url ) ? $item->post_title : sprintf( '<a href="%s">%s</a>', $recipe->parent_edit_url(), $item->post_title );
62
-	}
63
-
64
-	public function column_url( $item ) {
65
-		$url = get_permalink( $item->ID );
66
-		return esc_html( $url );
67
-	}
68
-
69
-	public function column_actions( $item ) {
70
-
71
-		$url = admin_url(
72
-			sprintf( 'admin.php?page=wl_ingredients&modal_window=true&id=%d&TB_iframe=true', $item->ID )
73
-		);
74
-
75
-		return sprintf(
76
-			'<a href="%s" class="button alignright thickbox open-plugin-details-modal" data-title="%s" type="button">%s</a>',
77
-			$url,
78
-			esc_attr( $item->post_title ),
79
-			esc_html__( 'JSON-LD', 'wordlift' )
80
-		);
81
-	}
42
+        );
43
+    }
44
+
45
+    public function no_items() {
46
+        esc_html_e( 'No main ingredients found.', 'wordlift' );
47
+    }
48
+
49
+    public function get_columns() {
50
+        return array(
51
+            'post_title' => __( 'Name', 'wordlift' ),
52
+            'url'        => __( 'URL', 'wordlift' ),
53
+            'actions'    => '',
54
+        );
55
+    }
56
+
57
+    public function column_post_title( $item ) {
58
+        $recipe   = WPRM_Recipe_Manager::get_recipe( $item->ID );
59
+        $edit_url = $recipe->parent_edit_url();
60
+
61
+        return empty( $edit_url ) ? $item->post_title : sprintf( '<a href="%s">%s</a>', $recipe->parent_edit_url(), $item->post_title );
62
+    }
63
+
64
+    public function column_url( $item ) {
65
+        $url = get_permalink( $item->ID );
66
+        return esc_html( $url );
67
+    }
68
+
69
+    public function column_actions( $item ) {
70
+
71
+        $url = admin_url(
72
+            sprintf( 'admin.php?page=wl_ingredients&modal_window=true&id=%d&TB_iframe=true', $item->ID )
73
+        );
74
+
75
+        return sprintf(
76
+            '<a href="%s" class="button alignright thickbox open-plugin-details-modal" data-title="%s" type="button">%s</a>',
77
+            $url,
78
+            esc_attr( $item->post_title ),
79
+            esc_html__( 'JSON-LD', 'wordlift' )
80
+        );
81
+    }
82 82
 
83 83
 }
84 84
 
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -2,8 +2,8 @@  discard block
 block discarded – undo
2 2
 
3 3
 namespace Wordlift\Modules\Food_Kg\Admin;
4 4
 
5
-if ( ! class_exists( 'WP_List_Table' ) ) {
6
-	require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
5
+if ( ! class_exists('WP_List_Table')) {
6
+	require_once ABSPATH.'wp-admin/includes/class-wp-list-table.php';
7 7
 }
8 8
 
9 9
 use WP_List_Table;
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
 		 * 3 other arrays. One for all columns, one for hidden columns, and one
32 32
 		 * for sortable columns.
33 33
 		 */
34
-		$this->_column_headers = array( $columns, $hidden, $sortable );
34
+		$this->_column_headers = array($columns, $hidden, $sortable);
35 35
 
36 36
 		$this->items = $wpdb->get_results(
37 37
 			"SELECT p.ID, p.post_title, pm.meta_value
@@ -43,40 +43,40 @@  discard block
 block discarded – undo
43 43
 	}
44 44
 
45 45
 	public function no_items() {
46
-		esc_html_e( 'No main ingredients found.', 'wordlift' );
46
+		esc_html_e('No main ingredients found.', 'wordlift');
47 47
 	}
48 48
 
49 49
 	public function get_columns() {
50 50
 		return array(
51
-			'post_title' => __( 'Name', 'wordlift' ),
52
-			'url'        => __( 'URL', 'wordlift' ),
51
+			'post_title' => __('Name', 'wordlift'),
52
+			'url'        => __('URL', 'wordlift'),
53 53
 			'actions'    => '',
54 54
 		);
55 55
 	}
56 56
 
57
-	public function column_post_title( $item ) {
58
-		$recipe   = WPRM_Recipe_Manager::get_recipe( $item->ID );
57
+	public function column_post_title($item) {
58
+		$recipe   = WPRM_Recipe_Manager::get_recipe($item->ID);
59 59
 		$edit_url = $recipe->parent_edit_url();
60 60
 
61
-		return empty( $edit_url ) ? $item->post_title : sprintf( '<a href="%s">%s</a>', $recipe->parent_edit_url(), $item->post_title );
61
+		return empty($edit_url) ? $item->post_title : sprintf('<a href="%s">%s</a>', $recipe->parent_edit_url(), $item->post_title);
62 62
 	}
63 63
 
64
-	public function column_url( $item ) {
65
-		$url = get_permalink( $item->ID );
66
-		return esc_html( $url );
64
+	public function column_url($item) {
65
+		$url = get_permalink($item->ID);
66
+		return esc_html($url);
67 67
 	}
68 68
 
69
-	public function column_actions( $item ) {
69
+	public function column_actions($item) {
70 70
 
71 71
 		$url = admin_url(
72
-			sprintf( 'admin.php?page=wl_ingredients&modal_window=true&id=%d&TB_iframe=true', $item->ID )
72
+			sprintf('admin.php?page=wl_ingredients&modal_window=true&id=%d&TB_iframe=true', $item->ID)
73 73
 		);
74 74
 
75 75
 		return sprintf(
76 76
 			'<a href="%s" class="button alignright thickbox open-plugin-details-modal" data-title="%s" type="button">%s</a>',
77 77
 			$url,
78
-			esc_attr( $item->post_title ),
79
-			esc_html__( 'JSON-LD', 'wordlift' )
78
+			esc_attr($item->post_title),
79
+			esc_html__('JSON-LD', 'wordlift')
80 80
 		);
81 81
 	}
82 82
 
Please login to merge, or discard this patch.
src/modules/food-kg/includes/Main_Ingredient_Recipe_Lift_Strategy.php 2 patches
Indentation   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -4,66 +4,66 @@
 block discarded – undo
4 4
 
5 5
 class Main_Ingredient_Recipe_Lift_Strategy implements Recipe_Lift_Strategy {
6 6
 
7
-	/**
8
-	 * @var Ingredients_Client
9
-	 */
10
-	private $ingredients_client;
7
+    /**
8
+     * @var Ingredients_Client
9
+     */
10
+    private $ingredients_client;
11 11
 
12
-	/**
13
-	 * @var Notices
14
-	 */
15
-	private $notices;
12
+    /**
13
+     * @var Notices
14
+     */
15
+    private $notices;
16 16
 
17
-	public function __construct( Ingredients_Client $ingredients_client, Notices $notices ) {
18
-		$this->ingredients_client = $ingredients_client;
19
-		$this->notices            = $notices;
20
-	}
17
+    public function __construct( Ingredients_Client $ingredients_client, Notices $notices ) {
18
+        $this->ingredients_client = $ingredients_client;
19
+        $this->notices            = $notices;
20
+    }
21 21
 
22
-	public function get_json_ld_data( $ingredient ) {
23
-		// Get JSON LD Data.
24
-		return $this->ingredients_client->main_ingredient( $ingredient );
25
-	}
22
+    public function get_json_ld_data( $ingredient ) {
23
+        // Get JSON LD Data.
24
+        return $this->ingredients_client->main_ingredient( $ingredient );
25
+    }
26 26
 
27
-	public function run() {
28
-		$this->notices->queue( 'info', __( 'WordLift detected WP Recipe Maker and, it is lifting the ingredients...', 'wordlift' ) );
27
+    public function run() {
28
+        $this->notices->queue( 'info', __( 'WordLift detected WP Recipe Maker and, it is lifting the ingredients...', 'wordlift' ) );
29 29
 
30
-		$recipes = get_posts(
31
-			array(
32
-				'post_type'   => 'wprm_recipe',
33
-				'numberposts' => - 1,
34
-			)
35
-		);
36
-		$count   = count( $recipes );
30
+        $recipes = get_posts(
31
+            array(
32
+                'post_type'   => 'wprm_recipe',
33
+                'numberposts' => - 1,
34
+            )
35
+        );
36
+        $count   = count( $recipes );
37 37
 
38
-		$count_lifted = 0;
39
-		foreach ( $recipes as $recipe ) {
40
-			/* translators: 1: The number of lifted recipes, 2: The total number of recipes. */
41
-			$this->notices->queue( 'info', sprintf( __( 'WordLift is adding the main ingredient to recipes. So far it lifted %1$d of %2$d recipe(s).', 'wordlift' ), $count_lifted, $count ) );
38
+        $count_lifted = 0;
39
+        foreach ( $recipes as $recipe ) {
40
+            /* translators: 1: The number of lifted recipes, 2: The total number of recipes. */
41
+            $this->notices->queue( 'info', sprintf( __( 'WordLift is adding the main ingredient to recipes. So far it lifted %1$d of %2$d recipe(s).', 'wordlift' ), $count_lifted, $count ) );
42 42
 
43
-			// Emit something to keep the connection alive.
44
-			echo esc_html( "$count_lifted\n" );
43
+            // Emit something to keep the connection alive.
44
+            echo esc_html( "$count_lifted\n" );
45 45
 
46
-			// Skip posts with existing data.
47
-			$existing = get_post_meta( $recipe->ID, '_wl_main_ingredient_jsonld', true );
48
-			if ( ! empty( $existing ) ) {
49
-				$count_lifted ++;
50
-				continue;
51
-			}
46
+            // Skip posts with existing data.
47
+            $existing = get_post_meta( $recipe->ID, '_wl_main_ingredient_jsonld', true );
48
+            if ( ! empty( $existing ) ) {
49
+                $count_lifted ++;
50
+                continue;
51
+            }
52 52
 
53
-			$jsonld = $this->ingredients_client->main_ingredient( $recipe->post_title );
54
-			if ( ! empty( $jsonld ) ) {
55
-				add_post_meta( $recipe->ID, '_wl_main_ingredient_jsonld', $jsonld );
56
-				$count_lifted ++;
57
-			} else {
58
-				delete_post_meta( $recipe->ID, '_wl_main_ingredient_jsonld' );
59
-			}
60
-		}
53
+            $jsonld = $this->ingredients_client->main_ingredient( $recipe->post_title );
54
+            if ( ! empty( $jsonld ) ) {
55
+                add_post_meta( $recipe->ID, '_wl_main_ingredient_jsonld', $jsonld );
56
+                $count_lifted ++;
57
+            } else {
58
+                delete_post_meta( $recipe->ID, '_wl_main_ingredient_jsonld' );
59
+            }
60
+        }
61 61
 
62
-		/**
63
-		 * @@todo add notification that procedure is complete, with information about the number of processed items vs
64
-		 *   total items
65
-		 */
66
-		/* translators: 1: The number of lifted recipes, 2: The total number of recipes. */
67
-		$this->notices->queue( 'info', sprintf( __( 'WordLift lifted %1$d of %2$d recipe(s).', 'wordlift' ), $count_lifted, $count ) );
68
-	}
62
+        /**
63
+         * @@todo add notification that procedure is complete, with information about the number of processed items vs
64
+         *   total items
65
+         */
66
+        /* translators: 1: The number of lifted recipes, 2: The total number of recipes. */
67
+        $this->notices->queue( 'info', sprintf( __( 'WordLift lifted %1$d of %2$d recipe(s).', 'wordlift' ), $count_lifted, $count ) );
68
+    }
69 69
 }
Please login to merge, or discard this patch.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -14,48 +14,48 @@  discard block
 block discarded – undo
14 14
 	 */
15 15
 	private $notices;
16 16
 
17
-	public function __construct( Ingredients_Client $ingredients_client, Notices $notices ) {
17
+	public function __construct(Ingredients_Client $ingredients_client, Notices $notices) {
18 18
 		$this->ingredients_client = $ingredients_client;
19 19
 		$this->notices            = $notices;
20 20
 	}
21 21
 
22
-	public function get_json_ld_data( $ingredient ) {
22
+	public function get_json_ld_data($ingredient) {
23 23
 		// Get JSON LD Data.
24
-		return $this->ingredients_client->main_ingredient( $ingredient );
24
+		return $this->ingredients_client->main_ingredient($ingredient);
25 25
 	}
26 26
 
27 27
 	public function run() {
28
-		$this->notices->queue( 'info', __( 'WordLift detected WP Recipe Maker and, it is lifting the ingredients...', 'wordlift' ) );
28
+		$this->notices->queue('info', __('WordLift detected WP Recipe Maker and, it is lifting the ingredients...', 'wordlift'));
29 29
 
30 30
 		$recipes = get_posts(
31 31
 			array(
32 32
 				'post_type'   => 'wprm_recipe',
33
-				'numberposts' => - 1,
33
+				'numberposts' => -1,
34 34
 			)
35 35
 		);
36
-		$count   = count( $recipes );
36
+		$count = count($recipes);
37 37
 
38 38
 		$count_lifted = 0;
39
-		foreach ( $recipes as $recipe ) {
39
+		foreach ($recipes as $recipe) {
40 40
 			/* translators: 1: The number of lifted recipes, 2: The total number of recipes. */
41
-			$this->notices->queue( 'info', sprintf( __( 'WordLift is adding the main ingredient to recipes. So far it lifted %1$d of %2$d recipe(s).', 'wordlift' ), $count_lifted, $count ) );
41
+			$this->notices->queue('info', sprintf(__('WordLift is adding the main ingredient to recipes. So far it lifted %1$d of %2$d recipe(s).', 'wordlift'), $count_lifted, $count));
42 42
 
43 43
 			// Emit something to keep the connection alive.
44
-			echo esc_html( "$count_lifted\n" );
44
+			echo esc_html("$count_lifted\n");
45 45
 
46 46
 			// Skip posts with existing data.
47
-			$existing = get_post_meta( $recipe->ID, '_wl_main_ingredient_jsonld', true );
48
-			if ( ! empty( $existing ) ) {
49
-				$count_lifted ++;
47
+			$existing = get_post_meta($recipe->ID, '_wl_main_ingredient_jsonld', true);
48
+			if ( ! empty($existing)) {
49
+				$count_lifted++;
50 50
 				continue;
51 51
 			}
52 52
 
53
-			$jsonld = $this->ingredients_client->main_ingredient( $recipe->post_title );
54
-			if ( ! empty( $jsonld ) ) {
55
-				add_post_meta( $recipe->ID, '_wl_main_ingredient_jsonld', $jsonld );
56
-				$count_lifted ++;
53
+			$jsonld = $this->ingredients_client->main_ingredient($recipe->post_title);
54
+			if ( ! empty($jsonld)) {
55
+				add_post_meta($recipe->ID, '_wl_main_ingredient_jsonld', $jsonld);
56
+				$count_lifted++;
57 57
 			} else {
58
-				delete_post_meta( $recipe->ID, '_wl_main_ingredient_jsonld' );
58
+				delete_post_meta($recipe->ID, '_wl_main_ingredient_jsonld');
59 59
 			}
60 60
 		}
61 61
 
@@ -64,6 +64,6 @@  discard block
 block discarded – undo
64 64
 		 *   total items
65 65
 		 */
66 66
 		/* translators: 1: The number of lifted recipes, 2: The total number of recipes. */
67
-		$this->notices->queue( 'info', sprintf( __( 'WordLift lifted %1$d of %2$d recipe(s).', 'wordlift' ), $count_lifted, $count ) );
67
+		$this->notices->queue('info', sprintf(__('WordLift lifted %1$d of %2$d recipe(s).', 'wordlift'), $count_lifted, $count));
68 68
 	}
69 69
 }
Please login to merge, or discard this patch.
src/modules/food-kg/includes/Preconditions.php 2 patches
Indentation   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -4,39 +4,39 @@
 block discarded – undo
4 4
 
5 5
 class Preconditions {
6 6
 
7
-	/**
8
-	 * @var Notices
9
-	 */
10
-	private $notices;
11
-
12
-	public function __construct( Notices $notices ) {
13
-		$this->notices = $notices;
14
-	}
15
-
16
-	public function pass() {
17
-		return $this->has_prerequisites() && $this->check_version();
18
-	}
19
-
20
-	private function has_prerequisites() {
21
-		return defined( 'WPRM_VERSION' )
22
-			   && class_exists( 'WP_Recipe_Maker' )
23
-		       // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
24
-			   && apply_filters( 'wl_feature__enable__food-kg', false );
25
-	}
26
-
27
-	private function check_version() {
28
-		$check = version_compare( WPRM_VERSION, '8.1.0', '>=' )
29
-				&& version_compare( WPRM_VERSION, '8.6.0', '<' );
30
-
31
-		if ( ! $check ) {
32
-			$this->notices->queue(
33
-				'warning',
34
-				/* translators: 1: minimum supported WPRM version, 2: maximum supported WPRM version, 3: Detected WP Recipe Maker version. */
35
-				sprintf( __( 'WordLift Food KG support requires WP Recipe Maker %1$s-%2$s, %3$s found.', 'wordlift' ), '8.1.0', '8.5.0', WPRM_VERSION )
36
-			);
37
-		}
38
-
39
-		return $check;
40
-	}
7
+    /**
8
+     * @var Notices
9
+     */
10
+    private $notices;
11
+
12
+    public function __construct( Notices $notices ) {
13
+        $this->notices = $notices;
14
+    }
15
+
16
+    public function pass() {
17
+        return $this->has_prerequisites() && $this->check_version();
18
+    }
19
+
20
+    private function has_prerequisites() {
21
+        return defined( 'WPRM_VERSION' )
22
+               && class_exists( 'WP_Recipe_Maker' )
23
+                // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
24
+               && apply_filters( 'wl_feature__enable__food-kg', false );
25
+    }
26
+
27
+    private function check_version() {
28
+        $check = version_compare( WPRM_VERSION, '8.1.0', '>=' )
29
+                && version_compare( WPRM_VERSION, '8.6.0', '<' );
30
+
31
+        if ( ! $check ) {
32
+            $this->notices->queue(
33
+                'warning',
34
+                /* translators: 1: minimum supported WPRM version, 2: maximum supported WPRM version, 3: Detected WP Recipe Maker version. */
35
+                sprintf( __( 'WordLift Food KG support requires WP Recipe Maker %1$s-%2$s, %3$s found.', 'wordlift' ), '8.1.0', '8.5.0', WPRM_VERSION )
36
+            );
37
+        }
38
+
39
+        return $check;
40
+    }
41 41
 
42 42
 }
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
 	 */
10 10
 	private $notices;
11 11
 
12
-	public function __construct( Notices $notices ) {
12
+	public function __construct(Notices $notices) {
13 13
 		$this->notices = $notices;
14 14
 	}
15 15
 
@@ -18,21 +18,21 @@  discard block
 block discarded – undo
18 18
 	}
19 19
 
20 20
 	private function has_prerequisites() {
21
-		return defined( 'WPRM_VERSION' )
22
-			   && class_exists( 'WP_Recipe_Maker' )
21
+		return defined('WPRM_VERSION')
22
+			   && class_exists('WP_Recipe_Maker')
23 23
 		       // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
24
-			   && apply_filters( 'wl_feature__enable__food-kg', false );
24
+			   && apply_filters('wl_feature__enable__food-kg', false);
25 25
 	}
26 26
 
27 27
 	private function check_version() {
28
-		$check = version_compare( WPRM_VERSION, '8.1.0', '>=' )
29
-				&& version_compare( WPRM_VERSION, '8.6.0', '<' );
28
+		$check = version_compare(WPRM_VERSION, '8.1.0', '>=')
29
+				&& version_compare(WPRM_VERSION, '8.6.0', '<');
30 30
 
31
-		if ( ! $check ) {
31
+		if ( ! $check) {
32 32
 			$this->notices->queue(
33 33
 				'warning',
34 34
 				/* translators: 1: minimum supported WPRM version, 2: maximum supported WPRM version, 3: Detected WP Recipe Maker version. */
35
-				sprintf( __( 'WordLift Food KG support requires WP Recipe Maker %1$s-%2$s, %3$s found.', 'wordlift' ), '8.1.0', '8.5.0', WPRM_VERSION )
35
+				sprintf(__('WordLift Food KG support requires WP Recipe Maker %1$s-%2$s, %3$s found.', 'wordlift'), '8.1.0', '8.5.0', WPRM_VERSION)
36 36
 			);
37 37
 		}
38 38
 
Please login to merge, or discard this patch.
src/js/dist/ingredients-meta-box.asset.php 2 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@
 block discarded – undo
1 1
 <?php return array(
2
-	'dependencies' => array( 'wp-polyfill' ),
3
-	'version'      => '600e3325af21a315a54408123fd7d7ad',
2
+    'dependencies' => array( 'wp-polyfill' ),
3
+    'version'      => '600e3325af21a315a54408123fd7d7ad',
4 4
 );
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@
 block discarded – undo
1 1
 <?php return array(
2
-	'dependencies' => array( 'wp-polyfill' ),
2
+	'dependencies' => array('wp-polyfill'),
3 3
 	'version'      => '600e3325af21a315a54408123fd7d7ad',
4 4
 );
Please login to merge, or discard this patch.
src/modules/food-kg/includes/Meta_Box.php 2 patches
Indentation   +191 added lines, -191 removed lines patch added patch discarded remove patch
@@ -11,67 +11,67 @@  discard block
 block discarded – undo
11 11
 
12 12
 class Meta_Box {
13 13
 
14
-	/**
15
-	 * @var Api_Service_Ext
16
-	 */
17
-	private $api_service;
18
-
19
-	/**
20
-	 * @var Recipe_Lift_Strategy
21
-	 */
22
-	private $recipe_lift_strategy;
23
-
24
-	/**
25
-	 * @param Api_Service_Ext      $api_service
26
-	 * @param Recipe_Lift_Strategy $recipe_lift_strategy
27
-	 */
28
-	public function __construct( Api_Service_Ext $api_service, Recipe_Lift_Strategy $recipe_lift_strategy ) {
29
-		$this->api_service          = $api_service;
30
-		$this->recipe_lift_strategy = $recipe_lift_strategy;
31
-	}
32
-
33
-	/**
34
-	 * Register Hooks.
35
-	 *
36
-	 * @return void
37
-	 */
38
-	public function register_hooks() {
39
-		add_action( 'wl_ingredient_metabox_html', array( $this, 'ingredients_html' ) );
40
-		add_action( 'wp_ajax_wl_update_ingredient_post_meta', array( $this, 'update_ingredient_post_meta' ) );
41
-		add_action( 'wp_ajax_wl_ingredient_autocomplete', array( $this, 'wl_ingredient_autocomplete' ) );
42
-	}
43
-
44
-	/**
45
-	 * Ingredients HTML.
46
-	 */
47
-	public function ingredients_html() {
48
-
49
-		// Enqueue scripts.
50
-		$this->enqueue_scripts();
51
-
52
-		$recipe_ids = \WPRM_Recipe_Manager::get_recipe_ids_from_post( get_the_ID() );
53
-		if ( empty( $recipe_ids ) ) {
54
-			return;
55
-		}
56
-		foreach ( $recipe_ids as $key => $recipe_id ) {
57
-			$recipe_json_ld = get_post_meta( $recipe_id, '_wl_main_ingredient_jsonld', true );
58
-			if ( ! $recipe_json_ld ) {
59
-				continue;
60
-			}
61
-			$recipe = json_decode( $recipe_json_ld, true );
62
-			if ( ! isset( $recipe['name'] ) ) {
63
-				continue;
64
-			}
65
-			?>
14
+    /**
15
+     * @var Api_Service_Ext
16
+     */
17
+    private $api_service;
18
+
19
+    /**
20
+     * @var Recipe_Lift_Strategy
21
+     */
22
+    private $recipe_lift_strategy;
23
+
24
+    /**
25
+     * @param Api_Service_Ext      $api_service
26
+     * @param Recipe_Lift_Strategy $recipe_lift_strategy
27
+     */
28
+    public function __construct( Api_Service_Ext $api_service, Recipe_Lift_Strategy $recipe_lift_strategy ) {
29
+        $this->api_service          = $api_service;
30
+        $this->recipe_lift_strategy = $recipe_lift_strategy;
31
+    }
32
+
33
+    /**
34
+     * Register Hooks.
35
+     *
36
+     * @return void
37
+     */
38
+    public function register_hooks() {
39
+        add_action( 'wl_ingredient_metabox_html', array( $this, 'ingredients_html' ) );
40
+        add_action( 'wp_ajax_wl_update_ingredient_post_meta', array( $this, 'update_ingredient_post_meta' ) );
41
+        add_action( 'wp_ajax_wl_ingredient_autocomplete', array( $this, 'wl_ingredient_autocomplete' ) );
42
+    }
43
+
44
+    /**
45
+     * Ingredients HTML.
46
+     */
47
+    public function ingredients_html() {
48
+
49
+        // Enqueue scripts.
50
+        $this->enqueue_scripts();
51
+
52
+        $recipe_ids = \WPRM_Recipe_Manager::get_recipe_ids_from_post( get_the_ID() );
53
+        if ( empty( $recipe_ids ) ) {
54
+            return;
55
+        }
56
+        foreach ( $recipe_ids as $key => $recipe_id ) {
57
+            $recipe_json_ld = get_post_meta( $recipe_id, '_wl_main_ingredient_jsonld', true );
58
+            if ( ! $recipe_json_ld ) {
59
+                continue;
60
+            }
61
+            $recipe = json_decode( $recipe_json_ld, true );
62
+            if ( ! isset( $recipe['name'] ) ) {
63
+                continue;
64
+            }
65
+            ?>
66 66
 			<div class="wl-recipe-ingredient">
67 67
 				<?php
68
-					$allowed_tags = array(
69
-						'p'      => array(),
70
-						'strong' => array(),
71
-					);
72
-					// translators: %s is the ingredient name.
73
-					echo wp_kses( sprintf( '<p>' . __( 'The main ingredient is', 'wordlift' ) . ' <strong>%s</strong></p>', esc_html( $recipe['name'] ) ), $allowed_tags );
74
-					?>
68
+                    $allowed_tags = array(
69
+                        'p'      => array(),
70
+                        'strong' => array(),
71
+                    );
72
+                    // translators: %s is the ingredient name.
73
+                    echo wp_kses( sprintf( '<p>' . __( 'The main ingredient is', 'wordlift' ) . ' <strong>%s</strong></p>', esc_html( $recipe['name'] ) ), $allowed_tags );
74
+                    ?>
75 75
 				<form class="wl-recipe-ingredient-form" id="wl-recipe-ingredient-form-<?php echo esc_attr( $key ); ?>">
76 76
 					<div class="wl-recipe-ingredient__field">
77 77
 						<label for="wl-recipe-ingredient__field-<?php echo esc_attr( $recipe['name'] ) . '-' . esc_attr( $key ); ?>"><?php echo esc_html__( 'Replace the main ingredient', 'wordlift' ); ?>: </label>
@@ -82,136 +82,136 @@  discard block
 block discarded – undo
82 82
 				</form>
83 83
 			</div>
84 84
 			<?php
85
-		}
86
-	}
87
-
88
-	/**
89
-	 * Ingredient Autocomplete.
90
-	 */
91
-	public function wl_ingredient_autocomplete() {
92
-
93
-		check_ajax_referer( 'wl-ac-ingredient-nonce' );
94
-
95
-		// Return error if the query param is empty.
96
-		if ( ! empty( $_REQUEST['query'] ) ) { // Input var okay.
97
-			$query = sanitize_text_field( wp_unslash( $_REQUEST['query'] ) ); // Input var okay.
98
-		} else {
99
-			wp_send_json_error(
100
-				array(
101
-					'message' => __( 'The query param is empty.', 'wordlift' ),
102
-				)
103
-			);
104
-		}
105
-
106
-		// Get new JSON LD Data.
107
-		$new_json_ld = $this->recipe_lift_strategy->get_json_ld_data( $query );
108
-
109
-		$data = json_decode( $new_json_ld );
110
-
111
-		// Clear any buffer.
112
-		ob_clean();
113
-
114
-		if ( $data ) {
115
-			wp_send_json_success( array( $data->name ) );
116
-		} else {
117
-			wp_send_json_error(
118
-				array(
119
-					'message' => __( 'No results found.', 'wordlift' ),
120
-				)
121
-			);
122
-		}
123
-	}
124
-
125
-	/**
126
-	 * Update Ingredient Post Meta.
127
-	 */
128
-	public function update_ingredient_post_meta() {
129
-		check_ajax_referer( 'wl-ingredient-nonce' );
130
-
131
-		// Check if current user can edit posts.
132
-		if ( ! current_user_can( 'edit_posts' ) ) {
133
-			wp_send_json_error(
134
-				array(
135
-					'message' => __( 'You are not allowed to edit posts.', 'wordlift' ),
136
-					'btnText' => __( 'Denied!', 'wordlift' ),
137
-				)
138
-			);
139
-		}
140
-
141
-		// Return error if the recipe id is empty.
142
-		if ( ! empty( $_REQUEST['recipe_id'] ) ) { // Input var okay.
143
-			$recipe_id = sanitize_text_field( wp_unslash( $_REQUEST['recipe_id'] ) ); // Input var okay.
144
-		} else {
145
-			wp_send_json_error(
146
-				array(
147
-					'message' => __( 'The recipe id is empty.', 'wordlift' ),
148
-					'btnText' => __( 'Failed!', 'wordlift' ),
149
-				)
150
-			);
151
-		}
152
-
153
-		// Return error if the main ingredient is empty.
154
-		if ( ! empty( $_REQUEST['main_ingredient'] ) ) {
155
-			$main_ingredient = sanitize_text_field( wp_unslash( $_REQUEST['main_ingredient'] ) );
156
-		} else {
157
-			wp_send_json_error(
158
-				array(
159
-					'message' => __( 'The main ingredient is empty.', 'wordlift' ),
160
-					'btnText' => __( 'Failed!', 'wordlift' ),
161
-				)
162
-			);
163
-		}
164
-
165
-		// Get new JSON LD Data.
166
-		$new_json_ld = $this->recipe_lift_strategy->get_json_ld_data( $main_ingredient );
167
-
168
-		if ( $new_json_ld ) {
169
-			// Update the recipe post meta for JSON-LD.
170
-			$update = update_post_meta( $recipe_id, '_wl_main_ingredient_jsonld', $new_json_ld );
171
-			if ( $update ) {
172
-				wp_send_json_success(
173
-					array(
174
-						'message' => __( 'The main ingredient has been updated.', 'wordlift' ),
175
-						'btnText' => __( 'Saved!', 'wordlift' ),
176
-					)
177
-				);
178
-			} else {
179
-				wp_send_json(
180
-					array(
181
-						'same'    => true,
182
-						'message' => __( 'You didn\'t updated the main ingredient value.', 'wordlift' ),
183
-						'btnText' => __( 'Save', 'wordlift' ),
184
-					)
185
-				);
186
-			}
187
-		} else {
188
-			wp_send_json_error(
189
-				array(
190
-					'message' => __( 'Failed to Update Recipe Ingredient.', 'wordlift' ),
191
-					'btnText' => __( 'Failed!', 'wordlift' ),
192
-				)
193
-			);
194
-		}
195
-	}
196
-
197
-	/**
198
-	 * Enqueue Scripts.
199
-	 */
200
-	public function enqueue_scripts() {
201
-		wp_enqueue_script( 'wl-meta-box-ingredient', WL_DIR_URL . 'js/dist/ingredients-meta-box.js', array( 'jquery', 'jquery-ui-autocomplete' ), WORDLIFT_VERSION, true );
202
-
203
-		wp_localize_script(
204
-			'wl-meta-box-ingredient',
205
-			'_wlRecipeIngredient',
206
-			array(
207
-				'ajaxurl' => admin_url( 'admin-ajax.php' ),
208
-				'nonce'   => wp_create_nonce( 'wl-ingredient-nonce' ),
209
-				'acNonce' => wp_create_nonce( 'wl-ac-ingredient-nonce' ),
210
-				'texts'   => array(
211
-					'saving'    => __( 'Saving...', 'wordlift' ),
212
-					'noResults' => __( 'No results found.', 'wordlift' ),
213
-				),
214
-			)
215
-		);
216
-	}
85
+        }
86
+    }
87
+
88
+    /**
89
+     * Ingredient Autocomplete.
90
+     */
91
+    public function wl_ingredient_autocomplete() {
92
+
93
+        check_ajax_referer( 'wl-ac-ingredient-nonce' );
94
+
95
+        // Return error if the query param is empty.
96
+        if ( ! empty( $_REQUEST['query'] ) ) { // Input var okay.
97
+            $query = sanitize_text_field( wp_unslash( $_REQUEST['query'] ) ); // Input var okay.
98
+        } else {
99
+            wp_send_json_error(
100
+                array(
101
+                    'message' => __( 'The query param is empty.', 'wordlift' ),
102
+                )
103
+            );
104
+        }
105
+
106
+        // Get new JSON LD Data.
107
+        $new_json_ld = $this->recipe_lift_strategy->get_json_ld_data( $query );
108
+
109
+        $data = json_decode( $new_json_ld );
110
+
111
+        // Clear any buffer.
112
+        ob_clean();
113
+
114
+        if ( $data ) {
115
+            wp_send_json_success( array( $data->name ) );
116
+        } else {
117
+            wp_send_json_error(
118
+                array(
119
+                    'message' => __( 'No results found.', 'wordlift' ),
120
+                )
121
+            );
122
+        }
123
+    }
124
+
125
+    /**
126
+     * Update Ingredient Post Meta.
127
+     */
128
+    public function update_ingredient_post_meta() {
129
+        check_ajax_referer( 'wl-ingredient-nonce' );
130
+
131
+        // Check if current user can edit posts.
132
+        if ( ! current_user_can( 'edit_posts' ) ) {
133
+            wp_send_json_error(
134
+                array(
135
+                    'message' => __( 'You are not allowed to edit posts.', 'wordlift' ),
136
+                    'btnText' => __( 'Denied!', 'wordlift' ),
137
+                )
138
+            );
139
+        }
140
+
141
+        // Return error if the recipe id is empty.
142
+        if ( ! empty( $_REQUEST['recipe_id'] ) ) { // Input var okay.
143
+            $recipe_id = sanitize_text_field( wp_unslash( $_REQUEST['recipe_id'] ) ); // Input var okay.
144
+        } else {
145
+            wp_send_json_error(
146
+                array(
147
+                    'message' => __( 'The recipe id is empty.', 'wordlift' ),
148
+                    'btnText' => __( 'Failed!', 'wordlift' ),
149
+                )
150
+            );
151
+        }
152
+
153
+        // Return error if the main ingredient is empty.
154
+        if ( ! empty( $_REQUEST['main_ingredient'] ) ) {
155
+            $main_ingredient = sanitize_text_field( wp_unslash( $_REQUEST['main_ingredient'] ) );
156
+        } else {
157
+            wp_send_json_error(
158
+                array(
159
+                    'message' => __( 'The main ingredient is empty.', 'wordlift' ),
160
+                    'btnText' => __( 'Failed!', 'wordlift' ),
161
+                )
162
+            );
163
+        }
164
+
165
+        // Get new JSON LD Data.
166
+        $new_json_ld = $this->recipe_lift_strategy->get_json_ld_data( $main_ingredient );
167
+
168
+        if ( $new_json_ld ) {
169
+            // Update the recipe post meta for JSON-LD.
170
+            $update = update_post_meta( $recipe_id, '_wl_main_ingredient_jsonld', $new_json_ld );
171
+            if ( $update ) {
172
+                wp_send_json_success(
173
+                    array(
174
+                        'message' => __( 'The main ingredient has been updated.', 'wordlift' ),
175
+                        'btnText' => __( 'Saved!', 'wordlift' ),
176
+                    )
177
+                );
178
+            } else {
179
+                wp_send_json(
180
+                    array(
181
+                        'same'    => true,
182
+                        'message' => __( 'You didn\'t updated the main ingredient value.', 'wordlift' ),
183
+                        'btnText' => __( 'Save', 'wordlift' ),
184
+                    )
185
+                );
186
+            }
187
+        } else {
188
+            wp_send_json_error(
189
+                array(
190
+                    'message' => __( 'Failed to Update Recipe Ingredient.', 'wordlift' ),
191
+                    'btnText' => __( 'Failed!', 'wordlift' ),
192
+                )
193
+            );
194
+        }
195
+    }
196
+
197
+    /**
198
+     * Enqueue Scripts.
199
+     */
200
+    public function enqueue_scripts() {
201
+        wp_enqueue_script( 'wl-meta-box-ingredient', WL_DIR_URL . 'js/dist/ingredients-meta-box.js', array( 'jquery', 'jquery-ui-autocomplete' ), WORDLIFT_VERSION, true );
202
+
203
+        wp_localize_script(
204
+            'wl-meta-box-ingredient',
205
+            '_wlRecipeIngredient',
206
+            array(
207
+                'ajaxurl' => admin_url( 'admin-ajax.php' ),
208
+                'nonce'   => wp_create_nonce( 'wl-ingredient-nonce' ),
209
+                'acNonce' => wp_create_nonce( 'wl-ac-ingredient-nonce' ),
210
+                'texts'   => array(
211
+                    'saving'    => __( 'Saving...', 'wordlift' ),
212
+                    'noResults' => __( 'No results found.', 'wordlift' ),
213
+                ),
214
+            )
215
+        );
216
+    }
217 217
 }
Please login to merge, or discard this patch.
Spacing   +54 added lines, -54 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
 	 * @param Api_Service_Ext      $api_service
26 26
 	 * @param Recipe_Lift_Strategy $recipe_lift_strategy
27 27
 	 */
28
-	public function __construct( Api_Service_Ext $api_service, Recipe_Lift_Strategy $recipe_lift_strategy ) {
28
+	public function __construct(Api_Service_Ext $api_service, Recipe_Lift_Strategy $recipe_lift_strategy) {
29 29
 		$this->api_service          = $api_service;
30 30
 		$this->recipe_lift_strategy = $recipe_lift_strategy;
31 31
 	}
@@ -36,9 +36,9 @@  discard block
 block discarded – undo
36 36
 	 * @return void
37 37
 	 */
38 38
 	public function register_hooks() {
39
-		add_action( 'wl_ingredient_metabox_html', array( $this, 'ingredients_html' ) );
40
-		add_action( 'wp_ajax_wl_update_ingredient_post_meta', array( $this, 'update_ingredient_post_meta' ) );
41
-		add_action( 'wp_ajax_wl_ingredient_autocomplete', array( $this, 'wl_ingredient_autocomplete' ) );
39
+		add_action('wl_ingredient_metabox_html', array($this, 'ingredients_html'));
40
+		add_action('wp_ajax_wl_update_ingredient_post_meta', array($this, 'update_ingredient_post_meta'));
41
+		add_action('wp_ajax_wl_ingredient_autocomplete', array($this, 'wl_ingredient_autocomplete'));
42 42
 	}
43 43
 
44 44
 	/**
@@ -49,17 +49,17 @@  discard block
 block discarded – undo
49 49
 		// Enqueue scripts.
50 50
 		$this->enqueue_scripts();
51 51
 
52
-		$recipe_ids = \WPRM_Recipe_Manager::get_recipe_ids_from_post( get_the_ID() );
53
-		if ( empty( $recipe_ids ) ) {
52
+		$recipe_ids = \WPRM_Recipe_Manager::get_recipe_ids_from_post(get_the_ID());
53
+		if (empty($recipe_ids)) {
54 54
 			return;
55 55
 		}
56
-		foreach ( $recipe_ids as $key => $recipe_id ) {
57
-			$recipe_json_ld = get_post_meta( $recipe_id, '_wl_main_ingredient_jsonld', true );
58
-			if ( ! $recipe_json_ld ) {
56
+		foreach ($recipe_ids as $key => $recipe_id) {
57
+			$recipe_json_ld = get_post_meta($recipe_id, '_wl_main_ingredient_jsonld', true);
58
+			if ( ! $recipe_json_ld) {
59 59
 				continue;
60 60
 			}
61
-			$recipe = json_decode( $recipe_json_ld, true );
62
-			if ( ! isset( $recipe['name'] ) ) {
61
+			$recipe = json_decode($recipe_json_ld, true);
62
+			if ( ! isset($recipe['name'])) {
63 63
 				continue;
64 64
 			}
65 65
 			?>
@@ -70,15 +70,15 @@  discard block
 block discarded – undo
70 70
 						'strong' => array(),
71 71
 					);
72 72
 					// translators: %s is the ingredient name.
73
-					echo wp_kses( sprintf( '<p>' . __( 'The main ingredient is', 'wordlift' ) . ' <strong>%s</strong></p>', esc_html( $recipe['name'] ) ), $allowed_tags );
73
+					echo wp_kses(sprintf('<p>'.__('The main ingredient is', 'wordlift').' <strong>%s</strong></p>', esc_html($recipe['name'])), $allowed_tags);
74 74
 					?>
75
-				<form class="wl-recipe-ingredient-form" id="wl-recipe-ingredient-form-<?php echo esc_attr( $key ); ?>">
75
+				<form class="wl-recipe-ingredient-form" id="wl-recipe-ingredient-form-<?php echo esc_attr($key); ?>">
76 76
 					<div class="wl-recipe-ingredient__field">
77
-						<label for="wl-recipe-ingredient__field-<?php echo esc_attr( $recipe['name'] ) . '-' . esc_attr( $key ); ?>"><?php echo esc_html__( 'Replace the main ingredient', 'wordlift' ); ?>: </label>
78
-						<input type="text" class="main-ingredient" id="wl-recipe-ingredient__field-<?php echo esc_attr( $recipe['name'] ) . '-' . esc_attr( $key ); ?>" name="main_ingredient" placeholder="<?php echo esc_html__( 'Type at least 3 characters to search...', 'wordlift' ); ?>">
77
+						<label for="wl-recipe-ingredient__field-<?php echo esc_attr($recipe['name']).'-'.esc_attr($key); ?>"><?php echo esc_html__('Replace the main ingredient', 'wordlift'); ?>: </label>
78
+						<input type="text" class="main-ingredient" id="wl-recipe-ingredient__field-<?php echo esc_attr($recipe['name']).'-'.esc_attr($key); ?>" name="main_ingredient" placeholder="<?php echo esc_html__('Type at least 3 characters to search...', 'wordlift'); ?>">
79 79
 					</div>
80
-					<input type="hidden" id="recipe_id" name="recipe_id" value="<?php echo esc_attr( $recipe_id ); ?>">
81
-					<button type="submit" class="wl-recipe-ingredient__save"><?php echo esc_html__( 'Save', 'wordlift' ); ?></button>
80
+					<input type="hidden" id="recipe_id" name="recipe_id" value="<?php echo esc_attr($recipe_id); ?>">
81
+					<button type="submit" class="wl-recipe-ingredient__save"><?php echo esc_html__('Save', 'wordlift'); ?></button>
82 82
 				</form>
83 83
 			</div>
84 84
 			<?php
@@ -90,33 +90,33 @@  discard block
 block discarded – undo
90 90
 	 */
91 91
 	public function wl_ingredient_autocomplete() {
92 92
 
93
-		check_ajax_referer( 'wl-ac-ingredient-nonce' );
93
+		check_ajax_referer('wl-ac-ingredient-nonce');
94 94
 
95 95
 		// Return error if the query param is empty.
96
-		if ( ! empty( $_REQUEST['query'] ) ) { // Input var okay.
97
-			$query = sanitize_text_field( wp_unslash( $_REQUEST['query'] ) ); // Input var okay.
96
+		if ( ! empty($_REQUEST['query'])) { // Input var okay.
97
+			$query = sanitize_text_field(wp_unslash($_REQUEST['query'])); // Input var okay.
98 98
 		} else {
99 99
 			wp_send_json_error(
100 100
 				array(
101
-					'message' => __( 'The query param is empty.', 'wordlift' ),
101
+					'message' => __('The query param is empty.', 'wordlift'),
102 102
 				)
103 103
 			);
104 104
 		}
105 105
 
106 106
 		// Get new JSON LD Data.
107
-		$new_json_ld = $this->recipe_lift_strategy->get_json_ld_data( $query );
107
+		$new_json_ld = $this->recipe_lift_strategy->get_json_ld_data($query);
108 108
 
109
-		$data = json_decode( $new_json_ld );
109
+		$data = json_decode($new_json_ld);
110 110
 
111 111
 		// Clear any buffer.
112 112
 		ob_clean();
113 113
 
114
-		if ( $data ) {
115
-			wp_send_json_success( array( $data->name ) );
114
+		if ($data) {
115
+			wp_send_json_success(array($data->name));
116 116
 		} else {
117 117
 			wp_send_json_error(
118 118
 				array(
119
-					'message' => __( 'No results found.', 'wordlift' ),
119
+					'message' => __('No results found.', 'wordlift'),
120 120
 				)
121 121
 			);
122 122
 		}
@@ -126,69 +126,69 @@  discard block
 block discarded – undo
126 126
 	 * Update Ingredient Post Meta.
127 127
 	 */
128 128
 	public function update_ingredient_post_meta() {
129
-		check_ajax_referer( 'wl-ingredient-nonce' );
129
+		check_ajax_referer('wl-ingredient-nonce');
130 130
 
131 131
 		// Check if current user can edit posts.
132
-		if ( ! current_user_can( 'edit_posts' ) ) {
132
+		if ( ! current_user_can('edit_posts')) {
133 133
 			wp_send_json_error(
134 134
 				array(
135
-					'message' => __( 'You are not allowed to edit posts.', 'wordlift' ),
136
-					'btnText' => __( 'Denied!', 'wordlift' ),
135
+					'message' => __('You are not allowed to edit posts.', 'wordlift'),
136
+					'btnText' => __('Denied!', 'wordlift'),
137 137
 				)
138 138
 			);
139 139
 		}
140 140
 
141 141
 		// Return error if the recipe id is empty.
142
-		if ( ! empty( $_REQUEST['recipe_id'] ) ) { // Input var okay.
143
-			$recipe_id = sanitize_text_field( wp_unslash( $_REQUEST['recipe_id'] ) ); // Input var okay.
142
+		if ( ! empty($_REQUEST['recipe_id'])) { // Input var okay.
143
+			$recipe_id = sanitize_text_field(wp_unslash($_REQUEST['recipe_id'])); // Input var okay.
144 144
 		} else {
145 145
 			wp_send_json_error(
146 146
 				array(
147
-					'message' => __( 'The recipe id is empty.', 'wordlift' ),
148
-					'btnText' => __( 'Failed!', 'wordlift' ),
147
+					'message' => __('The recipe id is empty.', 'wordlift'),
148
+					'btnText' => __('Failed!', 'wordlift'),
149 149
 				)
150 150
 			);
151 151
 		}
152 152
 
153 153
 		// Return error if the main ingredient is empty.
154
-		if ( ! empty( $_REQUEST['main_ingredient'] ) ) {
155
-			$main_ingredient = sanitize_text_field( wp_unslash( $_REQUEST['main_ingredient'] ) );
154
+		if ( ! empty($_REQUEST['main_ingredient'])) {
155
+			$main_ingredient = sanitize_text_field(wp_unslash($_REQUEST['main_ingredient']));
156 156
 		} else {
157 157
 			wp_send_json_error(
158 158
 				array(
159
-					'message' => __( 'The main ingredient is empty.', 'wordlift' ),
160
-					'btnText' => __( 'Failed!', 'wordlift' ),
159
+					'message' => __('The main ingredient is empty.', 'wordlift'),
160
+					'btnText' => __('Failed!', 'wordlift'),
161 161
 				)
162 162
 			);
163 163
 		}
164 164
 
165 165
 		// Get new JSON LD Data.
166
-		$new_json_ld = $this->recipe_lift_strategy->get_json_ld_data( $main_ingredient );
166
+		$new_json_ld = $this->recipe_lift_strategy->get_json_ld_data($main_ingredient);
167 167
 
168
-		if ( $new_json_ld ) {
168
+		if ($new_json_ld) {
169 169
 			// Update the recipe post meta for JSON-LD.
170
-			$update = update_post_meta( $recipe_id, '_wl_main_ingredient_jsonld', $new_json_ld );
171
-			if ( $update ) {
170
+			$update = update_post_meta($recipe_id, '_wl_main_ingredient_jsonld', $new_json_ld);
171
+			if ($update) {
172 172
 				wp_send_json_success(
173 173
 					array(
174
-						'message' => __( 'The main ingredient has been updated.', 'wordlift' ),
175
-						'btnText' => __( 'Saved!', 'wordlift' ),
174
+						'message' => __('The main ingredient has been updated.', 'wordlift'),
175
+						'btnText' => __('Saved!', 'wordlift'),
176 176
 					)
177 177
 				);
178 178
 			} else {
179 179
 				wp_send_json(
180 180
 					array(
181 181
 						'same'    => true,
182
-						'message' => __( 'You didn\'t updated the main ingredient value.', 'wordlift' ),
183
-						'btnText' => __( 'Save', 'wordlift' ),
182
+						'message' => __('You didn\'t updated the main ingredient value.', 'wordlift'),
183
+						'btnText' => __('Save', 'wordlift'),
184 184
 					)
185 185
 				);
186 186
 			}
187 187
 		} else {
188 188
 			wp_send_json_error(
189 189
 				array(
190
-					'message' => __( 'Failed to Update Recipe Ingredient.', 'wordlift' ),
191
-					'btnText' => __( 'Failed!', 'wordlift' ),
190
+					'message' => __('Failed to Update Recipe Ingredient.', 'wordlift'),
191
+					'btnText' => __('Failed!', 'wordlift'),
192 192
 				)
193 193
 			);
194 194
 		}
@@ -198,18 +198,18 @@  discard block
 block discarded – undo
198 198
 	 * Enqueue Scripts.
199 199
 	 */
200 200
 	public function enqueue_scripts() {
201
-		wp_enqueue_script( 'wl-meta-box-ingredient', WL_DIR_URL . 'js/dist/ingredients-meta-box.js', array( 'jquery', 'jquery-ui-autocomplete' ), WORDLIFT_VERSION, true );
201
+		wp_enqueue_script('wl-meta-box-ingredient', WL_DIR_URL.'js/dist/ingredients-meta-box.js', array('jquery', 'jquery-ui-autocomplete'), WORDLIFT_VERSION, true);
202 202
 
203 203
 		wp_localize_script(
204 204
 			'wl-meta-box-ingredient',
205 205
 			'_wlRecipeIngredient',
206 206
 			array(
207
-				'ajaxurl' => admin_url( 'admin-ajax.php' ),
208
-				'nonce'   => wp_create_nonce( 'wl-ingredient-nonce' ),
209
-				'acNonce' => wp_create_nonce( 'wl-ac-ingredient-nonce' ),
207
+				'ajaxurl' => admin_url('admin-ajax.php'),
208
+				'nonce'   => wp_create_nonce('wl-ingredient-nonce'),
209
+				'acNonce' => wp_create_nonce('wl-ac-ingredient-nonce'),
210 210
 				'texts'   => array(
211
-					'saving'    => __( 'Saving...', 'wordlift' ),
212
-					'noResults' => __( 'No results found.', 'wordlift' ),
211
+					'saving'    => __('Saving...', 'wordlift'),
212
+					'noResults' => __('No results found.', 'wordlift'),
213 213
 				),
214 214
 			)
215 215
 		);
Please login to merge, or discard this patch.