Ticket #38323: 38323-improved-filter.diff
File 38323-improved-filter.diff, 1.9 KB (added by , 5 years ago) |
---|
-
src/wp-includes/meta.php
1298 1298 } 1299 1299 1300 1300 /** 1301 * /** 1301 1302 * Returns the object subtype for a given object ID of a specific type. 1302 1303 * 1303 1304 * @since 5.0.0 … … 1309 1310 function get_object_subtype( $object_type, $object_id ) { 1310 1311 $object_id = (int) $object_id; 1311 1312 $object_subtype = ''; 1312 1313 $object = null; 1313 1314 switch ( $object_type ) { 1314 1315 case 'post': 1315 $post_type = get_post_type( $object_id ); 1316 $object = get_post( $object_id ); 1317 if ( ! $object instanceof WP_Post ) { 1318 break; 1319 } 1316 1320 1317 if ( ! empty( $post_type ) ) { 1318 $object_subtype = $post_type; 1319 } 1321 $object_subtype = $object->post_type; 1320 1322 break; 1321 1323 1322 1324 case 'term': 1323 $ term= get_term( $object_id );1324 if ( ! $ terminstanceof WP_Term ) {1325 $object = get_term( $object_id ); 1326 if ( ! $object instanceof WP_Term ) { 1325 1327 break; 1326 1328 } 1327 1329 1328 $object_subtype = $ term->taxonomy;1330 $object_subtype = $object->taxonomy; 1329 1331 break; 1330 1332 1331 1333 case 'comment': 1332 $ comment = get_comment( $object_id );1333 if ( ! $ comment ) {1334 $object = get_comment( $object_id ); 1335 if ( ! $object ) { 1334 1336 break; 1335 1337 } 1336 1338 … … 1338 1340 break; 1339 1341 1340 1342 case 'user': 1341 $ user= get_user_by( 'id', $object_id );1342 if ( ! $ user) {1343 $object = get_user_by( 'id', $object_id ); 1344 if ( ! $object ) { 1343 1345 break; 1344 1346 } 1345 1347 … … 1357 1359 * 1358 1360 * @param string $object_subtype Empty string to override. 1359 1361 * @param int $object_id ID of the object to get the subtype for. 1362 * @param WP_Post|WP_Term|WP_Comment|WP_User|null $object The object to get the subtype for 1360 1363 */ 1361 return apply_filters( "get_object_subtype_{$object_type}", $object_subtype, $object_id );1364 return apply_filters( "get_object_subtype_{$object_type}", $object_subtype, $object_id, $object ); 1362 1365 }