@@ -367,6 +367,10 @@ function _peh_get_object_by_wp_migrated_legacy_alias_db( $slug ) {
367
367
'name ' => 'node ' ,
368
368
'replace ' => 'node/ ' ,
369
369
),
370
+ array (
371
+ 'name ' => 'file ' ,
372
+ 'replace ' => 'file/ ' ,
373
+ ),
370
374
array (
371
375
'name ' => 'taxonomy ' ,
372
376
'replace ' => 'taxonomy/term/ ' ,
@@ -388,8 +392,9 @@ function _peh_get_object_by_wp_migrated_legacy_alias_db( $slug ) {
388
392
// Return only if something is found.
389
393
if ( $ id && $ type ) {
390
394
391
- $ wp_id = '' ;
392
- $ wp_type = '' ;
395
+ $ wp_id = '' ;
396
+ $ wp_type = '' ;
397
+ $ wp_meta_key = 'nid ' ;
393
398
394
399
// Convert type from node to post_type if needed.
395
400
switch ( $ type ) {
@@ -402,6 +407,11 @@ function _peh_get_object_by_wp_migrated_legacy_alias_db( $slug ) {
402
407
$ wp_type = 'post ' ;
403
408
break ;
404
409
410
+ case 'media ' :
411
+ $ wp_type = 'segment ' ;
412
+ $ wp_meta_key = 'fid ' ;
413
+ break ;
414
+
405
415
default :
406
416
$ wp_type = $ type ;
407
417
break ;
@@ -410,15 +420,20 @@ function _peh_get_object_by_wp_migrated_legacy_alias_db( $slug ) {
410
420
// Get WP Posts by node id.
411
421
$ s_args = array (
412
422
'post_type ' => $ wp_type ,
413
- 'meta_key ' => ' nid ' ,
423
+ 'meta_key ' => $ wp_meta_key ,
414
424
'meta_value ' => $ id ,
425
+ 'fields ' => 'ids ' ,
426
+ 'posts_per_page ' => 1 ,
427
+ 'no_found_rows ' => true ,
428
+ 'update_post_meta_cache ' => false ,
429
+ 'update_post_term_cache ' => false
415
430
);
416
431
417
432
$ posts = get_posts ( $ s_args );
418
433
419
434
if ( $ posts && ! is_wp_error ( $ posts ) ) {
420
435
421
- $ wp_id = $ posts [0 ]-> ID ;
436
+ $ wp_id = $ posts [0 ];
422
437
}
423
438
424
439
if ( $ wp_id && $ wp_type ) {
@@ -435,6 +450,7 @@ function _peh_get_object_by_wp_migrated_legacy_alias_db( $slug ) {
435
450
return false ;
436
451
}
437
452
453
+
438
454
/**
439
455
* Get post by slug.
440
456
*
@@ -448,6 +464,9 @@ function _peh_get_object_by_slug( $slug, $extra_args = array() ) {
448
464
'name ' => $ slug ,
449
465
'post_status ' => 'publish ' ,
450
466
'posts_per_page ' => 1 ,
467
+ 'no_found_rows ' => true ,
468
+ 'update_post_meta_cache ' => false ,
469
+ 'update_post_term_cache ' => false
451
470
);
452
471
453
472
if ( $ extra_args ) {
0 commit comments