Completed
Push — develop ( dfb4ea...a280ae )
by David
02:05 queued 13s
created
src/install/class-wordlift-install-service.php 1 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/classes/jsonld/class-jsonld-article-wrapper.php 1 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.