esc_html__( 'An widget to upload image.', 'business-center' ), ) // Args ); } /** * Front-end display of widget. * * @see WP_Widget::widget() * * @param array $args Widget arguments. * @param array $instance Saved values from database. */ public function widget( $args, $instance ) { $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base ); $image_url = ! empty( $instance['image_url'] ) ? $instance['image_url'] : ''; $link = ! empty( $instance['link'] ) ? $instance['link'] : ''; $alt_text = ! empty( $instance['alt_text'] ) ? $instance['alt_text'] : ''; $open_link = ! empty( $instance['open_link'] ) ? $instance['open_link'] : false; $instance['link_open'] = ''; $instance['link_close'] = ''; if ( ! empty ( $link ) ) { $target = ( empty( $open_link ) ) ? '' : ' target="_blank" '; $instance['link_open'] = ''; $instance['link_close'] = ''; } echo $args['before_widget']; if ( $title ) { echo $args['before_title'] ; echo esc_html( $title ); echo $args['after_title'] ; } if ( ! empty( $image_url ) ) { $sizes = array(); $alt_text = ( ! empty( $alt_text ) ) ? $alt_text : basename( $image_url ); $imgtag = '' . esc_attr( $alt_text ) . ''; echo sprintf( '%s%s%s', $instance['link_open'], $imgtag, $instance['link_close'] ); } // End if : image is there. echo $args['after_widget']; } /** * Back-end widget form. * * @see WP_Widget::form() * * @param array $instance Previously saved values from database. */ public function form( $instance ) { // Defaults. $instance = wp_parse_args( (array) $instance, array( 'title' => '', 'image_url' => '', 'link' => '', 'alt_text' => '', 'open_link' => 0, ) ); $title = htmlspecialchars( $instance['title'] ); $image_url = isset( $instance['image_url'] ) ? $instance['image_url'] : ''; $link = isset( $instance['link'] ) ? $instance['link'] : ''; $alt_text = isset( $instance['alt_text'] ) ? $instance['alt_text'] : ''; $open_link = isset( $instance['open_link'] ) ? $instance['open_link'] : false; ?>

:

> <?php esc_attr_e( 'Preview', 'business-center'); ?>

/>