Changeset 43982 for trunk/src/wp-includes/taxonomy.php
- Timestamp:
- 12/12/2018 03:02:00 AM (7 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/5.0 merged: 43729
- Property svn:mergeinfo changed
-
trunk/src/wp-includes/taxonomy.php
r43631 r43982 1212 1212 */ 1213 1213 function add_term_meta( $term_id, $meta_key, $meta_value, $unique = false ) { 1214 // Bail if term meta table is not installed.1215 if ( get_option( 'db_version' ) < 34370 ) {1216 return false;1217 }1218 1219 1214 if ( wp_term_is_shared( $term_id ) ) { 1220 1215 return new WP_Error( 'ambiguous_term_id', __( 'Term meta cannot be added to terms that are shared between taxonomies.' ), $term_id ); 1221 1216 } 1222 1217 1223 $added = add_metadata( 'term', $term_id, $meta_key, $meta_value, $unique ); 1224 1225 // Bust term query cache. 1226 if ( $added ) { 1227 wp_cache_set( 'last_changed', microtime(), 'terms' ); 1228 } 1229 1230 return $added; 1218 return add_metadata( 'term', $term_id, $meta_key, $meta_value, $unique ); 1231 1219 } 1232 1220 … … 1242 1230 */ 1243 1231 function delete_term_meta( $term_id, $meta_key, $meta_value = '' ) { 1244 // Bail if term meta table is not installed. 1245 if ( get_option( 'db_version' ) < 34370 ) { 1246 return false; 1247 } 1248 1249 $deleted = delete_metadata( 'term', $term_id, $meta_key, $meta_value ); 1250 1251 // Bust term query cache. 1252 if ( $deleted ) { 1253 wp_cache_set( 'last_changed', microtime(), 'terms' ); 1254 } 1255 1256 return $deleted; 1232 return delete_metadata( 'term', $term_id, $meta_key, $meta_value ); 1257 1233 } 1258 1234 … … 1269 1245 */ 1270 1246 function get_term_meta( $term_id, $key = '', $single = false ) { 1271 // Bail if term meta table is not installed.1272 if ( get_option( 'db_version' ) < 34370 ) {1273 return false;1274 }1275 1276 1247 return get_metadata( 'term', $term_id, $key, $single ); 1277 1248 } … … 1294 1265 */ 1295 1266 function update_term_meta( $term_id, $meta_key, $meta_value, $prev_value = '' ) { 1296 // Bail if term meta table is not installed.1297 if ( get_option( 'db_version' ) < 34370 ) {1298 return false;1299 }1300 1301 1267 if ( wp_term_is_shared( $term_id ) ) { 1302 1268 return new WP_Error( 'ambiguous_term_id', __( 'Term meta cannot be added to terms that are shared between taxonomies.' ), $term_id ); 1303 1269 } 1304 1270 1305 $updated = update_metadata( 'term', $term_id, $meta_key, $meta_value, $prev_value ); 1306 1307 // Bust term query cache. 1308 if ( $updated ) { 1309 wp_cache_set( 'last_changed', microtime(), 'terms' ); 1310 } 1311 1312 return $updated; 1271 return update_metadata( 'term', $term_id, $meta_key, $meta_value, $prev_value ); 1313 1272 } 1314 1273 … … 1325 1284 */ 1326 1285 function update_termmeta_cache( $term_ids ) { 1327 // Bail if term meta table is not installed.1328 if ( get_option( 'db_version' ) < 34370 ) {1329 return;1330 }1331 1332 1286 return update_meta_cache( 'term', $term_ids ); 1333 1287 } … … 1344 1298 */ 1345 1299 function has_term_meta( $term_id ) { 1346 // Bail if term meta table is not installed.1347 if ( get_option( 'db_version' ) < 34370) {1348 return false;1300 $check = wp_check_term_meta_support_prefilter( null ); 1301 if ( null !== $check ) { 1302 return $check; 1349 1303 } 1350 1304 … … 4633 4587 return $taxonomy->publicly_queryable; 4634 4588 } 4589 4590 /** 4591 * Sets the last changed time for the 'terms' cache group. 4592 * 4593 * @since 5.0.0 4594 */ 4595 function wp_cache_set_terms_last_changed() { 4596 wp_cache_set( 'last_changed', microtime(), 'terms' ); 4597 } 4598 4599 /** 4600 * Aborts calls to term meta if it is not supported. 4601 * 4602 * @since 5.0.0 4603 * 4604 * @param mixed $check Skip-value for whether to proceed term meta function execution. 4605 * @return mixed Original value of $check, or false if term meta is not supported. 4606 */ 4607 function wp_check_term_meta_support_prefilter( $check ) { 4608 if ( get_option( 'db_version' ) < 34370 ) { 4609 return false; 4610 } 4611 4612 return $check; 4613 }
Note: See TracChangeset
for help on using the changeset viewer.