Make WordPress Core


Ignore:
Timestamp:
03/26/2024 09:25:20 AM (2 years ago)
Author:
swissspidy
Message:

Editor: Relocate font files uploads to the uploads directory.

Relocate the upload of font files uploaded via the Font Library feature to the wp-content/uploads/fonts (or multisite equivalent) directory.

This accounts for immutable file systems in which directories are unable to be created within wp-content and deploy processes which require special consideration of the uploads directory to ensure it remains persistent between deploys.

Reviewed by davidbaumwald.
Merges [57878] to the 6.5 branch.

Props azaozz, burnuser, cbirdsong, christopherplus, costdev, davidbaumwald, desrosj, elrae, euthelup, get_dave, grantmkin, hellofromtonya, janthiel, jazzs3quence, johnbillion, jorbin, justlevine, kraftner, matveb, mcsf, mmaattiiaass, nico23, peterwilsoncc, priethor, rmccue, samuelsidler, swissspidy, youknowriad.
Fixes #60845.

Location:
branches/6.5
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/6.5

  • branches/6.5/tests/phpunit/tests/fonts/font-library/wpFontsDir.php

    r57879 r57880  
    1616        public static function set_up_before_class() {
    1717                parent::set_up_before_class();
     18                $upload_dir = wp_get_upload_dir();
    1819
    1920                static::$dir_defaults = array(
    20                         'path'    => path_join( WP_CONTENT_DIR, 'fonts' ),
    21                         'url'     => content_url( 'fonts' ),
     21                        'path'    => untrailingslashit( $upload_dir['basedir'] ) . '/fonts',
     22                        'url'     => untrailingslashit( $upload_dir['baseurl'] ) . '/fonts',
    2223                        'subdir'  => '',
    23                         'basedir' => path_join( WP_CONTENT_DIR, 'fonts' ),
    24                         'baseurl' => content_url( 'fonts' ),
     24                        'basedir' => untrailingslashit( $upload_dir['basedir'] ) . '/fonts',
     25                        'baseurl' => untrailingslashit( $upload_dir['baseurl'] ) . '/fonts',
    2526                        'error'   => false,
    2627                );
    2728        }
    2829
     30        /**
     31         * Ensure the font directory is correct.
     32         */
    2933        public function test_fonts_dir() {
    3034                $font_dir = wp_get_font_dir();
     
    3337        }
    3438
     39        /**
     40         * Ensure that the fonts directory is correct for a multisite installation.
     41         *
     42         * The main site will use the default location and others will follow a pattern of  `/sites/{$blog_id}/fonts`
     43         *
     44         * @group multisite
     45         * @group ms-required
     46         */
     47        public function test_fonts_dir_for_multisite() {
     48                $blog_id              = self::factory()->blog->create();
     49                $main_site_upload_dir = wp_get_upload_dir();
     50                switch_to_blog( $blog_id );
     51
     52                $actual   = wp_get_font_dir();
     53                $expected = array(
     54                        'path'    => untrailingslashit( $main_site_upload_dir['basedir'] ) . "/sites/{$blog_id}/fonts",
     55                        'url'     => untrailingslashit( $main_site_upload_dir['baseurl'] ) . "/sites/{$blog_id}/fonts",
     56                        'subdir'  => '',
     57                        'basedir' => untrailingslashit( $main_site_upload_dir['basedir'] ) . "/sites/{$blog_id}/fonts",
     58                        'baseurl' => untrailingslashit( $main_site_upload_dir['baseurl'] ) . "/sites/{$blog_id}/fonts",
     59                        'error'   => false,
     60                );
     61
     62                // Restore blog prior to assertions.
     63                restore_current_blog();
     64                $this->assertSameSets( $expected, $actual );
     65        }
     66
     67        /**
     68         * Ensure modifying the font directory via the 'font_dir' filter works.
     69         */
    3570        public function test_fonts_dir_with_filter() {
    3671                // Define a callback function to pass to the filter.
     
    72107
    73108        /**
     109         * Ensure infinite loops are not triggered when filtering the font uploads directory.
     110         *
    74111         * @ticket 60652
    75112         */
Note: See TracChangeset for help on using the changeset viewer.