defaults = array( 'title' => __( 'Tag Cloud', 'advance-widget-pack' ), 'number_of_tags' => '20', 'order_by' => 'name', 'show_count' => '0', ); $widget_ops = array( 'classname' => 'awp_tag_cloud awp_widget', 'description' => __( 'Widget to display a cloud of the site\'s most-used tags.', 'advance-widget-pack' ), ); $control_ops = array( 'id_base' => 'awp_tag_cloud', 'width' => 200, 'height' => 250, ); parent::__construct( 'awp_tag_cloud', __( 'AWP Tag Cloud', 'advance-widget-pack' ), $widget_ops, $control_ops ); } public function widget( $args, $instance ) { $instance = wp_parse_args( (array) $instance, $this->defaults ); $title = apply_filters( 'widget_title', $instance['title'] ); $number = absint( $instance['number_of_tags'] ); $order_by = 'count' === $instance['order_by'] ? 'count' : 'name'; $show_count = ! empty( $instance['show_count'] ); $tag_cloud = wp_tag_cloud( array( 'taxonomy' => 'post_tag', 'number' => $number, 'orderby' => $order_by, 'order' => 'count' === $order_by ? 'DESC' : 'ASC', 'show_count' => $show_count, 'echo' => false, ) ); if ( ! $tag_cloud ) { return; } echo $args['before_widget']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- sidebar-provided wrapper markup, trusted per WP core convention. if ( ! empty( $title ) ) { echo $args['before_title'] . esc_html( $title ) . $args['after_title']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- title text is esc_html()'d; before/after_title are sidebar-provided wrapper markup. } echo '
id="get_field_id( 'show_count' ) ); ?>" name="get_field_name( 'show_count' ) ); ?>" />