diff --git a/wp-content/plugins/oembed-provider/oembed-provider.php b/wp-content/plugins/oembed-provider/oembed-provider.php index 3e7c39c26d7f60e2ea4e4266ddba152b9f8a7927..58c2cf7a8ef364b061484d1c1955b9a3a048625f 100644 --- a/wp-content/plugins/oembed-provider/oembed-provider.php +++ b/wp-content/plugins/oembed-provider/oembed-provider.php @@ -3,7 +3,7 @@ Plugin Name: oEmbed Provider Plugin URI: http://wordpress.org/extend/plugins/oembed-provider/ Description: An oEmbed provider for Wordpress -Version: 2.0.0 +Version: 2.0.1 Author: pfefferle, candrews Author URI: https://github.com/pfefferle/oEmbedProvider/ */ @@ -15,12 +15,12 @@ Author URI: https://github.com/pfefferle/oEmbedProvider/ * @author Craig Andrews */ class OembedProvider { - + /** * auto discovery links */ - function add_oembed_links(){ - if(is_singular()){ + public static function add_oembed_links() { + if (is_singular()) { echo '<link rel="alternate" type="application/json+oembed" href="' . site_url('/?oembed=true&format=json&url=' . urlencode(get_permalink())) . '" />'."\n"; echo '<link rel="alternate" type="text/xml+oembed" href="' . site_url('/?oembed=true&format=xml&url=' . urlencode(get_permalink())) . '" />'."\n"; } @@ -29,7 +29,7 @@ class OembedProvider { /** * adds query vars */ - function query_vars($query_vars) { + public static function query_vars($query_vars) { $query_vars[] = 'oembed'; $query_vars[] = 'format'; $query_vars[] = 'url'; @@ -37,11 +37,11 @@ class OembedProvider { return $query_vars; } - + /** * handles request */ - function parse_query($wp) { + public static function parse_query($wp) { if (!array_key_exists('oembed', $wp->query_vars) || !array_key_exists('url', $wp->query_vars)) { return; @@ -49,31 +49,31 @@ class OembedProvider { $post_ID = url_to_postid($wp->query_vars['url']); $post = get_post($post_ID); - + if(!$post) { header('Status: 404'); - die("Not found"); + wp_die("Not found"); } - + $post_type = get_post_type($post); - + // add support for alternate output formats $oembed_provider_formats = apply_filters("oembed_provider_formats", array('json', 'xml')); - + // check output format $format = "json"; if (array_key_exists('format', $wp->query_vars) && in_array(strtolower($wp->query_vars['format']), $oembed_provider_formats)) { $format = $wp->query_vars['format']; } - + // content filter $oembed_provider_data = apply_filters("oembed_provider_data", array(), $post_type, $post); $oembed_provider_data = apply_filters("oembed_provider_data_{$post_type}", $oembed_provider_data, $post); - - do_action("oembed_provider_render", $oembed_provider_data, $wp->query_vars); + + do_action("oembed_provider_render", $format, $oembed_provider_data, $wp->query_vars); do_action("oembed_provider_render_{$format}", $oembed_provider_data, $wp->query_vars); } - + /** * adds default content * @@ -81,7 +81,7 @@ class OembedProvider { * @param string $post_type * @param Object $post */ - function generate_default_content($oembed_provider_data, $post_type, $post) { + public static function generate_default_content($oembed_provider_data, $post_type, $post) { $author = get_userdata($post->post_author); $oembed_provider_data['version'] = '1.0'; @@ -90,79 +90,85 @@ class OembedProvider { $oembed_provider_data['author_name'] = $author->display_name; $oembed_provider_data['author_url'] = get_author_posts_url($author->ID, $author->nicename); $oembed_provider_data['title'] = $post->post_title; - + return $oembed_provider_data; } - + /** * adds attachement specific content * * @param array $oembed_provider_data * @param Object $post */ - function generate_attachement_content($oembed_provider_data, $post) { + public static function generate_attachment_content($oembed_provider_data, $post) { if (substr($post->post_mime_type,0,strlen('image/'))=='image/') { - $oembed_provider_data['type']='photo'; + $oembed_provider_data['type'] = 'photo'; } else { - $oembed_provider_data['type']='link'; + $oembed_provider_data['type'] = 'link'; } + $oembed_provider_data['url'] = wp_get_attachment_url($post->ID); - + + $metadata = wp_get_attachment_metadata($post->ID); + + $oembed_provider_data['width'] = $metadata['width']; + $oembed_provider_data['height'] = $metadata['height']; + return $oembed_provider_data; } - + /** * adds post/page specific content * * @param array $oembed_provider_data * @param Object $post */ - function generate_post_content($oembed_provider_data, $post) { + public static function generate_post_content($oembed_provider_data, $post) { if (function_exists('has_post_thumbnail') && has_post_thumbnail($post->ID)) { $image = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID)); $oembed_provider_data['thumbnail_url'] = $image[0]; $oembed_provider_data['thumbnail_width'] = $image[1]; $oembed_provider_data['thumbnail_height'] = $image[2]; } - $oembed_provider_data['type']='rich'; - $oembed_provider_data['html'] = empty($post->post_excerpt) ? $post->post_content : $post->post_excerpt; + $oembed_provider_data['type'] = 'rich'; + $oembed_provider_data['html'] = $post->post_content; return $oembed_provider_data; } - + /** * render json output * * @param array $oembed_provider_data */ - function render_json($oembed_provider_data, $wp_query) { + public static function render_json($oembed_provider_data, $wp_query) { header('Content-Type: application/json; charset=' . get_bloginfo('charset'), true); - + // render json output $json = json_encode($oembed_provider_data); - + // add callback if available if (array_key_exists('callback', $wp_query)) { $json = $wp_query['callback'] . "($json);"; } - + echo $json; exit; } - + /** * render xml output * * @param array $oembed_provider_data */ - function render_xml($oembed_provider_data) { + public static function render_xml($oembed_provider_data) { header('Content-Type: text/xml; charset=' . get_bloginfo('charset'), true); - + // render xml-output echo '<?xml version="1.0" encoding="' . get_bloginfo('charset') . '" ?>'; echo '<oembed>'; foreach(array_keys($oembed_provider_data) as $element){ - echo '<' . $element . '>' . htmlspecialchars($oembed_provider_data[$element]) . '</' . $element . '>'; + echo '<' . $element . '>' . esc_html($oembed_provider_data[$element]) . '</' . $element . '>'; } echo '</oembed>'; exit; @@ -173,8 +179,8 @@ add_action('wp_head', array('OembedProvider', 'add_oembed_links')); add_action('parse_query', array('OembedProvider', 'parse_query')); add_filter('query_vars', array('OembedProvider', 'query_vars')); add_filter('oembed_provider_data', array('OembedProvider', 'generate_default_content'), 90, 3); -add_filter('oembed_provider_data_attachement', array('OembedProvider', 'generate_attachement_content'), 91, 2); +add_filter('oembed_provider_data_attachment', array('OembedProvider', 'generate_attachment_content'), 91, 2); add_filter('oembed_provider_data_post', array('OembedProvider', 'generate_post_content'), 91, 2); add_filter('oembed_provider_data_page', array('OembedProvider', 'generate_post_content'), 91, 2); add_action('oembed_provider_render_json', array('OembedProvider', 'render_json'), 99, 2); -add_action('oembed_provider_render_xml', array('OembedProvider', 'render_xml'), 99); \ No newline at end of file +add_action('oembed_provider_render_xml', array('OembedProvider', 'render_xml'), 99); diff --git a/wp-content/plugins/oembed-provider/readme.txt b/wp-content/plugins/oembed-provider/readme.txt index 8463320fb1d5ee23ccf15d79fbf714bc0746c043..9d16fc2656d29fd3d592b26fee16f2aa23008580 100644 --- a/wp-content/plugins/oembed-provider/readme.txt +++ b/wp-content/plugins/oembed-provider/readme.txt @@ -2,8 +2,8 @@ Contributors: pfefferle, candrews Tags: oembed, links Requires at least: 3.0 -Tested up to: 3.5.1 -Stable tag: 2.0.0 +Tested up to: 3.7.1 +Stable tag: 2.0.1 An oEmbed provider for Wordpress. @@ -27,6 +27,10 @@ Yes! == Changelog == += 2.0.1 = +* type 'rich' now returns the full html +* take use of more WordPress functions + = 2.0.0 = * complete refactoring