post_type ) { add_option( self::OPTION, time(), '', false ); } } /** * Whether a quickscan has been published. Also covers scans published * before this request existed. */ private static function has_published_scan(): bool { if ( get_option( self::OPTION ) ) { return true; } $published = get_posts( array( 'post_type' => Post_Type::POST_TYPE, 'post_status' => 'publish', 'posts_per_page' => 1, 'fields' => 'ids', 'no_found_rows' => true, ) ); if ( ! $published ) { return false; } add_option( self::OPTION, time(), '', false ); return true; } /** * Whether the current user should see the request on this screen. */ private static function should_show(): bool { if ( ! current_user_can( 'edit_posts' ) ) { return false; } $screen = function_exists( 'get_current_screen' ) ? get_current_screen() : null; if ( ! $screen || Post_Type::POST_TYPE !== $screen->post_type || Admin::is_editor_screen() ) { return false; } $state = get_user_meta( get_current_user_id(), self::USER_META, true ); if ( 'done' === $state || ( is_numeric( $state ) && time() < (int) $state ) ) { return false; } return self::has_published_scan(); } /** * URL that records the user's choice. * * @param string $choice "rate", "later" or "done". */ private static function choice_url( string $choice ): string { return wp_nonce_url( add_query_arg( array( 'action' => self::ACTION, 'choice' => $choice, ), admin_url( 'admin-post.php' ) ), self::ACTION ); } /** * Styles for the request. */ public static function enqueue(): void { if ( ! self::should_show() ) { return; } wp_enqueue_style( 'funnelfork-fonts', FUNNELFORK_URL . 'assets/fonts/fonts.css', array(), FUNNELFORK_VERSION ); wp_enqueue_style( 'funnelfork-review', FUNNELFORK_URL . 'assets/review.css', array( 'funnelfork-fonts' ), FUNNELFORK_VERSION ); } /** * Renders the request. */ public static function render_notice(): void { if ( ! self::should_show() ) { return; } $user = wp_get_current_user(); $name = $user->first_name ? $user->first_name : $user->display_name; ?>

' . esc_html__( 'Let us know in the support forum', 'funnelfork' ) . '' ); ?>