<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName /** * MailChimp popup widget. * It acts as a wrapper for the mailchimp_subscriber_popup shortcode. * * @package automattic/jetpack */ // phpcs:disable Universal.Files.SeparateFunctionsFromOO.Mixed -- TODO: Move classes to appropriately-named class files. if ( ! class_exists( 'Jetpack_MailChimp_Subscriber_Popup_Widget' ) ) { if ( ! class_exists( 'MailChimp_Subscriber_Popup' ) ) { include_once JETPACK__PLUGIN_DIR . 'modules/shortcodes/mailchimp.php'; } /** * Register MailChimp Subscriber Popup widget. */ function jetpack_mailchimp_subscriber_popup_widget_init() { register_widget( 'Jetpack_MailChimp_Subscriber_Popup_Widget' ); } add_action( 'widgets_init', 'jetpack_mailchimp_subscriber_popup_widget_init' ); /** * Add a MailChimp subscription form. */ class Jetpack_MailChimp_Subscriber_Popup_Widget extends WP_Widget { /** * Constructor */ public function __construct() { parent::__construct( 'widget_mailchimp_subscriber_popup', /** This filter is documented in modules/widgets/facebook-likebox.php */ apply_filters( 'jetpack_widget_name', __( 'MailChimp Subscriber Popup', 'jetpack' ) ), array( 'classname' => 'widget_mailchimp_subscriber_popup', 'description' => __( 'Allows displaying a popup subscription form to visitors.', 'jetpack' ), 'customize_selective_refresh' => true, ) ); add_filter( 'widget_types_to_hide_from_legacy_widget_block', array( $this, 'hide_widget_in_block_editor' ) ); } /** * Remove the "Mailchimp Subscriber Popup" widget from the Legacy Widget block * * @param array $widget_types List of widgets that are currently removed from the Legacy Widget block. * @return array $widget_types New list of widgets that will be removed. */ public function hide_widget_in_block_editor( $widget_types ) { $widget_types[] = 'widget_mailchimp_subscriber_popup'; return $widget_types; } /** * Outputs the HTML for this widget. * * @param array $args An array of standard parameters for widgets in this theme. * @param array $instance An array of settings for this widget instance. * * @return void Echoes it's output */ public function widget( $args, $instance ) { $instance = wp_parse_args( $instance, array( 'code' => '' ) ); // Regular expresion that will match maichimp shortcode. $regex = '(\[mailchimp_subscriber_popup[^\]]+\])'; // Check if the shortcode exists. preg_match( $regex, $instance['code'], $matches ); // Process the shortcode only, if exists. if ( ! empty( $matches[0] ) ) { echo do_shortcode( $matches[0] ); } /** This action is documented in modules/widgets/gravatar-profile.php */ do_action( 'jetpack_stats_extra', 'widget_view', 'mailchimp_subscriber_popup' ); } /** * Deals with the settings when they are saved by the admin. * * @param array $new_instance New configuration values. * @param array $old_instance Old configuration values. * * @return array */ public function update( $new_instance, $old_instance ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable $instance = array(); $instance['code'] = MailChimp_Subscriber_Popup::reversal( $new_instance['code'] ); return $instance; } /** * Displays the form for this widget on the Widgets page of the WP Admin area. * * @param array $instance Instance configuration. * * @return void */ public function form( $instance ) { $instance = wp_parse_args( $instance, array( 'code' => '' ) ); $label = sprintf( wp_kses( /* Translators: %s is a link to the MailChimp support docs. */ __( 'Code: <a href="%s" target="_blank">( ? )</a>', 'jetpack' ), array( 'a' => array( 'href' => array(), 'target' => array(), ), ) ), 'https://en.support.wordpress.com/mailchimp/' ); printf( '<p><label for="%1$s">%4$s</label><textarea class="widefat" id="%1$s" name="%2$s" rows="3">%3$s</textarea></p>', esc_attr( $this->get_field_id( 'code' ) ), esc_attr( $this->get_field_name( 'code' ) ), esc_textarea( $instance['code'] ), $label // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- escaped above. ); } } }
Name | Type | Size | Permission | Actions |
---|---|---|---|---|
authors | Folder | 0755 |
|
|
contact-info | Folder | 0755 |
|
|
eu-cookie-law | Folder | 0755 |
|
|
facebook-likebox | Folder | 0755 |
|
|
flickr | Folder | 0755 |
|
|
gallery | Folder | 0755 |
|
|
goodreads | Folder | 0755 |
|
|
google-translate | Folder | 0755 |
|
|
image-widget | Folder | 0755 |
|
|
Folder | 0755 |
|
||
internet-defense-league | Folder | 0755 |
|
|
migrate-to-core | Folder | 0755 |
|
|
milestone | Folder | 0755 |
|
|
my-community | Folder | 0755 |
|
|
simple-payments | Folder | 0755 |
|
|
social-icons | Folder | 0755 |
|
|
social-media-icons | Folder | 0755 |
|
|
top-posts | Folder | 0755 |
|
|
wordpress-post-widget | Folder | 0755 |
|
|
authors.php | File | 8.95 KB | 0644 |
|
blog-stats.php | File | 6.11 KB | 0644 |
|
class-jetpack-eu-cookie-law-widget.php | File | 10.55 KB | 0644 |
|
class-jetpack-instagram-widget.php | File | 24.05 KB | 0644 |
|
contact-info.php | File | 17.95 KB | 0644 |
|
customizer-controls.css | File | 165 B | 0644 |
|
customizer-utils.js | File | 4.06 KB | 0644 |
|
facebook-likebox.php | File | 15.28 KB | 0644 |
|
flickr.php | File | 7.46 KB | 0644 |
|
gallery.php | File | 16.14 KB | 0644 |
|
goodreads.php | File | 8.71 KB | 0644 |
|
google-translate.php | File | 6.44 KB | 0644 |
|
gravatar-profile.css | File | 1.23 KB | 0644 |
|
gravatar-profile.php | File | 16.04 KB | 0644 |
|
image-widget.php | File | 12.09 KB | 0644 |
|
internet-defense-league.php | File | 5.65 KB | 0644 |
|
mailchimp.php | File | 4.29 KB | 0644 |
|
milestone.php | File | 346 B | 0644 |
|
my-community.php | File | 10.93 KB | 0644 |
|
rsslinks-widget.php | File | 10.6 KB | 0644 |
|
simple-payments.php | File | 21.91 KB | 0644 |
|
social-icons.php | File | 22.41 KB | 0644 |
|
social-media-icons.php | File | 10.72 KB | 0644 |
|
top-posts.php | File | 27.65 KB | 0644 |
|
twitter-timeline-admin.js | File | 2.18 KB | 0644 |
|
twitter-timeline.php | File | 19.9 KB | 0644 |
|
upcoming-events.php | File | 6.73 KB | 0644 |
|
wordpress-post-widget.php | File | 3.71 KB | 0644 |
|