Skip to content

Commit

Permalink
Merge pull request #672 from pbrocks/gp-admin-alert-timezone
Browse files Browse the repository at this point in the history
Update membership-check.php to include timezone check
  • Loading branch information
mauteri authored Jun 5, 2024
2 parents a682d42 + 6946db7 commit 7218df7
Show file tree
Hide file tree
Showing 15 changed files with 68 additions and 65 deletions.
2 changes: 1 addition & 1 deletion build/admin_style.css
Original file line number Diff line number Diff line change
@@ -1 +1 @@
.gatherpress-admin__membership-check{align-items:center;display:flex;gap:1rem;padding:.5rem}.gatherpress-admin__membership-check>div:last-child{margin-left:auto}
.gatherpress-admin__site-check{align-items:center;display:flex;gap:1rem;padding:.5rem}.gatherpress-admin__site-check>div:last-child{margin-left:auto}
8 changes: 4 additions & 4 deletions includes/core/classes/class-setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ protected function create_tables(): void {
public function check_users_can_register(): void {
if (
filter_var( get_option( 'users_can_register' ), FILTER_VALIDATE_BOOLEAN ) ||
filter_var( get_option( 'gatherpress_suppress_membership_notification' ), FILTER_VALIDATE_BOOLEAN ) ||
filter_var( get_option( 'gatherpress_suppress_site_notification' ), FILTER_VALIDATE_BOOLEAN ) ||
filter_var( ! current_user_can( 'manage_options' ), FILTER_VALIDATE_BOOLEAN ) ||
false === strpos( get_current_screen()->id, 'gatherpress' )
) {
Expand All @@ -410,14 +410,14 @@ public function check_users_can_register(): void {
wp_enqueue_style( 'gatherpress-admin-style' );

if (
'gatherpress_suppress_membership_notification' === filter_input( INPUT_GET, 'action' ) &&
'gatherpress_suppress_site_notification' === filter_input( INPUT_GET, 'action' ) &&
! empty( filter_input( INPUT_GET, '_wpnonce' ) ) &&
wp_verify_nonce( sanitize_text_field( wp_unslash( filter_input( INPUT_GET, '_wpnonce' ) ) ), 'clear-notification' )
) {
update_option( 'gatherpress_suppress_membership_notification', true );
update_option( 'gatherpress_suppress_site_notification', true );
} else {
Utility::render_template(
sprintf( '%s/includes/templates/admin/setup/membership-check.php', GATHERPRESS_CORE_PATH ),
sprintf( '%s/includes/templates/admin/setup/site-check.php', GATHERPRESS_CORE_PATH ),
array(),
true
);
Expand Down
31 changes: 0 additions & 31 deletions includes/templates/admin/setup/membership-check.php

This file was deleted.

34 changes: 34 additions & 0 deletions includes/templates/admin/setup/site-check.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php
/**
* Admin Notice for open membership check.
*
* @package GatherPress\Core
* @since 1.0.0
*/

// Exit if accessed directly.
defined( 'ABSPATH' ) || exit; // @codeCoverageIgnore

?>
<div class="gatherpress-admin__site-check notice notice-warning">
<div>
<?php
printf(
/* translators: 1: Enabling user registration 2: Setting time zone */
esc_html__( 'To ensure GatherPress functions optimally, we recommend enabling user registration and setting your site\'s timezone. You can do so by %1$s and %2$s.', 'gatherpress' ),
'<a href=' . esc_url( admin_url( 'options-general.php#users_can_register' ) ) . '>'
. esc_html_x( 'enabling user registration here', 'Context: To ensure GatherPress functions optimally, user registration and setting your site\'s timezone. You can do so by %1$s and %2$s.', 'gatherpress' )
. '</a>',
'<a href=' . esc_url( admin_url( 'options-general.php#timezone_string' ) ) . '>'
. esc_html_x( 'setting time zone here', 'Context: To ensure GatherPress functions optimally, user registration and setting your site\'s timezone. You can do so by %1$s and %2$s.', 'gatherpress' )
. '</a>'
);
?>
</div>
<div>
<a href="<?php echo esc_url( wp_nonce_url( add_query_arg( 'action', 'gatherpress_suppress_site_notification' ), 'clear-notification' ) ); ?>" class="button button-secondary">
<?php esc_html_e( 'Dismiss forever', 'gatherpress' ); ?>
</a>
</div>
</div>
<?php
6 changes: 3 additions & 3 deletions languages/gatherpress-ca.po
Original file line number Diff line number Diff line change
Expand Up @@ -455,19 +455,19 @@ msgstr "Vista prèvia:"
msgid "Save Settings"
msgstr "Desa la configuració"

#: includes/templates/admin/setup/membership-check.php:12
#: includes/templates/admin/setup/site-check.php:12
msgid ""
"To ensure GatherPress functions optimally, we recommend enabling user "
"registration. You can do so by"
msgstr ""
"Per garantir que GatherPress funcioni de manera òptima, us recomanem que "
"habiliteu el registre d'usuaris. Podeu fer-ho mitjançant"

#: includes/templates/admin/setup/membership-check.php:14
#: includes/templates/admin/setup/site-check.php:14
msgid "enabling user registration here"
msgstr "habilitació del registre d'usuari aquí"

#: includes/templates/admin/setup/membership-check.php:19
#: includes/templates/admin/setup/site-check.php:19
msgid "Dismiss forever"
msgstr "Ignora-ho sempre"

Expand Down
6 changes: 3 additions & 3 deletions languages/gatherpress-de_AT.po
Original file line number Diff line number Diff line change
Expand Up @@ -477,19 +477,19 @@ msgstr "Vorschau:"
msgid "Save Settings"
msgstr "Einstellungen speichern"

#: includes/templates/admin/setup/membership-check.php:12
#: includes/templates/admin/setup/site-check.php:12
msgid ""
"To ensure GatherPress functions optimally, we recommend enabling user "
"registration. You can do so by"
msgstr ""
"Um sicherzustellen, dass GatherPress optimal funktioniert, empfehlen wir, "
"die Benutzerregistrierung zu aktivieren. Das kannst du tun, indem du"

#: includes/templates/admin/setup/membership-check.php:14
#: includes/templates/admin/setup/site-check.php:14
msgid "enabling user registration here"
msgstr "hier die Benutzerregistrierung aktivierst"

#: includes/templates/admin/setup/membership-check.php:19
#: includes/templates/admin/setup/site-check.php:19
msgid "Dismiss forever"
msgstr "Nicht wieder anzeigen"

Expand Down
6 changes: 3 additions & 3 deletions languages/gatherpress-de_CH.po
Original file line number Diff line number Diff line change
Expand Up @@ -477,19 +477,19 @@ msgstr "Vorschau:"
msgid "Save Settings"
msgstr "Einstellungen speichern"

#: includes/templates/admin/setup/membership-check.php:12
#: includes/templates/admin/setup/site-check.php:12
msgid ""
"To ensure GatherPress functions optimally, we recommend enabling user "
"registration. You can do so by"
msgstr ""
"Um sicherzustellen, dass GatherPress optimal funktioniert, empfehlen wir, "
"die Benutzerregistrierung zu aktivieren. Sie können dies tun, indem Sie"

#: includes/templates/admin/setup/membership-check.php:14
#: includes/templates/admin/setup/site-check.php:14
msgid "enabling user registration here"
msgstr "hier die Benutzerregistrierung aktivieren"

#: includes/templates/admin/setup/membership-check.php:19
#: includes/templates/admin/setup/site-check.php:19
msgid "Dismiss forever"
msgstr "Nicht wieder anzeigen"

Expand Down
6 changes: 3 additions & 3 deletions languages/gatherpress-de_CH_informal.po
Original file line number Diff line number Diff line change
Expand Up @@ -477,19 +477,19 @@ msgstr "Vorschau:"
msgid "Save Settings"
msgstr "Einstellungen speichern"

#: includes/templates/admin/setup/membership-check.php:12
#: includes/templates/admin/setup/site-check.php:12
msgid ""
"To ensure GatherPress functions optimally, we recommend enabling user "
"registration. You can do so by"
msgstr ""
"Um sicherzustellen, dass GatherPress optimal funktioniert, empfehlen wir, "
"die Benutzerregistrierung zu aktivieren. Das kannst du tun, indem du"

#: includes/templates/admin/setup/membership-check.php:14
#: includes/templates/admin/setup/site-check.php:14
msgid "enabling user registration here"
msgstr "hier die Benutzerregistrierung aktivierst"

#: includes/templates/admin/setup/membership-check.php:19
#: includes/templates/admin/setup/site-check.php:19
msgid "Dismiss forever"
msgstr "Nicht wieder anzeigen"

Expand Down
6 changes: 3 additions & 3 deletions languages/gatherpress-de_DE.po
Original file line number Diff line number Diff line change
Expand Up @@ -476,19 +476,19 @@ msgstr "Vorschau:"
msgid "Save Settings"
msgstr "Einstellungen speichern"

#: includes/templates/admin/setup/membership-check.php:12
#: includes/templates/admin/setup/site-check.php:12
msgid ""
"To ensure GatherPress functions optimally, we recommend enabling user "
"registration. You can do so by"
msgstr ""
"Um sicherzustellen, dass GatherPress optimal funktioniert, empfehlen wir, "
"die Benutzerregistrierung zu aktivieren. Das kannst du tun, indem du"

#: includes/templates/admin/setup/membership-check.php:14
#: includes/templates/admin/setup/site-check.php:14
msgid "enabling user registration here"
msgstr "hier die Benutzerregistrierung aktivierst"

#: includes/templates/admin/setup/membership-check.php:19
#: includes/templates/admin/setup/site-check.php:19
msgid "Dismiss forever"
msgstr "Nicht wieder anzeigen"

Expand Down
6 changes: 3 additions & 3 deletions languages/gatherpress-de_DE_formal.po
Original file line number Diff line number Diff line change
Expand Up @@ -476,19 +476,19 @@ msgstr "Vorschau:"
msgid "Save Settings"
msgstr "Einstellungen speichern"

#: includes/templates/admin/setup/membership-check.php:12
#: includes/templates/admin/setup/site-check.php:12
msgid ""
"To ensure GatherPress functions optimally, we recommend enabling user "
"registration. You can do so by"
msgstr ""
"Um sicherzustellen, dass GatherPress optimal funktioniert, empfehlen wir, "
"die Benutzerregistrierung zu aktivieren. Sie können dies tun, indem Sie"

#: includes/templates/admin/setup/membership-check.php:14
#: includes/templates/admin/setup/site-check.php:14
msgid "enabling user registration here"
msgstr "hier die Benutzerregistrierung aktivieren"

#: includes/templates/admin/setup/membership-check.php:19
#: includes/templates/admin/setup/site-check.php:19
msgid "Dismiss forever"
msgstr "Nicht wieder anzeigen"

Expand Down
6 changes: 3 additions & 3 deletions languages/gatherpress-es_ES.po
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ msgstr "Vista previa:"
msgid "Save Settings"
msgstr "Guardar ajustes"

#: includes/templates/admin/setup/membership-check.php:24
#: includes/templates/admin/setup/site-check.php:24
msgid "Dismiss forever"
msgstr "Descartar para siempre"

Expand Down Expand Up @@ -939,11 +939,11 @@ msgid "Enable Immediate \"Not Attending\" Option for Attendees."
msgstr "Activar la opción inmediata «No asistir» para los asistentes."

#. translators: %s: "enabling user registration here" (hyperlinked)
#: includes/templates/admin/setup/membership-check.php:15
#: includes/templates/admin/setup/site-check.php:15
msgid "To ensure GatherPress functions optimally, we recommend enabling user registration. You can do so by %s"
msgstr "Para que GatherPress funcione de forma óptima, te recomendamos que actives el registro de usuarios. Puedes hacerlo %s"

#: includes/templates/admin/setup/membership-check.php:17
#: includes/templates/admin/setup/site-check.php:17
msgctxt "Context: To ensure GatherPress functions optimally, we recommend enabling user registration. You can do so by %s."
msgid "enabling user registration here"
msgstr "permitiendo el registro de usuarios aquí"
Expand Down
6 changes: 3 additions & 3 deletions languages/gatherpress-fr_FR.po
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ msgstr "Date : %s"
msgid "Didn't Go"
msgstr "Membre(s) n'ayant pas participé"

#: includes/templates/admin/setup/membership-check.php:19
#: includes/templates/admin/setup/site-check.php:19
msgid "Dismiss forever"
msgstr "Rejeter définitivement"

Expand Down Expand Up @@ -314,7 +314,7 @@ msgstr "Activer les RSVP anonymes"
msgid "Enable Anonymous RSVP for New Events."
msgstr "Activer les RSVP anonymes pour les nouveaux évènements"

#: includes/templates/admin/setup/membership-check.php:14
#: includes/templates/admin/setup/site-check.php:14
msgid "enabling user registration here"
msgstr "permettant l'enregistrement des utilisateur·rices ici"

Expand Down Expand Up @@ -879,7 +879,7 @@ msgstr "Format horaire"
msgid "Time Zone"
msgstr "Fuseau horaire"

#: includes/templates/admin/setup/membership-check.php:12
#: includes/templates/admin/setup/site-check.php:12
msgid ""
"To ensure GatherPress functions optimally, we recommend enabling user "
"registration. You can do so by"
Expand Down
6 changes: 3 additions & 3 deletions languages/gatherpress.pot
Original file line number Diff line number Diff line change
Expand Up @@ -491,16 +491,16 @@ msgid "Save Settings"
msgstr ""

#. translators: %s: "enabling user registration here" (hyperlinked)
#: includes/templates/admin/setup/membership-check.php:15
#: includes/templates/admin/setup/site-check.php:15
msgid "To ensure GatherPress functions optimally, we recommend enabling user registration. You can do so by %s"
msgstr ""

#: includes/templates/admin/setup/membership-check.php:17
#: includes/templates/admin/setup/site-check.php:17
msgctxt "Context: To ensure GatherPress functions optimally, we recommend enabling user registration. You can do so by %s."
msgid "enabling user registration here"
msgstr ""

#: includes/templates/admin/setup/membership-check.php:24
#: includes/templates/admin/setup/site-check.php:24
msgid "Dismiss forever"
msgstr ""

Expand Down
2 changes: 1 addition & 1 deletion src/admin.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.gatherpress-admin {
&__membership-check {
&__site-check {
align-items: center;
display: flex;
gap: 1rem;
Expand Down
2 changes: 1 addition & 1 deletion test/unit/php/includes/core/classes/class-test-setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public function test_setup_hooks(): void {
public function test_check_users_can_register(): void {
$instance = Setup::get_instance();
$users_can_register_name = 'users_can_register';
$suppress_membership_notification_name = 'gatherpress_suppress_membership_notification';
$suppress_membership_notification_name = 'gatherpress_suppress_site_notification';

$this->mock->user( 'admin', 'gatherpress_general' );
$this->mock->wp(
Expand Down

0 comments on commit 7218df7

Please sign in to comment.