Plugin Directory

Changeset 3003145


Ignore:
Timestamp:
11/29/2023 09:04:13 AM (2 years ago)
Author:
outshifter
Message:

new delete webhooks

Location:
outshifter-export/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • outshifter-export/trunk/README.txt

    r2978112 r3003145  
    33Tags: EcommerceManagement, Omnichannel, CrossChannel, Distribution, Headless, Inventorysynchronization, Sales
    44Requires at least: 5.0
    5 Tested up to: 6.2
    6 Stable tag: 3.4
     5Tested up to: 6.3
     6Stable tag: 3.5
    77Requires PHP: 7.0
    88License: GPLv3
  • outshifter-export/trunk/index.php

    r2978112 r3003145  
    88 * Author: Reachu
    99 * Author URI: https://reachu.io/
    10  * Version: 3.4
     10 * Version: 3.5
    1111 */
    1212
     
    8282          update_option('wc_reachu_password', '');
    8383          update_option('firebaseUserId', '');
     84          if (class_exists('OSEWCPHJC_reachuSync') && method_exists('OSEWCPHJC_reachuSync', 'plugin_uninstall')) {
     85            OSEWCPHJC_reachuSync::plugin_uninstall();
     86          }
    8487        }
    8588      );
    8689    }
     90
     91    public static function remove_webhook()
     92    {
     93      self::log('Inicio - remove_webhook');
     94   
     95      $data_store = WC_Data_Store::load('webhook');
     96      $webhooks = $data_store->search_webhooks();
     97
     98      foreach ($webhooks as $webhook_id) {
     99        $webhook = wc_get_webhook($webhook_id);
     100        $nombre_webhook_creado = "Outshifter order.created";
     101        $nombre_webhook_actualizado = "Outshifter order.updated";
     102
     103        self::log('Nombre del Webhook: ' . $webhook->get_name());
     104
     105
     106        if ($webhook->get_name() === $nombre_webhook_creado || $webhook->get_name() === $nombre_webhook_actualizado) {
     107            self::log('Webhook ' . $webhook->get_name() . ' eliminado.');
     108            $webhook->delete(true);
     109        }
     110      }
     111
     112      self::log('Fin - remove_webhook');
     113    }
     114
     115    public static function remove_api_keys()
     116    {
     117      self::log('Inicio - remove_api_keys');
     118
     119      // Parte de la descripción que estamos buscando
     120      $descripcion_buscada = "Reachu export";
     121 
     122      global $wpdb;
     123      $tabla_api_keys = $wpdb->prefix . 'woocommerce_api_keys';
     124      $api_keys = $wpdb->get_results("SELECT key_id, description FROM {$tabla_api_keys}");
     125 
     126      foreach ($api_keys as $api_key) {
     127          // Verificar si la descripción contiene la subcadena buscada
     128          if (strpos($api_key->description, $descripcion_buscada) !== false) {
     129              $wpdb->delete($tabla_api_keys, ['key_id' => $api_key->key_id], ['%d']);
     130              self::log('Clave API con descripción conteniendo "' . $descripcion_buscada . '" eliminada.');
     131          }
     132      }
     133 
     134      self::log('Fin - remove_api_keys');
     135
     136    }
     137
     138    public static function plugin_uninstall() {
     139      self::remove_webhook();
     140      self::remove_api_keys();
     141  }
    87142
    88143    public static function overrule_webhook_disable_limit($number)
     
    600655      update_option('wc_reachu_password', '');
    601656      update_option('firebaseUserId', '');
     657
     658      self::plugin_uninstall();
    602659
    603660      self::log('[logout_reachu] disconnect reachu success');
Note: See TracChangeset for help on using the changeset viewer.