Completed
Pull Request — develop (#1698)
by
unknown
01:26
created
src/wordlift/shipping-data/class-offer-structured-data.php 2 patches
Indentation   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -4,43 +4,43 @@
 block discarded – undo
4 4
 
5 5
 class Offer_Structured_Data {
6 6
 
7
-	/**
8
-	 * @var Shipping_Zones
9
-	 */
10
-	private $shipping_zones;
7
+    /**
8
+     * @var Shipping_Zones
9
+     */
10
+    private $shipping_zones;
11 11
 
12
-	/**
13
-	 * Offer_Structured_Data constructor.
14
-	 *
15
-	 * @param Shipping_Zones $shipping_zones
16
-	 */
17
-	public function __construct( $shipping_zones ) {
12
+    /**
13
+     * Offer_Structured_Data constructor.
14
+     *
15
+     * @param Shipping_Zones $shipping_zones
16
+     */
17
+    public function __construct( $shipping_zones ) {
18 18
 
19
-		$this->shipping_zones = $shipping_zones;
19
+        $this->shipping_zones = $shipping_zones;
20 20
 
21
-		add_filter( 'wl_entity_jsonld', array( $this, 'entity_jsonld' ), 10, 2 );
21
+        add_filter( 'wl_entity_jsonld', array( $this, 'entity_jsonld' ), 10, 2 );
22 22
 
23
-	}
23
+    }
24 24
 
25
-	public function entity_jsonld( $jsonld, $post_id ) {
25
+    public function entity_jsonld( $jsonld, $post_id ) {
26 26
 
27
-		// Bail out if it's not a Product or the offers property isn't set.
28
-		if ( ! in_array( 'Product', (array) $jsonld['@type'], true ) || ! isset( $jsonld['offers'] ) ) {
29
-			return $jsonld;
30
-		}
27
+        // Bail out if it's not a Product or the offers property isn't set.
28
+        if ( ! in_array( 'Product', (array) $jsonld['@type'], true ) || ! isset( $jsonld['offers'] ) ) {
29
+            return $jsonld;
30
+        }
31 31
 
32
-		if ( ! is_array( $jsonld['offers'] ) || ! is_numeric( key( $jsonld['offers'] ) ) ) {
33
-			$jsonld['offers'] = array( $jsonld['offers'] );
34
-		}
32
+        if ( ! is_array( $jsonld['offers'] ) || ! is_numeric( key( $jsonld['offers'] ) ) ) {
33
+            $jsonld['offers'] = array( $jsonld['offers'] );
34
+        }
35 35
 
36
-		$product = new Product( $post_id );
36
+        $product = new Product( $post_id );
37 37
 
38
-		foreach ( $jsonld['offers'] as &$offer ) {
39
-			$this->shipping_zones->add_available_delivery_method( $offer );
40
-			$this->shipping_zones->add_offer_shipping_details( $offer, $product );
41
-		}
38
+        foreach ( $jsonld['offers'] as &$offer ) {
39
+            $this->shipping_zones->add_available_delivery_method( $offer );
40
+            $this->shipping_zones->add_offer_shipping_details( $offer, $product );
41
+        }
42 42
 
43
-		return $jsonld;
44
-	}
43
+        return $jsonld;
44
+    }
45 45
 
46 46
 }
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -14,30 +14,30 @@
 block discarded – undo
14 14
 	 *
15 15
 	 * @param Shipping_Zones $shipping_zones
16 16
 	 */
17
-	public function __construct( $shipping_zones ) {
17
+	public function __construct($shipping_zones) {
18 18
 
19 19
 		$this->shipping_zones = $shipping_zones;
20 20
 
21
-		add_filter( 'wl_entity_jsonld', array( $this, 'entity_jsonld' ), 10, 2 );
21
+		add_filter('wl_entity_jsonld', array($this, 'entity_jsonld'), 10, 2);
22 22
 
23 23
 	}
24 24
 
25
-	public function entity_jsonld( $jsonld, $post_id ) {
25
+	public function entity_jsonld($jsonld, $post_id) {
26 26
 
27 27
 		// Bail out if it's not a Product or the offers property isn't set.
28
-		if ( ! in_array( 'Product', (array) $jsonld['@type'], true ) || ! isset( $jsonld['offers'] ) ) {
28
+		if ( ! in_array('Product', (array) $jsonld['@type'], true) || ! isset($jsonld['offers'])) {
29 29
 			return $jsonld;
30 30
 		}
31 31
 
32
-		if ( ! is_array( $jsonld['offers'] ) || ! is_numeric( key( $jsonld['offers'] ) ) ) {
33
-			$jsonld['offers'] = array( $jsonld['offers'] );
32
+		if ( ! is_array($jsonld['offers']) || ! is_numeric(key($jsonld['offers']))) {
33
+			$jsonld['offers'] = array($jsonld['offers']);
34 34
 		}
35 35
 
36
-		$product = new Product( $post_id );
36
+		$product = new Product($post_id);
37 37
 
38
-		foreach ( $jsonld['offers'] as &$offer ) {
39
-			$this->shipping_zones->add_available_delivery_method( $offer );
40
-			$this->shipping_zones->add_offer_shipping_details( $offer, $product );
38
+		foreach ($jsonld['offers'] as &$offer) {
39
+			$this->shipping_zones->add_available_delivery_method($offer);
40
+			$this->shipping_zones->add_offer_shipping_details($offer, $product);
41 41
 		}
42 42
 
43 43
 		return $jsonld;
Please login to merge, or discard this patch.
src/wordlift/shipping-data/class-product.php 2 patches
Indentation   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -4,58 +4,58 @@
 block discarded – undo
4 4
 
5 5
 class Product {
6 6
 
7
-	/**
8
-	 * @var false|\WC_Product|null
9
-	 */
10
-	private $wc_product;
7
+    /**
8
+     * @var false|\WC_Product|null
9
+     */
10
+    private $wc_product;
11 11
 
12
-	/**
13
-	 * Product constructor.
14
-	 *
15
-	 * @param $post_id
16
-	 */
17
-	public function __construct( $post_id ) {
12
+    /**
13
+     * Product constructor.
14
+     *
15
+     * @param $post_id
16
+     */
17
+    public function __construct( $post_id ) {
18 18
 
19
-		$this->wc_product = wc_get_product( $post_id );
19
+        $this->wc_product = wc_get_product( $post_id );
20 20
 
21
-	}
21
+    }
22 22
 
23
-	public function add_handling_time( &$shipping_delivery_time ) {
23
+    public function add_handling_time( &$shipping_delivery_time ) {
24 24
 
25
-		// Bail out if there's no product.
26
-		if ( empty( $this->wc_product ) ) {
27
-			return;
28
-		}
25
+        // Bail out if there's no product.
26
+        if ( empty( $this->wc_product ) ) {
27
+            return;
28
+        }
29 29
 
30
-		$shipping_class_id = $this->wc_product->get_shipping_class_id();
30
+        $shipping_class_id = $this->wc_product->get_shipping_class_id();
31 31
 
32
-		$option = get_option( 'wpsso_options' );
32
+        $option = get_option( 'wpsso_options' );
33 33
 
34
-		if ( empty( $option[ "wcsdt_handling_c{$shipping_class_id}_unit_code" ] )
35
-			 || empty( $option[ "wcsdt_handling_c{$shipping_class_id}_minimum" ] )
36
-			 || empty( $option[ "wcsdt_handling_c{$shipping_class_id}_maximum" ] ) ) {
37
-			return;
38
-		}
34
+        if ( empty( $option[ "wcsdt_handling_c{$shipping_class_id}_unit_code" ] )
35
+             || empty( $option[ "wcsdt_handling_c{$shipping_class_id}_minimum" ] )
36
+             || empty( $option[ "wcsdt_handling_c{$shipping_class_id}_maximum" ] ) ) {
37
+            return;
38
+        }
39 39
 
40
-		$unit_code = $option[ "wcsdt_handling_c{$shipping_class_id}_unit_code" ];
41
-		$minimum   = $option[ "wcsdt_handling_c{$shipping_class_id}_minimum" ];
42
-		$maximum   = $option[ "wcsdt_handling_c{$shipping_class_id}_maximum" ];
40
+        $unit_code = $option[ "wcsdt_handling_c{$shipping_class_id}_unit_code" ];
41
+        $minimum   = $option[ "wcsdt_handling_c{$shipping_class_id}_minimum" ];
42
+        $maximum   = $option[ "wcsdt_handling_c{$shipping_class_id}_maximum" ];
43 43
 
44
-		if ( 'HUR' === $unit_code ) {
45
-			$minimum = floor( $minimum / 24.0 );
46
-			$maximum = ceil( $maximum / 24.0 );
47
-		}
44
+        if ( 'HUR' === $unit_code ) {
45
+            $minimum = floor( $minimum / 24.0 );
46
+            $maximum = ceil( $maximum / 24.0 );
47
+        }
48 48
 
49
-		$shipping_delivery_time['handlingTime'] = array(
50
-			'@type'    => 'QuantitativeValue',
51
-			'minValue' => $minimum,
52
-			'maxValue' => $maximum,
53
-		);
49
+        $shipping_delivery_time['handlingTime'] = array(
50
+            '@type'    => 'QuantitativeValue',
51
+            'minValue' => $minimum,
52
+            'maxValue' => $maximum,
53
+        );
54 54
 
55
-	}
55
+    }
56 56
 
57
-	private function get_handling_time() {
57
+    private function get_handling_time() {
58 58
 
59
-	}
59
+    }
60 60
 
61 61
 }
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -14,36 +14,36 @@
 block discarded – undo
14 14
 	 *
15 15
 	 * @param $post_id
16 16
 	 */
17
-	public function __construct( $post_id ) {
17
+	public function __construct($post_id) {
18 18
 
19
-		$this->wc_product = wc_get_product( $post_id );
19
+		$this->wc_product = wc_get_product($post_id);
20 20
 
21 21
 	}
22 22
 
23
-	public function add_handling_time( &$shipping_delivery_time ) {
23
+	public function add_handling_time(&$shipping_delivery_time) {
24 24
 
25 25
 		// Bail out if there's no product.
26
-		if ( empty( $this->wc_product ) ) {
26
+		if (empty($this->wc_product)) {
27 27
 			return;
28 28
 		}
29 29
 
30 30
 		$shipping_class_id = $this->wc_product->get_shipping_class_id();
31 31
 
32
-		$option = get_option( 'wpsso_options' );
32
+		$option = get_option('wpsso_options');
33 33
 
34
-		if ( empty( $option[ "wcsdt_handling_c{$shipping_class_id}_unit_code" ] )
35
-			 || empty( $option[ "wcsdt_handling_c{$shipping_class_id}_minimum" ] )
36
-			 || empty( $option[ "wcsdt_handling_c{$shipping_class_id}_maximum" ] ) ) {
34
+		if (empty($option["wcsdt_handling_c{$shipping_class_id}_unit_code"])
35
+			 || empty($option["wcsdt_handling_c{$shipping_class_id}_minimum"])
36
+			 || empty($option["wcsdt_handling_c{$shipping_class_id}_maximum"])) {
37 37
 			return;
38 38
 		}
39 39
 
40
-		$unit_code = $option[ "wcsdt_handling_c{$shipping_class_id}_unit_code" ];
41
-		$minimum   = $option[ "wcsdt_handling_c{$shipping_class_id}_minimum" ];
42
-		$maximum   = $option[ "wcsdt_handling_c{$shipping_class_id}_maximum" ];
40
+		$unit_code = $option["wcsdt_handling_c{$shipping_class_id}_unit_code"];
41
+		$minimum   = $option["wcsdt_handling_c{$shipping_class_id}_minimum"];
42
+		$maximum   = $option["wcsdt_handling_c{$shipping_class_id}_maximum"];
43 43
 
44
-		if ( 'HUR' === $unit_code ) {
45
-			$minimum = floor( $minimum / 24.0 );
46
-			$maximum = ceil( $maximum / 24.0 );
44
+		if ('HUR' === $unit_code) {
45
+			$minimum = floor($minimum / 24.0);
46
+			$maximum = ceil($maximum / 24.0);
47 47
 		}
48 48
 
49 49
 		$shipping_delivery_time['handlingTime'] = array(
Please login to merge, or discard this patch.
src/wordlift/shipping-data/class-shipping-zones.php 2 patches
Indentation   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -6,81 +6,81 @@
 block discarded – undo
6 6
 
7 7
 class Shipping_Zones {
8 8
 
9
-	/**
10
-	 * @var Shipping_Zone[]
11
-	 */
12
-	private $zones;
9
+    /**
10
+     * @var Shipping_Zone[]
11
+     */
12
+    private $zones;
13 13
 
14
-	public function __construct() {
15
-		$this->zones = array();
16
-	}
14
+    public function __construct() {
15
+        $this->zones = array();
16
+    }
17 17
 
18
-	private function load_zones() {
18
+    private function load_zones() {
19 19
 
20
-		$zone_ids          = array_keys( WC_Shipping_Zones::get_zones() );
21
-		$wc_shipping_zones = array( WC_Shipping_Zones::get_zone( 0 ) );
22
-		foreach ( $zone_ids as $zone_id ) {
23
-			$wc_shipping_zones[] = WC_Shipping_Zones::get_zone( $zone_id );
24
-		}
20
+        $zone_ids          = array_keys( WC_Shipping_Zones::get_zones() );
21
+        $wc_shipping_zones = array( WC_Shipping_Zones::get_zone( 0 ) );
22
+        foreach ( $zone_ids as $zone_id ) {
23
+            $wc_shipping_zones[] = WC_Shipping_Zones::get_zone( $zone_id );
24
+        }
25 25
 
26
-		$zones = array();
27
-		foreach ( $wc_shipping_zones as $wc_shipping_zone ) {
28
-			$country_codes = $this->get_country_codes( $wc_shipping_zone->get_zone_locations() );
26
+        $zones = array();
27
+        foreach ( $wc_shipping_zones as $wc_shipping_zone ) {
28
+            $country_codes = $this->get_country_codes( $wc_shipping_zone->get_zone_locations() );
29 29
 
30
-			if ( empty( $country_codes ) ) {
31
-				$zones[] = Shipping_Zone::from_wc_shipping_zone( $wc_shipping_zone );
32
-			} else {
33
-				foreach ( $country_codes as $country_code ) {
34
-					$zones[] = Shipping_Zone::from_wc_shipping_zone( $wc_shipping_zone, $country_code );
35
-				}
36
-			}
37
-		}
30
+            if ( empty( $country_codes ) ) {
31
+                $zones[] = Shipping_Zone::from_wc_shipping_zone( $wc_shipping_zone );
32
+            } else {
33
+                foreach ( $country_codes as $country_code ) {
34
+                    $zones[] = Shipping_Zone::from_wc_shipping_zone( $wc_shipping_zone, $country_code );
35
+                }
36
+            }
37
+        }
38 38
 
39
-		$this->zones = $zones;
39
+        $this->zones = $zones;
40 40
 
41
-	}
41
+    }
42 42
 
43
-	public function add_available_delivery_method( &$jsonld ) {
43
+    public function add_available_delivery_method( &$jsonld ) {
44 44
 
45
-		$this->load_zones();
45
+        $this->load_zones();
46 46
 
47
-		foreach ( $this->zones as $zone ) {
48
-			$zone->add_available_delivery_method( $jsonld );
49
-		}
47
+        foreach ( $this->zones as $zone ) {
48
+            $zone->add_available_delivery_method( $jsonld );
49
+        }
50 50
 
51
-	}
51
+    }
52 52
 
53
-	/**
54
-	 * @param array   $jsonld
55
-	 * @param Product $product
56
-	 */
57
-	public function add_offer_shipping_details( &$jsonld, $product ) {
53
+    /**
54
+     * @param array   $jsonld
55
+     * @param Product $product
56
+     */
57
+    public function add_offer_shipping_details( &$jsonld, $product ) {
58 58
 
59
-		$this->load_zones();
59
+        $this->load_zones();
60 60
 
61
-		foreach ( $this->zones as $zone ) {
62
-			$zone->add_offer_shipping_details( $jsonld, $product );
63
-		}
61
+        foreach ( $this->zones as $zone ) {
62
+            $zone->add_offer_shipping_details( $jsonld, $product );
63
+        }
64 64
 
65
-	}
65
+    }
66 66
 
67
-	private function get_country_codes( $wc_shipping_zones ) {
68
-		$countries = array();
67
+    private function get_country_codes( $wc_shipping_zones ) {
68
+        $countries = array();
69 69
 
70
-		foreach ( $wc_shipping_zones as $wc_shipping_zone ) {
71
-			if ( ! isset( $wc_shipping_zone->type )
72
-				 || ( 'country' !== $wc_shipping_zone->type && 'state' !== $wc_shipping_zone->type ) ) {
73
-				continue;
74
-			}
70
+        foreach ( $wc_shipping_zones as $wc_shipping_zone ) {
71
+            if ( ! isset( $wc_shipping_zone->type )
72
+                 || ( 'country' !== $wc_shipping_zone->type && 'state' !== $wc_shipping_zone->type ) ) {
73
+                continue;
74
+            }
75 75
 
76
-			$country = substr( $wc_shipping_zone->code, 0, 2 );
76
+            $country = substr( $wc_shipping_zone->code, 0, 2 );
77 77
 
78
-			if ( ! in_array( $country, $countries, true ) ) {
79
-				$countries[] = $country;
80
-			}
81
-		}
78
+            if ( ! in_array( $country, $countries, true ) ) {
79
+                $countries[] = $country;
80
+            }
81
+        }
82 82
 
83
-		return $countries;
84
-	}
83
+        return $countries;
84
+    }
85 85
 
86 86
 }
Please login to merge, or discard this patch.
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -17,21 +17,21 @@  discard block
 block discarded – undo
17 17
 
18 18
 	private function load_zones() {
19 19
 
20
-		$zone_ids          = array_keys( WC_Shipping_Zones::get_zones() );
21
-		$wc_shipping_zones = array( WC_Shipping_Zones::get_zone( 0 ) );
22
-		foreach ( $zone_ids as $zone_id ) {
23
-			$wc_shipping_zones[] = WC_Shipping_Zones::get_zone( $zone_id );
20
+		$zone_ids          = array_keys(WC_Shipping_Zones::get_zones());
21
+		$wc_shipping_zones = array(WC_Shipping_Zones::get_zone(0));
22
+		foreach ($zone_ids as $zone_id) {
23
+			$wc_shipping_zones[] = WC_Shipping_Zones::get_zone($zone_id);
24 24
 		}
25 25
 
26 26
 		$zones = array();
27
-		foreach ( $wc_shipping_zones as $wc_shipping_zone ) {
28
-			$country_codes = $this->get_country_codes( $wc_shipping_zone->get_zone_locations() );
27
+		foreach ($wc_shipping_zones as $wc_shipping_zone) {
28
+			$country_codes = $this->get_country_codes($wc_shipping_zone->get_zone_locations());
29 29
 
30
-			if ( empty( $country_codes ) ) {
31
-				$zones[] = Shipping_Zone::from_wc_shipping_zone( $wc_shipping_zone );
30
+			if (empty($country_codes)) {
31
+				$zones[] = Shipping_Zone::from_wc_shipping_zone($wc_shipping_zone);
32 32
 			} else {
33
-				foreach ( $country_codes as $country_code ) {
34
-					$zones[] = Shipping_Zone::from_wc_shipping_zone( $wc_shipping_zone, $country_code );
33
+				foreach ($country_codes as $country_code) {
34
+					$zones[] = Shipping_Zone::from_wc_shipping_zone($wc_shipping_zone, $country_code);
35 35
 				}
36 36
 			}
37 37
 		}
@@ -40,12 +40,12 @@  discard block
 block discarded – undo
40 40
 
41 41
 	}
42 42
 
43
-	public function add_available_delivery_method( &$jsonld ) {
43
+	public function add_available_delivery_method(&$jsonld) {
44 44
 
45 45
 		$this->load_zones();
46 46
 
47
-		foreach ( $this->zones as $zone ) {
48
-			$zone->add_available_delivery_method( $jsonld );
47
+		foreach ($this->zones as $zone) {
48
+			$zone->add_available_delivery_method($jsonld);
49 49
 		}
50 50
 
51 51
 	}
@@ -54,28 +54,28 @@  discard block
 block discarded – undo
54 54
 	 * @param array   $jsonld
55 55
 	 * @param Product $product
56 56
 	 */
57
-	public function add_offer_shipping_details( &$jsonld, $product ) {
57
+	public function add_offer_shipping_details(&$jsonld, $product) {
58 58
 
59 59
 		$this->load_zones();
60 60
 
61
-		foreach ( $this->zones as $zone ) {
62
-			$zone->add_offer_shipping_details( $jsonld, $product );
61
+		foreach ($this->zones as $zone) {
62
+			$zone->add_offer_shipping_details($jsonld, $product);
63 63
 		}
64 64
 
65 65
 	}
66 66
 
67
-	private function get_country_codes( $wc_shipping_zones ) {
67
+	private function get_country_codes($wc_shipping_zones) {
68 68
 		$countries = array();
69 69
 
70
-		foreach ( $wc_shipping_zones as $wc_shipping_zone ) {
71
-			if ( ! isset( $wc_shipping_zone->type )
72
-				 || ( 'country' !== $wc_shipping_zone->type && 'state' !== $wc_shipping_zone->type ) ) {
70
+		foreach ($wc_shipping_zones as $wc_shipping_zone) {
71
+			if ( ! isset($wc_shipping_zone->type)
72
+				 || ('country' !== $wc_shipping_zone->type && 'state' !== $wc_shipping_zone->type)) {
73 73
 				continue;
74 74
 			}
75 75
 
76
-			$country = substr( $wc_shipping_zone->code, 0, 2 );
76
+			$country = substr($wc_shipping_zone->code, 0, 2);
77 77
 
78
-			if ( ! in_array( $country, $countries, true ) ) {
78
+			if ( ! in_array($country, $countries, true)) {
79 79
 				$countries[] = $country;
80 80
 			}
81 81
 		}
Please login to merge, or discard this patch.
src/wordlift/shipping-data/index.php 2 patches
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -4,16 +4,16 @@
 block discarded – undo
4 4
 use Wordlift\Shipping_Data\Shipping_Zones;
5 5
 
6 6
 if ( ! class_exists( '\WC_Shipping_Zones' )
7
-	 || ! class_exists( '\WC_Shipping_Zone' )
8
-	 || ! class_exists( '\WC_Shipping_Method' )
9
-	 || ! function_exists( 'get_woocommerce_currency' )
10
-	 || ! function_exists( 'wc_get_product' ) ) {
11
-	return;
7
+     || ! class_exists( '\WC_Shipping_Zone' )
8
+     || ! class_exists( '\WC_Shipping_Method' )
9
+     || ! function_exists( 'get_woocommerce_currency' )
10
+     || ! function_exists( 'wc_get_product' ) ) {
11
+    return;
12 12
 }
13 13
 
14 14
 // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
15 15
 if ( ! apply_filters( 'wl_feature__enable__shipping-sd', false ) ) {
16
-	return;
16
+    return;
17 17
 }
18 18
 
19 19
 $shipping_zones = new Shipping_Zones();
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -3,18 +3,18 @@
 block discarded – undo
3 3
 use Wordlift\Shipping_Data\Offer_Structured_Data;
4 4
 use Wordlift\Shipping_Data\Shipping_Zones;
5 5
 
6
-if ( ! class_exists( '\WC_Shipping_Zones' )
7
-	 || ! class_exists( '\WC_Shipping_Zone' )
8
-	 || ! class_exists( '\WC_Shipping_Method' )
9
-	 || ! function_exists( 'get_woocommerce_currency' )
10
-	 || ! function_exists( 'wc_get_product' ) ) {
6
+if ( ! class_exists('\WC_Shipping_Zones')
7
+	 || ! class_exists('\WC_Shipping_Zone')
8
+	 || ! class_exists('\WC_Shipping_Method')
9
+	 || ! function_exists('get_woocommerce_currency')
10
+	 || ! function_exists('wc_get_product')) {
11 11
 	return;
12 12
 }
13 13
 
14 14
 // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
15
-if ( ! apply_filters( 'wl_feature__enable__shipping-sd', false ) ) {
15
+if ( ! apply_filters('wl_feature__enable__shipping-sd', false)) {
16 16
 	return;
17 17
 }
18 18
 
19 19
 $shipping_zones = new Shipping_Zones();
20
-new Offer_Structured_Data( $shipping_zones );
20
+new Offer_Structured_Data($shipping_zones);
Please login to merge, or discard this patch.
src/wordlift/common/editor/class-edit-post-loader.php 2 patches
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -10,19 +10,19 @@
 block discarded – undo
10 10
  */
11 11
 abstract class Edit_Post_Loader {
12 12
 
13
-	public function init() {
13
+    public function init() {
14 14
 
15
-		add_action( 'admin_enqueue_scripts', array( $this, 'post_edit_screen' ) );
16
-	}
15
+        add_action( 'admin_enqueue_scripts', array( $this, 'post_edit_screen' ) );
16
+    }
17 17
 
18
-	public function post_edit_screen( $hook ) {
18
+    public function post_edit_screen( $hook ) {
19 19
 
20
-		if ( 'post.php' === $hook || 'post-new.php' === $hook ) {
21
-			$this->run_on_edit_post_screen();
22
-		}
20
+        if ( 'post.php' === $hook || 'post-new.php' === $hook ) {
21
+            $this->run_on_edit_post_screen();
22
+        }
23 23
 
24
-	}
24
+    }
25 25
 
26
-	abstract public function run_on_edit_post_screen();
26
+    abstract public function run_on_edit_post_screen();
27 27
 
28 28
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -12,12 +12,12 @@
 block discarded – undo
12 12
 
13 13
 	public function init() {
14 14
 
15
-		add_action( 'admin_enqueue_scripts', array( $this, 'post_edit_screen' ) );
15
+		add_action('admin_enqueue_scripts', array($this, 'post_edit_screen'));
16 16
 	}
17 17
 
18
-	public function post_edit_screen( $hook ) {
18
+	public function post_edit_screen($hook) {
19 19
 
20
-		if ( 'post.php' === $hook || 'post-new.php' === $hook ) {
20
+		if ('post.php' === $hook || 'post-new.php' === $hook) {
21 21
 			$this->run_on_edit_post_screen();
22 22
 		}
23 23
 
Please login to merge, or discard this patch.
src/wordlift/common/term-checklist/class-term-checklist.php 2 patches
Indentation   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -10,36 +10,36 @@
 block discarded – undo
10 10
  */
11 11
 class Term_Checklist {
12 12
 
13
-	/**
14
-	 * @param $input_name string The name of the input field assigned to checkbox.
15
-	 * @param $terms array<\WP_Term>
16
-	 * @param $selected_term_slugs array<string> The list of selected term slugs.
17
-	 *
18
-	 * @return string Html string to be rendered.
19
-	 */
20
-	public static function render( $input_name, $terms, $selected_term_slugs ) {
21
-
22
-		$terms_html = '';
23
-
24
-		$input_name = esc_html( $input_name );
25
-
26
-		foreach ( $terms as $term ) {
27
-
28
-			/**
29
-			 * @var $term \WP_Term
30
-			 */
31
-			$term_name   = esc_html( $term->name );
32
-			$checked     = in_array( $term->slug, $selected_term_slugs, true ) ? 'checked' : '';
33
-			$terms_html .= "<li id=\"wl_entity_type-{$term->term_id}\">
13
+    /**
14
+     * @param $input_name string The name of the input field assigned to checkbox.
15
+     * @param $terms array<\WP_Term>
16
+     * @param $selected_term_slugs array<string> The list of selected term slugs.
17
+     *
18
+     * @return string Html string to be rendered.
19
+     */
20
+    public static function render( $input_name, $terms, $selected_term_slugs ) {
21
+
22
+        $terms_html = '';
23
+
24
+        $input_name = esc_html( $input_name );
25
+
26
+        foreach ( $terms as $term ) {
27
+
28
+            /**
29
+             * @var $term \WP_Term
30
+             */
31
+            $term_name   = esc_html( $term->name );
32
+            $checked     = in_array( $term->slug, $selected_term_slugs, true ) ? 'checked' : '';
33
+            $terms_html .= "<li id=\"wl_entity_type-{$term->term_id}\">
34 34
 	<label class=\"selectit\">
35 35
 	<input value=\"{$term->slug}\" type=\"checkbox\" name=\"{$input_name}[]\" id=\"in-wl_entity_type-{$term->term_id}\" $checked>
36 36
 		${term_name}
37 37
 	</label>
38 38
 </li>";
39 39
 
40
-		}
40
+        }
41 41
 
42
-		return '<input type="text" id="wl_entity_type_search" placeholder="Search Entity Types.." /><ul id="wl-entity-type__ul">' . $terms_html . '</ul>';
43
-	}
42
+        return '<input type="text" id="wl_entity_type_search" placeholder="Search Entity Types.." /><ul id="wl-entity-type__ul">' . $terms_html . '</ul>';
43
+    }
44 44
 
45 45
 }
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -17,19 +17,19 @@  discard block
 block discarded – undo
17 17
 	 *
18 18
 	 * @return string Html string to be rendered.
19 19
 	 */
20
-	public static function render( $input_name, $terms, $selected_term_slugs ) {
20
+	public static function render($input_name, $terms, $selected_term_slugs) {
21 21
 
22 22
 		$terms_html = '';
23 23
 
24
-		$input_name = esc_html( $input_name );
24
+		$input_name = esc_html($input_name);
25 25
 
26
-		foreach ( $terms as $term ) {
26
+		foreach ($terms as $term) {
27 27
 
28 28
 			/**
29 29
 			 * @var $term \WP_Term
30 30
 			 */
31
-			$term_name   = esc_html( $term->name );
32
-			$checked     = in_array( $term->slug, $selected_term_slugs, true ) ? 'checked' : '';
31
+			$term_name   = esc_html($term->name);
32
+			$checked     = in_array($term->slug, $selected_term_slugs, true) ? 'checked' : '';
33 33
 			$terms_html .= "<li id=\"wl_entity_type-{$term->term_id}\">
34 34
 	<label class=\"selectit\">
35 35
 	<input value=\"{$term->slug}\" type=\"checkbox\" name=\"{$input_name}[]\" id=\"in-wl_entity_type-{$term->term_id}\" $checked>
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 
40 40
 		}
41 41
 
42
-		return '<input type="text" id="wl_entity_type_search" placeholder="Search Entity Types.." /><ul id="wl-entity-type__ul">' . $terms_html . '</ul>';
42
+		return '<input type="text" id="wl_entity_type_search" placeholder="Search Entity Types.." /><ul id="wl-entity-type__ul">'.$terms_html.'</ul>';
43 43
 	}
44 44
 
45 45
 }
Please login to merge, or discard this patch.
src/wordlift/common/background-process/class-background-process.php 2 patches
Indentation   +196 added lines, -196 removed lines patch added patch discarded remove patch
@@ -3,201 +3,201 @@
 block discarded – undo
3 3
 namespace Wordlift\Common\Background_Process;
4 4
 
5 5
 abstract class Background_Process extends \Wordlift_Plugin_WP_Background_Process {
6
-	/**
7
-	 * @var \Wordlift_Log_Service
8
-	 */
9
-	private $log;
10
-	/**
11
-	 * @var Data_Source
12
-	 */
13
-	protected $data_source;
14
-
15
-	/**
16
-	 * Background_Process constructor.
17
-	 *
18
-	 * @param $data_source Data_Source
19
-	 */
20
-	public function __construct( $data_source ) {
21
-		parent::__construct();
22
-		$this->data_source = $data_source;
23
-		$this->log         = \Wordlift_Log_Service::get_logger( get_class() );
24
-		// Set value for action key.
25
-		$this->action = $this->get_action_key();
26
-	}
27
-
28
-	/**
29
-	 * The key which is used to store the Sync_State class for the current process
30
-	 *
31
-	 * @return string
32
-	 */
33
-	abstract protected function get_state_storage_key();
34
-
35
-	/**
36
-	 * The key which is used as prefix to store the options.
37
-	 *
38
-	 * @return string
39
-	 */
40
-	abstract protected function get_action_key();
41
-
42
-	/**
43
-	 * Check whether the process must cancel or not.
44
-	 *
45
-	 * @return bool Whether to cancel or not the process.
46
-	 */
47
-	private function must_cancel() {
48
-
49
-		return get_transient( "{$this->action}__cancel" );
50
-	}
51
-
52
-	/**
53
-	 * Check whether the provided state is `started` or not.
54
-	 *
55
-	 * @param Sync_State $state The {@link Sync_State}.
56
-	 *
57
-	 * @return bool True if the state is started.
58
-	 */
59
-	private function is_started( $state ) {
60
-		return $state instanceof Sync_State && 'started' === $state->state && 30 > ( time() - $state->last_update );
61
-	}
62
-
63
-	/**
64
-	 * Start the background processing.
65
-	 *
66
-	 * @return bool True if the process has been started, otherwise false.
67
-	 */
68
-	public function start() {
69
-		$action = $this->get_action_key();
70
-		$this->log->debug( "Trying to start  ${action}..." );
71
-		// Create a new Sync_Model state of `started`.
72
-		if ( ! $this->is_started( self::get_state() ) ) {
73
-			$this->log->debug( 'Starting...' );
74
-
75
-			$sync_state = new Sync_State( time(), 0, $this->data_source->count(), time(), 'started' );
76
-			update_option( $this->get_state_storage_key(), $sync_state, false );
77
-
78
-			$next = $this->data_source->next();
79
-
80
-			$this->push_to_queue( $next );
81
-			$this->save()->dispatch();
82
-
83
-			if ( $next && is_array( $next ) ) {
84
-				$this->log->debug( sprintf( 'Started with term IDs %s.', implode( ', ', $next ) ) );
85
-			}
86
-
87
-			return true;
88
-		}
89
-
90
-		return false;
91
-	}
92
-
93
-	/**
94
-	 * Cancels the current process.
95
-	 */
96
-	public function cancel() {
97
-
98
-		$action = $this->action;
99
-		$this->log->debug( "Cancelling ${action}..." );
100
-
101
-		// Cleanup the process data.
102
-		$this->cancel_process();
103
-
104
-		// Set the state to cancelled.
105
-		$state = $this->get_state();
106
-		$state->set_state( 'cancelled' );
107
-		update_option( $this->get_state_storage_key(), $state, false );
108
-
109
-		// Finally delete the transient.
110
-		delete_transient( "{$this->action}__cancel" );
111
-
112
-	}
113
-
114
-	/**
115
-	 * Get the sync state.
116
-	 *
117
-	 * @return Sync_State The {@link Sync_State}.
118
-	 */
119
-	public function get_state() {
120
-
121
-		try {
122
-			return get_option( $this->get_state_storage_key(), Sync_State::unknown() );
123
-		} catch ( \Exception $e ) {
124
-			return Sync_State::unknown();
125
-		}
126
-
127
-	}
128
-
129
-	/**
130
-	 * This function is called:
131
-	 *  - To start a new Synchronization, by passing a {@link Sync_Start_Message} instance.
132
-	 *  - To process a item, by passing a numeric ID.
133
-	 *
134
-	 * This function returns the parameter for the next call or NULL if there are no more items to process.
135
-	 *
136
-	 * @param int[] $items An array of item IDs.
137
-	 *
138
-	 * @return int[]|false The next IDs or false if there are no more.
139
-	 */
140
-	protected function task( $items ) {
141
-
142
-		// Check if we must cancel.
143
-		if ( $this->must_cancel() || ! $items ) {
144
-			$this->log->debug( 'Cancelling background process ' . $this->action . ' due to no items inside task() method' );
145
-			$this->cancel();
146
-
147
-			return false;
148
-		}
149
-
150
-		if ( $items && is_array( $items ) ) {
151
-			$this->log->debug( sprintf( 'Synchronizing items %s...', implode( ', ', $items ) ) );
152
-		}
153
-		// Sync the item.
154
-		if ( $this->process_items( $items ) ) {
155
-			// Update the process state, set the index in state in order
156
-			// to reflect the new items.
157
-			$this->update_batch_index();
158
-
159
-			// Get the next batch for processing.
160
-			return $this->get_next_batch();
161
-		} else {
162
-			// Return the failed term ids again.
163
-			return $items;
164
-		}
165
-	}
166
-
167
-	/**
168
-	 * Process all the items in the current batch.
169
-	 *
170
-	 * @param $items
171
-	 *
172
-	 * @return bool If all items are successfully processed.
173
-	 */
174
-	abstract protected function process_items( $items );
175
-
176
-	/**
177
-	 * Return next batch of items after processing.
178
-	 *
179
-	 * @return int[] or false
180
-	 */
181
-	protected function get_next_batch() {
182
-		return $this->data_source->next();
183
-	}
184
-
185
-	private function update_batch_index() {
186
-		$next = $this->data_source->next();
187
-
188
-		$next_state = isset( $next ) ? 'started' : 'ended';
189
-
190
-		/**
191
-		 * Update the synchronization meta data, by increasing the current index.
192
-		 *
193
-		 * @var Sync_State $sync The {@link Sync_State}.
194
-		 */
195
-		$state = self::get_state()
196
-					 ->increment_index( $this->data_source->get_batch_size() )
197
-					 ->set_state( $next_state );
198
-
199
-		update_option( $this->get_state_storage_key(), $state, false );
200
-
201
-	}
6
+    /**
7
+     * @var \Wordlift_Log_Service
8
+     */
9
+    private $log;
10
+    /**
11
+     * @var Data_Source
12
+     */
13
+    protected $data_source;
14
+
15
+    /**
16
+     * Background_Process constructor.
17
+     *
18
+     * @param $data_source Data_Source
19
+     */
20
+    public function __construct( $data_source ) {
21
+        parent::__construct();
22
+        $this->data_source = $data_source;
23
+        $this->log         = \Wordlift_Log_Service::get_logger( get_class() );
24
+        // Set value for action key.
25
+        $this->action = $this->get_action_key();
26
+    }
27
+
28
+    /**
29
+     * The key which is used to store the Sync_State class for the current process
30
+     *
31
+     * @return string
32
+     */
33
+    abstract protected function get_state_storage_key();
34
+
35
+    /**
36
+     * The key which is used as prefix to store the options.
37
+     *
38
+     * @return string
39
+     */
40
+    abstract protected function get_action_key();
41
+
42
+    /**
43
+     * Check whether the process must cancel or not.
44
+     *
45
+     * @return bool Whether to cancel or not the process.
46
+     */
47
+    private function must_cancel() {
48
+
49
+        return get_transient( "{$this->action}__cancel" );
50
+    }
51
+
52
+    /**
53
+     * Check whether the provided state is `started` or not.
54
+     *
55
+     * @param Sync_State $state The {@link Sync_State}.
56
+     *
57
+     * @return bool True if the state is started.
58
+     */
59
+    private function is_started( $state ) {
60
+        return $state instanceof Sync_State && 'started' === $state->state && 30 > ( time() - $state->last_update );
61
+    }
62
+
63
+    /**
64
+     * Start the background processing.
65
+     *
66
+     * @return bool True if the process has been started, otherwise false.
67
+     */
68
+    public function start() {
69
+        $action = $this->get_action_key();
70
+        $this->log->debug( "Trying to start  ${action}..." );
71
+        // Create a new Sync_Model state of `started`.
72
+        if ( ! $this->is_started( self::get_state() ) ) {
73
+            $this->log->debug( 'Starting...' );
74
+
75
+            $sync_state = new Sync_State( time(), 0, $this->data_source->count(), time(), 'started' );
76
+            update_option( $this->get_state_storage_key(), $sync_state, false );
77
+
78
+            $next = $this->data_source->next();
79
+
80
+            $this->push_to_queue( $next );
81
+            $this->save()->dispatch();
82
+
83
+            if ( $next && is_array( $next ) ) {
84
+                $this->log->debug( sprintf( 'Started with term IDs %s.', implode( ', ', $next ) ) );
85
+            }
86
+
87
+            return true;
88
+        }
89
+
90
+        return false;
91
+    }
92
+
93
+    /**
94
+     * Cancels the current process.
95
+     */
96
+    public function cancel() {
97
+
98
+        $action = $this->action;
99
+        $this->log->debug( "Cancelling ${action}..." );
100
+
101
+        // Cleanup the process data.
102
+        $this->cancel_process();
103
+
104
+        // Set the state to cancelled.
105
+        $state = $this->get_state();
106
+        $state->set_state( 'cancelled' );
107
+        update_option( $this->get_state_storage_key(), $state, false );
108
+
109
+        // Finally delete the transient.
110
+        delete_transient( "{$this->action}__cancel" );
111
+
112
+    }
113
+
114
+    /**
115
+     * Get the sync state.
116
+     *
117
+     * @return Sync_State The {@link Sync_State}.
118
+     */
119
+    public function get_state() {
120
+
121
+        try {
122
+            return get_option( $this->get_state_storage_key(), Sync_State::unknown() );
123
+        } catch ( \Exception $e ) {
124
+            return Sync_State::unknown();
125
+        }
126
+
127
+    }
128
+
129
+    /**
130
+     * This function is called:
131
+     *  - To start a new Synchronization, by passing a {@link Sync_Start_Message} instance.
132
+     *  - To process a item, by passing a numeric ID.
133
+     *
134
+     * This function returns the parameter for the next call or NULL if there are no more items to process.
135
+     *
136
+     * @param int[] $items An array of item IDs.
137
+     *
138
+     * @return int[]|false The next IDs or false if there are no more.
139
+     */
140
+    protected function task( $items ) {
141
+
142
+        // Check if we must cancel.
143
+        if ( $this->must_cancel() || ! $items ) {
144
+            $this->log->debug( 'Cancelling background process ' . $this->action . ' due to no items inside task() method' );
145
+            $this->cancel();
146
+
147
+            return false;
148
+        }
149
+
150
+        if ( $items && is_array( $items ) ) {
151
+            $this->log->debug( sprintf( 'Synchronizing items %s...', implode( ', ', $items ) ) );
152
+        }
153
+        // Sync the item.
154
+        if ( $this->process_items( $items ) ) {
155
+            // Update the process state, set the index in state in order
156
+            // to reflect the new items.
157
+            $this->update_batch_index();
158
+
159
+            // Get the next batch for processing.
160
+            return $this->get_next_batch();
161
+        } else {
162
+            // Return the failed term ids again.
163
+            return $items;
164
+        }
165
+    }
166
+
167
+    /**
168
+     * Process all the items in the current batch.
169
+     *
170
+     * @param $items
171
+     *
172
+     * @return bool If all items are successfully processed.
173
+     */
174
+    abstract protected function process_items( $items );
175
+
176
+    /**
177
+     * Return next batch of items after processing.
178
+     *
179
+     * @return int[] or false
180
+     */
181
+    protected function get_next_batch() {
182
+        return $this->data_source->next();
183
+    }
184
+
185
+    private function update_batch_index() {
186
+        $next = $this->data_source->next();
187
+
188
+        $next_state = isset( $next ) ? 'started' : 'ended';
189
+
190
+        /**
191
+         * Update the synchronization meta data, by increasing the current index.
192
+         *
193
+         * @var Sync_State $sync The {@link Sync_State}.
194
+         */
195
+        $state = self::get_state()
196
+                        ->increment_index( $this->data_source->get_batch_size() )
197
+                        ->set_state( $next_state );
198
+
199
+        update_option( $this->get_state_storage_key(), $state, false );
200
+
201
+    }
202 202
 
203 203
 }
Please login to merge, or discard this patch.
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -17,10 +17,10 @@  discard block
 block discarded – undo
17 17
 	 *
18 18
 	 * @param $data_source Data_Source
19 19
 	 */
20
-	public function __construct( $data_source ) {
20
+	public function __construct($data_source) {
21 21
 		parent::__construct();
22 22
 		$this->data_source = $data_source;
23
-		$this->log         = \Wordlift_Log_Service::get_logger( get_class() );
23
+		$this->log         = \Wordlift_Log_Service::get_logger(get_class());
24 24
 		// Set value for action key.
25 25
 		$this->action = $this->get_action_key();
26 26
 	}
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 	 */
47 47
 	private function must_cancel() {
48 48
 
49
-		return get_transient( "{$this->action}__cancel" );
49
+		return get_transient("{$this->action}__cancel");
50 50
 	}
51 51
 
52 52
 	/**
@@ -56,8 +56,8 @@  discard block
 block discarded – undo
56 56
 	 *
57 57
 	 * @return bool True if the state is started.
58 58
 	 */
59
-	private function is_started( $state ) {
60
-		return $state instanceof Sync_State && 'started' === $state->state && 30 > ( time() - $state->last_update );
59
+	private function is_started($state) {
60
+		return $state instanceof Sync_State && 'started' === $state->state && 30 > (time() - $state->last_update);
61 61
 	}
62 62
 
63 63
 	/**
@@ -67,21 +67,21 @@  discard block
 block discarded – undo
67 67
 	 */
68 68
 	public function start() {
69 69
 		$action = $this->get_action_key();
70
-		$this->log->debug( "Trying to start  ${action}..." );
70
+		$this->log->debug("Trying to start  ${action}...");
71 71
 		// Create a new Sync_Model state of `started`.
72
-		if ( ! $this->is_started( self::get_state() ) ) {
73
-			$this->log->debug( 'Starting...' );
72
+		if ( ! $this->is_started(self::get_state())) {
73
+			$this->log->debug('Starting...');
74 74
 
75
-			$sync_state = new Sync_State( time(), 0, $this->data_source->count(), time(), 'started' );
76
-			update_option( $this->get_state_storage_key(), $sync_state, false );
75
+			$sync_state = new Sync_State(time(), 0, $this->data_source->count(), time(), 'started');
76
+			update_option($this->get_state_storage_key(), $sync_state, false);
77 77
 
78 78
 			$next = $this->data_source->next();
79 79
 
80
-			$this->push_to_queue( $next );
80
+			$this->push_to_queue($next);
81 81
 			$this->save()->dispatch();
82 82
 
83
-			if ( $next && is_array( $next ) ) {
84
-				$this->log->debug( sprintf( 'Started with term IDs %s.', implode( ', ', $next ) ) );
83
+			if ($next && is_array($next)) {
84
+				$this->log->debug(sprintf('Started with term IDs %s.', implode(', ', $next)));
85 85
 			}
86 86
 
87 87
 			return true;
@@ -96,18 +96,18 @@  discard block
 block discarded – undo
96 96
 	public function cancel() {
97 97
 
98 98
 		$action = $this->action;
99
-		$this->log->debug( "Cancelling ${action}..." );
99
+		$this->log->debug("Cancelling ${action}...");
100 100
 
101 101
 		// Cleanup the process data.
102 102
 		$this->cancel_process();
103 103
 
104 104
 		// Set the state to cancelled.
105 105
 		$state = $this->get_state();
106
-		$state->set_state( 'cancelled' );
107
-		update_option( $this->get_state_storage_key(), $state, false );
106
+		$state->set_state('cancelled');
107
+		update_option($this->get_state_storage_key(), $state, false);
108 108
 
109 109
 		// Finally delete the transient.
110
-		delete_transient( "{$this->action}__cancel" );
110
+		delete_transient("{$this->action}__cancel");
111 111
 
112 112
 	}
113 113
 
@@ -119,8 +119,8 @@  discard block
 block discarded – undo
119 119
 	public function get_state() {
120 120
 
121 121
 		try {
122
-			return get_option( $this->get_state_storage_key(), Sync_State::unknown() );
123
-		} catch ( \Exception $e ) {
122
+			return get_option($this->get_state_storage_key(), Sync_State::unknown());
123
+		} catch (\Exception $e) {
124 124
 			return Sync_State::unknown();
125 125
 		}
126 126
 
@@ -137,21 +137,21 @@  discard block
 block discarded – undo
137 137
 	 *
138 138
 	 * @return int[]|false The next IDs or false if there are no more.
139 139
 	 */
140
-	protected function task( $items ) {
140
+	protected function task($items) {
141 141
 
142 142
 		// Check if we must cancel.
143
-		if ( $this->must_cancel() || ! $items ) {
144
-			$this->log->debug( 'Cancelling background process ' . $this->action . ' due to no items inside task() method' );
143
+		if ($this->must_cancel() || ! $items) {
144
+			$this->log->debug('Cancelling background process '.$this->action.' due to no items inside task() method');
145 145
 			$this->cancel();
146 146
 
147 147
 			return false;
148 148
 		}
149 149
 
150
-		if ( $items && is_array( $items ) ) {
151
-			$this->log->debug( sprintf( 'Synchronizing items %s...', implode( ', ', $items ) ) );
150
+		if ($items && is_array($items)) {
151
+			$this->log->debug(sprintf('Synchronizing items %s...', implode(', ', $items)));
152 152
 		}
153 153
 		// Sync the item.
154
-		if ( $this->process_items( $items ) ) {
154
+		if ($this->process_items($items)) {
155 155
 			// Update the process state, set the index in state in order
156 156
 			// to reflect the new items.
157 157
 			$this->update_batch_index();
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
 	 *
172 172
 	 * @return bool If all items are successfully processed.
173 173
 	 */
174
-	abstract protected function process_items( $items );
174
+	abstract protected function process_items($items);
175 175
 
176 176
 	/**
177 177
 	 * Return next batch of items after processing.
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
 	private function update_batch_index() {
186 186
 		$next = $this->data_source->next();
187 187
 
188
-		$next_state = isset( $next ) ? 'started' : 'ended';
188
+		$next_state = isset($next) ? 'started' : 'ended';
189 189
 
190 190
 		/**
191 191
 		 * Update the synchronization meta data, by increasing the current index.
@@ -193,10 +193,10 @@  discard block
 block discarded – undo
193 193
 		 * @var Sync_State $sync The {@link Sync_State}.
194 194
 		 */
195 195
 		$state = self::get_state()
196
-					 ->increment_index( $this->data_source->get_batch_size() )
197
-					 ->set_state( $next_state );
196
+					 ->increment_index($this->data_source->get_batch_size())
197
+					 ->set_state($next_state);
198 198
 
199
-		update_option( $this->get_state_storage_key(), $state, false );
199
+		update_option($this->get_state_storage_key(), $state, false);
200 200
 
201 201
 	}
202 202
 
Please login to merge, or discard this patch.
src/wordlift/common/loader/class-loader.php 1 patch
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -9,11 +9,11 @@
 block discarded – undo
9 9
 
10 10
 interface Loader {
11 11
 
12
-	/**
13
-	 * The loader should register the feature to feature registry.
14
-	 *
15
-	 * @return void
16
-	 */
17
-	public function init_feature();
12
+    /**
13
+     * The loader should register the feature to feature registry.
14
+     *
15
+     * @return void
16
+     */
17
+    public function init_feature();
18 18
 
19 19
 }
Please login to merge, or discard this patch.
src/wordlift-editor.php 2 patches
Indentation   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -9,32 +9,32 @@  discard block
 block discarded – undo
9 9
  */
10 10
 function wordlift_mce_css( $mce_css ) {
11 11
 
12
-	/*
12
+    /*
13 13
 	 * Call the `wl_can_see_classification_box` filter to determine whether we can display the classification box.
14 14
 	 *
15 15
 	 * @since 3.20.3
16 16
 	 *
17 17
 	 * @see https://github.com/insideout10/wordlift-plugin/issues/914
18 18
 	 */
19
-	if ( ! apply_filters( 'wl_can_see_classification_box', true ) ) {
20
-		return $mce_css;
21
-	}
22
-
23
-	if ( ! empty( $mce_css ) ) {
24
-		$mce_css .= ',';
25
-	}
26
-
27
-	/**
28
-	 * Replacing the legacy `wordlift-reloaded.min.css` with tiny-mce.css.
29
-	 *
30
-	 * tiny-mce.css is generated using the new webpack project and its rules are shared with Gutenberg.
31
-	 *
32
-	 * @author David Riccitelli <[email protected]>
33
-	 * @since 3.23.0
34
-	 */
35
-	$mce_css .= plugin_dir_url( __FILE__ ) . 'js/dist/tiny-mce.css';
36
-
37
-	return $mce_css;
19
+    if ( ! apply_filters( 'wl_can_see_classification_box', true ) ) {
20
+        return $mce_css;
21
+    }
22
+
23
+    if ( ! empty( $mce_css ) ) {
24
+        $mce_css .= ',';
25
+    }
26
+
27
+    /**
28
+     * Replacing the legacy `wordlift-reloaded.min.css` with tiny-mce.css.
29
+     *
30
+     * tiny-mce.css is generated using the new webpack project and its rules are shared with Gutenberg.
31
+     *
32
+     * @author David Riccitelli <[email protected]>
33
+     * @since 3.23.0
34
+     */
35
+    $mce_css .= plugin_dir_url( __FILE__ ) . 'js/dist/tiny-mce.css';
36
+
37
+    return $mce_css;
38 38
 }
39 39
 
40 40
 // hook the TinyMCE custom styles function.
@@ -49,13 +49,13 @@  discard block
 block discarded – undo
49 49
  */
50 50
 function wordlift_filter_tiny_mce_before_init( $options ) {
51 51
 
52
-	if ( ! isset( $options['extended_valid_elements'] ) ) {
53
-		$options['extended_valid_elements'] = '';
54
-	}
52
+    if ( ! isset( $options['extended_valid_elements'] ) ) {
53
+        $options['extended_valid_elements'] = '';
54
+    }
55 55
 
56
-	$options['extended_valid_elements'] .= ',span[*]';
56
+    $options['extended_valid_elements'] .= ',span[*]';
57 57
 
58
-	return $options;
58
+    return $options;
59 59
 }
60 60
 
61 61
 add_filter( 'tiny_mce_before_init', 'wordlift_filter_tiny_mce_before_init', PHP_INT_MAX );
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
  *
8 8
  * @return string The updated list of styles, including the custom style provided by WordLift.
9 9
  */
10
-function wordlift_mce_css( $mce_css ) {
10
+function wordlift_mce_css($mce_css) {
11 11
 
12 12
 	/*
13 13
 	 * Call the `wl_can_see_classification_box` filter to determine whether we can display the classification box.
@@ -16,11 +16,11 @@  discard block
 block discarded – undo
16 16
 	 *
17 17
 	 * @see https://github.com/insideout10/wordlift-plugin/issues/914
18 18
 	 */
19
-	if ( ! apply_filters( 'wl_can_see_classification_box', true ) ) {
19
+	if ( ! apply_filters('wl_can_see_classification_box', true)) {
20 20
 		return $mce_css;
21 21
 	}
22 22
 
23
-	if ( ! empty( $mce_css ) ) {
23
+	if ( ! empty($mce_css)) {
24 24
 		$mce_css .= ',';
25 25
 	}
26 26
 
@@ -32,13 +32,13 @@  discard block
 block discarded – undo
32 32
 	 * @author David Riccitelli <[email protected]>
33 33
 	 * @since 3.23.0
34 34
 	 */
35
-	$mce_css .= plugin_dir_url( __FILE__ ) . 'js/dist/tiny-mce.css';
35
+	$mce_css .= plugin_dir_url(__FILE__).'js/dist/tiny-mce.css';
36 36
 
37 37
 	return $mce_css;
38 38
 }
39 39
 
40 40
 // hook the TinyMCE custom styles function.
41
-add_filter( 'mce_css', 'wordlift_mce_css' );
41
+add_filter('mce_css', 'wordlift_mce_css');
42 42
 
43 43
 /**
44 44
  * Set TinyMCE options, in particular enable microdata tagging.
@@ -47,9 +47,9 @@  discard block
 block discarded – undo
47 47
  *
48 48
  * @return mixed
49 49
  */
50
-function wordlift_filter_tiny_mce_before_init( $options ) {
50
+function wordlift_filter_tiny_mce_before_init($options) {
51 51
 
52
-	if ( ! isset( $options['extended_valid_elements'] ) ) {
52
+	if ( ! isset($options['extended_valid_elements'])) {
53 53
 		$options['extended_valid_elements'] = '';
54 54
 	}
55 55
 
@@ -58,4 +58,4 @@  discard block
 block discarded – undo
58 58
 	return $options;
59 59
 }
60 60
 
61
-add_filter( 'tiny_mce_before_init', 'wordlift_filter_tiny_mce_before_init', PHP_INT_MAX );
61
+add_filter('tiny_mce_before_init', 'wordlift_filter_tiny_mce_before_init', PHP_INT_MAX);
Please login to merge, or discard this patch.