Completed
Push — develop ( 07d4e6...558e95 )
by David
03:30
created
src/admin/wordlift_admin_edit_post.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@
 block discarded – undo
12 12
  * @param string $new_title Optional. New title.
13 13
  * @param string $new_slug Optional. New slug.
14 14
  *
15
- * @return The enhanced html.
15
+ * @return string enhanced html.
16 16
  */
17 17
 function wl_admin_permalink_html( $html, $post_id, $new_title, $new_slug ) {
18 18
 
Please login to merge, or discard this patch.
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -16,23 +16,23 @@
 block discarded – undo
16 16
  */
17 17
 function wl_admin_permalink_html( $html, $post_id, $new_title, $new_slug ) {
18 18
 
19
-	// If the post is published, add the button to view Redlink's linked data.
20
-	if ( 'publish' == get_post_status( $post_id ) ) {
21
-		if ( $uri = wl_get_entity_uri( $post_id ) ) {
22
-			$uri_esc       = esc_attr( wl_get_entity_uri( $post_id ) );
23
-			$lod_view_href = 'http://lodview.it/lodview/?IRI=' . $uri_esc;
24
-			$html .= "<span id='view-post-btn'><a href='$lod_view_href' class='button button-small wl-button' target='_blank'>" .
25
-			         __( 'View Linked Data', 'wordlift' ) .
26
-			         "</a></span>\n";
27
-		}
28
-		$html .= "<span id='view-post-btn'><a href='" . WL_CONFIG_TEST_GOOGLE_RICH_SNIPPETS_URL .
29
-		         urlencode( get_permalink( $post_id ) ) .
30
-		         "' class='button button-small wl-button' target='_blank'>" .
31
-		         __( 'Test Google Rich Snippets', 'wordlift' ) .
32
-		         "</a></span>\n";
33
-	}
19
+    // If the post is published, add the button to view Redlink's linked data.
20
+    if ( 'publish' == get_post_status( $post_id ) ) {
21
+        if ( $uri = wl_get_entity_uri( $post_id ) ) {
22
+            $uri_esc       = esc_attr( wl_get_entity_uri( $post_id ) );
23
+            $lod_view_href = 'http://lodview.it/lodview/?IRI=' . $uri_esc;
24
+            $html .= "<span id='view-post-btn'><a href='$lod_view_href' class='button button-small wl-button' target='_blank'>" .
25
+                        __( 'View Linked Data', 'wordlift' ) .
26
+                        "</a></span>\n";
27
+        }
28
+        $html .= "<span id='view-post-btn'><a href='" . WL_CONFIG_TEST_GOOGLE_RICH_SNIPPETS_URL .
29
+                    urlencode( get_permalink( $post_id ) ) .
30
+                    "' class='button button-small wl-button' target='_blank'>" .
31
+                    __( 'Test Google Rich Snippets', 'wordlift' ) .
32
+                    "</a></span>\n";
33
+    }
34 34
 
35
-	return $html;
35
+    return $html;
36 36
 }
37 37
 
38 38
 add_filter( 'get_sample_permalink_html', 'wl_admin_permalink_html', 10, 4 );
39 39
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -14,25 +14,25 @@
 block discarded – undo
14 14
  *
15 15
  * @return The enhanced html.
16 16
  */
17
-function wl_admin_permalink_html( $html, $post_id, $new_title, $new_slug ) {
17
+function wl_admin_permalink_html($html, $post_id, $new_title, $new_slug) {
18 18
 
19 19
 	// If the post is published, add the button to view Redlink's linked data.
20
-	if ( 'publish' == get_post_status( $post_id ) ) {
21
-		if ( $uri = wl_get_entity_uri( $post_id ) ) {
22
-			$uri_esc       = esc_attr( wl_get_entity_uri( $post_id ) );
23
-			$lod_view_href = 'http://lodview.it/lodview/?IRI=' . $uri_esc;
24
-			$html .= "<span id='view-post-btn'><a href='$lod_view_href' class='button button-small wl-button' target='_blank'>" .
25
-			         __( 'View Linked Data', 'wordlift' ) .
20
+	if ('publish' == get_post_status($post_id)) {
21
+		if ($uri = wl_get_entity_uri($post_id)) {
22
+			$uri_esc       = esc_attr(wl_get_entity_uri($post_id));
23
+			$lod_view_href = 'http://lodview.it/lodview/?IRI='.$uri_esc;
24
+			$html .= "<span id='view-post-btn'><a href='$lod_view_href' class='button button-small wl-button' target='_blank'>".
25
+			         __('View Linked Data', 'wordlift').
26 26
 			         "</a></span>\n";
27 27
 		}
28
-		$html .= "<span id='view-post-btn'><a href='" . WL_CONFIG_TEST_GOOGLE_RICH_SNIPPETS_URL .
29
-		         urlencode( get_permalink( $post_id ) ) .
30
-		         "' class='button button-small wl-button' target='_blank'>" .
31
-		         __( 'Test Google Rich Snippets', 'wordlift' ) .
28
+		$html .= "<span id='view-post-btn'><a href='".WL_CONFIG_TEST_GOOGLE_RICH_SNIPPETS_URL.
29
+		         urlencode(get_permalink($post_id)).
30
+		         "' class='button button-small wl-button' target='_blank'>".
31
+		         __('Test Google Rich Snippets', 'wordlift').
32 32
 		         "</a></span>\n";
33 33
 	}
34 34
 
35 35
 	return $html;
36 36
 }
37 37
 
38
-add_filter( 'get_sample_permalink_html', 'wl_admin_permalink_html', 10, 4 );
39 38
\ No newline at end of file
39
+add_filter('get_sample_permalink_html', 'wl_admin_permalink_html', 10, 4);
40 40
\ No newline at end of file
Please login to merge, or discard this patch.
src/shortcodes/wordlift_shortcode_geomap.php 3 patches
Doc Comments   -1 removed lines patch added patch discarded remove patch
@@ -160,7 +160,6 @@
 block discarded – undo
160 160
  * @uses wl_shortcode_geomap_get_places() in order to retrieve places
161 161
  * @uses wl_shortcode_geomap_prepare_map() in order to encode retireved places in a Leaflet friendly format
162 162
  *
163
- * @param array $places An array of place posts.
164 163
  *
165 164
  * @return array An array of place posts.
166 165
  */
Please login to merge, or discard this patch.
Indentation   +119 added lines, -119 removed lines patch added patch discarded remove patch
@@ -14,56 +14,56 @@  discard block
 block discarded – undo
14 14
  */
15 15
 function wl_shortcode_geomap_get_places( $post_id = null ) {
16 16
 
17
-	// If $post_id is null or is not numeric it means this is a global geomap
18
-	$is_global = is_null( $post_id ) || ! is_numeric( $post_id );
17
+    // If $post_id is null or is not numeric it means this is a global geomap
18
+    $is_global = is_null( $post_id ) || ! is_numeric( $post_id );
19 19
 
20
-	// If the current one is not a global geomap, retrieve related entities ids
21
-	if ( $is_global ) {
22
-		$related_ids = array();
23
-	} else {
24
-		$related_ids = wl_core_get_related_entity_ids( $post_id, array(
25
-			'status' => 'publish'
26
-		) );
20
+    // If the current one is not a global geomap, retrieve related entities ids
21
+    if ( $is_global ) {
22
+        $related_ids = array();
23
+    } else {
24
+        $related_ids = wl_core_get_related_entity_ids( $post_id, array(
25
+            'status' => 'publish'
26
+        ) );
27 27
 		
28
-		// Also include current entity
29
-		if ( Wordlift_Entity_Service::get_instance()->is_entity( $post_id ) ) {
30
-			$related_ids[] = $post_id;
31
-		}
32
-	}
28
+        // Also include current entity
29
+        if ( Wordlift_Entity_Service::get_instance()->is_entity( $post_id ) ) {
30
+            $related_ids[] = $post_id;
31
+        }
32
+    }
33 33
 
34
-	// If is not a global geomap, an empty $related_ids means that no entities are related to the post
35
-	// An empty array can be returned in this case
36
-	if ( ! $is_global && empty( $related_ids ) ) {
37
-		return array();
38
-	}
34
+    // If is not a global geomap, an empty $related_ids means that no entities are related to the post
35
+    // An empty array can be returned in this case
36
+    if ( ! $is_global && empty( $related_ids ) ) {
37
+        return array();
38
+    }
39 39
 
40
-	// Retrieve all 'published' places with geo coordinates defined
41
-	// If $related_ids is not empty, it's used to limit query results to the current post related places
42
-	// Please note that when $place_ids is an empty array, the 'post__in' parameter is not considered in the query
43
-	return get_posts( array(
44
-		'post__in'    => $related_ids,
45
-		'post_type'   => Wordlift_Entity_Service::TYPE_NAME,
46
-		'nopaging'    => true,
47
-		'post_status' => 'publish',
48
-		'meta_query'  => array(
49
-			'relation' => 'AND',
50
-			array(
51
-				'key'     => Wordlift_Schema_Service::FIELD_GEO_LATITUDE,
52
-				'value'   => null,
53
-				'compare' => '!=',
54
-			),
55
-			array(
56
-				'key'     => Wordlift_Schema_Service::FIELD_GEO_LONGITUDE,
57
-				'value'   => null,
58
-				'compare' => '!=',
59
-			)
60
-		),
61
-		'tax_query'      => array(
62
-			'taxonomy' => Wordlift_Entity_Types_Taxonomy_Service::TAXONOMY_NAME,
63
-			'field'    => 'slug',
64
-			'terms'    => 'place'
65
-		)
66
-	) );
40
+    // Retrieve all 'published' places with geo coordinates defined
41
+    // If $related_ids is not empty, it's used to limit query results to the current post related places
42
+    // Please note that when $place_ids is an empty array, the 'post__in' parameter is not considered in the query
43
+    return get_posts( array(
44
+        'post__in'    => $related_ids,
45
+        'post_type'   => Wordlift_Entity_Service::TYPE_NAME,
46
+        'nopaging'    => true,
47
+        'post_status' => 'publish',
48
+        'meta_query'  => array(
49
+            'relation' => 'AND',
50
+            array(
51
+                'key'     => Wordlift_Schema_Service::FIELD_GEO_LATITUDE,
52
+                'value'   => null,
53
+                'compare' => '!=',
54
+            ),
55
+            array(
56
+                'key'     => Wordlift_Schema_Service::FIELD_GEO_LONGITUDE,
57
+                'value'   => null,
58
+                'compare' => '!=',
59
+            )
60
+        ),
61
+        'tax_query'      => array(
62
+            'taxonomy' => Wordlift_Entity_Types_Taxonomy_Service::TAXONOMY_NAME,
63
+            'field'    => 'slug',
64
+            'terms'    => 'place'
65
+        )
66
+    ) );
67 67
 }
68 68
 
69 69
 /**
@@ -78,88 +78,88 @@  discard block
 block discarded – undo
78 78
  */
79 79
 function wl_shortcode_geomap_prepare_map( $places ) {
80 80
 
81
-	// Prepare for min/max lat/long in case we need to define a view boundary for the client JavaScript.
82
-	$min_latitude  = PHP_INT_MAX;
83
-	$min_longitude = PHP_INT_MAX;
84
-	$max_latitude  = ~PHP_INT_MAX;
85
-	$max_longitude = ~PHP_INT_MAX;
81
+    // Prepare for min/max lat/long in case we need to define a view boundary for the client JavaScript.
82
+    $min_latitude  = PHP_INT_MAX;
83
+    $min_longitude = PHP_INT_MAX;
84
+    $max_latitude  = ~PHP_INT_MAX;
85
+    $max_longitude = ~PHP_INT_MAX;
86 86
 
87
-	// Prepare an empty array of POIs in geoJSON format.
88
-	$pois = array();
89
-	// And store list of points to allow Leaflet compute the optimal bounding box.
90
-	// The main reason for this is that geoJSON has swapped coordinates (lon. lat)
91
-	$boundaries = array();
87
+    // Prepare an empty array of POIs in geoJSON format.
88
+    $pois = array();
89
+    // And store list of points to allow Leaflet compute the optimal bounding box.
90
+    // The main reason for this is that geoJSON has swapped coordinates (lon. lat)
91
+    $boundaries = array();
92 92
 
93
-	// Add a POI for each entity that has coordinates.
94
-	foreach ( $places as $entity ) {
93
+    // Add a POI for each entity that has coordinates.
94
+    foreach ( $places as $entity ) {
95 95
 
96
-		// Get the coordinates.
97
-		$coordinates = wl_get_coordinates( $entity->ID );
96
+        // Get the coordinates.
97
+        $coordinates = wl_get_coordinates( $entity->ID );
98 98
 
99
-		// Don't show the widget if the coordinates aren't set.
100
-		if ( $coordinates['latitude'] == 0 || $coordinates['longitude'] == 0 ) {
101
-			continue;
102
-		}
99
+        // Don't show the widget if the coordinates aren't set.
100
+        if ( $coordinates['latitude'] == 0 || $coordinates['longitude'] == 0 ) {
101
+            continue;
102
+        }
103 103
 
104
-		// TODO Map html rendering should be delegated to the wordlift js ui layer
105
-		// This function should be focused on returning pure data instead
104
+        // TODO Map html rendering should be delegated to the wordlift js ui layer
105
+        // This function should be focused on returning pure data instead
106 106
 
107
-		// Get the title, URL and thumb of the entity.
108
-		$title = esc_attr( $entity->post_title );
109
-		$link  = esc_attr( get_permalink( $entity->ID ) );
110
-		if ( '' !== ( $thumbnail_id = get_post_thumbnail_id( $entity->ID ) ) &&
111
-		     false !== ( $attachment = wp_get_attachment_image_src( $thumbnail_id ) )
112
-		) {
113
-			$img_src = esc_attr( $attachment[0] );
114
-		}
107
+        // Get the title, URL and thumb of the entity.
108
+        $title = esc_attr( $entity->post_title );
109
+        $link  = esc_attr( get_permalink( $entity->ID ) );
110
+        if ( '' !== ( $thumbnail_id = get_post_thumbnail_id( $entity->ID ) ) &&
111
+             false !== ( $attachment = wp_get_attachment_image_src( $thumbnail_id ) )
112
+        ) {
113
+            $img_src = esc_attr( $attachment[0] );
114
+        }
115 115
 
116
-		// Build HTML popup. TODO: move thumb width in css
117
-		$content = "<a href=$link><h6>$title</h6>";
118
-		if ( isset( $img_src ) ) {
119
-			$content = $content . "<img src=$img_src style='width:100%'/>";
120
-		}
121
-		$content = $content . "</a><ul>";
122
-		// Get the related posts (published) and print them in the popup.
123
-		$related_posts = wl_core_get_related_post_ids( $entity->ID, array(
124
-			'status' => 'publish'
125
-		) );
126
-		foreach ( $related_posts as $rp_id ) {
116
+        // Build HTML popup. TODO: move thumb width in css
117
+        $content = "<a href=$link><h6>$title</h6>";
118
+        if ( isset( $img_src ) ) {
119
+            $content = $content . "<img src=$img_src style='width:100%'/>";
120
+        }
121
+        $content = $content . "</a><ul>";
122
+        // Get the related posts (published) and print them in the popup.
123
+        $related_posts = wl_core_get_related_post_ids( $entity->ID, array(
124
+            'status' => 'publish'
125
+        ) );
126
+        foreach ( $related_posts as $rp_id ) {
127 127
 
128
-			$rp      = get_post( $rp_id );
129
-			$title   = esc_attr( $rp->post_title );
130
-			$link    = esc_attr( get_permalink( $rp->ID ) );
131
-			$content = $content . "<li><a href=$link>$title</a></li>";
132
-		}
133
-		$content = $content . "</ul>";
128
+            $rp      = get_post( $rp_id );
129
+            $title   = esc_attr( $rp->post_title );
130
+            $link    = esc_attr( get_permalink( $rp->ID ) );
131
+            $content = $content . "<li><a href=$link>$title</a></li>";
132
+        }
133
+        $content = $content . "</ul>";
134 134
 
135
-		// Formatting POI in geoJSON.
136
-		// http://leafletjs.com/examples/geojson.html
137
-		$poi = array(
138
-			'type'       => 'Feature',
139
-			'properties' => array( 'popupContent' => $content ),
140
-			'geometry'   => array(
141
-				'type'        => 'Point',
142
-				'coordinates' => array(
143
-					// Leaflet geoJSON wants them swapped
144
-					$coordinates['longitude'],
145
-					$coordinates['latitude']
146
-				)
147
-			)
148
-		);
135
+        // Formatting POI in geoJSON.
136
+        // http://leafletjs.com/examples/geojson.html
137
+        $poi = array(
138
+            'type'       => 'Feature',
139
+            'properties' => array( 'popupContent' => $content ),
140
+            'geometry'   => array(
141
+                'type'        => 'Point',
142
+                'coordinates' => array(
143
+                    // Leaflet geoJSON wants them swapped
144
+                    $coordinates['longitude'],
145
+                    $coordinates['latitude']
146
+                )
147
+            )
148
+        );
149 149
 
150
-		$pois[] = $poi;
150
+        $pois[] = $poi;
151 151
 
152
-		// Formatting boundaries in a Leaflet-like format (see LatLngBounds).
153
-		// http://leafletjs.com/reference.html#latlngbounds
154
-		$boundaries[] = array( $coordinates['latitude'], $coordinates['longitude'] );
152
+        // Formatting boundaries in a Leaflet-like format (see LatLngBounds).
153
+        // http://leafletjs.com/reference.html#latlngbounds
154
+        $boundaries[] = array( $coordinates['latitude'], $coordinates['longitude'] );
155 155
 
156
-	}
156
+    }
157 157
 
158
-	$map_data               = array();
159
-	$map_data['features']   = $pois;
160
-	$map_data['boundaries'] = $boundaries;
158
+    $map_data               = array();
159
+    $map_data['features']   = $pois;
160
+    $map_data['boundaries'] = $boundaries;
161 161
 
162
-	return $map_data;
162
+    return $map_data;
163 163
 }
164 164
 
165 165
 /**
@@ -173,13 +173,13 @@  discard block
 block discarded – undo
173 173
  * @return array An array of place posts.
174 174
  */
175 175
 function wl_shortcode_geomap_ajax() {
176
-	// Get the post Id.
177
-	$post_id = ( isset( $_REQUEST['post_id'] ) ? $_REQUEST['post_id'] : null );
176
+    // Get the post Id.
177
+    $post_id = ( isset( $_REQUEST['post_id'] ) ? $_REQUEST['post_id'] : null );
178 178
 
179
-	$places   = wl_shortcode_geomap_get_places( $post_id );
180
-	$map_data = wl_shortcode_geomap_prepare_map( $places );
179
+    $places   = wl_shortcode_geomap_get_places( $post_id );
180
+    $map_data = wl_shortcode_geomap_prepare_map( $places );
181 181
 
182
-	wl_core_send_json( $map_data );
182
+    wl_core_send_json( $map_data );
183 183
 }
184 184
 
185 185
 add_action( 'wp_ajax_wl_geomap', 'wl_shortcode_geomap_ajax' );
Please login to merge, or discard this patch.
Spacing   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -12,35 +12,35 @@  discard block
 block discarded – undo
12 12
  *
13 13
  * @return array An array of place posts.
14 14
  */
15
-function wl_shortcode_geomap_get_places( $post_id = null ) {
15
+function wl_shortcode_geomap_get_places($post_id = null) {
16 16
 
17 17
 	// If $post_id is null or is not numeric it means this is a global geomap
18
-	$is_global = is_null( $post_id ) || ! is_numeric( $post_id );
18
+	$is_global = is_null($post_id) || ! is_numeric($post_id);
19 19
 
20 20
 	// If the current one is not a global geomap, retrieve related entities ids
21
-	if ( $is_global ) {
21
+	if ($is_global) {
22 22
 		$related_ids = array();
23 23
 	} else {
24
-		$related_ids = wl_core_get_related_entity_ids( $post_id, array(
24
+		$related_ids = wl_core_get_related_entity_ids($post_id, array(
25 25
 			'status' => 'publish'
26
-		) );
26
+		));
27 27
 		
28 28
 		// Also include current entity
29
-		if ( Wordlift_Entity_Service::get_instance()->is_entity( $post_id ) ) {
29
+		if (Wordlift_Entity_Service::get_instance()->is_entity($post_id)) {
30 30
 			$related_ids[] = $post_id;
31 31
 		}
32 32
 	}
33 33
 
34 34
 	// If is not a global geomap, an empty $related_ids means that no entities are related to the post
35 35
 	// An empty array can be returned in this case
36
-	if ( ! $is_global && empty( $related_ids ) ) {
36
+	if ( ! $is_global && empty($related_ids)) {
37 37
 		return array();
38 38
 	}
39 39
 
40 40
 	// Retrieve all 'published' places with geo coordinates defined
41 41
 	// If $related_ids is not empty, it's used to limit query results to the current post related places
42 42
 	// Please note that when $place_ids is an empty array, the 'post__in' parameter is not considered in the query
43
-	return get_posts( array(
43
+	return get_posts(array(
44 44
 		'post__in'    => $related_ids,
45 45
 		'post_type'   => Wordlift_Entity_Service::TYPE_NAME,
46 46
 		'nopaging'    => true,
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
 			'field'    => 'slug',
64 64
 			'terms'    => 'place'
65 65
 		)
66
-	) );
66
+	));
67 67
 }
68 68
 
69 69
 /**
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
  *
77 77
  * @return array An array of markers and boundaries for Leaflet.
78 78
  */
79
-function wl_shortcode_geomap_prepare_map( $places ) {
79
+function wl_shortcode_geomap_prepare_map($places) {
80 80
 
81 81
 	// Prepare for min/max lat/long in case we need to define a view boundary for the client JavaScript.
82 82
 	$min_latitude  = PHP_INT_MAX;
@@ -91,13 +91,13 @@  discard block
 block discarded – undo
91 91
 	$boundaries = array();
92 92
 
93 93
 	// Add a POI for each entity that has coordinates.
94
-	foreach ( $places as $entity ) {
94
+	foreach ($places as $entity) {
95 95
 
96 96
 		// Get the coordinates.
97
-		$coordinates = wl_get_coordinates( $entity->ID );
97
+		$coordinates = wl_get_coordinates($entity->ID);
98 98
 
99 99
 		// Don't show the widget if the coordinates aren't set.
100
-		if ( $coordinates['latitude'] == 0 || $coordinates['longitude'] == 0 ) {
100
+		if ($coordinates['latitude'] == 0 || $coordinates['longitude'] == 0) {
101 101
 			continue;
102 102
 		}
103 103
 
@@ -105,38 +105,38 @@  discard block
 block discarded – undo
105 105
 		// This function should be focused on returning pure data instead
106 106
 
107 107
 		// Get the title, URL and thumb of the entity.
108
-		$title = esc_attr( $entity->post_title );
109
-		$link  = esc_attr( get_permalink( $entity->ID ) );
110
-		if ( '' !== ( $thumbnail_id = get_post_thumbnail_id( $entity->ID ) ) &&
111
-		     false !== ( $attachment = wp_get_attachment_image_src( $thumbnail_id ) )
108
+		$title = esc_attr($entity->post_title);
109
+		$link  = esc_attr(get_permalink($entity->ID));
110
+		if ('' !== ($thumbnail_id = get_post_thumbnail_id($entity->ID)) &&
111
+		     false !== ($attachment = wp_get_attachment_image_src($thumbnail_id))
112 112
 		) {
113
-			$img_src = esc_attr( $attachment[0] );
113
+			$img_src = esc_attr($attachment[0]);
114 114
 		}
115 115
 
116 116
 		// Build HTML popup. TODO: move thumb width in css
117 117
 		$content = "<a href=$link><h6>$title</h6>";
118
-		if ( isset( $img_src ) ) {
119
-			$content = $content . "<img src=$img_src style='width:100%'/>";
118
+		if (isset($img_src)) {
119
+			$content = $content."<img src=$img_src style='width:100%'/>";
120 120
 		}
121
-		$content = $content . "</a><ul>";
121
+		$content = $content."</a><ul>";
122 122
 		// Get the related posts (published) and print them in the popup.
123
-		$related_posts = wl_core_get_related_post_ids( $entity->ID, array(
123
+		$related_posts = wl_core_get_related_post_ids($entity->ID, array(
124 124
 			'status' => 'publish'
125
-		) );
126
-		foreach ( $related_posts as $rp_id ) {
125
+		));
126
+		foreach ($related_posts as $rp_id) {
127 127
 
128
-			$rp      = get_post( $rp_id );
129
-			$title   = esc_attr( $rp->post_title );
130
-			$link    = esc_attr( get_permalink( $rp->ID ) );
131
-			$content = $content . "<li><a href=$link>$title</a></li>";
128
+			$rp      = get_post($rp_id);
129
+			$title   = esc_attr($rp->post_title);
130
+			$link    = esc_attr(get_permalink($rp->ID));
131
+			$content = $content."<li><a href=$link>$title</a></li>";
132 132
 		}
133
-		$content = $content . "</ul>";
133
+		$content = $content."</ul>";
134 134
 
135 135
 		// Formatting POI in geoJSON.
136 136
 		// http://leafletjs.com/examples/geojson.html
137 137
 		$poi = array(
138 138
 			'type'       => 'Feature',
139
-			'properties' => array( 'popupContent' => $content ),
139
+			'properties' => array('popupContent' => $content),
140 140
 			'geometry'   => array(
141 141
 				'type'        => 'Point',
142 142
 				'coordinates' => array(
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
 
152 152
 		// Formatting boundaries in a Leaflet-like format (see LatLngBounds).
153 153
 		// http://leafletjs.com/reference.html#latlngbounds
154
-		$boundaries[] = array( $coordinates['latitude'], $coordinates['longitude'] );
154
+		$boundaries[] = array($coordinates['latitude'], $coordinates['longitude']);
155 155
 
156 156
 	}
157 157
 
@@ -174,16 +174,16 @@  discard block
 block discarded – undo
174 174
  */
175 175
 function wl_shortcode_geomap_ajax() {
176 176
 	// Get the post Id.
177
-	$post_id = ( isset( $_REQUEST['post_id'] ) ? $_REQUEST['post_id'] : null );
177
+	$post_id = (isset($_REQUEST['post_id']) ? $_REQUEST['post_id'] : null);
178 178
 
179
-	$places   = wl_shortcode_geomap_get_places( $post_id );
180
-	$map_data = wl_shortcode_geomap_prepare_map( $places );
179
+	$places   = wl_shortcode_geomap_get_places($post_id);
180
+	$map_data = wl_shortcode_geomap_prepare_map($places);
181 181
 
182
-	wl_core_send_json( $map_data );
182
+	wl_core_send_json($map_data);
183 183
 }
184 184
 
185
-add_action( 'wp_ajax_wl_geomap', 'wl_shortcode_geomap_ajax' );
186
-add_action( 'wp_ajax_nopriv_wl_geomap', 'wl_shortcode_geomap_ajax' );
185
+add_action('wp_ajax_wl_geomap', 'wl_shortcode_geomap_ajax');
186
+add_action('wp_ajax_nopriv_wl_geomap', 'wl_shortcode_geomap_ajax');
187 187
 
188 188
 ///**
189 189
 // * Print geomap shortcode
Please login to merge, or discard this patch.
src/wordlift.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -93,7 +93,7 @@
 block discarded – undo
93 93
  *
94 94
  * @since 3.0.0
95 95
  *
96
- * @param $text string A text that may potentially contain a WL key.
96
+ * @param string $text string A text that may potentially contain a WL key.
97 97
  *
98 98
  * @return string A text with the key hidden.
99 99
  */
Please login to merge, or discard this patch.
Indentation   +245 added lines, -245 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
 //	$handler = apply_filters( 'wl_write_log_handler', null );
54 54
 //
@@ -76,20 +76,20 @@  discard block
 block discarded – undo
76 76
  */
77 77
 function wl_write_log_handler( $log, $caller = null ) {
78 78
 
79
-	global $wl_logger;
79
+    global $wl_logger;
80 80
 
81
-	if ( true === WP_DEBUG ) {
81
+    if ( true === WP_DEBUG ) {
82 82
 
83
-		$message = ( isset( $caller ) ? sprintf( '[%-40.40s] ', $caller ) : '' ) .
84
-		           ( is_array( $log ) || is_object( $log ) ? print_r( $log, true ) : wl_write_log_hide_key( $log ) );
83
+        $message = ( isset( $caller ) ? sprintf( '[%-40.40s] ', $caller ) : '' ) .
84
+                    ( is_array( $log ) || is_object( $log ) ? print_r( $log, true ) : wl_write_log_hide_key( $log ) );
85 85
 
86
-		if ( isset( $wl_logger ) ) {
87
-			$wl_logger->info( $message );
88
-		} else {
89
-			error_log( $message );
90
-		}
86
+        if ( isset( $wl_logger ) ) {
87
+            $wl_logger->info( $message );
88
+        } else {
89
+            error_log( $message );
90
+        }
91 91
 
92
-	}
92
+    }
93 93
 
94 94
 }
95 95
 
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
  */
107 107
 function wl_write_log_hide_key( $text ) {
108 108
 
109
-	return str_ireplace( wl_configuration_get_key(), '<hidden>', $text );
109
+    return str_ireplace( wl_configuration_get_key(), '<hidden>', $text );
110 110
 }
111 111
 
112 112
 /**
@@ -118,10 +118,10 @@  discard block
 block discarded – undo
118 118
  */
119 119
 function wl_queue_sparql_update_query( $query ) {
120 120
 
121
-	$filename = WL_TEMP_DIR . WL_REQUEST_ID . '.sparql';
122
-	file_put_contents( $filename, $query . "\n", FILE_APPEND );
121
+    $filename = WL_TEMP_DIR . WL_REQUEST_ID . '.sparql';
122
+    file_put_contents( $filename, $query . "\n", FILE_APPEND );
123 123
 
124
-	wl_write_log( "wl_queue_sparql_update_query [ filename :: $filename ]" );
124
+    wl_write_log( "wl_queue_sparql_update_query [ filename :: $filename ]" );
125 125
 }
126 126
 
127 127
 /**
@@ -131,28 +131,28 @@  discard block
 block discarded – undo
131 131
  */
132 132
 function wl_execute_saved_sparql_update_query( $request_id ) {
133 133
 
134
-	$filename = WL_TEMP_DIR . $request_id . '.sparql';
134
+    $filename = WL_TEMP_DIR . $request_id . '.sparql';
135 135
 
136
-	// If the file doesn't exist, exit.
137
-	if ( ! file_exists( $filename ) ) {
138
-		wl_write_log( "wl_execute_saved_sparql_update_query : file doesn't exist [ filename :: $filename ]" );
136
+    // If the file doesn't exist, exit.
137
+    if ( ! file_exists( $filename ) ) {
138
+        wl_write_log( "wl_execute_saved_sparql_update_query : file doesn't exist [ filename :: $filename ]" );
139 139
 
140
-		return;
141
-	}
140
+        return;
141
+    }
142 142
 
143
-	wl_write_log( "wl_execute_saved_sparql_update_query [ filename :: $filename ]" );
143
+    wl_write_log( "wl_execute_saved_sparql_update_query [ filename :: $filename ]" );
144 144
 
145
-	// Get the query saved in the file.
146
-	$query = file_get_contents( $filename );
145
+    // Get the query saved in the file.
146
+    $query = file_get_contents( $filename );
147 147
 
148
-	// Execute the SPARQL query.
149
-	rl_execute_sparql_update_query( $query, false );
148
+    // Execute the SPARQL query.
149
+    rl_execute_sparql_update_query( $query, false );
150 150
 
151
-	// Reindex the triple store.
152
-	wordlift_reindex_triple_store();
151
+    // Reindex the triple store.
152
+    wordlift_reindex_triple_store();
153 153
 
154
-	// Delete the temporary file.
155
-	unlink( $filename );
154
+    // Delete the temporary file.
155
+    unlink( $filename );
156 156
 }
157 157
 
158 158
 add_action( 'wl_execute_saved_sparql_update_query', 'wl_execute_saved_sparql_update_query', 10, 1 );
@@ -162,10 +162,10 @@  discard block
 block discarded – undo
162 162
  */
163 163
 function wordlift_buttonhooks() {
164 164
 
165
-	// Only add hooks when the current user has permissions AND is in Rich Text editor mode
166
-	if ( ( current_user_can( 'edit_posts' ) || current_user_can( 'edit_pages' ) ) && get_user_option( 'rich_editing' ) ) {
167
-		add_filter( 'mce_external_plugins', 'wordlift_register_tinymce_javascript' );
168
-	}
165
+    // Only add hooks when the current user has permissions AND is in Rich Text editor mode
166
+    if ( ( current_user_can( 'edit_posts' ) || current_user_can( 'edit_pages' ) ) && get_user_option( 'rich_editing' ) ) {
167
+        add_filter( 'mce_external_plugins', 'wordlift_register_tinymce_javascript' );
168
+    }
169 169
 }
170 170
 
171 171
 /**
@@ -177,16 +177,16 @@  discard block
 block discarded – undo
177 177
  */
178 178
 function wordlift_register_tinymce_javascript( $plugin_array ) {
179 179
 
180
-	// add the wordlift plugin.
181
-	// We can't use the minified version here.
180
+    // add the wordlift plugin.
181
+    // We can't use the minified version here.
182 182
 
183
-	// Get WordLift's version as a cache killer.
184
-	$version = Wordlift::get_instance()->get_version();
183
+    // Get WordLift's version as a cache killer.
184
+    $version = Wordlift::get_instance()->get_version();
185 185
 
186
-	// Add our own JavaScript file to TinyMCE's extensions.
187
-	$plugin_array['wordlift'] = plugin_dir_url( __FILE__ ) . 'js/wordlift-reloaded.js?ver=' . $version;
186
+    // Add our own JavaScript file to TinyMCE's extensions.
187
+    $plugin_array['wordlift'] = plugin_dir_url( __FILE__ ) . 'js/wordlift-reloaded.js?ver=' . $version;
188 188
 
189
-	return $plugin_array;
189
+    return $plugin_array;
190 190
 }
191 191
 
192 192
 /**
@@ -194,21 +194,21 @@  discard block
 block discarded – undo
194 194
  * see http://vip.wordpress.com/documentation/register-additional-html-attributes-for-tinymce-and-wp-kses/
195 195
  */
196 196
 function wordlift_allowed_post_tags() {
197
-	global $allowedposttags;
198
-
199
-	$tags           = array( 'span' );
200
-	$new_attributes = array(
201
-		'itemscope' => array(),
202
-		'itemtype'  => array(),
203
-		'itemprop'  => array(),
204
-		'itemid'    => array(),
205
-	);
206
-
207
-	foreach ( $tags as $tag ) {
208
-		if ( isset( $allowedposttags[ $tag ] ) && is_array( $allowedposttags[ $tag ] ) ) {
209
-			$allowedposttags[ $tag ] = array_merge( $allowedposttags[ $tag ], $new_attributes );
210
-		}
211
-	}
197
+    global $allowedposttags;
198
+
199
+    $tags           = array( 'span' );
200
+    $new_attributes = array(
201
+        'itemscope' => array(),
202
+        'itemtype'  => array(),
203
+        'itemprop'  => array(),
204
+        'itemid'    => array(),
205
+    );
206
+
207
+    foreach ( $tags as $tag ) {
208
+        if ( isset( $allowedposttags[ $tag ] ) && is_array( $allowedposttags[ $tag ] ) ) {
209
+            $allowedposttags[ $tag ] = array_merge( $allowedposttags[ $tag ], $new_attributes );
210
+        }
211
+    }
212 212
 }
213 213
 
214 214
 // init process for button control
@@ -222,28 +222,28 @@  discard block
 block discarded – undo
222 222
  */
223 223
 function wordlift_admin_enqueue_scripts() {
224 224
 
225
-	// Added for compatibility with WordPress 3.9 (see http://make.wordpress.org/core/2014/04/16/jquery-ui-and-wpdialogs-in-wordpress-3-9/)
226
-	wp_enqueue_script( 'wpdialogs' );
227
-	wp_enqueue_style( 'wp-jquery-ui-dialog' );
225
+    // Added for compatibility with WordPress 3.9 (see http://make.wordpress.org/core/2014/04/16/jquery-ui-and-wpdialogs-in-wordpress-3-9/)
226
+    wp_enqueue_script( 'wpdialogs' );
227
+    wp_enqueue_style( 'wp-jquery-ui-dialog' );
228 228
 
229
-	wp_enqueue_style( 'wordlift-reloaded', plugin_dir_url( __FILE__ ) . 'css/wordlift-reloaded.min.css' );
229
+    wp_enqueue_style( 'wordlift-reloaded', plugin_dir_url( __FILE__ ) . 'css/wordlift-reloaded.min.css' );
230 230
 
231
-	wp_enqueue_script( 'jquery-ui-autocomplete' );
232
-	wp_enqueue_script( 'angularjs', 'https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.11/angular.min.js' );
233
-	wp_enqueue_script( 'angularjs-geolocation', plugin_dir_url( __FILE__ ) . '/bower_components/angularjs-geolocation/dist/angularjs-geolocation.min.js' );
234
-	wp_enqueue_script( 'angularjs-touch', 'https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.11/angular-touch.min.js' );
235
-	wp_enqueue_script( 'angularjs-animate', 'https://code.angularjs.org/1.3.11/angular-animate.min.js' );
231
+    wp_enqueue_script( 'jquery-ui-autocomplete' );
232
+    wp_enqueue_script( 'angularjs', 'https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.11/angular.min.js' );
233
+    wp_enqueue_script( 'angularjs-geolocation', plugin_dir_url( __FILE__ ) . '/bower_components/angularjs-geolocation/dist/angularjs-geolocation.min.js' );
234
+    wp_enqueue_script( 'angularjs-touch', 'https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.11/angular-touch.min.js' );
235
+    wp_enqueue_script( 'angularjs-animate', 'https://code.angularjs.org/1.3.11/angular-animate.min.js' );
236 236
 
237
-	// Disable auto-save for custom entity posts only
238
-	if ( Wordlift_Entity_Service::TYPE_NAME === get_post_type() ) {
239
-		wp_dequeue_script( 'autosave' );
240
-	}
237
+    // Disable auto-save for custom entity posts only
238
+    if ( Wordlift_Entity_Service::TYPE_NAME === get_post_type() ) {
239
+        wp_dequeue_script( 'autosave' );
240
+    }
241 241
 }
242 242
 
243 243
 add_action( 'admin_enqueue_scripts', 'wordlift_admin_enqueue_scripts' );
244 244
 
245 245
 function wl_enqueue_scripts() {
246
-	wp_enqueue_style( 'wordlift-ui', plugin_dir_url( __FILE__ ) . 'css/wordlift-ui.min.css' );
246
+    wp_enqueue_style( 'wordlift-ui', plugin_dir_url( __FILE__ ) . 'css/wordlift-ui.min.css' );
247 247
 }
248 248
 
249 249
 add_action( 'wp_enqueue_scripts', 'wl_enqueue_scripts' );
@@ -258,18 +258,18 @@  discard block
 block discarded – undo
258 258
  */
259 259
 function wordlift_allowed_html( $allowedtags, $context ) {
260 260
 
261
-	if ( 'post' !== $context ) {
262
-		return $allowedtags;
263
-	}
264
-
265
-	return array_merge_recursive( $allowedtags, array(
266
-		'span' => array(
267
-			'itemscope' => true,
268
-			'itemtype'  => true,
269
-			'itemid'    => true,
270
-			'itemprop'  => true,
271
-		),
272
-	) );
261
+    if ( 'post' !== $context ) {
262
+        return $allowedtags;
263
+    }
264
+
265
+    return array_merge_recursive( $allowedtags, array(
266
+        'span' => array(
267
+            'itemscope' => true,
268
+            'itemtype'  => true,
269
+            'itemid'    => true,
270
+            'itemprop'  => true,
271
+        ),
272
+    ) );
273 273
 }
274 274
 
275 275
 add_filter( 'wp_kses_allowed_html', 'wordlift_allowed_html', 10, 2 );
@@ -283,15 +283,15 @@  discard block
 block discarded – undo
283 283
  */
284 284
 function wl_get_coordinates( $post_id ) {
285 285
 
286
-	$latitude  = wl_schema_get_value( $post_id, 'latitude' );
287
-	$longitude = wl_schema_get_value( $post_id, 'longitude' );
286
+    $latitude  = wl_schema_get_value( $post_id, 'latitude' );
287
+    $longitude = wl_schema_get_value( $post_id, 'longitude' );
288 288
 
289
-	// DO NOT set latitude/longitude to 0/0 as default values. It's a specific place on the globe:
290
-	// "The zero/zero point of this system is located in the Gulf of Guinea about 625 km (390 mi) south of Tema, Ghana."
291
-	return array(
292
-		'latitude'  => isset( $latitude[0] ) && is_numeric( $latitude[0] ) ? $latitude[0] : '',
293
-		'longitude' => isset( $longitude[0] ) && is_numeric( $longitude[0] ) ? $longitude[0] : '',
294
-	);
289
+    // DO NOT set latitude/longitude to 0/0 as default values. It's a specific place on the globe:
290
+    // "The zero/zero point of this system is located in the Gulf of Guinea about 625 km (390 mi) south of Tema, Ghana."
291
+    return array(
292
+        'latitude'  => isset( $latitude[0] ) && is_numeric( $latitude[0] ) ? $latitude[0] : '',
293
+        'longitude' => isset( $longitude[0] ) && is_numeric( $longitude[0] ) ? $longitude[0] : '',
294
+    );
295 295
 }
296 296
 
297 297
 /**
@@ -303,13 +303,13 @@  discard block
 block discarded – undo
303 303
  */
304 304
 function wl_get_post_modified_time( $post ) {
305 305
 
306
-	$date_modified = get_post_modified_time( 'c', true, $post );
306
+    $date_modified = get_post_modified_time( 'c', true, $post );
307 307
 
308
-	if ( '-' === substr( $date_modified, 0, 1 ) ) {
309
-		return get_the_time( 'c', $post );
310
-	}
308
+    if ( '-' === substr( $date_modified, 0, 1 ) ) {
309
+        return get_the_time( 'c', $post );
310
+    }
311 311
 
312
-	return $date_modified;
312
+    return $date_modified;
313 313
 }
314 314
 
315 315
 /**
@@ -322,42 +322,42 @@  discard block
 block discarded – undo
322 322
 function wl_get_image_urls( $post_id ) {
323 323
 
324 324
 
325
-	// If there is a featured image it has the priority
326
-	$featured_image_id = get_post_thumbnail_id( $post_id );
327
-	if ( is_numeric( $featured_image_id ) ) {
328
-		$image_url = wp_get_attachment_url( $featured_image_id );
325
+    // If there is a featured image it has the priority
326
+    $featured_image_id = get_post_thumbnail_id( $post_id );
327
+    if ( is_numeric( $featured_image_id ) ) {
328
+        $image_url = wp_get_attachment_url( $featured_image_id );
329 329
 
330
-		return array( $image_url );
331
-	}
330
+        return array( $image_url );
331
+    }
332 332
 
333
-	// wl_write_log( "wl_get_image_urls [ post id :: $post_id ]" );
333
+    // wl_write_log( "wl_get_image_urls [ post id :: $post_id ]" );
334 334
 
335
-	$images = get_children( array(
336
-		'post_parent'    => $post_id,
337
-		'post_type'      => 'attachment',
338
-		'post_mime_type' => 'image',
339
-	) );
335
+    $images = get_children( array(
336
+        'post_parent'    => $post_id,
337
+        'post_type'      => 'attachment',
338
+        'post_mime_type' => 'image',
339
+    ) );
340 340
 
341
-	// Return an empty array if no image is found.
342
-	if ( empty( $images ) ) {
343
-		return array();
344
-	}
341
+    // Return an empty array if no image is found.
342
+    if ( empty( $images ) ) {
343
+        return array();
344
+    }
345 345
 
346
-	// Prepare the return array.
347
-	$image_urls = array();
346
+    // Prepare the return array.
347
+    $image_urls = array();
348 348
 
349
-	// Collect the URLs.
350
-	foreach ( $images as $attachment_id => $attachment ) {
351
-		$image_url = wp_get_attachment_url( $attachment_id );
352
-		// Ensure the URL isn't collected already.
353
-		if ( ! in_array( $image_url, $image_urls ) ) {
354
-			array_push( $image_urls, $image_url );
355
-		}
356
-	}
349
+    // Collect the URLs.
350
+    foreach ( $images as $attachment_id => $attachment ) {
351
+        $image_url = wp_get_attachment_url( $attachment_id );
352
+        // Ensure the URL isn't collected already.
353
+        if ( ! in_array( $image_url, $image_urls ) ) {
354
+            array_push( $image_urls, $image_url );
355
+        }
356
+    }
357 357
 
358
-	// wl_write_log( "wl_get_image_urls [ post id :: $post_id ][ image urls count :: " . count( $image_urls ) . " ]" );
358
+    // wl_write_log( "wl_get_image_urls [ post id :: $post_id ][ image urls count :: " . count( $image_urls ) . " ]" );
359 359
 
360
-	return $image_urls;
360
+    return $image_urls;
361 361
 }
362 362
 
363 363
 /**
@@ -370,19 +370,19 @@  discard block
 block discarded – undo
370 370
  */
371 371
 function wl_get_sparql_images( $uri, $post_id ) {
372 372
 
373
-	$sparql = '';
373
+    $sparql = '';
374 374
 
375
-	// Get the escaped URI.
376
-	$uri_e = esc_html( $uri );
375
+    // Get the escaped URI.
376
+    $uri_e = esc_html( $uri );
377 377
 
378
-	// Add SPARQL stmts to write the schema:image.
379
-	$image_urls = wl_get_image_urls( $post_id );
380
-	foreach ( $image_urls as $image_url ) {
381
-		$image_url_esc = wl_sparql_escape_uri( $image_url );
382
-		$sparql .= " <$uri_e> schema:image <$image_url_esc> . \n";
383
-	}
378
+    // Add SPARQL stmts to write the schema:image.
379
+    $image_urls = wl_get_image_urls( $post_id );
380
+    foreach ( $image_urls as $image_url ) {
381
+        $image_url_esc = wl_sparql_escape_uri( $image_url );
382
+        $sparql .= " <$uri_e> schema:image <$image_url_esc> . \n";
383
+    }
384 384
 
385
-	return $sparql;
385
+    return $sparql;
386 386
 }
387 387
 
388 388
 /**
@@ -395,24 +395,24 @@  discard block
 block discarded – undo
395 395
  */
396 396
 function wl_get_attachment_for_source_url( $parent_post_id, $source_url ) {
397 397
 
398
-	// wl_write_log( "wl_get_attachment_for_source_url [ parent post id :: $parent_post_id ][ source url :: $source_url ]" );
398
+    // wl_write_log( "wl_get_attachment_for_source_url [ parent post id :: $parent_post_id ][ source url :: $source_url ]" );
399 399
 
400
-	$posts = get_posts( array(
401
-		'post_type'      => 'attachment',
402
-		'posts_per_page' => 1,
403
-		'post_status'    => 'any',
404
-		'post_parent'    => $parent_post_id,
405
-		'meta_key'       => 'wl_source_url',
406
-		'meta_value'     => $source_url,
407
-	) );
400
+    $posts = get_posts( array(
401
+        'post_type'      => 'attachment',
402
+        'posts_per_page' => 1,
403
+        'post_status'    => 'any',
404
+        'post_parent'    => $parent_post_id,
405
+        'meta_key'       => 'wl_source_url',
406
+        'meta_value'     => $source_url,
407
+    ) );
408 408
 
409
-	// Return the found post.
410
-	if ( 1 === count( $posts ) ) {
411
-		return $posts[0];
412
-	}
409
+    // Return the found post.
410
+    if ( 1 === count( $posts ) ) {
411
+        return $posts[0];
412
+    }
413 413
 
414
-	// Return null.
415
-	return null;
414
+    // Return null.
415
+    return null;
416 416
 }
417 417
 
418 418
 /**
@@ -423,8 +423,8 @@  discard block
 block discarded – undo
423 423
  */
424 424
 function wl_set_source_url( $post_id, $source_url ) {
425 425
 
426
-	delete_post_meta( $post_id, 'wl_source_url' );
427
-	add_post_meta( $post_id, 'wl_source_url', $source_url );
426
+    delete_post_meta( $post_id, 'wl_source_url' );
427
+    add_post_meta( $post_id, 'wl_source_url', $source_url );
428 428
 }
429 429
 
430 430
 
@@ -442,61 +442,61 @@  discard block
 block discarded – undo
442 442
  */
443 443
 function wl_flush_rewrite_rules_hard( $hard ) {
444 444
 
445
-	// If WL is not yet configured, we cannot perform any update, so we exit.
446
-	if ( '' === wl_configuration_get_key() ) {
447
-		return;
448
-	}
445
+    // If WL is not yet configured, we cannot perform any update, so we exit.
446
+    if ( '' === wl_configuration_get_key() ) {
447
+        return;
448
+    }
449 449
 
450
-	// Set the initial offset and limit each call to 100 posts to avoid memory errors.
451
-	$offset = 0;
452
-	$limit  = 100;
450
+    // Set the initial offset and limit each call to 100 posts to avoid memory errors.
451
+    $offset = 0;
452
+    $limit  = 100;
453 453
 
454
-	// Get more posts if the number of returned posts matches the limit.
455
-	while ( $limit === ( $posts = get_posts( array(
456
-			'offset'      => $offset,
457
-			'numberposts' => $limit,
458
-			'orderby'     => 'ID',
459
-			'post_type'   => 'any',
460
-			'post_status' => 'publish',
461
-		) ) ) ) {
454
+    // Get more posts if the number of returned posts matches the limit.
455
+    while ( $limit === ( $posts = get_posts( array(
456
+            'offset'      => $offset,
457
+            'numberposts' => $limit,
458
+            'orderby'     => 'ID',
459
+            'post_type'   => 'any',
460
+            'post_status' => 'publish',
461
+        ) ) ) ) {
462 462
 
463
-		// Holds the delete part of the query.
464
-		$delete_query = rl_sparql_prefixes();
463
+        // Holds the delete part of the query.
464
+        $delete_query = rl_sparql_prefixes();
465 465
 
466
-		// Holds the insert part of the query.
467
-		$insert_query = '';
466
+        // Holds the insert part of the query.
467
+        $insert_query = '';
468 468
 
469
-		// Cycle in each post to build the query.
470
-		foreach ( $posts as $post ) {
469
+        // Cycle in each post to build the query.
470
+        foreach ( $posts as $post ) {
471 471
 
472
-			// Ignore revisions.
473
-			if ( wp_is_post_revision( $post->ID ) ) {
474
-				continue;
475
-			}
472
+            // Ignore revisions.
473
+            if ( wp_is_post_revision( $post->ID ) ) {
474
+                continue;
475
+            }
476 476
 
477
-			// Get the entity URI.
478
-			$s = Wordlift_Sparql_Service::escape_uri( Wordlift_Entity_Service::get_instance()
479
-			                                                                 ->get_uri( $post->ID ) );
477
+            // Get the entity URI.
478
+            $s = Wordlift_Sparql_Service::escape_uri( Wordlift_Entity_Service::get_instance()
479
+                                                                                ->get_uri( $post->ID ) );
480 480
 
481
-			// Get the post URL.
482
-			// $url = wl_sparql_escape_uri( get_permalink( $post->ID ) );
481
+            // Get the post URL.
482
+            // $url = wl_sparql_escape_uri( get_permalink( $post->ID ) );
483 483
 
484
-			// Prepare the DELETE and INSERT commands.
485
-			$delete_query .= "DELETE { <$s> schema:url ?u . } WHERE  { <$s> schema:url ?u . };\n";
484
+            // Prepare the DELETE and INSERT commands.
485
+            $delete_query .= "DELETE { <$s> schema:url ?u . } WHERE  { <$s> schema:url ?u . };\n";
486 486
 
487
-			$insert_query .= Wordlift_Schema_Url_Property_Service::get_instance()
488
-			                                                     ->get_insert_query( $s, $post->ID );
487
+            $insert_query .= Wordlift_Schema_Url_Property_Service::get_instance()
488
+                                                                    ->get_insert_query( $s, $post->ID );
489 489
 
490
-		}
490
+        }
491 491
 
492 492
 
493
-		// Execute the query.
494
-		rl_execute_sparql_update_query( $delete_query . $insert_query );
493
+        // Execute the query.
494
+        rl_execute_sparql_update_query( $delete_query . $insert_query );
495 495
 
496
-		// Advance to the next posts.
497
-		$offset += $limit;
496
+        // Advance to the next posts.
497
+        $offset += $limit;
498 498
 
499
-	}
499
+    }
500 500
 
501 501
 //	// Get all published posts.
502 502
 //	$posts = get_posts( array(
@@ -522,7 +522,7 @@  discard block
 block discarded – undo
522 522
  */
523 523
 function wl_sanitize_uri_path( $path, $char = '_' ) {
524 524
 
525
-	return Wordlift_Uri_Service::get_instance()->sanitize_path( $path, $char );
525
+    return Wordlift_Uri_Service::get_instance()->sanitize_path( $path, $char );
526 526
 }
527 527
 
528 528
 /**
@@ -534,11 +534,11 @@  discard block
 block discarded – undo
534 534
  */
535 535
 function wl_force_to_array( $value ) {
536 536
 
537
-	if ( ! is_array( $value ) ) {
538
-		return array( $value );
539
-	}
537
+    if ( ! is_array( $value ) ) {
538
+        return array( $value );
539
+    }
540 540
 
541
-	return $value;
541
+    return $value;
542 542
 }
543 543
 
544 544
 /**
@@ -546,26 +546,26 @@  discard block
 block discarded – undo
546 546
  */
547 547
 function wl_shutdown() {
548 548
 
549
-	// Get the filename to the temporary SPARQL file.
550
-	$filename = WL_TEMP_DIR . WL_REQUEST_ID . '.sparql';
549
+    // Get the filename to the temporary SPARQL file.
550
+    $filename = WL_TEMP_DIR . WL_REQUEST_ID . '.sparql';
551 551
 
552
-	// If WordLift is buffering SPARQL queries, we're admins and a buffer exists, then schedule it.
553
-	if ( WL_ENABLE_SPARQL_UPDATE_QUERIES_BUFFERING && is_admin() && file_exists( $filename ) ) {
552
+    // If WordLift is buffering SPARQL queries, we're admins and a buffer exists, then schedule it.
553
+    if ( WL_ENABLE_SPARQL_UPDATE_QUERIES_BUFFERING && is_admin() && file_exists( $filename ) ) {
554 554
 
555
-		// The request ID.
556
-		$args = array( WL_REQUEST_ID );
555
+        // The request ID.
556
+        $args = array( WL_REQUEST_ID );
557 557
 
558
-		// Schedule the execution of the SPARQL query with the request ID.
559
-		wp_schedule_single_event( time(), 'wl_execute_saved_sparql_update_query', $args );
558
+        // Schedule the execution of the SPARQL query with the request ID.
559
+        wp_schedule_single_event( time(), 'wl_execute_saved_sparql_update_query', $args );
560 560
 
561
-		// Check that the request is scheduled.
562
-		$timestamp = wp_next_scheduled( 'wl_execute_saved_sparql_update_query', $args );
561
+        // Check that the request is scheduled.
562
+        $timestamp = wp_next_scheduled( 'wl_execute_saved_sparql_update_query', $args );
563 563
 
564
-		// Spawn the cron.
565
-		spawn_cron();
564
+        // Spawn the cron.
565
+        spawn_cron();
566 566
 
567
-		wl_write_log( "wl_shutdown [ request id :: " . WL_REQUEST_ID . " ][ timestamp :: $timestamp ]" );
568
-	}
567
+        wl_write_log( "wl_shutdown [ request id :: " . WL_REQUEST_ID . " ][ timestamp :: $timestamp ]" );
568
+    }
569 569
 }
570 570
 
571 571
 add_action( 'shutdown', 'wl_shutdown' );
@@ -579,46 +579,46 @@  discard block
 block discarded – undo
579 579
  */
580 580
 function wl_replace_item_id_with_uri( $content ) {
581 581
 
582
-	// wl_write_log( "wl_replace_item_id_with_uri" );
582
+    // wl_write_log( "wl_replace_item_id_with_uri" );
583 583
 
584
-	// Strip slashes, see https://core.trac.wordpress.org/ticket/21767
585
-	$content = stripslashes( $content );
584
+    // Strip slashes, see https://core.trac.wordpress.org/ticket/21767
585
+    $content = stripslashes( $content );
586 586
 
587
-	// If any match are found.
588
-	$matches = array();
589
-	if ( 0 < preg_match_all( '/ itemid="([^"]+)"/i', $content, $matches, PREG_SET_ORDER ) ) {
587
+    // If any match are found.
588
+    $matches = array();
589
+    if ( 0 < preg_match_all( '/ itemid="([^"]+)"/i', $content, $matches, PREG_SET_ORDER ) ) {
590 590
 
591
-		foreach ( $matches as $match ) {
591
+        foreach ( $matches as $match ) {
592 592
 
593
-			// Get the item ID.
594
-			$item_id = $match[1];
593
+            // Get the item ID.
594
+            $item_id = $match[1];
595 595
 
596
-			// Get the post bound to that item ID (looking both in the 'official' URI and in the 'same-as' .
597
-			$post = Wordlift_Entity_Service::get_instance()
598
-			                               ->get_entity_post_by_uri( $item_id );
596
+            // Get the post bound to that item ID (looking both in the 'official' URI and in the 'same-as' .
597
+            $post = Wordlift_Entity_Service::get_instance()
598
+                                            ->get_entity_post_by_uri( $item_id );
599 599
 
600
-			// If no entity is found, continue to the next one.
601
-			if ( null === $post ) {
602
-				continue;
603
-			}
600
+            // If no entity is found, continue to the next one.
601
+            if ( null === $post ) {
602
+                continue;
603
+            }
604 604
 
605
-			// Get the URI for that post.
606
-			$uri = wl_get_entity_uri( $post->ID );
605
+            // Get the URI for that post.
606
+            $uri = wl_get_entity_uri( $post->ID );
607 607
 
608
-			// wl_write_log( "wl_replace_item_id_with_uri [ item id :: $item_id ][ uri :: $uri ]" );
608
+            // wl_write_log( "wl_replace_item_id_with_uri [ item id :: $item_id ][ uri :: $uri ]" );
609 609
 
610
-			// If the item ID and the URI differ, replace the item ID with the URI saved in WordPress.
611
-			if ( $item_id !== $uri ) {
612
-				$uri_e   = esc_html( $uri );
613
-				$content = str_replace( " itemid=\"$item_id\"", " itemid=\"$uri_e\"", $content );
614
-			}
615
-		}
616
-	}
610
+            // If the item ID and the URI differ, replace the item ID with the URI saved in WordPress.
611
+            if ( $item_id !== $uri ) {
612
+                $uri_e   = esc_html( $uri );
613
+                $content = str_replace( " itemid=\"$item_id\"", " itemid=\"$uri_e\"", $content );
614
+            }
615
+        }
616
+    }
617 617
 
618
-	// Reapply slashes.
619
-	$content = addslashes( $content );
618
+    // Reapply slashes.
619
+    $content = addslashes( $content );
620 620
 
621
-	return $content;
621
+    return $content;
622 622
 }
623 623
 
624 624
 add_filter( 'content_save_pre', 'wl_replace_item_id_with_uri', 1, 1 );
@@ -691,8 +691,8 @@  discard block
 block discarded – undo
691 691
  * This action is documented in includes/class-wordlift-activator.php
692 692
  */
693 693
 function activate_wordlift() {
694
-	require_once plugin_dir_path( __FILE__ ) . 'includes/class-wordlift-activator.php';
695
-	Wordlift_Activator::activate();
694
+    require_once plugin_dir_path( __FILE__ ) . 'includes/class-wordlift-activator.php';
695
+    Wordlift_Activator::activate();
696 696
 }
697 697
 
698 698
 /**
@@ -700,8 +700,8 @@  discard block
 block discarded – undo
700 700
  * This action is documented in includes/class-wordlift-deactivator.php
701 701
  */
702 702
 function deactivate_wordlift() {
703
-	require_once plugin_dir_path( __FILE__ ) . 'includes/class-wordlift-deactivator.php';
704
-	Wordlift_Deactivator::deactivate();
703
+    require_once plugin_dir_path( __FILE__ ) . 'includes/class-wordlift-deactivator.php';
704
+    Wordlift_Deactivator::deactivate();
705 705
 }
706 706
 
707 707
 register_activation_hook( __FILE__, 'activate_wordlift' );
@@ -724,8 +724,8 @@  discard block
 block discarded – undo
724 724
  */
725 725
 function run_wordlift() {
726 726
 
727
-	$plugin = new Wordlift();
728
-	$plugin->run();
727
+    $plugin = new Wordlift();
728
+    $plugin->run();
729 729
 
730 730
 }
731 731
 
Please login to merge, or discard this patch.
Spacing   +157 added lines, -157 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
 //	$handler = apply_filters( 'wl_write_log_handler', null );
54 54
 //
@@ -74,19 +74,19 @@  discard block
 block discarded – undo
74 74
  * @param string|array $log    The log data.
75 75
  * @param string       $caller The calling function.
76 76
  */
77
-function wl_write_log_handler( $log, $caller = null ) {
77
+function wl_write_log_handler($log, $caller = null) {
78 78
 
79 79
 	global $wl_logger;
80 80
 
81
-	if ( true === WP_DEBUG ) {
81
+	if (true === WP_DEBUG) {
82 82
 
83
-		$message = ( isset( $caller ) ? sprintf( '[%-40.40s] ', $caller ) : '' ) .
84
-		           ( is_array( $log ) || is_object( $log ) ? print_r( $log, true ) : wl_write_log_hide_key( $log ) );
83
+		$message = (isset($caller) ? sprintf('[%-40.40s] ', $caller) : '').
84
+		           (is_array($log) || is_object($log) ? print_r($log, true) : wl_write_log_hide_key($log));
85 85
 
86
-		if ( isset( $wl_logger ) ) {
87
-			$wl_logger->info( $message );
86
+		if (isset($wl_logger)) {
87
+			$wl_logger->info($message);
88 88
 		} else {
89
-			error_log( $message );
89
+			error_log($message);
90 90
 		}
91 91
 
92 92
 	}
@@ -104,9 +104,9 @@  discard block
 block discarded – undo
104 104
  *
105 105
  * @return string A text with the key hidden.
106 106
  */
107
-function wl_write_log_hide_key( $text ) {
107
+function wl_write_log_hide_key($text) {
108 108
 
109
-	return str_ireplace( wl_configuration_get_key(), '<hidden>', $text );
109
+	return str_ireplace(wl_configuration_get_key(), '<hidden>', $text);
110 110
 }
111 111
 
112 112
 /**
@@ -116,12 +116,12 @@  discard block
 block discarded – undo
116 116
  *
117 117
  * @param string $query A SPARQL query.
118 118
  */
119
-function wl_queue_sparql_update_query( $query ) {
119
+function wl_queue_sparql_update_query($query) {
120 120
 
121
-	$filename = WL_TEMP_DIR . WL_REQUEST_ID . '.sparql';
122
-	file_put_contents( $filename, $query . "\n", FILE_APPEND );
121
+	$filename = WL_TEMP_DIR.WL_REQUEST_ID.'.sparql';
122
+	file_put_contents($filename, $query."\n", FILE_APPEND);
123 123
 
124
-	wl_write_log( "wl_queue_sparql_update_query [ filename :: $filename ]" );
124
+	wl_write_log("wl_queue_sparql_update_query [ filename :: $filename ]");
125 125
 }
126 126
 
127 127
 /**
@@ -129,33 +129,33 @@  discard block
 block discarded – undo
129 129
  *
130 130
  * @param int $request_id The request ID.
131 131
  */
132
-function wl_execute_saved_sparql_update_query( $request_id ) {
132
+function wl_execute_saved_sparql_update_query($request_id) {
133 133
 
134
-	$filename = WL_TEMP_DIR . $request_id . '.sparql';
134
+	$filename = WL_TEMP_DIR.$request_id.'.sparql';
135 135
 
136 136
 	// If the file doesn't exist, exit.
137
-	if ( ! file_exists( $filename ) ) {
138
-		wl_write_log( "wl_execute_saved_sparql_update_query : file doesn't exist [ filename :: $filename ]" );
137
+	if ( ! file_exists($filename)) {
138
+		wl_write_log("wl_execute_saved_sparql_update_query : file doesn't exist [ filename :: $filename ]");
139 139
 
140 140
 		return;
141 141
 	}
142 142
 
143
-	wl_write_log( "wl_execute_saved_sparql_update_query [ filename :: $filename ]" );
143
+	wl_write_log("wl_execute_saved_sparql_update_query [ filename :: $filename ]");
144 144
 
145 145
 	// Get the query saved in the file.
146
-	$query = file_get_contents( $filename );
146
+	$query = file_get_contents($filename);
147 147
 
148 148
 	// Execute the SPARQL query.
149
-	rl_execute_sparql_update_query( $query, false );
149
+	rl_execute_sparql_update_query($query, false);
150 150
 
151 151
 	// Reindex the triple store.
152 152
 	wordlift_reindex_triple_store();
153 153
 
154 154
 	// Delete the temporary file.
155
-	unlink( $filename );
155
+	unlink($filename);
156 156
 }
157 157
 
158
-add_action( 'wl_execute_saved_sparql_update_query', 'wl_execute_saved_sparql_update_query', 10, 1 );
158
+add_action('wl_execute_saved_sparql_update_query', 'wl_execute_saved_sparql_update_query', 10, 1);
159 159
 
160 160
 /**
161 161
  * Add buttons hook for the TinyMCE editor. This method is called by the WP init hook.
@@ -163,8 +163,8 @@  discard block
 block discarded – undo
163 163
 function wordlift_buttonhooks() {
164 164
 
165 165
 	// Only add hooks when the current user has permissions AND is in Rich Text editor mode
166
-	if ( ( current_user_can( 'edit_posts' ) || current_user_can( 'edit_pages' ) ) && get_user_option( 'rich_editing' ) ) {
167
-		add_filter( 'mce_external_plugins', 'wordlift_register_tinymce_javascript' );
166
+	if ((current_user_can('edit_posts') || current_user_can('edit_pages')) && get_user_option('rich_editing')) {
167
+		add_filter('mce_external_plugins', 'wordlift_register_tinymce_javascript');
168 168
 	}
169 169
 }
170 170
 
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
  *
176 176
  * @return array The modified plugins array.
177 177
  */
178
-function wordlift_register_tinymce_javascript( $plugin_array ) {
178
+function wordlift_register_tinymce_javascript($plugin_array) {
179 179
 
180 180
 	// add the wordlift plugin.
181 181
 	// We can't use the minified version here.
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
 	$version = Wordlift::get_instance()->get_version();
185 185
 
186 186
 	// Add our own JavaScript file to TinyMCE's extensions.
187
-	$plugin_array['wordlift'] = plugin_dir_url( __FILE__ ) . 'js/wordlift-reloaded.js?ver=' . $version;
187
+	$plugin_array['wordlift'] = plugin_dir_url(__FILE__).'js/wordlift-reloaded.js?ver='.$version;
188 188
 
189 189
 	return $plugin_array;
190 190
 }
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
 function wordlift_allowed_post_tags() {
197 197
 	global $allowedposttags;
198 198
 
199
-	$tags           = array( 'span' );
199
+	$tags           = array('span');
200 200
 	$new_attributes = array(
201 201
 		'itemscope' => array(),
202 202
 		'itemtype'  => array(),
@@ -204,17 +204,17 @@  discard block
 block discarded – undo
204 204
 		'itemid'    => array(),
205 205
 	);
206 206
 
207
-	foreach ( $tags as $tag ) {
208
-		if ( isset( $allowedposttags[ $tag ] ) && is_array( $allowedposttags[ $tag ] ) ) {
209
-			$allowedposttags[ $tag ] = array_merge( $allowedposttags[ $tag ], $new_attributes );
207
+	foreach ($tags as $tag) {
208
+		if (isset($allowedposttags[$tag]) && is_array($allowedposttags[$tag])) {
209
+			$allowedposttags[$tag] = array_merge($allowedposttags[$tag], $new_attributes);
210 210
 		}
211 211
 	}
212 212
 }
213 213
 
214 214
 // init process for button control
215
-add_action( 'init', 'wordlift_buttonhooks' );
215
+add_action('init', 'wordlift_buttonhooks');
216 216
 // add allowed post tags.
217
-add_action( 'init', 'wordlift_allowed_post_tags' );
217
+add_action('init', 'wordlift_allowed_post_tags');
218 218
 
219 219
 
220 220
 /**
@@ -223,30 +223,30 @@  discard block
 block discarded – undo
223 223
 function wordlift_admin_enqueue_scripts() {
224 224
 
225 225
 	// Added for compatibility with WordPress 3.9 (see http://make.wordpress.org/core/2014/04/16/jquery-ui-and-wpdialogs-in-wordpress-3-9/)
226
-	wp_enqueue_script( 'wpdialogs' );
227
-	wp_enqueue_style( 'wp-jquery-ui-dialog' );
226
+	wp_enqueue_script('wpdialogs');
227
+	wp_enqueue_style('wp-jquery-ui-dialog');
228 228
 
229
-	wp_enqueue_style( 'wordlift-reloaded', plugin_dir_url( __FILE__ ) . 'css/wordlift-reloaded.min.css' );
229
+	wp_enqueue_style('wordlift-reloaded', plugin_dir_url(__FILE__).'css/wordlift-reloaded.min.css');
230 230
 
231
-	wp_enqueue_script( 'jquery-ui-autocomplete' );
232
-	wp_enqueue_script( 'angularjs', 'https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.11/angular.min.js' );
233
-	wp_enqueue_script( 'angularjs-geolocation', plugin_dir_url( __FILE__ ) . '/bower_components/angularjs-geolocation/dist/angularjs-geolocation.min.js' );
234
-	wp_enqueue_script( 'angularjs-touch', 'https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.11/angular-touch.min.js' );
235
-	wp_enqueue_script( 'angularjs-animate', 'https://code.angularjs.org/1.3.11/angular-animate.min.js' );
231
+	wp_enqueue_script('jquery-ui-autocomplete');
232
+	wp_enqueue_script('angularjs', 'https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.11/angular.min.js');
233
+	wp_enqueue_script('angularjs-geolocation', plugin_dir_url(__FILE__).'/bower_components/angularjs-geolocation/dist/angularjs-geolocation.min.js');
234
+	wp_enqueue_script('angularjs-touch', 'https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.11/angular-touch.min.js');
235
+	wp_enqueue_script('angularjs-animate', 'https://code.angularjs.org/1.3.11/angular-animate.min.js');
236 236
 
237 237
 	// Disable auto-save for custom entity posts only
238
-	if ( Wordlift_Entity_Service::TYPE_NAME === get_post_type() ) {
239
-		wp_dequeue_script( 'autosave' );
238
+	if (Wordlift_Entity_Service::TYPE_NAME === get_post_type()) {
239
+		wp_dequeue_script('autosave');
240 240
 	}
241 241
 }
242 242
 
243
-add_action( 'admin_enqueue_scripts', 'wordlift_admin_enqueue_scripts' );
243
+add_action('admin_enqueue_scripts', 'wordlift_admin_enqueue_scripts');
244 244
 
245 245
 function wl_enqueue_scripts() {
246
-	wp_enqueue_style( 'wordlift-ui', plugin_dir_url( __FILE__ ) . 'css/wordlift-ui.min.css' );
246
+	wp_enqueue_style('wordlift-ui', plugin_dir_url(__FILE__).'css/wordlift-ui.min.css');
247 247
 }
248 248
 
249
-add_action( 'wp_enqueue_scripts', 'wl_enqueue_scripts' );
249
+add_action('wp_enqueue_scripts', 'wl_enqueue_scripts');
250 250
 
251 251
 /**
252 252
  * Hooked to *wp_kses_allowed_html* filter, adds microdata attributes.
@@ -256,23 +256,23 @@  discard block
 block discarded – undo
256 256
  *
257 257
  * @return array An array which contains allowed microdata attributes.
258 258
  */
259
-function wordlift_allowed_html( $allowedtags, $context ) {
259
+function wordlift_allowed_html($allowedtags, $context) {
260 260
 
261
-	if ( 'post' !== $context ) {
261
+	if ('post' !== $context) {
262 262
 		return $allowedtags;
263 263
 	}
264 264
 
265
-	return array_merge_recursive( $allowedtags, array(
265
+	return array_merge_recursive($allowedtags, array(
266 266
 		'span' => array(
267 267
 			'itemscope' => true,
268 268
 			'itemtype'  => true,
269 269
 			'itemid'    => true,
270 270
 			'itemprop'  => true,
271 271
 		),
272
-	) );
272
+	));
273 273
 }
274 274
 
275
-add_filter( 'wp_kses_allowed_html', 'wordlift_allowed_html', 10, 2 );
275
+add_filter('wp_kses_allowed_html', 'wordlift_allowed_html', 10, 2);
276 276
 
277 277
 /**
278 278
  * Get the coordinates for the specified post ID.
@@ -281,16 +281,16 @@  discard block
 block discarded – undo
281 281
  *
282 282
  * @return array|null An array of coordinates or null.
283 283
  */
284
-function wl_get_coordinates( $post_id ) {
284
+function wl_get_coordinates($post_id) {
285 285
 
286
-	$latitude  = wl_schema_get_value( $post_id, 'latitude' );
287
-	$longitude = wl_schema_get_value( $post_id, 'longitude' );
286
+	$latitude  = wl_schema_get_value($post_id, 'latitude');
287
+	$longitude = wl_schema_get_value($post_id, 'longitude');
288 288
 
289 289
 	// DO NOT set latitude/longitude to 0/0 as default values. It's a specific place on the globe:
290 290
 	// "The zero/zero point of this system is located in the Gulf of Guinea about 625 km (390 mi) south of Tema, Ghana."
291 291
 	return array(
292
-		'latitude'  => isset( $latitude[0] ) && is_numeric( $latitude[0] ) ? $latitude[0] : '',
293
-		'longitude' => isset( $longitude[0] ) && is_numeric( $longitude[0] ) ? $longitude[0] : '',
292
+		'latitude'  => isset($latitude[0]) && is_numeric($latitude[0]) ? $latitude[0] : '',
293
+		'longitude' => isset($longitude[0]) && is_numeric($longitude[0]) ? $longitude[0] : '',
294 294
 	);
295 295
 }
296 296
 
@@ -301,12 +301,12 @@  discard block
 block discarded – undo
301 301
  *
302 302
  * @return string A datetime.
303 303
  */
304
-function wl_get_post_modified_time( $post ) {
304
+function wl_get_post_modified_time($post) {
305 305
 
306
-	$date_modified = get_post_modified_time( 'c', true, $post );
306
+	$date_modified = get_post_modified_time('c', true, $post);
307 307
 
308
-	if ( '-' === substr( $date_modified, 0, 1 ) ) {
309
-		return get_the_time( 'c', $post );
308
+	if ('-' === substr($date_modified, 0, 1)) {
309
+		return get_the_time('c', $post);
310 310
 	}
311 311
 
312 312
 	return $date_modified;
@@ -319,27 +319,27 @@  discard block
 block discarded – undo
319 319
  *
320 320
  * @return array An array of image URLs.
321 321
  */
322
-function wl_get_image_urls( $post_id ) {
322
+function wl_get_image_urls($post_id) {
323 323
 
324 324
 
325 325
 	// If there is a featured image it has the priority
326
-	$featured_image_id = get_post_thumbnail_id( $post_id );
327
-	if ( is_numeric( $featured_image_id ) ) {
328
-		$image_url = wp_get_attachment_url( $featured_image_id );
326
+	$featured_image_id = get_post_thumbnail_id($post_id);
327
+	if (is_numeric($featured_image_id)) {
328
+		$image_url = wp_get_attachment_url($featured_image_id);
329 329
 
330
-		return array( $image_url );
330
+		return array($image_url);
331 331
 	}
332 332
 
333 333
 	// wl_write_log( "wl_get_image_urls [ post id :: $post_id ]" );
334 334
 
335
-	$images = get_children( array(
335
+	$images = get_children(array(
336 336
 		'post_parent'    => $post_id,
337 337
 		'post_type'      => 'attachment',
338 338
 		'post_mime_type' => 'image',
339
-	) );
339
+	));
340 340
 
341 341
 	// Return an empty array if no image is found.
342
-	if ( empty( $images ) ) {
342
+	if (empty($images)) {
343 343
 		return array();
344 344
 	}
345 345
 
@@ -347,11 +347,11 @@  discard block
 block discarded – undo
347 347
 	$image_urls = array();
348 348
 
349 349
 	// Collect the URLs.
350
-	foreach ( $images as $attachment_id => $attachment ) {
351
-		$image_url = wp_get_attachment_url( $attachment_id );
350
+	foreach ($images as $attachment_id => $attachment) {
351
+		$image_url = wp_get_attachment_url($attachment_id);
352 352
 		// Ensure the URL isn't collected already.
353
-		if ( ! in_array( $image_url, $image_urls ) ) {
354
-			array_push( $image_urls, $image_url );
353
+		if ( ! in_array($image_url, $image_urls)) {
354
+			array_push($image_urls, $image_url);
355 355
 		}
356 356
 	}
357 357
 
@@ -368,17 +368,17 @@  discard block
 block discarded – undo
368 368
  *
369 369
  * @return string The SPARQL fragment.
370 370
  */
371
-function wl_get_sparql_images( $uri, $post_id ) {
371
+function wl_get_sparql_images($uri, $post_id) {
372 372
 
373 373
 	$sparql = '';
374 374
 
375 375
 	// Get the escaped URI.
376
-	$uri_e = esc_html( $uri );
376
+	$uri_e = esc_html($uri);
377 377
 
378 378
 	// Add SPARQL stmts to write the schema:image.
379
-	$image_urls = wl_get_image_urls( $post_id );
380
-	foreach ( $image_urls as $image_url ) {
381
-		$image_url_esc = wl_sparql_escape_uri( $image_url );
379
+	$image_urls = wl_get_image_urls($post_id);
380
+	foreach ($image_urls as $image_url) {
381
+		$image_url_esc = wl_sparql_escape_uri($image_url);
382 382
 		$sparql .= " <$uri_e> schema:image <$image_url_esc> . \n";
383 383
 	}
384 384
 
@@ -393,21 +393,21 @@  discard block
 block discarded – undo
393 393
  *
394 394
  * @return WP_Post|null A post instance or null if not found.
395 395
  */
396
-function wl_get_attachment_for_source_url( $parent_post_id, $source_url ) {
396
+function wl_get_attachment_for_source_url($parent_post_id, $source_url) {
397 397
 
398 398
 	// wl_write_log( "wl_get_attachment_for_source_url [ parent post id :: $parent_post_id ][ source url :: $source_url ]" );
399 399
 
400
-	$posts = get_posts( array(
400
+	$posts = get_posts(array(
401 401
 		'post_type'      => 'attachment',
402 402
 		'posts_per_page' => 1,
403 403
 		'post_status'    => 'any',
404 404
 		'post_parent'    => $parent_post_id,
405 405
 		'meta_key'       => 'wl_source_url',
406 406
 		'meta_value'     => $source_url,
407
-	) );
407
+	));
408 408
 
409 409
 	// Return the found post.
410
-	if ( 1 === count( $posts ) ) {
410
+	if (1 === count($posts)) {
411 411
 		return $posts[0];
412 412
 	}
413 413
 
@@ -421,10 +421,10 @@  discard block
 block discarded – undo
421 421
  * @param int    $post_id    The post ID.
422 422
  * @param string $source_url The source URL.
423 423
  */
424
-function wl_set_source_url( $post_id, $source_url ) {
424
+function wl_set_source_url($post_id, $source_url) {
425 425
 
426
-	delete_post_meta( $post_id, 'wl_source_url' );
427
-	add_post_meta( $post_id, 'wl_source_url', $source_url );
426
+	delete_post_meta($post_id, 'wl_source_url');
427
+	add_post_meta($post_id, 'wl_source_url', $source_url);
428 428
 }
429 429
 
430 430
 
@@ -440,10 +440,10 @@  discard block
 block discarded – undo
440 440
  *
441 441
  * @param bool $hard True if the rewrite involves configuration updates in Apache/IIS.
442 442
  */
443
-function wl_flush_rewrite_rules_hard( $hard ) {
443
+function wl_flush_rewrite_rules_hard($hard) {
444 444
 
445 445
 	// If WL is not yet configured, we cannot perform any update, so we exit.
446
-	if ( '' === wl_configuration_get_key() ) {
446
+	if ('' === wl_configuration_get_key()) {
447 447
 		return;
448 448
 	}
449 449
 
@@ -452,13 +452,13 @@  discard block
 block discarded – undo
452 452
 	$limit  = 100;
453 453
 
454 454
 	// Get more posts if the number of returned posts matches the limit.
455
-	while ( $limit === ( $posts = get_posts( array(
455
+	while ($limit === ($posts = get_posts(array(
456 456
 			'offset'      => $offset,
457 457
 			'numberposts' => $limit,
458 458
 			'orderby'     => 'ID',
459 459
 			'post_type'   => 'any',
460 460
 			'post_status' => 'publish',
461
-		) ) ) ) {
461
+		)))) {
462 462
 
463 463
 		// Holds the delete part of the query.
464 464
 		$delete_query = rl_sparql_prefixes();
@@ -467,16 +467,16 @@  discard block
 block discarded – undo
467 467
 		$insert_query = '';
468 468
 
469 469
 		// Cycle in each post to build the query.
470
-		foreach ( $posts as $post ) {
470
+		foreach ($posts as $post) {
471 471
 
472 472
 			// Ignore revisions.
473
-			if ( wp_is_post_revision( $post->ID ) ) {
473
+			if (wp_is_post_revision($post->ID)) {
474 474
 				continue;
475 475
 			}
476 476
 
477 477
 			// Get the entity URI.
478
-			$s = Wordlift_Sparql_Service::escape_uri( Wordlift_Entity_Service::get_instance()
479
-			                                                                 ->get_uri( $post->ID ) );
478
+			$s = Wordlift_Sparql_Service::escape_uri(Wordlift_Entity_Service::get_instance()
479
+			                                                                 ->get_uri($post->ID));
480 480
 
481 481
 			// Get the post URL.
482 482
 			// $url = wl_sparql_escape_uri( get_permalink( $post->ID ) );
@@ -485,13 +485,13 @@  discard block
 block discarded – undo
485 485
 			$delete_query .= "DELETE { <$s> schema:url ?u . } WHERE  { <$s> schema:url ?u . };\n";
486 486
 
487 487
 			$insert_query .= Wordlift_Schema_Url_Property_Service::get_instance()
488
-			                                                     ->get_insert_query( $s, $post->ID );
488
+			                                                     ->get_insert_query($s, $post->ID);
489 489
 
490 490
 		}
491 491
 
492 492
 
493 493
 		// Execute the query.
494
-		rl_execute_sparql_update_query( $delete_query . $insert_query );
494
+		rl_execute_sparql_update_query($delete_query.$insert_query);
495 495
 
496 496
 		// Advance to the next posts.
497 497
 		$offset += $limit;
@@ -507,7 +507,7 @@  discard block
 block discarded – undo
507 507
 
508 508
 }
509 509
 
510
-add_filter( 'flush_rewrite_rules_hard', 'wl_flush_rewrite_rules_hard', 10, 1 );
510
+add_filter('flush_rewrite_rules_hard', 'wl_flush_rewrite_rules_hard', 10, 1);
511 511
 
512 512
 /**
513 513
  * Sanitizes an URI path by replacing the non allowed characters with an underscore.
@@ -520,9 +520,9 @@  discard block
 block discarded – undo
520 520
  *
521 521
  * @return string The sanitized path.
522 522
  */
523
-function wl_sanitize_uri_path( $path, $char = '_' ) {
523
+function wl_sanitize_uri_path($path, $char = '_') {
524 524
 
525
-	return Wordlift_Uri_Service::get_instance()->sanitize_path( $path, $char );
525
+	return Wordlift_Uri_Service::get_instance()->sanitize_path($path, $char);
526 526
 }
527 527
 
528 528
 /**
@@ -532,10 +532,10 @@  discard block
 block discarded – undo
532 532
  *
533 533
  * @return array Array containing $value (if $value was not an array)
534 534
  */
535
-function wl_force_to_array( $value ) {
535
+function wl_force_to_array($value) {
536 536
 
537
-	if ( ! is_array( $value ) ) {
538
-		return array( $value );
537
+	if ( ! is_array($value)) {
538
+		return array($value);
539 539
 	}
540 540
 
541 541
 	return $value;
@@ -547,28 +547,28 @@  discard block
 block discarded – undo
547 547
 function wl_shutdown() {
548 548
 
549 549
 	// Get the filename to the temporary SPARQL file.
550
-	$filename = WL_TEMP_DIR . WL_REQUEST_ID . '.sparql';
550
+	$filename = WL_TEMP_DIR.WL_REQUEST_ID.'.sparql';
551 551
 
552 552
 	// If WordLift is buffering SPARQL queries, we're admins and a buffer exists, then schedule it.
553
-	if ( WL_ENABLE_SPARQL_UPDATE_QUERIES_BUFFERING && is_admin() && file_exists( $filename ) ) {
553
+	if (WL_ENABLE_SPARQL_UPDATE_QUERIES_BUFFERING && is_admin() && file_exists($filename)) {
554 554
 
555 555
 		// The request ID.
556
-		$args = array( WL_REQUEST_ID );
556
+		$args = array(WL_REQUEST_ID);
557 557
 
558 558
 		// Schedule the execution of the SPARQL query with the request ID.
559
-		wp_schedule_single_event( time(), 'wl_execute_saved_sparql_update_query', $args );
559
+		wp_schedule_single_event(time(), 'wl_execute_saved_sparql_update_query', $args);
560 560
 
561 561
 		// Check that the request is scheduled.
562
-		$timestamp = wp_next_scheduled( 'wl_execute_saved_sparql_update_query', $args );
562
+		$timestamp = wp_next_scheduled('wl_execute_saved_sparql_update_query', $args);
563 563
 
564 564
 		// Spawn the cron.
565 565
 		spawn_cron();
566 566
 
567
-		wl_write_log( "wl_shutdown [ request id :: " . WL_REQUEST_ID . " ][ timestamp :: $timestamp ]" );
567
+		wl_write_log("wl_shutdown [ request id :: ".WL_REQUEST_ID." ][ timestamp :: $timestamp ]");
568 568
 	}
569 569
 }
570 570
 
571
-add_action( 'shutdown', 'wl_shutdown' );
571
+add_action('shutdown', 'wl_shutdown');
572 572
 
573 573
 /**
574 574
  * Replaces the *itemid* attributes URIs with the WordLift URIs.
@@ -577,113 +577,113 @@  discard block
 block discarded – undo
577 577
  *
578 578
  * @return string The updated post content.
579 579
  */
580
-function wl_replace_item_id_with_uri( $content ) {
580
+function wl_replace_item_id_with_uri($content) {
581 581
 
582 582
 	// wl_write_log( "wl_replace_item_id_with_uri" );
583 583
 
584 584
 	// Strip slashes, see https://core.trac.wordpress.org/ticket/21767
585
-	$content = stripslashes( $content );
585
+	$content = stripslashes($content);
586 586
 
587 587
 	// If any match are found.
588 588
 	$matches = array();
589
-	if ( 0 < preg_match_all( '/ itemid="([^"]+)"/i', $content, $matches, PREG_SET_ORDER ) ) {
589
+	if (0 < preg_match_all('/ itemid="([^"]+)"/i', $content, $matches, PREG_SET_ORDER)) {
590 590
 
591
-		foreach ( $matches as $match ) {
591
+		foreach ($matches as $match) {
592 592
 
593 593
 			// Get the item ID.
594 594
 			$item_id = $match[1];
595 595
 
596 596
 			// Get the post bound to that item ID (looking both in the 'official' URI and in the 'same-as' .
597 597
 			$post = Wordlift_Entity_Service::get_instance()
598
-			                               ->get_entity_post_by_uri( $item_id );
598
+			                               ->get_entity_post_by_uri($item_id);
599 599
 
600 600
 			// If no entity is found, continue to the next one.
601
-			if ( null === $post ) {
601
+			if (null === $post) {
602 602
 				continue;
603 603
 			}
604 604
 
605 605
 			// Get the URI for that post.
606
-			$uri = wl_get_entity_uri( $post->ID );
606
+			$uri = wl_get_entity_uri($post->ID);
607 607
 
608 608
 			// wl_write_log( "wl_replace_item_id_with_uri [ item id :: $item_id ][ uri :: $uri ]" );
609 609
 
610 610
 			// If the item ID and the URI differ, replace the item ID with the URI saved in WordPress.
611
-			if ( $item_id !== $uri ) {
612
-				$uri_e   = esc_html( $uri );
613
-				$content = str_replace( " itemid=\"$item_id\"", " itemid=\"$uri_e\"", $content );
611
+			if ($item_id !== $uri) {
612
+				$uri_e   = esc_html($uri);
613
+				$content = str_replace(" itemid=\"$item_id\"", " itemid=\"$uri_e\"", $content);
614 614
 			}
615 615
 		}
616 616
 	}
617 617
 
618 618
 	// Reapply slashes.
619
-	$content = addslashes( $content );
619
+	$content = addslashes($content);
620 620
 
621 621
 	return $content;
622 622
 }
623 623
 
624
-add_filter( 'content_save_pre', 'wl_replace_item_id_with_uri', 1, 1 );
624
+add_filter('content_save_pre', 'wl_replace_item_id_with_uri', 1, 1);
625 625
 
626
-require_once( 'wordlift_entity_functions.php' );
626
+require_once('wordlift_entity_functions.php');
627 627
 
628 628
 // add editor related methods.
629
-require_once( 'wordlift_editor.php' );
629
+require_once('wordlift_editor.php');
630 630
 
631 631
 // add the WordLift entity custom type.
632
-require_once( 'wordlift_entity_type.php' );
633
-require_once( 'wordlift_entity_type_taxonomy.php' );
632
+require_once('wordlift_entity_type.php');
633
+require_once('wordlift_entity_type_taxonomy.php');
634 634
 
635 635
 // add callbacks on post save to notify data changes from wp to redlink triple store
636
-require_once( 'wordlift_to_redlink_data_push_callbacks.php' );
636
+require_once('wordlift_to_redlink_data_push_callbacks.php');
637 637
 
638
-require_once( 'modules/configuration/wordlift_configuration_settings.php' );
638
+require_once('modules/configuration/wordlift_configuration_settings.php');
639 639
 
640 640
 // Load modules
641
-require_once( 'modules/analyzer/wordlift_analyzer.php' );
642
-require_once( 'modules/linked_data/wordlift_linked_data.php' );
643
-require_once( 'modules/prefixes/wordlift_prefixes.php' );
644
-require_once( 'modules/redirector/wordlift_redirector.php' );
641
+require_once('modules/analyzer/wordlift_analyzer.php');
642
+require_once('modules/linked_data/wordlift_linked_data.php');
643
+require_once('modules/prefixes/wordlift_prefixes.php');
644
+require_once('modules/redirector/wordlift_redirector.php');
645 645
 
646 646
 // Shortcodes
647 647
 
648
-require_once( 'modules/geo_widget/wordlift_geo_widget.php' );
649
-require_once( 'shortcodes/wordlift_shortcode_chord.php' );
650
-require_once( 'shortcodes/wordlift_shortcode_geomap.php' );
651
-require_once( 'shortcodes/wordlift_shortcode_field.php' );
652
-require_once( 'shortcodes/wordlift_shortcode_faceted_search.php' );
653
-require_once( 'shortcodes/wordlift_shortcode_navigator.php' );
648
+require_once('modules/geo_widget/wordlift_geo_widget.php');
649
+require_once('shortcodes/wordlift_shortcode_chord.php');
650
+require_once('shortcodes/wordlift_shortcode_geomap.php');
651
+require_once('shortcodes/wordlift_shortcode_field.php');
652
+require_once('shortcodes/wordlift_shortcode_faceted_search.php');
653
+require_once('shortcodes/wordlift_shortcode_navigator.php');
654 654
 
655
-require_once( 'widgets/wordlift_widget_geo.php' );
656
-require_once( 'widgets/wordlift_widget_chord.php' );
657
-require_once( 'widgets/wordlift_widget_timeline.php' );
655
+require_once('widgets/wordlift_widget_geo.php');
656
+require_once('widgets/wordlift_widget_chord.php');
657
+require_once('widgets/wordlift_widget_timeline.php');
658 658
 
659
-require_once( 'wordlift_sparql.php' );
660
-require_once( 'wordlift_redlink.php' );
659
+require_once('wordlift_sparql.php');
660
+require_once('wordlift_redlink.php');
661 661
 
662 662
 // Add admin functions.
663 663
 // TODO: find a way to make 'admin' UI tests work.
664 664
 //if ( is_admin() ) {
665 665
 
666
-require_once( 'admin/wordlift_admin.php' );
667
-require_once( 'admin/wordlift_admin_edit_post.php' );
668
-require_once( 'admin/wordlift_admin_save_post.php' );
666
+require_once('admin/wordlift_admin.php');
667
+require_once('admin/wordlift_admin_edit_post.php');
668
+require_once('admin/wordlift_admin_save_post.php');
669 669
 
670 670
 // add the entities meta box.
671
-require_once( 'admin/wordlift_admin_meta_box_entities.php' );
671
+require_once('admin/wordlift_admin_meta_box_entities.php');
672 672
 
673 673
 // add the entity creation AJAX.
674
-require_once( 'admin/wordlift_admin_ajax_related_posts.php' );
674
+require_once('admin/wordlift_admin_ajax_related_posts.php');
675 675
 
676 676
 // Load the wl_chord TinyMCE button and configuration dialog.
677
-require_once( 'admin/wordlift_admin_shortcodes.php' );
677
+require_once('admin/wordlift_admin_shortcodes.php');
678 678
 
679 679
 // Provide syncing features.
680
-require_once( 'admin/wordlift_admin_sync.php' );
680
+require_once('admin/wordlift_admin_sync.php');
681 681
 //}
682 682
 
683 683
 // load languages.
684 684
 // TODO: the following call gives for granted that the plugin is in the wordlift directory,
685 685
 //       we're currently doing this because wordlift is symbolic linked.
686
-load_plugin_textdomain( 'wordlift', false, '/wordlift/languages' );
686
+load_plugin_textdomain('wordlift', false, '/wordlift/languages');
687 687
 
688 688
 
689 689
 /**
@@ -691,7 +691,7 @@  discard block
 block discarded – undo
691 691
  * This action is documented in includes/class-wordlift-activator.php
692 692
  */
693 693
 function activate_wordlift() {
694
-	require_once plugin_dir_path( __FILE__ ) . 'includes/class-wordlift-activator.php';
694
+	require_once plugin_dir_path(__FILE__).'includes/class-wordlift-activator.php';
695 695
 	Wordlift_Activator::activate();
696 696
 }
697 697
 
@@ -700,18 +700,18 @@  discard block
 block discarded – undo
700 700
  * This action is documented in includes/class-wordlift-deactivator.php
701 701
  */
702 702
 function deactivate_wordlift() {
703
-	require_once plugin_dir_path( __FILE__ ) . 'includes/class-wordlift-deactivator.php';
703
+	require_once plugin_dir_path(__FILE__).'includes/class-wordlift-deactivator.php';
704 704
 	Wordlift_Deactivator::deactivate();
705 705
 }
706 706
 
707
-register_activation_hook( __FILE__, 'activate_wordlift' );
708
-register_deactivation_hook( __FILE__, 'deactivate_wordlift' );
707
+register_activation_hook(__FILE__, 'activate_wordlift');
708
+register_deactivation_hook(__FILE__, 'deactivate_wordlift');
709 709
 
710 710
 /**
711 711
  * The core plugin class that is used to define internationalization,
712 712
  * admin-specific hooks, and public-facing site hooks.
713 713
  */
714
-require plugin_dir_path( __FILE__ ) . 'includes/class-wordlift.php';
714
+require plugin_dir_path(__FILE__).'includes/class-wordlift.php';
715 715
 
716 716
 /**
717 717
  * Begins execution of the plugin.
Please login to merge, or discard this patch.
src/admin/WL_Metabox/WL_Metabox_Field_coordinates.php 2 patches
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
 
4 4
 class WL_Metabox_Field_coordinates extends WL_Metabox_Field {
5 5
 
6
-	public function __construct( $args ) {
6
+	public function __construct($args) {
7 7
 
8 8
 		// Just set up the necessary info without calling the parent constructor.
9 9
 		// TODO: write a parent class for grouped properties
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
 
16 16
 	public function get_data() {
17 17
 		$entity_id  = get_the_ID();
18
-		$this->data = wl_get_coordinates( $entity_id );
18
+		$this->data = wl_get_coordinates($entity_id);
19 19
 	}
20 20
 
21 21
 	public function html() {
@@ -33,20 +33,20 @@  discard block
 block discarded – undo
33 33
 		$data        = $this->data;
34 34
 		// TODO: We temporary use here 0,0 as default coordinates for the marker, but if no coordinates are given we
35 35
 		// want to use the current user location for the marker.
36
-		$coordinates = ( ! empty( $data['latitude'] ) && ! empty( $data['longitude'] ) ? sprintf( '[%f,%f]', $data['latitude'], $data['longitude'] ) : '[0,0]' );
36
+		$coordinates = ( ! empty($data['latitude']) && ! empty($data['longitude']) ? sprintf('[%f,%f]', $data['latitude'], $data['longitude']) : '[0,0]');
37 37
 		$map_init    = '[0,0]' === $coordinates
38 38
 			? 'locate( {setView: true, maxZoom: 16} )'
39
-			: sprintf( "setView( [%f,%f], 9 )", $data['latitude'], $data['longitude'] );
39
+			: sprintf("setView( [%f,%f], 9 )", $data['latitude'], $data['longitude']);
40 40
 
41 41
 		// Print input fields
42
-		$html .= '<label for="wl_place_lat">' . __( 'Latitude', 'wordlift' ) . '</label>';
43
-		$html .= '<input type="text" id="wl_place_lat" name="wl_metaboxes[coordinates][]" value="' . $data['latitude'] . '" style="width:100%" />';
42
+		$html .= '<label for="wl_place_lat">'.__('Latitude', 'wordlift').'</label>';
43
+		$html .= '<input type="text" id="wl_place_lat" name="wl_metaboxes[coordinates][]" value="'.$data['latitude'].'" style="width:100%" />';
44 44
 
45
-		$html .= '<label for="wl_place_lon">' . __( 'Longitude', 'wordlift' ) . '</label>';
46
-		$html .= '<input type="text" id="wl_place_lon" name="wl_metaboxes[coordinates][]" value="' . $data['longitude'] . '" style="width:100%" />';
45
+		$html .= '<label for="wl_place_lon">'.__('Longitude', 'wordlift').'</label>';
46
+		$html .= '<input type="text" id="wl_place_lon" name="wl_metaboxes[coordinates][]" value="'.$data['longitude'].'" style="width:100%" />';
47 47
 
48 48
 		// Show Leaflet map to pick coordinates
49
-		$element_id = uniqid( 'wl-gep-map-' );
49
+		$element_id = uniqid('wl-gep-map-');
50 50
 		$html .= <<<EOF
51 51
 
52 52
 <div id="$element_id"></div>
@@ -84,23 +84,23 @@  discard block
 block discarded – undo
84 84
 		return $html;
85 85
 	}
86 86
 
87
-	public function save_data( $coords ) {
87
+	public function save_data($coords) {
88 88
 
89
-		$this->sanitize_data( $coords );
89
+		$this->sanitize_data($coords);
90 90
 
91 91
 		$entity_id = get_the_ID();
92 92
 
93 93
 		// Take away old values
94
-		delete_post_meta( $entity_id, Wordlift_Schema_Service::FIELD_GEO_LATITUDE );
95
-		delete_post_meta( $entity_id, Wordlift_Schema_Service::FIELD_GEO_LONGITUDE );
94
+		delete_post_meta($entity_id, Wordlift_Schema_Service::FIELD_GEO_LATITUDE);
95
+		delete_post_meta($entity_id, Wordlift_Schema_Service::FIELD_GEO_LONGITUDE);
96 96
 
97 97
 		$latitude  = $this->data[0];
98 98
 		$longitude = $this->data[1];
99 99
 
100 100
 		// insert new coordinate values
101
-		if ( ! empty( $latitude ) && ! empty( $longitude ) ) {
102
-			add_post_meta( $entity_id, Wordlift_Schema_Service::FIELD_GEO_LATITUDE, $latitude, true );
103
-			add_post_meta( $entity_id, Wordlift_Schema_Service::FIELD_GEO_LONGITUDE, $longitude, true );
101
+		if ( ! empty($latitude) && ! empty($longitude)) {
102
+			add_post_meta($entity_id, Wordlift_Schema_Service::FIELD_GEO_LATITUDE, $latitude, true);
103
+			add_post_meta($entity_id, Wordlift_Schema_Service::FIELD_GEO_LONGITUDE, $longitude, true);
104 104
 		}
105 105
 
106 106
 	}
@@ -108,11 +108,11 @@  discard block
 block discarded – undo
108 108
 	/**
109 109
 	 * Only accept float numbers
110 110
 	 */
111
-	public function sanitize_data_filter( $value ) {
111
+	public function sanitize_data_filter($value) {
112 112
 
113 113
 		// DO NOT set latitude/longitude to 0/0 as default values. It's a specific place on the globe:
114 114
 		// "The zero/zero point of this system is located in the Gulf of Guinea about 625 km (390 mi) south of Tema, Ghana."
115
-		if ( ! is_numeric( $value ) ) {
115
+		if ( ! is_numeric($value)) {
116 116
 			return '';
117 117
 		}
118 118
 
Please login to merge, or discard this patch.
Indentation   +62 added lines, -62 removed lines patch added patch discarded remove patch
@@ -3,51 +3,51 @@  discard block
 block discarded – undo
3 3
 
4 4
 class WL_Metabox_Field_coordinates extends WL_Metabox_Field {
5 5
 
6
-	public function __construct( $args ) {
6
+    public function __construct( $args ) {
7 7
 
8
-		// Just set up the necessary info without calling the parent constructor.
9
-		// TODO: write a parent class for grouped properties
8
+        // Just set up the necessary info without calling the parent constructor.
9
+        // TODO: write a parent class for grouped properties
10 10
 
11
-		// we use 'coordinates' to namespace the Field in $_POST data.
12
-		// In  the DB the correct meta names will be used.
13
-		$this->meta_name = 'coordinates';
14
-	}
11
+        // we use 'coordinates' to namespace the Field in $_POST data.
12
+        // In  the DB the correct meta names will be used.
13
+        $this->meta_name = 'coordinates';
14
+    }
15 15
 
16
-	public function get_data() {
17
-		$entity_id  = get_the_ID();
18
-		$this->data = wl_get_coordinates( $entity_id );
19
-	}
16
+    public function get_data() {
17
+        $entity_id  = get_the_ID();
18
+        $this->data = wl_get_coordinates( $entity_id );
19
+    }
20 20
 
21
-	public function html() {
21
+    public function html() {
22 22
 
23
-		// Open main <div> for the Field
24
-		$html = $this->html_wrapper_open();
23
+        // Open main <div> for the Field
24
+        $html = $this->html_wrapper_open();
25 25
 
26
-		// Label
27
-		$html .= '<h3>coordinates</h3>';
26
+        // Label
27
+        $html .= '<h3>coordinates</h3>';
28 28
 
29
-		// print nonce
30
-		$html .= $this->html_nonce();
29
+        // print nonce
30
+        $html .= $this->html_nonce();
31 31
 
32
-		// Get coordinates
33
-		$data        = $this->data;
34
-		// TODO: We temporary use here 0,0 as default coordinates for the marker, but if no coordinates are given we
35
-		// want to use the current user location for the marker.
36
-		$coordinates = ( ! empty( $data['latitude'] ) && ! empty( $data['longitude'] ) ? sprintf( '[%f,%f]', $data['latitude'], $data['longitude'] ) : '[0,0]' );
37
-		$map_init    = '[0,0]' === $coordinates
38
-			? 'locate( {setView: true, maxZoom: 16} )'
39
-			: sprintf( "setView( [%f,%f], 9 )", $data['latitude'], $data['longitude'] );
32
+        // Get coordinates
33
+        $data        = $this->data;
34
+        // TODO: We temporary use here 0,0 as default coordinates for the marker, but if no coordinates are given we
35
+        // want to use the current user location for the marker.
36
+        $coordinates = ( ! empty( $data['latitude'] ) && ! empty( $data['longitude'] ) ? sprintf( '[%f,%f]', $data['latitude'], $data['longitude'] ) : '[0,0]' );
37
+        $map_init    = '[0,0]' === $coordinates
38
+            ? 'locate( {setView: true, maxZoom: 16} )'
39
+            : sprintf( "setView( [%f,%f], 9 )", $data['latitude'], $data['longitude'] );
40 40
 
41
-		// Print input fields
42
-		$html .= '<label for="wl_place_lat">' . __( 'Latitude', 'wordlift' ) . '</label>';
43
-		$html .= '<input type="text" id="wl_place_lat" name="wl_metaboxes[coordinates][]" value="' . $data['latitude'] . '" style="width:100%" />';
41
+        // Print input fields
42
+        $html .= '<label for="wl_place_lat">' . __( 'Latitude', 'wordlift' ) . '</label>';
43
+        $html .= '<input type="text" id="wl_place_lat" name="wl_metaboxes[coordinates][]" value="' . $data['latitude'] . '" style="width:100%" />';
44 44
 
45
-		$html .= '<label for="wl_place_lon">' . __( 'Longitude', 'wordlift' ) . '</label>';
46
-		$html .= '<input type="text" id="wl_place_lon" name="wl_metaboxes[coordinates][]" value="' . $data['longitude'] . '" style="width:100%" />';
45
+        $html .= '<label for="wl_place_lon">' . __( 'Longitude', 'wordlift' ) . '</label>';
46
+        $html .= '<input type="text" id="wl_place_lon" name="wl_metaboxes[coordinates][]" value="' . $data['longitude'] . '" style="width:100%" />';
47 47
 
48
-		// Show Leaflet map to pick coordinates
49
-		$element_id = uniqid( 'wl-gep-map-' );
50
-		$html .= <<<EOF
48
+        // Show Leaflet map to pick coordinates
49
+        $element_id = uniqid( 'wl-gep-map-' );
50
+        $html .= <<<EOF
51 51
 
52 52
 <div id="$element_id"></div>
53 53
 
@@ -79,44 +79,44 @@  discard block
 block discarded – undo
79 79
 EOF;
80 80
 
81 81
 
82
-		$html .= $this->html_wrapper_close();
82
+        $html .= $this->html_wrapper_close();
83 83
 
84
-		return $html;
85
-	}
84
+        return $html;
85
+    }
86 86
 
87
-	public function save_data( $coords ) {
87
+    public function save_data( $coords ) {
88 88
 
89
-		$this->sanitize_data( $coords );
89
+        $this->sanitize_data( $coords );
90 90
 
91
-		$entity_id = get_the_ID();
91
+        $entity_id = get_the_ID();
92 92
 
93
-		// Take away old values
94
-		delete_post_meta( $entity_id, Wordlift_Schema_Service::FIELD_GEO_LATITUDE );
95
-		delete_post_meta( $entity_id, Wordlift_Schema_Service::FIELD_GEO_LONGITUDE );
93
+        // Take away old values
94
+        delete_post_meta( $entity_id, Wordlift_Schema_Service::FIELD_GEO_LATITUDE );
95
+        delete_post_meta( $entity_id, Wordlift_Schema_Service::FIELD_GEO_LONGITUDE );
96 96
 
97
-		$latitude  = $this->data[0];
98
-		$longitude = $this->data[1];
97
+        $latitude  = $this->data[0];
98
+        $longitude = $this->data[1];
99 99
 
100
-		// insert new coordinate values
101
-		if ( ! empty( $latitude ) && ! empty( $longitude ) ) {
102
-			add_post_meta( $entity_id, Wordlift_Schema_Service::FIELD_GEO_LATITUDE, $latitude, true );
103
-			add_post_meta( $entity_id, Wordlift_Schema_Service::FIELD_GEO_LONGITUDE, $longitude, true );
104
-		}
100
+        // insert new coordinate values
101
+        if ( ! empty( $latitude ) && ! empty( $longitude ) ) {
102
+            add_post_meta( $entity_id, Wordlift_Schema_Service::FIELD_GEO_LATITUDE, $latitude, true );
103
+            add_post_meta( $entity_id, Wordlift_Schema_Service::FIELD_GEO_LONGITUDE, $longitude, true );
104
+        }
105 105
 
106
-	}
106
+    }
107 107
 
108
-	/**
109
-	 * Only accept float numbers
110
-	 */
111
-	public function sanitize_data_filter( $value ) {
108
+    /**
109
+     * Only accept float numbers
110
+     */
111
+    public function sanitize_data_filter( $value ) {
112 112
 
113
-		// DO NOT set latitude/longitude to 0/0 as default values. It's a specific place on the globe:
114
-		// "The zero/zero point of this system is located in the Gulf of Guinea about 625 km (390 mi) south of Tema, Ghana."
115
-		if ( ! is_numeric( $value ) ) {
116
-			return '';
117
-		}
113
+        // DO NOT set latitude/longitude to 0/0 as default values. It's a specific place on the globe:
114
+        // "The zero/zero point of this system is located in the Gulf of Guinea about 625 km (390 mi) south of Tema, Ghana."
115
+        if ( ! is_numeric( $value ) ) {
116
+            return '';
117
+        }
118 118
 
119
-		return $value;
120
-	}
119
+        return $value;
120
+    }
121 121
 }
122 122
 
Please login to merge, or discard this patch.
src/admin/wordlift_admin_save_post.php 2 patches
Indentation   +73 added lines, -73 removed lines patch added patch discarded remove patch
@@ -23,19 +23,19 @@  discard block
 block discarded – undo
23 23
  */
24 24
 function wl_transition_post_status( $new_status, $old_status, $post ) {
25 25
 
26
-	// wl_write_log( "wl_transition_post_status [ new status :: $new_status ][ old status :: $old_status ][ post ID :: $post->ID ]" );
27
-
28
-	// transition from *published* to any other status: delete the post.
29
-	if ( 'publish' === $old_status && 'publish' !== $new_status ) {
30
-		rl_delete_post( $post );
31
-	}
32
-
33
-	// when a post is published, then all the referenced entities must be published.
34
-	if ( 'publish' !== $old_status && 'publish' === $new_status ) {
35
-		foreach ( wl_core_get_related_entity_ids( $post->ID ) as $entity_id ) {
36
-			wl_update_post_status( $entity_id, 'publish' );
37
-		}
38
-	}
26
+    // wl_write_log( "wl_transition_post_status [ new status :: $new_status ][ old status :: $old_status ][ post ID :: $post->ID ]" );
27
+
28
+    // transition from *published* to any other status: delete the post.
29
+    if ( 'publish' === $old_status && 'publish' !== $new_status ) {
30
+        rl_delete_post( $post );
31
+    }
32
+
33
+    // when a post is published, then all the referenced entities must be published.
34
+    if ( 'publish' !== $old_status && 'publish' === $new_status ) {
35
+        foreach ( wl_core_get_related_entity_ids( $post->ID ) as $entity_id ) {
36
+            wl_update_post_status( $entity_id, 'publish' );
37
+        }
38
+    }
39 39
 }
40 40
 
41 41
 // hook save events.
@@ -49,49 +49,49 @@  discard block
 block discarded – undo
49 49
  */
50 50
 function rl_delete_post( $post ) {
51 51
 
52
-	$post_id = ( is_numeric( $post ) ? $post : $post->ID );
52
+    $post_id = ( is_numeric( $post ) ? $post : $post->ID );
53 53
 
54
-	// hide all entities that are not referenced by any published post.
55
-	foreach ( wl_core_get_related_entity_ids( $post_id ) as $entity_id ) {
54
+    // hide all entities that are not referenced by any published post.
55
+    foreach ( wl_core_get_related_entity_ids( $post_id ) as $entity_id ) {
56 56
 
57
-		// check if there is at least one referencing post published.
58
-		$is_published = array_reduce( wl_core_get_related_post_ids( $entity_id ), function ( $carry, $item ) {
57
+        // check if there is at least one referencing post published.
58
+        $is_published = array_reduce( wl_core_get_related_post_ids( $entity_id ), function ( $carry, $item ) {
59 59
                     $post = get_post( $item );
60 60
                     return ( $carry || ( 'publish' === $post->post_status ) );
61
-		} );
62
-		// set the entity to draft if no referencing posts are published.
63
-		if ( ! $is_published ) {
64
-			wl_update_post_status( $entity_id, 'draft' );
65
-		}
66
-	}
67
-
68
-	// get the entity URI (valid also for posts)
69
-	$uri_esc = wl_sparql_escape_uri( wl_get_entity_uri( $post_id ) );
70
-
71
-	wl_write_log( "rl_delete_post [ post id :: $post_id ][ uri esc :: $uri_esc ]" );
72
-
73
-	// create the SPARQL statement by joining the SPARQL prefixes and deleting any known predicate.
74
-	$stmt = rl_sparql_prefixes();
75
-	foreach ( wl_predicates() as $predicate ) {
76
-		$stmt .= "DELETE { <$uri_esc> $predicate ?o . } WHERE { <$uri_esc> $predicate ?o . };\n" .
77
-		         "DELETE { ?s $predicate <$uri_esc> . } WHERE { ?s $predicate <$uri_esc> . };\n";
78
-	}
79
-
80
-	// if the post is an entity and has exported properties, delete the related predicates.
81
-	if ( Wordlift_Entity_Service::TYPE_NAME === $post->post_type ) {
82
-		$type = wl_entity_type_taxonomy_get_type( $post->ID );
83
-
84
-		if ( isset( $type['custom_fields'] ) ) {
85
-			foreach ( $type['custom_fields'] as $field => $params ) {
86
-				// TODO: enclose in <> only if predicate starts with http(s)://
87
-				$predicate = '<' . $params['predicate'] . '>';
88
-				$stmt .= "DELETE { <$uri_esc> $predicate ?o . } WHERE { <$uri_esc> $predicate ?o . };\n";
89
-			}
90
-		}
91
-	}
92
-
93
-	// finally execute the query.
94
-	rl_execute_sparql_update_query( $stmt );
61
+        } );
62
+        // set the entity to draft if no referencing posts are published.
63
+        if ( ! $is_published ) {
64
+            wl_update_post_status( $entity_id, 'draft' );
65
+        }
66
+    }
67
+
68
+    // get the entity URI (valid also for posts)
69
+    $uri_esc = wl_sparql_escape_uri( wl_get_entity_uri( $post_id ) );
70
+
71
+    wl_write_log( "rl_delete_post [ post id :: $post_id ][ uri esc :: $uri_esc ]" );
72
+
73
+    // create the SPARQL statement by joining the SPARQL prefixes and deleting any known predicate.
74
+    $stmt = rl_sparql_prefixes();
75
+    foreach ( wl_predicates() as $predicate ) {
76
+        $stmt .= "DELETE { <$uri_esc> $predicate ?o . } WHERE { <$uri_esc> $predicate ?o . };\n" .
77
+                    "DELETE { ?s $predicate <$uri_esc> . } WHERE { ?s $predicate <$uri_esc> . };\n";
78
+    }
79
+
80
+    // if the post is an entity and has exported properties, delete the related predicates.
81
+    if ( Wordlift_Entity_Service::TYPE_NAME === $post->post_type ) {
82
+        $type = wl_entity_type_taxonomy_get_type( $post->ID );
83
+
84
+        if ( isset( $type['custom_fields'] ) ) {
85
+            foreach ( $type['custom_fields'] as $field => $params ) {
86
+                // TODO: enclose in <> only if predicate starts with http(s)://
87
+                $predicate = '<' . $params['predicate'] . '>';
88
+                $stmt .= "DELETE { <$uri_esc> $predicate ?o . } WHERE { <$uri_esc> $predicate ?o . };\n";
89
+            }
90
+        }
91
+    }
92
+
93
+    // finally execute the query.
94
+    rl_execute_sparql_update_query( $stmt );
95 95
 }
96 96
 
97 97
 /**
@@ -102,34 +102,34 @@  discard block
 block discarded – undo
102 102
  */
103 103
 function wl_update_post_status( $post_id, $status ) {
104 104
 
105
-	wl_write_log( "wl_update_post_status [ post ID :: $post_id ][ status :: $status ]" );
105
+    wl_write_log( "wl_update_post_status [ post ID :: $post_id ][ status :: $status ]" );
106 106
 
107
-	global $wpdb;
107
+    global $wpdb;
108 108
 
109
-	if ( ! $post = get_post( $post_id ) ) {
110
-		return;
111
-	}
109
+    if ( ! $post = get_post( $post_id ) ) {
110
+        return;
111
+    }
112 112
 
113
-	if ( $status === $post->post_status ) {
114
-		return;
115
-	}
113
+    if ( $status === $post->post_status ) {
114
+        return;
115
+    }
116 116
 
117
-	$wpdb->update( $wpdb->posts, array( 'post_status' => $status ), array( 'ID' => $post->ID ) );
117
+    $wpdb->update( $wpdb->posts, array( 'post_status' => $status ), array( 'ID' => $post->ID ) );
118 118
 
119
-	clean_post_cache( $post->ID );
119
+    clean_post_cache( $post->ID );
120 120
 
121
-	$old_status        = $post->post_status;
122
-	$post->post_status = $status;
121
+    $old_status        = $post->post_status;
122
+    $post->post_status = $status;
123 123
 
124
-	wp_transition_post_status( $status, $old_status, $post );
124
+    wp_transition_post_status( $status, $old_status, $post );
125 125
 
126
-	/** This action is documented in wp-includes/post.php */
127
-	do_action( 'edit_post', $post->ID, $post );
128
-	/** This action is documented in wp-includes/post.php */
129
-	do_action( "save_post_{$post->post_type}", $post->ID, $post, true );
130
-	/** This action is documented in wp-includes/post.php */
131
-	do_action( 'wl_linked_data_save_post', $post->ID );
132
-	/** This action is documented in wp-includes/post.php */
133
-	do_action( 'wp_insert_post', $post->ID, $post, true );
126
+    /** This action is documented in wp-includes/post.php */
127
+    do_action( 'edit_post', $post->ID, $post );
128
+    /** This action is documented in wp-includes/post.php */
129
+    do_action( "save_post_{$post->post_type}", $post->ID, $post, true );
130
+    /** This action is documented in wp-includes/post.php */
131
+    do_action( 'wl_linked_data_save_post', $post->ID );
132
+    /** This action is documented in wp-includes/post.php */
133
+    do_action( 'wp_insert_post', $post->ID, $post, true );
134 134
 }
135 135
 
Please login to merge, or discard this patch.
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -21,25 +21,25 @@  discard block
 block discarded – undo
21 21
  * @param string $old_status The old post status
22 22
  * @param array $post An array with the post data
23 23
  */
24
-function wl_transition_post_status( $new_status, $old_status, $post ) {
24
+function wl_transition_post_status($new_status, $old_status, $post) {
25 25
 
26 26
 	// wl_write_log( "wl_transition_post_status [ new status :: $new_status ][ old status :: $old_status ][ post ID :: $post->ID ]" );
27 27
 
28 28
 	// transition from *published* to any other status: delete the post.
29
-	if ( 'publish' === $old_status && 'publish' !== $new_status ) {
30
-		rl_delete_post( $post );
29
+	if ('publish' === $old_status && 'publish' !== $new_status) {
30
+		rl_delete_post($post);
31 31
 	}
32 32
 
33 33
 	// when a post is published, then all the referenced entities must be published.
34
-	if ( 'publish' !== $old_status && 'publish' === $new_status ) {
35
-		foreach ( wl_core_get_related_entity_ids( $post->ID ) as $entity_id ) {
36
-			wl_update_post_status( $entity_id, 'publish' );
34
+	if ('publish' !== $old_status && 'publish' === $new_status) {
35
+		foreach (wl_core_get_related_entity_ids($post->ID) as $entity_id) {
36
+			wl_update_post_status($entity_id, 'publish');
37 37
 		}
38 38
 	}
39 39
 }
40 40
 
41 41
 // hook save events.
42
-add_action( 'transition_post_status', 'wl_transition_post_status', 10, 3 );
42
+add_action('transition_post_status', 'wl_transition_post_status', 10, 3);
43 43
 
44 44
 
45 45
 /**
@@ -47,51 +47,51 @@  discard block
 block discarded – undo
47 47
  *
48 48
  * @param array|int $post An array of post data
49 49
  */
50
-function rl_delete_post( $post ) {
50
+function rl_delete_post($post) {
51 51
 
52
-	$post_id = ( is_numeric( $post ) ? $post : $post->ID );
52
+	$post_id = (is_numeric($post) ? $post : $post->ID);
53 53
 
54 54
 	// hide all entities that are not referenced by any published post.
55
-	foreach ( wl_core_get_related_entity_ids( $post_id ) as $entity_id ) {
55
+	foreach (wl_core_get_related_entity_ids($post_id) as $entity_id) {
56 56
 
57 57
 		// check if there is at least one referencing post published.
58
-		$is_published = array_reduce( wl_core_get_related_post_ids( $entity_id ), function ( $carry, $item ) {
59
-                    $post = get_post( $item );
60
-                    return ( $carry || ( 'publish' === $post->post_status ) );
58
+		$is_published = array_reduce(wl_core_get_related_post_ids($entity_id), function($carry, $item) {
59
+                    $post = get_post($item);
60
+                    return ($carry || ('publish' === $post->post_status));
61 61
 		} );
62 62
 		// set the entity to draft if no referencing posts are published.
63
-		if ( ! $is_published ) {
64
-			wl_update_post_status( $entity_id, 'draft' );
63
+		if ( ! $is_published) {
64
+			wl_update_post_status($entity_id, 'draft');
65 65
 		}
66 66
 	}
67 67
 
68 68
 	// get the entity URI (valid also for posts)
69
-	$uri_esc = wl_sparql_escape_uri( wl_get_entity_uri( $post_id ) );
69
+	$uri_esc = wl_sparql_escape_uri(wl_get_entity_uri($post_id));
70 70
 
71
-	wl_write_log( "rl_delete_post [ post id :: $post_id ][ uri esc :: $uri_esc ]" );
71
+	wl_write_log("rl_delete_post [ post id :: $post_id ][ uri esc :: $uri_esc ]");
72 72
 
73 73
 	// create the SPARQL statement by joining the SPARQL prefixes and deleting any known predicate.
74 74
 	$stmt = rl_sparql_prefixes();
75
-	foreach ( wl_predicates() as $predicate ) {
76
-		$stmt .= "DELETE { <$uri_esc> $predicate ?o . } WHERE { <$uri_esc> $predicate ?o . };\n" .
75
+	foreach (wl_predicates() as $predicate) {
76
+		$stmt .= "DELETE { <$uri_esc> $predicate ?o . } WHERE { <$uri_esc> $predicate ?o . };\n".
77 77
 		         "DELETE { ?s $predicate <$uri_esc> . } WHERE { ?s $predicate <$uri_esc> . };\n";
78 78
 	}
79 79
 
80 80
 	// if the post is an entity and has exported properties, delete the related predicates.
81
-	if ( Wordlift_Entity_Service::TYPE_NAME === $post->post_type ) {
82
-		$type = wl_entity_type_taxonomy_get_type( $post->ID );
81
+	if (Wordlift_Entity_Service::TYPE_NAME === $post->post_type) {
82
+		$type = wl_entity_type_taxonomy_get_type($post->ID);
83 83
 
84
-		if ( isset( $type['custom_fields'] ) ) {
85
-			foreach ( $type['custom_fields'] as $field => $params ) {
84
+		if (isset($type['custom_fields'])) {
85
+			foreach ($type['custom_fields'] as $field => $params) {
86 86
 				// TODO: enclose in <> only if predicate starts with http(s)://
87
-				$predicate = '<' . $params['predicate'] . '>';
87
+				$predicate = '<'.$params['predicate'].'>';
88 88
 				$stmt .= "DELETE { <$uri_esc> $predicate ?o . } WHERE { <$uri_esc> $predicate ?o . };\n";
89 89
 			}
90 90
 		}
91 91
 	}
92 92
 
93 93
 	// finally execute the query.
94
-	rl_execute_sparql_update_query( $stmt );
94
+	rl_execute_sparql_update_query($stmt);
95 95
 }
96 96
 
97 97
 /**
@@ -100,36 +100,36 @@  discard block
 block discarded – undo
100 100
  * @param int $post_id The post ID
101 101
  * @param string $status The new status
102 102
  */
103
-function wl_update_post_status( $post_id, $status ) {
103
+function wl_update_post_status($post_id, $status) {
104 104
 
105
-	wl_write_log( "wl_update_post_status [ post ID :: $post_id ][ status :: $status ]" );
105
+	wl_write_log("wl_update_post_status [ post ID :: $post_id ][ status :: $status ]");
106 106
 
107 107
 	global $wpdb;
108 108
 
109
-	if ( ! $post = get_post( $post_id ) ) {
109
+	if ( ! $post = get_post($post_id)) {
110 110
 		return;
111 111
 	}
112 112
 
113
-	if ( $status === $post->post_status ) {
113
+	if ($status === $post->post_status) {
114 114
 		return;
115 115
 	}
116 116
 
117
-	$wpdb->update( $wpdb->posts, array( 'post_status' => $status ), array( 'ID' => $post->ID ) );
117
+	$wpdb->update($wpdb->posts, array('post_status' => $status), array('ID' => $post->ID));
118 118
 
119
-	clean_post_cache( $post->ID );
119
+	clean_post_cache($post->ID);
120 120
 
121 121
 	$old_status        = $post->post_status;
122 122
 	$post->post_status = $status;
123 123
 
124
-	wp_transition_post_status( $status, $old_status, $post );
124
+	wp_transition_post_status($status, $old_status, $post);
125 125
 
126 126
 	/** This action is documented in wp-includes/post.php */
127
-	do_action( 'edit_post', $post->ID, $post );
127
+	do_action('edit_post', $post->ID, $post);
128 128
 	/** This action is documented in wp-includes/post.php */
129
-	do_action( "save_post_{$post->post_type}", $post->ID, $post, true );
129
+	do_action("save_post_{$post->post_type}", $post->ID, $post, true);
130 130
 	/** This action is documented in wp-includes/post.php */
131
-	do_action( 'wl_linked_data_save_post', $post->ID );
131
+	do_action('wl_linked_data_save_post', $post->ID);
132 132
 	/** This action is documented in wp-includes/post.php */
133
-	do_action( 'wp_insert_post', $post->ID, $post, true );
133
+	do_action('wp_insert_post', $post->ID, $post, true);
134 134
 }
135 135
 
Please login to merge, or discard this patch.
src/admin/wordlift_admin_shortcodes.php 2 patches
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -9,12 +9,12 @@  discard block
 block discarded – undo
9 9
  * Loads the buttons in TinyMCE.
10 10
  */
11 11
 function wl_admin_shortcode_buttons() {
12
-	// Only add hooks when the current user has permissions AND is in Rich Text editor mode
13
-	if ( ( current_user_can( 'edit_posts' ) || current_user_can( 'edit_pages' ) ) && get_user_option( 'rich_editing' ) ) {
14
-		add_filter( 'mce_external_plugins', 'wl_admin_shortcode_buttons_register_tinymce_javascript' );
15
-		add_filter( 'mce_buttons', 'wl_admin_shortcode_register_buttons' );
16
-		add_action( 'admin_footer', 'wl_admin_inject_chord_dialog_dependencies' );
17
-	}
12
+    // Only add hooks when the current user has permissions AND is in Rich Text editor mode
13
+    if ( ( current_user_can( 'edit_posts' ) || current_user_can( 'edit_pages' ) ) && get_user_option( 'rich_editing' ) ) {
14
+        add_filter( 'mce_external_plugins', 'wl_admin_shortcode_buttons_register_tinymce_javascript' );
15
+        add_filter( 'mce_buttons', 'wl_admin_shortcode_register_buttons' );
16
+        add_action( 'admin_footer', 'wl_admin_inject_chord_dialog_dependencies' );
17
+    }
18 18
 }
19 19
 
20 20
 /**
@@ -26,9 +26,9 @@  discard block
 block discarded – undo
26 26
  */
27 27
 function wl_admin_shortcode_buttons_register_tinymce_javascript( $plugin_array ) {
28 28
 
29
-	$plugin_array['wl_shortcodes'] = plugin_dir_url( __FILE__ ) . 'js/wordlift_shortcode_tinymce_plugin.js';
29
+    $plugin_array['wl_shortcodes'] = plugin_dir_url( __FILE__ ) . 'js/wordlift_shortcode_tinymce_plugin.js';
30 30
 
31
-	return $plugin_array;
31
+    return $plugin_array;
32 32
 }
33 33
 
34 34
 /**
@@ -39,9 +39,9 @@  discard block
 block discarded – undo
39 39
  * @return array The buttons array including the *wl_shortcodes_menu*.
40 40
  */
41 41
 function wl_admin_shortcode_register_buttons( $buttons ) {
42
-	array_push( $buttons, 'wl_shortcodes_menu' );
42
+    array_push( $buttons, 'wl_shortcodes_menu' );
43 43
 
44
-	return $buttons;
44
+    return $buttons;
45 45
 }
46 46
 
47 47
 // init process for button control
@@ -55,16 +55,16 @@  discard block
 block discarded – undo
55 55
  */
56 56
 function wl_admin_inject_chord_dialog_dependencies() {
57 57
 
58
-	wp_enqueue_style( 'wp-color-picker' );
59
-	wp_enqueue_script( 'wp-color-picker' );
60
-	wp_enqueue_style( 'jquery-ui-slider' );
61
-	// Not included by default :|
62
-	// TODO include jquery ui css from the plugin creates css issues on the slider
63
-	// wp_enqueue_style('jquery-ui-css', plugins_url( 'css/jquery-ui/jquery-ui.min.css', __FILE__ ) );
64
-	wp_enqueue_style( 'wp-jquery-ui-css', 'https://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery.ui.all.css' );
58
+    wp_enqueue_style( 'wp-color-picker' );
59
+    wp_enqueue_script( 'wp-color-picker' );
60
+    wp_enqueue_style( 'jquery-ui-slider' );
61
+    // Not included by default :|
62
+    // TODO include jquery ui css from the plugin creates css issues on the slider
63
+    // wp_enqueue_style('jquery-ui-css', plugins_url( 'css/jquery-ui/jquery-ui.min.css', __FILE__ ) );
64
+    wp_enqueue_style( 'wp-jquery-ui-css', 'https://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery.ui.all.css' );
65 65
 
66
-	wp_enqueue_script( 'jquery' );
67
-	wp_enqueue_script( 'jquery-ui-core' );
68
-	wp_enqueue_script( 'jquery-ui-slider' );
66
+    wp_enqueue_script( 'jquery' );
67
+    wp_enqueue_script( 'jquery-ui-core' );
68
+    wp_enqueue_script( 'jquery-ui-slider' );
69 69
 
70 70
 }
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -10,10 +10,10 @@  discard block
 block discarded – undo
10 10
  */
11 11
 function wl_admin_shortcode_buttons() {
12 12
 	// Only add hooks when the current user has permissions AND is in Rich Text editor mode
13
-	if ( ( current_user_can( 'edit_posts' ) || current_user_can( 'edit_pages' ) ) && get_user_option( 'rich_editing' ) ) {
14
-		add_filter( 'mce_external_plugins', 'wl_admin_shortcode_buttons_register_tinymce_javascript' );
15
-		add_filter( 'mce_buttons', 'wl_admin_shortcode_register_buttons' );
16
-		add_action( 'admin_footer', 'wl_admin_inject_chord_dialog_dependencies' );
13
+	if ((current_user_can('edit_posts') || current_user_can('edit_pages')) && get_user_option('rich_editing')) {
14
+		add_filter('mce_external_plugins', 'wl_admin_shortcode_buttons_register_tinymce_javascript');
15
+		add_filter('mce_buttons', 'wl_admin_shortcode_register_buttons');
16
+		add_action('admin_footer', 'wl_admin_inject_chord_dialog_dependencies');
17 17
 	}
18 18
 }
19 19
 
@@ -24,9 +24,9 @@  discard block
 block discarded – undo
24 24
  *
25 25
  * @return array The TinyMCE plugins array including WordLift shortcodes plugin.
26 26
  */
27
-function wl_admin_shortcode_buttons_register_tinymce_javascript( $plugin_array ) {
27
+function wl_admin_shortcode_buttons_register_tinymce_javascript($plugin_array) {
28 28
 
29
-	$plugin_array['wl_shortcodes'] = plugin_dir_url( __FILE__ ) . 'js/wordlift_shortcode_tinymce_plugin.js';
29
+	$plugin_array['wl_shortcodes'] = plugin_dir_url(__FILE__).'js/wordlift_shortcode_tinymce_plugin.js';
30 30
 
31 31
 	return $plugin_array;
32 32
 }
@@ -38,14 +38,14 @@  discard block
 block discarded – undo
38 38
  *
39 39
  * @return array The buttons array including the *wl_shortcodes_menu*.
40 40
  */
41
-function wl_admin_shortcode_register_buttons( $buttons ) {
42
-	array_push( $buttons, 'wl_shortcodes_menu' );
41
+function wl_admin_shortcode_register_buttons($buttons) {
42
+	array_push($buttons, 'wl_shortcodes_menu');
43 43
 
44 44
 	return $buttons;
45 45
 }
46 46
 
47 47
 // init process for button control
48
-add_action( 'admin_init', 'wl_admin_shortcode_buttons' );
48
+add_action('admin_init', 'wl_admin_shortcode_buttons');
49 49
 
50 50
 
51 51
 /**
@@ -55,16 +55,16 @@  discard block
 block discarded – undo
55 55
  */
56 56
 function wl_admin_inject_chord_dialog_dependencies() {
57 57
 
58
-	wp_enqueue_style( 'wp-color-picker' );
59
-	wp_enqueue_script( 'wp-color-picker' );
60
-	wp_enqueue_style( 'jquery-ui-slider' );
58
+	wp_enqueue_style('wp-color-picker');
59
+	wp_enqueue_script('wp-color-picker');
60
+	wp_enqueue_style('jquery-ui-slider');
61 61
 	// Not included by default :|
62 62
 	// TODO include jquery ui css from the plugin creates css issues on the slider
63 63
 	// wp_enqueue_style('jquery-ui-css', plugins_url( 'css/jquery-ui/jquery-ui.min.css', __FILE__ ) );
64
-	wp_enqueue_style( 'wp-jquery-ui-css', 'https://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery.ui.all.css' );
64
+	wp_enqueue_style('wp-jquery-ui-css', 'https://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery.ui.all.css');
65 65
 
66
-	wp_enqueue_script( 'jquery' );
67
-	wp_enqueue_script( 'jquery-ui-core' );
68
-	wp_enqueue_script( 'jquery-ui-slider' );
66
+	wp_enqueue_script('jquery');
67
+	wp_enqueue_script('jquery-ui-core');
68
+	wp_enqueue_script('jquery-ui-slider');
69 69
 
70 70
 }
Please login to merge, or discard this patch.
src/admin/wordlift_admin_sync.php 2 patches
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -9,20 +9,20 @@  discard block
 block discarded – undo
9 9
  */
10 10
 function wl_admin_sync_to_redlink() {
11 11
 
12
-	$posts = get_posts( array(
13
-		'post_type'      => 'any',
14
-		'posts_per_page' => - 1
15
-	) );
12
+    $posts = get_posts( array(
13
+        'post_type'      => 'any',
14
+        'posts_per_page' => - 1
15
+    ) );
16 16
 
17
-	wl_write_log( "wl_admin_sync_to_redlink [ post count :: " . sizeof( $posts ) . " ]" );
17
+    wl_write_log( "wl_admin_sync_to_redlink [ post count :: " . sizeof( $posts ) . " ]" );
18 18
 
19
-	foreach ( $posts as $post ) {
20
-		echo esc_html( $post->post_title ) . '<br/>';
21
-		wl_linked_data_push_to_redlink( $post->ID );
22
-	}
19
+    foreach ( $posts as $post ) {
20
+        echo esc_html( $post->post_title ) . '<br/>';
21
+        wl_linked_data_push_to_redlink( $post->ID );
22
+    }
23 23
 
24
-	// Schedule the execution of SPARQL.
25
-	wl_shutdown();
24
+    // Schedule the execution of SPARQL.
25
+    wl_shutdown();
26 26
 }
27 27
 
28 28
 /**
@@ -30,9 +30,9 @@  discard block
 block discarded – undo
30 30
  */
31 31
 function wl_admin_ajax_sync_to_redlink() {
32 32
 
33
-	// TODO: check appropriate permissions here.
34
-	wl_admin_sync_to_redlink();
35
-	die();
33
+    // TODO: check appropriate permissions here.
34
+    wl_admin_sync_to_redlink();
35
+    die();
36 36
 
37 37
 }
38 38
 
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -9,16 +9,16 @@  discard block
 block discarded – undo
9 9
  */
10 10
 function wl_admin_sync_to_redlink() {
11 11
 
12
-	$posts = get_posts( array(
12
+	$posts = get_posts(array(
13 13
 		'post_type'      => 'any',
14
-		'posts_per_page' => - 1
15
-	) );
14
+		'posts_per_page' => -1
15
+	));
16 16
 
17
-	wl_write_log( "wl_admin_sync_to_redlink [ post count :: " . sizeof( $posts ) . " ]" );
17
+	wl_write_log("wl_admin_sync_to_redlink [ post count :: ".sizeof($posts)." ]");
18 18
 
19
-	foreach ( $posts as $post ) {
20
-		echo esc_html( $post->post_title ) . '<br/>';
21
-		wl_linked_data_push_to_redlink( $post->ID );
19
+	foreach ($posts as $post) {
20
+		echo esc_html($post->post_title).'<br/>';
21
+		wl_linked_data_push_to_redlink($post->ID);
22 22
 	}
23 23
 
24 24
 	// Schedule the execution of SPARQL.
@@ -36,4 +36,4 @@  discard block
 block discarded – undo
36 36
 
37 37
 }
38 38
 
39
-add_action( 'wp_ajax_wl_sync_to_redlink', 'wl_admin_ajax_sync_to_redlink' );
39
+add_action('wp_ajax_wl_sync_to_redlink', 'wl_admin_ajax_sync_to_redlink');
Please login to merge, or discard this patch.
src/includes/class-wordlift-deactivator.php 1 patch
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -22,15 +22,15 @@
 block discarded – undo
22 22
  */
23 23
 class Wordlift_Deactivator {
24 24
 
25
-	/**
26
-	 * Short Description. (use period)
27
-	 *
28
-	 * Long Description.
29
-	 *
30
-	 * @since    1.0.0
31
-	 */
32
-	public static function deactivate() {
25
+    /**
26
+     * Short Description. (use period)
27
+     *
28
+     * Long Description.
29
+     *
30
+     * @since    1.0.0
31
+     */
32
+    public static function deactivate() {
33 33
 
34
-	}
34
+    }
35 35
 
36 36
 }
Please login to merge, or discard this patch.
src/includes/class-wordlift-entity-types-taxonomy-service.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -7,6 +7,6 @@
 block discarded – undo
7 7
  */
8 8
 class Wordlift_Entity_Types_Taxonomy_Service {
9 9
 
10
-	const TAXONOMY_NAME = 'wl_entity_type';
10
+    const TAXONOMY_NAME = 'wl_entity_type';
11 11
 
12 12
 }
Please login to merge, or discard this patch.