Last active
September 24, 2021 17:16
-
-
Save donmhico/bcbcc57042ae25fe11d3dda4dc79c693 to your computer and use it in GitHub Desktop.
This file contains 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 | |
add_action( 'edit_form_top', 'add_parameters_to_preserve_in_post_form' ); | |
/** | |
* Add a new input in Post form if 'go-back-to-plugin' is a URL parameter. | |
* | |
* @see https://developer.wordpress.org/reference/hooks/edit_form_top/ | |
* | |
* @return void | |
*/ | |
function add_parameters_to_preserve_in_post_form() : void { | |
$back_to_plugin = filter_input( INPUT_GET, 'go-back-to-plugin', FILTER_SANITIZE_STRING ); | |
if ( empty( $back_to_plugin ) || '1' !== $back_to_plugin ) { | |
return; | |
} | |
?> | |
<input | |
type="hidden" | |
id="go-back-to-plugin" | |
name="go-back-to-plugin" | |
value="1" | |
/> | |
<?php | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment