Completed
Push — develop ( 8dee00...a73902 )
by David
03:37
created
src/shortcodes/wordlift_shortcode_chord.php 2 patches
Indentation   +177 added lines, -177 removed lines patch added patch discarded remove patch
@@ -8,33 +8,33 @@  discard block
 block discarded – undo
8 8
  * @return mixed
9 9
  */
10 10
 function wl_shortcode_chord_most_referenced_entity_id() {
11
-	// Get the last 20 posts by post date.
12
-	// For each post get the entities they reference.
13
-	$post_ids = get_posts( array(
14
-		'numberposts' => 20,
15
-		'post_type'   => 'post',
16
-		'fields'      => 'ids', //only get post IDs
17
-		'post_status' => 'published',
18
-		'orderby'     => 'post_date',
19
-		'order'       => 'DESC',
20
-	) );
21
-
22
-	if ( empty( $post_ids ) ) {
23
-		return null;
24
-	}
25
-
26
-	$entities = array();
27
-	foreach ( $post_ids as $id ) {
28
-		$entities = array_merge( $entities, wl_core_get_related_entity_ids( $id ) );
29
-	}
30
-
31
-	$famous_entities = array_count_values( $entities );
32
-	arsort( $famous_entities );
33
-	if ( sizeof( $famous_entities ) >= 1 ) {
34
-		return key( $famous_entities );
35
-	} else {
36
-		return $post_ids[0];
37
-	}
11
+    // Get the last 20 posts by post date.
12
+    // For each post get the entities they reference.
13
+    $post_ids = get_posts( array(
14
+        'numberposts' => 20,
15
+        'post_type'   => 'post',
16
+        'fields'      => 'ids', //only get post IDs
17
+        'post_status' => 'published',
18
+        'orderby'     => 'post_date',
19
+        'order'       => 'DESC',
20
+    ) );
21
+
22
+    if ( empty( $post_ids ) ) {
23
+        return null;
24
+    }
25
+
26
+    $entities = array();
27
+    foreach ( $post_ids as $id ) {
28
+        $entities = array_merge( $entities, wl_core_get_related_entity_ids( $id ) );
29
+    }
30
+
31
+    $famous_entities = array_count_values( $entities );
32
+    arsort( $famous_entities );
33
+    if ( sizeof( $famous_entities ) >= 1 ) {
34
+        return key( $famous_entities );
35
+    } else {
36
+        return $post_ids[0];
37
+    }
38 38
 
39 39
 }
40 40
 
@@ -52,59 +52,59 @@  discard block
 block discarded – undo
52 52
  */
53 53
 function wl_shortcode_chord_get_relations( $entity_id, $depth = 2, $related = null,  $max_size = 9 ) {
54 54
 
55
-	if ( ! is_null( $related ) ) {
56
-		if ( 0 === $depth ) {
57
-			return $related;
58
-		}
59
-	}
60
-
61
-	wl_write_log( "wl_shortcode_chord_get_relations [ post id :: $entity_id ][ depth :: $depth ][ related? :: " . ( is_null( $related ) ? 'yes' : 'no' ) . " ]" );
62
-
63
-	// Create a related array which will hold entities and relations.
64
-	if ( is_null( $related ) ) {
65
-		$related = array(
66
-			'entities'  => array( $entity_id ),
67
-			'relations' => array()
68
-		);
69
-	}
70
-
71
-	// Get related entities
72
-	$related_entity_ids = wl_core_get_related_entity_ids( $entity_id, array(
73
-		'status' => 'publish'
74
-	) );
75
-
76
-	// If the current node is an entity, add related posts too
77
-	$related_post_ids = ( Wordlift_Entity_Service::get_instance()->is_entity( $entity_id ) ) ?
78
-		wl_core_get_related_post_ids( $entity_id, array(
79
-			'status' => 'publish'
80
-		) ) :
81
-		array();
82
-
83
-	// Merge results and remove duplicated entries
84
-	$related_ids = array_unique( array_merge( $related_post_ids, $related_entity_ids ) );
55
+    if ( ! is_null( $related ) ) {
56
+        if ( 0 === $depth ) {
57
+            return $related;
58
+        }
59
+    }
60
+
61
+    wl_write_log( "wl_shortcode_chord_get_relations [ post id :: $entity_id ][ depth :: $depth ][ related? :: " . ( is_null( $related ) ? 'yes' : 'no' ) . " ]" );
62
+
63
+    // Create a related array which will hold entities and relations.
64
+    if ( is_null( $related ) ) {
65
+        $related = array(
66
+            'entities'  => array( $entity_id ),
67
+            'relations' => array()
68
+        );
69
+    }
70
+
71
+    // Get related entities
72
+    $related_entity_ids = wl_core_get_related_entity_ids( $entity_id, array(
73
+        'status' => 'publish'
74
+    ) );
75
+
76
+    // If the current node is an entity, add related posts too
77
+    $related_post_ids = ( Wordlift_Entity_Service::get_instance()->is_entity( $entity_id ) ) ?
78
+        wl_core_get_related_post_ids( $entity_id, array(
79
+            'status' => 'publish'
80
+        ) ) :
81
+        array();
82
+
83
+    // Merge results and remove duplicated entries
84
+    $related_ids = array_unique( array_merge( $related_post_ids, $related_entity_ids ) );
85 85
 	
86
-	// TODO: List of entities ($rel) should be ordered by interest factors.
87
-	shuffle( $related_ids );
86
+    // TODO: List of entities ($rel) should be ordered by interest factors.
87
+    shuffle( $related_ids );
88 88
 
89
-	// Now we have all the related IDs.
90
-	foreach ( $related_ids as $related_id ) {
89
+    // Now we have all the related IDs.
90
+    foreach ( $related_ids as $related_id ) {
91 91
 
92
-		if( count( $related['entities'] ) >= $max_size ) {
93
-			return $related;
94
-		}
92
+        if( count( $related['entities'] ) >= $max_size ) {
93
+            return $related;
94
+        }
95 95
 		
96
-		$related['relations'][] = array( $entity_id, $related_id );
96
+        $related['relations'][] = array( $entity_id, $related_id );
97 97
 
98
-		if ( ! in_array( $related_id, $related['entities'] ) ) {
99
-			// Found new related entity!
100
-			$related['entities'][] = $related_id;
98
+        if ( ! in_array( $related_id, $related['entities'] ) ) {
99
+            // Found new related entity!
100
+            $related['entities'][] = $related_id;
101 101
 
102
-			$related = wl_shortcode_chord_get_relations( $related_id, ( $depth - 1 ), $related, $max_size );
103
-		}
104
-	}
102
+            $related = wl_shortcode_chord_get_relations( $related_id, ( $depth - 1 ), $related, $max_size );
103
+        }
104
+    }
105 105
 
106
-	// End condition 2: no more entities to search for.
107
-	return $related;
106
+    // End condition 2: no more entities to search for.
107
+    return $related;
108 108
 }
109 109
 
110 110
 /**
@@ -118,56 +118,56 @@  discard block
 block discarded – undo
118 118
  */
119 119
 function wl_shortcode_chord_get_graph( $data ) {
120 120
 
121
-	// Refactor the entities array in order to provide entities relevant data (uri, url, label, type, css_class).
122
-	array_walk( $data['entities'], function ( &$item ) {
123
-		$post = get_post( $item );
124
-
125
-		// Skip non-existing posts.
126
-		if ( is_null( $post ) ) {
127
-			wl_write_log( "wl_shortcode_chord_get_graph : post not found [ post id :: $item ]" );
128
-
129
-			return $item;
130
-		}
131
-
132
-		// Get the entity taxonomy bound to this post (if there's no taxonomy, no stylesheet will be set).
133
-		$term = wl_entity_type_taxonomy_get_type( $item );
134
-
135
-		wl_write_log( "wl_shortcode_chord_get_graph [ post id :: $post->ID ][ term :: " . var_export( $term, true ) . " ]" );
136
-
137
-		// TODO: get all images
138
-		$thumbnail    = null;
139
-		$thumbnail_id = get_post_thumbnail_id( $post->ID );
140
-		if ( '' !== $thumbnail_id ) {
141
-			$attachment = wp_get_attachment_image_src( $thumbnail_id );
142
-			if ( false !== $attachment ) {
143
-				$thumbnail = esc_attr( $attachment[0] );
144
-			}
145
-		}
146
-
147
-		$entity = array(
148
-			'uri'        => wl_get_entity_uri( $item ),
149
-			'url'        => get_permalink( $item ),
150
-			'label'      => $post->post_title,
151
-			'type'       => $post->post_type,
152
-			'thumbnails' => array( $thumbnail ),
153
-			'css_class'  => ( isset( $term['css_class'] ) ? $term['css_class'] : '' )
154
-		);
155
-
156
-		$item = $entity;
157
-	} );
158
-
159
-	// Refactor the relations.
160
-	array_walk( $data['relations'], function ( &$item ) {
161
-		$relation = array(
162
-			's' => wl_get_entity_uri( $item[0] ),
163
-			'o' => wl_get_entity_uri( $item[1] )
164
-		);
165
-
166
-		$item = $relation;
167
-	} );
168
-
169
-	// Return the JSON representation.
170
-	return $data;
121
+    // Refactor the entities array in order to provide entities relevant data (uri, url, label, type, css_class).
122
+    array_walk( $data['entities'], function ( &$item ) {
123
+        $post = get_post( $item );
124
+
125
+        // Skip non-existing posts.
126
+        if ( is_null( $post ) ) {
127
+            wl_write_log( "wl_shortcode_chord_get_graph : post not found [ post id :: $item ]" );
128
+
129
+            return $item;
130
+        }
131
+
132
+        // Get the entity taxonomy bound to this post (if there's no taxonomy, no stylesheet will be set).
133
+        $term = wl_entity_type_taxonomy_get_type( $item );
134
+
135
+        wl_write_log( "wl_shortcode_chord_get_graph [ post id :: $post->ID ][ term :: " . var_export( $term, true ) . " ]" );
136
+
137
+        // TODO: get all images
138
+        $thumbnail    = null;
139
+        $thumbnail_id = get_post_thumbnail_id( $post->ID );
140
+        if ( '' !== $thumbnail_id ) {
141
+            $attachment = wp_get_attachment_image_src( $thumbnail_id );
142
+            if ( false !== $attachment ) {
143
+                $thumbnail = esc_attr( $attachment[0] );
144
+            }
145
+        }
146
+
147
+        $entity = array(
148
+            'uri'        => wl_get_entity_uri( $item ),
149
+            'url'        => get_permalink( $item ),
150
+            'label'      => $post->post_title,
151
+            'type'       => $post->post_type,
152
+            'thumbnails' => array( $thumbnail ),
153
+            'css_class'  => ( isset( $term['css_class'] ) ? $term['css_class'] : '' )
154
+        );
155
+
156
+        $item = $entity;
157
+    } );
158
+
159
+    // Refactor the relations.
160
+    array_walk( $data['relations'], function ( &$item ) {
161
+        $relation = array(
162
+            's' => wl_get_entity_uri( $item[0] ),
163
+            'o' => wl_get_entity_uri( $item[1] )
164
+        );
165
+
166
+        $item = $relation;
167
+    } );
168
+
169
+    // Return the JSON representation.
170
+    return $data;
171 171
 }
172 172
 
173 173
 /**
@@ -178,13 +178,13 @@  discard block
 block discarded – undo
178 178
  */
179 179
 function wl_shortcode_chord_ajax() {
180 180
 
181
-	$post_id = $_REQUEST['post_id'];
182
-	$depth   = $_REQUEST['depth'];
181
+    $post_id = $_REQUEST['post_id'];
182
+    $depth   = $_REQUEST['depth'];
183 183
 
184
-	$relations = wl_shortcode_chord_get_relations( $post_id, $depth );
185
-	$graph     = wl_shortcode_chord_get_graph( $relations );
184
+    $relations = wl_shortcode_chord_get_relations( $post_id, $depth );
185
+    $graph     = wl_shortcode_chord_get_graph( $relations );
186 186
 
187
-	wl_core_send_json( $graph );
187
+    wl_core_send_json( $graph );
188 188
 }
189 189
 
190 190
 add_action( 'wp_ajax_wl_chord', 'wl_shortcode_chord_ajax' );
@@ -202,54 +202,54 @@  discard block
 block discarded – undo
202 202
  */
