Last active
April 22, 2025 07:49
-
-
Save taricco/8f0d092ee246c55a8472f221bd8a9585 to your computer and use it in GitHub Desktop.
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
| <?php | |
| /* | |
| Plugin Name: Staging System Custom Functions | |
| Plugin URI: https://www.timtaricco.com | |
| Description: Staging system for: domain.com | |
| Version:09.09.22 | |
| Author: Tim Taricco | |
| Author URI: https://www.timtaricco.com | |
| License: GPL2 | |
| */ | |
| /*** Change color of WordPress Admin Bar for staging website | |
| –––––––––––––––––––––––––––––––––––––––––––––––––– ***/ | |
| function wsv_is_it_staging() | |
| { | |
| if (strpos($_SERVER['HTTP_HOST'], 'staging.domain.com') !== false) { | |
| echo ' | |
| <style type="text/css"> | |
| #wpadminbar { | |
| background-color: #ff6600; | |
| } | |
| </style> | |
| '; | |
| } | |
| } | |
| add_action('admin_head', 'wsv_is_it_staging'); | |
| /*** Disable plugins on live website (i.e password protected plugin) | |
| –––––––––––––––––––––––––––––––––––––––––––––––––– ***/ | |
| function wsv_disable_plugins_live_website($plugins) | |
| { | |
| if (strpos($_SERVER['HTTP_HOST'], 'www.domain.com') !== false) { | |
| $key = array_search('password-protected/password-protected.php', $plugins); | |
| if (false !== $key) { | |
| unset($plugins[$key]); | |
| } | |
| } | |
| return $plugins; | |
| } | |
| add_filter('option_active_plugins', 'wsv_disable_plugins_live_website'); | |
| /*** Disable plugins on staging website (i.e caching plugin) | |
| –––––––––––––––––––––––––––––––––––––––––––––––––– ***/ | |
| function wsv_disable_plugins_staging_website($plugins) | |
| { | |
| if (strpos($_SERVER['HTTP_HOST'], 'staging.domain.com') !== false) { | |
| $key = array_search('wp-cloudflare-page-cache/wp-cloudflare-super-page-cache.php', $plugins); | |
| if (false !== $key) { | |
| unset($plugins[$key]); | |
| } | |
| } | |
| return $plugins; | |
| } | |
| add_filter('option_active_plugins', 'wsv_disable_plugins_staging_website'); | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment