PluginProbe ʕ •ᴥ•ʔ
Custom Twitter Feeds – A Tweets Widget or X Feed Widget / 2.8.0
Custom Twitter Feeds – A Tweets Widget or X Feed Widget v2.8.0
2.8.0 2.7.0 2.6.1 2.6.0 1.0 1.0.1 1.1 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.1.8 1.2 1.2.1 1.2.10 1.2.11 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3 1.4 1.4.1 1.5 1.5.1 1.6 1.6.1 1.7 1.8 1.8.1 1.8.2 1.8.3 1.8.4 2.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.1 2.1.1 2.1.2 2.2 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.3.0 2.3.1 2.5.4 2.5.5 trunk
custom-twitter-feeds / inc / widget.php
custom-twitter-feeds / inc Last commit date
Admin 3 weeks ago Builder 3 weeks ago Integrations 3 weeks ago SmashTwitter 3 weeks ago UsageTracking 3 weeks ago V2 3 weeks ago blocks 3 weeks ago CTF_Display_Elements.php 3 weeks ago CTF_Feed.php 3 weeks ago CTF_Feed_Locator.php 3 weeks ago CTF_GDPR_Integrations.php 3 weeks ago CTF_Parse.php 3 weeks ago CTF_Settings.php 3 weeks ago CtfAdmin.php 3 weeks ago CtfCache.php 3 weeks ago CtfFeed.php 3 weeks ago CtfOauthConnect.php 3 weeks ago SB_Twitter_Cron_Updater.php 3 weeks ago admin-hooks.php 3 weeks ago ctf-functions.php 3 weeks ago notices.php 3 weeks ago widget.php 3 weeks ago
widget.php
67 lines
1 <?php
2 /**
3 * Class CtfWidget
4 *
5 * Creates a text widget with the custom-twitter-feeds shortcode inside
6 */
7
8 class CtfWidget extends WP_Widget
9 {
10 function __construct() {
11 parent::__construct(
12 'custom-twitter-feeds-widget',
13 __( 'Custom Twitter Feeds', 'custom-twitter-feeds' ),
14 array( 'description' => __( 'Display your Twitter feed', 'custom-twitter-feeds' ), )
15 );
16 }
17
18 public function widget( $args, $instance ) {
19
20 $title = isset( $instance['title'] ) ? apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base ) : '';
21 $content = isset( $instance['content'] ) ? strip_tags( $instance['content'] ) : '[custom-twitter-feeds]';
22
23 echo $args['before_widget'];
24
25 if ( ! empty( $title ) ) {
26 echo $args['before_title'] . esc_html( $title ) . $args['after_title'];
27 }
28
29 echo do_shortcode( $content );
30
31 echo $args['after_widget'];
32 }
33
34 public function form( $instance ) {
35
36 $title = isset( $instance['title'] ) ? $instance['title'] : '';
37 $content = isset ( $instance['content'] ) ? strip_tags( $instance['content'] ) : '[custom-twitter-feeds]';
38 ?>
39 <p>
40 <label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php _e( 'Title:' ); ?></label>
41 <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" />
42 </p>
43 <p>
44 <label for="<?php echo esc_attr( $this->get_field_id( 'content' ) ); ?>"><?php _e( 'Shortcode:', 'custom-twitter-feeds' ); ?></label>
45 <textarea class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'content' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'content' ) ); ?>" rows="16"><?php echo strip_tags( $content ); ?></textarea>
46 </p>
47 <?php
48 }
49
50 public function update( $new_instance, $old_instance ) {
51 $instance = array();
52 $instance['title'] = ( ! empty( $new_instance['title'] ) ) ? strip_tags( $new_instance['title'] ) : '';
53 $instance['content'] = ( ! empty( $new_instance['content'] ) ) ? strip_tags( $new_instance['content'] ) : '';
54
55 return $instance;
56 }
57 }
58
59 // register and load the widget
60 function ctf_load_widget() {
61 register_widget( 'CtfWidget' );
62 }
63 add_action( 'widgets_init', 'ctf_load_widget' );
64
65 // allow shortcode in widgets
66 add_filter( 'widget_text', 'do_shortcode' );
67