Changeset 989738
- Timestamp:
- 09/14/2014 10:01:52 PM (12 years ago)
- Location:
- health-progress
- Files:
-
- 1 deleted
- 5 edited
-
assets/screenshot-1.png (modified) (previous)
-
assets/screenshot-2.png (modified) (previous)
-
assets/screenshot-3.png (deleted)
-
trunk/health-progress.js (modified) (1 diff)
-
trunk/health-progress.php (modified) (11 diffs)
-
trunk/readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
health-progress/trunk/health-progress.js
r949106 r989738 1 1 jQuery(document).ready(function($){ 2 2 $('#date').datepicker(); 3 4 5 3 }); -
health-progress/trunk/health-progress.php
r949850 r989738 3 3 Plugin Name: Health Progress 4 4 Plugin URI: http://sandymcfadden.com/2014/07/16/health-progress-wordpress-plugin/ 5 Description: Creates a widget so you can display progress in healthy measurements.5 Description: Creates a widget / shortcode so you can display progress in healthy measurements. 6 6 Author: Sandy McFadden 7 Version: 1. 27 Version: 1.3 8 8 Author URI: http://sandymcfadden.com 9 9 */ … … 33 33 } 34 34 35 function smhp_display ($instance = null) {35 function smhp_display_widget($instance = null) { 36 36 static $smhp_count = 1; 37 37 … … 59 59 $widget .= ' <td>'. __(@$options['field_'. $i . '_title'], 'smhp_widget_domain') .'</td>'; 60 60 $widget .= ' <td>'. @$options['field_'. $i . '_start'] . __(@$options['field_'. $i . '_unit'], 'smhp_widget_domain') .'</td>'; 61 $widget .= ' <td>'. @$ instance['field_' . $i . '_now'] . __(@$options['field_'. $i . '_unit'], 'smhp_widget_domain') .'</td>';62 $widget .= ' <td><strong>'. (@$options['field_'. $i . '_start'] - @$ instance['field_' . $i . '_now']) . __(@$options['field_'. $i . '_unit'], 'smhp_widget_domain') .'</strong></td>';61 $widget .= ' <td>'. @$options['field_' . $i . '_now'] . __(@$options['field_'. $i . '_unit'], 'smhp_widget_domain') .'</td>'; 62 $widget .= ' <td><strong>'. (@$options['field_'. $i . '_start'] - @$options['field_' . $i . '_now']) . __(@$options['field_'. $i . '_unit'], 'smhp_widget_domain') .'</strong></td>'; 63 63 $widget .= '</tr>'; 64 64 } … … 93 93 echo $args['before_title'] . $title . $args['after_title']; 94 94 95 echo smhp_display ($instance);95 echo smhp_display_widget($instance); 96 96 echo $args['after_widget']; 97 97 } … … 117 117 </p> 118 118 119 119 120 <?php 120 121 $num = intval($options['num']);122 for ($i = 1; $i <= $num; $i++) {123 ?>124 125 <p>126 <label for="<?php echo $this->get_field_id( 'field_' . $i . '_now' ); ?>">Current <?php echo __($options['field_'. $i . '_title'], 'smhp_widget_domain'); ?></label>127 <input class="widefat" id="<?php echo $this->get_field_id( 'field_' . $i . '_now' ); ?>" name="<?php echo $this->get_field_name( 'field_' . $i . '_now' ); ?>" type="text" value="<?php echo esc_attr( $instance['field_' . $i . '_now'] ); ?>"> <?php echo __($options['field_'. $i . '_unit'], 'smhp_widget_domain'); ?>128 </p>129 130 <?php131 }132 133 121 } 134 122 … … 137 125 $instance = array(); 138 126 $instance['title'] = ( ! empty( $new_instance['title'] ) ) ? strip_tags( $new_instance['title'] ) : ''; 139 140 foreach ($new_instance as $key => $value) { 141 $instance[$key] = strip_tags( $value ); 142 } 127 143 128 return $instance; 144 129 } … … 154 139 155 140 141 /** 142 * Display Shortcode 143 */ 144 145 function smhp_display_shortcode($instance = null) { 146 static $smhp_count = 1; 147 148 $options = get_option('smhp_options', array() ); 149 if (empty($options)) { 150 return '<p>You must input settings on the plugin settings page.</p>'; 151 } 152 153 $start_date = $options['date']; 154 $start_date = strtotime($start_date); 155 $start_date = date("M/y", $start_date); 156 157 $shortcode = ' <div id="smhp_shortcode_'. $smhp_count .'" class="smhp_shortcode"> 158 <table id="smhp_shortcode_table_'. $smhp_count .'" class="smhp_shortcode_table"> 159 <tr> 160 <th> </th> 161 <th>'. $start_date .'</th> 162 <th>'. __('Now', 'smhp_widget_domain') .'</th> 163 <th>'. __('Lost', 'smhp_widget_domain') .'</th> 164 </tr>'; 165 166 $num = intval($options['num']); 167 for ($i = 1; $i <= $num; $i++) { 168 $shortcode .= '<tr>'; 169 $shortcode .= ' <td>'. __(@$options['field_'. $i . '_title'], 'smhp_widget_domain') .'</td>'; 170 $shortcode .= ' <td>'. @$options['field_'. $i . '_start'] . __(@$options['field_'. $i . '_unit'], 'smhp_widget_domain') .'</td>'; 171 $shortcode .= ' <td>'. @$options['field_' . $i . '_now'] . __(@$options['field_'. $i . '_unit'], 'smhp_widget_domain') .'</td>'; 172 $shortcode .= ' <td><strong>'. (@$options['field_'. $i . '_start'] - @$options['field_' . $i . '_now']) . __(@$options['field_'. $i . '_unit'], 'smhp_widget_domain') .'</strong></td>'; 173 $shortcode .= '</tr>'; 174 } 175 176 $shortcode .= ' 177 </table> 178 </div>'; 179 180 $smhp_count++; 181 return $shortcode; 182 } 156 183 157 184 … … 200 227 $this->options = get_option( 'smhp_options' ); 201 228 202 203 229 if (!isset($this->options['num']) || $this->options['num'] == '') 204 230 $this->options['num'] = 1; 205 231 ?> 206 232 <div class="wrap"> 207 <h2>Health Progress Settings</h2> 208 <form method="post" action="options.php"> 233 <h2>Health Progress Settings</h2> 234 235 <form method="post" name="inital-settings" action="options.php"> 236 <input type="hidden" name="smhp_form" value="initial"> 209 237 <?php 210 238 // This prints out all hidden setting fields … … 292 320 $new_input['field_'. $i .'_unit'] = sanitize_text_field($input['field_'. $i .'_unit']); 293 321 $new_input['field_'. $i .'_start'] = sanitize_text_field($input['field_'. $i .'_start']); 322 $new_input['field_'. $i .'_now'] = sanitize_text_field($input['field_'. $i .'_now']); 294 323 } 295 324 … … 324 353 isset( $this->options['field_'. $field_num .'_unit'] ) ? esc_attr( $this->options['field_'. $field_num .'_unit']) : '' ); 325 354 printf('<input type="text" id="field_'. $field_num .'_start" name="smhp_options[field_'. $field_num .'_start]" value="%s" placeholder="Starting Measurement (eg. 100)" />', 326 isset( $this->options['field_'. $field_num .'_start'] ) ? esc_attr( $this->options['field_'. $field_num .'_start']) : '' ); 355 isset( $this->options['field_'. $field_num .'_start'] ) ? esc_attr( $this->options['field_'. $field_num .'_start']) : '' ); 356 printf('<input type="text" id="field_'. $field_num .'_now" name="smhp_options[field_'. $field_num .'_now]" value="%s" placeholder="Current Measurement (eg. 100)" />', 357 isset( $this->options['field_'. $field_num .'_now'] ) ? esc_attr( $this->options['field_'. $field_num .'_now']) : '' ); 327 358 } 328 359 … … 341 372 } 342 373 374 // Add shortcode 375 function get_sm_health_progress_shortcode($atts) { 376 return smhp_display_shortcode(); 377 } 378 379 add_shortcode('sm_health_progress', 'get_sm_health_progress_shortcode'); 380 343 381 if( is_admin() ) 344 382 $smhp_settings_page = new smhp_settings_page(); -
health-progress/trunk/readme.txt
r979984 r989738 11 11 Stable tag: 1.2 12 12 13 Health Progress will add a widget to your site which will display your starting measurements and progress as you get healthy.13 Health Progress will add a widget and shortcode to your site which will display your starting measurements and progress as you get healthy. 14 14 15 15 == Description == … … 28 28 * You will then have that many fields available to you. 29 29 * Set the date with the date picker for when these starting measurements were taken. 30 * Input your fields and starting measurements.31 * For each measurement there are three fields. The title, the units, and the starting measurement.32 * The units can remain blank if you like and only digits should to in the starting measurement .30 * Input your fields, starting measurements and current values. 31 * For each measurement there are four fields. The title, the units, the starting measurement and the current value. 32 * The units can remain blank if you like and only digits should to in the starting measurement and current value. 33 33 * Submit the changes 34 34 35 35 Next you can go to the Appearance then Widgets. You will see the widget availabe for you to add to your site. 36 36 You can fill in the title you want to appear with this widget. 37 Then you can fill out your current measurments for each that you are keeping track of. 37 38 == Frequently Asked Questions == 39 40 1. What shortcode do I use? 41 **[sm_health_progress]** 38 42 39 43 == Screenshots == 40 44 41 1. Enter settings and initial measurements 42 2. Fill in the current measurements for the widget 43 3. Example front end look 45 1. Enter settings, initial measurements and current values 46 2. Example front end look 44 47 45 48 == Changelog == 46 49 50 = 1.3 = 51 * Add shortcode of [sm_health_progress] to display progress. 52 * Move current values form from widget to settings page. 53 47 54 = 1.2 = 48 55 * Updating readme.txt file with proper version and URI fields.
Note: See TracChangeset
for help on using the changeset viewer.