'', 'first_page_id' => '', 'first_button_text' => esc_html__( 'Shop Now', 'online-shop' ), 'first_button_url' => '', 'second_page_id' => '', 'second_button_text' => esc_html__( 'Shop Now', 'online-shop' ), 'second_button_url' => '' ); return $defaults; } function __construct() { parent::__construct( /*Base ID of your widget*/ 'online_shop_featured_page', /*Widget name will appear in UI*/ esc_html__('AT Featured Section', 'online-shop'), /*Widget description*/ array( 'description' => esc_html__( 'Select page and Show title, featured image and excerpt', 'online-shop' ), ) ); } /*Widget Backend*/ public function form( $instance ) { $instance = wp_parse_args( (array) $instance, $this->defaults() ); /*default values*/ $online_shop_widget_title = esc_attr( $instance['online_shop_widget_title'] ); $first_page_id = absint( $instance[ 'first_page_id' ] ); $first_button_text = esc_attr( $instance[ 'first_button_text' ] ); $first_button_url = esc_url( $instance[ 'first_button_url' ] ); $second_page_id = absint( $instance[ 'second_page_id' ] ); $second_button_text = esc_attr( $instance[ 'second_button_text' ] ); $second_button_url = esc_url( $instance[ 'second_button_url' ] ); ?>
$first_page_id,
'name' => esc_attr( $this->get_field_name( 'first_page_id' ) ),
'id' => esc_attr( $this->get_field_id( 'first_page_id' ) ),
'class' => 'widefat',
'show_option_none' => esc_html__('Select Page','online-shop'),
'option_none_value' => 0 // string
);
wp_dropdown_pages( $args );
?>
$second_page_id,
'name' => $this->get_field_name( 'second_page_id' ),
'id' => $this->get_field_id( 'second_page_id' ),
'class' => 'widefat',
'show_option_none' => esc_html__('Select Page','online-shop'),
'option_none_value' => 0 // string
);
wp_dropdown_pages( $args );
?>