Skip to content

Commit

Permalink
fix: prevent webhook firing when calling rest api from sp (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
Lyrisbee authored Mar 13, 2024
1 parent 0098b55 commit c239ec8
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/class-action-handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,15 @@ final class Action_Handler {
* Constructor.
*/
public function __construct() {
// Prevent webhook firing when calling REST Api.
if ( ! empty( $_SERVER['HTTP_USER_AGENT'] ) ) {
$user_agent = sanitize_text_field( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) );

if ( stripos( $user_agent, 'Storipress' ) !== false ) {
return;
}
}

$this->register_actions(
array(
new Category_Created(),
Expand Down

0 comments on commit c239ec8

Please sign in to comment.