plugin = $plugin; } /** * Registers the handler and the redirect after activation. */ public function register(): void { add_action( 'admin_post_' . self::FINISH, array( $this, 'finish' ) ); add_action( 'admin_init', array( $this, 'maybe_redirect' ) ); } /** * After the plugin is activated for the first time, opens the guide once. */ public function maybe_redirect(): void { if ( ! get_transient( self::REDIRECT_FLAG ) ) { return; } delete_transient( self::REDIRECT_FLAG ); if ( wp_doing_ajax() || isset( $_GET['activate-multi'] ) || get_option( self::OPTION_DONE ) || ! current_user_can( Plugin::CAPABILITY ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- only checks whether WordPress is activating several plugins. return; } wp_safe_redirect( Menu::welcome_url() ); exit; } /** * Marks the guide as finished. */ public function finish(): void { if ( ! current_user_can( Plugin::CAPABILITY ) ) { wp_die( esc_html__( 'You are not allowed to do this.', 'tidelist' ), '', array( 'response' => 403 ) ); } check_admin_referer( self::FINISH ); update_option( self::OPTION_DONE, 1, false ); wp_safe_redirect( Menu::listings_url() ); exit; } /** * Where the guide stands. */ private function facts(): array { $settings = $this->plugin->settings(); return array( $this->plugin->channel()->is_connected(), count( $this->plugin->category_map()->all() ), '' !== trim( (string) $settings->get( 'contact_name' ) ) && $this->plugin->channel()->is_configured(), (bool) get_option( self::OPTION_PREVIEW ), ); } /** * Renders the page. */ public function render(): void { $channel_label = $this->plugin->channel()->label(); if ( ! current_user_can( Plugin::CAPABILITY ) ) { return; } list( $connected, $mapped, $contact, $previewed ) = $this->facts(); $steps = array_column( OnboardingSteps::steps( $connected, $mapped, $contact, $previewed ), 'done', 'id' ); $current = OnboardingSteps::current( $connected, $mapped, $contact, $previewed ); $cards = array( OnboardingSteps::WELCOME => array( __( 'Welcome to Tidelist', 'tidelist' ), Text::channel( __( 'Tidelist lists your WooCommerce products on {channel} and keeps the adverts in step with your shop: when an item sells out, its advert comes down. You choose what goes online and when. Nothing is published without you.', 'tidelist' ), $channel_label ) . ' ' . Text::channel( __( 'Dry-run is ON from the start: Tidelist builds and logs every advert but sends nothing that changes {channel}. You switch dry-run off yourself when you are ready, in Settings.', 'tidelist' ), $channel_label ), '', '', ), OnboardingSteps::CONNECT => array( Text::channel( __( '1. Connect your {channel} account', 'tidelist' ), $channel_label ), Text::channel( __( 'Choose your country, register your own {channel} developer app and connect your account. Also enter the contact name and the city for your adverts in Settings.', 'tidelist' ), $channel_label ), Menu::connect_url(), __( 'Open the Connect screen', 'tidelist' ), ), OnboardingSteps::CATEGORIES => array( __( '2. Map your categories', 'tidelist' ), Text::channel( __( 'Say which {channel} category each of your shop categories belongs to, then check the {channel} fields such as condition and size.', 'tidelist' ), $channel_label ), Menu::categories_url(), __( 'Map categories', 'tidelist' ), ), OnboardingSteps::PREVIEW => array( __( '3. Preview a few products', 'tidelist' ), __( 'Open the preview of three products on the Listings screen. It shows exactly what would be sent and what is still missing.', 'tidelist' ), Menu::listings_url(), __( 'Open the Listings', 'tidelist' ), ), ); ?>

$card ) : ?>