Last active
February 11, 2022 21:25
-
-
Save trueqap/8ea11d74c9fbdf6c981cc0bd7e010f7b to your computer and use it in GitHub Desktop.
wp-content/mu-plugins/die-jetwoo.php
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 | |
/** | |
* jetwoodie_plugins_affected_by function | |
* | |
* @param [type] $rules | |
* @return void | |
*/ | |
function jetwoodie_plugins_affected_by($rules) | |
{ | |
$affected = array(); | |
$current_path = add_query_arg(array()); | |
foreach ($rules as $plugin => $paths) { | |
$matches = array_filter( | |
$paths, | |
function ($path) use ($current_path) { | |
return ( | |
$path === $current_path || | |
preg_match('%'.$path.'%', $current_path) | |
); | |
} | |
); | |
if (empty($matches)) { | |
continue; | |
} | |
$affected[] = $plugin; | |
add_filter('plugin_action_links_'.$plugin, 'jetwoodie_add_action_links'); | |
} | |
return $affected; | |
} | |
/** | |
* jetwoodie_plugin_control function | |
* | |
* @param [type] $plugins | |
* @return void | |
*/ | |
function jetwoodie_plugin_control($plugins) | |
{ | |
$jetwoodie_controlled_plugins = wp_cache_get('jetwoodie_controlled_plugins', 'plugins'); | |
if ($jetwoodie_controlled_plugins !== false) { | |
return $jetwoodie_controlled_plugins; | |
} | |
wp_cache_set('jetwoodie_original_plugins', $plugins, 'plugins'); | |
$disabling_rules = array( | |
'jet-woo-builder/jet-woo-builder.php' => array( | |
'/penztar/$' //Ezt a sort írd át a pénztár SLUG url-re. | |
) | |
); | |
$plugins = array_diff($plugins, jetwoodie_plugins_affected_by($disabling_rules)); | |
wp_cache_set('jetwoodie_controlled_plugins', $plugins, 'plugins'); | |
return $plugins; | |
} | |
add_filter('option_active_plugins', 'jetwoodie_plugin_control'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment