/**
 * Lift the post content with the microdata.
 *
 * @param string $content The post content.
 *
 * @return string The updated post content.
 */
function wl_content_embed_microdata($content)
{
    // Apply microdata only to single pages.
    /*if ( ! is_single() ) {
    		wl_write_log( "wl_content_embed_microdata : is not single" );
    
    		return $content;
    	}
    
    	global $post;
            */
    return _wl_content_embed_microdata(get_the_ID(), $content);
}
 function testMicrodataCompilingForAnEntityPage()
 {
     // A place
     $place_id = wl_create_post('', 'my-place', 'MyPlace', 'publish', 'entity');
     wl_set_entity_main_type($place_id, 'http://schema.org/Place');
     wl_schema_set_value($place_id, 'latitude', 40.12);
     wl_schema_set_value($place_id, 'longitude', 72.3);
     wl_schema_set_value($place_id, 'streetAddress', 'via del ciuccio 23');
     // Compile markup for the given content
     $compiled_markup = _wl_content_embed_microdata($place_id, '');
     $expected_markup = file_get_contents(dirname(__FILE__) . '/assets/microdata_compiling_entity_page.txt');
     // Verify correct markup
     $this->assertEquals($this->prepareMarkup($expected_markup), $this->prepareMarkup($compiled_markup));
 }
    function testMicrodataCompilingRecursivityLimitation()
    {
        // A place
        $place_id = wl_create_post('Just a place', 'my-place', 'MyPlace', 'publish', 'entity');
        wl_set_entity_main_type($place_id, 'http://schema.org/Place');
        // Trying out both the schema API and the classic WP method
        wl_schema_set_value($place_id, 'latitude', 40.12);
        add_post_meta($place_id, WL_CUSTOM_FIELD_GEO_LONGITUDE, 72.3, true);
        // An Event having as location the place above
        $event_id = wl_create_post('Just an event', 'my-event', 'MyEvent', 'publish', 'entity');
        wl_set_entity_main_type($event_id, 'http://schema.org/Event');
        add_post_meta($event_id, WL_CUSTOM_FIELD_CAL_DATE_START, '2014-10-21', true);
        add_post_meta($event_id, WL_CUSTOM_FIELD_CAL_DATE_END, '2015-10-26', true);
        wl_schema_set_value($event_id, 'sameAs', array('http://rdf.freebase.com/my-event', 'http://dbpedia.org/resource/my-event'));
        //wl_schema_set_value($event_id, 'sameAs', 'http://dbpedia.org/resource/my-event');
        add_post_meta($event_id, WL_CUSTOM_FIELD_LOCATION, $place_id, true);
        // Create an annotated post containing the entities
        $entity_uri = wl_get_entity_uri($event_id);
        $content = <<<EOF
    <span itemid="{$entity_uri}">MyEvent</span>
EOF;
        $post_id = wl_create_post($content, 'post', 'A post');
        // Set to 0 the recursivity limitation on entity metadata compiling
        $this->setRecursionDepthLimit(0);
        // The expected mark-up expects color coding to be on.
        wl_configuration_set_enable_color_coding(true);
        // Compile markup for the given content
        $compiled_markup = _wl_content_embed_microdata($post_id, $content);
        $expected_markup = file_get_contents(dirname(__FILE__) . '/assets/microdata_compiling_recursivity_limitation.txt');
        // Verify correct markup
        $this->assertEquals($this->prepareMarkup($expected_markup), $this->prepareMarkup($compiled_markup));
        $this->setRecursionDepthLimit(1);
        // Compile markup for the given content
        $compiled_markup = _wl_content_embed_microdata($post_id, $content);
        $expected_markup = file_get_contents(dirname(__FILE__) . '/assets/microdata_compiling_for_an_entity_with_nested_entities.txt');
        // Verify correct markup
        $this->assertEquals($this->prepareMarkup($expected_markup), $this->prepareMarkup($compiled_markup));
    }