0 && $now - $since >= self::MIN_DAYS * DAY_IN_SECONDS && $products >= self::MIN_PRODUCTS; } /** * Screen of ProdTabs the question may show on. * * @return string "screen", "import" (report of a successful import), or empty elsewhere. */ private static function context(): string { $screen = function_exists( 'get_current_screen' ) ? get_current_screen() : null; if ( ! $screen ) { return ''; } // phpcs:disable WordPress.Security.NonceVerification.Recommended -- screen detection only. $page = isset( $_GET['page'] ) ? sanitize_key( wp_unslash( $_GET['page'] ) ) : ''; if ( Admin_Import::PAGE === $page ) { $state = Import_Yikes::state(); $ok = 'done' === ( $state['status'] ?? '' ) && ! empty( $state['counts']['imported'] ) && empty( $state['counts']['errors'] ); return $ok ? 'import' : ''; } $settings = 'wc-settings' === $page && isset( $_GET['section'] ) && Admin_Settings::SECTION === $_GET['section']; // phpcs:enable return Admin_Hub::PAGE === $page || $settings || 'edit-' . Library::POST_TYPE === $screen->id ? 'screen' : ''; } /** * Link to an answer. * * @param string $answer yes, no, review, support, later or done. */ private static function link( string $answer ): string { return wp_nonce_url( admin_url( 'admin-post.php?action=' . self::ACTION . '&answer=' . $answer ), self::ACTION ); } /** The question, or the step its answer leads to. */ public static function notice(): void { if ( ! current_user_can( 'edit_products' ) ) { return; } $context = self::context(); if ( '' === $context ) { return; } $user = get_current_user_id(); $products = Admin_Hub::products_with_tabs(); if ( ! self::due( get_user_meta( $user, self::META, true ), (int) get_option( self::SINCE, 0 ), $products, 'import' === $context, time() ) ) { return; } $step = (string) get_user_meta( $user, self::STEP, true ); $new_tab = ' ' . esc_html__( '(opens in a new tab)', 'prodtabs' ) . ''; ?>