' . esc_html__( 'Connection', 'abs-courier' ) . ''; echo ''; echo ''; if ( $has_key && $state['checked_at'] > 0 ) { echo ''; } echo ''; if ( $has_key ) { SettingsPage::action_button( Actions::TEST, __( 'Test connection', 'abs-courier' ), 'secondary' ); } else { printf( '

%s

', esc_url( Menu::url( 'settings' ) ), esc_html__( 'Connect your ABS account', 'abs-courier' ) ); } if ( $connected ) { self::render_status_updates(); } echo '

' . esc_html__( 'Setup', 'abs-courier' ) . '

'; echo ''; } /** * Live webhook and periodic check status. * * @return void */ private static function render_status_updates() { $webhook = \ABSCourier\Webhooks\WebhookRegistrar::saved(); $live = \ABSCourier\Webhooks\WebhookRegistrar::is_registered(); $last = (int) get_option( \ABSCourier\Webhooks\WebhookController::LAST_OPTION, 0 ); $next = function_exists( 'as_next_scheduled_action' ) ? as_next_scheduled_action( \ABSCourier\Shipments\StatusSync::HOOK_RECONCILE, array(), \ABSCourier\Shipments\Queue::GROUP ) : false; echo '

' . esc_html__( 'Shipment status updates', 'abs-courier' ) . '

'; echo ''; echo ''; echo ''; echo ''; if ( ! $live ) { SettingsPage::action_button( Actions::WEBHOOK, __( 'Turn on live updates', 'abs-courier' ), 'secondary' ); } } /** * Prints a coloured status label. * * @param string $status Connection status. * @return void */ private static function status_badge( $status ) { $labels = array( Connection::CONNECTED => array( __( 'Connected', 'abs-courier' ), '#00a32a' ), Connection::INVALID => array( __( 'API key rejected', 'abs-courier' ), '#d63638' ), Connection::UNBOUND => array( __( 'Key needs changes', 'abs-courier' ), '#dba617' ), Connection::ERROR => array( __( 'Could not reach ABS', 'abs-courier' ), '#dba617' ), Connection::NOT_CONNECTED => array( __( 'Not connected', 'abs-courier' ), '#646970' ), ); list( $label, $color ) = isset( $labels[ $status ] ) ? $labels[ $status ] : $labels[ Connection::NOT_CONNECTED ]; printf( '● %2$s', esc_attr( $color ), esc_html( $label ) ); } /** * Prints a checklist item. * * @param bool $done Whether the step is complete. * @param string $label Step label. * @return void */ private static function check_item( $done, $label ) { printf( '
  • %2$s %3$s
  • ', $done ? 'dashicons-yes-alt' : 'dashicons-marker', esc_html( $label ), $done ? esc_html__( '(done)', 'abs-courier' ) : esc_html__( '(to do)', 'abs-courier' ) ); } }