Created
June 11, 2025 19:13
-
-
Save mikemcalister/b049c379d80d73408e48717d131c3e13 to your computer and use it in GitHub Desktop.
Disable all Ollie Patterns
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_action( 'init', 'unregister_ollie_patterns', 999 ); | |
function unregister_ollie_patterns() { | |
// Get all registered patterns | |
$patterns = WP_Block_Patterns_Registry::get_instance()->get_all_registered(); | |
// Loop through patterns and unregister those from Ollie theme | |
foreach ( $patterns as $pattern_key => $pattern_data ) { | |
// Check if pattern has slug or name starting with 'ollie/' | |
$is_ollie_pattern = false; | |
if ( isset( $pattern_data['slug'] ) && strpos( $pattern_data['slug'], 'ollie/' ) === 0 ) { | |
$is_ollie_pattern = true; | |
} | |
if ( isset( $pattern_data['name'] ) && strpos( $pattern_data['name'], 'ollie/' ) === 0 ) { | |
$is_ollie_pattern = true; | |
} | |
// Unregister if it's an Ollie pattern | |
if ( $is_ollie_pattern ) { | |
// Use the slug/name for unregistering, not the numeric key | |
$pattern_name = isset( $pattern_data['name'] ) ? $pattern_data['name'] : $pattern_data['slug']; | |
unregister_block_pattern( $pattern_name ); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment