Changeset 43729 for branches/5.0/src/wp-includes/taxonomy.php
- Timestamp:
- 10/15/2018 11:45:16 AM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/5.0/src/wp-includes/taxonomy.php
r43510 r43729 1136 1136 */ 1137 1137 function add_term_meta( $term_id, $meta_key, $meta_value, $unique = false ) { 1138 // Bail if term meta table is not installed.1139 if ( get_option( 'db_version' ) < 34370 ) {1140 return false;1141 }1142 1143 1138 if ( wp_term_is_shared( $term_id ) ) { 1144 1139 return new WP_Error( 'ambiguous_term_id', __( 'Term meta cannot be added to terms that are shared between taxonomies.'), $term_id ); 1145 1140 } 1146 1141 1147 $added = add_metadata( 'term', $term_id, $meta_key, $meta_value, $unique ); 1148 1149 // Bust term query cache. 1150 if ( $added ) { 1151 wp_cache_set( 'last_changed', microtime(), 'terms' ); 1152 } 1153 1154 return $added; 1142 return add_metadata( 'term', $term_id, $meta_key, $meta_value, $unique ); 1155 1143 } 1156 1144 … … 1166 1154 */ 1167 1155 function delete_term_meta( $term_id, $meta_key, $meta_value = '' ) { 1168 // Bail if term meta table is not installed. 1169 if ( get_option( 'db_version' ) < 34370 ) { 1170 return false; 1171 } 1172 1173 $deleted = delete_metadata( 'term', $term_id, $meta_key, $meta_value ); 1174 1175 // Bust term query cache. 1176 if ( $deleted ) { 1177 wp_cache_set( 'last_changed', microtime(), 'terms' ); 1178 } 1179 1180 return $deleted; 1156 return delete_metadata( 'term', $term_id, $meta_key, $meta_value ); 1181 1157 } 1182 1158 … … 1193 1169 */ 1194 1170 function get_term_meta( $term_id, $key = '', $single = false ) { 1195 // Bail if term meta table is not installed.1196 if ( get_option( 'db_version' ) < 34370 ) {1197 return false;1198 }1199 1200 1171 return get_metadata( 'term', $term_id, $key, $single ); 1201 1172 } … … 1218 1189 */ 1219 1190 function update_term_meta( $term_id, $meta_key, $meta_value, $prev_value = '' ) { 1220 // Bail if term meta table is not installed.1221 if ( get_option( 'db_version' ) < 34370 ) {1222 return false;1223 }1224 1225 1191 if ( wp_term_is_shared( $term_id ) ) { 1226 1192 return new WP_Error( 'ambiguous_term_id', __( 'Term meta cannot be added to terms that are shared between taxonomies.'), $term_id ); 1227 1193 } 1228 1194 1229 $updated = update_metadata( 'term', $term_id, $meta_key, $meta_value, $prev_value ); 1230 1231 // Bust term query cache. 1232 if ( $updated ) { 1233 wp_cache_set( 'last_changed', microtime(), 'terms' ); 1234 } 1235 1236 return $updated; 1195 return update_metadata( 'term', $term_id, $meta_key, $meta_value, $prev_value ); 1237 1196 } 1238 1197 … … 1249 1208 */ 1250 1209 function update_termmeta_cache( $term_ids ) { 1251 // Bail if term meta table is not installed.1252 if ( get_option( 'db_version' ) < 34370 ) {1253 return;1254 }1255 1256 1210 return update_meta_cache( 'term', $term_ids ); 1257 1211 } … … 1268 1222 */ 1269 1223 function has_term_meta( $term_id ) { 1270 // Bail if term meta table is not installed.1271 if ( get_option( 'db_version' ) < 34370) {1272 return false;1224 $check = wp_check_term_meta_support_prefilter( null ); 1225 if ( null !== $check ) { 1226 return $check; 1273 1227 } 1274 1228 … … 4342 4296 return $parent; 4343 4297 } 4298 4299 /** 4300 * Sets the last changed time for the 'terms' cache group. 4301 * 4302 * @since 5.0.0 4303 */ 4304 function wp_cache_set_terms_last_changed() { 4305 wp_cache_set( 'last_changed', microtime(), 'terms' ); 4306 } 4307 4308 /** 4309 * Aborts calls to term meta if it is not supported. 4310 * 4311 * @since 5.0.0 4312 * 4313 * @param mixed $check Skip-value for whether to proceed term meta function execution. 4314 * @return mixed Original value of $check, or false if term meta is not supported. 4315 */ 4316 function wp_check_term_meta_support_prefilter( $check ) { 4317 if ( get_option( 'db_version' ) < 34370 ) { 4318 return false; 4319 } 4320 4321 return $check; 4322 }
Note: See TracChangeset
for help on using the changeset viewer.