From 67c5ff7da38b3f8eddb4a4b6b3d6da7ba349be20 Mon Sep 17 00:00:00 2001 From: Carsten Bach Date: Thu, 1 Aug 2024 13:48:03 +0200 Subject: [PATCH 01/16] Make sure translation files are loaded properly. This is important for users how selected a different from the sites default language. --- gatherpress.php | 1 - includes/core/classes/class-setup.php | 34 +++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/gatherpress.php b/gatherpress.php index 1566357e7..e56fcfd88 100644 --- a/gatherpress.php +++ b/gatherpress.php @@ -9,7 +9,6 @@ * Requires PHP: 7.4 * Requires at least: 6.4 * Text Domain: gatherpress - * Domain Path: /languages * License: GNU General Public License v2.0 or later * License URI: https://www.gnu.org/licenses/gpl-2.0.html * diff --git a/includes/core/classes/class-setup.php b/includes/core/classes/class-setup.php index 152c6a9fa..2ca384d3d 100644 --- a/includes/core/classes/class-setup.php +++ b/includes/core/classes/class-setup.php @@ -82,6 +82,8 @@ protected function instantiate_classes(): void { * @return void */ protected function setup_hooks(): void { + add_action( 'init', array( $this, 'load_gatherpress_textdomain' ), 0 ); + register_activation_hook( GATHERPRESS_CORE_FILE, array( $this, 'activate_gatherpress_plugin' ) ); register_deactivation_hook( GATHERPRESS_CORE_FILE, array( $this, 'deactivate_gatherpress_plugin' ) ); @@ -111,6 +113,38 @@ protected function setup_hooks(): void { ); } + /** + * Load plugin textdomain. + * + * Calling load_plugin_textdomain() should be delayed until init action. + * @see https://developer.wordpress.org/reference/functions/load_plugin_textdomain/#comment-1568 + * + * load_plugin_textdomain() will try to load the mo file firstly from: + * WP_LANG_DIR . β€˜/plugins/’ . $mofile + * Only if it is not able to it will load it from GATHERPRESS_DIR_NAME folder + * @see https://developer.wordpress.org/reference/functions/load_plugin_textdomain/#comment-3521 + * + * Since WordPress 4.6 translations now take translate.wordpress.org as priority and so + * plugins that are translated via translate.wordpress.org DO NOT necessary require load_plugin_textdomain() anymore. + * If you don’t want to add a load_plugin_textdomain() call to your plugin + * you have to set the Requires at least: field in your readme.txt to 4.6 or more. + * @see https://developer.wordpress.org/plugins/internationalization/how-to-internationalize-your-plugin/#plugins-on-wordpress-org + * + * BUT, ...!!! + * + * A call to load_plugin_textdomain() is ABSOLUTELY NEEDED to properly load all translation files + * for users how chosed another than the sites default language in their /profile.php. + */ + public function load_gatherpress_textdomain() { + // Keep as a fallback if translation files were not loaded from translate.wordpress.org ?? + // load_plugin_textdomain( 'gatherpress', false, GATHERPRESS_DIR_NAME . '/languages' ); + + // Or use it like that + // and DELETE the /languages folder, + // and "* Domain Path: /languages" as well? + load_plugin_textdomain( 'gatherpress', false, false ); + } + /** * Add custom links to the plugin action links in the WordPress plugins list. * From ba03e3861740ca79c02da28cff9196189f0b62de Mon Sep 17 00:00:00 2001 From: Carsten Bach Date: Thu, 1 Aug 2024 13:49:19 +0200 Subject: [PATCH 02/16] Load users locale before sending emails & reset afterwards --- includes/core/classes/class-rest-api.php | 29 ++++++++++++++---------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/includes/core/classes/class-rest-api.php b/includes/core/classes/class-rest-api.php index fdeee7f6e..682aecc10 100644 --- a/includes/core/classes/class-rest-api.php +++ b/includes/core/classes/class-rest-api.php @@ -449,18 +449,6 @@ public function send_emails( int $post_id, array $send, string $message ): bool } $members = $this->get_members( $send, $post_id ); - /* translators: %s: event title. */ - $subject = sprintf( __( 'πŸ“… %s', 'gatherpress' ), get_the_title( $post_id ) ); - $body = Utility::render_template( - sprintf( '%s/includes/templates/admin/emails/event-email.php', GATHERPRESS_CORE_PATH ), - array( - 'event_id' => $post_id, - 'message' => $message, - ), - ); - $headers = array( 'Content-Type: text/html; charset=UTF-8' ); - $subject = stripslashes_deep( html_entity_decode( $subject, ENT_QUOTES, 'UTF-8' ) ); - foreach ( $members as $member ) { if ( '0' === get_user_meta( $member->ID, 'gatherpress_event_updates_opt_in', true ) ) { continue; @@ -468,8 +456,25 @@ public function send_emails( int $post_id, array $send, string $message ): bool if ( $member->user_email ) { $to = $member->user_email; + $switched_locale = switch_to_user_locale( $member->ID ); + + /* translators: %s: event title. */ + $subject = sprintf( __( 'πŸ“… %s', 'gatherpress' ), get_the_title( $post_id ) ); + $body = Utility::render_template( + sprintf( '%s/includes/templates/admin/emails/event-email.php', GATHERPRESS_CORE_PATH ), + array( + 'event_id' => $post_id, + 'message' => $message, + ), + ); + $headers = array( 'Content-Type: text/html; charset=UTF-8' ); + $subject = stripslashes_deep( html_entity_decode( $subject, ENT_QUOTES, 'UTF-8' ) ); wp_mail( $to, $subject, $body, $headers ); + + if ( $switched_locale ) { + restore_previous_locale(); + } } } From 4fec72876054bd736b6af1ca4591f27448403fea Mon Sep 17 00:00:00 2001 From: Carsten Bach Date: Thu, 1 Aug 2024 13:51:36 +0200 Subject: [PATCH 03/16] Set html language attributes correctly for the email --- includes/templates/admin/emails/event-email.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/templates/admin/emails/event-email.php b/includes/templates/admin/emails/event-email.php index ac247310b..6347fe6db 100644 --- a/includes/templates/admin/emails/event-email.php +++ b/includes/templates/admin/emails/event-email.php @@ -26,7 +26,7 @@ ?> - +> <?php echo wp_kses_post( get_the_title( $event_id ) ); ?> From da5707162467ecd19b262160e592a1f710fc7bba Mon Sep 17 00:00:00 2001 From: Carsten Bach Date: Thu, 1 Aug 2024 13:52:41 +0200 Subject: [PATCH 04/16] Conditionally render the featured image in the email, only if it is set. --- includes/templates/admin/emails/event-email.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/includes/templates/admin/emails/event-email.php b/includes/templates/admin/emails/event-email.php index 6347fe6db..363788b52 100644 --- a/includes/templates/admin/emails/event-email.php +++ b/includes/templates/admin/emails/event-email.php @@ -20,8 +20,9 @@ return; } -$gatherpress_event = new Event( $event_id ); -$gatherpress_venue = $gatherpress_event->get_venue_information()['name']; +$gatherpress_event = new Event( $event_id ); +$gatherpress_event_image = get_the_post_thumbnail_url( $event_id, 'full' ); +$gatherpress_venue = $gatherpress_event->get_venue_information()['name']; ?> @@ -36,8 +37,10 @@ array() ) ); ?>

- - <?php esc_attr_e( 'Event Image', 'gatherpress' ); ?> + + + <?php esc_attr_e( 'Event Image', 'gatherpress' ); ?> +

From eb209060375ec135afb6e995392336ccdfb92cd0 Mon Sep 17 00:00:00 2001 From: Carsten Bach Date: Thu, 1 Aug 2024 14:14:13 +0200 Subject: [PATCH 05/16] Set the current user to the actual member to mail to, to make sure the GatherPress filters for date- and time- format, as well as the users timezone, are recognized by the functions inside render_template(). --- includes/core/classes/class-rest-api.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/includes/core/classes/class-rest-api.php b/includes/core/classes/class-rest-api.php index 682aecc10..73de51d20 100644 --- a/includes/core/classes/class-rest-api.php +++ b/includes/core/classes/class-rest-api.php @@ -448,16 +448,23 @@ public function send_emails( int $post_id, array $send, string $message ): bool return false; } + // Keep the currently logged-in user. + $current_user = wp_get_current_user(); + $members = $this->get_members( $send, $post_id ); foreach ( $members as $member ) { if ( '0' === get_user_meta( $member->ID, 'gatherpress_event_updates_opt_in', true ) ) { continue; } - if ( $member->user_email ) { $to = $member->user_email; $switched_locale = switch_to_user_locale( $member->ID ); + // Set the current user to the actual member to mail to, + // to make sure the GatherPress filters for date- and time- format, as well as the users timezone, + // are recognized by the functions inside render_template(). + wp_set_current_user( $member->ID ); + /* translators: %s: event title. */ $subject = sprintf( __( 'πŸ“… %s', 'gatherpress' ), get_the_title( $post_id ) ); $body = Utility::render_template( @@ -470,6 +477,9 @@ public function send_emails( int $post_id, array $send, string $message ): bool $headers = array( 'Content-Type: text/html; charset=UTF-8' ); $subject = stripslashes_deep( html_entity_decode( $subject, ENT_QUOTES, 'UTF-8' ) ); + // Reset the current user to the editor sending the email. + wp_set_current_user( $current_user->ID ); + wp_mail( $to, $subject, $body, $headers ); if ( $switched_locale ) { From 6ffc7979cc3b0944d49c4e0e955aba03d7dc2d88 Mon Sep 17 00:00:00 2001 From: Carsten Bach Date: Thu, 1 Aug 2024 17:50:48 +0200 Subject: [PATCH 06/16] Fix CS --- includes/core/classes/class-rest-api.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/core/classes/class-rest-api.php b/includes/core/classes/class-rest-api.php index 73de51d20..f976965a7 100644 --- a/includes/core/classes/class-rest-api.php +++ b/includes/core/classes/class-rest-api.php @@ -457,7 +457,7 @@ public function send_emails( int $post_id, array $send, string $message ): bool continue; } if ( $member->user_email ) { - $to = $member->user_email; + $to = $member->user_email; $switched_locale = switch_to_user_locale( $member->ID ); // Set the current user to the actual member to mail to, From 4d012cf11a042d97b5db08e31bf3520409f809ef Mon Sep 17 00:00:00 2001 From: Carsten Bach Date: Thu, 1 Aug 2024 18:02:30 +0200 Subject: [PATCH 07/16] Do not rely on /languages folder in favor of translate.wordpress.org --- includes/core/classes/class-setup.php | 6 ------ 1 file changed, 6 deletions(-) diff --git a/includes/core/classes/class-setup.php b/includes/core/classes/class-setup.php index 2ca384d3d..90c6e4a48 100644 --- a/includes/core/classes/class-setup.php +++ b/includes/core/classes/class-setup.php @@ -136,12 +136,6 @@ protected function setup_hooks(): void { * for users how chosed another than the sites default language in their /profile.php. */ public function load_gatherpress_textdomain() { - // Keep as a fallback if translation files were not loaded from translate.wordpress.org ?? - // load_plugin_textdomain( 'gatherpress', false, GATHERPRESS_DIR_NAME . '/languages' ); - - // Or use it like that - // and DELETE the /languages folder, - // and "* Domain Path: /languages" as well? load_plugin_textdomain( 'gatherpress', false, false ); } From 65905e805cbd4461a72b8f21c2916a4ec4a53461 Mon Sep 17 00:00:00 2001 From: Carsten Bach Date: Thu, 1 Aug 2024 18:04:26 +0200 Subject: [PATCH 08/16] Fix whitespaces for CS --- includes/core/classes/class-setup.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/includes/core/classes/class-setup.php b/includes/core/classes/class-setup.php index 90c6e4a48..2d108c14a 100644 --- a/includes/core/classes/class-setup.php +++ b/includes/core/classes/class-setup.php @@ -83,7 +83,7 @@ protected function instantiate_classes(): void { */ protected function setup_hooks(): void { add_action( 'init', array( $this, 'load_gatherpress_textdomain' ), 0 ); - + register_activation_hook( GATHERPRESS_CORE_FILE, array( $this, 'activate_gatherpress_plugin' ) ); register_deactivation_hook( GATHERPRESS_CORE_FILE, array( $this, 'deactivate_gatherpress_plugin' ) ); @@ -115,7 +115,7 @@ protected function setup_hooks(): void { /** * Load plugin textdomain. - * + * * Calling load_plugin_textdomain() should be delayed until init action. * @see https://developer.wordpress.org/reference/functions/load_plugin_textdomain/#comment-1568 * @@ -136,7 +136,7 @@ protected function setup_hooks(): void { * for users how chosed another than the sites default language in their /profile.php. */ public function load_gatherpress_textdomain() { - load_plugin_textdomain( 'gatherpress', false, false ); + load_plugin_textdomain( 'gatherpress', false, false ); } /** From 8867db12918156c925a56ae34e02216a3c069196 Mon Sep 17 00:00:00 2001 From: Carsten Bach Date: Thu, 1 Aug 2024 18:06:35 +0200 Subject: [PATCH 09/16] Add doc-comment desc --- includes/core/classes/class-setup.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/includes/core/classes/class-setup.php b/includes/core/classes/class-setup.php index 2d108c14a..8a33de436 100644 --- a/includes/core/classes/class-setup.php +++ b/includes/core/classes/class-setup.php @@ -116,6 +116,9 @@ protected function setup_hooks(): void { /** * Load plugin textdomain. * + * Make sure to load all translation fileseven for users + * who chosed another than the sites default language. + * * Calling load_plugin_textdomain() should be delayed until init action. * @see https://developer.wordpress.org/reference/functions/load_plugin_textdomain/#comment-1568 * @@ -133,7 +136,7 @@ protected function setup_hooks(): void { * BUT, ...!!! * * A call to load_plugin_textdomain() is ABSOLUTELY NEEDED to properly load all translation files - * for users how chosed another than the sites default language in their /profile.php. + * for users who chosed another than the sites default language in their /profile.php. */ public function load_gatherpress_textdomain() { load_plugin_textdomain( 'gatherpress', false, false ); From bd0fdb72a6709b485484471e43cd242c51df5e93 Mon Sep 17 00:00:00 2001 From: Carsten Bach Date: Thu, 1 Aug 2024 18:08:12 +0200 Subject: [PATCH 10/16] fulfilling 1001 wishes for the CS check action --- includes/core/classes/class-setup.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/includes/core/classes/class-setup.php b/includes/core/classes/class-setup.php index 8a33de436..973c0ec1a 100644 --- a/includes/core/classes/class-setup.php +++ b/includes/core/classes/class-setup.php @@ -119,6 +119,8 @@ protected function setup_hooks(): void { * Make sure to load all translation fileseven for users * who chosed another than the sites default language. * + * @see https://developer.wordpress.org/reference/functions/load_plugin_textdomain + * * Calling load_plugin_textdomain() should be delayed until init action. * @see https://developer.wordpress.org/reference/functions/load_plugin_textdomain/#comment-1568 * From 02358ab60318a7464e31865ffea0f3bb8c961809 Mon Sep 17 00:00:00 2001 From: Carsten Bach Date: Sun, 25 Aug 2024 23:14:21 +0200 Subject: [PATCH 11/16] Keep slashes in user-defined date- and time-format strings --- includes/core/classes/class-user.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/includes/core/classes/class-user.php b/includes/core/classes/class-user.php index 75523ef27..45701817e 100644 --- a/includes/core/classes/class-user.php +++ b/includes/core/classes/class-user.php @@ -214,8 +214,8 @@ public function save_profile_fields( int $user_id ): void { } update_user_meta( $user_id, 'gatherpress_event_updates_opt_in', intval( filter_input( INPUT_POST, 'gatherpress_event_updates_opt_in' ) ) ); - update_user_meta( $user_id, 'gatherpress_date_format', sanitize_text_field( filter_input( INPUT_POST, 'gatherpress_date_format' ) ) ); - update_user_meta( $user_id, 'gatherpress_time_format', sanitize_text_field( filter_input( INPUT_POST, 'gatherpress_time_format' ) ) ); + update_user_meta( $user_id, 'gatherpress_date_format', sanitize_text_field( filter_input( INPUT_POST, 'gatherpress_date_format', FILTER_SANITIZE_ADD_SLASHES ) ) ); + update_user_meta( $user_id, 'gatherpress_time_format', sanitize_text_field( filter_input( INPUT_POST, 'gatherpress_time_format', FILTER_SANITIZE_ADD_SLASHES ) ) ); update_user_meta( $user_id, 'gatherpress_timezone', sanitize_text_field( filter_input( INPUT_POST, 'gatherpress_timezone' ) ) ); } } From 7e5aae7e2b93153fffa95dbf6edcf4775313e91b Mon Sep 17 00:00:00 2001 From: Carsten Bach Date: Thu, 5 Sep 2024 16:26:23 +0200 Subject: [PATCH 12/16] Initialize all setups later, hook on 'plugins_loaded' --- gatherpress.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/gatherpress.php b/gatherpress.php index e56fcfd88..ad03d1e70 100644 --- a/gatherpress.php +++ b/gatherpress.php @@ -40,4 +40,7 @@ GatherPress\Core\Autoloader::register(); // Initialize setups. -GatherPress\Core\Setup::get_instance(); +add_action( + 'plugins_loaded', + array( '\GatherPress\Core\Setup', 'get_instance' ) +); From 38c9f07208ca8c46a21b9edb172b15a7625d2af0 Mon Sep 17 00:00:00 2001 From: Carsten Bach Date: Thu, 5 Sep 2024 16:27:00 +0200 Subject: [PATCH 13/16] Remove superflous load_plugin_textdomain() call --- includes/core/classes/class-setup.php | 33 --------------------------- 1 file changed, 33 deletions(-) diff --git a/includes/core/classes/class-setup.php b/includes/core/classes/class-setup.php index 973c0ec1a..152c6a9fa 100644 --- a/includes/core/classes/class-setup.php +++ b/includes/core/classes/class-setup.php @@ -82,8 +82,6 @@ protected function instantiate_classes(): void { * @return void */ protected function setup_hooks(): void { - add_action( 'init', array( $this, 'load_gatherpress_textdomain' ), 0 ); - register_activation_hook( GATHERPRESS_CORE_FILE, array( $this, 'activate_gatherpress_plugin' ) ); register_deactivation_hook( GATHERPRESS_CORE_FILE, array( $this, 'deactivate_gatherpress_plugin' ) ); @@ -113,37 +111,6 @@ protected function setup_hooks(): void { ); } - /** - * Load plugin textdomain. - * - * Make sure to load all translation fileseven for users - * who chosed another than the sites default language. - * - * @see https://developer.wordpress.org/reference/functions/load_plugin_textdomain - * - * Calling load_plugin_textdomain() should be delayed until init action. - * @see https://developer.wordpress.org/reference/functions/load_plugin_textdomain/#comment-1568 - * - * load_plugin_textdomain() will try to load the mo file firstly from: - * WP_LANG_DIR . β€˜/plugins/’ . $mofile - * Only if it is not able to it will load it from GATHERPRESS_DIR_NAME folder - * @see https://developer.wordpress.org/reference/functions/load_plugin_textdomain/#comment-3521 - * - * Since WordPress 4.6 translations now take translate.wordpress.org as priority and so - * plugins that are translated via translate.wordpress.org DO NOT necessary require load_plugin_textdomain() anymore. - * If you don’t want to add a load_plugin_textdomain() call to your plugin - * you have to set the Requires at least: field in your readme.txt to 4.6 or more. - * @see https://developer.wordpress.org/plugins/internationalization/how-to-internationalize-your-plugin/#plugins-on-wordpress-org - * - * BUT, ...!!! - * - * A call to load_plugin_textdomain() is ABSOLUTELY NEEDED to properly load all translation files - * for users who chosed another than the sites default language in their /profile.php. - */ - public function load_gatherpress_textdomain() { - load_plugin_textdomain( 'gatherpress', false, false ); - } - /** * Add custom links to the plugin action links in the WordPress plugins list. * From 3b9a063cb2bf5273ee67d2da02dd2371a8cf2a0e Mon Sep 17 00:00:00 2001 From: Carsten Bach Date: Thu, 5 Sep 2024 16:27:38 +0200 Subject: [PATCH 14/16] Fix i18n-loading problem, by providing a locale to wp_timezone_choice() --- includes/core/classes/class-utility.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/core/classes/class-utility.php b/includes/core/classes/class-utility.php index aa77da1ee..38b7f34e1 100644 --- a/includes/core/classes/class-utility.php +++ b/includes/core/classes/class-utility.php @@ -97,7 +97,7 @@ public static function unprefix_key( string $key ): string { * @return array An array of time zones with labels as keys and time zone choices as values. */ public static function timezone_choices(): array { - $timezones_raw = explode( PHP_EOL, wp_timezone_choice( 'UTC' ) ); + $timezones_raw = explode( PHP_EOL, wp_timezone_choice( 'UTC', get_user_locale() ) ); $timezones_clean = array(); $group = null; From 3c2230a19163dcf0770d3bc65d0290f24e4e016f Mon Sep 17 00:00:00 2001 From: Carsten Bach Date: Thu, 5 Sep 2024 17:17:39 +0200 Subject: [PATCH 15/16] Require main-plugin-file to test on priority 9, because the plugin itself is loaded on 10. --- test/unit/php/bootstrap.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/unit/php/bootstrap.php b/test/unit/php/bootstrap.php index ca82f1618..8207501de 100755 --- a/test/unit/php/bootstrap.php +++ b/test/unit/php/bootstrap.php @@ -18,7 +18,8 @@ static function () { // Manually load our plugin without having to setup the development folder in the correct plugin folder. require_once __DIR__ . '/../../../gatherpress.php'; - } + }, + 9 // Require file on 9, because the plugin itself is loaded on 10. ); $gatherpress_bootstrap_instance->start(); From 41681fe56c798b6488705ac77896af003423f19f Mon Sep 17 00:00:00 2001 From: Carsten Bach Date: Thu, 5 Sep 2024 22:24:04 +0200 Subject: [PATCH 16/16] Move de-activation-hooks out of 'plugins_loaded' --- gatherpress.php | 7 +++++++ includes/core/classes/class-setup.php | 6 +++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/gatherpress.php b/gatherpress.php index ad03d1e70..7a9ca66e6 100644 --- a/gatherpress.php +++ b/gatherpress.php @@ -39,8 +39,15 @@ require_once GATHERPRESS_CORE_PATH . '/includes/core/classes/class-autoloader.php'; GatherPress\Core\Autoloader::register(); +register_activation_hook( GATHERPRESS_CORE_FILE, array( '\GatherPress\Core\Setup', 'activate_gatherpress_plugin' ) ); +register_deactivation_hook( GATHERPRESS_CORE_FILE, array( '\GatherPress\Core\Setup', 'deactivate_gatherpress_plugin' ) ); + + // Initialize setups. add_action( 'plugins_loaded', array( '\GatherPress\Core\Setup', 'get_instance' ) ); + + +// GatherPress\Core\Setup::get_instance(); \ No newline at end of file diff --git a/includes/core/classes/class-setup.php b/includes/core/classes/class-setup.php index 152c6a9fa..b1467a4dc 100644 --- a/includes/core/classes/class-setup.php +++ b/includes/core/classes/class-setup.php @@ -82,12 +82,12 @@ protected function instantiate_classes(): void { * @return void */ protected function setup_hooks(): void { - register_activation_hook( GATHERPRESS_CORE_FILE, array( $this, 'activate_gatherpress_plugin' ) ); - register_deactivation_hook( GATHERPRESS_CORE_FILE, array( $this, 'deactivate_gatherpress_plugin' ) ); + // register_activation_hook( GATHERPRESS_CORE_FILE, array( $this, 'activate_gatherpress_plugin' ) ); + // register_deactivation_hook( GATHERPRESS_CORE_FILE, array( $this, 'deactivate_gatherpress_plugin' ) ); add_action( 'init', array( $this, 'maybe_flush_rewrite_rules' ) ); add_action( 'admin_notices', array( $this, 'check_users_can_register' ) ); - add_action( 'admin_init', array( $this, 'check_gatherpress_alpha' ) ); + add_action( 'admin_notices', array( $this, 'check_gatherpress_alpha' ) ); add_action( 'wp_initialize_site', array( $this, 'on_site_create' ) ); add_filter( 'block_categories_all', array( $this, 'register_gatherpress_block_category' ) );