Plugin Directory

Changeset 2273701


Ignore:
Timestamp:
04/02/2020 08:38:05 AM (6 years ago)
Author:
snappic
Message:

Track Fb events by 'trackSingle'. Manage settings to inject/remove pixel. Bump version to v1.2

Location:
snappic
Files:
1 added
10 edited
9 copied

Legend:

Unmodified
Added
Removed
  • snappic/tags/1.2/class-snappic-pixel-display.php

    r2271526 r2273701  
    148148
    149149    // @Todo: do we need to SSL verify? Skipping for now
    150     $result = wp_safe_remote_get( $url, array( 'sslverify'   => false ) );
     150    $result = wp_safe_remote_get( $url, array( 'sslverify' => false, 'timeout' => 10 ) );
    151151
    152152    if( ! is_wp_error( $result ) ) {
  • snappic/tags/1.2/includes/class-snappic-api-controller.php

    r1874793 r2273701  
    3434    ) );
    3535
     36    register_rest_route( $this->namespace, '/' . $this->rest_base . '/get_setting', array(
     37      array(
     38        'methods'             => WP_REST_Server::READABLE,
     39        'callback'            => array( $this, 'get_setting' ),
     40        'permission_callback' => array( $this, 'get_items_permissions_check' ),
     41        'args'                => $this->get_collection_params(),
     42      ),
     43      'schema' => array( $this, 'get_public_item_schema' ),
     44    ) );
     45
     46    register_rest_route( $this->namespace, '/' . $this->rest_base . '/set_setting', array(
     47      array(
     48        'methods'             => WP_REST_Server::READABLE,
     49        'callback'            => array( $this, 'set_setting' ),
     50        'permission_callback' => array( $this, 'get_items_permissions_check' ),
     51        'args'                => $this->get_collection_params(),
     52      ),
     53      'schema' => array( $this, 'get_public_item_schema' ),
     54    ) );
     55
    3656  }
    3757 
     
    5676 
    5777    return rest_ensure_response( $data );
     78  }
     79
     80  public function get_setting( $request ) {
     81    return rest_ensure_response(
     82      array($request['param'] => Snappic_Integration::instance()->get_option($request['param']))
     83    );
     84  }
     85
     86  public function set_setting( $request ) {
     87    Snappic_Helper::get_instance()->update_options(array($request['param'] => $request['value']));
     88
     89    return rest_ensure_response( array('success' => true) );
    5890  }
    5991
  • snappic/tags/1.2/includes/class-snappic-pixel-display.php

    r1715114 r2273701  
    148148
    149149    // @Todo: do we need to SSL verify? Skipping for now
    150     $result = wp_safe_remote_get( $url, array( 'sslverify'   => false ) );
     150    $result = wp_safe_remote_get( $url, array( 'sslverify' => false, 'timeout' => 10 ) );
    151151
    152152    if( ! is_wp_error( $result ) ) {
  • snappic/tags/1.2/includes/class-snappic-pixel.php

    r1715114 r2273701  
    1818  */
    1919  public function pixel_base_code() {
     20    if (Snappic_Integration::instance()->get_option('skip_pixel')) {
     21      return;
     22    }
     23
    2024    $params = self::add_version_info();
    2125
     
    3034document,'script','https://connect.facebook.net/en_US/fbevents.js');
    3135%s
    32 fbq('track', 'PageView', %s);
     36fbq('trackSingle', '%s', 'PageView', %s);
    3337
    3438<!-- Support AJAX add to cart -->
     
    5559      ",
    5660      $this->pixel_init_code(),
     61      $this->pixel_id,
    5762      json_encode($params, JSON_PRETTY_PRINT | JSON_FORCE_OBJECT),
    5863      esc_js($this->pixel_id));
     
    6368  * instead of Snappic_Pixel::build_event()
    6469  */
    65   public function inject_event($event_name, $params, $method='track') {
     70  public function inject_event($event_name, $params, $method='trackSingle') {
     71    if (Snappic_Integration::instance()->get_option('skip_pixel')) {
     72      return;
     73    }
     74
    6675    $code = self::build_event($event_name, $params, $method);
    6776    wc_enqueue_js($code);
     
    7281  * this method is available if you need to modify the JS code somehow
    7382  */
    74   public static function build_event($event_name, $params, $method='track') {
     83  public static function build_event($event_name, $params, $method='trackSingle') {
     84    if (Snappic_Integration::instance()->get_option('skip_pixel')) {
     85      return;
     86    }
     87
    7588    $params = self::add_version_info($params);
    7689    return sprintf(
    7790      "// WooCommerce Snappic Integration Event Tracking\n".
    78       "fbq('%s', '%s', %s);",
     91      "fbq('%s', '%s', '%s', %s);",
    7992      $method,
     93      Snappic_Integration::instance()->get_option('pixel_id'),
    8094      $event_name,
    8195      json_encode($params, JSON_PRETTY_PRINT | JSON_FORCE_OBJECT));
  • snappic/tags/1.2/languages/snappic-for-woocommerce.pot

    r1987816 r2273701  
    33msgid ""
    44msgstr ""
    5 "Project-Id-Version: Snappic for WooCommerce 1.1.0\n"
     5"Project-Id-Version: Snappic for WooCommerce 1.2.0\n"
    66"Report-Msgid-Bugs-To: "
    77"https://wordpress.org/support/plugin/snappic-for-woocommerce\n"
  • snappic/tags/1.2/readme.txt

    r2271526 r2273701  
    55Requires at least: 4.7
    66Tested up to: 5.0
    7 Stable tag: 1.1
     7Stable tag: 1.2
    88License: GPLv3
    99License URI: http://www.gnu.org/licenses/gpl-3.0.html
     
    4747== Changelog ==
    4848
     49= 1.2 (2020-3-31) =
     50
     51* Track pixel activity by `trackSingle`
     52* Skip pixel injection if needed
     53
    4954= 1.1 (2018-12-7) =
    5055* Updated to the new API url
  • snappic/tags/1.2/snappic-for-woocommerce.php

    r2271526 r2273701  
    44Plugin URI: https://wordpress.org/plugins/snappic-for-woocommerce/
    55Description: Link your WooCommerce store to Snappic
    6 Version: 1.1.0
     6Version: 1.2.0
    77Author: Snappic
    88Author URI: https://www.snappic.io
     
    1515
    1616class Snappic_Base {
    17     const VERSION = '1.1.0';
     17    const VERSION = '1.2.0';
    1818    const REQUIRED_WOO = '3.1.0';
    1919
  • snappic/trunk/includes/class-snappic-api-controller.php

    r1874793 r2273701  
    3434    ) );
    3535
     36    register_rest_route( $this->namespace, '/' . $this->rest_base . '/get_setting', array(
     37      array(
     38        'methods'             => WP_REST_Server::READABLE,
     39        'callback'            => array( $this, 'get_setting' ),
     40        'permission_callback' => array( $this, 'get_items_permissions_check' ),
     41        'args'                => $this->get_collection_params(),
     42      ),
     43      'schema' => array( $this, 'get_public_item_schema' ),
     44    ) );
     45
     46    register_rest_route( $this->namespace, '/' . $this->rest_base . '/set_setting', array(
     47      array(
     48        'methods'             => WP_REST_Server::READABLE,
     49        'callback'            => array( $this, 'set_setting' ),
     50        'permission_callback' => array( $this, 'get_items_permissions_check' ),
     51        'args'                => $this->get_collection_params(),
     52      ),
     53      'schema' => array( $this, 'get_public_item_schema' ),
     54    ) );
     55
    3656  }
    3757 
     
    5676 
    5777    return rest_ensure_response( $data );
     78  }
     79
     80  public function get_setting( $request ) {
     81    return rest_ensure_response(
     82      array($request['param'] => Snappic_Integration::instance()->get_option($request['param']))
     83    );
     84  }
     85
     86  public function set_setting( $request ) {
     87    Snappic_Helper::get_instance()->update_options(array($request['param'] => $request['value']));
     88
     89    return rest_ensure_response( array('success' => true) );
    5890  }
    5991
  • snappic/trunk/includes/class-snappic-pixel-display.php

    r1715114 r2273701  
    148148
    149149    // @Todo: do we need to SSL verify? Skipping for now
    150     $result = wp_safe_remote_get( $url, array( 'sslverify'   => false ) );
     150    $result = wp_safe_remote_get( $url, array( 'sslverify' => false, 'timeout' => 10 ) );
    151151
    152152    if( ! is_wp_error( $result ) ) {
  • snappic/trunk/includes/class-snappic-pixel.php

    r1715114 r2273701  
    1818  */
    1919  public function pixel_base_code() {
     20    if (Snappic_Integration::instance()->get_option('skip_pixel')) {
     21      return;
     22    }
     23
    2024    $params = self::add_version_info();
    2125
     
    3034document,'script','https://connect.facebook.net/en_US/fbevents.js');
    3135%s
    32 fbq('track', 'PageView', %s);
     36fbq('trackSingle', '%s', 'PageView', %s);
    3337
    3438<!-- Support AJAX add to cart -->
     
    5559      ",
    5660      $this->pixel_init_code(),
     61      $this->pixel_id,
    5762      json_encode($params, JSON_PRETTY_PRINT | JSON_FORCE_OBJECT),
    5863      esc_js($this->pixel_id));
     
    6368  * instead of Snappic_Pixel::build_event()
    6469  */
    65   public function inject_event($event_name, $params, $method='track') {
     70  public function inject_event($event_name, $params, $method='trackSingle') {
     71    if (Snappic_Integration::instance()->get_option('skip_pixel')) {
     72      return;
     73    }
     74
    6675    $code = self::build_event($event_name, $params, $method);
    6776    wc_enqueue_js($code);
     
    7281  * this method is available if you need to modify the JS code somehow
    7382  */
    74   public static function build_event($event_name, $params, $method='track') {
     83  public static function build_event($event_name, $params, $method='trackSingle') {
     84    if (Snappic_Integration::instance()->get_option('skip_pixel')) {
     85      return;
     86    }
     87
    7588    $params = self::add_version_info($params);
    7689    return sprintf(
    7790      "// WooCommerce Snappic Integration Event Tracking\n".
    78       "fbq('%s', '%s', %s);",
     91      "fbq('%s', '%s', '%s', %s);",
    7992      $method,
     93      Snappic_Integration::instance()->get_option('pixel_id'),
    8094      $event_name,
    8195      json_encode($params, JSON_PRETTY_PRINT | JSON_FORCE_OBJECT));
  • snappic/trunk/languages/snappic-for-woocommerce.pot

    r1987816 r2273701  
    33msgid ""
    44msgstr ""
    5 "Project-Id-Version: Snappic for WooCommerce 1.1.0\n"
     5"Project-Id-Version: Snappic for WooCommerce 1.2.0\n"
    66"Report-Msgid-Bugs-To: "
    77"https://wordpress.org/support/plugin/snappic-for-woocommerce\n"
  • snappic/trunk/readme.txt

    r1987816 r2273701  
    55Requires at least: 4.7
    66Tested up to: 5.0
    7 Stable tag: 1.1
     7Stable tag: 1.2
    88License: GPLv3
    99License URI: http://www.gnu.org/licenses/gpl-3.0.html
     
    4747== Changelog ==
    4848
     49= 1.2 (2020-3-31) =
     50
     51* Track pixel activity by `trackSingle`
     52* Skip pixel injection if needed
     53
    4954= 1.1 (2018-12-7) =
    5055* Updated to the new API url
  • snappic/trunk/snappic-for-woocommerce.php

    r1987816 r2273701  
    44Plugin URI: https://wordpress.org/plugins/snappic-for-woocommerce/
    55Description: Link your WooCommerce store to Snappic
    6 Version: 1.1.0
     6Version: 1.2.0
    77Author: Snappic
    88Author URI: https://www.snappic.io
     
    1515
    1616class Snappic_Base {
    17     const VERSION = '1.1.0';
     17    const VERSION = '1.2.0';
    1818    const REQUIRED_WOO = '3.1.0';
    1919
Note: See TracChangeset for help on using the changeset viewer.