Plugin Directory

Changeset 1191394


Ignore:
Timestamp:
07/02/2015 07:06:06 PM (11 years ago)
Author:
bryanmonzon
Message:

fix widget class constructor function to use PHP 5.3+

Location:
ifgathering-fundraising-widget/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • ifgathering-fundraising-widget/trunk/ifg-fundraiser.php

    r1072837 r1191394  
    99Description: This plugin is a widget you can use to install on your site and display the fundraiser results
    1010Author: Bryan Monzon
    11 Version: 1.2
     11Version: 1.3
    1212Author URI: http://fiftyandfifty.org
    1313*/
     
    2121{
    2222
     23   
     24
    2325    // constructor
    24     function ifg_fundraiser_widget()
     26    public function __construct( $arr = array() )
    2527    {
    26         /* ... */
    27         parent::WP_Widget(false, $name = __('IF:Gathering Widget', 'ifg_fundraiser_widget') );
    28     }
    29 
    30     // widget form creation
    31     function form( $instance )
    32     { 
    33         /* ... */
    34         // Check values
    35         if( $instance ) {
    36              $title   = esc_attr( $instance['title'] );
    37         } else {
    38              $title   = '';
    39              
    40         }
    41         ?>
    42         <p><em>This widget is not responsive and requires the minimum width to be 350px</em></p>
    43         <p>
    44             <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:', 'dntly'); ?></label>
    45             <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" />
    46         </p>
    47 
    48        
    49         <p style="display:block; clear:both;"></p>
    50 
    51 
    52        
    53 
    54     <?php
    55     }
    56 
    57     // widget update
    58     function update( $new_instance, $old_instance )
    59     {
    60         /* ... */
    61         $instance = $old_instance;
    62              // Fields
    63             $instance['title']   = strip_tags( $new_instance['title'] );
    64      
    65 
    66             return $instance;
     28   
     29        parent::__construct(
     30                    'ifg_fundraiser_widget', // Base ID
     31                    __( 'IF:Gathering Widget', 'ifg_fundraiser_widget' ), // Name
     32                    array( 'description' => __( 'A simple widget to show IF:Gathering\'s fundraiser progress', 'ifg_fundraiser_widget' ), ) // Args
     33                );
    6734    }
    6835
    6936    // widget display
    70     function widget( $args, $instance ) {
     37    public function widget( $args, $instance ) {
    7138        /* ... */
    7239       
     
    9663
    9764    }
     65
     66    // widget form creation
     67    public function form( $instance )
     68    { 
     69        /* ... */
     70        // Check values
     71        if( $instance ) {
     72             $title   = esc_attr( $instance['title'] );
     73        } else {
     74             $title   = '';
     75             
     76        }
     77        ?>
     78        <p><em>This widget is not responsive and requires the minimum width to be 350px</em></p>
     79        <p>
     80            <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:', 'dntly'); ?></label>
     81            <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" />
     82        </p>
     83
     84       
     85        <p style="display:block; clear:both;"></p>
     86
     87
     88       
     89
     90    <?php
     91    }
     92
     93    // widget update
     94    public function update( $new_instance, $old_instance )
     95    {
     96        /* ... */
     97        $instance = $old_instance;
     98             // Fields
     99            $instance['title']   = strip_tags( $new_instance['title'] );
     100     
     101
     102            return $instance;
     103    }
     104
     105   
    98106}
    99107// register widget
    100 add_action('widgets_init', create_function('', 'return register_widget("ifg_fundraiser_widget");'));
    101108
     109/**
     110 * Register the Widget
     111 * @return [type] [description]
     112 */
     113function register_if_gathering_widget() {
     114    register_widget( 'ifg_fundraiser_widget' );
     115}
     116add_action( 'widgets_init', 'register_if_gathering_widget' );
     117
     118
     119/**
     120 * [ifg_fundraiser_shortcode description]
     121 * @param  [type] $atts    [description]
     122 * @param  [type] $content [description]
     123 * @return [type]          [description]
     124 */
    102125function ifg_fundraiser_shortcode( $atts, $content=null )
    103126{
  • ifgathering-fundraising-widget/trunk/readme.txt

    r1072837 r1191394  
    44Requires at least: 3.0
    55Tested up to: 4.1
    6 Stable tag: 1.2
     6Stable tag: 1.3
    77
    88Display fundraiser widget for IF:Gathering fundraising needs.
     
    5252== Changelog ==
    5353
     54= 1.3 =
     55*   Fix widget class constructor
     56
    5457= 1.2 =
    5558*   Fix comma placement
Note: See TracChangeset for help on using the changeset viewer.