Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate and make Fonts API non-functional. #52485

Merged
merged 3 commits into from
Jul 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php
/**
* Fonts API BC Layer helpers.
*
* BACKPORT NOTE: Do not backport this file to Core.
* This file is now part of the API's Backwards-Compatibility (BC) layer.
*
* @package Gutenberg
* @subpackage Fonts API
* @since 15.7.0
*/

/**
* Class Gutenberg_Fonts_API_BC_Layer
*
* BACKPORT NOTE: Do not backport this file to Core.
*
* @since X.X.X
* @deprecated 16.3.0 Fonts API is not supported.
*/
class Gutenberg_Fonts_API_BC_Layer {
aristath marked this conversation as resolved.
Show resolved Hide resolved

/**
* Determines if the given fonts array is the deprecated array structure.
*
* @since X.X.X
* @deprecated 16.3.0 Structure check is not functional.
*
* @return bool False.
*/
public static function is_deprecated_structure() {
_deprecated_function( __METHOD__, 'Gutenberg 16.3.0' );
return false;
}

/**
* Migrates deprecated fonts structure into new API data structure,
* i.e. variations grouped by their font-family.
*
* @since X.X.X
* @deprecated 16.3.0 Migrate is not supported.
*
* @return array Empty array.
*/
public static function migrate_deprecated_structure() {
_deprecated_function( __METHOD__, 'Gutenberg 16.3.0' );
return array();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php
/**
* Webfonts API: Provider for locally-hosted fonts.
*
* @package WordPress
* @subpackage Fonts API
* @since X.X.X
*/

if ( class_exists( 'WP_Fonts_Provider_Local' ) ) {
return;
}

/**
* A core bundled provider for generating `@font-face` styles
* from locally-hosted font files.
*
* @since X.X.X
* @deprecated 16.3.0 Providers are not supported.
* Local provider is in WP_Font_Face.
*/
class WP_Fonts_Provider_Local extends WP_Fonts_Provider {

/**
* The provider's unique ID.
*
* @since X.X.X
* @deprecated 16.3.0
*
* @var string
*/
protected $id = 'local';

/**
* Gets the `@font-face` CSS styles for locally-hosted font files.
*
* @since X.X.X
* @deprecated 16.3.0 Get styles is not supported.
*
* @return string Empty string.
*/
public function get_css() {
_deprecated_function( __FUNCTION__, 'Gutenberg 16.3' );
return '';
}
}
98 changes: 98 additions & 0 deletions lib/experimental/fonts/bc-layer/class-wp-fonts-provider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
<?php
/**
* Fonts API: Provider abstract class.
*
* Individual fonts providers should extend this class and implement.
*
* @package WordPress
* @subpackage Fonts API
* @since X.X.X
*/

if ( class_exists( 'WP_Fonts_Provider' ) ) {
return;
}

/**
* Abstract class for Fonts API providers.
*
* @since X.X.X
* @deprecated 16.3.0 Custom providers are not supported.
*/
abstract class WP_Fonts_Provider {

/**
* The provider's unique ID.
*
* @since X.X.X
* @deprecated 16.3.0
*
* @var string
*/
protected $id = '';

/**
* Fonts to be processed.
*
* @since X.X.X
* @deprecated 16.3.0
*
* @var array[]
*/
protected $fonts = array();

/**
* Array of Font-face style tag's attribute(s)
* where the key is the attribute name and the
* value is its value.
*
* @since X.X.X
* @deprecated 16.3.0
*
* @var string[]
*/
protected $style_tag_atts = array();

/**
* Sets this provider's fonts property.
*
* @since X.X.X
* @deprecated 16.3.0 Set is not supported.
*/
public function set_fonts() {
_deprecated_function( __METHOD__, 'Gutenberg 16.3.0' );
}

/**
* Prints the generated styles.
*
* @since X.X.X
* @deprecated 16.3.0 Use wp_print_font_faces() instead.
*/
public function print_styles() {
_deprecated_function( __METHOD__, 'Gutenberg 16.3.0', 'wp_print_font_faces' );
}

/**
* Gets the `@font-face` CSS for the provider's fonts.
*
* @since X.X.X
* @deprecated 16.3.0
*
* @return string The `@font-face` CSS.
*/
abstract public function get_css();

/**
* Gets the `<style>` element for wrapping the `@font-face` CSS.
*
* @since X.X.X
* @deprecated 16.3.0 Get style element is not supported.
*
* @return string Empty string.
*/
protected function get_style_element() {
_deprecated_function( __METHOD__, 'Gutenberg 16.3.0' );
return '';
}
}
64 changes: 64 additions & 0 deletions lib/experimental/fonts/bc-layer/class-wp-fonts-resolver.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?php
/**
* WP_Fonts_Resolver class.
*
* @package WordPress
* @subpackage Fonts API
* @since X.X.X
*/

if ( class_exists( 'WP_Fonts_Resolver' ) ) {
return;
}

/**
* The Fonts API Resolver abstracts the processing of different data sources
* (such as theme.json and global styles) for font interactions with the API.
*
* This class is for internal core usage and is not supposed to be used by
* extenders (plugins and/or themes).
*
* @access private
*
* @since X.X.X
* @deprecated 16.3.0 Fonts API is not supported.
*/
class WP_Fonts_Resolver {

/**
* Enqueues user-selected fonts via global styles.
*
* @since X.X.X
* @deprecated 16.3.0 Enqueue is not supported.
*
* @return array Empty array.
*/
public static function enqueue_user_selected_fonts() {
_deprecated_function( __FUNCTION__, 'Gutenberg 16.3' );
return array();
}

/**
* Register fonts defined in theme.json.
*
* @since X.X.X
* @deprecated 16.3.0 Register is not supported.
*/
public static function register_fonts_from_theme_json() {
_deprecated_function( __FUNCTION__, 'Gutenberg 16.3' );
}

/**
* Add missing fonts to the global styles.
*
* @since X.X.X
* @deprecated 16.3.0 Adding fonts into theme.json theme data layer is not supported.
*
* @param WP_Theme_JSON_Gutenberg|WP_Theme_JSON $data The global styles.
* @return WP_Theme_JSON_Gutenberg|WP_Theme_JSON Unchanged global styles.
*/
public static function add_missing_fonts_to_theme_json( $data ) {
_deprecated_function( __FUNCTION__, 'Gutenberg 16.3' );
return $data;
}
}
74 changes: 74 additions & 0 deletions lib/experimental/fonts/bc-layer/class-wp-fonts-utils.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<?php
/**
* Font API's utility helpers.
*
* @package WordPress
* @subpackage Fonts API
* @since X.X.X
*/

if ( class_exists( 'WP_Fonts_Utils' ) ) {
return;
}

/**
* Utility helpers for the Fonts API.
*
* @since X.X.X
* @deprecated 16.3.0 Fonts API is not supported.
*/
class WP_Fonts_Utils {

/**
* Converts the given font family into a handle.
*
* @since X.X.X
* @deprecated 16.3.0 This method is not supported.
*
* @return null
*/
public static function convert_font_family_into_handle() {
_deprecated_function( __METHOD__, 'Gutenberg 16.3.0' );
return null;
}

/**
* Converts the given variation and its font-family into a handle.
*
* @since X.X.X
* @deprecated 16.3.0 This method is not supported.
*
* @return null
*/
public static function convert_variation_into_handle() {
_deprecated_function( __METHOD__, 'Gutenberg 16.3.0' );
return null;
}

/**
* Gets the font family from the variation.
*
* @since X.X.X
* @deprecated 16.3.0 This method is not supported.
*
* @return null Null.
*/
public static function get_font_family_from_variation() {
_deprecated_function( __METHOD__, 'Gutenberg 16.3.0' );
return null;
}

/**
* Checks if the given input is defined, i.e. meaning is a non-empty string.
*
* @since X.X.X
* @deprecated 16.3.0
*
* @param string $input The input to check.
* @return bool True when non-empty string. Else false.
*/
public static function is_defined( $input ) {
_deprecated_function( __METHOD__, 'Gutenberg 16.3.0' );
return ( is_string( $input ) && ! empty( $input ) );
}
}
Loading
Loading