Construction
The entire plugin is contained in a class definition, and is initialized through the __construct()
function.
1 2 3 4 5 6 | public function __construct() { add_action( ‘admin_init’, array( $this, ‘wp_link_pages_extended_admin_init’ ) ); add_filter( ‘query_vars’, array( $this, ‘wp_link_pages_extended_parameter_queryvars’ ) ); add_action( ‘the_post’, array( $this, ‘wp_link_pages_extended_the_post’ ), 0 ); } |
In order for the viewall
URL parameter to be returned, it needed to be defined as a valid query parameter.
1 2 3 4 5 | function wp_link_pages_extended_parameter_queryvars( $queryvars ) { $queryvars[] = ‘viewall’; return( $queryvars ); } |
Internationalization
Internationalization was performed as a demonstration of the power of WordPress internationalization.
1 | load_plugin_textdomain( ‘wp-link-pages-extended’, false, dirname( plugin_basename( __FILE__ ) ) ); |
There are only eight words or phrases that need to be translated: “First”, “Last”, “Next”, “of”, “Page”, “Prev”, “View All” and “View Pages”.
Notes
- No attempt was made to style the links so they retain the parent theme styling.
- There is an error on the
wp_link_pages
reference page that had my head whirling for several minutes wondering where the separators were during testing before I finally realized it. The reference page lists the array element as being spelled ‘Seperator’ while the actual array element is correctly spelled in the example as ‘separator’.
The short URL of the present article is: http://www.terryobrien.me/g3w0j
Personal Links