/
shortcodetwitter.php
49 lines (41 loc) · 1.38 KB
/
shortcodetwitter.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php
/*
Plugin Name: ShortcodeTwitter
Version: 1.0
Description: Shortcode to share on Twitter
Author: Pinto
Author URI: http://bitado.com
Plugin URI: http://bitado.com
Text Domain: shortcodetwitter
Domain Path: /languages
*/
/*
* Shortcode share on Twitter. [sct_sharetwitter]
* Attributes:
*
* - text. Default is empty
* - size. Default is small. Other value is big
*
* Example: [sct_sharetwitter text="Compartir en Twitter" size="big"]
*/
function shortcodetwitter_sharetwitter( $atts, $content = null ) {
$atts_sharetwitter = shortcode_atts( array(
'text' => 'Compartir en Twitter',
'size' => 'small',
), $atts );
$link_twitter = 'http://twitter.com/intent/tweet?url=' . urlencode( get_permalink() ) . '&text=' . urlencode( get_the_title() );
$bigclass = '';
if ( $atts_sharetwitter['size'] == 'big' )
$bigclass = 'sct-twitter-big';
$content = '<a class="sct-twitter ' . $bigclass . '" target="_blank" href="' . $link_twitter . '">' . $atts_sharetwitter['text'] . '</a>';
return $content;
}
add_shortcode( 'sct_sharetwitter', 'shortcodetwitter_sharetwitter' );
/*
* Enqueue css, javascript, and fonts files needed
*/
function shortcodetwitter_css() {
wp_enqueue_style( 'shortcodetwitter-style', plugins_url( '/shortcodetwitter.css', __FILE__ ) );
wp_enqueue_style( 'dashicons' );
}
add_action( 'wp_enqueue_scripts', 'shortcodetwitter_css' );