Created
June 11, 2025 19:13
-
-
Save mikemcalister/d6c85bfeef66abad0450654fd1034d76 to your computer and use it in GitHub Desktop.
Disable all Ollie Patterns except Header and Footer
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 (except headers/footers) | |
foreach ( $patterns as $pattern_key => $pattern_data ) { | |
// Check if pattern has slug or name starting with 'ollie/' | |
$pattern_identifier = ''; | |
if ( isset( $pattern_data['slug'] ) && strpos( $pattern_data['slug'], 'ollie/' ) === 0 ) { | |
$pattern_identifier = $pattern_data['slug']; | |
} elseif ( isset( $pattern_data['name'] ) && strpos( $pattern_data['name'], 'ollie/' ) === 0 ) { | |
$pattern_identifier = $pattern_data['name']; | |
} | |
// If it's an Ollie pattern, check if it's NOT a header or footer | |
if ( $pattern_identifier && | |
strpos( $pattern_identifier, 'ollie/header-' ) !== 0 && | |
strpos( $pattern_identifier, 'ollie/footer-' ) !== 0 ) { | |
unregister_block_pattern( $pattern_identifier ); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment