post_type || false !== strpos( $screen->id, self::PAGE ) ) { return true; } // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- screen detection only. return 'woocommerce_page_wc-settings' === $screen->id && isset( $_GET['tab'] ) && Admin::TAB === sanitize_key( wp_unslash( $_GET['tab'] ) ); } /** * Admin styles on plugin screens. */ public function enqueue() { if ( self::is_plugin_screen() ) { wp_enqueue_style( 'bbquote-admin', BBQUOTE_URL . 'assets/css/admin.css', array(), BBQUOTE_VERSION ); } } /** * "Getting started" link on the plugins screen. * * @param array $links Links. * @return array */ public function action_link( $links ) { $links[] = sprintf( '%s', esc_url( self::url() ), esc_html__( 'Getting started', 'boring-quote' ) ); return $links; } /** * Help tab with the essentials on every plugin screen. */ public function help_tabs() { if ( ! self::is_plugin_screen() ) { return; } $screen = get_current_screen(); $screen->add_help_tab( array( 'id' => 'bbquote_help_overview', 'title' => __( 'Boring Quote', 'boring-quote' ), 'content' => '
' . esc_html__( 'Customers add products to a quote list with the "Request a quote" button and send the list with the form on the quote page. Every request lands in WooCommerce > Quote Requests and in your inbox.', 'boring-quote' ) . '
' . '' . esc_html__( 'Reply to the notification email to answer the customer directly. Change the status of the request to keep track of your work.', 'boring-quote' ) . '
', ) ); $screen->add_help_tab( array( 'id' => 'bbquote_help_catalog', 'title' => __( 'Catalog mode', 'boring-quote' ), 'content' => '' . esc_html__( 'Turn on both catalog mode options (hide prices, hide "Add to cart") in WooCommerce > Settings > Boring Quote. Customers can then only ask for a quote, they cannot buy online.', 'boring-quote' ) . '
' . '' . esc_html__( 'To hide the quote button on a single product, tick "Hide quote button" in the product data box.', 'boring-quote' ) . '
', ) ); $screen->set_help_sidebar( '' . esc_html__( 'More help', 'boring-quote' ) . '
' . '' . '' ); } /** * Setup steps with their done state. * * @return array */ public static function steps() { $page_id = (int) get_option( 'bbquote_page_id' ); $page_ok = $page_id && 'publish' === get_post_status( $page_id ); $settings = get_option( 'bbquote_settings', false ); $counts = wp_count_posts( QuoteCPT::POST_TYPE ); $quotes = 0; foreach ( array_keys( QuoteCPT::statuses() ) as $status ) { $quotes += isset( $counts->$status ) ? (int) $counts->$status : 0; } $product = wc_get_products( array( 'limit' => 1, 'status' => 'publish', 'return' => 'ids', ) ); $steps = array( 'page' => array( 'title' => __( 'Quote page', 'boring-quote' ), 'text' => __( 'Customers review their list and send the request on this page. It was created on activation.', 'boring-quote' ), 'done' => $page_ok, 'url' => $page_ok ? get_permalink( $page_id ) : admin_url( 'admin.php?page=wc-settings&tab=' . Admin::TAB ), 'cta' => $page_ok ? __( 'View page', 'boring-quote' ) : __( 'Choose a page', 'boring-quote' ), ), 'settings' => array( 'title' => __( 'Button and catalog mode', 'boring-quote' ), 'text' => __( 'Set the button label and decide whether prices and "Add to cart" stay visible.', 'boring-quote' ), 'done' => false !== $settings, 'url' => admin_url( 'admin.php?page=wc-settings&tab=' . Admin::TAB ), 'cta' => __( 'Open settings', 'boring-quote' ), ), 'emails' => array( 'title' => __( 'Emails', 'boring-quote' ), 'text' => __( 'Check the recipient of new requests and the confirmation sent to customers.', 'boring-quote' ), 'done' => false !== get_option( 'woocommerce_bbquote_new_request_settings', false ), 'url' => admin_url( 'admin.php?page=wc-settings&tab=email' ), 'cta' => __( 'Email settings', 'boring-quote' ), ), 'test' => array( 'title' => __( 'Send a test request', 'boring-quote' ), 'text' => __( 'Add a product to the list on your shop and send the form. The request appears in Quote Requests.', 'boring-quote' ), 'done' => $quotes > 0, 'url' => $product ? get_permalink( $product[0] ) : admin_url( 'post-new.php?post_type=product' ), 'cta' => $product ? __( 'Open a product', 'boring-quote' ) : __( 'Add a product', 'boring-quote' ), ), ); /** * Steps on the Getting started screen. * * @param array $steps Steps: title, text, done, url, cta. */ return apply_filters( 'bbquote_getting_started_steps', $steps ); } /** * Render the page. */ public function render() { $steps = self::steps(); $done = count( array_filter( wp_list_pluck( $steps, 'done' ) ) ); ?>