id || str_contains( $screen->id, '_page_' . Menu::SLUG . '-' ); } /** * Five star links, each opening the review form at that rating. All * five are filled to start with; hovering one shows that rating. * * @param string $extra_class Extra class. * @return string */ public static function stars_html( string $extra_class = '' ): string { $html = ''; // Printed 5 → 1: the CSS lays them out reversed, so "this star and // the ones before it" is `:hover ~ a`. for ( $stars = 5; $stars >= 1; $stars-- ) { $html .= sprintf( '%2$s', esc_url( self::review_url( $stars ) ), /* translators: %d: number of stars, 1 to 5 */ esc_html( sprintf( _n( 'Rate %d star on WordPress.org (opens in a new tab)', 'Rate %d stars on WordPress.org (opens in a new tab)', $stars, 'all-in-one-utilities' ), $stars ) ) ); } return '' . $html . ''; } /** * When the plugin was installed. Sites that had it before this was * recorded start counting from the first time this runs. * * @return int Timestamp. */ public static function installed_at(): int { $installed = (int) get_option( self::INSTALLED_OPTION, 0 ); if ( $installed < 1 ) { $installed = time(); add_option( self::INSTALLED_OPTION, $installed, '', false ); } return $installed; } /** * Whether the notice should show for the current user right now. * * @return bool */ private static function notice_due(): bool { if ( ! self::enabled() || ! current_user_can( self::CAP ) || is_network_admin() ) { return false; } $screen = function_exists( 'get_current_screen' ) ? get_current_screen() : null; // The block editor has no room for classic notices. if ( $screen && $screen->is_block_editor() ) { return false; } /** * Filters how long after install the review notice first appears. * * @since 2.0.0 * * @param int $seconds Default one week. */ $delay = (int) apply_filters( 'aiou_promo_notice_delay', self::NOTICE_DELAY ); if ( time() < self::installed_at() + $delay ) { return false; } $hidden = get_user_meta( get_current_user_id(), self::META, true ); if ( 'never' === $hidden ) { return false; } return ! ( is_numeric( $hidden ) && (int) $hidden > time() ); } /** * A link that hides the notice. * * @param string $how 'week' or 'never'. * @return string */ private static function dismiss_url( string $how ): string { return wp_nonce_url( add_query_arg( array( 'action' => self::ACTION, 'hide' => $how, ), admin_url( 'admin-post.php' ) ), self::ACTION ); } /** * Print the notice. * * @return void */ public static function notice(): void { if ( ! self::notice_due() ) { return; } $pro = ! defined( 'AIOU_PRO_VERSION' ); wp_enqueue_style( 'aiou-promotions', AIOU_URL . 'assets/css/promotions.css', array( 'dashicons' ), Menu::asset_version( 'assets/css/promotions.css' ) ); wp_enqueue_script( 'aiou-promotions', AIOU_URL . 'assets/js/promotions.js', array(), Menu::asset_version( 'assets/js/promotions.js' ), true ); ?>
' . sprintf( /* translators: 1: plugin name, 2: five linked stars, 3: "WordPress.org" link */ esc_html__( 'Enjoying %1$s? Please rate it %2$s on %3$s. It helps others find and trust it. Thank you!', 'all-in-one-utilities' ), '' . esc_html__( 'All-in-One Utilities', 'all-in-one-utilities' ) . '', self::stars_html( 'aiou-stars--small' ), 'WordPress.org' ) . ''; } /** * Right footer on the plugin's screens: the plugin version and a support * link, before WordPress's own version. * * @param string $content Footer content. * @return string */ public static function footer_version( $content ) { if ( ! self::is_plugin_screen() || ! current_user_can( self::CAP ) ) { return $content; } $ours = sprintf( /* translators: %s: plugin version */ esc_html__( 'All-in-One Utilities %s', 'all-in-one-utilities' ), esc_html( AIOU_VERSION ) ) . ' · ' . esc_html__( 'Get support', 'all-in-one-utilities' ) . ''; return '' !== trim( wp_strip_all_tags( (string) $content ) ) ? $ours . ' · ' . $content : $ours; } }