' . wp_kses_post( $custom ) . '' : ''; } /** * Hide "Version x.y" in the footer from users who can't update * WordPress (those who can still see it, and any update notice). * * @param string $content Footer HTML. * @return string */ public function footer_version( $content ) { return current_user_can( 'update_core' ) ? $content : ''; } /** * "WordPress 7.1 running Twenty Twenty-Five theme." → "Running the * Twenty Twenty-Five theme." in At a Glance, for users who can't * update WordPress. * * @param string $content Format string (1: version, 2: theme). * @return string */ public function at_a_glance_text( $content ) { /* translators: 2: Theme name. (1, the WordPress version, is deliberately not shown.) */ return current_user_can( 'update_core' ) ? $content : __( 'Running the %2$s theme.', 'all-in-one-utilities' ); } /** * Core scripts and styles carry the WordPress version as `?ver=`. * Swap it for a short hash of the version: browsers still fetch fresh * files after an update, but the version itself isn't exposed. * * @param string $src Asset URL. * @return string */ public function mask_asset_version( $src ) { $version = (string) get_bloginfo( 'version' ); if ( ! is_string( $src ) || '' === $version || ! str_contains( $src, 'ver=' . $version ) ) { return $src; } return (string) preg_replace( '/([?&]ver=)' . preg_quote( $version, '/' ) . '(?=&|$)/', '${1}' . substr( wp_hash( $version ), 0, 8 ), $src ); } /** * Turn the toolbar off on the site for users in a chosen role. (In * wp-admin itself WordPress always shows it.) * * @param bool $show Whether to show it. * @return bool */ public function maybe_hide_admin_bar( $show ) { if ( ! $show || ! is_user_logged_in() ) { return $show; } $roles = (array) aiou_get_setting( 'admin', 'admin_bar', 'hide_for_roles', array() ); return array_intersect( $roles, (array) wp_get_current_user()->roles ) ? false : $show; } }