Created
March 25, 2014 17:48
-
-
Save dobsondev/9767276 to your computer and use it in GitHub Desktop.
Shortcode for Embedding PDF's - Used in DobsonDev Shortcodes Plugin for WordPress
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* Adds a shortcode for displaying PDF's Inline */ | |
function dobson_embed_PDF($atts) { | |
extract(shortcode_atts(array( | |
'source' => "Invalid Source", | |
'width' => "100%", | |
'height' => "600", | |
), $atts)); | |
$source_headers = @get_headers($source); | |
if (strpos($source_headers[0], '404 Not Found')) { | |
return '<p> Invalid PDF source. Please check your PDF source. </p>'; | |
} else { | |
return '<object width="' . $width . '" height="' . $height . '" type="application/pdf" data="' | |
. $source . '"></object>'; | |
} | |
} | |
add_shortcode('embedPDF', 'dobson_embed_pdf'); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment