Plugin Directory

Changeset 2003543


Ignore:
Timestamp:
12/29/2018 06:22:40 PM (7 years ago)
Author:
diddledan
Message:

version 2.1.0

Location:
a-z-listing
Files:
60 added
23 edited

Legend:

Unmodified
Added
Removed
  • a-z-listing/trunk/Gruntfile.js

    r1939419 r2003543  
    9494            dist: {
    9595                files: {
    96                     'css/a-z-listing-default.css': 'css/a-z-listing-default.scss'
     96                    'css/a-z-listing-default.css': 'css/a-z-listing-default.scss',
     97                    'css/a-z-listing-customize.css': 'css/a-z-listing-customize.scss'
    9798                }
    9899            }
  • a-z-listing/trunk/README.md

    r1942709 r2003543  
    66**Requires at least:** 4.6 
    77**Requires PHP:** 5.6 
    8 **Tested up to:** 4.9 
    9 **Stable tag:** 2.0.5 
     8**Tested up to:** 5.0 
     9**Stable tag:** 2.1.0 
    1010**License:** GPLv2 or later 
    1111**License URI:** http://www.gnu.org/licenses/gpl-2.0.html 
     
    230230### How do I show posts of a different post-type (not pages) or multiple post-types (e.g. posts AND pages) ###
    231231
    232 This can be achieved using the shortcode or PHP.
     232This can be achieved using the shortcode or PHP. In these examples the generic phrase `post-type-slug` is used to describe the concept. The default post types provided by WordPress are called "Posts" and "Pages". Their slugs are `post` and `page` respectively. You need to use these names in place of the examples (i.e. `your-post-type-slug`, `type1-slug`, and `type1-slug`).
    233233
    234234#### Shortcode method ####
     
    268268```
    269269
    270 The argument to `the_a_z_listing()` is an [array](http://php.net/manual/en/language.types.array.php) and takes the same parameters as [WP_Query](https://codex.wordpress.org/Class_Reference/WP_Query)
     270The argument to `the_a_z_listing()` is an [array](https://secure.php.net/manual/en/language.types.array.php) and takes the same parameters as [WP_Query](https://codex.wordpress.org/Class_Reference/WP_Query)
    271271
    272272The code above needs to be within a php block which is denoted by the `<?php` and `?>` pair. Depending on your theme, you might not need the opening and closing php tags shown in the above snippet; if that is the case, you are free to omit them in your code.
     
    274274### How do I show posts from a specific category only ###
    275275
    276 This can be achieved using the shortcode or PHP.
     276This can be achieved using the shortcode or PHP. In these examples the generic phrase `taxonomy` and `term` are used to describe the concept. The default taxonomies provided by WordPress are called "Categories" and "Tags". Their slugs are `category` and `post_tag` respectively. Each Category and Tag are then known as "terms". You need to use the slug for each individual category or tag in place of the example slugs (i.e. `term-slug`, `term1-slug`, and `term1-slug`).
    277277
    278278#### Shortcode method ####
     
    304304```
    305305
    306 Any number of terms may be added to the `terms` [array](http://php.net/manual/en/language.types.array.php), including one or none.
    307 
    308 The argument to `the_a_z_listing()` is an [array](http://php.net/manual/en/language.types.array.php) and takes the same parameters as [WP_Query](https://codex.wordpress.org/Class_Reference/WP_Query)
     306Any number of terms may be added to the `terms` [array](https://secure.php.net/manual/en/language.types.array.php), including one or none.
     307
     308The argument to `the_a_z_listing()` is an [array](https://secure.php.net/manual/en/language.types.array.php) and takes the same parameters as [WP_Query](https://codex.wordpress.org/Class_Reference/WP_Query)
    309309
    310310The code above needs to be within a php block which is denoted by the `<?php` and `?>` pair. Depending on your theme, you might not need the opening and closing php tags shown in the above snippet; if that is the case, you are free to omit them in your code.
     
    312312### How do I show terms from a taxonomy instead of posts ###
    313313
    314 This can be achieved using the shortcode or PHP.
     314This can be achieved using the shortcode or PHP. In these examples the generic phrase `taxonomy` and `term` are used to describe the concept. The default taxonomies provided by WordPress are called "Categories" and "Tags". Their slugs are `category` and `post_tag` respectively. You need to use the slug for the taxonomy in place of the example slugs (i.e. `taxonomy-slug`).
    315315
    316316#### Shortcode method ####
     
    332332```
    333333
    334 The argument to `the_a_z_listing()` is a [string](http://php.net/manual/en/language.types.string.php) and contains the slug of a single taxonomy, e.g. `category` or `post_tag`.
     334The argument to `the_a_z_listing()` is a [string](https://secure.php.net/manual/en/language.types.string.php) and contains the slug of a single taxonomy, e.g. `category` or `post_tag`.
    335335
    336336The code above needs to be within a php block which is denoted by the `<?php` and `?>` pair. Depending on your theme, you might not need the opening and closing php tags shown in the above snippet; if that is the case, you are free to omit them in your code.
     
    356356```php
    357357<?php
    358 add_action( 'wp', 'a_z_listing_force_enable_styles', 99 );
     358add_action( 'init', 'a_z_listing_force_enable_styles', 99 );
    359359?>
    360360```
     
    368368```php
    369369<?php
    370 add_action( 'wp', 'your_override_wrapper_function', 99 );
     370add_action( 'init', 'your_override_wrapper_function', 99 );
    371371function your_override_wrapper_function() {
    372372    if ( ! is_page( 'your-a-z-listing-page-slug-or-ID' ) ) { // ID is numeric, slug is a string.
     
    415415## Changelog ##
    416416
     417### 2.1.0 ###
     418
     419#### Bug Fixes: ####
     420
     421* Fix widget configuration autocomplete fields for target post and parent post in the theme customizer
     422* Fix taxonomy-term-filtered listings displaying all posts (e.g. shortcodes of the form `[a-z-listing taxonomy="category" terms="term"])
     423* Fix `get_the_item_object()` to work with old-style overridden indices
     424* Fix `get_the_item_object()` to correctly extract the item ID and load the correct item
     425* Improve javascript on the widget configuration
     426* Clarified the examples with explanations about "post types", "taxonomies", and "terms" to explain what each of these mean.
     427
     428#### New Features: ####
     429
     430* Add parent-page attribute to the shortcode
     431* Add simpler and safer filter for overriding the index letter for an item
     432* Add simpler and safer filter for overriding the title for an item
     433* Add new function for fetching meta data in a template: `$a_z_listing->get_item_meta()`
     434* Allow exclude-terms to be used with display="posts"
     435* Moved template loading function outside of the `A_Z_Query` class to prevent accidental access to the plugin internal structure
     436
    417437### 2.0.6 ###
    418438
    419 * *Personal Note:* Sorry to everyone who upgraded to 2.0.0 thru to 2.0.5 about yet another update. I have failed you all by shipping faulty versions to you, and I'm sorry, especially so that you've had to endure so many updates the past few days.
    420439* Fix widget target post support
    421440* Fix filtering posts by multiple taxonomy terms
     
    425444* Fix javascript error on widgets screen
    426445
    427 ##### 2.0.0 also introduced the following changes: #####
     446### 2.0.0 ###
    428447
    429448* Improved widget configuration.
     
    436455* Fix the stylesheet to better cope with variances in font-size and text length in the alphabet links list and widget.
    437456* Introduce PHP classes for adding numbers and grouping to the alphabet. Allows unhooking from the filters to undo the changes, where previously you could not unhook these modifications once they'd been applied.
    438 * **BREAKING CHANGES:**
    439   * Multi column example:
    440     If you have copied the multi-column example in previous releases to your theme folder then you will need to perform some manual steps.
    441     If you have not edited the file, just delete it and the new template from the plugin will take control and perform the same functionality.
    442     If you have modified the example template then you will need to compare with the file in the plugin at `templates/a-z-listing.php` and merge any changes into your template.
    443   * Template customisations:
    444     If you have customised the in-built templates or written your own then you may experience breakage due to the post object not being loaded automatically.
    445     If you require the template to access more than the post title and URL then you will need to add an additional call after `the_item()` to load the full `WP_Post` object into memory.
    446     To load the post object you need to call `$a_z_query->get_the_item_object( 'I understand the issues!' );`.
    447     **The argument must read exactly as written here to confirm that you understand that this might cause slowness or memory usage problems.**
    448     *This step is purposely omitted to save memory and try to improve performance.*
    449 
    450 ### 2.0.0 ###
    451 
    452 * Improved widget configuration.
    453 * New attribute added to the shortcode when `display="posts"`:
    454   * `exclude-posts`: remove specific posts from the list
    455 * New attributes added to the shortcode when `display="terms"`:
    456   * `exclude-terms`: sets the terms to exclude from display
    457   * `parent-term`: set the parent that all displayed terms must be organised under
    458   * `hide-empty-terms`: hide terms that have no posts associated
    459 * Fix the stylesheet to better cope with variances in font-size and text length in the alphabet links list and widget.
    460 * Introduce PHP classes for adding numbers and grouping to the alphabet. Allows unhooking from the filters to undo the changes, where previously you could not unhook these modifications once they'd been applied.
    461 * **BREAKING CHANGES:**
    462   * Multi column example:
    463     If you have copied the multi-column example in previous releases to your theme folder then you will need to perform some manual steps.
    464     If you have not edited the file, just delete it and the new template from the plugin will take control and perform the same functionality.
    465     If you have modified the example template then you will need to compare with the file in the plugin at `templates/a-z-listing.php` and merge any changes into your template.
    466   * Template customisations:
    467     If you have customised the in-built templates or written your own then you may experience breakage due to the post object not being loaded automatically.
    468     If you require the template to access more than the post title and URL then you will need to add an additional call after `the_item()` to load the full `WP_Post` object into memory.
    469     To load the post object you need to call `$a_z_query->get_the_item_object( 'I understand the issues!' );`.
    470     **The argument must read exactly as written here to confirm that you understand that this might cause slowness or memory usage problems.**
    471     *This step is purposely omitted to save memory and try to improve performance.*
    472 
    473 ### 1.9.2 ###
    474 
    475 Bugfix:
    476 
    477 * Fix using multiple terms in the shortcode only displays results for the first term
    478 ### 1.9.1 ###
    479 
    480 Feature Request:
    481 Add CSS classes to letters indicating presence of posts or not:
    482 
    483 * `has-posts` allows styling of letters that have posts visible in the listing
    484 * `no-posts` allows styling of letters that do not have any posts visible in the listing
    485 
    486 You can use these classes to hide letters that have no posts by including the following CSS rule:
    487 `.az-letters ul.az-links li.no-posts {
    488     display: none;
    489 }`
    490 
    491 ### 1.9.0 ###
    492 
    493 * Fix multi-column example template
    494 * Update multi-column styles to include display:grid support
    495 * Add back-to-top link
    496 * Add server system requirements to readme
    497 * Add PHP section to readme including link to API Reference
     457
     458#### BREAKING CHANGES: ####
     459
     460##### Multi column example: #####
     461
     462* If you have copied the multi-column example in previous releases to your theme folder then you will need to perform some manual steps.
     463* If you have not edited the file, just delete it and the new template from the plugin will take control and perform the same functionality.
     464* If you have modified the example template then you will need to compare with the file in the plugin at `templates/a-z-listing.php` and merge any changes into your template.
     465
     466##### Template customisations: #####
     467
     468* If you have customised the in-built templates or written your own then you may experience breakage due to the post object not being loaded automatically.
     469* If you require the template to access more than the post title and URL then you will need to add an additional call after `the_item()` to load the full `WP_Post` object into memory.
     470* To load the post object you need to call `$a_z_query->get_the_item_object( 'I understand the issues!' );`.
     471  __The argument must read exactly as written here to confirm that you understand that this might cause slowness or memory usage problems.__
     472  _This step is purposely omitted to save memory and try to improve performance._
    498473
    499474### Previous ###
  • a-z-listing/trunk/a-z-listing.php

    r1942709 r2003543  
    88 * Text Domain:     a-z-listing
    99 * Domain Path:     /languages
    10  * Version:         2.0.6
     10 * Version:         2.1.0
    1111 *
    1212 * @package         A_Z_Listing
  • a-z-listing/trunk/changelog.md

    r1942709 r2003543  
    11# Full Changelog #
    22
    3 ### 2.0.6 ###
    4 
    5 * *Personal Note:* Sorry to everyone who upgraded to 2.0.0 thru to 2.0.4 about yet another update. I have failed you all by shipping faulty versions to you, and I'm sorry, especially so that you've had to endure so many updates the past few days.
     3## 2.1.0 ##
     4
     5### Bug Fixes ###
     6
     7* Fix widget configuration autocomplete fields for target post and parent post in the theme customizer
     8* Fix taxonomy-term-filtered listings displaying all posts (e.g. shortcodes of the form `[a-z-listing taxonomy="category" terms="term"])
     9* Fix `get_the_item_object()` to work with old-style overridden indices
     10* Fix `get_the_item_object()` to correctly extract the item ID and load the correct item
     11* Improve javascript on the widget configuration
     12* Clarified the examples with explanations about "post types", "taxonomies", and "terms" to explain what each of these mean.
     13
     14### New Features ###
     15
     16* Add parent-page attribute to the shortcode
     17* Add simpler and safer filter for overriding the index letter for an item
     18* Add simpler and safer filter for overriding the title for an item
     19* Add new function for fetching meta data in a template: `$a_z_listing->get_item_meta()`
     20* Allow exclude-terms to be used with display="posts"
     21* Moved template loading function outside of the `A_Z_Query` class to prevent accidental access to the plugin internal structure
     22
     23## 2.0.6 ##
     24
     25* *Personal Note:* Sorry to everyone who upgraded to 2.0.0 thru to 2.0.5 about yet another update. I have failed you all by shipping faulty versions to you, and I'm sorry, especially so that you've had to endure so many updates the past few days.
    626* Fix widget target post support
    727
    8 ### 2.0.5 ###
     28## 2.0.5 ##
    929
    1030* Fix filtering posts by multiple taxonomy terms
    1131
    12 ### 2.0.4 ###
     32## 2.0.4 ##
    1333
    1434* Fix styling error causing two or more posts to sometimes appear on the same line
    1535
    16 ### 2.0.3 ###
     36## 2.0.3 ##
    1737
    1838* Minor style tweak to fix short listings, and long titles
    1939
    20 ### 2.0.2 ###
     40## 2.0.2 ##
    2141
    2242* Fix broken styling in 2.0.0
    2343
    24 ### 2.0.1 ###
     44## 2.0.1 ##
    2545
    2646* Fix javascript error on widgets screen
    2747
    28 ### 2.0.0 ###
     48## 2.0.0 ##
    2949
    3050* Improved widget configuration.
     
    3757* Fix the stylesheet to better cope with variances in font-size and text length in the alphabet links list and widget.
    3858* Introduce PHP classes for adding numbers and grouping to the alphabet. Allows unhooking from the filters to undo the changes, where previously you could not unhook these modifications once they'd been applied.
    39 * **BREAKING CHANGES:**
    40   * Multi column example:
    41     If you have copied the multi-column example in previous releases to your theme folder then you will need to perform some manual steps.
    42     If you have not edited the file, just delete it and the new template from the plugin will take control and perform the same functionality.
    43     If you have modified the example template then you will need to compare with the file in the plugin at `templates/a-z-listing.php` and merge any changes into your template.
    44   * Template customisations:
    45     If you have customised the in-built templates or written your own then you may experience breakage due to the post object not being loaded automatically.
    46     If you require the template to access more than the post title and URL then you will need to add an additional call after `the_item()` to load the full `WP_Post` object into memory.
    47     To load the post object you need to call `$a_z_query->get_the_item_object( 'I understand the issues!' );`.
    48     **The argument must read exactly as written here to confirm that you understand that this might cause slowness or memory usage problems.**
    49     *This step is purposely omitted to save memory and try to improve performance.*
     59
     60### BREAKING CHANGES ###
     61* Multi column example:
     62  If you have copied the multi-column example in previous releases to your theme folder then you will need to perform some manual steps.
     63  If you have not edited the file, just delete it and the new template from the plugin will take control and perform the same functionality.
     64  If you have modified the example template then you will need to compare with the file in the plugin at `templates/a-z-listing.php` and merge any changes into your template.
     65* Template customisations:
     66  If you have customised the in-built templates or written your own then you may experience breakage due to the post object not being loaded automatically.
     67  If you require the template to access more than the post title and URL then you will need to add an additional call after `the_item()` to load the full `WP_Post` object into memory.
     68  To load the post object you need to call `$a_z_query->get_the_item_object( 'I understand the issues!' );`.
     69  **The argument must read exactly as written here to confirm that you understand that this might cause slowness or memory usage problems.**
     70  *This step is purposely omitted to save memory and try to improve performance.*
    5071
    5172## 1.9.1 ##
  • a-z-listing/trunk/classes/class-a-z-listing-grouping.php

    r1939419 r2003543  
    3131     */
    3232    private $headings;
     33
     34    /**
     35     * Perform a multibyte substring operation if mbstring is loaded, else use substr.
     36     *
     37     * @since 2.1.0
     38     * @param string $string The string to extract the substring from.
     39     * @param int    $start Start the substring at this character number (starts at zero).
     40     * @param int    $length Number of characters to include in the substring.
     41     */
     42    public static function maybe_mb_substr( $string, $start, $length ) {
     43        if ( extension_loaded( 'mbstring' ) ) {
     44            return mb_substr( $string, $start, $length, 'UTF-8' );
     45        }
     46        return substr( $string, $start, $length );
     47    }
    3348
    3449    /**
     
    6681    public function alphabet_filter( $alphabet ) {
    6782        $headings = array();
    68         $letters  = mb_split( ',', $alphabet );
     83        $letters  = explode( ',', $alphabet );
    6984        $letters  = array_map( 'trim', $letters );
    7085
     
    8297                    $carry[ $j ] = $carry[ $j ] . $letter;
    8398                }
    84                 $headings[ $j ][] = mb_substr( $letter, 0, 1 );
     99                $headings[ $j ][] = A_Z_Listing_Grouping::maybe_mb_substr( $letter, 0, 1 );
    85100
    86101                if ( $i + 1 === $grouping ) {
  • a-z-listing/trunk/classes/class-a-z-listing-indices.php

    r1939419 r2003543  
    2222
    2323    /**
     24     * Get the first letter of a title for use as the Index letter
     25     *
     26     * @since 2.1.0
     27     * @param string $title The title of the item to extract the index letter from.
     28     */
     29    public static function get_index_letter( $title ) {
     30        if ( extension_loaded( 'mbstring' ) ) {
     31            return mb_substr( $title, 0, 1, 'UTF-8' );
     32        }
     33        return substr( $title, 0, 1 );
     34    }
     35
     36    /**
    2437     * Find and return the index letter for a post
    2538     *
     
    4154        }
    4255
    43         $index = mb_substr( $title, 0, 1, 'UTF-8' );
     56        /**
     57         * Modify the title for this item before indexing
     58         *
     59         * @since 2.1.0
     60         * @param string          $title The current title
     61         * @param WP_Term|WP_Post $item The item
     62         * @param string          $item_type The type of the item. Either 'posts' or 'terms'.
     63         */
     64        $title = apply_filters( 'a-z-listing-pre-index-item-title', $title, $item, $type );
    4465
    45         $indices[ $index ][] = array(
    46             'title' => $title,
    47             'item'  => ( 'terms' === $type ) ? "term:{$item_id}" : "post:{$item_id}",
    48             'link'  => $permalink,
    49         );
     66        /**
     67         * Modify the title for this item before indexing
     68         *
     69         * @since 2.1.0
     70         * @param string          $title The current title
     71         * @param WP_Term|WP_Post $item The item
     72         * @param string          $item_type The type of the item. Either 'posts' or 'terms'.
     73         */
     74        $title = apply_filters( 'a_z_listing_pre_index_item_title', $title, $item, $type );
     75
     76        $index = self::get_index_letter( $title );
     77
     78        /**
     79         * Modify the indice(s) to group this item under
     80         *
     81         * @since 2.1.0
     82         * @param array           $indices The current indices
     83         * @param WP_Term|WP_Post $item The item
     84         * @param string          $item_type The type of the item. Either 'posts' or 'terms'.
     85         */
     86        $index_letters = apply_filters( 'a-z-listing-item-index-letter', array( $index ), $item, $type );
     87
     88        /**
     89         * Modify the indice(s) to group this item under
     90         *
     91         * @since 2.1.0
     92         * @param array           $indices The current indices
     93         * @param WP_Term|WP_Post $item The item
     94         * @param string          $item_type The type of the item. Either 'posts' or 'terms'.
     95         */
     96        $index_letters = apply_filters( 'a_z_listing_item_index_letter', $index_letters, $item, $type );
     97
     98        foreach ( $index_letters as $letter ) {
     99            $indices[ $letter ][] = array(
     100                'title' => $title,
     101                'item'  => ( 'terms' === $type ) ? "term:{$item_id}" : "post:{$item_id}",
     102                'link'  => $permalink,
     103            );
     104        }
    50105
    51106        if ( 'terms' === $type ) {
     
    53108             * Modify the indice(s) to group this term under
    54109             *
    55              * @deprecated Use a_z_listing_item_indices
    56              * @see a_z_listing_item_indices
     110             * @deprecated Use a_z_listing_item_index_letter and/or a_z_listing_item_title
     111             * @see a_z_listing_item_index_letter, a_z_listing_item_title
    57112             */
    58             $indices = apply_filters_deprecated( 'a_z_listing_term_indices', array( $indices, $item ), '1.0.0', 'a_z_listing_item_indices' );
     113            $indices = apply_filters_deprecated( 'a_z_listing_term_indices', array( $indices, $item ), '1.0.0', 'a_z_listing_item_index_letter' );
    59114        } else {
    60115            /**
    61116             * Modify the indice(s) to group this post under
    62117             *
    63              * @deprecated Use a_z_listing_item_indices
    64              * @see a_z_listing_item_indices
     118             * @deprecated Use a_z_listing_item_index_letter and/or a_z_listing_item_title
     119             * @see a_z_listing_item_index_letter, a_z_listing_item_title
    65120             */
    66             $indices = apply_filters_deprecated( 'a_z_listing_post_indices', array( $indices, $item ), '1.5.0', 'a_z_listing_item_indices' );
     121            $indices = apply_filters_deprecated( 'a_z_listing_post_indices', array( $indices, $item ), '1.5.0', 'a_z_listing_item_index_letter' );
    67122        } // End if.
    68123
     
    70125         * Modify the indice(s) to group this item under
    71126         *
     127         * @since 1.7.0
     128         * @since 2.1.0 Deprecated
     129         * @deprecated Use a_z_listing_item_index_letter and/or a_z_listing_item_title
     130         * @see a_z_listing_item_index_letter, a_z_listing_item_title
    72131         * @param array           $indices The current indices
    73132         * @param WP_Term|WP_Post $item The item
    74133         * @param string          $item_type The type of the item. Either 'posts' or 'terms'.
    75134         */
    76         $indices = apply_filters( 'a_z_listing_item_indices', $indices, $item, $type );
     135        $indices = apply_filters_deprecated( 'a_z_listing_item_indices', array( $indices, $item, $type ), '2.1.0', 'a_z_listing_item_index_letter' );
    77136
    78137        /**
     
    80139         *
    81140         * @since 1.7.1
     141         * @since 2.1.0 Deprecated
     142         * @deprecated Use a_z_listing_item_index_letter and/or a_z_listing_item_title
     143         * @see a_z_listing_item_index_letter, a_z_listing_item_title
    82144         * @param array           $indices The current indices
    83145         * @param WP_Term|WP_Post $item The item
    84146         * @param string          $item_type The type of the item. Either 'posts' or 'terms'.
    85147         */
    86         $indices = apply_filters( 'a-z-listing-item-indices', $indices, $item, $type );
     148        $indices = apply_filters_deprecated( 'a-z-listing-item-indices', array( $indices, $item, $type ), '2.1.0', 'a_z_listing_item_index_letter' );
    87149
    88150        if ( AZLISTINGLOG > 2 ) {
  • a-z-listing/trunk/classes/class-a-z-listing-numbers.php

    r1939419 r2003543  
    1717class A_Z_Listing_Numbers {
    1818    /**
     19     * Where to place the numbers.
     20     *
     21     * @var string
     22     */
     23    protected $position = 'hide';
     24
     25    /**
     26     * Whether to group the numbers in a single entry.
     27     *
     28     * @var boolean
     29     */
     30    protected $group = false;
     31
     32    /**
    1933     * Add filters to append or prepend numbers to the alphabet with optional grouping
    2034     *
     
    2337     * @param bool   $group Whether to group the numbers into a single heading or individually.
    2438     */
    25     public function __construct( $position = 'after', $group = false ) {
    26         $this->position = $position;
    27         $this->group    = $group;
    28 
    29         add_filter( 'a-z-listing-alphabet', array( $this, 'add_to_alphabet' ) );
    30         add_filter( 'the-a-z-letter-title', array( $this, 'title' ) );
     39    public function __construct( $position = 'hide', $group = false ) {
     40        if ( 'before' === $position || 'after' === $position ) {
     41            $this->position = $position;
     42            $this->group    = a_z_listing_is_truthy( $group );
     43            add_filter( 'a-z-listing-alphabet', array( $this, 'add_to_alphabet' ) );
     44            add_filter( 'the-a-z-letter-title', array( $this, 'title' ) );
     45        }
    3146    }
    3247
     
    4964     */
    5065    public function add_to_alphabet( $alphabet ) {
    51         $numbers = '0,1,2,3,4,5,6,7,8,9';
     66        if ( 'hide' === $this->position ) {
     67            return $alphabet;
     68        }
     69
    5270        if ( true === $this->group ) {
    5371            $numbers = '0123456789';
     72        } else {
     73            $numbers = '0,1,2,3,4,5,6,7,8,9';
    5474        }
    5575
  • a-z-listing/trunk/classes/class-a-z-listing.php

    r1941011 r2003543  
    203203                $query = (array) $query;
    204204
    205                 if ( ( ! isset( $query['post_type'] ) || 'page' === $query['post_type'] ) &&
    206                 isset( $post ) && 'page' === $post->post_type &&
    207                 ! ( isset( $query['child_of'] ) || isset( $query['parent'] ) ) ) {
    208                     $section       = self::get_section();
    209                     $q['child_of'] = $section->ID;
     205                if ( isset( $query['post_type'] ) ) {
     206                    if ( is_array( $query['post_type'] ) && count( $query['post_type'] ) === 1 ) {
     207                        $query['post_type'] = array_shift( $query['post_type'] );
     208                    }
    210209                }
    211210
     211                if ( ! isset( $query['post_parent'] ) && ! isset( $query['child_of'] ) ) {
     212                    if ( isset( $query['post_type'] ) && isset( $post ) ) {
     213                        if ( 'page' === $query['post_type'] && 'page' === $post->post_type ) {
     214                            $section           = self::get_section();
     215                            $query['child_of'] = $section->ID;
     216                        }
     217                    }
     218                }
     219
    212220                $query = wp_parse_args(
    213                     (array) $query,
     221                    $query,
    214222                    array(
    215223                        'post_type'   => 'page',
     
    225233
    226234            if ( $query instanceof WP_Query ) {
    227                 $post_type = $query->post_type;
    228             } else {
    229                 $post_type = $query['post_type'];
    230             }
    231 
    232             if ( 'page' === $post_type ) {
    233                 $items       = get_pages( $query );
     235                $items       = $query->posts;
    234236                $this->query = $query;
    235237            } else {
    236                 $wq          = new WP_Query( $query );
    237                 $items       = $wq->posts;
    238                 $this->query = $wq;
     238                if ( isset( $query['child_of'] ) ) {
     239                    $items       = get_pages( $query );
     240                    $this->query = $query;
     241                } else {
     242                    $wq          = new WP_Query( $query );
     243                    $items       = $wq->posts;
     244                    $this->query = $wq;
     245                }
    239246            }
    240247
     
    297304     */
    298305    public static function mb_string_to_array( $string ) {
    299         return array_map(
    300             function ( $i ) use ( $string ) {
    301                 return mb_substr( $string, $i, 1 );
    302             },
    303             range( 0, mb_strlen( $string ) - 1 )
    304         );
     306        if ( extension_loaded( 'mbstring' ) ) {
     307            return array_map(
     308                function ( $i ) use ( $string ) {
     309                    return mb_substr( $string, $i, 1 );
     310                },
     311                range( 0, mb_strlen( $string ) - 1 )
     312            );
     313        }
     314        return explode( '', $string );
    305315    }
    306316
     
    348358        $others = apply_filters( 'a-z-listing-non-alpha-char', $others );
    349359
    350         $alphabet_groups = mb_split( ',', $alphabet );
     360        $alphabet_groups = explode( ',', $alphabet );
    351361        $letters         = array_reduce(
    352362            $alphabet_groups,
     
    524534                            $index = $this->alphabet[ $index ];
    525535                        } else {
    526                             $index = '_';
     536                            $index = $this->unknown_letters;
    527537                        }
    528538
     
    535545            }
    536546
    537             if ( ! empty( $index[ $this->unknown_letters ] ) ) {
     547            if ( array_key_exists( $this->unknown_letters, $indexed_items ) && ! empty( $indexed_items[ $this->unknown_letters ] ) ) {
    538548                $this->alphabet_chars[] = $this->unknown_letters;
    539549            }
     
    581591
    582592    /**
    583      * Return the letter links HTML
     593     * Retrieve the letter links HTML
    584594     *
    585595     * @since 1.0.0
     
    644654
    645655    /**
    646      * Load and execute a theme template
    647      *
    648      * @since 1.0.0
    649      * @param string $template_file The path of the template to execute.
    650      */
    651     protected function do_template( $template_file ) {
    652         $a_z_query = $this;
    653         if ( ! empty( $template_file ) ) {
    654             include $template_file;
    655         }
    656     }
    657 
    658     /**
    659656     * Print the index list HTML created by a theme template
    660657     *
     
    673670        $template = locate_template( array( 'a-z-listing-' . $section . '.php', 'a-z-listing.php' ) );
    674671        if ( $template ) {
    675             $this->do_template( $template );
     672            a_z_listing_do_template( $this, $template );
    676673        } else {
    677             $this->do_template( dirname( __FILE__ ) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR . 'a-z-listing.php' );
     674            a_z_listing_do_template( $this, dirname( __FILE__ ) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR . 'a-z-listing.php' );
    678675        }
    679676        wp_reset_postdata();
     
    681678
    682679    /**
    683      * Return the index list HTML created by a theme template
     680     * Retrieve the index list HTML created by a theme template
    684681     *
    685682     * @since 0.7
     
    778775
    779776    /**
    780      * Get the item object for the current post
     777     * Retrieve the item object for the current post
    781778     *
    782779     * @since 2.0.0
     
    787784     */
    788785    public function get_the_item_object( $force = '' ) {
     786        global $post;
    789787        if ( 'I understand the issues!' === $force ) {
    790             $item = explode( ':', $this->current_item['item'], 1 );
    791 
    792             if ( isset( $item[1] ) ) {
    793                 if ( 'terms' === $this->type ) {
    794                     return get_term( $item[1] );
     788            $current_item = $this->current_item['item'];
     789            if ( is_string( $current_item ) ) {
     790                $item = explode( ':', $current_item, 2 );
     791
     792                if ( isset( $item[1] ) ) {
     793                    if ( 'terms' === $this->type ) {
     794                        return get_term( $item[1] );
     795                    }
     796
     797                    $post = get_post( $item[1] );
     798                    setup_postdata( $post );
     799
     800                    return $post;
    795801                }
    796 
    797                 global $post;
    798                 $post = get_post( $item[1] );
     802            }
     803
     804            if ( is_a( $current_item, 'WP_Post' ) ) {
     805                $post = $current_item;
    799806                setup_postdata( $post );
    800807
    801808                return $post;
    802809            }
     810
     811            return $current_item;
    803812        }
    804813
     
    807816
    808817    /**
    809      * Returns the number of letters in the loaded alphabet
     818     * Retrieve meta field for an item.
     819     *
     820     * @since 2.1.0
     821     * @param string $key The meta key to retrieve. By default returns data for all keys.
     822     * @param bool   $single Whether to return a single value.
     823     * @return mixed Will be an array if $single is false. Will be value of meta data field if $single is true.
     824     */
     825    function get_item_meta( $key = '', $single = false ) {
     826        if ( is_string( $this->current_item['item'] ) ) {
     827            $item = explode( ':', $this->current_item['item'], 2 );
     828
     829            if ( 'term' === $type[0] ) {
     830                return get_term_meta( $item[1], $key, $single );
     831            }
     832
     833            return get_post_meta( $item[1], $key, $single );
     834        }
     835
     836        if ( is_a( $this->current_item['item'], 'WP_Term' ) ) {
     837            return get_term_meta( $this->current_item['item']->term_id, $key, $single );
     838        }
     839
     840        return get_post_meta( $this->current_item['item']->ID, $key, $single );
     841    }
     842
     843    /**
     844     * Retrieve the number of letters in the loaded alphabet
    810845     *
    811846     * @since 1.0.0
     
    817852
    818853    /**
    819      * Return the number of posts within the current letter
     854     * Retrieve the number of posts within the current letter
    820855     *
    821856     * @since 0.7
     
    829864
    830865    /**
    831      * Return the number of posts within the current letter
     866     * Retrieve the number of posts within the current letter
    832867     *
    833868     * @since 0.7
     
    850885
    851886    /**
    852      * Return the number of posts within the current letter
     887     * Retrieve the number of posts within the current letter
    853888     *
    854889     * @since 1.0.0
     
    869904
    870905    /**
    871      * Return the ID of the current letter. This is not escaped!
     906     * Retrieve the ID of the current letter. This is not escaped!
    872907     *
    873908     * @since 0.7
     
    889924
    890925    /**
    891      * Return the title of the current letter. For example, upper-case A or B or C etc. This is not escaped!
     926     * Retrieve the title of the current letter. For example, upper-case A or B or C etc. This is not escaped!
    892927     *
    893928     * @since 0.7
     
    936971
    937972    /**
    938      * Return the title of the current post. This is not escaped!
     973     * Retrieve the title of the current post. This is not escaped!
    939974     *
    940975     * @since 1.0.0
     
    943978    public function get_the_title() {
    944979        $title = $this->current_item['title'];
    945         $item  = $this->current_item['item'];
    946         if ( $item instanceof WP_Post ) {
    947             $title = apply_filters( 'the_title', $title, $item->ID );
    948         } elseif ( $item instanceof WP_Term ) {
    949             $title = apply_filters( 'term_name', $title, $item );
    950         }
     980        if ( is_string( $this->current_item['item'] ) ) {
     981            $item = explode( ':', $this->current_item['item'], 2 );
     982        } else {
     983            $item = $this->current_item['item'];
     984        }
     985
     986        if ( is_array( $item ) ) {
     987            if ( 'post' === $item[0] ) {
     988                return apply_filters( 'the_title', $title, $item[1] );
     989            }
     990            if ( 'term' === $item[0] ) {
     991                return apply_filters( 'term_name', $title, $item[1] );
     992            }
     993        } else {
     994            if ( is_a( $item, 'WP_Post' ) ) {
     995                return apply_filters( 'the_title', $title, $item->ID );
     996            }
     997            if ( is_a( $item, 'WP_Term' ) ) {
     998                return apply_filters( 'term_name', $title, $item->term_id );
     999            }
     1000        }
     1001
    9511002        return $title;
    9521003    }
     
    9621013
    9631014    /**
    964      * Return the permalink of the current post. This is not escaped!
     1015     * Retrieve the permalink of the current post. This is not escaped!
    9651016     *
    9661017     * @since 1.0.0
     
    9701021        return $this->current_item['link'];
    9711022    }
     1023}
     1024
     1025/**
     1026 * Load and execute a theme template
     1027 *
     1028 * @since 2.1.0
     1029 * @param A_Z_Query $a_z_query The Query object.
     1030 * @param string    $template_file The path of the template to execute.
     1031 */
     1032function a_z_listing_do_template( $a_z_query, $template_file ) {
     1033    require $template_file;
    9721034}
    9731035
  • a-z-listing/trunk/css/a-z-listing-default.css

    r1940891 r2003543  
    1616    height: 2em;
    1717    box-sizing: border-box;
    18     margin: 0.15em;
     18    margin: 0 0 0.6em;
    1919    border: 2px solid #e5e5e5;
    2020    background: #f5f5f5;
     
    4646    box-sizing: border-box;
    4747    column-gap: 0.6em;
    48     column-width: 10em;
     48    column-width: 15em;
    4949    line-height: 1.6em; }
    5050    .letter-section ul.columns li {
     
    5252    .letter-section ul.columns.max-0-columns, .letter-section ul.columns.max-1-columns {
    5353      column-count: 1;
    54       max-width: 10.6em; }
     54      max-width: 15.6em; }
    5555    .letter-section ul.columns.max-2-columns {
    5656      column-count: 2;
    57       max-width: 20.6em; }
     57      max-width: 30.6em; }
    5858    .letter-section ul.columns.max-3-columns {
    5959      column-count: 3;
    60       max-width: 31.2em; }
     60      max-width: 46.2em; }
    6161    .letter-section ul.columns.max-4-columns {
    6262      column-count: 4;
    63       max-width: 41.8em; }
     63      max-width: 61.8em; }
    6464    .letter-section ul.columns.max-5-columns {
    6565      column-count: 5;
    66       max-width: 52.4em; }
     66      max-width: 77.4em; }
    6767    .letter-section ul.columns.max-6-columns {
    6868      column-count: 6;
    69       max-width: 63em; }
     69      max-width: 93em; }
    7070    .letter-section ul.columns.max-7-columns {
    7171      column-count: 7;
    72       max-width: 73.6em; }
     72      max-width: 108.6em; }
    7373    .letter-section ul.columns.max-8-columns {
    7474      column-count: 8;
    75       max-width: 84.2em; }
     75      max-width: 124.2em; }
    7676    .letter-section ul.columns.max-9-columns {
    7777      column-count: 9;
    78       max-width: 94.8em; }
     78      max-width: 139.8em; }
    7979    .letter-section ul.columns.max-10-columns {
    8080      column-count: 10;
    81       max-width: 105.4em; }
     81      max-width: 155.4em; }
    8282    .letter-section ul.columns.max-11-columns {
    8383      column-count: 11;
    84       max-width: 116em; }
     84      max-width: 171em; }
    8585    .letter-section ul.columns.max-12-columns {
    8686      column-count: 12;
    87       max-width: 126.6em; }
     87      max-width: 186.6em; }
    8888    .letter-section ul.columns.max-13-columns {
    8989      column-count: 13;
    90       max-width: 137.2em; }
     90      max-width: 202.2em; }
    9191    .letter-section ul.columns.max-14-columns {
    9292      column-count: 14;
    93       max-width: 147.8em; }
     93      max-width: 217.8em; }
    9494    .letter-section ul.columns.max-15-columns {
    9595      column-count: 15;
    96       max-width: 158.4em; }
     96      max-width: 233.4em; }
    9797  .letter-section div.back-to-top {
    9898    width: 100%;
  • a-z-listing/trunk/css/a-z-listing-default.css.map

    r1940891 r2003543  
    77    ],
    88    "names": [],
    9     "mappings": "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"
     9    "mappings": "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"
    1010}
  • a-z-listing/trunk/css/a-z-listing-default.scss

    r1940891 r2003543  
    1717            height: 2em;
    1818            box-sizing: border-box;
    19             margin: 0.15em;
     19            margin: 0 0 0.6em;
    2020            border: 2px solid #e5e5e5;
    2121            background: #f5f5f5;
     
    5151        box-sizing: border-box;
    5252        column-gap: 0.6em;
    53         column-width: 10em;
     53        column-width: 15em;
    5454        line-height: 1.6em;
    5555        li {
     
    5959        &.max-1-columns {
    6060            column-count: 1;
    61             max-width: 10.6em;
     61            max-width: 15.6em;
    6262        }
    6363        @for $column from 2 to 16 {
    6464            &.max-#{$column}-columns {
    6565                column-count: $column;
    66                 max-width: ($column * 10em) + (($column - 1) * 0.6em);
     66                max-width: ($column * 15em) + (($column - 1) * 0.6em);
    6767            }
    6868        }
  • a-z-listing/trunk/functions/enqueues.php

    r1939516 r2003543  
    1717 */
    1818function a_z_listing_do_enqueue() {
    19     wp_register_style( 'a-z-listing', plugins_url( 'css/a-z-listing-default.css', dirname( __FILE__ ) ), array( 'dashicons' ) );
    20     wp_register_script( 'a-z-listing-tabs', plugins_url( 'js/a-z-listing-tabs.js', dirname( __FILE__ ) ), array( 'jquery', 'jquery-ui-tabs' ) );
     19    wp_register_style(
     20        'a-z-listing',
     21        plugins_url( 'css/a-z-listing-default.css', dirname( __FILE__ ) ),
     22        array( 'dashicons' )
     23    );
     24
     25    wp_register_style(
     26        'a-z-listing-admin',
     27        plugins_url( 'css/a-z-listing-customize.css', dirname( __FILE__ ) ),
     28        array()
     29    );
     30
     31    wp_register_script(
     32        'a-z-listing-tabs',
     33        plugins_url( 'scripts/a-z-listing-tabs.js', dirname( __FILE__ ) ),
     34        array(
     35            'jquery',
     36            'jquery-ui-tabs',
     37        ),
     38        false,
     39        true
     40    );
     41
     42    wp_register_script(
     43        'a-z-listing-widget-admin',
     44        plugins_url( 'scripts/a-z-listing-widget-admin.js', dirname( __FILE__ ) ),
     45        array(
     46            'jquery',
     47            'jquery-ui-autocomplete',
     48        ),
     49        false,
     50        true
     51    );
    2152
    2253    $add_styles = get_option( 'a-z-listing-add-styling', true );
     
    4273        add_action( 'wp_enqueue_scripts', 'a_z_listing_enqueue_styles' );
    4374    }
     75
     76    add_action( 'customize_controls_enqueue_scripts', 'a_z_listing_customize_enqueue_styles' );
    4477
    4578    $tabify = get_option( 'a-z-listing-add-tabs', false );
  • a-z-listing/trunk/functions/helpers.php

    r1939419 r2003543  
    1111
    1212/**
    13  * Returns whether the query has any letters left
     13 * Retrieve whether the query has any letters left
    1414 *
    1515 * @since 0.7
     
    2222
    2323/**
    24  * Returns whether the query has any posts left for the current letter
     24 * Whether the query has any posts left for the current letter
    2525 *
    2626 * @since 0.7
     
    3434
    3535/**
    36  * Returns whether the query has any posts left for the current letter
     36 * Whether the query has any posts left for the current letter
    3737 *
    3838 * @since 0.8.0
     
    7777
    7878/**
    79  * Returns the number of posts for the letter
     79 * Retrieve the number of posts for the letter
    8080 *
    8181 * @since 0.7
     
    8989
    9090/**
    91  * Returns the number of posts for the letter
     91 * Retrieve the number of posts for the letter
    9292 *
    9393 * @since 0.7
     
    101101
    102102/**
    103  * Returns the number of posts for the letter
     103 * Retrieve the number of posts for the letter
    104104 *
    105105 * @since 0.7
     
    123123
    124124/**
    125  * Get the number of letters for the query
     125 * Retrieve the number of letters for the query
    126126 *
    127127 * @since 1.0.0
     
    144144
    145145/**
    146  * Get the current letter ID
     146 * Retrieve the current letter ID
    147147 *
    148148 * @since 0.7
     
    165165
    166166/**
    167  * Get the current letter title
     167 * Retrieve the current letter title
    168168 *
    169169 * @since 0.7
     
    186186
    187187/**
    188  * Get the current item title
     188 * Retrieve the current item title
    189189 *
    190190 * @since 0.8.0
     
    207207
    208208/**
    209  * Get the current item permalink
     209 * Retrieve the current item permalink
    210210 *
    211211 * @since 0.8.0
     
    242242
    243243/**
    244  * Returns the A-Z Index page content
     244 * Retrieve the A-Z Index page content
    245245 *
    246246 * @since 0.1
     
    258258
    259259/**
    260  * Returns the index of posts ordered and segmented alphabetically
     260 * Retrieve the index of posts ordered and segmented alphabetically
    261261 *
    262262 * @since 0.8.0
     
    298298
    299299/**
    300  * Returns the A-Z Letter list
     300 * Retrieve the A-Z Letter list
    301301 *
    302302 * @since 0.7
     
    314314
    315315/**
    316  * Returns the A-Z Letter list
     316 * Retrieve the A-Z Letter list
    317317 *
    318318 * @since 0.8.0
     
    326326    return a_z_listing_cache( $query, '', $use_cache )->get_the_letters( $target, $styling );
    327327}
     328
     329/**
     330 * Check value for truthiness
     331 *
     332 * @since 2.1.0
     333 * @param string|int|bool $value The value to check for thruthiness.
     334 * @return bool The truthiness of the value.
     335 */
     336function a_z_listing_is_truthy( $value ) {
     337    switch ( $value ) {
     338        case '1':
     339        case 'yes':
     340        case 'true':
     341        case 1:
     342        case true:
     343            return true;
     344        default:
     345            return false;
     346    }
     347}
  • a-z-listing/trunk/functions/scripts.php

    r1939419 r2003543  
    4343    add_action( 'wp_enqueue_scripts', 'a_z_listing_force_enqueue_tabs' );
    4444}
     45
     46/**
     47 * Enqueue the widget configuration support script
     48 *
     49 * @since 2.1.0
     50 */
     51function a_z_listing_enqueue_widget_admin_script() {
     52    wp_enqueue_script( 'a-z-listing-widget-admin' );
     53}
  • a-z-listing/trunk/functions/shortcode.php

    r1941011 r2003543  
    1616 * @since 1.7.0 Add numbers attribute to append or prepend numerics to the listing.
    1717 * @since 1.8.0 Fix numbers attribute when selecting to display terms. Add grouping to numbers via attribute. Add alphabet override via new attribute.
     18 * @since 2.0.0 Add parent-term and hide-empty parameters.
    1819 * @param  array $attributes Provided by WordPress core. Contains the shortcode attributes.
    1920 * @return string The A-Z Listing HTML.
     
    2425            'alphabet'         => '',
    2526            'display'          => 'posts',
    26             'group-numbers'    => false,
     27            'exclude-posts'    => '',
     28            'exclude-terms'    => '',
     29            'get-all-children' => 'false',
     30            'group-numbers'    => '',
    2731            'grouping'         => '',
     32            'hide-empty-terms' => 'false',
    2833            'numbers'          => 'hide',
     34            'parent-post'      => '',
     35            'parent-term'      => '',
    2936            'post-type'        => 'page',
    30             'exclude-posts'    => '',
     37            'return'           => 'listing',
     38            'target'           => '',
    3139            'taxonomy'         => '',
    3240            'terms'            => '',
    33             'exclude-terms'    => '',
    34             'hide-empty-terms' => false,
    35             'parent-term'      => '',
    36             'return'           => 'listing',
    37             'target'           => '',
    3841        ),
    3942        $attributes,
     
    5356    $grouping      = $attributes['grouping'];
    5457    $group_numbers = false;
     58    if ( ! empty( $attributes['group-numbers'] ) && a_z_listing_is_truthy( $attributes['group-numbers'] ) ) {
     59        $group_numbers = true;
     60    }
     61
    5562    if ( 'numbers' === $grouping ) {
    5663        $group_numbers = true;
     
    5865    } else {
    5966        $grouping = intval( $grouping );
    60         if ( 1 < $grouping ) {
     67        if ( 1 < $grouping && empty( $attributes['group-numbers'] ) ) {
    6168            $group_numbers = true;
    6269        }
    6370    }
    6471
    65     if ( true === $attributes['group-numbers'] ) {
    66         $group_numbers = true;
    67     }
    68 
    6972    $grouping_obj = new A_Z_Listing_Grouping( $grouping );
    70 
    71     $numbers_obj = null;
    72     if ( ! empty( $attributes['numbers'] ) && 'hide' !== $attributes['numbers'] ) {
    73         $numbers_obj = add_a_z_numbers( $attributes['numbers'], $group_numbers );
    74     }
     73    $numbers_obj  = new A_Z_Listing_Numbers( $attributes['numbers'], $group_numbers );
    7574
    7675    if ( 'terms' === $attributes['display'] && ! empty( $attributes['taxonomy'] ) ) {
    7776        $taxonomy = '' !== $attributes['taxonomy'] ? $attributes['taxonomy'] : 'category';
    7877        $query    = array(
    79             'taxonomy' => $taxonomy,
     78            'taxonomy'   => $taxonomy,
     79            'hide_empty' => isset( $attributes['hide_empty'] ) && a_z_listing_is_truthy( $attributes['hide-empty'] ),
    8080        );
    8181
     
    9191
    9292        if ( ! empty( $terms_string ) ) {
    93             $terms = mb_split( ',', $terms_string );
     93            $terms = explode( ',', $terms_string );
    9494            $terms = array_map( 'trim', $terms );
    9595            $terms = array_map( 'intval', $terms );
     
    120120
    121121        if ( ! empty( $attributes['hide-empty-terms'] ) ) {
    122             $hide_empty = false;
    123             if ( 'true' === $attributes['hide-empty-terms'] || '1' === $attributes['hide-empty-terms'] ) {
    124                 $hide_empty = true;
    125             }
     122            $hide_empty = a_z_listing_is_truthy( $attributes['hide-empty-terms'] );
     123
    126124            $query = wp_parse_args(
    127125                $query,
     
    134132        $a_z_query = new A_Z_Listing( $query, 'terms' );
    135133    } else {
     134        $post_type = explode( ',', $attributes['post-type'] );
     135        $post_type = array_map( 'trim', $post_type );
     136
    136137        $query = array(
    137             'post_type' => $attributes['post-type'],
     138            'post_type' => $post_type,
    138139        );
    139140
    140141        if ( ! empty( $attributes['exclude-posts'] ) ) {
    141             $exclude_posts = mb_split( ',', $attributes['exclude-posts'] );
     142            $exclude_posts = explode( ',', $attributes['exclude-posts'] );
    142143            $exclude_posts = array_map( 'trim', $exclude_posts );
    143144            $exclude_posts = array_map( 'intval', $exclude_posts );
     
    151152
    152153            if ( ! empty( $exclude_posts ) ) {
    153                 $query = wp_parse_args(
    154                     $query,
    155                     array(
    156                         'post__not_in' => $exclude_posts,
    157                     )
    158                 );
     154                $query = wp_parse_args( $query, array( 'post__not_in' => $exclude_posts ) );
    159155            }
    160156        }
    161157
     158        if ( ! empty( $attributes['parent-post'] ) ) {
     159            if ( a_z_listing_is_truthy( $attributes['get-all-children'] ) ) {
     160                $child_query = array( 'child_of' => $attributes['parent-post'] );
     161            } else {
     162                $child_query = array( 'post_parent' => $attributes['parent-post'] );
     163            }
     164            $query = wp_parse_args( $query, $child_query );
     165        }
     166
     167        $taxonomy  = '' !== $attributes['taxonomy'] ? $attributes['taxonomy'] : 'category';
     168        $tax_query = array();
    162169        if ( ! empty( $attributes['terms'] ) ) {
    163             $taxonomy = '' !== $attributes['taxonomy'] ? $attributes['taxonomy'] : 'category';
    164             $terms    = mb_split( ',', $attributes['terms'] );
    165             $terms    = array_map( 'trim', $terms );
    166             $terms    = array_filter(
     170            $terms = explode( ',', $attributes['terms'] );
     171            $terms = array_map( 'trim', $terms );
     172            $terms = array_filter(
    167173                $terms,
    168174                function( $value ) {
     
    170176                }
    171177            );
    172             $terms    = array_unique( $terms );
    173 
    174             $query = wp_parse_args(
    175                 $query,
    176                 array(
    177                     'tax_query' => array(
    178                         array(
    179                             'taxonomy' => $taxonomy,
    180                             'field'    => 'slug',
    181                             'terms'    => $terms,
    182                         ),
    183                     ),
    184                 )
    185             );
     178            $terms = array_unique( $terms );
     179
     180            $tax_query[] = array(
     181                'taxonomy' => $taxonomy,
     182                'field'    => 'slug',
     183                'terms'    => $terms,
     184                'operator' => 'IN',
     185            );
     186        }
     187        if ( ! empty( $attributes['exclude-terms'] ) ) {
     188            $ex_terms = explode( ',', $attributes['exclude-termsterms'] );
     189            $ex_terms = array_map( 'trim', $terms );
     190            $ex_terms = array_filter(
     191                $ex_terms,
     192                function( $value ) {
     193                    return ! empty( $value );
     194                }
     195            );
     196            $ex_terms = array_unique( $ex_terms );
     197
     198            $tax_query[] = array(
     199                'taxonomy' => $taxonomy,
     200                'field'    => 'slug',
     201                'terms'    => $ex_terms,
     202                'operator' => 'NOT IN',
     203            );
     204        }
     205
     206        if ( ! empty( $tax_query ) ) {
     207            $query['tax_query'] = $tax_query;
    186208        }
    187209
     
    205227
    206228    $grouping_obj->teardown();
    207     if ( null != $numbers_obj ) {
    208         $numbers_obj->teardown();
    209     }
     229    $numbers_obj->teardown();
    210230
    211231    return $ret;
  • a-z-listing/trunk/functions/styles.php

    r1939419 r2003543  
    1818function a_z_listing_enqueue_styles( $force = false ) {
    1919    global $post;
    20     if ( $force || is_active_widget( false, false, 'bh_az_widget', true ) || ( is_singular() && has_shortcode( $post->post_content, 'a-z-listing' ) ) ) {
     20    if ( $force || is_customize_preview() || is_active_widget( false, false, 'bh_az_widget', true ) || ( is_singular() && has_shortcode( $post->post_content, 'a-z-listing' ) ) ) {
    2121        wp_enqueue_style( 'a-z-listing' );
    2222    }
     23}
     24
     25/**
     26 * Enqueue A-Z customizer styles.
     27 *
     28 * @since 2.1.0
     29 */
     30function a_z_listing_customize_enqueue_styles() {
     31    wp_enqueue_style( 'a-z-listing-admin' );
    2332}
    2433
  • a-z-listing/trunk/languages/a-z-listing.pot

    r1942709 r2003543  
    33msgid ""
    44msgstr ""
    5 "Project-Id-Version: A-Z Listing 2.0.6\n"
     5"Project-Id-Version: A-Z Listing 2.1.0\n"
    66"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/a-z-listing\n"
    7 "POT-Creation-Date: 2018-09-17 00:28:41+00:00\n"
     7"POT-Creation-Date: 2018-12-28 14:28:39+00:00\n"
    88"MIME-Version: 1.0\n"
    99"Content-Type: text/plain; charset=utf-8\n"
     
    2525"X-Generator: grunt-wp-i18n1.0.2\n"
    2626
    27 #: classes/class-a-z-listing.php:318
     27#: classes/class-a-z-listing.php:328
    2828#. translators: List the aphabet of your language in the order that your
    2929#. language prefers. list as groups of identical meanings but different
     
    4343msgstr ""
    4444
    45 #: classes/class-a-z-listing.php:320
     45#: classes/class-a-z-listing.php:330
    4646#. translators: This should be a single character to denote "all entries that
    4747#. didn't fit under one of the alphabet character groups defined". This is used
     
    5252msgstr ""
    5353
    54 #: templates/a-z-listing.example.php:45 templates/a-z-listing.php:52
     54#: templates/a-z-listing.example.php:45 templates/a-z-listing.php:67
    5555msgid "Back to top"
    5656msgstr ""
    5757
    58 #: templates/a-z-listing.example.php:53 templates/a-z-listing.php:62
     58#: templates/a-z-listing.example.php:53 templates/a-z-listing.php:81
    5959msgid "There are no posts included in this index."
    6060msgstr ""
     
    6464msgstr ""
    6565
    66 #: widgets/class-a-z-listing-widget.php:29
     66#: widgets/class-a-z-listing-widget.php:30
    6767msgid "Alphabetised links to the A-Z site map"
    6868msgstr ""
    6969
    70 #: widgets/class-a-z-listing-widget.php:110
    71 #: widgets/class-a-z-listing-widget.php:115
     70#: widgets/class-a-z-listing-widget.php:125
     71#: widgets/class-a-z-listing-widget.php:130
    7272msgid "Widget Title"
    7373msgstr ""
    7474
    75 #: widgets/class-a-z-listing-widget.php:119
     75#: widgets/class-a-z-listing-widget.php:134
    7676msgid ""
    7777"Leave the title field blank, above, to use the title from the page set in "
     
    7979msgstr ""
    8080
    81 #: widgets/class-a-z-listing-widget.php:126
    82 msgid "Site map A-Z page"
     81#: widgets/class-a-z-listing-widget.php:141
     82msgid "Sitemap A-Z page"
    8383msgstr ""
    8484
    85 #: widgets/class-a-z-listing-widget.php:142
     85#: widgets/class-a-z-listing-widget.php:153
     86msgid ""
     87"Type some or all of the title of the page you want links to point at. "
     88"Ensure this input field is not selected when you save the settings."
     89msgstr ""
     90
     91#: widgets/class-a-z-listing-widget.php:154
     92#: widgets/class-a-z-listing-widget.php:214
     93msgid ""
     94"Matching posts will be shown as you type. Click on the correct post from "
     95"the matches to update the setting."
     96msgstr ""
     97
     98#: widgets/class-a-z-listing-widget.php:161
    8699msgid "Display posts or terms?"
    87100msgstr ""
    88101
    89 #: widgets/class-a-z-listing-widget.php:149
     102#: widgets/class-a-z-listing-widget.php:168
    90103msgid "Posts"
    91104msgstr ""
    92105
    93 #: widgets/class-a-z-listing-widget.php:153
     106#: widgets/class-a-z-listing-widget.php:172
    94107msgid "Taxonomy terms"
    95108msgstr ""
    96109
    97 #: widgets/class-a-z-listing-widget.php:163
     110#: widgets/class-a-z-listing-widget.php:181
    98111msgid "Post-type to display"
    99112msgstr ""
    100113
    101 #: widgets/class-a-z-listing-widget.php:183
     114#: widgets/class-a-z-listing-widget.php:200
     115msgid "Show only children of this post (ID)"
     116msgstr ""
     117
     118#: widgets/class-a-z-listing-widget.php:213
     119msgid ""
     120"Type some or all of the title of the post to limit the listing to only the "
     121"children of that post. Ensure this input field is not selected when you "
     122"save the settings."
     123msgstr ""
     124
     125#: widgets/class-a-z-listing-widget.php:218
     126msgid "Include grand-children?"
     127msgstr ""
     128
     129#: widgets/class-a-z-listing-widget.php:230
    102130msgid "Taxonomy to display"
    103131msgstr ""
    104132
    105 #: widgets/class-a-z-listing-widget.php:203
     133#: widgets/class-a-z-listing-widget.php:249
    106134msgid "Parent term to display children of"
    107135msgstr ""
    108136
    109 #: widgets/class-a-z-listing-widget.php:215
     137#: widgets/class-a-z-listing-widget.php:261
    110138msgid "Terms to include (IDs)"
    111139msgstr ""
    112140
    113 #: widgets/class-a-z-listing-widget.php:228
     141#: widgets/class-a-z-listing-widget.php:273
    114142msgid "Terms to exclude (IDs)"
    115143msgstr ""
    116144
    117 #: widgets/class-a-z-listing-widget.php:241
     145#: widgets/class-a-z-listing-widget.php:285
    118146msgid "Hide empty terms"
    119147msgstr ""
  • a-z-listing/trunk/package-lock.json

    r1939419 r2003543  
    25742574    },
    25752575    "sprintf-js": {
    2576       "version": "1.1.1",
    2577       "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.1.1.tgz",
    2578       "integrity": "sha1-Nr54Mgr+WAH2zqPueLblqrlA6gw=",
     2576      "version": "1.1.2",
     2577      "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.1.2.tgz",
     2578      "integrity": "sha512-VE0SOVEHCk7Qc8ulkWw3ntAzXuqf7S2lvwQaDLRnUeIEaKNQJzV6BwmLKhOqT61aGhfUMrXeaBk+oDGCzvhcug==",
    25792579      "dev": true
    25802580    },
     
    27542754    },
    27552755    "underscore.string": {
    2756       "version": "3.3.4",
    2757       "resolved": "https://registry.npmjs.org/underscore.string/-/underscore.string-3.3.4.tgz",
    2758       "integrity": "sha1-LCo/n4PmR2L9xF5s6sZRQoZCE9s=",
     2756      "version": "3.3.5",
     2757      "resolved": "https://registry.npmjs.org/underscore.string/-/underscore.string-3.3.5.tgz",
     2758      "integrity": "sha512-g+dpmgn+XBneLmXXo+sGlW5xQEt4ErkS3mgeN2GFbremYeMBSJKr9Wf2KJplQVaiPY/f7FN6atosWYNm9ovrYg==",
    27592759      "dev": true,
    27602760      "requires": {
  • a-z-listing/trunk/readme.txt

    r1991923 r2003543  
    77Requires PHP: 5.6
    88Tested up to: 5.0
    9 Stable tag: 2.0.4
     9Stable tag: 2.1.0
    1010License: GPLv2 or later
    1111License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    230230= How do I show posts of a different post-type (not pages) or multiple post-types (e.g. posts AND pages) =
    231231
    232 This can be achieved using the shortcode or PHP.
     232This can be achieved using the shortcode or PHP. In these examples the generic phrase `post-type-slug` is used to describe the concept. The default post types provided by WordPress are called "Posts" and "Pages". Their slugs are `post` and `page` respectively. You need to use these names in place of the examples (i.e. `your-post-type-slug`, `type1-slug`, and `type1-slug`).
    233233
    234234**Shortcode method**
     
    268268`
    269269
    270 The argument to `the_a_z_listing()` is an [array](http://php.net/manual/en/language.types.array.php) and takes the same parameters as [WP_Query](https://codex.wordpress.org/Class_Reference/WP_Query)
     270The argument to `the_a_z_listing()` is an [array](https://secure.php.net/manual/en/language.types.array.php) and takes the same parameters as [WP_Query](https://codex.wordpress.org/Class_Reference/WP_Query)
    271271
    272272The code above needs to be within a php block which is denoted by the `<?php` and `?>` pair. Depending on your theme, you might not need the opening and closing php tags shown in the above snippet; if that is the case, you are free to omit them in your code.
     
    274274= How do I show posts from a specific category only =
    275275
    276 This can be achieved using the shortcode or PHP.
     276This can be achieved using the shortcode or PHP. In these examples the generic phrase `taxonomy` and `term` are used to describe the concept. The default taxonomies provided by WordPress are called "Categories" and "Tags". Their slugs are `category` and `post_tag` respectively. Each Category and Tag are then known as "terms". You need to use the slug for each individual category or tag in place of the example slugs (i.e. `term-slug`, `term1-slug`, and `term1-slug`).
    277277
    278278**Shortcode method**
     
    304304`
    305305
    306 Any number of terms may be added to the `terms` [array](http://php.net/manual/en/language.types.array.php), including one or none.
    307 
    308 The argument to `the_a_z_listing()` is an [array](http://php.net/manual/en/language.types.array.php) and takes the same parameters as [WP_Query](https://codex.wordpress.org/Class_Reference/WP_Query)
     306Any number of terms may be added to the `terms` [array](https://secure.php.net/manual/en/language.types.array.php), including one or none.
     307
     308The argument to `the_a_z_listing()` is an [array](https://secure.php.net/manual/en/language.types.array.php) and takes the same parameters as [WP_Query](https://codex.wordpress.org/Class_Reference/WP_Query)
    309309
    310310The code above needs to be within a php block which is denoted by the `<?php` and `?>` pair. Depending on your theme, you might not need the opening and closing php tags shown in the above snippet; if that is the case, you are free to omit them in your code.
     
    312312= How do I show terms from a taxonomy instead of posts =
    313313
    314 This can be achieved using the shortcode or PHP.
     314This can be achieved using the shortcode or PHP. In these examples the generic phrase `taxonomy` and `term` are used to describe the concept. The default taxonomies provided by WordPress are called "Categories" and "Tags". Their slugs are `category` and `post_tag` respectively. You need to use the slug for the taxonomy in place of the example slugs (i.e. `taxonomy-slug`).
    315315
    316316**Shortcode method**
     
    332332`
    333333
    334 The argument to `the_a_z_listing()` is a [string](http://php.net/manual/en/language.types.string.php) and contains the slug of a single taxonomy, e.g. `category` or `post_tag`.
     334The argument to `the_a_z_listing()` is a [string](https://secure.php.net/manual/en/language.types.string.php) and contains the slug of a single taxonomy, e.g. `category` or `post_tag`.
    335335
    336336The code above needs to be within a php block which is denoted by the `<?php` and `?>` pair. Depending on your theme, you might not need the opening and closing php tags shown in the above snippet; if that is the case, you are free to omit them in your code.
     
    356356`
    357357<?php
    358 add_action( 'wp', 'a_z_listing_force_enable_styles', 99 );
     358add_action( 'init', 'a_z_listing_force_enable_styles', 99 );
    359359?>
    360360`
     
    368368`
    369369<?php
    370 add_action( 'wp', 'your_override_wrapper_function', 99 );
     370add_action( 'init', 'your_override_wrapper_function', 99 );
    371371function your_override_wrapper_function() {
    372372    if ( ! is_page( 'your-a-z-listing-page-slug-or-ID' ) ) { // ID is numeric, slug is a string.
     
    411411== Changelog ==
    412412
     413= 2.1.0 =
     414
     415**Bug Fixes:**
     416
     417* Fix widget configuration autocomplete fields for target post and parent post in the theme customizer
     418* Fix taxonomy-term-filtered listings displaying all posts (e.g. shortcodes of the form `[a-z-listing taxonomy="category" terms="term"])
     419* Fix `get_the_item_object()` to work with old-style overridden indices
     420* Fix `get_the_item_object()` to correctly extract the item ID and load the correct item
     421* Improve javascript on the widget configuration
     422* Clarified the examples with explanations about "post types", "taxonomies", and "terms" to explain what each of these mean.
     423
     424**New Features:**
     425
     426* Add parent-page attribute to the shortcode
     427* Add simpler and safer filter for overriding the index letter for an item
     428* Add simpler and safer filter for overriding the title for an item
     429* Add new function for fetching meta data in a template: `$a_z_listing->get_item_meta()`
     430* Allow exclude-terms to be used with display="posts"
     431* Moved template loading function outside of the `A_Z_Query` class to prevent accidental access to the plugin internal structure
     432
    413433= 2.0.6 =
    414434
    415 * *Personal Note:* Sorry to everyone who upgraded to 2.0.0 thru to 2.0.5 about yet another update. I have failed you all by shipping faulty versions to you, and I'm sorry, especially so that you've had to endure so many updates the past few days.
    416435* Fix widget target post support
    417436* Fix filtering posts by multiple taxonomy terms
     
    421440* Fix javascript error on widgets screen
    422441
    423 *2.0.0 also introduced the following changes:*
     442= 2.0.0 =
    424443
    425444* Improved widget configuration.
     
    432451* Fix the stylesheet to better cope with variances in font-size and text length in the alphabet links list and widget.
    433452* Introduce PHP classes for adding numbers and grouping to the alphabet. Allows unhooking from the filters to undo the changes, where previously you could not unhook these modifications once they'd been applied.
    434 * **BREAKING CHANGES:**
    435   * Multi column example:
    436     If you have copied the multi-column example in previous releases to your theme folder then you will need to perform some manual steps.
    437     If you have not edited the file, just delete it and the new template from the plugin will take control and perform the same functionality.
    438     If you have modified the example template then you will need to compare with the file in the plugin at `templates/a-z-listing.php` and merge any changes into your template.
    439   * Template customisations:
    440     If you have customised the in-built templates or written your own then you may experience breakage due to the post object not being loaded automatically.
    441     If you require the template to access more than the post title and URL then you will need to add an additional call after `the_item()` to load the full `WP_Post` object into memory.
    442     To load the post object you need to call `$a_z_query->get_the_item_object( 'I understand the issues!' );`.
    443     **The argument must read exactly as written here to confirm that you understand that this might cause slowness or memory usage problems.**
    444     *This step is purposely omitted to save memory and try to improve performance.*
    445 
    446 = 2.0.0 =
    447 
    448 * Improved widget configuration.
    449 * New attribute added to the shortcode when `display="posts"`:
    450   * `exclude-posts`: remove specific posts from the list
    451 * New attributes added to the shortcode when `display="terms"`:
    452   * `exclude-terms`: sets the terms to exclude from display
    453   * `parent-term`: set the parent that all displayed terms must be organised under
    454   * `hide-empty-terms`: hide terms that have no posts associated
    455 * Fix the stylesheet to better cope with variances in font-size and text length in the alphabet links list and widget.
    456 * Introduce PHP classes for adding numbers and grouping to the alphabet. Allows unhooking from the filters to undo the changes, where previously you could not unhook these modifications once they'd been applied.
    457 * **BREAKING CHANGES:**
    458   * Multi column example:
    459     If you have copied the multi-column example in previous releases to your theme folder then you will need to perform some manual steps.
    460     If you have not edited the file, just delete it and the new template from the plugin will take control and perform the same functionality.
    461     If you have modified the example template then you will need to compare with the file in the plugin at `templates/a-z-listing.php` and merge any changes into your template.
    462   * Template customisations:
    463     If you have customised the in-built templates or written your own then you may experience breakage due to the post object not being loaded automatically.
    464     If you require the template to access more than the post title and URL then you will need to add an additional call after `the_item()` to load the full `WP_Post` object into memory.
    465     To load the post object you need to call `$a_z_query->get_the_item_object( 'I understand the issues!' );`.
    466     **The argument must read exactly as written here to confirm that you understand that this might cause slowness or memory usage problems.**
    467     *This step is purposely omitted to save memory and try to improve performance.*
    468 
    469 = 1.9.2 =
    470 
    471 Bugfix:
    472 
    473 * Fix using multiple terms in the shortcode only displays results for the first term
    474 = 1.9.1 =
    475 
    476 Feature Request:
    477 Add CSS classes to letters indicating presence of posts or not:
    478 
    479 * `has-posts` allows styling of letters that have posts visible in the listing
    480 * `no-posts` allows styling of letters that do not have any posts visible in the listing
    481 
    482 You can use these classes to hide letters that have no posts by including the following CSS rule:
    483 `.az-letters ul.az-links li.no-posts {
    484     display: none;
    485 }`
    486 
    487 = 1.9.0 =
    488 
    489 * Fix multi-column example template
    490 * Update multi-column styles to include display:grid support
    491 * Add back-to-top link
    492 * Add server system requirements to readme
    493 * Add PHP section to readme including link to API Reference
     453
     454**BREAKING CHANGES:**
     455
     456*Multi column example:*
     457
     458* If you have copied the multi-column example in previous releases to your theme folder then you will need to perform some manual steps.
     459* If you have not edited the file, just delete it and the new template from the plugin will take control and perform the same functionality.
     460* If you have modified the example template then you will need to compare with the file in the plugin at `templates/a-z-listing.php` and merge any changes into your template.
     461
     462*Template customisations:*
     463
     464* If you have customised the in-built templates or written your own then you may experience breakage due to the post object not being loaded automatically.
     465* If you require the template to access more than the post title and URL then you will need to add an additional call after `the_item()` to load the full `WP_Post` object into memory.
     466* To load the post object you need to call `$a_z_query->get_the_item_object( 'I understand the issues!' );`.
     467  __The argument must read exactly as written here to confirm that you understand that this might cause slowness or memory usage problems.__
     468  _This step is purposely omitted to save memory and try to improve performance._
    494469
    495470= Previous =
  • a-z-listing/trunk/scripts/a-z-listing-tabs.js

    r1939419 r2003543  
    11// props to @claytonchase (https://profiles.wordpress.org/claytonchase)
    22jQuery( document ).ready( function() {
    3     jQuery( "#az-tabs" ).tabs();
     3    const tabs = document.getElementById( 'az-tabs' );
     4    if ( tabs ) {
     5        let link;
     6        const letters = tabs.getElementById( 'letters' );
     7        if ( letters ) {
     8            link = letters.querySelector( `a[href="${window.location.hash}"]` );
     9        }
     10
     11        if ( window.location.hash && link ) {
     12            const activeTab = jQuery( link ).parent().index();
     13            jQuery( tabs ).tabs( { active: activeTab } );
     14        } else {
     15            jQuery( tabs ).tabs();
     16        }
     17    }
    418} );
  • a-z-listing/trunk/templates/a-z-listing.example.php

    r1939419 r2003543  
    1414?>
    1515<div id="az-tabs">
    16 <div id="letters">
    17     <div class="az-letters">
    18         <?php $a_z_query->the_letters(); ?>
     16    <div id="letters">
     17        <div class="az-letters">
     18            <?php $a_z_query->the_letters(); ?>
     19        </div>
    1920    </div>
    20 </div>
    21 <?php if ( $a_z_query->have_letters() ) : ?>
    22 <div id="az-slider">
    23     <div id="inner-slider">
    24         <?php
    25         while ( $a_z_query->have_letters() ) :
    26             $a_z_query->the_letter();
    27             ?>
    28             <?php if ( $a_z_query->have_items() ) : ?>
    29                 <div class="letter-section" id="<?php $a_z_query->the_letter_id(); ?>">
    30                     <h2 class="letter-title">
    31                         <span><?php $a_z_query->the_letter_title(); ?></span>
    32                     </h2>
     21    <?php if ( $a_z_query->have_letters() ) : ?>
     22    <div id="az-slider">
     23        <div id="inner-slider">
     24            <?php
     25            while ( $a_z_query->have_letters() ) :
     26                $a_z_query->the_letter();
     27                ?>
     28                <?php if ( $a_z_query->have_items() ) : ?>
     29                    <div class="letter-section" id="<?php $a_z_query->the_letter_id(); ?>">
     30                        <h2 class="letter-title">
     31                            <span><?php $a_z_query->the_letter_title(); ?></span>
     32                        </h2>
    3333
    34                     <ul>
    35                         <?php
    36                         while ( $a_z_query->have_items() ) :
    37                             $a_z_query->the_item();
    38                             ?>
    39                             <li>
    40                                 <a href="<?php $a_z_query->the_permalink(); ?>"><?php $a_z_query->the_title(); ?></a>
    41                             </li>
    42                         <?php endwhile; ?>
    43                     </ul>
     34                        <ul>
     35                            <?php
     36                            while ( $a_z_query->have_items() ) :
     37                                $a_z_query->the_item();
     38                                ?>
     39                                <li>
     40                                    <a href="<?php $a_z_query->the_permalink(); ?>"><?php $a_z_query->the_title(); ?></a>
     41                                </li>
     42                            <?php endwhile; ?>
     43                        </ul>
    4444
    45                     <div class="back-to-top"><a href="#letters"><?php _e( 'Back to top', 'a-z-listing' ); ?></a></div>
    46                 </div>
    47             <?php endif; ?>
    48         <?php endwhile; ?>
     45                        <div class="back-to-top"><a href="#letters"><?php _e( 'Back to top', 'a-z-listing' ); ?></a></div>
     46                    </div>
     47                <?php endif; ?>
     48            <?php endwhile; ?>
     49        </div>
    4950    </div>
    50 </div>
    5151</div>
    5252<?php else : ?>
  • a-z-listing/trunk/templates/a-z-listing.php

    r1939419 r2003543  
    33 * Default multicolumn template for the A-Z Listing plugin
    44 *
    5  * This template will be given the variable `$a_z_query` which is an instance of
    6  * `A_Z_Listing`.
     5 * This template will be given the variable `$a_z_query` which is an instance
     6 * of `A_Z_Listing`.
    77 *
    88 * You can override this template by copying this file into your theme
     
    1212 */
    1313
    14 $_a_z_listing_colcount  = 3;
     14/**
     15 * This value indicates the number of posts to require before a second column
     16 * is created. However, due to the design of web browsers, the posts will flow
     17 * evenly between the available columns. E.g. if you have 11 items, a value of
     18 * 10 here will create two columns with 6 items in the first column and 5 items
     19 * in the second column.
     20 */
    1521$_a_z_listing_minpercol = 10;
    1622?>
    1723<div id="az-tabs">
    18 <div id="letters">
    19     <div class="az-letters">
    20         <?php $a_z_query->the_letters(); ?>
     24    <div id="letters">
     25        <div class="az-letters">
     26            <?php $a_z_query->the_letters(); ?>
     27        </div>
     28    </div>
     29    <?php if ( $a_z_query->have_letters() ) : ?>
     30    <div id="az-slider">
     31        <div id="inner-slider">
     32            <?php
     33            while ( $a_z_query->have_letters() ) :
     34                $a_z_query->the_letter();
     35                ?>
     36                <?php if ( $a_z_query->have_items() ) : ?>
     37                    <?php
     38                    $item_count  = $a_z_query->get_the_letter_count();
     39                    $num_columns = ceil(
     40                        $item_count / $_a_z_listing_minpercol
     41                    );
     42                    ?>
     43                    <div class="letter-section"
     44                        id="<?php $a_z_query->the_letter_id(); ?>">
     45                        <h2 class="letter-title">
     46                            <span>
     47                                <?php $a_z_query->the_letter_title(); ?>
     48                            </span>
     49                        </h2>
     50                        <?php $column_class = "max-$num_columns-columns"; ?>
     51                        <ul class="columns <?php echo $column_class; ?>">
     52                            <?php
     53                            while ( $a_z_query->have_items() ) :
     54                                $a_z_query->the_item();
     55                                ?>
     56                                <li>
     57                                    <a href="
     58                                        <?php $a_z_query->the_permalink(); ?>
     59                                    ">
     60                                        <?php $a_z_query->the_title(); ?>
     61                                    </a>
     62                                </li>
     63                            <?php endwhile; ?>
     64                        </ul>
     65                        <div class="back-to-top">
     66                            <a href="#letters">
     67                                <?php _e( 'Back to top', 'a-z-listing' ); ?>
     68                            </a>
     69                        </div>
     70                    </div>
     71                    <?php
     72                endif;
     73            endwhile;
     74            ?>
     75        </div>
    2176    </div>
    2277</div>
    23 <?php if ( $a_z_query->have_letters() ) : ?>
    24 <div id="az-slider">
    25     <div id="inner-slider">
     78<?php else : ?>
     79    <p>
    2680        <?php
    27         while ( $a_z_query->have_letters() ) :
    28             $a_z_query->the_letter();
    29             ?>
    30             <?php if ( $a_z_query->have_items() ) : ?>
    31                 <?php
    32                 $item_count   = $a_z_query->get_the_letter_count();
    33                 $column_limit = round( $item_count / $_a_z_listing_minpercol );
    34                 if ( $column_limit > $_a_z_listing_colcount ) {
    35                     $column_limit = $_a_z_listing_colcount;
    36                 }
    37                 ?>
    38                 <div class="letter-section" id="<?php $a_z_query->the_letter_id(); ?>">
    39                     <h2 class="letter-title">
    40                         <span><?php $a_z_query->the_letter_title(); ?></span>
    41                     </h2>
    42                     <ul class="columns max-<?php echo $column_limit; ?>-columns">
    43                         <?php
    44                         while ( $a_z_query->have_items() ) :
    45                             $a_z_query->the_item();
    46                             ?>
    47                             <li>
    48                                 <a href="<?php $a_z_query->the_permalink(); ?>"><?php $a_z_query->the_title(); ?></a>
    49                             </li>
    50                         <?php endwhile; ?>
    51                     </ul>
    52                     <div class="back-to-top"><a href="#letters"><?php _e( 'Back to top', 'a-z-listing' ); ?></a></div>
    53                 </div>
    54                 <?php
    55             endif;
    56         endwhile;
     81        esc_html_e(
     82            'There are no posts included in this index.',
     83            'a-z-listing'
     84        );
    5785        ?>
    58     </div>
    59 </div>
    60 </div>
    61 <?php else : ?>
    62     <p><?php esc_html_e( 'There are no posts included in this index.', 'a-z-listing' ); ?></p>
     86    </p>
    6387    <?php
    6488endif;
  • a-z-listing/trunk/widgets/class-a-z-listing-widget.php

    r1942709 r2003543  
    3131        );
    3232
     33        add_action( 'admin_enqueue_scripts', 'a_z_listing_enqueue_widget_admin_script' );
     34
    3335        if ( is_active_widget( false, false, $this->id_base, true ) ) {
    3436            a_z_listing_do_enqueue();
     
    6062        $public_taxonomies = get_taxonomies( $args, 'objects' );
    6163
    62         $widget_title      = $instance['title'];
     64        $widget_title      = isset( $instance['title'] ) ? $instance['title'] : '';
    6365        $widget_title_id   = $this->get_field_id( 'title' );
    6466        $widget_title_name = $this->get_field_name( 'title' );
    6567
    66         $display_type      = $instance['type'];
     68        $display_type      = ( 'terms' === $instance['type'] ) ? 'terms' : 'posts';
    6769        $display_type_id   = $this->get_field_id( 'type' );
    6870        $display_type_name = $this->get_field_name( 'type' );
    6971
    70         $target_post            = isset( $instance['post'] ) ? $instance['post'] : ( isset( $instance['page'] ) ? $instance['page'] : 0 );
     72        $target_post            = isset( $instance['post'] ) ? intval( $instance['post'] ) : ( isset( $instance['page'] ) ? intval( $instance['page'] ) : 0 );
    7173        $target_post_id         = $this->get_field_id( 'post' );
    7274        $target_post_name       = $this->get_field_name( 'post' );
    73         $target_post_title      = ( $target_post > 0 ) ? get_the_title( $target_post ) : '';
     75        $target_post_title      = isset( $instance['target_post'] ) ? $instance['target_post'] : ( 0 < $target_post ) ? get_the_title( $target_post ) : '';
    7476        $target_post_title_id   = $this->get_field_id( 'target_post_title' );
    7577        $target_post_title_name = $this->get_field_name( 'target_post_title' );
    7678
    77         $listing_post_type            = isset( $instance['post_type'] ) ? $instance['post_type'] : 'page';
    78         $listing_post_type_id         = $this->get_field_id( 'post_type' );
    79         $listing_post_type_name       = $this->get_field_name( 'post_type' );
    80         $listing_post_type_wrapper_id = $this->get_field_id( 'post_type_wrapper' );
    81 
    82         $listing_taxonomy            = isset( $instance['taxonomy'] ) ? $instance['taxonomy'] : 'page';
    83         $listing_taxonomy_id         = $this->get_field_id( 'taxonomy' );
    84         $listing_taxonomy_name       = $this->get_field_name( 'taxonomy' );
    85         $listing_taxonomy_wrapper_id = $this->get_field_id( 'taxonomy_wrapper' );
    86 
    87         $listing_parent_term            = isset( $instance['parent_term'] ) ? $instance['parent_term'] : '';
    88         $listing_parent_term_id         = $this->get_field_id( 'parent_term' );
    89         $listing_parent_term_name       = $this->get_field_name( 'parent_term' );
    90         $listing_parent_term_wrapper_id = $this->get_field_id( 'parent_term_wrapper' );
     79        $listing_post_type      = isset( $instance['post_type'] ) ? $instance['post_type'] : 'page';
     80        $listing_post_type_id   = $this->get_field_id( 'post_type' );
     81        $listing_post_type_name = $this->get_field_name( 'post_type' );
     82
     83        $listing_parent_post            = isset( $instance['parent_post'] ) ? $instance['parent_post'] : '';
     84        $listing_parent_post_id         = $this->get_field_id( 'parent_post' );
     85        $listing_parent_post_name       = $this->get_field_name( 'parent_post' );
     86        $listing_parent_post_title      = isset( $instance['parent_post_title'] ) ? $instance['parent_post_title'] : ( 0 < $listing_parent_post ) ? get_the_title( $listing_parent_post ) : '';
     87        $listing_parent_post_title_id   = $this->get_field_id( 'parent_post_title' );
     88        $listing_parent_post_title_name = $this->get_field_name( 'parent_post_title' );
     89
     90        $listing_all_children      = isset( $instance['all_children'] ) ? $instance['all_children'] : 'true';
     91        $listing_all_children_id   = $this->get_field_id( 'all_children' );
     92        $listing_all_children_name = $this->get_field_name( 'all_children' );
     93
     94        $listing_taxonomy      = isset( $instance['taxonomy'] ) ? $instance['taxonomy'] : 'page';
     95        $listing_taxonomy_id   = $this->get_field_id( 'taxonomy' );
     96        $listing_taxonomy_name = $this->get_field_name( 'taxonomy' );
     97
     98        $listing_parent_term      = isset( $instance['parent_term'] ) ? $instance['parent_term'] : '';
     99        $listing_parent_term_id   = $this->get_field_id( 'parent_term' );
     100        $listing_parent_term_name = $this->get_field_name( 'parent_term' );
    91101
    92102        $listing_terms_include      = isset( $instance['terms'] ) ? $instance['terms'] : '';
     
    94104        $listing_terms_include_name = $this->get_field_name( 'terms' );
    95105
    96         $listing_terms_exclude            = isset( $instance['terms_exclude'] ) ? $instance['terms_exclude'] : '';
    97         $listing_terms_exclude_id         = $this->get_field_id( 'terms_exclude' );
    98         $listing_terms_exclude_name       = $this->get_field_name( 'terms_exclude' );
    99         $listing_terms_exclude_wrapper_id = $this->get_field_id( 'terms_exclude_wrapper' );
    100 
    101         $listing_hide_empty_terms            = isset( $instance['hide_empty_terms'] ) ? $instance['hide_empty_terms'] : '';
    102         $listing_hide_empty_terms_id         = $this->get_field_id( 'hide_empty_terms' );
    103         $listing_hide_empty_terms_name       = $this->get_field_name( 'hide_empty_terms' );
    104         $listing_hide_empty_terms_wrapper_id = $this->get_field_id( 'hide_empty_terms_wrapper' );
     106        $listing_terms_exclude      = isset( $instance['terms_exclude'] ) ? $instance['terms_exclude'] : '';
     107        $listing_terms_exclude_id   = $this->get_field_id( 'terms_exclude' );
     108        $listing_terms_exclude_name = $this->get_field_name( 'terms_exclude' );
     109
     110        $listing_hide_empty_terms      = isset( $instance['hide_empty_terms'] ) ? $instance['hide_empty_terms'] : '';
     111        $listing_hide_empty_terms_id   = $this->get_field_id( 'hide_empty_terms' );
     112        $listing_hide_empty_terms_name = $this->get_field_name( 'hide_empty_terms' );
    105113        ?>
    106114
    107         <div>
    108             <p>
    109                 <label for="<?php echo esc_attr( $widget_title_id ); ?>">
    110                     <?php esc_html_e( 'Widget Title', 'a-z-listing' ); ?>
    111                 </label>
    112                 <input class="widefat" type="text"
    113                     id="<?php echo esc_attr( $widget_title_id ); ?>"
    114                     name="<?php echo esc_attr( $widget_title_name ); ?>"
    115                     placeholder="<?php esc_attr_e( 'Widget Title', 'a-z-listing' ); ?>"
    116                     value="<?php echo esc_attr( $widget_title ); ?>" />
    117             </p>
    118             <p style="color: #333;">
    119                 <?php esc_html_e( 'Leave the title field blank, above, to use the title from the page set in the next field', 'a-z-listing' ); ?>
    120             </p>
     115        <div class="a-z-listing-widget">
     116            <div class="a-z-listing-widget-title-wrapper">
     117                <p>
     118                    <label for="<?php echo esc_attr( $widget_title_id ); ?>">
     119                        <?php esc_html_e( 'Widget Title', 'a-z-listing' ); ?>
     120                    </label>
     121                    <input type="text" class="widefat a-z-listing-title"
     122                        id="<?php echo esc_attr( $widget_title_id ); ?>"
     123                        name="<?php echo esc_attr( $widget_title_name ); ?>"
     124                        placeholder="<?php esc_attr_e( 'Widget Title', 'a-z-listing' ); ?>"
     125                        value="<?php echo esc_attr( $widget_title ); ?>" />
     126                </p>
     127                <p style="color: #333;">
     128                    <?php esc_html_e( 'Leave the title field blank, above, to use the title from the page set in the next field', 'a-z-listing' ); ?>
     129                </p>
     130            </div>
     131
     132            <div class="a-z-listing-target-post-wrapper">
     133                <p>
     134                    <label for="<?php echo esc_attr( $target_post_id ); ?>">
     135                        <?php esc_html_e( 'Sitemap A-Z page', 'a-z-listing' ); ?>
     136                    </label>
     137                    <input type="text" class="widefat a-z-listing-target-post-title"
     138                        id="<?php echo esc_attr( $target_post_title_id ); ?>"
     139                        name="<?php echo esc_attr( $target_post_title_name ); ?>"
     140                        value="<?php echo esc_attr( $target_post_title ); ?>" />
     141                    <input type="hidden"
     142                        id="<?php echo esc_attr( $target_post_id ); ?>"
     143                        name="<?php echo esc_attr( $target_post_name ); ?>"
     144                        value="<?php echo esc_attr( $target_post ); ?>" />
     145                </p>
     146                <p>
     147                    <?php esc_html_e( 'Type some or all of the title of the page you want links to point at. Ensure this input field is not selected when you save the settings.', 'a-z-listing' ); ?>
     148                    <?php esc_html_e( 'Matching posts will be shown as you type. Click on the correct post from the matches to update the setting.', 'a-z-listing' ); ?>
     149                </p>
     150            </div>
     151
     152            <div class="a-z-listing-display-type-wrapper">
     153                <p>
     154                    <label for="<?php echo esc_attr( $display_type_id ); ?>">
     155                        <?php esc_html_e( 'Display posts or terms?', 'a-z-listing' ); ?>
     156                    </label>
     157                    <select class="widefat a-z-listing-display-type"
     158                        id="<?php echo esc_attr( $display_type_id ); ?>"
     159                        name="<?php echo esc_attr( $display_type_name ); ?>">
     160                        <option value="posts"
     161                            <?php echo ( 'terms' !== $display_type ) ? 'selected' : ''; ?>>
     162                            <?php esc_html_e( 'Posts', 'a-z-listing' ); ?>
     163                        </option>
     164                        <option value="terms"
     165                            <?php echo ( 'terms' === $display_type ) ? 'selected' : ''; ?>>
     166                            <?php esc_html_e( 'Taxonomy terms', 'a-z-listing' ); ?>
     167                        </option>
     168                    </select>
     169                </p>
     170            </div>
     171
     172            <div class="a-z-listing-post-type-wrapper" <?php echo ( 'terms' !== $display_type ) ? '' : 'style="display: none;"'; ?>>
     173                <p>
     174                    <label for="<?php echo esc_attr( $listing_post_type_id ); ?>">
     175                        <?php esc_html_e( 'Post-type to display', 'a-z-listing' ); ?>
     176                    </label>
     177                    <select class="widefat a-z-listing-post-type"
     178                        id="<?php echo esc_attr( $listing_post_type_id ); ?>"
     179                        name="<?php echo esc_attr( $listing_post_type_name ); ?>"
     180                        <?php echo ( 'terms' !== $display_type ) ? '' : 'disabled'; ?>>
     181                        <?php foreach ( $public_post_types as $k => $t ) : ?>
     182                            <option value="<?php echo esc_attr( $k ); ?>"
     183                                <?php echo ( $k === $listing_post_type ) ? 'selected' : ''; ?>>
     184                                <?php echo esc_html( $t->labels->name ); ?>
     185                            </option>
     186                        <?php endforeach; ?>
     187                    </select>
     188                </p>
     189            </div>
     190
     191            <div class="a-z-listing-parent-post-wrapper" <?php echo ( 'terms' !== $display_type ) ? '' : 'style="display: none"'; ?>>
     192                <p>
     193                    <label for="<?php echo esc_attr( $listing_parent_post_id ); ?>">
     194                        <?php esc_html_e( 'Show only children of this post (ID)', 'a-z-listing' ); ?>
     195                    </label>
     196                    <input type="text" class="widefat a-z-listing-parent-post-title"
     197                        id="<?php echo esc_attr( $listing_parent_post_title_id ); ?>"
     198                        name="<?php echo esc_attr( $listing_parent_post_title_name ); ?>"
     199                        <?php echo ( 'terms' !== $display_type ) ? '' : 'disabled'; ?>
     200                        value="<?php echo esc_attr( $listing_parent_post_title ); ?>" />
     201                    <input type="hidden"
     202                        id="<?php echo esc_attr( $listing_parent_post_id ); ?>"
     203                        name="<?php echo esc_attr( $listing_parent_post_name ); ?>"
     204                        value="<?php echo esc_attr( $listing_parent_post ); ?>" />
     205                </p>
     206                <p>
     207                    <?php esc_html_e( 'Type some or all of the title of the post to limit the listing to only the children of that post. Ensure this input field is not selected when you save the settings.', 'a-z-listing' ); ?>
     208                    <?php esc_html_e( 'Matching posts will be shown as you type. Click on the correct post from the matches to update the setting.', 'a-z-listing' ); ?>
     209                </p>
     210                <p>
     211                    <label for="<?php echo esc_attr( $listing_all_children_id ); ?>">
     212                        <?php esc_html_e( 'Include grand-children?', 'a-z-listing' ); ?>
     213                    </label>
     214                    <input type="checkbox" class="a-z-listing-all-children"
     215                        id="<?php echo esc_attr( $listing_all_children_id ); ?>"
     216                        name="<?php echo esc_attr( $listing_all_children_name ); ?>"
     217                        <?php echo ( isset( $listing_all_children ) && 'true' === $listing_all_children ) ? 'checked' : ''; ?> />
     218                </p>
     219            </div>
     220
     221            <div class="a-z-listing-taxonomy-wrapper" <?php echo ( 'terms' === $display_type ) ? '' : 'style="display: none;"'; ?>>
     222                <p>
     223                    <label for="<?php echo esc_attr( $listing_taxonomy_id ); ?>">
     224                        <?php esc_html_e( 'Taxonomy to display', 'a-z-listing' ); ?>
     225                    </label>
     226                    <select class="widefat a-z-listing-taxonomy"
     227                        id="<?php echo esc_attr( $listing_taxonomy_id ); ?>"
     228                        name="<?php echo esc_attr( $listing_taxonomy_name ); ?>"
     229                        <?php echo ( 'terms' === $display_type ) ? '' : 'disabled'; ?>>
     230                        <?php foreach ( $public_taxonomies as $k => $t ) : ?>
     231                            <option value="<?php echo esc_attr( $k ); ?>"
     232                                <?php echo ( $k === $listing_taxonomy ) ? 'selected' : ''; ?>>
     233                                <?php echo esc_html( $t->labels->name ); ?>
     234                            </option>
     235                        <?php endforeach; ?>
     236                    </select>
     237                </p>
     238            </div>
     239
     240            <div class="a-z-listing-parent-term-wrapper" <?php echo ( 'terms' === $display_type ) ? '' : 'style="display: none;"'; ?>>
     241                <p>
     242                    <label for="<?php echo esc_attr( $listing_parent_term_id ); ?>">
     243                        <?php esc_html_e( 'Parent term to display children of', 'a-z-listing' ); ?>
     244                    </label>
     245                    <input type="text" class="widefat a-z-listing-parent-term"
     246                        id="<?php echo esc_attr( $listing_parent_term_id ); ?>"
     247                        name="<?php echo esc_attr( $listing_parent_term_name ); ?>"
     248                        value="<?php echo esc_attr( $listing_parent_term ); ?>" />
     249                </p>
     250            </div>
     251
     252            <div class="a-z-listing-include-terms-wrapper">
     253                <p>
     254                    <label for="<?php echo esc_attr( $listing_terms_include_id ); ?>">
     255                        <?php esc_html_e( 'Terms to include (IDs)', 'a-z-listing' ); ?>
     256                    </label>
     257                    <input type="text" class="widefat a-z-listing-include-terms"
     258                        id="<?php echo esc_attr( $listing_terms_include_id ); ?>"
     259                        name="<?php echo esc_attr( $listing_terms_include_name ); ?>"
     260                        value="<?php echo esc_attr( $listing_terms_include ); ?>" />
     261                </p>
     262            </div>
     263
     264            <div class="a-z-listing-exclude-terms-wrapper" <?php echo ( 'terms' === $display_type ) ? '' : 'style="display: none;"'; ?>>
     265                <p>
     266                    <label for="<?php echo esc_attr( $listing_terms_exclude_id ); ?>">
     267                        <?php esc_html_e( 'Terms to exclude (IDs)', 'a-z-listing' ); ?>
     268                    </label>
     269                    <input type="text" class="widefat a-z-listing-exclude-terms"
     270                        id="<?php echo esc_attr( $listing_terms_exclude_id ); ?>"
     271                        name="<?php echo esc_attr( $listing_terms_exclude_name ); ?>"
     272                        value="<?php echo esc_attr( $listing_terms_exclude ); ?>" />
     273                </p>
     274            </div>
     275
     276            <div class="a-z-listing-hide-empty-terms-wrapper" <?php echo ( 'terms' === $display_type ) ? '' : 'style="display: none;"'; ?>>
     277                <p>
     278                    <label for="<?php echo esc_attr( $listing_hide_empty_terms_id ); ?>">
     279                        <?php esc_html_e( 'Hide empty terms', 'a-z-listing' ); ?>
     280                    </label>
     281                    <input type="checkbox" class="a-z-listing-hide-empty-terms"
     282                        id="<?php echo esc_attr( $listing_hide_empty_terms_id ); ?>"
     283                        name="<?php echo esc_attr( $listing_hide_empty_terms_name ); ?>"
     284                        <?php echo ( isset( $listing_hide_empty_terms ) && 'true' === $listing_hide_empty_terms ) ? 'checked' : ''; ?> />
     285                </p>
     286            </div>
    121287        </div>
    122 
    123         <div>
    124             <p>
    125                 <label for="<?php echo esc_attr( $target_post_id ); ?>">
    126                     <?php esc_html_e( 'Site map A-Z page', 'a-z-listing' ); ?>
    127                 </label>
    128                 <input class="widefat" type="text"
    129                     id="<?php echo esc_attr( $target_post_title_id ); ?>"
    130                     name="<?php echo esc_attr( $target_post_title_name ); ?>"
    131                     value="<?php echo esc_attr( $target_post_title ); ?>" />
    132                 <input type="hidden"
    133                     id="<?php echo esc_attr( $target_post_id ); ?>"
    134                     name="<?php echo esc_attr( $target_post_name ); ?>"
    135                     value="<?php echo esc_attr( $target_post ); ?>" />
    136             </p>
    137         </div>
    138 
    139         <div>
    140             <p>
    141                 <label for="<?php echo esc_attr( $display_type_id ); ?>">
    142                     <?php esc_html_e( 'Display posts or terms?', 'a-z-listing' ); ?>
    143                 </label>
    144                 <select class="widefat"
    145                     id="<?php echo esc_attr( $display_type_id ); ?>"
    146                     name="<?php echo esc_attr( $display_type_name ); ?>">
    147                     <option value="posts"
    148                         <?php echo ( 'terms' !== $display_type ) ? 'selected' : ''; ?>>
    149                         <?php esc_html_e( 'Posts', 'a-z-listing' ); ?>
    150                     </option>
    151                     <option value="terms"
    152                         <?php echo ( 'terms' === $display_type ) ? 'selected' : ''; ?>>
    153                         <?php esc_html_e( 'Taxonomy terms', 'a-z-listing' ); ?>
    154                     </option>
    155                 </select>
    156             </p>
    157         </div>
    158 
    159         <div <?php echo ( 'terms' !== $display_type ) ? '' : 'style="display: none;"'; ?>
    160             id="<?php echo esc_attr( $listing_post_type_wrapper_id ); ?>">
    161             <p>
    162                 <label for="<?php echo esc_attr( $listing_post_type_id ); ?>">
    163                     <?php esc_html_e( 'Post-type to display', 'a-z-listing' ); ?>
    164                 </label>
    165                 <select class="widefat"
    166                     id="<?php echo esc_attr( $listing_post_type_id ); ?>"
    167                     name="<?php echo esc_attr( $listing_post_type_name ); ?>"
    168                     <?php echo ( 'terms' !== $display_type ) ? '' : 'disabled'; ?>>
    169                     <?php foreach ( $public_post_types as $k => $t ) : ?>
    170                         <option value="<?php echo esc_attr( $k ); ?>"
    171                             <?php echo ( $k === $listing_post_type ) ? 'selected' : ''; ?>>
    172                             <?php echo esc_html( $t->labels->name ); ?>
    173                         </option>
    174                     <?php endforeach; ?>
    175                 </select>
    176             </p>
    177         </div>
    178 
    179         <div <?php echo ( 'terms' === $display_type ) ? '' : 'style="display: none;"'; ?>
    180             id="<?php echo esc_attr( $listing_taxonomy_wrapper_id ); ?>">
    181             <p>
    182                 <label for="<?php echo esc_attr( $listing_taxonomy_id ); ?>">
    183                     <?php esc_html_e( 'Taxonomy to display', 'a-z-listing' ); ?>
    184                 </label>
    185                 <select class="widefat"
    186                     id="<?php echo esc_attr( $listing_taxonomy_id ); ?>"
    187                     name="<?php echo esc_attr( $listing_taxonomy_name ); ?>"
    188                     <?php echo ( 'terms' === $display_type ) ? '' : 'disabled'; ?>>
    189                     <?php foreach ( $public_taxonomies as $k => $t ) : ?>
    190                         <option value="<?php echo esc_attr( $k ); ?>"
    191                             <?php echo ( $k === $listing_taxonomy ) ? 'selected' : ''; ?>>
    192                             <?php echo esc_html( $t->labels->name ); ?>
    193                         </option>
    194                     <?php endforeach; ?>
    195                 </select>
    196             </p>
    197         </div>
    198 
    199         <div <?php echo ( 'terms' === $display_type ) ? '' : 'style="display: none;"'; ?>
    200             id="<?php echo esc_attr( $listing_parent_term_wrapper_id ); ?>">
    201             <p>
    202                 <label for="<?php echo esc_attr( $listing_parent_term_id ); ?>">
    203                     <?php esc_html_e( 'Parent term to display children of', 'a-z-listing' ); ?>
    204                 </label>
    205                 <input class="widefat" type="text"
    206                     id="<?php echo esc_attr( $listing_parent_term_id ); ?>"
    207                     name="<?php echo esc_attr( $listing_parent_term_name ); ?>"
    208                     value="<?php echo esc_attr( $listing_parent_term ); ?>" />
    209             </p>
    210         </div>
    211 
    212         <div>
    213             <p>
    214                 <label for="<?php echo esc_attr( $listing_terms_include_id ); ?>">
    215                     <?php esc_html_e( 'Terms to include (IDs)', 'a-z-listing' ); ?>
    216                 </label>
    217                 <input class="widefat" type="text"
    218                     id="<?php echo esc_attr( $listing_terms_include_id ); ?>"
    219                     name="<?php echo esc_attr( $listing_terms_include_name ); ?>"
    220                     value="<?php echo esc_attr( $listing_terms_include ); ?>" />
    221             </p>
    222         </div>
    223 
    224         <div <?php echo ( 'terms' === $display_type ) ? '' : 'style="display: none;"'; ?>
    225             id="<?php echo esc_attr( $listing_terms_exclude_wrapper_id ); ?>">
    226             <p>
    227                 <label for="<?php echo esc_attr( $listing_terms_exclude_id ); ?>">
    228                     <?php esc_html_e( 'Terms to exclude (IDs)', 'a-z-listing' ); ?>
    229                 </label>
    230                 <input class="widefat" type="text"
    231                     id="<?php echo esc_attr( $listing_terms_exclude_id ); ?>"
    232                     name="<?php echo esc_attr( $listing_terms_exclude_name ); ?>"
    233                     value="<?php echo esc_attr( $listing_terms_exclude ); ?>" />
    234             </p>
    235         </div>
    236 
    237         <div <?php echo ( 'terms' === $display_type ) ? '' : 'style="display: none;"'; ?>
    238             id="<?php echo esc_attr( $listing_hide_empty_terms_wrapper_id ); ?>">
    239             <p>
    240                 <label for="<?php echo esc_attr( $listing_hide_empty_terms_id ); ?>">
    241                     <?php esc_html_e( 'Hide empty terms', 'a-z-listing' ); ?>
    242                 </label>
    243                 <input type="checkbox"
    244                     id="<?php echo esc_attr( $listing_hide_empty_terms_id ); ?>"
    245                     name="<?php echo esc_attr( $listing_hide_empty_terms_name ); ?>"
    246                     <?php echo ( isset( $listing_hide_empty_terms ) && 'true' === $listing_hide_empty_terms ) ? 'checked' : ''; ?> />
    247             </p>
    248         </div>
    249 
    250         <script type="text/javascript">
    251             jQuery(document).ready(function($) {
    252                 const target_post                      = document.getElementById( '<?php echo esc_html( $target_post_id ); ?>' );
    253                 const target_post_title                = document.getElementById( '<?php echo esc_html( $target_post_title_id ); ?>' );
    254                 const display_type                     = document.getElementById( '<?php echo esc_html( $display_type_id ); ?>' );
    255                 const listing_post_type                = document.getElementById( '<?php echo esc_html( $listing_post_type_id ); ?>' );
    256                 const listing_post_type_wrapper        = document.getElementById( '<?php echo esc_html( $listing_post_type_wrapper_id ); ?>' );
    257                 const listing_taxonomy                 = document.getElementById( '<?php echo esc_html( $listing_taxonomy_id ); ?>' );
    258                 const listing_taxonomy_wrapper         = document.getElementById( '<?php echo esc_html( $listing_taxonomy_wrapper_id ); ?>' );
    259                 const listing_parent_term              = document.getElementById( '<?php echo esc_html( $listing_parent_term_id ); ?>' );
    260                 const listing_parent_term_wrapper      = document.getElementById( '<?php echo esc_html( $listing_parent_term_wrapper_id ); ?>' );
    261                 const listing_hide_empty_terms         = document.getElementById( '<?php echo esc_html( $listing_hide_empty_terms_id ); ?>' );
    262                 const listing_hide_empty_terms_wrapper = document.getElementById( '<?php echo esc_html( $listing_hide_empty_terms_wrapper_id ); ?>' );
    263                 const listing_terms_exclude            = document.getElementById( '<?php echo esc_html( $listing_terms_exclude_id ); ?>' );
    264                 const listing_terms_exclude_wrapper    = document.getElementById( '<?php echo esc_html( $listing_terms_exclude_wrapper_id ); ?>' );
    265 
    266                 function switch_taxonomy_or_posts() {
    267                     if ( 'terms' === display_type.value ) {
    268                         listing_post_type.setAttribute( 'disabled', 'disabled' );
    269                         listing_post_type_wrapper.style.display = 'none';
    270                         listing_taxonomy.removeAttribute( 'disabled' );
    271                         listing_taxonomy_wrapper.style.display = 'unset';
    272                         listing_parent_term.removeAttribute( 'disabled' );
    273                         listing_parent_term_wrapper.style.display = 'unset';
    274                         listing_hide_empty_terms.removeAttribute( 'disabled' );
    275                         listing_hide_empty_terms_wrapper.style.display = 'unset';
    276                         listing_terms_exclude.removeAttribute( 'disabled' );
    277                         listing_terms_exclude_wrapper.style.display = 'unset';
    278                     } else {
    279                         listing_post_type.removeAttribute( 'disabled' );
    280                         listing_post_type_wrapper.style.display = 'unset';
    281                         listing_taxonomy.setAttribute( 'disabled', 'disabled' );
    282                         listing_taxonomy_wrapper.style.display = 'none';
    283                         listing_parent_term.setAttribute( 'disabled', 'disabled' );
    284                         listing_parent_term_wrapper.style.display = 'none';
    285                         listing_hide_empty_terms.setAttribute( 'disabled', 'disabled' );
    286                         listing_hide_empty_terms_wrapper.style.display = 'none';
    287                         listing_terms_exclude.setAttribute( 'disabled', 'disabled' );
    288                         listing_terms_exclude_wrapper.style.display = 'none';
    289                     }
    290                 }
    291                 switch_taxonomy_or_posts();
    292                 display_type.addEventListener( 'change', switch_taxonomy_or_posts );
    293 
    294                 $( target_post_title ).autocomplete( {
    295                     source: function( post_title, response ) {
    296                         $.ajax( {
    297                             url:      '/wp-admin/admin-ajax.php',
    298                             type:     'POST',
    299                             dataType: 'json',
    300                             data: {
    301                                 action:     'get_a_z_listing_autocomplete_post_titles',
    302                                 post_title,
    303                             },
    304                             success: function( data ) {
    305                                 response( data );
    306                             },
    307                             error: function() {
    308                                 response();
    309                             },
    310                         } );
    311                     },
    312                     select: function( event, ui ) {
    313                         event.preventDefault();
    314                         target_post.value       = ui.item.value;
    315                         target_post_title.value = ui.item.label;
    316                     },
    317                 } );
    318             } );
    319         </script>
    320288        <?php
    321289    }
     
    337305        $instance['target_post_title'] = strip_tags( $new_instance['target_post_title'] );
    338306        $instance['post_type']         = strip_tags( $new_instance['post_type'] );
    339         $instance['parent']            = (int) $new_instance['parent'];
    340307        $instance['taxonomy']          = strip_tags( $new_instance['taxonomy'] );
     308        $instance['parent_post']       = (int) $new_instance['parent_post'];
     309        $instance['all_children']      = 'on' === $new_instance['all_children'] ? 'true' : 'false';
    341310        $instance['parent_term']       = strip_tags( $new_instance['parent_term'] );
    342311        $instance['terms']             = strip_tags( $new_instance['terms'] );
     
    344313        $instance['hide_empty_terms']  = 'on' === $new_instance['hide_empty_terms'] ? 'true' : 'false';
    345314
    346         if ( empty( $instance['target_post_title'] ) ) {
     315        if ( empty( $new_instance['target_post_title'] ) ) {
    347316            $instance['post'] = 0;
     317        }
     318        if ( empty( $new_instance['parent_post_title'] ) ) {
     319            $instance['parent_post'] = 0;
    348320        }
    349321
     
    419391        $instance,
    420392        array(
     393            'all_children'     => 'true',
     394            'exclude_terms'    => '',
     395            'hide_empty_terms' => false,
     396            'parent_post'      => '',
     397            'parent_term'      => '',
     398            'post'             => -1, // target.
     399            'page'             => -1, // obsolete target.
     400            'post_type'        => 'page',
     401            'taxonomy'         => '',
     402            'terms'            => '',
    421403            'title'            => '',
    422             'post'             => -1, // target.
    423404            'type'             => 'posts',
    424             'taxonomy'         => '',
    425             'post_type'        => 'page',
    426             'terms'            => '',
    427             'exclude_terms'    => '',
    428             'parent_term'      => '',
    429             'hide_empty_terms' => false,
    430405        )
    431406    );
     
    433408    $title  = esc_html( $instance['title'] );
    434409    $target = '';
    435     if ( empty( $title ) ) {
    436         if ( $instance['post'] > 0 ) { // target.
    437             $title  = get_the_title( $instance['post'] );
    438             $target = get_the_permalink( $instance['post'] );
    439         } else {
    440             $title = esc_html__( 'A-Z Listing', 'a-z-listing' );
     410    if ( 0 < $instance['post'] || 0 < $instance['page'] ) { // target.
     411        $target_id = (int) $instance['post']; // target.
     412        if ( ! ( 0 < $instance['post'] ) ) {
     413            $target_id = (int) $instance['page']; // obsolete target.
    441414        }
    442     }
    443 
    444     $hide_empty = true === $instance['hide_empty_terms'] ? 'true' : 'false';
     415
     416        $target_url = get_the_permalink( $target_id );
     417        if ( empty( $title ) ) {
     418            $title = get_the_title( $target_id );
     419        }
     420    } elseif ( empty( $title ) ) {
     421        $title = esc_html__( 'A-Z Listing', 'a-z-listing' );
     422    }
     423
     424    $hide_empty_terms = true === $instance['hide_empty_terms'] ? 'true' : 'false';
    445425
    446426    $ret  = '';
     
    453433    $ret .= do_shortcode(
    454434        "[a-z-listing
    455             return='letters'
    456             target='{$target}'
     435            alphabet=''
    457436            display='{$instance['type']}'
    458             taxonomy='{$instance['taxonomy']}'
    459             alphabet=''
     437            exclude-posts=''
     438            exclude-terms='{$instance['exclude_terms']}'
     439            get-all-children='{$instance['all_children']}'
    460440            group-numbers=''
    461441            grouping=''
     442            hide-empty-terms='{$hide_empty_terms}'
    462443            numbers='hide'
     444            parent-post='{$instance['parent_post']}'
     445            parent-term='{$instance['parent_term']}'
    463446            post-type='{$instance['post_type']}'
    464             exclude-posts=''
     447            return='letters'
     448            target='{$target_url}'
     449            taxonomy='{$instance['taxonomy']}'
    465450            terms='{$instance['terms']}'
    466             exclude-terms='{$instance['exclude_terms']}'
    467             parent-term='{$instance['parent_term']}'
    468             hide-empty-terms='{$hide_empty}'
    469451        ]"
    470452    );
     
    476458
    477459/**
     460 * Retrive posts by title.
     461 *
     462 * @since 2.1.0
     463 * @param string $post_title the title to search for.
     464 * @param string $post_type the post type to search within.
     465 * @return array the post IDs that are found.
     466 */
     467function a_z_listing_get_posts_by_title( $post_title, $post_type = '' ) {
     468    global $wpdb;
     469
     470    $post_title = '%' . $wpdb->esc_like( $post_title ) . '%';
     471
     472    if ( ! empty( $post_type ) ) {
     473        return $wpdb->get_results(
     474            $wpdb->prepare(
     475                "SELECT `ID`, `post_title` FROM `$wpdb->posts`
     476                WHERE `post_title` LIKE %s AND `post_type` = %s AND `post_status` = 'publish'",
     477                $post_title,
     478                $post_type
     479            )
     480        );
     481    } else {
     482        return $wpdb->get_results(
     483            $wpdb->prepare(
     484                "SELECT `ID`, `post_title` FROM `$wpdb->posts`
     485                WHERE `post_title` LIKE %s AND `post_status` = 'publish'",
     486                $post_title
     487            )
     488        );
     489    }
     490}
     491
     492/**
    478493 * Ajax responder for A_Z_Listing_Widget configuration
     494 *
     495 * @since 2.0.0
    479496 */
    480497function a_z_listing_autocomplete_post_titles() {
    481     global $wpdb;
    482 
    483     $post_title = '%' . $wpdb->esc_like( stripslashes( $_POST['post_title']['term'] ) ) . '%';
    484 
    485     $results = $wpdb->get_results(
    486         $wpdb->prepare(
    487             "SELECT `ID`, `post_title` FROM `$wpdb->posts`
    488             WHERE `post_title` LIKE %s AND `post_status` = 'publish'",
    489             $post_title
    490         )
    491     );
     498    $post_title = stripslashes( $_POST['post_title']['term'] );
     499    $post_type  = stripslashes( $_POST['post_type'] );
     500
     501    $results = a_z_listing_get_posts_by_title( $post_title, $post_type );
    492502
    493503    $titles = array();
     
    518528/**
    519529 * Enqueue the jquery-ui autocomplete script
     530 *
     531 * @since 2.0.0
    520532 */
    521533function a_z_listing_autocomplete_script() {
Note: See TracChangeset for help on using the changeset viewer.