SIOC metadata export to WordPress blog. Author: Uldis Bojars Version: 1.25 Author URI: http://captsolo.net/info/ */ require_once "sioc-include.php"; // This displays a link to SIOC metadata profile function sioc_get_link() { global $posts; # TODO - Use WP_Rewrite to get correct pathname $base_mid = "http://$_SERVER[HTTP_HOST]$_SERVER[PHP_SELF]"; # '/wp-sioc.php'; if ( is_home() ) $base_mid .= '?sioc_type=site'; if ( is_single() ) $base_mid .= '?sioc_type=post&sioc_id=' . $posts[0]->ID; if ( is_author() ) { // TODO - Check if getting author won't break if there is more than one author queried for $user_id = get_query_var('author'); $base_mid .= '?sioc_type=user&sioc_id=' . $user_id; } /* Types of pages we don't do special processing for */ if ( is_category() || is_page() || is_archive() || is_paged() ) { // No auto-discovery link return ''; } else { return $base_mid; } } function sioc_link() { global $posts; if ( is_feed() ) return; // Form the template link to SIOC metadata $base_url = '' . "\n\n"; # TODO - Use WP_Rewrite to get correct pathname $base_mid = sioc_get_link(); if ( !empty($base_mid) ) echo $base_url . htmlentities($base_mid) . $base_end; } // Add sioc_link function to execute during a page HEAD section add_action('wp_head', 'sioc_link'); function is_sioc() { if ( !empty($_GET['sioc_type']) ) return true; return false; } function is_rdf_request() { if ( $_SERVER['HTTP_ACCEPT'] == 'application/rdf+xml' ) { return true; } return false; } // ************* Get control from WordPress ************* function sioc_get_control() { global $aaa; if ( is_sioc() ) { $aaa = $_GET['sioc_type']; # @header("Custom-header: PING"); # @header('Content-type: application/rdf+xml'); sioc_main(); die(); } if ( is_rdf_request() ) { $redir = sioc_get_link(); if ( !empty($redir) ) { @header( "Location: " . sioc_get_link() ); die(); } } } add_action('template_redirect', 'sioc_get_control'); ?>