Changeset 523224
- Timestamp:
- 03/25/2012 01:03:28 AM (12 years ago)
- Location:
- tdd-progress-bar/trunk
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
tdd-progress-bar/trunk
-
Property
svn:ignore
set to
deploy.sh
README.md
.git
.gitignore
-
Property
svn:ignore
set to
-
tdd-progress-bar/trunk/inc/admin.php
r499559 r523224 4 4 * Array of color options 5 5 */ 6 $colors = array ( 6 $colors = array ( 7 7 'strawberry' => __ ( 'Strawberry', 'tdd_pb' ), 8 8 'fuchsia' => __( 'Fuchsia', 'tdd_pb' ), … … 14 14 'yellow' => __( 'Yellow', 'tdd_pb' ), 15 15 'orange' => __( 'Orange', 'tdd_pb' ), 16 'red' 16 'red'=> __( 'Red', 'tdd_pb' ), 17 17 'black' => __( 'Black', 'tdd_pb' ), 18 18 'silver' => __( 'Silver', 'tdd_pb' ), 19 19 ); 20 20 21 21 /* … … 27 27 add_action( 'add_meta_boxes', 'tdd_pb_metabox_create' ); 28 28 29 /* 30 * Post type meta box display 31 */ 32 function tdd_pb_metabox_display($post) { 29 30 /** 31 * Meta box display for the Progress Bar post type. 32 * 33 * Provides the form controls necessary to select the color of the bar as well as: 34 * Percentage input 35 * X of Y input 36 * Label Display mode (only applicable if global show percentages option is on): 37 * - None 38 * - Percentage only 39 * - Text label 40 * - Percentage (text label) 41 * - Text label (percentage) 42 */ 43 function tdd_pb_metabox_display( $post ) { 33 44 $tdd_pb_color = get_post_meta( $post->ID, '_tdd_pb_color', true ); 34 45 $tdd_pb_percentage = get_post_meta( $post->ID, '_tdd_pb_percentage', true ); 46 47 48 49 50 35 51 ?> 36 52 37 53 <table class="form-table"> 38 54 <tr valign="top"> 39 <th scope="row"><label for="tdd_pb_color"> Bar Color</label></th>55 <th scope="row"><label for="tdd_pb_color"></label></th> 40 56 <td><select name="tdd_pb_color"> 41 57 <?php global $colors; ?> 42 <?php foreach ( $colors as $color=>$label ): ?>58 <?php foreach ($colors as $color=>$label ): ?> 43 59 <option value="<?php echo $color; ?>" <?php selected( $tdd_pb_color, $color ); ?>"><?php echo $label; ?></option> 44 60 <?php endforeach; ?> … … 46 62 </tr> 47 63 <tr valign="top"> 48 <th scope="row"><label for="tdd_pb_percentage">Percent Complete</label></th> 49 <td><input name="tdd_pb_percentage" type="text" maxlength="3" size="3" value="<?php echo esc_attr( $tdd_pb_percentage ); ?>">%</td> 64 <th scope="row"><?php _e( 'Calculation Mode', 'tdd_pb' ); ?></th> 65 <td> 66 <fieldset> 67 <legend class="screen-reader-text"><span><?php _e( 'Input Method and Percentage Calculation', 'tdd_pb' ); ?></span></legend> 68 69 <table class="form-table"> 70 <tr valign="top"> 71 <td> 72 <label><input name="tdd_pb_input_method" type="radio" <?php checked( $tdd_pb_input_method, 'percentage' ); ?> value="percentage" > <?php _e( 'Percentage', 'tdd_pb' ); ?></label> 73 </td> 74 <td> 75 <input name="tdd_pb_percentage" type="text" size="2" value="<?php echo esc_attr( $tdd_pb_percentage ); ?>"> % </td> 76 </tr> 77 <tr valign="top"> 78 <td> 79 <label><input name="tdd_pb_input_method" type="radio" <?php checked( $tdd_pb_input_method, 'xofy' ); ?> value="xofy" > <?php _e( 'Calculate Percentage (x of y)', 'tdd_pb' ); ?></label> 80 </td> 81 <td> 82 <input name="tdd_pb_start" type="text" size="10" value="<?php echo esc_attr( $tdd_pb_start ); ?>"> <?php _e( 'of', 'tdd_pb' ); ?> 83 <input name="tdd_pb_end" type="text" size="10" value="<?php echo esc_attr( $tdd_pb_end ); ?>"><br /> 84 <span class="description"><?php _e( "Numbers only, don't include units", 'tdd_pb' ); ?></span> 85 </td> 86 </tr> 87 </table> 88 </fieldset> 89 </td> 90 </tr> 91 <tr valign="top"> 92 <th scope="row"><?php _e( 'Display the following on the progress bar:', 'tdd_pb' ); ?></th> 93 <td> 94 <fieldset> 95 <legend class="screen-reader-text"><span><?php _e( 'Display the following on the progress bar:', 'tdd_pb' ); ?></span></legend> 96 <label><input name="tdd_pb_percentage_display" type="checkbox" <?php checked( $tdd_pb_percentage_display, 'on' ); ?>> <?php _e( 'Display Calculated Percentage', 'tdd_pb' ); ?><label><br /> 97 <label><input name="tdd_pb_xofy_display" type="checkbox" <?php checked( $tdd_pb_xofy_display, 'on' ); ?> > <?php _e( 'Display x of y Values', 'tdd_pb' ); ?></label> 98 </fieldset> 99 </td> 50 100 </tr> 51 101 </table> 102 52 103 <?php $id = get_the_ID(); ?> 53 <p><?php _e( "Example shortcode: <code>[progress id={$id}]</code>", 'tdd_pb' ); ?> </p>54 104 <p><?php _e( "Example shortcode: <code>[progress id={$id}]</code>", 'tdd_pb'); ?> </p> 105 55 106 <?php echo tdd_pb_get_bars( array( 56 'ids' => array( get_the_ID() ),57 'class' => 'tdd_pb_race',58 ) );59 60 107 'ids' => array( get_the_ID() ), 108 'class' => 'tdd_pb_race', 109 ) ); 110 ?> 111 61 112 <?php 62 113 } 63 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 64 129 /* 65 130 * Saves the meta box info for the post 66 131 */ 67 function tdd_pb_metabox_save( $post_id ) {68 if ( isset( $_POST['tdd_pb_color'] ) ) {132 function tdd_pb_metabox_save( $post_id ){ 133 if ( isset( $_POST['tdd_pb_color'] ) ){ 69 134 update_post_meta( $post_id, '_tdd_pb_color', strip_tags( $_POST['tdd_pb_color'] ) ); 70 135 } 71 72 if ( isset( $_POST['tdd_pb_percentage'] ) ){ 73 //remove any percent signs ppl decided to put in 74 $percentage = trim( $_POST['tdd_pb_percentage'], " %" ); 75 update_post_meta( $post_id, '_tdd_pb_percentage', strip_tags( $percentage ) ); 76 } 77 136 137 if ( isset( $_POST['tdd_pb_percentage'] ) ) { 138 $tdd_pb_percentage = tdd_float_number_only( $_POST['tdd_pb_percentage'] ); 139 update_post_meta( $post_id, '_tdd_pb_percentage', $tdd_pb_percentage ); 140 } 141 142 if ( isset( $_POST['tdd_pb_start'] ) ) { 143 $tdd_pb_start = tdd_float_number_only( $_POST['tdd_pb_start'] ); 144 update_post_meta( $post_id, '_tdd_pb_start', $tdd_pb_start ); 145 } 146 147 if ( isset( $_POST['tdd_pb_end'] ) ) { 148 $tdd_pb_end = tdd_float_number_only( $_POST['tdd_pb_end'] ); 149 update_post_meta( $post_id, '_tdd_pb_end', $tdd_pb_end ); 150 } 151 152 if ( isset( $_POST['tdd_pb_input_method'] ) ){ 153 update_post_meta( $post_id, '_tdd_pb_input_method', strip_tags( $_POST['tdd_pb_input_method'] ) ); 154 } 155 156 if ( isset( $_POST['tdd_pb_percentage_display'] ) ){ 157 update_post_meta( $post_id, '_tdd_pb_percentage_display', 'on' ); 158 } else { 159 update_post_meta( $post_id, '_tdd_pb_percentage_display', 'off' ); 160 } 161 162 if ( isset( $_POST['tdd_pb_xofy_display'] ) ){ 163 update_post_meta( $post_id, '_tdd_pb_xofy_display', 'on' ); 164 } else { 165 update_post_meta( $post_id, '_tdd_pb_xofy_display', 'off' ); 166 } 167 168 // $tdd_pb_input_method = get_post_meta( $post->ID, '_tdd_pb_input_method', true ); 169 // $tdd_pb_start = get_post_meta( $post->ID, '_tdd_pb_start', true ); 170 // $tdd_pb_end = get_post_meta( $post->ID, '_tdd_pb_end', true ); 171 // $tdd_pb_percentage_display = get_post_meta( $post->ID, '_tdd_pb_percentage_display', true ); 172 // $tdd_pb_xofy_display = get_post_meta( $post->ID, '_tdd_pb_xofy_display', true ); 173 174 175 78 176 } 79 177 add_action( 'save_post', 'tdd_pb_metabox_save' ); … … 82 180 * Adds custom columns to the Progress Bars view 83 181 */ 84 function set_edit_tdd_pb_columns( $columns) {85 unset($columns['date']);86 return array_merge($columns, 87 array('progress_bar' => 'Progress Bar',88 89 'date' => __('Date'),90 ));91 } 92 add_filter( 'manage_edit-tdd_pb_columns' , 'set_edit_tdd_pb_columns');182 function set_edit_tdd_pb_columns() { 183 ); 184 return array_merge( $columns, 185 'progress_bar' => 'Progress Bar', 186 'shortcode' => 'Shortcode', 187 ), 188 ); 189 } 190 add_filter(); 93 191 94 192 … … 96 194 * Put content in those custom columns 97 195 */ 98 function tdd_pb_custom_columns( $column ) {196 function tdd_pb_custom_columns( $column ){ 99 197 global $post; 100 101 switch ( $column ) {102 103 echo tdd_pb_get_bars( array(198 199 switch ( $column ){ 200 case 'progress_bar': 201 104 202 'ids' => array( $post->ID ), 105 203 'class' => 'tdd_pb_race', 106 204 ) ); 107 205 108 109 110 111 206 break; 207 case 'shortcode': 208 echo '<code>[progress id='. $post->ID .']</code>'; 209 break; 112 210 } 113 211 } … … 118 216 * Normally this would require a hook into save_posts (because it doesn't do it automatically), but we've already done that for the custom meta box info. 119 217 */ 120 function tdd_pb_add_quick_edit( $column_name, $post_type ) {218 function tdd_pb_add_quick_edit( $column_name, $post_type ){ 121 219 if ( $column_name != 'progress_bar' || $post_type != 'tdd_pb' ) return; 122 123 220 ?> 221 124 222 <fieldset class="inline-edit-col-right"> 125 223 <div class="inline-edit-col"> … … 132 230 <select name="tdd_pb_color" id="tdd_pb_color"> 133 231 <?php global $colors; ?> 134 <?php foreach ( $colors as $color=>$label ): ?>232 <?php foreach ($colors as $color=>$label ): ?> 135 233 <option value="<?php echo $color; ?>"><?php echo $label; ?></option> 136 234 <?php endforeach; ?> … … 139 237 </fieldset> 140 238 <?php 141 239 } 142 240 add_action( 'quick_edit_custom_box', 'tdd_pb_add_quick_edit', 20, 2 ); 143 241 … … 148 246 global $wpdb; 149 247 150 //If the incoming post id isn't numeric -- or isn't set, return an error. 151 if ( !is_numeric( $_GET['post_id']) || !isset($_GET['post_id']) ){248 //If the incoming post id isn't numeric -- or isn't set, return an error. 249 if ( !is_numeric({ 152 250 $json = array ( 'error' => 'Post ID not set' ); 153 echo json_encode( $json);251 echo json_encode(); 154 252 die(); 155 253 } 156 254 157 255 //Check for correct permissions, and verify nonce 158 if ( !current_user_can( 'edit_posts' ) || !check_ajax_referer( "tdd_pb_get_{$_GET['post_id']}", 'nonce', false ) ) {256 if ( !current_user_can( 'edit_posts' ) || !check_ajax_referer( "tdd_pb_get_{$_GET['post_id']}", 'nonce', false) ) { 159 257 $json = array ( 'error' => 'Permission Denied', 'GET' => $_GET ); 160 echo json_encode( $json);258 echo json_encode(); 161 259 die(); 162 } 163 164 $tdd_pb_percentage = get_post_meta( $_GET['post_id'], '_tdd_pb_percentage', true ); 260 } 261 262 $tdd_pb_percentage = get_post_meta( $_GET['post_id'], '_tdd_pb_percentage', true ); 165 263 $tdd_pb_color = get_post_meta( $_GET['post_id'], '_tdd_pb_color', true ); 166 264 … … 168 266 'percentage' => $tdd_pb_percentage, 169 267 'color' => $tdd_pb_color 170 171 172 echo json_encode( $json);268 ); 269 270 echo json_encode(); 173 271 die(); 174 272 } … … 177 275 * Add some javascript to feed the correct values to the quick edit screen 178 276 */ 179 function tdd_pb_quick_edit_js() {277 function tdd_pb_quick_edit_js(){ 180 278 global $current_screen; 181 if ( ( $current_screen->id != 'edit-tdd_pb') || ($current_screen->post_type != 'tdd_pb') ) return;182 279 if ( () ) return; 280 ?> 183 281 <script type="text/javascript"> 184 282 function set_inline_tdd_pb( post_id, nonce ){ 185 283 inlineEditPost.revert(); //Calls an internal handler to make all the regular values fix themselves appropriately. 186 284 187 285 var ajaxdata = { 188 286 action: 'tdd_pb_get_custom_values', … … 190 288 post_id: post_id 191 289 } 192 290 193 291 jQuery.getJSON(ajaxurl, ajaxdata, function(response){ 194 292 195 293 //Set the percentage to be correct 196 294 var tdd_pb_percentage = document.getElementById('tdd_pb_percentage'); 197 295 tdd_pb_percentage.value = response.percentage; 198 296 199 //Set "selected" for the right option in the color select list 297 //Set "selected" for the right option in the color select list 200 298 var tdd_pb_color = document.getElementById('tdd_pb_color'); 201 299 jQuery('#tdd_pb_color').val(response.color).attr('selected', true); 202 300 }); 203 301 204 302 } //end set_inline_tdd_pb 205 303 </script> … … 211 309 * Binds the tdd_pb_quick_edit_js to the quick edit button 212 310 */ 213 function tdd_pb_quick_edit_button( $actions, $post ) {311 function tdd_pb_quick_edit_button( $actions, $post ){ 214 312 global $current_screen; 215 if ( ( $current_screen->id != 'edit-tdd_pb') || ($current_screen->post_type != 'tdd_pb') ) return $actions;216 313 if ( () ) return $actions; 314 217 315 $nonce = wp_create_nonce( "tdd_pb_get_{$post->ID}" ); 218 316 219 317 $actions['inline hide-if-no-js'] = '<a href="#" class="editinline" title="'; 220 $actions['inline hide-if-no-js'] .= esc_attr( __( 'Edit this item inline') ). '" ';318 $actions['inline hide-if-no-js'] .= esc_attr( __() ). '" '; 221 319 $actions['inline hide-if-no-js'] .= ' onclick="set_inline_tdd_pb('.$post->ID.', \''.$nonce.'\');">'; 222 $actions['inline hide-if-no-js'] .= __( 'Quick Edit');320 $actions['inline hide-if-no-js'] .= __(); 223 321 $actions['inline hide-if-no-js'] .= '</a>'; 224 322 return $actions; … … 230 328 * View Settings admin page 231 329 */ 232 function tdd_pb_view_settings() {233 $tdd_pb_options = get_option( 'tdd_pb_options');330 function tdd_pb_view_settings(){ 331 ); 234 332 235 333 ?> … … 237 335 <?php screen_icon( 'plugins' ); ?> 238 336 <h2><?php _e( 'TDD Progress Bars', 'tdd_pb' ); ?></h2> 239 337 240 338 <form action="options.php" method="post"> 241 339 <?php settings_fields( 'tdd_pb_options' ); ?> … … 250 348 function tdd_pb_admin_init() { 251 349 register_setting( 'tdd_pb_options', 'tdd_pb_options', 'tdd_pb_options_validate' ); 252 350 253 351 //register Scripts and Styles section & controls 254 352 add_settings_section( 'tdd_pb_sas', __( 'Scripts and Styles', 'tdd_pb' ), 'tdd_pb_admin_sasheader', __FILE__ ); 255 353 add_settings_field( 'animate', __( 'Animate Bars', 'tdd_pb' ), 'tdd_pb_admin_form_animate', __FILE__ , 'tdd_pb_sas' ); 256 add_settings_field( 'default_css', __( 'Use Default CSS', 'tdd_pb' ), 'tdd_pb_admin_form_default_css', __FILE__, 'tdd_pb_sas' );354 add_settings_field( 'default_css', __( 'Use Default CSS', 'tdd_pb' ), 'tdd_pb_admin_form_default_css', __FILE__, 'tdd_pb_sas'); 257 355 258 356 //register Percent section & controls 259 357 add_settings_section( 'tdd_pb_percent', __( 'Percentage Displays', 'tdd_pb' ), 'tdd_pb_admin_percentheader', __FILE__ ); 260 add_settings_field( 'display_percentage', __( 'Display Percent Complete', 'tdd_pb' ), 'tdd_pb_admin_form_perecent_display', __FILE__, 'tdd_pb_percent' );358 add_settings_field( 'display_percentage', __( 'Display ', 'tdd_pb' ), 'tdd_pb_admin_form_perecent_display', __FILE__, 'tdd_pb_percent' ); 261 359 add_settings_field( 'percentage_color', __( 'Color of Percentage Text', 'tdd_pb' ), 'tdd_pb_admin_form_percentage_color', __FILE__, 'tdd_pb_percent' ); 262 360 add_settings_field( 'bar_background_color', __( 'Color of Bar Background', 'tdd_pb' ), 'tdd_pb_admin_form_bar_background_color', __FILE__, 'tdd_pb_percent' ); … … 266 364 267 365 //Scripts & Styles section header 268 function tdd_pb_admin_sasheader() {366 function tdd_pb_admin_sasheader(){ 269 367 _e( "<p>The following two boxes allow you to stop including the animation javascript and the default CSS on each page load. It's highly suggested that you don't turn off the Default CSS option unless you have a replacement in mind. The Animate Bars option can be turned off freely if you'd prefer the bars didn't have that cool animation (or you want to save HTTP requests).</p>", 'tdd_pb' ); 270 368 } 271 369 272 370 //Animate Checkbox 273 function tdd_pb_admin_form_animate() {274 $options = get_option( 'tdd_pb_options');275 $checked = ( $options['animate']) ? ' checked="checked" ' : '';371 function tdd_pb_admin_form_animate(){ 372 $options = get_option(); 373 $checked = () ? ' checked="checked" ' : ''; 276 374 echo "<input name='tdd_pb_options[animate]' id='animate' type='checkbox' ". $checked ."> <br /> "; 277 375 _e( "<small>This script depends on jQuery, so it will ensure that is loaded as well</small>", 'tdd_pb' ); … … 279 377 280 378 //Default CSS 281 function tdd_pb_admin_form_default_css() {282 $options = get_option( 'tdd_pb_options');283 $checked = ( $options['default_css']) ? ' checked="checked" ' : '';379 function tdd_pb_admin_form_default_css(){ 380 $options = get_option(); 381 $checked = () ? ' checked="checked" ' : ''; 284 382 echo "<input name='tdd_pb_options[default_css]' id='default_css' type='checkbox' ".$checked.">"; 285 383 } … … 287 385 288 386 //Percentage displays section header 289 function tdd_pb_admin_percentheader() {290 _e( "<p> By default, the percentage progress is displayed in the bar. This allows you to optionally turn that off and/or set the color of the text</p>", 'tdd_pb' );387 function tdd_pb_admin_percentheader(){ 388 _e( "<p></p>", 'tdd_pb' ); 291 389 } 292 390 293 391 294 392 //Percent Display 295 function tdd_pb_admin_form_perecent_display() {296 $options = get_option( 'tdd_pb_options');297 $checked = ( $options['display_percentage']) ? ' checked="checked" ' : '';393 function tdd_pb_admin_form_perecent_display(){ 394 $options = get_option(); 395 $checked = () ? ' checked="checked" ' : ''; 298 396 echo "<input name='tdd_pb_options[display_percentage]' id='display_percentage' type='checkbox' ". $checked .">"; 299 397 } 300 398 301 399 //percentage_color 302 function tdd_pb_admin_form_percentage_color() {303 $options = get_option( 'tdd_pb_options');400 function tdd_pb_admin_form_percentage_color(){ 401 $options = get_option(); 304 402 _e( "#<input name='tdd_pb_options[percentage_color]' id='percentage_color' type='text' value='{$options['percentage_color']}' maxlength='6' size='6' />", 'tdd_pb' ); 305 403 } 306 404 307 function tdd_pb_admin_form_bar_background_color() {308 $options = get_option( 'tdd_pb_options');405 function tdd_pb_admin_form_bar_background_color(){ 406 $options = get_option(); 309 407 echo "#<input name='tdd_pb_options[bar_background_color]' id='bar_backround_color' type='text' value='{$options['bar_background_color']}' maxlength='6' size='6' />"; 310 408 } 311 409 312 410 //validate 313 function tdd_pb_options_validate( $input ) {314 315 316 317 318 319 411 function tdd_pb_options_validate( $input ){ 412 413 //whitelist checkboxes (add them back in, even if false) 414 $input['display_percentage'] = ( isset( $input['display_percentage'] ) ) ? $input['display_percentage'] : false; 415 $input['animate'] = ( isset( $input['animate'] ) ) ? $input['animate'] : false; 416 $input['default_css'] = ( isset( $input['default_css'] ) ) ? $input['default_css'] : false; 417 320 418 return $input; 321 419 } -
tdd-progress-bar/trunk/readme.txt
r499602 r523224 2 2 Contributors: taylorde 3 3 Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=FEQG5KTTPRRXS 4 Tags: progress, shortcode 5 Requires at least: 3. 2.14 Tags: progress, shortcode 5 Requires at least: 3. 6 6 Tested up to: 3.3.1 7 Stable tag: 0. 3.57 Stable tag: 0. 8 8 9 Configure and display any number of percent-complete progress bars. 9 Configure and display any number of percent-complete progress bars. 10 10 11 11 == Description == … … 17 17 2. Progress Bar management page showing all the colors available 18 18 3. A solo Progress Bar 19 19 20 20 21 Unfortunately screenshots don't really capture how cool these look while animating... … … 24 25 = It doesn't look right.. = 25 26 This project uses some cutting-edge CSS3 to make things look cooler like drop shadow, inner-shadow, border-radius, etc. If it doesn't look right in your browser first, consider upgrading, second: let me know what browser you're using to see if I want to consider support. Things should degrade gracefully for non-cutting edge browsers (although IE6 is still going to look like crap no matter what you do). You're welcome to write your own CSS to override what I've already written (or un-check "Default Styles" on the settings page and roll-yer-own). 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 26 43 27 44 == Installation == … … 44 61 45 62 == Changelog == 63 64 65 66 67 68 46 69 47 70 = 0.3.5 = -
tdd-progress-bar/trunk/tdd-progress-bar.php
r499602 r523224 4 4 Plugin URI: http://github.com/tddewey/tdd-progress 5 5 Description: Manage and display progress bars 6 Version: 0. 3.56 Version: 0. 7 7 Author: Taylor D. Dewey 8 8 Author URI: http://websitesthatdontsuck.com … … 17 17 - display percentage - default=true 18 18 - percentage color - default=#ececec; 19 19 20 20 shortcode options: 21 21 - race height (if multiple ID's involved) 22 22 - width 23 23 24 24 bar specific options: 25 25 - color/graphic 26 26 - percentage (or API call) 27 27 28 28 29 29 @todo: 30 30 make a variety of the colored bars. Assemble into a sprite and work-in above. Only need the width to be long enough to feel random. Blend the seam. 31 31 32 32 Global options page 33 33 34 34 Page to add progress bars. 35 35 - Name 36 36 - Bar style 37 37 - Perecentage / or API call. 38 38 39 39 */ 40 40 … … 62 62 'percentage_color' => 'ececec', 63 63 ); 64 64 65 65 update_option( 'tdd_pb_options', $tdd_pb_options ); 66 66 } … … 126 126 'not_found_in_trash' => __( 'No Progress Bars Found in the Trash', 'tdd_pb' ), 127 127 ); 128 128 129 129 $args = array( 130 130 'labels' => $labels, … … 140 140 add_action( 'init', 'tdd_pb_register_post_type' ); 141 141 142 /* 142 /* 143 143 * Set up admin menus 144 144 */ … … 178 178 'class' => '', 179 179 ), $args ); 180 181 180 181 182 182 //explode "id" and "ids" on their commas separately, then merge the arrays together 183 183 $idarr = explode( ',', $args['id'] ); 184 184 $idsarr = explode( ',', $args['ids'] ); 185 185 $idsarr = array_merge($idarr, $idsarr); 186 186 187 187 //Request some bars 188 188 $return = tdd_pb_get_bars(array( … … 191 191 'class' => $args['class'], 192 192 )); 193 193 194 194 //Return them bars 195 195 return $return; … … 218 218 $tdd_pb_options = get_option( 'tdd_pb_options'); 219 219 220 221 220 //parse incoming arguments against default. 222 221 $args = wp_parse_args( $args, $defaults ); 223 222 224 225 223 //Filter the array to ensure we're getting things that look like integers. Will also filter out blank array items (i.e. '' ) 226 224 $idsarr = array_filter( $args['ids'], 'is_numeric' ); … … 231 229 //Set up our global container 232 230 $return = '<div class="tdd_pb_global_container '.$race.' '.$args['class'].'" style="width:'.strip_tags( $args['width'] ).'">'; 233 231 234 232 //If there are no ids to display, this is kind of a moot proccess - so let's say so: 235 233 if ( count( $idsarr ) <= 0 ){ … … 237 235 return $return; 238 236 } 239 237 240 238 //Setup a new WP_Query for our progress bars. 241 239 $tdd_pb_query = new WP_Query(); … … 244 242 'posts_per_page' => -1, 245 243 'post__in' => $idsarr, 246 'meta_key' => '_tdd_pb_percentage' 244 'no_found_rows' => true, 245 // 'meta_key' => '_tdd_pb_percentage' //Used to be this was the only, and required key. Is no longer the case... 247 246 )); 248 247 … … 252 251 return $return; 253 252 } 254 253 255 254 while ( $tdd_pb_query->have_posts() ): $tdd_pb_query->the_post(); 256 255 $percentage = strip_tags( get_post_meta( get_the_ID(), '_tdd_pb_percentage', true ) ); 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 257 271 $color = strip_tags( get_post_meta( get_the_ID(), '_tdd_pb_color', true ) ); 258 272 //if no color, define a default 259 273 $color = (!$color) ? $args['default_color'] : 'tdd_pb_'.$color; 260 $return .= '<div title="'.get_the_title() .': '.$percentage.'%" class="tdd_pb_bar_container" style="background-color: #'. $tdd_pb_options["bar_background_color"] .'" role="progressbar" aria-valuenow="'.$percentage.'" aria-valuemax="100" aria-valuemin="0">'; 261 if ($tdd_pb_options['display_percentage']){ 262 $return .= '<div class="tdd_pb_numbers" style="color: #'.$tdd_pb_options["percentage_color"].'">'. $percentage .'%</div>'; 263 } 264 $return .= '<div class="tdd_pb_bar '. $color .'" style="width:'. $percentage .'%"></div></div>'; 265 274 $return .= '<div title="'.get_the_title() .': '.$calcpercentage.'%" class="tdd_pb_bar_container" style="background-color: #'. $tdd_pb_options["bar_background_color"] .'" role="progressbar" aria-valuenow="'.$calcpercentage.'" aria-valuemax="100" aria-valuemin="0">'; 275 if ($tdd_pb_options['display_percentage']): 276 $return .= '<div class="tdd_pb_numbers" style="color: #'.$tdd_pb_options["percentage_color"].'">'; 277 278 if ( $percentage_display == 'on' || $percentage_display === '' ){ 279 $return .= $calcpercentage .'%'; 280 } 281 282 if ( $xofy_display == 'on' ){ 283 $return .=' ' . $start . ' ' . __( 'of', 'tdd_pb' ) . ' ' . $end; 284 } 285 286 $return .='</div>'; 287 endif; 288 $return .= '<div class="tdd_pb_bar '. $color .'" style="width:'. $calcpercentage .'%"></div></div>'; 289 266 290 endwhile; 267 291
Note: See TracChangeset
for help on using the changeset viewer.