includes
1 year ago
server
9 months ago
tests
1 year ago
wordpress
9 months ago
class-rsssl-htaccess-file-manager.php
9 months ago
cron.php
1 year ago
deactivate-integration.php
3 years ago
firewall-manager.php
9 months ago
functions.php
9 months ago
hardening.php
1 year ago
index.php
2 years ago
integrations.php
1 year ago
notices.php
1 year ago
security.php
9 months ago
sync-settings.php
1 year ago
tests.php
1 year ago
deactivate-integration.php
54 lines
| 1 | <?php |
| 2 | defined('ABSPATH') or die(); |
| 3 | /** |
| 4 | * If a plugin is deactivated, add to deactivated list. |
| 5 | * @param string $field_id |
| 6 | * @param mixed $new_value |
| 7 | * @param mixed $prev_value |
| 8 | * @param string $type |
| 9 | * |
| 10 | * @return void |
| 11 | */ |
| 12 | function rsssl_handle_integration_deactivation($field_id, $new_value, $prev_value, $type){ |
| 13 | if (!rsssl_user_can_manage()) { |
| 14 | return; |
| 15 | } |
| 16 | if ($new_value !== $prev_value && $new_value === 0 ){ |
| 17 | //check if this field id exists in the list of plugins |
| 18 | global $rsssl_integrations_list; |
| 19 | foreach ( $rsssl_integrations_list as $plugin => $plugin_data ) { |
| 20 | if ( |
| 21 | isset($plugin_data['has_deactivation']) && |
| 22 | $plugin_data['has_deactivation'] && |
| 23 | isset($plugin_data['option_id']) && |
| 24 | $plugin_data['option_id'] === $field_id |
| 25 | ) { |
| 26 | //add to deactivated list |
| 27 | $current_list = get_option('rsssl_deactivate_list', []); |
| 28 | if ( !in_array($plugin, $current_list)) { |
| 29 | $current_list[] = $plugin; |
| 30 | update_option('rsssl_deactivate_list', $current_list, false); |
| 31 | } |
| 32 | } |
| 33 | } |
| 34 | } |
| 35 | } |
| 36 | add_action( "rsssl_after_save_field", "rsssl_handle_integration_deactivation", 10, 4 ); |
| 37 | |
| 38 | /** |
| 39 | * Remove a plugin from the deactivation list if deactivation procedure was completed |
| 40 | * @param string $plugin |
| 41 | * |
| 42 | * @return void |
| 43 | */ |
| 44 | function rsssl_remove_from_deactivation_list($plugin){ |
| 45 | if (!rsssl_user_can_manage()) { |
| 46 | return; |
| 47 | } |
| 48 | $deactivate_list = get_option('rsssl_deactivate_list', []); |
| 49 | if ( in_array($plugin, $deactivate_list )) { |
| 50 | $index = array_search($plugin, $deactivate_list); |
| 51 | unset($deactivate_list[$index]); |
| 52 | update_option('rsssl_deactivate_list', $deactivate_list, false ); |
| 53 | } |
| 54 | } |