Completed
Push — develop ( dfb4ea...a280ae )
by David
02:05 queued 13s
created
src/install/class-wordlift-install-service.php 2 patches
Indentation   +194 added lines, -194 removed lines patch added patch discarded remove patch
@@ -18,204 +18,204 @@
 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
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-52-1.php';
85
-
86
-		// Get the install services.
87
-		$this->installs = array(
88
-			new Wordlift_Install_1_0_0(),
89
-			new Wordlift_Install_3_10_0(),
90
-			new Wordlift_Install_3_12_0(),
91
-			new Wordlift_Install_3_14_0(),
92
-			new Wordlift_Install_3_15_0(),
93
-			new Wordlift_Install_3_18_0(),
94
-			new Wordlift_Install_3_18_3(),
95
-			new Wordlift_Install_3_19_5(),
96
-			new Wordlift_Install_3_20_0(),
97
-
98
-			/*
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
+        require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-52-1.php';
85
+
86
+        // Get the install services.
87
+        $this->installs = array(
88
+            new Wordlift_Install_1_0_0(),
89
+            new Wordlift_Install_3_10_0(),
90
+            new Wordlift_Install_3_12_0(),
91
+            new Wordlift_Install_3_14_0(),
92
+            new Wordlift_Install_3_15_0(),
93
+            new Wordlift_Install_3_18_0(),
94
+            new Wordlift_Install_3_18_3(),
95
+            new Wordlift_Install_3_19_5(),
96
+            new Wordlift_Install_3_20_0(),
97
+
98
+            /*
99 99
 			 * This should be enabled with #852.
100 100
 			 */
101
-			new Wordlift_Install_Package_Type(),
102
-			new Wordlift_Install_3_23_4(),
103
-			new Wordlift_Install_3_24_2(),
104
-			new Wordlift_Install_3_25_0(),
105
-			new Wordlift_Install_3_27_0(),
106
-			new Wordlift_Install_3_27_1(),
107
-			new Wordlift_Install_3_28_0(),
108
-			// Add column to represent term
109
-			new Wordlift_Install_3_32_0(),
110
-			// Add the entities table.
111
-			new Wordlift_Install_3_33_9(),
112
-			// When woocommerce extension installed, acf4so should be installed automatically.
113
-			new Wordlift_Install_3_36_0(),
101
+            new Wordlift_Install_Package_Type(),
102
+            new Wordlift_Install_3_23_4(),
103
+            new Wordlift_Install_3_24_2(),
104
+            new Wordlift_Install_3_25_0(),
105
+            new Wordlift_Install_3_27_0(),
106
+            new Wordlift_Install_3_27_1(),
107
+            new Wordlift_Install_3_28_0(),
108
+            // Add column to represent term
109
+            new Wordlift_Install_3_32_0(),
110
+            // Add the entities table.
111
+            new Wordlift_Install_3_33_9(),
112
+            // When woocommerce extension installed, acf4so should be installed automatically.
113
+            new Wordlift_Install_3_36_0(),
114 114
 
115
-			new Wordlift_Install_3_38_5(),
116
-			new Wordlift_Install_3_39_1(),
117
-
118
-			// See #1621.
119
-			new Wordlift_Install_3_40_1(),
120
-
121
-			// @link https://github.com/insideout10/wordlift-plugin/issues/1627
122
-			new Wordlift_Install_3_40_2(),
123
-
124
-			new Wordlift_Install_3_41_0(),
125
-			new Wordlift_Install_3_42_0(),
126
-
127
-			new Wordlift_Install_3_44_1(),
128
-			new Wordlift_Install_3_44_4(),
129
-
130
-			new Wordlift_Install_3_45_0(),
131
-			new Wordlift_Install_3_45_1(),
132
-
133
-			new Wordlift_Install_3_49_2(),
134
-
135
-			new Wordlift_Install_3_52_1(),
136
-		);
137
-		self::$instance = $this;
138
-
139
-		$this->log = Wordlift_Log_Service::get_logger( get_class() );
140
-
141
-		add_action( 'init', array( $this, 'install' ) );
142
-
143
-	}
144
-
145
-	/**
146
-	 * Get the singleton instance.
147
-	 *
148
-	 * @since 3.18.0
149
-	 */
150
-	public static function get_instance() {
151
-
152
-		return self::$instance;
153
-	}
154
-
155
-	/**
156
-	 * Loop thought all versions and install the updates.
157
-	 *
158
-	 * @return void
159
-	 * @since 3.18.0
160
-	 *
161
-	 * @since 3.20.0 use a transient to avoid concurrent installation calls.
162
-	 */
163
-	public function install() {
164
-
165
-		$version = null;
166
-
167
-		if ( $this->install_required() && false === get_transient( '_wl_installing' ) ) {
168
-			set_transient( '_wl_installing', true, 5 * MINUTE_IN_SECONDS );
169
-			/** @var Wordlift_Install $install */
170
-			foreach ( $this->installs as $install ) {
171
-				// Get the install version.
172
-				$version = $install->get_version();
173
-
174
-				if ( version_compare( $version, $this->get_current_version(), '>' )
175
-					 || $install->must_install() ) {
176
-					$class_name = get_class( $install );
177
-
178
-					$this->log->info( "Current version is {$this->get_current_version()}, installing $class_name..." );
179
-					// Install version.
180
-					$install->install();
181
-
182
-					$this->log->info( "$class_name installed." );
183
-
184
-					// Bump the version.
185
-					update_option( 'wl_db_version', $version );
186
-				}
187
-			}
188
-
189
-			// phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged
190
-			@delete_transient( '_wl_installing' );
191
-
192
-		}
193
-
194
-	}
195
-
196
-	private function install_required() {
197
-
198
-		/** @var Wordlift_Install $install */
199
-		foreach ( $this->installs as $install ) {
200
-			// Get the install version.
201
-			$version = $install->get_version();
202
-
203
-			if ( version_compare( $version, $this->get_current_version(), '>' )
204
-				 || $install->must_install() ) {
205
-				return true;
206
-			}
207
-		}
115
+            new Wordlift_Install_3_38_5(),
116
+            new Wordlift_Install_3_39_1(),
117
+
118
+            // See #1621.
119
+            new Wordlift_Install_3_40_1(),
120
+
121
+            // @link https://github.com/insideout10/wordlift-plugin/issues/1627
122
+            new Wordlift_Install_3_40_2(),
123
+
124
+            new Wordlift_Install_3_41_0(),
125
+            new Wordlift_Install_3_42_0(),
126
+
127
+            new Wordlift_Install_3_44_1(),
128
+            new Wordlift_Install_3_44_4(),
129
+
130
+            new Wordlift_Install_3_45_0(),
131
+            new Wordlift_Install_3_45_1(),
132
+
133
+            new Wordlift_Install_3_49_2(),
134
+
135
+            new Wordlift_Install_3_52_1(),
136
+        );
137
+        self::$instance = $this;
138
+
139
+        $this->log = Wordlift_Log_Service::get_logger( get_class() );
140
+
141
+        add_action( 'init', array( $this, 'install' ) );
142
+
143
+    }
144
+
145
+    /**
146
+     * Get the singleton instance.
147
+     *
148
+     * @since 3.18.0
149
+     */
150
+    public static function get_instance() {
151
+
152
+        return self::$instance;
153
+    }
154
+
155
+    /**
156
+     * Loop thought all versions and install the updates.
157
+     *
158
+     * @return void
159
+     * @since 3.18.0
160
+     *
161
+     * @since 3.20.0 use a transient to avoid concurrent installation calls.
162
+     */
163
+    public function install() {
164
+
165
+        $version = null;
166
+
167
+        if ( $this->install_required() && false === get_transient( '_wl_installing' ) ) {
168
+            set_transient( '_wl_installing', true, 5 * MINUTE_IN_SECONDS );
169
+            /** @var Wordlift_Install $install */
170
+            foreach ( $this->installs as $install ) {
171
+                // Get the install version.
172
+                $version = $install->get_version();
173
+
174
+                if ( version_compare( $version, $this->get_current_version(), '>' )
175
+                     || $install->must_install() ) {
176
+                    $class_name = get_class( $install );
177
+
178
+                    $this->log->info( "Current version is {$this->get_current_version()}, installing $class_name..." );
179
+                    // Install version.
180
+                    $install->install();
181
+
182
+                    $this->log->info( "$class_name installed." );
183
+
184
+                    // Bump the version.
185
+                    update_option( 'wl_db_version', $version );
186
+                }
187
+            }
188
+
189
+            // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged
190
+            @delete_transient( '_wl_installing' );
191
+
192
+        }
193
+
194
+    }
195
+
196
+    private function install_required() {
197
+
198
+        /** @var Wordlift_Install $install */
199
+        foreach ( $this->installs as $install ) {
200
+            // Get the install version.
201
+            $version = $install->get_version();
202
+
203
+            if ( version_compare( $version, $this->get_current_version(), '>' )
204
+                 || $install->must_install() ) {
205
+                return true;
206
+            }
207
+        }
208 208
 
209
-		return false;
210
-	}
209
+        return false;
210
+    }
211 211
 
212
-	/**
213
-	 * Retrieve the current db version.
214
-	 *
215
-	 * @return type
216
-	 */
217
-	private function get_current_version() {
218
-		return get_option( 'wl_db_version', '0.0.0' );
219
-	}
212
+    /**
213
+     * Retrieve the current db version.
214
+     *
215
+     * @return type
216
+     */
217
+    private function get_current_version() {
218
+        return get_option( 'wl_db_version', '0.0.0' );
219
+    }
220 220
 
221 221
 }
Please login to merge, or discard this patch.
Spacing   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -49,39 +49,39 @@  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';
84
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-52-1.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
+		require_once plugin_dir_path(__DIR__).'install/class-wordlift-install-3-52-1.php';
85 85
 
86 86
 		// Get the install services.
87 87
 		$this->installs = array(
@@ -136,9 +136,9 @@  discard block
 block discarded – undo
136 136
 		);
137 137
 		self::$instance = $this;
138 138
 
139
-		$this->log = Wordlift_Log_Service::get_logger( get_class() );
139
+		$this->log = Wordlift_Log_Service::get_logger(get_class());
140 140
 
141
-		add_action( 'init', array( $this, 'install' ) );
141
+		add_action('init', array($this, 'install'));
142 142
 
143 143
 	}
144 144
 
