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-button.php
<?php
[0] Fix | Delete
if ( ! defined( 'ABSPATH' ) ) {
[1] Fix | Delete
exit;
[2] Fix | Delete
}
[3] Fix | Delete
class AMPFORWP_Button_Widget extends WP_Widget {
[4] Fix | Delete
[5] Fix | Delete
/*--------------------------------------------------*/
[6] Fix | Delete
/* Constructor
[7] Fix | Delete
/*--------------------------------------------------*/
[8] Fix | Delete
[9] Fix | Delete
/**
[10] Fix | Delete
* Specifies the classname and description, instantiates the widget,
[11] Fix | Delete
* loads localization files, and includes necessary stylesheets and JavaScript.
[12] Fix | Delete
*/
[13] Fix | Delete
public function __construct() {
[14] Fix | Delete
[15] Fix | Delete
// Hooks fired when the Widget is activated and deactivated
[16] Fix | Delete
register_activation_hook( __FILE__, array( $this, 'activate' ) );
[17] Fix | Delete
register_deactivation_hook( __FILE__, array( $this, 'deactivate' ) );
[18] Fix | Delete
[19] Fix | Delete
parent::__construct(
[20] Fix | Delete
'ampforwp-button',
[21] Fix | Delete
esc_html__( 'AMP Button Module', 'accelerated-mobile-pages' ),
[22] Fix | Delete
array(
[23] Fix | Delete
'classname' => 'ampforwp-button',
[24] Fix | Delete
'description' => esc_html__( 'Displays Button with text and link options.', 'accelerated-mobile-pages' )
[25] Fix | Delete
)
[26] Fix | Delete
);
[27] Fix | Delete
[28] Fix | Delete
add_action( 'admin_enqueue_scripts', array( $this, 'register_admin_scripts' ) );
[29] Fix | Delete
[30] Fix | Delete
// Add static written Jquery
[31] Fix | Delete
add_action( 'admin_footer', array( $this, 'footer_scritps') );
[32] Fix | Delete
[33] Fix | Delete
[34] Fix | Delete
} // end constructor
[35] Fix | Delete
[36] Fix | Delete
/*--------------------------------------------------*/
[37] Fix | Delete
/* Widget API Functions
[38] Fix | Delete
/*--------------------------------------------------*/
[39] Fix | Delete
[40] Fix | Delete
/**
[41] Fix | Delete
* Outputs the content of the widget.
[42] Fix | Delete
*
[43] Fix | Delete
* @param array args The array of form elements
[44] Fix | Delete
* @param array instance The current instance of the widget
[45] Fix | Delete
*/
[46] Fix | Delete
public function widget( $args, $instance ) {
[47] Fix | Delete
$target = "";
[48] Fix | Delete
$output = "";
[49] Fix | Delete
[50] Fix | Delete
extract( $args, EXTR_SKIP );
[51] Fix | Delete
[52] Fix | Delete
$title = ( ! empty( $instance['title'] ) ) ? $instance['title'] : esc_html__( 'Classes', 'accelerated-mobile-pages' );
[53] Fix | Delete
$title = apply_filters( 'widget_title', $title, $instance, $this->id_base );
[54] Fix | Delete
[55] Fix | Delete
$features = ( ! empty( $instance['features'] ) ) ? $instance['features'] : array();
[56] Fix | Delete
[57] Fix | Delete
$output .= '<div class="amp-wp-content amp_cb_module amp_cb_btn">';
[58] Fix | Delete
[59] Fix | Delete
foreach( $features as $feature ) {
[60] Fix | Delete
[61] Fix | Delete
if ( $feature['radio'] == 'radio-off'){
[62] Fix | Delete
$target = "_self";
[63] Fix | Delete
} elseif( $feature['radio'] == 'radio-on' ){
[64] Fix | Delete
$target = "_blank";
[65] Fix | Delete
}
[66] Fix | Delete
[67] Fix | Delete
if ( $feature['size'] == '1'){
[68] Fix | Delete
$size = "s_btn";
[69] Fix | Delete
} elseif( $feature['size'] == '2' ){
[70] Fix | Delete
$size = "m_btn";
[71] Fix | Delete
} elseif( $feature['size'] == '3' ){
[72] Fix | Delete
$size = "l_btn";
[73] Fix | Delete
}
[74] Fix | Delete
//Corrected the URL in button module and breaking of desing and link issue #951 & #972
[75] Fix | Delete
$output .= '<a href="'.esc_url($feature['url']).'" class="' . esc_attr($size) . '" target="' . esc_attr($target) . '" >'. esc_html($feature['title']) .'</a>';
[76] Fix | Delete
}
[77] Fix | Delete
$output .= '</div>';
[78] Fix | Delete
[79] Fix | Delete
$sanitizer = new AMPFORWP_Content( $output, array(),
[80] Fix | Delete
apply_filters( 'ampforwp_content_sanitizers',array( 'AMP_Img_Sanitizer' => array(),'AMP_Style_Sanitizer' => array() ) ) );
[81] Fix | Delete
$sanitized_output = $sanitizer->get_amp_content();
[82] Fix | Delete
[83] Fix | Delete
if( $sanitized_output ) {
[84] Fix | Delete
echo $sanitized_output; // amphtml content, no kses
[85] Fix | Delete
}
[86] Fix | Delete
[87] Fix | Delete
} // end widget
[88] Fix | Delete
[89] Fix | Delete
/**
[90] Fix | Delete
* Processes the widget's options to be saved.
[91] Fix | Delete
*
[92] Fix | Delete
* @param array new_instance The new instance of values to be generated via the update.
[93] Fix | Delete
* @param array old_instance The previous instance of values before the update.
[94] Fix | Delete
*/
[95] Fix | Delete
public function update( $new_instance, $old_instance ) {
[96] Fix | Delete
[97] Fix | Delete
$instance = $old_instance;
[98] Fix | Delete
[99] Fix | Delete
$instance['title'] = strip_tags($new_instance['title']);
[100] Fix | Delete
[101] Fix | Delete
foreach($new_instance['features'] as $feature){
[102] Fix | Delete
$feature['title'] = strip_tags($feature['title']);
[103] Fix | Delete
$feature['description'] = strip_tags($feature['description']);
[104] Fix | Delete
$feature['image'] = strip_tags($feature['image']);
[105] Fix | Delete
}
[106] Fix | Delete
$instance['features'] = $new_instance['features'];
[107] Fix | Delete
[108] Fix | Delete
return $instance;
[109] Fix | Delete
[110] Fix | Delete
} // end widget
[111] Fix | Delete
[112] Fix | Delete
/**
[113] Fix | Delete
* Generates the administration form for the widget.
[114] Fix | Delete
*
[115] Fix | Delete
* @param array instance The array of keys and values for the widget.
[116] Fix | Delete
*/
[117] Fix | Delete
public function form( $instance ) {
[118] Fix | Delete
[119] Fix | Delete
$instance = wp_parse_args(
[120] Fix | Delete
(array) $instance
[121] Fix | Delete
);
[122] Fix | Delete
[123] Fix | Delete
$title = isset( $instance['title'] ) ? esc_attr( $instance['title'] ) : ''; ?>
[124] Fix | Delete
<p> </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-button-additional"> <?php
[131] Fix | Delete
$c = 0; ?>
[132] Fix | Delete
[133] Fix | Delete
<?php
[134] Fix | Delete
[135] Fix | Delete
if ( count( $features ) > 0 ) {
[136] Fix | Delete
foreach( $features as $feature ) {
[137] Fix | Delete
if ( isset( $feature['title'] ) || isset( $feature['description'] ) ) { ?>
[138] Fix | Delete
<div class="widget">
[139] 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>
[140] Fix | Delete
</div>
[141] Fix | Delete
[142] Fix | Delete
<div class="widget-inside">
[143] Fix | Delete
<div class="widget-content">
[144] Fix | Delete
<p>
[145] Fix | Delete
<label for="<?php echo esc_attr($this->get_field_name( 'features' )) . '['.$c.'][title]'; ?>"><?php esc_attr_e( 'Button Text:' ); ?></label>
[146] 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']); ?>" /> </p>
[147] Fix | Delete
[148] Fix | Delete
<p><label for="<?php echo esc_attr($this->get_field_name( 'features' )) . '['.$c.'][url]'; ?>"><?php esc_attr_e( 'Url:' ); ?></label>
[149] Fix | Delete
<input class="widefat" id="<?php echo esc_attr($this->get_field_id( 'features' )) .'-'. $c.'-url'; ?>" name="<?php echo esc_attr($this->get_field_name( 'features' )) . '['.$c.'][url]'; ?>" type="text" value="<?php echo esc_attr($feature['url']); ?>" />
[150] Fix | Delete
</p>
[151] Fix | Delete
[152] Fix | Delete
[153] Fix | Delete
<p><label><?php esc_attr_e('URL Target:'); ?> </label><br />
[154] Fix | Delete
<label class="radio_label" for="<?php echo esc_attr($this->get_field_id('id')) . "-on"; ?>"><?php esc_attr_e('New Tab'); ?> </label>
[155] Fix | Delete
<input class="widefat" id="<?php echo esc_attr($this->get_field_id('id')) . "-on"; ?>" name="<?php echo esc_attr($this->get_field_name( 'features' )) . '['.$c.'][radio]'; ?>" type="radio" value="radio-on" <?php if ( $feature['radio'] == 'radio-on'): ?> checked <?php endif ?> />
[156] Fix | Delete
[157] Fix | Delete
<label class="radio_label" for="<?php echo esc_attr($this->get_field_id('id')) . "-off"; ?>"> <?php esc_attr_e('Current'); ?> </label>
[158] Fix | Delete
[159] Fix | Delete
<input class="widefat" id="<?php echo esc_attr($this->get_field_id('id') . "-off"); ?>" name="<?php echo esc_attr($this->get_field_name( 'features' )) . '['.$c.'][radio]'; ?>" type="radio" value="radio-off" <?php if ( $feature['radio'] == 'radio-off' || $feature['radio'] == ''): ?> checked <?php endif ?> />
[160] Fix | Delete
</p>
[161] Fix | Delete
<!-- done -->
[162] Fix | Delete
<p>
[163] Fix | Delete
<label for="<?php echo esc_attr($this->get_field_id('id')) . "-size"; ?>"> <?php esc_attr_e('Select Size:'); ?> </label>
[164] Fix | Delete
<select id="<?php echo esc_attr($this->get_field_id('id')) . "-size"; ?>" class="widefat" name="<?php echo esc_attr($this->get_field_name( 'features' )) . '['.$c.'][size]'; ?>">
[165] Fix | Delete
<option value="1" <?php selected( $feature['size'], 1 ); ?>>Small</option>
[166] Fix | Delete
<option value="2" <?php selected( $feature['size'], 2 ); ?>>Medium</option>
[167] Fix | Delete
<option value="3" <?php selected( $feature['size'], 3 ); ?>>Large</option>
[168] Fix | Delete
</select>
[169] Fix | Delete
</p>
[170] Fix | Delete
[171] Fix | Delete
<p> <a class="ampforwp-button-remove delete button left"><?php esc_attr_e('Remove Feature','accelerated-mobile-pages')?></a> </p>
[172] Fix | Delete
</div>
[173] Fix | Delete
</div>
[174] Fix | Delete
</div>
[175] Fix | Delete
<?php
[176] Fix | Delete
$c = $c +1;
[177] Fix | Delete
}
[178] Fix | Delete
}
[179] Fix | Delete
} ?>
[180] Fix | Delete
</span>
[181] Fix | Delete
[182] Fix | Delete
<a class="ampforwp-button-add button left"> <?php esc_attr_e('Add Feature','accelerated-mobile-pages'); ?> </a><p> </p>
[183] Fix | Delete
<?php
[184] Fix | Delete
[185] Fix | Delete
} // end form
[186] Fix | Delete
[187] Fix | Delete
/*--------------------------------------------------*/
[188] Fix | Delete
/* Public Functions
[189] Fix | Delete
/*--------------------------------------------------*/
[190] Fix | Delete
[191] Fix | Delete
/**
[192] Fix | Delete
* Registers and enqueues admin-specific JavaScript.
[193] Fix | Delete
*/
[194] Fix | Delete
public function register_admin_scripts() {
[195] Fix | Delete
$builder_data['amp_icon_check'] = AMPFORWP_IMAGE_DIR . '/amp-icon-check.png';
[196] Fix | Delete
wp_localize_script( 'ampforwp-builder-script', 'builder_script_data', $builder_data );
[197] Fix | Delete
wp_enqueue_script( 'ampforwp-builder-script', plugins_url('/modules/js/amp.js' , dirname(__FILE__) ) , array( 'jquery' ), false, true );
[198] Fix | Delete
[199] Fix | Delete
} // end register_admin_scripts
[200] Fix | Delete
[201] Fix | Delete
public function footer_scritps() { ?>
[202] Fix | Delete
<style>.radio_label{}</style> <?php
[203] Fix | Delete
}
[204] Fix | Delete
[205] Fix | Delete
} // end class
[206] Fix | Delete
[207] Fix | Delete
[208] Fix | Delete
add_action( 'widgets_init', 'ampforwp_register_button_widget');
[209] Fix | Delete
function ampforwp_register_button_widget(){
[210] Fix | Delete
register_widget( 'AMPFORWP_Button_Widget' );
[211] Fix | Delete
}
[212] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function