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: woo-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
class AMPFORWP_Woo_Widget extends WP_Widget {
[5] Fix | Delete
[6] Fix | Delete
// Set up the widget name and description.
[7] Fix | Delete
public function __construct() {
[8] Fix | Delete
$widget_options = array(
[9] Fix | Delete
'classname' => 'AMPFORWP_Woo_Widget',
[10] Fix | Delete
'description' => esc_html__('This Widget adds Woocommerce Products where necessary in AMP Pages','accelerated-mobile-pages')
[11] Fix | Delete
);
[12] Fix | Delete
parent::__construct( 'AMPFORWP_Woo_Widget', esc_html__('AMP WooCommerce','accelerated-mobile-pages'), $widget_options );
[13] Fix | Delete
}
[14] Fix | Delete
[15] Fix | Delete
[16] Fix | Delete
// args for the output of the form
[17] Fix | Delete
public $args = array(
[18] Fix | Delete
'before_title' => '<h4 class="wc_widgettitle">',
[19] Fix | Delete
'after_title' => '</h4>',
[20] Fix | Delete
'before_widget' => '<div class="widget-wrap">',
[21] Fix | Delete
'after_widget' => '</div>'
[22] Fix | Delete
);
[23] Fix | Delete
[24] Fix | Delete
// Create the widget output.
[25] Fix | Delete
public function widget( $args,$instance ) {
[26] Fix | Delete
// initializing these to avoid debug errors
[27] Fix | Delete
global $redux_builder_amp;
[28] Fix | Delete
global $woocommerce;
[29] Fix | Delete
[30] Fix | Delete
if( !class_exists( 'WooCommerce' ) ){
[31] Fix | Delete
return;
[32] Fix | Delete
}
[33] Fix | Delete
$ampforwp_title = apply_filters( 'widget_wc_title', $instance[ 'title' ] );
[34] Fix | Delete
$ampforwp_enable_ratings = $instance[ 'ratings' ];
[35] Fix | Delete
$on_sale_logo_on_product = $instance[ 'on_sale' ];
[36] Fix | Delete
$ampforwp_procts_page_link = $instance[ 'link' ];
[37] Fix | Delete
$ampforwp_number_of_products = $instance[ 'num_of_products' ];
[38] Fix | Delete
$ampforwp_show_price = $instance[ 'show_price' ];
[39] Fix | Delete
[40] Fix | Delete
$exclude_ids = ampforwp_exclude_posts();
[41] Fix | Delete
[42] Fix | Delete
$q = new WP_Query( array(
[43] Fix | Delete
'post_type' => 'product',
[44] Fix | Delete
'orderby' => 'date',
[45] Fix | Delete
'post__not_in' => $exclude_ids,
[46] Fix | Delete
'has_password' => false,
[47] Fix | Delete
'no_found_rows' => true,
[48] Fix | Delete
'post_status' => 'publish',
[49] Fix | Delete
'posts_per_page' => esc_attr( $ampforwp_number_of_products )
[50] Fix | Delete
) );
[51] Fix | Delete
[52] Fix | Delete
echo '<h4 class="wc_widgettitle">' . esc_html( $ampforwp_title) . '</h4>';
[53] Fix | Delete
echo '<div class="widget-wrap amp-wp-content">' ;
[54] Fix | Delete
[55] Fix | Delete
if ( $q->have_posts() ) : ?>
[56] Fix | Delete
<ul class="ampforwp_wc_shortcode"> <?php
[57] Fix | Delete
while ( $q->have_posts() ) : $q->the_post();
[58] Fix | Delete
global $post;
[59] Fix | Delete
global $product;
[60] Fix | Delete
if( $ampforwp_procts_page_link === 'amp' ) {
[61] Fix | Delete
$ampforwp_post_url = ampforwp_url_controller( get_permalink() );
[62] Fix | Delete
} else {
[63] Fix | Delete
$ampforwp_post_url = trailingslashit( get_permalink() ) ;
[64] Fix | Delete
} ?>
[65] Fix | Delete
<li class="ampforwp_wc_shortcode_child"><a href="<?php echo esc_url( $ampforwp_post_url );?>"> <?php
[66] Fix | Delete
[67] Fix | Delete
if ( ampforwp_has_post_thumbnail() ) {
[68] Fix | Delete
$thumb_url = ampforwp_get_post_thumbnail('url');
[69] Fix | Delete
$thumb_width = ampforwp_get_post_thumbnail('width');
[70] Fix | Delete
$thumb_height = ampforwp_get_post_thumbnail('height'); ?>
[71] Fix | Delete
[72] Fix | Delete
<amp-img src='<?php echo esc_url( $thumb_url ); ?>' width="<?php echo esc_attr($thumb_width); ?>" height="<?php echo esc_attr($thumb_height); ?>" layout="responsive"></amp-img> <?php
[73] Fix | Delete
}
[74] Fix | Delete
[75] Fix | Delete
if ( $product->is_on_sale() && $on_sale_logo_on_product=='yes' ) { ?>
[76] Fix | Delete
<span class="onsale"> <?php echo esc_html__('Sale!','accelerated-mobile-pages') ?> </span> <?php
[77] Fix | Delete
} ?>
[78] Fix | Delete
[79] Fix | Delete
<div class="ampforwp-wc-title"> <?php echo get_the_title() ?> </div> <?php
[80] Fix | Delete
if ( class_exists( 'WooCommerce' ) ) {
[81] Fix | Delete
$amp_product_price = $woocommerce->product_factory->get_product()->get_price_html();
[82] Fix | Delete
$context = '';
[83] Fix | Delete
$allowed_tags = wp_kses_allowed_html( $context );
[84] Fix | Delete
[85] Fix | Delete
$stock_status = $product->is_in_stock() ? 'InStock' : 'OutOfStock' ;
[86] Fix | Delete
if ( $amp_product_price && $stock_status == 'InStock' && $ampforwp_show_price=='yes' ) { ?>
[87] Fix | Delete
<div class="ampforwp-wc-price"><?php echo wp_kses( $amp_product_price , $allowed_tags ) ?> </div> <?php
[88] Fix | Delete
}
[89] Fix | Delete
[90] Fix | Delete
$rating_count = $product->get_rating_count();
[91] Fix | Delete
$rating = $product->get_average_rating();
[92] Fix | Delete
[93] Fix | Delete
if ( get_option( 'woocommerce_enable_review_rating' ) === 'yes' && $rating_count && $ampforwp_enable_ratings=='yes' ) {
[94] Fix | Delete
$content = '<div class="ampforwp_wc_star_rating" class="star-rating" title="Rated '.$rating.' out of 5' . '">';
[95] Fix | Delete
$content .= '<span class="ampforwp_wc_star_rating_text" ><strong>'.$rating.'</strong>'.__(' out of 5 </span>','accelerated-mobile-pages');
[96] Fix | Delete
$content .= '</div>';
[97] Fix | Delete
echo wp_kses( $content, $allowed_tags );
[98] Fix | Delete
}
[99] Fix | Delete
[100] Fix | Delete
} ?>
[101] Fix | Delete
</a></li>
[102] Fix | Delete
<?php endwhile; ?>
[103] Fix | Delete
</ul>
[104] Fix | Delete
<?php endif; ?><?php
[105] Fix | Delete
[106] Fix | Delete
echo '</div>' ;
[107] Fix | Delete
/* Restore original Post Data */
[108] Fix | Delete
wp_reset_postdata();
[109] Fix | Delete
}
[110] Fix | Delete
[111] Fix | Delete
[112] Fix | Delete
// Create the admin area widget settings form.
[113] Fix | Delete
public function form( $instance ) {
[114] Fix | Delete
[115] Fix | Delete
// Declarations for all the values to be stored
[116] Fix | Delete
$ampforwp_title = ! empty( $instance['title'] ) ? $instance['title'] : 'Woocommerce Title';
[117] Fix | Delete
$ampforwp_enable_ratings = ! empty( $instance['ratings'] ) ? $instance['ratings'] : 'yes';
[118] Fix | Delete
$on_sale_logo_on_product = ! empty( $instance['on_sale'] ) ? $instance['on_sale'] : 'yes';
[119] Fix | Delete
$ampforwp_show_price = ! empty( $instance['show_price'] ) ? $instance['show_price'] : 'yes';
[120] Fix | Delete
$ampforwp_procts_page_link = ! empty( $instance['link'] ) ? $instance['link'] : 'noamp';
[121] Fix | Delete
$ampforwp_number_of_products = ! empty( $instance['num_of_products'] ) ? $instance['num_of_products'] : 3; ?>
[122] Fix | Delete
<!-- Form Starts Here -->
[123] Fix | Delete
<p>
[124] Fix | Delete
<!-- text Start Here -->
[125] Fix | Delete
<label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"> <?php echo esc_html__('Title:','accelerated-mobile-pages') ?>
[126] Fix | Delete
<input class="widefat" type="text" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" value="<?php echo esc_html( $ampforwp_title ); ?>" />
[127] Fix | Delete
</label><br>
[128] Fix | Delete
<!-- text End Here -->
[129] Fix | Delete
</p>
[130] Fix | Delete
[131] Fix | Delete
<!-- number input starts Here -->
[132] Fix | Delete
<p>
[133] Fix | Delete
<label for="<?php echo esc_attr( $this->get_field_id( 'num_of_products' ) ); ?>"><?php echo esc_html__('Number of Products:','accelerated-mobile-pages') ?>
[134] Fix | Delete
<input class="widefat" type="number" id="<?php echo esc_attr( $this->get_field_id( 'num_of_products' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'num_of_products' ) ); ?>" value="<?php echo esc_attr( $ampforwp_number_of_products ); ?>" />
[135] Fix | Delete
</label>
[136] Fix | Delete
</p>
[137] Fix | Delete
<!-- number input End Here -->
[138] Fix | Delete
[139] Fix | Delete
<p>
[140] Fix | Delete
<!-- radio buttons starts Here -->
[141] Fix | Delete
<label for="<?php echo esc_attr($this->get_field_id( 'ratings' ) ); ?>" value="<?php echo esc_attr( $ampforwp_enable_ratings );?>"><?php echo esc_html__('Enable Ratings:','accelerated-mobile-pages') ?> </label><br>
[142] Fix | Delete
<label for="<?php echo esc_attr( $this->get_field_id('ratings_1') ); ?>">
[143] Fix | Delete
<input class="widefat" id="<?php echo esc_attr( $this->get_field_id('ratings_1') ); ?>" name="<?php echo esc_attr( $this->get_field_name('ratings') ); ?>" type="radio" value="yes" <?php if($ampforwp_enable_ratings === 'yes'){ echo 'checked="checked"'; } ?> /><?php echo esc_html__('Yes ','accelerated-mobile-pages'); ?>
[144] Fix | Delete
</label>
[145] Fix | Delete
<label for="<?php echo esc_attr( $this->get_field_id('ratings_2') ); ?>">
[146] Fix | Delete
<input class="widefat" id="<?php echo esc_attr( $this->get_field_id('ratings_2') ); ?>" name="<?php echo esc_attr( $this->get_field_name('ratings') ); ?>" type="radio" value="no" <?php if($ampforwp_enable_ratings === 'no'){ echo esc_attr( 'checked="checked"' ); } ?> /><?php echo esc_html__(' No','accelerated-mobile-pages'); ?>
[147] Fix | Delete
</label>
[148] Fix | Delete
<!-- radio buttons Ends Here -->
[149] Fix | Delete
</p>
[150] Fix | Delete
[151] Fix | Delete
<p>
[152] Fix | Delete
<!-- radio buttons starts Here -->
[153] Fix | Delete
<label for="<?php echo esc_attr( $this->get_field_id( 'on_sale' ) ); ?>" value="<?php echo esc_attr( $on_sale_logo_on_product );?>"><?php echo esc_html__('Show On Sale:','accelerated-mobile-pages') ?> </label><br>
[154] Fix | Delete
<label for="<?php echo esc_attr( $this->get_field_id('on_sale_1') ); ?>">
[155] Fix | Delete
<input class="widefat" id="<?php echo esc_attr( $this->get_field_id('on_sale_1') ); ?>" name="<?php echo esc_attr( $this->get_field_name('on_sale') ); ?>" type="radio" value="yes" <?php if( $on_sale_logo_on_product === 'yes'){ echo esc_attr('checked="checked"' ); } ?> /><?php echo esc_html__('Yes ','accelerated-mobile-pages'); ?>
[156] Fix | Delete
</label>
[157] Fix | Delete
<label for="<?php echo esc_attr( $this->get_field_id('on_sale_2') ); ?>">
[158] Fix | Delete
<input class="widefat" id="<?php echo esc_attr( $this->get_field_id('on_sale_2') ); ?>" name="<?php echo esc_attr( $this->get_field_name('on_sale') ); ?>" type="radio" value="no" <?php if($on_sale_logo_on_product === 'no'){ echo 'checked="checked"'; } ?> /><?php echo esc_html__(' No','accelerated-mobile-pages'); ?>
[159] Fix | Delete
</label>
[160] Fix | Delete
<!-- radio buttons Ends Here -->
[161] Fix | Delete
</p>
[162] Fix | Delete
[163] Fix | Delete
<p>
[164] Fix | Delete
<!-- radio buttons starts Here -->
[165] Fix | Delete
<label for="<?php echo esc_attr( $this->get_field_id( 'show_price' ) ); ?>" value="<?php echo esc_attr( $ampforwp_show_price );?>"> <?php echo esc_html__('Show Price:','accelerated-mobile-pages') ?></label><br>
[166] Fix | Delete
<label for="<?php echo esc_attr( $this->get_field_id('show_price_1') ); ?>">
[167] Fix | Delete
<input class="widefat" id="<?php echo esc_attr( $this->get_field_id('show_price_1') ); ?>" name="<?php echo esc_attr( $this->get_field_name('show_price') ); ?>" type="radio" value="yes" <?php if($ampforwp_show_price === 'yes'){ echo esc_attr( 'checked="checked"' ); } ?> /><?php echo esc_html__('Yes ','accelerated-mobile-pages'); ?>
[168] Fix | Delete
</label>
[169] Fix | Delete
<label for="<?php echo esc_attr( $this->get_field_id('show_price_2') ); ?>">
[170] Fix | Delete
<input class="widefat" id="<?php echo esc_attr( $this->get_field_id('show_price_2') ); ?>" name="<?php echo esc_attr( $this->get_field_name('show_price') ); ?>" type="radio" value="no" <?php if($ampforwp_show_price === 'no'){ echo esc_attr( 'checked="checked"' ); } ?> /><?php echo esc_html__(' No','accelerated-mobile-pages'); ?>
[171] Fix | Delete
</label>
[172] Fix | Delete
<!-- radio buttons Ends Here -->
[173] Fix | Delete
</p>
[174] Fix | Delete
<p>
[175] Fix | Delete
<!-- radio buttons starts Here -->
[176] Fix | Delete
<label for="<?php echo esc_attr( $this->get_field_id( 'link' ) ); ?>" value="<?php echo esc_attr( $ampforwp_procts_page_link );?>"><?php echo esc_html__('Show View more Button:','accelerated-mobile-pages') ?> </label><br>
[177] Fix | Delete
<label for="<?php echo esc_attr( $this->get_field_id('link_1') ); ?>">
[178] Fix | Delete
<input class="widefat" id="<?php echo esc_attr( $this->get_field_id('link_1') ); ?>" name="<?php echo esc_attr( $this->get_field_name('link') ); ?>" type="radio" value="amp" <?php if($ampforwp_procts_page_link === 'amp'){ echo esc_attr( 'checked="checked"' ); } ?> /><?php echo esc_html__('AMP ','accelerated-mobile-pages'); ?>
[179] Fix | Delete
</label>
[180] Fix | Delete
<label for="<?php echo esc_attr( $this->get_field_id('link_2') ); ?>">
[181] Fix | Delete
<input class="widefat" id="<?php echo esc_attr( $this->get_field_id('link_2') ); ?>" name="<?php echo esc_attr( $this->get_field_name('link') ); ?>" type="radio" value="noamp" <?php if($ampforwp_procts_page_link === 'noamp'){ echo esc_attr( 'checked="checked"' ); } ?> /><?php echo esc_html__(' Non AMP','accelerated-mobile-pages'); ?>
[182] Fix | Delete
</label>
[183] Fix | Delete
<!-- radio buttons Ends Here -->
[184] Fix | Delete
</p>
[185] Fix | Delete
[186] Fix | Delete
[187] Fix | Delete
<!-- Form Ends Here -->
[188] Fix | Delete
[189] Fix | Delete
<?php
[190] Fix | Delete
}
[191] Fix | Delete
[192] Fix | Delete
// Apply settings to the widget instance.
[193] Fix | Delete
public function update( $new_instance, $old_instance ) {
[194] Fix | Delete
$instance = $old_instance;
[195] Fix | Delete
$instance[ 'title' ] = strip_tags( $new_instance[ 'title' ] );
[196] Fix | Delete
$instance[ 'num_of_products' ] = strip_tags( $new_instance[ 'num_of_products' ] );
[197] Fix | Delete
$instance['link'] = strip_tags($new_instance['link']);
[198] Fix | Delete
$instance['show_price'] = strip_tags($new_instance['show_price']);
[199] Fix | Delete
$instance['on_sale'] = strip_tags($new_instance['on_sale']);
[200] Fix | Delete
$instance['ratings'] = strip_tags($new_instance['ratings']);
[201] Fix | Delete
[202] Fix | Delete
return $instance;
[203] Fix | Delete
}
[204] Fix | Delete
[205] Fix | Delete
}
[206] Fix | Delete
[207] Fix | Delete
// Register the widget.
[208] Fix | Delete
function ampforwp_register_woo_widget() {
[209] Fix | Delete
if ( class_exists( 'WooCommerce' ) ) {
[210] Fix | Delete
register_widget( 'AMPFORWP_Woo_Widget' );
[211] Fix | Delete
}
[212] Fix | Delete
}
[213] Fix | Delete
add_action( 'widgets_init', 'ampforwp_register_woo_widget' );
[214] Fix | Delete
?>
[215] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function