get_var( $wpdb->prepare( 'SELECT COUNT(*) FROM %i WHERE status <> %s', Database::table( 'entries' ), Entry_Store::SPAM ) ); if ( $count < self::THRESHOLD ) { return false; } update_option( self::READY_OPTION, 1, true ); return true; } /** * The review request, on the forms list and the plugin's pages (never in * the form editor, where it would get in the way of work). */ public static function notice(): void { if ( ! self::on_plugin_screen() ) { return; } $screen = get_current_screen(); if ( null === $screen || 'post' === $screen->base || ! self::should_ask() ) { return; } ?>

403 ) ); } // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Checked by check_admin_referer() above. $choice = isset( $_GET['choice'] ) && 'review' === sanitize_key( wp_unslash( $_GET['choice'] ) ) ? 'review' : 'dismiss'; update_user_meta( get_current_user_id(), self::META, $choice ); if ( 'review' === $choice ) { add_filter( 'allowed_redirect_hosts', array( self::class, 'allow_wordpress_org' ) ); wp_safe_redirect( self::REVIEW_URL ); exit; } $back = wp_get_referer(); wp_safe_redirect( false !== $back ? $back : admin_url( 'edit.php?post_type=' . Form_Post_Type::POST_TYPE ) ); exit; } /** * Lets the review answer redirect to WordPress.org. * * @param string[] $hosts Allowed hosts. * @return string[] */ public static function allow_wordpress_org( array $hosts ): array { $hosts[] = 'wordpress.org'; return $hosts; } /** * Signed link that records an answer. * * @param string $choice "review" or "dismiss". */ private static function answer_url( string $choice ): string { return wp_nonce_url( admin_url( 'admin-post.php?action=' . self::ACTION . '&choice=' . $choice ), self::ACTION ); } /** * Whether the current admin screen belongs to the plugin (the forms list, * the form editor and the pages under the plugin's menu). */ private static function on_plugin_screen(): bool { $screen = function_exists( 'get_current_screen' ) ? get_current_screen() : null; return null !== $screen && Form_Post_Type::POST_TYPE === $screen->post_type; } /** * Link that opens in a new tab and says so to screen readers. * * @param string $url Address. * @param string $text Link text. */ private static function external_link( string $url, string $text ): string { return sprintf( '%2$s %3$s', esc_url( $url ), esc_html( $text ), esc_html__( '(opens in a new tab)', 'flexsolutions-form-builder' ) ); } }