Changeset 1256216
- Timestamp:
- 09/30/2015 01:42:38 AM (10 years ago)
- Location:
- r3df-meetup-widget/trunk
- Files:
-
- 6 added
- 2 edited
-
css (added)
-
css/index.php (added)
-
css/r3df-mw.css (added)
-
lang/r3df-meetup-widget-fr_FR.mo (added)
-
lang/r3df-meetup-widget-fr_FR.po (added)
-
lang/r3df-meetup-widget.pot (added)
-
r3df-meetup-widget.php (modified) (10 diffs)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
r3df-meetup-widget/trunk/r3df-meetup-widget.php
r1131574 r1256216 4 4 Description: Displays meetup group link in a widget 5 5 Plugin URI: http://r3df.com/ 6 Version: 1.0.1 16 Version: 1.0.12 7 7 Text Domain: r3df-meetup-widget 8 8 Domain Path: /lang/ … … 29 29 */ 30 30 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' ); }); 37 add_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 */ 42 class Widget_R3DF_Meetup extends WP_Widget { 43 44 /** 45 * Constructor - sets up the widget 46 */ 35 47 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(); 36 52 37 53 // Define the widget: ID, name and description … … 45 61 46 62 // 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? 48 64 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 hook55 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 */ 59 75 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 ); 62 82 63 83 // display anything passed in the $before_widget parameter … … 83 103 } 84 104 85 // Set $middle to ' middle if it is set, or blank otherwise'105 // Set $middle to ' middle' if it is set, or blank ('') otherwise 86 106 $middle = ! empty( $instance['middle'] ) ? ' middle' : ''; 87 107 … … 98 118 } 99 119 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 */ 101 125 function form( $instance ) { 102 126 // check that parameters are set and strip (clean) any saved values (from the database, passed in $instance) … … 133 157 134 158 <!-- 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' ); ?> 136 160 <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; ?>" /> 137 161 </label></p> … … 149 173 <label for="<?php echo $this->get_field_id( 'middle' ); ?>"><?php _e( 'Postion text in middle vertically', 'r3df-meetup-widget' ); ?></label></p> 150 174 <?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 */ 154 186 function update( $new_instance, $old_instance ) { 155 187 $instance = array(); … … 178 210 } 179 211 180 // Language file loader 212 /** 213 * Language file loader 214 */ 181 215 function text_domain() { 182 216 // Load language files - files must be r3df-meetup-widget-xx_XX.mo … … 184 218 } 185 219 186 // Style Sheet loader 220 /** 221 * Style Sheet loader 222 */ 187 223 function add_style() { 188 224 // Get the plugin version (added to css file loaded to clear browser caches on change) … … 190 226 191 227 // 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'] ); 193 229 wp_enqueue_style( 'r3df-mw' ); 194 230 } 195 231 } 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 3 3 Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=MX3FLF4YGXRLE 4 4 Tags: meetup, meetups, meetup.com, widget, meetup widget 5 Stable tag: 1.0.1 15 Stable tag: 1.0.12 6 6 Requires at least: 4.0 7 Tested up to: 4. 17 Tested up to: 4.3 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 44 44 45 45 == Changelog == 46 47 = 1.0.12 = 48 1. Tidied code some more for WordPress coding standards 49 2. Changed the text domain load to load before widget instantiation 50 3. Added a crude French translation (If you can improve it let me know) 51 4. Changed tested version to 4.3 46 52 47 53 = 1.0.11 =
Note: See TracChangeset
for help on using the changeset viewer.