RWMB_Wysiwyg_Field

The Evolved RWMB Wysiwyg Field class.

Defined (1)

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

/meta-box/inc/fields/wysiwyg.php  
  1. class RWMB_Wysiwyg_Field 
  2. /** 
  3. * Enqueue scripts and styles 
  4. * @return void 
  5. */ 
  6. static function admin_enqueue_scripts( ) 
  7. wp_enqueue_style( 'rwmb-meta-box-wysiwyg', RWMB_CSS_URL.'wysiwyg.css', RWMB_VER ); 
  8.  
  9. /** 
  10. * Add field actions 
  11. * @return void 
  12. */ 
  13. static function add_actions( ) 
  14. // Add TinyMCE script for WP version < 3.3 
  15. global $wp_version; 
  16.  
  17. if ( version_compare( $wp_version, '3.2.1' ) < 1 ) 
  18. add_action( 'admin_print_footer-post.php', 'wp_tiny_mce', 25 ); 
  19. add_action( 'admin_print_footer-post-new.php', 'wp_tiny_mce', 25 ); 
  20.  
  21. /** 
  22. * Change field value on save 
  23. * @param mixed $new 
  24. * @param mixed $old 
  25. * @param int $post_id 
  26. * @param array $field 
  27. * @return string 
  28. */ 
  29. static function value( $new, $old, $post_id, $field ) 
  30. return wpautop( $new ); 
  31.  
  32. /** 
  33. * Get field HTML 
  34. * @param string $html 
  35. * @param mixed $meta 
  36. * @param array $field 
  37. * @return string 
  38. */ 
  39. static function html( $html, $meta, $field ) 
  40. global $wp_version; 
  41. $name = "name='{$field['field_name']}'"; 
  42.  
  43. if ( version_compare( $wp_version, '3.2.1' ) < 1 ) 
  44. return "<textarea class='rwmb-wysiwyg theEditor large-text' {$name} id='{$field['id']}' cols='60' rows='10'>$meta</textarea>"; 
  45. else 
  46. // Apply filter to wp_editor() settings 
  47. $editor_settings = apply_filters( 'rwmb_wysiwyg_settings', array( 'editor_class' => 'rwmb-wysiwyg' ), 10, 1 ); 
  48. // Using output buffering because wp_editor() echos directly 
  49. ob_start( ); 
  50. // Use new wp_editor() since WP 3.3 
  51. wp_editor( $meta, $field['id'], $editor_settings ); 
  52.  
  53. return ob_get_clean( );