PDF for GravityView Hooks – gfpdf_gv_multiple_entries_page_size_options
Description
Add or remove choices in the Multiple Entry PDF widget's "Number of Entries to Display" dropdown, which sets how many entries the PDF includes.
The default choices are "Display all", "Display current page", and fixed counts of 250, 200, 150, 100, 50, 25 and 10.
After this filter runs, any count at or above the entry limit is removed, because it would produce the same PDF as "Display all". That's why there's no "Display 500" choice with the default limit of 500. To offer 1,000, raise the limit with gfpdf_gv_multiple_entries_limit too.
Version
This hook was introduced in PDF for GravityView 2.0.
Arguments
The following arguments are passed to functions that use this hook:
$options | array
- The dropdown choices, as
value => label. - The
allanddefaultkeys are the "Display all" and "Display current page" choices. - Every other key is an entry count, such as
250. - The default value is
[ 'all' => 'Display all (up to 500)', 'default' => 'Display current page', 500 => 'Display 500', 250 => 'Display 250', 200 => 'Display 200', 150 => 'Display 150', 100 => 'Display 100', 50 => 'Display 50', 25 => 'Display 25', 10 => 'Display 10' ]. The500choice is present when your filter runs, then removed because of the default limit.
Usage
Add a choice of 75 entries (it appears at the end of the list):
add_filter( 'gfpdf_gv_multiple_entries_page_size_options', function( $options ) {
$options[75] = 'Display 75';
return $options;
} );
Offer 1,000 and 2,000 entries, raising the limit so they aren't removed:
add_filter( 'gfpdf_gv_multiple_entries_limit', function() {
return 2500;
} );
add_filter( 'gfpdf_gv_multiple_entries_page_size_options', function( $options ) {
$options[1000] = 'Display 1,000';
$options[2000] = 'Display 2,000';
return $options;
} );
Remove every fixed count, leaving only "Display all" and "Display current page":
add_filter( 'gfpdf_gv_multiple_entries_page_size_options', function( $options ) {
return array_intersect_key( $options, [ 'all' => true, 'default' => true ] );
} );
Source Code
This filter is located in src/GravityView/Widgets/MultipleEntryPdfLink.php of the PDF for GravityView extension.