get_the_section_a_z_widget( array $args, array $instance )
Get the user-visible widget html
Description
Parameters
- $args
(Required) General widget configuration. Often shared between all widgets on the site.
- $instance
(Required) Configuration of this Widget. Unique to this invocation.
Return
(string) The complete A-Z Widget HTML ready for echoing to the page.
Source
File: widgets/class-a-z-listing-widget.php
function get_the_section_a_z_widget( array $args, array $instance ): string { //phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound do_action( 'a_z_listing_log', 'A-Z Listing: Running widget' ); $instance = wp_parse_args( $instance, array( 'all_children' => 'true', 'exclude_terms' => '', 'hide_empty_terms' => false, 'parent_post' => '', 'parent_term' => '', 'post' => -1, // target. 'page' => -1, // obsolete target. 'post_type' => 'page', 'taxonomy' => '', 'terms' => '', 'title' => '', 'type' => 'posts', ) ); $title = esc_html( $instance['title'] ); $target_url = ''; if ( 0 < $instance['post'] || 0 < $instance['page'] ) { // target. $target_id = (int) $instance['post']; // target. if ( ! ( 0 < $instance['post'] ) ) { $target_id = (int) $instance['page']; // obsolete target. } $target_url = get_the_permalink( $target_id ); if ( empty( $title ) ) { $title = get_the_title( $target_id ); } } elseif ( empty( $title ) ) { $title = esc_html__( 'A-Z Listing', 'a-z-listing' ); } $hide_empty_terms = true === $instance['hide_empty_terms'] ? 'true' : 'false'; $ret = ''; $ret .= $args['before_widget']; $ret .= $args['before_title']; $ret .= $title; $ret .= $args['after_title']; $ret .= do_shortcode( "[a-z-listing alphabet='' display='{$instance['type']}' exclude-posts='' exclude-terms='{$instance['exclude_terms']}' get-all-children='{$instance['all_children']}' group-numbers='' grouping='' hide-empty-terms='{$hide_empty_terms}' numbers='hide' parent-post='{$instance['parent_post']}' parent-term='{$instance['parent_term']}' post-type='{$instance['post_type']}' return='letters' target='{$target_url}' taxonomy='{$instance['taxonomy']}' terms='{$instance['terms']}' ]" ); $ret .= $args['after_widget']; return $ret; }
Changelog
Version | Description |
---|---|
0.8.0 | Introduced. |