Plugin Directory

Changeset 1256216


Ignore:
Timestamp:
09/30/2015 01:42:38 AM (10 years ago)
Author:
r3df
Message:

1.0.12 Update

Location:
r3df-meetup-widget/trunk
Files:
6 added
2 edited

Legend:

Unmodified
Added
Removed
  • r3df-meetup-widget/trunk/r3df-meetup-widget.php

    r1131574 r1256216  
    44Description:    Displays meetup group link in a widget
    55Plugin URI:     http://r3df.com/
    6 Version:        1.0.11
     6Version:        1.0.12
    77Text Domain:    r3df-meetup-widget
    88Domain Path:    /lang/
     
    2929*/
    3030
    31 // Class definition, creates a widget using the WordPress widget class
    32 class widget_r3dfmeetup extends WP_Widget {
    33 
    34     // Constructor function - sets up the widget
     31/**
     32 * Register the widget on the widgets_init hook.
     33 */
     34
     35// Use create_function() until WP requires PHP 5.3 function() only added in 5.3+
     36// add_action( 'widgets_init', function(){ register_widget( 'Widget_R3DF_Meetup' ); });
     37add_action( 'widgets_init', create_function( '', 'return register_widget( "Widget_R3DF_Meetup" );' ) );
     38
     39/**
     40 * Class Widget_R3DF_Meetup definition, creates a widget using the WordPress widget class
     41 */
     42class Widget_R3DF_Meetup extends WP_Widget {
     43
     44    /**
     45     * Constructor - sets up the widget
     46     */
    3547    function __construct() {
     48
     49        // Load text domain (needs to load immediately to translate the name, description etc.
     50        // widget_init is sub_action of init, priority 1...
     51        $this->text_domain();
    3652
    3753        // Define the widget: ID, name and description
     
    4561
    4662        // load plugin css
    47         // TODO: can we figure out if widget is actually being displayed?
     63        // TODO: can we figure out if widget is actually being displayed, and only load css as needed?
    4864        if ( is_active_widget( false, false, $this->id_base, true ) ) {
    49             if ( file_exists( __DIR__ . '/inc/r3df-mw.css' ) ) {
    50                 add_action( 'wp_enqueue_scripts', array( get_class( $this ), 'add_style' ), 1025 );
    51             }
    52         }
    53 
    54         // Add text domain hook
    55         add_action( 'init', array( &$this, 'text_domain' ) );
    56     }
    57 
    58     // Function that displays the widget content on the site frontend.
     65            add_action( 'wp_enqueue_scripts', array( $this, 'add_style' ), 1025 );
     66        }
     67    }
     68
     69    /**
     70     * Function that displays the widget content on the site frontend.
     71     *
     72     * @param array $args
     73     * @param array $instance
     74     */
    5975    function widget( $args, $instance ) {
    60         // Expand the passed in args into the function space - creates $before_widget, $after_widget, $before_title, $after_title
    61         extract( $args );
     76        // Expand the passed in args into the function space, restrict to expected args
     77        $before_widget = '';
     78        $before_title = '';
     79        $after_title = '';
     80        $after_widget = '';
     81        extract( $args, EXTR_IF_EXISTS );
    6282
    6383         // display anything passed in the $before_widget parameter
     
    83103        }
    84104
    85         // Set $middle to ' middle if it is set, or blank otherwise'
     105        // Set $middle to ' middle' if it is set, or blank ('') otherwise
    86106        $middle = ! empty( $instance['middle'] ) ? ' middle' : '';
    87107
     
    98118    }
    99119
    100     // Displays the widget options in the WordPress admin
     120    /**
     121     * Displays the widget options in the WordPress admin
     122     *
     123     * @param array $instance
     124     */
    101125    function form( $instance ) {
    102126        // check that parameters are set and strip (clean) any saved values (from the database, passed in $instance)
     
    133157
    134158            <!-- URL input box -->
    135             <p><label for="<?php echo $this->get_field_id( 'url' ); ?>"><?php _e('URL:', 'r3df-meetup-widget' ); ?>
     159            <p><label for="<?php echo $this->get_field_id( 'url' ); ?>"><?php _e( 'URL:', 'r3df-meetup-widget' ); ?>
    136160            <input class="widefat" id="<?php echo $this->get_field_id( 'url' ); ?>" name="<?php echo $this->get_field_name( 'url' ); ?>" type="text" value="<?php echo $url; ?>" />
    137161            </label></p>
     
    149173            <label for="<?php echo $this->get_field_id( 'middle' ); ?>"><?php _e( 'Postion text in middle vertically', 'r3df-meetup-widget' ); ?></label></p>
    150174        <?php
    151     }
    152 
    153     // Updates the database with user values from the admin form
     175
     176    }
     177
     178    /**
     179     * Updates the database with user values from the admin form
     180     *
     181     * @param array $new_instance
     182     * @param array $old_instance
     183     *
     184     * @return array
     185     */
    154186    function update( $new_instance, $old_instance ) {
    155187        $instance = array();
     
    178210    }
    179211
    180     // Language file loader
     212    /**
     213     * Language file loader
     214     */
    181215    function text_domain() {
    182216        // Load language files - files must be r3df-meetup-widget-xx_XX.mo
     
    184218    }
    185219
    186     // Style Sheet loader
     220    /**
     221     * Style Sheet loader
     222     */
    187223    function add_style() {
    188224        // Get the plugin version (added to css file loaded to clear browser caches on change)
     
    190226
    191227        // Register and enqueue the css file
    192         wp_register_style( 'r3df-mw', plugins_url( 'inc/r3df-mw.css', __FILE__ ), false, $plugin['Version'] );
     228        wp_register_style( 'r3df-mw', plugins_url( 'css/r3df-mw.css', __FILE__ ), false, $plugin['Version'] );
    193229        wp_enqueue_style( 'r3df-mw' );
    194230    }
    195231}
    196 // Register the widget on the widgets_init hook:
    197 // Temporarily reverted until WP requires PHP 5.3 function() only added in 5.3+
    198 // add_action( 'widgets_init', function(){ register_widget( 'widget_r3dfmeetup' ); });
    199 add_action( 'widgets_init', create_function( '', 'return register_widget("widget_r3dfmeetup");' ) );
     232
  • r3df-meetup-widget/trunk/readme.txt

    r1131582 r1256216  
    33Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=MX3FLF4YGXRLE
    44Tags: meetup, meetups, meetup.com, widget, meetup widget
    5 Stable tag: 1.0.11
     5Stable tag: 1.0.12
    66Requires at least: 4.0
    7 Tested up to: 4.1
     7Tested up to: 4.3
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    4444
    4545== Changelog ==
     46
     47= 1.0.12 =
     481. Tidied code some more for WordPress coding standards
     492. Changed the text domain load to load before widget instantiation
     503. Added a crude French translation (If you can improve it let me know)
     514. Changed tested version to 4.3
    4652
    4753= 1.0.11 =
Note: See TracChangeset for help on using the changeset viewer.