PluginProbe
Powerkit – Supercharge your WordPress Site / 2.3.7
Powerkit – Supercharge your WordPress Site v2.3.7
3.1.1 3.1.0 3.0.9 3.0.8 trunk 2.2.6 2.2.7 2.2.8 2.2.9 2.3.0 2.3.1 2.3.2 2.3.3 2.3.4 2.3.5 2.3.6 2.3.7 2.3.8 2.3.9 2.4.0 2.4.1 2.4.2 2.4.3 2.4.4 2.4.5 All 87 releases
powerkit / modules / twitter / public / class-powerkit-twitter-shortcode.php

class-powerkit-twitter-shortcode.php in Powerkit – Supercharge your WordPress Site 2.3.7, at modules/twitter/public/class-powerkit-twitter-shortcode.php

104 lines 2.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Shortcode Twitter
4 *
5 * @link https://codesupply.co
6 * @since 1.0.0
7 *
8 * @package PowerKit
9 * @subpackage PowerKit/shortcodes
10 */
11
12 /**
13 * Twitter Shortcode
14 *
15 * @param array $atts User defined attributes in shortcode tag.
16 * @param string $content Shorcode tag content.
17 * @return string Shortcode result HTML.
18 */
19 function powerkit_twitter_shortcode( $atts, $content = '' ) {
20 $params = powerkit_shortcode_atts( shortcode_atts( array(
21 'title' => esc_html__( 'Twitter Feed', 'powerkit' ),
22 'username' => '',
23 'number' => 5,
24 'template' => 'default',
25 'header' => true,
26 'button' => true,
27 'replies' => false,
28 'retweets' => false,
29 ), $atts ) );
30
31 ob_start();
32
33 powerkit_twitter_get_recent( $params, 'powerkit_twitter_shortcode_cache' );
34
35 return ob_get_clean();
36 }
37 add_shortcode( 'powerkit_twitter_feed', 'powerkit_twitter_shortcode' );
38
39 /**
40 * Map Twitter Shortcode into the Basic Shortcodes Plugin
41 */
42 if ( function_exists( 'powerkit_basic_shortcodes_register' ) ) :
43
44 $shortcode_map = array(
45 'name' => 'twitter',
46 'title' => esc_html__( 'Twitter Feed', 'powerkit' ),
47 'priority' => 100,
48 'base' => 'powerkit_twitter_feed',
49 'autoregister' => false,
50 'fields' => array(
51 array(
52 'type' => 'input',
53 'name' => 'username',
54 'label' => esc_html__( 'Twitter user ID', 'powerkit' ),
55 ),
56 array(
57 'type' => 'input',
58 'name' => 'number',
59 'label' => esc_html__( 'Number of tweets to displays', 'powerkit' ),
60 'default' => 5,
61 ),
62 array(
63 'type' => 'checkbox',
64 'name' => 'header',
65 'label' => esc_html__( 'Display header', 'powerkit' ),
66 'default' => true,
67 ),
68 array(
69 'type' => 'checkbox',
70 'name' => 'button',
71 'label' => esc_html__( 'Display follow button', 'powerkit' ),
72 'default' => true,
73 ),
74 array(
75 'type' => 'checkbox',
76 'name' => 'replies',
77 'label' => esc_html__( 'Include replies', 'powerkit' ),
78 'default' => false,
79 ),
80 array(
81 'type' => 'checkbox',
82 'name' => 'retweets',
83 'label' => esc_html__( 'Include retweets', 'powerkit' ),
84 'default' => false,
85 ),
86 ),
87 );
88
89 $templates = apply_filters( 'powerkit_twitter_templates', array() );
90
91 if ( count( (array) $templates ) > 1 ) {
92 $shortcode_map['fields'][] = array(
93 'type' => 'select',
94 'name' => 'template',
95 'label' => esc_html__( 'Template', 'powerkit' ),
96 'default' => 'default',
97 'options' => powerkit_twitter_get_templates_options(),
98 );
99 }
100
101 powerkit_basic_shortcodes_register( $shortcode_map );
102
103 endif;
104