Changeset 57740
- Timestamp:
- 02/29/2024 10:15:20 AM (16 months ago)
- Location:
- trunk/src/wp-includes
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/fonts.php
r57720 r57740 97 97 * @since 6.5.0 98 98 * 99 * @ paramarray $defaults {99 * @return array $defaults { 100 100 * Array of information about the upload directory. 101 101 * … … 107 107 * @type string|false $error False or error message. 108 108 * } 109 * @return array $defaults { 110 * Array of information about the upload directory. 111 * 112 * @type string $path Base directory and subdirectory or full path to the fonts upload directory. 113 * @type string $url Base URL and subdirectory or absolute URL to the fonts upload directory. 114 * @type string $subdir Subdirectory 115 * @type string $basedir Path without subdir. 116 * @type string $baseurl URL path without subdir. 117 * @type string|false $error False or error message. 118 * } 119 */ 120 function wp_get_font_dir( $defaults = array() ) { 109 */ 110 function wp_get_font_dir() { 121 111 $site_path = ''; 122 112 if ( is_multisite() && ! ( is_main_network() && is_main_site() ) ) { … … 124 114 } 125 115 126 // Sets the defaults. 127 $defaults['path'] = path_join( WP_CONTENT_DIR, 'fonts' ) . $site_path; 128 $defaults['url'] = untrailingslashit( content_url( 'fonts' ) ) . $site_path; 129 $defaults['subdir'] = ''; 130 $defaults['basedir'] = path_join( WP_CONTENT_DIR, 'fonts' ) . $site_path; 131 $defaults['baseurl'] = untrailingslashit( content_url( 'fonts' ) ) . $site_path; 132 $defaults['error'] = false; 116 $defaults = array( 117 'path' => path_join( WP_CONTENT_DIR, 'fonts' ) . $site_path, 118 'url' => untrailingslashit( content_url( 'fonts' ) ) . $site_path, 119 'subdir' => '', 120 'basedir' => path_join( WP_CONTENT_DIR, 'fonts' ) . $site_path, 121 'baseurl' => untrailingslashit( content_url( 'fonts' ) ) . $site_path, 122 'error' => false, 123 ); 133 124 134 125 /** -
trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-font-faces-controller.php
r57548 r57740 857 857 protected function handle_font_file_upload( $file ) { 858 858 add_filter( 'upload_mimes', array( 'WP_Font_Utils', 'get_allowed_font_mime_types' ) ); 859 add_filter( 'upload_dir', 'wp_get_font_dir' ); 859 860 /* 861 * Set the upload directory to the fonts directory. 862 * 863 * wp_get_font_dir() contains the 'font_dir' hook, whose callbacks are 864 * likely to call wp_get_upload_dir(). 865 * 866 * To avoid an infinite loop, don't hook wp_get_font_dir() to 'upload_dir'. 867 * Instead, just pass its return value to the 'upload_dir' callback. 868 */ 869 $font_dir = wp_get_font_dir(); 870 $set_upload_dir = function () use ( $font_dir ) { 871 return $font_dir; 872 }; 873 add_filter( 'upload_dir', $set_upload_dir ); 860 874 861 875 $overrides = array( … … 875 889 $uploaded_file = wp_handle_upload( $file, $overrides ); 876 890 877 remove_filter( 'upload_dir', 'wp_get_font_dir');891 remove_filter( 'upload_dir', $set_upload_dir ); 878 892 remove_filter( 'upload_mimes', array( 'WP_Font_Utils', 'get_allowed_font_mime_types' ) ); 879 893 … … 903 917 904 918 /** 905 * Returns relative path to an uploaded font file.906 *907 * The path is relative to the current fonts directory.908 *909 * @since 6.5.0910 * @access private911 *912 * @param string $path Full path to the file.913 * @return string Relative path on success, unchanged path on failure.914 */919 * Returns relative path to an uploaded font file. 920 * 921 * The path is relative to the current fonts directory. 922 * 923 * @since 6.5.0 924 * @access private 925 * 926 * @param string $path Full path to the file. 927 * @return string Relative path on success, unchanged path on failure. 928 */ 915 929 protected function relative_fonts_path( $path ) { 916 930 $new_path = $path;
Note: See TracChangeset
for help on using the changeset viewer.