Skip to content

Instantly share code, notes, and snippets.

@tokkonopapa
Last active October 22, 2016 02:18
Show Gist options
  • Save tokkonopapa/17fde296e7ffe249f4325d551ef7c5e0 to your computer and use it in GitHub Desktop.
Save tokkonopapa/17fde296e7ffe249f4325d551ef7c5e0 to your computer and use it in GitHub Desktop.
/**
* Example : Validate specific actions of admin-ajax.php at front-end
* Use case: Give permission to ajax with specific action at public facing page
*
* @global array $_GET and $_POST requested queries
* @param array $queries array of admin queries which should bypass WP-ZEP.
* @return array $queries array of admin queries which should bypass WP-ZEP.
*/
function my_bypass_admins( $queries ) {
if ( defined( 'DOING_AJAX' ) && DOING_AJAX && isset( $_POST['action'] ) ) {
// heartbeat
if ( 'heartbeat' === $_POST['action'] )
$queries = array( 'heartbeat' );
// elementor_
elseif ( 0 === strpos( $_POST['action'], 'elementor_' ) )
$queries = array( $_POST['action'] );
}
elseif ( 'post.php' === $GLOBALS['pagenow'] && isset( $_GET['action'] ) ) {
// edit
if ( 'edit' === $_GET['action'] )
$queries = array( 'edit' );
}
return $queries;
}
add_filter( 'ip-geo-block-bypass-admins', 'my_bypass_admins' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment