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 / diggthis.php
diggthis.php
41 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Digg changed their button API.
5 *
6 * The old style button was something like this:
7 * [digg=http://digg.com/some-digg-permalink] - uses digg permalink as id.
8 *
9 * The new style is:
10 * [digg class="wide"] # The class options are: 'wide', 'medium', 'compact', 'icon'
11 * and uses get_permalink() as id.
12 *
13 * @author Veselin Nikolov
14 */
15
16 function digg_shortcode_js() {
17 echo '
18 <script type="text/javascript">
19 (function(){var s=document.createElement("SCRIPT"),s1=document.getElementsByTagName("SCRIPT")[0];s.type="text/javascript";s.async=true;s.src="http://widgets.digg.com/buttons.js";s1.parentNode.insertBefore(s,s1);})();
20 </script>
21 ';
22 }
23
24 function digg_shortcode( $atts ) {
25 static $printed_digg_code = false;
26
27 if ( ! $printed_digg_code ) {
28 add_action( 'wp_footer', 'digg_shortcode_js' );
29 $printed_digg_code = true;
30 }
31
32 if ( isset( $atts['class']) && in_array( $atts['class'], array( 'wide', 'medium', 'compact', 'icon' ) ) )
33 $class = ucfirst( $atts['class'] );
34 else
35 $class = 'Medium';
36
37 return '<a class="DiggThisButton Digg' . $class . '" href="http://digg.com/submit?url=' . urlencode( get_permalink() ) . '&amp;title=' . urlencode( get_the_title() ) . '"></a>';
38 }
39
40 add_shortcode( 'digg', 'digg_shortcode' );
41