Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93
/home/sportsfe.../public_h.../clone/wp-conte.../plugins/wpforms-.../includes
File: class-widget.php
<?php
[0] Fix | Delete
[1] Fix | Delete
if ( ! defined( 'ABSPATH' ) ) {
[2] Fix | Delete
exit;
[3] Fix | Delete
}
[4] Fix | Delete
[5] Fix | Delete
/**
[6] Fix | Delete
* WPForms widget.
[7] Fix | Delete
*
[8] Fix | Delete
* @since 1.0.2
[9] Fix | Delete
*/
[10] Fix | Delete
class WPForms_Widget extends WP_Widget {
[11] Fix | Delete
[12] Fix | Delete
/**
[13] Fix | Delete
* Hold widget settings defaults, populated in constructor.
[14] Fix | Delete
*
[15] Fix | Delete
* @since 1.0.2
[16] Fix | Delete
*
[17] Fix | Delete
* @var array
[18] Fix | Delete
*/
[19] Fix | Delete
protected $defaults;
[20] Fix | Delete
[21] Fix | Delete
/**
[22] Fix | Delete
* Constructor
[23] Fix | Delete
*
[24] Fix | Delete
* @since 1.0.2
[25] Fix | Delete
*/
[26] Fix | Delete
public function __construct() {
[27] Fix | Delete
[28] Fix | Delete
// Widget defaults.
[29] Fix | Delete
$this->defaults = [
[30] Fix | Delete
'title' => '',
[31] Fix | Delete
'form_id' => '',
[32] Fix | Delete
'show_title' => false,
[33] Fix | Delete
'show_desc' => false,
[34] Fix | Delete
];
[35] Fix | Delete
[36] Fix | Delete
// Widget Slug.
[37] Fix | Delete
$widget_slug = 'wpforms-widget';
[38] Fix | Delete
[39] Fix | Delete
// Widget basics.
[40] Fix | Delete
$widget_ops = [
[41] Fix | Delete
'classname' => $widget_slug,
[42] Fix | Delete
'description' => esc_html_x( 'Display a form.', 'Widget', 'wpforms-lite' ),
[43] Fix | Delete
'show_instance_in_rest' => true,
[44] Fix | Delete
];
[45] Fix | Delete
[46] Fix | Delete
// Widget controls.
[47] Fix | Delete
$control_ops = [
[48] Fix | Delete
'id_base' => $widget_slug,
[49] Fix | Delete
];
[50] Fix | Delete
[51] Fix | Delete
// Load widget.
[52] Fix | Delete
parent::__construct( $widget_slug, esc_html_x( 'WPForms', 'Widget', 'wpforms-lite' ), $widget_ops, $control_ops );
[53] Fix | Delete
}
[54] Fix | Delete
[55] Fix | Delete
/**
[56] Fix | Delete
* Output the HTML for this widget.
[57] Fix | Delete
*
[58] Fix | Delete
* @since 1.0.2
[59] Fix | Delete
*
[60] Fix | Delete
* @param array $args An array of standard parameters for widgets in this theme.
[61] Fix | Delete
* @param array $instance An array of settings for this widget instance.
[62] Fix | Delete
*/
[63] Fix | Delete
public function widget( $args, $instance ) {
[64] Fix | Delete
[65] Fix | Delete
// Merge with defaults.
[66] Fix | Delete
$instance = wp_parse_args( (array) $instance, $this->defaults );
[67] Fix | Delete
[68] Fix | Delete
echo $args['before_widget']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
[69] Fix | Delete
[70] Fix | Delete
// Title.
[71] Fix | Delete
if ( ! empty( $instance['title'] ) ) {
[72] Fix | Delete
echo $args['before_title'] . apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base ) . $args['after_title']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
[73] Fix | Delete
}
[74] Fix | Delete
[75] Fix | Delete
// Form.
[76] Fix | Delete
if ( ! empty( $instance['form_id'] ) ) {
[77] Fix | Delete
wpforms()->get( 'frontend' )->output( absint( $instance['form_id'] ), $instance['show_title'], $instance['show_desc'] );
[78] Fix | Delete
}
[79] Fix | Delete
[80] Fix | Delete
echo $args['after_widget']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
[81] Fix | Delete
}
[82] Fix | Delete
[83] Fix | Delete
/**
[84] Fix | Delete
* Deal with the settings when they are saved by the admin. Here is
[85] Fix | Delete
* where any validation should be dealt with.
[86] Fix | Delete
*
[87] Fix | Delete
* @since 1.0.2
[88] Fix | Delete
*
[89] Fix | Delete
* @param array $new_instance An array of new settings as submitted by the admin.
[90] Fix | Delete
* @param array $old_instance An array of the previous settings.
[91] Fix | Delete
*
[92] Fix | Delete
* @return array The validated and (if necessary) amended settings
[93] Fix | Delete
*/
[94] Fix | Delete
public function update( $new_instance, $old_instance ) {
[95] Fix | Delete
[96] Fix | Delete
$new_instance['title'] = wp_strip_all_tags( $new_instance['title'] );
[97] Fix | Delete
$new_instance['form_id'] = ! empty( $new_instance['form_id'] ) ? (int) $new_instance['form_id'] : 0;
[98] Fix | Delete
$new_instance['show_title'] = isset( $new_instance['show_title'] ) && $new_instance['show_title'] ? '1' : false;
[99] Fix | Delete
$new_instance['show_desc'] = isset( $new_instance['show_desc'] ) && $new_instance['show_desc'] ? '1' : false;
[100] Fix | Delete
[101] Fix | Delete
return $new_instance;
[102] Fix | Delete
}
[103] Fix | Delete
[104] Fix | Delete
/**
[105] Fix | Delete
* Display the form for this widget on the Widgets page of the WP Admin area.
[106] Fix | Delete
*
[107] Fix | Delete
* @since 1.0.2
[108] Fix | Delete
*
[109] Fix | Delete
* @param array $instance An array of the current settings for this widget.
[110] Fix | Delete
*/
[111] Fix | Delete
public function form( $instance ) {
[112] Fix | Delete
[113] Fix | Delete
// Merge with defaults.
[114] Fix | Delete
$instance = wp_parse_args( (array) $instance, $this->defaults );
[115] Fix | Delete
?>
[116] Fix | Delete
<p>
[117] Fix | Delete
<label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>">
[118] Fix | Delete
<?php echo esc_html( _x( 'Title:', 'Widget', 'wpforms-lite' ) ); ?>
[119] Fix | Delete
</label>
[120] Fix | Delete
<input type="text"
[121] Fix | Delete
id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"
[122] Fix | Delete
name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>"
[123] Fix | Delete
value="<?php echo esc_attr( $instance['title'] ); ?>" class="widefat"/>
[124] Fix | Delete
</p>
[125] Fix | Delete
<p>
[126] Fix | Delete
<label for="<?php echo esc_attr( $this->get_field_id( 'form_id' ) ); ?>">
[127] Fix | Delete
<?php echo esc_html( _x( 'Form:', 'Widget', 'wpforms-lite' ) ); ?>
[128] Fix | Delete
</label>
[129] Fix | Delete
<select class="widefat"
[130] Fix | Delete
id="<?php echo esc_attr( $this->get_field_id( 'form_id' ) ); ?>"
[131] Fix | Delete
name="<?php echo esc_attr( $this->get_field_name( 'form_id' ) ); ?>">
[132] Fix | Delete
<?php
[133] Fix | Delete
$forms = wpforms()->get( 'form' )->get();
[134] Fix | Delete
[135] Fix | Delete
if ( ! empty( $forms ) ) {
[136] Fix | Delete
echo '<option value="" selected disabled>' . esc_html_x( 'Select your form', 'Widget', 'wpforms-lite' ) . '</option>';
[137] Fix | Delete
[138] Fix | Delete
foreach ( $forms as $form ) {
[139] Fix | Delete
echo '<option value="' . esc_attr( $form->ID ) . '" ' . selected( $instance['form_id'], $form->ID, false ) . '>' . esc_html( $form->post_title ) . '</option>';
[140] Fix | Delete
}
[141] Fix | Delete
} else {
[142] Fix | Delete
echo '<option value="">' . esc_html_x( 'No forms', 'Widget', 'wpforms-lite' ) . '</option>';
[143] Fix | Delete
}
[144] Fix | Delete
?>
[145] Fix | Delete
</select>
[146] Fix | Delete
</p>
[147] Fix | Delete
<p>
[148] Fix | Delete
<input type="checkbox" id="<?php echo esc_attr( $this->get_field_id( 'show_title' ) ); ?>"
[149] Fix | Delete
name="<?php echo esc_attr( $this->get_field_name( 'show_title' ) ); ?>" <?php checked( '1', $instance['show_title'] ); ?>>
[150] Fix | Delete
<label for="<?php echo esc_attr( $this->get_field_id( 'show_title' ) ); ?>">
[151] Fix | Delete
<?php echo esc_html( _x( 'Display form name', 'Widget', 'wpforms-lite' ) ); ?>
[152] Fix | Delete
</label>
[153] Fix | Delete
<br>
[154] Fix | Delete
<input type="checkbox" id="<?php echo esc_attr( $this->get_field_id( 'show_desc' ) ); ?>"
[155] Fix | Delete
name="<?php echo esc_attr( $this->get_field_name( 'show_desc' ) ); ?>" <?php checked( '1', $instance['show_desc'] ); ?>>
[156] Fix | Delete
<label for="<?php echo esc_attr( $this->get_field_id( 'show_desc' ) ); ?>">
[157] Fix | Delete
<?php echo esc_html( _x( 'Display form description', 'Widget', 'wpforms-lite' ) ); ?>
[158] Fix | Delete
</label>
[159] Fix | Delete
</p>
[160] Fix | Delete
<?php
[161] Fix | Delete
}
[162] Fix | Delete
}
[163] Fix | Delete
[164] Fix | Delete
/**
[165] Fix | Delete
* Register WPForms plugin widgets.
[166] Fix | Delete
*/
[167] Fix | Delete
function wpforms_register_widgets() {
[168] Fix | Delete
register_widget( 'WPForms_Widget' );
[169] Fix | Delete
}
[170] Fix | Delete
[171] Fix | Delete
add_action( 'widgets_init', 'wpforms_register_widgets' );
[172] Fix | Delete
[173] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function