Completed
Push — develop ( 7e6348...4ca448 )
by David
03:38
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/modules/core/wordlift_core_schema_api.php 3 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -170,9 +170,9 @@
 block discarded – undo
170 170
  * Sets the entity type(s) for the specified post ID. Support is now for only one type per entity.
171 171
  *
172 172
  * @param $post_id numeric The numeric post ID
173
- * @param $type_names array An array of strings, each defining a type (e.g. Type, for the http://schema.org/Type)
173
+ * @param string $type_names array An array of strings, each defining a type (e.g. Type, for the http://schema.org/Type)
174 174
  *
175
- * @return boolean True if everything went ok, an error string otherwise.
175
+ * @return boolean|null True if everything went ok, an error string otherwise.
176 176
  */
177 177
 function wl_schema_set_types( $post_id, $type_names ) {
178 178
 
Please login to merge, or discard this patch.
Indentation   +115 added lines, -115 removed lines patch added patch discarded remove patch
@@ -10,28 +10,28 @@  discard block
 block discarded – undo
10 10
  */
11 11
 function wl_schema_reset_value( $post_id, $property_name ) {
12 12
 
13
-	// Some checks on the parameters
14
-	if ( ! is_numeric( $post_id ) || is_null( $property_name ) ) {
15
-		return false;
16
-	}
13
+    // Some checks on the parameters
14
+    if ( ! is_numeric( $post_id ) || is_null( $property_name ) ) {
15
+        return false;
16
+    }
17 17
 
18
-	// Build full schema uri if necessary
19
-	$property_name = wl_build_full_schema_uri_from_schema_slug( $property_name );
18
+    // Build full schema uri if necessary
19
+    $property_name = wl_build_full_schema_uri_from_schema_slug( $property_name );
20 20
 
21
-	// Get accepted properties
22
-	$accepted_fields = wl_entity_taxonomy_get_custom_fields( $post_id );
21
+    // Get accepted properties
22
+    $accepted_fields = wl_entity_taxonomy_get_custom_fields( $post_id );
23 23
 
24
-	// Find the name of the custom-field managing the schema property
25
-	foreach ( $accepted_fields as $wl_constant => $field ) {
26
-		if ( $field['predicate'] == $property_name ) {
24
+    // Find the name of the custom-field managing the schema property
25
+    foreach ( $accepted_fields as $wl_constant => $field ) {
26
+        if ( $field['predicate'] == $property_name ) {
27 27
 
28
-			delete_post_meta( $post_id, $wl_constant );
28
+            delete_post_meta( $post_id, $wl_constant );
29 29
 
30
-			return true;
31
-		}
32
-	}
30
+            return true;
31
+        }
32
+    }
33 33
 
34
-	return false;
34
+    return false;
35 35
 }
36 36
 
37 37
 /**
@@ -44,34 +44,34 @@  discard block
 block discarded – undo
44 44
  */
45 45
 function wl_schema_get_value( $post_id, $property_name ) {
46 46
 
47
-	// Property name must be defined.
48
-	if ( ! isset( $property_name ) || is_null( $property_name ) ) {
49
-		return null;
50
-	}
51
-
52
-	// store eventual schema name in  different variable
53
-	$property_schema_name = wl_build_full_schema_uri_from_schema_slug( $property_name );
54
-
55
-	// Establish entity id.
56
-	if ( is_null( $post_id ) || ! is_numeric( $post_id ) ) {
57
-		$post_id = get_the_ID();
58
-		if ( is_null( $post_id ) || ! is_numeric( $post_id ) ) {
59
-			return null;
60
-		}
61
-	}
62
-
63
-	// Get custom fields.
64
-	$term_mapping = wl_entity_taxonomy_get_custom_fields( $post_id );
65
-	// Search for the required meta value (by constant name or schema name)
66
-	foreach ( $term_mapping as $wl_constant => $property_info ) {
67
-		$found_constant  = ( $wl_constant == $property_name );
68
-		$found_predicate = ( isset( $property_info['predicate'] ) && $property_info['predicate'] == $property_schema_name );
69
-		if ( $found_constant || $found_predicate ) {
70
-			return get_post_meta( $post_id, $wl_constant );
71
-		}
72
-	}
73
-
74
-	return null;
47
+    // Property name must be defined.
48
+    if ( ! isset( $property_name ) || is_null( $property_name ) ) {
49
+        return null;
50
+    }
51
+
52
+    // store eventual schema name in  different variable
53
+    $property_schema_name = wl_build_full_schema_uri_from_schema_slug( $property_name );
54
+
55
+    // Establish entity id.
56
+    if ( is_null( $post_id ) || ! is_numeric( $post_id ) ) {
57
+        $post_id = get_the_ID();
58
+        if ( is_null( $post_id ) || ! is_numeric( $post_id ) ) {
59
+            return null;
60
+        }
61
+    }
62
+
63
+    // Get custom fields.
64
+    $term_mapping = wl_entity_taxonomy_get_custom_fields( $post_id );
65
+    // Search for the required meta value (by constant name or schema name)
66
+    foreach ( $term_mapping as $wl_constant => $property_info ) {
67
+        $found_constant  = ( $wl_constant == $property_name );
68
+        $found_predicate = ( isset( $property_info['predicate'] ) && $property_info['predicate'] == $property_schema_name );
69
+        if ( $found_constant || $found_predicate ) {
70
+            return get_post_meta( $post_id, $wl_constant );
71
+        }
72
+    }
73
+
74
+    return null;
75 75
 }
76 76
 
77 77
 /**
@@ -85,16 +85,16 @@  discard block
 block discarded – undo
85 85
  */
86 86
 function wl_schema_add_value( $post_id, $property_name, $property_value ) {
87 87
 
88
-	if ( ! is_array( $property_value ) ) {
89
-		$property_value = array( $property_value );
90
-	}
88
+    if ( ! is_array( $property_value ) ) {
89
+        $property_value = array( $property_value );
90
+    }
91 91
 
92
-	// Get the old values or set an empty array.
93
-	$old_values = wl_schema_get_value( $post_id, $property_name ) ?: array();
92
+    // Get the old values or set an empty array.
93
+    $old_values = wl_schema_get_value( $post_id, $property_name ) ?: array();
94 94
 
95
-	$merged_property_value = array_unique( array_merge( $property_value, $old_values ) );
95
+    $merged_property_value = array_unique( array_merge( $property_value, $old_values ) );
96 96
 
97
-	wl_schema_set_value( $post_id, $property_name, $merged_property_value );
97
+    wl_schema_set_value( $post_id, $property_name, $merged_property_value );
98 98
 
99 99
 }
100 100
 
@@ -109,38 +109,38 @@  discard block
 block discarded – undo
109 109
  */
110 110
 function wl_schema_set_value( $post_id, $property_name, $property_value ) {
111 111
 
112
-	// Some checks on the parameters
113
-	if ( ! is_numeric( $post_id ) || is_null( $property_name ) || empty( $property_value ) || is_null( $property_value ) ) {
114
-		return false;
115
-	}
112
+    // Some checks on the parameters
113
+    if ( ! is_numeric( $post_id ) || is_null( $property_name ) || empty( $property_value ) || is_null( $property_value ) ) {
114
+        return false;
115
+    }
116 116
 
117
-	// Build full schema uri if necessary
118
-	$property_name = wl_build_full_schema_uri_from_schema_slug( $property_name );
117
+    // Build full schema uri if necessary
118
+    $property_name = wl_build_full_schema_uri_from_schema_slug( $property_name );
119 119
 
120
-	// Get accepted properties
121
-	$accepted_fields = wl_entity_taxonomy_get_custom_fields( $post_id );
120
+    // Get accepted properties
121
+    $accepted_fields = wl_entity_taxonomy_get_custom_fields( $post_id );
122 122
 
123
-	// Find the name of the custom-field managing the schema property
124
-	foreach ( $accepted_fields as $wl_constant => $field ) {
125
-		if ( $field['predicate'] == $property_name ) {
123
+    // Find the name of the custom-field managing the schema property
124
+    foreach ( $accepted_fields as $wl_constant => $field ) {
125
+        if ( $field['predicate'] == $property_name ) {
126 126
 
127
-			// Deal with single values
128
-			if ( ! is_array( $property_value ) ) {
129
-				$property_value = array( $property_value );
130
-			}
127
+            // Deal with single values
128
+            if ( ! is_array( $property_value ) ) {
129
+                $property_value = array( $property_value );
130
+            }
131 131
 
132
-			// Delete present meta
133
-			delete_post_meta( $post_id, $wl_constant );
132
+            // Delete present meta
133
+            delete_post_meta( $post_id, $wl_constant );
134 134
 
135
-			foreach ( $property_value as $value ) {
136
-				add_post_meta( $post_id, $wl_constant, $value );
137
-			}
135
+            foreach ( $property_value as $value ) {
136
+                add_post_meta( $post_id, $wl_constant, $value );
137
+            }
138 138
 
139
-			return true;
140
-		}
141
-	}
139
+            return true;
140
+        }
141
+    }
142 142
 
143
-	return false;
143
+    return false;
144 144
 }
145 145
 
146 146
 
@@ -154,18 +154,18 @@  discard block
 block discarded – undo
154 154
  */
155 155
 function wl_schema_get_types( $post_id ) {
156 156
 
157
-	// Some checks on the parameters
158
-	if ( ! is_numeric( $post_id ) ) {
159
-		return null;
160
-	}
157
+    // Some checks on the parameters
158
+    if ( ! is_numeric( $post_id ) ) {
159
+        return null;
160
+    }
161 161
 
162
-	$type = wl_entity_type_taxonomy_get_type( $post_id );
162
+    $type = wl_entity_type_taxonomy_get_type( $post_id );
163 163
 
164
-	if ( isset( $type['uri'] ) ) {
165
-		return array( $type['uri'] );
166
-	}
164
+    if ( isset( $type['uri'] ) ) {
165
+        return array( $type['uri'] );
166
+    }
167 167
 
168
-	return null;
168
+    return null;
169 169
 }
170 170
 
171 171
 /**
@@ -178,21 +178,21 @@  discard block
 block discarded – undo
178 178
  */
179 179
 function wl_schema_set_types( $post_id, $type_names ) {
180 180
 
181
-	// Some checks on the parameters
182
-	if ( ! is_numeric( $post_id ) || empty( $type_names ) || is_null( $type_names ) ) {
183
-		return null;
184
-	}
181
+    // Some checks on the parameters
182
+    if ( ! is_numeric( $post_id ) || empty( $type_names ) || is_null( $type_names ) ) {
183
+        return null;
184
+    }
185 185
 
186
-	// TODO: support more than one type.
187
-	if ( is_array( $type_names ) ) {
188
-		$type_names = $type_names[0];
189
-	}
186
+    // TODO: support more than one type.
187
+    if ( is_array( $type_names ) ) {
188
+        $type_names = $type_names[0];
189
+    }
190 190
 
191
-	// Get the schema URI (e.g. http://schema.org/Thing)
192
-	$type_names = wl_build_full_schema_uri_from_schema_slug( $type_names );
191
+    // Get the schema URI (e.g. http://schema.org/Thing)
192
+    $type_names = wl_build_full_schema_uri_from_schema_slug( $type_names );
193 193
 
194
-	// Actually sets the taxonomy type
195
-	wl_set_entity_main_type( $post_id, $type_names );
194
+    // Actually sets the taxonomy type
195
+    wl_set_entity_main_type( $post_id, $type_names );
196 196
 
197 197
 }
198 198
 
@@ -208,24 +208,24 @@  discard block
 block discarded – undo
208 208
  */
209 209
 function wl_schema_get_type_properties( $type_name ) {
210 210
 
211
-	// Build full schema uri if necessary
212
-	$type_name = wl_build_full_schema_uri_from_schema_slug( $type_name );
211
+    // Build full schema uri if necessary
212
+    $type_name = wl_build_full_schema_uri_from_schema_slug( $type_name );
213 213
 
214
-	// Get all custom fields
215
-	$all_types_and_fields = wl_entity_taxonomy_get_custom_fields();
214
+    // Get all custom fields
215
+    $all_types_and_fields = wl_entity_taxonomy_get_custom_fields();
216 216
 
217
-	$schema_root_address = 'http://schema.org/';
218
-	$type_properties     = array();
217
+    $schema_root_address = 'http://schema.org/';
218
+    $type_properties     = array();
219 219
 
220
-	// Search for the entity type which has the requested name as uri
221
-	if ( isset( $all_types_and_fields[ $type_name ] ) ) {
222
-		foreach ( $all_types_and_fields[ $type_name ] as $field ) {
223
-			// Convert to schema slug and store in array
224
-			$type_properties[] = str_replace( $schema_root_address, '', $field['predicate'] );
225
-		}
226
-	}
220
+    // Search for the entity type which has the requested name as uri
221
+    if ( isset( $all_types_and_fields[ $type_name ] ) ) {
222
+        foreach ( $all_types_and_fields[ $type_name ] as $field ) {
223
+            // Convert to schema slug and store in array
224
+            $type_properties[] = str_replace( $schema_root_address, '', $field['predicate'] );
225
+        }
226
+    }
227 227
 
228
-	return $type_properties;
228
+    return $type_properties;
229 229
 }
230 230
 
231 231
 /**
@@ -237,11 +237,11 @@  discard block
 block discarded – undo
237 237
  */
238 238
 function wl_build_full_schema_uri_from_schema_slug( $schema_name ) {
239 239
 
240
-	$schema_root_address = 'http://schema.org/';
240
+    $schema_root_address = 'http://schema.org/';
241 241
 
242
-	if ( strpos( $schema_name, $schema_root_address ) === false ) {   // === necessary
243
-		$schema_name = $schema_root_address . $schema_name;
244
-	}
242
+    if ( strpos( $schema_name, $schema_root_address ) === false ) {   // === necessary
243
+        $schema_name = $schema_root_address . $schema_name;
244
+    }
245 245
 
246
-	return $schema_name;
246
+    return $schema_name;
247 247
 }
248 248
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -8,24 +8,24 @@  discard block
 block discarded – undo
8 8
  *
9 9
  * @return boolean The method returns true if everything went ok, false otherwise.
10 10
  */
11
-function wl_schema_reset_value( $post_id, $property_name ) {
11
+function wl_schema_reset_value($post_id, $property_name) {
12 12
 
13 13
 	// Some checks on the parameters
14
-	if ( ! is_numeric( $post_id ) || is_null( $property_name ) ) {
14
+	if ( ! is_numeric($post_id) || is_null($property_name)) {
15 15
 		return false;
16 16
 	}
17 17
 
18 18
 	// Build full schema uri if necessary
19
-	$property_name = wl_build_full_schema_uri_from_schema_slug( $property_name );
19
+	$property_name = wl_build_full_schema_uri_from_schema_slug($property_name);
20 20
 
21 21
 	// Get accepted properties
22
-	$accepted_fields = wl_entity_taxonomy_get_custom_fields( $post_id );
22
+	$accepted_fields = wl_entity_taxonomy_get_custom_fields($post_id);
23 23
 
24 24
 	// Find the name of the custom-field managing the schema property
25
-	foreach ( $accepted_fields as $wl_constant => $field ) {
26
-		if ( $field['predicate'] == $property_name ) {
25
+	foreach ($accepted_fields as $wl_constant => $field) {
26
+		if ($field['predicate'] == $property_name) {
27 27
 
28
-			delete_post_meta( $post_id, $wl_constant );
28
+			delete_post_meta($post_id, $wl_constant);
29 29
 
30 30
 			return true;
31 31
 		}
@@ -42,32 +42,32 @@  discard block
 block discarded – undo
42 42
  *
43 43
  * @return array|null An array of values or NULL in case of no values (or error).
44 44
  */
45
-function wl_schema_get_value( $post_id, $property_name ) {
45
+function wl_schema_get_value($post_id, $property_name) {
46 46
 
47 47
 	// Property name must be defined.
48
-	if ( ! isset( $property_name ) || is_null( $property_name ) ) {
48
+	if ( ! isset($property_name) || is_null($property_name)) {
49 49
 		return null;
50 50
 	}
51 51
 
52 52
 	// store eventual schema name in  different variable
53
-	$property_schema_name = wl_build_full_schema_uri_from_schema_slug( $property_name );
53
+	$property_schema_name = wl_build_full_schema_uri_from_schema_slug($property_name);
54 54
 
55 55
 	// Establish entity id.
56
-	if ( is_null( $post_id ) || ! is_numeric( $post_id ) ) {
56
+	if (is_null($post_id) || ! is_numeric($post_id)) {
57 57
 		$post_id = get_the_ID();
58
-		if ( is_null( $post_id ) || ! is_numeric( $post_id ) ) {
58
+		if (is_null($post_id) || ! is_numeric($post_id)) {
59 59
 			return null;
60 60
 		}
61 61
 	}
62 62
 
63 63
 	// Get custom fields.
64
-	$term_mapping = wl_entity_taxonomy_get_custom_fields( $post_id );
64
+	$term_mapping = wl_entity_taxonomy_get_custom_fields($post_id);
65 65
 	// Search for the required meta value (by constant name or schema name)
66
-	foreach ( $term_mapping as $wl_constant => $property_info ) {
67
-		$found_constant  = ( $wl_constant == $property_name );
68
-		$found_predicate = ( isset( $property_info['predicate'] ) && $property_info['predicate'] == $property_schema_name );
69
-		if ( $found_constant || $found_predicate ) {
70
-			return get_post_meta( $post_id, $wl_constant );
66
+	foreach ($term_mapping as $wl_constant => $property_info) {
67
+		$found_constant  = ($wl_constant == $property_name);
68
+		$found_predicate = (isset($property_info['predicate']) && $property_info['predicate'] == $property_schema_name);
69
+		if ($found_constant || $found_predicate) {
70
+			return get_post_meta($post_id, $wl_constant);
71 71
 		}
72 72
 	}
73 73
 
@@ -83,18 +83,18 @@  discard block
 block discarded – undo
83 83
  *
84 84
  * @return array An array of values or NULL in case of no values (or error).
85 85
  */
86
-function wl_schema_add_value( $post_id, $property_name, $property_value ) {
86
+function wl_schema_add_value($post_id, $property_name, $property_value) {
87 87
 
88
-	if ( ! is_array( $property_value ) ) {
89
-		$property_value = array( $property_value );
88
+	if ( ! is_array($property_value)) {
89
+		$property_value = array($property_value);
90 90
 	}
91 91
 
92 92
 	// Get the old values or set an empty array.
93
-	$old_values = wl_schema_get_value( $post_id, $property_name ) ?: array();
93
+	$old_values = wl_schema_get_value($post_id, $property_name) ?: array();
94 94
 
95
-	$merged_property_value = array_unique( array_merge( $property_value, $old_values ) );
95
+	$merged_property_value = array_unique(array_merge($property_value, $old_values));
96 96
 
97
-	wl_schema_set_value( $post_id, $property_name, $merged_property_value );
97
+	wl_schema_set_value($post_id, $property_name, $merged_property_value);
98 98
 
99 99
 }
100 100
 
@@ -107,33 +107,33 @@  discard block
 block discarded – undo
107 107
  *
108 108
  * @return boolean The method returns true if everything went ok, an error string otherwise.
109 109
  */
110
-function wl_schema_set_value( $post_id, $property_name, $property_value ) {
110
+function wl_schema_set_value($post_id, $property_name, $property_value) {
111 111
 
112 112
 	// Some checks on the parameters
113
-	if ( ! is_numeric( $post_id ) || is_null( $property_name ) || empty( $property_value ) || is_null( $property_value ) ) {
113
+	if ( ! is_numeric($post_id) || is_null($property_name) || empty($property_value) || is_null($property_value)) {
114 114
 		return false;
115 115
 	}
116 116
 
117 117
 	// Build full schema uri if necessary
118
-	$property_name = wl_build_full_schema_uri_from_schema_slug( $property_name );
118
+	$property_name = wl_build_full_schema_uri_from_schema_slug($property_name);
119 119
 
120 120
 	// Get accepted properties
121
-	$accepted_fields = wl_entity_taxonomy_get_custom_fields( $post_id );
121
+	$accepted_fields = wl_entity_taxonomy_get_custom_fields($post_id);
122 122
 
123 123
 	// Find the name of the custom-field managing the schema property
124
-	foreach ( $accepted_fields as $wl_constant => $field ) {
125
-		if ( $field['predicate'] == $property_name ) {
124
+	foreach ($accepted_fields as $wl_constant => $field) {
125
+		if ($field['predicate'] == $property_name) {
126 126
 
127 127
 			// Deal with single values
128
-			if ( ! is_array( $property_value ) ) {
129
-				$property_value = array( $property_value );
128
+			if ( ! is_array($property_value)) {
129
+				$property_value = array($property_value);
130 130
 			}
131 131
 
132 132
 			// Delete present meta
133
-			delete_post_meta( $post_id, $wl_constant );
133
+			delete_post_meta($post_id, $wl_constant);
134 134
 
135
-			foreach ( $property_value as $value ) {
136
-				add_post_meta( $post_id, $wl_constant, $value );
135
+			foreach ($property_value as $value) {
136
+				add_post_meta($post_id, $wl_constant, $value);
137 137
 			}
138 138
 
139 139
 			return true;
@@ -152,17 +152,17 @@  discard block
 block discarded – undo
152 152
  * @return array Array of type(s) (e.g. Type, for the http://schema.org/Type)
153 153
  * or NULL in case of no values (or error).
154 154
  */
155
-function wl_schema_get_types( $post_id ) {
155
+function wl_schema_get_types($post_id) {
156 156
 
157 157
 	// Some checks on the parameters
158
-	if ( ! is_numeric( $post_id ) ) {
158
+	if ( ! is_numeric($post_id)) {
159 159
 		return null;
160 160
 	}
161 161
 
162
-	$type = wl_entity_type_taxonomy_get_type( $post_id );
162
+	$type = wl_entity_type_taxonomy_get_type($post_id);
163 163
 
164
-	if ( isset( $type['uri'] ) ) {
165
-		return array( $type['uri'] );
164
+	if (isset($type['uri'])) {
165
+		return array($type['uri']);
166 166
 	}
167 167
 
168 168
 	return null;
@@ -176,23 +176,23 @@  discard block
 block discarded – undo
176 176
  *
177 177
  * @return boolean True if everything went ok, an error string otherwise.
178 178
  */
179
-function wl_schema_set_types( $post_id, $type_names ) {
179
+function wl_schema_set_types($post_id, $type_names) {
180 180
 
181 181
 	// Some checks on the parameters
182
-	if ( ! is_numeric( $post_id ) || empty( $type_names ) || is_null( $type_names ) ) {
182
+	if ( ! is_numeric($post_id) || empty($type_names) || is_null($type_names)) {
183 183
 		return null;
184 184
 	}
185 185
 
186 186
 	// TODO: support more than one type.
187
-	if ( is_array( $type_names ) ) {
187
+	if (is_array($type_names)) {
188 188
 		$type_names = $type_names[0];
189 189
 	}
190 190
 
191 191
 	// Get the schema URI (e.g. http://schema.org/Thing)
192
-	$type_names = wl_build_full_schema_uri_from_schema_slug( $type_names );
192
+	$type_names = wl_build_full_schema_uri_from_schema_slug($type_names);
193 193
 
194 194
 	// Actually sets the taxonomy type
195
-	wl_set_entity_main_type( $post_id, $type_names );
195
+	wl_set_entity_main_type($post_id, $type_names);
196 196
 
197 197
 }
198 198
 
@@ -206,10 +206,10 @@  discard block
 block discarded – undo
206 206
  * @return array The method returns an array of supported properties for the type, e.g. (‘startDate’, ‘endDate’) for an Event.
207 207
  * You can call wl_schema_get_property_expected_type on each to know which data type they expect.
208 208
  */
209
-function wl_schema_get_type_properties( $type_name ) {
209
+function wl_schema_get_type_properties($type_name) {
210 210
 
211 211
 	// Build full schema uri if necessary
212
-	$type_name = wl_build_full_schema_uri_from_schema_slug( $type_name );
212
+	$type_name = wl_build_full_schema_uri_from_schema_slug($type_name);
213 213
 
214 214
 	// Get all custom fields
215 215
 	$all_types_and_fields = wl_entity_taxonomy_get_custom_fields();
@@ -218,10 +218,10 @@  discard block
 block discarded – undo
218 218
 	$type_properties     = array();
219 219
 
220 220
 	// Search for the entity type which has the requested name as uri
221
-	if ( isset( $all_types_and_fields[ $type_name ] ) ) {
222
-		foreach ( $all_types_and_fields[ $type_name ] as $field ) {
221
+	if (isset($all_types_and_fields[$type_name])) {
222
+		foreach ($all_types_and_fields[$type_name] as $field) {
223 223
 			// Convert to schema slug and store in array
224
-			$type_properties[] = str_replace( $schema_root_address, '', $field['predicate'] );
224
+			$type_properties[] = str_replace($schema_root_address, '', $field['predicate']);
225 225
 		}
226 226
 	}
227 227
 
@@ -235,12 +235,12 @@  discard block
 block discarded – undo
235 235
  *
236 236
  * @return string The full schema uri (es. 'latitude' returns 'http://schema.org/latitude')
237 237
  */
238
-function wl_build_full_schema_uri_from_schema_slug( $schema_name ) {
238
+function wl_build_full_schema_uri_from_schema_slug($schema_name) {
239 239
 
240 240
 	$schema_root_address = 'http://schema.org/';
241 241
 
242
-	if ( strpos( $schema_name, $schema_root_address ) === false ) {   // === necessary
243
-		$schema_name = $schema_root_address . $schema_name;
242
+	if (strpos($schema_name, $schema_root_address) === false) {   // === necessary
243
+		$schema_name = $schema_root_address.$schema_name;
244 244
 	}
245 245
 
246 246
 	return $schema_name;
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   +242 added lines, -242 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.
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
  */
50 50
 function wl_write_log( $log ) {
51 51
 
52
-	Wordlift_Log_Service::get_instance()->info( $log );
52
+    Wordlift_Log_Service::get_instance()->info( $log );
53 53
 
54 54
 //	$handler = apply_filters( 'wl_write_log_handler', null );
55 55
 //
@@ -77,20 +77,20 @@  discard block
 block discarded – undo
77 77
  */
78 78
 function wl_write_log_handler( $log, $caller = null ) {
79 79
 
80
-	global $wl_logger;
80
+    global $wl_logger;
81 81
 
82
-	if ( true === WP_DEBUG ) {
82
+    if ( true === WP_DEBUG ) {
83 83
 
84
-		$message = ( isset( $caller ) ? sprintf( '[%-40.40s] ', $caller ) : '' ) .
85
-		           ( is_array( $log ) || is_object( $log ) ? print_r( $log, true ) : wl_write_log_hide_key( $log ) );
84
+        $message = ( isset( $caller ) ? sprintf( '[%-40.40s] ', $caller ) : '' ) .
85
+                    ( is_array( $log ) || is_object( $log ) ? print_r( $log, true ) : wl_write_log_hide_key( $log ) );
86 86
 
87
-		if ( isset( $wl_logger ) ) {
88
-			$wl_logger->info( $message );
89
-		} else {
90
-			error_log( $message );
91
-		}
87
+        if ( isset( $wl_logger ) ) {
88
+            $wl_logger->info( $message );
89
+        } else {
90
+            error_log( $message );
91
+        }
92 92
 
93
-	}
93
+    }
94 94
 
95 95
 }
96 96
 
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
  */
108 108
 function wl_write_log_hide_key( $text ) {
109 109
 
110
-	return str_ireplace( wl_configuration_get_key(), '<hidden>', $text );
110
+    return str_ireplace( wl_configuration_get_key(), '<hidden>', $text );
111 111
 }
112 112
 
113 113
 /**
@@ -119,10 +119,10 @@  discard block
 block discarded – undo
119 119
  */
120 120
 function wl_queue_sparql_update_query( $query ) {
121 121
 
122
-	$filename = WL_TEMP_DIR . WL_REQUEST_ID . '.sparql';
123
-	file_put_contents( $filename, $query . "\n", FILE_APPEND );
122
+    $filename = WL_TEMP_DIR . WL_REQUEST_ID . '.sparql';
123
+    file_put_contents( $filename, $query . "\n", FILE_APPEND );
124 124
 
125
-	wl_write_log( "wl_queue_sparql_update_query [ filename :: $filename ]" );
125
+    wl_write_log( "wl_queue_sparql_update_query [ filename :: $filename ]" );
126 126
 }
127 127
 
128 128
 /**
@@ -132,28 +132,28 @@  discard block
 block discarded – undo
132 132
  */
133 133
 function wl_execute_saved_sparql_update_query( $request_id ) {
134 134
 
135
-	$filename = WL_TEMP_DIR . $request_id . '.sparql';
135
+    $filename = WL_TEMP_DIR . $request_id . '.sparql';
136 136
 
137
-	// If the file doesn't exist, exit.
138
-	if ( ! file_exists( $filename ) ) {
139
-		wl_write_log( "wl_execute_saved_sparql_update_query : file doesn't exist [ filename :: $filename ]" );
137
+    // If the file doesn't exist, exit.
138
+    if ( ! file_exists( $filename ) ) {
139
+        wl_write_log( "wl_execute_saved_sparql_update_query : file doesn't exist [ filename :: $filename ]" );
140 140
 
141
-		return;
142
-	}
141
+        return;
142
+    }
143 143
 
144
-	wl_write_log( "wl_execute_saved_sparql_update_query [ filename :: $filename ]" );
144
+    wl_write_log( "wl_execute_saved_sparql_update_query [ filename :: $filename ]" );
145 145
 
146
-	// Get the query saved in the file.
147
-	$query = file_get_contents( $filename );
146
+    // Get the query saved in the file.
147
+    $query = file_get_contents( $filename );
148 148
 
149
-	// Execute the SPARQL query.
150
-	rl_execute_sparql_update_query( $query, false );
149
+    // Execute the SPARQL query.
150
+    rl_execute_sparql_update_query( $query, false );
151 151
 
152
-	// Reindex the triple store.
153
-	wordlift_reindex_triple_store();
152
+    // Reindex the triple store.
153
+    wordlift_reindex_triple_store();
154 154
 
155
-	// Delete the temporary file.
156
-	unlink( $filename );
155
+    // Delete the temporary file.
156
+    unlink( $filename );
157 157
 }
158 158
 
159 159
 add_action( 'wl_execute_saved_sparql_update_query', 'wl_execute_saved_sparql_update_query', 10, 1 );
@@ -163,10 +163,10 @@  discard block
 block discarded – undo
163 163
  */
164 164
 function wordlift_buttonhooks() {
165 165
 
166
-	// Only add hooks when the current user has permissions AND is in Rich Text editor mode
167
-	if ( ( current_user_can( 'edit_posts' ) || current_user_can( 'edit_pages' ) ) && get_user_option( 'rich_editing' ) ) {
168
-		add_filter( 'mce_external_plugins', 'wordlift_register_tinymce_javascript' );
169
-	}
166
+    // Only add hooks when the current user has permissions AND is in Rich Text editor mode
167
+    if ( ( current_user_can( 'edit_posts' ) || current_user_can( 'edit_pages' ) ) && get_user_option( 'rich_editing' ) ) {
168
+        add_filter( 'mce_external_plugins', 'wordlift_register_tinymce_javascript' );
169
+    }
170 170
 }
171 171
 
172 172
 /**
@@ -178,11 +178,11 @@  discard block
 block discarded – undo
178 178
  */
179 179
 function wordlift_register_tinymce_javascript( $plugin_array ) {
180 180
 
181
-	// add the wordlift plugin.
182
-	// We can't use the minified version here.
183
-	$plugin_array['wordlift'] = plugin_dir_url( __FILE__ ) . 'js/wordlift-reloaded.js';
181
+    // add the wordlift plugin.
182
+    // We can't use the minified version here.
183
+    $plugin_array['wordlift'] = plugin_dir_url( __FILE__ ) . 'js/wordlift-reloaded.js';
184 184
 
185
-	return $plugin_array;
185
+    return $plugin_array;
186 186
 }
187 187
 
188 188
 /**
@@ -190,21 +190,21 @@  discard block
 block discarded – undo
190 190
  * see http://vip.wordpress.com/documentation/register-additional-html-attributes-for-tinymce-and-wp-kses/
191 191
  */
192 192
 function wordlift_allowed_post_tags() {
193
-	global $allowedposttags;
194
-
195
-	$tags           = array( 'span' );
196
-	$new_attributes = array(
197
-		'itemscope' => array(),
198
-		'itemtype'  => array(),
199
-		'itemprop'  => array(),
200
-		'itemid'    => array(),
201
-	);
202
-
203
-	foreach ( $tags as $tag ) {
204
-		if ( isset( $allowedposttags[ $tag ] ) && is_array( $allowedposttags[ $tag ] ) ) {
205
-			$allowedposttags[ $tag ] = array_merge( $allowedposttags[ $tag ], $new_attributes );
206
-		}
207
-	}
193
+    global $allowedposttags;
194
+
195
+    $tags           = array( 'span' );
196
+    $new_attributes = array(
197
+        'itemscope' => array(),
198
+        'itemtype'  => array(),
199
+        'itemprop'  => array(),
200
+        'itemid'    => array(),
201
+    );
202
+
203
+    foreach ( $tags as $tag ) {
204
+        if ( isset( $allowedposttags[ $tag ] ) && is_array( $allowedposttags[ $tag ] ) ) {
205
+            $allowedposttags[ $tag ] = array_merge( $allowedposttags[ $tag ], $new_attributes );
206
+        }
207
+    }
208 208
 }
209 209
 
210 210
 // init process for button control
@@ -218,28 +218,28 @@  discard block
 block discarded – undo
218 218
  */
219 219
 function wordlift_admin_enqueue_scripts() {
220 220
 
221
-	// Added for compatibility with WordPress 3.9 (see http://make.wordpress.org/core/2014/04/16/jquery-ui-and-wpdialogs-in-wordpress-3-9/)
222
-	wp_enqueue_script( 'wpdialogs' );
223
-	wp_enqueue_style( 'wp-jquery-ui-dialog' );
221
+    // Added for compatibility with WordPress 3.9 (see http://make.wordpress.org/core/2014/04/16/jquery-ui-and-wpdialogs-in-wordpress-3-9/)
222
+    wp_enqueue_script( 'wpdialogs' );
223
+    wp_enqueue_style( 'wp-jquery-ui-dialog' );
224 224
 
225
-	wp_enqueue_style( 'wordlift-reloaded', plugin_dir_url( __FILE__ ) . 'css/wordlift-reloaded.min.css' );
225
+    wp_enqueue_style( 'wordlift-reloaded', plugin_dir_url( __FILE__ ) . 'css/wordlift-reloaded.min.css' );
226 226
 
227
-	wp_enqueue_script( 'jquery-ui-autocomplete' );
228
-	wp_enqueue_script( 'angularjs', 'https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.11/angular.min.js' );
229
-	wp_enqueue_script( 'angularjs-geolocation', plugin_dir_url( __FILE__ ) . '/bower_components/angularjs-geolocation/dist/angularjs-geolocation.min.js' );
230
-	wp_enqueue_script( 'angularjs-touch', 'https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.11/angular-touch.min.js' );
231
-	wp_enqueue_script( 'angularjs-animate', 'https://code.angularjs.org/1.3.11/angular-animate.min.js' );
227
+    wp_enqueue_script( 'jquery-ui-autocomplete' );
228
+    wp_enqueue_script( 'angularjs', 'https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.11/angular.min.js' );
229
+    wp_enqueue_script( 'angularjs-geolocation', plugin_dir_url( __FILE__ ) . '/bower_components/angularjs-geolocation/dist/angularjs-geolocation.min.js' );
230
+    wp_enqueue_script( 'angularjs-touch', 'https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.11/angular-touch.min.js' );
231
+    wp_enqueue_script( 'angularjs-animate', 'https://code.angularjs.org/1.3.11/angular-animate.min.js' );
232 232
 
233
-	// Disable auto-save for custom entity posts only
234
-	if ( Wordlift_Entity_Service::TYPE_NAME === get_post_type() ) {
235
-		wp_dequeue_script( 'autosave' );
236
-	}
233
+    // Disable auto-save for custom entity posts only
234
+    if ( Wordlift_Entity_Service::TYPE_NAME === get_post_type() ) {
235
+        wp_dequeue_script( 'autosave' );
236
+    }
237 237
 }
238 238
 
239 239
 add_action( 'admin_enqueue_scripts', 'wordlift_admin_enqueue_scripts' );
240 240
 
241 241
 function wl_enqueue_scripts() {
242
-	wp_enqueue_style( 'wordlift-ui', plugin_dir_url( __FILE__ ) . 'css/wordlift-ui.min.css' );
242
+    wp_enqueue_style( 'wordlift-ui', plugin_dir_url( __FILE__ ) . 'css/wordlift-ui.min.css' );
243 243
 }
244 244
 
245 245
 add_action( 'wp_enqueue_scripts', 'wl_enqueue_scripts' );
@@ -254,18 +254,18 @@  discard block
 block discarded – undo
254 254
  */
255 255
 function wordlift_allowed_html( $allowedtags, $context ) {
256 256
 
257
-	if ( 'post' !== $context ) {
258
-		return $allowedtags;
259
-	}
260
-
261
-	return array_merge_recursive( $allowedtags, array(
262
-		'span' => array(
263
-			'itemscope' => true,
264
-			'itemtype'  => true,
265
-			'itemid'    => true,
266
-			'itemprop'  => true,
267
-		),
268
-	) );
257
+    if ( 'post' !== $context ) {
258
+        return $allowedtags;
259
+    }
260
+
261
+    return array_merge_recursive( $allowedtags, array(
262
+        'span' => array(
263
+            'itemscope' => true,
264
+            'itemtype'  => true,
265
+            'itemid'    => true,
266
+            'itemprop'  => true,
267
+        ),
268
+    ) );
269 269
 }
270 270
 
271 271
 add_filter( 'wp_kses_allowed_html', 'wordlift_allowed_html', 10, 2 );
@@ -279,15 +279,15 @@  discard block
 block discarded – undo
279 279
  */
280 280
 function wl_get_coordinates( $post_id ) {
281 281
 
282
-	$latitude  = wl_schema_get_value( $post_id, 'latitude' );
283
-	$longitude = wl_schema_get_value( $post_id, 'longitude' );
282
+    $latitude  = wl_schema_get_value( $post_id, 'latitude' );
283
+    $longitude = wl_schema_get_value( $post_id, 'longitude' );
284 284
 
285
-	// DO NOT set latitude/longitude to 0/0 as default values. It's a specific place on the globe:
286
-	// "The zero/zero point of this system is located in the Gulf of Guinea about 625 km (390 mi) south of Tema, Ghana."
287
-	return array(
288
-		'latitude'  => isset( $latitude[0] ) && is_numeric( $latitude[0] ) ? $latitude[0] : '',
289
-		'longitude' => isset( $longitude[0] ) && is_numeric( $longitude[0] ) ? $longitude[0] : '',
290
-	);
285
+    // DO NOT set latitude/longitude to 0/0 as default values. It's a specific place on the globe:
286
+    // "The zero/zero point of this system is located in the Gulf of Guinea about 625 km (390 mi) south of Tema, Ghana."
287
+    return array(
288
+        'latitude'  => isset( $latitude[0] ) && is_numeric( $latitude[0] ) ? $latitude[0] : '',
289
+        'longitude' => isset( $longitude[0] ) && is_numeric( $longitude[0] ) ? $longitude[0] : '',
290
+    );
291 291
 }
292 292
 
293 293
 /**
@@ -299,13 +299,13 @@  discard block
 block discarded – undo
299 299
  */
300 300
 function wl_get_post_modified_time( $post ) {
301 301
 
302
-	$date_modified = get_post_modified_time( 'c', true, $post );
302
+    $date_modified = get_post_modified_time( 'c', true, $post );
303 303
 
304
-	if ( '-' === substr( $date_modified, 0, 1 ) ) {
305
-		return get_the_time( 'c', $post );
306
-	}
304
+    if ( '-' === substr( $date_modified, 0, 1 ) ) {
305
+        return get_the_time( 'c', $post );
306
+    }
307 307
 
308
-	return $date_modified;
308
+    return $date_modified;
309 309
 }
310 310
 
311 311
 /**
@@ -318,42 +318,42 @@  discard block
 block discarded – undo
318 318
 function wl_get_image_urls( $post_id ) {
319 319
 
320 320
 
321
-	// If there is a featured image it has the priority
322
-	$featured_image_id = get_post_thumbnail_id( $post_id );
323
-	if ( is_numeric( $featured_image_id ) ) {
324
-		$image_url = wp_get_attachment_url( $featured_image_id );
321
+    // If there is a featured image it has the priority
322
+    $featured_image_id = get_post_thumbnail_id( $post_id );
323
+    if ( is_numeric( $featured_image_id ) ) {
324
+        $image_url = wp_get_attachment_url( $featured_image_id );
325 325
 
326
-		return array( $image_url );
327
-	}
326
+        return array( $image_url );
327
+    }
328 328
 
329
-	// wl_write_log( "wl_get_image_urls [ post id :: $post_id ]" );
329
+    // wl_write_log( "wl_get_image_urls [ post id :: $post_id ]" );
330 330
 
331
-	$images = get_children( array(
332
-		'post_parent'    => $post_id,
333
-		'post_type'      => 'attachment',
334
-		'post_mime_type' => 'image',
335
-	) );
331
+    $images = get_children( array(
332
+        'post_parent'    => $post_id,
333
+        'post_type'      => 'attachment',
334
+        'post_mime_type' => 'image',
335
+    ) );
336 336
 
337
-	// Return an empty array if no image is found.
338
-	if ( empty( $images ) ) {
339
-		return array();
340
-	}
337
+    // Return an empty array if no image is found.
338
+    if ( empty( $images ) ) {
339
+        return array();
340
+    }
341 341
 
342
-	// Prepare the return array.
343
-	$image_urls = array();
342
+    // Prepare the return array.
343
+    $image_urls = array();
344 344
 
345
-	// Collect the URLs.
346
-	foreach ( $images as $attachment_id => $attachment ) {
347
-		$image_url = wp_get_attachment_url( $attachment_id );
348
-		// Ensure the URL isn't collected already.
349
-		if ( ! in_array( $image_url, $image_urls ) ) {
350
-			array_push( $image_urls, $image_url );
351
-		}
352
-	}
345
+    // Collect the URLs.
346
+    foreach ( $images as $attachment_id => $attachment ) {
347
+        $image_url = wp_get_attachment_url( $attachment_id );
348
+        // Ensure the URL isn't collected already.
349
+        if ( ! in_array( $image_url, $image_urls ) ) {
350
+            array_push( $image_urls, $image_url );
351
+        }
352
+    }
353 353
 
354
-	// wl_write_log( "wl_get_image_urls [ post id :: $post_id ][ image urls count :: " . count( $image_urls ) . " ]" );
354
+    // wl_write_log( "wl_get_image_urls [ post id :: $post_id ][ image urls count :: " . count( $image_urls ) . " ]" );
355 355
 
356
-	return $image_urls;
356
+    return $image_urls;
357 357
 }
358 358
 
359 359
 /**
@@ -366,19 +366,19 @@  discard block
 block discarded – undo
366 366
  */
367 367
 function wl_get_sparql_images( $uri, $post_id ) {
368 368
 
369
-	$sparql = '';
369
+    $sparql = '';
370 370
 
371
-	// Get the escaped URI.
372
-	$uri_e = esc_html( $uri );
371
+    // Get the escaped URI.
372
+    $uri_e = esc_html( $uri );
373 373
 
374
-	// Add SPARQL stmts to write the schema:image.
375
-	$image_urls = wl_get_image_urls( $post_id );
376
-	foreach ( $image_urls as $image_url ) {
377
-		$image_url_esc = wl_sparql_escape_uri( $image_url );
378
-		$sparql .= " <$uri_e> schema:image <$image_url_esc> . \n";
379
-	}
374
+    // Add SPARQL stmts to write the schema:image.
375
+    $image_urls = wl_get_image_urls( $post_id );
376
+    foreach ( $image_urls as $image_url ) {
377
+        $image_url_esc = wl_sparql_escape_uri( $image_url );
378
+        $sparql .= " <$uri_e> schema:image <$image_url_esc> . \n";
379
+    }
380 380
 
381
-	return $sparql;
381
+    return $sparql;
382 382
 }
383 383
 
384 384
 /**
@@ -391,24 +391,24 @@  discard block
 block discarded – undo
391 391
  */
392 392
 function wl_get_attachment_for_source_url( $parent_post_id, $source_url ) {
393 393
 
394
-	// wl_write_log( "wl_get_attachment_for_source_url [ parent post id :: $parent_post_id ][ source url :: $source_url ]" );
394
+    // wl_write_log( "wl_get_attachment_for_source_url [ parent post id :: $parent_post_id ][ source url :: $source_url ]" );
395 395
 
396
-	$posts = get_posts( array(
397
-		'post_type'      => 'attachment',
398
-		'posts_per_page' => 1,
399
-		'post_status'    => 'any',
400
-		'post_parent'    => $parent_post_id,
401
-		'meta_key'       => 'wl_source_url',
402
-		'meta_value'     => $source_url,
403
-	) );
396
+    $posts = get_posts( array(
397
+        'post_type'      => 'attachment',
398
+        'posts_per_page' => 1,
399
+        'post_status'    => 'any',
400
+        'post_parent'    => $parent_post_id,
401
+        'meta_key'       => 'wl_source_url',
402
+        'meta_value'     => $source_url,
403
+    ) );
404 404
 
405
-	// Return the found post.
406
-	if ( 1 === count( $posts ) ) {
407
-		return $posts[0];
408
-	}
405
+    // Return the found post.
406
+    if ( 1 === count( $posts ) ) {
407
+        return $posts[0];
408
+    }
409 409
 
410
-	// Return null.
411
-	return null;
410
+    // Return null.
411
+    return null;
412 412
 }
413 413
 
414 414
 /**
@@ -419,8 +419,8 @@  discard block
 block discarded – undo
419 419
  */
420 420
 function wl_set_source_url( $post_id, $source_url ) {
421 421
 
422
-	delete_post_meta( $post_id, 'wl_source_url' );
423
-	add_post_meta( $post_id, 'wl_source_url', $source_url );
422
+    delete_post_meta( $post_id, 'wl_source_url' );
423
+    add_post_meta( $post_id, 'wl_source_url', $source_url );
424 424
 }
425 425
 
426 426
 
@@ -438,61 +438,61 @@  discard block
 block discarded – undo
438 438
  */
439 439
 function wl_flush_rewrite_rules_hard( $hard ) {
440 440
 
441
-	// If WL is not yet configured, we cannot perform any update, so we exit.
442
-	if ( '' === wl_configuration_get_key() ) {
443
-		return;
444
-	}
441
+    // If WL is not yet configured, we cannot perform any update, so we exit.
442
+    if ( '' === wl_configuration_get_key() ) {
443
+        return;
444
+    }
445 445
 
446
-	// Set the initial offset and limit each call to 100 posts to avoid memory errors.
447
-	$offset = 0;
448
-	$limit  = 100;
446
+    // Set the initial offset and limit each call to 100 posts to avoid memory errors.
447
+    $offset = 0;
448
+    $limit  = 100;
449 449
 
450
-	// Get more posts if the number of returned posts matches the limit.
451
-	while ( $limit === ( $posts = get_posts( array(
452
-			'offset'      => $offset,
453
-			'numberposts' => $limit,
454
-			'orderby'     => 'ID',
455
-			'post_type'   => 'any',
456
-			'post_status' => 'publish',
457
-		) ) ) ) {
450
+    // Get more posts if the number of returned posts matches the limit.
451
+    while ( $limit === ( $posts = get_posts( array(
452
+            'offset'      => $offset,
453
+            'numberposts' => $limit,
454
+            'orderby'     => 'ID',
455
+            'post_type'   => 'any',
456
+            'post_status' => 'publish',
457
+        ) ) ) ) {
458 458
 
459
-		// Holds the delete part of the query.
460
-		$delete_query = rl_sparql_prefixes();
459
+        // Holds the delete part of the query.
460
+        $delete_query = rl_sparql_prefixes();
461 461
 
462
-		// Holds the insert part of the query.
463
-		$insert_query = '';
462
+        // Holds the insert part of the query.
463
+        $insert_query = '';
464 464
 
465
-		// Cycle in each post to build the query.
466
-		foreach ( $posts as $post ) {
465
+        // Cycle in each post to build the query.
466
+        foreach ( $posts as $post ) {
467 467
 
468
-			// Ignore revisions.
469
-			if ( wp_is_post_revision( $post->ID ) ) {
470
-				continue;
471
-			}
468
+            // Ignore revisions.
469
+            if ( wp_is_post_revision( $post->ID ) ) {
470
+                continue;
471
+            }
472 472
 
473
-			// Get the entity URI.
474
-			$s = Wordlift_Sparql_Service::escape_uri( Wordlift_Entity_Service::get_instance()
475
-			                                                                 ->get_uri( $post->ID ) );
473
+            // Get the entity URI.
474
+            $s = Wordlift_Sparql_Service::escape_uri( Wordlift_Entity_Service::get_instance()
475
+                                                                                ->get_uri( $post->ID ) );
476 476
 
477
-			// Get the post URL.
478
-			// $url = wl_sparql_escape_uri( get_permalink( $post->ID ) );
477
+            // Get the post URL.
478
+            // $url = wl_sparql_escape_uri( get_permalink( $post->ID ) );
479 479
 
480
-			// Prepare the DELETE and INSERT commands.
481
-			$delete_query .= "DELETE { <$s> schema:url ?u . } WHERE  { <$s> schema:url ?u . };\n";
480
+            // Prepare the DELETE and INSERT commands.
481
+            $delete_query .= "DELETE { <$s> schema:url ?u . } WHERE  { <$s> schema:url ?u . };\n";
482 482
 
483
-			$insert_query .= Wordlift_Schema_Url_Property_Service::get_instance()
484
-			                                                     ->get_insert_query( $s, $post->ID );
483
+            $insert_query .= Wordlift_Schema_Url_Property_Service::get_instance()
484
+                                                                    ->get_insert_query( $s, $post->ID );
485 485
 
486
-		}
486
+        }
487 487
 
488 488
 
489
-		// Execute the query.
490
-		rl_execute_sparql_update_query( $delete_query . $insert_query );
489
+        // Execute the query.
490
+        rl_execute_sparql_update_query( $delete_query . $insert_query );
491 491
 
492
-		// Advance to the next posts.
493
-		$offset += $limit;
492
+        // Advance to the next posts.
493
+        $offset += $limit;
494 494
 
495
-	}
495
+    }
496 496
 
497 497
 //	// Get all published posts.
498 498
 //	$posts = get_posts( array(
@@ -518,7 +518,7 @@  discard block
 block discarded – undo
518 518
  */
519 519
 function wl_sanitize_uri_path( $path, $char = '_' ) {
520 520
 
521
-	return Wordlift_Uri_Service::get_instance()->sanitize_path( $path, $char );
521
+    return Wordlift_Uri_Service::get_instance()->sanitize_path( $path, $char );
522 522
 }
523 523
 
524 524
 /**
@@ -530,11 +530,11 @@  discard block
 block discarded – undo
530 530
  */
531 531
 function wl_force_to_array( $value ) {
532 532
 
533
-	if ( ! is_array( $value ) ) {
534
-		return array( $value );
535
-	}
533
+    if ( ! is_array( $value ) ) {
534
+        return array( $value );
535
+    }
536 536
 
537
-	return $value;
537
+    return $value;
538 538
 }
539 539
 
540 540
 /**
@@ -542,26 +542,26 @@  discard block
 block discarded – undo
542 542
  */
543 543
 function wl_shutdown() {
544 544
 
545
-	// Get the filename to the temporary SPARQL file.
546
-	$filename = WL_TEMP_DIR . WL_REQUEST_ID . '.sparql';
545
+    // Get the filename to the temporary SPARQL file.
546
+    $filename = WL_TEMP_DIR . WL_REQUEST_ID . '.sparql';
547 547
 
548
-	// If WordLift is buffering SPARQL queries, we're admins and a buffer exists, then schedule it.
549
-	if ( WL_ENABLE_SPARQL_UPDATE_QUERIES_BUFFERING && is_admin() && file_exists( $filename ) ) {
548
+    // If WordLift is buffering SPARQL queries, we're admins and a buffer exists, then schedule it.
549
+    if ( WL_ENABLE_SPARQL_UPDATE_QUERIES_BUFFERING && is_admin() && file_exists( $filename ) ) {
550 550
 
551
-		// The request ID.
552
-		$args = array( WL_REQUEST_ID );
551
+        // The request ID.
552
+        $args = array( WL_REQUEST_ID );
553 553
 
554
-		// Schedule the execution of the SPARQL query with the request ID.
555
-		wp_schedule_single_event( time(), 'wl_execute_saved_sparql_update_query', $args );
554
+        // Schedule the execution of the SPARQL query with the request ID.
555
+        wp_schedule_single_event( time(), 'wl_execute_saved_sparql_update_query', $args );
556 556
 
557
-		// Check that the request is scheduled.
558
-		$timestamp = wp_next_scheduled( 'wl_execute_saved_sparql_update_query', $args );
557
+        // Check that the request is scheduled.
558
+        $timestamp = wp_next_scheduled( 'wl_execute_saved_sparql_update_query', $args );
559 559
 
560
-		// Spawn the cron.
561
-		spawn_cron();
560
+        // Spawn the cron.
561
+        spawn_cron();
562 562
 
563
-		wl_write_log( "wl_shutdown [ request id :: " . WL_REQUEST_ID . " ][ timestamp :: $timestamp ]" );
564
-	}
563
+        wl_write_log( "wl_shutdown [ request id :: " . WL_REQUEST_ID . " ][ timestamp :: $timestamp ]" );
564
+    }
565 565
 }
566 566
 
567 567
 add_action( 'shutdown', 'wl_shutdown' );
@@ -575,46 +575,46 @@  discard block
 block discarded – undo
575 575
  */
576 576
 function wl_replace_item_id_with_uri( $content ) {
577 577
 
578
-	// wl_write_log( "wl_replace_item_id_with_uri" );
578
+    // wl_write_log( "wl_replace_item_id_with_uri" );
579 579
 
580
-	// Strip slashes, see https://core.trac.wordpress.org/ticket/21767
581
-	$content = stripslashes( $content );
580
+    // Strip slashes, see https://core.trac.wordpress.org/ticket/21767
581
+    $content = stripslashes( $content );
582 582
 
583
-	// If any match are found.
584
-	$matches = array();
585
-	if ( 0 < preg_match_all( '/ itemid="([^"]+)"/i', $content, $matches, PREG_SET_ORDER ) ) {
583
+    // If any match are found.
584
+    $matches = array();
585
+    if ( 0 < preg_match_all( '/ itemid="([^"]+)"/i', $content, $matches, PREG_SET_ORDER ) ) {
586 586
 
587
-		foreach ( $matches as $match ) {
587
+        foreach ( $matches as $match ) {
588 588
 
589
-			// Get the item ID.
590
-			$item_id = $match[1];
589
+            // Get the item ID.
590
+            $item_id = $match[1];
591 591
 
592
-			// Get the post bound to that item ID (looking both in the 'official' URI and in the 'same-as' .
593
-			$post = Wordlift_Entity_Service::get_instance()
594
-			                               ->get_entity_post_by_uri( $item_id );
592
+            // Get the post bound to that item ID (looking both in the 'official' URI and in the 'same-as' .
593
+            $post = Wordlift_Entity_Service::get_instance()
594
+                                            ->get_entity_post_by_uri( $item_id );
595 595
 
596
-			// If no entity is found, continue to the next one.
597
-			if ( null === $post ) {
598
-				continue;
599
-			}
596
+            // If no entity is found, continue to the next one.
597
+            if ( null === $post ) {
598
+                continue;
599
+            }
600 600
 
601
-			// Get the URI for that post.
602
-			$uri = wl_get_entity_uri( $post->ID );
601
+            // Get the URI for that post.
602
+            $uri = wl_get_entity_uri( $post->ID );
603 603
 
604
-			// wl_write_log( "wl_replace_item_id_with_uri [ item id :: $item_id ][ uri :: $uri ]" );
604
+            // wl_write_log( "wl_replace_item_id_with_uri [ item id :: $item_id ][ uri :: $uri ]" );
605 605
 
606
-			// If the item ID and the URI differ, replace the item ID with the URI saved in WordPress.
607
-			if ( $item_id !== $uri ) {
608
-				$uri_e   = esc_html( $uri );
609
-				$content = str_replace( " itemid=\"$item_id\"", " itemid=\"$uri_e\"", $content );
610
-			}
611
-		}
612
-	}
606
+            // If the item ID and the URI differ, replace the item ID with the URI saved in WordPress.
607
+            if ( $item_id !== $uri ) {
608
+                $uri_e   = esc_html( $uri );
609
+                $content = str_replace( " itemid=\"$item_id\"", " itemid=\"$uri_e\"", $content );
610
+            }
611
+        }
612
+    }
613 613
 
614
-	// Reapply slashes.
615
-	$content = addslashes( $content );
614
+    // Reapply slashes.
615
+    $content = addslashes( $content );
616 616
 
617
-	return $content;
617
+    return $content;
618 618
 }
619 619
 
620 620
 add_filter( 'content_save_pre', 'wl_replace_item_id_with_uri', 1, 1 );
@@ -685,8 +685,8 @@  discard block
 block discarded – undo
685 685
  * This action is documented in includes/class-wordlift-activator.php
686 686
  */
687 687
 function activate_wordlift() {
688
-	require_once plugin_dir_path( __FILE__ ) . 'includes/class-wordlift-activator.php';
689
-	Wordlift_Activator::activate();
688
+    require_once plugin_dir_path( __FILE__ ) . 'includes/class-wordlift-activator.php';
689
+    Wordlift_Activator::activate();
690 690
 }
691 691
 
692 692
 /**
@@ -694,8 +694,8 @@  discard block
 block discarded – undo
694 694
  * This action is documented in includes/class-wordlift-deactivator.php
695 695
  */
696 696
 function deactivate_wordlift() {
697
-	require_once plugin_dir_path( __FILE__ ) . 'includes/class-wordlift-deactivator.php';
698
-	Wordlift_Deactivator::deactivate();
697
+    require_once plugin_dir_path( __FILE__ ) . 'includes/class-wordlift-deactivator.php';
698
+    Wordlift_Deactivator::deactivate();
699 699
 }
700 700
 
701 701
 register_activation_hook( __FILE__, 'activate_wordlift' );
@@ -718,8 +718,8 @@  discard block
 block discarded – undo
718 718
  */
719 719
 function run_wordlift() {
720 720
 
721
-	$plugin = new Wordlift();
722
-	$plugin->run();
721
+    $plugin = new Wordlift();
722
+    $plugin->run();
723 723
 
724 724
 }
725 725
 
Please login to merge, or discard this patch.
Spacing   +157 added lines, -157 removed lines patch added patch discarded remove patch
@@ -25,16 +25,16 @@  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' );
37
-require_once( 'modules/configuration/wordlift_configuration.php' );
36
+require_once('modules/core/wordlift_core.php');
37
+require_once('modules/configuration/wordlift_configuration.php');
38 38
 
39 39
 /**
40 40
  * Log to the debug.log file.
@@ -47,9 +47,9 @@  discard block
 block discarded – undo
47 47
  *
48 48
  * @param string|mixed $log The log data.
49 49
  */
50
-function wl_write_log( $log ) {
50
+function wl_write_log($log) {
51 51
 
52
-	Wordlift_Log_Service::get_instance()->info( $log );
52
+	Wordlift_Log_Service::get_instance()->info($log);
53 53
 
54 54
 //	$handler = apply_filters( 'wl_write_log_handler', null );
55 55
 //
@@ -75,19 +75,19 @@  discard block
 block discarded – undo
75 75
  * @param string|array $log    The log data.
76 76
  * @param string       $caller The calling function.
77 77
  */
78
-function wl_write_log_handler( $log, $caller = null ) {
78
+function wl_write_log_handler($log, $caller = null) {
79 79
 
80 80
 	global $wl_logger;
81 81
 
82
-	if ( true === WP_DEBUG ) {
82
+	if (true === WP_DEBUG) {
83 83
 
84
-		$message = ( isset( $caller ) ? sprintf( '[%-40.40s] ', $caller ) : '' ) .
85
-		           ( is_array( $log ) || is_object( $log ) ? print_r( $log, true ) : wl_write_log_hide_key( $log ) );
84
+		$message = (isset($caller) ? sprintf('[%-40.40s] ', $caller) : '').
85
+		           (is_array($log) || is_object($log) ? print_r($log, true) : wl_write_log_hide_key($log));
86 86
 
87
-		if ( isset( $wl_logger ) ) {
88
-			$wl_logger->info( $message );
87
+		if (isset($wl_logger)) {
88
+			$wl_logger->info($message);
89 89
 		} else {
90
-			error_log( $message );
90
+			error_log($message);
91 91
 		}
92 92
 
93 93
 	}
@@ -105,9 +105,9 @@  discard block
 block discarded – undo
105 105
  *
106 106
  * @return string A text with the key hidden.
107 107
  */
108
-function wl_write_log_hide_key( $text ) {
108
+function wl_write_log_hide_key($text) {
109 109
 
110
-	return str_ireplace( wl_configuration_get_key(), '<hidden>', $text );
110
+	return str_ireplace(wl_configuration_get_key(), '<hidden>', $text);
111 111
 }
112 112
 
113 113
 /**
@@ -117,12 +117,12 @@  discard block
 block discarded – undo
117 117
  *
118 118
  * @param string $query A SPARQL query.
119 119
  */
120
-function wl_queue_sparql_update_query( $query ) {
120
+function wl_queue_sparql_update_query($query) {
121 121
 
122
-	$filename = WL_TEMP_DIR . WL_REQUEST_ID . '.sparql';
123
-	file_put_contents( $filename, $query . "\n", FILE_APPEND );
122
+	$filename = WL_TEMP_DIR.WL_REQUEST_ID.'.sparql';
123
+	file_put_contents($filename, $query."\n", FILE_APPEND);
124 124
 
125
-	wl_write_log( "wl_queue_sparql_update_query [ filename :: $filename ]" );
125
+	wl_write_log("wl_queue_sparql_update_query [ filename :: $filename ]");
126 126
 }
127 127
 
128 128
 /**
@@ -130,33 +130,33 @@  discard block
 block discarded – undo
130 130
  *
131 131
  * @param int $request_id The request ID.
132 132
  */
133
-function wl_execute_saved_sparql_update_query( $request_id ) {
133
+function wl_execute_saved_sparql_update_query($request_id) {
134 134
 
135
-	$filename = WL_TEMP_DIR . $request_id . '.sparql';
135
+	$filename = WL_TEMP_DIR.$request_id.'.sparql';
136 136
 
137 137
 	// If the file doesn't exist, exit.
138
-	if ( ! file_exists( $filename ) ) {
139
-		wl_write_log( "wl_execute_saved_sparql_update_query : file doesn't exist [ filename :: $filename ]" );
138
+	if ( ! file_exists($filename)) {
139
+		wl_write_log("wl_execute_saved_sparql_update_query : file doesn't exist [ filename :: $filename ]");
140 140
 
141 141
 		return;
142 142
 	}
143 143
 
144
-	wl_write_log( "wl_execute_saved_sparql_update_query [ filename :: $filename ]" );
144
+	wl_write_log("wl_execute_saved_sparql_update_query [ filename :: $filename ]");
145 145
 
146 146
 	// Get the query saved in the file.
147
-	$query = file_get_contents( $filename );
147
+	$query = file_get_contents($filename);
148 148
 
149 149
 	// Execute the SPARQL query.
150
-	rl_execute_sparql_update_query( $query, false );
150
+	rl_execute_sparql_update_query($query, false);
151 151
 
152 152
 	// Reindex the triple store.
153 153
 	wordlift_reindex_triple_store();
154 154
 
155 155
 	// Delete the temporary file.
156
-	unlink( $filename );
156
+	unlink($filename);
157 157
 }
158 158
 
159
-add_action( 'wl_execute_saved_sparql_update_query', 'wl_execute_saved_sparql_update_query', 10, 1 );
159
+add_action('wl_execute_saved_sparql_update_query', 'wl_execute_saved_sparql_update_query', 10, 1);
160 160
 
161 161
 /**
162 162
  * Add buttons hook for the TinyMCE editor. This method is called by the WP init hook.
@@ -164,8 +164,8 @@  discard block
 block discarded – undo
164 164
 function wordlift_buttonhooks() {
165 165
 
166 166
 	// Only add hooks when the current user has permissions AND is in Rich Text editor mode
167
-	if ( ( current_user_can( 'edit_posts' ) || current_user_can( 'edit_pages' ) ) && get_user_option( 'rich_editing' ) ) {
168
-		add_filter( 'mce_external_plugins', 'wordlift_register_tinymce_javascript' );
167
+	if ((current_user_can('edit_posts') || current_user_can('edit_pages')) && get_user_option('rich_editing')) {
168
+		add_filter('mce_external_plugins', 'wordlift_register_tinymce_javascript');
169 169
 	}
170 170
 }
171 171
 
@@ -176,11 +176,11 @@  discard block
 block discarded – undo
176 176
  *
177 177
  * @return array The modified plugins array.
178 178
  */
179
-function wordlift_register_tinymce_javascript( $plugin_array ) {
179
+function wordlift_register_tinymce_javascript($plugin_array) {
180 180
 
181 181
 	// add the wordlift plugin.
182 182
 	// We can't use the minified version here.
183
-	$plugin_array['wordlift'] = plugin_dir_url( __FILE__ ) . 'js/wordlift-reloaded.js';
183
+	$plugin_array['wordlift'] = plugin_dir_url(__FILE__).'js/wordlift-reloaded.js';
184 184
 
185 185
 	return $plugin_array;
186 186
 }
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
 function wordlift_allowed_post_tags() {
193 193
 	global $allowedposttags;
194 194
 
195
-	$tags           = array( 'span' );
195
+	$tags           = array('span');
196 196
 	$new_attributes = array(
197 197
 		'itemscope' => array(),
198 198
 		'itemtype'  => array(),
@@ -200,17 +200,17 @@  discard block
 block discarded – undo
200 200
 		'itemid'    => array(),
201 201
 	);
202 202
 
203
-	foreach ( $tags as $tag ) {
204
-		if ( isset( $allowedposttags[ $tag ] ) && is_array( $allowedposttags[ $tag ] ) ) {
205
-			$allowedposttags[ $tag ] = array_merge( $allowedposttags[ $tag ], $new_attributes );
203
+	foreach ($tags as $tag) {
204
+		if (isset($allowedposttags[$tag]) && is_array($allowedposttags[$tag])) {
205
+			$allowedposttags[$tag] = array_merge($allowedposttags[$tag], $new_attributes);
206 206
 		}
207 207
 	}
208 208
 }
209 209
 
210 210
 // init process for button control
211
-add_action( 'init', 'wordlift_buttonhooks' );
211
+add_action('init', 'wordlift_buttonhooks');
212 212
 // add allowed post tags.
213
-add_action( 'init', 'wordlift_allowed_post_tags' );
213
+add_action('init', 'wordlift_allowed_post_tags');
214 214
 
215 215
 
216 216
 /**
@@ -219,30 +219,30 @@  discard block
 block discarded – undo
219 219
 function wordlift_admin_enqueue_scripts() {
220 220
 
221 221
 	// Added for compatibility with WordPress 3.9 (see http://make.wordpress.org/core/2014/04/16/jquery-ui-and-wpdialogs-in-wordpress-3-9/)
222
-	wp_enqueue_script( 'wpdialogs' );
223
-	wp_enqueue_style( 'wp-jquery-ui-dialog' );
222
+	wp_enqueue_script('wpdialogs');
223
+	wp_enqueue_style('wp-jquery-ui-dialog');
224 224
 
225
-	wp_enqueue_style( 'wordlift-reloaded', plugin_dir_url( __FILE__ ) . 'css/wordlift-reloaded.min.css' );
225
+	wp_enqueue_style('wordlift-reloaded', plugin_dir_url(__FILE__).'css/wordlift-reloaded.min.css');
226 226
 
227
-	wp_enqueue_script( 'jquery-ui-autocomplete' );
228
-	wp_enqueue_script( 'angularjs', 'https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.11/angular.min.js' );
229
-	wp_enqueue_script( 'angularjs-geolocation', plugin_dir_url( __FILE__ ) . '/bower_components/angularjs-geolocation/dist/angularjs-geolocation.min.js' );
230
-	wp_enqueue_script( 'angularjs-touch', 'https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.11/angular-touch.min.js' );
231
-	wp_enqueue_script( 'angularjs-animate', 'https://code.angularjs.org/1.3.11/angular-animate.min.js' );
227
+	wp_enqueue_script('jquery-ui-autocomplete');
228
+	wp_enqueue_script('angularjs', 'https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.11/angular.min.js');
229
+	wp_enqueue_script('angularjs-geolocation', plugin_dir_url(__FILE__).'/bower_components/angularjs-geolocation/dist/angularjs-geolocation.min.js');
230
+	wp_enqueue_script('angularjs-touch', 'https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.11/angular-touch.min.js');
231
+	wp_enqueue_script('angularjs-animate', 'https://code.angularjs.org/1.3.11/angular-animate.min.js');
232 232
 
233 233
 	// Disable auto-save for custom entity posts only
234
-	if ( Wordlift_Entity_Service::TYPE_NAME === get_post_type() ) {
235
-		wp_dequeue_script( 'autosave' );
234
+	if (Wordlift_Entity_Service::TYPE_NAME === get_post_type()) {
235
+		wp_dequeue_script('autosave');
236 236
 	}
237 237
 }
238 238
 
239
-add_action( 'admin_enqueue_scripts', 'wordlift_admin_enqueue_scripts' );
239
+add_action('admin_enqueue_scripts', 'wordlift_admin_enqueue_scripts');
240 240
 
241 241
 function wl_enqueue_scripts() {
242
-	wp_enqueue_style( 'wordlift-ui', plugin_dir_url( __FILE__ ) . 'css/wordlift-ui.min.css' );
242
+	wp_enqueue_style('wordlift-ui', plugin_dir_url(__FILE__).'css/wordlift-ui.min.css');
243 243
 }
244 244
 
245
-add_action( 'wp_enqueue_scripts', 'wl_enqueue_scripts' );
245
+add_action('wp_enqueue_scripts', 'wl_enqueue_scripts');
246 246
 
247 247
 /**
248 248
  * Hooked to *wp_kses_allowed_html* filter, adds microdata attributes.
@@ -252,23 +252,23 @@  discard block
 block discarded – undo
252 252
  *
253 253
  * @return array An array which contains allowed microdata attributes.
254 254
  */
255
-function wordlift_allowed_html( $allowedtags, $context ) {
255
+function wordlift_allowed_html($allowedtags, $context) {
256 256
 
257
-	if ( 'post' !== $context ) {
257
+	if ('post' !== $context) {
258 258
 		return $allowedtags;
259 259
 	}
260 260
 
261
-	return array_merge_recursive( $allowedtags, array(
261
+	return array_merge_recursive($allowedtags, array(
262 262
 		'span' => array(
263 263
 			'itemscope' => true,
264 264
 			'itemtype'  => true,
265 265
 			'itemid'    => true,
266 266
 			'itemprop'  => true,
267 267
 		),
268
-	) );
268
+	));
269 269
 }
270 270
 
271
-add_filter( 'wp_kses_allowed_html', 'wordlift_allowed_html', 10, 2 );
271
+add_filter('wp_kses_allowed_html', 'wordlift_allowed_html', 10, 2);
272 272
 
273 273
 /**
274 274
  * Get the coordinates for the specified post ID.
@@ -277,16 +277,16 @@  discard block
 block discarded – undo
277 277
  *
278 278
  * @return array|null An array of coordinates or null.
279 279
  */
280
-function wl_get_coordinates( $post_id ) {
280
+function wl_get_coordinates($post_id) {
281 281
 
282
-	$latitude  = wl_schema_get_value( $post_id, 'latitude' );
283
-	$longitude = wl_schema_get_value( $post_id, 'longitude' );
282
+	$latitude  = wl_schema_get_value($post_id, 'latitude');
283
+	$longitude = wl_schema_get_value($post_id, 'longitude');
284 284
 
285 285
 	// DO NOT set latitude/longitude to 0/0 as default values. It's a specific place on the globe:
286 286
 	// "The zero/zero point of this system is located in the Gulf of Guinea about 625 km (390 mi) south of Tema, Ghana."
287 287
 	return array(
288
-		'latitude'  => isset( $latitude[0] ) && is_numeric( $latitude[0] ) ? $latitude[0] : '',
289
-		'longitude' => isset( $longitude[0] ) && is_numeric( $longitude[0] ) ? $longitude[0] : '',
288
+		'latitude'  => isset($latitude[0]) && is_numeric($latitude[0]) ? $latitude[0] : '',
289
+		'longitude' => isset($longitude[0]) && is_numeric($longitude[0]) ? $longitude[0] : '',
290 290
 	);
291 291
 }
292 292
 
@@ -297,12 +297,12 @@  discard block
 block discarded – undo
297 297
  *
298 298
  * @return string A datetime.
299 299
  */
300
-function wl_get_post_modified_time( $post ) {
300
+function wl_get_post_modified_time($post) {
301 301
 
302
-	$date_modified = get_post_modified_time( 'c', true, $post );
302
+	$date_modified = get_post_modified_time('c', true, $post);
303 303
 
304
-	if ( '-' === substr( $date_modified, 0, 1 ) ) {
305
-		return get_the_time( 'c', $post );
304
+	if ('-' === substr($date_modified, 0, 1)) {
305
+		return get_the_time('c', $post);
306 306
 	}
307 307
 
308 308
 	return $date_modified;
@@ -315,27 +315,27 @@  discard block
 block discarded – undo
315 315
  *
316 316
  * @return array An array of image URLs.
317 317
  */
318
-function wl_get_image_urls( $post_id ) {
318
+function wl_get_image_urls($post_id) {
319 319
 
320 320
 
321 321
 	// If there is a featured image it has the priority
322
-	$featured_image_id = get_post_thumbnail_id( $post_id );
323
-	if ( is_numeric( $featured_image_id ) ) {
324
-		$image_url = wp_get_attachment_url( $featured_image_id );
322
+	$featured_image_id = get_post_thumbnail_id($post_id);
323
+	if (is_numeric($featured_image_id)) {
324
+		$image_url = wp_get_attachment_url($featured_image_id);
325 325
 
326
-		return array( $image_url );
326
+		return array($image_url);
327 327
 	}
328 328
 
329 329
 	// wl_write_log( "wl_get_image_urls [ post id :: $post_id ]" );
330 330
 
331
-	$images = get_children( array(
331
+	$images = get_children(array(
332 332
 		'post_parent'    => $post_id,
333 333
 		'post_type'      => 'attachment',
334 334
 		'post_mime_type' => 'image',
335
-	) );
335
+	));
336 336
 
337 337
 	// Return an empty array if no image is found.
338
-	if ( empty( $images ) ) {
338
+	if (empty($images)) {
339 339
 		return array();
340 340
 	}
341 341
 
@@ -343,11 +343,11 @@  discard block
 block discarded – undo
343 343
 	$image_urls = array();
344 344
 
345 345
 	// Collect the URLs.
346
-	foreach ( $images as $attachment_id => $attachment ) {
347
-		$image_url = wp_get_attachment_url( $attachment_id );
346
+	foreach ($images as $attachment_id => $attachment) {
347
+		$image_url = wp_get_attachment_url($attachment_id);
348 348
 		// Ensure the URL isn't collected already.
349
-		if ( ! in_array( $image_url, $image_urls ) ) {
350
-			array_push( $image_urls, $image_url );
349
+		if ( ! in_array($image_url, $image_urls)) {
350
+			array_push($image_urls, $image_url);
351 351
 		}
352 352
 	}
353 353
 
@@ -364,17 +364,17 @@  discard block
 block discarded – undo
364 364
  *
365 365
  * @return string The SPARQL fragment.
366 366
  */
367
-function wl_get_sparql_images( $uri, $post_id ) {
367
+function wl_get_sparql_images($uri, $post_id) {
368 368
 
369 369
 	$sparql = '';
370 370
 
371 371
 	// Get the escaped URI.
372
-	$uri_e = esc_html( $uri );
372
+	$uri_e = esc_html($uri);
373 373
 
374 374
 	// Add SPARQL stmts to write the schema:image.
375
-	$image_urls = wl_get_image_urls( $post_id );
376
-	foreach ( $image_urls as $image_url ) {
377
-		$image_url_esc = wl_sparql_escape_uri( $image_url );
375
+	$image_urls = wl_get_image_urls($post_id);
376
+	foreach ($image_urls as $image_url) {
377
+		$image_url_esc = wl_sparql_escape_uri($image_url);
378 378
 		$sparql .= " <$uri_e> schema:image <$image_url_esc> . \n";
379 379
 	}
380 380
 
@@ -389,21 +389,21 @@  discard block
 block discarded – undo
389 389
  *
390 390
  * @return WP_Post|null A post instance or null if not found.
391 391
  */
392
-function wl_get_attachment_for_source_url( $parent_post_id, $source_url ) {
392
+function wl_get_attachment_for_source_url($parent_post_id, $source_url) {
393 393
 
394 394
 	// wl_write_log( "wl_get_attachment_for_source_url [ parent post id :: $parent_post_id ][ source url :: $source_url ]" );
395 395
 
396
-	$posts = get_posts( array(
396
+	$posts = get_posts(array(
397 397
 		'post_type'      => 'attachment',
398 398
 		'posts_per_page' => 1,
399 399
 		'post_status'    => 'any',
400 400
 		'post_parent'    => $parent_post_id,
401 401
 		'meta_key'       => 'wl_source_url',
402 402
 		'meta_value'     => $source_url,
403
-	) );
403
+	));
404 404
 
405 405
 	// Return the found post.
406
-	if ( 1 === count( $posts ) ) {
406
+	if (1 === count($posts)) {
407 407
 		return $posts[0];
408 408
 	}
409 409
 
@@ -417,10 +417,10 @@  discard block
 block discarded – undo
417 417
  * @param int    $post_id    The post ID.
418 418
  * @param string $source_url The source URL.
419 419
  */
420
-function wl_set_source_url( $post_id, $source_url ) {
420
+function wl_set_source_url($post_id, $source_url) {
421 421
 
422
-	delete_post_meta( $post_id, 'wl_source_url' );
423
-	add_post_meta( $post_id, 'wl_source_url', $source_url );
422
+	delete_post_meta($post_id, 'wl_source_url');
423
+	add_post_meta($post_id, 'wl_source_url', $source_url);
424 424
 }
425 425
 
426 426
 
@@ -436,10 +436,10 @@  discard block
 block discarded – undo
436 436
  *
437 437
  * @param bool $hard True if the rewrite involves configuration updates in Apache/IIS.
438 438
  */
439
-function wl_flush_rewrite_rules_hard( $hard ) {
439
+function wl_flush_rewrite_rules_hard($hard) {
440 440
 
441 441
 	// If WL is not yet configured, we cannot perform any update, so we exit.
442
-	if ( '' === wl_configuration_get_key() ) {
442
+	if ('' === wl_configuration_get_key()) {
443 443
 		return;
444 444
 	}
445 445
 
@@ -448,13 +448,13 @@  discard block
 block discarded – undo
448 448
 	$limit  = 100;
449 449
 
450 450
 	// Get more posts if the number of returned posts matches the limit.
451
-	while ( $limit === ( $posts = get_posts( array(
451
+	while ($limit === ($posts = get_posts(array(
452 452
 			'offset'      => $offset,
453 453
 			'numberposts' => $limit,
454 454
 			'orderby'     => 'ID',
455 455
 			'post_type'   => 'any',
456 456
 			'post_status' => 'publish',
457
-		) ) ) ) {
457
+		)))) {
458 458
 
459 459
 		// Holds the delete part of the query.
460 460
 		$delete_query = rl_sparql_prefixes();
@@ -463,16 +463,16 @@  discard block
 block discarded – undo
463 463
 		$insert_query = '';
464 464
 
465 465
 		// Cycle in each post to build the query.
466
-		foreach ( $posts as $post ) {
466
+		foreach ($posts as $post) {
467 467
 
468 468
 			// Ignore revisions.
469
-			if ( wp_is_post_revision( $post->ID ) ) {
469
+			if (wp_is_post_revision($post->ID)) {
470 470
 				continue;
471 471
 			}
472 472
 
473 473
 			// Get the entity URI.
474
-			$s = Wordlift_Sparql_Service::escape_uri( Wordlift_Entity_Service::get_instance()
475
-			                                                                 ->get_uri( $post->ID ) );
474
+			$s = Wordlift_Sparql_Service::escape_uri(Wordlift_Entity_Service::get_instance()
475
+			                                                                 ->get_uri($post->ID));
476 476
 
477 477
 			// Get the post URL.
478 478
 			// $url = wl_sparql_escape_uri( get_permalink( $post->ID ) );
@@ -481,13 +481,13 @@  discard block
 block discarded – undo
481 481
 			$delete_query .= "DELETE { <$s> schema:url ?u . } WHERE  { <$s> schema:url ?u . };\n";
482 482
 
483 483
 			$insert_query .= Wordlift_Schema_Url_Property_Service::get_instance()
484
-			                                                     ->get_insert_query( $s, $post->ID );
484
+			                                                     ->get_insert_query($s, $post->ID);
485 485
 
486 486
 		}
487 487
 
488 488
 
489 489
 		// Execute the query.
490
-		rl_execute_sparql_update_query( $delete_query . $insert_query );
490
+		rl_execute_sparql_update_query($delete_query.$insert_query);
491 491
 
492 492
 		// Advance to the next posts.
493 493
 		$offset += $limit;
@@ -503,7 +503,7 @@  discard block
 block discarded – undo
503 503
 
504 504
 }
505 505
 
506
-add_filter( 'flush_rewrite_rules_hard', 'wl_flush_rewrite_rules_hard', 10, 1 );
506
+add_filter('flush_rewrite_rules_hard', 'wl_flush_rewrite_rules_hard', 10, 1);
507 507
 
508 508
 /**
509 509
  * Sanitizes an URI path by replacing the non allowed characters with an underscore.
@@ -516,9 +516,9 @@  discard block
 block discarded – undo
516 516
  *
517 517
  * @return string The sanitized path.
518 518
  */
519
-function wl_sanitize_uri_path( $path, $char = '_' ) {
519
+function wl_sanitize_uri_path($path, $char = '_') {
520 520
 
521
-	return Wordlift_Uri_Service::get_instance()->sanitize_path( $path, $char );
521
+	return Wordlift_Uri_Service::get_instance()->sanitize_path($path, $char);
522 522
 }
523 523
 
524 524
 /**
@@ -528,10 +528,10 @@  discard block
 block discarded – undo
528 528
  *
529 529
  * @return array Array containing $value (if $value was not an array)
530 530
  */
531
-function wl_force_to_array( $value ) {
531
+function wl_force_to_array($value) {
532 532
 
533
-	if ( ! is_array( $value ) ) {
534
-		return array( $value );
533
+	if ( ! is_array($value)) {
534
+		return array($value);
535 535
 	}
536 536
 
537 537
 	return $value;
@@ -543,28 +543,28 @@  discard block
 block discarded – undo
543 543
 function wl_shutdown() {
544 544
 
545 545
 	// Get the filename to the temporary SPARQL file.
546
-	$filename = WL_TEMP_DIR . WL_REQUEST_ID . '.sparql';
546
+	$filename = WL_TEMP_DIR.WL_REQUEST_ID.'.sparql';
547 547
 
548 548
 	// If WordLift is buffering SPARQL queries, we're admins and a buffer exists, then schedule it.
549
-	if ( WL_ENABLE_SPARQL_UPDATE_QUERIES_BUFFERING && is_admin() && file_exists( $filename ) ) {
549
+	if (WL_ENABLE_SPARQL_UPDATE_QUERIES_BUFFERING && is_admin() && file_exists($filename)) {
550 550
 
551 551
 		// The request ID.
552
-		$args = array( WL_REQUEST_ID );
552
+		$args = array(WL_REQUEST_ID);
553 553
 
554 554
 		// Schedule the execution of the SPARQL query with the request ID.
555
-		wp_schedule_single_event( time(), 'wl_execute_saved_sparql_update_query', $args );
555
+		wp_schedule_single_event(time(), 'wl_execute_saved_sparql_update_query', $args);
556 556
 
557 557
 		// Check that the request is scheduled.
558
-		$timestamp = wp_next_scheduled( 'wl_execute_saved_sparql_update_query', $args );
558
+		$timestamp = wp_next_scheduled('wl_execute_saved_sparql_update_query', $args);
559 559
 
560 560
 		// Spawn the cron.
561 561
 		spawn_cron();
562 562
 
563
-		wl_write_log( "wl_shutdown [ request id :: " . WL_REQUEST_ID . " ][ timestamp :: $timestamp ]" );
563
+		wl_write_log("wl_shutdown [ request id :: ".WL_REQUEST_ID." ][ timestamp :: $timestamp ]");
564 564
 	}
565 565
 }
566 566
 
567
-add_action( 'shutdown', 'wl_shutdown' );
567
+add_action('shutdown', 'wl_shutdown');
568 568
 
569 569
 /**
570 570
  * Replaces the *itemid* attributes URIs with the WordLift URIs.
@@ -573,111 +573,111 @@  discard block
 block discarded – undo
573 573
  *
574 574
  * @return string The updated post content.
575 575
  */
576
-function wl_replace_item_id_with_uri( $content ) {
576
+function wl_replace_item_id_with_uri($content) {
577 577
 
578 578
 	// wl_write_log( "wl_replace_item_id_with_uri" );
579 579
 
580 580
 	// Strip slashes, see https://core.trac.wordpress.org/ticket/21767
581
-	$content = stripslashes( $content );
581
+	$content = stripslashes($content);
582 582
 
583 583
 	// If any match are found.
584 584
 	$matches = array();
585
-	if ( 0 < preg_match_all( '/ itemid="([^"]+)"/i', $content, $matches, PREG_SET_ORDER ) ) {
585
+	if (0 < preg_match_all('/ itemid="([^"]+)"/i', $content, $matches, PREG_SET_ORDER)) {
586 586
 
587
-		foreach ( $matches as $match ) {
587
+		foreach ($matches as $match) {
588 588
 
589 589
 			// Get the item ID.
590 590
 			$item_id = $match[1];
591 591
 
592 592
 			// Get the post bound to that item ID (looking both in the 'official' URI and in the 'same-as' .
593 593
 			$post = Wordlift_Entity_Service::get_instance()
594
-			                               ->get_entity_post_by_uri( $item_id );
594
+			                               ->get_entity_post_by_uri($item_id);
595 595
 
596 596
 			// If no entity is found, continue to the next one.
597
-			if ( null === $post ) {
597
+			if (null === $post) {
598 598
 				continue;
599 599
 			}
600 600
 
601 601
 			// Get the URI for that post.
602
-			$uri = wl_get_entity_uri( $post->ID );
602
+			$uri = wl_get_entity_uri($post->ID);
603 603
 
604 604
 			// wl_write_log( "wl_replace_item_id_with_uri [ item id :: $item_id ][ uri :: $uri ]" );
605 605
 
606 606
 			// If the item ID and the URI differ, replace the item ID with the URI saved in WordPress.
607
-			if ( $item_id !== $uri ) {
608
-				$uri_e   = esc_html( $uri );
609
-				$content = str_replace( " itemid=\"$item_id\"", " itemid=\"$uri_e\"", $content );
607
+			if ($item_id !== $uri) {
608
+				$uri_e   = esc_html($uri);
609
+				$content = str_replace(" itemid=\"$item_id\"", " itemid=\"$uri_e\"", $content);
610 610
 			}
611 611
 		}
612 612
 	}
613 613
 
614 614
 	// Reapply slashes.
615
-	$content = addslashes( $content );
615
+	$content = addslashes($content);
616 616
 
617 617
 	return $content;
618 618
 }
619 619
 
620
-add_filter( 'content_save_pre', 'wl_replace_item_id_with_uri', 1, 1 );
620
+add_filter('content_save_pre', 'wl_replace_item_id_with_uri', 1, 1);
621 621
 
622
-require_once( 'wordlift_entity_functions.php' );
622
+require_once('wordlift_entity_functions.php');
623 623
 
624 624
 // add editor related methods.
625
-require_once( 'wordlift_editor.php' );
625
+require_once('wordlift_editor.php');
626 626
 
627 627
 // add the WordLift entity custom type.
628
-require_once( 'wordlift_entity_type.php' );
629
-require_once( 'wordlift_entity_type_taxonomy.php' );
628
+require_once('wordlift_entity_type.php');
629
+require_once('wordlift_entity_type_taxonomy.php');
630 630
 
631 631
 // add callbacks on post save to notify data changes from wp to redlink triple store
632
-require_once( 'wordlift_to_redlink_data_push_callbacks.php' );
632
+require_once('wordlift_to_redlink_data_push_callbacks.php');
633 633
 
634 634
 // Load modules
635
-require_once( 'modules/analyzer/wordlift_analyzer.php' );
636
-require_once( 'modules/linked_data/wordlift_linked_data.php' );
637
-require_once( 'modules/prefixes/wordlift_prefixes.php' );
638
-require_once( 'modules/redirector/wordlift_redirector.php' );
635
+require_once('modules/analyzer/wordlift_analyzer.php');
636
+require_once('modules/linked_data/wordlift_linked_data.php');
637
+require_once('modules/prefixes/wordlift_prefixes.php');
638
+require_once('modules/redirector/wordlift_redirector.php');
639 639
 
640 640
 // Shortcodes
641 641
 
642
-require_once( 'modules/geo_widget/wordlift_geo_widget.php' );
643
-require_once( 'shortcodes/wordlift_shortcode_chord.php' );
644
-require_once( 'shortcodes/wordlift_shortcode_geomap.php' );
645
-require_once( 'shortcodes/wordlift_shortcode_field.php' );
646
-require_once( 'shortcodes/wordlift_shortcode_faceted_search.php' );
647
-require_once( 'shortcodes/wordlift_shortcode_navigator.php' );
642
+require_once('modules/geo_widget/wordlift_geo_widget.php');
643
+require_once('shortcodes/wordlift_shortcode_chord.php');
644
+require_once('shortcodes/wordlift_shortcode_geomap.php');
645
+require_once('shortcodes/wordlift_shortcode_field.php');
646
+require_once('shortcodes/wordlift_shortcode_faceted_search.php');
647
+require_once('shortcodes/wordlift_shortcode_navigator.php');
648 648
 
649
-require_once( 'widgets/wordlift_widget_geo.php' );
650
-require_once( 'widgets/wordlift_widget_chord.php' );
651
-require_once( 'widgets/wordlift_widget_timeline.php' );
649
+require_once('widgets/wordlift_widget_geo.php');
650
+require_once('widgets/wordlift_widget_chord.php');
651
+require_once('widgets/wordlift_widget_timeline.php');
652 652
 
653
-require_once( 'wordlift_sparql.php' );
654
-require_once( 'wordlift_redlink.php' );
653
+require_once('wordlift_sparql.php');
654
+require_once('wordlift_redlink.php');
655 655
 
656 656
 // Add admin functions.
657 657
 // TODO: find a way to make 'admin' UI tests work.
658 658
 //if ( is_admin() ) {
659 659
 
660
-require_once( 'admin/wordlift_admin.php' );
661
-require_once( 'admin/wordlift_admin_edit_post.php' );
662
-require_once( 'admin/wordlift_admin_save_post.php' );
660
+require_once('admin/wordlift_admin.php');
661
+require_once('admin/wordlift_admin_edit_post.php');
662
+require_once('admin/wordlift_admin_save_post.php');
663 663
 
664 664
 // add the entities meta box.
665
-require_once( 'admin/wordlift_admin_meta_box_entities.php' );
665
+require_once('admin/wordlift_admin_meta_box_entities.php');
666 666
 
667 667
 // add the entity creation AJAX.
668
-require_once( 'admin/wordlift_admin_ajax_related_posts.php' );
668
+require_once('admin/wordlift_admin_ajax_related_posts.php');
669 669
 
670 670
 // Load the wl_chord TinyMCE button and configuration dialog.
671
-require_once( 'admin/wordlift_admin_shortcodes.php' );
671
+require_once('admin/wordlift_admin_shortcodes.php');
672 672
 
673 673
 // Provide syncing features.
674
-require_once( 'admin/wordlift_admin_sync.php' );
674
+require_once('admin/wordlift_admin_sync.php');
675 675
 //}
676 676
 
677 677
 // load languages.
678 678
 // TODO: the following call gives for granted that the plugin is in the wordlift directory,
679 679
 //       we're currently doing this because wordlift is symbolic linked.
680
-load_plugin_textdomain( 'wordlift', false, '/wordlift/languages' );
680
+load_plugin_textdomain('wordlift', false, '/wordlift/languages');
681 681
 
682 682
 
683 683
 /**
@@ -685,7 +685,7 @@  discard block
 block discarded – undo
685 685
  * This action is documented in includes/class-wordlift-activator.php
686 686
  */
687 687
 function activate_wordlift() {
688
-	require_once plugin_dir_path( __FILE__ ) . 'includes/class-wordlift-activator.php';
688
+	require_once plugin_dir_path(__FILE__).'includes/class-wordlift-activator.php';
689 689
 	Wordlift_Activator::activate();
690 690
 }
691 691
 
@@ -694,18 +694,18 @@  discard block
 block discarded – undo
694 694
  * This action is documented in includes/class-wordlift-deactivator.php
695 695
  */
696 696
 function deactivate_wordlift() {
697
-	require_once plugin_dir_path( __FILE__ ) . 'includes/class-wordlift-deactivator.php';
697
+	require_once plugin_dir_path(__FILE__).'includes/class-wordlift-deactivator.php';
698 698
 	Wordlift_Deactivator::deactivate();
699 699
 }
700 700
 
701
-register_activation_hook( __FILE__, 'activate_wordlift' );
702
-register_deactivation_hook( __FILE__, 'deactivate_wordlift' );
701
+register_activation_hook(__FILE__, 'activate_wordlift');
702
+register_deactivation_hook(__FILE__, 'deactivate_wordlift');
703 703
 
704 704
 /**
705 705
  * The core plugin class that is used to define internationalization,
706 706
  * admin-specific hooks, and public-facing site hooks.
707 707
  */
708
-require plugin_dir_path( __FILE__ ) . 'includes/class-wordlift.php';
708
+require plugin_dir_path(__FILE__).'includes/class-wordlift.php';
709 709
 
710 710
 /**
711 711
  * 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.