Ticket #5377: defer-taxonomy-counts-r6340.patch
| File defer-taxonomy-counts-r6340.patch, 1.8 KB (added by , 19 years ago) |
|---|
-
wordpress/wp-includes/taxonomy.php
1318 1318 return array('term_id' => $term_id, 'term_taxonomy_id' => $tt_id); 1319 1319 } 1320 1320 1321 // enable or disable term count deferring 1322 // if no value is supplied, the current value of the defer setting is returned 1323 function wp_defer_term_counting($defer=NULL) { 1324 static $_defer = false; 1325 1326 if ( is_bool($defer) ) { 1327 $_defer = $defer; 1328 // flush any deferred counts 1329 if ( !$defer ) 1330 wp_update_term_count( NULL, NULL, true ); 1331 } 1332 1333 return $_defer; 1334 } 1335 1321 1336 /** 1322 1337 * wp_update_term_count() - Updates the amount of terms in taxonomy 1323 1338 * … … 1335 1350 * @param string $taxonomy The context of the term. 1336 1351 * @return bool If no terms will return false, and if successful will return true. 1337 1352 */ 1338 function wp_update_term_count( $terms, $taxonomy ) {1339 global $wpdb;1353 function wp_update_term_count( $terms, $taxonomy, $do_deferred=false ) { 1354 static $_deferred = array(); 1340 1355 1356 if ( $do_deferred ) { 1357 foreach ( array_keys($_deferred) as $tax ) { 1358 wp_update_term_count_now( $_deferred[$tax], $tax ); 1359 unset( $_deferred[$tax] ); 1360 } 1361 } 1362 1341 1363 if ( empty($terms) ) 1342 1364 return false; 1343 1365 1344 1366 if ( !is_array($terms) ) 1345 1367 $terms = array($terms); 1346 1368 1369 if ( wp_defer_term_counting() ) { 1370 if ( !isset($_deferred[$taxonomy]) ) 1371 $_deferred[$taxonomy] = array(); 1372 $_deferred[$taxonomy] = array_unique( array_merge($_deferred[$taxonomy], $terms) ); 1373 return true; 1374 } 1375 1376 return wp_update_term_count_now( $terms, $taxonomy ); 1377 } 1378 1379 function wp_update_term_count_now( $terms, $taxonomy ) { 1380 global $wpdb; 1381 1347 1382 $terms = array_map('intval', $terms); 1348 1383 1349 1384 $taxonomy = get_taxonomy($taxonomy);
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)