Advertisement
Guest User

Untitled

a guest
Apr 24th, 2012
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.06 KB | None | 0 0
  1. <?php
  2. if (!class_exists('WYSIWYG_Widgets_Widget')) {
  3.  
  4. class WYSIWYG_Widgets_Widget extends WP_Widget {
  5.  
  6. // function __construct() {
  7. // $widget_ops = array('classname' => 'wysiwyg_widget widget_text', 'description' => __('A widget with a WYSIWYG / Rich Text editor - supports media uploading'));
  8. // $control_ops = array('width' => 560, 'height' => 400);
  9. // $id_base = 'wysiwyg_widget';
  10. // parent::__construct($id_base, 'WYSIWYG Widget', $widget_ops, $control_ops);
  11. // }
  12.  
  13.  
  14. public function __construct() {
  15. parent::__construct(
  16. 'wysiwyg_widget', // Base ID
  17. 'WYSIWYG Widget', // Name
  18. array( 'description' => __( 'A widget with a WYSIWYG / Rich Text editor - supports media uploading', 'text_domain' ), ), // Args
  19. array('width' => 560, 'height' => 400) //size
  20. );
  21. }
  22.  
  23. function widget($args, $instance) {
  24. extract($args);
  25. $title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base);
  26. $text = apply_filters('widget_text', $instance['text'], $instance);
  27. echo $before_widget;
  28.  
  29. if (!empty($title)) {
  30. echo $before_title . $title . $after_title;
  31. }
  32.  
  33. ?>
  34.  
  35. <div class="textwidget"><?php echo wpautop($text); ?></div>
  36.  
  37. <?php
  38. echo $after_widget;
  39. }
  40.  
  41. function update($new_instance, $old_instance) {
  42. $instance = $old_instance;
  43.  
  44. $instance['title'] = strip_tags($new_instance['title']);
  45. $instance['type'] = strip_tags($new_instance['type']);
  46.  
  47. if (current_user_can('unfiltered_html'))
  48. $instance['text'] = $new_instance['text'];
  49. else
  50. $instance['text'] = stripslashes(wp_filter_post_kses(addslashes($new_instance['text'])));
  51.  
  52. return $instance;
  53. }
  54.  
  55. function form($instance) {
  56. $instance = wp_parse_args((array) $instance, array('title' => '', 'text' => '', 'type' => 'visual'));
  57.  
  58. $title = strip_tags($instance['title']);
  59. $text = $instance['text'];
  60. $type = esc_textarea($instance['type']);
  61.  
  62. ?>
  63. <span class="wysiwyg_widget"></span>
  64. <input id="<?php echo $this->get_field_id('type'); ?>" name="<?php echo $this->get_field_name('type'); ?>" class="wwe_type" type="hidden" value="<?php echo esc_attr($type); ?>" />
  65.  
  66. <p>
  67. <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label>
  68. <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($title); ?>" />
  69. </p>
  70.  
  71.  
  72. <div class="wwe_container">
  73. <?php wp_editor($text, $this->get_field_id('text'), array( 'textarea_name' => $this->get_field_name('text'), 'textarea_rows' => 25 )) ?>
  74. </div>
  75.  
  76. <?php
  77. }
  78.  
  79. }
  80.  
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement