user_can_richedit

Whether the user can access the visual editor.

Description

user_can_richedit(); 

Checks if the user can access the visual editor and that it's supported by the user's browser.


Usage

  1. if ( !function_exists( 'user_can_richedit' ) ) { 
  2. require_once ABSPATH . WPINC . '/general-template.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = user_can_richedit(); 
  7.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/general-template.php  
  1. function user_can_richedit() { 
  2. global $wp_rich_edit, $is_gecko, $is_opera, $is_safari, $is_chrome, $is_IE, $is_edge; 
  3.  
  4. if ( !isset($wp_rich_edit) ) { 
  5. $wp_rich_edit = false; 
  6.  
  7. if ( get_user_option( 'rich_editing' ) == 'true' || ! is_user_logged_in() ) { // default to 'true' for logged out users 
  8. if ( $is_safari ) { 
  9. $wp_rich_edit = ! wp_is_mobile() || ( preg_match( '!AppleWebKit/(\d+)!', $_SERVER['HTTP_USER_AGENT'], $match ) && intval( $match[1] ) >= 534 ); 
  10. } elseif ( $is_gecko || $is_chrome || $is_IE || $is_edge || ( $is_opera && !wp_is_mobile() ) ) { 
  11. $wp_rich_edit = true; 
  12.  
  13. /** 
  14. * Filters whether the user can access the visual editor. 
  15. * @since 2.1.0 
  16. * @param bool $wp_rich_edit Whether the user can access the visual editor. 
  17. */ 
  18. return apply_filters( 'user_can_richedit', $wp_rich_edit );