Changeset 2848034
- Timestamp:
- 01/13/2023 03:47:51 PM (3 years ago)
- Location:
- gravitywp-count
- Files:
-
- 4 added
- 2 edited
-
tags/0.9.9 (added)
-
tags/0.9.9/LICENSE (added)
-
tags/0.9.9/gravitywp-count.php (added)
-
tags/0.9.9/readme.txt (added)
-
trunk/gravitywp-count.php (modified) (10 diffs)
-
trunk/readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
gravitywp-count/trunk/gravitywp-count.php
r2734660 r2848034 5 5 * Description: Adds a shortcode to count, filter and display Gravity Forms entries or the total of a number field in multiple entries. 6 6 * Author: GravityWP 7 * Version: 0.9. 87 * Version: 0.9.9 8 8 * Author URI: https://gravitywp.com/add-on/count/ 9 9 * License: GPL2 … … 12 12 if ( class_exists( 'GFForms' ) ) { 13 13 14 /** 15 * gravitywp_count_func. 16 * 17 * @param array<mixed> $atts 18 * @param string|null $content Default: null 19 * @return string 20 */ 14 21 function gravitywp_count_func( $atts, $content = null ) { 15 22 $atts = shortcode_atts( … … 145 152 $search_criteria['field_filters'][] = array( 146 153 'key' => 'is_starred', 147 'value' => true,154 'value' => 1, 148 155 ); 149 156 } … … 151 158 $search_criteria['field_filters'][] = array( 152 159 'key' => 'is_starred', 153 'value' => false,160 'value' => 0, 154 161 ); 155 162 } … … 158 165 $search_criteria['field_filters'][] = array( 159 166 'key' => 'is_read', 160 'value' => true,167 'value' => 1, 161 168 ); 162 169 } … … 164 171 $search_criteria['field_filters'][] = array( 165 172 'key' => 'is_read', 166 'value' => false,173 'value' => 0, 167 174 ); 168 175 } … … 171 178 if ( $is_approved === 'yes' ) { 172 179 $search_criteria['field_filters'][] = array( 173 'key' => GravityView_Entry_Approval::meta_key,174 'value' => GravityView_Entry_Approval_Status::APPROVED,180 'key' => 'is_approved', // GravityView_Entry_Approval::meta_key. 181 'value' => 1, // GravityView_Entry_Approval_Status::APPROVED. 175 182 ); 176 183 } 177 184 if ( $is_approved === 'no' ) { 178 185 $search_criteria['field_filters'][] = array( 179 'key' => GravityView_Entry_Approval::meta_key,186 'key' => 'is_approved', // GravityView_Entry_Approval::meta_key. 180 187 'is_approved', 181 'value' => GravityView_Entry_Approval_Status::DISAPPROVED,188 'value' => 2, // GravityView_Entry_Approval_Status::DISAPPROVED. 182 189 ); 183 190 } … … 232 239 $formids = explode( ',', $formids ); 233 240 $countentries = GFAPI::count_entries( $formids, $search_criteria ); 234 $raw_value = $add_number+ $countentries;241 $raw_value = floatval( $add_number ) + $countentries; 235 242 236 243 $sorting = null; … … 250 257 $entries = GFAPI::get_entries( $formids, $search_criteria, $sorting, $paging ); 251 258 252 $raw_value = $add_number; 259 if ( is_wp_error( $entries ) ) { 260 return 'ERROR'; 261 } 262 263 $raw_value = floatval( $add_number ); 253 264 254 265 // Loop through each entry and add number to count. 255 266 for ( $row = 0; $row < $countentries; $row ++ ) { 256 $raw_value += is_numeric( $entries[ $row ][ $number_field ] ) ? $entries[ $row ][ $number_field ]: 0;267 $raw_value += is_numeric( $entries[ $row ][ $number_field ] ) ? floatval( $entries[ $row ][ $number_field ] ) : 0; 257 268 } 258 269 // Apply multiplier to value. 259 $raw_value *= $multiply;270 $raw_value *= floatval( $multiply ); 260 271 // Format raw value. 261 272 $formatted_value = number_format( $raw_value, (int) $decimals, $dec_point, $thousands_sep ); 262 273 } else { 263 274 // Apply multiplier to value. 264 $raw_value *= $multiply;275 $raw_value *= floatval( $multiply ); 265 276 // Format raw value. 266 $formatted_value = number_format( $raw_value, '0', '.', $thousands_sep );277 $formatted_value = number_format( $raw_value, 0, '.', $thousands_sep ); 267 278 } 268 279 … … 270 281 * Apply filter for result from count. 271 282 * 272 * @param str $formatted_value273 * @param str$raw_value274 * @param array $formids275 * @return str 283 * @param string $formatted_value 284 * @param float $raw_value 285 * @param array<string> $formids 286 * @return string 276 287 */ 277 278 288 return apply_filters( 'gwp_count_result', $formatted_value, $raw_value, $formids ); 279 289 } -
gravitywp-count/trunk/readme.txt
r2734660 r2848034 4 4 Tags: gravity forms, number field, count, form, forms, gravity form 5 5 Requires at least: 3.0.1 6 Tested up to: 5.97 Stable tag: 0.9. 86 Tested up to: 6.1 7 Stable tag: 0.9.9 8 8 License: GPLv2 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 32 32 33 33 == Changelog == 34 35 = 0.9.9 = 36 * PHP 8+ compatibility for calculations. 34 37 35 38 = 0.9.8 =
Note: See TracChangeset
for help on using the changeset viewer.