Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: fixed

A4A Client: defer connection check to plugins_loaded hook to prevent fatal errors when WordPress core functions are not yet available.

Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,19 @@ public static function init() {
add_action( 'load-settings_page_' . AUTOMATTIC_FOR_AGENCIES_CLIENT_SLUG, array( static::class, 'load_scripts_styles' ) );

// Display a modal when trying to deactivate the plugin.
// Hook to plugins_loaded at priority 20 to ensure connection package is initialized
// and WordPress core functions (like get_user_by) are available.
add_action( 'plugins_loaded', array( static::class, 'init_deactivation_handler' ), 20 );
}

/**
* Initialize the deactivation handler if the site is connected.
*
* @since 0.1.0
*
* @return void
*/
public static function init_deactivation_handler() {
$manager = new Connection_Manager( 'automattic-for-agencies-client' );
if ( $manager->is_connected() ) {
Deactivation_Handler::init( AUTOMATTIC_FOR_AGENCIES_CLIENT_SLUG, __DIR__ . '/admin/deactivation-dialog.php' );
Expand Down
Loading