<?php
/***************************************************************************
 *
 * 	----------------------------------------------------------------------
 * 						DO NOT EDIT THIS FILE
 *	----------------------------------------------------------------------
 * 
 *  				     Copyright (C) Themify
 * 
 *	----------------------------------------------------------------------
 *
 ***************************************************************************/

if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly

///////////////////////////////////////////
// Feature Posts Class
///////////////////////////////////////////
class Themify_Social_Links extends WP_Widget {
	
	///////////////////////////////////////////
	// Feature Posts
	///////////////////////////////////////////
	function Themify_Social_Links() {
		/* Widget settings. */
		$widget_ops = array( 'classname' => 'themify-social-links', 'description' => __('Social media links.', 'themify') );

		/* Widget control settings. */
		$control_ops = array( 'id_base' => 'themify-social-links' );

		/* Create the widget. */
		$this->WP_Widget( 'themify-social-links', __('Themify - Social Links', 'themify'), $widget_ops, $control_ops );

	}

	///////////////////////////////////////////
	// Widget
	///////////////////////////////////////////
	function widget( $args, $instance ) {

		/* User-selected settings. */
		$title = apply_filters( 'widget_title', isset( $instance['title'] ) ? $instance['title'] : '' );

		/* Before widget (defined by themes). */
		echo wp_kses( $args['before_widget'], themify_before_after_widget_allowed_tags() );
		
		/* Title of widget (before and after defined by themes). */
		if ( $title ) echo wp_kses( $args['before_title'] . $title . $args['after_title'], themify_before_after_widget_title_allowed_tags() );
		
		$data = themify_get_data();
		$pre = 'setting-link_';

		$field_ids = isset( $data[$pre.'field_ids'] ) ? json_decode( $data[$pre.'field_ids'] ) : '';
		
		if ( is_array( $field_ids ) || is_object( $field_ids ) ) {

			$show_link_name  = isset( $instance['show_link_name'] ) && $instance['show_link_name'] ? true : false;
			$open_new_window = isset( $instance['open_new_window'] ) && $instance['open_new_window'] ? true : false;
			$new_window_attr = $open_new_window ? 'target="_blank"' : '';
			$icon_type = themify_check( $pre . 'icon_type' )? themify_get( $pre . 'icon_type' ) : 'image-icon';

			// Icon Size
			$icon_size = isset($instance['icon_size']) && '' != $instance['icon_size']? $instance['icon_size'] : 'icon-medium';

			// Orientation
			$orientation = isset($instance['orientation']) && '' != $instance['orientation']? $instance['orientation'] : 'horizontal';

			echo '<ul class="social-links ' . esc_attr( $orientation ) . '">';

				foreach($field_ids as $key => $fid){

					$type_val = isset($data[$pre.'type_'.$fid])? $data[$pre.'type_'.$fid] : '';
					if ( $type_val != $icon_type ) {
						continue;
					}
					
					$title_name = $pre.'title_'.$fid;

					if ( function_exists( 'icl_t' ) ) {
						$title_val = icl_t('Themify', $title_name, $data[$title_name]);
					} else {
						$title_val = isset($data[$title_name])? $data[$title_name] : '';
					}

					$link_name = $pre.'link_'.$fid;
					$link_val = isset($data[$link_name])? trim( $data[$link_name] ) : '';
					if ( '' == $link_val ) {
						continue;
					}

					// Image Icon
					$img_name = $pre.'img_'.$fid;
					$img_val = ! isset( $data[$img_name] ) || '' == $data[$img_name] ? '' : '<img src="' . esc_url( $data[ $img_name ] ) . '" />';

					// Font Icon
					$font_icon = '';
					if ( $font_icon_class = themify_get( $pre.'ficon_'.$fid ) ) {
						$fi_style = '';
						$font_icon_class = 'fa ' . $font_icon_class;
						if ( stripos( $font_icon_class, 'icon-' ) !== false ) {
							$font_icon_class = str_replace( 'icon-', 'fa-', $font_icon_class );
						}
						if ( $font_icon_color = themify_get( $pre.'ficolor_'.$fid ) ) {
							$fi_style .= 'color: #' . $font_icon_color . ';';
						}
						if ( $font_icon_bgcolor = themify_get( $pre.'fibgcolor_'.$fid ) ) {
							$fi_style .= 'background-color: #' . $font_icon_bgcolor . ';';
						}
						if ( '' != $fi_style ) {
							$fi_style = 'style="' . esc_attr( $fi_style ) . '"';
						}
						$font_icon = '<i class="' . esc_attr( $font_icon_class ) . '" ' . $fi_style . '></i>';
					}

					if('' != $link_val){
						echo sprintf('
							<li class="social-link-item %s %s %s">
								<a href="%s" title="%s" %s>%s %s %s</a>
							</li>
							<!-- /themify-link-item -->',
							sanitize_title($title_val),
							esc_attr( $icon_type ),
							esc_attr( $icon_size ),
							esc_url( $link_val ),
							esc_attr( $title_val ),
							$new_window_attr,
							$font_icon,
							$img_val,
							$show_link_name? $title_val : ''
						);
					}
				}
			
			echo '</ul>';
		}

		/* After widget (defined by themes). */
		echo wp_kses( $args['after_widget'], themify_before_after_widget_allowed_tags() );
	}
	
	
	///////////////////////////////////////////
	// Update
	///////////////////////////////////////////
	function update( $new_instance, $old_instance ) {
		$instance = $old_instance;

		/* Strip tags (if needed) and update the widget settings. */
		$instance['title'] = strip_tags( $new_instance['title'] );
		$instance['show_link_name'] = $new_instance['show_link_name'];
		$instance['open_new_window'] = $new_instance['open_new_window'];
		$instance['icon_size'] = $new_instance['icon_size'];
		$instance['orientation'] = $new_instance['orientation'];

		return $instance;
	}
	
