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.../httpdocs/clone/wp-conte.../plugins/accelera.../template...
File: amp-code-widget.php
<?php
[0] Fix | Delete
// Exit if accessed directly
[1] Fix | Delete
if ( ! defined( 'ABSPATH' ) ) {
[2] Fix | Delete
exit;
[3] Fix | Delete
}
[4] Fix | Delete
[5] Fix | Delete
class AMPFORWP_AMP_Code_Widget extends WP_Widget {
[6] Fix | Delete
protected $registered = false;
[7] Fix | Delete
protected $default_instance = array(
[8] Fix | Delete
'title' => '',
[9] Fix | Delete
'content' => '',
[10] Fix | Delete
);
[11] Fix | Delete
[12] Fix | Delete
// Set up the widget name and description.
[13] Fix | Delete
public function __construct() {
[14] Fix | Delete
$widget_options = array(
[15] Fix | Delete
'classname' => 'AMPFORWP_AMP_Code_Widget',
[16] Fix | Delete
'description' => esc_html__('You can add the AMP code in this widget which will appear in AMP Pages','accelerated-mobile-pages')
[17] Fix | Delete
);
[18] Fix | Delete
parent::__construct( 'AMPFORWP_AMP_Code_Widget', esc_html__('Custom AMP Code','accelerated-mobile-pages'), $widget_options );
[19] Fix | Delete
}
[20] Fix | Delete
[21] Fix | Delete
public function _register_one( $number = -1 ) {
[22] Fix | Delete
parent::_register_one( $number );
[23] Fix | Delete
if ( $this->registered ) {
[24] Fix | Delete
return;
[25] Fix | Delete
}
[26] Fix | Delete
$this->registered = true;
[27] Fix | Delete
[28] Fix | Delete
wp_add_inline_script( 'custom-html-widgets', sprintf( 'wp.customHtmlWidgets.idBases.push( %s );', wp_json_encode( $this->id_base ) ) );
[29] Fix | Delete
add_action( 'admin_footer-widgets.php', array( 'AMPFORWP_AMP_Code_Widget', 'render_control_template_scripts' ) );
[30] Fix | Delete
}
[31] Fix | Delete
[32] Fix | Delete
[33] Fix | Delete
public function widget( $args, $instance ) {
[34] Fix | Delete
$simulated_text_widget_instance = array_merge(
[35] Fix | Delete
$instance,
[36] Fix | Delete
array(
[37] Fix | Delete
'text' => isset( $instance['content'] ) ? $instance['content'] : '',
[38] Fix | Delete
'filter' => false, // Because wpautop is not applied.
[39] Fix | Delete
'visual' => false, // Because it wasn't created in TinyMCE.
[40] Fix | Delete
)
[41] Fix | Delete
);
[42] Fix | Delete
unset( $simulated_text_widget_instance['content'] ); // Was moved to 'text' prop.
[43] Fix | Delete
[44] Fix | Delete
/** This filter is documented in wp-includes/widgets/class-wp-widget-text.php */
[45] Fix | Delete
$content = apply_filters( 'widget_text', $instance['content'], $simulated_text_widget_instance, $this );
[46] Fix | Delete
[47] Fix | Delete
// Adds 'noopener' relationship, without duplicating values, to all HTML A elements that have a target.
[48] Fix | Delete
$content = wp_targeted_link_rel( $content );
[49] Fix | Delete
$args['before_widget'] = preg_replace( '/(?<=\sclass=["\'])/', 'widget_text ', $args['before_widget'] );
[50] Fix | Delete
[51] Fix | Delete
echo $args['before_widget'];
[52] Fix | Delete
echo '<div class="textwidget custom-html-widget">'; // The textwidget class is for theme styling compatibility.
[53] Fix | Delete
echo $content;
[54] Fix | Delete
echo '</div>';
[55] Fix | Delete
echo $args['after_widget'];
[56] Fix | Delete
}
[57] Fix | Delete
[58] Fix | Delete
public function form( $instance ) {
[59] Fix | Delete
$instance = wp_parse_args( (array) $instance, $this->default_instance );
[60] Fix | Delete
?>
[61] Fix | Delete
<input id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" class="title sync-input" type="hidden" value="<?php echo esc_attr( $instance['title'] ); ?>"/>
[62] Fix | Delete
<textarea id="<?php echo $this->get_field_id( 'content' ); ?>" name="<?php echo $this->get_field_name( 'content' ); ?>" class="content sync-input" hidden><?php echo esc_textarea( $instance['content'] ); ?></textarea>
[63] Fix | Delete
<?php
[64] Fix | Delete
}
[65] Fix | Delete
public static function render_control_template_scripts() { ?>
[66] Fix | Delete
<script type="text/html" id="tmpl-widget-custom-html-control-fields">
[67] Fix | Delete
<# var elementIdPrefix = 'el' + String( Math.random() ).replace( /\D/g, '' ) + '_' #>
[68] Fix | Delete
[69] Fix | Delete
<p>
[70] Fix | Delete
<label for="{{ elementIdPrefix }}title"><?php esc_html_e( 'Title:' ); ?></label>
[71] Fix | Delete
<input id="{{ elementIdPrefix }}title" type="text" class="widefat title">
[72] Fix | Delete
</p>
[73] Fix | Delete
[74] Fix | Delete
<p>
[75] Fix | Delete
<label for="{{ elementIdPrefix }}content" id="{{ elementIdPrefix }}content-label"><?php esc_html_e( 'Content:' ); ?></label>
[76] Fix | Delete
<textarea id="{{ elementIdPrefix }}content" class="widefat code content" rows="16" cols="20"></textarea>
[77] Fix | Delete
</p>
[78] Fix | Delete
[79] Fix | Delete
<?php if ( ! current_user_can( 'unfiltered_html' ) ) : ?>
[80] Fix | Delete
<?php
[81] Fix | Delete
$probably_unsafe_html = array( 'script', 'iframe', 'form', 'input', 'style' );
[82] Fix | Delete
$allowed_html = wp_kses_allowed_html( 'post' );
[83] Fix | Delete
$disallowed_html = array_diff( $probably_unsafe_html, array_keys( $allowed_html ) );
[84] Fix | Delete
?>
[85] Fix | Delete
<?php if ( ! empty( $disallowed_html ) ) : ?>
[86] Fix | Delete
<# if ( data.codeEditorDisabled ) { #>
[87] Fix | Delete
<p>
[88] Fix | Delete
<?php _e( 'Some HTML tags are not permitted, including:' ); ?>
[89] Fix | Delete
<code><?php echo implode( '</code>, <code>', $disallowed_html ); ?></code>
[90] Fix | Delete
</p>
[91] Fix | Delete
<# } #>
[92] Fix | Delete
<?php endif; ?>
[93] Fix | Delete
<?php endif; ?>
[94] Fix | Delete
[95] Fix | Delete
<div class="code-editor-error-container"></div>
[96] Fix | Delete
</script>
[97] Fix | Delete
<?php
[98] Fix | Delete
}
[99] Fix | Delete
[100] Fix | Delete
public function update( $new_instance, $old_instance ) {
[101] Fix | Delete
$instance = array_merge( $this->default_instance, $old_instance );
[102] Fix | Delete
$instance['title'] = sanitize_text_field( $new_instance['title'] );
[103] Fix | Delete
if ( current_user_can( 'unfiltered_html' ) ) {
[104] Fix | Delete
$instance['content'] = $new_instance['content'];
[105] Fix | Delete
} else {
[106] Fix | Delete
$instance['content'] = wp_kses_post( $new_instance['content'] );
[107] Fix | Delete
}
[108] Fix | Delete
return $instance;
[109] Fix | Delete
}
[110] Fix | Delete
}
[111] Fix | Delete
[112] Fix | Delete
// Register the widget.
[113] Fix | Delete
function ampforwp_register_amp_code_widget() {
[114] Fix | Delete
register_widget( 'AMPFORWP_AMP_Code_Widget' );
[115] Fix | Delete
}
[116] Fix | Delete
add_action( 'widgets_init', 'ampforwp_register_amp_code_widget' );
[117] Fix | Delete
[118] Fix | Delete
?>
[119] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function