css
1 year ago
images
2 years ago
img
2 years ago
js
1 year ago
archiveorg-book.php
5 years ago
archiveorg.php
5 years ago
archives.php
5 years ago
bandcamp.php
3 years ago
brightcove.php
5 years ago
cartodb.php
5 years ago
class.filter-embedded-html-objects.php
2 years ago
codepen.php
5 years ago
crowdsignal.php
1 year ago
dailymotion.php
3 years ago
descript.php
4 years ago
facebook.php
1 year ago
flatio.php
5 years ago
flickr.php
1 year ago
getty.php
2 years ago
gist.php
1 year ago
googleapps.php
2 years ago
googlemaps.php
2 years ago
googleplus.php
5 years ago
gravatar.php
2 years ago
houzz.php
5 years ago
inline-pdfs.php
4 years ago
instagram.php
1 year ago
kickstarter.php
3 years ago
mailchimp.php
3 years ago
medium.php
3 years ago
mixcloud.php
2 years ago
others.php
1 year ago
pinterest.php
2 years ago
presentations.php
2 years ago
quiz.php
4 years ago
recipe.php
1 year ago
scribd.php
5 years ago
sitemap.php
5 years ago
slideshare.php
5 years ago
slideshow.php
1 year ago
smartframe.php
3 years ago
soundcloud.php
3 years ago
spotify.php
2 years ago
ted.php
5 years ago
tweet.php
2 years ago
twitchtv.php
5 years ago
twitter-timeline.php
5 years ago
twitter.php
1 year ago
unavailable.php
3 years ago
untappd-menu.php
3 years ago
upcoming-events.php
1 year ago
ustream.php
5 years ago
videopress.php
4 years ago
vimeo.php
2 years ago
vine.php
5 years ago
vr.php
2 years ago
wufoo.php
3 years ago
youtube.php
1 year ago
inline-pdfs.php
37 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Embed support for Inline PDFs |
| 4 | * |
| 5 | * Takes a plain-text PDF URL (*.pdf), and attempts to embed it directly |
| 6 | * in the post instead of leaving it as a bare link. |
| 7 | * |
| 8 | * @package automattic/jetpack |
| 9 | */ |
| 10 | |
| 11 | wp_embed_register_handler( 'inline-pdfs', '#https?://[^<]*\.pdf$#i', 'jetpack_inline_pdf_embed_handler' ); |
| 12 | |
| 13 | /** |
| 14 | * Callback to modify the output of embedded PDF files. |
| 15 | * |
| 16 | * @param array $matches Regex partial matches against the URL passed. |
| 17 | * @param array $attr Attributes received in embed response. |
| 18 | * @param array $url Requested URL to be embedded. |
| 19 | */ |
| 20 | function jetpack_inline_pdf_embed_handler( $matches, $attr, $url ) { |
| 21 | /** This action is documented in modules/widgets/social-media-icons.php */ |
| 22 | do_action( 'jetpack_bump_stats_extras', 'embeds', 'inline-pdf' ); |
| 23 | |
| 24 | $filename = basename( wp_parse_url( $url, PHP_URL_PATH ) ); |
| 25 | $fallback_text = sprintf( |
| 26 | /* translators: Placeholder is a file name, for example "file.pdf" */ |
| 27 | esc_html__( 'Click to access %1$s', 'jetpack' ), |
| 28 | $filename |
| 29 | ); |
| 30 | |
| 31 | return sprintf( |
| 32 | '<p><a href="%1$s" target="_blank" rel="noopener noreferrer nofollow">%2$s</a></p>', |
| 33 | esc_url( $url ), |
| 34 | $fallback_text |
| 35 | ); |
| 36 | } |
| 37 |