← All changes
|
core/module/google-calendar/Controller/calendar-auth-controller.php
+42
-0
1.0.21
→
1.0.28
View file →
| @@ -52,8 +52,9 @@ | ||
| 52 | 52 | */ |
| 53 | 53 | public function __construct() { |
| 54 | 54 | $this->oauth_config = $this->get_oauth_config(); |
| 55 | 55 | add_action( 'template_redirect', array( $this, 'handle_google_auth_callback' ) ); |
| 56 | + add_action( 'admin_notices', array( $this, 'permalink_warning_notice' ) ); | |
| 56 | 57 | |
| 57 | 58 | // In your addon's main file or a dedicated class |
| 58 | 59 | add_filter( |
| 59 | 60 | 'booktics_team_member_data', |
| @@ -63,8 +64,49 @@ | ||
| 63 | 64 | return $team_member; |
| 64 | 65 | }, |
| 65 | 66 | 10, |
| 66 | 67 | 2 |
| 68 | + ); | |
| 69 | + } | |
| 70 | + | |
| 71 | + /** | |
| 72 | + * Warn the admin when the permalink structure breaks the OAuth callback. | |
| 73 | + * | |
| 74 | + * The Google callback lives at a pretty path ( booktics-integration/ | |
| 75 | + * google-auth ), which WordPress only routes when permalinks are not set to | |
| 76 | + * Plain. On Plain that URL 404s and the connection silently fails, so a | |
| 77 | + * heads-up is shown — but only once Google is actually configured, to keep | |
| 78 | + * the notice off screens where it would be noise. | |
| 79 | + * | |
| 80 | + * @return void | |
| 81 | + */ | |
| 82 | + public function permalink_warning_notice() { | |
| 83 | + if ( ! current_user_can( 'manage_options' ) ) { | |
| 84 | + return; | |
| 85 | + } | |
| 86 | + | |
| 87 | + // Plain permalinks store an empty structure. | |
| 88 | + if ( get_option( 'permalink_structure' ) ) { | |
| 89 | + return; | |
| 90 | + } | |
| 91 | + | |
| 92 | + if ( ! booktics_get_option( 'google_client_id' ) ) { | |
| 93 | + return; | |
| 94 | + } | |
| 95 | + | |
| 96 | + printf( | |
| 97 | + '<div class="notice notice-warning"><p>%s</p></div>', | |
| 98 | + wp_kses( | |
| 99 | + sprintf( | |
| 100 | + /* translators: %s: link to the WordPress permalink settings screen. */ | |
| 101 | + __( 'Booktics: Google Calendar sign-in needs a permalink structure other than <strong>Plain</strong>. Open <a href="%s">Settings → Permalinks</a> and pick <strong>Post name</strong>, or the Google connection will fail.', 'booktics' ), | |
| 102 | + esc_url( admin_url( 'options-permalink.php' ) ) | |
| 103 | + ), | |
| 104 | + array( | |
| 105 | + 'strong' => array(), | |
| 106 | + 'a' => array( 'href' => array() ), | |
| 107 | + ) | |
| 108 | + ) | |
| 67 | 109 | ); |
| 68 | 110 | } |
| 69 | 111 | |
| 70 | 112 | /** |