Last active
December 13, 2019 18:35
-
-
Save chriscarr/85650a318445319946606ae6460fa002 to your computer and use it in GitHub Desktop.
Save some WordPress site options as site meta to make site queries easy
This file contains 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
<?php | |
// 🥕 Carrot | |
// To make the transition easy from site options to | |
// site meta for specific options we want to easily | |
// query, this idea will automatically duplicate | |
// specific site options to site meta and keep in sync. | |
// NOTE: this is an idea expressed in sudocode | |
add_filter('update_option', function($option, $old, $new) { | |
$options_whitelist = ['theme', 'classic-editor', 'site-template']; | |
if (in_array($option, $options_whitelist)) { | |
update_site_meta(get_current_blog_id(), 'carrotstuff-' . $option, $new); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment