PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 6.2
Jetpack – WP Security, Backup, Speed, & Growth v6.2
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.2, at modules/shortcodes/scribd.php

58 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 /* Scribd Short Code
4 Author: Nick Momrik
5
6 [scribd id=DOCUMENT_ID key=DOCUMENT_KEY mode=MODE]
7 DOCUMENT_ID is an integer (also used as an object_id)
8 DOCUMENT_KEY is an alphanumeric hash ('-' character as well)
9 MODE can be 'list', 'book', 'slide', 'slideshow', or 'tile'
10
11 [scribd id=39027960 key=key-3kaiwcjqhtipf25m8tw mode=list]
12 */
13
14 function scribd_shortcode_handler( $atts ) {
15 $atts = shortcode_atts( array(
16 'id' => 0,
17 'key' => 0,
18 'mode' => '',
19 ), $atts, 'scribd' );
20
21 $modes = array( 'list', 'book', 'slide', 'slideshow', 'tile' );
22
23 $atts['id'] = (int) $atts['id'];
24 if ( preg_match( '/^[A-Za-z0-9-]+$/', $atts['key'], $m ) ) {
25 $atts['key'] = $m[0];
26
27 if ( ! in_array( $atts['mode'], $modes ) ) {
28 $atts['mode'] = '';
29 }
30
31 return scribd_shortcode_markup( $atts );
32 } else {
33 return '';
34 }
35 }
36
37 function scribd_shortcode_markup( $atts ) {
38 $markup = <<<EOD
39 <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>
40 <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>
41 EOD;
42
43 return $markup;
44 }
45
46 add_shortcode( 'scribd', 'scribd_shortcode_handler' );
47
48 // Scribd supports HTTPS, so use that endpoint to get HTTPS-compatible embeds
49 function scribd_https_oembed( $providers ) {
50 if ( isset( $providers['#https?://(www\.)?scribd\.com/doc/.*#i'] ) ) {
51 $providers['#https?://(www\.)?scribd\.com/doc/.*#i'][0] = 'https://www.scribd.com/services/oembed';
52 }
53
54 return $providers;
55 }
56
57 add_filter( 'oembed_providers', 'scribd_https_oembed' );
58