'AMPFORWP_Woo_Widget', 'description' => esc_html__('This Widget adds Woocommerce Products where necessary in AMP Pages','accelerated-mobile-pages') ); parent::__construct( 'AMPFORWP_Woo_Widget', esc_html__('AMP WooCommerce','accelerated-mobile-pages'), $widget_options ); } // args for the output of the form public $args = array( 'before_title' => '

', 'after_title' => '

', 'before_widget' => '
', 'after_widget' => '
' ); // Create the widget output. public function widget( $args,$instance ) { // initializing these to avoid debug errors global $redux_builder_amp; global $woocommerce; if( !class_exists( 'WooCommerce' ) ){ return; } $ampforwp_title = apply_filters( 'widget_wc_title', $instance[ 'title' ] ); $ampforwp_enable_ratings = $instance[ 'ratings' ]; $on_sale_logo_on_product = $instance[ 'on_sale' ]; $ampforwp_procts_page_link = $instance[ 'link' ]; $ampforwp_number_of_products = $instance[ 'num_of_products' ]; $ampforwp_show_price = $instance[ 'show_price' ]; $exclude_ids = ampforwp_exclude_posts(); $q = new WP_Query( array( 'post_type' => 'product', 'orderby' => 'date', 'post__not_in' => $exclude_ids, 'has_password' => false, 'post_status' => 'publish', 'posts_per_page' => esc_attr( $ampforwp_number_of_products ) ) ); echo '

' . esc_html( $ampforwp_title) . '

'; echo '
' ; if ( $q->have_posts() ) : ?> ' ; /* Restore original Post Data */ wp_reset_postdata(); } // Create the admin area widget settings form. public function form( $instance ) { // Declarations for all the values to be stored $ampforwp_title = ! empty( $instance['title'] ) ? $instance['title'] : 'Woocommerce Title'; $ampforwp_enable_ratings = ! empty( $instance['ratings'] ) ? $instance['ratings'] : 'yes'; $on_sale_logo_on_product = ! empty( $instance['on_sale'] ) ? $instance['on_sale'] : 'yes'; $ampforwp_show_price = ! empty( $instance['show_price'] ) ? $instance['show_price'] : 'yes'; $ampforwp_procts_page_link = ! empty( $instance['link'] ) ? $instance['link'] : 'noamp'; $ampforwp_number_of_products = ! empty( $instance['num_of_products'] ) ? $instance['num_of_products'] : 3; ?>