Making WordPress.org

Changeset 13722


Ignore:
Timestamp:
05/17/2024 03:17:10 AM (7 months ago)
Author:
dd32
Message:

Plugin Directory: Blocks: Tweak the fallback name slightly, to skip the plugin slug if it's the namespace..

See [13718].
See #5971.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/cli/class-import.php

    r13718 r13722  
    850850                // If the block duplicates the namespace, remove it. 'plugin-slug/plugin-slug-block-name'
    851851                $block->title = preg_replace( '#^([^/]+)/\\1-?#i', '$1/', $block->title );
     852                // If the namespace is the slug (w/ or w/o dashes..), remove it.
     853                if (
     854                    str_starts_with( $block->title, $plugin_slug . '/' ) ||
     855                    str_starts_with( $block->title, str_replace( '-', '', $plugin_slug ) . '/' )
     856                ) {
     857                    $block->title = explode( '/', $block->title, 2 )[1];
     858                }
    852859                // Treat any non-wordy characters as spaces.
    853                 $block->title = preg_replace( '/[^a-z]+/', ' ', $block_name );
     860                $block->title = preg_replace( '/[^a-z]+/', ' ', $block->title );
    854861                // Capitalise all words.
    855862                $block->title = ucwords( $block->title );
Note: See TracChangeset for help on using the changeset viewer.