Changeset 57539
- Timestamp:
- 02/06/2024 08:40:38 AM (10 months ago)
- Location:
- trunk
- Files:
-
- 19 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/default-filters.php
r57306 r57539 749 749 // Font management. 750 750 add_action( 'wp_head', 'wp_print_font_faces', 50 ); 751 add_action( 'deleted_post', '_wp_after_delete_font_family', 10, 2 ); 752 add_action( 'before_delete_post', '_wp_before_delete_font_face', 10, 2 ); 751 753 752 754 unset( $filter, $action ); -
trunk/src/wp-includes/fonts.php
r57240 r57539 52 52 $wp_font_face->generate_and_print( $fonts ); 53 53 } 54 55 /** 56 * Registers a new Font Collection in the Font Library. 57 * 58 * @since 6.5.0 59 * 60 * @param string $slug Font collection slug. May only contain alphanumeric characters, dashes, 61 * and underscores. See sanitize_title(). 62 * @param array|string $data_or_file { 63 * Font collection data array or a path/URL to a JSON file containing the font collection. 64 * 65 * @link https://schemas.wp.org/trunk/font-collection.json 66 * 67 * @type string $name Required. Name of the font collection shown in the Font Library. 68 * @type string $description Optional. A short descriptive summary of the font collection. Default empty. 69 * @type array $font_families Required. Array of font family definitions that are in the collection. 70 * @type array $categories Optional. Array of categories, each with a name and slug, that are used by the 71 * fonts in the collection. Default empty. 72 * } 73 * @return WP_Font_Collection|WP_Error A font collection if it was registered 74 * successfully, or WP_Error object on failure. 75 */ 76 function wp_register_font_collection( $slug, $data_or_file ) { 77 return WP_Font_Library::get_instance()->register_font_collection( $slug, $data_or_file ); 78 } 79 80 /** 81 * Unregisters a font collection from the Font Library. 82 * 83 * @since 6.5.0 84 * 85 * @param string $slug Font collection slug. 86 * @return bool True if the font collection was unregistered successfully, else false. 87 */ 88 function wp_unregister_font_collection( $slug ) { 89 return WP_Font_Library::get_instance()->unregister_font_collection( $slug ); 90 } 91 92 /** 93 * Returns an array containing the current fonts upload directory's path and URL. 94 * 95 * @since 6.5.0 96 * 97 * @param array $defaults { 98 * Array of information about the upload directory. 99 * 100 * @type string $path Base directory and subdirectory or full path to the fonts upload directory. 101 * @type string $url Base URL and subdirectory or absolute URL to the fonts upload directory. 102 * @type string $subdir Subdirectory 103 * @type string $basedir Path without subdir. 104 * @type string $baseurl URL path without subdir. 105 * @type string|false $error False or error message. 106 * } 107 * @return array $defaults { 108 * Array of information about the upload directory. 109 * 110 * @type string $path Base directory and subdirectory or full path to the fonts upload directory. 111 * @type string $url Base URL and subdirectory or absolute URL to the fonts upload directory. 112 * @type string $subdir Subdirectory 113 * @type string $basedir Path without subdir. 114 * @type string $baseurl URL path without subdir. 115 * @type string|false $error False or error message. 116 * } 117 */ 118 function wp_get_font_dir( $defaults = array() ) { 119 $site_path = ''; 120 if ( is_multisite() && ! ( is_main_network() && is_main_site() ) ) { 121 $site_path = '/sites/' . get_current_blog_id(); 122 } 123 124 // Sets the defaults. 125 $defaults['path'] = path_join( WP_CONTENT_DIR, 'fonts' ) . $site_path; 126 $defaults['url'] = untrailingslashit( content_url( 'fonts' ) ) . $site_path; 127 $defaults['subdir'] = ''; 128 $defaults['basedir'] = path_join( WP_CONTENT_DIR, 'fonts' ) . $site_path; 129 $defaults['baseurl'] = untrailingslashit( content_url( 'fonts' ) ) . $site_path; 130 $defaults['error'] = false; 131 132 /** 133 * Filters the fonts directory data. 134 * 135 * This filter allows developers to modify the fonts directory data. 136 * 137 * @since 6.5.0 138 * 139 * @param array $defaults The original fonts directory data. 140 */ 141 return apply_filters( 'font_dir', $defaults ); 142 } 143 144 /** 145 * Deletes child font faces when a font family is deleted. 146 * 147 * @access private 148 * @since 6.5.0 149 * 150 * @param int $post_id Post ID. 151 * @param WP_Post $post Post object. 152 */ 153 function _wp_after_delete_font_family( $post_id, $post ) { 154 if ( 'wp_font_family' !== $post->post_type ) { 155 return; 156 } 157 158 $font_faces = get_children( 159 array( 160 'post_parent' => $post_id, 161 'post_type' => 'wp_font_face', 162 ) 163 ); 164 165 foreach ( $font_faces as $font_face ) { 166 wp_delete_post( $font_face->ID, true ); 167 } 168 } 169 170 /** 171 * Deletes associated font files when a font face is deleted. 172 * 173 * @access private 174 * @since 6.5.0 175 * 176 * @param int $post_id Post ID. 177 * @param WP_Post $post Post object. 178 */ 179 function _wp_before_delete_font_face( $post_id, $post ) { 180 if ( 'wp_font_face' !== $post->post_type ) { 181 return; 182 } 183 184 $font_files = get_post_meta( $post_id, '_wp_font_face_file', false ); 185 $font_dir = wp_get_font_dir()['path']; 186 187 foreach ( $font_files as $font_file ) { 188 wp_delete_file( $font_dir . '/' . $font_file ); 189 } 190 } -
trunk/src/wp-includes/post.php
r57524 r57539 562 562 'revisions', 563 563 ), 564 ) 565 ); 566 567 register_post_type( 568 'wp_font_family', 569 array( 570 'labels' => array( 571 'name' => __( 'Font Families' ), 572 'singular_name' => __( 'Font Family' ), 573 ), 574 'public' => false, 575 '_builtin' => true, /* internal use only. don't use this when registering your own post type. */ 576 'hierarchical' => false, 577 'capabilities' => array( 578 'read' => 'edit_theme_options', 579 'read_private_posts' => 'edit_theme_options', 580 'create_posts' => 'edit_theme_options', 581 'publish_posts' => 'edit_theme_options', 582 'edit_posts' => 'edit_theme_options', 583 'edit_others_posts' => 'edit_theme_options', 584 'edit_published_posts' => 'edit_theme_options', 585 'delete_posts' => 'edit_theme_options', 586 'delete_others_posts' => 'edit_theme_options', 587 'delete_published_posts' => 'edit_theme_options', 588 ), 589 'map_meta_cap' => true, 590 'query_var' => false, 591 'show_in_rest' => false, 592 'rewrite' => false, 593 ) 594 ); 595 596 register_post_type( 597 'wp_font_face', 598 array( 599 'labels' => array( 600 'name' => __( 'Font Faces' ), 601 'singular_name' => __( 'Font Face' ), 602 ), 603 'public' => false, 604 '_builtin' => true, /* internal use only. don't use this when registering your own post type. */ 605 'hierarchical' => false, 606 'capabilities' => array( 607 'read' => 'edit_theme_options', 608 'read_private_posts' => 'edit_theme_options', 609 'create_posts' => 'edit_theme_options', 610 'publish_posts' => 'edit_theme_options', 611 'edit_posts' => 'edit_theme_options', 612 'edit_others_posts' => 'edit_theme_options', 613 'edit_published_posts' => 'edit_theme_options', 614 'delete_posts' => 'edit_theme_options', 615 'delete_others_posts' => 'edit_theme_options', 616 'delete_published_posts' => 'edit_theme_options', 617 ), 618 'map_meta_cap' => true, 619 'query_var' => false, 620 'show_in_rest' => false, 621 'rewrite' => false, 564 622 ) 565 623 ); -
trunk/src/wp-settings.php
r57526 r57539 375 375 require ABSPATH . WPINC . '/style-engine/class-wp-style-engine-processor.php'; 376 376 require ABSPATH . WPINC . '/fonts/class-wp-font-face-resolver.php'; 377 require ABSPATH . WPINC . '/fonts/class-wp-font-collection.php'; 377 378 require ABSPATH . WPINC . '/fonts/class-wp-font-face.php'; 379 require ABSPATH . WPINC . '/fonts/class-wp-font-library.php'; 380 require ABSPATH . WPINC . '/fonts/class-wp-font-utils.php'; 378 381 require ABSPATH . WPINC . '/fonts.php'; 379 382 require ABSPATH . WPINC . '/class-wp-script-modules.php';
Note: See TracChangeset
for help on using the changeset viewer.