Skip to content

Instantly share code, notes, and snippets.

@mauteri
Created April 24, 2025 01:11
Show Gist options
  • Select an option

  • Save mauteri/5b8402d29de94502fff1e0da9e68f2d8 to your computer and use it in GitHub Desktop.

Select an option

Save mauteri/5b8402d29de94502fff1e0da9e68f2d8 to your computer and use it in GitHub Desktop.
GatherPress Duration Options (Test)
<?php
/**
* Plugin Name: GatherPress Duration Options
* Description: Adds custom duration options to the GatherPress plugin using the durationOptions filter.
* Version: 1.0
* Author: Mike Auteri
* License: GPL2+
*/
defined( 'ABSPATH' ) || exit;
add_action( 'admin_print_footer_scripts', 'gatherpress_duration_options_inline_script', 100 );
function gatherpress_duration_options_inline_script() {
// Only load on block editor screens
$screen = get_current_screen();
if ( ! method_exists( $screen, 'is_block_editor' ) || ! $screen->is_block_editor() ) {
return;
}
?>
<script>
(function () {
if ( typeof wp === 'undefined' || ! wp.hooks ) return;
wp.hooks.addFilter(
'gatherpress.durationOptions',
'gatherpress/durationOptionsTest',
function ( options ) {
return [
{
label: '2 hours',
value: 2,
},
{
label: '10 hours',
value: 10,
},
{
label: 'Set an end time...',
value: false,
},
];
}
);
})();
</script>
<?php
}
@mauteri
Copy link
Author

mauteri commented Apr 24, 2025

Add this file to plugins in your WordPress installation and activate to test duration option filter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment