Completed
Push — develop ( 36a199...920e68 )
by David
01:14
created
src/install/class-wordlift-install-3-49-2.php 1 patch
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.
src/install/class-wordlift-install-service.php 1 patch
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.
src/modules/events/includes/Term_Entity/Events_Term_Entity_Jsonld.php 1 patch
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.
src/modules/events/includes/Post_Entity/Events_Post_Entity_Jsonld.php 1 patch
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.
src/modules/food-kg/includes/Preconditions.php 1 patch
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.