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

Plugin: Remove compat layers for WP 6.4 and 6.5 #64096

Merged
merged 9 commits into from
Jul 31, 2024
25 changes: 4 additions & 21 deletions lib/block-supports/layout.php
Original file line number Diff line number Diff line change
Expand Up @@ -1019,27 +1019,10 @@ function gutenberg_restore_group_inner_container( $block_content, $block ) {
$processor = new WP_HTML_Tag_Processor( $block_content );

if ( $processor->next_tag( array( 'class_name' => 'wp-block-group' ) ) ) {
if ( method_exists( $processor, 'class_list' ) ) {
foreach ( $processor->class_list() as $class_name ) {
if ( str_contains( $class_name, 'layout' ) ) {
array_push( $layout_classes, $class_name );
$processor->remove_class( $class_name );
}
}
} else {
/*
* The class_list method was only added in 6.4 so this needs a temporary fallback.
* This fallback should be removed when the minimum supported version is 6.4.
*/
$classes = $processor->get_attribute( 'class' );
if ( $classes ) {
$classes = explode( ' ', $classes );
foreach ( $classes as $class_name ) {
if ( str_contains( $class_name, 'is-layout-' ) ) {
array_push( $layout_classes, $class_name );
$processor->remove_class( $class_name );
}
}
foreach ( $processor->class_list() as $class_name ) {
if ( str_contains( $class_name, 'layout' ) ) {
array_push( $layout_classes, $class_name );
$processor->remove_class( $class_name );
}
}
}
Expand Down
43 changes: 43 additions & 0 deletions lib/compat/plugin/fonts.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php
/**
* A special compat layer for legacy font files upload directory.
*
* @see https://github.com/WordPress/gutenberg/pull/57688#issuecomment-2259037546
*
* @package gutenberg
*/

// @core-merge: Do not merge this function, it is for deleting fonts from the wp-content/fonts directory only used in Gutenberg.
/**
* Deletes associated font files from wp-content/fonts, when a font face is deleted.
*
* @param int $post_id Post ID.
* @param WP_Post $post Post object.
*/
function gutenberg_before_delete_font_face( $post_id, $post ) {
if ( 'wp_font_face' !== $post->post_type ) {
return;
}

$font_files = get_post_meta( $post_id, '_wp_font_face_file', false );

if ( empty( $font_files ) ) {
return;
}

$site_path = '';
if ( is_multisite() && ! ( is_main_network() && is_main_site() ) ) {
$site_path = '/sites/' . get_current_blog_id();
}

$font_dir = path_join( WP_CONTENT_DIR, 'fonts' ) . $site_path;

foreach ( $font_files as $font_file ) {
$font_path = $font_dir . '/' . $font_file;

if ( file_exists( $font_path ) ) {
wp_delete_file( $font_path );
}
}
}
add_action( 'before_delete_post', 'gutenberg_before_delete_font_face', 10, 2 );
250 changes: 0 additions & 250 deletions lib/compat/plugin/footnotes.php

This file was deleted.

Loading
Loading