Changeset 2055658
- Timestamp:
- 03/22/2019 09:13:57 PM (7 years ago)
- Location:
- makemydonation-imo/trunk
- Files:
-
- 2 edited
-
mmdimo.php (modified) (1 diff)
-
template.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
makemydonation-imo/trunk/mmdimo.php
r2052722 r2055658 245 245 } 246 246 } 247 } 248 249 function mmdimo_load_donations_by_post( $post_id = 0, $count = FALSE ) { 250 $post = get_post( $post ); 251 $id = isset( $post->ID ) ? $post->ID : 0; 252 $now = time(); 253 $expires = 60 * 60; 254 255 $meta_id = $count ? 'mmdimo_donations_count' : 'mmdimo_donations'; 256 257 $donations = array( 258 'content' => '' 259 ); 260 261 $cached_donations = get_post_meta( $id, $meta_id, TRUE ); 262 263 if ( $cached_donations && isset($cached_donations['expires']) && $cached_donations['expires'] > $now ) { 264 $donations = $cached_donations; 265 } 266 else { 267 $mmdimo_case = get_post_meta( $id, 'mmdimo_case', TRUE ); 268 $case_id = $mmdimo_case && isset( $mmdimo_case['id'] ) ? $mmdimo_case['id'] : NULL; 269 require_once( MMDIMO_PLUGIN_DIR . '/api.php' ); 270 271 if ( $case_id && $content = mmdimo_api_case_donations_load($case_id, $count) ) { 272 273 $donations = array( 274 'content' => $content, 275 'expires' => $now + $expires 276 ); 277 278 update_post_meta( $id, $meta_id, $donations ); 279 } 280 } 281 282 283 return $donations['content']; 247 284 } 248 285 -
makemydonation-imo/trunk/template.php
r2055657 r2055658 152 152 $post = get_post( $post ); 153 153 $id = isset( $post->ID ) ? $post->ID : 0; 154 $mmdimo_case = get_post_meta( $id, 'mmdimo_case', TRUE ); 155 156 require_once( MMDIMO_PLUGIN_DIR . '/api.php' ); 157 $donations_count = mmdimo_api_case_donations_load($mmdimo_case['id'], TRUE); 154 155 $donations_count = mmdimo_load_donations_by_post($id, TRUE); 158 156 159 157 if ( $post->ID && $donations_count['total'] ) { … … 196 194 $post = get_post( $post ); 197 195 $id = isset( $post->ID ) ? $post->ID : 0; 198 $mmdimo_case = get_post_meta( $id, 'mmdimo_case', TRUE ); 199 200 require_once( MMDIMO_PLUGIN_DIR . '/api.php' ); 201 $donations = mmdimo_api_case_donations_load($mmdimo_case['id']); 196 197 $donations = mmdimo_load_donations_by_post($id); 202 198 203 199 $default_display_attributes = array(
Note: See TracChangeset
for help on using the changeset viewer.