The global_terms_enabled WordPress PHP filter allows you to check if global terms are enabled on a WordPress multisite installation.
Usage
add_filter('global_terms_enabled', 'your_custom_function'); function your_custom_function($enabled) { // your custom code here return $enabled; }
Parameters
$enabled (null)
– Whether global terms are enabled or not.
More information
See WordPress Developer Resources: global_terms_enabled
Examples
Disable global terms
Disable global terms across the multisite installation.
add_filter('global_terms_enabled', 'disable_global_terms'); function disable_global_terms($enabled) { return false; }
Enable global terms
Enable global terms across the multisite installation.
add_filter('global_terms_enabled', 'enable_global_terms'); function enable_global_terms($enabled) { return true; }
Toggle global terms based on user role
Enable global terms for administrators only.
add_filter('global_terms_enabled', 'toggle_global_terms_based_on_user_role'); function toggle_global_terms_based_on_user_role($enabled) { if (current_user_can('administrator')) { return true; } return false; }
Enable global terms for specific site
Enable global terms only for a specific site within the multisite installation.
add_filter('global_terms_enabled', 'enable_global_terms_for_specific_site'); function enable_global_terms_for_specific_site($enabled) { if (get_current_blog_id() == 5) { // Replace 5 with your desired site ID return true; } return false; }
Log when global terms are checked
Log every time the global_terms_enabled filter is checked.
add_filter('global_terms_enabled', 'log_global_terms_check'); function log_global_terms_check($enabled) { error_log('Global terms checked: ' . ($enabled ? 'enabled' : 'disabled')); return $enabled; }