Skip to content

Commit

Permalink
Simplify method
Browse files Browse the repository at this point in the history
  • Loading branch information
wpscholar committed Jan 25, 2024
1 parent ac2a859 commit 59853fb
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions includes/ComingSoon.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,18 +130,19 @@ public function on_update_mm_coming_soon( $old_value, $value ) {
* @return void
*/
public function conditionally_trigger_coming_soon_action_hooks( bool $isEnabled ) {

if ( ! did_action( 'init' ) ) {
add_action( 'init', function () use ( $isEnabled ) {
$this->conditionally_trigger_coming_soon_action_hooks( $isEnabled );
}, 99 );

return;
}

if ( $isEnabled ) {
if ( did_action( 'init' ) ) {
$this->trigger_enabled_action_hook();
} else {
add_action( 'init', array( $this, 'trigger_enabled_action_hook' ), 99 );
}
$this->trigger_enabled_action_hook();
} else {
if ( did_action( 'init' ) ) {
$this->trigger_disabled_action_hook();
} else {
add_action( 'init', array( $this, 'trigger_disabled_action_hook' ), 99 );
}
$this->trigger_disabled_action_hook();
}
}

Expand Down

0 comments on commit 59853fb

Please sign in to comment.