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.../includes/modules
File: ampforwp-blurb.php
<?php
[0] Fix | Delete
if ( ! defined( 'ABSPATH' ) ) {
[1] Fix | Delete
exit;
[2] Fix | Delete
}
[3] Fix | Delete
class AMPFORWP_Blurb_Widget extends WP_Widget {
[4] Fix | Delete
/*--------------------------------------------------*/
[5] Fix | Delete
/* Constructor
[6] Fix | Delete
/*--------------------------------------------------*/
[7] Fix | Delete
[8] Fix | Delete
/**
[9] Fix | Delete
* Specifies the classname and description, instantiates the widget,
[10] Fix | Delete
* loads localization files, and includes necessary stylesheets and JavaScript.
[11] Fix | Delete
*/
[12] Fix | Delete
public function __construct() {
[13] Fix | Delete
[14] Fix | Delete
// Hooks fired when the Widget is activated and deactivated
[15] Fix | Delete
register_activation_hook( __FILE__, array( $this, 'activate' ) );
[16] Fix | Delete
register_deactivation_hook( __FILE__, array( $this, 'deactivate' ) );
[17] Fix | Delete
[18] Fix | Delete
parent::__construct(
[19] Fix | Delete
'ampforwp-blurb',
[20] Fix | Delete
esc_html__( 'AMP Blurb Module', 'accelerated-mobile-pages' ),
[21] Fix | Delete
array( //
[22] Fix | Delete
'classname' => 'ampforwp-blurb',
[23] Fix | Delete
'description' => esc_html__( 'Displays Icon, headline and description. Best for showing features.', 'accelerated-mobile-pages' )
[24] Fix | Delete
)
[25] Fix | Delete
);
[26] Fix | Delete
[27] Fix | Delete
add_action( 'admin_enqueue_scripts', array( $this, 'register_admin_scripts' ) );
[28] Fix | Delete
[29] Fix | Delete
} // end constructor
[30] Fix | Delete
[31] Fix | Delete
/*--------------------------------------------------*/
[32] Fix | Delete
/* Widget API Functions
[33] Fix | Delete
/*--------------------------------------------------*/
[34] Fix | Delete
[35] Fix | Delete
/**
[36] Fix | Delete
* Outputs the content of the widget.
[37] Fix | Delete
*
[38] Fix | Delete
* @param array args The array of form elements
[39] Fix | Delete
* @param array instance The current instance of the widget
[40] Fix | Delete
*/
[41] Fix | Delete
public function widget( $args, $instance ) {
[42] Fix | Delete
$output = "";
[43] Fix | Delete
[44] Fix | Delete
extract( $args, EXTR_SKIP );
[45] Fix | Delete
[46] Fix | Delete
$title = ( ! empty( $instance['title'] ) ) ? $instance['title'] : '';
[47] Fix | Delete
$title = apply_filters( 'widget_title', $title, $instance, $this->id_base );
[48] Fix | Delete
[49] Fix | Delete
$features = ( ! empty( $instance['features'] ) ) ? $instance['features'] : array();
[50] Fix | Delete
[51] Fix | Delete
[52] Fix | Delete
echo $before_widget;
[53] Fix | Delete
[54] Fix | Delete
$output .= '<div class="amp-wp-content amp_cb_module amp_cb_blurb">';
[55] Fix | Delete
[56] Fix | Delete
if ( $title ) {
[57] Fix | Delete
$output .= '<div class="amp_module_title"><span>';
[58] Fix | Delete
$output .= esc_html( $title );
[59] Fix | Delete
$output .= '</span></div>';
[60] Fix | Delete
}
[61] Fix | Delete
[62] Fix | Delete
$output .= '<div class="flex-grid">';
[63] Fix | Delete
[64] Fix | Delete
foreach( $features as $feature ) {
[65] Fix | Delete
$output .= '<div class="clmn">';
[66] Fix | Delete
if ( $feature['image'] ) {
[67] Fix | Delete
$output .= '<img src="'. esc_url($feature['image']) .'" height="80" width="80" alt="" />';
[68] Fix | Delete
}
[69] Fix | Delete
$output .= '<div class="amp_cb_content">';
[70] Fix | Delete
$output .= '<h4>'.esc_html( $feature['title']).'</h4>';
[71] Fix | Delete
$output .= '<p>' .esc_html( $feature['description']).'</p>';
[72] Fix | Delete
$output .= '</div>';
[73] Fix | Delete
$output .= '</div>';
[74] Fix | Delete
}
[75] Fix | Delete
$output .= '</div></div>'; // flex-grid & amp_cb_module
[76] Fix | Delete
$sanitizer = new AMPFORWP_Content( $output, array(),
[77] Fix | Delete
apply_filters( 'ampforwp_content_sanitizers',array( 'AMP_Img_Sanitizer' => array(),'AMP_Style_Sanitizer' => array() ) ) );
[78] Fix | Delete
$sanitized_output = $sanitizer->get_amp_content();
[79] Fix | Delete
[80] Fix | Delete
if( $sanitized_output ) {
[81] Fix | Delete
echo $sanitized_output; // amphtml content, no kses
[82] Fix | Delete
}
[83] Fix | Delete
[84] Fix | Delete
echo $after_widget;
[85] Fix | Delete
[86] Fix | Delete
} // end widget
[87] Fix | Delete
[88] Fix | Delete
/**
[89] Fix | Delete
* Processes the widget's options to be saved.
[90] Fix | Delete
*
[91] Fix | Delete
* @param array new_instance The new instance of values to be generated via the update.
[92] Fix | Delete
* @param array old_instance The previous instance of values before the update.
[93] Fix | Delete
*/
[94] Fix | Delete
public function update( $new_instance, $old_instance ) {
[95] Fix | Delete
[96] Fix | Delete
$instance = $old_instance;
[97] Fix | Delete
[98] Fix | Delete
$instance['title'] = strip_tags($new_instance['title']);
[99] Fix | Delete
[100] Fix | Delete
foreach($new_instance['features'] as $feature){
[101] Fix | Delete
$feature['title'] = strip_tags($feature['title']);
[102] Fix | Delete
$feature['description'] = strip_tags($feature['description']);
[103] Fix | Delete
$feature['image'] = strip_tags($feature['image']);
[104] Fix | Delete
}
[105] Fix | Delete
$instance['features'] = $new_instance['features'];
[106] Fix | Delete
[107] Fix | Delete
return $instance;
[108] Fix | Delete
[109] Fix | Delete
} // end widget
[110] Fix | Delete
[111] Fix | Delete
/**
[112] Fix | Delete
* Generates the administration form for the widget.
[113] Fix | Delete
*
[114] Fix | Delete
* @param array instance The array of keys and values for the widget.
[115] Fix | Delete
*/
[116] Fix | Delete
public function form( $instance ) {
[117] Fix | Delete
[118] Fix | Delete
$instance = wp_parse_args(
[119] Fix | Delete
(array) $instance
[120] Fix | Delete
);
[121] Fix | Delete
[122] Fix | Delete
$title = isset( $instance['title'] ) ? esc_attr( $instance['title'] ) : ''; ?>
[123] Fix | Delete
<p><label for="<?php echo esc_attr($this->get_field_id( 'title' )); ?>"><?php esc_attr_e( 'Title:' ); ?></label>
[124] Fix | Delete
<input class="widefat" id="<?php echo esc_attr($this->get_field_id( 'title' )); ?>" name="<?php echo esc_attr($this->get_field_name( 'title' )); ?>" type="text" value="<?php echo esc_attr($title); ?>" /></p>
[125] Fix | Delete
[126] Fix | Delete
[127] Fix | Delete
<?php
[128] Fix | Delete
[129] Fix | Delete
$features = ( ! empty( $instance['features'] ) ) ? $instance['features'] : array(); ?>
[130] Fix | Delete
<span class="ampforwp-blurb-additional">
[131] Fix | Delete
<?php
[132] Fix | Delete
$c = 0;
[133] Fix | Delete
if ( count( $features ) > 0 ) {
[134] Fix | Delete
foreach( $features as $feature ) {
[135] Fix | Delete
if ( isset( $feature['title'] ) || isset( $feature['description'] ) ) { ?>
[136] Fix | Delete
<div class="widget">
[137] Fix | Delete
<div class="widget-top"><div class="widget-title"><h3><?php echo esc_attr($feature['title']);?><span class="in-widget-title"></span></h3></div>
[138] Fix | Delete
</div>
[139] Fix | Delete
[140] Fix | Delete
<div class="widget-inside">
[141] Fix | Delete
<p>
[142] Fix | Delete
<label for="<?php echo esc_attr($this->get_field_name( 'features' )) . '['.$c.'][title]'; ?>"><?php esc_attr_e( 'Title:' ); ?></label>
[143] Fix | Delete
<input class="widefat" id="<?php echo esc_attr($this->get_field_id( 'features' )) .'-'. $c.'-title'; ?>" name="<?php echo esc_attr($this->get_field_name( 'features' )) . '['.$c.'][title]'; ?>" type="text" value="<?php echo esc_attr($feature['title']); ?>" />
[144] Fix | Delete
<label for="<?php echo esc_attr($this->get_field_name( 'features' )) . '['.$c.'][description]'; ?>"><?php esc_attr_e( 'Description:' ); ?></label>
[145] Fix | Delete
[146] Fix | Delete
<textarea class="widefat" id="<?php echo esc_attr($this->get_field_id( 'features' )) .'-'. $c.'-description'; ?>" name="<?php echo esc_attr($this->get_field_name( 'features' )) . '['.$c.'][description]'; ?>" rows="6" cols="50"><?php echo esc_attr($feature['description']); ?></textarea> <span class="clear"></span>
[147] Fix | Delete
</p>
[148] Fix | Delete
<p>
[149] Fix | Delete
<label for="<?php echo esc_attr($this->get_field_name( 'features' )) . '['.$c.'][image]'; ?>"><?php esc_attr_e( 'Image:' ); ?></label>
[150] Fix | Delete
<input type="button" class="select-img-<?php echo esc_attr($c);?> button left" style="width:auto;" value="Select Image" onclick="ampSelectImage('<?php echo esc_attr($c);?>');"/>
[151] Fix | Delete
<input type="button" style="display:none" name="removeimg" id="remove-img-<?php echo esc_attr($c);?>" class="button button-secondary remove-img-button" data-count-type="<?php echo esc_attr($c);?>" value="Remove Image" onclick="removeImage('<?php echo esc_attr($c);?>')">
[152] Fix | Delete
<img src="<?php echo esc_url($instance['features']["$c"]['image']) ?>" class="preview-image block-image-<?php echo esc_attr($c);?>" >
[153] Fix | Delete
<input type="hidden" id="amp-img-field-<?php echo esc_attr($c);?>" class="img<?php echo esc_attr($c);?>" style="width:auto;" name="<?php echo esc_attr($this->get_field_name( 'features' )) . '['.$c.'][image]'; ?>" id="<?php echo esc_attr($this->get_field_name( 'features' )) . '['.$c.'][image]';?>'" value="<?php echo esc_attr($instance['features']["$c"]['image']) ?>" />
[154] Fix | Delete
</p>
[155] Fix | Delete
<p> <a class="ampforwp-blurb-remove delete button left"><?php esc_attr_e('Remove Feature','accelerated-mobile-pages')?></a> </p>
[156] Fix | Delete
</div>
[157] Fix | Delete
</div>
[158] Fix | Delete
<?php
[159] Fix | Delete
$c = $c +1;
[160] Fix | Delete
}
[161] Fix | Delete
}
[162] Fix | Delete
} ?>
[163] Fix | Delete
</span>
[164] Fix | Delete
[165] Fix | Delete
<a class="ampforwp-blurb-add button left"> <?php esc_attr_e('Add Feature','accelerated-mobile-pages'); ?> </a>
[166] Fix | Delete
[167] Fix | Delete
<?php
[168] Fix | Delete
[169] Fix | Delete
} // end form
[170] Fix | Delete
[171] Fix | Delete
/*--------------------------------------------------*/
[172] Fix | Delete
/* Public Functions
[173] Fix | Delete
/*--------------------------------------------------*/
[174] Fix | Delete
[175] Fix | Delete
/**
[176] Fix | Delete
* Registers and enqueues admin-specific JavaScript.
[177] Fix | Delete
*/
[178] Fix | Delete
public function register_admin_scripts() {
[179] Fix | Delete
[180] Fix | Delete
wp_enqueue_script('media-upload');
[181] Fix | Delete
wp_enqueue_script('thickbox');
[182] Fix | Delete
wp_enqueue_style('thickbox');
[183] Fix | Delete
$builder_data['amp_icon_check'] = AMPFORWP_IMAGE_DIR . '/amp-icon-check.png';
[184] Fix | Delete
wp_localize_script( 'ampforwp-builder-script', 'builder_script_data', $builder_data );
[185] Fix | Delete
wp_enqueue_script( 'ampforwp-builder-script', plugins_url('/modules/js/amp.js' , dirname(__FILE__) ) , array( 'jquery' ), false, true );
[186] Fix | Delete
[187] Fix | Delete
} // end register_admin_scripts
[188] Fix | Delete
[189] Fix | Delete
[190] Fix | Delete
} // end class
[191] Fix | Delete
[192] Fix | Delete
[193] Fix | Delete
add_action( 'widgets_init', 'ampforwp_register_blurb_widget' );
[194] Fix | Delete
function ampforwp_register_blurb_widget(){
[195] Fix | Delete
register_widget( 'AMPFORWP_Blurb_Widget' );
[196] Fix | Delete
}
[197] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function