id, Admin::SLUG ) ) { return false; } $since = (int) get_option( self::OPTION ); if ( ! $since ) { add_option( self::OPTION, time(), '', false ); return false; } if ( time() - $since < WEEK_IN_SECONDS ) { return false; } $state = get_user_meta( get_current_user_id(), self::META, true ); if ( 'done' === $state || 'never' === $state || ( is_numeric( $state ) && time() < (int) $state ) ) { return false; } $ok = get_transient( 'handymcp_review_calls' ); if ( false === $ok ) { global $wpdb; $ok = (int) $wpdb->get_var( $wpdb->prepare( 'SELECT COUNT(*) FROM %i WHERE status = %s', Installer::table( 'log' ), 'success' ) ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- cached in a transient below. set_transient( 'handymcp_review_calls', $ok, DAY_IN_SECONDS ); } return (int) $ok >= self::CALLS; } public static function notice(): void { if ( ! self::due() ) { return; } $link = static function ( string $do ): string { return wp_nonce_url( add_query_arg( array( 'action' => 'handymcp_review', 'do' => $do ), admin_url( 'admin-post.php' ) ), 'handymcp_review' ); }; $later = is_numeric( get_user_meta( get_current_user_id(), self::META, true ) ) ? 'never' : 'later'; echo '
' . esc_html__( 'Is HandyMCP helping you?', 'handymcp' ) . ' ' . esc_html__( 'You have been using it for a week. If it saves you time, a short review on WordPress.org helps other site owners find it. It only takes a minute.', 'handymcp' ) . '
' . '' . esc_html__( 'Leave a review', 'handymcp' ) . ' ' . '' . esc_html( 'later' === $later ? __( 'Maybe later', 'handymcp' ) : __( 'Not now', 'handymcp' ) ) . ' ' . '' . esc_html__( 'Do not ask again', 'handymcp' ) . '