@@ -164,30 +164,30 @@  discard block
 block discarded – undo
164 164
 
165 165
 		$version = null;
166 166
 
167
-		if ( $this->install_required() && false === get_transient( '_wl_installing' ) ) {
168
-			set_transient( '_wl_installing', true, 5 * MINUTE_IN_SECONDS );
167
+		if ($this->install_required() && false === get_transient('_wl_installing')) {
168
+			set_transient('_wl_installing', true, 5 * MINUTE_IN_SECONDS);
169 169
 			/** @var Wordlift_Install $install */
170
-			foreach ( $this->installs as $install ) {
170
+			foreach ($this->installs as $install) {
171 171
 				// Get the install version.
172 172
 				$version = $install->get_version();
173 173
 
174
-				if ( version_compare( $version, $this->get_current_version(), '>' )
175
-					 || $install->must_install() ) {
176
-					$class_name = get_class( $install );
174
+				if (version_compare($version, $this->get_current_version(), '>')
175
+					 || $install->must_install()) {
176
+					$class_name = get_class($install);
177 177
 
178
-					$this->log->info( "Current version is {$this->get_current_version()}, installing $class_name..." );
178
+					$this->log->info("Current version is {$this->get_current_version()}, installing $class_name...");
179 179
 					// Install version.
180 180
 					$install->install();
181 181
 
182
-					$this->log->info( "$class_name installed." );
182
+					$this->log->info("$class_name installed.");
183 183
 
184 184
 					// Bump the version.
185
-					update_option( 'wl_db_version', $version );
185
+					update_option('wl_db_version', $version);
186 186
 				}
187 187
 			}
188 188
 
189 189
 			// phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged
190
-			@delete_transient( '_wl_installing' );
190
+			@delete_transient('_wl_installing');
191 191
 
192 192
 		}
193 193
 
@@ -196,12 +196,12 @@  discard block
 block discarded – undo
196 196
 	private function install_required() {
197 197
 
198 198
 		/** @var Wordlift_Install $install */
199
-		foreach ( $this->installs as $install ) {
199
+		foreach ($this->installs as $install) {
200 200
 			// Get the install version.
201 201
 			$version = $install->get_version();
202 202
 
203
-			if ( version_compare( $version, $this->get_current_version(), '>' )
204
-				 || $install->must_install() ) {
203
+			if (version_compare($version, $this->get_current_version(), '>')
204
+				 || $install->must_install()) {
205 205
 				return true;
206 206
 			}
207 207
 		}
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
 	 * @return type
216 216
 	 */
217 217
 	private function get_current_version() {
218
-		return get_option( 'wl_db_version', '0.0.0' );
218
+		return get_option('wl_db_version', '0.0.0');
219 219
 	}
220 220
 
221 221
 }
Please login to merge, or discard this patch.
src/install/class-wordlift-install-3-52-1.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -7,14 +7,14 @@
 block discarded – undo
7 7
  */
8 8
 class Wordlift_Install_3_52_1 extends Wordlift_Install {
9 9
 
10
-	/**
11
-	 * {@inheritdoc}
12
-	 */
13
-	protected static $version = '3.52.1';
10
+    /**
11
+     * {@inheritdoc}
12
+     */
13
+    protected static $version = '3.52.1';
14 14
 
15
-	public function install() {
16
-		// Since we're fixing JSON-LDs better flush them all.
17
-		Ttl_Cache::flush_all();
18
-	}
15
+    public function install() {
16
+        // Since we're fixing JSON-LDs better flush them all.
17
+        Ttl_Cache::flush_all();
18
+    }
19 19
 
20 20
 }
Please login to merge, or discard this patch.
src/classes/jsonld/class-jsonld-article-wrapper.php 2 patches
Indentation   +198 added lines, -198 removed lines patch added patch discarded remove patch
@@ -7,203 +7,203 @@
 block discarded – undo
7 7
 
8 8
 class Jsonld_Article_Wrapper {
9 9
 
10
-	public static $article_types = array(
11
-		'Article',
12
-		'AdvertiserContentArticle',
13
-		'NewsArticle',
14
-		'AnalysisNewsArticle',
15
-		'AskPublicNewsArticle',
16
-		'BackgroundNewsArticle',
17
-		'OpinionNewsArticle',
18
-		'ReportageNewsArticle',
19
-		'ReviewNewsArticle',
20
-		'Report',
21
-		'SatiricalArticle',
22
-		'ScholarlyArticle',
23
-		'MedicalScholarlyArticle',
24
-		'SocialMediaPosting',
25
-		'BlogPosting',
26
-		'LiveBlogPosting',
27
-		'DiscussionForumPosting',
28
-		'TechArticle',
29
-		'APIReference',
30
-	);
31
-
32
-	/**
33
-	 * @var Wordlift_Post_To_Jsonld_Converter
34
-	 */
35
-	private $post_to_jsonld_converter;
36
-	/**
37
-	 * @var \Wordlift_Cached_Post_Converter
38
-	 */
39
-	private $cached_postid_to_jsonld_converter;
40
-	/**
41
-	 * @var \Wordlift_Entity_Uri_Service
42
-	 */
43
-	private $entity_uri_service;
44
-
45
-	/**
46
-	 * Jsonld_Article_Wrapper constructor.
47
-	 *
48
-	 * @param Wordlift_Post_To_Jsonld_Converter $post_to_jsonld_converter
49
-	 * @param $cached_postid_to_jsonld_converter
50
-	 */
51
-	public function __construct( $post_to_jsonld_converter, $cached_postid_to_jsonld_converter ) {
52
-
53
-		$this->post_to_jsonld_converter = $post_to_jsonld_converter->new_instance_with_filters_disabled();
54
-
55
-		add_filter(
56
-			'wl_after_get_jsonld',
57
-			array(
58
-				$this,
59
-				'after_get_jsonld',
60
-			),
61
-			PHP_INT_MAX - 100,
62
-			3
63
-		);
64
-
65
-		$this->cached_postid_to_jsonld_converter = $cached_postid_to_jsonld_converter;
66
-
67
-		$this->entity_uri_service = \Wordlift_Entity_Uri_Service::get_instance();
68
-	}
69
-
70
-	public function after_get_jsonld( $jsonld, $post_id, $context ) {
71
-
72
-		// Invalid data structure
73
-		if ( ! is_array( $jsonld ) || ! isset( $jsonld[0] ) || ! is_array( $jsonld[0] ) ) {
74
-			return $jsonld;
75
-		}
76
-
77
-		if ( Jsonld_Context_Enum::PAGE !== $context
78
-			 // Returns true for "1", "true", "on" and "yes". Returns false otherwise.
79
-			 && ! filter_input( INPUT_GET, 'article_wrapper', FILTER_VALIDATE_BOOLEAN ) ) {
80
-			return $jsonld;
81
-		}
82
-
83
-		// Copy the 1st array element
84
-		$post_jsonld = $jsonld[0];
85
-
86
-		// Don't wrap in article if the json-ld is already about an Article (or its descendants). `@type` must be
87
-		// in the schema.org context, i.e. `Article`, not `http://schema.org/Article`.
88
-		if ( ! isset( $post_jsonld['@id'] ) || ! isset( $post_jsonld['@type'] ) || $this->is_article( $post_jsonld['@type'] ) ) {
89
-			return $jsonld;
90
-		}
91
-
92
-		$references      = array();
93
-		$reference_infos = array();
94
-
95
-		// Convert the post as Article.
96
-		$article_jsonld = $this->post_to_jsonld_converter->convert( $post_id, $references, $reference_infos, new Relations() );
97
-
98
-		$article_jsonld['@id'] = $post_jsonld['@id'] . '#article';
99
-		// Reset the type, since by default the type assigned via the Entity Type taxonomy is used.
100
-		$article_jsonld['@type'] = 'Article';
101
-		$article_jsonld['about'] = array( '@id' => $post_jsonld['@id'] );
102
-
103
-		// Copy over the URLs.
104
-		if ( isset( $post_jsonld['url'] ) ) {
105
-			$article_jsonld['url'] = $post_jsonld['url'];
106
-		}
107
-
108
-		array_unshift( $jsonld, $article_jsonld );
109
-
110
-		// Only add authors if the key is present.
111
-		if ( isset( $article_jsonld['author'] ) ) {
112
-			$this->add_author_data_if_missing( $jsonld, $article_jsonld['author'] );
113
-		}
114
-
115
-		return $jsonld;
116
-	}
117
-
118
-	/**
119
-	 * @param array            $jsonld
120
-	 * @param array|false|null $author Either a keyed or an indexed array.
121
-	 *
122
-	 * @return void
123
-	 */
124
-	private function add_author_data_if_missing( &$jsonld, $author ) {
125
-
126
-		// For each author when if the `@id` is present and if not, add the author data.
127
-		$entities_ids = $this->get_list_of_entities_ids( $author );
128
-		foreach ( $entities_ids as $entity_id ) {
129
-			if ( $this->is_author_entity_present_in_graph( $jsonld, $entity_id ) ) {
130
-				continue;
131
-			}
132
-
133
-			$author_data = $this->get_author_data_by_entity_id( $entity_id );
134
-
135
-			if ( ! is_array( $author_data ) || empty( $author_data ) ) {
136
-				continue;
137
-			}
138
-			$jsonld[] = $author_data;
139
-		}
140
-
141
-	}
142
-
143
-	/**
144
-	 * This function takes any input parameter and when it's an array, it'll return the @id properties in this array as
145
-	 * an array of `@id`s.
146
-	 *
147
-	 * @param mixed $items Preferably an array, either keyed or indexed.
148
-	 *
149
-	 * @return array An array of `@id`s. Empty if not found.
150
-	 */
151
-	private function get_list_of_entities_ids( $items ) {
152
-		// If this is not an array, then what are we doing here? we return an empty array.
153
-		if ( ! is_array( $items ) || empty( $items ) ) {
154
-			return array();
155
-		}
156
-
157
-		// If this is a keyed array and the `@id` is set, then we return that single `@id`.
158
-		if ( isset( $items['@id'] ) ) {
159
-			return array( $items['@id'] );
160
-		}
161
-
162
-		// Poor way to check whether this is an indexed array.
163
-		if ( ! isset( $items[0] ) ) {
164
-			return array();
165
-		}
166
-
167
-		// If this is an indexed array then we return the `@id` for all the items in the array.
168
-		return array_filter( array_column( $items, '@id' ) );
169
-	}
170
-
171
-	private function is_article( $schema_types ) {
172
-
173
-		$array_intersect = array_intersect( self::$article_types, (array) $schema_types );
174
-
175
-		return ! empty( $array_intersect );
176
-	}
177
-
178
-	private function get_author_data_by_entity_id( $author_linked_entity_id ) {
179
-
180
-		$author_entity_post = $this->entity_uri_service->get_entity( $author_linked_entity_id );
181
-
182
-		if ( ! $author_entity_post instanceof \WP_Post ) {
183
-			return false;
184
-		}
185
-
186
-		$references      = array();
187
-		$reference_infos = array();
188
-
189
-		return $this->cached_postid_to_jsonld_converter->convert(
190
-			$author_entity_post->ID,
191
-			$references,
192
-			$reference_infos,
193
-			new Relations()
194
-		);
195
-
196
-	}
197
-
198
-	private function is_author_entity_present_in_graph( $jsonld, $author_entity_id ) {
199
-
200
-		foreach ( $jsonld as $item ) {
201
-			if ( $item && array_key_exists( '@id', $item ) && $item['@id'] === $author_entity_id ) {
202
-				return true;
203
-			}
204
-		}
205
-
206
-		return false;
207
-	}
10
+    public static $article_types = array(
11
+        'Article',
12
+        'AdvertiserContentArticle',
13
+        'NewsArticle',
14
+        'AnalysisNewsArticle',
15
+        'AskPublicNewsArticle',
16
+        'BackgroundNewsArticle',
17
+        'OpinionNewsArticle',
18
+        'ReportageNewsArticle',
19
+        'ReviewNewsArticle',
20
+        'Report',
21
+        'SatiricalArticle',
22
+        'ScholarlyArticle',
23
+        'MedicalScholarlyArticle',
24
+        'SocialMediaPosting',
25
+        'BlogPosting',
26
+        'LiveBlogPosting',
27
+        'DiscussionForumPosting',
28
+        'TechArticle',
29
+        'APIReference',
30
+    );
31
+
32
+    /**
33
+     * @var Wordlift_Post_To_Jsonld_Converter
34
+     */
35
+    private $post_to_jsonld_converter;
36
+    /**
37
+     * @var \Wordlift_Cached_Post_Converter
38
+     */
39
+    private $cached_postid_to_jsonld_converter;
40
+    /**
41
+     * @var \Wordlift_Entity_Uri_Service
42
+     */
43
+    private $entity_uri_service;
44
+
45
+    /**
46
+     * Jsonld_Article_Wrapper constructor.
47
+     *
48
+     * @param Wordlift_Post_To_Jsonld_Converter $post_to_jsonld_converter
49
+     * @param $cached_postid_to_jsonld_converter
50
+     */
51
+    public function __construct( $post_to_jsonld_converter, $cached_postid_to_jsonld_converter ) {
52
+
53
+        $this->post_to_jsonld_converter = $post_to_jsonld_converter->new_instance_with_filters_disabled();
54
+
55
+        add_filter(
56
+            'wl_after_get_jsonld',
57
+            array(
58
+                $this,
59
+                'after_get_jsonld',
60
+            ),
61
+            PHP_INT_MAX - 100,
62
+            3
63
+        );
64
+
65
+        $this->cached_postid_to_jsonld_converter = $cached_postid_to_jsonld_converter;
66
+
67
+        $this->entity_uri_service = \Wordlift_Entity_Uri_Service::get_instance();
68
+    }
69
+
70
+    public function after_get_jsonld( $jsonld, $post_id, $context ) {
71
+
72
+        // Invalid data structure
73
+        if ( ! is_array( $jsonld ) || ! isset( $jsonld[0] ) || ! is_array( $jsonld[0] ) ) {
74
+            return $jsonld;
75
+        }
76
+
77
+        if ( Jsonld_Context_Enum::PAGE !== $context
78
+                // Returns true for "1", "true", "on" and "yes". Returns false otherwise.
79
+             && ! filter_input( INPUT_GET, 'article_wrapper', FILTER_VALIDATE_BOOLEAN ) ) {
80
+            return $jsonld;
81
+        }
82
+
83
+        // Copy the 1st array element
84
+        $post_jsonld = $jsonld[0];
85
+
86
+        // Don't wrap in article if the json-ld is already about an Article (or its descendants). `@type` must be
87
+        // in the schema.org context, i.e. `Article`, not `http://schema.org/Article`.
88
+        if ( ! isset( $post_jsonld['@id'] ) || ! isset( $post_jsonld['@type'] ) || $this->is_article( $post_jsonld['@type'] ) ) {
89
+            return $jsonld;
90
+        }
91
+
92
+        $references      = array();
93
+        $reference_infos = array();
94
+
95
+        // Convert the post as Article.
96
+        $article_jsonld = $this->post_to_jsonld_converter->convert( $post_id, $references, $reference_infos, new Relations() );
97
+
98
+        $article_jsonld['@id'] = $post_jsonld['@id'] . '#article';
99
+        // Reset the type, since by default the type assigned via the Entity Type taxonomy is used.
100
+        $article_jsonld['@type'] = 'Article';
101
+        $article_jsonld['about'] = array( '@id' => $post_jsonld['@id'] );
102
+
103
+        // Copy over the URLs.
104
+        if ( isset( $post_jsonld['url'] ) ) {
105
+            $article_jsonld['url'] = $post_jsonld['url'];
106
+        }
107
+
108
+        array_unshift( $jsonld, $article_jsonld );
109
+
110
+        // Only add authors if the key is present.
111
+        if ( isset( $article_jsonld['author'] ) ) {
112
+            $this->add_author_data_if_missing( $jsonld, $article_jsonld['author'] );
113
+        }
114
+
115
+        return $jsonld;
116
+    }
117
+
118
+    /**
119
+     * @param array            $jsonld
120
+     * @param array|false|null $author Either a keyed or an indexed array.
121
+     *
122
+     * @return void
123
+     */
124
+    private function add_author_data_if_missing( &$jsonld, $author ) {
125
+
126
+        // For each author when if the `@id` is present and if not, add the author data.
127
+        $entities_ids = $this->get_list_of_entities_ids( $author );
128
+        foreach ( $entities_ids as $entity_id ) {
129
+            if ( $this->is_author_entity_present_in_graph( $jsonld, $entity_id ) ) {
130
+                continue;
131
+            }
132
+
133
+            $author_data = $this->get_author_data_by_entity_id( $entity_id );
134
+
135
+            if ( ! is_array( $author_data ) || empty( $author_data ) ) {
136
+                continue;
137
+            }
138
+            $jsonld[] = $author_data;
139
+        }
140
+
141
+    }
142
+
143
+    /**
144
+     * This function takes any input parameter and when it's an array, it'll return the @id properties in this array as
145
+     * an array of `@id`s.
146
+     *
147
+     * @param mixed $items Preferably an array, either keyed or indexed.
148
+     *
149
+     * @return array An array of `@id`s. Empty if not found.
150
+     */
151
+    private function get_list_of_entities_ids( $items ) {
152
+        // If this is not an array, then what are we doing here? we return an empty array.
153
+        if ( ! is_array( $items ) || empty( $items ) ) {
154
+            return array();
155
+        }
156
+
157
+        // If this is a keyed array and the `@id` is set, then we return that single `@id`.
158
+        if ( isset( $items['@id'] ) ) {
159
+            return array( $items['@id'] );
160
+        }
161
+
162
+        // Poor way to check whether this is an indexed array.
163
+        if ( ! isset( $items[0] ) ) {
164
+            return array();
165
+        }
166
+
167
+        // If this is an indexed array then we return the `@id` for all the items in the array.
168
+        return array_filter( array_column( $items, '@id' ) );
169
+    }
170
+
171
+    private function is_article( $schema_types ) {
172
+
173
+        $array_intersect = array_intersect( self::$article_types, (array) $schema_types );
174
+
175
+        return ! empty( $array_intersect );
176
+    }
177
+
178
+    private function get_author_data_by_entity_id( $author_linked_entity_id ) {
179
+
180
+        $author_entity_post = $this->entity_uri_service->get_entity( $author_linked_entity_id );
181
+
182
+        if ( ! $author_entity_post instanceof \WP_Post ) {
183
+            return false;
184
+        }
185
+
186
+        $references      = array();
187
+        $reference_infos = array();
188
+
189
+        return $this->cached_postid_to_jsonld_converter->convert(
190
+            $author_entity_post->ID,
191
+            $references,
192
+            $reference_infos,
193
+            new Relations()
194
+        );
195
+
196
+    }
197
+
198
+    private function is_author_entity_present_in_graph( $jsonld, $author_entity_id ) {
199
+
200
+        foreach ( $jsonld as $item ) {
201
+            if ( $item && array_key_exists( '@id', $item ) && $item['@id'] === $author_entity_id ) {
202
+                return true;
203
+            }
204
+        }
205
+
206
+        return false;
207
+    }
208 208
 
209 209
 }
Please login to merge, or discard this patch.
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 	 * @param Wordlift_Post_To_Jsonld_Converter $post_to_jsonld_converter
49 49
 	 * @param $cached_postid_to_jsonld_converter
50 50
 	 */
51
-	public function __construct( $post_to_jsonld_converter, $cached_postid_to_jsonld_converter ) {
51
+	public function __construct($post_to_jsonld_converter, $cached_postid_to_jsonld_converter) {
52 52
 
53 53
 		$this->post_to_jsonld_converter = $post_to_jsonld_converter->new_instance_with_filters_disabled();
54 54
 
@@ -67,16 +67,16 @@  discard block
 block discarded – undo
67 67
 		$this->entity_uri_service = \Wordlift_Entity_Uri_Service::get_instance();
68 68
 	}
69 69
 
70
-	public function after_get_jsonld( $jsonld, $post_id, $context ) {
70
+	public function after_get_jsonld($jsonld, $post_id, $context) {
71 71
 
72 72
 		// Invalid data structure
73
-		if ( ! is_array( $jsonld ) || ! isset( $jsonld[0] ) || ! is_array( $jsonld[0] ) ) {
73
+		if ( ! is_array($jsonld) || ! isset($jsonld[0]) || ! is_array($jsonld[0])) {
74 74
 			return $jsonld;
75 75
 		}
76 76
 
77
-		if ( Jsonld_Context_Enum::PAGE !== $context
77
+		if (Jsonld_Context_Enum::PAGE !== $context
78 78
 			 // Returns true for "1", "true", "on" and "yes". Returns false otherwise.
79
-			 && ! filter_input( INPUT_GET, 'article_wrapper', FILTER_VALIDATE_BOOLEAN ) ) {
79
+			 && ! filter_input(INPUT_GET, 'article_wrapper', FILTER_VALIDATE_BOOLEAN)) {
80 80
 			return $jsonld;
81 81
 		}
82 82
 
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 
86 86
 		// Don't wrap in article if the json-ld is already about an Article (or its descendants). `@type` must be
87 87
 		// in the schema.org context, i.e. `Article`, not `http://schema.org/Article`.
88
-		if ( ! isset( $post_jsonld['@id'] ) || ! isset( $post_jsonld['@type'] ) || $this->is_article( $post_jsonld['@type'] ) ) {
88
+		if ( ! isset($post_jsonld['@id']) || ! isset($post_jsonld['@type']) || $this->is_article($post_jsonld['@type'])) {
89 89
 			return $jsonld;
90 90
 		}
91 91
 
@@ -93,23 +93,23 @@  discard block
 block discarded – undo
93 93
 		$reference_infos = array();
94 94
 
95 95
 		// Convert the post as Article.
96
-		$article_jsonld = $this->post_to_jsonld_converter->convert( $post_id, $references, $reference_infos, new Relations() );
96
+		$article_jsonld = $this->post_to_jsonld_converter->convert($post_id, $references, $reference_infos, new Relations());
97 97
 
98
-		$article_jsonld['@id'] = $post_jsonld['@id'] . '#article';
98
+		$article_jsonld['@id'] = $post_jsonld['@id'].'#article';
99 99
 		// Reset the type, since by default the type assigned via the Entity Type taxonomy is used.
100 100
 		$article_jsonld['@type'] = 'Article';
101
-		$article_jsonld['about'] = array( '@id' => $post_jsonld['@id'] );
101
+		$article_jsonld['about'] = array('@id' => $post_jsonld['@id']);
102 102
 
103 103
 		// Copy over the URLs.
104
-		if ( isset( $post_jsonld['url'] ) ) {
104
+		if (isset($post_jsonld['url'])) {
105 105
 			$article_jsonld['url'] = $post_jsonld['url'];
106 106
 		}
107 107
 
108
-		array_unshift( $jsonld, $article_jsonld );
108
+		array_unshift($jsonld, $article_jsonld);
109 109
 
110 110
 		// Only add authors if the key is present.
111
-		if ( isset( $article_jsonld['author'] ) ) {
112
-			$this->add_author_data_if_missing( $jsonld, $article_jsonld['author'] );
111
+		if (isset($article_jsonld['author'])) {
112
+			$this->add_author_data_if_missing($jsonld, $article_jsonld['author']);
113 113
 		}
114 114
 
115 115
 		return $jsonld;
@@ -121,18 +121,18 @@  discard block
 block discarded – undo
121 121
 	 *
122 122
 	 * @return void
123 123
 	 */
124
-	private function add_author_data_if_missing( &$jsonld, $author ) {
124
+	private function add_author_data_if_missing(&$jsonld, $author) {
125 125
 
126 126
 		// For each author when if the `@id` is present and if not, add the author data.
127
-		$entities_ids = $this->get_list_of_entities_ids( $author );
128
-		foreach ( $entities_ids as $entity_id ) {
129
-			if ( $this->is_author_entity_present_in_graph( $jsonld, $entity_id ) ) {
127
+		$entities_ids = $this->get_list_of_entities_ids($author);
128
+		foreach ($entities_ids as $entity_id) {
129
+			if ($this->is_author_entity_present_in_graph($jsonld, $entity_id)) {
130 130
 				continue;
131 131
 			}
132 132
 
133
-			$author_data = $this->get_author_data_by_entity_id( $entity_id );
133
+			$author_data = $this->get_author_data_by_entity_id($entity_id);
134 134
 
135
-			if ( ! is_array( $author_data ) || empty( $author_data ) ) {
135
+			if ( ! is_array($author_data) || empty($author_data)) {
136 136
 				continue;
137 137
 			}
138 138
 			$jsonld[] = $author_data;
@@ -148,38 +148,38 @@  discard block
 block discarded – undo
148 148
 	 *
149 149
 	 * @return array An array of `@id`s. Empty if not found.
150 150
 	 */
151
-	private function get_list_of_entities_ids( $items ) {
151
+	private function get_list_of_entities_ids($items) {
152 152
 		// If this is not an array, then what are we doing here? we return an empty array.
153
-		if ( ! is_array( $items ) || empty( $items ) ) {
153
+		if ( ! is_array($items) || empty($items)) {
154 154
 			return array();
155 155
 		}
156 156
 
157 157
 		// If this is a keyed array and the `@id` is set, then we return that single `@id`.
158
-		if ( isset( $items['@id'] ) ) {
159
-			return array( $items['@id'] );
158
+		if (isset($items['@id'])) {
159
+			return array($items['@id']);
160 160
 		}
161 161
 
162 162
 		// Poor way to check whether this is an indexed array.
163
-		if ( ! isset( $items[0] ) ) {
163
+		if ( ! isset($items[0])) {
164 164
 			return array();
165 165
 		}
166 166
 
167 167
 		// If this is an indexed array then we return the `@id` for all the items in the array.
168
-		return array_filter( array_column( $items, '@id' ) );
168
+		return array_filter(array_column($items, '@id'));
169 169
 	}
170 170
 
171
-	private function is_article( $schema_types ) {
171
+	private function is_article($schema_types) {
172 172
 
173
-		$array_intersect = array_intersect( self::$article_types, (array) $schema_types );
173
+		$array_intersect = array_intersect(self::$article_types, (array) $schema_types);
174 174
 
175
-		return ! empty( $array_intersect );
175
+		return ! empty($array_intersect);
176 176
 	}
177 177
 
178
-	private function get_author_data_by_entity_id( $author_linked_entity_id ) {
178
+	private function get_author_data_by_entity_id($author_linked_entity_id) {
179 179
 
180
-		$author_entity_post = $this->entity_uri_service->get_entity( $author_linked_entity_id );
180
+		$author_entity_post = $this->entity_uri_service->get_entity($author_linked_entity_id);
181 181
 
182
-		if ( ! $author_entity_post instanceof \WP_Post ) {
182
+		if ( ! $author_entity_post instanceof \WP_Post) {
183 183
 			return false;
184 184
 		}
185 185
 
@@ -195,10 +195,10 @@  discard block
 block discarded – undo
195 195
 
196 196
 	}
197 197
 
198
-	private function is_author_entity_present_in_graph( $jsonld, $author_entity_id ) {
198
+	private function is_author_entity_present_in_graph($jsonld, $author_entity_id) {
199 199
 
200
-		foreach ( $jsonld as $item ) {
201
-			if ( $item && array_key_exists( '@id', $item ) && $item['@id'] === $author_entity_id ) {
200
+		foreach ($jsonld as $item) {
201
+			if ($item && array_key_exists('@id', $item) && $item['@id'] === $author_entity_id) {
202 202
 				return true;
203 203
 			}
204 204
 		}
Please login to merge, or discard this patch.