Plugin Directory

Changeset 2290248


Ignore:
Timestamp:
04/23/2020 04:01:16 PM (6 years ago)
Author:
ghostmonitor
Message:

AUTOMATED COMMIT, PLUGIN VERSION: 1.13.0

Location:
ghostmonitor
Files:
165 added
4 edited

Legend:

Unmodified
Added
Removed
  • ghostmonitor/trunk/config.json

    r2216995 r2290248  
    11{
    22    "sitesUrl": "https://sites.ghostmonitor.com/",
    3     "trackingUrl": "https://tracking.ghostmonitor.com",
    4     "settingsUrl": "https://api.recart.com/tracking/v2/settings/",
     3    "trackingUrl": "https://tracking.ghostmonitor.com",
     4    "settingsUrl": "https://api.recart.com/tracking/v2/settings/",
     5    "webhookUrl": "https://api.recart.com/store/webhooks/",
    56    "cdnUrl": "https://cdn.ghostmonitor.com",
    6     "version": "v1.12.14",
    7     "logentriesToken": "d3695c56-67af-4c86-8c7d-26c6c252987b",
     7    "version": "v1.13.0",
    88    "env": "production"
    99}
  • ghostmonitor/trunk/includes/class-wc-ghostmonitor.php

    r2147618 r2290248  
    4949        );
    5050        $this->gm_helper->setLogPath(GHOSTMONITOR_PLUGIN_PATH . 'log.txt');
    51         $this->gm_helper->setLogentriesToken((string)$this->get_gm_config_value('logentriesToken'));
    5251
    5352        $this->gm_helper->logDebug(array('PLUGIN_CONFIG' => $this->plugin_config));
     
    685684    public function handle_url_discount_code() {
    686685      preg_match("/\/discount\/(\w+)/", $_SERVER['REQUEST_URI'], $url_subitems);
    687      
     686
    688687      // Only proceed if url matched /discount/somediscountcode
    689688      if (count($url_subitems) < 1) return;
    690689      if (!isset($url_subitems[1])) return;
    691  
     690
    692691      $discount_code = $url_subitems[1];
    693  
     692
    694693      if (WC()->cart && !WC()->cart->is_empty() && !WC()->cart->has_discount($discount_code)) {
    695694          WC()->cart->add_discount($discount_code);
     
    697696          setcookie("recart_saved_discount_code", $discount_code, time() + (86400 * 7), "/");
    698697      }
    699  
     698
    700699      $this->handle_redirect_parameter();
    701700  }
    702    
     701
    703702    private function handle_redirect_parameter() {
    704703        $requested_url = urldecode($_SERVER['REQUEST_URI']);
     
    724723            $redirect_url = '/';
    725724        }
    726        
     725
    727726        $is_https = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on';
    728727        $full_url = ($is_https ? "https" : "http") . "://" . $_SERVER['HTTP_HOST'] . $redirect_url;
     
    742741                    "\n"
    743742                ];
    744                
     743
    745744                foreach($EZSQL_ERROR AS $error) {
    746745                    $log[] = str_repeat('-', 50) . "\n" . implode("\n", $error) . "\n" . str_repeat('-', 50) . "\n";
     
    749748                $this->gm_helper->logError(implode($log));
    750749            }
    751         } catch(Exception $e) { 
     750        } catch(Exception $e) {
    752751            $this->gm_helper->logError($e->__toString());
    753752        }
     
    755754        return;
    756755    }
    757            
     756
    758757    function attempt_apply_saved_discount_code() {
    759758        // Can apply discount code only if cart exists & not empty
     
    770769        }
    771770    }
    772    
     771
    773772    function redirect_client_to_url($redirect_url) {
    774773        echo '<script type="text/javascript">' .
  • ghostmonitor/trunk/readme.txt

    r2216995 r2290248  
    44Requires at least: 3.9
    55Tested up to: 5.3.2
    6 Stable tag: 1.12.14
     6Stable tag: 1.13.0
    77License: GPLv2 or later
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
  • ghostmonitor/trunk/woocommerce-ghostmonitor.php

    r2216995 r2290248  
    66 * Author: Ghostmonitor INC
    77 * Author URI: http://www.recart.com
    8  * Version: v1.12.14
     8 * Version: v1.13.0
    99 */
    1010
    1111defined('ABSPATH') or die();
    1212
    13 require_once 'includes/ghostmonitor_helper/vendor/autoload.php';
     13require_once 'includes/class-wc-helper.php';
     14require_once 'includes/class-wc-logger.php';
    1415
    1516class Woocommerce_Ghostmonitor {
     
    3233        update_option('ghostmonitor_http_status', $http_status, true);
    3334
    34         $this->send_shop_info();
     35        $this->create_recart_webhooks();
     36        $this->send_shop_info("activated");
    3537    }
    3638
    3739    public function deactivate_plugin() {
    38         $this->send_shop_info();
     40        $this->delete_recart_webhooks();
     41        $this->send_shop_info("deactivated");
    3942    }
    4043
    41     public function send_shop_info() {
     44    public function send_shop_info($event) {
    4245        global $woocommerce;
    4346        global $wpdb;
    4447        global $wp_version;
    4548
    46         $version = 'v1.12.14';
     49        $version = 'v1.13.0';
    4750
    4851        $discount_enabled = get_option('woocommerce_enable_coupons') === 'yes' ? 'true' : 'false';
     
    5053        $gm_helper = $this->get_gm_helper();
    5154        $shop_data = array(
     55            'event' => $event,
    5256            'plugin_type' => 'woocommerce',
    5357            'plugin_version' => $this->config ? $this->config->version : $version,
     
    103107        );
    104108    }
     109
     110    private function create_recart_webhooks() {
     111        $webhookURL = $this->config && property_exists($this->config, 'webhookUrl') ? $this->config->webhookUrl : null;
     112
     113        if ($webhookURL === null || get_option("recart_webhooks_enabled")) {
     114            return;
     115        }
     116
     117        $secret = wp_generate_password(50, true, true);
     118        $topics = ["order.created", "order.updated", "order.deleted", "order.restored"];
     119
     120        foreach ($topics as $topic) {
     121            $webhook = new WC_Webhook();
     122            $webhook->set_name("Recart");
     123            if (!$webhook->get_user_id()) {
     124                $webhook->set_user_id(get_current_user_id());
     125            }
     126            $webhook->set_delivery_url($webhookURL);
     127            $webhook->set_secret($secret);
     128            $webhook->set_api_version("wp_api_v3");
     129            $webhook->set_status("active");
     130            $webhook->set_topic($topic);
     131            $webhook->save();
     132        }
     133
     134        update_option("recart_webhooks_enabled", true);
     135    }
     136
     137    private function delete_recart_webhooks() {
     138        $data_store = WC_Data_Store::load('webhook');
     139        $args = array(
     140            'limit'    => -1,
     141            'offset'   => 0,
     142            'order'    => 'DESC',
     143            'orderby'  => 'id',
     144            'paginate' => false,
     145            's' => 'Recart',
     146        );
     147        $webhooks = $data_store->search_webhooks($args);
     148        foreach ($webhooks as $webhookID) {
     149            $webhook = new WC_Webhook($webhookID);
     150            if (preg_match("/recart.com/", $webhook->get_delivery_url())) {
     151                $webhook->delete();
     152            }
     153        }
     154
     155        update_option("recart_webhooks_enabled", false);
     156    }
    105157}
    106158
Note: See TracChangeset for help on using the changeset viewer.