Changeset 1142252
- Timestamp:
- 04/22/2015 02:56:10 PM (11 years ago)
- File:
-
- 1 edited
-
simple-newsletter-br/trunk/simple-newsletter.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
simple-newsletter-br/trunk/simple-newsletter.php
r1142160 r1142252 192 192 register_deactivation_hook(__FILE__, array('simpleNewsletter', 'deactivate')); 193 193 $simpleNewsletter = new simpleNewsletter; 194 } 195 196 ?> 194 add_action( 'widgets_init', 'simplenewsletter_register_widgets' ); 195 } 196 197 class widgetSimpleNewsletter extends WP_Widget { 198 199 function widgetSimpleNewsletter() { 200 // Instantiate the parent object 201 parent::__construct( false, 'Simple Newsletter', array('description' => __('Add the subscription form on widget area', 'simple-newsletter-br')) ); 202 } 203 204 function widget( $args, $instance ) { 205 ?> 206 <aside id="simplenewsletter-widget" class="widget"> 207 <h2 class="widget-title"><?php echo $instance['title'] ?></h2> 208 <p><?php echo ( isset($instance['boxtext']) && !empty($instance['boxtext']) ) ? $instance['boxtext'] : ''; ?></p> 209 <?php do_shortcode('[simplenewsletter]'); ?> 210 </aside> 211 <?php 212 } 213 214 function update( $new_instance, $old_instance ) { 215 $instance = array(); 216 $instance['title'] = ( ! empty( $new_instance['title'] ) ) ? strip_tags( $new_instance['title'] ) : ''; 217 $instance['boxtext'] = ( ! empty( $new_instance['boxtext'] ) ) ? strip_tags( $new_instance['boxtext'] ) : ''; 218 return $instance; 219 } 220 221 function form( $instance ) { 222 $title = ! empty( $instance['title'] ) ? $instance['title'] : __( 'New title', 'simple-newsletter-br' ); 223 $boxtext = ! empty( $instance['boxtext'] ) ? $instance['boxtext'] : __( 'Box Text', 'simple-newsletter-br' ); 224 ?> 225 <p> 226 <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:' ); ?></label> 227 <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 ); ?>"> 228 <label for="<?php echo $this->get_field_id( 'boxtext' ); ?>"><?php _e( 'Box Text:', 'simple-newsletter-br' ); ?></label> 229 <input class="widefat" id="<?php echo $this->get_field_id( 'boxtext' ); ?>" name="<?php echo $this->get_field_name( 'boxtext' ); ?>" type="text" value="<?php echo esc_attr( $boxtext ); ?>"> 230 </p> 231 <?php 232 } 233 } 234 235 function simplenewsletter_register_widgets() { 236 register_widget( 'widgetSimpleNewsletter' ); 237 }
Note: See TracChangeset
for help on using the changeset viewer.