post_type ) { return 0; } $state = get_user_meta( get_current_user_id(), 'klbq_review', true ); if ( 'done' === $state || ( is_numeric( $state ) && time() < (int) $state ) ) { return 0; } if ( time() - klbq_installed_at() < KLBQ_REVIEW_DAYS * DAY_IN_SECONDS ) { return 0; } $quotes = new WP_Query( array( 'post_type' => KLBQ_CPT, 'post_status' => 'any', 'posts_per_page' => 1, 'fields' => 'ids', 'no_found_rows' => false, ) ); $count = (int) $quotes->found_posts; return $count >= KLBQ_REVIEW_QUOTES ? $count : 0; } /** * Link that records the user's choice. * * @param string $choice rate|later|done. * @return string */ function klbq_review_link( $choice ) { return wp_nonce_url( add_query_arg( array( 'action' => 'klbq_review', 'choice' => $choice, ), admin_url( 'admin-post.php' ) ), 'klbq_review' ); } add_action( 'admin_notices', function () { $count = klbq_review_due(); if ( ! $count ) { return; } ?>