add_a_z_numbers( string $position = 'after', bool $group = false )

Returns a function for use in the a_z_listing_alphabet filter


Description


Parameters

$position

(string) (Optional) set to before to place the numbers first. Any other value will place them last.

Default value: 'after'

$group

(bool) (Optional) group the numbers in a single collection rather than individually.

Default value: false


Return

(A_Z_Listing_Numbers)


Source

File: classes/class-a-z-listing-numbers.php

function add_a_z_numbers( $position = 'after', $group = false ) {
	add_filter( 'a-z-listing-alphabet', function( $alphabet ) use ( $position, $group ) {
		$numbers = '0,1,2,3,4,5,6,7,8,9';
		if ( true === $group ) {
			$numbers = '0123456789';
			add_filter( 'the-a-z-letter-title', function( $letter ) {
				if ( '0' === $letter ) {
					return '0-9';
				}
				return $letter;
			});
		}
		if ( 'before' === $position ) {
			return join( ',', array( $numbers, $alphabet ) );
		}
		return join( ',', array( $alphabet, $numbers ) );
	} );
}

Changelog

Changelog
VersionDescription
1.8.0Add $group parameter and functionality to group numbers into a single collection.
1.7.0Introduced.

More Information

You are currently logged out. To view tickets you must first login.

I have read and understood the Terms of Service



User Contributed Notes

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.