Completed
Push — develop ( 36a199...920e68 )
by David
01:14
created
src/install/class-wordlift-install-3-49-2.php 2 patches
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -5,20 +5,20 @@
 block discarded – undo
5 5
  */
6 6
 class Wordlift_Install_3_49_2 extends Wordlift_Install {
7 7
 
8
-	/**
9
-	 * {@inheritdoc}
10
-	 */
11
-	protected static $version = '3.49.2';
8
+    /**
9
+     * {@inheritdoc}
10
+     */
11
+    protected static $version = '3.49.2';
12 12
 
13
-	public function install() {
13
+    public function install() {
14 14
 
15
-		global $wpdb;
15
+        global $wpdb;
16 16
 
17
-		$wpdb->query( "DELETE FROM $wpdb->termmeta WHERE meta_key = 'wl_mentions_count'" );
18
-		$wpdb->query( "DELETE FROM $wpdb->termmeta WHERE meta_key = 'wl_about_count'" );
19
-		$wpdb->query( "DELETE FROM $wpdb->postmeta WHERE meta_key = 'wl_mentions_count'" );
20
-		$wpdb->query( "DELETE FROM $wpdb->postmeta WHERE meta_key = 'wl_about_count'" );
17
+        $wpdb->query( "DELETE FROM $wpdb->termmeta WHERE meta_key = 'wl_mentions_count'" );
18
+        $wpdb->query( "DELETE FROM $wpdb->termmeta WHERE meta_key = 'wl_about_count'" );
19
+        $wpdb->query( "DELETE FROM $wpdb->postmeta WHERE meta_key = 'wl_mentions_count'" );
20
+        $wpdb->query( "DELETE FROM $wpdb->postmeta WHERE meta_key = 'wl_about_count'" );
21 21
 
22
-	}
22
+    }
23 23
 
24 24
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -14,10 +14,10 @@
 block discarded – undo
14 14
 
15 15
 		global $wpdb;
16 16
 
17
-		$wpdb->query( "DELETE FROM $wpdb->termmeta WHERE meta_key = 'wl_mentions_count'" );
18
-		$wpdb->query( "DELETE FROM $wpdb->termmeta WHERE meta_key = 'wl_about_count'" );
19
-		$wpdb->query( "DELETE FROM $wpdb->postmeta WHERE meta_key = 'wl_mentions_count'" );
20
-		$wpdb->query( "DELETE FROM $wpdb->postmeta WHERE meta_key = 'wl_about_count'" );
17
+		$wpdb->query("DELETE FROM $wpdb->termmeta WHERE meta_key = 'wl_mentions_count'");
18
+		$wpdb->query("DELETE FROM $wpdb->termmeta WHERE meta_key = 'wl_about_count'");
19
+		$wpdb->query("DELETE FROM $wpdb->postmeta WHERE meta_key = 'wl_mentions_count'");
20
+		$wpdb->query("DELETE FROM $wpdb->postmeta WHERE meta_key = 'wl_about_count'");
21 21
 
22 22
 	}
23 23
 
Please login to merge, or discard this patch.
src/install/class-wordlift-install-service.php 2 patches
Indentation   +193 added lines, -193 removed lines patch added patch discarded remove patch
@@ -18,201 +18,201 @@
 block discarded – undo
18 18
  */
19 19
 class Wordlift_Install_Service {
20 20
 
21
-	/**
22
-	 * A {@link Wordlift_Log_Service} instance.
23
-	 *
24
-	 * @since  3.18.0
25
-	 * @access private
26
-	 * @var \Wordlift_Log_Service $log A {@link Wordlift_Log_Service} instance.
27
-	 */
28
-	private $log;
29
-
30
-	/**
31
-	 * The singleton instance.
32
-	 *
33
-	 * @since  3.18.0
34
-	 * @access private
35
-	 * @var \Wordlift_Install_Service $instance A {@link Wordlift_Install_Service} instance.
36
-	 */
37
-	private static $instance;
38
-
39
-	/**
40
-	 * @var array
41
-	 */
42
-	private $installs;
43
-
44
-	/**
45
-	 * Wordlift_Install_Service constructor.
46
-	 *
47
-	 * @since 3.18.0
48
-	 */
49
-	public function __construct() {
50
-
51
-		/** Installs. */
52
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install.php';
53
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-1-0-0.php';
54
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-10-0.php';
55
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-12-0.php';
56
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-14-0.php';
57
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-15-0.php';
58
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-18-0.php';
59
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-18-3.php';
60
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-19-5.php';
61
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-20-0.php';
62
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-23-4.php';
63
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-24-2.php';
64
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-all-entity-types.php';
65
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-package-type.php';
66
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-25-0.php';
67
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-27-0.php';
68
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-27-1.php';
69
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-28-0.php';
70
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-32-0.php';
71
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-33-9.php';
72
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-36-0.php';
73
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-38-5.php';
74
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-39-1.php';
75
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-40-1.php';
76
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-40-2.php';
77
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-41-0.php';
78
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-42-0.php';
79
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-44-1.php';
80
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-44-4.php';
81
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-45-0.php';
82
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-45-1.php';
83
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-49-2.php';
84
-
85
-		// Get the install services.
86
-		$this->installs = array(
87
-			new Wordlift_Install_1_0_0(),
88
-			new Wordlift_Install_3_10_0(),
89
-			new Wordlift_Install_3_12_0(),
90
-			new Wordlift_Install_3_14_0(),
91
-			new Wordlift_Install_3_15_0(),
92
-			new Wordlift_Install_3_18_0(),
93
-			new Wordlift_Install_3_18_3(),
94
-			new Wordlift_Install_3_19_5(),
95
-			new Wordlift_Install_3_20_0(),
96
-
97
-			/*
21
+    /**
22
+     * A {@link Wordlift_Log_Service} instance.
23
+     *
24
+     * @since  3.18.0
25
+     * @access private
26
+     * @var \Wordlift_Log_Service $log A {@link Wordlift_Log_Service} instance.
27
+     */
28
+    private $log;
29
+
30
+    /**
31
+     * The singleton instance.
32
+     *
33
+     * @since  3.18.0
34
+     * @access private
35
+     * @var \Wordlift_Install_Service $instance A {@link Wordlift_Install_Service} instance.
36
+     */
37
+    private static $instance;
38
+
39
+    /**
40
+     * @var array
41
+     */
42
+    private $installs;
43
+
44
+    /**
45
+     * Wordlift_Install_Service constructor.
46
+     *
47
+     * @since 3.18.0
48
+     */
49
+    public function __construct() {
50
+
51
+        /** Installs. */
52
+        require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install.php';
53
+        require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-1-0-0.php';
54
+        require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-10-0.php';
55
+        require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-12-0.php';
56
+        require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-14-0.php';
57
+        require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-15-0.php';
58
+        require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-18-0.php';
59
+        require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-18-3.php';
60
+        require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-19-5.php';
61
+        require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-20-0.php';
62
+        require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-23-4.php';
63
+        require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-24-2.php';
64
+        require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-all-entity-types.php';
65
+        require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-package-type.php';
66
+        require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-25-0.php';
67
+        require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-27-0.php';
68
+        require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-27-1.php';
69
+        require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-28-0.php';
70
+        require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-32-0.php';
71
+        require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-33-9.php';
72
+        require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-36-0.php';
73
+        require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-38-5.php';
74
+        require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-39-1.php';
75
+        require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-40-1.php';
76
+        require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-40-2.php';
77
+        require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-41-0.php';
78
+        require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-42-0.php';
79
+        require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-44-1.php';
80
+        require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-44-4.php';
81
+        require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-45-0.php';
82
+        require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-45-1.php';
83
+        require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-49-2.php';
84
+
85
+        // Get the install services.
86
+        $this->installs = array(
87
+            new Wordlift_Install_1_0_0(),
88
+            new Wordlift_Install_3_10_0(),
89
+            new Wordlift_Install_3_12_0(),
90
+            new Wordlift_Install_3_14_0(),
91
+            new Wordlift_Install_3_15_0(),
92
+            new Wordlift_Install_3_18_0(),
93
+            new Wordlift_Install_3_18_3(),
94
+            new Wordlift_Install_3_19_5(),
95
+            new Wordlift_Install_3_20_0(),
96
+
97
+            /*
98 98
 			 * This should be enabled with #852.
99 99
 			 */
100
-			new Wordlift_Install_Package_Type(),
101
-			new Wordlift_Install_3_23_4(),
102
-			new Wordlift_Install_3_24_2(),
103
-			new Wordlift_Install_3_25_0(),
104
-			new Wordlift_Install_3_27_0(),
105
-			new Wordlift_Install_3_27_1(),
106
-			new Wordlift_Install_3_28_0(),
107
-			// Add column to represent term
108
-			new Wordlift_Install_3_32_0(),
109
-			// Add the entities table.
110
-			new Wordlift_Install_3_33_9(),
111
-			// When woocommerce extension installed, acf4so should be installed automatically.
112
-			new Wordlift_Install_3_36_0(),
113
-
114
-			new Wordlift_Install_3_38_5(),
115
-			new Wordlift_Install_3_39_1(),
116
-
117
-			// See #1621.
118
-			new Wordlift_Install_3_40_1(),
119
-
120
-			// @link https://github.com/insideout10/wordlift-plugin/issues/1627
121
-			new Wordlift_Install_3_40_2(),
122
-
123
-			new Wordlift_Install_3_41_0(),
124
-			new Wordlift_Install_3_42_0(),
125
-
126
-			new Wordlift_Install_3_44_1(),
127
-			new Wordlift_Install_3_44_4(),
128
-
129
-			new Wordlift_Install_3_45_0(),
130
-			new Wordlift_Install_3_45_1(),
131
-
132
-			new Wordlift_Install_3_49_2(),
133
-		);
134
-		self::$instance = $this;
135
-
136
-		$this->log = Wordlift_Log_Service::get_logger( get_class() );
137
-
138
-		add_action( 'init', array( $this, 'install' ) );
139
-
140
-	}
141
-
142
-	/**
143
-	 * Get the singleton instance.
144
-	 *
145
-	 * @since 3.18.0
146
-	 */
147
-	public static function get_instance() {
148
-
149
-		return self::$instance;
150
-	}
151
-
152
-	/**
153
-	 * Loop thought all versions and install the updates.
154
-	 *
155
-	 * @return void
156
-	 * @since 3.18.0
157
-	 *
158
-	 * @since 3.20.0 use a transient to avoid concurrent installation calls.
159
-	 */
160
-	public function install() {
161
-
162
-		$version = null;
163
-
164
-		if ( $this->install_required() && false === get_transient( '_wl_installing' ) ) {
165
-			set_transient( '_wl_installing', true, 5 * MINUTE_IN_SECONDS );
166
-			/** @var Wordlift_Install $install */
167
-			foreach ( $this->installs as $install ) {
168
-				// Get the install version.
169
-				$version = $install->get_version();
170
-
171
-				if ( version_compare( $version, $this->get_current_version(), '>' )
172
-					 || $install->must_install() ) {
173
-					$class_name = get_class( $install );
174
-
175
-					$this->log->info( "Current version is {$this->get_current_version()}, installing $class_name..." );
176
-					// Install version.
177
-					$install->install();
178
-
179
-					$this->log->info( "$class_name installed." );
180
-
181
-					// Bump the version.
182
-					update_option( 'wl_db_version', $version );
183
-				}
184
-			}
185
-
186
-			// phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged
187
-			@delete_transient( '_wl_installing' );
188
-
189
-		}
190
-
191
-	}
192
-
193
-	private function install_required() {
194
-
195
-		/** @var Wordlift_Install $install */
196
-		foreach ( $this->installs as $install ) {
197
-			// Get the install version.
198
-			$version = $install->get_version();
199
-
200
-			if ( version_compare( $version, $this->get_current_version(), '>' )
201
-				 || $install->must_install() ) {
202
-				return true;
203
-			}
204
-		}
205
-
206
-		return false;
207
-	}
100
+            new Wordlift_Install_Package_Type(),
101
+            new Wordlift_Install_3_23_4(),
102
+            new Wordlift_Install_3_24_2(),
103
+            new Wordlift_Install_3_25_0(),
104
+            new Wordlift_Install_3_27_0(),
105
+            new Wordlift_Install_3_27_1(),
106
+            new Wordlift_Install_3_28_0(),
107
+            // Add column to represent term
108
+            new Wordlift_Install_3_32_0(),
109
+            // Add the entities table.
110
+            new Wordlift_Install_3_33_9(),
111
+            // When woocommerce extension installed, acf4so should be installed automatically.
112
+            new Wordlift_Install_3_36_0(),
113
+
114
+            new Wordlift_Install_3_38_5(),
115
+            new Wordlift_Install_3_39_1(),
116
+
117
+            // See #1621.
118
+            new Wordlift_Install_3_40_1(),
119
+
120
+            // @link https://github.com/insideout10/wordlift-plugin/issues/1627
121
+            new Wordlift_Install_3_40_2(),
122
+
123
+            new Wordlift_Install_3_41_0(),
124
+            new Wordlift_Install_3_42_0(),
125
+
126
+            new Wordlift_Install_3_44_1(),
127
+            new Wordlift_Install_3_44_4(),
128
+
129
+            new Wordlift_Install_3_45_0(),
130
+            new Wordlift_Install_3_45_1(),
131
+
132
+            new Wordlift_Install_3_49_2(),
133
+        );
134
+        self::$instance = $this;
135
+
136
+        $this->log = Wordlift_Log_Service::get_logger( get_class() );
137
+
138
+        add_action( 'init', array( $this, 'install' ) );
139
+
140
+    }
141
+
142
+    /**
143
+     * Get the singleton instance.
144
+     *
145
+     * @since 3.18.0
146
+     */
147
+    public static function get_instance() {
148
+
149
+        return self::$instance;
150
+    }
151
+
152
+    /**
153
+     * Loop thought all versions and install the updates.
154
+     *
155
+     * @return void
156
+     * @since 3.18.0
157
+     *
158
+     * @since 3.20.0 use a transient to avoid concurrent installation calls.
159
+     */
160
+    public function install() {
161
+
162
+        $version = null;
163
+
164
+        if ( $this->install_required() && false === get_transient( '_wl_installing' ) ) {
165
+            set_transient( '_wl_installing', true, 5 * MINUTE_IN_SECONDS );
166
+            /** @var Wordlift_Install $install */
167
+            foreach ( $this->installs as $install ) {
168
+                // Get the install version.
169
+                $version = $install->get_version();
170
+
171
+                if ( version_compare( $version, $this->get_current_version(), '>' )
172
+                     || $install->must_install() ) {
173
+                    $class_name = get_class( $install );
174
+
175
+                    $this->log->info( "Current version is {$this->get_current_version()}, installing $class_name..." );
176
+                    // Install version.
177
+                    $install->install();
178
+
179
+                    $this->log->info( "$class_name installed." );
180
+
181
+                    // Bump the version.
182
+                    update_option( 'wl_db_version', $version );
183
+                }
184
+            }
185
+
186
+            // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged
187
+            @delete_transient( '_wl_installing' );
188
+
189
+        }
190
+
191
+    }
192
+
193
+    private function install_required() {
194
+
195
+        /** @var Wordlift_Install $install */
196
+        foreach ( $this->installs as $install ) {
197
+            // Get the install version.
198
+            $version = $install->get_version();
199
+
200
+            if ( version_compare( $version, $this->get_current_version(), '>' )
201
+                 || $install->must_install() ) {
202
+                return true;
203
+            }
204
+        }
205
+
206
+        return false;
207
+    }
208 208
 
209
-	/**
210
-	 * Retrieve the current db version.
211
-	 *
212
-	 * @return type
213
-	 */
214
-	private function get_current_version() {
215
-		return get_option( 'wl_db_version', '0.0.0' );
216
-	}
209
+    /**
210
+     * Retrieve the current db version.
211
+     *
212
+     * @return type
213
+     */
214
+    private function get_current_version() {
215
+        return get_option( 'wl_db_version', '0.0.0' );
216
+    }
217 217
 
218 218
 }