203 203
 function wl_shortcode_chord( $atts ) {
204 204
 
205
-	//extract attributes and set default values
206
-	$chord_atts = shortcode_atts( array(
207
-		'width'      => '100%',
208
-		'height'     => '500px',
209
-		'main_color' => '000',
210
-		'depth'      => 2,
211
-		'global'     => false
212
-	), $atts );
213
-
214
-	if ( $chord_atts['global'] ) {
215
-		$post_id = wl_shortcode_chord_most_referenced_entity_id();
216
-		if ( $post_id == null ) {
217
-			return "WordLift Chord: no entities found.";
218
-		}
219
-		$widget_id            = 'wl_chord_global';
220
-		$chord_atts['height'] = '200px';
221
-	} else {
222
-		$post_id   = get_the_ID();
223
-		$widget_id = 'wl_chord_' . $post_id;
224
-	}
225
-
226
-	// Adding css
227
-	wp_enqueue_style( 'wordlift-ui', dirname( plugin_dir_url( __FILE__ ) ) . '/css/wordlift-ui.min.css' );
228
-
229
-	// Adding javascript code
230
-	wp_enqueue_script( 'd3', dirname( plugin_dir_url( __FILE__ ) ) . '/bower_components/d3/d3.min.js' );
231
-
232
-	wp_enqueue_script( 'wordlift-ui', dirname( plugin_dir_url( __FILE__ ) ) . '/js/wordlift-ui.min.js', array( 'jquery' ) );
233
-
234
-	wp_localize_script( 'wordlift-ui', 'wl_chord_params', array(
235
-			'ajax_url' => admin_url( 'admin-ajax.php' ),
236
-			'action'   => 'wl_chord'
237
-		)
238
-	);
239
-
240
-	// Escaping atts.
241
-	$esc_class  = esc_attr( 'wl-chord' );
242
-	$esc_id     = esc_attr( $widget_id );
243
-	$esc_width  = esc_attr( $chord_atts['width'] );
244
-	$esc_height = esc_attr( $chord_atts['height'] );
245
-
246
-	$esc_post_id    = esc_attr( $post_id );
247
-	$esc_depth      = esc_attr( $chord_atts['depth'] );
248
-	$esc_main_color = esc_attr( $chord_atts['main_color'] );
249
-
250
-	// Building template.
251
-	// TODO: in the HTML code there are static CSS rules. Move them to the CSS file.
252
-	return <<<EOF
205
+    //extract attributes and set default values
206
+    $chord_atts = shortcode_atts( array(
207
+        'width'      => '100%',
208
+        'height'     => '500px',
209
+        'main_color' => '000',
210
+        'depth'      => 2,
211
+        'global'     => false
212
+    ), $atts );
213
+
214
+    if ( $chord_atts['global'] ) {
215
+        $post_id = wl_shortcode_chord_most_referenced_entity_id();
216
+        if ( $post_id == null ) {
217
+            return "WordLift Chord: no entities found.";
218
+        }
219
+        $widget_id            = 'wl_chord_global';
220
+        $chord_atts['height'] = '200px';
221
+    } else {
222
+        $post_id   = get_the_ID();
223
+        $widget_id = 'wl_chord_' . $post_id;
224
+    }
225
+
226
+    // Adding css
227
+    wp_enqueue_style( 'wordlift-ui', dirname( plugin_dir_url( __FILE__ ) ) . '/css/wordlift-ui.min.css' );
228
+
229
+    // Adding javascript code
230
+    wp_enqueue_script( 'd3', dirname( plugin_dir_url( __FILE__ ) ) . '/bower_components/d3/d3.min.js' );
231
+
232
+    wp_enqueue_script( 'wordlift-ui', dirname( plugin_dir_url( __FILE__ ) ) . '/js/wordlift-ui.min.js', array( 'jquery' ) );
233
+
234
+    wp_localize_script( 'wordlift-ui', 'wl_chord_params', array(
235
+            'ajax_url' => admin_url( 'admin-ajax.php' ),
236
+            'action'   => 'wl_chord'
237
+        )
238
+    );
239
+
240
+    // Escaping atts.
241
+    $esc_class  = esc_attr( 'wl-chord' );
242
+    $esc_id     = esc_attr( $widget_id );
243
+    $esc_width  = esc_attr( $chord_atts['width'] );
244
+    $esc_height = esc_attr( $chord_atts['height'] );
245
+
246
+    $esc_post_id    = esc_attr( $post_id );
247
+    $esc_depth      = esc_attr( $chord_atts['depth'] );
248
+    $esc_main_color = esc_attr( $chord_atts['main_color'] );
249
+
250
+    // Building template.
251
+    // TODO: in the HTML code there are static CSS rules. Move them to the CSS file.
252
+    return <<<EOF
253 253
 <div class="$esc_class" 
254 254
 	id="$esc_id"
255 255
 	data-post-id="$esc_post_id"
@@ -269,7 +269,7 @@  discard block
 block discarded – undo
269 269
  * Registers the *wl_chord* shortcode.
270 270
  */
271 271
 function wl_shortcode_chord_register() {
272
-	add_shortcode( 'wl_chord', 'wl_shortcode_chord' );
272
+    add_shortcode( 'wl_chord', 'wl_shortcode_chord' );
273 273
 }
274 274
 
275 275
 add_action( 'init', 'wl_shortcode_chord_register' );
Please login to merge, or discard this patch.
Spacing   +71 added lines, -72 removed lines patch added patch discarded remove patch
@@ -10,28 +10,28 @@  discard block
 block discarded – undo
10 10
 function wl_shortcode_chord_most_referenced_entity_id() {
11 11
 	// Get the last 20 posts by post date.
12 12
 	// For each post get the entities they reference.
13
-	$post_ids = get_posts( array(
13
+	$post_ids = get_posts(array(
14 14
 		'numberposts' => 20,
15 15
 		'post_type'   => 'post',
16 16
 		'fields'      => 'ids', //only get post IDs
17 17
 		'post_status' => 'published',
18 18
 		'orderby'     => 'post_date',
19 19
 		'order'       => 'DESC',
20
-	) );
20
+	));
21 21
 
22
-	if ( empty( $post_ids ) ) {
22
+	if (empty($post_ids)) {
23 23
 		return null;
24 24
 	}
25 25
 
26 26
 	$entities = array();
27
-	foreach ( $post_ids as $id ) {
28
-		$entities = array_merge( $entities, wl_core_get_related_entity_ids( $id ) );
27
+	foreach ($post_ids as $id) {
28
+		$entities = array_merge($entities, wl_core_get_related_entity_ids($id));
29 29
 	}
30 30
 
31
-	$famous_entities = array_count_values( $entities );
32
-	arsort( $famous_entities );
33
-	if ( sizeof( $famous_entities ) >= 1 ) {
34
-		return key( $famous_entities );
31
+	$famous_entities = array_count_values($entities);
32
+	arsort($famous_entities);
33
+	if (sizeof($famous_entities) >= 1) {
34
+		return key($famous_entities);
35 35
 	} else {
36 36
 		return $post_ids[0];
37 37
 	}
@@ -50,56 +50,55 @@  discard block
 block discarded – undo
50 50
  *
51 51
  * @return array
52 52
  */
53
-function wl_shortcode_chord_get_relations( $entity_id, $depth = 2, $related = null,  $max_size = 9 ) {
53
+function wl_shortcode_chord_get_relations($entity_id, $depth = 2, $related = null, $max_size = 9) {
54 54
 
55
-	if ( ! is_null( $related ) ) {
56
-		if ( 0 === $depth ) {
55
+	if ( ! is_null($related)) {
56
+		if (0 === $depth) {
57 57
 			return $related;
58 58
 		}
59 59
 	}
60 60
 
61
-	wl_write_log( "wl_shortcode_chord_get_relations [ post id :: $entity_id ][ depth :: $depth ][ related? :: " . ( is_null( $related ) ? 'yes' : 'no' ) . " ]" );
61
+	wl_write_log("wl_shortcode_chord_get_relations [ post id :: $entity_id ][ depth :: $depth ][ related? :: ".(is_null($related) ? 'yes' : 'no')." ]");
62 62
 
63 63
 	// Create a related array which will hold entities and relations.
64
-	if ( is_null( $related ) ) {
64
+	if (is_null($related)) {
65 65
 		$related = array(
66
-			'entities'  => array( $entity_id ),
66
+			'entities'  => array($entity_id),
67 67
 			'relations' => array()
68 68
 		);
69 69
 	}
70 70
 
71 71
 	// Get related entities
72
-	$related_entity_ids = wl_core_get_related_entity_ids( $entity_id, array(
72
+	$related_entity_ids = wl_core_get_related_entity_ids($entity_id, array(
73 73
 		'status' => 'publish'
74
-	) );
74
+	));
75 75
 
76 76
 	// If the current node is an entity, add related posts too
77
-	$related_post_ids = ( Wordlift_Entity_Service::get_instance()->is_entity( $entity_id ) ) ?
78
-		wl_core_get_related_post_ids( $entity_id, array(
77
+	$related_post_ids = (Wordlift_Entity_Service::get_instance()->is_entity($entity_id)) ?
78
+		wl_core_get_related_post_ids($entity_id, array(
79 79
 			'status' => 'publish'
80
-		) ) :
81
-		array();
80
+		)) : array();
82 81
 
83 82
 	// Merge results and remove duplicated entries
84
-	$related_ids = array_unique( array_merge( $related_post_ids, $related_entity_ids ) );
83
+	$related_ids = array_unique(array_merge($related_post_ids, $related_entity_ids));
85 84
 	
86 85
 	// TODO: List of entities ($rel) should be ordered by interest factors.
87
-	shuffle( $related_ids );
86
+	shuffle($related_ids);
88 87
 
89 88
 	// Now we have all the related IDs.
90
-	foreach ( $related_ids as $related_id ) {
89
+	foreach ($related_ids as $related_id) {
91 90
 
92
-		if( count( $related['entities'] ) >= $max_size ) {
91
+		if (count($related['entities']) >= $max_size) {
93 92
 			return $related;
94 93
 		}
95 94
 		
96
-		$related['relations'][] = array( $entity_id, $related_id );
95
+		$related['relations'][] = array($entity_id, $related_id);
97 96
 
98
-		if ( ! in_array( $related_id, $related['entities'] ) ) {
97
+		if ( ! in_array($related_id, $related['entities'])) {
99 98
 			// Found new related entity!
100 99
 			$related['entities'][] = $related_id;
101 100
 
102
-			$related = wl_shortcode_chord_get_relations( $related_id, ( $depth - 1 ), $related, $max_size );
101
+			$related = wl_shortcode_chord_get_relations($related_id, ($depth - 1), $related, $max_size);
103 102
 		}
104 103
 	}
105 104
 
@@ -116,51 +115,51 @@  discard block
 block discarded – undo
116 115
  *
117 116
  * @return mixed|string|void
118 117
  */
119
-function wl_shortcode_chord_get_graph( $data ) {
118
+function wl_shortcode_chord_get_graph($data) {
120 119
 
121 120
 	// Refactor the entities array in order to provide entities relevant data (uri, url, label, type, css_class).
122
-	array_walk( $data['entities'], function ( &$item ) {
123
-		$post = get_post( $item );
121
+	array_walk($data['entities'], function(&$item) {
122
+		$post = get_post($item);
124 123
 
125 124
 		// Skip non-existing posts.
126
-		if ( is_null( $post ) ) {
127
-			wl_write_log( "wl_shortcode_chord_get_graph : post not found [ post id :: $item ]" );
125
+		if (is_null($post)) {
126
+			wl_write_log("wl_shortcode_chord_get_graph : post not found [ post id :: $item ]");
128 127
 
129 128
 			return $item;
130 129
 		}
131 130
 
132 131
 		// Get the entity taxonomy bound to this post (if there's no taxonomy, no stylesheet will be set).
133
-		$term = wl_entity_type_taxonomy_get_type( $item );
132
+		$term = wl_entity_type_taxonomy_get_type($item);
134 133
 
135
-		wl_write_log( "wl_shortcode_chord_get_graph [ post id :: $post->ID ][ term :: " . var_export( $term, true ) . " ]" );
134
+		wl_write_log("wl_shortcode_chord_get_graph [ post id :: $post->ID ][ term :: ".var_export($term, true)." ]");
136 135
 
137 136
 		// TODO: get all images
138 137
 		$thumbnail    = null;
139
-		$thumbnail_id = get_post_thumbnail_id( $post->ID );
140
-		if ( '' !== $thumbnail_id ) {
141
-			$attachment = wp_get_attachment_image_src( $thumbnail_id );
142
-			if ( false !== $attachment ) {
143
-				$thumbnail = esc_attr( $attachment[0] );
138
+		$thumbnail_id = get_post_thumbnail_id($post->ID);
139
+		if ('' !== $thumbnail_id) {
140
+			$attachment = wp_get_attachment_image_src($thumbnail_id);
141
+			if (false !== $attachment) {
142
+				$thumbnail = esc_attr($attachment[0]);
144 143
 			}
145 144
 		}
146 145
 
147 146
 		$entity = array(
148
-			'uri'        => wl_get_entity_uri( $item ),
149
-			'url'        => get_permalink( $item ),
147
+			'uri'        => wl_get_entity_uri($item),
148
+			'url'        => get_permalink($item),
150 149
 			'label'      => $post->post_title,
151 150
 			'type'       => $post->post_type,
152
-			'thumbnails' => array( $thumbnail ),
153
-			'css_class'  => ( isset( $term['css_class'] ) ? $term['css_class'] : '' )
151
+			'thumbnails' => array($thumbnail),
152
+			'css_class'  => (isset($term['css_class']) ? $term['css_class'] : '')
154 153
 		);
155 154
 
156 155
 		$item = $entity;
157 156
 	} );
158 157
 
159 158
 	// Refactor the relations.
160
-	array_walk( $data['relations'], function ( &$item ) {
159
+	array_walk($data['relations'], function(&$item) {
161 160
 		$relation = array(
162
-			's' => wl_get_entity_uri( $item[0] ),
163
-			'o' => wl_get_entity_uri( $item[1] )
161
+			's' => wl_get_entity_uri($item[0]),
162
+			'o' => wl_get_entity_uri($item[1])
164 163
 		);
165 164
 
166 165
 		$item = $relation;
@@ -181,14 +180,14 @@  discard block
 block discarded – undo
181 180
 	$post_id = $_REQUEST['post_id'];
182 181
 	$depth   = $_REQUEST['depth'];
183 182
 
184
-	$relations = wl_shortcode_chord_get_relations( $post_id, $depth );
185
-	$graph     = wl_shortcode_chord_get_graph( $relations );
183
+	$relations = wl_shortcode_chord_get_relations($post_id, $depth);
184
+	$graph     = wl_shortcode_chord_get_graph($relations);
186 185
 
187
-	wl_core_send_json( $graph );
186
+	wl_core_send_json($graph);
188 187
 }
189 188
 
190
-add_action( 'wp_ajax_wl_chord', 'wl_shortcode_chord_ajax' );
191
-add_action( 'wp_ajax_nopriv_wl_chord', 'wl_shortcode_chord_ajax' );
189
+add_action('wp_ajax_wl_chord', 'wl_shortcode_chord_ajax');
190
+add_action('wp_ajax_nopriv_wl_chord', 'wl_shortcode_chord_ajax');
192 191
 
193 192
 
194 193
 /**
@@ -200,52 +199,52 @@  discard block
 block discarded – undo
200 199
  *
201 200
  * @return string
202 201
  */
203
-function wl_shortcode_chord( $atts ) {
202
+function wl_shortcode_chord($atts) {
204 203
 
205 204
 	//extract attributes and set default values
206
-	$chord_atts = shortcode_atts( array(
205
+	$chord_atts = shortcode_atts(array(
207 206
 		'width'      => '100%',
208 207
 		'height'     => '500px',
209 208
 		'main_color' => '000',
210 209
 		'depth'      => 2,
211 210
 		'global'     => false
212
-	), $atts );
211
+	), $atts);
213 212
 
214
-	if ( $chord_atts['global'] ) {
213
+	if ($chord_atts['global']) {
215 214
 		$post_id = wl_shortcode_chord_most_referenced_entity_id();
216
-		if ( $post_id == null ) {
215
+		if ($post_id == null) {
217 216
 			return "WordLift Chord: no entities found.";
218 217
 		}
219 218
 		$widget_id            = 'wl_chord_global';
220 219
 		$chord_atts['height'] = '200px';
221 220
 	} else {
222 221
 		$post_id   = get_the_ID();
223
-		$widget_id = 'wl_chord_' . $post_id;
222
+		$widget_id = 'wl_chord_'.$post_id;
224 223
 	}
225 224
 
226 225
 	// Adding css
227
-	wp_enqueue_style( 'wordlift-ui', dirname( plugin_dir_url( __FILE__ ) ) . '/css/wordlift-ui.min.css' );
226
+	wp_enqueue_style('wordlift-ui', dirname(plugin_dir_url(__FILE__)).'/css/wordlift-ui.min.css');
228 227
 
229 228
 	// Adding javascript code
230
-	wp_enqueue_script( 'd3', dirname( plugin_dir_url( __FILE__ ) ) . '/bower_components/d3/d3.min.js' );
229
+	wp_enqueue_script('d3', dirname(plugin_dir_url(__FILE__)).'/bower_components/d3/d3.min.js');
231 230
 
232
-	wp_enqueue_script( 'wordlift-ui', dirname( plugin_dir_url( __FILE__ ) ) . '/js/wordlift-ui.min.js', array( 'jquery' ) );
231
+	wp_enqueue_script('wordlift-ui', dirname(plugin_dir_url(__FILE__)).'/js/wordlift-ui.min.js', array('jquery'));
233 232
 
234
-	wp_localize_script( 'wordlift-ui', 'wl_chord_params', array(
235
-			'ajax_url' => admin_url( 'admin-ajax.php' ),
233
+	wp_localize_script('wordlift-ui', 'wl_chord_params', array(
234
+			'ajax_url' => admin_url('admin-ajax.php'),
236 235
 			'action'   => 'wl_chord'
237 236
 		)
238 237
 	);
239 238
 
240 239
 	// Escaping atts.
241
-	$esc_class  = esc_attr( 'wl-chord' );
242
-	$esc_id     = esc_attr( $widget_id );
243
-	$esc_width  = esc_attr( $chord_atts['width'] );
244
-	$esc_height = esc_attr( $chord_atts['height'] );
240
+	$esc_class  = esc_attr('wl-chord');
241
+	$esc_id     = esc_attr($widget_id);
242
+	$esc_width  = esc_attr($chord_atts['width']);
243
+	$esc_height = esc_attr($chord_atts['height']);
245 244
 
246
-	$esc_post_id    = esc_attr( $post_id );
247
-	$esc_depth      = esc_attr( $chord_atts['depth'] );
248
-	$esc_main_color = esc_attr( $chord_atts['main_color'] );
245
+	$esc_post_id    = esc_attr($post_id);
246
+	$esc_depth      = esc_attr($chord_atts['depth']);
247
+	$esc_main_color = esc_attr($chord_atts['main_color']);
249 248
 
250 249
 	// Building template.
251 250
 	// TODO: in the HTML code there are static CSS rules. Move them to the CSS file.
@@ -269,7 +268,7 @@  discard block
 block discarded – undo
269 268
  * Registers the *wl_chord* shortcode.
270 269
  */
271 270
 function wl_shortcode_chord_register() {
272
-	add_shortcode( 'wl_chord', 'wl_shortcode_chord' );
271
+	add_shortcode('wl_chord', 'wl_shortcode_chord');
273 272
 }
274 273
 
275
-add_action( 'init', 'wl_shortcode_chord_register' );
274
+add_action('init', 'wl_shortcode_chord_register');
Please login to merge, or discard this patch.
src/includes/class-wordlift-page-service.php 2 patches
Indentation   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -10,54 +10,54 @@
 block discarded – undo
10 10
  */
11 11
 class Wordlift_Page_Service {
12 12
 
13
-	/**
14
-	 * Hook to wp_head and create a response buffer.
15
-	 *
16
-	 * @since 3.5.3
17
-	 */
18
-	public function wp_head() {
19
-
20
-		// When the buffer is flushed, have the handler markup the content.
21
-		ob_start( array( $this, 'handler' ) );
22
-
23
-	}
24
-
25
-	/**
26
-	 * Hook to wp_footer and flush the response buffer.
27
-	 *
28
-	 * @since 3.5.3
29
-	 */
30
-	public function wp_footer() {
31
-
32
-		ob_end_flush();
33
-
34
-	}
35
-
36
-	/**
37
-	 * Handle the buffer, by inserting schema.org microdata markup with itemscope/itemtype/itemprop.
38
-	 *
39
-	 * @since 3.5.3
40
-	 *
41
-	 * @param string $buffer The output buffer.
42
-	 *
43
-	 * @return string The processed output buffer.
44
-	 */
45
-	public function handler( $buffer ) {
46
-
47
-		// Look for the following regexs.
48
-		$regexs = array(
49
-			'/<article ([^>]*)class="([^"]*)type-post([^"]*)"([^>]*)/i',
50
-			'/<h1 ([^>]*)class="([^"]*)entry-title([^"]*)"([^>]*)/i',
51
-		);
52
-
53
-		// Replacements.
54
-		$replacements = array(
55
-			'<article itemscope itemtype="http://schema.org/Article" ${1}class="${2}type-post${3}"${4}',
56
-			'<h1 itemprop="name" ${1}class="${2}entry-title${3}"${4}',
57
-		);
58
-
59
-		// Perform the replacements in the buffer.
60
-		return preg_replace( $regexs, $replacements, $buffer );
61
-	}
13
+    /**
14
+     * Hook to wp_head and create a response buffer.
15
+     *
16
+     * @since 3.5.3
17
+     */
18
+    public function wp_head() {
19
+
20
+        // When the buffer is flushed, have the handler markup the content.
21
+        ob_start( array( $this, 'handler' ) );
22
+
23
+    }
24
+
25
+    /**
26
+     * Hook to wp_footer and flush the response buffer.
27
+     *
28
+     * @since 3.5.3
29
+     */
30
+    public function wp_footer() {
31
+
32
+        ob_end_flush();
33
+
34
+    }
35
+
36
+    /**
37
+     * Handle the buffer, by inserting schema.org microdata markup with itemscope/itemtype/itemprop.
38
+     *
39
+     * @since 3.5.3
40
+     *
41
+     * @param string $buffer The output buffer.
42
+     *
43
+     * @return string The processed output buffer.
44
+     */
45
+    public function handler( $buffer ) {
46
+
47
+        // Look for the following regexs.
48
+        $regexs = array(
49
+            '/<article ([^>]*)class="([^"]*)type-post([^"]*)"([^>]*)/i',
50
+            '/<h1 ([^>]*)class="([^"]*)entry-title([^"]*)"([^>]*)/i',
51
+        );
52
+
53
+        // Replacements.
54
+        $replacements = array(
55
+            '<article itemscope itemtype="http://schema.org/Article" ${1}class="${2}type-post${3}"${4}',
56
+            '<h1 itemprop="name" ${1}class="${2}entry-title${3}"${4}',
57
+        );
58
+
59
+        // Perform the replacements in the buffer.
60
+        return preg_replace( $regexs, $replacements, $buffer );
61
+    }
62 62
 
63 63
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 	public function wp_head() {
19 19
 
20 20
 		// When the buffer is flushed, have the handler markup the content.
21
-		ob_start( array( $this, 'handler' ) );
21
+		ob_start(array($this, 'handler'));
22 22
 
23 23
 	}
24 24
 
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 	 *
43 43
 	 * @return string The processed output buffer.
44 44
 	 */
45
-	public function handler( $buffer ) {
45
+	public function handler($buffer) {
46 46
 
47 47
 		// Look for the following regexs.
48 48
 		$regexs = array(
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 		);
58 58
 
59 59
 		// Perform the replacements in the buffer.
60
-		return preg_replace( $regexs, $replacements, $buffer );
60
+		return preg_replace($regexs, $replacements, $buffer);
61 61
 	}
62 62
 
63 63
 }
Please login to merge, or discard this patch.
src/includes/class-wordlift-sanitizer.php 2 patches
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -4,22 +4,22 @@
 block discarded – undo
4 4
  */
5 5
 class Wordlift_Sanitizer {
6 6
 
7
-	/**
8
-	 * Only accept URIs
9
-	 */
10
-	public static function sanitize_url( $value ) {
7
+    /**
8
+     * Only accept URIs
9
+     */
10
+    public static function sanitize_url( $value ) {
11 11
 
12
-		// Initially this function used also filter_var( $value, FILTER_VALIDATE_URL )
13
-		// but URLs with UTF-8 characters are not valid. We store those anyway in the DB as it's up to the browser
14
-		// to do proper url encoding when requesting the URL.
15
-		//
16
-		// see also http://stackoverflow.com/questions/2137080/php-filter-var-filter-validate-url
12
+        // Initially this function used also filter_var( $value, FILTER_VALIDATE_URL )
13
+        // but URLs with UTF-8 characters are not valid. We store those anyway in the DB as it's up to the browser
14
+        // to do proper url encoding when requesting the URL.
15
+        //
16
+        // see also http://stackoverflow.com/questions/2137080/php-filter-var-filter-validate-url
17 17
 
18
-		if ( ! is_null( $value ) && $value !== '' ) {
19
-			return $value;
20
-		}
18
+        if ( ! is_null( $value ) && $value !== '' ) {
19
+            return $value;
20
+        }
21 21
 
22
-		return null;
23
-	}
22
+        return null;
23
+    }
24 24
 
25 25
 }
26 26
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
 	/**
8 8
 	 * Only accept URIs
9 9
 	 */
10
-	public static function sanitize_url( $value ) {
10
+	public static function sanitize_url($value) {
11 11
 
12 12
 		// Initially this function used also filter_var( $value, FILTER_VALIDATE_URL )
13 13
 		// but URLs with UTF-8 characters are not valid. We store those anyway in the DB as it's up to the browser
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
 		//
16 16
 		// see also http://stackoverflow.com/questions/2137080/php-filter-var-filter-validate-url
17 17
 
18
-		if ( ! is_null( $value ) && $value !== '' ) {
18
+		if ( ! is_null($value) && $value !== '') {
19 19
 			return $value;
20 20
 		}
21 21
 
Please login to merge, or discard this patch.
src/modules/linked_data/wordlift_linked_data.php 2 patches
Indentation   +320 added lines, -320 removed lines patch added patch discarded remove patch
@@ -14,19 +14,19 @@  discard block
 block discarded – undo
14 14
  */
15 15
 function wl_linked_data_save_post( $post_id ) {
16 16
 
17
-	// If it's not numeric exit from here.
18
-	if ( ! is_numeric( $post_id ) || is_numeric( wp_is_post_revision( $post_id ) ) ) {
19
-		return;
20
-	}
17
+    // If it's not numeric exit from here.
18
+    if ( ! is_numeric( $post_id ) || is_numeric( wp_is_post_revision( $post_id ) ) ) {
19
+        return;
20
+    }
21 21
 
22
-	// unhook this function so it doesn't loop infinitely
23
-	remove_action( 'save_post', 'wl_linked_data_save_post' );
22
+    // unhook this function so it doesn't loop infinitely
23
+    remove_action( 'save_post', 'wl_linked_data_save_post' );
24 24
 
25
-	// raise the *wl_linked_data_save_post* event.
26
-	do_action( 'wl_linked_data_save_post', $post_id );
25
+    // raise the *wl_linked_data_save_post* event.
26
+    do_action( 'wl_linked_data_save_post', $post_id );
27 27
 
28
-	// re-hook this function
29
-	add_action( 'save_post', 'wl_linked_data_save_post' );
28
+    // re-hook this function
29
+    add_action( 'save_post', 'wl_linked_data_save_post' );
30 30
 }
31 31
 
32 32
 add_action( 'save_post', 'wl_linked_data_save_post' );
@@ -40,143 +40,143 @@  discard block
 block discarded – undo
40 40
  */
41 41
 function wl_linked_data_save_post_and_related_entities( $post_id ) {
42 42
 
43
-	// Ignore auto-saves
44
-	if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
45
-		return;
46
-	}
43
+    // Ignore auto-saves
44
+    if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
45
+        return;
46
+    }
47 47
 
48
-	// get the current post.
49
-	$post = get_post( $post_id );
48
+    // get the current post.
49
+    $post = get_post( $post_id );
50 50
 
51
-	remove_action( 'wl_linked_data_save_post', 'wl_linked_data_save_post_and_related_entities' );
51
+    remove_action( 'wl_linked_data_save_post', 'wl_linked_data_save_post_and_related_entities' );
52 52
 
53
-	// wl_write_log( "[ post id :: $post_id ][ autosave :: false ][ post type :: $post->post_type ]" );
53
+    // wl_write_log( "[ post id :: $post_id ][ autosave :: false ][ post type :: $post->post_type ]" );
54 54
 
55
-	// Store mapping between tmp new entities uris and real new entities uri
56
-	$entities_uri_mapping = array();
55
+    // Store mapping between tmp new entities uris and real new entities uri
56
+    $entities_uri_mapping = array();
57 57
 
58
-	// Save the entities coming with POST data.
59
-	if ( isset( $_POST['wl_entities'] ) && isset( $_POST['wl_boxes'] ) ) {
58
+    // Save the entities coming with POST data.
59
+    if ( isset( $_POST['wl_entities'] ) && isset( $_POST['wl_boxes'] ) ) {
60 60
 
61
-		wl_write_log( "[ post id :: $post_id ][ POST(wl_entities) :: " );
62
-		wl_write_log( json_encode( $_POST['wl_entities'] ) );
63
-		wl_write_log( "]" );
64
-		wl_write_log( "[ post id :: $post_id ][ POST(wl_boxes) :: " );
65
-		wl_write_log( json_encode( $_POST['wl_boxes'], true ) );
66
-		wl_write_log( "]" );
61
+        wl_write_log( "[ post id :: $post_id ][ POST(wl_entities) :: " );
62
+        wl_write_log( json_encode( $_POST['wl_entities'] ) );
63
+        wl_write_log( "]" );
64
+        wl_write_log( "[ post id :: $post_id ][ POST(wl_boxes) :: " );
65
+        wl_write_log( json_encode( $_POST['wl_boxes'], true ) );
66
+        wl_write_log( "]" );
67 67
 
68
-		$entities_via_post = $_POST['wl_entities'];
69
-		$boxes_via_post    = $_POST['wl_boxes'];
68
+        $entities_via_post = $_POST['wl_entities'];
69
+        $boxes_via_post    = $_POST['wl_boxes'];
70 70
 
71
-		foreach ( $entities_via_post as $entity_uri => $entity ) {
71
+        foreach ( $entities_via_post as $entity_uri => $entity ) {
72 72
 
73
-			// Only if the current entity is created from scratch let's avoid to create 
74
-			// more than one entity with same label & entity type
75
-			$entity_type = ( preg_match( '/^local-entity-.+/', $entity_uri ) > 0 ) ?
76
-				$entity[ 'main_type' ] : NULL;
73
+            // Only if the current entity is created from scratch let's avoid to create 
74
+            // more than one entity with same label & entity type
75
+            $entity_type = ( preg_match( '/^local-entity-.+/', $entity_uri ) > 0 ) ?
76
+                $entity[ 'main_type' ] : NULL;
77 77
 
78
-			// Look if current entity uri matchs an internal existing entity, meaning:
79
-			// 1. when $entity_uri is an internal uri 
80
-			// 2. when $entity_uri is an external uri used as sameAs of an internal entity	
81
-			$ie = Wordlift_Entity_Service::get_instance()->get_entity_post_by_uri( $entity_uri );
78
+            // Look if current entity uri matchs an internal existing entity, meaning:
79
+            // 1. when $entity_uri is an internal uri 
80
+            // 2. when $entity_uri is an external uri used as sameAs of an internal entity	
81
+            $ie = Wordlift_Entity_Service::get_instance()->get_entity_post_by_uri( $entity_uri );
82 82
 
83
-			// Detect the uri depending if is an existing or a new entity
84
-			$uri = ( NULL === $ie ) ?
85
-				Wordlift_Entity_Service::get_instance()->build_uri(
86
-					$entity[ 'label' ],
87
-					Wordlift_Entity_Service::TYPE_NAME,
88
-					$entity_type
89
-				) : wl_get_entity_uri( $ie->ID );
83
+            // Detect the uri depending if is an existing or a new entity
84
+            $uri = ( NULL === $ie ) ?
85
+                Wordlift_Entity_Service::get_instance()->build_uri(
86
+                    $entity[ 'label' ],
87
+                    Wordlift_Entity_Service::TYPE_NAME,
88
+                    $entity_type
89
+                ) : wl_get_entity_uri( $ie->ID );
90 90
 
91
-			wl_write_log("Map $entity_uri on $uri");
92
-			$entities_uri_mapping[ $entity_uri ] = $uri;
91
+            wl_write_log("Map $entity_uri on $uri");
92
+            $entities_uri_mapping[ $entity_uri ] = $uri;
93 93
 
94
-			// Local entities have a tmp uri with 'local-entity-' prefix
95
-			// These uris need to be rewritten here and replaced in the content
96
-			if ( preg_match( '/^local-entity-.+/', $entity_uri ) > 0 ) {
97
-				// Override the entity obj
98
-				$entity[ 'uri' ] = $uri;
99
-			}
94
+            // Local entities have a tmp uri with 'local-entity-' prefix
95
+            // These uris need to be rewritten here and replaced in the content
96
+            if ( preg_match( '/^local-entity-.+/', $entity_uri ) > 0 ) {
97
+                // Override the entity obj
98
+                $entity[ 'uri' ] = $uri;
99
+            }
100 100
 
101
-			// Update entity data with related post
102
-			$entity[ 'related_post_id' ] = $post_id;
101
+            // Update entity data with related post
102
+            $entity[ 'related_post_id' ] = $post_id;
103 103
 
104
-			// Save the entity if is a new entity
105
-			if ( NULL === $ie ) {
106
-				wl_save_entity( $entity );
107
-			}
104
+            // Save the entity if is a new entity
105
+            if ( NULL === $ie ) {
106
+                wl_save_entity( $entity );
107
+            }
108 108
 
109
-		}
109
+        }
110 110
 
111
-	}
111
+    }
112 112
 
113
-	// Replace tmp uris in content post if needed
114
-	$updated_post_content = $post->post_content;
115
-	// Save each entity and store the post id.
116
-	foreach ( $entities_uri_mapping as $tmp_uri => $uri ) {
117
-		$updated_post_content = str_replace( $tmp_uri, $uri, $updated_post_content );
118
-	}
113
+    // Replace tmp uris in content post if needed
114
+    $updated_post_content = $post->post_content;
115
+    // Save each entity and store the post id.
116
+    foreach ( $entities_uri_mapping as $tmp_uri => $uri ) {
117
+        $updated_post_content = str_replace( $tmp_uri, $uri, $updated_post_content );
118
+    }
119 119
 
120
-	// Update the post content
121
-	wp_update_post( array(
122
-		'ID'           => $post->ID,
123
-		'post_content' => $updated_post_content,
124
-	) );
120
+    // Update the post content
121
+    wp_update_post( array(
122
+        'ID'           => $post->ID,
123
+        'post_content' => $updated_post_content,
124
+    ) );
125 125
 
126
-	// Extract related/referenced entities from text.
127
-	$disambiguated_entities = wl_linked_data_content_get_embedded_entities( $updated_post_content );
126
+    // Extract related/referenced entities from text.
127
+    $disambiguated_entities = wl_linked_data_content_get_embedded_entities( $updated_post_content );
128 128
 
129
-	// Reset previously saved instances
130
-	wl_core_delete_relation_instances( $post_id );
129
+    // Reset previously saved instances
130
+    wl_core_delete_relation_instances( $post_id );
131 131
 
132
-	// Save relation instances
133
-	foreach ( array_unique( $disambiguated_entities ) as $referenced_entity_id ) {
132
+    // Save relation instances
133
+    foreach ( array_unique( $disambiguated_entities ) as $referenced_entity_id ) {
134 134
 
135
-		wl_core_add_relation_instance(
136
-			$post_id,
137
-			Wordlift_Entity_Service::get_instance()->get_classification_scope_for( $referenced_entity_id ),
138
-			$referenced_entity_id
139
-		);
135
+        wl_core_add_relation_instance(
136
+            $post_id,
137
+            Wordlift_Entity_Service::get_instance()->get_classification_scope_for( $referenced_entity_id ),
138
+            $referenced_entity_id
139
+        );
140 140
 
141
-	}
141
+    }
142 142
 
143 143
     if ( isset( $_POST['wl_entities'] ) ) {
144
-		// Save post metadata if available
145
-		$metadata_via_post    =  ( isset( $_POST['wl_metadata'] ) ) ?
146
-			$_POST['wl_metadata'] : array();
147
-
148
-		$fields = array(
149
-			Wordlift_Schema_Service::FIELD_LOCATION_CREATED,
150
-			Wordlift_Schema_Service::FIELD_TOPIC
151
-		);
152
-
153
-		// Unlink topic taxonomy terms
154
-		Wordlift_Topic_Taxonomy_Service::get_instance()->unlink_topic_for( $post->ID );
155
-
156
-		foreach ( $fields as $field ) {
157
-
158
-			// Delete current values
159
-			delete_post_meta( $post->ID, $field );
160
-			// Retrieve the entity uri
161
-			$uri 	= ( isset( $metadata_via_post[ $field ] ) ) ?
162
-				stripslashes( $metadata_via_post[ $field ] ) : '';
163
-
164
-			$entity = Wordlift_Entity_Service::get_instance()->get_entity_post_by_uri( $uri );
165
-
166
-			if ( $entity ) {
167
-				add_post_meta( $post->ID, $field, $entity->ID, true );
168
-				// Set also the topic taxonomy
169
-				if ( $field === Wordlift_Schema_Service::FIELD_TOPIC ) {
170
-					Wordlift_Topic_Taxonomy_Service::get_instance()->set_topic_for( $post->ID, $entity );
171
-				}
172
-			}
173
-		}
174
-	}
175
-
176
-	// Push the post to Redlink.
177
-	wl_linked_data_push_to_redlink( $post->ID );
178
-
179
-	add_action( 'wl_linked_data_save_post', 'wl_linked_data_save_post_and_related_entities' );
144
+        // Save post metadata if available
145
+        $metadata_via_post    =  ( isset( $_POST['wl_metadata'] ) ) ?
146
+            $_POST['wl_metadata'] : array();
147
+
148
+        $fields = array(
149
+            Wordlift_Schema_Service::FIELD_LOCATION_CREATED,
150
+            Wordlift_Schema_Service::FIELD_TOPIC
151
+        );
152
+
153
+        // Unlink topic taxonomy terms
154
+        Wordlift_Topic_Taxonomy_Service::get_instance()->unlink_topic_for( $post->ID );
155
+
156
+        foreach ( $fields as $field ) {
157
+
158
+            // Delete current values
159
+            delete_post_meta( $post->ID, $field );
160
+            // Retrieve the entity uri
161
+            $uri 	= ( isset( $metadata_via_post[ $field ] ) ) ?
162
+                stripslashes( $metadata_via_post[ $field ] ) : '';
163
+
164
+            $entity = Wordlift_Entity_Service::get_instance()->get_entity_post_by_uri( $uri );
165
+
166
+            if ( $entity ) {
167
+                add_post_meta( $post->ID, $field, $entity->ID, true );
168
+                // Set also the topic taxonomy
169
+                if ( $field === Wordlift_Schema_Service::FIELD_TOPIC ) {
170
+                    Wordlift_Topic_Taxonomy_Service::get_instance()->set_topic_for( $post->ID, $entity );
171
+                }
172
+            }
173
+        }
174
+    }
175
+
176
+    // Push the post to Redlink.
177
+    wl_linked_data_push_to_redlink( $post->ID );
178
+
179
+    add_action( 'wl_linked_data_save_post', 'wl_linked_data_save_post_and_related_entities' );
180 180
 }
181 181
 
182 182
 add_action( 'wl_linked_data_save_post', 'wl_linked_data_save_post_and_related_entities' );
@@ -186,13 +186,13 @@  discard block
 block discarded – undo
186 186
  */
187 187
 function wordlift_save_post_add_default_schema_type( $entity_id ) {
188 188
 
189
-	$entity      = get_post( $entity_id );
190
-	$entity_type = wl_schema_get_types( $entity_id );
189
+    $entity      = get_post( $entity_id );
190
+    $entity_type = wl_schema_get_types( $entity_id );
191 191
 
192
-	// Assign type 'Thing' if we are dealing with an entity without type
193
-	if ( $entity->post_type == Wordlift_Entity_Service::TYPE_NAME && is_null( $entity_type ) ) {
194
-		wl_schema_set_types( $entity_id, 'Thing' );
195
-	}
192
+    // Assign type 'Thing' if we are dealing with an entity without type
193
+    if ( $entity->post_type == Wordlift_Entity_Service::TYPE_NAME && is_null( $entity_type ) ) {
194
+        wl_schema_set_types( $entity_id, 'Thing' );
195
+    }
196 196
 
197 197
 }
198 198
 
@@ -218,166 +218,166 @@  discard block
 block discarded – undo
218 218
  */
219 219
 function wl_save_entity( $entity_data ) {
220 220
 
221
-	$uri              = $entity_data['uri'];
222
-	$label            = $entity_data['label'];
223
-	$type_uri         = $entity_data['main_type'];
224
-	$entity_types     = isset( $entity_data['type'] ) ? $entity_data['type'] : array();
225
-	$description      = $entity_data['description'];
226
-	$images           = isset( $entity_data['image'] ) ? wl_force_to_array( $entity_data['image'] ) : array();
227
-	$same_as          = isset( $entity_data['sameas'] ) ? wl_force_to_array( $entity_data['sameas'] ) : array();
228
-	$related_post_id  = isset( $entity_data['related_post_id'] ) ? $entity_data['related_post_id'] : null;
229
-	$other_properties = isset( $entity_data['properties'] ) ? $entity_data['properties'] : array();
230
-
231
-	// wl_write_log( "[ uri :: $uri ][ label :: $label ][ type uri :: $type_uri ]" );
232
-
233
-	// Prepare properties of the new entity.
234
-	$params = array(
235
-		'post_status'  => ( is_numeric( $related_post_id ) ? get_post_status( $related_post_id ) : 'draft' ),
236
-		'post_type'    => Wordlift_Entity_Service::TYPE_NAME,
237
-		'post_title'   => $label,
238
-		'post_content' => $description,
239
-		'post_excerpt' => ''
240
-	);
241
-
242
-	// Check whether an entity already exists with the provided URI.
243
-	$post = Wordlift_Entity_Service::get_instance()->get_entity_post_by_uri( $uri );
244
-
245
-	if ( null !== $post ) {
246
-		return $post;
247
-	}
248
-
249
-	// If Yoast is installed and active, we temporary remove the save_postdata hook which causes Yoast to "pass over"
250
-	// the local SEO form values to the created entity (https://github.com/insideout10/wordlift-plugin/issues/156)
251
-	// Same thing applies to SEO Ultimate (https://github.com/insideout10/wordlift-plugin/issues/148)
252
-	// This does NOT affect saving an entity from the entity admin page since this function is called when an entity
253
-	// is created when saving a post.
254
-	global $wpseo_metabox, $seo_ultimate;
255
-	if ( isset( $wpseo_metabox ) ) {
256
-		remove_action( 'wp_insert_post', array( $wpseo_metabox, 'save_postdata' ) );
257
-	}
258
-
259
-	if ( isset( $seo_ultimate ) ) {
260
-		remove_action( 'save_post', array( $seo_ultimate, 'save_postmeta_box' ) );
261
-	}
262
-
263
-	// The fact that we're calling here wp_insert_post is causing issues with plugins (and ourselves too) that hook to
264
-	// save_post in order to save additional inputs from the edit page. In order to avoid issues, we pop all the hooks
265
-	// to the save_post and restore them after we saved the entity.
266
-	// see https://github.com/insideout10/wordlift-plugin/issues/203
267
-	// see https://github.com/insideout10/wordlift-plugin/issues/156
268
-	// see https://github.com/insideout10/wordlift-plugin/issues/148
269
-	global $wp_filter;
270
-	$save_post_filters      = $wp_filter['save_post'];
271
-	$wp_filter['save_post'] = array();
272
-
273
-	// create or update the post.
274
-	$post_id = wp_insert_post( $params, true );
275
-
276
-	// Restore all the existing filters.
277
-	$wp_filter['save_post'] = $save_post_filters;
278
-
279
-	// If Yoast is installed and active, we restore the Yoast save_postdata hook (https://github.com/insideout10/wordlift-plugin/issues/156)
280
-	if ( isset( $wpseo_metabox ) ) {
281
-		add_action( 'wp_insert_post', array( $wpseo_metabox, 'save_postdata' ) );
282
-	}
283
-
284
-	// If SEO Ultimate is installed, add back the hook we removed a few lines above.
285
-	if ( isset( $seo_ultimate ) ) {
286
-		add_action( 'save_post', array( $seo_ultimate, 'save_postmeta_box' ), 10, 2 );
287
-	}
288
-
289
-	// TODO: handle errors.
290
-	if ( is_wp_error( $post_id ) ) {
291
-		wl_write_log( ': error occurred' );
292
-
293
-		// inform an error occurred.
294
-		return null;
295
-	}
296
-
297
-	wl_set_entity_main_type( $post_id, $type_uri );
298
-
299
-	// Save the entity types.
300
-	wl_set_entity_rdf_types( $post_id, $entity_types );
301
-
302
-	// Get a dataset URI for the entity.
303
-	$wl_uri = wl_build_entity_uri( $post_id );
304
-
305
-	// Save the entity URI.
306
-	wl_set_entity_uri( $post_id, $wl_uri );
307
-
308
-	// Add the uri to the sameAs data if it's not a local URI.
309
-	if ( $wl_uri !== $uri ) {
310
-		array_push( $same_as, $uri );
311
-	}
312
-
313
-	$new_uri = wl_get_entity_uri( $post_id );
314
-
315
-	// Save the sameAs data for the entity.
316
-	wl_schema_set_value( $post_id, 'sameAs', $same_as );
317
-
318
-	// Save the other properties (latitude, langitude, startDate, endDate, etc.)
319
-	foreach ( $other_properties as $property_name => $property_value ) {
320
-		wl_schema_set_value( $post_id, $property_name, $property_value );
321
-	}
322
-
323
-	// Call hooks.
324
-	do_action( 'wl_save_entity', $post_id );
325
-
326
-	wl_write_log( "[ post id :: $post_id ][ uri :: $uri ][ label :: $label ][ wl uri :: $wl_uri ][ types :: " . implode( ',', $entity_types ) . " ][ images count :: " . count( $images ) . " ][ same_as count :: " . count( $same_as ) . " ]" );
327
-
328
-	foreach ( $images as $image_remote_url ) {
329
-
330
-		// Check if image is already present in local DB
331
-		if ( strpos( $image_remote_url, site_url() ) !== false ) {
332
-			// Do nothing.
333
-			continue;
334
-		}
335
-
336
-		// Check if there is an existing attachment for this post ID and source URL.
337
-		$existing_image = wl_get_attachment_for_source_url( $post_id, $image_remote_url );
338
-
339
-		// Skip if an existing image is found.
340
-		if ( null !== $existing_image ) {
341
-			continue;
342
-		}
343
-
344
-		// Save the image and get the local path.
345
-		$image = wl_save_image( $image_remote_url );
346
-
347
-		// Get the local URL.
348
-		$filename     = $image['path'];
349
-		$url          = $image['url'];
350
-		$content_type = $image['content_type'];
351
-
352
-		$attachment = array(
353
-			'guid'           => $url,
354
-			// post_title, post_content (the value for this key should be the empty string), post_status and post_mime_type
355
-			'post_title'     => $label,
356
-			// Set the title to the post title.
357
-			'post_content'   => '',
358
-			'post_status'    => 'inherit',
359
-			'post_mime_type' => $content_type
360
-		);
221
+    $uri              = $entity_data['uri'];
222
+    $label            = $entity_data['label'];
223
+    $type_uri         = $entity_data['main_type'];
224
+    $entity_types     = isset( $entity_data['type'] ) ? $entity_data['type'] : array();
225
+    $description      = $entity_data['description'];
226
+    $images           = isset( $entity_data['image'] ) ? wl_force_to_array( $entity_data['image'] ) : array();
227
+    $same_as          = isset( $entity_data['sameas'] ) ? wl_force_to_array( $entity_data['sameas'] ) : array();
228
+    $related_post_id  = isset( $entity_data['related_post_id'] ) ? $entity_data['related_post_id'] : null;
229
+    $other_properties = isset( $entity_data['properties'] ) ? $entity_data['properties'] : array();
230
+
231
+    // wl_write_log( "[ uri :: $uri ][ label :: $label ][ type uri :: $type_uri ]" );
232
+
233
+    // Prepare properties of the new entity.
234
+    $params = array(
235
+        'post_status'  => ( is_numeric( $related_post_id ) ? get_post_status( $related_post_id ) : 'draft' ),
236
+        'post_type'    => Wordlift_Entity_Service::TYPE_NAME,
237
+        'post_title'   => $label,
238
+        'post_content' => $description,
239
+        'post_excerpt' => ''
240
+    );
241
+
242
+    // Check whether an entity already exists with the provided URI.
243
+    $post = Wordlift_Entity_Service::get_instance()->get_entity_post_by_uri( $uri );
244
+
245
+    if ( null !== $post ) {
246
+        return $post;
247
+    }
248
+
249
+    // If Yoast is installed and active, we temporary remove the save_postdata hook which causes Yoast to "pass over"
250
+    // the local SEO form values to the created entity (https://github.com/insideout10/wordlift-plugin/issues/156)
251
+    // Same thing applies to SEO Ultimate (https://github.com/insideout10/wordlift-plugin/issues/148)
252
+    // This does NOT affect saving an entity from the entity admin page since this function is called when an entity
253
+    // is created when saving a post.
254
+    global $wpseo_metabox, $seo_ultimate;
255
+    if ( isset( $wpseo_metabox ) ) {
256
+        remove_action( 'wp_insert_post', array( $wpseo_metabox, 'save_postdata' ) );
257
+    }
258
+
259
+    if ( isset( $seo_ultimate ) ) {
260
+        remove_action( 'save_post', array( $seo_ultimate, 'save_postmeta_box' ) );
261
+    }
262
+
263
+    // The fact that we're calling here wp_insert_post is causing issues with plugins (and ourselves too) that hook to
264
+    // save_post in order to save additional inputs from the edit page. In order to avoid issues, we pop all the hooks
265
+    // to the save_post and restore them after we saved the entity.
266
+    // see https://github.com/insideout10/wordlift-plugin/issues/203
267
+    // see https://github.com/insideout10/wordlift-plugin/issues/156
268
+    // see https://github.com/insideout10/wordlift-plugin/issues/148
269
+    global $wp_filter;
270
+    $save_post_filters      = $wp_filter['save_post'];
271
+    $wp_filter['save_post'] = array();
272
+
273
+    // create or update the post.
274
+    $post_id = wp_insert_post( $params, true );
275
+
276
+    // Restore all the existing filters.
277
+    $wp_filter['save_post'] = $save_post_filters;
278
+
279
+    // If Yoast is installed and active, we restore the Yoast save_postdata hook (https://github.com/insideout10/wordlift-plugin/issues/156)
280
+    if ( isset( $wpseo_metabox ) ) {
281
+        add_action( 'wp_insert_post', array( $wpseo_metabox, 'save_postdata' ) );
282
+    }
283
+
284
+    // If SEO Ultimate is installed, add back the hook we removed a few lines above.
285
+    if ( isset( $seo_ultimate ) ) {
286
+        add_action( 'save_post', array( $seo_ultimate, 'save_postmeta_box' ), 10, 2 );
287
+    }
288
+
289
+    // TODO: handle errors.
290
+    if ( is_wp_error( $post_id ) ) {
291
+        wl_write_log( ': error occurred' );
292
+
293
+        // inform an error occurred.
294
+        return null;
295
+    }
296
+
297
+    wl_set_entity_main_type( $post_id, $type_uri );
298
+
299
+    // Save the entity types.
300
+    wl_set_entity_rdf_types( $post_id, $entity_types );
301
+
302
+    // Get a dataset URI for the entity.
303
+    $wl_uri = wl_build_entity_uri( $post_id );
304
+
305
+    // Save the entity URI.
306
+    wl_set_entity_uri( $post_id, $wl_uri );
307
+
308
+    // Add the uri to the sameAs data if it's not a local URI.
309
+    if ( $wl_uri !== $uri ) {
310
+        array_push( $same_as, $uri );
311
+    }
312
+
313
+    $new_uri = wl_get_entity_uri( $post_id );
314
+
315
+    // Save the sameAs data for the entity.
316
+    wl_schema_set_value( $post_id, 'sameAs', $same_as );
317
+
318
+    // Save the other properties (latitude, langitude, startDate, endDate, etc.)
319
+    foreach ( $other_properties as $property_name => $property_value ) {
320
+        wl_schema_set_value( $post_id, $property_name, $property_value );
321
+    }
322
+
323
+    // Call hooks.
324
+    do_action( 'wl_save_entity', $post_id );
325
+
326
+    wl_write_log( "[ post id :: $post_id ][ uri :: $uri ][ label :: $label ][ wl uri :: $wl_uri ][ types :: " . implode( ',', $entity_types ) . " ][ images count :: " . count( $images ) . " ][ same_as count :: " . count( $same_as ) . " ]" );
327
+
328
+    foreach ( $images as $image_remote_url ) {
329
+
330
+        // Check if image is already present in local DB
331
+        if ( strpos( $image_remote_url, site_url() ) !== false ) {
332
+            // Do nothing.
333
+            continue;
334
+        }
335
+
336
+        // Check if there is an existing attachment for this post ID and source URL.
337
+        $existing_image = wl_get_attachment_for_source_url( $post_id, $image_remote_url );
338
+
339
+        // Skip if an existing image is found.
340
+        if ( null !== $existing_image ) {
341
+            continue;
342
+        }
343
+
344
+        // Save the image and get the local path.
345
+        $image = wl_save_image( $image_remote_url );
346
+
347
+        // Get the local URL.
348
+        $filename     = $image['path'];
349
+        $url          = $image['url'];
350
+        $content_type = $image['content_type'];
351
+
352
+        $attachment = array(
353
+            'guid'           => $url,
354
+            // post_title, post_content (the value for this key should be the empty string), post_status and post_mime_type
355
+            'post_title'     => $label,
356
+            // Set the title to the post title.
357
+            'post_content'   => '',
358
+            'post_status'    => 'inherit',
359
+            'post_mime_type' => $content_type
360
+        );
361 361
 
362
-		// Create the attachment in WordPress and generate the related metadata.
363
-		$attachment_id = wp_insert_attachment( $attachment, $filename, $post_id );
362
+        // Create the attachment in WordPress and generate the related metadata.
363
+        $attachment_id = wp_insert_attachment( $attachment, $filename, $post_id );
364 364
 
365
-		// Set the source URL for the image.
366
-		wl_set_source_url( $attachment_id, $image_remote_url );
365
+        // Set the source URL for the image.
366
+        wl_set_source_url( $attachment_id, $image_remote_url );
367 367
 
368
-		$attachment_data = wp_generate_attachment_metadata( $attachment_id, $filename );
369
-		wp_update_attachment_metadata( $attachment_id, $attachment_data );
368
+        $attachment_data = wp_generate_attachment_metadata( $attachment_id, $filename );
369
+        wp_update_attachment_metadata( $attachment_id, $attachment_data );
370 370
 
371
-		// Set it as the featured image.
372
-		set_post_thumbnail( $post_id, $attachment_id );
373
-	}
371
+        // Set it as the featured image.
372
+        set_post_thumbnail( $post_id, $attachment_id );
373
+    }
374 374
 
375
-	// The entity is pushed to Redlink on save by the function hooked to save_post.
376
-	// save the entity in the triple store.
377
-	wl_linked_data_push_to_redlink( $post_id );
375
+    // The entity is pushed to Redlink on save by the function hooked to save_post.
376
+    // save the entity in the triple store.
377
+    wl_linked_data_push_to_redlink( $post_id );
378 378
 
379
-	// finally return the entity post.
380
-	return get_post( $post_id );
379
+    // finally return the entity post.
380
+    return get_post( $post_id );
381 381
 }
382 382
 
383 383
 /**
@@ -391,42 +391,42 @@  discard block
 block discarded – undo
391 391
  */
392 392
 function wl_linked_data_content_get_embedded_entities( $content ) {
393 393
 
394
-	// Remove quote escapes.
395
-	$content = str_replace( '\\"', '"', $content );
394
+    // Remove quote escapes.
395
+    $content = str_replace( '\\"', '"', $content );
396 396
 
397
-	// Match all itemid attributes.
398
-	$pattern = '/<\w+[^>]*\sitemid="([^"]+)"[^>]*>/im';
397
+    // Match all itemid attributes.
398
+    $pattern = '/<\w+[^>]*\sitemid="([^"]+)"[^>]*>/im';
399 399
 
400
-	//	wl_write_log( "Getting entities embedded into content [ pattern :: $pattern ]" );
400
+    //	wl_write_log( "Getting entities embedded into content [ pattern :: $pattern ]" );
401 401
 
402
-	// Remove the pattern while it is found (match nested annotations).
403
-	$matches = array();
402
+    // Remove the pattern while it is found (match nested annotations).
403
+    $matches = array();
404 404
 
405
-	// In case of errors, return an empty array.
406
-	if ( false === preg_match_all( $pattern, $content, $matches ) ) {
407
-		wl_write_log( "Found no entities embedded in content" );
405
+    // In case of errors, return an empty array.
406
+    if ( false === preg_match_all( $pattern, $content, $matches ) ) {
407
+        wl_write_log( "Found no entities embedded in content" );
408 408
 
409
-		return array();
410
-	}
409
+        return array();
410
+    }
411 411
 
412 412
 //    wl_write_log("wl_update_related_entities [ content :: $content ][ data :: " . var_export($data, true). " ][ matches :: " . var_export($matches, true) . " ]");
413 413
 
414
-	// Collect the entities.
415
-	$entities = array();
416
-	foreach ( $matches[1] as $uri ) {
417
-		$uri_d  = html_entity_decode( $uri );
414
+    // Collect the entities.
415
+    $entities = array();
416
+    foreach ( $matches[1] as $uri ) {
417
+        $uri_d  = html_entity_decode( $uri );
418 418
 
419
-		$entity = Wordlift_Entity_Service::get_instance()->get_entity_post_by_uri( $uri_d );
419
+        $entity = Wordlift_Entity_Service::get_instance()->get_entity_post_by_uri( $uri_d );
420 420
 
421
-		if ( null !== $entity ) {
422
-			array_push( $entities, $entity->ID );
423
-		}
424
-	}
421
+        if ( null !== $entity ) {
422
+            array_push( $entities, $entity->ID );
423
+        }
424
+    }
425 425
 
426
-	// $count = sizeof( $entities );
427
-	// wl_write_log( "Found $count entities embedded in content" );
426
+    // $count = sizeof( $entities );
427
+    // wl_write_log( "Found $count entities embedded in content" );
428 428
 
429
-	return $entities;
429
+    return $entities;
430 430
 }
431 431
 
432 432
 /**
@@ -438,22 +438,22 @@  discard block
 block discarded – undo
438 438
  */
439 439
 function wl_linked_data_push_to_redlink( $post_id ) {
440 440
 
441
-	// Get the post.
442
-	$post = get_post( $post_id );
441
+    // Get the post.
442
+    $post = get_post( $post_id );
443 443
 
444
-	// wl_write_log( "wl_linked_data_push_to_redlink [ post id :: $post_id ][ post type :: $post->post_type ]" );
444
+    // wl_write_log( "wl_linked_data_push_to_redlink [ post id :: $post_id ][ post type :: $post->post_type ]" );
445 445
 
446
-	// Call the method on behalf of the post type.
447
-	switch ( $post->post_type ) {
448
-		case 'entity':
449
-			wl_push_entity_post_to_redlink( $post );
450
-			break;
451
-		default:
452
-			wl_push_post_to_redlink( $post );
453
-	}
446
+    // Call the method on behalf of the post type.
447
+    switch ( $post->post_type ) {
448
+        case 'entity':
449
+            wl_push_entity_post_to_redlink( $post );
450
+            break;
451
+        default:
452
+            wl_push_post_to_redlink( $post );
453
+    }
454 454
 
455
-	// Reindex the triple store if buffering is turned off.
456
-	if ( false === WL_ENABLE_SPARQL_UPDATE_QUERIES_BUFFERING ) {
457
-		wordlift_reindex_triple_store();
458
-	}
455
+    // Reindex the triple store if buffering is turned off.
456
+    if ( false === WL_ENABLE_SPARQL_UPDATE_QUERIES_BUFFERING ) {
457
+        wordlift_reindex_triple_store();
458
+    }
459 459
 }
Please login to merge, or discard this patch.
Spacing   +119 added lines, -119 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
  * The Linked Data module provides synchronization of local WordPress data with the remote Linked Data store.
4 4
  */
5 5
 
6
-require_once( 'wordlift_linked_data_images.php' );
6
+require_once('wordlift_linked_data_images.php');
7 7
 
8 8
 /**
9 9
  * Receive events from post saves, and split them according to the post type.
@@ -12,24 +12,24 @@  discard block
 block discarded – undo
12 12
  *
13 13
  * @param int $post_id The post id.
14 14
  */
15
-function wl_linked_data_save_post( $post_id ) {
15
+function wl_linked_data_save_post($post_id) {
16 16
 
17 17
 	// If it's not numeric exit from here.
18
-	if ( ! is_numeric( $post_id ) || is_numeric( wp_is_post_revision( $post_id ) ) ) {
18
+	if ( ! is_numeric($post_id) || is_numeric(wp_is_post_revision($post_id))) {
19 19
 		return;
20 20
 	}
21 21
 
22 22
 	// unhook this function so it doesn't loop infinitely
23
-	remove_action( 'save_post', 'wl_linked_data_save_post' );
23
+	remove_action('save_post', 'wl_linked_data_save_post');
24 24
 
25 25
 	// raise the *wl_linked_data_save_post* event.
26
-	do_action( 'wl_linked_data_save_post', $post_id );
26
+	do_action('wl_linked_data_save_post', $post_id);
27 27
 
28 28
 	// re-hook this function
29
-	add_action( 'save_post', 'wl_linked_data_save_post' );
29
+	add_action('save_post', 'wl_linked_data_save_post');
30 30
 }
31 31
 
32
-add_action( 'save_post', 'wl_linked_data_save_post' );
32
+add_action('save_post', 'wl_linked_data_save_post');
33 33
 
34 34
 /**
35 35
  * Save the post to the triple store. Also saves the entities locally and on the triple store.
@@ -38,17 +38,17 @@  discard block
 block discarded – undo
38 38
  *
39 39
  * @param int $post_id The post id being saved.
40 40
  */
41
-function wl_linked_data_save_post_and_related_entities( $post_id ) {
41
+function wl_linked_data_save_post_and_related_entities($post_id) {
42 42
 
43 43
 	// Ignore auto-saves
44
-	if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
44
+	if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
45 45
 		return;
46 46
 	}
47 47
 
48 48
 	// get the current post.
49
-	$post = get_post( $post_id );
49
+	$post = get_post($post_id);
50 50
 
51
-	remove_action( 'wl_linked_data_save_post', 'wl_linked_data_save_post_and_related_entities' );
51
+	remove_action('wl_linked_data_save_post', 'wl_linked_data_save_post_and_related_entities');
52 52
 
53 53
 	// wl_write_log( "[ post id :: $post_id ][ autosave :: false ][ post type :: $post->post_type ]" );
54 54
 
@@ -56,54 +56,54 @@  discard block
 block discarded – undo
56 56
 	$entities_uri_mapping = array();
57 57
 
58 58
 	// Save the entities coming with POST data.
59
-	if ( isset( $_POST['wl_entities'] ) && isset( $_POST['wl_boxes'] ) ) {
59
+	if (isset($_POST['wl_entities']) && isset($_POST['wl_boxes'])) {
60 60
 
61
-		wl_write_log( "[ post id :: $post_id ][ POST(wl_entities) :: " );
62
-		wl_write_log( json_encode( $_POST['wl_entities'] ) );
63
-		wl_write_log( "]" );
64
-		wl_write_log( "[ post id :: $post_id ][ POST(wl_boxes) :: " );
65
-		wl_write_log( json_encode( $_POST['wl_boxes'], true ) );
66
-		wl_write_log( "]" );
61
+		wl_write_log("[ post id :: $post_id ][ POST(wl_entities) :: ");
62
+		wl_write_log(json_encode($_POST['wl_entities']));
63
+		wl_write_log("]");
64
+		wl_write_log("[ post id :: $post_id ][ POST(wl_boxes) :: ");
65
+		wl_write_log(json_encode($_POST['wl_boxes'], true));
66
+		wl_write_log("]");
67 67
 
68 68
 		$entities_via_post = $_POST['wl_entities'];
69 69
 		$boxes_via_post    = $_POST['wl_boxes'];
70 70
 
71
-		foreach ( $entities_via_post as $entity_uri => $entity ) {
71
+		foreach ($entities_via_post as $entity_uri => $entity) {
72 72
 
73 73
 			// Only if the current entity is created from scratch let's avoid to create 
74 74
 			// more than one entity with same label & entity type
75
-			$entity_type = ( preg_match( '/^local-entity-.+/', $entity_uri ) > 0 ) ?
76
-				$entity[ 'main_type' ] : NULL;
75
+			$entity_type = (preg_match('/^local-entity-.+/', $entity_uri) > 0) ?
76
+				$entity['main_type'] : NULL;
77 77
 
78 78
 			// Look if current entity uri matchs an internal existing entity, meaning:
79 79
 			// 1. when $entity_uri is an internal uri 
80 80
 			// 2. when $entity_uri is an external uri used as sameAs of an internal entity	
81
-			$ie = Wordlift_Entity_Service::get_instance()->get_entity_post_by_uri( $entity_uri );
81
+			$ie = Wordlift_Entity_Service::get_instance()->get_entity_post_by_uri($entity_uri);
82 82
 
83 83
 			// Detect the uri depending if is an existing or a new entity
84
-			$uri = ( NULL === $ie ) ?
84
+			$uri = (NULL === $ie) ?
85 85
 				Wordlift_Entity_Service::get_instance()->build_uri(
86
-					$entity[ 'label' ],
86
+					$entity['label'],
87 87
 					Wordlift_Entity_Service::TYPE_NAME,
88 88
 					$entity_type
89
-				) : wl_get_entity_uri( $ie->ID );
89
+				) : wl_get_entity_uri($ie->ID);
90 90
 
91 91
 			wl_write_log("Map $entity_uri on $uri");
92
-			$entities_uri_mapping[ $entity_uri ] = $uri;
92
+			$entities_uri_mapping[$entity_uri] = $uri;
93 93
 
94 94
 			// Local entities have a tmp uri with 'local-entity-' prefix
95 95
 			// These uris need to be rewritten here and replaced in the content
96
-			if ( preg_match( '/^local-entity-.+/', $entity_uri ) > 0 ) {
96
+			if (preg_match('/^local-entity-.+/', $entity_uri) > 0) {
97 97
 				// Override the entity obj
98
-				$entity[ 'uri' ] = $uri;
98
+				$entity['uri'] = $uri;
99 99
 			}
100 100
 
101 101
 			// Update entity data with related post
102
-			$entity[ 'related_post_id' ] = $post_id;
102
+			$entity['related_post_id'] = $post_id;
103 103
 
104 104
 			// Save the entity if is a new entity
105
-			if ( NULL === $ie ) {
106
-				wl_save_entity( $entity );
105
+			if (NULL === $ie) {
106
+				wl_save_entity($entity);
107 107
 			}
108 108
 
109 109
 		}
@@ -113,36 +113,36 @@  discard block
 block discarded – undo
113 113
 	// Replace tmp uris in content post if needed
114 114
 	$updated_post_content = $post->post_content;
115 115
 	// Save each entity and store the post id.
116
-	foreach ( $entities_uri_mapping as $tmp_uri => $uri ) {
117
-		$updated_post_content = str_replace( $tmp_uri, $uri, $updated_post_content );
116
+	foreach ($entities_uri_mapping as $tmp_uri => $uri) {
117
+		$updated_post_content = str_replace($tmp_uri, $uri, $updated_post_content);
118 118
 	}
119 119
 
120 120
 	// Update the post content
121
-	wp_update_post( array(
121
+	wp_update_post(array(
122 122
 		'ID'           => $post->ID,
123 123
 		'post_content' => $updated_post_content,
124
-	) );
124
+	));
125 125
 
126 126
 	// Extract related/referenced entities from text.
127
-	$disambiguated_entities = wl_linked_data_content_get_embedded_entities( $updated_post_content );
127
+	$disambiguated_entities = wl_linked_data_content_get_embedded_entities($updated_post_content);
128 128
 
129 129
 	// Reset previously saved instances
130
-	wl_core_delete_relation_instances( $post_id );
130
+	wl_core_delete_relation_instances($post_id);
131 131
 
132 132
 	// Save relation instances
133
-	foreach ( array_unique( $disambiguated_entities ) as $referenced_entity_id ) {
133
+	foreach (array_unique($disambiguated_entities) as $referenced_entity_id) {
134 134
 
135 135
 		wl_core_add_relation_instance(
136 136
 			$post_id,
137
-			Wordlift_Entity_Service::get_instance()->get_classification_scope_for( $referenced_entity_id ),
137
+			Wordlift_Entity_Service::get_instance()->get_classification_scope_for($referenced_entity_id),
138 138
 			$referenced_entity_id
139 139
 		);
140 140
 
141 141
 	}
142 142
 
143
-    if ( isset( $_POST['wl_entities'] ) ) {
143
+    if (isset($_POST['wl_entities'])) {
144 144
 		// Save post metadata if available
145
-		$metadata_via_post    =  ( isset( $_POST['wl_metadata'] ) ) ?
145
+		$metadata_via_post = (isset($_POST['wl_metadata'])) ?
146 146
 			$_POST['wl_metadata'] : array();
147 147
 
148 148
 		$fields = array(
@@ -151,54 +151,54 @@  discard block
 block discarded – undo
151 151
 		);
152 152
 
153 153
 		// Unlink topic taxonomy terms
154
-		Wordlift_Topic_Taxonomy_Service::get_instance()->unlink_topic_for( $post->ID );
154
+		Wordlift_Topic_Taxonomy_Service::get_instance()->unlink_topic_for($post->ID);
155 155
 
156
-		foreach ( $fields as $field ) {
156
+		foreach ($fields as $field) {
157 157
 
158 158
 			// Delete current values
159
-			delete_post_meta( $post->ID, $field );
159
+			delete_post_meta($post->ID, $field);
160 160
 			// Retrieve the entity uri
161
-			$uri 	= ( isset( $metadata_via_post[ $field ] ) ) ?
162
-				stripslashes( $metadata_via_post[ $field ] ) : '';
161
+			$uri = (isset($metadata_via_post[$field])) ?
162
+				stripslashes($metadata_via_post[$field]) : '';
163 163
 
164
-			$entity = Wordlift_Entity_Service::get_instance()->get_entity_post_by_uri( $uri );
164
+			$entity = Wordlift_Entity_Service::get_instance()->get_entity_post_by_uri($uri);
165 165
 
166
-			if ( $entity ) {
167
-				add_post_meta( $post->ID, $field, $entity->ID, true );
166
+			if ($entity) {
167
+				add_post_meta($post->ID, $field, $entity->ID, true);
168 168
 				// Set also the topic taxonomy
169
-				if ( $field === Wordlift_Schema_Service::FIELD_TOPIC ) {
170
-					Wordlift_Topic_Taxonomy_Service::get_instance()->set_topic_for( $post->ID, $entity );
169
+				if ($field === Wordlift_Schema_Service::FIELD_TOPIC) {
170
+					Wordlift_Topic_Taxonomy_Service::get_instance()->set_topic_for($post->ID, $entity);
171 171
 				}
172 172
 			}
173 173
 		}
174 174
 	}
175 175
 
176 176
 	// Push the post to Redlink.
177
-	wl_linked_data_push_to_redlink( $post->ID );
177
+	wl_linked_data_push_to_redlink($post->ID);
178 178
 
179
-	add_action( 'wl_linked_data_save_post', 'wl_linked_data_save_post_and_related_entities' );
179
+	add_action('wl_linked_data_save_post', 'wl_linked_data_save_post_and_related_entities');
180 180
 }
181 181
 
182
-add_action( 'wl_linked_data_save_post', 'wl_linked_data_save_post_and_related_entities' );
182
+add_action('wl_linked_data_save_post', 'wl_linked_data_save_post_and_related_entities');
183 183
 
184 184
 /**
185 185
  * Adds default schema type "Thing" as soon as an entity is created.
186 186
  */
187
-function wordlift_save_post_add_default_schema_type( $entity_id ) {
187
+function wordlift_save_post_add_default_schema_type($entity_id) {
188 188
 
189
-	$entity      = get_post( $entity_id );
190
-	$entity_type = wl_schema_get_types( $entity_id );
189
+	$entity      = get_post($entity_id);
190
+	$entity_type = wl_schema_get_types($entity_id);
191 191
 
192 192
 	// Assign type 'Thing' if we are dealing with an entity without type
193
-	if ( $entity->post_type == Wordlift_Entity_Service::TYPE_NAME && is_null( $entity_type ) ) {
194
-		wl_schema_set_types( $entity_id, 'Thing' );
193
+	if ($entity->post_type == Wordlift_Entity_Service::TYPE_NAME && is_null($entity_type)) {
194
+		wl_schema_set_types($entity_id, 'Thing');
195 195
 	}
196 196
 
197 197
 }
198 198
 
199 199
 // Priority 1 (default is 10) because we want the default type to be set as soon as possible
200 200
 // Attatched to save_post because *wl_linked_data_save_post* does not always fire
201
-add_action( 'save_post', 'wordlift_save_post_add_default_schema_type', 1 );
201
+add_action('save_post', 'wordlift_save_post_add_default_schema_type', 1);
202 202
 
203 203
 /**
204 204
  * Save the specified data as an entity in WordPress. This method only create new entities. When an existing entity is
@@ -216,23 +216,23 @@  discard block
 block discarded – undo
216 216
  *
217 217
  * @return null|WP_Post A post instance or null in case of failure.
218 218
  */
219
-function wl_save_entity( $entity_data ) {
219
+function wl_save_entity($entity_data) {
220 220
 
221 221
 	$uri              = $entity_data['uri'];
222 222
 	$label            = $entity_data['label'];
223 223
 	$type_uri         = $entity_data['main_type'];
224
-	$entity_types     = isset( $entity_data['type'] ) ? $entity_data['type'] : array();
224
+	$entity_types     = isset($entity_data['type']) ? $entity_data['type'] : array();
225 225
 	$description      = $entity_data['description'];
226
-	$images           = isset( $entity_data['image'] ) ? wl_force_to_array( $entity_data['image'] ) : array();
227
-	$same_as          = isset( $entity_data['sameas'] ) ? wl_force_to_array( $entity_data['sameas'] ) : array();
228
-	$related_post_id  = isset( $entity_data['related_post_id'] ) ? $entity_data['related_post_id'] : null;
229
-	$other_properties = isset( $entity_data['properties'] ) ? $entity_data['properties'] : array();
226
+	$images           = isset($entity_data['image']) ? wl_force_to_array($entity_data['image']) : array();
227
+	$same_as          = isset($entity_data['sameas']) ? wl_force_to_array($entity_data['sameas']) : array();
228
+	$related_post_id  = isset($entity_data['related_post_id']) ? $entity_data['related_post_id'] : null;
229
+	$other_properties = isset($entity_data['properties']) ? $entity_data['properties'] : array();
230 230
 
231 231
 	// wl_write_log( "[ uri :: $uri ][ label :: $label ][ type uri :: $type_uri ]" );
232 232
 
233 233
 	// Prepare properties of the new entity.
234 234
 	$params = array(
235
-		'post_status'  => ( is_numeric( $related_post_id ) ? get_post_status( $related_post_id ) : 'draft' ),
235
+		'post_status'  => (is_numeric($related_post_id) ? get_post_status($related_post_id) : 'draft'),
236 236
 		'post_type'    => Wordlift_Entity_Service::TYPE_NAME,
237 237
 		'post_title'   => $label,
238 238
 		'post_content' => $description,
@@ -240,9 +240,9 @@  discard block
 block discarded – undo
240 240
 	);
241 241
 
242 242
 	// Check whether an entity already exists with the provided URI.
243
-	$post = Wordlift_Entity_Service::get_instance()->get_entity_post_by_uri( $uri );
243
+	$post = Wordlift_Entity_Service::get_instance()->get_entity_post_by_uri($uri);
244 244
 
245
-	if ( null !== $post ) {
245
+	if (null !== $post) {
246 246
 		return $post;
247 247
 	}
248 248
 
@@ -252,12 +252,12 @@  discard block
 block discarded – undo
252 252
 	// This does NOT affect saving an entity from the entity admin page since this function is called when an entity
253 253
 	// is created when saving a post.
254 254
 	global $wpseo_metabox, $seo_ultimate;
255
-	if ( isset( $wpseo_metabox ) ) {
256
-		remove_action( 'wp_insert_post', array( $wpseo_metabox, 'save_postdata' ) );
255
+	if (isset($wpseo_metabox)) {
256
+		remove_action('wp_insert_post', array($wpseo_metabox, 'save_postdata'));
257 257
 	}
258 258
 
259
-	if ( isset( $seo_ultimate ) ) {
260
-		remove_action( 'save_post', array( $seo_ultimate, 'save_postmeta_box' ) );
259
+	if (isset($seo_ultimate)) {
260
+		remove_action('save_post', array($seo_ultimate, 'save_postmeta_box'));
261 261
 	}
262 262
 
263 263
 	// The fact that we're calling here wp_insert_post is causing issues with plugins (and ourselves too) that hook to
@@ -271,78 +271,78 @@  discard block
 block discarded – undo
271 271
 	$wp_filter['save_post'] = array();
272 272
 
273 273
 	// create or update the post.
274
-	$post_id = wp_insert_post( $params, true );
274
+	$post_id = wp_insert_post($params, true);
275 275
 
276 276
 	// Restore all the existing filters.
277 277
 	$wp_filter['save_post'] = $save_post_filters;
278 278
 
279 279
 	// If Yoast is installed and active, we restore the Yoast save_postdata hook (https://github.com/insideout10/wordlift-plugin/issues/156)
280
-	if ( isset( $wpseo_metabox ) ) {
281
-		add_action( 'wp_insert_post', array( $wpseo_metabox, 'save_postdata' ) );
280
+	if (isset($wpseo_metabox)) {
281
+		add_action('wp_insert_post', array($wpseo_metabox, 'save_postdata'));
282 282
 	}
283 283
 
284 284
 	// If SEO Ultimate is installed, add back the hook we removed a few lines above.
285
-	if ( isset( $seo_ultimate ) ) {
286
-		add_action( 'save_post', array( $seo_ultimate, 'save_postmeta_box' ), 10, 2 );
285
+	if (isset($seo_ultimate)) {
286
+		add_action('save_post', array($seo_ultimate, 'save_postmeta_box'), 10, 2);
287 287
 	}
288 288
 
289 289
 	// TODO: handle errors.
290
-	if ( is_wp_error( $post_id ) ) {
291
-		wl_write_log( ': error occurred' );
290
+	if (is_wp_error($post_id)) {
291
+		wl_write_log(': error occurred');
292 292
 
293 293
 		// inform an error occurred.
294 294
 		return null;
295 295
 	}
296 296
 
297
-	wl_set_entity_main_type( $post_id, $type_uri );
297
+	wl_set_entity_main_type($post_id, $type_uri);
298 298
 
299 299
 	// Save the entity types.
300
-	wl_set_entity_rdf_types( $post_id, $entity_types );
300
+	wl_set_entity_rdf_types($post_id, $entity_types);
301 301
 
302 302
 	// Get a dataset URI for the entity.
303
-	$wl_uri = wl_build_entity_uri( $post_id );
303
+	$wl_uri = wl_build_entity_uri($post_id);
304 304
 
305 305
 	// Save the entity URI.
306
-	wl_set_entity_uri( $post_id, $wl_uri );
306
+	wl_set_entity_uri($post_id, $wl_uri);
307 307
 
308 308
 	// Add the uri to the sameAs data if it's not a local URI.
309
-	if ( $wl_uri !== $uri ) {
310
-		array_push( $same_as, $uri );
309
+	if ($wl_uri !== $uri) {
310
+		array_push($same_as, $uri);
311 311
 	}
312 312
 
313
-	$new_uri = wl_get_entity_uri( $post_id );
313
+	$new_uri = wl_get_entity_uri($post_id);
314 314
 
315 315
 	// Save the sameAs data for the entity.
316
-	wl_schema_set_value( $post_id, 'sameAs', $same_as );
316
+	wl_schema_set_value($post_id, 'sameAs', $same_as);
317 317
 
318 318
 	// Save the other properties (latitude, langitude, startDate, endDate, etc.)
319
-	foreach ( $other_properties as $property_name => $property_value ) {
320
-		wl_schema_set_value( $post_id, $property_name, $property_value );
319
+	foreach ($other_properties as $property_name => $property_value) {
320
+		wl_schema_set_value($post_id, $property_name, $property_value);
321 321
 	}
322 322
 
323 323
 	// Call hooks.
324
-	do_action( 'wl_save_entity', $post_id );
324
+	do_action('wl_save_entity', $post_id);
325 325
 
326
-	wl_write_log( "[ post id :: $post_id ][ uri :: $uri ][ label :: $label ][ wl uri :: $wl_uri ][ types :: " . implode( ',', $entity_types ) . " ][ images count :: " . count( $images ) . " ][ same_as count :: " . count( $same_as ) . " ]" );
326
+	wl_write_log("[ post id :: $post_id ][ uri :: $uri ][ label :: $label ][ wl uri :: $wl_uri ][ types :: ".implode(',', $entity_types)." ][ images count :: ".count($images)." ][ same_as count :: ".count($same_as)." ]");
327 327
 
328
-	foreach ( $images as $image_remote_url ) {
328
+	foreach ($images as $image_remote_url) {
329 329
 
330 330
 		// Check if image is already present in local DB
331
-		if ( strpos( $image_remote_url, site_url() ) !== false ) {
331
+		if (strpos($image_remote_url, site_url()) !== false) {
332 332
 			// Do nothing.
333 333
 			continue;
334 334
 		}
335 335
 
336 336
 		// Check if there is an existing attachment for this post ID and source URL.
337
-		$existing_image = wl_get_attachment_for_source_url( $post_id, $image_remote_url );
337
+		$existing_image = wl_get_attachment_for_source_url($post_id, $image_remote_url);
338 338
 
339 339
 		// Skip if an existing image is found.
340
-		if ( null !== $existing_image ) {
340
+		if (null !== $existing_image) {
341 341
 			continue;
342 342
 		}
343 343
 
344 344
 		// Save the image and get the local path.
345
-		$image = wl_save_image( $image_remote_url );
345
+		$image = wl_save_image($image_remote_url);
346 346
 
347 347
 		// Get the local URL.
348 348
 		$filename     = $image['path'];
@@ -360,24 +360,24 @@  discard block
 block discarded – undo
360 360
 		);
361 361
 
362 362
 		// Create the attachment in WordPress and generate the related metadata.
363
-		$attachment_id = wp_insert_attachment( $attachment, $filename, $post_id );
363
+		$attachment_id = wp_insert_attachment($attachment, $filename, $post_id);
364 364
 
365 365
 		// Set the source URL for the image.
366
-		wl_set_source_url( $attachment_id, $image_remote_url );
366
+		wl_set_source_url($attachment_id, $image_remote_url);
367 367
 
368
-		$attachment_data = wp_generate_attachment_metadata( $attachment_id, $filename );
369
-		wp_update_attachment_metadata( $attachment_id, $attachment_data );
368
+		$attachment_data = wp_generate_attachment_metadata($attachment_id, $filename);
369
+		wp_update_attachment_metadata($attachment_id, $attachment_data);
370 370
 
371 371
 		// Set it as the featured image.
372
-		set_post_thumbnail( $post_id, $attachment_id );
372
+		set_post_thumbnail($post_id, $attachment_id);
373 373
 	}
374 374
 
375 375
 	// The entity is pushed to Redlink on save by the function hooked to save_post.
376 376
 	// save the entity in the triple store.
377
-	wl_linked_data_push_to_redlink( $post_id );
377
+	wl_linked_data_push_to_redlink($post_id);
378 378
 
379 379
 	// finally return the entity post.
380
-	return get_post( $post_id );
380
+	return get_post($post_id);
381 381
 }
382 382
 
383 383
 /**
@@ -389,10 +389,10 @@  discard block
 block discarded – undo
389 389
  *
390 390
  * @return array An array of entity posts.
391 391
  */
392
-function wl_linked_data_content_get_embedded_entities( $content ) {
392
+function wl_linked_data_content_get_embedded_entities($content) {
393 393
 
394 394
 	// Remove quote escapes.
395
-	$content = str_replace( '\\"', '"', $content );
395
+	$content = str_replace('\\"', '"', $content);
396 396
 
397 397
 	// Match all itemid attributes.
398 398
 	$pattern = '/<\w+[^>]*\sitemid="([^"]+)"[^>]*>/im';
@@ -403,8 +403,8 @@  discard block
 block discarded – undo
403 403
 	$matches = array();
404 404
 
405 405
 	// In case of errors, return an empty array.
406
-	if ( false === preg_match_all( $pattern, $content, $matches ) ) {
407
-		wl_write_log( "Found no entities embedded in content" );
406
+	if (false === preg_match_all($pattern, $content, $matches)) {
407
+		wl_write_log("Found no entities embedded in content");
408 408
 
409 409
 		return array();
410 410
 	}
@@ -413,13 +413,13 @@  discard block
 block discarded – undo
413 413
 
414 414
 	// Collect the entities.
415 415
 	$entities = array();
416
-	foreach ( $matches[1] as $uri ) {
417
-		$uri_d  = html_entity_decode( $uri );
416
+	foreach ($matches[1] as $uri) {
417
+		$uri_d  = html_entity_decode($uri);
418 418
 
419
-		$entity = Wordlift_Entity_Service::get_instance()->get_entity_post_by_uri( $uri_d );
419
+		$entity = Wordlift_Entity_Service::get_instance()->get_entity_post_by_uri($uri_d);
420 420
 
421
-		if ( null !== $entity ) {
422
-			array_push( $entities, $entity->ID );
421
+		if (null !== $entity) {
422
+			array_push($entities, $entity->ID);
423 423
 		}
424 424
 	}
425 425
 
@@ -436,24 +436,24 @@  discard block
 block discarded – undo
436 436
  *
437 437
  * @param int $post_id The post ID.
438 438
  */
439
-function wl_linked_data_push_to_redlink( $post_id ) {
439
+function wl_linked_data_push_to_redlink($post_id) {
440 440
 
441 441
 	// Get the post.
442
-	$post = get_post( $post_id );
442
+	$post = get_post($post_id);
443 443
 
444 444
 	// wl_write_log( "wl_linked_data_push_to_redlink [ post id :: $post_id ][ post type :: $post->post_type ]" );
445 445
 
446 446
 	// Call the method on behalf of the post type.
447
-	switch ( $post->post_type ) {
447
+	switch ($post->post_type) {
448 448
 		case 'entity':
449
-			wl_push_entity_post_to_redlink( $post );
449
+			wl_push_entity_post_to_redlink($post);
450 450
 			break;
451 451
 		default:
452
-			wl_push_post_to_redlink( $post );
452
+			wl_push_post_to_redlink($post);
453 453
 	}
454 454
 
455 455
 	// Reindex the triple store if buffering is turned off.
456
-	if ( false === WL_ENABLE_SPARQL_UPDATE_QUERIES_BUFFERING ) {
456
+	if (false === WL_ENABLE_SPARQL_UPDATE_QUERIES_BUFFERING) {
457 457
 		wordlift_reindex_triple_store();
458 458
 	}
459 459
 }
Please login to merge, or discard this patch.
src/modules/core/wordlift_core_schema_api.php 1 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,15 +85,15 @@  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
-	$old_values = wl_schema_get_value( $post_id, $property_name );
92
+    $old_values = wl_schema_get_value( $post_id, $property_name );
93 93
 
94
-	$merged_property_value = array_unique( array_merge( $property_value, $old_values ) );
94
+    $merged_property_value = array_unique( array_merge( $property_value, $old_values ) );
95 95
 
96
-	wl_schema_set_value( $post_id, $property_name, $merged_property_value );
96
+    wl_schema_set_value( $post_id, $property_name, $merged_property_value );
97 97
 }
98 98
 
99 99
 /**
@@ -107,38 +107,38 @@  discard block
 block discarded – undo
107 107
  */
108 108
 function wl_schema_set_value( $post_id, $property_name, $property_value ) {
109 109
 
110
-	// Some checks on the parameters
111
-	if ( ! is_numeric( $post_id ) || is_null( $property_name ) || empty( $property_value ) || is_null( $property_value ) ) {
112
-		return false;
113
-	}
110
+    // Some checks on the parameters
111
+    if ( ! is_numeric( $post_id ) || is_null( $property_name ) || empty( $property_value ) || is_null( $property_value ) ) {
112
+        return false;
113
+    }
114 114
 
115
-	// Build full schema uri if necessary
116
-	$property_name = wl_build_full_schema_uri_from_schema_slug( $property_name );
115
+    // Build full schema uri if necessary
116
+    $property_name = wl_build_full_schema_uri_from_schema_slug( $property_name );
117 117
 
118
-	// Get accepted properties
119
-	$accepted_fields = wl_entity_taxonomy_get_custom_fields( $post_id );
118
+    // Get accepted properties
119
+    $accepted_fields = wl_entity_taxonomy_get_custom_fields( $post_id );
120 120
 
121
-	// Find the name of the custom-field managing the schema property
122
-	foreach ( $accepted_fields as $wl_constant => $field ) {
123
-		if ( $field['predicate'] == $property_name ) {
121
+    // Find the name of the custom-field managing the schema property
122
+    foreach ( $accepted_fields as $wl_constant => $field ) {
123
+        if ( $field['predicate'] == $property_name ) {
124 124
 
125
-			// Deal with single values
126
-			if ( ! is_array( $property_value ) ) {
127
-				$property_value = array( $property_value );
128
-			}
125
+            // Deal with single values
126
+            if ( ! is_array( $property_value ) ) {
127
+                $property_value = array( $property_value );
128
+            }
129 129
 
130
-			// Delete present meta
131
-			delete_post_meta( $post_id, $wl_constant );
130
+            // Delete present meta
131
+            delete_post_meta( $post_id, $wl_constant );
132 132
 
133
-			foreach ( $property_value as $value ) {
134
-				add_post_meta( $post_id, $wl_constant, $value );
135
-			}
133
+            foreach ( $property_value as $value ) {
134
+                add_post_meta( $post_id, $wl_constant, $value );
135
+            }
136 136
 
137
-			return true;
138
-		}
139
-	}
137
+            return true;
138
+        }
139
+    }
140 140
 
141
-	return false;
141
+    return false;
142 142
 }
143 143
 
144 144
 
@@ -152,18 +152,18 @@  discard block
 block discarded – undo
152 152
  */
153 153
 function wl_schema_get_types( $post_id ) {
154 154
 
155
-	// Some checks on the parameters
156
-	if ( ! is_numeric( $post_id ) ) {
157
-		return null;
158
-	}
155
+    // Some checks on the parameters
156
+    if ( ! is_numeric( $post_id ) ) {
157
+        return null;
158
+    }
159 159
 
160
-	$type = wl_entity_type_taxonomy_get_type( $post_id );
160
+    $type = wl_entity_type_taxonomy_get_type( $post_id );
161 161
 
162
-	if ( isset( $type['uri'] ) ) {
163
-		return array( $type['uri'] );
164
-	}
162
+    if ( isset( $type['uri'] ) ) {
163
+        return array( $type['uri'] );
164
+    }
165 165
 
166
-	return null;
166
+    return null;
167 167
 }
168 168
 
169 169
 /**
@@ -176,23 +176,23 @@  discard block
 block discarded – undo
176 176
  */
177 177
 function wl_schema_set_types( $post_id, $type_names ) {
178 178
 
179
-	// Some checks on the parameters
180
-	if ( ! is_numeric( $post_id ) || empty( $type_names ) || is_null( $type_names ) ) {
181
-		return null;
182
-	}
179
+    // Some checks on the parameters
180
+    if ( ! is_numeric( $post_id ) || empty( $type_names ) || is_null( $type_names ) ) {
181
+        return null;
182
+    }
183 183
 
184
-	// TODO: support more than one type
185
-	if ( is_array( $type_names ) ) {
186
-		$type_names = $type_names[0];
187
-	}
184
+    // TODO: support more than one type
185
+    if ( is_array( $type_names ) ) {
186
+        $type_names = $type_names[0];
187
+    }
188 188
 
189
-	// Get the schema URI (e.g. http://schema.org/Thing)
190
-	$type_names = wl_build_full_schema_uri_from_schema_slug( $type_names );
189
+    // Get the schema URI (e.g. http://schema.org/Thing)
190
+    $type_names = wl_build_full_schema_uri_from_schema_slug( $type_names );
191 191
 
192
-	Wordlift_Log_Service::get_logger('wl_schema_set_types')->debug("[ type names :: $type_names ]");
192
+    Wordlift_Log_Service::get_logger('wl_schema_set_types')->debug("[ type names :: $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.
src/admin/WL_Metabox/WL_Metabox_Field_sameas.php 2 patches
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -2,16 +2,16 @@
 block discarded – undo
2 2
 
3 3
 class WL_Metabox_Field_sameas extends WL_Metabox_Field {
4 4
 
5
-	public function __construct( $args ) {
6
-		parent::__construct( $args['sameas'] );
7
-	}
5
+    public function __construct( $args ) {
6
+        parent::__construct( $args['sameas'] );
7
+    }
8 8
 
9
-	/**
10
-	 * Only accept URIs
11
-	 */
12
-	public function sanitize_data_filter( $value ) {
9
+    /**
10
+     * Only accept URIs
11
+     */
12
+    public function sanitize_data_filter( $value ) {
13 13
 
14
-		// Call our sanitizer helper.
15
-		return Wordlift_Sanitizer::sanitize_url( $value );
16
-	}
14
+        // Call our sanitizer helper.
15
+        return Wordlift_Sanitizer::sanitize_url( $value );
16
+    }
17 17
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -2,16 +2,16 @@
 block discarded – undo
2 2
 
3 3
 class WL_Metabox_Field_sameas extends WL_Metabox_Field {
4 4
 
5
-	public function __construct( $args ) {
6
-		parent::__construct( $args['sameas'] );
5
+	public function __construct($args) {
6
+		parent::__construct($args['sameas']);
7 7
 	}
8 8
 
9 9
 	/**
10 10
 	 * Only accept URIs
11 11
 	 */
12
-	public function sanitize_data_filter( $value ) {
12
+	public function sanitize_data_filter($value) {
13 13
 
14 14
 		// Call our sanitizer helper.
15
-		return Wordlift_Sanitizer::sanitize_url( $value );
15
+		return Wordlift_Sanitizer::sanitize_url($value);
16 16
 	}
17 17
 }
Please login to merge, or discard this patch.
src/wordlift_entity_type.php 2 patches
Indentation   +61 added lines, -61 removed lines patch added patch discarded remove patch
@@ -10,42 +10,42 @@  discard block
 block discarded – undo
10 10
 
11 11
 //	wl_write_log( "wl_set_entity_main_type [ post id :: $post_id ][ type uri :: $type_uri ]" );
12 12
 
13
-	// If the type URI is empty we remove the type.
14
-	if ( empty( $type_uri ) ) {
15
-		wp_set_object_terms( $post_id, null, Wordlift_Entity_Types_Taxonomy_Service::TAXONOMY_NAME );
16
-
17
-		return;
18
-	}
19
-
20
-	// Get all the terms bound to the wl_entity_type taxonomy.
21
-	$terms = get_terms( Wordlift_Entity_Types_Taxonomy_Service::TAXONOMY_NAME, array(
22
-		'hide_empty' => false,
23
-		// Because of #334 (and the AAM plugin) we changed fields from 'id=>slug' to 'all'.
24
-		// An issue has been opened with the AAM plugin author as well.
25
-		//
26
-		// see https://github.com/insideout10/wordlift-plugin/issues/334
27
-		// see https://wordpress.org/support/topic/idslug-not-working-anymore?replies=1#post-8806863
28
-		'fields'     => 'all'
29
-	) );
30
-
31
-	// Check which term matches the specified URI.
32
-	foreach ( $terms as $term ) {
33
-
34
-		$term_id   = $term->term_id;
35
-		$term_slug = $term->slug;
36
-
37
-		// Load the type data.
38
-		$type = Wordlift_Schema_Service::get_instance()->get_schema( $term_slug );
39
-		// Set the related term ID.
40
-		if ( $type_uri === $type['uri'] || $type_uri === $type['css_class'] ) {
41
-
42
-			Wordlift_Log_Service::get_logger( 'wl_set_entity_main_type' )->debug( "Setting entity type [ post id :: $post_id ][ term id :: $term_id ][ term slug :: $term_slug ][ type uri :: {$type['uri']} ][ type css class :: {$type['css_class']} ]" );
43
-
44
-			wp_set_object_terms( $post_id, (int) $term_id, Wordlift_Entity_Types_Taxonomy_Service::TAXONOMY_NAME );
45
-
46
-			return;
47
-		}
48
-	}
13
+    // If the type URI is empty we remove the type.
14
+    if ( empty( $type_uri ) ) {
15
+        wp_set_object_terms( $post_id, null, Wordlift_Entity_Types_Taxonomy_Service::TAXONOMY_NAME );
16
+
17
+        return;
18
+    }
19
+
20
+    // Get all the terms bound to the wl_entity_type taxonomy.
21
+    $terms = get_terms( Wordlift_Entity_Types_Taxonomy_Service::TAXONOMY_NAME, array(
22
+        'hide_empty' => false,
23
+        // Because of #334 (and the AAM plugin) we changed fields from 'id=>slug' to 'all'.
24
+        // An issue has been opened with the AAM plugin author as well.
25
+        //
26
+        // see https://github.com/insideout10/wordlift-plugin/issues/334
27
+        // see https://wordpress.org/support/topic/idslug-not-working-anymore?replies=1#post-8806863
28
+        'fields'     => 'all'
29
+    ) );
30
+
31
+    // Check which term matches the specified URI.
32
+    foreach ( $terms as $term ) {
33
+
34
+        $term_id   = $term->term_id;
35
+        $term_slug = $term->slug;
36
+
37
+        // Load the type data.
38
+        $type = Wordlift_Schema_Service::get_instance()->get_schema( $term_slug );
39
+        // Set the related term ID.
40
+        if ( $type_uri === $type['uri'] || $type_uri === $type['css_class'] ) {
41
+
42
+            Wordlift_Log_Service::get_logger( 'wl_set_entity_main_type' )->debug( "Setting entity type [ post id :: $post_id ][ term id :: $term_id ][ term slug :: $term_slug ][ type uri :: {$type['uri']} ][ type css class :: {$type['css_class']} ]" );
43
+
44
+            wp_set_object_terms( $post_id, (int) $term_id, Wordlift_Entity_Types_Taxonomy_Service::TAXONOMY_NAME );
45
+
46
+            return;
47
+        }
48
+    }
49 49
 }
50 50
 
51 51
 /**
@@ -53,46 +53,46 @@  discard block
 block discarded – undo
53 53
  */
54 54
 function wl_print_entity_type_inline_js() {
55 55
 
56
-	$terms = get_terms( Wordlift_Entity_Types_Taxonomy_Service::TAXONOMY_NAME, array(
57
-		'hide_empty' => false
58
-	) );
56
+    $terms = get_terms( Wordlift_Entity_Types_Taxonomy_Service::TAXONOMY_NAME, array(
57
+        'hide_empty' => false
58
+    ) );
59 59
 
60
-	echo <<<EOF
60
+    echo <<<EOF
61 61
     <script type="text/javascript">
62 62
         (function() {
63 63
         var t = [];
64 64
 
65 65
 EOF;
66 66
 
67
-	// Cycle in each WordLift term and get its metadata. The metadata will be printed as a global object in JavaScript
68
-	// to be used by the JavaScript client library.
69
-	foreach ( $terms as $term ) {
67
+    // Cycle in each WordLift term and get its metadata. The metadata will be printed as a global object in JavaScript
68
+    // to be used by the JavaScript client library.
69
+    foreach ( $terms as $term ) {
70 70
 
71
-		$term_name = $term->name;
71
+        $term_name = $term->name;
72 72
 
73
-		// Load the type data.
74
-		$type = Wordlift_Schema_Service::get_instance()->get_schema( $term->slug );
73
+        // Load the type data.
74
+        $type = Wordlift_Schema_Service::get_instance()->get_schema( $term->slug );
75 75
 
76
-		// Skip types that are not defined.
77
-		if ( ! empty( $type['uri'] ) ) {
76
+        // Skip types that are not defined.
77
+        if ( ! empty( $type['uri'] ) ) {
78 78
 
79
-			// Prepare the JSON output then print it to the browser.
80
-			$json = json_encode( array(
81
-				'label'     => $term_name,
82
-				'uri'       => $type['uri'],
83
-				'css'       => $type['css_class'],
84
-				'sameAs'    => $type['same_as'],
85
-				'templates' => ( isset( $type['templates'] ) ? $type['templates'] : array() ),
86
-			) );
79
+            // Prepare the JSON output then print it to the browser.
80
+            $json = json_encode( array(
81
+                'label'     => $term_name,
82
+                'uri'       => $type['uri'],
83
+                'css'       => $type['css_class'],
84
+                'sameAs'    => $type['same_as'],
85
+                'templates' => ( isset( $type['templates'] ) ? $type['templates'] : array() ),
86
+            ) );
87 87
 
88
-			// Output the type data.
89
-			echo "t.push($json);\n";
88
+            // Output the type data.
89
+            echo "t.push($json);\n";
90 90
 
91
-		}
91
+        }
92 92
 
93
-	}
93
+    }
94 94
 
95
-	echo <<<EOF
95
+    echo <<<EOF
96 96
             if ('undefined' == typeof window.wordlift) {
97 97
                 window.wordlift = {}
98 98
             }
Please login to merge, or discard this patch.
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -6,19 +6,19 @@  discard block
 block discarded – undo
6 6
  * @param int $post_id The numeric post ID.
7 7
  * @param string $type_uri A type URI.
8 8
  */
9
-function wl_set_entity_main_type( $post_id, $type_uri ) {
9
+function wl_set_entity_main_type($post_id, $type_uri) {
10 10
 
11 11
 //	wl_write_log( "wl_set_entity_main_type [ post id :: $post_id ][ type uri :: $type_uri ]" );
12 12
 
13 13
 	// If the type URI is empty we remove the type.
14
-	if ( empty( $type_uri ) ) {
15
-		wp_set_object_terms( $post_id, null, Wordlift_Entity_Types_Taxonomy_Service::TAXONOMY_NAME );
14
+	if (empty($type_uri)) {
15
+		wp_set_object_terms($post_id, null, Wordlift_Entity_Types_Taxonomy_Service::TAXONOMY_NAME);
16 16
 
17 17
 		return;
18 18
 	}
19 19
 
20 20
 	// Get all the terms bound to the wl_entity_type taxonomy.
21
-	$terms = get_terms( Wordlift_Entity_Types_Taxonomy_Service::TAXONOMY_NAME, array(
21
+	$terms = get_terms(Wordlift_Entity_Types_Taxonomy_Service::TAXONOMY_NAME, array(
22 22
 		'hide_empty' => false,
23 23
 		// Because of #334 (and the AAM plugin) we changed fields from 'id=>slug' to 'all'.
24 24
 		// An issue has been opened with the AAM plugin author as well.
@@ -26,22 +26,22 @@  discard block
 block discarded – undo
26 26
 		// see https://github.com/insideout10/wordlift-plugin/issues/334
27 27
 		// see https://wordpress.org/support/topic/idslug-not-working-anymore?replies=1#post-8806863
28 28
 		'fields'     => 'all'
29
-	) );
29
+	));
30 30
 
31 31
 	// Check which term matches the specified URI.
32
-	foreach ( $terms as $term ) {
32
+	foreach ($terms as $term) {
33 33
 
34 34
 		$term_id   = $term->term_id;
35 35
 		$term_slug = $term->slug;
36 36
 
37 37
 		// Load the type data.
38
-		$type = Wordlift_Schema_Service::get_instance()->get_schema( $term_slug );
38
+		$type = Wordlift_Schema_Service::get_instance()->get_schema($term_slug);
39 39
 		// Set the related term ID.
40
-		if ( $type_uri === $type['uri'] || $type_uri === $type['css_class'] ) {
40
+		if ($type_uri === $type['uri'] || $type_uri === $type['css_class']) {
41 41
 
42
-			Wordlift_Log_Service::get_logger( 'wl_set_entity_main_type' )->debug( "Setting entity type [ post id :: $post_id ][ term id :: $term_id ][ term slug :: $term_slug ][ type uri :: {$type['uri']} ][ type css class :: {$type['css_class']} ]" );
42
+			Wordlift_Log_Service::get_logger('wl_set_entity_main_type')->debug("Setting entity type [ post id :: $post_id ][ term id :: $term_id ][ term slug :: $term_slug ][ type uri :: {$type['uri']} ][ type css class :: {$type['css_class']} ]");
43 43
 
44
-			wp_set_object_terms( $post_id, (int) $term_id, Wordlift_Entity_Types_Taxonomy_Service::TAXONOMY_NAME );
44
+			wp_set_object_terms($post_id, (int) $term_id, Wordlift_Entity_Types_Taxonomy_Service::TAXONOMY_NAME);
45 45
 
46 46
 			return;
47 47
 		}
@@ -53,9 +53,9 @@  discard block
 block discarded – undo
53 53
  */
54 54
 function wl_print_entity_type_inline_js() {
55 55
 
56
-	$terms = get_terms( Wordlift_Entity_Types_Taxonomy_Service::TAXONOMY_NAME, array(
56
+	$terms = get_terms(Wordlift_Entity_Types_Taxonomy_Service::TAXONOMY_NAME, array(
57 57
 		'hide_empty' => false
58
-	) );
58
+	));
59 59
 
60 60
 	echo <<<EOF
61 61
     <script type="text/javascript">
@@ -66,24 +66,24 @@  discard block
 block discarded – undo
66 66
 
67 67
 	// Cycle in each WordLift term and get its metadata. The metadata will be printed as a global object in JavaScript
68 68
 	// to be used by the JavaScript client library.
69
-	foreach ( $terms as $term ) {
69
+	foreach ($terms as $term) {
70 70
 
71 71
 		$term_name = $term->name;
72 72
 
73 73
 		// Load the type data.
74
-		$type = Wordlift_Schema_Service::get_instance()->get_schema( $term->slug );
74
+		$type = Wordlift_Schema_Service::get_instance()->get_schema($term->slug);
75 75
 
76 76
 		// Skip types that are not defined.
77
-		if ( ! empty( $type['uri'] ) ) {
77
+		if ( ! empty($type['uri'])) {
78 78
 
79 79
 			// Prepare the JSON output then print it to the browser.
80
-			$json = json_encode( array(
80
+			$json = json_encode(array(
81 81
 				'label'     => $term_name,
82 82
 				'uri'       => $type['uri'],
83 83
 				'css'       => $type['css_class'],
84 84
 				'sameAs'    => $type['same_as'],
85
-				'templates' => ( isset( $type['templates'] ) ? $type['templates'] : array() ),
86
-			) );
85
+				'templates' => (isset($type['templates']) ? $type['templates'] : array()),
86
+			));
87 87
 
88 88
 			// Output the type data.
89 89
 			echo "t.push($json);\n";
@@ -104,6 +104,6 @@  discard block
 block discarded – undo
104 104
 
105 105
 }
106 106
 
107
-add_action( 'admin_print_scripts', 'wl_print_entity_type_inline_js' );
107
+add_action('admin_print_scripts', 'wl_print_entity_type_inline_js');
108 108
 
109
-add_action( 'init', 'wl_entity_type_taxonomy_register', 0 );
109
+add_action('init', 'wl_entity_type_taxonomy_register', 0);
Please login to merge, or discard this patch.
src/includes/class-wordlift.php 2 patches
Indentation   +529 added lines, -529 removed lines patch added patch discarded remove patch
@@ -29,571 +29,571 @@
 block discarded – undo
29 29
  */
30 30
 class Wordlift {
31 31
 
32
-	/**
33
-	 * The loader that's responsible for maintaining and registering all hooks that power
34
-	 * the plugin.
35
-	 *
36
-	 * @since    1.0.0
37
-	 * @access   protected
38
-	 * @var      Wordlift_Loader $loader Maintains and registers all hooks for the plugin.
39
-	 */
40
-	protected $loader;
41
-
42
-	/**
43
-	 * The unique identifier of this plugin.
44
-	 *
45
-	 * @since    1.0.0
46
-	 * @access   protected
47
-	 * @var      string $plugin_name The string used to uniquely identify this plugin.
48
-	 */
49
-	protected $plugin_name;
50
-
51
-	/**
52
-	 * The current version of the plugin.
53
-	 *
54
-	 * @since    1.0.0
55
-	 * @access   protected
56
-	 * @var      string $version The current version of the plugin.
57
-	 */
58
-	protected $version;
59
-
60
-	/**
61
-	 * The Thumbnail service.
62
-	 *
63
-	 * @since 3.1.5
64
-	 * @access private
65
-	 * @var \Wordlift_Thumbnail_Service $thumbnail_service The Thumbnail service.
66
-	 */
67
-	private $thumbnail_service;
68
-
69
-	/**
70
-	 * The UI service.
71
-	 *
72
-	 * @since 3.2.0
73
-	 * @access private
74
-	 * @var \Wordlift_UI_Service $ui_service The UI service.
75
-	 */
76
-	private $ui_service;
77
-
78
-	/**
79
-	 * The Schema service.
80
-	 *
81
-	 * @since 3.3.0
82
-	 * @access private
83
-	 * @var \Wordlift_Schema_Service $schema_service The Schema service.
84
-	 */
85
-	private $schema_service;
86
-
87
-	/**
88
-	 * The Entity service.
89
-	 *
90
-	 * @since 3.1.0
91
-	 * @access private
92
-	 * @var \Wordlift_Entity_Service $entity_service The Entity service.
93
-	 */
94
-	private $entity_service;
95
-
96
-	/**
97
-	 * The Topic Taxonomy service.
98
-	 *
99
-	 * @since 3.5.0
100
-	 * @access private
101
-	 * @var \Wordlift_Topic_Taxonomy_Service The Topic Taxonomy service.
102
-	 */
103
-	private $topic_taxonomy_service;
104
-
105
-	/**
106
-	 * The User service.
107
-	 *
108
-	 * @since 3.1.7
109
-	 * @access private
110
-	 * @var \Wordlift_User_Service $user_service The User service.
111
-	 */
112
-	private $user_service;
113
-
114
-	/**
115
-	 * The Timeline service.
116
-	 *
117
-	 * @since 3.1.0
118
-	 * @access private
119
-	 * @var \Wordlift_Timeline_Service $timeline_service The Timeline service.
120
-	 */
121
-	private $timeline_service;
122
-
123
-	/**
124
-	 * The Redirect service.
125
-	 *
126
-	 * @since 3.2.0
127
-	 * @access private
128
-	 * @var \Wordlift_Redirect_Service $redirect_service The Redirect service.
129
-	 */
130
-	private $redirect_service;
131
-
132
-	/**
133
-	 * The Notice service.
134
-	 *
135
-	 * @since 3.3.0
136
-	 * @access private
137
-	 * @var \Wordlift_Notice_Service $notice_service The Notice service.
138
-	 */
139
-	private $notice_service;
140
-
141
-	/**
142
-	 * The Entity list customization.
143
-	 *
144
-	 * @since 3.3.0
145
-	 * @access private
146
-	 * @var \Wordlift_List_Service $entity_list_service The Entity list service.
147
-	 */
148
-	private $entity_list_service;
149
-
150
-	/**
151
-	 * The Entity Types Taxonomy Walker.
152
-	 *
153
-	 * @since 3.1.0
154
-	 * @access private
155
-	 * @var \Wordlift_Entity_Types_Taxonomy_Walker $entity_types_taxonomy_walker The Entity Types Taxonomy Walker
156
-	 */
157
-	private $entity_types_taxonomy_walker;
158
-
159
-	/**
160
-	 * The ShareThis service.
161
-	 *
162
-	 * @since 3.2.0
163
-	 * @access private
164
-	 * @var \Wordlift_ShareThis_Service $sharethis_service The ShareThis service.
165
-	 */
166
-	private $sharethis_service;
167
-
168
-	/**
169
-	 * The PrimaShop adapter.
170
-	 *
171
-	 * @since 3.2.3
172
-	 * @access private
173
-	 * @var \Wordlift_PrimaShop_Adapter $primashop_adapter The PrimaShop adapter.
174
-	 */
175
-	private $primashop_adapter;
176
-
177
-	/**
178
-	 * The WordLift Dashboard adapter.
179
-	 *
180
-	 * @since 3.4.0
181
-	 * @access private
182
-	 * @var \Wordlift_Dashboard_Service $dashboard_service The WordLift Dashboard service;
183
-	 */
184
-	private $dashboard_service;
185
-
186
-	/**
187
-	 * The entity type service.
188
-	 *
189
-	 * @since 3.6.0
190
-	 * @access private
191
-	 * @var \Wordlift_Entity_Type_Service
192
-	 */
193
-	private $entity_type_service;
194
-
195
-	/**
196
-	 * The entity link service used to mangle links to entities with a custom slug or even w/o a slug.
197
-	 *
198
-	 * @since 3.6.0
199
-	 * @access private
200
-	 * @var \Wordlift_Entity_Link_Service
201
-	 */
202
-	private $entity_link_service;
203
-
204
-	/**
205
-	 * The page service instance which processes the page output in order to insert schema.org microdata to export the
206
-	 * correct page title to Google+.
207
-	 *
208
-	 * @since 3.5.3
209
-	 * @access private
210
-	 * @var \Wordlift_Page_Service
211
-	 */
212
-	private $page_service;
213
-
214
-
215
-	/**
216
-	 * Define the core functionality of the plugin.
217
-	 *
218
-	 * Set the plugin name and the plugin version that can be used throughout the plugin.
219
-	 * Load the dependencies, define the locale, and set the hooks for the admin area and
220
-	 * the public-facing side of the site.
221
-	 *
222
-	 * @since    1.0.0
223
-	 */
224
-	public function __construct() {
225
-
226
-		$this->plugin_name = 'wordlift';
227
-		$this->version     = '3.6.0-dev';
228
-		$this->load_dependencies();
229
-		$this->set_locale();
230
-		$this->define_admin_hooks();
231
-		$this->define_public_hooks();
232
-
233
-	}
234
-
235
-	/**
236
-	 * Load the required dependencies for this plugin.
237
-	 *
238
-	 * Include the following files that make up the plugin:
239
-	 *
240
-	 * - Wordlift_Loader. Orchestrates the hooks of the plugin.
241
-	 * - Wordlift_i18n. Defines internationalization functionality.
242
-	 * - Wordlift_Admin. Defines all hooks for the admin area.
243
-	 * - Wordlift_Public. Defines all hooks for the public side of the site.
244
-	 *
245
-	 * Create an instance of the loader which will be used to register the hooks
246
-	 * with WordPress.
247
-	 *
248
-	 * @since    1.0.0
249
-	 * @access   private
250
-	 */
251
-	private function load_dependencies() {
252
-
253
-		/**
254
-		 * The class responsible for orchestrating the actions and filters of the
255
-		 * core plugin.
256
-		 */
257
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-loader.php';
258
-
259
-		/**
260
-		 * The class responsible for defining internationalization functionality
261
-		 * of the plugin.
262
-		 */
263
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-i18n.php';
264
-
265
-		/**
266
-		 * Provide support functions to sanitize data.
267
-		 */
268
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sanitizer.php';
269
-
270
-		/**
271
-		 * The Redirect service.
272
-		 */
273
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-redirect-service.php';
274
-
275
-		/**
276
-		 * The Log service.
277
-		 */
278
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-log-service.php';
279
-
280
-		/**
281
-		 * The entity post type service.
282
-		 */
283
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-type-service.php';
284
-
285
-		/**
286
-		 * The entity link service.
287
-		 */
288
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-link-service.php';
289
-
290
-		/**
291
-		 * The Query builder.
292
-		 */
293
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-query-builder.php';
294
-
295
-		/**
296
-		 * The Schema service.
297
-		 */
298
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-schema-service.php';
299
-
300
-		/**
301
-		 * The UI service.
302
-		 */
303
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-ui-service.php';
304
-
305
-		/**
306
-		 * The Thumbnail service.
307
-		 */
308
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-thumbnail-service.php';
309
-
310
-		/**
311
-		 * The Entity Types Taxonomy service.
312
-		 */
313
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-types-taxonomy-service.php';
314
-
315
-		/**
316
-		 * The Entity service.
317
-		 */
318
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-service.php';
319
-
320
-		/**
321
-		 * The User service.
322
-		 */
323
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-user-service.php';
324
-
325
-		/**
326
-		 * The Timeline service.
327
-		 */
328
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-timeline-service.php';
329
-
330
-		/**
331
-		 * The Topic Taxonomy service.
332
-		 */
333
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-topic-taxonomy-service.php';
334
-
335
-
336
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-page-service.php';
337
-
338
-		/**
339
-		 * The class responsible for defining all actions that occur in the admin area.
340
-		 */
341
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin.php';
342
-
343
-		/**
344
-		 * The class to customize the entity list admin page.
345
-		 */
346
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-entity-list.php';
347
-
348
-		/**
349
-		 * The Entity Types Taxonomy Walker (transforms checkboxes into radios).
350
-		 */
351
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-types-taxonomy-walker.php';
352
-
353
-		/**
354
-		 * The Notice service.
355
-		 */
356
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-notice-service.php';
32
+    /**
33
+     * The loader that's responsible for maintaining and registering all hooks that power
34
+     * the plugin.
35
+     *
36
+     * @since    1.0.0
37
+     * @access   protected
38
+     * @var      Wordlift_Loader $loader Maintains and registers all hooks for the plugin.
39
+     */
40
+    protected $loader;
41
+
42
+    /**
43
+     * The unique identifier of this plugin.
44
+     *
45
+     * @since    1.0.0
46
+     * @access   protected
47
+     * @var      string $plugin_name The string used to uniquely identify this plugin.
48
+     */
49
+    protected $plugin_name;
50
+
51
+    /**
52
+     * The current version of the plugin.
53
+     *
54
+     * @since    1.0.0
55
+     * @access   protected
56
+     * @var      string $version The current version of the plugin.
57
+     */
58
+    protected $version;
59
+
60
+    /**
61
+     * The Thumbnail service.
62
+     *
63
+     * @since 3.1.5
64
+     * @access private
65
+     * @var \Wordlift_Thumbnail_Service $thumbnail_service The Thumbnail service.
66
+     */
67
+    private $thumbnail_service;
68
+
69
+    /**
70
+     * The UI service.
71
+     *
72
+     * @since 3.2.0
73
+     * @access private
74
+     * @var \Wordlift_UI_Service $ui_service The UI service.
75
+     */
76
+    private $ui_service;
77
+
78
+    /**
79
+     * The Schema service.
80
+     *
81
+     * @since 3.3.0
82
+     * @access private
83
+     * @var \Wordlift_Schema_Service $schema_service The Schema service.
84
+     */
85
+    private $schema_service;
86
+
87
+    /**
88
+     * The Entity service.
89
+     *
90
+     * @since 3.1.0
91
+     * @access private
92
+     * @var \Wordlift_Entity_Service $entity_service The Entity service.
93
+     */
94
+    private $entity_service;
95
+
96
+    /**
97
+     * The Topic Taxonomy service.
98
+     *
99
+     * @since 3.5.0
100
+     * @access private
101
+     * @var \Wordlift_Topic_Taxonomy_Service The Topic Taxonomy service.
102
+     */
103
+    private $topic_taxonomy_service;
104
+
105
+    /**
106
+     * The User service.
107
+     *
108
+     * @since 3.1.7
109
+     * @access private
110
+     * @var \Wordlift_User_Service $user_service The User service.
111
+     */
112
+    private $user_service;
113
+
114
+    /**
115
+     * The Timeline service.
116
+     *
117
+     * @since 3.1.0
118
+     * @access private
119
+     * @var \Wordlift_Timeline_Service $timeline_service The Timeline service.
120
+     */
121
+    private $timeline_service;
122
+
123
+    /**
124
+     * The Redirect service.
125
+     *
126
+     * @since 3.2.0
127
+     * @access private
128
+     * @var \Wordlift_Redirect_Service $redirect_service The Redirect service.
129
+     */
130
+    private $redirect_service;
131
+
132
+    /**
133
+     * The Notice service.
134
+     *
135
+     * @since 3.3.0
136
+     * @access private
137
+     * @var \Wordlift_Notice_Service $notice_service The Notice service.
138
+     */
139
+    private $notice_service;
140
+
141
+    /**
142
+     * The Entity list customization.
143
+     *
144
+     * @since 3.3.0
145
+     * @access private
146
+     * @var \Wordlift_List_Service $entity_list_service The Entity list service.
147
+     */
148
+    private $entity_list_service;
149
+
150
+    /**
151
+     * The Entity Types Taxonomy Walker.
152
+     *
153
+     * @since 3.1.0
154
+     * @access private
155
+     * @var \Wordlift_Entity_Types_Taxonomy_Walker $entity_types_taxonomy_walker The Entity Types Taxonomy Walker
156
+     */
157
+    private $entity_types_taxonomy_walker;
158
+
159
+    /**
160
+     * The ShareThis service.
161
+     *
162
+     * @since 3.2.0
163
+     * @access private
164
+     * @var \Wordlift_ShareThis_Service $sharethis_service The ShareThis service.
165
+     */
166
+    private $sharethis_service;
167
+
168
+    /**
169
+     * The PrimaShop adapter.
170
+     *
171
+     * @since 3.2.3
172
+     * @access private
173
+     * @var \Wordlift_PrimaShop_Adapter $primashop_adapter The PrimaShop adapter.
174
+     */
175
+    private $primashop_adapter;
176
+
177
+    /**
178
+     * The WordLift Dashboard adapter.
179
+     *
180
+     * @since 3.4.0
181
+     * @access private
182
+     * @var \Wordlift_Dashboard_Service $dashboard_service The WordLift Dashboard service;
183
+     */
184
+    private $dashboard_service;
185
+
186
+    /**
187
+     * The entity type service.
188
+     *
189
+     * @since 3.6.0
190
+     * @access private
191
+     * @var \Wordlift_Entity_Type_Service
192
+     */
193
+    private $entity_type_service;
194
+
195
+    /**
196
+     * The entity link service used to mangle links to entities with a custom slug or even w/o a slug.
197
+     *
198
+     * @since 3.6.0
199
+     * @access private
200
+     * @var \Wordlift_Entity_Link_Service
201
+     */
202
+    private $entity_link_service;
203
+
204
+    /**
205
+     * The page service instance which processes the page output in order to insert schema.org microdata to export the
206
+     * correct page title to Google+.
207
+     *
208
+     * @since 3.5.3
209
+     * @access private
210
+     * @var \Wordlift_Page_Service
211
+     */
212
+    private $page_service;
213
+
214
+
215
+    /**
216
+     * Define the core functionality of the plugin.
217
+     *
218
+     * Set the plugin name and the plugin version that can be used throughout the plugin.
219
+     * Load the dependencies, define the locale, and set the hooks for the admin area and
220
+     * the public-facing side of the site.
221
+     *
222
+     * @since    1.0.0
223
+     */
224
+    public function __construct() {
225
+
226
+        $this->plugin_name = 'wordlift';
227
+        $this->version     = '3.6.0-dev';
228
+        $this->load_dependencies();
229
+        $this->set_locale();
230
+        $this->define_admin_hooks();
231
+        $this->define_public_hooks();
232
+
233
+    }
234
+
235
+    /**
236
+     * Load the required dependencies for this plugin.
237
+     *
238
+     * Include the following files that make up the plugin:
239
+     *
240
+     * - Wordlift_Loader. Orchestrates the hooks of the plugin.
241
+     * - Wordlift_i18n. Defines internationalization functionality.
242
+     * - Wordlift_Admin. Defines all hooks for the admin area.
243
+     * - Wordlift_Public. Defines all hooks for the public side of the site.
244
+     *
245
+     * Create an instance of the loader which will be used to register the hooks
246
+     * with WordPress.
247
+     *
248
+     * @since    1.0.0
249
+     * @access   private
250
+     */
251
+    private function load_dependencies() {
252
+
253
+        /**
254
+         * The class responsible for orchestrating the actions and filters of the
255
+         * core plugin.
256
+         */
257
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-loader.php';
258
+
259
+        /**
260
+         * The class responsible for defining internationalization functionality
261
+         * of the plugin.
262
+         */
263
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-i18n.php';
264
+
265
+        /**
266
+         * Provide support functions to sanitize data.
267
+         */
268
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sanitizer.php';
269
+
270
+        /**
271
+         * The Redirect service.
272
+         */
273
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-redirect-service.php';
274
+
275
+        /**
276
+         * The Log service.
277
+         */
278
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-log-service.php';
279
+
280
+        /**
281
+         * The entity post type service.
282
+         */
283
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-type-service.php';
284
+
285
+        /**
286
+         * The entity link service.
287
+         */
288
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-link-service.php';
289
+
290
+        /**
291
+         * The Query builder.
292
+         */
293
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-query-builder.php';
294
+
295
+        /**
296
+         * The Schema service.
297
+         */
298
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-schema-service.php';
299
+
300
+        /**
301
+         * The UI service.
302
+         */
303
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-ui-service.php';
304
+
305
+        /**
306
+         * The Thumbnail service.
307
+         */
308
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-thumbnail-service.php';
309
+
310
+        /**
311
+         * The Entity Types Taxonomy service.
312
+         */
313
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-types-taxonomy-service.php';
314
+
315
+        /**
316
+         * The Entity service.
317
+         */
318
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-service.php';
319
+
320
+        /**
321
+         * The User service.
322
+         */
323
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-user-service.php';
324
+
325
+        /**
326
+         * The Timeline service.
327
+         */
328
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-timeline-service.php';
329
+
330
+        /**
331
+         * The Topic Taxonomy service.
332
+         */
333
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-topic-taxonomy-service.php';
334
+
335
+
336
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-page-service.php';
337
+
338
+        /**
339
+         * The class responsible for defining all actions that occur in the admin area.
340
+         */
341
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin.php';
342
+
343
+        /**
344
+         * The class to customize the entity list admin page.
345
+         */
346
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-entity-list.php';
347
+
348
+        /**
349
+         * The Entity Types Taxonomy Walker (transforms checkboxes into radios).
350
+         */
351
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-types-taxonomy-walker.php';
352
+
353
+        /**
354
+         * The Notice service.
355
+         */
356
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-notice-service.php';
357 357
 
358
-		/**
359
-		 * The PrimaShop adapter.
360
-		 */
361
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-primashop-adapter.php';
358
+        /**
359
+         * The PrimaShop adapter.
360
+         */
361
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-primashop-adapter.php';
362 362
 
363
-		/**
364
-		 * The WordLift Dashboard service.
365
-		 */
366
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-dashboard.php';
367
-
368
-		/**
369
-		 * The class responsible for defining all actions that occur in the public-facing
370
-		 * side of the site.
371
-		 */
372
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-public.php';
363
+        /**
364
+         * The WordLift Dashboard service.
365
+         */
366
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-dashboard.php';
367
+
368
+        /**
369
+         * The class responsible for defining all actions that occur in the public-facing
370
+         * side of the site.
371
+         */
372
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-public.php';
373 373
 
374
-		/**
375
-		 * The Timeline shortcode.
376
-		 */
377
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-timeline-shortcode.php';
374
+        /**
375
+         * The Timeline shortcode.
376
+         */
377
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-timeline-shortcode.php';
378 378
 
379
-		/**
380
-		 * The ShareThis service.
381
-		 */
382
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-sharethis-service.php';
379
+        /**
380
+         * The ShareThis service.
381
+         */
382
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-sharethis-service.php';
383 383
 
384
-		$this->loader = new Wordlift_Loader();
384
+        $this->loader = new Wordlift_Loader();
385 385
 
386
-		// Instantiate a global logger.
387
-		global $wl_logger;
388
-		$wl_logger = Wordlift_Log_Service::get_logger( 'WordLift' );
386
+        // Instantiate a global logger.
387
+        global $wl_logger;
388
+        $wl_logger = Wordlift_Log_Service::get_logger( 'WordLift' );
389 389
 
390
-		// Create an entity type service instance. It'll be later bound to the init action.
391
-		$this->entity_type_service = new Wordlift_Entity_Type_Service( Wordlift_Entity_Service::TYPE_NAME, WL_ENTITY_TYPE_SLUG );
390
+        // Create an entity type service instance. It'll be later bound to the init action.
391
+        $this->entity_type_service = new Wordlift_Entity_Type_Service( Wordlift_Entity_Service::TYPE_NAME, WL_ENTITY_TYPE_SLUG );
392 392
 
393
-		// Create an entity link service instance. It'll be later bound to the post_type_link and pre_get_posts actions.
394
-		$this->entity_link_service = new Wordlift_Entity_Link_Service( $this->entity_type_service, WL_ENTITY_TYPE_SLUG );
393
+        // Create an entity link service instance. It'll be later bound to the post_type_link and pre_get_posts actions.
394
+        $this->entity_link_service = new Wordlift_Entity_Link_Service( $this->entity_type_service, WL_ENTITY_TYPE_SLUG );
395 395
 
396
-		// Create an instance of the UI service.
397
-		$this->ui_service = new Wordlift_UI_Service();
396
+        // Create an instance of the UI service.
397
+        $this->ui_service = new Wordlift_UI_Service();
398 398
 
399
-		// Create an instance of the Thumbnail service. Later it'll be hooked to post meta events.
400
-		$this->thumbnail_service = new Wordlift_Thumbnail_Service();
399
+        // Create an instance of the Thumbnail service. Later it'll be hooked to post meta events.
400
+        $this->thumbnail_service = new Wordlift_Thumbnail_Service();
401 401
 
402
-		// Create an instance of the Schema service.
403
-		$this->schema_service = new Wordlift_Schema_Service();
402
+        // Create an instance of the Schema service.
403
+        $this->schema_service = new Wordlift_Schema_Service();
404 404
 
405
-		// Create an instance of the Notice service.
406
-		$this->notice_service = new Wordlift_Notice_Service();
405
+        // Create an instance of the Notice service.
406
+        $this->notice_service = new Wordlift_Notice_Service();
407 407
 
408
-		// Create an instance of the Entity service, passing the UI service to draw parts of the Entity admin page.
409
-		$this->entity_service = new Wordlift_Entity_Service( $this->ui_service, $this->schema_service, $this->notice_service );
408
+        // Create an instance of the Entity service, passing the UI service to draw parts of the Entity admin page.
409
+        $this->entity_service = new Wordlift_Entity_Service( $this->ui_service, $this->schema_service, $this->notice_service );
410 410
 
411
-		// Create an instance of the User service.
412
-		$this->user_service = new Wordlift_User_Service();
411
+        // Create an instance of the User service.
412
+        $this->user_service = new Wordlift_User_Service();
413 413
 
414
-		// Create a new instance of the Timeline service and Timeline shortcode.
415
-		$this->timeline_service = new Wordlift_Timeline_Service( $this->entity_service );
414
+        // Create a new instance of the Timeline service and Timeline shortcode.
415
+        $this->timeline_service = new Wordlift_Timeline_Service( $this->entity_service );
416 416
 
417
-		// Create a new instance of the Redirect service.
418
-		$this->redirect_service = new Wordlift_Redirect_Service( $this->entity_service );
417
+        // Create a new instance of the Redirect service.
418
+        $this->redirect_service = new Wordlift_Redirect_Service( $this->entity_service );
419 419
 
420
-		// Create a new instance of the Redirect service.
421
-		$this->dashboard_service = new Wordlift_Dashboard_Service( $this->entity_service );
420
+        // Create a new instance of the Redirect service.
421
+        $this->dashboard_service = new Wordlift_Dashboard_Service( $this->entity_service );
422 422
 
423
-		// Create an instance of the Timeline shortcode.
424
-		new Wordlift_Timeline_Shortcode();
423
+        // Create an instance of the Timeline shortcode.
424
+        new Wordlift_Timeline_Shortcode();
425 425
 
426
-		// Create entity list customization (wp-admin/edit.php)
427
-		$this->entity_list_service = new Wordlift_Entity_List_Service( $this->entity_service );
426
+        // Create entity list customization (wp-admin/edit.php)
427
+        $this->entity_list_service = new Wordlift_Entity_List_Service( $this->entity_service );
428 428
 
429
-		$this->entity_types_taxonomy_walker = new Wordlift_Entity_Types_Taxonomy_Walker();
429
+        $this->entity_types_taxonomy_walker = new Wordlift_Entity_Types_Taxonomy_Walker();
430 430
 
431
-		$this->topic_taxonomy_service = new Wordlift_Topic_Taxonomy_Service();
431
+        $this->topic_taxonomy_service = new Wordlift_Topic_Taxonomy_Service();
432 432
 
433
-		// Create an instance of the ShareThis service, later we hook it to the_content and the_excerpt filters.
434
-		$this->sharethis_service = new Wordlift_ShareThis_Service();
433
+        // Create an instance of the ShareThis service, later we hook it to the_content and the_excerpt filters.
434
+        $this->sharethis_service = new Wordlift_ShareThis_Service();
435 435
 
436
-		// Create an instance of the PrimaShop adapter.
437
-		$this->primashop_adapter = new Wordlift_PrimaShop_Adapter();
436
+        // Create an instance of the PrimaShop adapter.
437
+        $this->primashop_adapter = new Wordlift_PrimaShop_Adapter();
438 438
 
439
-		$this->page_service = new Wordlift_Page_Service();
440
-	}
439
+        $this->page_service = new Wordlift_Page_Service();
440
+    }
441 441
 
442
-	/**
443
-	 * Define the locale for this plugin for internationalization.
444
-	 *
445
-	 * Uses the Wordlift_i18n class in order to set the domain and to register the hook
446
-	 * with WordPress.
447
-	 *
448
-	 * @since    1.0.0
449
-	 * @access   private
450
-	 */
451
-	private function set_locale() {
442
+    /**
443
+     * Define the locale for this plugin for internationalization.
444
+     *
445
+     * Uses the Wordlift_i18n class in order to set the domain and to register the hook
446
+     * with WordPress.
447
+     *
448
+     * @since    1.0.0
449
+     * @access   private
450
+     */
451
+    private function set_locale() {
452 452
 
453
-		$plugin_i18n = new Wordlift_i18n();
454
-		$plugin_i18n->set_domain( $this->get_plugin_name() );
453
+        $plugin_i18n = new Wordlift_i18n();
454
+        $plugin_i18n->set_domain( $this->get_plugin_name() );
455 455
 
456
-		$this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' );
456
+        $this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' );
457 457
 
458
-	}
458
+    }
459 459
 
460
-	/**
461
-	 * Register all of the hooks related to the admin area functionality
462
-	 * of the plugin.
463
-	 *
464
-	 * @since    1.0.0
465
-	 * @access   private
466
-	 */
467
-	private function define_admin_hooks() {
460
+    /**
461
+     * Register all of the hooks related to the admin area functionality
462
+     * of the plugin.
463
+     *
464
+     * @since    1.0.0
465
+     * @access   private
466
+     */
467
+    private function define_admin_hooks() {
468 468
 
469
-		$plugin_admin = new Wordlift_Admin( $this->get_plugin_name(), $this->get_version() );
469
+        $plugin_admin = new Wordlift_Admin( $this->get_plugin_name(), $this->get_version() );
470 470
 
471
-		$this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' );
472
-		$this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' );
471
+        $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' );
472
+        $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' );
473 473
 
474
-		// Hook the init action to the Topic Taxonomy service.
475
-		$this->loader->add_action( 'init', $this->topic_taxonomy_service, 'init', 0 );
474
+        // Hook the init action to the Topic Taxonomy service.
475
+        $this->loader->add_action( 'init', $this->topic_taxonomy_service, 'init', 0 );
476 476
 
477
-		// Hook the deleted_post_meta action to the Thumbnail service.
478
-		$this->loader->add_action( 'deleted_post_meta', $this->thumbnail_service, 'deleted_post_meta', 10, 4 );
477
+        // Hook the deleted_post_meta action to the Thumbnail service.
478
+        $this->loader->add_action( 'deleted_post_meta', $this->thumbnail_service, 'deleted_post_meta', 10, 4 );
479 479
 
480
-		// Hook the added_post_meta action to the Thumbnail service.
481
-		$this->loader->add_action( 'added_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4 );
480
+        // Hook the added_post_meta action to the Thumbnail service.
481
+        $this->loader->add_action( 'added_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4 );
482 482
 
483
-		// Hook the updated_post_meta action to the Thumbnail service.
484
-		$this->loader->add_action( 'updated_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4 );
483
+        // Hook the updated_post_meta action to the Thumbnail service.
484
+        $this->loader->add_action( 'updated_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4 );
485 485
 
486
-		// Hook posts inserts (or updates) to the user service.
487
-		$this->loader->add_action( 'wp_insert_post', $this->user_service, 'wp_insert_post', 10, 3 );
486
+        // Hook posts inserts (or updates) to the user service.
487
+        $this->loader->add_action( 'wp_insert_post', $this->user_service, 'wp_insert_post', 10, 3 );
488 488
 
489
-		// Hook the AJAX wl_timeline action to the Timeline service.
490
-		$this->loader->add_action( 'wp_ajax_wl_timeline', $this->timeline_service, 'ajax_timeline' );
491
-
492
-		// Register custom allowed redirect hosts.
493
-		$this->loader->add_filter( 'allowed_redirect_hosts', $this->redirect_service, 'allowed_redirect_hosts' );
494
-		// Hook the AJAX wordlift_redirect action to the Redirect service.
495
-		$this->loader->add_action( 'wp_ajax_wordlift_redirect', $this->redirect_service, 'ajax_redirect' );
496
-		// Hook the AJAX wordlift_redirect action to the Redirect service.
497
-		$this->loader->add_action( 'wp_ajax_wordlift_get_stats', $this->dashboard_service, 'ajax_get_stats' );
498
-		// Hook the AJAX wordlift_redirect action to the Redirect service.
499
-		$this->loader->add_action( 'wp_dashboard_setup', $this->dashboard_service, 'add_dashboard_widgets' );
500
-
501
-		// Hook save_post to the entity service to update custom fields (such as alternate labels).
502
-		// We have a priority of 9 because we want to be executed before data is sent to Redlink.
503
-		$this->loader->add_action( 'save_post', $this->entity_service, 'save_post', 9, 3 );
504
-		$this->loader->add_action( 'save_post_entity', $this->entity_service, 'set_rating_for', 10, 1 );
505
-
506
-		$this->loader->add_action( 'edit_form_before_permalink', $this->entity_service, 'edit_form_before_permalink', 10, 1 );
507
-		$this->loader->add_action( 'in_admin_header', $this->entity_service, 'in_admin_header' );
508
-
509
-		// Entity listing customization (wp-admin/edit.php)
510
-		// Add custom columns
511
-		$this->loader->add_filter( 'manage_entity_posts_columns', $this->entity_list_service, 'register_custom_columns' );
512
-		$this->loader->add_filter( 'manage_entity_posts_custom_column', $this->entity_list_service, 'render_custom_columns', 10, 2 );
513
-		// Add 4W selection
514
-		$this->loader->add_action( 'restrict_manage_posts', $this->entity_list_service, 'restrict_manage_posts_classification_scope' );
515
-		$this->loader->add_filter( 'posts_clauses', $this->entity_list_service, 'posts_clauses_classification_scope' );
516
-
517
-		$this->loader->add_filter( 'wp_terms_checklist_args', $this->entity_types_taxonomy_walker, 'terms_checklist_args' );
518
-
519
-		// Hook the PrimaShop adapter to <em>prima_metabox_entity_header_args</em> in order to add header support for
520
-		// entities.
521
-		$this->loader->add_filter( 'prima_metabox_entity_header_args', $this->primashop_adapter, 'prima_metabox_entity_header_args', 10, 2 );
522
-	}
523
-
524
-	/**
525
-	 * Register all of the hooks related to the public-facing functionality
526
-	 * of the plugin.
527
-	 *
528
-	 * @since    1.0.0
529
-	 * @access   private
530
-	 */
531
-	private function define_public_hooks() {
532
-
533
-		$plugin_public = new Wordlift_Public( $this->get_plugin_name(), $this->get_version() );
534
-
535
-		// Register the entity post type.
536
-		$this->loader->add_action( 'init', $this->entity_type_service, 'register' );
537
-
538
-		// Bind the link generation and handling hooks to the entity link service.
539
-		$this->loader->add_filter( 'post_type_link', $this->entity_link_service, 'post_type_link', 10, 4 );
540
-		$this->loader->add_action( 'pre_get_posts', $this->entity_link_service, 'pre_get_posts', 10, 1 );
541
-		$this->loader->add_filter( 'wp_unique_post_slug_is_bad_flat_slug', $this->entity_link_service, 'wp_unique_post_slug_is_bad_flat_slug', 10, 3 );
542
-		$this->loader->add_filter( 'wp_unique_post_slug_is_bad_hierarchical_slug', $this->entity_link_service, 'wp_unique_post_slug_is_bad_hierarchical_slug', 10, 4 );
543
-
544
-		$this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' );
545
-		$this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' );
546
-
547
-		// Hook the AJAX wl_timeline action to the Timeline service.
548
-		$this->loader->add_action( 'wp_ajax_nopriv_wl_timeline', $this->timeline_service, 'ajax_timeline' );
549
-
550
-		// Hook the ShareThis service.
551
-		$this->loader->add_filter( 'the_content', $this->sharethis_service, 'the_content', 99 );
552
-		$this->loader->add_filter( 'the_excerpt', $this->sharethis_service, 'the_excerpt', 99 );
553
-
554
-		$this->loader->add_action( 'wp_head', $this->page_service, 'wp_head', PHP_INT_MAX );
555
-		$this->loader->add_action( 'wp_footer', $this->page_service, 'wp_head', -PHP_INT_MAX );
556
-
557
-	}
558
-
559
-	/**
560
-	 * Run the loader to execute all of the hooks with WordPress.
561
-	 *
562
-	 * @since    1.0.0
563
-	 */
564
-	public function run() {
565
-		$this->loader->run();
566
-	}
567
-
568
-	/**
569
-	 * The name of the plugin used to uniquely identify it within the context of
570
-	 * WordPress and to define internationalization functionality.
571
-	 *
572
-	 * @since     1.0.0
573
-	 * @return    string    The name of the plugin.
574
-	 */
575
-	public function get_plugin_name() {
576
-		return $this->plugin_name;
577
-	}
578
-
579
-	/**
580
-	 * The reference to the class that orchestrates the hooks with the plugin.
581
-	 *
582
-	 * @since     1.0.0
583
-	 * @return    Wordlift_Loader    Orchestrates the hooks of the plugin.
584
-	 */
585
-	public function get_loader() {
586
-		return $this->loader;
587
-	}
588
-
589
-	/**
590
-	 * Retrieve the version number of the plugin.
591
-	 *
592
-	 * @since     1.0.0
593
-	 * @return    string    The version number of the plugin.
594
-	 */
595
-	public function get_version() {
596
-		return $this->version;
597
-	}
489
+        // Hook the AJAX wl_timeline action to the Timeline service.
490
+        $this->loader->add_action( 'wp_ajax_wl_timeline', $this->timeline_service, 'ajax_timeline' );
491
+
492
+        // Register custom allowed redirect hosts.
493
+        $this->loader->add_filter( 'allowed_redirect_hosts', $this->redirect_service, 'allowed_redirect_hosts' );
494
+        // Hook the AJAX wordlift_redirect action to the Redirect service.
495
+        $this->loader->add_action( 'wp_ajax_wordlift_redirect', $this->redirect_service, 'ajax_redirect' );
496
+        // Hook the AJAX wordlift_redirect action to the Redirect service.
497
+        $this->loader->add_action( 'wp_ajax_wordlift_get_stats', $this->dashboard_service, 'ajax_get_stats' );
498
+        // Hook the AJAX wordlift_redirect action to the Redirect service.
499
+        $this->loader->add_action( 'wp_dashboard_setup', $this->dashboard_service, 'add_dashboard_widgets' );
500
+
501
+        // Hook save_post to the entity service to update custom fields (such as alternate labels).
502
+        // We have a priority of 9 because we want to be executed before data is sent to Redlink.
503
+        $this->loader->add_action( 'save_post', $this->entity_service, 'save_post', 9, 3 );
504
+        $this->loader->add_action( 'save_post_entity', $this->entity_service, 'set_rating_for', 10, 1 );
505
+
506
+        $this->loader->add_action( 'edit_form_before_permalink', $this->entity_service, 'edit_form_before_permalink', 10, 1 );
507
+        $this->loader->add_action( 'in_admin_header', $this->entity_service, 'in_admin_header' );
508
+
509
+        // Entity listing customization (wp-admin/edit.php)
510
+        // Add custom columns
511
+        $this->loader->add_filter( 'manage_entity_posts_columns', $this->entity_list_service, 'register_custom_columns' );
512
+        $this->loader->add_filter( 'manage_entity_posts_custom_column', $this->entity_list_service, 'render_custom_columns', 10, 2 );
513
+        // Add 4W selection
514
+        $this->loader->add_action( 'restrict_manage_posts', $this->entity_list_service, 'restrict_manage_posts_classification_scope' );
515
+        $this->loader->add_filter( 'posts_clauses', $this->entity_list_service, 'posts_clauses_classification_scope' );
516
+
517
+        $this->loader->add_filter( 'wp_terms_checklist_args', $this->entity_types_taxonomy_walker, 'terms_checklist_args' );
518
+
519
+        // Hook the PrimaShop adapter to <em>prima_metabox_entity_header_args</em> in order to add header support for
520
+        // entities.
521
+        $this->loader->add_filter( 'prima_metabox_entity_header_args', $this->primashop_adapter, 'prima_metabox_entity_header_args', 10, 2 );
522
+    }
523
+
524
+    /**
525
+     * Register all of the hooks related to the public-facing functionality
526
+     * of the plugin.
527
+     *
528
+     * @since    1.0.0
529
+     * @access   private
530
+     */
531
+    private function define_public_hooks() {
532
+
533
+        $plugin_public = new Wordlift_Public( $this->get_plugin_name(), $this->get_version() );
534
+
535
+        // Register the entity post type.
536
+        $this->loader->add_action( 'init', $this->entity_type_service, 'register' );
537
+
538
+        // Bind the link generation and handling hooks to the entity link service.
539
+        $this->loader->add_filter( 'post_type_link', $this->entity_link_service, 'post_type_link', 10, 4 );
540
+        $this->loader->add_action( 'pre_get_posts', $this->entity_link_service, 'pre_get_posts', 10, 1 );
541
+        $this->loader->add_filter( 'wp_unique_post_slug_is_bad_flat_slug', $this->entity_link_service, 'wp_unique_post_slug_is_bad_flat_slug', 10, 3 );
542
+        $this->loader->add_filter( 'wp_unique_post_slug_is_bad_hierarchical_slug', $this->entity_link_service, 'wp_unique_post_slug_is_bad_hierarchical_slug', 10, 4 );
543
+
544
+        $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' );
545
+        $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' );
546
+
547
+        // Hook the AJAX wl_timeline action to the Timeline service.
548
+        $this->loader->add_action( 'wp_ajax_nopriv_wl_timeline', $this->timeline_service, 'ajax_timeline' );
549
+
550
+        // Hook the ShareThis service.
551
+        $this->loader->add_filter( 'the_content', $this->sharethis_service, 'the_content', 99 );
552
+        $this->loader->add_filter( 'the_excerpt', $this->sharethis_service, 'the_excerpt', 99 );
553
+
554
+        $this->loader->add_action( 'wp_head', $this->page_service, 'wp_head', PHP_INT_MAX );
555
+        $this->loader->add_action( 'wp_footer', $this->page_service, 'wp_head', -PHP_INT_MAX );
556
+
557
+    }
558
+
559
+    /**
560
+     * Run the loader to execute all of the hooks with WordPress.
561
+     *
562
+     * @since    1.0.0
563
+     */
564
+    public function run() {
565
+        $this->loader->run();
566
+    }
567
+
568
+    /**
569
+     * The name of the plugin used to uniquely identify it within the context of
570
+     * WordPress and to define internationalization functionality.
571
+     *
572
+     * @since     1.0.0
573
+     * @return    string    The name of the plugin.
574
+     */
575
+    public function get_plugin_name() {
576
+        return $this->plugin_name;
577
+    }
578
+
579
+    /**
580
+     * The reference to the class that orchestrates the hooks with the plugin.
581
+     *
582
+     * @since     1.0.0
583
+     * @return    Wordlift_Loader    Orchestrates the hooks of the plugin.
584
+     */
585
+    public function get_loader() {
586
+        return $this->loader;
587
+    }
588
+
589
+    /**
590
+     * Retrieve the version number of the plugin.
591
+     *
592
+     * @since     1.0.0
593
+     * @return    string    The version number of the plugin.
594
+     */
595
+    public function get_version() {
596
+        return $this->version;
597
+    }
598 598
 
599 599
 }
Please login to merge, or discard this patch.
Spacing   +72 added lines, -72 removed lines patch added patch discarded remove patch
@@ -254,144 +254,144 @@  discard block
 block discarded – undo
254 254
 		 * The class responsible for orchestrating the actions and filters of the
255 255
 		 * core plugin.
256 256
 		 */
257
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-loader.php';
257
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-loader.php';
258 258
 
259 259
 		/**
260 260
 		 * The class responsible for defining internationalization functionality
261 261
 		 * of the plugin.
262 262
 		 */
263
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-i18n.php';
263
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-i18n.php';
264 264
 
265 265
 		/**
266 266
 		 * Provide support functions to sanitize data.
267 267
 		 */
268
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sanitizer.php';
268
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-sanitizer.php';
269 269
 
270 270
 		/**
271 271
 		 * The Redirect service.
272 272
 		 */
273
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-redirect-service.php';
273
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-redirect-service.php';
274 274
 
275 275
 		/**
276 276
 		 * The Log service.
277 277
 		 */
278
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-log-service.php';
278
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-log-service.php';
279 279
 
280 280
 		/**
281 281
 		 * The entity post type service.
282 282
 		 */
283
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-type-service.php';
283
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-entity-type-service.php';
284 284
 
285 285
 		/**
286 286
 		 * The entity link service.
287 287
 		 */
288
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-link-service.php';
288
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-entity-link-service.php';
289 289
 
290 290
 		/**
291 291
 		 * The Query builder.
292 292
 		 */
293
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-query-builder.php';
293
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-query-builder.php';
294 294
 
295 295
 		/**
296 296
 		 * The Schema service.
297 297
 		 */
298
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-schema-service.php';
298
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-schema-service.php';
299 299
 
300 300
 		/**
301 301
 		 * The UI service.
302 302
 		 */
303
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-ui-service.php';
303
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-ui-service.php';
304 304
 
305 305
 		/**
306 306
 		 * The Thumbnail service.
307 307
 		 */
308
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-thumbnail-service.php';
308
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-thumbnail-service.php';
309 309
 
310 310
 		/**
311 311
 		 * The Entity Types Taxonomy service.
312 312
 		 */
313
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-types-taxonomy-service.php';
313
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-entity-types-taxonomy-service.php';
314 314
 
315 315
 		/**
316 316
 		 * The Entity service.
317 317
 		 */
318
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-service.php';
318
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-entity-service.php';
319 319
 
320 320
 		/**
321 321
 		 * The User service.
322 322
 		 */
323
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-user-service.php';
323
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-user-service.php';
324 324
 
325 325
 		/**
326 326
 		 * The Timeline service.
327 327
 		 */
328
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-timeline-service.php';
328
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-timeline-service.php';
329 329
 
330 330
 		/**
331 331
 		 * The Topic Taxonomy service.
332 332
 		 */
333
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-topic-taxonomy-service.php';
333
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-topic-taxonomy-service.php';
334 334
 
335 335
 
336
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-page-service.php';
336
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-page-service.php';
337 337
 
338 338
 		/**
339 339
 		 * The class responsible for defining all actions that occur in the admin area.
340 340
 		 */
341
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin.php';
341
+		require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin.php';
342 342
 
343 343
 		/**
344 344
 		 * The class to customize the entity list admin page.
345 345
 		 */
346
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-entity-list.php';
346
+		require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-entity-list.php';
347 347
 
348 348
 		/**
349 349
 		 * The Entity Types Taxonomy Walker (transforms checkboxes into radios).
350 350
 		 */
351
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-types-taxonomy-walker.php';
351
+		require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-entity-types-taxonomy-walker.php';
352 352
 
353 353
 		/**
354 354
 		 * The Notice service.
355 355
 		 */
356
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-notice-service.php';
356
+		require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-notice-service.php';
357 357
 
358 358
 		/**
359 359
 		 * The PrimaShop adapter.
360 360
 		 */
361
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-primashop-adapter.php';
361
+		require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-primashop-adapter.php';
362 362
 
363 363
 		/**
364 364
 		 * The WordLift Dashboard service.
365 365
 		 */
366
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-dashboard.php';
366
+		require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-dashboard.php';
367 367
 
368 368
 		/**
369 369
 		 * The class responsible for defining all actions that occur in the public-facing
370 370
 		 * side of the site.
371 371
 		 */
372
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-public.php';
372
+		require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-public.php';
373 373
 
374 374
 		/**
375 375
 		 * The Timeline shortcode.
376 376
 		 */
377
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-timeline-shortcode.php';
377
+		require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-timeline-shortcode.php';
378 378
 
379 379
 		/**
380 380
 		 * The ShareThis service.
381 381
 		 */
382
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-sharethis-service.php';
382
+		require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-sharethis-service.php';
383 383
 
384 384
 		$this->loader = new Wordlift_Loader();
385 385
 
386 386
 		// Instantiate a global logger.
387 387
 		global $wl_logger;
388
-		$wl_logger = Wordlift_Log_Service::get_logger( 'WordLift' );
388
+		$wl_logger = Wordlift_Log_Service::get_logger('WordLift');
389 389
 
390 390
 		// Create an entity type service instance. It'll be later bound to the init action.
391
-		$this->entity_type_service = new Wordlift_Entity_Type_Service( Wordlift_Entity_Service::TYPE_NAME, WL_ENTITY_TYPE_SLUG );
391
+		$this->entity_type_service = new Wordlift_Entity_Type_Service(Wordlift_Entity_Service::TYPE_NAME, WL_ENTITY_TYPE_SLUG);
392 392
 
393 393
 		// Create an entity link service instance. It'll be later bound to the post_type_link and pre_get_posts actions.
394
-		$this->entity_link_service = new Wordlift_Entity_Link_Service( $this->entity_type_service, WL_ENTITY_TYPE_SLUG );
394
+		$this->entity_link_service = new Wordlift_Entity_Link_Service($this->entity_type_service, WL_ENTITY_TYPE_SLUG);
395 395
 
396 396
 		// Create an instance of the UI service.
397 397
 		$this->ui_service = new Wordlift_UI_Service();
@@ -406,25 +406,25 @@  discard block
 block discarded – undo
406 406
 		$this->notice_service = new Wordlift_Notice_Service();
407 407
 
408 408
 		// Create an instance of the Entity service, passing the UI service to draw parts of the Entity admin page.
409
-		$this->entity_service = new Wordlift_Entity_Service( $this->ui_service, $this->schema_service, $this->notice_service );
409
+		$this->entity_service = new Wordlift_Entity_Service($this->ui_service, $this->schema_service, $this->notice_service);
410 410
 
411 411
 		// Create an instance of the User service.
412 412
 		$this->user_service = new Wordlift_User_Service();
413 413
 
414 414
 		// Create a new instance of the Timeline service and Timeline shortcode.
415
-		$this->timeline_service = new Wordlift_Timeline_Service( $this->entity_service );
415
+		$this->timeline_service = new Wordlift_Timeline_Service($this->entity_service);
416 416
 
417 417
 		// Create a new instance of the Redirect service.
418
-		$this->redirect_service = new Wordlift_Redirect_Service( $this->entity_service );
418
+		$this->redirect_service = new Wordlift_Redirect_Service($this->entity_service);
419 419
 
420 420
 		// Create a new instance of the Redirect service.
421
-		$this->dashboard_service = new Wordlift_Dashboard_Service( $this->entity_service );
421
+		$this->dashboard_service = new Wordlift_Dashboard_Service($this->entity_service);
422 422
 
423 423
 		// Create an instance of the Timeline shortcode.
424 424
 		new Wordlift_Timeline_Shortcode();
425 425
 
426 426
 		// Create entity list customization (wp-admin/edit.php)
427
-		$this->entity_list_service = new Wordlift_Entity_List_Service( $this->entity_service );
427
+		$this->entity_list_service = new Wordlift_Entity_List_Service($this->entity_service);
428 428
 
429 429
 		$this->entity_types_taxonomy_walker = new Wordlift_Entity_Types_Taxonomy_Walker();
430 430
 
@@ -451,9 +451,9 @@  discard block
 block discarded – undo
451 451
 	private function set_locale() {
452 452
 
453 453
 		$plugin_i18n = new Wordlift_i18n();
454
-		$plugin_i18n->set_domain( $this->get_plugin_name() );
454
+		$plugin_i18n->set_domain($this->get_plugin_name());
455 455
 
456
-		$this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' );
456
+		$this->loader->add_action('plugins_loaded', $plugin_i18n, 'load_plugin_textdomain');
457 457
 
458 458
 	}
459 459
 
@@ -466,59 +466,59 @@  discard block
 block discarded – undo
466 466
 	 */
467 467
 	private function define_admin_hooks() {
468 468
 
469
-		$plugin_admin = new Wordlift_Admin( $this->get_plugin_name(), $this->get_version() );
469
+		$plugin_admin = new Wordlift_Admin($this->get_plugin_name(), $this->get_version());
470 470
 
471
-		$this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' );
472
-		$this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' );
471
+		$this->loader->add_action('admin_enqueue_scripts', $plugin_admin, 'enqueue_styles');
472
+		$this->loader->add_action('admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts');
473 473
 
474 474
 		// Hook the init action to the Topic Taxonomy service.
475
-		$this->loader->add_action( 'init', $this->topic_taxonomy_service, 'init', 0 );
475
+		$this->loader->add_action('init', $this->topic_taxonomy_service, 'init', 0);
476 476
 
477 477
 		// Hook the deleted_post_meta action to the Thumbnail service.
478
-		$this->loader->add_action( 'deleted_post_meta', $this->thumbnail_service, 'deleted_post_meta', 10, 4 );
478
+		$this->loader->add_action('deleted_post_meta', $this->thumbnail_service, 'deleted_post_meta', 10, 4);
479 479
 
480 480
 		// Hook the added_post_meta action to the Thumbnail service.
481
-		$this->loader->add_action( 'added_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4 );
481
+		$this->loader->add_action('added_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4);
482 482
 
483 483
 		// Hook the updated_post_meta action to the Thumbnail service.
484
-		$this->loader->add_action( 'updated_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4 );
484
+		$this->loader->add_action('updated_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4);
485 485
 
486 486
 		// Hook posts inserts (or updates) to the user service.
487
-		$this->loader->add_action( 'wp_insert_post', $this->user_service, 'wp_insert_post', 10, 3 );
487
+		$this->loader->add_action('wp_insert_post', $this->user_service, 'wp_insert_post', 10, 3);
488 488
 
489 489
 		// Hook the AJAX wl_timeline action to the Timeline service.
490
-		$this->loader->add_action( 'wp_ajax_wl_timeline', $this->timeline_service, 'ajax_timeline' );
490
+		$this->loader->add_action('wp_ajax_wl_timeline', $this->timeline_service, 'ajax_timeline');
491 491
 
492 492
 		// Register custom allowed redirect hosts.
493
-		$this->loader->add_filter( 'allowed_redirect_hosts', $this->redirect_service, 'allowed_redirect_hosts' );
493
+		$this->loader->add_filter('allowed_redirect_hosts', $this->redirect_service, 'allowed_redirect_hosts');
494 494
 		// Hook the AJAX wordlift_redirect action to the Redirect service.
495
-		$this->loader->add_action( 'wp_ajax_wordlift_redirect', $this->redirect_service, 'ajax_redirect' );
495
+		$this->loader->add_action('wp_ajax_wordlift_redirect', $this->redirect_service, 'ajax_redirect');
496 496
 		// Hook the AJAX wordlift_redirect action to the Redirect service.
497
-		$this->loader->add_action( 'wp_ajax_wordlift_get_stats', $this->dashboard_service, 'ajax_get_stats' );
497
+		$this->loader->add_action('wp_ajax_wordlift_get_stats', $this->dashboard_service, 'ajax_get_stats');
498 498
 		// Hook the AJAX wordlift_redirect action to the Redirect service.
499
-		$this->loader->add_action( 'wp_dashboard_setup', $this->dashboard_service, 'add_dashboard_widgets' );
499
+		$this->loader->add_action('wp_dashboard_setup', $this->dashboard_service, 'add_dashboard_widgets');
500 500
 
501 501
 		// Hook save_post to the entity service to update custom fields (such as alternate labels).
502 502
 		// We have a priority of 9 because we want to be executed before data is sent to Redlink.
503
-		$this->loader->add_action( 'save_post', $this->entity_service, 'save_post', 9, 3 );
504
-		$this->loader->add_action( 'save_post_entity', $this->entity_service, 'set_rating_for', 10, 1 );
503
+		$this->loader->add_action('save_post', $this->entity_service, 'save_post', 9, 3);
504
+		$this->loader->add_action('save_post_entity', $this->entity_service, 'set_rating_for', 10, 1);
505 505
 
506
-		$this->loader->add_action( 'edit_form_before_permalink', $this->entity_service, 'edit_form_before_permalink', 10, 1 );
507
-		$this->loader->add_action( 'in_admin_header', $this->entity_service, 'in_admin_header' );
506
+		$this->loader->add_action('edit_form_before_permalink', $this->entity_service, 'edit_form_before_permalink', 10, 1);
507
+		$this->loader->add_action('in_admin_header', $this->entity_service, 'in_admin_header');
508 508
 
509 509
 		// Entity listing customization (wp-admin/edit.php)
510 510
 		// Add custom columns
511
-		$this->loader->add_filter( 'manage_entity_posts_columns', $this->entity_list_service, 'register_custom_columns' );
512
-		$this->loader->add_filter( 'manage_entity_posts_custom_column', $this->entity_list_service, 'render_custom_columns', 10, 2 );
511
+		$this->loader->add_filter('manage_entity_posts_columns', $this->entity_list_service, 'register_custom_columns');
512
+		$this->loader->add_filter('manage_entity_posts_custom_column', $this->entity_list_service, 'render_custom_columns', 10, 2);
513 513
 		// Add 4W selection
514
-		$this->loader->add_action( 'restrict_manage_posts', $this->entity_list_service, 'restrict_manage_posts_classification_scope' );
515
-		$this->loader->add_filter( 'posts_clauses', $this->entity_list_service, 'posts_clauses_classification_scope' );
514
+		$this->loader->add_action('restrict_manage_posts', $this->entity_list_service, 'restrict_manage_posts_classification_scope');
515
+		$this->loader->add_filter('posts_clauses', $this->entity_list_service, 'posts_clauses_classification_scope');
516 516
 
517
-		$this->loader->add_filter( 'wp_terms_checklist_args', $this->entity_types_taxonomy_walker, 'terms_checklist_args' );
517
+		$this->loader->add_filter('wp_terms_checklist_args', $this->entity_types_taxonomy_walker, 'terms_checklist_args');
518 518
 
519 519
 		// Hook the PrimaShop adapter to <em>prima_metabox_entity_header_args</em> in order to add header support for
520 520
 		// entities.
521
-		$this->loader->add_filter( 'prima_metabox_entity_header_args', $this->primashop_adapter, 'prima_metabox_entity_header_args', 10, 2 );
521
+		$this->loader->add_filter('prima_metabox_entity_header_args', $this->primashop_adapter, 'prima_metabox_entity_header_args', 10, 2);
522 522
 	}
523 523
 
524 524
 	/**
@@ -530,29 +530,29 @@  discard block
 block discarded – undo
530 530
 	 */
531 531
 	private function define_public_hooks() {
532 532
 
533
-		$plugin_public = new Wordlift_Public( $this->get_plugin_name(), $this->get_version() );
533
+		$plugin_public = new Wordlift_Public($this->get_plugin_name(), $this->get_version());
534 534
 
535 535
 		// Register the entity post type.
536
-		$this->loader->add_action( 'init', $this->entity_type_service, 'register' );
536
+		$this->loader->add_action('init', $this->entity_type_service, 'register');
537 537
 
538 538
 		// Bind the link generation and handling hooks to the entity link service.
539
-		$this->loader->add_filter( 'post_type_link', $this->entity_link_service, 'post_type_link', 10, 4 );
540
-		$this->loader->add_action( 'pre_get_posts', $this->entity_link_service, 'pre_get_posts', 10, 1 );
541
-		$this->loader->add_filter( 'wp_unique_post_slug_is_bad_flat_slug', $this->entity_link_service, 'wp_unique_post_slug_is_bad_flat_slug', 10, 3 );
542
-		$this->loader->add_filter( 'wp_unique_post_slug_is_bad_hierarchical_slug', $this->entity_link_service, 'wp_unique_post_slug_is_bad_hierarchical_slug', 10, 4 );
539
+		$this->loader->add_filter('post_type_link', $this->entity_link_service, 'post_type_link', 10, 4);
540
+		$this->loader->add_action('pre_get_posts', $this->entity_link_service, 'pre_get_posts', 10, 1);
541
+		$this->loader->add_filter('wp_unique_post_slug_is_bad_flat_slug', $this->entity_link_service, 'wp_unique_post_slug_is_bad_flat_slug', 10, 3);
542
+		$this->loader->add_filter('wp_unique_post_slug_is_bad_hierarchical_slug', $this->entity_link_service, 'wp_unique_post_slug_is_bad_hierarchical_slug', 10, 4);
543 543
 
544
-		$this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' );
545
-		$this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' );
544
+		$this->loader->add_action('wp_enqueue_scripts', $plugin_public, 'enqueue_styles');
545
+		$this->loader->add_action('wp_enqueue_scripts', $plugin_public, 'enqueue_scripts');
546 546
 
547 547
 		// Hook the AJAX wl_timeline action to the Timeline service.
548
-		$this->loader->add_action( 'wp_ajax_nopriv_wl_timeline', $this->timeline_service, 'ajax_timeline' );
548
+		$this->loader->add_action('wp_ajax_nopriv_wl_timeline', $this->timeline_service, 'ajax_timeline');
549 549
 
550 550
 		// Hook the ShareThis service.
551
-		$this->loader->add_filter( 'the_content', $this->sharethis_service, 'the_content', 99 );
552
-		$this->loader->add_filter( 'the_excerpt', $this->sharethis_service, 'the_excerpt', 99 );
551
+		$this->loader->add_filter('the_content', $this->sharethis_service, 'the_content', 99);
552
+		$this->loader->add_filter('the_excerpt', $this->sharethis_service, 'the_excerpt', 99);
553 553
 
554
-		$this->loader->add_action( 'wp_head', $this->page_service, 'wp_head', PHP_INT_MAX );
555
-		$this->loader->add_action( 'wp_footer', $this->page_service, 'wp_head', -PHP_INT_MAX );
554
+		$this->loader->add_action('wp_head', $this->page_service, 'wp_head', PHP_INT_MAX);
555
+		$this->loader->add_action('wp_footer', $this->page_service, 'wp_head', -PHP_INT_MAX);
556 556
 
557 557
 	}
558 558
 
Please login to merge, or discard this patch.