updated theme GeneratePress version 3.4.0

This commit is contained in:
2024-02-08 12:32:18 +00:00
committed by Gitium
parent 0a68b68387
commit ebadc7fb45
30 changed files with 158 additions and 125 deletions

View File

@ -37,6 +37,7 @@ class GeneratePress_Typography {
public function __construct() {
add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_google_fonts' ) );
add_filter( 'generate_editor_styles', array( $this, 'add_editor_styles' ) );
add_action( 'enqueue_block_editor_assets', array( $this, 'enqueue_editor_scripts' ) );
// Load fonts the old way in versions before 5.8 as block_editor_settings_all didn't exist.
if ( version_compare( $GLOBALS['wp_version'], '5.8', '<' ) ) {
@ -118,9 +119,10 @@ class GeneratePress_Typography {
/**
* Build our typography CSS.
*
* @param string $module The name of the module we're generating CSS for.
* @param string $module The name of the module we're generating CSS for.
* @param string $specific_selector Target a specific selector to get the CSS for.
*/
public static function get_css( $module = 'core' ) {
public static function get_css( $module = 'core', $specific_selector = '' ) {
$typography = generate_get_option( 'typography' );
// Get data for a specific module so CSS can be compiled separately.
@ -152,6 +154,14 @@ class GeneratePress_Typography {
$selector = $options['customSelector'];
}
if (
$specific_selector &&
$options['selector'] !== $specific_selector &&
$options['customSelector'] !== $specific_selector
) {
continue;
}
$font_family = self::get_font_family( $options['fontFamily'] );
$css->set_selector( $selector );
@ -321,6 +331,7 @@ class GeneratePress_Typography {
public static function get_defaults() {
return array(
'selector' => '',
'customSelector' => '',
'fontFamily' => '',
'fontWeight' => '',
'textTransform' => '',
@ -357,6 +368,28 @@ class GeneratePress_Typography {
return $editor_styles;
}
/**
* Add scripts to the block editor.
*/
public function enqueue_editor_scripts() {
$html_typography = self::get_css( 'core', 'html' );
if ( $html_typography ) {
wp_add_inline_style(
/**
* `wp-edit-blocks` is enqueued in the editor, including the iframes.
* This is not ideal, as we should use the `block_editor_settings_all` filter to add editor CSS.
* However, that filter prepends all selectors with `.editor-styles-wrapper`, which breaks the above
* selector, as it appears above that element in the DOM.
*
* Related: https://github.com/tomusborne/generatepress/issues/472
*/
'wp-edit-blocks',
$html_typography
);
}
}
}
GeneratePress_Typography::get_instance();