Completed
Push — develop ( 20572c...a02698 )
by Naveen
01:15 queued 12s
created
src/wordlift.php 1 patch
Spacing   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -32,25 +32,25 @@  discard block
 block discarded – undo
32 32
 use Wordlift\Post\Post_Adapter;
33 33
 
34 34
 // If this file is called directly, abort.
35
-if ( ! defined( 'WPINC' ) ) {
35
+if ( ! defined('WPINC')) {
36 36
 	die;
37 37
 }
38 38
 
39
-define( 'WORDLIFT_VERSION', '3.40.1' );
39
+define('WORDLIFT_VERSION', '3.40.1');
40 40
 
41
-require_once __DIR__ . '/modules/common/load.php';
42
-require_once __DIR__ . '/modules/include-exclude/load.php';
41
+require_once __DIR__.'/modules/common/load.php';
42
+require_once __DIR__.'/modules/include-exclude/load.php';
43 43
 
44 44
 /**
45 45
  * Filter to disable WLP on any request, defaults to true.
46 46
  *
47 47
  * @since 3.33.6
48 48
  */
49
-if ( ! apply_filters( 'wl_is_enabled', true ) ) {
49
+if ( ! apply_filters('wl_is_enabled', true)) {
50 50
 	return;
51 51
 }
52 52
 
53
-require_once plugin_dir_path( __FILE__ ) . 'vendor/autoload.php';
53
+require_once plugin_dir_path(__FILE__).'vendor/autoload.php';
54 54
 
55 55
 /*
56 56
 	 * We introduce the WordLift autoloader, since we start using classes in namespaces, i.e. Wordlift\Http.
@@ -60,15 +60,15 @@  discard block
 block discarded – undo
60 60
 wordlift_plugin_autoload_register();
61 61
 
62 62
 // Include WordLift constants.
63
-require_once plugin_dir_path( __FILE__ ) . 'wordlift-constants.php';
63
+require_once plugin_dir_path(__FILE__).'wordlift-constants.php';
64 64
 
65 65
 // Load modules.
66
-require_once plugin_dir_path( __FILE__ ) . 'modules/core/wordlift-core.php';
66
+require_once plugin_dir_path(__FILE__).'modules/core/wordlift-core.php';
67 67
 
68
-require_once plugin_dir_path( __FILE__ ) . 'deprecations.php';
68
+require_once plugin_dir_path(__FILE__).'deprecations.php';
69 69
 
70 70
 // Load early to enable/disable features.
71
-require_once plugin_dir_path( __FILE__ ) . 'wordlift/features/index.php';
71
+require_once plugin_dir_path(__FILE__).'wordlift/features/index.php';
72 72
 
73 73
 /**
74 74
  * The code that runs during plugin activation.
@@ -76,11 +76,11 @@  discard block
 block discarded – undo
76 76
  */
77 77
 function activate_wordlift() {
78 78
 
79
-	$log = Wordlift_Log_Service::get_logger( 'activate_wordlift' );
79
+	$log = Wordlift_Log_Service::get_logger('activate_wordlift');
80 80
 
81
-	$log->info( 'Activating WordLift...' );
81
+	$log->info('Activating WordLift...');
82 82
 
83
-	require_once plugin_dir_path( __FILE__ ) . 'includes/class-wordlift-activator.php';
83
+	require_once plugin_dir_path(__FILE__).'includes/class-wordlift-activator.php';
84 84
 	Wordlift_Activator::activate();
85 85
 
86 86
 	/**
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
  */
108 108
 function deactivate_wordlift() {
109 109
 
110
-	require_once plugin_dir_path( __FILE__ ) . 'includes/class-wordlift-deactivator.php';
110
+	require_once plugin_dir_path(__FILE__).'includes/class-wordlift-deactivator.php';
111 111
 	Wordlift_Deactivator::deactivate();
112 112
 	Wordlift_Http_Api::deactivate();
113 113
 	Ttl_Cache_Cleaner::deactivate();
@@ -125,14 +125,14 @@  discard block
 block discarded – undo
125 125
 
126 126
 }
127 127
 
128
-register_activation_hook( __FILE__, 'activate_wordlift' );
129
-register_deactivation_hook( __FILE__, 'deactivate_wordlift' );
128
+register_activation_hook(__FILE__, 'activate_wordlift');
129
+register_deactivation_hook(__FILE__, 'deactivate_wordlift');
130 130
 
131 131
 /**
132 132
  * The core plugin class that is used to define internationalization,
133 133
  * admin-specific hooks, and public-facing site hooks.
134 134
  */
135
-require plugin_dir_path( __FILE__ ) . 'includes/class-wordlift.php';
135
+require plugin_dir_path(__FILE__).'includes/class-wordlift.php';
136 136
 
137 137
 /**
138 138
  * Begins execution of the plugin.
@@ -152,12 +152,12 @@  discard block
 block discarded – undo
152 152
 	 * @return bool
153 153
 	 * @since 3.27.6
154 154
 	 */
155
-	if ( apply_filters( 'wl_feature__enable__widgets', true ) ) {
156
-		add_action( 'widgets_init', 'wl_register_chord_widget' );
157
-		add_action( 'widgets_init', 'wl_register_geo_widget' );
158
-		add_action( 'widgets_init', 'wl_register_timeline_widget' );
155
+	if (apply_filters('wl_feature__enable__widgets', true)) {
156
+		add_action('widgets_init', 'wl_register_chord_widget');
157
+		add_action('widgets_init', 'wl_register_geo_widget');
158
+		add_action('widgets_init', 'wl_register_timeline_widget');
159 159
 	}
160
-	add_filter( 'widget_text', 'do_shortcode' );
160
+	add_filter('widget_text', 'do_shortcode');
161 161
 
162 162
 	/**
163 163
 	 * Filter: wl_feature__enable__analysis
@@ -167,10 +167,10 @@  discard block
 block discarded – undo
167 167
 	 * @return bool
168 168
 	 * @since 3.27.6
169 169
 	 */
170
-	if ( apply_filters( 'wl_feature__enable__analysis', true ) ) {
171
-		add_action( 'wp_ajax_wl_analyze', 'wl_ajax_analyze_action' );
170
+	if (apply_filters('wl_feature__enable__analysis', true)) {
171
+		add_action('wp_ajax_wl_analyze', 'wl_ajax_analyze_action');
172 172
 	} else {
173
-		add_action( 'wp_ajax_wl_analyze', 'wl_ajax_analyze_disabled_action' );
173
+		add_action('wp_ajax_wl_analyze', 'wl_ajax_analyze_disabled_action');
174 174
 	}
175 175
 
176 176
 	$plugin = new Wordlift();
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
 
188 188
 	add_action(
189 189
 		'plugins_loaded',
190
-		function () {
190
+		function() {
191 191
 			// All features from registry should be initialized here.
192 192
 			$features_registry = Features_Registry::get_instance();
193 193
 			$features_registry->initialize_all_features();
@@ -198,27 +198,27 @@  discard block
 block discarded – undo
198 198
 	add_action(
199 199
 		'plugins_loaded',
200 200
 		// phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
201
-		function () use ( $plugin ) {
201
+		function() use ($plugin) {
202 202
 
203 203
 			new Wordlift_Products_Navigator_Shortcode_REST();
204 204
 
205 205
 			// Register the Dataset module, requires `$api_service`.
206
-			require_once plugin_dir_path( __FILE__ ) . 'wordlift/dataset/index.php';
207
-			require_once plugin_dir_path( __FILE__ ) . 'wordlift/shipping-data/index.php';
206
+			require_once plugin_dir_path(__FILE__).'wordlift/dataset/index.php';
207
+			require_once plugin_dir_path(__FILE__).'wordlift/shipping-data/index.php';
208 208
 
209 209
 			/*
210 210
 			* Require the Entity annotation cleanup module.
211 211
 			*
212 212
 			* @since 3.34.6
213 213
 			*/
214
-			require_once plugin_dir_path( __FILE__ ) . 'wordlift/cleanup/index.php';
214
+			require_once plugin_dir_path(__FILE__).'wordlift/cleanup/index.php';
215 215
 
216 216
 			/*
217 217
 			* Import LOD entities.
218 218
 			*
219 219
 			* @since 3.35.0
220 220
 			*/
221
-			require_once plugin_dir_path( __FILE__ ) . 'wordlift/lod-import/index.php';
221
+			require_once plugin_dir_path(__FILE__).'wordlift/lod-import/index.php';
222 222
 
223 223
 		}
224 224
 	);
@@ -236,23 +236,23 @@  discard block
 block discarded – undo
236 236
 function wordlift_plugin_autoload_register() {
237 237
 
238 238
 	spl_autoload_register(
239
-		function ( $class_name ) {
239
+		function($class_name) {
240 240
 
241 241
 			// Bail out if these are not our classes.
242
-			if ( 0 !== strpos( $class_name, 'Wordlift\\' ) ) {
242
+			if (0 !== strpos($class_name, 'Wordlift\\')) {
243 243
 				return false;
244 244
 			}
245 245
 
246
-			$class_name_lc = strtolower( str_replace( '_', '-', $class_name ) );
246
+			$class_name_lc = strtolower(str_replace('_', '-', $class_name));
247 247
 
248
-			preg_match( '|^(?:(.*)\\\\)?(.+?)$|', $class_name_lc, $matches );
248
+			preg_match('|^(?:(.*)\\\\)?(.+?)$|', $class_name_lc, $matches);
249 249
 
250
-			$path = str_replace( '\\', DIRECTORY_SEPARATOR, $matches[1] );
251
-			$file = 'class-' . $matches[2] . '.php';
250
+			$path = str_replace('\\', DIRECTORY_SEPARATOR, $matches[1]);
251
+			$file = 'class-'.$matches[2].'.php';
252 252
 
253
-			$full_path = plugin_dir_path( __FILE__ ) . $path . DIRECTORY_SEPARATOR . $file;
253
+			$full_path = plugin_dir_path(__FILE__).$path.DIRECTORY_SEPARATOR.$file;
254 254
 
255
-			if ( ! file_exists( $full_path ) ) {
255
+			if ( ! file_exists($full_path)) {
256 256
 				return false;
257 257
 			}
258 258
 
@@ -264,13 +264,13 @@  discard block
 block discarded – undo
264 264
 
265 265
 }
266 266
 
267
-function wl_block_categories( $categories ) {
267
+function wl_block_categories($categories) {
268 268
 	return array_merge(
269 269
 		$categories,
270 270
 		array(
271 271
 			array(
272 272
 				'slug'  => 'wordlift',
273
-				'title' => __( 'WordLift', 'wordlift' ),
273
+				'title' => __('WordLift', 'wordlift'),
274 274
 			),
275 275
 		)
276 276
 	);
@@ -280,22 +280,22 @@  discard block
 block discarded – undo
280 280
  * This function is created temporarily to handle the legacy library,
281 281
  * this has to be removed when removing the legacy fields from the ui.
282 282
  */
283
-function wl_enqueue_leaflet( $in_footer = false ) {
283
+function wl_enqueue_leaflet($in_footer = false) {
284 284
 	// Leaflet.
285
-	wp_enqueue_style( 'wl-leaflet', plugin_dir_url( __FILE__ ) . 'js/leaflet/leaflet.css', array(), '1.6.0' );
286
-	wp_enqueue_script( 'wl-leaflet', plugin_dir_url( __FILE__ ) . 'js/leaflet/leaflet.js', array(), '1.6.0', $in_footer );
285
+	wp_enqueue_style('wl-leaflet', plugin_dir_url(__FILE__).'js/leaflet/leaflet.css', array(), '1.6.0');
286
+	wp_enqueue_script('wl-leaflet', plugin_dir_url(__FILE__).'js/leaflet/leaflet.js', array(), '1.6.0', $in_footer);
287 287
 }
288 288
 
289
-add_filter( 'block_categories', 'wl_block_categories', 10 );
289
+add_filter('block_categories', 'wl_block_categories', 10);
290 290
 
291 291
 // Temporary fix for a typo in WooCommerce Extension.
292 292
 add_filter(
293 293
 	'wl_feature__enable__dataset',
294
-	function ( $value ) {
295
-		return apply_filters( 'wl_features__enable__dataset', $value );
294
+	function($value) {
295
+		return apply_filters('wl_features__enable__dataset', $value);
296 296
 	}
297 297
 );
298 298
 
299
-require_once __DIR__ . '/modules/food-kg/load.php';
300
-require_once __DIR__ . '/modules/acf4so/load.php';
301
-require_once __DIR__ . '/modules/pods/load.php';
299
+require_once __DIR__.'/modules/food-kg/load.php';
300
+require_once __DIR__.'/modules/acf4so/load.php';
301
+require_once __DIR__.'/modules/pods/load.php';
Please login to merge, or discard this patch.
src/includes/class-wordlift-abstract-post-to-jsonld-converter.php 1 patch
Spacing   +60 added lines, -60 removed lines patch added patch discarded remove patch
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 	 *
73 73
 	 * @since 3.10.0
74 74
 	 */
75
-	public function __construct( $entity_type_service, $user_service, $attachment_service, $property_getter ) {
75
+	public function __construct($entity_type_service, $user_service, $attachment_service, $property_getter) {
76 76
 		$this->entity_type_service = $entity_type_service;
77 77
 		$this->user_service        = $user_service;
78 78
 		$this->attachment_service  = $attachment_service;
@@ -91,19 +91,19 @@  discard block
 block discarded – undo
91 91
 	 * @since 3.10.0
92 92
 	 */
93 93
 	// phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
94
-	public function convert( $post_id, &$references = array(), &$references_infos = array() ) {
94
+	public function convert($post_id, &$references = array(), &$references_infos = array()) {
95 95
 
96 96
 		// Get the post instance.
97
-		$post = get_post( $post_id );
98
-		if ( null === $post ) {
97
+		$post = get_post($post_id);
98
+		if (null === $post) {
99 99
 			// Post not found.
100 100
 			return null;
101 101
 		}
102 102
 
103 103
 		// Get the post URI @id.
104
-		$id = Wordlift_Entity_Service::get_instance()->get_uri( $post->ID );
105
-		if ( $id === null ) {
106
-			$id = 'get_uri returned null, dataset is ' . wl_configuration_get_redlink_dataset_uri();
104
+		$id = Wordlift_Entity_Service::get_instance()->get_uri($post->ID);
105
+		if ($id === null) {
106
+			$id = 'get_uri returned null, dataset is '.wl_configuration_get_redlink_dataset_uri();
107 107
 		}
108 108
 
109 109
 		/*
@@ -115,8 +115,8 @@  discard block
 block discarded – undo
115 115
 		 */
116 116
 		// Get the entity @type. We consider `post` BlogPostings.
117 117
 		// $type = $this->entity_type_service->get( $post_id );
118
-		$types = $this->entity_type_service->get_names( $post_id );
119
-		$type  = self::make_one( $types );
118
+		$types = $this->entity_type_service->get_names($post_id);
119
+		$type  = self::make_one($types);
120 120
 
121 121
 		// Prepare the response.
122 122
 		$jsonld = array(
@@ -125,8 +125,8 @@  discard block
 block discarded – undo
125 125
 			'@type'    => $type,
126 126
 		);
127 127
 
128
-		if ( post_type_supports( $post->post_type, 'excerpt' ) ) {
129
-			$jsonld['description'] = Wordlift_Post_Excerpt_Helper::get_text_excerpt( $post );
128
+		if (post_type_supports($post->post_type, 'excerpt')) {
129
+			$jsonld['description'] = Wordlift_Post_Excerpt_Helper::get_text_excerpt($post);
130 130
 		}
131 131
 
132 132
 		// Set the `mainEntityOfPage` property if the post has some contents.
@@ -136,8 +136,8 @@  discard block
 block discarded – undo
136 136
 		 *
137 137
 		 * @since 3.20.0
138 138
 		 */
139
-		$post_content = apply_filters( 'wl_post_content', $post->post_content, $post );
140
-		if ( ! empty( $post_content ) ) {
139
+		$post_content = apply_filters('wl_post_content', $post->post_content, $post);
140
+		if ( ! empty($post_content)) {
141 141
 			// We're setting the `mainEntityOfPage` to signal which one is the
142 142
 			// main entity for the specified URL. It might be however that the
143 143
 			// post/page is actually about another specific entity. How WL deals
@@ -148,28 +148,28 @@  discard block
 block discarded – undo
148 148
 			// No need to specify `'@type' => 'WebPage'.
149 149
 			//
150 150
 			// See https://github.com/insideout10/wordlift-plugin/issues/451.
151
-			$jsonld['mainEntityOfPage'] = get_the_permalink( $post->ID );
151
+			$jsonld['mainEntityOfPage'] = get_the_permalink($post->ID);
152 152
 
153 153
 			/**
154 154
 			 * @see https://github.com/insideout10/wordlift-plugin/issues/1207
155 155
 			 *
156 156
 			 * @since 3.27.7
157 157
 			 */
158
-			if ( in_array( $type, array( 'Occupation', 'OccupationAggregationByEmployer' ), true ) ) {
158
+			if (in_array($type, array('Occupation', 'OccupationAggregationByEmployer'), true)) {
159 159
 				$jsonld['mainEntityOfPage'] = array(
160 160
 					'@type'        => 'WebPage',
161
-					'lastReviewed' => get_post_time( 'Y-m-d\TH:i:sP', true, $post, false ),
161
+					'lastReviewed' => get_post_time('Y-m-d\TH:i:sP', true, $post, false),
162 162
 				);
163 163
 			}
164 164
 		};
165 165
 
166
-		$this->set_images( $this->attachment_service, $post, $jsonld );
166
+		$this->set_images($this->attachment_service, $post, $jsonld);
167 167
 
168 168
 		// Get the entities referenced by this post and set it to the `references`
169 169
 		// array so that the caller can do further processing, such as printing out
170 170
 		// more of those references.
171 171
 		$references_without_locations = Object_Relation_Service::get_instance()
172
-															   ->get_references( $post_id, Object_Type_Enum::POST );
172
+															   ->get_references($post_id, Object_Type_Enum::POST);
173 173
 
174 174
 		/*
175 175
 		 * Add the locations to the references.
@@ -182,33 +182,33 @@  discard block
 block discarded – undo
182 182
 		$entity_type_service = $this->entity_type_service;
183 183
 		$locations           = array_reduce(
184 184
 			$references_without_locations,
185
-			function ( $carry, $reference ) use ( $entity_type_service ) {
185
+			function($carry, $reference) use ($entity_type_service) {
186 186
 				/**
187 187
 				 * @var $reference Reference
188 188
 				 */
189 189
 				// @see https://schema.org/location for the schema.org types using the `location` property.
190
-				if ( ! $entity_type_service->has_entity_type( $reference->get_id(), 'http://schema.org/Action' )
191
-					 && ! $entity_type_service->has_entity_type( $reference->get_id(), 'http://schema.org/Event' )
192
-					 && ! $entity_type_service->has_entity_type( $reference->get_id(), 'http://schema.org/Organization' ) ) {
190
+				if ( ! $entity_type_service->has_entity_type($reference->get_id(), 'http://schema.org/Action')
191
+					 && ! $entity_type_service->has_entity_type($reference->get_id(), 'http://schema.org/Event')
192
+					 && ! $entity_type_service->has_entity_type($reference->get_id(), 'http://schema.org/Organization')) {
193 193
 
194 194
 					return $carry;
195 195
 				}
196
-				$post_location_ids        = get_post_meta( $reference->get_id(), Wordlift_Schema_Service::FIELD_LOCATION );
196
+				$post_location_ids        = get_post_meta($reference->get_id(), Wordlift_Schema_Service::FIELD_LOCATION);
197 197
 				$post_location_references = array_map(
198
-					function ( $post_id ) {
199
-						return new Post_Reference( $post_id );
198
+					function($post_id) {
199
+						return new Post_Reference($post_id);
200 200
 					},
201 201
 					$post_location_ids
202 202
 				);
203 203
 
204
-				return array_merge( $carry, $post_location_references );
204
+				return array_merge($carry, $post_location_references);
205 205
 			},
206 206
 			array()
207 207
 		);
208 208
 
209 209
 		// Merge the references with the referenced locations if any.
210 210
 		// phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
211
-		$references = array_merge( $references_without_locations, $locations );
211
+		$references = array_merge($references_without_locations, $locations);
212 212
 
213 213
 		return $jsonld;
214 214
 	}
@@ -222,8 +222,8 @@  discard block
 block discarded – undo
222 222
 	 * @return string The property value without the context.
223 223
 	 * @since 3.10.0
224 224
 	 */
225
-	public function relative_to_context( $value ) {
226
-		return ! is_array( $value ) && 0 === strpos( $value, self::CONTEXT . '/' ) ? substr( $value, strlen( self::CONTEXT ) + 1 ) : $value;
225
+	public function relative_to_context($value) {
226
+		return ! is_array($value) && 0 === strpos($value, self::CONTEXT.'/') ? substr($value, strlen(self::CONTEXT) + 1) : $value;
227 227
 	}
228 228
 
229 229
 	/**
@@ -238,14 +238,14 @@  discard block
 block discarded – undo
238 238
 	 *
239 239
 	 * @since 3.10.0
240 240
 	 */
241
-	public static function set_images( $attachment_service, $post, &$jsonld ) {
241
+	public static function set_images($attachment_service, $post, &$jsonld) {
242 242
 
243 243
 		// Prepare the attachment ids array.
244 244
 		$ids = array();
245 245
 
246 246
 		// Set the thumbnail id as first attachment id, if any.
247
-		$thumbnail_id = get_post_thumbnail_id( $post->ID );
248
-		if ( '' !== $thumbnail_id && 0 !== $thumbnail_id ) {
247
+		$thumbnail_id = get_post_thumbnail_id($post->ID);
248
+		if ('' !== $thumbnail_id && 0 !== $thumbnail_id) {
249 249
 			$ids[] = $thumbnail_id;
250 250
 		}
251 251
 
@@ -256,34 +256,34 @@  discard block
 block discarded – undo
256 256
 		//
257 257
 		// Get the embeds, removing existing ids.
258 258
 		// phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
259
-		if ( apply_filters( 'wl_feature__enable__image-embeds', false ) ) {
260
-			$embeds = array_diff( $attachment_service->get_image_embeds( $post->post_content ), $ids );
259
+		if (apply_filters('wl_feature__enable__image-embeds', false)) {
260
+			$embeds = array_diff($attachment_service->get_image_embeds($post->post_content), $ids);
261 261
 		} else {
262 262
 			$embeds = array();
263 263
 		}
264 264
 
265 265
 		// Get the gallery, removing existing ids.
266
-		$gallery = array_diff( $attachment_service->get_gallery( $post ), $ids, $embeds );
266
+		$gallery = array_diff($attachment_service->get_gallery($post), $ids, $embeds);
267 267
 
268 268
 		// Map the attachment ids to images' data structured for schema.org use.
269 269
 		$images_with_sizes = array_filter(
270 270
 			array_reduce(
271
-				array_merge( $ids, $embeds, $gallery ),
272
-				function ( $carry, $item ) {
271
+				array_merge($ids, $embeds, $gallery),
272
+				function($carry, $item) {
273 273
 					/*
274 274
 					* @todo: we're not sure that we're getting attachment data here, we
275 275
 					* should filter `false`s.
276 276
 					*/
277 277
 
278 278
 					$sources = array_merge(
279
-						Wordlift_Image_Service::get_sources( $item ),
280
-						array( wp_get_attachment_image_src( $item, 'full' ) )
279
+						Wordlift_Image_Service::get_sources($item),
280
+						array(wp_get_attachment_image_src($item, 'full'))
281 281
 					);
282 282
 
283 283
 					$sources_with_image = array_filter(
284 284
 						$sources,
285
-						function ( $source ) {
286
-							return ! empty( $source[0] );
285
+						function($source) {
286
+							return ! empty($source[0]);
287 287
 						}
288 288
 					);
289 289
 
@@ -297,7 +297,7 @@  discard block
 block discarded – undo
297 297
 					// or from uploads dir, but the image id still exists as featured image
298 298
 					// or in [gallery] shortcode.
299 299
 					// if ( empty( $attachment[0] ) ) {
300
-					if ( empty( $sources_with_image ) ) {
300
+					if (empty($sources_with_image)) {
301 301
 						return $carry;
302 302
 					}
303 303
 
@@ -315,7 +315,7 @@  discard block
 block discarded – undo
315 315
 
316 316
 		// Refactor data as per schema.org specifications.
317 317
 		$images = array_map(
318
-			function ( $attachment ) {
318
+			function($attachment) {
319 319
 				return Wordlift_Abstract_Post_To_Jsonld_Converter::set_image_size(
320 320
 					array(
321 321
 						'@type' => 'ImageObject',
@@ -328,7 +328,7 @@  discard block
 block discarded – undo
328 328
 		);
329 329
 
330 330
 		// Add images if present.
331
-		if ( 0 < count( $images ) ) {
331
+		if (0 < count($images)) {
332 332
 			$jsonld['image'] = $images;
333 333
 		}
334 334
 
@@ -346,9 +346,9 @@  discard block
 block discarded – undo
346 346
 	 * @since  3.8.0
347 347
 	 * @access private
348 348
 	 */
349
-	protected static function make_one( $value ) {
349
+	protected static function make_one($value) {
350 350
 
351
-		return 1 === count( $value ) ? $value[0] : $value;
351
+		return 1 === count($value) ? $value[0] : $value;
352 352
 	}
353 353
 
354 354
 	/**
@@ -361,17 +361,17 @@  discard block
 block discarded – undo
361 361
 	 * @return array The enriched `ImageObject` array.
362 362
 	 * @since 3.14.0
363 363
 	 */
364
-	public static function set_image_size( $image, $attachment ) {
364
+	public static function set_image_size($image, $attachment) {
365 365
 
366 366
 		// If you specify a "width" or "height" value you should leave out
367 367
 		// 'px'. For example: "width":"4608px" should be "width":"4608".
368 368
 		//
369 369
 		// See https://github.com/insideout10/wordlift-plugin/issues/451.
370
-		if ( isset( $attachment[1] ) && is_numeric( $attachment[1] ) && 0 < $attachment[1] ) {
370
+		if (isset($attachment[1]) && is_numeric($attachment[1]) && 0 < $attachment[1]) {
371 371
 			$image['width'] = $attachment[1];
372 372
 		}
373 373
 
374
-		if ( isset( $attachment[2] ) && is_numeric( $attachment[2] ) && 0 < $attachment[2] ) {
374
+		if (isset($attachment[2]) && is_numeric($attachment[2]) && 0 < $attachment[2]) {
375 375
 			$image['height'] = $attachment[2];
376 376
 		}
377 377
 
@@ -390,33 +390,33 @@  discard block
 block discarded – undo
390 390
 	 * @since 3.20.0 This code moved from the above function `convert`, used for entity types defined in
391 391
 	 *  the {@link Wordlift_Schema_Service} class.
392 392
 	 */
393
-	protected function process_type_custom_fields( &$jsonld, $fields, $post, &$references, &$references_infos ) {
393
+	protected function process_type_custom_fields(&$jsonld, $fields, $post, &$references, &$references_infos) {
394 394
 
395 395
 		// Set a reference to use in closures.
396 396
 		$converter = $this;
397 397
 
398 398
 		// Try each field on the entity.
399
-		foreach ( $fields as $key => $value ) {
399
+		foreach ($fields as $key => $value) {
400 400
 
401 401
 			// Get the predicate.
402
-			$name = $this->relative_to_context( $value['predicate'] );
402
+			$name = $this->relative_to_context($value['predicate']);
403 403
 
404 404
 			// Get the value, the property service will get the right extractor
405 405
 			// for that property.
406
-			$value = $this->property_getter->get( $post->ID, $key, Object_Type_Enum::POST );
406
+			$value = $this->property_getter->get($post->ID, $key, Object_Type_Enum::POST);
407 407
 
408
-			if ( empty( $value ) ) {
408
+			if (empty($value)) {
409 409
 				continue;
410 410
 			}
411 411
 
412 412
 			// Map the value to the property name.
413 413
 			// If we got an array with just one value, we return that one value.
414 414
 			// If we got a Wordlift_Property_Entity_Reference we get the URL.
415
-			$jsonld[ $name ] = self::make_one(
415
+			$jsonld[$name] = self::make_one(
416 416
 				array_map(
417
-					function ( $item ) use ( $converter, &$references, &$references_infos ) {
417
+					function($item) use ($converter, &$references, &$references_infos) {
418 418
 
419
-						if ( $item instanceof Wordlift_Property_Entity_Reference ) {
419
+						if ($item instanceof Wordlift_Property_Entity_Reference) {
420 420
 
421 421
 							$url = $item->get_url();
422 422
 
@@ -425,12 +425,12 @@  discard block
 block discarded – undo
425 425
 							$references[] = $item->to_reference();
426 426
 
427 427
 							// phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UndefinedVariable
428
-							$references_infos[] = array( 'reference' => $item );
428
+							$references_infos[] = array('reference' => $item);
429 429
 
430
-							return array( '@id' => $url );
430
+							return array('@id' => $url);
431 431
 						}
432 432
 
433
-						return $converter->relative_to_context( $item );
433
+						return $converter->relative_to_context($item);
434 434
 					},
435 435
 					$value
436 436
 				)
Please login to merge, or discard this patch.
src/includes/class-wordlift-entity-post-type-service.php 1 patch
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -60,9 +60,9 @@  discard block
 block discarded – undo
60 60
 	 *
61 61
 	 * @since 3.6.0
62 62
 	 */
63
-	public function __construct( $post_type, $slug ) {
63
+	public function __construct($post_type, $slug) {
64 64
 
65
-		$this->log = Wordlift_Log_Service::get_logger( get_class() );
65
+		$this->log = Wordlift_Log_Service::get_logger(get_class());
66 66
 
67 67
 		$this->post_type = $post_type;
68 68
 
@@ -114,22 +114,22 @@  discard block
 block discarded – undo
114 114
 	 */
115 115
 	public function register() {
116 116
 
117
-		$this->log->debug( "Registering post type $this->post_type..." );
117
+		$this->log->debug("Registering post type $this->post_type...");
118 118
 
119 119
 		$labels = array(
120
-			'name'               => _x( 'Vocabulary', 'post type general name', 'wordlift' ),
121
-			'singular_name'      => _x( 'Entity', 'post type singular name', 'wordlift' ),
122
-			'add_new'            => _x( 'Add New Entity', 'entity', 'wordlift' ),
123
-			'add_new_item'       => __( 'Add New Entity', 'wordlift' ),
124
-			'edit_item'          => __( 'Edit Entity', 'wordlift' ),
125
-			'new_item'           => __( 'New Entity', 'wordlift' ),
126
-			'all_items'          => __( 'All Entities', 'wordlift' ),
127
-			'view_item'          => __( 'View Entity', 'wordlift' ),
128
-			'search_items'       => __( 'Search in Vocabulary', 'wordlift' ),
129
-			'not_found'          => __( 'No entities found', 'wordlift' ),
130
-			'not_found_in_trash' => __( 'No entities found in the Trash', 'wordlift' ),
120
+			'name'               => _x('Vocabulary', 'post type general name', 'wordlift'),
121
+			'singular_name'      => _x('Entity', 'post type singular name', 'wordlift'),
122
+			'add_new'            => _x('Add New Entity', 'entity', 'wordlift'),
123
+			'add_new_item'       => __('Add New Entity', 'wordlift'),
124
+			'edit_item'          => __('Edit Entity', 'wordlift'),
125
+			'new_item'           => __('New Entity', 'wordlift'),
126
+			'all_items'          => __('All Entities', 'wordlift'),
127
+			'view_item'          => __('View Entity', 'wordlift'),
128
+			'search_items'       => __('Search in Vocabulary', 'wordlift'),
129
+			'not_found'          => __('No entities found', 'wordlift'),
130
+			'not_found_in_trash' => __('No entities found in the Trash', 'wordlift'),
131 131
 			'parent_item_colon'  => '',
132
-			'menu_name'          => __( 'Vocabulary', 'wordlift' ),
132
+			'menu_name'          => __('Vocabulary', 'wordlift'),
133 133
 		);
134 134
 
135 135
 		$args = array(
@@ -151,9 +151,9 @@  discard block
 block discarded – undo
151 151
 				'revisions',
152 152
 				'custom-fields',
153 153
 			),
154
-			'menu_icon'       => WP_CONTENT_URL . '/plugins/wordlift/images/svg/wl-vocabulary-icon.svg',
154
+			'menu_icon'       => WP_CONTENT_URL.'/plugins/wordlift/images/svg/wl-vocabulary-icon.svg',
155 155
 			// Although we define our slug here, we further manage linking to entities using the Wordlift_Entity_Link_Service.
156
-			'rewrite'         => array( 'slug' => $this->slug ),
156
+			'rewrite'         => array('slug' => $this->slug),
157 157
 			'capability_type' => array(
158 158
 				'wordlift_entity',
159 159
 				'wordlift_entities',
@@ -171,10 +171,10 @@  discard block
 block discarded – undo
171 171
 			 * @return bool
172 172
 			 * @since 3.27.6
173 173
 			 */
174
-			'show_in_menu'    => apply_filters( 'wl_feature__enable__vocabulary', true ),
174
+			'show_in_menu'    => apply_filters('wl_feature__enable__vocabulary', true),
175 175
 		);
176 176
 
177
-		register_post_type( $this->post_type, $args );
177
+		register_post_type($this->post_type, $args);
178 178
 
179 179
 		// Enable WP's standard `category` taxonomy for entities.
180 180
 		//
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
 		// WP's main category query to include the `entity` post type.
184 184
 		//
185 185
 		// See https://github.com/insideout10/wordlift-plugin/issues/442
186
-		register_taxonomy_for_object_type( 'category', $this->post_type );
186
+		register_taxonomy_for_object_type('category', $this->post_type);
187 187
 
188 188
 	}
189 189
 
Please login to merge, or discard this patch.
src/install/class-wordlift-install-service.php 1 patch
Spacing   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -49,30 +49,30 @@  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';
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 76
 
77 77
 		// Get the install services.
78 78
 		$this->installs = array(
@@ -111,9 +111,9 @@  discard block
 block discarded – undo
111 111
 		);
112 112
 		self::$instance = $this;
113 113
 
114
-		$this->log = Wordlift_Log_Service::get_logger( get_class() );
114
+		$this->log = Wordlift_Log_Service::get_logger(get_class());
115 115
 
116
-		add_action( 'init', array( $this, 'install' ) );
116
+		add_action('init', array($this, 'install'));
117 117
 
118 118
 	}
119 119
 
@@ -139,30 +139,30 @@  discard block
 block discarded – undo
139 139
 
140 140
 		$version = null;
141 141
 
142
-		if ( $this->install_required() && false === get_transient( '_wl_installing' ) ) {
143
-			set_transient( '_wl_installing', true, 5 * MINUTE_IN_SECONDS );
142
+		if ($this->install_required() && false === get_transient('_wl_installing')) {
143
+			set_transient('_wl_installing', true, 5 * MINUTE_IN_SECONDS);
144 144
 			/** @var Wordlift_Install $install */
145
-			foreach ( $this->installs as $install ) {
145
+			foreach ($this->installs as $install) {
146 146
 				// Get the install version.
147 147
 				$version = $install->get_version();
148 148
 
149
-				if ( version_compare( $version, $this->get_current_version(), '>' )
150
-					 || $install->must_install() ) {
151
-					$class_name = get_class( $install );
149
+				if (version_compare($version, $this->get_current_version(), '>')
150
+					 || $install->must_install()) {
151
+					$class_name = get_class($install);
152 152
 
153
-					$this->log->info( "Current version is {$this->get_current_version()}, installing $class_name..." );
153
+					$this->log->info("Current version is {$this->get_current_version()}, installing $class_name...");
154 154
 					// Install version.
155 155
 					$install->install();
156 156
 
157
-					$this->log->info( "$class_name installed." );
157
+					$this->log->info("$class_name installed.");
158 158
 
159 159
 					// Bump the version.
160
-					update_option( 'wl_db_version', $version );
160
+					update_option('wl_db_version', $version);
161 161
 				}
162 162
 			}
163 163
 
164 164
 			// phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged
165
-			@delete_transient( '_wl_installing' );
165
+			@delete_transient('_wl_installing');
166 166
 
167 167
 		}
168 168
 
@@ -171,12 +171,12 @@  discard block
 block discarded – undo
171 171
 	private function install_required() {
172 172
 
173 173
 		/** @var Wordlift_Install $install */
174
-		foreach ( $this->installs as $install ) {
174
+		foreach ($this->installs as $install) {
175 175
 			// Get the install version.
176 176
 			$version = $install->get_version();
177 177
 
178
-			if ( version_compare( $version, $this->get_current_version(), '>' )
179
-				 || $install->must_install() ) {
178
+			if (version_compare($version, $this->get_current_version(), '>')
179
+				 || $install->must_install()) {
180 180
 				return true;
181 181
 			}
182 182
 		}
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
 	 * @return type
191 191
 	 */
192 192
 	private function get_current_version() {
193
-		return get_option( 'wl_db_version', '0.0.0' );
193
+		return get_option('wl_db_version', '0.0.0');
194 194
 	}
195 195
 
196 196
 }
Please login to merge, or discard this patch.