Changeset 2003543
- Timestamp:
- 12/29/2018 06:22:40 PM (7 years ago)
- Location:
- a-z-listing
- Files:
-
- 60 added
- 23 edited
-
tags/2.1.0 (added)
-
tags/2.1.0/.distignore (added)
-
tags/2.1.0/.editorconfig (added)
-
tags/2.1.0/.jshintrc (added)
-
tags/2.1.0/.svnignore (added)
-
tags/2.1.0/Gruntfile.js (added)
-
tags/2.1.0/LICENSE (added)
-
tags/2.1.0/README.md (added)
-
tags/2.1.0/a-z-listing.php (added)
-
tags/2.1.0/changelog.md (added)
-
tags/2.1.0/classes (added)
-
tags/2.1.0/classes/class-a-z-listing-grouping.php (added)
-
tags/2.1.0/classes/class-a-z-listing-indices.php (added)
-
tags/2.1.0/classes/class-a-z-listing-numbers.php (added)
-
tags/2.1.0/classes/class-a-z-listing-singleton.php (added)
-
tags/2.1.0/classes/class-a-z-listing.php (added)
-
tags/2.1.0/composer.json (added)
-
tags/2.1.0/composer.lock (added)
-
tags/2.1.0/css (added)
-
tags/2.1.0/css/a-z-listing-customize.css (added)
-
tags/2.1.0/css/a-z-listing-customize.css.map (added)
-
tags/2.1.0/css/a-z-listing-customize.scss (added)
-
tags/2.1.0/css/a-z-listing-default.css (added)
-
tags/2.1.0/css/a-z-listing-default.css.map (added)
-
tags/2.1.0/css/a-z-listing-default.scss (added)
-
tags/2.1.0/css/mixins.css (added)
-
tags/2.1.0/css/mixins.scss (added)
-
tags/2.1.0/docker-compose.yml (added)
-
tags/2.1.0/functions (added)
-
tags/2.1.0/functions/enqueues.php (added)
-
tags/2.1.0/functions/helpers.php (added)
-
tags/2.1.0/functions/i18n.php (added)
-
tags/2.1.0/functions/scripts.php (added)
-
tags/2.1.0/functions/shortcode.php (added)
-
tags/2.1.0/functions/styles.php (added)
-
tags/2.1.0/interfaces (added)
-
tags/2.1.0/interfaces/interface-a-z-listing-extension.php (added)
-
tags/2.1.0/languages (added)
-
tags/2.1.0/languages/a-z-listing.pot (added)
-
tags/2.1.0/package-lock.json (added)
-
tags/2.1.0/package.json (added)
-
tags/2.1.0/phpcs.xml.dist (added)
-
tags/2.1.0/phpunit.xml.dist (added)
-
tags/2.1.0/readme.txt (added)
-
tags/2.1.0/scripts (added)
-
tags/2.1.0/scripts/a-z-listing-scroll-fix.js (added)
-
tags/2.1.0/scripts/a-z-listing-tabs.js (added)
-
tags/2.1.0/scripts/a-z-listing-widget-admin.js (added)
-
tags/2.1.0/templates (added)
-
tags/2.1.0/templates/a-z-listing.example.php (added)
-
tags/2.1.0/templates/a-z-listing.php (added)
-
tags/2.1.0/widgets (added)
-
tags/2.1.0/widgets/class-a-z-listing-widget.php (added)
-
tags/2.1.0/wp-includes (added)
-
tags/2.1.0/wp-includes/version.php (added)
-
trunk/Gruntfile.js (modified) (1 diff)
-
trunk/README.md (modified) (12 diffs)
-
trunk/a-z-listing.php (modified) (1 diff)
-
trunk/changelog.md (modified) (2 diffs)
-
trunk/classes/class-a-z-listing-grouping.php (modified) (3 diffs)
-
trunk/classes/class-a-z-listing-indices.php (modified) (5 diffs)
-
trunk/classes/class-a-z-listing-numbers.php (modified) (3 diffs)
-
trunk/classes/class-a-z-listing.php (modified) (22 diffs)
-
trunk/css/a-z-listing-customize.css (added)
-
trunk/css/a-z-listing-customize.css.map (added)
-
trunk/css/a-z-listing-customize.scss (added)
-
trunk/css/a-z-listing-default.css (modified) (3 diffs)
-
trunk/css/a-z-listing-default.css.map (modified) (1 diff)
-
trunk/css/a-z-listing-default.scss (modified) (3 diffs)
-
trunk/functions/enqueues.php (modified) (2 diffs)
-
trunk/functions/helpers.php (modified) (16 diffs)
-
trunk/functions/scripts.php (modified) (1 diff)
-
trunk/functions/shortcode.php (modified) (10 diffs)
-
trunk/functions/styles.php (modified) (1 diff)
-
trunk/languages/a-z-listing.pot (modified) (6 diffs)
-
trunk/package-lock.json (modified) (2 diffs)
-
trunk/readme.txt (modified) (12 diffs)
-
trunk/scripts/a-z-listing-scroll-fix.js (added)
-
trunk/scripts/a-z-listing-tabs.js (modified) (1 diff)
-
trunk/scripts/a-z-listing-widget-admin.js (added)
-
trunk/templates/a-z-listing.example.php (modified) (1 diff)
-
trunk/templates/a-z-listing.php (modified) (2 diffs)
-
trunk/widgets/class-a-z-listing-widget.php (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
a-z-listing/trunk/Gruntfile.js
r1939419 r2003543 94 94 dist: { 95 95 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' 97 98 } 98 99 } -
a-z-listing/trunk/README.md
r1942709 r2003543 6 6 **Requires at least:** 4.6 7 7 **Requires PHP:** 5.6 8 **Tested up to:** 4.99 **Stable tag:** 2. 0.58 **Tested up to:** 5.0 9 **Stable tag:** 2.1.0 10 10 **License:** GPLv2 or later 11 11 **License URI:** http://www.gnu.org/licenses/gpl-2.0.html … … 230 230 ### How do I show posts of a different post-type (not pages) or multiple post-types (e.g. posts AND pages) ### 231 231 232 This can be achieved using the shortcode or PHP. 232 This 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`). 233 233 234 234 #### Shortcode method #### … … 268 268 ``` 269 269 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)270 The 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) 271 271 272 272 The 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. … … 274 274 ### How do I show posts from a specific category only ### 275 275 276 This can be achieved using the shortcode or PHP. 276 This 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`). 277 277 278 278 #### Shortcode method #### … … 304 304 ``` 305 305 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)306 Any 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 308 The 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) 309 309 310 310 The 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. … … 312 312 ### How do I show terms from a taxonomy instead of posts ### 313 313 314 This can be achieved using the shortcode or PHP. 314 This 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`). 315 315 316 316 #### Shortcode method #### … … 332 332 ``` 333 333 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`.334 The 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`. 335 335 336 336 The 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. … … 356 356 ```php 357 357 <?php 358 add_action( ' wp', 'a_z_listing_force_enable_styles', 99 );358 add_action( 'init', 'a_z_listing_force_enable_styles', 99 ); 359 359 ?> 360 360 ``` … … 368 368 ```php 369 369 <?php 370 add_action( ' wp', 'your_override_wrapper_function', 99 );370 add_action( 'init', 'your_override_wrapper_function', 99 ); 371 371 function your_override_wrapper_function() { 372 372 if ( ! is_page( 'your-a-z-listing-page-slug-or-ID' ) ) { // ID is numeric, slug is a string. … … 415 415 ## Changelog ## 416 416 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 417 437 ### 2.0.6 ### 418 438 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.420 439 * Fix widget target post support 421 440 * Fix filtering posts by multiple taxonomy terms … … 425 444 * Fix javascript error on widgets screen 426 445 427 ### ## 2.0.0 also introduced the following changes: #####446 ### 2.0.0 ### 428 447 429 448 * Improved widget configuration. … … 436 455 * Fix the stylesheet to better cope with variances in font-size and text length in the alphabet links list and widget. 437 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. 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._ 498 473 499 474 ### Previous ### -
a-z-listing/trunk/a-z-listing.php
r1942709 r2003543 8 8 * Text Domain: a-z-listing 9 9 * Domain Path: /languages 10 * Version: 2. 0.610 * Version: 2.1.0 11 11 * 12 12 * @package A_Z_Listing -
a-z-listing/trunk/changelog.md
r1942709 r2003543 1 1 # Full Changelog # 2 2 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. 6 26 * Fix widget target post support 7 27 8 ## # 2.0.5 ###28 ## 2.0.5 ## 9 29 10 30 * Fix filtering posts by multiple taxonomy terms 11 31 12 ## # 2.0.4 ###32 ## 2.0.4 ## 13 33 14 34 * Fix styling error causing two or more posts to sometimes appear on the same line 15 35 16 ## # 2.0.3 ###36 ## 2.0.3 ## 17 37 18 38 * Minor style tweak to fix short listings, and long titles 19 39 20 ## # 2.0.2 ###40 ## 2.0.2 ## 21 41 22 42 * Fix broken styling in 2.0.0 23 43 24 ## # 2.0.1 ###44 ## 2.0.1 ## 25 45 26 46 * Fix javascript error on widgets screen 27 47 28 ## # 2.0.0 ###48 ## 2.0.0 ## 29 49 30 50 * Improved widget configuration. … … 37 57 * Fix the stylesheet to better cope with variances in font-size and text length in the alphabet links list and widget. 38 58 * 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.* 50 71 51 72 ## 1.9.1 ## -
a-z-listing/trunk/classes/class-a-z-listing-grouping.php
r1939419 r2003543 31 31 */ 32 32 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 } 33 48 34 49 /** … … 66 81 public function alphabet_filter( $alphabet ) { 67 82 $headings = array(); 68 $letters = mb_split( ',', $alphabet );83 $letters = explode( ',', $alphabet ); 69 84 $letters = array_map( 'trim', $letters ); 70 85 … … 82 97 $carry[ $j ] = $carry[ $j ] . $letter; 83 98 } 84 $headings[ $j ][] = mb_substr( $letter, 0, 1 );99 $headings[ $j ][] = A_Z_Listing_Grouping::maybe_mb_substr( $letter, 0, 1 ); 85 100 86 101 if ( $i + 1 === $grouping ) { -
a-z-listing/trunk/classes/class-a-z-listing-indices.php
r1939419 r2003543 22 22 23 23 /** 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 /** 24 37 * Find and return the index letter for a post 25 38 * … … 41 54 } 42 55 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 ); 44 65 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 } 50 105 51 106 if ( 'terms' === $type ) { … … 53 108 * Modify the indice(s) to group this term under 54 109 * 55 * @deprecated Use a_z_listing_item_ind ices56 * @see a_z_listing_item_ind ices110 * @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 57 112 */ 58 $indices = apply_filters_deprecated( 'a_z_listing_term_indices', array( $indices, $item ), '1.0.0', 'a_z_listing_item_ind ices' );113 $indices = apply_filters_deprecated( 'a_z_listing_term_indices', array( $indices, $item ), '1.0.0', 'a_z_listing_item_index_letter' ); 59 114 } else { 60 115 /** 61 116 * Modify the indice(s) to group this post under 62 117 * 63 * @deprecated Use a_z_listing_item_ind ices64 * @see a_z_listing_item_ind ices118 * @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 65 120 */ 66 $indices = apply_filters_deprecated( 'a_z_listing_post_indices', array( $indices, $item ), '1.5.0', 'a_z_listing_item_ind ices' );121 $indices = apply_filters_deprecated( 'a_z_listing_post_indices', array( $indices, $item ), '1.5.0', 'a_z_listing_item_index_letter' ); 67 122 } // End if. 68 123 … … 70 125 * Modify the indice(s) to group this item under 71 126 * 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 72 131 * @param array $indices The current indices 73 132 * @param WP_Term|WP_Post $item The item 74 133 * @param string $item_type The type of the item. Either 'posts' or 'terms'. 75 134 */ 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' ); 77 136 78 137 /** … … 80 139 * 81 140 * @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 82 144 * @param array $indices The current indices 83 145 * @param WP_Term|WP_Post $item The item 84 146 * @param string $item_type The type of the item. Either 'posts' or 'terms'. 85 147 */ 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' ); 87 149 88 150 if ( AZLISTINGLOG > 2 ) { -
a-z-listing/trunk/classes/class-a-z-listing-numbers.php
r1939419 r2003543 17 17 class A_Z_Listing_Numbers { 18 18 /** 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 /** 19 33 * Add filters to append or prepend numbers to the alphabet with optional grouping 20 34 * … … 23 37 * @param bool $group Whether to group the numbers into a single heading or individually. 24 38 */ 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 } 31 46 } 32 47 … … 49 64 */ 50 65 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 52 70 if ( true === $this->group ) { 53 71 $numbers = '0123456789'; 72 } else { 73 $numbers = '0,1,2,3,4,5,6,7,8,9'; 54 74 } 55 75 -
a-z-listing/trunk/classes/class-a-z-listing.php
r1941011 r2003543 203 203 $query = (array) $query; 204 204 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 } 210 209 } 211 210 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 212 220 $query = wp_parse_args( 213 (array)$query,221 $query, 214 222 array( 215 223 'post_type' => 'page', … … 225 233 226 234 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; 234 236 $this->query = $query; 235 237 } 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 } 239 246 } 240 247 … … 297 304 */ 298 305 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 ); 305 315 } 306 316 … … 348 358 $others = apply_filters( 'a-z-listing-non-alpha-char', $others ); 349 359 350 $alphabet_groups = mb_split( ',', $alphabet );360 $alphabet_groups = explode( ',', $alphabet ); 351 361 $letters = array_reduce( 352 362 $alphabet_groups, … … 524 534 $index = $this->alphabet[ $index ]; 525 535 } else { 526 $index = '_';536 $index = $this->unknown_letters; 527 537 } 528 538 … … 535 545 } 536 546 537 if ( ! empty( $index[ $this->unknown_letters ] ) ) {547 if ( array_key_exists( $this->unknown_letters, $indexed_items ) && ! empty( $indexed_items[ $this->unknown_letters ] ) ) { 538 548 $this->alphabet_chars[] = $this->unknown_letters; 539 549 } … … 581 591 582 592 /** 583 * Ret urnthe letter links HTML593 * Retrieve the letter links HTML 584 594 * 585 595 * @since 1.0.0 … … 644 654 645 655 /** 646 * Load and execute a theme template647 *648 * @since 1.0.0649 * @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 /**659 656 * Print the index list HTML created by a theme template 660 657 * … … 673 670 $template = locate_template( array( 'a-z-listing-' . $section . '.php', 'a-z-listing.php' ) ); 674 671 if ( $template ) { 675 $this->do_template($template );672 a_z_listing_do_template( $this, $template ); 676 673 } 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' ); 678 675 } 679 676 wp_reset_postdata(); … … 681 678 682 679 /** 683 * Ret urnthe index list HTML created by a theme template680 * Retrieve the index list HTML created by a theme template 684 681 * 685 682 * @since 0.7 … … 778 775 779 776 /** 780 * Getthe item object for the current post777 * Retrieve the item object for the current post 781 778 * 782 779 * @since 2.0.0 … … 787 784 */ 788 785 public function get_the_item_object( $force = '' ) { 786 global $post; 789 787 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; 795 801 } 796 797 global $post; 798 $post = get_post( $item[1] ); 802 } 803 804 if ( is_a( $current_item, 'WP_Post' ) ) { 805 $post = $current_item; 799 806 setup_postdata( $post ); 800 807 801 808 return $post; 802 809 } 810 811 return $current_item; 803 812 } 804 813 … … 807 816 808 817 /** 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 810 845 * 811 846 * @since 1.0.0 … … 817 852 818 853 /** 819 * Ret urnthe number of posts within the current letter854 * Retrieve the number of posts within the current letter 820 855 * 821 856 * @since 0.7 … … 829 864 830 865 /** 831 * Ret urnthe number of posts within the current letter866 * Retrieve the number of posts within the current letter 832 867 * 833 868 * @since 0.7 … … 850 885 851 886 /** 852 * Ret urnthe number of posts within the current letter887 * Retrieve the number of posts within the current letter 853 888 * 854 889 * @since 1.0.0 … … 869 904 870 905 /** 871 * Ret urnthe ID of the current letter. This is not escaped!906 * Retrieve the ID of the current letter. This is not escaped! 872 907 * 873 908 * @since 0.7 … … 889 924 890 925 /** 891 * Ret urnthe 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! 892 927 * 893 928 * @since 0.7 … … 936 971 937 972 /** 938 * Ret urnthe title of the current post. This is not escaped!973 * Retrieve the title of the current post. This is not escaped! 939 974 * 940 975 * @since 1.0.0 … … 943 978 public function get_the_title() { 944 979 $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 951 1002 return $title; 952 1003 } … … 962 1013 963 1014 /** 964 * Ret urnthe permalink of the current post. This is not escaped!1015 * Retrieve the permalink of the current post. This is not escaped! 965 1016 * 966 1017 * @since 1.0.0 … … 970 1021 return $this->current_item['link']; 971 1022 } 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 */ 1032 function a_z_listing_do_template( $a_z_query, $template_file ) { 1033 require $template_file; 972 1034 } 973 1035 -
a-z-listing/trunk/css/a-z-listing-default.css
r1940891 r2003543 16 16 height: 2em; 17 17 box-sizing: border-box; 18 margin: 0 .15em;18 margin: 0 0 0.6em; 19 19 border: 2px solid #e5e5e5; 20 20 background: #f5f5f5; … … 46 46 box-sizing: border-box; 47 47 column-gap: 0.6em; 48 column-width: 1 0em;48 column-width: 15em; 49 49 line-height: 1.6em; } 50 50 .letter-section ul.columns li { … … 52 52 .letter-section ul.columns.max-0-columns, .letter-section ul.columns.max-1-columns { 53 53 column-count: 1; 54 max-width: 1 0.6em; }54 max-width: 15.6em; } 55 55 .letter-section ul.columns.max-2-columns { 56 56 column-count: 2; 57 max-width: 20.6em; }57 max-width: 30.6em; } 58 58 .letter-section ul.columns.max-3-columns { 59 59 column-count: 3; 60 max-width: 31.2em; }60 max-width: 46.2em; } 61 61 .letter-section ul.columns.max-4-columns { 62 62 column-count: 4; 63 max-width: 41.8em; }63 max-width: 61.8em; } 64 64 .letter-section ul.columns.max-5-columns { 65 65 column-count: 5; 66 max-width: 52.4em; }66 max-width: 77.4em; } 67 67 .letter-section ul.columns.max-6-columns { 68 68 column-count: 6; 69 max-width: 63em; }69 max-width: 93em; } 70 70 .letter-section ul.columns.max-7-columns { 71 71 column-count: 7; 72 max-width: 73.6em; }72 max-width: 108.6em; } 73 73 .letter-section ul.columns.max-8-columns { 74 74 column-count: 8; 75 max-width: 84.2em; }75 max-width: 124.2em; } 76 76 .letter-section ul.columns.max-9-columns { 77 77 column-count: 9; 78 max-width: 94.8em; }78 max-width: 139.8em; } 79 79 .letter-section ul.columns.max-10-columns { 80 80 column-count: 10; 81 max-width: 1 05.4em; }81 max-width: 155.4em; } 82 82 .letter-section ul.columns.max-11-columns { 83 83 column-count: 11; 84 max-width: 1 16em; }84 max-width: 171em; } 85 85 .letter-section ul.columns.max-12-columns { 86 86 column-count: 12; 87 max-width: 1 26.6em; }87 max-width: 186.6em; } 88 88 .letter-section ul.columns.max-13-columns { 89 89 column-count: 13; 90 max-width: 137.2em; }90 max-width: 202.2em; } 91 91 .letter-section ul.columns.max-14-columns { 92 92 column-count: 14; 93 max-width: 147.8em; }93 max-width: 217.8em; } 94 94 .letter-section ul.columns.max-15-columns { 95 95 column-count: 15; 96 max-width: 158.4em; }96 max-width: 233.4em; } 97 97 .letter-section div.back-to-top { 98 98 width: 100%; -
a-z-listing/trunk/css/a-z-listing-default.css.map
r1940891 r2003543 7 7 ], 8 8 "names": [], 9 "mappings": "AAEA,AAGC,WAHU,CAGV,EAAE,AAAA,SAAS;AAFZ,mBAAmB,CAAC,WAAW,CAE9B,EAAE,AAAA,SAAS;AADZ,mBAAmB,AAAA,OAAO,CAAC,WAAW,CACrC,EAAE,AAAA,SAAS,CAAC;EACX,OAAO,EAAE,CAAC;EACV,MAAM,EAAE,CAAC;EACT,KAAK,EAAE,IAAI;EACX,OAAO,EAAE,IAAI;EACb,cAAc,EAAE,GAAG;EACnB,SAAS,EAAE,IAAI;EACf,eAAe,EAAE,MAAM,GAoBvB;EA9BF,AAWE,WAXS,CAGV,EAAE,AAAA,SAAS,CAQV,EAAE;EAVJ,m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,KAAK,GAWjB;IA/CF,AAqCE,eArCa,CAkCd,GAAG,AAAA,YAAY,CAGd,CAAC,CAAC;MACD,cAAc,EAAE,SAAS;MACzB,SAAS,EAAE,KAAK,GAOhB;MA9CH,AAwCG,eAxCY,CAkCd,GAAG,AAAA,YAAY,CAGd,CAAC,AAGC,OAAO,EAxCX,eAAe,CAkCd,GAAG,AAAA,YAAY,CAGd,CAAC,AAIC,MAAM,CAAC;QACP,WAAW,EAAE,SAAS;QACtB,OAAO,EAAE,OAAO;QAChB,OAAO,EAAE,KAAK,GACd" 10 10 } -
a-z-listing/trunk/css/a-z-listing-default.scss
r1940891 r2003543 17 17 height: 2em; 18 18 box-sizing: border-box; 19 margin: 0 .15em;19 margin: 0 0 0.6em; 20 20 border: 2px solid #e5e5e5; 21 21 background: #f5f5f5; … … 51 51 box-sizing: border-box; 52 52 column-gap: 0.6em; 53 column-width: 1 0em;53 column-width: 15em; 54 54 line-height: 1.6em; 55 55 li { … … 59 59 &.max-1-columns { 60 60 column-count: 1; 61 max-width: 1 0.6em;61 max-width: 15.6em; 62 62 } 63 63 @for $column from 2 to 16 { 64 64 &.max-#{$column}-columns { 65 65 column-count: $column; 66 max-width: ($column * 1 0em) + (($column - 1) * 0.6em);66 max-width: ($column * 15em) + (($column - 1) * 0.6em); 67 67 } 68 68 } -
a-z-listing/trunk/functions/enqueues.php
r1939516 r2003543 17 17 */ 18 18 function 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 ); 21 52 22 53 $add_styles = get_option( 'a-z-listing-add-styling', true ); … … 42 73 add_action( 'wp_enqueue_scripts', 'a_z_listing_enqueue_styles' ); 43 74 } 75 76 add_action( 'customize_controls_enqueue_scripts', 'a_z_listing_customize_enqueue_styles' ); 44 77 45 78 $tabify = get_option( 'a-z-listing-add-tabs', false ); -
a-z-listing/trunk/functions/helpers.php
r1939419 r2003543 11 11 12 12 /** 13 * Ret urnswhether the query has any letters left13 * Retrieve whether the query has any letters left 14 14 * 15 15 * @since 0.7 … … 22 22 23 23 /** 24 * Returns whether the query has any posts left for the current letter24 * Whether the query has any posts left for the current letter 25 25 * 26 26 * @since 0.7 … … 34 34 35 35 /** 36 * Returns whether the query has any posts left for the current letter36 * Whether the query has any posts left for the current letter 37 37 * 38 38 * @since 0.8.0 … … 77 77 78 78 /** 79 * Ret urnsthe number of posts for the letter79 * Retrieve the number of posts for the letter 80 80 * 81 81 * @since 0.7 … … 89 89 90 90 /** 91 * Ret urnsthe number of posts for the letter91 * Retrieve the number of posts for the letter 92 92 * 93 93 * @since 0.7 … … 101 101 102 102 /** 103 * Ret urnsthe number of posts for the letter103 * Retrieve the number of posts for the letter 104 104 * 105 105 * @since 0.7 … … 123 123 124 124 /** 125 * Getthe number of letters for the query125 * Retrieve the number of letters for the query 126 126 * 127 127 * @since 1.0.0 … … 144 144 145 145 /** 146 * Getthe current letter ID146 * Retrieve the current letter ID 147 147 * 148 148 * @since 0.7 … … 165 165 166 166 /** 167 * Getthe current letter title167 * Retrieve the current letter title 168 168 * 169 169 * @since 0.7 … … 186 186 187 187 /** 188 * Getthe current item title188 * Retrieve the current item title 189 189 * 190 190 * @since 0.8.0 … … 207 207 208 208 /** 209 * Getthe current item permalink209 * Retrieve the current item permalink 210 210 * 211 211 * @since 0.8.0 … … 242 242 243 243 /** 244 * Ret urnsthe A-Z Index page content244 * Retrieve the A-Z Index page content 245 245 * 246 246 * @since 0.1 … … 258 258 259 259 /** 260 * Ret urnsthe index of posts ordered and segmented alphabetically260 * Retrieve the index of posts ordered and segmented alphabetically 261 261 * 262 262 * @since 0.8.0 … … 298 298 299 299 /** 300 * Ret urnsthe A-Z Letter list300 * Retrieve the A-Z Letter list 301 301 * 302 302 * @since 0.7 … … 314 314 315 315 /** 316 * Ret urnsthe A-Z Letter list316 * Retrieve the A-Z Letter list 317 317 * 318 318 * @since 0.8.0 … … 326 326 return a_z_listing_cache( $query, '', $use_cache )->get_the_letters( $target, $styling ); 327 327 } 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 */ 336 function 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 43 43 add_action( 'wp_enqueue_scripts', 'a_z_listing_force_enqueue_tabs' ); 44 44 } 45 46 /** 47 * Enqueue the widget configuration support script 48 * 49 * @since 2.1.0 50 */ 51 function 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 16 16 * @since 1.7.0 Add numbers attribute to append or prepend numerics to the listing. 17 17 * @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. 18 19 * @param array $attributes Provided by WordPress core. Contains the shortcode attributes. 19 20 * @return string The A-Z Listing HTML. … … 24 25 'alphabet' => '', 25 26 'display' => 'posts', 26 'group-numbers' => false, 27 'exclude-posts' => '', 28 'exclude-terms' => '', 29 'get-all-children' => 'false', 30 'group-numbers' => '', 27 31 'grouping' => '', 32 'hide-empty-terms' => 'false', 28 33 'numbers' => 'hide', 34 'parent-post' => '', 35 'parent-term' => '', 29 36 'post-type' => 'page', 30 'exclude-posts' => '', 37 'return' => 'listing', 38 'target' => '', 31 39 'taxonomy' => '', 32 40 'terms' => '', 33 'exclude-terms' => '',34 'hide-empty-terms' => false,35 'parent-term' => '',36 'return' => 'listing',37 'target' => '',38 41 ), 39 42 $attributes, … … 53 56 $grouping = $attributes['grouping']; 54 57 $group_numbers = false; 58 if ( ! empty( $attributes['group-numbers'] ) && a_z_listing_is_truthy( $attributes['group-numbers'] ) ) { 59 $group_numbers = true; 60 } 61 55 62 if ( 'numbers' === $grouping ) { 56 63 $group_numbers = true; … … 58 65 } else { 59 66 $grouping = intval( $grouping ); 60 if ( 1 < $grouping ) {67 if ( 1 < $grouping && empty( $attributes['group-numbers'] ) ) { 61 68 $group_numbers = true; 62 69 } 63 70 } 64 71 65 if ( true === $attributes['group-numbers'] ) {66 $group_numbers = true;67 }68 69 72 $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 ); 75 74 76 75 if ( 'terms' === $attributes['display'] && ! empty( $attributes['taxonomy'] ) ) { 77 76 $taxonomy = '' !== $attributes['taxonomy'] ? $attributes['taxonomy'] : 'category'; 78 77 $query = array( 79 'taxonomy' => $taxonomy, 78 'taxonomy' => $taxonomy, 79 'hide_empty' => isset( $attributes['hide_empty'] ) && a_z_listing_is_truthy( $attributes['hide-empty'] ), 80 80 ); 81 81 … … 91 91 92 92 if ( ! empty( $terms_string ) ) { 93 $terms = mb_split( ',', $terms_string );93 $terms = explode( ',', $terms_string ); 94 94 $terms = array_map( 'trim', $terms ); 95 95 $terms = array_map( 'intval', $terms ); … … 120 120 121 121 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 126 124 $query = wp_parse_args( 127 125 $query, … … 134 132 $a_z_query = new A_Z_Listing( $query, 'terms' ); 135 133 } else { 134 $post_type = explode( ',', $attributes['post-type'] ); 135 $post_type = array_map( 'trim', $post_type ); 136 136 137 $query = array( 137 'post_type' => $ attributes['post-type'],138 'post_type' => $post_type, 138 139 ); 139 140 140 141 if ( ! empty( $attributes['exclude-posts'] ) ) { 141 $exclude_posts = mb_split( ',', $attributes['exclude-posts'] );142 $exclude_posts = explode( ',', $attributes['exclude-posts'] ); 142 143 $exclude_posts = array_map( 'trim', $exclude_posts ); 143 144 $exclude_posts = array_map( 'intval', $exclude_posts ); … … 151 152 152 153 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 ) ); 159 155 } 160 156 } 161 157 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(); 162 169 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( 167 173 $terms, 168 174 function( $value ) { … … 170 176 } 171 177 ); 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; 186 208 } 187 209 … … 205 227 206 228 $grouping_obj->teardown(); 207 if ( null != $numbers_obj ) { 208 $numbers_obj->teardown(); 209 } 229 $numbers_obj->teardown(); 210 230 211 231 return $ret; -
a-z-listing/trunk/functions/styles.php
r1939419 r2003543 18 18 function a_z_listing_enqueue_styles( $force = false ) { 19 19 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' ) ) ) { 21 21 wp_enqueue_style( 'a-z-listing' ); 22 22 } 23 } 24 25 /** 26 * Enqueue A-Z customizer styles. 27 * 28 * @since 2.1.0 29 */ 30 function a_z_listing_customize_enqueue_styles() { 31 wp_enqueue_style( 'a-z-listing-admin' ); 23 32 } 24 33 -
a-z-listing/trunk/languages/a-z-listing.pot
r1942709 r2003543 3 3 msgid "" 4 4 msgstr "" 5 "Project-Id-Version: A-Z Listing 2. 0.6\n"5 "Project-Id-Version: A-Z Listing 2.1.0\n" 6 6 "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" 8 8 "MIME-Version: 1.0\n" 9 9 "Content-Type: text/plain; charset=utf-8\n" … … 25 25 "X-Generator: grunt-wp-i18n1.0.2\n" 26 26 27 #: classes/class-a-z-listing.php:3 1827 #: classes/class-a-z-listing.php:328 28 28 #. translators: List the aphabet of your language in the order that your 29 29 #. language prefers. list as groups of identical meanings but different … … 43 43 msgstr "" 44 44 45 #: classes/class-a-z-listing.php:3 2045 #: classes/class-a-z-listing.php:330 46 46 #. translators: This should be a single character to denote "all entries that 47 47 #. didn't fit under one of the alphabet character groups defined". This is used … … 52 52 msgstr "" 53 53 54 #: templates/a-z-listing.example.php:45 templates/a-z-listing.php: 5254 #: templates/a-z-listing.example.php:45 templates/a-z-listing.php:67 55 55 msgid "Back to top" 56 56 msgstr "" 57 57 58 #: templates/a-z-listing.example.php:53 templates/a-z-listing.php: 6258 #: templates/a-z-listing.example.php:53 templates/a-z-listing.php:81 59 59 msgid "There are no posts included in this index." 60 60 msgstr "" … … 64 64 msgstr "" 65 65 66 #: widgets/class-a-z-listing-widget.php: 2966 #: widgets/class-a-z-listing-widget.php:30 67 67 msgid "Alphabetised links to the A-Z site map" 68 68 msgstr "" 69 69 70 #: widgets/class-a-z-listing-widget.php:1 1071 #: widgets/class-a-z-listing-widget.php:1 1570 #: widgets/class-a-z-listing-widget.php:125 71 #: widgets/class-a-z-listing-widget.php:130 72 72 msgid "Widget Title" 73 73 msgstr "" 74 74 75 #: widgets/class-a-z-listing-widget.php:1 1975 #: widgets/class-a-z-listing-widget.php:134 76 76 msgid "" 77 77 "Leave the title field blank, above, to use the title from the page set in " … … 79 79 msgstr "" 80 80 81 #: widgets/class-a-z-listing-widget.php:1 2682 msgid "Site map A-Z page"81 #: widgets/class-a-z-listing-widget.php:141 82 msgid "Sitemap A-Z page" 83 83 msgstr "" 84 84 85 #: widgets/class-a-z-listing-widget.php:142 85 #: widgets/class-a-z-listing-widget.php:153 86 msgid "" 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." 89 msgstr "" 90 91 #: widgets/class-a-z-listing-widget.php:154 92 #: widgets/class-a-z-listing-widget.php:214 93 msgid "" 94 "Matching posts will be shown as you type. Click on the correct post from " 95 "the matches to update the setting." 96 msgstr "" 97 98 #: widgets/class-a-z-listing-widget.php:161 86 99 msgid "Display posts or terms?" 87 100 msgstr "" 88 101 89 #: widgets/class-a-z-listing-widget.php:1 49102 #: widgets/class-a-z-listing-widget.php:168 90 103 msgid "Posts" 91 104 msgstr "" 92 105 93 #: widgets/class-a-z-listing-widget.php:1 53106 #: widgets/class-a-z-listing-widget.php:172 94 107 msgid "Taxonomy terms" 95 108 msgstr "" 96 109 97 #: widgets/class-a-z-listing-widget.php:1 63110 #: widgets/class-a-z-listing-widget.php:181 98 111 msgid "Post-type to display" 99 112 msgstr "" 100 113 101 #: widgets/class-a-z-listing-widget.php:183 114 #: widgets/class-a-z-listing-widget.php:200 115 msgid "Show only children of this post (ID)" 116 msgstr "" 117 118 #: widgets/class-a-z-listing-widget.php:213 119 msgid "" 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." 123 msgstr "" 124 125 #: widgets/class-a-z-listing-widget.php:218 126 msgid "Include grand-children?" 127 msgstr "" 128 129 #: widgets/class-a-z-listing-widget.php:230 102 130 msgid "Taxonomy to display" 103 131 msgstr "" 104 132 105 #: widgets/class-a-z-listing-widget.php:2 03133 #: widgets/class-a-z-listing-widget.php:249 106 134 msgid "Parent term to display children of" 107 135 msgstr "" 108 136 109 #: widgets/class-a-z-listing-widget.php:2 15137 #: widgets/class-a-z-listing-widget.php:261 110 138 msgid "Terms to include (IDs)" 111 139 msgstr "" 112 140 113 #: widgets/class-a-z-listing-widget.php:2 28141 #: widgets/class-a-z-listing-widget.php:273 114 142 msgid "Terms to exclude (IDs)" 115 143 msgstr "" 116 144 117 #: widgets/class-a-z-listing-widget.php:2 41145 #: widgets/class-a-z-listing-widget.php:285 118 146 msgid "Hide empty terms" 119 147 msgstr "" -
a-z-listing/trunk/package-lock.json
r1939419 r2003543 2574 2574 }, 2575 2575 "sprintf-js": { 2576 "version": "1.1. 1",2577 "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.1. 1.tgz",2578 "integrity": "sha 1-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==", 2579 2579 "dev": true 2580 2580 }, … … 2754 2754 }, 2755 2755 "underscore.string": { 2756 "version": "3.3. 4",2757 "resolved": "https://registry.npmjs.org/underscore.string/-/underscore.string-3.3. 4.tgz",2758 "integrity": "sha 1-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==", 2759 2759 "dev": true, 2760 2760 "requires": { -
a-z-listing/trunk/readme.txt
r1991923 r2003543 7 7 Requires PHP: 5.6 8 8 Tested up to: 5.0 9 Stable tag: 2. 0.49 Stable tag: 2.1.0 10 10 License: GPLv2 or later 11 11 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 230 230 = How do I show posts of a different post-type (not pages) or multiple post-types (e.g. posts AND pages) = 231 231 232 This can be achieved using the shortcode or PHP. 232 This 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`). 233 233 234 234 **Shortcode method** … … 268 268 ` 269 269 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)270 The 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) 271 271 272 272 The 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. … … 274 274 = How do I show posts from a specific category only = 275 275 276 This can be achieved using the shortcode or PHP. 276 This 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`). 277 277 278 278 **Shortcode method** … … 304 304 ` 305 305 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)306 Any 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 308 The 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) 309 309 310 310 The 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. … … 312 312 = How do I show terms from a taxonomy instead of posts = 313 313 314 This can be achieved using the shortcode or PHP. 314 This 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`). 315 315 316 316 **Shortcode method** … … 332 332 ` 333 333 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`.334 The 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`. 335 335 336 336 The 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. … … 356 356 ` 357 357 <?php 358 add_action( ' wp', 'a_z_listing_force_enable_styles', 99 );358 add_action( 'init', 'a_z_listing_force_enable_styles', 99 ); 359 359 ?> 360 360 ` … … 368 368 ` 369 369 <?php 370 add_action( ' wp', 'your_override_wrapper_function', 99 );370 add_action( 'init', 'your_override_wrapper_function', 99 ); 371 371 function your_override_wrapper_function() { 372 372 if ( ! is_page( 'your-a-z-listing-page-slug-or-ID' ) ) { // ID is numeric, slug is a string. … … 411 411 == Changelog == 412 412 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 413 433 = 2.0.6 = 414 434 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.416 435 * Fix widget target post support 417 436 * Fix filtering posts by multiple taxonomy terms … … 421 440 * Fix javascript error on widgets screen 422 441 423 *2.0.0 also introduced the following changes:* 442 = 2.0.0 = 424 443 425 444 * Improved widget configuration. … … 432 451 * Fix the stylesheet to better cope with variances in font-size and text length in the alphabet links list and widget. 433 452 * 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._ 494 469 495 470 = Previous = -
a-z-listing/trunk/scripts/a-z-listing-tabs.js
r1939419 r2003543 1 1 // props to @claytonchase (https://profiles.wordpress.org/claytonchase) 2 2 jQuery( 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 } 4 18 } ); -
a-z-listing/trunk/templates/a-z-listing.example.php
r1939419 r2003543 14 14 ?> 15 15 <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> 19 20 </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> 33 33 34 <ul>35 <?php36 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> 44 44 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> 49 50 </div> 50 </div>51 51 </div> 52 52 <?php else : ?> -
a-z-listing/trunk/templates/a-z-listing.php
r1939419 r2003543 3 3 * Default multicolumn template for the A-Z Listing plugin 4 4 * 5 * This template will be given the variable `$a_z_query` which is an instance of6 * `A_Z_Listing`.5 * This template will be given the variable `$a_z_query` which is an instance 6 * of `A_Z_Listing`. 7 7 * 8 8 * You can override this template by copying this file into your theme … … 12 12 */ 13 13 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 */ 15 21 $_a_z_listing_minpercol = 10; 16 22 ?> 17 23 <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> 21 76 </div> 22 77 </div> 23 <?php if ( $a_z_query->have_letters() ) : ?> 24 <div id="az-slider"> 25 <div id="inner-slider"> 78 <?php else : ?> 79 <p> 26 80 <?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 ); 57 85 ?> 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> 63 87 <?php 64 88 endif; -
a-z-listing/trunk/widgets/class-a-z-listing-widget.php
r1942709 r2003543 31 31 ); 32 32 33 add_action( 'admin_enqueue_scripts', 'a_z_listing_enqueue_widget_admin_script' ); 34 33 35 if ( is_active_widget( false, false, $this->id_base, true ) ) { 34 36 a_z_listing_do_enqueue(); … … 60 62 $public_taxonomies = get_taxonomies( $args, 'objects' ); 61 63 62 $widget_title = $instance['title'];64 $widget_title = isset( $instance['title'] ) ? $instance['title'] : ''; 63 65 $widget_title_id = $this->get_field_id( 'title' ); 64 66 $widget_title_name = $this->get_field_name( 'title' ); 65 67 66 $display_type = $instance['type'];68 $display_type = ( 'terms' === $instance['type'] ) ? 'terms' : 'posts'; 67 69 $display_type_id = $this->get_field_id( 'type' ); 68 70 $display_type_name = $this->get_field_name( 'type' ); 69 71 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 ); 71 73 $target_post_id = $this->get_field_id( 'post' ); 72 74 $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 ) : ''; 74 76 $target_post_title_id = $this->get_field_id( 'target_post_title' ); 75 77 $target_post_title_name = $this->get_field_name( 'target_post_title' ); 76 78 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' ); 91 101 92 102 $listing_terms_include = isset( $instance['terms'] ) ? $instance['terms'] : ''; … … 94 104 $listing_terms_include_name = $this->get_field_name( 'terms' ); 95 105 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' ); 105 113 ?> 106 114 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> 121 287 </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>320 288 <?php 321 289 } … … 337 305 $instance['target_post_title'] = strip_tags( $new_instance['target_post_title'] ); 338 306 $instance['post_type'] = strip_tags( $new_instance['post_type'] ); 339 $instance['parent'] = (int) $new_instance['parent'];340 307 $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'; 341 310 $instance['parent_term'] = strip_tags( $new_instance['parent_term'] ); 342 311 $instance['terms'] = strip_tags( $new_instance['terms'] ); … … 344 313 $instance['hide_empty_terms'] = 'on' === $new_instance['hide_empty_terms'] ? 'true' : 'false'; 345 314 346 if ( empty( $ instance['target_post_title'] ) ) {315 if ( empty( $new_instance['target_post_title'] ) ) { 347 316 $instance['post'] = 0; 317 } 318 if ( empty( $new_instance['parent_post_title'] ) ) { 319 $instance['parent_post'] = 0; 348 320 } 349 321 … … 419 391 $instance, 420 392 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' => '', 421 403 'title' => '', 422 'post' => -1, // target.423 404 'type' => 'posts', 424 'taxonomy' => '',425 'post_type' => 'page',426 'terms' => '',427 'exclude_terms' => '',428 'parent_term' => '',429 'hide_empty_terms' => false,430 405 ) 431 406 ); … … 433 408 $title = esc_html( $instance['title'] ); 434 409 $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. 441 414 } 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'; 445 425 446 426 $ret = ''; … … 453 433 $ret .= do_shortcode( 454 434 "[a-z-listing 455 return='letters' 456 target='{$target}' 435 alphabet='' 457 436 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']}' 460 440 group-numbers='' 461 441 grouping='' 442 hide-empty-terms='{$hide_empty_terms}' 462 443 numbers='hide' 444 parent-post='{$instance['parent_post']}' 445 parent-term='{$instance['parent_term']}' 463 446 post-type='{$instance['post_type']}' 464 exclude-posts='' 447 return='letters' 448 target='{$target_url}' 449 taxonomy='{$instance['taxonomy']}' 465 450 terms='{$instance['terms']}' 466 exclude-terms='{$instance['exclude_terms']}'467 parent-term='{$instance['parent_term']}'468 hide-empty-terms='{$hide_empty}'469 451 ]" 470 452 ); … … 476 458 477 459 /** 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 */ 467 function 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 /** 478 493 * Ajax responder for A_Z_Listing_Widget configuration 494 * 495 * @since 2.0.0 479 496 */ 480 497 function 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 ); 492 502 493 503 $titles = array(); … … 518 528 /** 519 529 * Enqueue the jquery-ui autocomplete script 530 * 531 * @since 2.0.0 520 532 */ 521 533 function a_z_listing_autocomplete_script() {
Note: See TracChangeset
for help on using the changeset viewer.