Inventory_Presser_Location_Address::widget( array $args, array $instance )
Outputs the content of the widget
On This Page
Parameters Parameters
- $args
-
(array) (Required)
- $instance
-
(array) (Required)
Source Source
File: includes/widget/class-widget-address.php
public function widget( $args, $instance ) {
if ( empty( $instance['cb_display'] ) ) {
return;
}
$title = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'] );
// before and after widget arguments are defined by themes.
echo wp_kses_post( $args['before_widget'] );
if ( ! empty( $title ) ) {
echo wp_kses_post( $args['before_title'] ) . esc_html( $title ) . wp_kses_post( $args['after_title'] );
}
if ( isset( $instance['cb_single_line'] ) && $instance['cb_single_line'] == 'true' ) {
foreach ( $instance['cb_display'] as $i => $term_id ) {
$location = get_term( $term_id, 'location' );
if ( ! is_wp_error( $location ) && null != $location ) {
printf(
'<span>%s</span>',
esc_html( str_replace( PHP_EOL, ', ', trim( $location->description ) ) )
);
}
}
} else {
foreach ( $instance['cb_display'] as $i => $term_id ) {
$location = get_term( $term_id, 'location' );
if ( ! is_wp_error( $location ) && null !== $location ) {
echo '<div>' . wp_kses_post( nl2br( $location->description ) ) . '</div>';
}
}
}
echo wp_kses_post( $args['after_widget'] );
}
Expand full source codeCollapse full source codeView on Github