%s

', $this->get_notice_class($notification_type), $message); } /** * Get notice class name * @since 1.0.4 * @param string $notification_type (success, warning, danger, info) * @param string $className */ public function get_notice_class($notification_type = 'success') { return "notice-{$notification_type}"; } /** * Countdown + redirect markup (paired with routeapp-admin.js .routeapp-redirect-countdown). * * @param string $redirect_url Full URL. * @param string $mode "always" = ignore route_installed cookie (ownership / conflict flows). "once" = legacy cookie so we do not loop every visit. * @return string */ private function redirect_countdown_html( $redirect_url, $mode = 'always' ) { $url = esc_url( $redirect_url ); $countdown = '5 ' . esc_html__( 'seconds', 'routeapp' ) . ''; $manual = ' — ' . esc_html__( 'Open manually', 'routeapp' ) . ''; return $countdown . $manual; } /** * Import all admin notices message * @since 1.0.4 * @param void */ public function routeapp_attention_required() { //$this->billing_attention_required(); //MSS-5023: disabling this alert until we get a new FR to check the billing info. $this->user_attention_required(); $this->merchant_token_recovery_attention_required(); $this->merchant_attention_required(); $this->redirect_attention_required(); } /** * Import admin notice verification to Billing Info * @since 1.0.4 * @param void */ // public function billing_attention_required() //MSS-5023: commented this alert until we get a new FR to check the billing info. // { // $billingResponse = Routeapp_API_Client::getInstance()->get_billing(); // // if (!is_wp_error($billingResponse)) { // $body = json_decode($billingResponse['body']); // // if (isset($body) && is_countable($body)) { // if (count($body) === 0) { // $this->add_notice("Route: You haven't yet completed the Billing Info step. Click here to complete.", "warning"); // } // } // } // } /** * Import admin notice if user creation has failed * @since 1.0.4 * @param void */ public function user_attention_required() { $routeapp_public = $this->get_route_public_instance(); if ($routeapp_public->has_user_creation_conflicted()) { $dashboard_url = Route_Setup::get_dashboard_ownership_login_url(); $failed_step = get_option( Route_Setup::FAILED_REGISTRATION ); $auto_done = get_option( Route_Setup::USER_CONFLICT_AUTO_REDIRECT_DONE_OPTION ); if ( $auto_done ) { $link = sprintf( '%s', esc_url( $dashboard_url ), esc_html__( 'Open the Route Dashboard', 'routeapp' ) ); if ( Route_Setup::FAILED_REGISTRATION_STEP_USER_LOGIN_FAILED === $failed_step ) { $message = sprintf( /* translators: %s: "Open the Route Dashboard" link HTML */ __( 'Route could not sign you in. %s to sign in and link this store.', 'routeapp' ), $link ); } else { $message = sprintf( /* translators: %s: "Open the Route Dashboard" link HTML */ __( 'This email is already registered with Route. %s to sign in and link this store.', 'routeapp' ), $link ); } $this->add_notice( wp_kses_post( $message ), 'warning' ); } else { update_option( Route_Setup::USER_CONFLICT_AUTO_REDIRECT_DONE_OPTION, '1', false ); if ( Route_Setup::FAILED_REGISTRATION_STEP_USER_LOGIN_FAILED === $failed_step ) { $intro = esc_html__( 'Route could not sign you in. We\'re redirecting you to the Route Dashboard to sign in and link this store.', 'routeapp' ); } else { $intro = esc_html__( 'This email is already registered with Route. We\'re redirecting you to the Route Dashboard to sign in and link this store.', 'routeapp' ); } $message = $intro . ' ' . $this->redirect_countdown_html( $dashboard_url, 'always' ); $this->add_notice( $message, 'warning' ); } } if ($routeapp_public->has_user_creation_failed()) { $this->add_notice("We couldn't create your account, please contact our support or try again .", "warning"); } } /** * When public/secret tokens were cleared but onboarding state remains — prompt Dashboard OTP or password login to refresh keys. */ public function merchant_token_recovery_attention_required() { $routeapp_public = $this->get_route_public_instance(); if ( ! $routeapp_public || $routeapp_public->has_user_creation_conflicted() ) { return; } if ( ! Route_Setup::should_prompt_merchant_token_recovery() ) { return; } $dashboard_url = Route_Setup::get_dashboard_ownership_login_url(); $this->add_notice( 'Route configurations missing from this site. ' . sprintf( '%s', esc_url( $dashboard_url ), esc_html__( 'Open Route Dashboard to reconnect', 'routeapp' ) ), 'warning' ); } /** * @return WP_User */ private function get_current_user() { return wp_get_current_user(); } /** * @return string */ private function get_current_email() { return get_bloginfo('admin_email'); } /** * Import admin notice if merchant creation has failed * @since 1.0.4 * @param void */ public function merchant_attention_required() { $routeapp_public = $this->get_route_public_instance(); if ($routeapp_public->has_merchant_creation_failed()) { $this->add_notice("Route merchant creation has failed. Please click here to retry.", "warning"); } } /** * Import admin notice verification to Billing Info * @since 1.0.4 * @param void */ public function redirect_attention_required() { $routeapp_public = $this->get_route_public_instance(); if ($routeapp_public->successful_registration() && !$routeapp_public->was_redirected()) { $this->add_notice( "You're almost there! We're redirecting you to Route website to finalize your account setup... " . $this->redirect_countdown_html( Route_Setup::get_route_redirect(), 'once' ), 'success' ); $routeapp_public->set_as_redirected(); } if ($routeapp_public->has_merchant_creation_conflicted()) { $dashboard_url = Route_Setup::get_dashboard_ownership_login_url(); $link = sprintf( '%s', esc_url( $dashboard_url ), esc_html__( 'Sign in on the Route Dashboard', 'routeapp' ) ); $message = sprintf( /* translators: %s: "Sign in on the Route Dashboard" link HTML */ __( 'Your merchant account already exists. %s to link this store.', 'routeapp' ), $link ); $this->add_notice( wp_kses_post( $message ), 'warning' ); } } private function get_route_public_instance() { global $routeapp_public; return $routeapp_public; } }