'array', 'sanitize_callback' => array( 'Varly_Settings', 'sanitize' ), 'default' => Varly_Settings::defaults(), 'show_in_rest' => false, ) ); } /** * Styles for the settings page only. * * @param string $hook_suffix Current admin page. * @return void */ public static function assets( $hook_suffix ) { if ( 'settings_page_varly' === $hook_suffix ) { wp_enqueue_style( 'varly-admin', plugins_url( 'assets/css/admin.css', VARLY_FILE ), array(), VARLY_VERSION ); } } /** * "Settings" next to Deactivate on the Plugins screen. The word is WordPress's own, without a text * domain, so it is in the language of the admin right away. * * @param string[] $links Links. * @return string[] */ public static function action_links( $links ) { // phpcs:ignore WordPress.WP.I18n.MissingArgDomain -- On purpose: WordPress's own translation of "Settings". array_unshift( $links, '' . esc_html__( 'Settings' ) . '' ); return $links; } /** * On the Plugins screen only, while the site isn't connected: where to go next. * * @return void */ public static function plugins_screen_notice() { $screen = function_exists( 'get_current_screen' ) ? get_current_screen() : null; if ( ! $screen || 'plugins' !== $screen->id || ! current_user_can( 'manage_options' ) || Varly_Settings::connected() ) { return; } printf( '

%s %s

', esc_html__( 'Varly is installed. Connect it to your Varly account to add the snippet to your site.', 'varly' ), esc_url( Varly_Connect::settings_url() ), esc_html__( 'Go to Settings → Varly', 'varly' ) ); } /** * A button that posts to admin-post.php with a nonce. * * @param string $action Action name (also the nonce action). * @param string $label Button text. * @param string $classes Button classes. * @param string $confirm Question to confirm first, or ''. * @return void */ private static function action_button( $action, $label, $classes = 'button', $confirm = '' ) { ?>
(int) $state['last_sent'] ) ) { $why = 'invalid_key' === $error['message'] ? __( 'the order API key was not accepted', 'varly' ) : (string) $error['message']; /* translators: 1: order number, 2: reason, 3: "5 minutes ago". */ self::status_row( __( 'Orders', 'varly' ), 'error', sprintf( __( 'Sending order %1$s failed (%2$s), %3$s. See the notes on that order.', 'varly' ), $error['order'], $why, self::ago( (int) $error['time'] ) ) ); } elseif ( ! empty( $state['last_sent'] ) ) { /* translators: 1: order number, 2: "5 minutes ago". */ self::status_row( __( 'Orders', 'varly' ), 'ok', sprintf( __( 'Sent to Varly in the background. The last one, order %1$s, was sent %2$s.', 'varly' ), $state['last_order'], self::ago( (int) $state['last_sent'] ) ) ); } else { self::status_row( __( 'Orders', 'varly' ), 'ok', __( 'Ready. Every paid order is sent to Varly in the background; refunds and cancellations update it.', 'varly' ) ); } if ( Varly_Order_List::enabled() ) { $list_error = isset( $state['list_error'] ) && is_array( $state['list_error'] ) ? $state['list_error'] : null; if ( $list_error ) { $why = 'invalid_key' === $list_error['message'] ? __( 'the order API key was not accepted', 'varly' ) : (string) $list_error['message']; /* translators: 1: reason, 2: "5 minutes ago". */ self::status_row( __( 'Revenue check', 'varly' ), 'error', sprintf( __( 'Sending your order list failed (%1$s), %2$s. It is tried again tomorrow, or send it now.', 'varly' ), $why, self::ago( (int) $list_error['time'] ) ) ); } elseif ( ! empty( $state['list_done'] ) ) { /* translators: %s: "5 minutes ago". */ self::status_row( __( 'Revenue check', 'varly' ), 'ok', sprintf( __( 'Varly compares its orders with your shop’s own order list. The list was last sent %s; a new one goes once a day.', 'varly' ), self::ago( (int) $state['list_done'] ) ) ); } else { self::status_row( __( 'Revenue check', 'varly' ), 'info', __( 'Once a day your order list (number, time, amounts and status per order) goes to Varly, so it can compare its revenue with your shop. The first one is on its way.', 'varly' ) ); } } } } /** * The page. * * @return void */ public static function page() { if ( ! current_user_can( 'manage_options' ) ) { return; } // First what Varly says (kept for two minutes): it can change a setting shown below, such as // longer recognition in Safari. Varly_Connect::status(); $settings = Varly_Settings::get(); $connected = Varly_Settings::connected(); $woo = Varly_WooCommerce::active(); $notice = Varly_Connect::take_notice(); $option = Varly_Settings::OPTION; ?>

varly.ai' ); ?>

>

' . esc_html__( 'Install Varly on WordPress', 'varly' ) . '' ); ?>