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

46 lines 1.3 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 );
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 return scribd_shortcode_markup( $atts );
31 } else {
32 return '';
33 }
34 }
35
36 function scribd_shortcode_markup( $atts ) {
37 $markup = <<<EOD
38 <iframe class="scribd_iframe_embed" src="http://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>
39 <div style="font-size:10px;text-align:center;width:100%"><a href="http://www.scribd.com/doc/$atts[id]">View this document on Scribd</a></div>
40 EOD;
41
42 return $markup;
43 }
44
45 add_shortcode( 'scribd', 'scribd_shortcode_handler' );
46