	///////////////////////////////////////////
	// Form
	///////////////////////////////////////////
	function form( $instance ) {

		/* Set up some default widget settings. */
		$defaults = array(
			'title' => '',
			'show_link_name' => false,
			'open_new_window' => false,
			'icon_size' => 'icon-medium',
			'orientation' => 'horizontal',
		);
		$instance = wp_parse_args( (array) $instance, $defaults ); ?>
		
		<p>
			<label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php _e('Title:', 'themify'); ?></label><br />
			<input id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" value="<?php echo esc_attr( $instance['title'] ); ?>" class="widefat" type="text" />
		</p>
		
		<p>
			<input class="checkbox" type="checkbox" <?php checked( $instance['show_link_name'], 'on' ); ?> id="<?php echo esc_attr( $this->get_field_id( 'show_link_name' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'show_link_name' ) ); ?>" />
			<label for="<?php echo esc_attr( $this->get_field_id( 'show_link_name' ) ); ?>"><?php _e('Show link name', 'themify'); ?></label>
		</p>

		<p>
			<input class="checkbox" type="checkbox" <?php checked( $instance['open_new_window'], 'on' ); ?> id="<?php echo esc_attr( $this->get_field_id( 'open_new_window' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'open_new_window' ) ); ?>" />
			<label for="<?php echo esc_attr( $this->get_field_id( 'open_new_window' ) ); ?>"><?php _e('Open link in new window', 'themify'); ?></label>
		</p>

		<p>
			<label for="<?php echo esc_attr( $this->get_field_id( 'icon_size' ) ); ?>"><?php _e('Icon Size', 'themify'); ?></label>
			<select id="<?php echo esc_attr( $this->get_field_id( 'icon_size' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'icon_size' ) ); ?>">
				<?php
				$sizes = array(
					'icon-small' => __( 'Small', 'themify' ),
					'icon-medium' => __( 'Medium', 'themify' ),
					'icon-large' => __( 'Large', 'themify' ),
				);
				foreach( $sizes as $size => $name ) {
					echo '<option value="' . esc_attr( $size ) . '"' . selected( isset( $instance['icon_size'] )? $instance['icon_size'] : 'icon-medium', $size, false ) . '>';
						echo esc_html( $name );
					echo '</option>';
				}
				?>
			</select>
		</p>

		<p>
			<label for="<?php echo esc_attr( $this->get_field_id( 'orientation' ) ); ?>"><?php _e('Orientation', 'themify'); ?></label>
			<select id="<?php echo esc_attr( $this->get_field_id( 'orientation' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'orientation' ) ); ?>">
				<?php
				$orientation_options = array(
					'vertical'   => __( 'Vertical', 'themify' ),
					'horizontal' => __( 'Horizontal', 'themify' ),
				);
				foreach( $orientation_options as $orientation => $name ) {
					echo '<option value="' . esc_attr( $orientation ) . '"' . selected( isset( $instance['orientation'] )? $instance['orientation'] : 'horizontal', $orientation, false ) . '>';
						echo esc_html( $name );
					echo '</option>';
				}
				?>
			</select>
		</p>
		
		<p>
			<?php echo wp_kses_post( sprintf( __( '<small>Manage links at <a href="%s">Themify > Settings > Social Links</a>.</small>', 'themify' ), esc_url( admin_url( 'admin.php?page=themify#setting-social_links' ) ) ) ); ?>
		</p>
		<?php
	}
}

	///////////////////////////////////////////
	// Feature Posts Class
	///////////////////////////////////////////
	class Themify_Feature_Posts extends WP_Widget {
		
		///////////////////////////////////////////
		// Feature Posts
		///////////////////////////////////////////
		function Themify_Feature_Posts() {
			/* Widget settings. */
			$widget_ops = array( 'classname' => 'feature-posts', 'description' => __('A list of posts, optionally filter by category.', 'themify') );
	
			/* Widget control settings. */
			$control_ops = array( 'id_base' => 'themify-feature-posts' );
	
			/* Create the widget. */
			$this->WP_Widget( 'themify-feature-posts', __('Themify - Feature Posts', 'themify'), $widget_ops, $control_ops );
		}
		
		///////////////////////////////////////////
		// Widget
		///////////////////////////////////////////
		function widget( $args, $instance ) {

			extract( $args );

			/* User-selected settings. */
			$title = apply_filters( 'widget_title', isset( $instance['title'] ) ? $instance['title'] : '' );
			$category 		= isset( $instance['category'] ) ? $instance['category'] : 0;
			$show_count 	= isset( $instance['show_count'] ) ? $instance['show_count'] : 5;
			$show_date 		= isset( $instance['show_date'] ) ? true : false;
			$show_thumb 	= isset( $instance['show_thumb'] ) ? true : false;
			$display 		= isset( $instance['display'] )? $instance['display'] : false;
			$show_excerpt 	= isset( $instance['show_excerpt'] ) && $instance['show_excerpt'] ? true : false;
			$excerpt_length = isset( $instance['excerpt_length'] ) ? $instance['excerpt_length'] : 55;
			$show_title 	= isset( $instance['hide_title'] ) ? false : true;
			$orderby 		= isset( $instance['orderby'] ) ? $instance['orderby'] : 'date';
			$order 			= isset( $instance['order'] ) ? $instance['order'] : 'DESC';

			$query_opts = apply_filters('themify_query', array(
				'posts_per_page' => $show_count,
				'post_type' => 'post',
				'orderby' => $orderby,
				'order' => $order,
				'suppress_filters' => false,
			));
			if ( $category ) $query_opts['cat'] = $category;
			
			$loop = get_posts($query_opts);
			
			if($loop) {
				
				/* Before widget (defined by themes). */
				echo wp_kses( $before_widget, themify_before_after_widget_allowed_tags() );
				
				/* Title of widget (before and after defined by themes). */
				if ( $title )
					echo wp_kses( $before_title . $title . $after_title, themify_before_after_widget_title_allowed_tags() );

				echo '<ul class="feature-posts-list">';

				global $post;
				foreach ($loop as $post) {
					setup_postdata($post);
					echo '<li>';

						$link = get_post_meta( $post->ID, 'external_link', true );
						if ( ! isset( $link ) || '' == $link ) {
							$link = get_permalink();
						}

						if ( $show_thumb ) {
							themify_image('ignore=true&w='.$instance['thumb_width'].'&h='.$instance['thumb_height'].'&before=<a href="' . esc_url( $link ) . '">&after=</a>&class=post-img');
						}

						if ( $show_title ) echo '<a href="' . esc_url( $link ) . '" class="feature-posts-title">' . get_the_title() . '</a> <br />';

						if ( $show_date ) echo '<small>' . get_the_date( apply_filters( 'themify_filter_widget_date', '' ) ) . '</small> <br />';

						if ( $show_excerpt || 'excerpt' == $display ) {
							$the_excerpt = get_the_excerpt();
							if($excerpt_length != '') {
								// cut to character limit
								$the_excerpt = substr( $the_excerpt, 0, $excerpt_length );
								// cut to last space
								$the_excerpt = substr( $the_excerpt, 0, strrpos( $the_excerpt, ' '));
							}
							echo '<span class="post-excerpt">' . wp_kses_post( $the_excerpt ) . '</span>';
						} elseif( 'content' == $display ) {
							$the_content = get_the_content();
							echo '<div class="post-content">' . wp_kses_post( $the_content ) . '</div>';
						}

					echo '</li>';
					wp_reset_postdata();
				}//end for each
				
				echo '</ul>';
	
				/* After widget (defined by themes). */
				echo wp_kses( $after_widget, themify_before_after_widget_allowed_tags() );
				
			}//end if $loop
			
		}
		
		///////////////////////////////////////////
		// Update
		///////////////////////////////////////////
		function update( $new_instance, $old_instance ) {
			$instance = $old_instance;
	
			/* Strip tags (if needed) and update the widget settings. */
			$instance['title'] = strip_tags( $new_instance['title'] );
			$instance['category'] = $new_instance['category'];
			$instance['show_count'] = $new_instance['show_count'];
			$instance['show_date'] = $new_instance['show_date'];
			$instance['show_thumb'] = $new_instance['show_thumb'];
			$instance['display'] = $new_instance['display'];
			$instance['hide_title'] = $new_instance['hide_title'];
			$instance['thumb_width'] = $new_instance['thumb_width'];
			$instance['thumb_height'] = $new_instance['thumb_height'];
			$instance['excerpt_length'] = $new_instance['excerpt_length'];
			$instance['orderby'] = $new_instance['orderby'];
			$instance['order'] = $new_instance['order'];

			return $instance;
		}
		
		///////////////////////////////////////////
		// Form
		///////////////////////////////////////////
		function form( $instance ) {
	
			/* Set up some default widget settings. */
			$defaults = array(
				'title'          => __( 'Recent Posts', 'themify' ),
				'category'       => 0,
				'show_count'     => 5,
				'show_date'      => false,
				'show_thumb'     => false,
				'display'        => 'none',
				'hide_title'     => false,
				'thumb_width'    => 50,
				'thumb_height'   => 50,
				'excerpt_length' => 55,
				'orderby' => 'date',
				'order' => 'DESC',
			);
			$instance = wp_parse_args( (array) $instance, $defaults ); ?>
			
			<p>
				<label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php _e('Title:', 'themify'); ?></label><br />
				<input id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" value="<?php echo esc_attr( $instance['title'] ); ?>" width="100%" />
			</p>
	
			<p>
				<label for="<?php echo esc_attr( $this->get_field_id( 'category' ) ); ?>"><?php _e('Category:', 'themify'); ?></label>
				<select id="<?php echo esc_attr( $this->get_field_id( 'category' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'category' ) ); ?>">
					<option value="0" <?php if ( !$instance['category'] ) echo 'selected="selected"'; ?>><?php _e('All', 'themify'); ?></option>
					<?php
					$categories = get_categories(array('type' => 'post'));
					
					foreach( $categories as $cat ) {
						echo '<option value="' . esc_attr( $cat->cat_ID ) . '"';
						
						if ( $cat->cat_ID == $instance['category'] ) echo  ' selected="selected"';
						
						echo '>' . esc_html( $cat->cat_name . ' (' . $cat->category_count . ')' );
						
						echo '</option>';
					}
					?>
				</select>
			</p>

			<p>
				<label for="<?php echo esc_attr( $this->get_field_id( 'orderby' ) ); ?>"><?php _e( 'Order By', 'themify' ); ?></label>
				<select id="<?php echo esc_attr( $this->get_field_id( 'orderby' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'orderby' ) ); ?>">
					<?php
					$orderby_options = apply_filters( 'themify_posts_widget_orderby', array(
							'date'          => __( 'Date (default)', 'themify' ),
							'rand'          => __( 'Random', 'themify' ),
							'author'        => __( 'Author', 'themify' ),
							'title'         => __( 'Post Title', 'themify' ),
							'comment_count' => __( 'Comments Number', 'themify' ),
							'modified'      => __( 'Modified Date', 'themify' ),
							'name'          => __( 'Post Slug', 'themify' ),
							'ID'            => __( 'Post ID', 'themify' )
						)
					);
					foreach ( $orderby_options as $criteria => $name ) {
						echo '<option value="' . esc_attr( $criteria ) . '"' . selected( isset( $instance['orderby'] ) ? $instance['orderby'] : 'date', $criteria, false ) . '>';
						echo esc_html( $name );
						echo '</option>';
					}
					?>
				</select>
			</p>

			<p>
				<label for="<?php echo esc_attr( $this->get_field_id( 'order' ) ); ?>"><?php _e( 'Order', 'themify' ); ?></label>
				<select id="<?php echo esc_attr( $this->get_field_id( 'order' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'order' ) ); ?>">
					<?php
					$order_options = array(
						'DESC'	=> __( 'Descending (default)', 'themify' ),
						'ASC'  => __( 'Ascending', 'themify' ),
					);
					foreach ( $order_options as $criteria => $name ) {
						echo '<option value="' . esc_attr( $criteria ) . '"' . selected( isset( $instance['order'] ) ? $instance['order'] : 'date', $criteria, false ) . '>';
						echo esc_html( $name );
						echo '</option>';
					}
					?>
				</select>
			</p>
			
			<p>
				<label for="<?php echo esc_attr( $this->get_field_id( 'show_count' ) ); ?>"><?php _e('Show:', 'themify'); ?></label>
				<input id="<?php echo esc_attr( $this->get_field_id( 'show_count' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'show_count' ) ); ?>" value="<?php echo esc_attr( $instance['show_count'] ); ?>" size="2" /> <?php _e('posts', 'themify'); ?>
			</p>
			
			<p>
				<input class="checkbox" type="checkbox" <?php checked( $instance['hide_title'], 'on' ); ?> id="<?php echo esc_attr( $this->get_field_id( 'hide_title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'hide_title' ) ); ?>" />
				<label for="<?php echo esc_attr( $this->get_field_id( 'hide_title' ) ); ?>"><?php _e('Hide post title', 'themify'); ?></label>
			</p>
			
			<p>
				<input class="checkbox" type="checkbox" <?php checked( $instance['show_date'], 'on' ); ?> id="<?php echo esc_attr( $this->get_field_id( 'show_date' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'show_date' ) ); ?>" />
				<label for="<?php echo esc_attr( $this->get_field_id( 'show_date' ) ); ?>"><?php _e('Display post date', 'themify'); ?></label>
			</p>
			
			<p>
				<input class="checkbox" type="checkbox" <?php checked( $instance['show_thumb'], 'on' ); ?> id="<?php echo esc_attr( $this->get_field_id( 'show_thumb' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'show_thumb' ) ); ?>" />
				<label for="<?php echo esc_attr( $this->get_field_id( 'show_thumb' ) ); ?>"><?php _e('Display post thumbnail', 'themify'); ?></label>
			</p>
			
			<?php
			// only allow thumbnail dimensions if GD library supported
			if ( function_exists('imagecreatetruecolor') ) {
			?>
			<p>
			   <label for="<?php echo esc_attr( $this->get_field_id( 'thumb_width' ) ); ?>"><?php _e('Thumbnail size', 'themify'); ?></label> <input type="text" id="<?php echo esc_attr( $this->get_field_id( 'thumb_width' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'thumb_width' ) ); ?>" value="<?php echo esc_attr( $instance['thumb_width'] ); ?>" size="3" /> x <input type="text" id="<?php echo esc_attr( $this->get_field_id( 'thumb_height' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'thumb_height' ) ); ?>" value="<?php echo esc_attr( $instance['thumb_height'] ); ?>" size="3" />
			</p>
			<?php
			}
			?>
			
			<p>
				<label for="<?php echo esc_attr( $this->get_field_id( 'display' ) ); ?>"><?php _e('Display:', 'themify'); ?></label>
				<select id="<?php echo esc_attr( $this->get_field_id( 'display' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'display' ) ); ?>">
					<?php
					foreach( array(
						'none' => __('None', 'themify'),
						'content' => __('Content', 'themify'),
						'excerpt' => __('Excerpt', 'themify')
					) as $key => $title ) {
						echo '<option value="' . esc_attr( $key ) . '" '.selected($key, $instance['display'], false).' >' . esc_html( $title ) . '</option>';
					}
					?>
				</select>
			</p>
			
			<p>
				<label for="<?php echo esc_attr( $this->get_field_id( 'excerpt_length' ) ); ?>"><?php _e('Excerpt character limit:', 'themify'); ?></label>
				<input id="<?php echo esc_attr( $this->get_field_id( 'excerpt_length' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'excerpt_length' ) ); ?>" value="<?php echo esc_attr( $instance['excerpt_length'] ); ?>" size="5" /><br /><small><?php _e('(leave empty = full excerpt)', 'themify'); ?></small>
			</p>
			
			<?php
		}
	}
	
	///////////////////////////////////////////
	// List Pages Class
	///////////////////////////////////////////
	class Themify_List_Pages extends WP_Widget {
		
		///////////////////////////////////////////
		// List Pages
		///////////////////////////////////////////
		function Themify_List_Pages() {
			/* Widget settings. */
			$widget_ops = array( 'classname' => 'list-pages', 'description' => __('A list of pages', 'themify') );
	
			/* Widget control settings. */
			$control_ops = array( 'id_base' => 'themify-list-pages' );
	
			/* Create the widget. */
			$this->WP_Widget( 'themify-list-pages', __('Themify - List Pages', 'themify'), $widget_ops, $control_ops );
		}
		
		///////////////////////////////////////////
		// Widget
		///////////////////////////////////////////
		function widget( $args, $instance ) {
			extract( $args );
	
			/* User-selected settings. */
			$title = apply_filters( 'widget_title', isset( $instance['title'] ) ? $instance['title'] : '' );
			$parent = isset( $instance['parent'] ) ? $instance['parent'] : '';
			$depth = isset( $instance['depth'] ) ? $instance['depth'] : 0;
			$orderby = isset( $instance['orderby'] ) ? $instance['orderby'] : false;
			$exclude = isset( $instance['exclude'] ) ? $instance['exclude'] : false;
	
			/* Before widget (defined by themes). */
			echo wp_kses( $before_widget, themify_before_after_widget_allowed_tags() );
	
			/* Title of widget (before and after defined by themes). */
			if ( $title )
				echo wp_kses( $before_title . $title . $after_title, themify_before_after_widget_title_allowed_tags() );
			
			echo '<ul class="pages-list">';
			
			wp_list_pages(array(
				'child_of'       => $parent,
				'depth'         => $depth,
				'sort_column'   => $orderby,
				'exclude'  => $exclude,
				'title_li' => ''
			));
			
			echo '</ul>';
			
			/* After widget (defined by themes). */
			echo wp_kses( $after_widget, themify_before_after_widget_allowed_tags() );
		}
		
		///////////////////////////////////////////
		// Update
		///////////////////////////////////////////
		function update( $new_instance, $old_instance ) {
			$instance = $old_instance;
	
			/* Strip tags (if needed) and update the widget settings. */
			$instance['title'] = strip_tags( $new_instance['title'] );
			$instance['parent'] = $new_instance['parent'];
			$instance['depth'] = $new_instance['depth'];
			$instance['orderby'] = $new_instance['orderby'];
			$instance['exclude'] = $new_instance['exclude'];
	
			return $instance;
		}
		
		///////////////////////////////////////////
		// Form
		///////////////////////////////////////////
		function form( $instance ) {
	
			/* Set up some default widget settings. */
			$defaults = array( 
				'title' => __('Pages', 'themify'),
				'parent' => '',
				'depth' => 0,
				'orderby' => 'post_title',
				'exclude' => ''
				);
			$instance = wp_parse_args( (array) $instance, $defaults ); ?>
			
			<p>
				<label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php _e('Title:', 'themify'); ?></label><br />
				<input id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" value="<?php echo esc_attr( $instance['title'] ); ?>" width="100%" />
			</p>
	
			<p>
				<label for="<?php echo esc_attr( $this->get_field_id( 'parent' ) ); ?>"><?php _e('Parent:', 'themify'); ?></label>
				<select id="<?php echo esc_attr( $this->get_field_id( 'parent' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'parent' ) ); ?>">
					<option value="0" <?php if ( 0 == $instance['parent'] ) echo 'selected="selected"'; ?>>All</option>
					<?php
					$pages = get_pages();
					
					foreach( $pages as $thepage ) {
						echo '<option value="' . esc_attr( $thepage->ID ) . '"';
						
						if ( $thepage->ID == $instance['parent'] ) echo ' selected="selected"';
						
						echo '>' . esc_html( $thepage->post_title );
						
						echo '</option>';
					}
					?>
				</select>
			</p>
			
			<p>
				<label for="<?php echo esc_attr( $this->get_field_id( 'depth' ) ); ?>"><?php _e('Depth:', 'themify'); ?></label>
				<select id="<?php echo esc_attr( $this->get_field_id( 'depth' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'depth' ) ); ?>">
					<option value="0" <?php if ( 0 == $instance['depth'] ) echo 'selected="selected"'; ?>><?php _e('0 (default)', 'themify'); ?></option>
					<option value="1" <?php if ( 1 == $instance['depth'] ) echo 'selected="selected"'; ?>>1</option>
					<option value="2" <?php if ( 2 == $instance['depth'] ) echo 'selected="selected"'; ?>>2</option>
					<option value="3" <?php if ( 3 == $instance['depth'] ) echo 'selected="selected"'; ?>>3</option>
					<option value="4" <?php if ( 4 == $instance['depth'] ) echo 'selected="selected"'; ?>>4</option>
				</select>
			</p>
			
			<p>
				<label for="<?php echo esc_attr( $this->get_field_id( 'orderby' ) ); ?>"><?php _e('Sort By:', 'themify'); ?></label>
				<select id="<?php echo esc_attr( $this->get_field_id( 'orderby' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'orderby' ) ); ?>">
					<option value="id" <?php if ( 'id' == $instance['orderby'] ) echo 'selected="selected"'; ?>>ID</option>
					<option value="menu_order" <?php if ( 'menu_order' == $instance['orderby'] ) echo 'selected="selected"'; ?>><?php _e('Menu Order', 'themify'); ?></option>
					<option value="post_title" <?php if ( 'post_title' == $instance['orderby'] ) echo 'selected="selected"'; ?>><?php _e('Post Title', 'themify'); ?></option>
					<option value="post_date" <?php if ( 'post_date' == $instance['orderby'] ) echo 'selected="selected"'; ?>><?php _e('Post Date', 'themify'); ?></option>
					<option value="post_name" <?php if ( 'post_name' == $instance['orderby'] ) echo 'selected="selected"'; ?>><?php _e('Post Name', 'themify'); ?></option>
				</select>
			</p>
			
			<p>
				<label for="<?php echo esc_attr( $this->get_field_id( 'exclude' ) ); ?>"><?php _e('Exclude:', 'themify'); ?></label><br />
				<input id="<?php echo esc_attr( $this->get_field_id( 'exclude' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'exclude' ) ); ?>" value="<?php echo esc_attr( $instance['exclude'] ); ?>" /><br />
				<small><?php _e('Page IDs, separated by commas (eg. 5,8)', 'themify'); ?></small>
			</p>
			
			<?php
		}
	}
	
	///////////////////////////////////////////
	// List Categories Class
	///////////////////////////////////////////
	class Themify_List_Categories extends WP_Widget {
		
		///////////////////////////////////////////
		// List Categories
		///////////////////////////////////////////
		function Themify_List_Categories() {
			/* Widget settings. */
			$widget_ops = array( 'classname' => 'list-categories', 'description' => __('A list of categories', 'themify') );
	
			/* Widget control settings. */
			$control_ops = array( 'id_base' => 'themify-list-categories' );
	
			/* Create the widget. */
			$this->WP_Widget( 'themify-list-categories', __('Themify - List Categories', 'themify'), $widget_ops, $control_ops );
		}
		
		///////////////////////////////////////////
		// Widget
		///////////////////////////////////////////
		function widget( $args, $instance ) {
			extract( $args );

			$themify_this_widget_id_pre = isset( $args['widget_id'] ) ? $args['widget_id'] : '';
			$themify_widget_id = $themify_this_widget_id_pre . '-cats';
	
			/* User-selected settings. */
			$title = apply_filters( 'widget_title', isset( $instance['title'] ) ? $instance['title'] : '' );
			$parent = isset( $instance['parent'] ) ? $instance['parent'] : null;
			$depth = isset( $instance['depth'] ) ? $instance['depth'] : null;
			$orderby = isset( $instance['orderby'] ) ? $instance['orderby'] : null;
			$exclude = isset( $instance['exclude'] ) ? $instance['exclude'] : null;
			$show_dropdown = isset( $instance['show_dropdown'] ) ? $instance['show_dropdown'] : false;
			$show_counts = isset( $instance['show_counts'] ) ? $instance['show_counts'] : false;
			$show_hierarchy = isset( $instance['show_hierarchy'] ) ? $instance['show_hierarchy'] : false;
	
			/* Before widget (defined by themes). */
			echo wp_kses( $before_widget, themify_before_after_widget_allowed_tags() );
	
			/* Title of widget (before and after defined by themes). */
			if ( $title )
				echo wp_kses( $before_title . $title . $after_title, themify_before_after_widget_title_allowed_tags() );

			$args = array(
					'orderby'       => $orderby,
					'show_count'    => $show_counts,
					'child_of'      => $parent,
					'exclude'       => $exclude,
					'hierarchical'  => $show_hierarchy,
					'depth'         => $depth,
					'title_li'      => '',
					'id'			=> $themify_widget_id
				);

			if ( $show_dropdown ) {
				$args['show_option_none'] = __('Select Category', 'themify');
				wp_dropdown_categories($args);
			?>
			
				<script type='text/javascript'>
				/* <![CDATA[ */
					function onCatChange() {
						var dropdown = document.getElementById('<?php echo esc_js( $themify_widget_id ); ?>'),
							catSelected = dropdown.options[dropdown.selectedIndex].value;
						console.log(catSelected);
						if ( catSelected > 0 ) {
							location.href = "<?php echo home_url(); ?>/?cat="+catSelected;
						}
					}
					document.getElementById('<?php echo esc_js( $themify_widget_id ); ?>').onchange = onCatChange;
				/* ]]> */
				</script>
			
			<?php
			}
			else {
				echo '<ul class="categories-list">';
				
				wp_list_categories($args);
				
				echo '</ul>';
			}
	
			/* After widget (defined by themes). */
			echo wp_kses( $after_widget, themify_before_after_widget_allowed_tags() );
		}
		
		///////////////////////////////////////////
		// Update
		///////////////////////////////////////////
		function update( $new_instance, $old_instance ) {
			$instance = $old_instance;
	
			/* Strip tags (if needed) and update the widget settings. */
			$instance['title'] = strip_tags( $new_instance['title'] );
			$instance['parent'] = $new_instance['parent'];
			$instance['depth'] = $new_instance['depth'];
			$instance['orderby'] = $new_instance['orderby'];
			$instance['exclude'] = $new_instance['exclude'];
			$instance['show_dropdown'] = $new_instance['show_dropdown'];
			$instance['show_counts'] = $new_instance['show_counts'];
			$instance['show_hierarchy'] = $new_instance['show_hierarchy'];
	
			return $instance;
		}
		
		///////////////////////////////////////////
		// Form
		///////////////////////////////////////////
		function form( $instance ) {
	
			/* Set up some default widget settings. */
			$defaults = array( 'title' => __('Categories', 'themify'), 'parent' => 0, 'depth' => 0, 'orderby' => 'name', 'exclude' => '', 'show_dropdown' => false, 'show_counts' => false, 'show_hierarchy' => true );
			$instance = wp_parse_args( (array) $instance, $defaults ); ?>
			
			<p>
				<label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php _e('Title:', 'themify'); ?></label><br />
				<input id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" value="<?php echo esc_attr( $instance['title'] ); ?>" width="100%" />
			</p>
	
			<p>
				<label for="<?php echo esc_attr( $this->get_field_id( 'parent' ) ); ?>"><?php _e('Parent:', 'themify'); ?></label>
				<?php
				wp_dropdown_categories( array(
					'show_option_all' => __('All', 'themify'),
					'orderby'         => 'name',
					'hierarchical'    => 1,
					'selected'        => $instance['parent'],
					'id'              => $this->get_field_id( 'parent' ),
					'name'            => $this->get_field_name( 'parent' ),
				));
				?>
			</p>
			
			<p>
				<label for="<?php echo esc_attr( $this->get_field_id( 'depth' ) ); ?>"><?php _e('Depth:', 'themify'); ?></label>
				<select id="<?php echo esc_attr( $this->get_field_id( 'depth' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'depth' ) ); ?>">
					<option value="0" <?php if ( 0 == $instance['depth'] ) echo 'selected="selected"'; ?>><?php _e('0 (default)', 'themify'); ?></option>
					<option value="1" <?php if ( 1 == $instance['depth'] ) echo 'selected="selected"'; ?>>1</option>
					<option value="2" <?php if ( 2 == $instance['depth'] ) echo 'selected="selected"'; ?>>2</option>
					<option value="3" <?php if ( 3 == $instance['depth'] ) echo 'selected="selected"'; ?>>3</option>
					<option value="4" <?php if ( 4 == $instance['depth'] ) echo 'selected="selected"'; ?>>4</option>
				</select>
			</p>
			
			<p>
				<label for="<?php echo esc_attr( $this->get_field_id( 'orderby' ) ); ?>"><?php _e('Orderby:', 'themify'); ?></label>
				<select id="<?php echo esc_attr( $this->get_field_id( 'orderby' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'orderby' ) ); ?>">
					<option value="id" <?php if ( 'id' == $instance['orderby'] ) echo 'selected="selected"'; ?>>ID</option>
					<option value="name" <?php if ( 'name' == $instance['orderby'] ) echo 'selected="selected"'; ?>>Name</option>
					<option value="slug" <?php if ( 'slug' == $instance['orderby'] ) echo 'selected="selected"'; ?>>Slug</option>
					<option value="count" <?php if ( 'count' == $instance['orderby'] ) echo 'selected="selected"'; ?>><?php _e('Count', 'themify'); ?></option>
				</select>
			</p>
			
			<p>
				<label for="<?php echo esc_attr( $this->get_field_id( 'exclude' ) ); ?>"><?php _e('Exclude:', 'themify'); ?></label><br />
				<input id="<?php echo esc_attr( $this->get_field_id( 'exclude' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'exclude' ) ); ?>" value="<?php echo esc_attr( $instance['exclude'] ); ?>" /><br />
				<small><?php _e('Category IDs, separated by commas (eg. 5,8)', 'themify'); ?></small>
			</p>
			
			<p>
				<input class="checkbox" type="checkbox" <?php checked( $instance['show_dropdown'], 'on' ); ?> id="<?php echo esc_attr( $this->get_field_id( 'show_dropdown' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'show_dropdown' ) ); ?>" />
				<label for="<?php echo esc_attr( $this->get_field_id( 'show_dropdown' ) ); ?>"><?php _e('Show as dropdown', 'themify'); ?></label>
			</p>
			
			<p>
				<input class="checkbox" type="checkbox" <?php checked( $instance['show_counts'], 'on' ); ?> id="<?php echo esc_attr( $this->get_field_id( 'show_counts' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'show_counts' ) ); ?>" />
				<label for="<?php echo esc_attr( $this->get_field_id( 'show_counts' ) ); ?>"><?php _e('Show post counts', 'themify'); ?></label>
			</p>
			
			<p>
				<input class="checkbox" type="checkbox" <?php checked( $instance['show_hierarchy'], 'on' ); ?> id="<?php echo esc_attr( $this->get_field_id( 'show_hierarchy' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'show_hierarchy' ) ); ?>" />
				<label for="<?php echo esc_attr( $this->get_field_id( 'show_hierarchy' ) ); ?>"><?php _e('Show hierarchy', 'themify'); ?></label>
			</p>
			
			<?php
		}
	}
	
	///////////////////////////////////////////
	// Recent Comments Class
	///////////////////////////////////////////
	class Themify_Recent_Comments extends WP_Widget {
		
		///////////////////////////////////////////
		// Recent Comments
		///////////////////////////////////////////
		function Themify_Recent_Comments() {
			/* Widget settings. */
			$widget_ops = array( 'classname' => 'recent-comments', 'description' => __('A list of recent comments from all posts', 'themify') );
	
			/* Widget control settings. */
			$control_ops = array( 'id_base' => 'themify-recent-comments' );
	
			/* Create the widget. */
			$this->WP_Widget( 'themify-recent-comments', __('Themify - Recent Comments', 'themify'), $widget_ops, $control_ops );
		}
		
		///////////////////////////////////////////
		// Widget
		///////////////////////////////////////////
		function widget( $args, $instance ) {
			extract( $args );
	
			/* User-selected settings. */
			$title = apply_filters( 'widget_title', isset( $instance['title'] ) ? $instance['title'] : '' );
			$show_count = isset( $instance['show_count'] ) ? $instance['show_count'] : 3;
			$show_avatar = isset( $instance['show_avatar'] ) ? $instance['show_avatar'] : false;
			$avatar_size = isset( $instance['avatar_size'] ) ? $instance['avatar_size'] : 32;
			$excerpt_length = isset( $instance['excerpt_length'] ) ? $instance['excerpt_length'] : 60;

			$comments = get_comments(array(
				'number' => $show_count,
				'status' => 'approve',
				'type' => 'comment'
			));
			if($comments){
			
				/* Before widget (defined by themes). */
				echo wp_kses( $before_widget, themify_before_after_widget_allowed_tags() );
		
				/* Title of widget (before and after defined by themes). */
				if ( $title )
					echo wp_kses( $before_title . $title . $after_title, themify_before_after_widget_title_allowed_tags() );
				
				echo '<ul class="recent-comments-list">';
				
				foreach($comments as $comment){
					$p = get_post($comment->comment_post_ID);
					if( ! empty( $p->post_password ) ) continue;
					$comm_title = get_the_title($comment->comment_post_ID);
					$comm_link = get_comment_link($comment->comment_ID);
					?>
				
					<li>
						<?php
							if ( $show_avatar ) {
								echo '<a href="' . esc_url( $comm_link ) . '">' . get_avatar($comment,$size=$avatar_size) . '</a>';
							}
							$comment_text = get_comment_excerpt( $comment->comment_ID );
							if(0 != $excerpt_length) {
								$last = substr( substr( $comment_text , 0, $excerpt_length), -1);
								if ( strlen(count_chars($comment_text, 3)) > $excerpt_length ) {
									$comment_text = substr( $comment_text , 0, $excerpt_length - 1) . preg_replace('/[^(\x00-\x7F)]*/','', $last);
								} else {
									$comment_text = substr( $comment_text , 0, $excerpt_length - 1);
								}
							}
						?>
						<a href="<?php echo esc_url( $comm_link );?>"><strong class="comment-author"><?php echo wp_kses_data( $comment->comment_author ); ?></strong>:</a> <?php echo wp_kses_data( $comment_text ); ?>&hellip;
					</li> 
				
					<?php 
				}
				
				echo '</ul>';
	
				/* After widget (defined by themes). */
				echo wp_kses( $after_widget, themify_before_after_widget_allowed_tags() );
			}//end if $comments
		}
		
		///////////////////////////////////////////
		// Update
		///////////////////////////////////////////
		function update( $new_instance, $old_instance ) {
			$instance = $old_instance;
	
			/* Strip tags (if needed) and update the widget settings. */
			$instance['title'] = strip_tags( $new_instance['title'] );
			$instance['show_count'] = $new_instance['show_count'];
			$instance['show_avatar'] = $new_instance['show_avatar'];
			$instance['avatar_size'] = $new_instance['avatar_size'];
			$instance['excerpt_length'] = $new_instance['excerpt_length'];
	
			return $instance;
		}
		
		///////////////////////////////////////////
		// Form
		///////////////////////////////////////////
		function form( $instance ) {
	
			/* Set up some default widget settings. */
			$defaults = array(
				'title' => __('Recent Comments', 'themify'),
				'show_count' => 3, 
				'show_avatar' => false, 
				'avatar_size' => 32,
				'excerpt_length' => 60
				);
			$instance = wp_parse_args( (array) $instance, $defaults ); ?>
			
			<p>
				<label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php _e('Title:', 'themify'); ?></label><br />
				<input id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" value="<?php echo esc_attr( $instance['title'] ); ?>" width="100%" />
			</p>
	
			<p>
				<label for="<?php echo esc_attr( $this->get_field_id( 'show_count' ) ); ?>"><?php _e('Show:', 'themify'); ?></label>
				<select id="<?php echo esc_attr( $this->get_field_id( 'show_count' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'show_count' ) ); ?>">
					<?php
					for ( $i = 1; $i < 11; $i++ ) {
						echo '<option' . ( $i == $instance['show_count'] ? ' selected="selected"' : '' ) . '>' . $i . '</option>';
					}
					?>
				</select>
			</p>
			
			<p>
				<input class="checkbox" type="checkbox" <?php checked( $instance['show_avatar'], 'on' ); ?> id="<?php echo esc_attr( $this->get_field_id( 'show_avatar' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'show_avatar' ) ); ?>" />
				<label for="<?php echo esc_attr( $this->get_field_id( 'avatar' ) ); ?>"><?php _e('Show avatar', 'themify'); ?></label>
			</p>
			
			<p>
				<label for="<?php echo esc_attr( $this->get_field_id( 'avatar_size' ) ); ?>"><?php _e('Avatar size:', 'themify'); ?></label>
				<input id="<?php echo esc_attr( $this->get_field_id( 'avatar_size' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'avatar_size' ) ); ?>" value="<?php echo esc_attr( $instance['avatar_size'] ); ?>" size="4" /> px
			</p>
			
			<p>
				<label for="<?php echo esc_attr( $this->get_field_id( 'excerpt_length' ) ); ?>"><?php _e('Comment excerpt:', 'themify'); ?></label>
				<input id="<?php echo esc_attr( $this->get_field_id( 'excerpt_length' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'excerpt_length' ) ); ?>" value="<?php echo esc_attr( $instance['excerpt_length'] ); ?>" size="4" /> <?php _e('characters', 'themify'); ?>
			</p>
			
			<?php
		}
	}
	
	///////////////////////////////////////////
	// Banners & Links Class
	///////////////////////////////////////////
	class Themify_Links extends WP_Widget {
		
		///////////////////////////////////////////
		// Themify Links
		///////////////////////////////////////////
		function Themify_Links() {
			/* Widget settings. */
			$widget_ops = array( 'classname' => 'links', 'description' => __('A list of bookmarks', 'themify') );
	
			/* Widget control settings. */
			$control_ops = array( 'id_base' => 'themify-links' );
	
			/* Create the widget. */
			$this->WP_Widget( 'themify-links', __('Themify - Banners &amp; Links', 'themify'), $widget_ops, $control_ops );
		}
		
		///////////////////////////////////////////
		// Widget
		///////////////////////////////////////////
		function widget( $args, $instance ) {
			extract( $args );
	
			/* User-selected settings. */
			$title = apply_filters( 'widget_title', isset( $instance['title'] ) ? $instance['title'] : '' );
			$category = isset( $instance['category'] ) ? $instance['category'] : '';
			$orderby = isset( $instance['orderby'] ) ? $instance['orderby'] : 'rand';
			$show_count = isset( $instance['show_count'] ) ? $instance['show_count'] : '';
			$show_thumb = isset( $instance['show_thumb'] ) ? $instance['show_thumb'] : false;
			$show_name = isset( $instance['show_name'] ) ? $instance['show_name'] : false;
			$show_desc = isset( $instance['show_desc'] ) ? $instance['show_desc'] : false;
	
			/* Before widget (defined by themes). */
			echo wp_kses( $before_widget, themify_before_after_widget_allowed_tags() );
	
			/* Title of widget (before and after defined by themes). */
			if ( $title )
				echo wp_kses( $before_title . $title . $after_title, themify_before_after_widget_title_allowed_tags() );
			
			echo '<ul class="links-list">';
			
			wp_list_bookmarks( array(
				'categorize'        => false,
				'title_li'          => false,
				'orderby'           => $orderby,
				'limit'             => $show_count,
				'category'          => $category,
				'show_images'       => $show_thumb,
				'show_name'         => $show_name,
				'show_description'  => $show_desc
			));
			
			echo '</ul>';
	
			/* After widget (defined by themes). */
			echo wp_kses( $after_widget, themify_before_after_widget_allowed_tags() );
		}
		
		///////////////////////////////////////////
		// Update
		///////////////////////////////////////////
		function update( $new_instance, $old_instance ) {
			$instance = $old_instance;
	
			/* Strip tags (if needed) and update the widget settings. */
			$instance['title'] = strip_tags( $new_instance['title'] );
			$instance['category'] = $new_instance['category'];
			$instance['orderby'] = $new_instance['orderby'];
			$instance['show_count'] = $new_instance['show_count'];
			$instance['show_thumb'] = $new_instance['show_thumb'];
			$instance['show_name'] = $new_instance['show_name'];
			$instance['show_desc'] = $new_instance['show_desc'];
	
			return $instance;
		}
		
		///////////////////////////////////////////
		// Form
		///////////////////////////////////////////
		function form( $instance ) {
	
			/* Set up some default widget settings. */
			$defaults = array( 'title' => __('Blogroll', 'themify'), 'category' => '', 'orderby' => 'rand', 'show_count' => 10, 'show_thumb' => false, 'show_name' => false, 'show_desc' => false );
			$instance = wp_parse_args( (array) $instance, $defaults ); ?>
			
			<p>
				<label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php _e('Title:', 'themify'); ?></label><br />
				<input id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" value="<?php echo esc_attr( $instance['title'] ); ?>" width="100%" />
			</p>
	
			<p>
				<label for="<?php echo esc_attr( $this->get_field_id( 'category' ) ); ?>"><?php _e('Category:', 'themify'); ?></label>
				<select id="<?php echo esc_attr( $this->get_field_id( 'category' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'category' ) ); ?>">
					<option value="" <?php if ( '' == $instance['category'] ) echo 'selected="selected"'; ?>>All</option>
					<?php
					$categories = get_categories(array('type' => 'link'));
					
					foreach( $categories as $cat ) {
						echo '<option value="' . esc_attr( $cat->cat_ID ) . '"';
						
						if ( $cat->cat_ID == $instance['category'] ) echo  ' selected="selected"';
						
						echo '>' . esc_html( $cat->cat_name . ' (' . $cat->category_count . ')' );
						
						echo '</option>';
					}
					?>
				</select>
			</p>
			
			<p>
				<label for="<?php echo esc_attr( $this->get_field_id( 'orderby' ) ); ?>"><?php _e('Orderby:', 'themify'); ?></label>
				<select id="<?php echo esc_attr( $this->get_field_id( 'orderby' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'orderby' ) ); ?>">
					<option value="id" <?php if ( 'id' == $instance['orderby'] ) echo 'selected="selected"'; ?>><?php _e('ID', 'themify'); ?></option>
					<option value="name" <?php if ( 'name' == $instance['orderby'] ) echo 'selected="selected"'; ?>><?php _e('Name', 'themify'); ?></option>
					<option value="rating" <?php if ( 'rating' == $instance['orderby'] ) echo 'selected="selected"'; ?>><?php _e('Rating', 'themify'); ?></option>
					<option value="rand" <?php if ( 'rand' == $instance['orderby'] ) echo 'selected="selected"'; ?>><?php _e('Random', 'themify'); ?></option>
				</select>
			</p>
			
			<p>
				<label for="<?php echo esc_attr( $this->get_field_id( 'show_count' ) ); ?>"><?php _e('Limit:', 'themify'); ?></label>
				<input id="<?php echo esc_attr( $this->get_field_id( 'show_count' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'show_count' ) ); ?>" value="<?php echo esc_attr( $instance['show_count'] ); ?>" size="2" />
			</p>
			
			<p>
				<input class="checkbox" type="checkbox" <?php checked( $instance['show_thumb'], 'on' ); ?> id="<?php echo esc_attr( $this->get_field_id( 'show_thumb' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'show_thumb' ) ); ?>" />
				<label for="<?php echo esc_attr( $this->get_field_id( 'show_thumb' ) ); ?>"><?php _e('Show link image', 'themify'); ?></label>
			</p>
			
			<p>
				<input class="checkbox" type="checkbox" <?php checked( $instance['show_name'], 'on' ); ?> id="<?php echo esc_attr( $this->get_field_id( 'show_name' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'show_name' ) ); ?>" />
				<label for="<?php echo esc_attr( $this->get_field_id( 'show_name' ) ); ?>"><?php _e('Show link name', 'themify'); ?></label>
			</p>
			
			<p>
				<input class="checkbox" type="checkbox" <?php checked( $instance['show_desc'], 'on' ); ?> id="<?php echo esc_attr( $this->get_field_id( 'show_desc' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'show_desc' ) ); ?>" />
				<label for="<?php echo esc_attr( $this->get_field_id( 'show_desc' ) ); ?>"><?php _e('Show link description', 'themify'); ?></label>
			</p>
			
			<?php
		}
	}

	///////////////////////////////////////////
	// Twitter Class
	///////////////////////////////////////////
	class Themify_Twitter extends WP_Widget {
		
		///////////////////////////////////////////
		// Twitter
		///////////////////////////////////////////
		function Themify_Twitter() {
			/* Widget settings. */
			$widget_ops = array( 'classname' => 'twitter', 'description' => __('A list of latest tweets', 'themify') );
	
			/* Widget control settings. */
			$control_ops = array( 'id_base' => 'themify-twitter' );
	
			/* Create the widget. */
			$this->WP_Widget( 'themify-twitter', __('Themify - Twitter', 'themify'), $widget_ops, $control_ops );
		}
		
		///////////////////////////////////////////
		// Widget
		///////////////////////////////////////////
		function widget( $args, $instance ) {
			extract( $args );
	
			/* User-selected settings. */
			$title = apply_filters( 'widget_title', isset( $instance['title'] ) ? $instance['title'] : '' );
			$username = isset( $instance['username'] ) ? $instance['username'] : '';
			$show_count = isset( $instance['show_count'] ) ? $instance['show_count'] : 5;
			$hide_timestamp = isset( $instance['hide_timestamp'] ) ? 'false' : 'true';
			$show_follow = isset( $instance['show_follow'] ) ? ''.$instance['show_follow'] : 'false';
			$follow_text = isset( $instance['follow_text'] ) ? $instance['follow_text'] : '';
			$include_retweets = isset( $instance['include_retweets'] ) ? 'true' : 'false';
			$exclude_replies = isset( $instance['exclude_replies'] ) ? 'true' : 'false';
			$widget_id = $this->id;
	
			/* Before widget (defined by themes). */
			echo wp_kses( $before_widget, themify_before_after_widget_allowed_tags() );
	
			/* Title of widget (before and after defined by themes). */
			if ( $title )
				echo wp_kses( $before_title . $title . $after_title, themify_before_after_widget_title_allowed_tags() );

			echo themify_shortcode_twitter(array(
				'username' => $username,
				'show_count' => $show_count,
				'show_timestamp' => $hide_timestamp,
				'show_follow' => $show_follow,
				'follow_text' => $follow_text,
				'include_retweets' => $include_retweets,
				'exclude_replies' => $exclude_replies,
				'is_widget' => 'true',
				'widget_id' => $widget_id
			));
	
			/* After widget (defined by themes). */
			echo wp_kses( $after_widget, themify_before_after_widget_allowed_tags() );
		}
		
		///////////////////////////////////////////
		// Update
		///////////////////////////////////////////
		function update( $new_instance, $old_instance ) {
			$instance = $old_instance;
	
			/* Strip tags (if needed) and update the widget settings. */
			$instance['title'] = strip_tags( $new_instance['title'] );
			$instance['username'] = $new_instance['username'];
			$instance['show_count'] = $new_instance['show_count'];
			$instance['hide_timestamp'] = $new_instance['hide_timestamp'];
			$instance['show_follow'] = $new_instance['show_follow'];
			$instance['follow_text'] = $new_instance['follow_text'];
			$instance['include_retweets'] = $new_instance['include_retweets'];
			$instance['exclude_replies'] = $new_instance['exclude_replies'];

			// delete transient
			delete_transient( $this->id . '_themify_twitter_feeds_transient' );

			return $instance;
		}
		
		///////////////////////////////////////////
		// Form
		///////////////////////////////////////////
		function form( $instance ) {
	
			/* Set up some default widget settings. */
			$defaults = array(
				'title' => __('Latest Tweets', 'themify'),
				'username' => '',
				'show_count' => 5,
				'hide_timestamp' => false,
				'show_follow' => true,
				'follow_text' => __('&rarr; Follow me', 'themify'),
				'include_retweets' => false,
				'exclude_replies' => true
			);
			$instance = wp_parse_args( (array) $instance, $defaults ); ?>
			
			<p>
				<label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php _e('Title:', 'themify'); ?></label><br />
				<input id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" value="<?php echo esc_attr( $instance['title'] ); ?>" class="widefat" type="text" />
			</p>
	
			<p>
				<label for="<?php echo esc_attr( $this->get_field_id( 'username' ) ); ?>"><?php _e('Twitter ID:', 'themify'); ?></label>
				<input id="<?php echo esc_attr( $this->get_field_id( 'username' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'username' ) ); ?>" value="<?php echo esc_attr( $instance['username'] ); ?>" type="text"/>
			</p>
			
			<p>
				<label for="<?php echo esc_attr( $this->get_field_id( 'show_count' ) ); ?>"><?php _e('Show:', 'themify'); ?></label>
				<input id="<?php echo esc_attr( $this->get_field_id( 'show_count' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'show_count' ) ); ?>" value="<?php echo esc_attr( $instance['show_count'] ); ?>" size="3" type="text" /> <?php _e('tweets', 'themify'); ?>
			</p>
			
			<p>
				<input class="checkbox" type="checkbox" <?php checked( $instance['hide_timestamp'], 'on' ); ?> id="<?php echo esc_attr( $this->get_field_id( 'hide_timestamp' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'hide_timestamp' ) ); ?>" />
				<label for="<?php echo esc_attr( $this->get_field_id( 'hide_timestamp' ) ); ?>"><?php _e('Hide timestamp', 'themify'); ?></label>
			</p>
			
			<p>
				<input class="checkbox" type="checkbox" <?php checked( $instance['show_follow'], 'on' ); ?> id="<?php echo esc_attr( $this->get_field_id( 'show_follow' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'show_follow' ) ); ?>" />
				<label for="<?php echo esc_attr( $this->get_field_id( 'show_follow' ) ); ?>"><?php _e('Display follow me button', 'themify'); ?></label>
			</p>
			
			<p>
				<label for="<?php echo esc_attr( $this->get_field_id( 'follow_text' ) ); ?>"><?php _e('Follow me text:', 'themify'); ?></label>
				<input id="<?php echo esc_attr( $this->get_field_id( 'follow_text' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'follow_text' ) ); ?>" value="<?php echo esc_attr( $instance['follow_text'] ); ?>" type="text" />
			</p>
			
			<p>
				<input class="checkbox" type="checkbox" <?php checked( $instance['include_retweets'], 'on' ); ?> id="<?php echo esc_attr( $this->get_field_id( 'include_retweets' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'include_retweets' ) ); ?>" />
				<label for="<?php echo esc_attr( $this->get_field_id( 'include_retweets' ) ); ?>"><?php _e('Include retweets', 'themify'); ?></label>
			</p>
			
			<p>
				<input class="checkbox" type="checkbox" <?php checked( $instance['exclude_replies'], 'on' ); ?> id="<?php echo esc_attr( $this->get_field_id( 'exclude_replies' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'exclude_replies' ) ); ?>" />
				<label for="<?php echo esc_attr( $this->get_field_id( 'exclude_replies' ) ); ?>"><?php _e('Exclude replies', 'themify'); ?></label>
			</p>
			
			<p>
				<?php echo sprintf(__('<small>Twitter access token is required at <a href="%s">Themify > Settings > Twitter</a>.</small>', 'themify'), admin_url('admin.php?page=themify#setting')); ?>
			</p>
			
			<?php
		}
	}
	
	///////////////////////////////////////////
	// Flickr Class
	///////////////////////////////////////////
	class Themify_Flickr extends WP_Widget {
		
		///////////////////////////////////////////
		// Flickr
		///////////////////////////////////////////
		function Themify_Flickr() {
			/* Widget settings. */
			$widget_ops = array( 'classname' => 'flickr', 'description' => __('A reel of latest photos from Flickr', 'themify') );
	
			/* Widget control settings. */
			$control_ops = array( 'id_base' => 'themify-flickr' );
	
			/* Create the widget. */
			$this->WP_Widget( 'themify-flickr', __('Themify - Flickr', 'themify'), $widget_ops, $control_ops );
		}
		
		///////////////////////////////////////////
		// Widget
		///////////////////////////////////////////
		function widget( $args, $instance ) {
			extract( $args );
	
			/* User-selected settings. */
			$title = apply_filters( 'widget_title', isset( $instance['title'] ) ? $instance['title'] : '' );
			$username = isset( $instance['username'] ) ? $instance['username'] : '';
			$show_count = isset( $instance['show_count'] ) ? $instance['show_count'] : '10';
			$show_link = isset( $instance['show_link'] ) ? $instance['show_link'] : false;
	
			/* Before widget (defined by themes). */
			echo wp_kses( $before_widget, themify_before_after_widget_allowed_tags() );
	
			/* Title of widget (before and after defined by themes). */
			if ( $title ) {
				echo wp_kses( $before_title . $title . $after_title, themify_before_after_widget_title_allowed_tags() );
			}
			
			echo '<div id="flickr_badge_wrapper" class="clearfix">
					<script type="text/javascript" src="' . esc_url( themify_https_esc( 'http://www.flickr.com/badge_code_v2.gne' ) . '?count=' . $show_count . '.&amp;display=latest&amp;size=s&amp;layout=x&amp;source=user&amp;user=' . $username ) . '"></script>
				</div>';
			if( $show_link )
				echo '<a href="' . esc_url( 'http://www.flickr.com/photos/' . $username . '/' ) . '">' . __( 'View my Flickr photostream', 'themify' ) . '</a>';
	
			/* After widget (defined by themes). */
			echo wp_kses( $after_widget, themify_before_after_widget_allowed_tags() );
		}
		
        ///////////////////////////////////////////
        // Update
        ///////////////////////////////////////////
		function update( $new_instance, $old_instance ) {
			
            $instance = $old_instance;
	
			/* Strip tags (if needed) and update the widget settings. */
			$instance['title'] = strip_tags( $new_instance['title'] );
			$instance['username'] = $new_instance['username'];
			$instance['show_count'] = $new_instance['show_count'];
			$instance['show_link'] = $new_instance['show_link'];
			return $instance;
		}
		
        ///////////////////////////////////////////
        // Form
        ///////////////////////////////////////////
		function form( $instance ) {
	
			/* Set up some default widget settings. */
			$defaults = array(
				'title' => __('Recent Photos', 'themify'),
				'username' => '',
				'show_count' => 10,
				'show_link' => false,
			);
			$instance = wp_parse_args( (array) $instance, $defaults ); ?>
			
			<p>
				<label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php _e('Title:', 'themify'); ?></label><br />
				<input id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" value="<?php echo esc_attr( $instance['title'] ); ?>" width="100%" />
			</p>
	
			<p>
				<label for="<?php echo esc_attr( $this->get_field_id( 'username' ) ); ?>"><?php _e('Flickr ID:', 'themify'); ?></label>
				<input id="<?php echo esc_attr( $this->get_field_id( 'username' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'username' ) ); ?>" value="<?php echo esc_attr( $instance['username'] ); ?>" /><br />
				<small><?php printf( __( '* Find your Flickr ID: <a href="%s" target="_blank">idGettr</a>', 'themify' ), 'http://www.idgettr.com' ); ?></small>
			</p>
			
			<p>
				<label for="<?php echo esc_attr( $this->get_field_id( 'show_count' ) ); ?>"><?php _e('Show:', 'themify'); ?></label>
				<input id="<?php echo esc_attr( $this->get_field_id( 'show_count' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'show_count' ) ); ?>" value="<?php echo esc_attr( $instance['show_count'] ); ?>" size="2" /> <?php _e('photos', 'themify'); ?>
			</p>
			
			<p>
				<input class="checkbox" type="checkbox" <?php checked( $instance['show_link'], 'on' ); ?> id="<?php echo esc_attr( $this->get_field_id( 'show_link' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'show_link' ) ); ?>" />
				<label for="<?php echo esc_attr( $this->get_field_id( 'show_link' ) ); ?>"><?php _e('Show link to account', 'themify'); ?></label>
			</p>
	
			<?php
		}
	}

	/**
	 * @package themify
	 * @subpackage shortcodes
	 * @access public
	 * @since 1.1.2
	 */
	class Themify_Most_Commented extends WP_Widget{
		
		function __construct(){
			$widget_ops = array( 'classname' => 'themify-most-commented', 'description' => __('A list with the most commented posts.', 'themify') );
			$control_ops = array( 'id_base' => 'themify-most-commented' );
			parent::__construct( 'themify-most-commented', __('Themify - Most Commented', 'themify'), $widget_ops, $control_ops );
		}
		
		function widget( $args, $instance ) {

			extract( $args );

			$title = apply_filters( 'widget_title', isset( $instance['title'] ) ? $instance['title'] : '' );
			$show_count = isset( $instance['show_count'] ) ? $instance['show_count'] : 10;
			$show_excerpt = isset( $instance['show_excerpt'] ) ? $instance['show_excerpt'] : false;
			$show_thumb = isset( $instance['show_thumb'] ) ? $instance['show_thumb'] : false;
			$thumb_width = isset( $instance['thumb_width'] ) ? $instance['thumb_width'] : 50;
			$thumb_height = isset( $instance['thumb_height'] ) ? $instance['thumb_height'] : 50;
			$excerpt_length = isset( $instance['excerpt_length'] ) ? $instance['excerpt_length'] : 55;
			$hide_title = isset( $instance['hide_title'] ) ? $instance['hide_title'] : false;
			$show_comment_count = isset( $instance['show_comment_count'] ) ? $instance['show_comment_count'] : false;

			$loop = get_posts( array(
				'numberposts' => $show_count,
				'orderby' => 'comment_count',
				'post_type' => 'post',
				'order' => 'DESC',
				'suppress_filters' => false,
			) );

			if ( $loop ) {
				
				/* Before widget (defined by themes). */
				echo wp_kses( $before_widget, themify_before_after_widget_allowed_tags() );
				
				/* Title of widget (before and after defined by themes). */
				if ( $title )
					echo wp_kses( $before_title . $title . $after_title, themify_before_after_widget_title_allowed_tags() );
				
				echo '<ul class="feature-posts-list">';
				global $post;
				foreach ( $loop as $post ) {
					setup_postdata( $post );
					
					echo '<li>';
					
					if ( $show_thumb ) {
						echo themify_get_image( 'ignore=true&w=' . $instance['thumb_width'] . '&h=' . $instance['thumb_height'] . '&before=<a href="' . esc_url( get_permalink() ) . '">&after=</a>&class=post-img' );
					}

					if( !$hide_title ){
						echo '<a href="' . esc_url( get_permalink() ) . '" class="feature-posts-title">' . get_the_title() . '</a>';
					}
					
					if ( $show_comment_count ){
						$comment_string = (get_comments_number() > 1)? __('comments', 'themify') : __('comment', 'themify');
						echo '<br/><small>' . get_comments_number() . ' ' . $comment_string . '</small> <br />';
					}
					if ( $show_excerpt ) {
						$the_excerpt = get_the_excerpt();

						if ( $excerpt_length != '' ) {
							// cut to character limit
							$the_excerpt = substr( $the_excerpt, 0, $excerpt_length );

							// cut to last space
							$the_excerpt = substr( $the_excerpt, 0, strrpos( $the_excerpt, ' ' ) );
						}
						
						echo '<span class="post-excerpt">' . wp_kses_post( $the_excerpt ) . '</span>';
					}
						
					echo '</li>';
					wp_reset_postdata();
				}
				echo '</ul>';

				echo wp_kses( $after_widget, themify_before_after_widget_allowed_tags() );
			}
			
		}
		
		function update( $new_instance, $old_instance ){
			$instance = $old_instance;
			
			$instance['title'] = strip_tags( $new_instance['title'] );
			$instance['show_count'] = $new_instance['show_count'];
			$instance['show_thumb'] = $new_instance['show_thumb'];
			$instance['thumb_width'] = $new_instance['thumb_width'];
			$instance['thumb_height'] = $new_instance['thumb_height'];
			$instance['show_excerpt'] = $new_instance['show_excerpt'];
			$instance['excerpt_length'] = $new_instance['excerpt_length'];
			$instance['hide_title'] = $new_instance['hide_title'];
			$instance['show_comment_count'] = $new_instance['show_comment_count'];
			
			return $instance;
		}
		
		function form( $instance ) {
	
			/* Set up some default widget settings. */
			$defaults = array(
				'title' => __('Most Commented Posts', 'themify'),
				'show_count' => 5,
				'show_excerpt'	=> false,
				'show_thumb' => false,
				'thumb_width' => 50,
				'thumb_height' => 50,
				'excerpt_length' => 55,
				'hide_title' => false,
				'show_comment_count' => false
			);
			
			$instance = wp_parse_args( (array) $instance, $defaults ); ?>
			
			<p>
				<label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php _e('Title:', 'themify'); ?></label><br />
				<input id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" value="<?php echo esc_attr( $instance['title'] ); ?>" type="text" class="widefat" />
			</p>
			
			<p>
				<input class="checkbox" type="checkbox" <?php checked( $instance['hide_title'], 'on' ); ?> id="<?php echo esc_attr( $this->get_field_id( 'hide_title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'hide_title' ) ); ?>" />
				<label for="<?php echo esc_attr( $this->get_field_id( 'hide_title' ) ); ?>"><?php _e('Hide post title', 'themify'); ?></label>
			</p>
			
			<p>
				<input class="checkbox" type="checkbox" <?php checked( $instance['show_comment_count'], 'on' ); ?> id="<?php echo esc_attr( $this->get_field_id( 'show_comment_count' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'show_comment_count' ) ); ?>" />
				<label for="<?php echo esc_attr( $this->get_field_id( 'show_comment_count' ) ); ?>"><?php _e('Display comment count', 'themify'); ?></label>
			</p>
	
			<p>
				<label for="<?php echo esc_attr( $this->get_field_id( 'show_count' ) ); ?>"><?php _e('Number of posts:', 'themify'); ?></label>
				<input id="<?php echo esc_attr( $this->get_field_id( 'show_count' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'show_count' ) ); ?>" value="<?php echo esc_attr( $instance['show_count'] ); ?>" size="2" type="text" />
			</p>
			
			<p>
				<input class="checkbox" type="checkbox" <?php checked( $instance['show_thumb'], 'on' ); ?> id="<?php echo esc_attr( $this->get_field_id( 'show_thumb' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'show_thumb' ) ); ?>" />
				<label for="<?php echo esc_attr( $this->get_field_id( 'show_thumb' ) ); ?>"><?php _e('Display post thumbnail', 'themify'); ?></label>
			</p>
			
			<?php
			// only allow thumbnail dimensions if GD library supported
			if ( function_exists('imagecreatetruecolor') ) {
			?>
			<p>
			   <label for="<?php echo esc_attr( $this->get_field_id( 'thumb_width' ) ); ?>"><?php _e('Thumbnail size', 'themify'); ?></label> <input type="text" id="<?php echo esc_attr( $this->get_field_id( 'thumb_width' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'thumb_width' ) ); ?>" value="<?php echo esc_attr( $instance['thumb_width'] ); ?>" size="3" /> x <input type="text" id="<?php echo esc_attr( $this->get_field_id( 'thumb_height' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'thumb_height' ) ); ?>" value="<?php echo esc_attr( $instance['thumb_height'] ); ?>" size="3" />
			</p>
			<?php
			}
			?>
			
			<p>
				<input class="checkbox" type="checkbox" <?php checked( $instance['show_excerpt'], 'on' ); ?> id="<?php echo esc_attr( $this->get_field_id( 'show_excerpt' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'show_excerpt' ) ); ?>" />
				<label for="<?php echo esc_attr( $this->get_field_id( 'show_excerpt' ) ); ?>"><?php _e('Display post excerpt', 'themify'); ?></label>
			</p>
			
			<p>
				<label for="<?php echo esc_attr( $this->get_field_id( 'excerpt_length' ) ); ?>"><?php _e('Excerpt character limit:', 'themify'); ?></label>
				<input id="<?php echo esc_attr( $this->get_field_id( 'excerpt_length' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'excerpt_length' ) ); ?>" value="<?php echo esc_attr( $instance['excerpt_length'] ); ?>" size="1" type="text" /><br/><small><?php _e('(leave empty = full excerpt)', 'themify'); ?></small>
			</p>
	
			<?php
		}
	}

	
	///////////////////////////////////////////
	// Register Widgets
	///////////////////////////////////////////
	function themify_register_widgets() {
		register_widget('Themify_Feature_Posts');
		register_widget('Themify_List_Pages');
		register_widget('Themify_List_Categories');
		register_widget('Themify_Recent_Comments');
		if ( get_option( 'link_manager_enabled' ) ) {
			register_widget('Themify_Links');
		}
		register_widget('Themify_Social_Links');
		register_widget('Themify_Twitter');
		register_widget('Themify_Flickr');
		register_widget('Themify_Most_Commented');
	}
	add_action('widgets_init', 'themify_register_widgets', 1);

?>