'agency_ecommerce_widget_advertisement',
'description' => esc_html__( 'Widget to display advertisement. Recommended to use in Advertisement Below Slider area', 'agency-ecommerce' ),
);
parent::__construct( 'agency-ecommerce-advertisement', esc_html__( 'AE: Advertisement', 'agency-ecommerce' ), $opts );
}
/**
* Echo the widget content.
*
* @since 1.0.0
*
* @param array $args Display arguments including before_title, after_title,
* before_widget, and after_widget.
* @param array $instance The settings for the particular instance of the widget.
*/
function widget( $args, $instance ) {
$title = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base );
$sub_title = ! empty( $instance['sub_title'] ) ? esc_html( $instance['sub_title'] ) : '';
$offer_percent = ! empty( $instance['offer_percent'] ) ? esc_html( $instance['offer_percent'] ) : '';
$offer_text = ! empty( $instance['offer_text'] ) ? esc_html( $instance['offer_text'] ) : '';
$button_text = ! empty( $instance['button_text'] ) ? esc_html( $instance['button_text'] ) : '';
$button_url = ! empty( $instance['button_url'] ) ? esc_url( $instance['button_url'] ) : '';
$content_position = !empty( $instance['content_position'] ) ? $instance['content_position'] : '';
$content_style = !empty( $instance['content_style'] ) ? $instance['content_style'] : '';
$bg_pic = ! empty( $instance['bg_pic'] ) ? esc_url( $instance['bg_pic'] ) : '';
$disable_overlay = ! empty( $instance['disable_overlay'] ) ? $instance['disable_overlay'] : 0;
echo $args['before_widget'];
//For content position
if( 'right' === $content_position ){
$content_class = 'content-right-aligned';
}else{
$content_class = 'content-left-aligned';
}
//For content styles
if( 'style-2' === $content_style ){
$content_style = 'content-style-two';
}else{
$content_style = 'content-style-one';
}
//For overlay position
if( 1 === $disable_overlay ){
$overlay_class = 'overlay-disabled';
}else{
$overlay_class = 'overlay-enabled';
} ?>
' . esc_html( $sub_title ) . '';
} ?>
' . esc_html( $offer_percent ) . '';
}
if ( ! empty( $offer_text ) ) {
echo '' . esc_html( $offer_text ) . '';
} ?>
'',
'sub_title' => '',
'offer_percent' => esc_html__( '50%', 'agency-ecommerce' ),
'offer_text' => esc_html__( 'OFF', 'agency-ecommerce' ),
'button_text' => esc_html__( 'Start Shopping', 'agency-ecommerce' ),
'button_url' => '',
'content_position' => 'left',
'content_style' => 'style-1',
'bg_pic' => '',
'disable_overlay' => 0,
) );
$bg_pic = '';
if ( ! empty( $instance['bg_pic'] ) ) {
$bg_pic = $instance['bg_pic'];
}
$wrap_style = '';
if ( empty( $bg_pic ) ) {
$wrap_style = ' style="display:none;" ';
}
$image_status = false;
if ( ! empty( $bg_pic ) ) {
$image_status = true;
}
$delete_button = 'display:none;';
if ( true === $image_status ) {
$delete_button = 'display:inline-block;';
}
?>
dropdown_content_position( array(
'id' => $this->get_field_id( 'content_position' ),
'name' => $this->get_field_name( 'content_position' ),
'selected' => esc_attr( $instance['content_position'] ),
)
);
?>
dropdown_content_style( array(
'id' => $this->get_field_id( 'content_style' ),
'name' => $this->get_field_name( 'content_style' ),
'selected' => esc_attr( $instance['content_style'] ),
)
);
?>
id="get_field_id( 'disable_overlay' ); ?>" name="get_field_name( 'disable_overlay' ); ?>" />
'',
'name' => '',
'selected' => 'left',
);
$r = wp_parse_args( $args, $defaults );
$output = '';
$choices = array(
'left' => esc_html__( 'Left', 'agency-ecommerce' ),
'right' => esc_html__( 'Right', 'agency-ecommerce' ),
);
if ( ! empty( $choices ) ) {
$output = "
\n";
}
echo $output;
}
function dropdown_content_style( $args ) {
$defaults = array(
'id' => '',
'name' => '',
'selected' => 'style-1',
);
$r = wp_parse_args( $args, $defaults );
$output = '';
$choices = array(
'style-1' => esc_html__( 'Style One', 'agency-ecommerce' ),
'style-2' => esc_html__( 'Style Two', 'agency-ecommerce' ),
);
if ( ! empty( $choices ) ) {
$output = "
\n";
}
echo $output;
}
}
endif;