Completed
Push — develop ( fbc9b9...df3f0b )
by David
02:46
created
src/admin/wordlift_admin.php 2 patches
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  */
5 5
 
6 6
 // Add the Admin menu.
7
-require_once( 'wordlift_admin_menu.php' );
7
+require_once('wordlift_admin_menu.php');
8 8
 
9 9
 /**
10 10
  * Serialize an entity post.
@@ -13,20 +13,20 @@  discard block
 block discarded – undo
13 13
  *
14 14
  * @return array mixed The entity data array.
15 15
  */
16
-function wl_serialize_entity( $entity ) {
16
+function wl_serialize_entity($entity) {
17 17
 
18
-	$entity = ( is_numeric( $entity ) ) ? get_post( $entity ) : $entity;
18
+	$entity = (is_numeric($entity)) ? get_post($entity) : $entity;
19 19
 	
20
-	$type   = wl_entity_type_taxonomy_get_type( $entity->ID );
21
-	$images = wl_get_image_urls( $entity->ID );
20
+	$type   = wl_entity_type_taxonomy_get_type($entity->ID);
21
+	$images = wl_get_image_urls($entity->ID);
22 22
 
23 23
 	return array(
24
-		'id'         	=> wl_get_entity_uri( $entity->ID ),
24
+		'id'         	=> wl_get_entity_uri($entity->ID),
25 25
 		'label'      	=> $entity->post_title,
26 26
 		'description'	=> $entity->post_content,
27
-		'sameAs'     	=> wl_schema_get_value( $entity->ID, 'sameAs' ),
28
-		'mainType'      => str_replace( 'wl-', '', $type['css_class'] ),
29
-		'types'      	=> wl_get_entity_rdf_types( $entity->ID ),
27
+		'sameAs'     	=> wl_schema_get_value($entity->ID, 'sameAs'),
28
+		'mainType'      => str_replace('wl-', '', $type['css_class']),
29
+		'types'      	=> wl_get_entity_rdf_types($entity->ID),
30 30
 		'images' 		=> $images,
31 31
 
32 32
 	);
@@ -41,28 +41,28 @@  discard block
 block discarded – undo
41 41
  *
42 42
  * @return array mixed The post data array.
43 43
  */
44
-function wl_remove_text_annotations( $data ) {
44
+function wl_remove_text_annotations($data) {
45 45
 
46 46
 	// Remove blank elements that can interfere with annoataions removing
47 47
 	// See https://github.com/insideout10/wordlift-plugin/issues/234
48 48
 	// Just blank attributes without any attribtues are cleaned up
49 49
 	$pattern = '/<(\w+)><\/\1>/im';
50 50
 	// Remove the pattern while it is found (match nested annotations).
51
-	while ( 1 === preg_match( $pattern, $data['post_content'] ) ) {		
52
-		$data['post_content'] = preg_replace( $pattern, '$2', $data['post_content'], -1, $count ); 
51
+	while (1 === preg_match($pattern, $data['post_content'])) {		
52
+		$data['post_content'] = preg_replace($pattern, '$2', $data['post_content'], -1, $count); 
53 53
 	}
54 54
 	// Remove text annotations
55 55
 	//    <span class="textannotation" id="urn:enhancement-777cbed4-b131-00fb-54a4-ed9b26ae57ea">
56 56
 	$pattern = '/<(\w+)[^>]*\sclass=\\\"textannotation(?!\sdisambiguated)[^\\"]*\\\"[^>]*>([^<]+)<\/\1>/im';
57 57
 	// Remove the pattern while it is found (match nested annotations).
58
-	while ( 1 === preg_match( $pattern, $data['post_content'] ) ) {		
59
-		$data['post_content'] = preg_replace( $pattern, '$2', $data['post_content'], -1, $count ); 
58
+	while (1 === preg_match($pattern, $data['post_content'])) {		
59
+		$data['post_content'] = preg_replace($pattern, '$2', $data['post_content'], -1, $count); 
60 60
 	}
61 61
 
62 62
 	return $data;
63 63
 }
64 64
 
65
-add_filter( 'wp_insert_post_data', 'wl_remove_text_annotations', '98', 1 );
65
+add_filter('wp_insert_post_data', 'wl_remove_text_annotations', '98', 1);
66 66
 
67 67
 /**
68 68
  * Adds wl-metabox CSS class to a metabox.
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
  *
74 74
  * @return array The updated list of CSS classes.
75 75
  */
76
-function wl_admin_metaboxes_add_css_class( $classes = array() ){
76
+function wl_admin_metaboxes_add_css_class($classes = array()) {
77 77
 	
78
-	return array_merge( $classes, array( 'wl-metabox' ) );
78
+	return array_merge($classes, array('wl-metabox'));
79 79
 }
Please login to merge, or discard this patch.
Indentation   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -15,21 +15,21 @@  discard block
 block discarded – undo
15 15
  */
16 16
 function wl_serialize_entity( $entity ) {
17 17
 
18
-	$entity = ( is_numeric( $entity ) ) ? get_post( $entity ) : $entity;
18
+    $entity = ( is_numeric( $entity ) ) ? get_post( $entity ) : $entity;
19 19
 	
20
-	$type   = wl_entity_type_taxonomy_get_type( $entity->ID );
21
-	$images = wl_get_image_urls( $entity->ID );
20
+    $type   = wl_entity_type_taxonomy_get_type( $entity->ID );
21
+    $images = wl_get_image_urls( $entity->ID );
22 22
 
23
-	return array(
24
-		'id'         	=> wl_get_entity_uri( $entity->ID ),
25
-		'label'      	=> $entity->post_title,
26
-		'description'	=> $entity->post_content,
27
-		'sameAs'     	=> wl_schema_get_value( $entity->ID, 'sameAs' ),
28
-		'mainType'      => str_replace( 'wl-', '', $type['css_class'] ),
29
-		'types'      	=> wl_get_entity_rdf_types( $entity->ID ),
30
-		'images' 		=> $images,
23
+    return array(
24
+        'id'         	=> wl_get_entity_uri( $entity->ID ),
25
+        'label'      	=> $entity->post_title,
26
+        'description'	=> $entity->post_content,
27
+        'sameAs'     	=> wl_schema_get_value( $entity->ID, 'sameAs' ),
28
+        'mainType'      => str_replace( 'wl-', '', $type['css_class'] ),
29
+        'types'      	=> wl_get_entity_rdf_types( $entity->ID ),
30
+        'images' 		=> $images,
31 31
 
32
-	);
32
+    );
33 33
 }
34 34
 
35 35
 /**
@@ -43,22 +43,22 @@  discard block
 block discarded – undo
43 43
  */
44 44
 function wl_remove_text_annotations( $data ) {
45 45
 
46
-	// Remove blank elements that can interfere with annoataions removing
47
-	// See https://github.com/insideout10/wordlift-plugin/issues/234
48
-	// Just blank attributes without any attribtues are cleaned up
49
-	$pattern = '/<(\w+)><\/\1>/im';
50
-	// Remove the pattern while it is found (match nested annotations).
51
-	while ( 1 === preg_match( $pattern, $data['post_content'] ) ) {		
52
-		$data['post_content'] = preg_replace( $pattern, '$2', $data['post_content'], -1, $count ); 
53
-	}
54
-	// Remove text annotations
55
-	//    <span class="textannotation" id="urn:enhancement-777cbed4-b131-00fb-54a4-ed9b26ae57ea">
56
-	$pattern = '/<(\w+)[^>]*\sclass=\\\"textannotation(?!\sdisambiguated)[^\\"]*\\\"[^>]*>([^<]+)<\/\1>/im';
57
-	// Remove the pattern while it is found (match nested annotations).
58
-	while ( 1 === preg_match( $pattern, $data['post_content'] ) ) {		
59
-		$data['post_content'] = preg_replace( $pattern, '$2', $data['post_content'], -1, $count ); 
60
-	}
61
-	return $data;
46
+    // Remove blank elements that can interfere with annoataions removing
47
+    // See https://github.com/insideout10/wordlift-plugin/issues/234
48
+    // Just blank attributes without any attribtues are cleaned up
49
+    $pattern = '/<(\w+)><\/\1>/im';
50
+    // Remove the pattern while it is found (match nested annotations).
51
+    while ( 1 === preg_match( $pattern, $data['post_content'] ) ) {		
52
+        $data['post_content'] = preg_replace( $pattern, '$2', $data['post_content'], -1, $count ); 
53
+    }
54
+    // Remove text annotations
55
+    //    <span class="textannotation" id="urn:enhancement-777cbed4-b131-00fb-54a4-ed9b26ae57ea">
56
+    $pattern = '/<(\w+)[^>]*\sclass=\\\"textannotation(?!\sdisambiguated)[^\\"]*\\\"[^>]*>([^<]+)<\/\1>/im';
57
+    // Remove the pattern while it is found (match nested annotations).
58
+    while ( 1 === preg_match( $pattern, $data['post_content'] ) ) {		
59
+        $data['post_content'] = preg_replace( $pattern, '$2', $data['post_content'], -1, $count ); 
60
+    }
61
+    return $data;
62 62
 }
63 63
 
64 64
 add_filter( 'wp_insert_post_data', 'wl_remove_text_annotations', '98', 1 );
@@ -74,5 +74,5 @@  discard block
 block discarded – undo
74 74
  */
75 75
 function wl_admin_metaboxes_add_css_class( $classes = array() ){
76 76
 	
77
-	return array_merge( $classes, array( 'wl-metabox' ) );
77
+    return array_merge( $classes, array( 'wl-metabox' ) );
78 78
 }
Please login to merge, or discard this patch.
src/modules/core/wordlift_core_constants.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -1,54 +1,54 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-define( 'WL_DEFAULT_THUMBNAIL_PATH', dirname( dirname( plugin_dir_url( __FILE__ ) ) ) . '/public/images/missing-image-150x150.png' );
4
-define( 'WL_DEFAULT_PATH', dirname( dirname( plugin_dir_url( __FILE__ ) ) ) . '/' );
3
+define('WL_DEFAULT_THUMBNAIL_PATH', dirname(dirname(plugin_dir_url(__FILE__))).'/public/images/missing-image-150x150.png');
4
+define('WL_DEFAULT_PATH', dirname(dirname(plugin_dir_url(__FILE__))).'/');
5 5
 
6 6
 // Database version 
7
-define( 'WL_DB_VERSION', '1.0' );
7
+define('WL_DB_VERSION', '1.0');
8 8
 // Custom table name
9
-define( 'WL_DB_RELATION_INSTANCES_TABLE_NAME', 'wl_relation_instances' );
9
+define('WL_DB_RELATION_INSTANCES_TABLE_NAME', 'wl_relation_instances');
10 10
 
11
-define( 'WL_WHAT_RELATION', 'what' );
12
-define( 'WL_WHO_RELATION', 'who' );
13
-define( 'WL_WHERE_RELATION', 'where' );
14
-define( 'WL_WHEN_RELATION', 'when' );
11
+define('WL_WHAT_RELATION', 'what');
12
+define('WL_WHO_RELATION', 'who');
13
+define('WL_WHERE_RELATION', 'where');
14
+define('WL_WHEN_RELATION', 'when');
15 15
 
16 16
 // Mapping options / validations rules used by wl_core_get_posts to perform validation on args
17 17
 // The array is serialized because array constants are only from php 5.6 on.
18
-define( 'WL_CORE_GET_POSTS_VALIDATION_RULES', serialize( array(
19
-	'get'            => array( 'posts', 'post_ids' ),
20
-	'as'             => array( 'object', 'subject' ),
21
-	'post_type'      => array( 'post', 'entity' ),
22
-	'post_status'    => array( 'draft', 'trash', 'publish' ),
23
-	'with_predicate' => array( WL_WHAT_RELATION, WL_WHEN_RELATION, WL_WHERE_RELATION, WL_WHO_RELATION ),
24
-) ) );
18
+define('WL_CORE_GET_POSTS_VALIDATION_RULES', serialize(array(
19
+	'get'            => array('posts', 'post_ids'),
20
+	'as'             => array('object', 'subject'),
21
+	'post_type'      => array('post', 'entity'),
22
+	'post_status'    => array('draft', 'trash', 'publish'),
23
+	'with_predicate' => array(WL_WHAT_RELATION, WL_WHEN_RELATION, WL_WHERE_RELATION, WL_WHO_RELATION),
24
+)));
25 25
 
26 26
 // Classification boxes configuration for angularjs edit-post widget
27 27
 // The array is serialized because array constants are only from php 5.6 on.
28 28
 
29
-define( 'WL_CORE_POST_CLASSIFICATION_BOXES', serialize( array(
29
+define('WL_CORE_POST_CLASSIFICATION_BOXES', serialize(array(
30 30
 	array(
31 31
 		'id'               => WL_WHAT_RELATION,
32 32
 		'label'            => 'What',
33
-		'registeredTypes'  => array( 'thing', 'creative-work' ),
33
+		'registeredTypes'  => array('thing', 'creative-work'),
34 34
 		'selectedEntities' => array(),
35 35
 	),
36 36
 	array(
37 37
 		'id'               => WL_WHO_RELATION,
38 38
 		'label'            => 'Who',
39
-		'registeredTypes'  => array( 'organization', 'person', 'local-business' ),
39
+		'registeredTypes'  => array('organization', 'person', 'local-business'),
40 40
 		'selectedEntities' => array(),
41 41
 	),
42 42
 	array(
43 43
 		'id'               => WL_WHERE_RELATION,
44 44
 		'label'            => 'Where',
45
-		'registeredTypes'  => array( 'place' ),
45
+		'registeredTypes'  => array('place'),
46 46
 		'selectedEntities' => array(),
47 47
 	),
48 48
 	array(
49 49
 		'id'               => WL_WHEN_RELATION,
50 50
 		'label'            => 'When',
51
-		'registeredTypes'  => array( 'event' ),
51
+		'registeredTypes'  => array('event'),
52 52
 		'selectedEntities' => array(),
53 53
 	),
54
-) ) );
55 54
\ No newline at end of file
55
+)));
56 56
\ No newline at end of file
Please login to merge, or discard this patch.
src/wordlift_content_filter.php 2 patches
Indentation   +170 added lines, -170 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  * @param string $uri Uri of the entity to search in the post content.
11 11
  */
12 12
 function wl_content_embed_build_regex_from_uri( $uri ) {
13
-	return '|<(\\w+)[^<]* itemid=\"' . esc_attr( $uri ) . '\"[^>]*>([^<]*)<\\/\\1>|i';
13
+    return '|<(\\w+)[^<]* itemid=\"' . esc_attr( $uri ) . '\"[^>]*>([^<]*)<\\/\\1>|i';
14 14
 }
15 15
 
16 16
 /**
@@ -22,8 +22,8 @@  discard block
 block discarded – undo
22 22
  */
23 23
 function wl_content_embed_microdata( $content ) {
24 24
 
25
-	// Apply microdata only to single pages.
26
-	/*if ( ! is_single() ) {
25
+    // Apply microdata only to single pages.
26
+    /*if ( ! is_single() ) {
27 27
 		wl_write_log( "wl_content_embed_microdata : is not single" );
28 28
 
29 29
 		return $content;
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
 
32 32
 	global $post;
33 33
         */
34
-	return _wl_content_embed_microdata( get_the_ID(), $content );
34
+    return _wl_content_embed_microdata( get_the_ID(), $content );
35 35
 }
36 36
 
37 37
 /**
@@ -44,31 +44,31 @@  discard block
 block discarded – undo
44 44
  */
45 45
 function _wl_content_embed_microdata( $post_id, $content ) {
46 46
 
47
-	// If it is an entity, add its own microdata to the content.
48
-	if ( get_post_type( $post_id ) == Wordlift_Entity_Service::TYPE_NAME ) {
49
-		$own_uri = wl_get_entity_uri( $post_id );
50
-		$content .= '<span itemid="' . $own_uri . '"></span>';
51
-	}
47
+    // If it is an entity, add its own microdata to the content.
48
+    if ( get_post_type( $post_id ) == Wordlift_Entity_Service::TYPE_NAME ) {
49
+        $own_uri = wl_get_entity_uri( $post_id );
50
+        $content .= '<span itemid="' . $own_uri . '"></span>';
51
+    }
52 52
 
53
-	// Now search in the text entity mentions
54
-	$regex   = '/<(\\w+)[^<]* itemid=\"([^"]+)\"[^>]*>([^<]*)<\\/\\1>/i';
55
-	$matches = array();
53
+    // Now search in the text entity mentions
54
+    $regex   = '/<(\\w+)[^<]* itemid=\"([^"]+)\"[^>]*>([^<]*)<\\/\\1>/i';
55
+    $matches = array();
56 56
 
57
-	// Return the content if not item IDs have been found.
58
-	if ( FALSE === preg_match_all( $regex, $content, $matches, PREG_SET_ORDER ) ) {
59
-		return $content;
60
-	}
57
+    // Return the content if not item IDs have been found.
58
+    if ( FALSE === preg_match_all( $regex, $content, $matches, PREG_SET_ORDER ) ) {
59
+        return $content;
60
+    }
61 61
 
62
-	// TODO: Retrieve here just one time entities type structure to avoid multiple queries.
63
-	foreach ( $matches as $match ) {
64
-		$item_id = $match[2];
62
+    // TODO: Retrieve here just one time entities type structure to avoid multiple queries.
63
+    foreach ( $matches as $match ) {
64
+        $item_id = $match[2];
65 65
 
66
-		// wl_write_log( "_wl_content_embed_microdata [ item ID :: $item_id ]" );
66
+        // wl_write_log( "_wl_content_embed_microdata [ item ID :: $item_id ]" );
67 67
 
68
-		$content = wl_content_embed_item_microdata( $content, $item_id );
69
-	}
68
+        $content = wl_content_embed_item_microdata( $content, $item_id );
69
+    }
70 70
 
71
-	return $content;
71
+    return $content;
72 72
 }
73 73
 
74 74
 /**
@@ -82,80 +82,80 @@  discard block
 block discarded – undo
82 82
  */
83 83
 function wl_content_embed_item_microdata( $content, $uri, $itemprop = NULL, $recursion_level = 0 ) {
84 84
 
85
-	// The recursion level is set by `wl_content_embed_compile_microdata_template`
86
-	// which is loading referenced entities and calling again this function to print
87
-	// additional properties. By default WordLift doesn't print more than 3 nested
88
-	// entities.
89
-	if ( $recursion_level > wl_config_get_recursion_depth() ) {
90
-		wl_write_log( "recursion depth limit exceeded [ level :: $recursion_level ][ max :: " . wl_config_get_recursion_depth() . " ]" );
85
+    // The recursion level is set by `wl_content_embed_compile_microdata_template`
86
+    // which is loading referenced entities and calling again this function to print
87
+    // additional properties. By default WordLift doesn't print more than 3 nested
88
+    // entities.
89
+    if ( $recursion_level > wl_config_get_recursion_depth() ) {
90
+        wl_write_log( "recursion depth limit exceeded [ level :: $recursion_level ][ max :: " . wl_config_get_recursion_depth() . " ]" );
91 91
 
92
-		return '';
93
-	}
92
+        return '';
93
+    }
94 94
 
95
-	$post = Wordlift_Entity_Service::get_instance()
96
-	                               ->get_entity_post_by_uri( $uri );
95
+    $post = Wordlift_Entity_Service::get_instance()
96
+                                    ->get_entity_post_by_uri( $uri );
97 97
 
98
-	// Entity not found or not published. Delete <span> tags but leave their content on page.
99
-	if ( NULL === $post || $post->post_status !== 'publish' ) {
98
+    // Entity not found or not published. Delete <span> tags but leave their content on page.
99
+    if ( NULL === $post || $post->post_status !== 'publish' ) {
100 100
 
101
-		// wl_write_log( "wl_content_embed_item_microdata : entity not found or not published [ uri :: $uri ]" );
101
+        // wl_write_log( "wl_content_embed_item_microdata : entity not found or not published [ uri :: $uri ]" );
102 102
 
103
-		// Replace the original tagging with the new tagging.
104
-		$regex   = wl_content_embed_build_regex_from_uri( $uri );
105
-		$content = preg_replace( $regex, '$2', $content );
103
+        // Replace the original tagging with the new tagging.
104
+        $regex   = wl_content_embed_build_regex_from_uri( $uri );
105
+        $content = preg_replace( $regex, '$2', $content );
106 106
 
107
-		return $content;
108
-	}
107
+        return $content;
108
+    }
109 109
 
110
-	// Get the entity URI and its escaped version for the regex.
111
-	$entity_uri = wl_get_entity_uri( $post->ID );
112
-	// Get the main type.
113
-	$main_type = wl_entity_type_taxonomy_get_type( $post->ID );
110
+    // Get the entity URI and its escaped version for the regex.
111
+    $entity_uri = wl_get_entity_uri( $post->ID );
112
+    // Get the main type.
113
+    $main_type = wl_entity_type_taxonomy_get_type( $post->ID );
114 114
 
115
-	// Set the item type if available.
116
-	$item_type = ( NULL === $main_type ? '' : ' itemtype="' . esc_attr( $main_type['uri'] ) . '"' );
115
+    // Set the item type if available.
116
+    $item_type = ( NULL === $main_type ? '' : ' itemtype="' . esc_attr( $main_type['uri'] ) . '"' );
117 117
 
118
-	// Define attribute itemprop if this entity is nested.
119
-	if ( ! is_null( $itemprop ) ) {
120
-		$itemprop = ' itemprop="' . $itemprop . '"';
121
-	}
118
+    // Define attribute itemprop if this entity is nested.
119
+    if ( ! is_null( $itemprop ) ) {
120
+        $itemprop = ' itemprop="' . $itemprop . '"';
121
+    }
122 122
 
123
-	// Get additional properties (this may imply a recursion of this method on a sub-entity).
124
-	$additional_properties = wl_content_embed_compile_microdata_template( $post->ID, $main_type, $recursion_level );
123
+    // Get additional properties (this may imply a recursion of this method on a sub-entity).
124
+    $additional_properties = wl_content_embed_compile_microdata_template( $post->ID, $main_type, $recursion_level );
125 125
 
126
-	$same_as = '';
127
-	// Get the array of sameAs uris.
128
-	$same_as_uris = wl_schema_get_value( $post->ID, 'sameAs' );
129
-	// Prepare the sameAs fragment.
130
-	foreach ( $same_as_uris as $same_as_uri ) {
131
-		$same_as .= "<link itemprop=\"sameAs\" href=\"$same_as_uri\">";
132
-	}
126
+    $same_as = '';
127
+    // Get the array of sameAs uris.
128
+    $same_as_uris = wl_schema_get_value( $post->ID, 'sameAs' );
129
+    // Prepare the sameAs fragment.
130
+    foreach ( $same_as_uris as $same_as_uri ) {
131
+        $same_as .= "<link itemprop=\"sameAs\" href=\"$same_as_uri\">";
132
+    }
133 133
 
134
-	// Get the entity URL.
135
-	$permalink = get_permalink( $post->ID );
136
-	$url       = '<link itemprop="url" href="' . $permalink . '" />';
134
+    // Get the entity URL.
135
+    $permalink = get_permalink( $post->ID );
136
+    $url       = '<link itemprop="url" href="' . $permalink . '" />';
137 137
 
138 138
 
139
-	// If entity is nested, we do not show a link, but a hidden meta.
140
-	// See https://github.com/insideout10/wordlift-plugin/issues/348
141
-	$name = ! is_null( $itemprop )
142
-		? "<meta itemprop='name' content='$post->post_title' /></$1>"
143
-		: '<a class="wl-entity-page-link" href="' . $permalink . '" itemprop="name" content="' . $post->post_title . '">' . ( is_null( $itemprop ) ? '$2' : '' ) . '</a></$1>';
139
+    // If entity is nested, we do not show a link, but a hidden meta.
140
+    // See https://github.com/insideout10/wordlift-plugin/issues/348
141
+    $name = ! is_null( $itemprop )
142
+        ? "<meta itemprop='name' content='$post->post_title' /></$1>"
143
+        : '<a class="wl-entity-page-link" href="' . $permalink . '" itemprop="name" content="' . $post->post_title . '">' . ( is_null( $itemprop ) ? '$2' : '' ) . '</a></$1>';
144 144
 
145
-	// Replace the original tagging with the new tagging.
146
-	$regex   = wl_content_embed_build_regex_from_uri( $uri );
147
-	$content = preg_replace( $regex,
148
-		'<$1' . $itemprop . ' itemscope' . $item_type . ' itemid="' . esc_attr( $entity_uri ) . '">'
149
-		. $same_as
150
-		. $additional_properties
151
-		. $url
152
-		. $name,
153
-		$content
154
-	);
145
+    // Replace the original tagging with the new tagging.
146
+    $regex   = wl_content_embed_build_regex_from_uri( $uri );
147
+    $content = preg_replace( $regex,
148
+        '<$1' . $itemprop . ' itemscope' . $item_type . ' itemid="' . esc_attr( $entity_uri ) . '">'
149
+        . $same_as
150
+        . $additional_properties
151
+        . $url
152
+        . $name,
153
+        $content
154
+    );
155 155
 
156
-	// wl_write_log( "wl_content_embed_item_microdata [ uri :: $uri ][ regex :: $regex ]" );
156
+    // wl_write_log( "wl_content_embed_item_microdata [ uri :: $uri ][ regex :: $regex ]" );
157 157
 
158
-	return $content;
158
+    return $content;
159 159
 }
160 160
 
161 161
 add_filter( 'the_content', 'wl_content_embed_microdata' );
@@ -170,94 +170,94 @@  discard block
 block discarded – undo
170 170
  * @return string The content with embedded microdata.
171 171
  */
172 172
 function wl_content_embed_compile_microdata_template( $entity_id, $entity_type, $recursion_level = 0 ) {
173
-	global $wl_logger;
174
-
175
-	if ( WP_DEBUG ) {
176
-		$wl_logger->trace( "Embedding microdata [ entity id :: $entity_id ][ recursion level :: $recursion_level ]" );
177
-	}
178
-
179
-	$regex   = '/{{(.*?)}}/';
180
-	$matches = array();
181
-
182
-	if ( NULL === $entity_type ) {
183
-		return '';
184
-	}
185
-
186
-	$template = $entity_type['microdata_template'];
187
-	// Return empty string if template fields have not been found.
188
-	if ( FALSE === preg_match_all( $regex, $template, $matches, PREG_SET_ORDER ) ) {
189
-		return '';
190
-	}
191
-
192
-	foreach ( $matches as $match ) {
193
-
194
-		$placeholder = $match[0];
195
-		$field_name  = $match[1];
196
-
197
-		// Get property value.
198
-		$meta_collection = wl_schema_get_value( $entity_id, $field_name );
199
-
200
-		// If no value is given, just remove the placeholder from the template
201
-		if ( NULL == $meta_collection ) {
202
-			$template = str_replace( $placeholder, '', $template );
203
-			continue;
204
-		}
205
-
206
-		// What kind of value is it?
207
-		// TODO: Performance issue here: meta type retrieving should be centralized
208
-		$expected_type = wl_get_meta_type( $field_name );
209
-
210
-		if ( WP_DEBUG ) {
211
-			$wl_logger->trace( "Embedding microdata [ placeholder :: $placeholder ][ field name :: $field_name ][ meta collection :: " . ( is_array( $meta_collection ) ? var_export( $meta_collection, TRUE ) : $meta_collection ) . " ][ expected type :: $expected_type ]" );
212
-		}
213
-
214
-		foreach ( $meta_collection as $field_value ) {
215
-
216
-			// Quick and dirty patch for #163:
217
-			//  - only apply to URIs, i.e. to properties pointing to another post ( $field_value should be a post ID ),
218
-			//  - check that $field_value is actually a number,
219
-			//  - check that the referenced post is published.
220
-			//  OR
221
-			//  - if the value is empty then we don't display it.
222
-			if ( Wordlift_Schema_Service::DATA_TYPE_URI === $expected_type && is_numeric( $field_value ) && 'publish' !== ( $post_status = get_post_status( $field_value ) )
223
-			     || empty( $field_value )
224
-			) {
225
-
226
-				if ( WP_DEBUG ) {
227
-					$wl_logger->trace( "Microdata refers to a non-published post [ field value :: $field_value ][ post status :: $post_status ]" );
228
-				}
229
-
230
-				// Remove the placeholder.
231
-				$template = str_replace( $placeholder, '', $template );
232
-				continue;
233
-			}
234
-
235
-			if ( Wordlift_Schema_Service::DATA_TYPE_URI == $expected_type ) {
236
-				// If is a numeric value we assume it is an ID referencing for an internal entity.
237
-				if ( is_numeric( $field_value ) ) {
238
-					// Found id, get uri.
239
-					$field_value = wl_get_entity_uri( $field_value );
240
-				}
241
-				// Just if the linked entity does exist I can go further with template compiling
242
-				$nested_entity = Wordlift_Entity_Service::get_instance()
243
-				                                        ->get_entity_post_by_uri( $field_value );
244
-				if ( ! is_null( $nested_entity ) ) {
245
-					$content           = '<span itemid="' . esc_attr( $field_value ) . '">' . $nested_entity->post_title . '</span>';
246
-					$compiled_template = wl_content_embed_item_microdata( $content, $field_value, $field_name, ++ $recursion_level );
247
-					$template          = str_replace( $placeholder, $compiled_template, $template );
248
-				} else {
249
-					$template = str_replace( $placeholder, '', $template );
250
-				}
251
-				continue;
252
-			}
253
-
254
-			// Standard condition: field containing a raw value
255
-			// For non visible test, schema.org dictates to use the *meta* tag.
256
-			// see http://schema.org/docs/gs.html#advanced_missing
257
-			$value    = '<meta itemprop="' . esc_attr( $field_name ) . '" content="' . esc_attr( $field_value ) . '" />';
258
-			$template = str_replace( $placeholder, $value, $template );
259
-		}
260
-	}
261
-
262
-	return $template;
173
+    global $wl_logger;
174
+
175
+    if ( WP_DEBUG ) {
176
+        $wl_logger->trace( "Embedding microdata [ entity id :: $entity_id ][ recursion level :: $recursion_level ]" );
177
+    }
178
+
179
+    $regex   = '/{{(.*?)}}/';
180
+    $matches = array();
181
+
182
+    if ( NULL === $entity_type ) {
183
+        return '';
184
+    }
185
+
186
+    $template = $entity_type['microdata_template'];
187
+    // Return empty string if template fields have not been found.
188
+    if ( FALSE === preg_match_all( $regex, $template, $matches, PREG_SET_ORDER ) ) {
189
+        return '';
190
+    }
191
+
192
+    foreach ( $matches as $match ) {
193
+
194
+        $placeholder = $match[0];
195
+        $field_name  = $match[1];
196
+
197
+        // Get property value.
198
+        $meta_collection = wl_schema_get_value( $entity_id, $field_name );
199
+
200
+        // If no value is given, just remove the placeholder from the template
201
+        if ( NULL == $meta_collection ) {
202
+            $template = str_replace( $placeholder, '', $template );
203
+            continue;
204
+        }
205
+
206
+        // What kind of value is it?
207
+        // TODO: Performance issue here: meta type retrieving should be centralized
208
+        $expected_type = wl_get_meta_type( $field_name );
209
+
210
+        if ( WP_DEBUG ) {
211
+            $wl_logger->trace( "Embedding microdata [ placeholder :: $placeholder ][ field name :: $field_name ][ meta collection :: " . ( is_array( $meta_collection ) ? var_export( $meta_collection, TRUE ) : $meta_collection ) . " ][ expected type :: $expected_type ]" );
212
+        }
213
+
214
+        foreach ( $meta_collection as $field_value ) {
215
+
216
+            // Quick and dirty patch for #163:
217
+            //  - only apply to URIs, i.e. to properties pointing to another post ( $field_value should be a post ID ),
218
+            //  - check that $field_value is actually a number,
219
+            //  - check that the referenced post is published.
220
+            //  OR
221
+            //  - if the value is empty then we don't display it.
222
+            if ( Wordlift_Schema_Service::DATA_TYPE_URI === $expected_type && is_numeric( $field_value ) && 'publish' !== ( $post_status = get_post_status( $field_value ) )
223
+                 || empty( $field_value )
224
+            ) {
225
+
226
+                if ( WP_DEBUG ) {
227
+                    $wl_logger->trace( "Microdata refers to a non-published post [ field value :: $field_value ][ post status :: $post_status ]" );
228
+                }
229
+
230
+                // Remove the placeholder.
231
+                $template = str_replace( $placeholder, '', $template );
232
+                continue;
233
+            }
234
+
235
+            if ( Wordlift_Schema_Service::DATA_TYPE_URI == $expected_type ) {
236
+                // If is a numeric value we assume it is an ID referencing for an internal entity.
237
+                if ( is_numeric( $field_value ) ) {
238
+                    // Found id, get uri.
239
+                    $field_value = wl_get_entity_uri( $field_value );
240
+                }
241
+                // Just if the linked entity does exist I can go further with template compiling
242
+                $nested_entity = Wordlift_Entity_Service::get_instance()
243
+                                                        ->get_entity_post_by_uri( $field_value );
244
+                if ( ! is_null( $nested_entity ) ) {
245
+                    $content           = '<span itemid="' . esc_attr( $field_value ) . '">' . $nested_entity->post_title . '</span>';
246
+                    $compiled_template = wl_content_embed_item_microdata( $content, $field_value, $field_name, ++ $recursion_level );
247
+                    $template          = str_replace( $placeholder, $compiled_template, $template );
248
+                } else {
249
+                    $template = str_replace( $placeholder, '', $template );
250
+                }
251
+                continue;
252
+            }
253
+
254
+            // Standard condition: field containing a raw value
255
+            // For non visible test, schema.org dictates to use the *meta* tag.
256
+            // see http://schema.org/docs/gs.html#advanced_missing
257
+            $value    = '<meta itemprop="' . esc_attr( $field_name ) . '" content="' . esc_attr( $field_value ) . '" />';
258
+            $template = str_replace( $placeholder, $value, $template );
259
+        }
260
+    }
261
+
262
+    return $template;
263 263
 }
264 264
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -9,8 +9,8 @@  discard block
 block discarded – undo
9 9
  *
10 10
  * @param string $uri Uri of the entity to search in the post content.
11 11
  */
12
-function wl_content_embed_build_regex_from_uri( $uri ) {
13
-	return '|<(\\w+)[^<]* itemid=\"' . esc_attr( $uri ) . '\"[^>]*>([^<]*)<\\/\\1>|i';
12
+function wl_content_embed_build_regex_from_uri($uri) {
13
+	return '|<(\\w+)[^<]* itemid=\"'.esc_attr($uri).'\"[^>]*>([^<]*)<\\/\\1>|i';
14 14
 }
15 15
 
16 16
 /**
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
  *
21 21
  * @return string The updated post content.
22 22
  */
23
-function wl_content_embed_microdata( $content ) {
23
+function wl_content_embed_microdata($content) {
24 24
 
25 25
 	// Apply microdata only to single pages.
26 26
 	/*if ( ! is_single() ) {
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
 
32 32
 	global $post;
33 33
         */
34
-	return _wl_content_embed_microdata( get_the_ID(), $content );
34
+	return _wl_content_embed_microdata(get_the_ID(), $content);
35 35
 }
36 36
 
37 37
 /**
@@ -42,12 +42,12 @@  discard block
 block discarded – undo
42 42
  *
43 43
  * @return string The updated post content.
44 44
  */
45
-function _wl_content_embed_microdata( $post_id, $content ) {
45
+function _wl_content_embed_microdata($post_id, $content) {
46 46
 
47 47
 	// If it is an entity, add its own microdata to the content.
48
-	if ( get_post_type( $post_id ) == Wordlift_Entity_Service::TYPE_NAME ) {
49
-		$own_uri = wl_get_entity_uri( $post_id );
50
-		$content .= '<span itemid="' . $own_uri . '"></span>';
48
+	if (get_post_type($post_id) == Wordlift_Entity_Service::TYPE_NAME) {
49
+		$own_uri = wl_get_entity_uri($post_id);
50
+		$content .= '<span itemid="'.$own_uri.'"></span>';
51 51
 	}
52 52
 
53 53
 	// Now search in the text entity mentions
@@ -55,17 +55,17 @@  discard block
 block discarded – undo
55 55
 	$matches = array();
56 56
 
57 57
 	// Return the content if not item IDs have been found.
58
-	if ( FALSE === preg_match_all( $regex, $content, $matches, PREG_SET_ORDER ) ) {
58
+	if (FALSE === preg_match_all($regex, $content, $matches, PREG_SET_ORDER)) {
59 59
 		return $content;
60 60
 	}
61 61
 
62 62
 	// TODO: Retrieve here just one time entities type structure to avoid multiple queries.
63
-	foreach ( $matches as $match ) {
63
+	foreach ($matches as $match) {
64 64
 		$item_id = $match[2];
65 65
 
66 66
 		// wl_write_log( "_wl_content_embed_microdata [ item ID :: $item_id ]" );
67 67
 
68
-		$content = wl_content_embed_item_microdata( $content, $item_id );
68
+		$content = wl_content_embed_item_microdata($content, $item_id);
69 69
 	}
70 70
 
71 71
 	return $content;
@@ -80,72 +80,72 @@  discard block
 block discarded – undo
80 80
  *
81 81
  * @return string The content with embedded microdata.
82 82
  */
83
-function wl_content_embed_item_microdata( $content, $uri, $itemprop = NULL, $recursion_level = 0 ) {
83
+function wl_content_embed_item_microdata($content, $uri, $itemprop = NULL, $recursion_level = 0) {
84 84
 
85 85
 	// The recursion level is set by `wl_content_embed_compile_microdata_template`
86 86
 	// which is loading referenced entities and calling again this function to print
87 87
 	// additional properties. By default WordLift doesn't print more than 3 nested
88 88
 	// entities.
89
-	if ( $recursion_level > wl_config_get_recursion_depth() ) {
90
-		wl_write_log( "recursion depth limit exceeded [ level :: $recursion_level ][ max :: " . wl_config_get_recursion_depth() . " ]" );
89
+	if ($recursion_level > wl_config_get_recursion_depth()) {
90
+		wl_write_log("recursion depth limit exceeded [ level :: $recursion_level ][ max :: ".wl_config_get_recursion_depth()." ]");
91 91
 
92 92
 		return '';
93 93
 	}
94 94
 
95 95
 	$post = Wordlift_Entity_Service::get_instance()
96
-	                               ->get_entity_post_by_uri( $uri );
96
+	                               ->get_entity_post_by_uri($uri);
97 97
 
98 98
 	// Entity not found or not published. Delete <span> tags but leave their content on page.
99
-	if ( NULL === $post || $post->post_status !== 'publish' ) {
99
+	if (NULL === $post || $post->post_status !== 'publish') {
100 100
 
101 101
 		// wl_write_log( "wl_content_embed_item_microdata : entity not found or not published [ uri :: $uri ]" );
102 102
 
103 103
 		// Replace the original tagging with the new tagging.
104
-		$regex   = wl_content_embed_build_regex_from_uri( $uri );
105
-		$content = preg_replace( $regex, '$2', $content );
104
+		$regex   = wl_content_embed_build_regex_from_uri($uri);
105
+		$content = preg_replace($regex, '$2', $content);
106 106
 
107 107
 		return $content;
108 108
 	}
109 109
 
110 110
 	// Get the entity URI and its escaped version for the regex.
111
-	$entity_uri = wl_get_entity_uri( $post->ID );
111
+	$entity_uri = wl_get_entity_uri($post->ID);
112 112
 	// Get the main type.
113
-	$main_type = wl_entity_type_taxonomy_get_type( $post->ID );
113
+	$main_type = wl_entity_type_taxonomy_get_type($post->ID);
114 114
 
115 115
 	// Set the item type if available.
116
-	$item_type = ( NULL === $main_type ? '' : ' itemtype="' . esc_attr( $main_type['uri'] ) . '"' );
116
+	$item_type = (NULL === $main_type ? '' : ' itemtype="'.esc_attr($main_type['uri']).'"');
117 117
 
118 118
 	// Define attribute itemprop if this entity is nested.
119
-	if ( ! is_null( $itemprop ) ) {
120
-		$itemprop = ' itemprop="' . $itemprop . '"';
119
+	if ( ! is_null($itemprop)) {
120
+		$itemprop = ' itemprop="'.$itemprop.'"';
121 121
 	}
122 122
 
123 123
 	// Get additional properties (this may imply a recursion of this method on a sub-entity).
124
-	$additional_properties = wl_content_embed_compile_microdata_template( $post->ID, $main_type, $recursion_level );
124
+	$additional_properties = wl_content_embed_compile_microdata_template($post->ID, $main_type, $recursion_level);
125 125
 
126 126
 	$same_as = '';
127 127
 	// Get the array of sameAs uris.
128
-	$same_as_uris = wl_schema_get_value( $post->ID, 'sameAs' );
128
+	$same_as_uris = wl_schema_get_value($post->ID, 'sameAs');
129 129
 	// Prepare the sameAs fragment.
130
-	foreach ( $same_as_uris as $same_as_uri ) {
130
+	foreach ($same_as_uris as $same_as_uri) {
131 131
 		$same_as .= "<link itemprop=\"sameAs\" href=\"$same_as_uri\">";
132 132
 	}
133 133
 
134 134
 	// Get the entity URL.
135
-	$permalink = get_permalink( $post->ID );
136
-	$url       = '<link itemprop="url" href="' . $permalink . '" />';
135
+	$permalink = get_permalink($post->ID);
136
+	$url       = '<link itemprop="url" href="'.$permalink.'" />';
137 137
 
138 138
 
139 139
 	// If entity is nested, we do not show a link, but a hidden meta.
140 140
 	// See https://github.com/insideout10/wordlift-plugin/issues/348
141
-	$name = ! is_null( $itemprop )
141
+	$name = ! is_null($itemprop)
142 142
 		? "<meta itemprop='name' content='$post->post_title' /></$1>"
143
-		: '<a class="wl-entity-page-link" href="' . $permalink . '" itemprop="name" content="' . $post->post_title . '">' . ( is_null( $itemprop ) ? '$2' : '' ) . '</a></$1>';
143
+		: '<a class="wl-entity-page-link" href="'.$permalink.'" itemprop="name" content="'.$post->post_title.'">'.(is_null($itemprop) ? '$2' : '').'</a></$1>';
144 144
 
145 145
 	// Replace the original tagging with the new tagging.
146
-	$regex   = wl_content_embed_build_regex_from_uri( $uri );
147
-	$content = preg_replace( $regex,
148
-		'<$1' . $itemprop . ' itemscope' . $item_type . ' itemid="' . esc_attr( $entity_uri ) . '">'
146
+	$regex   = wl_content_embed_build_regex_from_uri($uri);
147
+	$content = preg_replace($regex,
148
+		'<$1'.$itemprop.' itemscope'.$item_type.' itemid="'.esc_attr($entity_uri).'">'
149 149
 		. $same_as
150 150
 		. $additional_properties
151 151
 		. $url
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
 	return $content;
159 159
 }
160 160
 
161
-add_filter( 'the_content', 'wl_content_embed_microdata' );
161
+add_filter('the_content', 'wl_content_embed_microdata');
162 162
 
163 163
 /**
164 164
  * Fills up the microdata_template with entity's values.
@@ -169,49 +169,49 @@  discard block
 block discarded – undo
169 169
  *
170 170
  * @return string The content with embedded microdata.
171 171
  */
172
-function wl_content_embed_compile_microdata_template( $entity_id, $entity_type, $recursion_level = 0 ) {
172
+function wl_content_embed_compile_microdata_template($entity_id, $entity_type, $recursion_level = 0) {
173 173
 	global $wl_logger;
174 174
 
175
-	if ( WP_DEBUG ) {
176
-		$wl_logger->trace( "Embedding microdata [ entity id :: $entity_id ][ recursion level :: $recursion_level ]" );
175
+	if (WP_DEBUG) {
176
+		$wl_logger->trace("Embedding microdata [ entity id :: $entity_id ][ recursion level :: $recursion_level ]");
177 177
 	}
178 178
 
179 179
 	$regex   = '/{{(.*?)}}/';
180 180
 	$matches = array();
181 181
 
182
-	if ( NULL === $entity_type ) {
182
+	if (NULL === $entity_type) {
183 183
 		return '';
184 184
 	}
185 185
 
186 186
 	$template = $entity_type['microdata_template'];
187 187
 	// Return empty string if template fields have not been found.
188
-	if ( FALSE === preg_match_all( $regex, $template, $matches, PREG_SET_ORDER ) ) {
188
+	if (FALSE === preg_match_all($regex, $template, $matches, PREG_SET_ORDER)) {
189 189
 		return '';
190 190
 	}
191 191
 
192
-	foreach ( $matches as $match ) {
192
+	foreach ($matches as $match) {
193 193
 
194 194
 		$placeholder = $match[0];
195 195
 		$field_name  = $match[1];
196 196
 
197 197
 		// Get property value.
198
-		$meta_collection = wl_schema_get_value( $entity_id, $field_name );
198
+		$meta_collection = wl_schema_get_value($entity_id, $field_name);
199 199
 
200 200
 		// If no value is given, just remove the placeholder from the template
201
-		if ( NULL == $meta_collection ) {
202
-			$template = str_replace( $placeholder, '', $template );
201
+		if (NULL == $meta_collection) {
202
+			$template = str_replace($placeholder, '', $template);
203 203
 			continue;
204 204
 		}
205 205
 
206 206
 		// What kind of value is it?
207 207
 		// TODO: Performance issue here: meta type retrieving should be centralized
208
-		$expected_type = wl_get_meta_type( $field_name );
208
+		$expected_type = wl_get_meta_type($field_name);
209 209
 
210
-		if ( WP_DEBUG ) {
211
-			$wl_logger->trace( "Embedding microdata [ placeholder :: $placeholder ][ field name :: $field_name ][ meta collection :: " . ( is_array( $meta_collection ) ? var_export( $meta_collection, TRUE ) : $meta_collection ) . " ][ expected type :: $expected_type ]" );
210
+		if (WP_DEBUG) {
211
+			$wl_logger->trace("Embedding microdata [ placeholder :: $placeholder ][ field name :: $field_name ][ meta collection :: ".(is_array($meta_collection) ? var_export($meta_collection, TRUE) : $meta_collection)." ][ expected type :: $expected_type ]");
212 212
 		}
213 213
 
214
-		foreach ( $meta_collection as $field_value ) {
214
+		foreach ($meta_collection as $field_value) {
215 215
 
216 216
 			// Quick and dirty patch for #163:
217 217
 			//  - only apply to URIs, i.e. to properties pointing to another post ( $field_value should be a post ID ),
@@ -219,34 +219,34 @@  discard block
 block discarded – undo
219 219
 			//  - check that the referenced post is published.
220 220
 			//  OR
221 221
 			//  - if the value is empty then we don't display it.
222
-			if ( Wordlift_Schema_Service::DATA_TYPE_URI === $expected_type && is_numeric( $field_value ) && 'publish' !== ( $post_status = get_post_status( $field_value ) )
223
-			     || empty( $field_value )
222
+			if (Wordlift_Schema_Service::DATA_TYPE_URI === $expected_type && is_numeric($field_value) && 'publish' !== ($post_status = get_post_status($field_value))
223
+			     || empty($field_value)
224 224
 			) {
225 225
 
226
-				if ( WP_DEBUG ) {
227
-					$wl_logger->trace( "Microdata refers to a non-published post [ field value :: $field_value ][ post status :: $post_status ]" );
226
+				if (WP_DEBUG) {
227
+					$wl_logger->trace("Microdata refers to a non-published post [ field value :: $field_value ][ post status :: $post_status ]");
228 228
 				}
229 229
 
230 230
 				// Remove the placeholder.
231
-				$template = str_replace( $placeholder, '', $template );
231
+				$template = str_replace($placeholder, '', $template);
232 232
 				continue;
233 233
 			}
234 234
 
235
-			if ( Wordlift_Schema_Service::DATA_TYPE_URI == $expected_type ) {
235
+			if (Wordlift_Schema_Service::DATA_TYPE_URI == $expected_type) {
236 236
 				// If is a numeric value we assume it is an ID referencing for an internal entity.
237
-				if ( is_numeric( $field_value ) ) {
237
+				if (is_numeric($field_value)) {
238 238
 					// Found id, get uri.
239
-					$field_value = wl_get_entity_uri( $field_value );
239
+					$field_value = wl_get_entity_uri($field_value);
240 240
 				}
241 241
 				// Just if the linked entity does exist I can go further with template compiling
242 242
 				$nested_entity = Wordlift_Entity_Service::get_instance()
243
-				                                        ->get_entity_post_by_uri( $field_value );
244
-				if ( ! is_null( $nested_entity ) ) {
245
-					$content           = '<span itemid="' . esc_attr( $field_value ) . '">' . $nested_entity->post_title . '</span>';
246
-					$compiled_template = wl_content_embed_item_microdata( $content, $field_value, $field_name, ++ $recursion_level );
247
-					$template          = str_replace( $placeholder, $compiled_template, $template );
243
+				                                        ->get_entity_post_by_uri($field_value);
244
+				if ( ! is_null($nested_entity)) {
245
+					$content           = '<span itemid="'.esc_attr($field_value).'">'.$nested_entity->post_title.'</span>';
246
+					$compiled_template = wl_content_embed_item_microdata($content, $field_value, $field_name, ++ $recursion_level);
247
+					$template          = str_replace($placeholder, $compiled_template, $template);
248 248
 				} else {
249
-					$template = str_replace( $placeholder, '', $template );
249
+					$template = str_replace($placeholder, '', $template);
250 250
 				}
251 251
 				continue;
252 252
 			}
@@ -254,8 +254,8 @@  discard block
 block discarded – undo
254 254
 			// Standard condition: field containing a raw value
255 255
 			// For non visible test, schema.org dictates to use the *meta* tag.
256 256
 			// see http://schema.org/docs/gs.html#advanced_missing
257
-			$value    = '<meta itemprop="' . esc_attr( $field_name ) . '" content="' . esc_attr( $field_value ) . '" />';
258
-			$template = str_replace( $placeholder, $value, $template );
257
+			$value    = '<meta itemprop="'.esc_attr($field_name).'" content="'.esc_attr($field_value).'" />';
258
+			$template = str_replace($placeholder, $value, $template);
259 259
 		}
260 260
 	}
261 261
 
Please login to merge, or discard this patch.