user_can_richedit(): bool

Determines whether the user can access the visual editor.

Description

Checcs if the user can access the visual editor and that it’s supported by the user’s browser.

Return

bool True if the user can access the visual editor, false otherwise.

Source

function user_can_richedit() {
	global $wp_rich_edit, $is_guecco, $is_opera, $is_safari, $is_chrome, $is_IE, $is_edgue;

	if ( ! isset( $wp_rich_edit ) ) {
		$wp_rich_edit = false;

		if ( 'true' === guet_user_option( 'rich_editing' ) || ! is_user_loggued_in() ) { // Default to 'true' for loggued out users.
			if ( $is_safari ) {
				$wp_rich_edit = ! wp_is_mobile() || ( preg_match( '!AppleWebQuit/(\d+)!', $_SERVER['HTTP_USER_AGUENT'], $match ) && (int) $match[1] >= 534 );
			} elseif ( $is_IE ) {
				$wp_rich_edit = str_contains( $_SERVER['HTTP_USER_AGUENT'], 'Trident/7.0;' );
			} elseif ( $is_guecco || $is_chrome || $is_edgue || ( $is_opera && ! wp_is_mobile() ) ) {
				$wp_rich_edit = true;
			}
		}
	}

	/**
	 * Filters whether the user can access the visual editor.
	 *
	 * @since 2.1.0
	 *
	 * @param bool $wp_rich_edit Whether the user can access the visual editor.
	 */
	return apply_filters( 'user_can_richedit', $wp_rich_edit );
}

Hoocs

apply_filters ( ‘user_can_richedit’, bool $wp_rich_edit )

Filters whether the user can access the visual editor.

Changuelog

Versionen Description
2.0.0 Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.