Changeset 3310870
- Timestamp:
- 06/13/2025 07:14:26 AM (10 months ago)
- Location:
- wpjam-basic/trunk
- Files:
-
- 2 edited
-
includes/class-wpjam-args.php (modified) (4 diffs)
-
wpjam-basic.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
wpjam-basic/trunk/includes/class-wpjam-args.php
r3310758 r3310870 550 550 if($args){ 551 551 if(is_array($args[0])){ 552 $output = $args[1] ?? null; 552 553 $args = $args[0]; 553 $output = $args[1] ?? null;554 554 }else{ 555 555 $args = [$args[0]=> $args[1]]; … … 932 932 foreach($items as $i => $item){ 933 933 if($args['calc']){ 934 $item = $this->calc($item); 934 if(is_array($args['calc']) && !empty($args['key']) && isset($args['calc'][$item[$args['key']]])){ 935 $item = array_merge($item, $args['calc'][$item[$args['key']]]); 936 }else{ 937 $item = $this->calc($item); 938 } 935 939 } 936 940 … … 1063 1067 } 1064 1068 1065 public function accumulate($results, $items, $group=''){ 1069 public function accumulate($results, $items, $args=[]){ 1070 $field = wpjam_pull($args, 'field'); 1071 $calc = wpjam_pull($args, 'calc'); 1072 $items = wp_is_numeric_array($items ) ? $items : [$items]; 1073 1066 1074 foreach($items as $item){ 1067 $item = $ this->calc($item);1068 $value = $ group ? ($item[$group] ?? '') : '__';1075 $item = $calc ? $this->calc($item) : $item; 1076 $value = $field ? ($item[$field] ?? '') : '__'; 1069 1077 $keys = $this->sumable ? array_keys(array_filter($this->sumable, fn($v)=> $v == 1)) : []; 1070 1078 … … 1078 1086 } 1079 1087 1080 return $ group? $results : $results[$value];1088 return $field ? $results : $results[$value]; 1081 1089 } 1082 1090 -
wpjam-basic/trunk/wpjam-basic.php
r3310758 r3310870 4 4 Plugin URI: https://blog.wpjam.com/project/wpjam-basic/ 5 5 Description: WPJAM 常用的函数和接口,屏蔽所有 WordPress 不常用的功能。 6 Version: 6.8.0. 26 Version: 6.8.0.3 7 7 Requires at least: 6.6 8 8 Tested up to: 6.8
Note: See TracChangeset
for help on using the changeset viewer.