Permalink
Browse files

removed advertisment widget and replaced it with advanced text widget

  • Loading branch information...
1 parent d796752 commit ed8645ef55e3516af15c5e46023c624a1db30a7d @madalinungureanu committed Nov 27, 2011
@@ -24,7 +24,7 @@ function bareskin_theme_setup() {
add_theme_support( 'bareskin-get-image' );
add_theme_support( 'bareskin-breadcrumb' );
add_theme_support( 'bareskin-shortcodes' );
- add_theme_support( 'bareskin-widgets', array( 'recent-posts' ) );
+ add_theme_support( 'bareskin-widgets', array( 'recent-posts', 'advanced-text' ) );
add_theme_support( 'post-formats', array( 'aside', 'chat', 'gallery', 'image', 'link', 'quote', 'status', 'video', 'audio' ) );
@@ -26,19 +26,19 @@ function bareskin_register_widgets() {
/* If there are any supported widgets, load them. */
if ( is_array( $supports[0] ) ) {
- /* Load the 'Advertisment' widget if it is supported, and register it. */
- if ( in_array( 'advertisment', $supports[0] ) ){
- require_once( trailingslashit( BARESKIN_WIDGETS ) . 'widget_advertisment.php' );
+ /* Load the 'Advanced Text' widget if it is supported, and register it. */
+ if ( in_array( 'advanced-text', $supports[0] ) ){
+ require_once( trailingslashit( BARESKIN_WIDGETS ) . 'widget_advanced_text.php' );
- /* Register the advertisment widget. */
- register_widget( 'BareSkin_Widget_Advertisment' );
+ /* Register the advanced text widget. */
+ register_widget( 'BareSkin_Advanced_Widget_Text' );
}
/* Load the 'Advanced Recent Posts' widget if it is supported, and register it. */
if ( in_array( 'recent-posts', $supports[0] ) ){
require_once( trailingslashit( BARESKIN_WIDGETS ) . 'widget_adv_recent_posts.php' );
- /* Register the advertisment widget. */
+ /* Register the advanced recent posts widget. */
register_widget( 'BareSkin_Widget_Advanced_Recent_Posts' );
}
@@ -0,0 +1,57 @@
+<?php
+/**
+ * Advanced Text widget class
+ *
+ * @since 1.0.0
+ */
+class BareSkin_Advanced_Widget_Text extends WP_Widget {
+
+ function __construct() {
+ $widget_ops = array('classname' => 'adv_widget_text', 'description' => __('Arbitrary text or HTML'));
+ $control_ops = array('width' => 400, 'height' => 350);
+ parent::__construct('advanced_text', __('Advanced Text'), $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( 'adv_widget_text', $instance['text'], $instance );
+ echo $before_widget;
+ echo '<div class="' . $instance['class'] . '">' ;
+ if ( !empty( $title ) ) { echo $before_title . $title . $after_title; } ?>
+ <div class="textwidget"><?php echo $instance['filter'] ? wpautop($text) : $text; ?></div>
+ <?php
+ echo '</div>';
+ echo $after_widget;
+ }
+
+ function update( $new_instance, $old_instance ) {
+ $instance = $old_instance;
+ $instance['title'] = strip_tags($new_instance['title']);
+ $instance['class'] = strip_tags($new_instance['class']);
+ 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' => '', 'class' => '', 'text' => '' ) );
+ $title = strip_tags($instance['title']);
+ $class = strip_tags($instance['class']);
+ $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>
+
+ <p><label for="<?php echo $this->get_field_id('class'); ?>"><?php _e('Css Class (do not remove or change):'); ?></label>
+ <input class="widefat" id="<?php echo $this->get_field_id('class'); ?>" name="<?php echo $this->get_field_name('class'); ?>" type="text" value="<?php echo esc_attr($class); ?>" /></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); ?> />&nbsp;<label for="<?php echo $this->get_field_id('filter'); ?>"><?php _e('Automatically add paragraphs'); ?></label></p>
+<?php
+ }
+}

0 comments on commit ed8645e

Please sign in to comment.