Created
April 24, 2025 01:11
-
-
Save mauteri/5b8402d29de94502fff1e0da9e68f2d8 to your computer and use it in GitHub Desktop.
GatherPress Duration Options (Test)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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 | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this file to plugins in your WordPress installation and activate to test duration option filter.