Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * wpmidia custom Widgets - Sidebar Comment Form Widget
- *
- * @package WordPress
- * @subpackage wpmidia
- * @author Miriam de Paula - http://wpmidia.com.br
- * @since 22/06/2012 - v1
- */
- class sidebar_commentform_Widget extends WP_Widget
- {
- function sidebar_commentform_Widget(){
- $widget_ops = array( 'description' => 'Exibe o formulário de comentários na sidebar' );
- $control_ops = array( 'width' => 250, 'height' => 200 );
- parent::WP_Widget( false, $name = 'Sidebar Comment Form', $widget_ops, $control_ops );
- }
- /* Displays the Widget in the front-end */
- function widget( $args, $instance ){
- if(is_single()) {
- extract($args);
- global $post;
- $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? 'Comentários' : esc_html( $instance['title'] ) );
- echo $before_widget;
- if ( ! empty( $title ) )
- echo $before_title . $title . $after_title;
- comments_template( '', true );
- echo $after_widget;
- }
- }
- /*Saves the settings. */
- function update( $new_instance, $old_instance ){
- $instance = $old_instance;
- $instance['title'] = strip_tags( $new_instance['title'] );
- return $instance;
- }
- /*Creates the form for the widget in the back-end. */
- function form( $instance ){
- //Defaults
- $instance = wp_parse_args( (array) $instance, array( 'title' => 'Comentários', 'qtd_agenda' => 5 ) );
- $title = esc_attr( $instance['title'] );
- # Title
- echo '<p><label for="' . $this->get_field_id('title') . '">' . 'Título:' . '</label><input class="widefat" id="' . $this->get_field_id('title') . '" name="' . $this->get_field_name('title') . '" type="text" value="' . $title . '" /></p>';
- }
- }
- function sidebar_commentform_Widget_Init() {
- register_widget('sidebar_commentform_Widget');
- }
- add_action('widgets_init', 'sidebar_commentform_Widget_Init');
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement