OS : Linux
PHP Version : 7.4.33
Software : Apache/2.4.6 (CentOS) PHP/7.4.33 Widgets
*/
add_action( 'widgets_init', 'jetpack_twitter_timeline_widget_init' );
function jetpack_twitter_timeline_widget_init() {
register_widget( 'Jetpack_Twitter_Timeline_Widget' );
}
class Jetpack_Twitter_Timeline_Widget extends WP_Widget {
/**
* Register widget with WordPress.
*/
public function __construct() {
parent::__construct(
'twitter_timeline',
/** This filter is documented in modules/widgets/facebook-likebox.php */
apply_filters( 'jetpack_widget_name', esc_html__( 'Twitter Timeline', 'jetpack' ) ),
array(
'classname' => 'widget_twitter_timeline',
'description' => __( 'Display an official Twitter Embedded Timeline widget.', 'jetpack' ),
'customize_selective_refresh' => true,
)
);
if ( is_active_widget( false, false, $this->id_base ) || is_active_widget( false, false, 'monster' ) || is_customize_preview() ) {
add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
}
add_action( 'admin_enqueue_scripts', array( $this, 'admin_scripts' ) );
}
/**
* Enqueue scripts.
*/
public function enqueue_scripts() {
wp_enqueue_script( 'jetpack-twitter-timeline' );
}
/**
* Enqueue Twitter's widget library.
*
* @deprecated
*/
public function library() {
_deprecated_function( __METHOD__, '4.0.0' );
wp_print_scripts( array( 'jetpack-twitter-timeline' ) );
}
/**
* Enqueue script to improve admin UI
*/
public function admin_scripts( $hook ) {
// This is still 'widgets.php' when managing widgets via the Customizer.
if ( 'widgets.php' === $hook ) {
wp_enqueue_script(
'twitter-timeline-admin',
Assets::get_file_url_for_environment(
'_inc/build/widgets/twitter-timeline-admin.min.js',
'modules/widgets/twitter-timeline-admin.js'
)
);
}
}
/**
* Front-end display of widget.
*
* @see WP_Widget::widget()
*
* @param array $args Widget arguments.
* @param array $instance Saved values from database.
*/
public function widget( $args, $instance ) {
// Twitter deprecated `data-widget-id` on 2018-05-25,
// with cease support deadline on 2018-07-27.
if ( isset( $instance['type'] ) && 'widget-id' === $instance['type'] ) {
if ( current_user_can( 'edit_theme_options' ) ) {
echo $args['before_widget'];
echo $args['before_title'] . esc_html__( 'Twitter Timeline', 'jetpack' ) . $args['after_title'];
echo ' ' . esc_html__( "The Twitter Timeline widget can't display tweets based on searches or hashtags. To display a simple list of tweets instead, change the Widget ID to a Twitter username. Otherwise, delete this widget.", 'jetpack' ) . ' ' . esc_html__( '(Only administrators will see this message.)', 'jetpack' ) . ' ' . esc_html__( 'As of July 27, 2018, the Twitter Timeline widget will no longer display tweets based on searches or hashtags. To display a simple list of tweets instead, change the Widget ID to a Twitter username.', 'jetpack' ) . ' ' . esc_html__( '(Only administrators will see this message.)', 'jetpack' ) . '
id="get_field_id( 'chrome-noheader' ); ?>"
name="get_field_name( 'chrome' ); ?>[]"
value="noheader"
/>
id="get_field_id( 'chrome-nofooter' ); ?>"
name="get_field_name( 'chrome' ); ?>[]"
value="nofooter"
/>
id="get_field_id( 'chrome-noborders' ); ?>"
name="get_field_name( 'chrome' ); ?>[]"
value="noborders"
/>
id="get_field_id( 'chrome-noscrollbar' ); ?>"
name="get_field_name( 'chrome' ); ?>[]"
value="noscrollbar"
/>
id="get_field_id( 'chrome-transparent' ); ?>"
name="get_field_name( 'chrome' ); ?>[]"
value="transparent"
/>