Make WordPress Core

Changeset 58448

Timestamp:
06/20/2024 04:28:55 PM (7 weeks ago)
Author:
hellofromTonya
Message:

Editor (Font Library): Store font subdirectory in post meta.

Stores the font file sub-directory in the wp_font_face post meta. Similar to attachments, only the portion of the path relative to the base directory is stored.

This ensures the files can be deleted alongside their post on sites using a plugin to store font files in sub-directories. Previously running such a plugin would result in the files remaining on the file system post delete.

Reviewed by hellofromTonya.
Merges [58353] to the 6.5 branch.

Props costdev, grantmkin, peterwilsoncc.
Fixes #61297.

Location:
branches/6.5
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/6.5

  • branches/6.5/src/wp-includes/fonts.php

    r57907 r58448  
    229229
    230230    $font_files = get_post_meta( $post_id, '_wp_font_face_file', false );
    231     $font_dir   = wp_get_font_dir()['path'];
     231    $font_dir   = ;
    232232
    233233    foreach ( $font_files as $font_file ) {
  • branches/6.5/src/wp-includes/rest-api/endpoints/class-wp-rest-font-faces-controller.php

    r57879 r58448  
    917917
    918918        $fonts_dir = wp_get_font_dir();
    919         if ( str_starts_with( $new_path, $fonts_dir['path'] ) ) {
    920             $new_path = str_replace( $fonts_dir, '', $new_path );
     919        if ( str_starts_with( $new_path, $fonts_dir[''] ) ) {
     920            $new_path = str_replace( $fonts_dir, '', $new_path );
    921921            $new_path = ltrim( $new_path, '/' );
    922922        }
  • branches/6.5/tests/phpunit/tests/fonts/font-library/wpRestFontFacesController.php

    r57548 r58448  
    395395
    396396        $this->assertSame( self::$font_family_id, $data['parent'], 'The returned parent id should match the font family id.' );
     397
     398
     399
     400
     401
     402
     403
     404
     405
     406
     407
     408
     409
     410
     411
     412
     413
     414
     415
     416
     417
     418
     419
     420
     421
     422
     423
     424
     425
     426
     427
     428
     429
     430
     431
     432
     433
     434
     435
     436
     437
     438
     439
     440
     441
     442
     443
     444
     445
     446
     447
     448
     449
     450
     451
     452
     453
     454
     455
     456
     457
     458
     459
     460
     461
     462
     463
    397464    }
    398465
     
    10491116        $file_meta = get_post_meta( $font_face_id, '_wp_font_face_file' );
    10501117
    1051         foreach ( $src_attributes as $src_attribute ) {
    1052             $file_name = basename( $src_attribute );
    1053             $this->assertContains( $file_name, $file_meta, 'The uploaded font file path should be saved in the post meta.' );
     1118        foreach ( $e ) {
     1119            $;
     1120            $this->asserted in the post meta.' );
    10541121        }
    10551122    }
Note: See TracChangeset for help on using the changeset viewer.