Completed
Push — develop ( ea412a...c483b2 )
by David
03:11
created
src/wordlift.php 2 patches
Indentation   +159 added lines, -159 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 
27 27
 // If this file is called directly, abort.
28 28
 if ( ! defined( 'WPINC' ) ) {
29
-	die;
29
+    die;
30 30
 }
31 31
 
32 32
 // Include WordLift constants.
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
  */
49 49
 function wl_write_log( $log ) {
50 50
 
51
-	Wordlift_Log_Service::get_instance()->info( $log );
51
+    Wordlift_Log_Service::get_instance()->info( $log );
52 52
 
53 53
 }
54 54
 
@@ -64,20 +64,20 @@  discard block
 block discarded – undo
64 64
  */
65 65
 function wl_write_log_handler( $log, $caller = null ) {
66 66
 
67
-	global $wl_logger;
67
+    global $wl_logger;
68 68
 
69
-	if ( true === WP_DEBUG ) {
69
+    if ( true === WP_DEBUG ) {
70 70
 
71
-		$message = ( isset( $caller ) ? sprintf( '[%-40.40s] ', $caller ) : '' ) .
72
-		           ( is_array( $log ) || is_object( $log ) ? print_r( $log, true ) : wl_write_log_hide_key( $log ) );
71
+        $message = ( isset( $caller ) ? sprintf( '[%-40.40s] ', $caller ) : '' ) .
72
+                    ( is_array( $log ) || is_object( $log ) ? print_r( $log, true ) : wl_write_log_hide_key( $log ) );
73 73
 
74
-		if ( isset( $wl_logger ) ) {
75
-			$wl_logger->info( $message );
76
-		} else {
77
-			error_log( $message );
78
-		}
74
+        if ( isset( $wl_logger ) ) {
75
+            $wl_logger->info( $message );
76
+        } else {
77
+            error_log( $message );
78
+        }
79 79
 
80
-	}
80
+    }
81 81
 
82 82
 }
83 83
 
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
  */
95 95
 function wl_write_log_hide_key( $text ) {
96 96
 
97
-	return str_ireplace( wl_configuration_get_key(), '<hidden>', $text );
97
+    return str_ireplace( wl_configuration_get_key(), '<hidden>', $text );
98 98
 }
99 99
 
100 100
 /**
@@ -102,21 +102,21 @@  discard block
 block discarded – undo
102 102
  * see http://vip.wordpress.com/documentation/register-additional-html-attributes-for-tinymce-and-wp-kses/
103 103
  */
104 104
 function wordlift_allowed_post_tags() {
105
-	global $allowedposttags;
106
-
107
-	$tags           = array( 'span' );
108
-	$new_attributes = array(
109
-		'itemscope' => array(),
110
-		'itemtype'  => array(),
111
-		'itemprop'  => array(),
112
-		'itemid'    => array(),
113
-	);
114
-
115
-	foreach ( $tags as $tag ) {
116
-		if ( isset( $allowedposttags[ $tag ] ) && is_array( $allowedposttags[ $tag ] ) ) {
117
-			$allowedposttags[ $tag ] = array_merge( $allowedposttags[ $tag ], $new_attributes );
118
-		}
119
-	}
105
+    global $allowedposttags;
106
+
107
+    $tags           = array( 'span' );
108
+    $new_attributes = array(
109
+        'itemscope' => array(),
110
+        'itemtype'  => array(),
111
+        'itemprop'  => array(),
112
+        'itemid'    => array(),
113
+    );
114
+
115
+    foreach ( $tags as $tag ) {
116
+        if ( isset( $allowedposttags[ $tag ] ) && is_array( $allowedposttags[ $tag ] ) ) {
117
+            $allowedposttags[ $tag ] = array_merge( $allowedposttags[ $tag ], $new_attributes );
118
+        }
119
+    }
120 120
 }
121 121
 
122 122
 // add allowed post tags.
@@ -127,28 +127,28 @@  discard block
 block discarded – undo
127 127
  */
128 128
 function wordlift_admin_enqueue_scripts() {
129 129
 
130
-	// Added for compatibility with WordPress 3.9 (see http://make.wordpress.org/core/2014/04/16/jquery-ui-and-wpdialogs-in-wordpress-3-9/)
131
-	wp_enqueue_script( 'wpdialogs' );
132
-	wp_enqueue_style( 'wp-jquery-ui-dialog' );
130
+    // Added for compatibility with WordPress 3.9 (see http://make.wordpress.org/core/2014/04/16/jquery-ui-and-wpdialogs-in-wordpress-3-9/)
131
+    wp_enqueue_script( 'wpdialogs' );
132
+    wp_enqueue_style( 'wp-jquery-ui-dialog' );
133 133
 
134
-	wp_enqueue_style( 'wordlift-reloaded', plugin_dir_url( __FILE__ ) . 'css/wordlift-reloaded.min.css' );
134
+    wp_enqueue_style( 'wordlift-reloaded', plugin_dir_url( __FILE__ ) . 'css/wordlift-reloaded.min.css' );
135 135
 
136
-	wp_enqueue_script( 'jquery-ui-autocomplete' );
137
-	wp_enqueue_script( 'angularjs', 'https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.11/angular.min.js' );
138
-	wp_enqueue_script( 'angularjs-geolocation', plugin_dir_url( __FILE__ ) . '/bower_components/angularjs-geolocation/dist/angularjs-geolocation.min.js' );
139
-	wp_enqueue_script( 'angularjs-touch', 'https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.11/angular-touch.min.js' );
140
-	wp_enqueue_script( 'angularjs-animate', 'https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.11/angular-animate.min.js' );
136
+    wp_enqueue_script( 'jquery-ui-autocomplete' );
137
+    wp_enqueue_script( 'angularjs', 'https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.11/angular.min.js' );
138
+    wp_enqueue_script( 'angularjs-geolocation', plugin_dir_url( __FILE__ ) . '/bower_components/angularjs-geolocation/dist/angularjs-geolocation.min.js' );
139
+    wp_enqueue_script( 'angularjs-touch', 'https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.11/angular-touch.min.js' );
140
+    wp_enqueue_script( 'angularjs-animate', 'https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.11/angular-animate.min.js' );
141 141
 
142
-	// Disable auto-save for custom entity posts only
143
-	if ( Wordlift_Entity_Service::TYPE_NAME === get_post_type() ) {
144
-		wp_dequeue_script( 'autosave' );
145
-	}
142
+    // Disable auto-save for custom entity posts only
143
+    if ( Wordlift_Entity_Service::TYPE_NAME === get_post_type() ) {
144
+        wp_dequeue_script( 'autosave' );
145
+    }
146 146
 }
147 147
 
148 148
 add_action( 'admin_enqueue_scripts', 'wordlift_admin_enqueue_scripts' );
149 149
 
150 150
 function wl_enqueue_scripts() {
151
-	wp_enqueue_style( 'wordlift-ui', plugin_dir_url( __FILE__ ) . 'css/wordlift-ui.min.css' );
151
+    wp_enqueue_style( 'wordlift-ui', plugin_dir_url( __FILE__ ) . 'css/wordlift-ui.min.css' );
152 152
 }
153 153
 
154 154
 add_action( 'wp_enqueue_scripts', 'wl_enqueue_scripts' );
@@ -163,18 +163,18 @@  discard block
 block discarded – undo
163 163
  */
164 164
 function wordlift_allowed_html( $allowedtags, $context ) {
165 165
 
166
-	if ( 'post' !== $context ) {
167
-		return $allowedtags;
168
-	}
169
-
170
-	return array_merge_recursive( $allowedtags, array(
171
-		'span' => array(
172
-			'itemscope' => true,
173
-			'itemtype'  => true,
174
-			'itemid'    => true,
175
-			'itemprop'  => true,
176
-		),
177
-	) );
166
+    if ( 'post' !== $context ) {
167
+        return $allowedtags;
168
+    }
169
+
170
+    return array_merge_recursive( $allowedtags, array(
171
+        'span' => array(
172
+            'itemscope' => true,
173
+            'itemtype'  => true,
174
+            'itemid'    => true,
175
+            'itemprop'  => true,
176
+        ),
177
+    ) );
178 178
 }
179 179
 
180 180
 add_filter( 'wp_kses_allowed_html', 'wordlift_allowed_html', 10, 2 );
@@ -188,16 +188,16 @@  discard block
 block discarded – undo
188 188
  */
189 189
 function wl_get_coordinates( $post_id ) {
190 190
 
191
-	$latitude  = wl_schema_get_value( $post_id, 'latitude' );
192
-	$longitude = wl_schema_get_value( $post_id, 'longitude' );
191
+    $latitude  = wl_schema_get_value( $post_id, 'latitude' );
192
+    $longitude = wl_schema_get_value( $post_id, 'longitude' );
193 193
 
194
-	// DO NOT set latitude/longitude to 0/0 as default values. It's a specific
195
-	// place on the globe:"The zero/zero point of this system is located in the
196
-	// Gulf of Guinea about 625 km (390 mi) south of Tema, Ghana."
197
-	return array(
198
-		'latitude'  => isset( $latitude[0] ) && is_numeric( $latitude[0] ) ? $latitude[0] : '',
199
-		'longitude' => isset( $longitude[0] ) && is_numeric( $longitude[0] ) ? $longitude[0] : '',
200
-	);
194
+    // DO NOT set latitude/longitude to 0/0 as default values. It's a specific
195
+    // place on the globe:"The zero/zero point of this system is located in the
196
+    // Gulf of Guinea about 625 km (390 mi) south of Tema, Ghana."
197
+    return array(
198
+        'latitude'  => isset( $latitude[0] ) && is_numeric( $latitude[0] ) ? $latitude[0] : '',
199
+        'longitude' => isset( $longitude[0] ) && is_numeric( $longitude[0] ) ? $longitude[0] : '',
200
+    );
201 201
 }
202 202
 
203 203
 /**
@@ -211,9 +211,9 @@  discard block
 block discarded – undo
211 211
  */
212 212
 function wl_get_image_urls( $post_id ) {
213 213
 
214
-	return Wordlift_Storage_Factory::get_instance()
215
-	                               ->post_images()
216
-	                               ->get( $post_id );
214
+    return Wordlift_Storage_Factory::get_instance()
215
+                                    ->post_images()
216
+                                    ->get( $post_id );
217 217
 
218 218
 //	// If there is a featured image it has the priority.
219 219
 //	$featured_image_id = get_post_thumbnail_id( $post_id );
@@ -261,24 +261,24 @@  discard block
 block discarded – undo
261 261
  */
262 262
 function wl_get_attachment_for_source_url( $parent_post_id, $source_url ) {
263 263
 
264
-	// wl_write_log( "wl_get_attachment_for_source_url [ parent post id :: $parent_post_id ][ source url :: $source_url ]" );
264
+    // wl_write_log( "wl_get_attachment_for_source_url [ parent post id :: $parent_post_id ][ source url :: $source_url ]" );
265 265
 
266
-	$posts = get_posts( array(
267
-		'post_type'      => 'attachment',
268
-		'posts_per_page' => 1,
269
-		'post_status'    => 'any',
270
-		'post_parent'    => $parent_post_id,
271
-		'meta_key'       => 'wl_source_url',
272
-		'meta_value'     => $source_url,
273
-	) );
266
+    $posts = get_posts( array(
267
+        'post_type'      => 'attachment',
268
+        'posts_per_page' => 1,
269
+        'post_status'    => 'any',
270
+        'post_parent'    => $parent_post_id,
271
+        'meta_key'       => 'wl_source_url',
272
+        'meta_value'     => $source_url,
273
+    ) );
274 274
 
275
-	// Return the found post.
276
-	if ( 1 === count( $posts ) ) {
277
-		return $posts[0];
278
-	}
275
+    // Return the found post.
276
+    if ( 1 === count( $posts ) ) {
277
+        return $posts[0];
278
+    }
279 279
 
280
-	// Return null.
281
-	return null;
280
+    // Return null.
281
+    return null;
282 282
 }
283 283
 
284 284
 /**
@@ -289,8 +289,8 @@  discard block
 block discarded – undo
289 289
  */
290 290
 function wl_set_source_url( $post_id, $source_url ) {
291 291
 
292
-	delete_post_meta( $post_id, 'wl_source_url' );
293
-	add_post_meta( $post_id, 'wl_source_url', $source_url );
292
+    delete_post_meta( $post_id, 'wl_source_url' );
293
+    add_post_meta( $post_id, 'wl_source_url', $source_url );
294 294
 }
295 295
 
296 296
 
@@ -307,61 +307,61 @@  discard block
 block discarded – undo
307 307
  */
308 308
 function wl_flush_rewrite_rules_hard( $hard ) {
309 309
 
310
-	// If WL is not yet configured, we cannot perform any update, so we exit.
311
-	if ( '' === wl_configuration_get_key() ) {
312
-		return;
313
-	}
310
+    // If WL is not yet configured, we cannot perform any update, so we exit.
311
+    if ( '' === wl_configuration_get_key() ) {
312
+        return;
313
+    }
314 314
 
315
-	// Set the initial offset and limit each call to 100 posts to avoid memory errors.
316
-	$offset = 0;
317
-	$limit  = 100;
315
+    // Set the initial offset and limit each call to 100 posts to avoid memory errors.
316
+    $offset = 0;
317
+    $limit  = 100;
318 318
 
319
-	// Get more posts if the number of returned posts matches the limit.
320
-	while ( $limit === ( $posts = get_posts( array(
321
-			'offset'      => $offset,
322
-			'numberposts' => $limit,
323
-			'orderby'     => 'ID',
324
-			'post_type'   => 'any',
325
-			'post_status' => 'publish',
326
-		) ) ) ) {
319
+    // Get more posts if the number of returned posts matches the limit.
320
+    while ( $limit === ( $posts = get_posts( array(
321
+            'offset'      => $offset,
322
+            'numberposts' => $limit,
323
+            'orderby'     => 'ID',
324
+            'post_type'   => 'any',
325
+            'post_status' => 'publish',
326
+        ) ) ) ) {
327 327
 
328
-		// Holds the delete part of the query.
329
-		$delete_query = rl_sparql_prefixes();
328
+        // Holds the delete part of the query.
329
+        $delete_query = rl_sparql_prefixes();
330 330
 
331
-		// Holds the insert part of the query.
332
-		$insert_query = '';
331
+        // Holds the insert part of the query.
332
+        $insert_query = '';
333 333
 
334
-		// Cycle in each post to build the query.
335
-		foreach ( $posts as $post ) {
334
+        // Cycle in each post to build the query.
335
+        foreach ( $posts as $post ) {
336 336
 
337
-			// Ignore revisions.
338
-			if ( wp_is_post_revision( $post->ID ) ) {
339
-				continue;
340
-			}
337
+            // Ignore revisions.
338
+            if ( wp_is_post_revision( $post->ID ) ) {
339
+                continue;
340
+            }
341 341
 
342
-			// Get the entity URI.
343
-			$s = Wordlift_Sparql_Service::escape_uri( Wordlift_Entity_Service::get_instance()
344
-			                                                                 ->get_uri( $post->ID ) );
342
+            // Get the entity URI.
343
+            $s = Wordlift_Sparql_Service::escape_uri( Wordlift_Entity_Service::get_instance()
344
+                                                                                ->get_uri( $post->ID ) );
345 345
 
346
-			// Get the post URL.
347
-			// $url = wl_sparql_escape_uri( get_permalink( $post->ID ) );
346
+            // Get the post URL.
347
+            // $url = wl_sparql_escape_uri( get_permalink( $post->ID ) );
348 348
 
349
-			// Prepare the DELETE and INSERT commands.
350
-			$delete_query .= "DELETE { <$s> schema:url ?u . } WHERE  { <$s> schema:url ?u . };\n";
349
+            // Prepare the DELETE and INSERT commands.
350
+            $delete_query .= "DELETE { <$s> schema:url ?u . } WHERE  { <$s> schema:url ?u . };\n";
351 351
 
352
-			$insert_query .= Wordlift_Schema_Url_Property_Service::get_instance()
353
-			                                                     ->get_insert_query( $s, $post->ID );
352
+            $insert_query .= Wordlift_Schema_Url_Property_Service::get_instance()
353
+                                                                    ->get_insert_query( $s, $post->ID );
354 354
 
355
-		}
355
+        }
356 356
 
357 357
 
358
-		// Execute the query.
359
-		rl_execute_sparql_update_query( $delete_query . $insert_query );
358
+        // Execute the query.
359
+        rl_execute_sparql_update_query( $delete_query . $insert_query );
360 360
 
361
-		// Advance to the next posts.
362
-		$offset += $limit;
361
+        // Advance to the next posts.
362
+        $offset += $limit;
363 363
 
364
-	}
364
+    }
365 365
 
366 366
 }
367 367
 
@@ -380,7 +380,7 @@  discard block
 block discarded – undo
380 380
  */
381 381
 function wl_sanitize_uri_path( $path, $char = '_' ) {
382 382
 
383
-	return Wordlift_Uri_Service::get_instance()->sanitize_path( $path, $char );
383
+    return Wordlift_Uri_Service::get_instance()->sanitize_path( $path, $char );
384 384
 }
385 385
 
386 386
 ///**
@@ -421,46 +421,46 @@  discard block
 block discarded – undo
421 421
  */
422 422
 function wl_replace_item_id_with_uri( $content ) {
423 423
 
424
-	// wl_write_log( "wl_replace_item_id_with_uri" );
424
+    // wl_write_log( "wl_replace_item_id_with_uri" );
425 425
 
426
-	// Strip slashes, see https://core.trac.wordpress.org/ticket/21767
427
-	$content = stripslashes( $content );
426
+    // Strip slashes, see https://core.trac.wordpress.org/ticket/21767
427
+    $content = stripslashes( $content );
428 428
 
429
-	// If any match are found.
430
-	$matches = array();
431
-	if ( 0 < preg_match_all( '/ itemid="([^"]+)"/i', $content, $matches, PREG_SET_ORDER ) ) {
429
+    // If any match are found.
430
+    $matches = array();
431
+    if ( 0 < preg_match_all( '/ itemid="([^"]+)"/i', $content, $matches, PREG_SET_ORDER ) ) {
432 432
 
433
-		foreach ( $matches as $match ) {
433
+        foreach ( $matches as $match ) {
434 434
 
435
-			// Get the item ID.
436
-			$item_id = $match[1];
435
+            // Get the item ID.
436
+            $item_id = $match[1];
437 437
 
438
-			// Get the post bound to that item ID (looking both in the 'official' URI and in the 'same-as' .
439
-			$post = Wordlift_Entity_Service::get_instance()
440
-			                               ->get_entity_post_by_uri( $item_id );
438
+            // Get the post bound to that item ID (looking both in the 'official' URI and in the 'same-as' .
439
+            $post = Wordlift_Entity_Service::get_instance()
440
+                                            ->get_entity_post_by_uri( $item_id );
441 441
 
442
-			// If no entity is found, continue to the next one.
443
-			if ( null === $post ) {
444
-				continue;
445
-			}
442
+            // If no entity is found, continue to the next one.
443
+            if ( null === $post ) {
444
+                continue;
445
+            }
446 446
 
447
-			// Get the URI for that post.
448
-			$uri = wl_get_entity_uri( $post->ID );
447
+            // Get the URI for that post.
448
+            $uri = wl_get_entity_uri( $post->ID );
449 449
 
450
-			// wl_write_log( "wl_replace_item_id_with_uri [ item id :: $item_id ][ uri :: $uri ]" );
450
+            // wl_write_log( "wl_replace_item_id_with_uri [ item id :: $item_id ][ uri :: $uri ]" );
451 451
 
452
-			// If the item ID and the URI differ, replace the item ID with the URI saved in WordPress.
453
-			if ( $item_id !== $uri ) {
454
-				$uri_e   = esc_html( $uri );
455
-				$content = str_replace( " itemid=\"$item_id\"", " itemid=\"$uri_e\"", $content );
456
-			}
457
-		}
458
-	}
452
+            // If the item ID and the URI differ, replace the item ID with the URI saved in WordPress.
453
+            if ( $item_id !== $uri ) {
454
+                $uri_e   = esc_html( $uri );
455
+                $content = str_replace( " itemid=\"$item_id\"", " itemid=\"$uri_e\"", $content );
456
+            }
457
+        }
458
+    }
459 459
 
460
-	// Reapply slashes.
461
-	$content = addslashes( $content );
460
+    // Reapply slashes.
461
+    $content = addslashes( $content );
462 462
 
463
-	return $content;
463
+    return $content;
464 464
 }
465 465
 
466 466
 add_filter( 'content_save_pre', 'wl_replace_item_id_with_uri', 1, 1 );
@@ -527,8 +527,8 @@  discard block
 block discarded – undo
527 527
  * This action is documented in includes/class-wordlift-activator.php
528 528
  */
529 529
 function activate_wordlift() {
530
-	require_once plugin_dir_path( __FILE__ ) . 'includes/class-wordlift-activator.php';
531
-	Wordlift_Activator::activate();
530
+    require_once plugin_dir_path( __FILE__ ) . 'includes/class-wordlift-activator.php';
531
+    Wordlift_Activator::activate();
532 532
 }
533 533
 
534 534
 /**
@@ -536,8 +536,8 @@  discard block
 block discarded – undo
536 536
  * This action is documented in includes/class-wordlift-deactivator.php
537 537
  */
538 538
 function deactivate_wordlift() {
539
-	require_once plugin_dir_path( __FILE__ ) . 'includes/class-wordlift-deactivator.php';
540
-	Wordlift_Deactivator::deactivate();
539
+    require_once plugin_dir_path( __FILE__ ) . 'includes/class-wordlift-deactivator.php';
540
+    Wordlift_Deactivator::deactivate();
541 541
 }
542 542
 
543 543
 register_activation_hook( __FILE__, 'activate_wordlift' );
@@ -560,8 +560,8 @@  discard block
 block discarded – undo
560 560
  */
561 561
 function run_wordlift() {
562 562
 
563
-	$plugin = new Wordlift();
564
-	$plugin->run();
563
+    $plugin = new Wordlift();
564
+    $plugin->run();
565 565
 
566 566
 }
567 567
 
Please login to merge, or discard this patch.
Spacing   +107 added lines, -107 removed lines patch added patch discarded remove patch
@@ -25,15 +25,15 @@  discard block
 block discarded – undo
25 25
  */
26 26
 
27 27
 // If this file is called directly, abort.
28
-if ( ! defined( 'WPINC' ) ) {
28
+if ( ! defined('WPINC')) {
29 29
 	die;
30 30
 }
31 31
 
32 32
 // Include WordLift constants.
33
-require_once( 'wordlift_constants.php' );
33
+require_once('wordlift_constants.php');
34 34
 
35 35
 // Load modules.
36
-require_once( 'modules/core/wordlift_core.php' );
36
+require_once('modules/core/wordlift_core.php');
37 37
 
38 38
 /**
39 39
  * Log to the debug.log file.
@@ -46,9 +46,9 @@  discard block
 block discarded – undo
46 46
  *
47 47
  * @param string|mixed $log The log data.
48 48
  */
49
-function wl_write_log( $log ) {
49
+function wl_write_log($log) {
50 50
 
51
-	Wordlift_Log_Service::get_instance()->info( $log );
51
+	Wordlift_Log_Service::get_instance()->info($log);
52 52
 
53 53
 }
54 54
 
@@ -62,19 +62,19 @@  discard block
 block discarded – undo
62 62
  * @param string|array $log    The log data.
63 63
  * @param string       $caller The calling function.
64 64
  */
65
-function wl_write_log_handler( $log, $caller = null ) {
65
+function wl_write_log_handler($log, $caller = null) {
66 66
 
67 67
 	global $wl_logger;
68 68
 
69
-	if ( true === WP_DEBUG ) {
69
+	if (true === WP_DEBUG) {
70 70
 
71
-		$message = ( isset( $caller ) ? sprintf( '[%-40.40s] ', $caller ) : '' ) .
72
-		           ( is_array( $log ) || is_object( $log ) ? print_r( $log, true ) : wl_write_log_hide_key( $log ) );
71
+		$message = (isset($caller) ? sprintf('[%-40.40s] ', $caller) : '').
72
+		           (is_array($log) || is_object($log) ? print_r($log, true) : wl_write_log_hide_key($log));
73 73
 
74
-		if ( isset( $wl_logger ) ) {
75
-			$wl_logger->info( $message );
74
+		if (isset($wl_logger)) {
75
+			$wl_logger->info($message);
76 76
 		} else {
77
-			error_log( $message );
77
+			error_log($message);
78 78
 		}
79 79
 
80 80
 	}
@@ -92,9 +92,9 @@  discard block
 block discarded – undo
92 92
  *
93 93
  * @return string A text with the key hidden.
94 94
  */
95
-function wl_write_log_hide_key( $text ) {
95
+function wl_write_log_hide_key($text) {
96 96
 
97
-	return str_ireplace( wl_configuration_get_key(), '<hidden>', $text );
97
+	return str_ireplace(wl_configuration_get_key(), '<hidden>', $text);
98 98
 }
99 99
 
100 100
 /**
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
 function wordlift_allowed_post_tags() {
105 105
 	global $allowedposttags;
106 106
 
107
-	$tags           = array( 'span' );
107
+	$tags           = array('span');
108 108
 	$new_attributes = array(
109 109
 		'itemscope' => array(),
110 110
 		'itemtype'  => array(),
@@ -112,15 +112,15 @@  discard block
 block discarded – undo
112 112
 		'itemid'    => array(),
113 113
 	);
114 114
 
115
-	foreach ( $tags as $tag ) {
116
-		if ( isset( $allowedposttags[ $tag ] ) && is_array( $allowedposttags[ $tag ] ) ) {
117
-			$allowedposttags[ $tag ] = array_merge( $allowedposttags[ $tag ], $new_attributes );
115
+	foreach ($tags as $tag) {
116
+		if (isset($allowedposttags[$tag]) && is_array($allowedposttags[$tag])) {
117
+			$allowedposttags[$tag] = array_merge($allowedposttags[$tag], $new_attributes);
118 118
 		}
119 119
 	}
120 120
 }
121 121
 
122 122
 // add allowed post tags.
123
-add_action( 'init', 'wordlift_allowed_post_tags' );
123
+add_action('init', 'wordlift_allowed_post_tags');
124 124
 
125 125
 /**
126 126
  * Register additional scripts for the admin UI.
@@ -128,30 +128,30 @@  discard block
 block discarded – undo
128 128
 function wordlift_admin_enqueue_scripts() {
129 129
 
130 130
 	// Added for compatibility with WordPress 3.9 (see http://make.wordpress.org/core/2014/04/16/jquery-ui-and-wpdialogs-in-wordpress-3-9/)
131
-	wp_enqueue_script( 'wpdialogs' );
132
-	wp_enqueue_style( 'wp-jquery-ui-dialog' );
131
+	wp_enqueue_script('wpdialogs');
132
+	wp_enqueue_style('wp-jquery-ui-dialog');
133 133
 
134
-	wp_enqueue_style( 'wordlift-reloaded', plugin_dir_url( __FILE__ ) . 'css/wordlift-reloaded.min.css' );
134
+	wp_enqueue_style('wordlift-reloaded', plugin_dir_url(__FILE__).'css/wordlift-reloaded.min.css');
135 135
 
136
-	wp_enqueue_script( 'jquery-ui-autocomplete' );
137
-	wp_enqueue_script( 'angularjs', 'https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.11/angular.min.js' );
138
-	wp_enqueue_script( 'angularjs-geolocation', plugin_dir_url( __FILE__ ) . '/bower_components/angularjs-geolocation/dist/angularjs-geolocation.min.js' );
139
-	wp_enqueue_script( 'angularjs-touch', 'https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.11/angular-touch.min.js' );
140
-	wp_enqueue_script( 'angularjs-animate', 'https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.11/angular-animate.min.js' );
136
+	wp_enqueue_script('jquery-ui-autocomplete');
137
+	wp_enqueue_script('angularjs', 'https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.11/angular.min.js');
138
+	wp_enqueue_script('angularjs-geolocation', plugin_dir_url(__FILE__).'/bower_components/angularjs-geolocation/dist/angularjs-geolocation.min.js');
139
+	wp_enqueue_script('angularjs-touch', 'https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.11/angular-touch.min.js');
140
+	wp_enqueue_script('angularjs-animate', 'https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.11/angular-animate.min.js');
141 141
 
142 142
 	// Disable auto-save for custom entity posts only
143
-	if ( Wordlift_Entity_Service::TYPE_NAME === get_post_type() ) {
144
-		wp_dequeue_script( 'autosave' );
143
+	if (Wordlift_Entity_Service::TYPE_NAME === get_post_type()) {
144
+		wp_dequeue_script('autosave');
145 145
 	}
146 146
 }
147 147
 
148
-add_action( 'admin_enqueue_scripts', 'wordlift_admin_enqueue_scripts' );
148
+add_action('admin_enqueue_scripts', 'wordlift_admin_enqueue_scripts');
149 149
 
150 150
 function wl_enqueue_scripts() {
151
-	wp_enqueue_style( 'wordlift-ui', plugin_dir_url( __FILE__ ) . 'css/wordlift-ui.min.css' );
151
+	wp_enqueue_style('wordlift-ui', plugin_dir_url(__FILE__).'css/wordlift-ui.min.css');
152 152
 }
153 153
 
154
-add_action( 'wp_enqueue_scripts', 'wl_enqueue_scripts' );
154
+add_action('wp_enqueue_scripts', 'wl_enqueue_scripts');
155 155
 
156 156
 /**
157 157
  * Hooked to *wp_kses_allowed_html* filter, adds microdata attributes.
@@ -161,23 +161,23 @@  discard block
 block discarded – undo
161 161
  *
162 162
  * @return array An array which contains allowed microdata attributes.
163 163
  */
164
-function wordlift_allowed_html( $allowedtags, $context ) {
164
+function wordlift_allowed_html($allowedtags, $context) {
165 165
 
166
-	if ( 'post' !== $context ) {
166
+	if ('post' !== $context) {
167 167
 		return $allowedtags;
168 168
 	}
169 169
 
170
-	return array_merge_recursive( $allowedtags, array(
170
+	return array_merge_recursive($allowedtags, array(
171 171
 		'span' => array(
172 172
 			'itemscope' => true,
173 173
 			'itemtype'  => true,
174 174
 			'itemid'    => true,
175 175
 			'itemprop'  => true,
176 176
 		),
177
-	) );
177
+	));
178 178
 }
179 179
 
180
-add_filter( 'wp_kses_allowed_html', 'wordlift_allowed_html', 10, 2 );
180
+add_filter('wp_kses_allowed_html', 'wordlift_allowed_html', 10, 2);
181 181
 
182 182
 /**
183 183
  * Get the coordinates for the specified post ID.
@@ -186,17 +186,17 @@  discard block
 block discarded – undo
186 186
  *
187 187
  * @return array|null An array of coordinates or null.
188 188
  */
189
-function wl_get_coordinates( $post_id ) {
189
+function wl_get_coordinates($post_id) {
190 190
 
191
-	$latitude  = wl_schema_get_value( $post_id, 'latitude' );
192
-	$longitude = wl_schema_get_value( $post_id, 'longitude' );
191
+	$latitude  = wl_schema_get_value($post_id, 'latitude');
192
+	$longitude = wl_schema_get_value($post_id, 'longitude');
193 193
 
194 194
 	// DO NOT set latitude/longitude to 0/0 as default values. It's a specific
195 195
 	// place on the globe:"The zero/zero point of this system is located in the
196 196
 	// Gulf of Guinea about 625 km (390 mi) south of Tema, Ghana."
197 197
 	return array(
198
-		'latitude'  => isset( $latitude[0] ) && is_numeric( $latitude[0] ) ? $latitude[0] : '',
199
-		'longitude' => isset( $longitude[0] ) && is_numeric( $longitude[0] ) ? $longitude[0] : '',
198
+		'latitude'  => isset($latitude[0]) && is_numeric($latitude[0]) ? $latitude[0] : '',
199
+		'longitude' => isset($longitude[0]) && is_numeric($longitude[0]) ? $longitude[0] : '',
200 200
 	);
201 201
 }
202 202
 
@@ -209,11 +209,11 @@  discard block
 block discarded – undo
209 209
  *
210 210
  * @return array An array of image URLs.
211 211
  */
212
-function wl_get_image_urls( $post_id ) {
212
+function wl_get_image_urls($post_id) {
213 213
 
214 214
 	return Wordlift_Storage_Factory::get_instance()
215 215
 	                               ->post_images()
216
-	                               ->get( $post_id );
216
+	                               ->get($post_id);
217 217
 
218 218
 //	// If there is a featured image it has the priority.
219 219
 //	$featured_image_id = get_post_thumbnail_id( $post_id );
@@ -259,21 +259,21 @@  discard block
 block discarded – undo
259 259
  *
260 260
  * @return WP_Post|null A post instance or null if not found.
261 261
  */
262
-function wl_get_attachment_for_source_url( $parent_post_id, $source_url ) {
262
+function wl_get_attachment_for_source_url($parent_post_id, $source_url) {
263 263
 
264 264
 	// wl_write_log( "wl_get_attachment_for_source_url [ parent post id :: $parent_post_id ][ source url :: $source_url ]" );
265 265
 
266
-	$posts = get_posts( array(
266
+	$posts = get_posts(array(
267 267
 		'post_type'      => 'attachment',
268 268
 		'posts_per_page' => 1,
269 269
 		'post_status'    => 'any',
270 270
 		'post_parent'    => $parent_post_id,
271 271
 		'meta_key'       => 'wl_source_url',
272 272
 		'meta_value'     => $source_url,
273
-	) );
273
+	));
274 274
 
275 275
 	// Return the found post.
276
-	if ( 1 === count( $posts ) ) {
276
+	if (1 === count($posts)) {
277 277
 		return $posts[0];
278 278
 	}
279 279
 
@@ -287,10 +287,10 @@  discard block
 block discarded – undo
287 287
  * @param int    $post_id    The post ID.
288 288
  * @param string $source_url The source URL.
289 289
  */
290
-function wl_set_source_url( $post_id, $source_url ) {
290
+function wl_set_source_url($post_id, $source_url) {
291 291
 
292
-	delete_post_meta( $post_id, 'wl_source_url' );
293
-	add_post_meta( $post_id, 'wl_source_url', $source_url );
292
+	delete_post_meta($post_id, 'wl_source_url');
293
+	add_post_meta($post_id, 'wl_source_url', $source_url);
294 294
 }
295 295
 
296 296
 
@@ -305,10 +305,10 @@  discard block
 block discarded – undo
305 305
  *
306 306
  * @param bool $hard True if the rewrite involves configuration updates in Apache/IIS.
307 307
  */
308
-function wl_flush_rewrite_rules_hard( $hard ) {
308
+function wl_flush_rewrite_rules_hard($hard) {
309 309
 
310 310
 	// If WL is not yet configured, we cannot perform any update, so we exit.
311
-	if ( '' === wl_configuration_get_key() ) {
311
+	if ('' === wl_configuration_get_key()) {
312 312
 		return;
313 313
 	}
314 314
 
@@ -317,13 +317,13 @@  discard block
 block discarded – undo
317 317
 	$limit  = 100;
318 318
 
319 319
 	// Get more posts if the number of returned posts matches the limit.
320
-	while ( $limit === ( $posts = get_posts( array(
320
+	while ($limit === ($posts = get_posts(array(
321 321
 			'offset'      => $offset,
322 322
 			'numberposts' => $limit,
323 323
 			'orderby'     => 'ID',
324 324
 			'post_type'   => 'any',
325 325
 			'post_status' => 'publish',
326
-		) ) ) ) {
326
+		)))) {
327 327
 
328 328
 		// Holds the delete part of the query.
329 329
 		$delete_query = rl_sparql_prefixes();
@@ -332,16 +332,16 @@  discard block
 block discarded – undo
332 332
 		$insert_query = '';
333 333
 
334 334
 		// Cycle in each post to build the query.
335
-		foreach ( $posts as $post ) {
335
+		foreach ($posts as $post) {
336 336
 
337 337
 			// Ignore revisions.
338
-			if ( wp_is_post_revision( $post->ID ) ) {
338
+			if (wp_is_post_revision($post->ID)) {
339 339
 				continue;
340 340
 			}
341 341
 
342 342
 			// Get the entity URI.
343
-			$s = Wordlift_Sparql_Service::escape_uri( Wordlift_Entity_Service::get_instance()
344
-			                                                                 ->get_uri( $post->ID ) );
343
+			$s = Wordlift_Sparql_Service::escape_uri(Wordlift_Entity_Service::get_instance()
344
+			                                                                 ->get_uri($post->ID));
345 345
 
346 346
 			// Get the post URL.
347 347
 			// $url = wl_sparql_escape_uri( get_permalink( $post->ID ) );
@@ -350,13 +350,13 @@  discard block
 block discarded – undo
350 350
 			$delete_query .= "DELETE { <$s> schema:url ?u . } WHERE  { <$s> schema:url ?u . };\n";
351 351
 
352 352
 			$insert_query .= Wordlift_Schema_Url_Property_Service::get_instance()
353
-			                                                     ->get_insert_query( $s, $post->ID );
353
+			                                                     ->get_insert_query($s, $post->ID);
354 354
 
355 355
 		}
356 356
 
357 357
 
358 358
 		// Execute the query.
359
-		rl_execute_sparql_update_query( $delete_query . $insert_query );
359
+		rl_execute_sparql_update_query($delete_query.$insert_query);
360 360
 
361 361
 		// Advance to the next posts.
362 362
 		$offset += $limit;
@@ -365,7 +365,7 @@  discard block
 block discarded – undo
365 365
 
366 366
 }
367 367
 
368
-add_filter( 'flush_rewrite_rules_hard', 'wl_flush_rewrite_rules_hard', 10, 1 );
368
+add_filter('flush_rewrite_rules_hard', 'wl_flush_rewrite_rules_hard', 10, 1);
369 369
 
370 370
 /**
371 371
  * Sanitizes an URI path by replacing the non allowed characters with an underscore.
@@ -378,9 +378,9 @@  discard block
 block discarded – undo
378 378
  *
379 379
  * @return string The sanitized path.
380 380
  */
381
-function wl_sanitize_uri_path( $path, $char = '_' ) {
381
+function wl_sanitize_uri_path($path, $char = '_') {
382 382
 
383
-	return Wordlift_Uri_Service::get_instance()->sanitize_path( $path, $char );
383
+	return Wordlift_Uri_Service::get_instance()->sanitize_path($path, $char);
384 384
 }
385 385
 
386 386
 ///**
@@ -419,107 +419,107 @@  discard block
 block discarded – undo
419 419
  *
420 420
  * @return string The updated post content.
421 421
  */
422
-function wl_replace_item_id_with_uri( $content ) {
422
+function wl_replace_item_id_with_uri($content) {
423 423
 
424 424
 	// wl_write_log( "wl_replace_item_id_with_uri" );
425 425
 
426 426
 	// Strip slashes, see https://core.trac.wordpress.org/ticket/21767
427
-	$content = stripslashes( $content );
427
+	$content = stripslashes($content);
428 428
 
429 429
 	// If any match are found.
430 430
 	$matches = array();
431
-	if ( 0 < preg_match_all( '/ itemid="([^"]+)"/i', $content, $matches, PREG_SET_ORDER ) ) {
431
+	if (0 < preg_match_all('/ itemid="([^"]+)"/i', $content, $matches, PREG_SET_ORDER)) {
432 432
 
433
-		foreach ( $matches as $match ) {
433
+		foreach ($matches as $match) {
434 434
 
435 435
 			// Get the item ID.
436 436
 			$item_id = $match[1];
437 437
 
438 438
 			// Get the post bound to that item ID (looking both in the 'official' URI and in the 'same-as' .
439 439
 			$post = Wordlift_Entity_Service::get_instance()
440
-			                               ->get_entity_post_by_uri( $item_id );
440
+			                               ->get_entity_post_by_uri($item_id);
441 441
 
442 442
 			// If no entity is found, continue to the next one.
443
-			if ( null === $post ) {
443
+			if (null === $post) {
444 444
 				continue;
445 445
 			}
446 446
 
447 447
 			// Get the URI for that post.
448
-			$uri = wl_get_entity_uri( $post->ID );
448
+			$uri = wl_get_entity_uri($post->ID);
449 449
 
450 450
 			// wl_write_log( "wl_replace_item_id_with_uri [ item id :: $item_id ][ uri :: $uri ]" );
451 451
 
452 452
 			// If the item ID and the URI differ, replace the item ID with the URI saved in WordPress.
453
-			if ( $item_id !== $uri ) {
454
-				$uri_e   = esc_html( $uri );
455
-				$content = str_replace( " itemid=\"$item_id\"", " itemid=\"$uri_e\"", $content );
453
+			if ($item_id !== $uri) {
454
+				$uri_e   = esc_html($uri);
455
+				$content = str_replace(" itemid=\"$item_id\"", " itemid=\"$uri_e\"", $content);
456 456
 			}
457 457
 		}
458 458
 	}
459 459
 
460 460
 	// Reapply slashes.
461
-	$content = addslashes( $content );
461
+	$content = addslashes($content);
462 462
 
463 463
 	return $content;
464 464
 }
465 465
 
466
-add_filter( 'content_save_pre', 'wl_replace_item_id_with_uri', 1, 1 );
466
+add_filter('content_save_pre', 'wl_replace_item_id_with_uri', 1, 1);
467 467
 
468
-require_once( 'wordlift_entity_functions.php' );
468
+require_once('wordlift_entity_functions.php');
469 469
 
470 470
 // add editor related methods.
471
-require_once( 'wordlift_editor.php' );
471
+require_once('wordlift_editor.php');
472 472
 
473 473
 // add the WordLift entity custom type.
474
-require_once( 'wordlift_entity_type.php' );
475
-require_once( 'wordlift_entity_type_taxonomy.php' );
474
+require_once('wordlift_entity_type.php');
475
+require_once('wordlift_entity_type_taxonomy.php');
476 476
 
477 477
 // add callbacks on post save to notify data changes from wp to redlink triple store
478
-require_once( 'wordlift_to_redlink_data_push_callbacks.php' );
478
+require_once('wordlift_to_redlink_data_push_callbacks.php');
479 479
 
480
-require_once( 'modules/configuration/wordlift_configuration_settings.php' );
480
+require_once('modules/configuration/wordlift_configuration_settings.php');
481 481
 
482 482
 // Load modules
483
-require_once( 'modules/analyzer/wordlift_analyzer.php' );
484
-require_once( 'modules/linked_data/wordlift_linked_data.php' );
485
-require_once( 'modules/prefixes/wordlift_prefixes.php' );
483
+require_once('modules/analyzer/wordlift_analyzer.php');
484
+require_once('modules/linked_data/wordlift_linked_data.php');
485
+require_once('modules/prefixes/wordlift_prefixes.php');
486 486
 
487 487
 // Shortcodes
488 488
 
489
-require_once( 'modules/geo_widget/wordlift_geo_widget.php' );
490
-require_once( 'shortcodes/wordlift_shortcode_chord.php' );
491
-require_once( 'shortcodes/wordlift_shortcode_geomap.php' );
492
-require_once( 'shortcodes/wordlift_shortcode_field.php' );
493
-require_once( 'shortcodes/wordlift_shortcode_faceted_search.php' );
494
-require_once( 'shortcodes/wordlift_shortcode_navigator.php' );
489
+require_once('modules/geo_widget/wordlift_geo_widget.php');
490
+require_once('shortcodes/wordlift_shortcode_chord.php');
491
+require_once('shortcodes/wordlift_shortcode_geomap.php');
492
+require_once('shortcodes/wordlift_shortcode_field.php');
493
+require_once('shortcodes/wordlift_shortcode_faceted_search.php');
494
+require_once('shortcodes/wordlift_shortcode_navigator.php');
495 495
 
496
-require_once( 'widgets/wordlift_widget_geo.php' );
497
-require_once( 'widgets/wordlift_widget_chord.php' );
498
-require_once( 'widgets/wordlift_widget_timeline.php' );
496
+require_once('widgets/wordlift_widget_geo.php');
497
+require_once('widgets/wordlift_widget_chord.php');
498
+require_once('widgets/wordlift_widget_timeline.php');
499 499
 
500
-require_once( 'wordlift_redlink.php' );
500
+require_once('wordlift_redlink.php');
501 501
 
502 502
 // Add admin functions.
503 503
 // TODO: find a way to make 'admin' UI tests work.
504 504
 //if ( is_admin() ) {
505 505
 
506
-require_once( 'admin/wordlift_admin.php' );
507
-require_once( 'admin/wordlift_admin_edit_post.php' );
508
-require_once( 'admin/wordlift_admin_save_post.php' );
506
+require_once('admin/wordlift_admin.php');
507
+require_once('admin/wordlift_admin_edit_post.php');
508
+require_once('admin/wordlift_admin_save_post.php');
509 509
 
510 510
 // add the entities meta box.
511
-require_once( 'admin/wordlift_admin_meta_box_entities.php' );
511
+require_once('admin/wordlift_admin_meta_box_entities.php');
512 512
 
513 513
 // add the entity creation AJAX.
514
-require_once( 'admin/wordlift_admin_ajax_related_posts.php' );
514
+require_once('admin/wordlift_admin_ajax_related_posts.php');
515 515
 
516 516
 // Load the wl_chord TinyMCE button and configuration dialog.
517
-require_once( 'admin/wordlift_admin_shortcodes.php' );
517
+require_once('admin/wordlift_admin_shortcodes.php');
518 518
 
519 519
 // load languages.
520 520
 // TODO: the following call gives for granted that the plugin is in the wordlift directory,
521 521
 //       we're currently doing this because wordlift is symbolic linked.
522
-load_plugin_textdomain( 'wordlift', false, '/wordlift/languages' );
522
+load_plugin_textdomain('wordlift', false, '/wordlift/languages');
523 523
 
524 524
 
525 525
 /**
@@ -527,7 +527,7 @@  discard block
 block discarded – undo
527 527
  * This action is documented in includes/class-wordlift-activator.php
528 528
  */
529 529
 function activate_wordlift() {
530
-	require_once plugin_dir_path( __FILE__ ) . 'includes/class-wordlift-activator.php';
530
+	require_once plugin_dir_path(__FILE__).'includes/class-wordlift-activator.php';
531 531
 	Wordlift_Activator::activate();
532 532
 }
533 533
 
@@ -536,18 +536,18 @@  discard block
 block discarded – undo
536 536
  * This action is documented in includes/class-wordlift-deactivator.php
537 537
  */
538 538
 function deactivate_wordlift() {
539
-	require_once plugin_dir_path( __FILE__ ) . 'includes/class-wordlift-deactivator.php';
539
+	require_once plugin_dir_path(__FILE__).'includes/class-wordlift-deactivator.php';
540 540
 	Wordlift_Deactivator::deactivate();
541 541
 }
542 542
 
543
-register_activation_hook( __FILE__, 'activate_wordlift' );
544
-register_deactivation_hook( __FILE__, 'deactivate_wordlift' );
543
+register_activation_hook(__FILE__, 'activate_wordlift');
544
+register_deactivation_hook(__FILE__, 'deactivate_wordlift');
545 545
 
546 546
 /**
547 547
  * The core plugin class that is used to define internationalization,
548 548
  * admin-specific hooks, and public-facing site hooks.
549 549
  */
550
-require plugin_dir_path( __FILE__ ) . 'includes/class-wordlift.php';
550
+require plugin_dir_path(__FILE__).'includes/class-wordlift.php';
551 551
 
552 552
 /**
553 553
  * Begins execution of the plugin.
Please login to merge, or discard this patch.