__( 'Allows you to showcase your tags.', 'p2020' ), 'customize_selective_refresh' => true, ] ); if ( is_active_widget( false, false, $this->id_base ) || is_active_widget( false, false, 'monster' ) || is_customize_preview() ) { add_action( 'wp_print_styles', [ $this, 'enqueue_style' ] ); } $this->default_title = __( 'Tags', 'p2020' ); } public function enqueue_style() { wp_enqueue_style( 'widget-grid-and-list' ); } /** * Back-end widget form. * * @param array $instance Previously saved values from database. * * @see WP_Widget::form() * */ public function form( $instance ) { $instance = $this->extend_default_options( $instance ); $title = $instance['title']; if ( false === $title ) { $title = $this->default_title; } $id = $this->get_field_id( 'title' ); $label = translate( 'Title:', 'p2020' ); $name = $this->get_field_name( 'title' ); ?>
5, 10 => 10, 20 => 20, 30 => 30, ]; $id = $this->get_field_id( 'limit' ); $label = translate( 'Limit:', 'p2020' ); $name = $this->get_field_name( 'limit' ); ?>
extend_default_options( $instance ); $title = $instance['title']; $title = apply_filters( 'widget_title', $title ); // phpcs:ignore WordPress.Security.EscapeOutput -- HTML from theme echo $args['before_widget']; if ( ! empty( $title ) ) { if ( is_user_member_of_blog() && current_user_can( 'customize' ) ) { $customize_url = P2_Core\Navigation\Urls::get_customizer_url(); $simple_menu = new P2_Core\Navigation\Simple_Menu( 'tags-widget-menu', __( 'More', 'p2' ) ); $simple_menu->add_item( __( 'Widget settings', 'p2020' ), $customize_url ); } // phpcs:ignore WordPress.Security.EscapeOutput -- HTML from theme echo $args['before_title']; echo esc_html( $title ); if ( $simple_menu ) { get_template_part( 'partials/ellipsis-menu', $simple_menu->get_type(), [ 'simple_menu' => $simple_menu ], ); } // phpcs:ignore WordPress.Security.EscapeOutput -- HTML from theme echo $args['after_title']; } $limit = (int) $instance['limit']; $tags = get_tags( [ 'orderby' => 'count', 'order' => 'DESC', 'number' => $limit, ] ); if ( empty( $tags ) ) { echo 'There are no post tags.'; } else { ?> $this->default_title, 'limit' => 5, ]; $merged = array_merge( $defaults, $options ); return $merged; } }