Current Path : /home/theafprt/conviviality360.com/wp-content/themes/dinky/inc/ |
Current File : /home/theafprt/conviviality360.com/wp-content/themes/dinky/inc/widgets.php |
<?php /** * Dinky theme custom widgets * * @package Dinky * @since Dinky 1.0 * @license GNU General Public License v3 or later * @copyright (C) 2013 Misam Saki, misam.ir * @author Misam Saki, http://misam.ir/ */ if ( !defined('ABSPATH')) exit; add_action('widgets_init', 'dinky_Widget_Search'); function dinky_Widget_Search() { register_widget('dinky_Widget_Search'); } class dinky_Widget_Search extends WP_Widget { function __construct() { $widget_ops = array('classname' => 'dinky-widget_search', 'description' => __( "A search form for your site") ); parent::__construct('search', __('Search'), $widget_ops); } function widget( $args, $instance ) { extract($args); $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base ); echo $before_widget; if ( $title ) echo $before_title . $title . $after_title; // Use current theme search form if it exists //get_search_form(); // Removed current theme search form and replaced it by Dinky theme search form ?> <form role="search" method="get" id="dinky-searchform" action="<?php echo home_url() ?>"> <input type="text" name="s" id="dinky-s" placeholder="<?php _e('Search...','dinky'); ?>" autocomplete="off"> </form> <?php echo $after_widget; } function form( $instance ) { $instance = wp_parse_args( (array) $instance, array( 'title' => '') ); $title = $instance['title']; ?> <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?> <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); ?>" /></label></p> <?php } function update( $new_instance, $old_instance ) { $instance = $old_instance; $new_instance = wp_parse_args((array) $new_instance, array( 'title' => '')); $instance['title'] = strip_tags($new_instance['title']); return $instance; } } ?> <?php /** * @since Dinky 1.1 */ add_action('widgets_init', 'dinky_Widget_Text'); function dinky_Widget_Text() { register_widget('dinky_Widget_Text'); } class dinky_Widget_Text extends WP_Widget { function __construct() { $widget_ops = array('classname' => 'widget_text_clearly', 'description' => __('Arbitrary text or HTML')); $control_ops = array('width' => 400, 'height' => 350); parent::__construct('text_clearly', __('Text without default widgets style', 'dinky'), $widget_ops, $control_ops); } function widget( $args, $instance ) { extract($args); $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base ); $text = apply_filters( 'widget_text', empty( $instance['text'] ) ? '' : $instance['text'], $instance ); echo $before_widget; if ( !empty( $title ) ) { echo $before_title . $title . $after_title; } ?> <div class="textwidget"><?php echo !empty( $instance['filter'] ) ? wpautop( $text ) : $text; ?></div> <?php echo $after_widget; } function update( $new_instance, $old_instance ) { $instance = $old_instance; $instance['title'] = strip_tags($new_instance['title']); if ( current_user_can('unfiltered_html') ) $instance['text'] = $new_instance['text']; else $instance['text'] = stripslashes( wp_filter_post_kses( addslashes($new_instance['text']) ) ); // wp_filter_post_kses() expects slashed $instance['filter'] = isset($new_instance['filter']); return $instance; } function form( $instance ) { $instance = wp_parse_args( (array) $instance, array( 'title' => '', 'text' => '' ) ); $title = strip_tags($instance['title']); $text = esc_textarea($instance['text']); ?> <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label> <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); ?>" /></p> <textarea class="widefat" rows="16" cols="20" id="<?php echo $this->get_field_id('text'); ?>" name="<?php echo $this->get_field_name('text'); ?>"><?php echo $text; ?></textarea> <p><input id="<?php echo $this->get_field_id('filter'); ?>" name="<?php echo $this->get_field_name('filter'); ?>" type="checkbox" <?php checked(isset($instance['filter']) ? $instance['filter'] : 0); ?> /> <label for="<?php echo $this->get_field_id('filter'); ?>"><?php _e('Automatically add paragraphs'); ?></label></p> <?php } }