PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 6.7
Jetpack – WP Security, Backup, Speed, & Growth v6.7
16.2-beta 12.0.3 12.1.3 12.2.3 12.3.2 12.4.2 12.5.2 12.6.4 12.7.3 12.8.3 12.9.5 13.0.2 13.1.5 13.2.4 13.3.3 13.4.5 13.5.2 13.6.2 13.7.2 13.8.3 13.9.2 14.0.1 14.1.1 14.2.2 14.3.1 All 501 releases
jetpack / modules / shortcodes / scribd.php

scribd.php in Jetpack – WP Security, Backup, Speed, & Growth 6.7, at modules/shortcodes/scribd.php

63 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /*
4 Scribd Short Code
5 Author: Nick Momrik
6
7 [scribd id=DOCUMENT_ID key=DOCUMENT_KEY mode=MODE]
8 DOCUMENT_ID is an integer (also used as an object_id)
9 DOCUMENT_KEY is an alphanumeric hash ('-' character as well)
10 MODE can be 'list', 'book', 'slide', 'slideshow', or 'tile'
11
12 [scribd id=39027960 key=key-3kaiwcjqhtipf25m8tw mode=list]
13 */
14
15 function scribd_shortcode_handler( $atts ) {
16 $atts = shortcode_atts(
17 array(
18 'id' => 0,
19 'key' => 0,
20 'mode' => '',
21 ),
22 $atts,
23 'scribd'
24 );
25
26 $modes = array( 'list', 'book', 'slide', 'slideshow', 'tile' );
27
28 $atts['id'] = (int) $atts['id'];
29 if ( preg_match( '/^[A-Za-z0-9-]+$/', $atts['key'], $m ) ) {
30 $atts['key'] = $m[0];
31
32 if ( ! in_array( $atts['mode'], $modes ) ) {
33 $atts['mode'] = '';
34 }
35
36 return scribd_shortcode_markup( $atts );
37 } else {
38 return '';
39 }
40 }
41
42 function scribd_shortcode_markup( $atts ) {
43 $markup = <<<EOD
44 <iframe class="scribd_iframe_embed" src="//www.scribd.com/embeds/$atts[id]/content?start_page=1&view_mode=$atts[mode]&access_key=$atts[key]" data-auto-height="true" scrolling="no" id="scribd_$atts[id]" width="100%" height="500" frameborder="0"></iframe>
45 <div style="font-size:10px;text-align:center;width:100%"><a href="http://www.scribd.com/doc/$atts[id]" target="_blank">View this document on Scribd</a></div>
46 EOD;
47
48 return $markup;
49 }
50
51 add_shortcode( 'scribd', 'scribd_shortcode_handler' );
52
53 // Scribd supports HTTPS, so use that endpoint to get HTTPS-compatible embeds
54 function scribd_https_oembed( $providers ) {
55 if ( isset( $providers['#https?://(www\.)?scribd\.com/doc/.*#i'] ) ) {
56 $providers['#https?://(www\.)?scribd\.com/doc/.*#i'][0] = 'https://www.scribd.com/services/oembed';
57 }
58
59 return $providers;
60 }
61
62 add_filter( 'oembed_providers', 'scribd_https_oembed' );
63