Edit File by line
/home/zeestwma/richards.../wp-conte.../plugins/jetpack/modules/widgets
File: mailchimp.php
<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
[0] Fix | Delete
/**
[1] Fix | Delete
* MailChimp popup widget.
[2] Fix | Delete
* It acts as a wrapper for the mailchimp_subscriber_popup shortcode.
[3] Fix | Delete
*
[4] Fix | Delete
* @package automattic/jetpack
[5] Fix | Delete
*/
[6] Fix | Delete
[7] Fix | Delete
if ( ! defined( 'ABSPATH' ) ) {
[8] Fix | Delete
exit( 0 );
[9] Fix | Delete
}
[10] Fix | Delete
[11] Fix | Delete
// phpcs:disable Universal.Files.SeparateFunctionsFromOO.Mixed -- TODO: Move classes to appropriately-named class files.
[12] Fix | Delete
[13] Fix | Delete
if ( ! class_exists( 'Jetpack_MailChimp_Subscriber_Popup_Widget' ) ) {
[14] Fix | Delete
[15] Fix | Delete
if ( ! class_exists( 'MailChimp_Subscriber_Popup' ) ) {
[16] Fix | Delete
include_once JETPACK__PLUGIN_DIR . 'modules/shortcodes/mailchimp.php';
[17] Fix | Delete
}
[18] Fix | Delete
[19] Fix | Delete
/**
[20] Fix | Delete
* Register MailChimp Subscriber Popup widget.
[21] Fix | Delete
*/
[22] Fix | Delete
function jetpack_mailchimp_subscriber_popup_widget_init() {
[23] Fix | Delete
register_widget( 'Jetpack_MailChimp_Subscriber_Popup_Widget' );
[24] Fix | Delete
}
[25] Fix | Delete
[26] Fix | Delete
add_action( 'widgets_init', 'jetpack_mailchimp_subscriber_popup_widget_init' );
[27] Fix | Delete
[28] Fix | Delete
/**
[29] Fix | Delete
* Add a MailChimp subscription form.
[30] Fix | Delete
*/
[31] Fix | Delete
class Jetpack_MailChimp_Subscriber_Popup_Widget extends WP_Widget {
[32] Fix | Delete
[33] Fix | Delete
/**
[34] Fix | Delete
* Constructor
[35] Fix | Delete
*/
[36] Fix | Delete
public function __construct() {
[37] Fix | Delete
parent::__construct(
[38] Fix | Delete
'widget_mailchimp_subscriber_popup',
[39] Fix | Delete
/** This filter is documented in modules/widgets/facebook-likebox.php */
[40] Fix | Delete
apply_filters( 'jetpack_widget_name', __( 'MailChimp Subscriber Popup', 'jetpack' ) ),
[41] Fix | Delete
array(
[42] Fix | Delete
'classname' => 'widget_mailchimp_subscriber_popup',
[43] Fix | Delete
'description' => __( 'Allows displaying a popup subscription form to visitors.', 'jetpack' ),
[44] Fix | Delete
'customize_selective_refresh' => true,
[45] Fix | Delete
)
[46] Fix | Delete
);
[47] Fix | Delete
[48] Fix | Delete
add_filter( 'widget_types_to_hide_from_legacy_widget_block', array( $this, 'hide_widget_in_block_editor' ) );
[49] Fix | Delete
}
[50] Fix | Delete
[51] Fix | Delete
/**
[52] Fix | Delete
* Remove the "Mailchimp Subscriber Popup" widget from the Legacy Widget block
[53] Fix | Delete
*
[54] Fix | Delete
* @param array $widget_types List of widgets that are currently removed from the Legacy Widget block.
[55] Fix | Delete
* @return array $widget_types New list of widgets that will be removed.
[56] Fix | Delete
*/
[57] Fix | Delete
public function hide_widget_in_block_editor( $widget_types ) {
[58] Fix | Delete
$widget_types[] = 'widget_mailchimp_subscriber_popup';
[59] Fix | Delete
return $widget_types;
[60] Fix | Delete
}
[61] Fix | Delete
[62] Fix | Delete
/**
[63] Fix | Delete
* Outputs the HTML for this widget.
[64] Fix | Delete
*
[65] Fix | Delete
* @param array $args An array of standard parameters for widgets in this theme.
[66] Fix | Delete
* @param array $instance An array of settings for this widget instance.
[67] Fix | Delete
*
[68] Fix | Delete
* @return void Echoes it's output
[69] Fix | Delete
*/
[70] Fix | Delete
public function widget( $args, $instance ) {
[71] Fix | Delete
$instance = wp_parse_args( $instance, array( 'code' => '' ) );
[72] Fix | Delete
[73] Fix | Delete
// Regular expresion that will match maichimp shortcode.
[74] Fix | Delete
$regex = '(\[mailchimp_subscriber_popup[^\]]+\])';
[75] Fix | Delete
[76] Fix | Delete
// Check if the shortcode exists.
[77] Fix | Delete
preg_match( $regex, $instance['code'], $matches );
[78] Fix | Delete
[79] Fix | Delete
// Process the shortcode only, if exists.
[80] Fix | Delete
if ( ! empty( $matches[0] ) ) {
[81] Fix | Delete
echo do_shortcode( $matches[0] );
[82] Fix | Delete
}
[83] Fix | Delete
[84] Fix | Delete
/** This action is documented in modules/widgets/gravatar-profile.php */
[85] Fix | Delete
do_action( 'jetpack_stats_extra', 'widget_view', 'mailchimp_subscriber_popup' );
[86] Fix | Delete
}
[87] Fix | Delete
[88] Fix | Delete
/**
[89] Fix | Delete
* Deals with the settings when they are saved by the admin.
[90] Fix | Delete
*
[91] Fix | Delete
* @param array $new_instance New configuration values.
[92] Fix | Delete
* @param array $old_instance Old configuration values.
[93] Fix | Delete
*
[94] Fix | Delete
* @return array
[95] Fix | Delete
*/
[96] Fix | Delete
public function update( $new_instance, $old_instance ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
[97] Fix | Delete
$instance = array();
[98] Fix | Delete
$instance['code'] = MailChimp_Subscriber_Popup::reversal( $new_instance['code'] );
[99] Fix | Delete
[100] Fix | Delete
return $instance;
[101] Fix | Delete
}
[102] Fix | Delete
[103] Fix | Delete
/**
[104] Fix | Delete
* Displays the form for this widget on the Widgets page of the WP Admin area.
[105] Fix | Delete
*
[106] Fix | Delete
* @param array $instance Instance configuration.
[107] Fix | Delete
*
[108] Fix | Delete
* @return string|void
[109] Fix | Delete
*/
[110] Fix | Delete
public function form( $instance ) {
[111] Fix | Delete
$instance = wp_parse_args( $instance, array( 'code' => '' ) );
[112] Fix | Delete
[113] Fix | Delete
$label = sprintf(
[114] Fix | Delete
wp_kses(
[115] Fix | Delete
/* Translators: %s is a link to the MailChimp support docs. */
[116] Fix | Delete
__( 'Code: <a href="%s" target="_blank">( ? )</a>', 'jetpack' ),
[117] Fix | Delete
array(
[118] Fix | Delete
'a' => array(
[119] Fix | Delete
'href' => array(),
[120] Fix | Delete
'target' => array(),
[121] Fix | Delete
),
[122] Fix | Delete
)
[123] Fix | Delete
),
[124] Fix | Delete
'https://en.support.wordpress.com/mailchimp/'
[125] Fix | Delete
);
[126] Fix | Delete
[127] Fix | Delete
printf(
[128] Fix | Delete
'<p><label for="%1$s">%4$s</label><textarea class="widefat" id="%1$s" name="%2$s" rows="3">%3$s</textarea></p>',
[129] Fix | Delete
esc_attr( $this->get_field_id( 'code' ) ),
[130] Fix | Delete
esc_attr( $this->get_field_name( 'code' ) ),
[131] Fix | Delete
esc_textarea( $instance['code'] ),
[132] Fix | Delete
$label // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- escaped above.
[133] Fix | Delete
);
[134] Fix | Delete
}
[135] Fix | Delete
}
[136] Fix | Delete
}
[137] Fix | Delete
[138] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function