Please login to merge, or discard this patch.
Spacing   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -49,38 +49,38 @@  discard block
 block discarded – undo
49 49
 	public function __construct() {
50 50
 
51 51
 		/** Installs. */
52
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install.php';
53
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-1-0-0.php';
54
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-10-0.php';
55
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-12-0.php';
56
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-14-0.php';
57
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-15-0.php';
58
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-18-0.php';
59
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-18-3.php';
60
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-19-5.php';
61
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-20-0.php';
62
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-23-4.php';
63
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-24-2.php';
64
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-all-entity-types.php';
65
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-package-type.php';
66
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-25-0.php';
67
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-27-0.php';
68
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-27-1.php';
69
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-28-0.php';
70
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-32-0.php';
71
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-33-9.php';
72
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-36-0.php';
73
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-38-5.php';
74
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-39-1.php';
75
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-40-1.php';
76
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-40-2.php';
77
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-41-0.php';
78
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-42-0.php';
79
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-44-1.php';
80
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-44-4.php';
81
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-45-0.php';
82
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-45-1.php';
83
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-49-2.php';
52
+		require_once plugin_dir_path(__DIR__).'install/class-wordlift-install.php';
53
+		require_once plugin_dir_path(__DIR__).'install/class-wordlift-install-1-0-0.php';
54
+		require_once plugin_dir_path(__DIR__).'install/class-wordlift-install-3-10-0.php';
55
+		require_once plugin_dir_path(__DIR__).'install/class-wordlift-install-3-12-0.php';
56
+		require_once plugin_dir_path(__DIR__).'install/class-wordlift-install-3-14-0.php';
57
+		require_once plugin_dir_path(__DIR__).'install/class-wordlift-install-3-15-0.php';
58
+		require_once plugin_dir_path(__DIR__).'install/class-wordlift-install-3-18-0.php';
59
+		require_once plugin_dir_path(__DIR__).'install/class-wordlift-install-3-18-3.php';
60
+		require_once plugin_dir_path(__DIR__).'install/class-wordlift-install-3-19-5.php';
61
+		require_once plugin_dir_path(__DIR__).'install/class-wordlift-install-3-20-0.php';
62
+		require_once plugin_dir_path(__DIR__).'install/class-wordlift-install-3-23-4.php';
63
+		require_once plugin_dir_path(__DIR__).'install/class-wordlift-install-3-24-2.php';
64
+		require_once plugin_dir_path(__DIR__).'install/class-wordlift-install-all-entity-types.php';
65
+		require_once plugin_dir_path(__DIR__).'install/class-wordlift-install-package-type.php';
66
+		require_once plugin_dir_path(__DIR__).'install/class-wordlift-install-3-25-0.php';
67
+		require_once plugin_dir_path(__DIR__).'install/class-wordlift-install-3-27-0.php';
68
+		require_once plugin_dir_path(__DIR__).'install/class-wordlift-install-3-27-1.php';
69
+		require_once plugin_dir_path(__DIR__).'install/class-wordlift-install-3-28-0.php';
70
+		require_once plugin_dir_path(__DIR__).'install/class-wordlift-install-3-32-0.php';
71
+		require_once plugin_dir_path(__DIR__).'install/class-wordlift-install-3-33-9.php';
72
+		require_once plugin_dir_path(__DIR__).'install/class-wordlift-install-3-36-0.php';
73
+		require_once plugin_dir_path(__DIR__).'install/class-wordlift-install-3-38-5.php';
74
+		require_once plugin_dir_path(__DIR__).'install/class-wordlift-install-3-39-1.php';
75
+		require_once plugin_dir_path(__DIR__).'install/class-wordlift-install-3-40-1.php';
76
+		require_once plugin_dir_path(__DIR__).'install/class-wordlift-install-3-40-2.php';
77
+		require_once plugin_dir_path(__DIR__).'install/class-wordlift-install-3-41-0.php';
78
+		require_once plugin_dir_path(__DIR__).'install/class-wordlift-install-3-42-0.php';
79
+		require_once plugin_dir_path(__DIR__).'install/class-wordlift-install-3-44-1.php';
80
+		require_once plugin_dir_path(__DIR__).'install/class-wordlift-install-3-44-4.php';
81
+		require_once plugin_dir_path(__DIR__).'install/class-wordlift-install-3-45-0.php';
82
+		require_once plugin_dir_path(__DIR__).'install/class-wordlift-install-3-45-1.php';
83
+		require_once plugin_dir_path(__DIR__).'install/class-wordlift-install-3-49-2.php';
84 84
 
85 85
 		// Get the install services.
86 86
 		$this->installs = array(
@@ -133,9 +133,9 @@  discard block
 block discarded – undo
133 133
 		);
134 134
 		self::$instance = $this;
135 135
 
136
-		$this->log = Wordlift_Log_Service::get_logger( get_class() );
136
+		$this->log = Wordlift_Log_Service::get_logger(get_class());
137 137
 
138
-		add_action( 'init', array( $this, 'install' ) );
138
+		add_action('init', array($this, 'install'));
139 139
 
140 140
 	}
141 141
 
@@ -161,30 +161,30 @@  discard block
 block discarded – undo
161 161
 
162 162
 		$version = null;
163 163
 
164
-		if ( $this->install_required() && false === get_transient( '_wl_installing' ) ) {
165
-			set_transient( '_wl_installing', true, 5 * MINUTE_IN_SECONDS );
164
+		if ($this->install_required() && false === get_transient('_wl_installing')) {
165
+			set_transient('_wl_installing', true, 5 * MINUTE_IN_SECONDS);
166 166
 			/** @var Wordlift_Install $install */
167
-			foreach ( $this->installs as $install ) {
167
+			foreach ($this->installs as $install) {
168 168
 				// Get the install version.
169 169
 				$version = $install->get_version();
170 170
 
171
-				if ( version_compare( $version, $this->get_current_version(), '>' )
172
-					 || $install->must_install() ) {
173
-					$class_name = get_class( $install );
171
+				if (version_compare($version, $this->get_current_version(), '>')
172
+					 || $install->must_install()) {
173
+					$class_name = get_class($install);
174 174
 
175
-					$this->log->info( "Current version is {$this->get_current_version()}, installing $class_name..." );
175
+					$this->log->info("Current version is {$this->get_current_version()}, installing $class_name...");
176 176
 					// Install version.
177 177
 					$install->install();
178 178
 
179
-					$this->log->info( "$class_name installed." );
179
+					$this->log->info("$class_name installed.");
180 180
 
181 181
 					// Bump the version.
182
-					update_option( 'wl_db_version', $version );
182
+					update_option('wl_db_version', $version);
183 183
 				}
184 184
 			}
185 185
 
186 186
 			// phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged
187
-			@delete_transient( '_wl_installing' );
187
+			@delete_transient('_wl_installing');
188 188
 
189 189
 		}
190 190
 
@@ -193,12 +193,12 @@  discard block
 block discarded – undo
193 193
 	private function install_required() {
194 194
 
195 195
 		/** @var Wordlift_Install $install */
196
-		foreach ( $this->installs as $install ) {
196
+		foreach ($this->installs as $install) {
197 197
 			// Get the install version.
198 198
 			$version = $install->get_version();
199 199
 
200
-			if ( version_compare( $version, $this->get_current_version(), '>' )
201
-				 || $install->must_install() ) {
200
+			if (version_compare($version, $this->get_current_version(), '>')
201
+				 || $install->must_install()) {
202 202
 				return true;
203 203
 			}
204 204
 		}
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
 	 * @return type
213 213
 	 */
214 214
 	private function get_current_version() {
215
-		return get_option( 'wl_db_version', '0.0.0' );
215
+		return get_option('wl_db_version', '0.0.0');
216 216
 	}
217 217
 
218 218
 }
Please login to merge, or discard this patch.
src/wordlift.php 1 patch
Spacing   +71 added lines, -71 removed lines patch added patch discarded remove patch
@@ -31,26 +31,26 @@  discard block
 block discarded – undo
31 31
 use Wordlift\Features\Features_Registry;
32 32
 use Wordlift\Post\Post_Adapter;
33 33
 
34
-define( 'WORDLIFT_PLUGIN_FILE', __FILE__ );
35
-define( 'WORDLIFT_VERSION', '3.50.0-8' );
34
+define('WORDLIFT_PLUGIN_FILE', __FILE__);
35
+define('WORDLIFT_VERSION', '3.50.0-8');
36 36
 
37 37
 // ## DO NOT REMOVE THIS LINE: WHITELABEL PLACEHOLDER ##
38 38
 
39
-require_once plugin_dir_path( __FILE__ ) . '/libraries/action-scheduler/action-scheduler.php';
40
-require_once __DIR__ . '/modules/common/load.php';
41
-require_once __DIR__ . '/modules/app/load.php';
42
-require_once __DIR__ . '/modules/include-exclude/load.php';
39
+require_once plugin_dir_path(__FILE__).'/libraries/action-scheduler/action-scheduler.php';
40
+require_once __DIR__.'/modules/common/load.php';
41
+require_once __DIR__.'/modules/app/load.php';
42
+require_once __DIR__.'/modules/include-exclude/load.php';
43 43
 
44 44
 /**
45 45
  * Filter to disable WLP on any request, defaults to true.
46 46
  *
47 47
  * @since 3.33.6
48 48
  */
49
-if ( ! apply_filters( 'wl_is_enabled', true ) ) {
49
+if ( ! apply_filters('wl_is_enabled', true)) {
50 50
 	return;
51 51
 }
52 52
 
53
-require_once plugin_dir_path( __FILE__ ) . 'vendor/autoload.php';
53
+require_once plugin_dir_path(__FILE__).'vendor/autoload.php';
54 54
 
55 55
 /*
56 56
  * We introduce the WordLift autoloader, since we start using classes in namespaces, i.e. Wordlift\Http.
@@ -60,15 +60,15 @@  discard block
 block discarded – undo
60 60
 wordlift_plugin_autoload_register();
61 61
 
62 62
 // Include WordLift constants.
63
-require_once plugin_dir_path( __FILE__ ) . 'wordlift-constants.php';
63
+require_once plugin_dir_path(__FILE__).'wordlift-constants.php';
64 64
 
65 65
 // Load modules.
66
-require_once plugin_dir_path( __FILE__ ) . 'modules/core/wordlift-core.php';
66
+require_once plugin_dir_path(__FILE__).'modules/core/wordlift-core.php';
67 67
 
68
-require_once plugin_dir_path( __FILE__ ) . 'deprecations.php';
68
+require_once plugin_dir_path(__FILE__).'deprecations.php';
69 69
 
70 70
 // Load early to enable/disable features.
71
-require_once plugin_dir_path( __FILE__ ) . 'classes/features/index.php';
71
+require_once plugin_dir_path(__FILE__).'classes/features/index.php';
72 72
 
73 73
 /**
74 74
  * The code that runs during plugin activation.
@@ -76,11 +76,11 @@  discard block
 block discarded – undo
76 76
  */
77 77
 function activate_wordlift() {
78 78
 
79
-	$log = Wordlift_Log_Service::get_logger( 'activate_wordlift' );
79
+	$log = Wordlift_Log_Service::get_logger('activate_wordlift');
80 80
 
81
-	$log->info( 'Activating WordLift...' );
81
+	$log->info('Activating WordLift...');
82 82
 
83
-	require_once plugin_dir_path( __FILE__ ) . 'includes/class-wordlift-activator.php';
83
+	require_once plugin_dir_path(__FILE__).'includes/class-wordlift-activator.php';
84 84
 	Wordlift_Activator::activate();
85 85
 
86 86
 	/**
@@ -100,8 +100,8 @@  discard block
 block discarded – undo
100 100
 	 */
101 101
 	Top_Entities::activate();
102 102
 
103
-	if ( ! wp_next_scheduled( 'wl_daily_cron' ) ) {
104
-		wp_schedule_event( time(), 'daily', 'wl_daily_cron' );
103
+	if ( ! wp_next_scheduled('wl_daily_cron')) {
104
+		wp_schedule_event(time(), 'daily', 'wl_daily_cron');
105 105
 	}
106 106
 
107 107
 }
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
  */
113 113
 function deactivate_wordlift() {
114 114
 
115
-	require_once plugin_dir_path( __FILE__ ) . 'includes/class-wordlift-deactivator.php';
115
+	require_once plugin_dir_path(__FILE__).'includes/class-wordlift-deactivator.php';
116 116
 	Wordlift_Deactivator::deactivate();
117 117
 	Wordlift_Http_Api::deactivate();
118 118
 	Ttl_Cache_Cleaner::deactivate();
@@ -128,18 +128,18 @@  discard block
 block discarded – undo
128 128
 	Key_Validation_Notice::remove_notification_flag();
129 129
 	flush_rewrite_rules();
130 130
 
131
-	wp_clear_scheduled_hook( 'wl_daily_cron' );
131
+	wp_clear_scheduled_hook('wl_daily_cron');
132 132
 
133 133
 }
134 134
 
135
-register_activation_hook( __FILE__, 'activate_wordlift' );
136
-register_deactivation_hook( __FILE__, 'deactivate_wordlift' );
135
+register_activation_hook(__FILE__, 'activate_wordlift');
136
+register_deactivation_hook(__FILE__, 'deactivate_wordlift');
137 137
 
138 138
 /**
139 139
  * The core plugin class that is used to define internationalization,
140 140
  * admin-specific hooks, and public-facing site hooks.
141 141
  */
142
-require plugin_dir_path( __FILE__ ) . 'includes/class-wordlift.php';
142
+require plugin_dir_path(__FILE__).'includes/class-wordlift.php';
143 143
 
144 144
 /**
145 145
  * Begins execution of the plugin.
@@ -159,12 +159,12 @@  discard block
 block discarded – undo
159 159
 	 * @return bool
160 160
 	 * @since 3.27.6
161 161
 	 */
162
-	if ( apply_filters( 'wl_feature__enable__widgets', true ) ) {
163
-		add_action( 'widgets_init', 'wl_register_chord_widget' );
164
-		add_action( 'widgets_init', 'wl_register_geo_widget' );
165
-		add_action( 'widgets_init', 'wl_register_timeline_widget' );
162
+	if (apply_filters('wl_feature__enable__widgets', true)) {
163
+		add_action('widgets_init', 'wl_register_chord_widget');
164
+		add_action('widgets_init', 'wl_register_geo_widget');
165
+		add_action('widgets_init', 'wl_register_timeline_widget');
166 166
 	}
167
-	add_filter( 'widget_text', 'do_shortcode' );
167
+	add_filter('widget_text', 'do_shortcode');
168 168
 
169 169
 	/**
170 170
 	 * Filter: wl_feature__enable__analysis
@@ -174,10 +174,10 @@  discard block
 block discarded – undo
174 174
 	 * @return bool
175 175
 	 * @since 3.27.6
176 176
 	 */
177
-	if ( apply_filters( 'wl_feature__enable__analysis', true ) ) {
178
-		add_action( 'wp_ajax_wl_analyze', 'wl_ajax_analyze_action' );
177
+	if (apply_filters('wl_feature__enable__analysis', true)) {
178
+		add_action('wp_ajax_wl_analyze', 'wl_ajax_analyze_action');
179 179
 	} else {
180
-		add_action( 'wp_ajax_wl_analyze', 'wl_ajax_analyze_disabled_action' );
180
+		add_action('wp_ajax_wl_analyze', 'wl_ajax_analyze_disabled_action');
181 181
 	}
182 182
 
183 183
 	$plugin = new Wordlift();
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
 
195 195
 	add_action(
196 196
 		'plugins_loaded',
197
-		function () {
197
+		function() {
198 198
 			// All features from registry should be initialized here.
199 199
 			$features_registry = Features_Registry::get_instance();
200 200
 			$features_registry->initialize_all_features();
@@ -205,27 +205,27 @@  discard block
 block discarded – undo
205 205
 	add_action(
206 206
 		'plugins_loaded',
207 207
 		// phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
208
-		function () use ( $plugin ) {
208
+		function() use ($plugin) {
209 209
 
210 210
 			new Wordlift_Products_Navigator_Shortcode_REST();
211 211
 
212 212
 			// Register the Dataset module, requires `$api_service`.
213
-			require_once plugin_dir_path( __FILE__ ) . 'classes/dataset/index.php';
214
-			require_once plugin_dir_path( __FILE__ ) . 'classes/shipping-data/index.php';
213
+			require_once plugin_dir_path(__FILE__).'classes/dataset/index.php';
214
+			require_once plugin_dir_path(__FILE__).'classes/shipping-data/index.php';
215 215
 
216 216
 			/*
217 217
 			* Require the Entity annotation cleanup module.
218 218
 			*
219 219
 			* @since 3.34.6
220 220
 			*/
221
-			require_once plugin_dir_path( __FILE__ ) . 'classes/cleanup/index.php';
221
+			require_once plugin_dir_path(__FILE__).'classes/cleanup/index.php';
222 222
 
223 223
 			/*
224 224
 			* Import LOD entities.
225 225
 			*
226 226
 			* @since 3.35.0
227 227
 			*/
228
-			require_once plugin_dir_path( __FILE__ ) . 'classes/lod-import/index.php';
228
+			require_once plugin_dir_path(__FILE__).'classes/lod-import/index.php';
229 229
 
230 230
 		}
231 231
 	);
@@ -243,31 +243,31 @@  discard block
 block discarded – undo
243 243
 function wordlift_plugin_autoload_register() {
244 244
 
245 245
 	spl_autoload_register(
246
-		function ( $class_name ) {
246
+		function($class_name) {
247 247
 
248 248
 			// Bail out if these are not our classes.
249
-			if ( 0 !== strpos( $class_name, 'Wordlift\\' ) ) {
249
+			if (0 !== strpos($class_name, 'Wordlift\\')) {
250 250
 				return false;
251 251
 			}
252 252
 
253
-			$class_name_lc = strtolower( str_replace( '_', '-', $class_name ) );
253
+			$class_name_lc = strtolower(str_replace('_', '-', $class_name));
254 254
 
255
-			preg_match( '|^wordlift\\\\(?:(.*)\\\\)?(.+?)$|', $class_name_lc, $matches );
255
+			preg_match('|^wordlift\\\\(?:(.*)\\\\)?(.+?)$|', $class_name_lc, $matches);
256 256
 
257
-			$path = str_replace( '\\', DIRECTORY_SEPARATOR, $matches[1] );
258
-			$file = 'class-' . $matches[2] . '.php';
257
+			$path = str_replace('\\', DIRECTORY_SEPARATOR, $matches[1]);
258
+			$file = 'class-'.$matches[2].'.php';
259 259
 
260
-			$full_path = plugin_dir_path( __FILE__ ) . 'classes' . DIRECTORY_SEPARATOR . $path . DIRECTORY_SEPARATOR . $file;
260
+			$full_path = plugin_dir_path(__FILE__).'classes'.DIRECTORY_SEPARATOR.$path.DIRECTORY_SEPARATOR.$file;
261 261
 
262
-			if ( ! file_exists( $full_path ) ) {
262
+			if ( ! file_exists($full_path)) {
263 263
 				return false;
264 264
 			}
265 265
 
266 266
 			try {
267 267
 				require_once $full_path;
268
-			} catch ( Exception $e ) {
268
+			} catch (Exception $e) {
269 269
 				// phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
270
-				error_log( "[WordLift] $full_path not found, cannot include." );
270
+				error_log("[WordLift] $full_path not found, cannot include.");
271 271
 			}
272 272
 
273 273
 			return true;
@@ -276,13 +276,13 @@  discard block
 block discarded – undo
276 276
 
277 277
 }
278 278
 
279
-function wl_block_categories( $categories ) {
279
+function wl_block_categories($categories) {
280 280
 	return array_merge(
281 281
 		$categories,
282 282
 		array(
283 283
 			array(
284 284
 				'slug'  => 'wordlift',
285
-				'title' => __( 'WordLift', 'wordlift' ),
285
+				'title' => __('WordLift', 'wordlift'),
286 286
 			),
287 287
 		)
288 288
 	);
@@ -292,49 +292,49 @@  discard block
 block discarded – undo
292 292
  * This function is created temporarily to handle the legacy library,
293 293
  * this has to be removed when removing the legacy fields from the ui.
294 294
  */
295
-function wl_enqueue_leaflet( $in_footer = false ) {
295
+function wl_enqueue_leaflet($in_footer = false) {
296 296
 	// Leaflet.
297
-	wp_enqueue_style( 'wl-leaflet', plugin_dir_url( __FILE__ ) . 'js/leaflet/leaflet.css', array(), '1.6.0' );
298
-	wp_enqueue_script( 'wl-leaflet', plugin_dir_url( __FILE__ ) . 'js/leaflet/leaflet.js', array(), '1.6.0', $in_footer );
297
+	wp_enqueue_style('wl-leaflet', plugin_dir_url(__FILE__).'js/leaflet/leaflet.css', array(), '1.6.0');
298
+	wp_enqueue_script('wl-leaflet', plugin_dir_url(__FILE__).'js/leaflet/leaflet.js', array(), '1.6.0', $in_footer);
299 299
 }
300 300
 
301
-add_filter( 'block_categories', 'wl_block_categories', 10 );
301
+add_filter('block_categories', 'wl_block_categories', 10);
302 302
 
303 303
 // Temporary fix for a typo in WooCommerce Extension.
304 304
 add_filter(
305 305
 	'wl_feature__enable__dataset',
306
-	function ( $value ) {
307
-		return apply_filters( 'wl_features__enable__dataset', $value );
306
+	function($value) {
307
+		return apply_filters('wl_features__enable__dataset', $value);
308 308
 	}
309 309
 );
310 310
 
311
-require_once __DIR__ . '/modules/food-kg/load.php';
312
-require_once __DIR__ . '/modules/gardening-kg/load.php';
313
-require_once __DIR__ . '/modules/acf4so/load.php';
314
-require_once __DIR__ . '/modules/dashboard/load.php';
315
-require_once __DIR__ . '/modules/pods/load.php';
316
-require_once __DIR__ . '/modules/include-exclude-push-config/load.php';
317
-require_once __DIR__ . '/modules/super-resolution/load.php';
318
-require_once __DIR__ . '/modules/redeem-code/load.php';
319
-require_once __DIR__ . '/modules/raptive-setup/load.php';
320
-require_once __DIR__ . '/modules/events/load.php';
321
-
322
-function _wl_update_plugins_raptive_domain( $update, $plugin_data, $plugin_file ) {
311
+require_once __DIR__.'/modules/food-kg/load.php';
312
+require_once __DIR__.'/modules/gardening-kg/load.php';
313
+require_once __DIR__.'/modules/acf4so/load.php';
314
+require_once __DIR__.'/modules/dashboard/load.php';
315
+require_once __DIR__.'/modules/pods/load.php';
316
+require_once __DIR__.'/modules/include-exclude-push-config/load.php';
317
+require_once __DIR__.'/modules/super-resolution/load.php';
318
+require_once __DIR__.'/modules/redeem-code/load.php';
319
+require_once __DIR__.'/modules/raptive-setup/load.php';
320
+require_once __DIR__.'/modules/events/load.php';
321
+
322
+function _wl_update_plugins_raptive_domain($update, $plugin_data, $plugin_file) {
323 323
 	// Bail out if it's not our plugin.
324 324
 	$update_uri = $plugin_data['UpdateURI'];
325
-	if ( 'wordlift/wordlift.php' !== $plugin_file || ! isset( $update_uri ) ) {
325
+	if ('wordlift/wordlift.php' !== $plugin_file || ! isset($update_uri)) {
326 326
 		return $update;
327 327
 	}
328 328
 
329
-	$response = wp_remote_get( "$update_uri?nocache=" . time() );
329
+	$response = wp_remote_get("$update_uri?nocache=".time());
330 330
 
331
-	if ( is_wp_error( $response ) ) {
331
+	if (is_wp_error($response)) {
332 332
 		return $update;
333 333
 	}
334 334
 
335 335
 	try {
336
-		return json_decode( wp_remote_retrieve_body( $response ) );
337
-	} catch ( Exception $e ) {
336
+		return json_decode(wp_remote_retrieve_body($response));
337
+	} catch (Exception $e) {
338 338
 		return $update;
339 339
 	}
340 340
 }
Please login to merge, or discard this patch.
src/modules/events/includes/Term_Entity/Events_Term_Entity_Jsonld.php 2 patches
Indentation   +200 added lines, -200 removed lines patch added patch discarded remove patch
@@ -13,204 +13,204 @@
 block discarded – undo
13 13
  */
14 14
 class Events_Term_Entity_Jsonld {
15 15
 
16
-	/**
17
-	 * The {@link Api_Service} used to communicate with the remote APIs.
18
-	 *
19
-	 * @access private
20
-	 * @var Api_Service
21
-	 */
22
-	private $api_service;
23
-
24
-	/**
25
-	 * @param Api_Service $api_service
26
-	 */
27
-	public function __construct( Api_Service $api_service ) {
28
-		$this->api_service = $api_service;
29
-	}
30
-
31
-	/**
32
-	 * Register hooks.
33
-	 */
34
-	public function register_hooks() {
35
-		add_filter( 'wl_term_jsonld_array', array( $this, 'set_events_request' ), 90, 3 );
36
-	}
37
-
38
-	/**
39
-	 * Set term jsonld array event.
40
-	 *
41
-	 * @param $data array An array containing jsonld for term and entities.
42
-	 * @param $term_id int The term id for which the jsonld is generated.
43
-	 * @param $context int A context for the JSON-LD generation, valid values in Jsonld_Context_Enum
44
-	 *
45
-	 * @return array
46
-	 */
47
-	public function set_events_request( $data, $term_id, $context ) {
48
-		$jsonld_arr = $data['jsonld'];
49
-		if ( $this->should_return_early( $context ) ) {
50
-			return $data;
51
-		}
52
-
53
-		// Bail out if we don't have a term URL.
54
-		$term_url = $this->get_term_url( $term_id );
55
-		if ( ! is_string( $term_url ) ) {
56
-			return $data;
57
-		}
58
-
59
-		$counts = $this->get_initial_counts( $term_id );
60
-
61
-		$change_status = $this->update_counts_if_necessary( $jsonld_arr, $counts, $term_id );
62
-
63
-		if ( $change_status ) {
64
-			$this->send_api_request( $counts, $term_url );
65
-		}
66
-
67
-		return $data;
68
-	}
69
-
70
-	/**
71
-	 * If context is not PAGE, return early.
72
-	 *
73
-	 * @param $context int A context for the JSON-LD generation, valid values in Jsonld_Context_Enum
74
-	 *
75
-	 * @return bool
76
-	 */
77
-	private function should_return_early( $context ) {
78
-		return Jsonld_Context_Enum::PAGE !== $context;
79
-	}
80
-
81
-	/**
82
-	 * Fetch the initial 'about' and 'mentions' counts from term meta.
83
-	 *
84
-	 * @param $term_id int The term id for which the jsonld is generated.
85
-	 *
86
-	 * @return int[]
87
-	 */
88
-	private function get_initial_counts( $term_id ) {
89
-		return array(
90
-			'about'    => get_term_meta( $term_id, 'wl_about_count', true ) ? (int) get_term_meta( $term_id, 'wl_about_count', true ) : 0,
91
-			'mentions' => get_term_meta( $term_id, 'wl_mentions_count', true )
92
-				? (int) get_term_meta( $term_id, 'wl_mentions_count', true )
93
-				: 0,
94
-		);
95
-	}
96
-
97
-	/**
98
-	 * Update counts if necessary.
99
-	 *
100
-	 * @param $jsonld_arr
101
-	 * @param $counts
102
-	 * @param $term_id
103
-	 *
104
-	 * @return bool
105
-	 */
106
-	private function update_counts_if_necessary( $jsonld_arr, &$counts, $term_id ) {
107
-		// Flag to indicate if we should make an API request.
108
-		$change_status = false;
109
-
110
-		// If the $jsonld_arr is empty but the counts were previously more than 0.
111
-		if ( empty( $jsonld_arr[0] ) ) {
112
-			return $this->reset_counts_if_non_zero( $counts, $term_id );
113
-		}
114
-
115
-		// Get data from the array.
116
-		$data_arr = $jsonld_arr[0];
117
-
118
-		// Iterate over the counts array.
119
-		foreach ( $counts as $type => $type_count ) {
120
-			// Check if data has 'about' or 'mentions' and the count is different from the existing meta value.
121
-			if ( isset( $data_arr[ $type ] ) ) {
122
-				$new_count = count( $data_arr[ $type ] );
123
-				if ( $type_count !== $new_count ) {
124
-					// Set flag to true if counts have changed.
125
-					$change_status = true;
126
-
127
-					// Update the counts array with new count.
128
-					$counts[ $type ] = $new_count;
129
-
130
-					// Update term meta with new count.
131
-					update_term_meta( $term_id, 'wl_' . $type . '_count', $new_count );
132
-					continue;
133
-				}
134
-			}
135
-
136
-			if ( ! isset( $data_arr[ $type ] ) && $type_count > 0 ) {
137
-				// If the 'about' or 'mentions' has become empty, set it to 0.
138
-				$change_status   = true;
139
-				$counts[ $type ] = 0;
140
-				update_term_meta( $term_id, 'wl_' . $type . '_count', 0 );
141
-			}
142
-		}
143
-
144
-		return $change_status;
145
-	}
146
-
147
-	/**
148
-	 * Reset counts if non zero.
149
-	 *
150
-	 * @param $counts
151
-	 * @param $term_id
152
-	 *
153
-	 * @return bool
154
-	 */
155
-	private function reset_counts_if_non_zero( &$counts, $term_id ) {
156
-		$change_status = false;
157
-
158
-		foreach ( $counts as $type => $type_count ) {
159
-			if ( $type_count > 0 ) {
160
-				$change_status   = true;
161
-				$counts[ $type ] = 0;
162
-				update_term_meta( $term_id, 'wl_' . $type . '_count', 0 );
163
-			}
164
-		}
165
-
166
-		return $change_status;
167
-	}
168
-
169
-	/**
170
-	 * Send api request.
171
-	 *
172
-	 * @param $counts
173
-	 * @param $term_url string The term URL.
174
-	 */
175
-	private function send_api_request( $counts, $term_url ) {
176
-		// If the count has changed, make the API request.
177
-		$this->api_service->request(
178
-			'POST',
179
-			'/plugin/events',
180
-			array( 'Content-Type' => 'application/json' ),
181
-			wp_json_encode(
182
-				array(
183
-					'source' => 'jsonld',
184
-					'args'   => array(
185
-						array( 'about_count' => $counts['about'] ),
186
-						array( 'mentions_count' => $counts['mentions'] ),
187
-					),
188
-					'url'    => $term_url,
189
-				)
190
-			),
191
-			0.001,
192
-			null,
193
-			array( 'blocking' => false )
194
-		);
195
-	}
196
-
197
-	/**
198
-	 * Get term url.
199
-	 *
200
-	 * @param $id
201
-	 *
202
-	 * @return array|false|int|mixed|string|\WP_Error|\WP_Term|null
203
-	 */
204
-	private function get_term_url( $id ) {
205
-		if ( null === $id ) {
206
-			return isset( $_SERVER['REQUEST_URI'] ) ? filter_var( wp_unslash( $_SERVER['REQUEST_URI'] ), FILTER_SANITIZE_URL ) : '';
207
-		}
208
-
209
-		$maybe_url = get_term_meta( $id, Wordlift_Url_Property_Service::META_KEY, true );
210
-		if ( ! empty( $maybe_url ) ) {
211
-			return $maybe_url;
212
-		}
213
-
214
-		return get_term_link( $id );
215
-	}
16
+    /**
17
+     * The {@link Api_Service} used to communicate with the remote APIs.
18
+     *
19
+     * @access private
20
+     * @var Api_Service
21
+     */
22
+    private $api_service;
23
+
24
+    /**
25
+     * @param Api_Service $api_service
26
+     */
27
+    public function __construct( Api_Service $api_service ) {
28
+        $this->api_service = $api_service;
29
+    }
30
+
31
+    /**
32
+     * Register hooks.
33
+     */
34
+    public function register_hooks() {
35
+        add_filter( 'wl_term_jsonld_array', array( $this, 'set_events_request' ), 90, 3 );
36
+    }
37
+
38
+    /**
39
+     * Set term jsonld array event.
40
+     *
41
+     * @param $data array An array containing jsonld for term and entities.
42
+     * @param $term_id int The term id for which the jsonld is generated.
43
+     * @param $context int A context for the JSON-LD generation, valid values in Jsonld_Context_Enum
44
+     *
45
+     * @return array
46
+     */
47
+    public function set_events_request( $data, $term_id, $context ) {
48
+        $jsonld_arr = $data['jsonld'];
49
+        if ( $this->should_return_early( $context ) ) {
50
+            return $data;
51
+        }
52
+
53
+        // Bail out if we don't have a term URL.
54
+        $term_url = $this->get_term_url( $term_id );
55
+        if ( ! is_string( $term_url ) ) {
56
+            return $data;
57
+        }
58
+
59
+        $counts = $this->get_initial_counts( $term_id );
60
+
61
+        $change_status = $this->update_counts_if_necessary( $jsonld_arr, $counts, $term_id );
62
+
63
+        if ( $change_status ) {
64
+            $this->send_api_request( $counts, $term_url );
65
+        }
66
+
67
+        return $data;
68
+    }
69
+
70
+    /**
71
+     * If context is not PAGE, return early.
72
+     *
73
+     * @param $context int A context for the JSON-LD generation, valid values in Jsonld_Context_Enum
74
+     *
75
+     * @return bool
76
+     */
77
+    private function should_return_early( $context ) {
78
+        return Jsonld_Context_Enum::PAGE !== $context;
79
+    }
80
+
81
+    /**
82
+     * Fetch the initial 'about' and 'mentions' counts from term meta.
83
+     *
84
+     * @param $term_id int The term id for which the jsonld is generated.
85
+     *
86
+     * @return int[]
87
+     */
88
+    private function get_initial_counts( $term_id ) {
89
+        return array(
90
+            'about'    => get_term_meta( $term_id, 'wl_about_count', true ) ? (int) get_term_meta( $term_id, 'wl_about_count', true ) : 0,
91
+            'mentions' => get_term_meta( $term_id, 'wl_mentions_count', true )
92
+                ? (int) get_term_meta( $term_id, 'wl_mentions_count', true )
93
+                : 0,
94
+        );
95
+    }
96
+
97
+    /**
98
+     * Update counts if necessary.
99
+     *
100
+     * @param $jsonld_arr
101
+     * @param $counts
102
+     * @param $term_id
103
+     *
104
+     * @return bool
105
+     */
106
+    private function update_counts_if_necessary( $jsonld_arr, &$counts, $term_id ) {
107
+        // Flag to indicate if we should make an API request.
108
+        $change_status = false;
109
+
110
+        // If the $jsonld_arr is empty but the counts were previously more than 0.
111
+        if ( empty( $jsonld_arr[0] ) ) {
112
+            return $this->reset_counts_if_non_zero( $counts, $term_id );
113
+        }
114
+
115
+        // Get data from the array.
116
+        $data_arr = $jsonld_arr[0];
117
+
118
+        // Iterate over the counts array.
119
+        foreach ( $counts as $type => $type_count ) {
120
+            // Check if data has 'about' or 'mentions' and the count is different from the existing meta value.
121
+            if ( isset( $data_arr[ $type ] ) ) {
122
+                $new_count = count( $data_arr[ $type ] );
123
+                if ( $type_count !== $new_count ) {
124
+                    // Set flag to true if counts have changed.
125
+                    $change_status = true;
126
+
127
+                    // Update the counts array with new count.
128
+                    $counts[ $type ] = $new_count;
129
+
130
+                    // Update term meta with new count.
131
+                    update_term_meta( $term_id, 'wl_' . $type . '_count', $new_count );
132
+                    continue;
133
+                }
134
+            }
135
+
136
+            if ( ! isset( $data_arr[ $type ] ) && $type_count > 0 ) {
137
+                // If the 'about' or 'mentions' has become empty, set it to 0.
138
+                $change_status   = true;
139
+                $counts[ $type ] = 0;
140
+                update_term_meta( $term_id, 'wl_' . $type . '_count', 0 );
141
+            }
142
+        }
143
+
144
+        return $change_status;
145
+    }
146
+
147
+    /**
148
+     * Reset counts if non zero.
149
+     *
150
+     * @param $counts
151
+     * @param $term_id
152
+     *
153
+     * @return bool
154
+     */
155
+    private function reset_counts_if_non_zero( &$counts, $term_id ) {
156
+        $change_status = false;
157
+
158
+        foreach ( $counts as $type => $type_count ) {
159
+            if ( $type_count > 0 ) {
160
+                $change_status   = true;
161
+                $counts[ $type ] = 0;
162
+                update_term_meta( $term_id, 'wl_' . $type . '_count', 0 );
163
+            }
164
+        }
165
+
166
+        return $change_status;
167
+    }
168
+
169
+    /**
170
+     * Send api request.
171
+     *
172
+     * @param $counts
173
+     * @param $term_url string The term URL.
174
+     */
175
+    private function send_api_request( $counts, $term_url ) {
176
+        // If the count has changed, make the API request.
177
+        $this->api_service->request(
178
+            'POST',
179
+            '/plugin/events',
180
+            array( 'Content-Type' => 'application/json' ),
181
+            wp_json_encode(
182
+                array(
183
+                    'source' => 'jsonld',
184
+                    'args'   => array(
185
+                        array( 'about_count' => $counts['about'] ),
186
+                        array( 'mentions_count' => $counts['mentions'] ),
187
+                    ),
188
+                    'url'    => $term_url,
189
+                )
190
+            ),
191
+            0.001,
192
+            null,
193
+            array( 'blocking' => false )
194
+        );
195
+    }
196
+
197
+    /**
198
+     * Get term url.
199
+     *
200
+     * @param $id
201
+     *
202
+     * @return array|false|int|mixed|string|\WP_Error|\WP_Term|null
203
+     */
204
+    private function get_term_url( $id ) {
205
+        if ( null === $id ) {
206
+            return isset( $_SERVER['REQUEST_URI'] ) ? filter_var( wp_unslash( $_SERVER['REQUEST_URI'] ), FILTER_SANITIZE_URL ) : '';
207
+        }
208
+
209
+        $maybe_url = get_term_meta( $id, Wordlift_Url_Property_Service::META_KEY, true );
210
+        if ( ! empty( $maybe_url ) ) {
211
+            return $maybe_url;
212
+        }
213
+
214
+        return get_term_link( $id );
215
+    }
216 216
 }
Please login to merge, or discard this patch.
Spacing   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 	/**
25 25
 	 * @param Api_Service $api_service
26 26
 	 */
27
-	public function __construct( Api_Service $api_service ) {
27
+	public function __construct(Api_Service $api_service) {
28 28
 		$this->api_service = $api_service;
29 29
 	}
30 30
 
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
 	 * Register hooks.
33 33
 	 */
34 34
 	public function register_hooks() {
35
-		add_filter( 'wl_term_jsonld_array', array( $this, 'set_events_request' ), 90, 3 );
35
+		add_filter('wl_term_jsonld_array', array($this, 'set_events_request'), 90, 3);
36 36
 	}
37 37
 
38 38
 	/**
@@ -44,24 +44,24 @@  discard block
 block discarded – undo
44 44
 	 *
45 45
 	 * @return array
46 46
 	 */
47
-	public function set_events_request( $data, $term_id, $context ) {
47
+	public function set_events_request($data, $term_id, $context) {
48 48
 		$jsonld_arr = $data['jsonld'];
49
-		if ( $this->should_return_early( $context ) ) {
49
+		if ($this->should_return_early($context)) {
50 50
 			return $data;
51 51
 		}
52 52
 
53 53
 		// Bail out if we don't have a term URL.
54
-		$term_url = $this->get_term_url( $term_id );
55
-		if ( ! is_string( $term_url ) ) {
54
+		$term_url = $this->get_term_url($term_id);
55
+		if ( ! is_string($term_url)) {
56 56
 			return $data;
57 57
 		}
58 58
 
59
-		$counts = $this->get_initial_counts( $term_id );
59
+		$counts = $this->get_initial_counts($term_id);
60 60
 
61
-		$change_status = $this->update_counts_if_necessary( $jsonld_arr, $counts, $term_id );
61
+		$change_status = $this->update_counts_if_necessary($jsonld_arr, $counts, $term_id);
62 62
 
63
-		if ( $change_status ) {
64
-			$this->send_api_request( $counts, $term_url );
63
+		if ($change_status) {
64
+			$this->send_api_request($counts, $term_url);
65 65
 		}
66 66
 
67 67
 		return $data;
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
 	 *
75 75
 	 * @return bool
76 76
 	 */
77
-	private function should_return_early( $context ) {
77
+	private function should_return_early($context) {
78 78
 		return Jsonld_Context_Enum::PAGE !== $context;
79 79
 	}
80 80
 
@@ -85,11 +85,11 @@  discard block
 block discarded – undo
85 85
 	 *
86 86
 	 * @return int[]
87 87
 	 */
88
-	private function get_initial_counts( $term_id ) {
88
+	private function get_initial_counts($term_id) {
89 89
 		return array(
90
-			'about'    => get_term_meta( $term_id, 'wl_about_count', true ) ? (int) get_term_meta( $term_id, 'wl_about_count', true ) : 0,
91
-			'mentions' => get_term_meta( $term_id, 'wl_mentions_count', true )
92
-				? (int) get_term_meta( $term_id, 'wl_mentions_count', true )
90
+			'about'    => get_term_meta($term_id, 'wl_about_count', true) ? (int) get_term_meta($term_id, 'wl_about_count', true) : 0,
91
+			'mentions' => get_term_meta($term_id, 'wl_mentions_count', true)
92
+				? (int) get_term_meta($term_id, 'wl_mentions_count', true)
93 93
 				: 0,
94 94
 		);
95 95
 	}
@@ -103,41 +103,41 @@  discard block
 block discarded – undo
103 103
 	 *
104 104
 	 * @return bool
105 105
 	 */
106
-	private function update_counts_if_necessary( $jsonld_arr, &$counts, $term_id ) {
106
+	private function update_counts_if_necessary($jsonld_arr, &$counts, $term_id) {
107 107
 		// Flag to indicate if we should make an API request.
108 108
 		$change_status = false;
109 109
 
110 110
 		// If the $jsonld_arr is empty but the counts were previously more than 0.
111
-		if ( empty( $jsonld_arr[0] ) ) {
112
-			return $this->reset_counts_if_non_zero( $counts, $term_id );
111
+		if (empty($jsonld_arr[0])) {
112
+			return $this->reset_counts_if_non_zero($counts, $term_id);
113 113
 		}
114 114
 
115 115
 		// Get data from the array.
116 116
 		$data_arr = $jsonld_arr[0];
117 117
 
118 118
 		// Iterate over the counts array.
119
-		foreach ( $counts as $type => $type_count ) {
119
+		foreach ($counts as $type => $type_count) {
120 120
 			// Check if data has 'about' or 'mentions' and the count is different from the existing meta value.
121
-			if ( isset( $data_arr[ $type ] ) ) {
122
-				$new_count = count( $data_arr[ $type ] );
123
-				if ( $type_count !== $new_count ) {
121
+			if (isset($data_arr[$type])) {
122
+				$new_count = count($data_arr[$type]);
123
+				if ($type_count !== $new_count) {
124 124
 					// Set flag to true if counts have changed.
125 125
 					$change_status = true;
126 126
 
127 127
 					// Update the counts array with new count.
128
-					$counts[ $type ] = $new_count;
128
+					$counts[$type] = $new_count;
129 129
 
130 130
 					// Update term meta with new count.
131
-					update_term_meta( $term_id, 'wl_' . $type . '_count', $new_count );
131
+					update_term_meta($term_id, 'wl_'.$type.'_count', $new_count);
132 132
 					continue;
133 133
 				}
134 134
 			}
135 135
 
136
-			if ( ! isset( $data_arr[ $type ] ) && $type_count > 0 ) {
136
+			if ( ! isset($data_arr[$type]) && $type_count > 0) {
137 137
 				// If the 'about' or 'mentions' has become empty, set it to 0.
138 138
 				$change_status   = true;
139
-				$counts[ $type ] = 0;
140
-				update_term_meta( $term_id, 'wl_' . $type . '_count', 0 );
139
+				$counts[$type] = 0;
140
+				update_term_meta($term_id, 'wl_'.$type.'_count', 0);
141 141
 			}
142 142
 		}
143 143
 
@@ -152,14 +152,14 @@  discard block
 block discarded – undo
152 152
 	 *
153 153
 	 * @return bool
154 154
 	 */
155
-	private function reset_counts_if_non_zero( &$counts, $term_id ) {
155
+	private function reset_counts_if_non_zero(&$counts, $term_id) {
156 156
 		$change_status = false;
157 157
 
158
-		foreach ( $counts as $type => $type_count ) {
159
-			if ( $type_count > 0 ) {
158
+		foreach ($counts as $type => $type_count) {
159
+			if ($type_count > 0) {
160 160
 				$change_status   = true;
161
-				$counts[ $type ] = 0;
162
-				update_term_meta( $term_id, 'wl_' . $type . '_count', 0 );
161
+				$counts[$type] = 0;
162
+				update_term_meta($term_id, 'wl_'.$type.'_count', 0);
163 163
 			}
164 164
 		}
165 165
 
@@ -172,25 +172,25 @@  discard block
 block discarded – undo
172 172
 	 * @param $counts
173 173
 	 * @param $term_url string The term URL.
174 174
 	 */
175
-	private function send_api_request( $counts, $term_url ) {
175
+	private function send_api_request($counts, $term_url) {
176 176
 		// If the count has changed, make the API request.
177 177
 		$this->api_service->request(
178 178
 			'POST',
179 179
 			'/plugin/events',
180
-			array( 'Content-Type' => 'application/json' ),
180
+			array('Content-Type' => 'application/json'),
181 181
 			wp_json_encode(
182 182
 				array(
183 183
 					'source' => 'jsonld',
184 184
 					'args'   => array(
185
-						array( 'about_count' => $counts['about'] ),
186
-						array( 'mentions_count' => $counts['mentions'] ),
185
+						array('about_count' => $counts['about']),
186
+						array('mentions_count' => $counts['mentions']),
187 187
 					),
188 188
 					'url'    => $term_url,
189 189
 				)
190 190
 			),
191 191
 			0.001,
192 192
 			null,
193
-			array( 'blocking' => false )
193
+			array('blocking' => false)
194 194
 		);
195 195
 	}
196 196
 
@@ -201,16 +201,16 @@  discard block
 block discarded – undo
201 201
 	 *
202 202
 	 * @return array|false|int|mixed|string|\WP_Error|\WP_Term|null
203 203
 	 */
204
-	private function get_term_url( $id ) {
205
-		if ( null === $id ) {
206
-			return isset( $_SERVER['REQUEST_URI'] ) ? filter_var( wp_unslash( $_SERVER['REQUEST_URI'] ), FILTER_SANITIZE_URL ) : '';
204
+	private function get_term_url($id) {
205
+		if (null === $id) {
206
+			return isset($_SERVER['REQUEST_URI']) ? filter_var(wp_unslash($_SERVER['REQUEST_URI']), FILTER_SANITIZE_URL) : '';
207 207
 		}
208 208
 
209
-		$maybe_url = get_term_meta( $id, Wordlift_Url_Property_Service::META_KEY, true );
210
-		if ( ! empty( $maybe_url ) ) {
209
+		$maybe_url = get_term_meta($id, Wordlift_Url_Property_Service::META_KEY, true);
210
+		if ( ! empty($maybe_url)) {
211 211
 			return $maybe_url;
212 212
 		}
213 213
 
214
-		return get_term_link( $id );
214
+		return get_term_link($id);
215 215
 	}
216 216
 }
Please login to merge, or discard this patch.
src/modules/events/includes/Post_Entity/Events_Post_Entity_Jsonld.php 2 patches
Indentation   +210 added lines, -210 removed lines patch added patch discarded remove patch
@@ -13,219 +13,219 @@
 block discarded – undo
13 13
  */
14 14
 class Events_Post_Entity_Jsonld {
15 15
 
16
-	/**
17
-	 * The {@link Api_Service} used to communicate with the remote APIs.
18
-	 *
19
-	 * @access private
20
-	 * @var Api_Service
21
-	 */
22
-	private $api_service;
23
-
24
-	/**
25
-	 * @param Api_Service $api_service
26
-	 */
27
-	public function __construct( Api_Service $api_service ) {
28
-		$this->api_service = $api_service;
29
-	}
30
-
31
-	/**
32
-	 * Register hooks.
33
-	 */
34
-	public function register_hooks() {
35
-		add_filter( 'wl_after_get_jsonld', array( $this, 'handle_after_get_jsonld' ), 90, 3 );
36
-		add_filter( 'wprm_recipe_metadata', array( $this, 'handle_recipe_metadata' ), PHP_INT_MAX - 100, 2 );
37
-	}
38
-
39
-	public function handle_after_get_jsonld( $jsonld_arr, $post_id, $context ) {
40
-
41
-		if (
42
-			// We're not in a page context.
43
-			Jsonld_Context_Enum::PAGE !== $context ||
44
-			// It's a Recipe post.
45
-			$this->is_a_recipe_post( $post_id )
46
-		) {
47
-			return $jsonld_arr;
48
-		}
49
-
50
-		return $this->set_events_request( $jsonld_arr, $post_id );
51
-	}
52
-
53
-	private function is_a_recipe_post( $post_id ) {
54
-		global $wpdb;
55
-
56
-		return $wpdb->get_var(
57
-			$wpdb->prepare(
58
-				"
16
+    /**
17
+     * The {@link Api_Service} used to communicate with the remote APIs.
18
+     *
19
+     * @access private
20
+     * @var Api_Service
21
+     */
22
+    private $api_service;
23
+
24
+    /**
25
+     * @param Api_Service $api_service
26
+     */
27
+    public function __construct( Api_Service $api_service ) {
28
+        $this->api_service = $api_service;
29
+    }
30
+
31
+    /**
32
+     * Register hooks.
33
+     */
34
+    public function register_hooks() {
35
+        add_filter( 'wl_after_get_jsonld', array( $this, 'handle_after_get_jsonld' ), 90, 3 );
36
+        add_filter( 'wprm_recipe_metadata', array( $this, 'handle_recipe_metadata' ), PHP_INT_MAX - 100, 2 );
37
+    }
38
+
39
+    public function handle_after_get_jsonld( $jsonld_arr, $post_id, $context ) {
40
+
41
+        if (
42
+            // We're not in a page context.
43
+            Jsonld_Context_Enum::PAGE !== $context ||
44
+            // It's a Recipe post.
45
+            $this->is_a_recipe_post( $post_id )
46
+        ) {
47
+            return $jsonld_arr;
48
+        }
49
+
50
+        return $this->set_events_request( $jsonld_arr, $post_id );
51
+    }
52
+
53
+    private function is_a_recipe_post( $post_id ) {
54
+        global $wpdb;
55
+
56
+        return $wpdb->get_var(
57
+            $wpdb->prepare(
58
+                "
59 59
 			SELECT COUNT(1) 
60 60
 			FROM $wpdb->postmeta 
61 61
 			WHERE meta_key = 'wprm_parent_post_id' 
62 62
 			AND meta_value = %d
63 63
 		",
64
-				$post_id
65
-			)
66
-		);
67
-	}
68
-
69
-	/**
70
-	 * @param $value
71
-	 * @param WPRM_Recipe $recipe
72
-	 *
73
-	 * @return mixed
74
-	 */
75
-	public function handle_recipe_metadata( $value, $recipe ) {
76
-		// We only handle the parent post.
77
-		$parent_post_id = $recipe->parent_post_id();
78
-		if ( is_numeric( $parent_post_id ) && 0 < $parent_post_id ) {
79
-			$this->set_events_request( array( $value ), $parent_post_id, Jsonld_Context_Enum::PAGE );
80
-		}
81
-
82
-		return $value;
83
-	}
84
-
85
-	/**
86
-	 * Set events request.
87
-	 *
88
-	 * @param $jsonld_arr array The final jsonld before outputting to page.
89
-	 * @param $post_id int The post id for which the jsonld is generated.
90
-	 *
91
-	 * @return array
92
-	 */
93
-	private function set_events_request( $jsonld_arr, $post_id ) {
94
-
95
-		// Bail out if we can't get a permalink.
96
-		$permalink = get_permalink( $post_id );
97
-		if ( false === $permalink ) {
98
-			return $jsonld_arr;
99
-		}
100
-
101
-		$counts = $this->get_initial_counts_post( $post_id );
102
-
103
-		$change_status = $this->update_counts_if_necessary_post( $jsonld_arr, $counts, $post_id );
104
-
105
-		if ( $change_status ) {
106
-			$this->send_api_request_post( $counts, $permalink );
107
-		}
108
-
109
-		return $jsonld_arr;
110
-	}
111
-
112
-	/**
113
-	 * Fetch the initial 'about' and 'mentions' counts from post meta.
114
-	 *
115
-	 * @param $post_id int The post id for which the jsonld is generated.
116
-	 *
117
-	 * @return int[]
118
-	 */
119
-	private function get_initial_counts_post( $post_id ) {
120
-		return array(
121
-			'about'    => get_post_meta( $post_id, 'wl_about_count', true ) ? (int) get_post_meta( $post_id, 'wl_about_count', true ) : 0,
122
-			'mentions' => get_post_meta( $post_id, 'wl_mentions_count', true )
123
-				? (int) get_post_meta( $post_id, 'wl_mentions_count', true )
124
-				: 0,
125
-		);
126
-	}
127
-
128
-	/**
129
-	 * Update counts if necessary post.
130
-	 *
131
-	 * @param $jsonld_arr
132
-	 * @param $counts
133
-	 * @param $post_id
134
-	 *
135
-	 * @return bool
136
-	 */
137
-	private function update_counts_if_necessary_post( $jsonld_arr, &$counts, $post_id ) {
138
-		// Flag to indicate if we should make an API request.
139
-		$change_status = false;
140
-
141
-		// If the $jsonld_arr is empty but the counts were previously more than 0.
142
-		if ( empty( $jsonld_arr[0] ) ) {
143
-			return $this->reset_counts_if_non_zero_post( $counts, $post_id );
144
-		}
145
-
146
-		// Get data from the array.
147
-		$data = $jsonld_arr[0];
148
-
149
-		// Iterate over the counts array.
150
-		foreach ( $counts as $type => $type_count ) {
151
-			// Check if data has 'about' or 'mentions' and the count is different from the existing meta value.
152
-			if ( isset( $data[ $type ] ) ) {
153
-				$new_count = count( $data[ $type ] );
154
-				if ( $type_count !== $new_count ) {
155
-					// Set flag to true if counts have changed.
156
-					$change_status = true;
157
-
158
-					// Update the counts array with new count.
159
-					$counts[ $type ] = $new_count;
160
-
161
-					// Update post meta with new count.
162
-					update_post_meta( $post_id, 'wl_' . $type . '_count', $new_count );
163
-					continue;
164
-				}
165
-			}
166
-
167
-			if ( ! isset( $data[ $type ] ) && $type_count > 0 ) {
168
-				// If the 'about' or 'mentions' has become empty, set it to 0.
169
-				$change_status   = true;
170
-				$counts[ $type ] = 0;
171
-				update_post_meta( $post_id, 'wl_' . $type . '_count', 0 );
172
-			}
173
-		}
174
-
175
-		return $change_status;
176
-	}
177
-
178
-	/**
179
-	 * Reset counts if non zero post.
180
-	 *
181
-	 * @param $counts
182
-	 * @param $post_id
183
-	 *
184
-	 * @return bool
185
-	 */
186
-	private function reset_counts_if_non_zero_post( &$counts, $post_id ) {
187
-		$change_status = false;
188
-
189
-		foreach ( $counts as $type => $type_count ) {
190
-			if ( $type_count > 0 ) {
191
-				$change_status   = true;
192
-				$counts[ $type ] = 0;
193
-				update_post_meta( $post_id, 'wl_' . $type . '_count', 0 );
194
-			}
195
-		}
196
-
197
-		return $change_status;
198
-	}
199
-
200
-	/**
201
-	 * Send api request post.
202
-	 *
203
-	 * @param $counts
204
-	 * @param $permalink string The web page URL
205
-	 */
206
-	private function send_api_request_post( $counts, $permalink ) {
207
-		// If the count has changed, make the API request.
208
-		// phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
209
-		$blocking = apply_filters( 'wl_feature__enable__sync-blocking', false );
210
-
211
-		// Apply the filter to the request args
212
-		$this->api_service->request(
213
-			'POST',
214
-			'/plugin/events',
215
-			array( 'Content-Type' => 'application/json' ),
216
-			wp_json_encode(
217
-				array(
218
-					'source' => 'jsonld',
219
-					'args'   => array(
220
-						array( 'about_count' => $counts['about'] ),
221
-						array( 'mentions_count' => $counts['mentions'] ),
222
-					),
223
-					'url'    => $permalink,
224
-				)
225
-			),
226
-			$blocking ? 60 : 0.001,
227
-			null,
228
-			array( 'blocking' => $blocking )
229
-		);
230
-	}
64
+                $post_id
65
+            )
66
+        );
67
+    }
68
+
69
+    /**
70
+     * @param $value
71
+     * @param WPRM_Recipe $recipe
72
+     *
73
+     * @return mixed
74
+     */
75
+    public function handle_recipe_metadata( $value, $recipe ) {
76
+        // We only handle the parent post.
77
+        $parent_post_id = $recipe->parent_post_id();
78
+        if ( is_numeric( $parent_post_id ) && 0 < $parent_post_id ) {
79
+            $this->set_events_request( array( $value ), $parent_post_id, Jsonld_Context_Enum::PAGE );
80
+        }
81
+
82
+        return $value;
83
+    }
84
+
85
+    /**
86
+     * Set events request.
87
+     *
88
+     * @param $jsonld_arr array The final jsonld before outputting to page.
89
+     * @param $post_id int The post id for which the jsonld is generated.
90
+     *
91
+     * @return array
92
+     */
93
+    private function set_events_request( $jsonld_arr, $post_id ) {
94
+
95
+        // Bail out if we can't get a permalink.
96
+        $permalink = get_permalink( $post_id );
97
+        if ( false === $permalink ) {
98
+            return $jsonld_arr;
99
+        }
100
+
101
+        $counts = $this->get_initial_counts_post( $post_id );
102
+
103
+        $change_status = $this->update_counts_if_necessary_post( $jsonld_arr, $counts, $post_id );
104
+
105
+        if ( $change_status ) {
106
+            $this->send_api_request_post( $counts, $permalink );
107
+        }
108
+
109
+        return $jsonld_arr;
110
+    }
111
+
112
+    /**
113
+     * Fetch the initial 'about' and 'mentions' counts from post meta.
114
+     *
115
+     * @param $post_id int The post id for which the jsonld is generated.
116
+     *
117
+     * @return int[]
118
+     */
119
+    private function get_initial_counts_post( $post_id ) {
120
+        return array(
121
+            'about'    => get_post_meta( $post_id, 'wl_about_count', true ) ? (int) get_post_meta( $post_id, 'wl_about_count', true ) : 0,
122
+            'mentions' => get_post_meta( $post_id, 'wl_mentions_count', true )
123
+                ? (int) get_post_meta( $post_id, 'wl_mentions_count', true )
124
+                : 0,
125
+        );
126
+    }
127
+
128
+    /**
129
+     * Update counts if necessary post.
130
+     *
131
+     * @param $jsonld_arr
132
+     * @param $counts
133
+     * @param $post_id
134
+     *
135
+     * @return bool
136
+     */
137
+    private function update_counts_if_necessary_post( $jsonld_arr, &$counts, $post_id ) {
138
+        // Flag to indicate if we should make an API request.
139
+        $change_status = false;
140
+
141
+        // If the $jsonld_arr is empty but the counts were previously more than 0.
142
+        if ( empty( $jsonld_arr[0] ) ) {
143
+            return $this->reset_counts_if_non_zero_post( $counts, $post_id );
144
+        }
145
+
146
+        // Get data from the array.
147
+        $data = $jsonld_arr[0];
148
+
149
+        // Iterate over the counts array.
150
+        foreach ( $counts as $type => $type_count ) {
151
+            // Check if data has 'about' or 'mentions' and the count is different from the existing meta value.
152
+            if ( isset( $data[ $type ] ) ) {
153
+                $new_count = count( $data[ $type ] );
154
+                if ( $type_count !== $new_count ) {
155
+                    // Set flag to true if counts have changed.
156
+                    $change_status = true;
157
+
158
+                    // Update the counts array with new count.
159
+                    $counts[ $type ] = $new_count;
160
+
161
+                    // Update post meta with new count.
162
+                    update_post_meta( $post_id, 'wl_' . $type . '_count', $new_count );
163
+                    continue;
164
+                }
165
+            }
166
+
167
+            if ( ! isset( $data[ $type ] ) && $type_count > 0 ) {
168
+                // If the 'about' or 'mentions' has become empty, set it to 0.
169
+                $change_status   = true;
170
+                $counts[ $type ] = 0;
171
+                update_post_meta( $post_id, 'wl_' . $type . '_count', 0 );
172
+            }
173
+        }
174
+
175
+        return $change_status;
176
+    }
177
+
178
+    /**
179
+     * Reset counts if non zero post.
180
+     *
181
+     * @param $counts
182
+     * @param $post_id
183
+     *
184
+     * @return bool
185
+     */
186
+    private function reset_counts_if_non_zero_post( &$counts, $post_id ) {
187
+        $change_status = false;
188
+
189
+        foreach ( $counts as $type => $type_count ) {
190
+            if ( $type_count > 0 ) {
191
+                $change_status   = true;
192
+                $counts[ $type ] = 0;
193
+                update_post_meta( $post_id, 'wl_' . $type . '_count', 0 );
194
+            }
195
+        }
196
+
197
+        return $change_status;
198
+    }
199
+
200
+    /**
201
+     * Send api request post.
202
+     *
203
+     * @param $counts
204
+     * @param $permalink string The web page URL
205
+     */
206
+    private function send_api_request_post( $counts, $permalink ) {
207
+        // If the count has changed, make the API request.
208
+        // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
209
+        $blocking = apply_filters( 'wl_feature__enable__sync-blocking', false );
210
+
211
+        // Apply the filter to the request args
212
+        $this->api_service->request(
213
+            'POST',
214
+            '/plugin/events',
215
+            array( 'Content-Type' => 'application/json' ),
216
+            wp_json_encode(
217
+                array(
218
+                    'source' => 'jsonld',
219
+                    'args'   => array(
220
+                        array( 'about_count' => $counts['about'] ),
221
+                        array( 'mentions_count' => $counts['mentions'] ),
222
+                    ),
223
+                    'url'    => $permalink,
224
+                )
225
+            ),
226
+            $blocking ? 60 : 0.001,
227
+            null,
228
+            array( 'blocking' => $blocking )
229
+        );
230
+    }
231 231
 }
Please login to merge, or discard this patch.
Spacing   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 	/**
25 25
 	 * @param Api_Service $api_service
26 26
 	 */
27
-	public function __construct( Api_Service $api_service ) {
27
+	public function __construct(Api_Service $api_service) {
28 28
 		$this->api_service = $api_service;
29 29
 	}
30 30
 
@@ -32,25 +32,25 @@  discard block
 block discarded – undo
32 32
 	 * Register hooks.
33 33
 	 */
34 34
 	public function register_hooks() {
35
-		add_filter( 'wl_after_get_jsonld', array( $this, 'handle_after_get_jsonld' ), 90, 3 );
36
-		add_filter( 'wprm_recipe_metadata', array( $this, 'handle_recipe_metadata' ), PHP_INT_MAX - 100, 2 );
35
+		add_filter('wl_after_get_jsonld', array($this, 'handle_after_get_jsonld'), 90, 3);
36
+		add_filter('wprm_recipe_metadata', array($this, 'handle_recipe_metadata'), PHP_INT_MAX - 100, 2);
37 37
 	}
38 38
 
39
-	public function handle_after_get_jsonld( $jsonld_arr, $post_id, $context ) {
39
+	public function handle_after_get_jsonld($jsonld_arr, $post_id, $context) {
40 40
 
41 41
 		if (
42 42
 			// We're not in a page context.
43 43
 			Jsonld_Context_Enum::PAGE !== $context ||
44 44
 			// It's a Recipe post.
45
-			$this->is_a_recipe_post( $post_id )
45
+			$this->is_a_recipe_post($post_id)
46 46
 		) {
47 47
 			return $jsonld_arr;
48 48
 		}
49 49
 
50
-		return $this->set_events_request( $jsonld_arr, $post_id );
50
+		return $this->set_events_request($jsonld_arr, $post_id);
51 51
 	}
52 52
 
53
-	private function is_a_recipe_post( $post_id ) {
53
+	private function is_a_recipe_post($post_id) {
54 54
 		global $wpdb;
55 55
 
56 56
 		return $wpdb->get_var(
@@ -72,11 +72,11 @@  discard block
 block discarded – undo
72 72
 	 *
73 73
 	 * @return mixed
74 74
 	 */
75
-	public function handle_recipe_metadata( $value, $recipe ) {
75
+	public function handle_recipe_metadata($value, $recipe) {
76 76
 		// We only handle the parent post.
77 77
 		$parent_post_id = $recipe->parent_post_id();
78
-		if ( is_numeric( $parent_post_id ) && 0 < $parent_post_id ) {
79
-			$this->set_events_request( array( $value ), $parent_post_id, Jsonld_Context_Enum::PAGE );
78
+		if (is_numeric($parent_post_id) && 0 < $parent_post_id) {
79
+			$this->set_events_request(array($value), $parent_post_id, Jsonld_Context_Enum::PAGE);
80 80
 		}
81 81
 
82 82
 		return $value;
@@ -90,20 +90,20 @@  discard block
 block discarded – undo
90 90
 	 *
91 91
 	 * @return array
92 92
 	 */
93
-	private function set_events_request( $jsonld_arr, $post_id ) {
93
+	private function set_events_request($jsonld_arr, $post_id) {
94 94
 
95 95
 		// Bail out if we can't get a permalink.
96
-		$permalink = get_permalink( $post_id );
97
-		if ( false === $permalink ) {
96
+		$permalink = get_permalink($post_id);
97
+		if (false === $permalink) {
98 98
 			return $jsonld_arr;
99 99
 		}
100 100
 
101
-		$counts = $this->get_initial_counts_post( $post_id );
101
+		$counts = $this->get_initial_counts_post($post_id);
102 102
 
103
-		$change_status = $this->update_counts_if_necessary_post( $jsonld_arr, $counts, $post_id );
103
+		$change_status = $this->update_counts_if_necessary_post($jsonld_arr, $counts, $post_id);
104 104
 
105
-		if ( $change_status ) {
106
-			$this->send_api_request_post( $counts, $permalink );
105
+		if ($change_status) {
106
+			$this->send_api_request_post($counts, $permalink);
107 107
 		}
108 108
 
109 109
 		return $jsonld_arr;
@@ -116,11 +116,11 @@  discard block
 block discarded – undo
116 116
 	 *
117 117
 	 * @return int[]
118 118
 	 */
119
-	private function get_initial_counts_post( $post_id ) {
119
+	private function get_initial_counts_post($post_id) {
120 120
 		return array(
121
-			'about'    => get_post_meta( $post_id, 'wl_about_count', true ) ? (int) get_post_meta( $post_id, 'wl_about_count', true ) : 0,
122
-			'mentions' => get_post_meta( $post_id, 'wl_mentions_count', true )
123
-				? (int) get_post_meta( $post_id, 'wl_mentions_count', true )
121
+			'about'    => get_post_meta($post_id, 'wl_about_count', true) ? (int) get_post_meta($post_id, 'wl_about_count', true) : 0,
122
+			'mentions' => get_post_meta($post_id, 'wl_mentions_count', true)
123
+				? (int) get_post_meta($post_id, 'wl_mentions_count', true)
124 124
 				: 0,
125 125
 		);
126 126
 	}
@@ -134,41 +134,41 @@  discard block
 block discarded – undo
134 134
 	 *
135 135
 	 * @return bool
136 136
 	 */
137
-	private function update_counts_if_necessary_post( $jsonld_arr, &$counts, $post_id ) {
137
+	private function update_counts_if_necessary_post($jsonld_arr, &$counts, $post_id) {
138 138
 		// Flag to indicate if we should make an API request.
139 139
 		$change_status = false;
140 140
 
141 141
 		// If the $jsonld_arr is empty but the counts were previously more than 0.
142
-		if ( empty( $jsonld_arr[0] ) ) {
143
-			return $this->reset_counts_if_non_zero_post( $counts, $post_id );
142
+		if (empty($jsonld_arr[0])) {
143
+			return $this->reset_counts_if_non_zero_post($counts, $post_id);
144 144
 		}
145 145
 
146 146
 		// Get data from the array.
147 147
 		$data = $jsonld_arr[0];
148 148
 
149 149
 		// Iterate over the counts array.
150
-		foreach ( $counts as $type => $type_count ) {
150
+		foreach ($counts as $type => $type_count) {
151 151
 			// Check if data has 'about' or 'mentions' and the count is different from the existing meta value.
152
-			if ( isset( $data[ $type ] ) ) {
153
-				$new_count = count( $data[ $type ] );
154
-				if ( $type_count !== $new_count ) {
152
+			if (isset($data[$type])) {
153
+				$new_count = count($data[$type]);
154
+				if ($type_count !== $new_count) {
155 155
 					// Set flag to true if counts have changed.
156 156
 					$change_status = true;
157 157
 
158 158
 					// Update the counts array with new count.
159
-					$counts[ $type ] = $new_count;
159
+					$counts[$type] = $new_count;
160 160
 
161 161
 					// Update post meta with new count.
162
-					update_post_meta( $post_id, 'wl_' . $type . '_count', $new_count );
162
+					update_post_meta($post_id, 'wl_'.$type.'_count', $new_count);
163 163
 					continue;
164 164
 				}
165 165
 			}
166 166
 
167
-			if ( ! isset( $data[ $type ] ) && $type_count > 0 ) {
167
+			if ( ! isset($data[$type]) && $type_count > 0) {
168 168
 				// If the 'about' or 'mentions' has become empty, set it to 0.
169 169
 				$change_status   = true;
170
-				$counts[ $type ] = 0;
171
-				update_post_meta( $post_id, 'wl_' . $type . '_count', 0 );
170
+				$counts[$type] = 0;
171
+				update_post_meta($post_id, 'wl_'.$type.'_count', 0);
172 172
 			}
173 173
 		}
174 174
 
@@ -183,14 +183,14 @@  discard block
 block discarded – undo
183 183
 	 *
184 184
 	 * @return bool
185 185
 	 */
186
-	private function reset_counts_if_non_zero_post( &$counts, $post_id ) {
186
+	private function reset_counts_if_non_zero_post(&$counts, $post_id) {
187 187
 		$change_status = false;
188 188
 
189
-		foreach ( $counts as $type => $type_count ) {
190
-			if ( $type_count > 0 ) {
189
+		foreach ($counts as $type => $type_count) {
190
+			if ($type_count > 0) {
191 191
 				$change_status   = true;
192
-				$counts[ $type ] = 0;
193
-				update_post_meta( $post_id, 'wl_' . $type . '_count', 0 );
192
+				$counts[$type] = 0;
193
+				update_post_meta($post_id, 'wl_'.$type.'_count', 0);
194 194
 			}
195 195
 		}
196 196
 
@@ -203,29 +203,29 @@  discard block
 block discarded – undo
203 203
 	 * @param $counts
204 204
 	 * @param $permalink string The web page URL
205 205
 	 */
206
-	private function send_api_request_post( $counts, $permalink ) {
206
+	private function send_api_request_post($counts, $permalink) {
207 207
 		// If the count has changed, make the API request.
208 208
 		// phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
209
-		$blocking = apply_filters( 'wl_feature__enable__sync-blocking', false );
209
+		$blocking = apply_filters('wl_feature__enable__sync-blocking', false);
210 210
 
211 211
 		// Apply the filter to the request args
212 212
 		$this->api_service->request(
213 213
 			'POST',
214 214
 			'/plugin/events',
215
-			array( 'Content-Type' => 'application/json' ),
215
+			array('Content-Type' => 'application/json'),
216 216
 			wp_json_encode(
217 217
 				array(
218 218
 					'source' => 'jsonld',
219 219
 					'args'   => array(
220
-						array( 'about_count' => $counts['about'] ),
221
-						array( 'mentions_count' => $counts['mentions'] ),
220
+						array('about_count' => $counts['about']),
221
+						array('mentions_count' => $counts['mentions']),
222 222
 					),
223 223
 					'url'    => $permalink,
224 224
 				)
225 225
 			),
226 226
 			$blocking ? 60 : 0.001,
227 227
 			null,
228
-			array( 'blocking' => $blocking )
228
+			array('blocking' => $blocking)
229 229
 		);
230 230
 	}
231 231
 }
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.11.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', '8.10', 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.11.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', '8.10', 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.11.0', '<' );
28
+		$check = version_compare(WPRM_VERSION, '8.1.0', '>=')
29
+				&& version_compare(WPRM_VERSION, '8.11.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', '8.10', WPRM_VERSION )
35
+				sprintf(__('WordLift Food KG support requires WP Recipe Maker %1$s-%2$s, %3$s found.', 'wordlift'), '8.1', '8.10', WPRM_VERSION)
36 36
 			);
37 37
 		}
38 38
 
Please login to merge, or discard this patch.