# routeapp/2.4.11/admin/class-routeapp-notice.php

Route ‑ Shipping Protection, version 2.4.11. 234 lines.

- Page: https://pluginprobe.com/plugins/routeapp/2.4.11/code/admin/class-routeapp-notice.php
- Raw: https://pluginprobe.com/plugins/routeapp/2.4.11/raw/admin/class-routeapp-notice.php
- Modified: 2026-04-13T19:55:40+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/routeapp/2.4.11/code/admin/class-routeapp-notice.php#L10-L20`.

```php
<?php

/**
 * The file that defines the core plugin class
 *
 * A class definition that includes attributes and functions used across both the
 * public-facing side of the site and the admin area.
 *
 * @link       https://route.com/
 * @since      1.0.4
 *
 * @package    Routeapp
 * @subpackage Routeapp/admin
 */

class Routeapp_Notice {

   public function __construct( ) {
      add_action( 'admin_notices', array( $this, 'routeapp_attention_required' ) );
      add_action('network_admin_notices', array( $this, 'routeapp_attention_required' ) );
   }

   /**
	 * Add admin notice messages to Woocommerce
	 * @since  1.0.4
	 * @param  string $message Message that would be output
    * @param  string $notification_type (success, warning, danger, info)
    * @param  void
	 */
   public function add_notice($message, $notification_type) {
      echo sprintf('<div class="notice %s is-dismissible"><p><span class="dashicons-before dashicons-arkcommerce" style="vertical-align:middle;"> </span> %s</p></div>', $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 = '<span class="routeapp-redirect-countdown" data-countdown-mode="' . esc_attr( $mode ) . '" data-seconds="5" data-redirect-src="' . $url . '"><span class="routeapp-redirect-countdown__num">5</span> ' . esc_html__( 'seconds', 'routeapp' ) . '</span>';
        $manual    = ' <span class="routeapp-redirect-manual"> — <a href="' . $url . '" class="routeapp-redirect-manual-link" target="_blank" rel="noopener noreferrer">' . esc_html__( 'Open manually', 'routeapp' ) . '</a></span>';

        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 <a href='http://dashboard.route.com/admin/preferences' target='_blank'>here</a> 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(
                    '<a href="%s" target="_blank" rel="noopener noreferrer">%s</a>',
                    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  <a href=\"/wp-json/route/recreate_user\"> try again </a></span>.", "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(
                '<a href="%s" target="_blank" rel="noopener noreferrer">%s</a>',
                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 <a href=\"/wp-json/route/recreate_merchant\"> here </a> to retry</span>.", "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(
                '<a href="%s" target="_blank" rel="noopener noreferrer">%s</a>',
                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;
    }

}

```
