Completed
Push — develop ( b6474c...82e5c6 )
by David
01:14
created
src/modules/food-kg/includes/admin/Main_Ingredient_Modal_Page_Delegate.php 2 patches
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -3,25 +3,25 @@
 block discarded – undo
3 3
 namespace Wordlift\Modules\Food_Kg\Admin;
4 4
 
5 5
 class Main_Ingredient_Modal_Page_Delegate implements Page_Delegate {
6
-	function render() {
7
-		$post_id = filter_input( INPUT_GET, 'id', FILTER_SANITIZE_NUMBER_INT );
8
-		$value   = get_post_meta( $post_id, '_wl_main_ingredient_jsonld', true );
6
+    function render() {
7
+        $post_id = filter_input( INPUT_GET, 'id', FILTER_SANITIZE_NUMBER_INT );
8
+        $value   = get_post_meta( $post_id, '_wl_main_ingredient_jsonld', true );
9 9
 
10
-		include WL_FOOD_KG_DIR_PATH . '/includes/admin/partials/jsonld.php';
11
-	}
10
+        include WL_FOOD_KG_DIR_PATH . '/includes/admin/partials/jsonld.php';
11
+    }
12 12
 
13
-	function admin_enqueue_scripts() {
14
-		wp_enqueue_style( 'wl-food-kg-jsonld', plugin_dir_url( __FILE__ ) . '/partials/jsonld.css' );
13
+    function admin_enqueue_scripts() {
14
+        wp_enqueue_style( 'wl-food-kg-jsonld', plugin_dir_url( __FILE__ ) . '/partials/jsonld.css' );
15 15
 
16
-		// Enqueue code editor and settings for manipulating HTML.
17
-		$settings = wp_enqueue_code_editor( array( 'type' => 'application/ld+json', 'minHeight' => '100%' ) );
16
+        // Enqueue code editor and settings for manipulating HTML.
17
+        $settings = wp_enqueue_code_editor( array( 'type' => 'application/ld+json', 'minHeight' => '100%' ) );
18 18
 
19
-		wp_add_inline_script(
20
-			'code-editor',
21
-			sprintf(
22
-				'jQuery( function() { wp.codeEditor.initialize( "jsonld", %s ); } );',
23
-				wp_json_encode( $settings )
24
-			)
25
-		);
26
-	}
19
+        wp_add_inline_script(
20
+            'code-editor',
21
+            sprintf(
22
+                'jQuery( function() { wp.codeEditor.initialize( "jsonld", %s ); } );',
23
+                wp_json_encode( $settings )
24
+            )
25
+        );
26
+    }
27 27
 }
28 28
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -4,23 +4,23 @@
 block discarded – undo
4 4
 
5 5
 class Main_Ingredient_Modal_Page_Delegate implements Page_Delegate {
6 6
 	function render() {
7
-		$post_id = filter_input( INPUT_GET, 'id', FILTER_SANITIZE_NUMBER_INT );
8
-		$value   = get_post_meta( $post_id, '_wl_main_ingredient_jsonld', true );
7
+		$post_id = filter_input(INPUT_GET, 'id', FILTER_SANITIZE_NUMBER_INT);
8
+		$value   = get_post_meta($post_id, '_wl_main_ingredient_jsonld', true);
9 9
 
10
-		include WL_FOOD_KG_DIR_PATH . '/includes/admin/partials/jsonld.php';
10
+		include WL_FOOD_KG_DIR_PATH.'/includes/admin/partials/jsonld.php';
11 11
 	}
12 12
 
13 13
 	function admin_enqueue_scripts() {
14
-		wp_enqueue_style( 'wl-food-kg-jsonld', plugin_dir_url( __FILE__ ) . '/partials/jsonld.css' );
14
+		wp_enqueue_style('wl-food-kg-jsonld', plugin_dir_url(__FILE__).'/partials/jsonld.css');
15 15
 
16 16
 		// Enqueue code editor and settings for manipulating HTML.
17
-		$settings = wp_enqueue_code_editor( array( 'type' => 'application/ld+json', 'minHeight' => '100%' ) );
17
+		$settings = wp_enqueue_code_editor(array('type' => 'application/ld+json', 'minHeight' => '100%'));
18 18
 
19 19
 		wp_add_inline_script(
20 20
 			'code-editor',
21 21
 			sprintf(
22 22
 				'jQuery( function() { wp.codeEditor.initialize( "jsonld", %s ); } );',
23
-				wp_json_encode( $settings )
23
+				wp_json_encode($settings)
24 24
 			)
25 25
 		);
26 26
 	}
Please login to merge, or discard this patch.
src/modules/food-kg/includes/admin/Full_Page_Delegate.php 2 patches
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -4,13 +4,13 @@
 block discarded – undo
4 4
 
5 5
 class Full_Page_Delegate implements Page_Delegate {
6 6
 
7
-	function render() {
8
-		include WL_FOOD_KG_DIR_PATH . '/includes/admin/partials/main_ingredient.php';
9
-	}
7
+    function render() {
8
+        include WL_FOOD_KG_DIR_PATH . '/includes/admin/partials/main_ingredient.php';
9
+    }
10 10
 
11
-	function admin_enqueue_scripts() {
12
-		wp_enqueue_style( 'thickbox' );
13
-		wp_enqueue_script( 'plugin-install' );
14
-	}
11
+    function admin_enqueue_scripts() {
12
+        wp_enqueue_style( 'thickbox' );
13
+        wp_enqueue_script( 'plugin-install' );
14
+    }
15 15
 
16 16
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -5,12 +5,12 @@
 block discarded – undo
5 5
 class Full_Page_Delegate implements Page_Delegate {
6 6
 
7 7
 	function render() {
8
-		include WL_FOOD_KG_DIR_PATH . '/includes/admin/partials/main_ingredient.php';
8
+		include WL_FOOD_KG_DIR_PATH.'/includes/admin/partials/main_ingredient.php';
9 9
 	}
10 10
 
11 11
 	function admin_enqueue_scripts() {
12
-		wp_enqueue_style( 'thickbox' );
13
-		wp_enqueue_script( 'plugin-install' );
12
+		wp_enqueue_style('thickbox');
13
+		wp_enqueue_script('plugin-install');
14 14
 	}
15 15
 
16 16
 }
Please login to merge, or discard this patch.
src/modules/food-kg/includes/Preconditions.php 2 patches
Indentation   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -4,35 +4,35 @@
 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
-		       && apply_filters( 'wl_feature__enable__food-kg', false );
24
-	}
25
-
26
-	private function check_version() {
27
-		$check = version_compare( WPRM_VERSION, '8.1.0', '>=' )
28
-		         && version_compare( WPRM_VERSION, '8.4.0', '<' );
29
-
30
-		if ( ! $check ) {
31
-			$this->notices->queue( 'warning',
32
-				sprintf( __( 'WordLift Food KG support requires WP Recipe Maker 8.1-8.3, %s found.', 'wordlift' ), WPRM_VERSION ) );
33
-		}
34
-
35
-		return $check;
36
-	}
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
+               && apply_filters( 'wl_feature__enable__food-kg', false );
24
+    }
25
+
26
+    private function check_version() {
27
+        $check = version_compare( WPRM_VERSION, '8.1.0', '>=' )
28
+                 && version_compare( WPRM_VERSION, '8.4.0', '<' );
29
+
30
+        if ( ! $check ) {
31
+            $this->notices->queue( 'warning',
32
+                sprintf( __( 'WordLift Food KG support requires WP Recipe Maker 8.1-8.3, %s found.', 'wordlift' ), WPRM_VERSION ) );
33
+        }
34
+
35
+        return $check;
36
+    }
37 37
 
38 38
 }
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 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,18 +18,18 @@  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' )
23
-		       && apply_filters( 'wl_feature__enable__food-kg', false );
21
+		return defined('WPRM_VERSION')
22
+		       && class_exists('WP_Recipe_Maker')
23
+		       && apply_filters('wl_feature__enable__food-kg', false);
24 24
 	}
25 25
 
26 26
 	private function check_version() {
27
-		$check = version_compare( WPRM_VERSION, '8.1.0', '>=' )
28
-		         && version_compare( WPRM_VERSION, '8.4.0', '<' );
27
+		$check = version_compare(WPRM_VERSION, '8.1.0', '>=')
28
+		         && version_compare(WPRM_VERSION, '8.4.0', '<');
29 29
 
30
-		if ( ! $check ) {
31
-			$this->notices->queue( 'warning',
32
-				sprintf( __( 'WordLift Food KG support requires WP Recipe Maker 8.1-8.3, %s found.', 'wordlift' ), WPRM_VERSION ) );
30
+		if ( ! $check) {
31
+			$this->notices->queue('warning',
32
+				sprintf(__('WordLift Food KG support requires WP Recipe Maker 8.1-8.3, %s found.', 'wordlift'), WPRM_VERSION));
33 33
 		}
34 34
 
35 35
 		return $check;
Please login to merge, or discard this patch.
src/modules/food-kg/includes/Recipe_Lift_Strategy.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -4,6 +4,6 @@
 block discarded – undo
4 4
 
5 5
 interface Recipe_Lift_Strategy {
6 6
 
7
-	function run();
7
+    function run();
8 8
 
9 9
 }
10 10
\ No newline at end of file
Please login to merge, or discard this patch.
src/modules/food-kg/includes/Main_Ingredient_Jsonld.php 2 patches
Indentation   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -6,30 +6,30 @@
 block discarded – undo
6 6
 
7 7
 class Main_Ingredient_Jsonld {
8 8
 
9
-	public function register_hooks() {
10
-		add_action( 'wprm_recipe_metadata', [ $this, '__recipe_metadata' ], 10, 2 );
11
-	}
12
-
13
-	/**
14
-	 * @param array $metadata
15
-	 * @param WPRM_Recipe $recipe
16
-	 *
17
-	 * @return array
18
-	 */
19
-	public function __recipe_metadata( $metadata, $recipe ) {
20
-
21
-		$jsonld = get_post_meta( $recipe->id(), '_wl_main_ingredient_jsonld', true );
22
-
23
-		if ( empty( $jsonld ) ) {
24
-			return $metadata;
25
-		}
26
-
27
-		// We're embedding the full json-ld here because WL doesn't output its own markup, so it makes no sense
28
-		// to hook to wl_after_json_ld.
29
-		$metadata['about'] = isset( $metadata['about'] ) ? $metadata['about'] : [];
30
-		$metadata['about'] = array_merge( $metadata['about'], [ json_decode( $jsonld, true ) ] );
31
-
32
-		return $metadata;
33
-	}
9
+    public function register_hooks() {
10
+        add_action( 'wprm_recipe_metadata', [ $this, '__recipe_metadata' ], 10, 2 );
11
+    }
12
+
13
+    /**
14
+     * @param array $metadata
15
+     * @param WPRM_Recipe $recipe
16
+     *
17
+     * @return array
18
+     */
19
+    public function __recipe_metadata( $metadata, $recipe ) {
20
+
21
+        $jsonld = get_post_meta( $recipe->id(), '_wl_main_ingredient_jsonld', true );
22
+
23
+        if ( empty( $jsonld ) ) {
24
+            return $metadata;
25
+        }
26
+
27
+        // We're embedding the full json-ld here because WL doesn't output its own markup, so it makes no sense
28
+        // to hook to wl_after_json_ld.
29
+        $metadata['about'] = isset( $metadata['about'] ) ? $metadata['about'] : [];
30
+        $metadata['about'] = array_merge( $metadata['about'], [ json_decode( $jsonld, true ) ] );
31
+
32
+        return $metadata;
33
+    }
34 34
 
35 35
 }
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
 class Main_Ingredient_Jsonld {
8 8
 
9 9
 	public function register_hooks() {
10
-		add_action( 'wprm_recipe_metadata', [ $this, '__recipe_metadata' ], 10, 2 );
10
+		add_action('wprm_recipe_metadata', [$this, '__recipe_metadata'], 10, 2);
11 11
 	}
12 12
 
13 13
 	/**
@@ -16,18 +16,18 @@  discard block
 block discarded – undo
16 16
 	 *
17 17
 	 * @return array
18 18
 	 */
19
-	public function __recipe_metadata( $metadata, $recipe ) {
19
+	public function __recipe_metadata($metadata, $recipe) {
20 20
 
21
-		$jsonld = get_post_meta( $recipe->id(), '_wl_main_ingredient_jsonld', true );
21
+		$jsonld = get_post_meta($recipe->id(), '_wl_main_ingredient_jsonld', true);
22 22
 
23
-		if ( empty( $jsonld ) ) {
23
+		if (empty($jsonld)) {
24 24
 			return $metadata;
25 25
 		}
26 26
 
27 27
 		// We're embedding the full json-ld here because WL doesn't output its own markup, so it makes no sense
28 28
 		// to hook to wl_after_json_ld.
29
-		$metadata['about'] = isset( $metadata['about'] ) ? $metadata['about'] : [];
30
-		$metadata['about'] = array_merge( $metadata['about'], [ json_decode( $jsonld, true ) ] );
29
+		$metadata['about'] = isset($metadata['about']) ? $metadata['about'] : [];
30
+		$metadata['about'] = array_merge($metadata['about'], [json_decode($jsonld, true)]);
31 31
 
32 32
 		return $metadata;
33 33
 	}
Please login to merge, or discard this patch.
src/modules/food-kg/includes/Ingredients_Client.php 2 patches
Indentation   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -6,43 +6,43 @@
 block discarded – undo
6 6
 
7 7
 class Ingredients_Client {
8 8
 
9
-	/**
10
-	 * @var Api_Service
11
-	 */
12
-	private $api_service;
13
-
14
-	public function __construct( Api_Service $api_service ) {
15
-		$this->api_service = $api_service;
16
-	}
17
-
18
-	/**
19
-	 * @param string[] $names
20
-	 *
21
-	 * @return Ingredients
22
-	 */
23
-	public function ingredients( $names ) {
24
-
25
-		$request_body = implode( "\n", $names );
26
-		$response     = $this->api_service->request( 'POST', '/thirdparty/cafemedia/food-kg/ingredients', [ 'content-type' => 'text/plain' ], $request_body );
27
-
28
-		return Ingredients::create_from_string( $response->get_body() );
29
-	}
30
-
31
-	/**
32
-	 * Get the JSON-LD as string for the main ingredient or an empty string if not found.
33
-	 *
34
-	 * @param string $input
35
-	 *
36
-	 * @return string
37
-	 */
38
-	public function main_ingredient( $input ) {
39
-
40
-		$response = $this->api_service->request( 'POST', '/thirdparty/cafemedia/food-kg/ingredients/main', [
41
-			'accept'       => 'application/ld+json',
42
-			'content-type' => 'text/plain'
43
-		], $input );
44
-
45
-		return $response->get_body();
46
-	}
9
+    /**
10
+     * @var Api_Service
11
+     */
12
+    private $api_service;
13
+
14
+    public function __construct( Api_Service $api_service ) {
15
+        $this->api_service = $api_service;
16
+    }
17
+
18
+    /**
19
+     * @param string[] $names
20
+     *
21
+     * @return Ingredients
22
+     */
23
+    public function ingredients( $names ) {
24
+
25
+        $request_body = implode( "\n", $names );
26
+        $response     = $this->api_service->request( 'POST', '/thirdparty/cafemedia/food-kg/ingredients', [ 'content-type' => 'text/plain' ], $request_body );
27
+
28
+        return Ingredients::create_from_string( $response->get_body() );
29
+    }
30
+
31
+    /**
32
+     * Get the JSON-LD as string for the main ingredient or an empty string if not found.
33
+     *
34
+     * @param string $input
35
+     *
36
+     * @return string
37
+     */
38
+    public function main_ingredient( $input ) {
39
+
40
+        $response = $this->api_service->request( 'POST', '/thirdparty/cafemedia/food-kg/ingredients/main', [
41
+            'accept'       => 'application/ld+json',
42
+            'content-type' => 'text/plain'
43
+        ], $input );
44
+
45
+        return $response->get_body();
46
+    }
47 47
 
48 48
 }
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 	 */
12 12
 	private $api_service;
13 13
 
14
-	public function __construct( Api_Service $api_service ) {
14
+	public function __construct(Api_Service $api_service) {
15 15
 		$this->api_service = $api_service;
16 16
 	}
17 17
 
@@ -20,12 +20,12 @@  discard block
 block discarded – undo
20 20
 	 *
21 21
 	 * @return Ingredients
22 22
 	 */
23
-	public function ingredients( $names ) {
23
+	public function ingredients($names) {
24 24
 
25
-		$request_body = implode( "\n", $names );
26
-		$response     = $this->api_service->request( 'POST', '/thirdparty/cafemedia/food-kg/ingredients', [ 'content-type' => 'text/plain' ], $request_body );
25
+		$request_body = implode("\n", $names);
26
+		$response     = $this->api_service->request('POST', '/thirdparty/cafemedia/food-kg/ingredients', ['content-type' => 'text/plain'], $request_body);
27 27
 
28
-		return Ingredients::create_from_string( $response->get_body() );
28
+		return Ingredients::create_from_string($response->get_body());
29 29
 	}
30 30
 
31 31
 	/**
@@ -35,12 +35,12 @@  discard block
 block discarded – undo
35 35
 	 *
36 36
 	 * @return string
37 37
 	 */
38
-	public function main_ingredient( $input ) {
38
+	public function main_ingredient($input) {
39 39
 
40
-		$response = $this->api_service->request( 'POST', '/thirdparty/cafemedia/food-kg/ingredients/main', [
40
+		$response = $this->api_service->request('POST', '/thirdparty/cafemedia/food-kg/ingredients/main', [
41 41
 			'accept'       => 'application/ld+json',
42 42
 			'content-type' => 'text/plain'
43
-		], $input );
43
+		], $input);
44 44
 
45 45
 		return $response->get_body();
46 46
 	}
Please login to merge, or discard this patch.
src/modules/food-kg/includes/Notices.php 2 patches
Indentation   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -3,38 +3,38 @@
 block discarded – undo
3 3
 namespace Wordlift\Modules\Food_Kg;
4 4
 
5 5
 class Notices {
6
-	/**
7
-	 * @var array{'type': string, 'html': string}
8
-	 */
9
-	private $notices = [];
6
+    /**
7
+     * @var array{'type': string, 'html': string}
8
+     */
9
+    private $notices = [];
10 10
 
11
-	public function register_hooks() {
12
-		add_action( 'admin_notices', [ $this, '__admin_notices' ] );
13
-	}
11
+    public function register_hooks() {
12
+        add_action( 'admin_notices', [ $this, '__admin_notices' ] );
13
+    }
14 14
 
15
-	/**
16
-	 * @param 'info'|'warning'|'error'|'success' $type
17
-	 * @param string $html
18
-	 *
19
-	 * @return void
20
-	 */
21
-	public function queue( $type, $html ) {
22
-		set_transient( '_wl_notices', [ 'type' => $type, 'html' => $html ], 60 );
23
-	}
15
+    /**
16
+     * @param 'info'|'warning'|'error'|'success' $type
17
+     * @param string $html
18
+     *
19
+     * @return void
20
+     */
21
+    public function queue( $type, $html ) {
22
+        set_transient( '_wl_notices', [ 'type' => $type, 'html' => $html ], 60 );
23
+    }
24 24
 
25
-	public function __admin_notices() {
26
-		/** @var false|array{'type': string, 'html': string} $notice */
27
-		$notice = get_transient( '_wl_notices' );
28
-		if ( ! $notice ) {
29
-			return;
30
-		}
25
+    public function __admin_notices() {
26
+        /** @var false|array{'type': string, 'html': string} $notice */
27
+        $notice = get_transient( '_wl_notices' );
28
+        if ( ! $notice ) {
29
+            return;
30
+        }
31 31
 
32
-		$type_e = esc_attr( $notice['type'] );
33
-		?>
32
+        $type_e = esc_attr( $notice['type'] );
33
+        ?>
34 34
         <div class="notice notice-<?php echo $type_e; ?> is-dismissible">
35 35
             <p><?php echo wp_kses( $notice['html'], [ 'a' ] ); ?></p>
36 36
         </div>
37 37
 		<?php
38
-	}
38
+    }
39 39
 
40 40
 }
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
 	private $notices = [];
10 10
 
11 11
 	public function register_hooks() {
12
-		add_action( 'admin_notices', [ $this, '__admin_notices' ] );
12
+		add_action('admin_notices', [$this, '__admin_notices']);
13 13
 	}
14 14
 
15 15
 	/**
@@ -18,21 +18,21 @@  discard block
 block discarded – undo
18 18
 	 *
19 19
 	 * @return void
20 20
 	 */
21
-	public function queue( $type, $html ) {
22
-		set_transient( '_wl_notices', [ 'type' => $type, 'html' => $html ], 60 );
21
+	public function queue($type, $html) {
22
+		set_transient('_wl_notices', ['type' => $type, 'html' => $html], 60);
23 23
 	}
24 24
 
25 25
 	public function __admin_notices() {
26 26
 		/** @var false|array{'type': string, 'html': string} $notice */
27
-		$notice = get_transient( '_wl_notices' );
28
-		if ( ! $notice ) {
27
+		$notice = get_transient('_wl_notices');
28
+		if ( ! $notice) {
29 29
 			return;
30 30
 		}
31 31
 
32
-		$type_e = esc_attr( $notice['type'] );
32
+		$type_e = esc_attr($notice['type']);
33 33
 		?>
34 34
         <div class="notice notice-<?php echo $type_e; ?> is-dismissible">
35
-            <p><?php echo wp_kses( $notice['html'], [ 'a' ] ); ?></p>
35
+            <p><?php echo wp_kses($notice['html'], ['a']); ?></p>
36 36
         </div>
37 37
 		<?php
38 38
 	}
Please login to merge, or discard this patch.
src/modules/food-kg/includes/Ingredients_Taxonomy_Recipe_Lift_Strategy.php 2 patches
Indentation   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -4,48 +4,48 @@
 block discarded – undo
4 4
 
5 5
 class Ingredients_Taxonomy_Recipe_Lift_Strategy implements Recipe_Lift_Strategy {
6 6
 
7
-	/**
8
-	 * @var Ingredients_Client
9
-	 */
10
-	private $ingredients_client;
11
-
12
-	/**
13
-	 * @var Notices
14
-	 */
15
-	private $notices;
16
-
17
-	function __construct( Ingredients_Client $ingredients_client, Notices $notices ) {
18
-		$this->ingredients_client = $ingredients_client;
19
-		$this->notices            = $notices;
20
-	}
21
-
22
-	function run() {
23
-		$this->notices->queue( 'info', __( 'WordLift detected WP Recipe Maker and, it is lifting the ingredients...', 'wordlift' ) );
24
-
25
-		/**
26
-		 * @var string[] $terms
27
-		 */
28
-		$terms       = get_terms( [ 'taxonomy' => 'wprm_ingredient', 'fields' => 'names', 'hide_empty' => false ] );
29
-		$ingredients = $this->ingredients_client->ingredients( $terms );
30
-
31
-		foreach ( $ingredients as $key => $value ) {
32
-			$term = get_term_by( 'name', $key, 'wprm_ingredient' );
33
-			if ( ! isset( $term ) ) {
34
-				continue;
35
-			}
36
-			update_term_meta( $term->term_id, '_wl_jsonld', $value );
37
-
38
-			/**
39
-			 * @@todo update notification with progress
40
-			 */
41
-		}
42
-
43
-		/**
44
-		 * @@todo add notification that procedure is complete, with information about the number of processed items vs
45
-		 *   total items
46
-		 */
47
-		$count_terms        = count( $terms );
48
-		$count_lifted_terms = count( $ingredients );
49
-		$this->notices->queue( 'info', sprintf( __( 'WordLift detected WP Recipe Maker and, it lifted %d of %d ingredient(s).', 'wordlift' ), $count_lifted_terms, $count_terms ) );
50
-	}
7
+    /**
8
+     * @var Ingredients_Client
9
+     */
10
+    private $ingredients_client;
11
+
12
+    /**
13
+     * @var Notices
14
+     */
15
+    private $notices;
16
+
17
+    function __construct( Ingredients_Client $ingredients_client, Notices $notices ) {
18
+        $this->ingredients_client = $ingredients_client;
19
+        $this->notices            = $notices;
20
+    }
21
+
22
+    function run() {
23
+        $this->notices->queue( 'info', __( 'WordLift detected WP Recipe Maker and, it is lifting the ingredients...', 'wordlift' ) );
24
+
25
+        /**
26
+         * @var string[] $terms
27
+         */
28
+        $terms       = get_terms( [ 'taxonomy' => 'wprm_ingredient', 'fields' => 'names', 'hide_empty' => false ] );
29
+        $ingredients = $this->ingredients_client->ingredients( $terms );
30
+
31
+        foreach ( $ingredients as $key => $value ) {
32
+            $term = get_term_by( 'name', $key, 'wprm_ingredient' );
33
+            if ( ! isset( $term ) ) {
34
+                continue;
35
+            }
36
+            update_term_meta( $term->term_id, '_wl_jsonld', $value );
37
+
38
+            /**
39
+             * @@todo update notification with progress
40
+             */
41
+        }
42
+
43
+        /**
44
+         * @@todo add notification that procedure is complete, with information about the number of processed items vs
45
+         *   total items
46
+         */
47
+        $count_terms        = count( $terms );
48
+        $count_lifted_terms = count( $ingredients );
49
+        $this->notices->queue( 'info', sprintf( __( 'WordLift detected WP Recipe Maker and, it lifted %d of %d ingredient(s).', 'wordlift' ), $count_lifted_terms, $count_terms ) );
50
+    }
51 51
 }
52 52
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -14,26 +14,26 @@  discard block
 block discarded – undo
14 14
 	 */
15 15
 	private $notices;
16 16
 
17
-	function __construct( Ingredients_Client $ingredients_client, Notices $notices ) {
17
+	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 22
 	function run() {
23
-		$this->notices->queue( 'info', __( 'WordLift detected WP Recipe Maker and, it is lifting the ingredients...', 'wordlift' ) );
23
+		$this->notices->queue('info', __('WordLift detected WP Recipe Maker and, it is lifting the ingredients...', 'wordlift'));
24 24
 
25 25
 		/**
26 26
 		 * @var string[] $terms
27 27
 		 */
28
-		$terms       = get_terms( [ 'taxonomy' => 'wprm_ingredient', 'fields' => 'names', 'hide_empty' => false ] );
29
-		$ingredients = $this->ingredients_client->ingredients( $terms );
28
+		$terms       = get_terms(['taxonomy' => 'wprm_ingredient', 'fields' => 'names', 'hide_empty' => false]);
29
+		$ingredients = $this->ingredients_client->ingredients($terms);
30 30
 
31
-		foreach ( $ingredients as $key => $value ) {
32
-			$term = get_term_by( 'name', $key, 'wprm_ingredient' );
33
-			if ( ! isset( $term ) ) {
31
+		foreach ($ingredients as $key => $value) {
32
+			$term = get_term_by('name', $key, 'wprm_ingredient');
33
+			if ( ! isset($term)) {
34 34
 				continue;
35 35
 			}
36
-			update_term_meta( $term->term_id, '_wl_jsonld', $value );
36
+			update_term_meta($term->term_id, '_wl_jsonld', $value);
37 37
 
38 38
 			/**
39 39
 			 * @@todo update notification with progress
@@ -44,8 +44,8 @@  discard block
 block discarded – undo
44 44
 		 * @@todo add notification that procedure is complete, with information about the number of processed items vs
45 45
 		 *   total items
46 46
 		 */
47
-		$count_terms        = count( $terms );
48
-		$count_lifted_terms = count( $ingredients );
49
-		$this->notices->queue( 'info', sprintf( __( 'WordLift detected WP Recipe Maker and, it lifted %d of %d ingredient(s).', 'wordlift' ), $count_lifted_terms, $count_terms ) );
47
+		$count_terms        = count($terms);
48
+		$count_lifted_terms = count($ingredients);
49
+		$this->notices->queue('info', sprintf(__('WordLift detected WP Recipe Maker and, it lifted %d of %d ingredient(s).', 'wordlift'), $count_lifted_terms, $count_terms));
50 50
 	}
51 51
 }
52 52
\ No newline at end of file
Please login to merge, or discard this patch.
src/modules/food-kg/includes/Module.php 2 patches
Indentation   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -7,61 +7,61 @@
 block discarded – undo
7 7
 
8 8
 class Module {
9 9
 
10
-	const RUN_EVENT = 'wl_food_kg__run';
11
-
12
-	/**
13
-	 * @var Api_Service_Ext
14
-	 */
15
-	private $api_service;
16
-
17
-	/**
18
-	 * @var Recipe_Lift_Strategy
19
-	 */
20
-	private $recipe_lift_strategy;
21
-
22
-	/**
23
-	 * @param Api_Service_Ext $api_service
24
-	 * @param Recipe_Lift_Strategy $recipe_lift_strategy
25
-	 */
26
-	public function __construct( Api_Service_Ext $api_service, Recipe_Lift_Strategy $recipe_lift_strategy ) {
27
-		$this->api_service          = $api_service;
28
-		$this->recipe_lift_strategy = $recipe_lift_strategy;
29
-	}
30
-
31
-	public function register_hooks() {
32
-		add_action( 'wl_key_updated', [ $this, '__key_updated' ] );
33
-		add_action( self::RUN_EVENT, [ $this, '__run' ] );
34
-		add_action( 'wp_ajax_wl_food_kg__run', [ $this, '__run' ] );
35
-	}
36
-
37
-	public function __key_updated() {
38
-		try {
39
-			$me_response    = $this->api_service->me();
40
-			$has_food_kg    = isset( $me_response->networks )
41
-			                  && array_reduce( $me_response->networks, [ $this, '__has_food_kg' ], false );
42
-			$next_scheduled = wp_next_scheduled( self::RUN_EVENT );
43
-
44
-			// We're connected to the Food KG, but not yet scheduled.
45
-			if ( $has_food_kg && ! $next_scheduled ) {
46
-				wp_schedule_event( time(), 'daily', self::RUN_EVENT );
47
-			}
48
-
49
-			// We're not connected to the Food KG, but we're scheduled.
50
-			if ( ! $has_food_kg && $next_scheduled ) {
51
-				wp_unschedule_event( $next_scheduled, self::RUN_EVENT );
52
-			}
53
-
54
-		} catch ( Exception $e ) {
55
-
56
-		}
57
-	}
58
-
59
-	public function __run() {
60
-		$this->recipe_lift_strategy->run();
61
-	}
62
-
63
-	private function __has_food_kg( $carry, $item ) {
64
-		return $carry || 'https://knowledge.cafemedia.com/food/' === $item->dataset_uri;
65
-	}
10
+    const RUN_EVENT = 'wl_food_kg__run';
11
+
12
+    /**
13
+     * @var Api_Service_Ext
14
+     */
15
+    private $api_service;
16
+
17
+    /**
18
+     * @var Recipe_Lift_Strategy
19
+     */
20
+    private $recipe_lift_strategy;
21
+
22
+    /**
23
+     * @param Api_Service_Ext $api_service
24
+     * @param Recipe_Lift_Strategy $recipe_lift_strategy
25
+     */
26
+    public function __construct( Api_Service_Ext $api_service, Recipe_Lift_Strategy $recipe_lift_strategy ) {
27
+        $this->api_service          = $api_service;
28
+        $this->recipe_lift_strategy = $recipe_lift_strategy;
29
+    }
30
+
31
+    public function register_hooks() {
32
+        add_action( 'wl_key_updated', [ $this, '__key_updated' ] );
33
+        add_action( self::RUN_EVENT, [ $this, '__run' ] );
34
+        add_action( 'wp_ajax_wl_food_kg__run', [ $this, '__run' ] );
35
+    }
36
+
37
+    public function __key_updated() {
38
+        try {
39
+            $me_response    = $this->api_service->me();
40
+            $has_food_kg    = isset( $me_response->networks )
41
+                              && array_reduce( $me_response->networks, [ $this, '__has_food_kg' ], false );
42
+            $next_scheduled = wp_next_scheduled( self::RUN_EVENT );
43
+
44
+            // We're connected to the Food KG, but not yet scheduled.
45
+            if ( $has_food_kg && ! $next_scheduled ) {
46
+                wp_schedule_event( time(), 'daily', self::RUN_EVENT );
47
+            }
48
+
49
+            // We're not connected to the Food KG, but we're scheduled.
50
+            if ( ! $has_food_kg && $next_scheduled ) {
51
+                wp_unschedule_event( $next_scheduled, self::RUN_EVENT );
52
+            }
53
+
54
+        } catch ( Exception $e ) {
55
+
56
+        }
57
+    }
58
+
59
+    public function __run() {
60
+        $this->recipe_lift_strategy->run();
61
+    }
62
+
63
+    private function __has_food_kg( $carry, $item ) {
64
+        return $carry || 'https://knowledge.cafemedia.com/food/' === $item->dataset_uri;
65
+    }
66 66
 
67 67
 }
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -23,35 +23,35 @@  discard block
 block discarded – undo
23 23
 	 * @param Api_Service_Ext $api_service
24 24
 	 * @param Recipe_Lift_Strategy $recipe_lift_strategy
25 25
 	 */
26
-	public function __construct( Api_Service_Ext $api_service, Recipe_Lift_Strategy $recipe_lift_strategy ) {
26
+	public function __construct(Api_Service_Ext $api_service, Recipe_Lift_Strategy $recipe_lift_strategy) {
27 27
 		$this->api_service          = $api_service;
28 28
 		$this->recipe_lift_strategy = $recipe_lift_strategy;
29 29
 	}
30 30
 
31 31
 	public function register_hooks() {
32
-		add_action( 'wl_key_updated', [ $this, '__key_updated' ] );
33
-		add_action( self::RUN_EVENT, [ $this, '__run' ] );
34
-		add_action( 'wp_ajax_wl_food_kg__run', [ $this, '__run' ] );
32
+		add_action('wl_key_updated', [$this, '__key_updated']);
33
+		add_action(self::RUN_EVENT, [$this, '__run']);
34
+		add_action('wp_ajax_wl_food_kg__run', [$this, '__run']);
35 35
 	}
36 36
 
37 37
 	public function __key_updated() {
38 38
 		try {
39 39
 			$me_response    = $this->api_service->me();
40
-			$has_food_kg    = isset( $me_response->networks )
41
-			                  && array_reduce( $me_response->networks, [ $this, '__has_food_kg' ], false );
42
-			$next_scheduled = wp_next_scheduled( self::RUN_EVENT );
40
+			$has_food_kg    = isset($me_response->networks)
41
+			                  && array_reduce($me_response->networks, [$this, '__has_food_kg'], false);
42
+			$next_scheduled = wp_next_scheduled(self::RUN_EVENT);
43 43
 
44 44
 			// We're connected to the Food KG, but not yet scheduled.
45
-			if ( $has_food_kg && ! $next_scheduled ) {
46
-				wp_schedule_event( time(), 'daily', self::RUN_EVENT );
45
+			if ($has_food_kg && ! $next_scheduled) {
46
+				wp_schedule_event(time(), 'daily', self::RUN_EVENT);
47 47
 			}
48 48
 
49 49
 			// We're not connected to the Food KG, but we're scheduled.
50
-			if ( ! $has_food_kg && $next_scheduled ) {
51
-				wp_unschedule_event( $next_scheduled, self::RUN_EVENT );
50
+			if ( ! $has_food_kg && $next_scheduled) {
51
+				wp_unschedule_event($next_scheduled, self::RUN_EVENT);
52 52
 			}
53 53
 
54
-		} catch ( Exception $e ) {
54
+		} catch (Exception $e) {
55 55
 
56 56
 		}
57 57
 	}
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
 		$this->recipe_lift_strategy->run();
61 61
 	}
62 62
 
63
-	private function __has_food_kg( $carry, $item ) {
63
+	private function __has_food_kg($carry, $item) {
64 64
 		return $carry || 'https://knowledge.cafemedia.com/food/' === $item->dataset_uri;
65 65
 	}
66 66
 
Please login to merge, or discard this patch.