芝麻web文件管理V1.00
编辑当前文件:/home4/randall/public_html/sl/wp-content/plugins/trx_utils/widgets/twitter.php
'widget_twitter', 'description' => esc_html__('Last Twitter Updates. Version for new Twitter API 1.1', 'trx_utils') ); parent::__construct( 'lorem_ipsum_books_media_store_widget_twitter', esc_html__('Lorem Ipsum - Twitter', 'trx_utils'), $widget_ops ); } // Show widget function widget( $args, $instance ) { extract( $args ); $title = apply_filters('widget_title', isset($instance['title']) ? $instance['title'] : '' ); $twitter_username = !empty($instance['twitter_username']) ? $instance['twitter_username'] : lorem_ipsum_books_media_store_get_theme_option('twitter_username'); $twitter_consumer_key = !empty($instance['twitter_consumer_key']) ? $instance['twitter_consumer_key'] : lorem_ipsum_books_media_store_get_theme_option('twitter_consumer_key'); $twitter_consumer_secret = !empty($instance['twitter_consumer_secret']) ? $instance['twitter_consumer_secret'] : lorem_ipsum_books_media_store_get_theme_option('twitter_consumer_secret'); $twitter_token_key = !empty($instance['twitter_token_key']) ? $instance['twitter_token_key'] : lorem_ipsum_books_media_store_get_theme_option('twitter_token_key'); $twitter_token_secret = !empty($instance['twitter_token_secret']) ? $instance['twitter_token_secret'] : lorem_ipsum_books_media_store_get_theme_option('twitter_token_secret'); $twitter_count = max(1, !empty($instance['twitter_count']) ? (int) $instance['twitter_count'] : (int) lorem_ipsum_books_media_store_get_theme_option('twitter_count')); if (empty($twitter_consumer_key) || empty($twitter_consumer_secret) || empty($twitter_token_key) || empty($twitter_token_secret)) return; $data = lorem_ipsum_books_media_store_get_twitter_data(array( 'mode' => 'user_timeline', 'consumer_key' => $twitter_consumer_key, 'consumer_secret' => $twitter_consumer_secret, 'token' => $twitter_token_key, 'secret' => $twitter_token_secret ) ); if (!$data || !isset($data[0]['text'])) return; $output = '
'; $cnt = 0; if (is_array($data) && count($data) > 0) { foreach ($data as $tweet) { if (lorem_ipsum_books_media_store_substr($tweet['text'], 0, 1)=='@') continue; $output .= '
@' . ($tweet['user']['screen_name']) . '
' . force_balance_tags(lorem_ipsum_books_media_store_prepare_twitter_text($tweet)) . '
'; if (++$cnt >= $twitter_count) break; } } $output .= '
'; if (!empty($output)) { // Before widget (defined by themes) lorem_ipsum_books_media_store_show_layout($before_widget); // Display the widget title if one was input (before and after defined by themes) if ($title) lorem_ipsum_books_media_store_show_layout($title, $before_title, $after_title); lorem_ipsum_books_media_store_show_layout($output); // After widget (defined by themes) lorem_ipsum_books_media_store_show_layout($after_widget); } } // Update the widget settings. function update( $new_instance, $old_instance ) { $instance = $old_instance; $instance['title'] = strip_tags( $new_instance['title'] ); $instance['twitter_username'] = strip_tags( $new_instance['twitter_username'] ); $instance['twitter_consumer_key'] = strip_tags( $new_instance['twitter_consumer_key'] ); $instance['twitter_consumer_secret'] = strip_tags( $new_instance['twitter_consumer_secret'] ); $instance['twitter_token_key'] = strip_tags( $new_instance['twitter_token_key'] ); $instance['twitter_token_secret'] = strip_tags( $new_instance['twitter_token_secret'] ); $instance['twitter_count'] = strip_tags( $new_instance['twitter_count'] ); return $instance; } // Displays the widget settings controls on the widget panel. function form( $instance ) { // Set up some default widget settings $instance = wp_parse_args( (array) $instance, array( 'title' => '', 'twitter_username' => '', 'twitter_consumer_key' => '', 'twitter_consumer_secret' => '', 'twitter_token_key' => '', 'twitter_token_secret' => '', 'twitter_count' => '' ) ); $title = $instance['title']; $twitter_username = $instance['twitter_username']; $twitter_consumer_key = $instance['twitter_consumer_key']; $twitter_consumer_secret = $instance['twitter_consumer_secret']; $twitter_token_key = $instance['twitter_token_key']; $twitter_token_secret = $instance['twitter_token_secret']; $twitter_count = $instance['twitter_count']; ?>
()
"", "count" => 2, "username" => "", "consumer_key" => "", "consumer_secret" => "", "token_key" => "", "token_secret" => "", // Common params "id" => "", "class" => "", "css" => "" ), $atts)); extract($atts); $type = 'lorem_ipsum_books_media_store_widget_twitter'; $output = ''; global $wp_widget_factory; if ( is_object( $wp_widget_factory ) && isset( $wp_widget_factory->widgets, $wp_widget_factory->widgets[ $type ] ) ) { $atts['twitter_username'] = $username; $atts['twitter_consumer_key'] = $consumer_key; $atts['twitter_consumer_secret'] = $consumer_secret; $atts['twitter_token_key'] = $token_key; $atts['twitter_token_secret'] = $token_secret; $atts['twitter_count'] = max(1, (int) $count); $output = '
'; ob_start(); the_widget( $type, $atts, lorem_ipsum_books_media_store_prepare_widgets_args(lorem_ipsum_books_media_store_storage_get('widgets_args'), $id ? $id.'_widget' : 'widget_twitter', 'widget_twitter') ); $output .= ob_get_contents(); ob_end_clean(); $output .= '
'; } return apply_filters('lorem_ipsum_books_media_store_shortcode_output', $output, 'trx_widget_twitter', $atts, $content); } add_shortcode("trx_widget_twitter", "lorem_ipsum_books_media_store_sc_widget_twitter"); } // Add [trx_widget_twitter] in the VC shortcodes list if (!function_exists('lorem_ipsum_books_media_store_widget_twitter_reg_shortcodes_vc')) { function lorem_ipsum_books_media_store_widget_twitter_reg_shortcodes_vc() { vc_map( array( "base" => "trx_widget_twitter", "name" => esc_html__("Widget Twitter Feed", 'trx_utils'), "description" => wp_kses_data( __("Insert widget with Twitter feed", 'trx_utils') ), "category" => esc_html__('Content', 'trx_utils'), "icon" => 'icon_trx_widget_twitter', "class" => "trx_widget_twitter", "content_element" => true, "is_container" => false, "show_settings_on_create" => true, "params" => array( array( "param_name" => "title", "heading" => esc_html__("Widget title", 'trx_utils'), "description" => wp_kses_data( __("Title of the widget", 'trx_utils') ), "admin_label" => true, "class" => "", "value" => "", "type" => "textfield" ), array( "param_name" => "count", "heading" => esc_html__("Tweets number", 'trx_utils'), "description" => wp_kses_data( __("Tweets number to show in the feed", 'trx_utils') ), "admin_label" => true, "class" => "", "value" => "2", "type" => "textfield" ), array( "param_name" => "username", "heading" => esc_html__("Twitter Username", 'trx_utils'), "description" => wp_kses_data( __("Twitter Username", 'trx_utils') ), "group" => esc_html__('Twitter account', 'trx_utils'), "class" => "", "value" => "", "type" => "textfield" ), array( "param_name" => "consumer_key", "heading" => esc_html__("Consumer Key", 'trx_utils'), "description" => wp_kses_data( __("Specify Consumer Key from Twitter application", 'trx_utils') ), "group" => esc_html__('Twitter account', 'trx_utils'), "class" => "", "value" => "", "type" => "textfield" ), array( "param_name" => "consumer_secret", "heading" => esc_html__("Consumer Secret", 'trx_utils'), "description" => wp_kses_data( __("Specify Consumer Secret from Twitter application", 'trx_utils') ), "group" => esc_html__('Twitter account', 'trx_utils'), "class" => "", "value" => "", "type" => "textfield" ), array( "param_name" => "token_key", "heading" => esc_html__("Token Key", 'trx_utils'), "description" => wp_kses_data( __("Specify Token Key from Twitter application", 'trx_utils') ), "group" => esc_html__('Twitter account', 'trx_utils'), "class" => "", "value" => "", "type" => "textfield" ), array( "param_name" => "token_secret", "heading" => esc_html__("Token Secret", 'trx_utils'), "description" => wp_kses_data( __("Specify Token Secret from Twitter application", 'trx_utils') ), "group" => esc_html__('Twitter account', 'trx_utils'), "class" => "", "value" => "", "type" => "textfield" ), lorem_ipsum_books_media_store_get_vc_param('id'), lorem_ipsum_books_media_store_get_vc_param('class'), lorem_ipsum_books_media_store_get_vc_param('css') ) ) ); class WPBakeryShortCode_Trx_Widget_Twitter extends WPBakeryShortCode {} } } ?>