Plugin Directory

Changeset 2062753


Ignore:
Timestamp:
04/04/2019 07:14:57 AM (7 years ago)
Author:
storespot
Message:

v1.1.1

Location:
storespot
Files:
16 edited
1 copied

Legend:

Unmodified
Added
Removed
  • storespot/tags/1.1.1/admin/class-storespot-api.php

    r2042059 r2062753  
    1616            'permission_callback' => array( $this, 'get_settings_permission_check' ),
    1717        ));
    18 
    19         register_rest_route( $this->namespace, '/storespot/feed/', array(
    20             'methods'                       => WP_REST_SERVER::READABLE,
    21             'callback'                      => array( $this, 'update_storespot_feed' ),
    22             'permission_callback' => array( $this, 'get_settings_permission_check' ),
    23         ) );
    2418    }
    2519
     
    6559
    6660    public function get_storespot_settings($request) {
     61        $custom_logo_id = get_theme_mod( 'custom_logo' );
     62        $image = wp_get_attachment_image_src( $custom_logo_id , 'full' );
     63
    6764        $data = array(
    6865            'settings'      => get_option( 'storespot_settings' ),
    69             'feed'          => get_option( 'storespot_feed' ),
     66            'logo'          => $image[0],
    7067            'stsp_version'  => STORESPOT_VERSION,
    7168            'wp_version'    => get_bloginfo( 'version' ),
     
    7875    }
    7976
    80     public function update_storespot_feed() {
    81         do_action('stsp_call_async_feed_update');
    82         $response = rest_ensure_response(array( 'received' => true ));
    83         $response->set_status(200);
    84         return $response;
    85     }
    86 
    8777}
  • storespot/tags/1.1.1/includes/class-storespot-activator.php

    r2042059 r2062753  
    1111                'pixel_id' => null,
    1212                'pixel_enabled' => false,
    13                 'feed_enabled' => false,
    14                 'product_category' => 0,
    1513            ];
    1614            add_option( 'storespot_settings', $options );
    17             add_option( 'storespot_feed', null );
    1815        }
    1916
  • storespot/tags/1.1.1/includes/class-storespot-deactivator.php

    r2042059 r2062753  
    33    public static function deactivate() {
    44        delete_option( 'storespot_settings' );
    5         delete_option( 'storespot_feed' );
    65    }
    76}
  • storespot/tags/1.1.1/includes/class-storespot.php

    r2042059 r2062753  
    4343    private function load_dependencies() {
    4444        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-storespot-loader.php';
    45         require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-storespot-productfeed.php';
    4645        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-storespot-messages.php';
    4746        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-storespot-api.php';
    48         require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-storespot-async.php';
    4947        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-storespot-events.php';
    5048        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-storespot-facebook-pixel.php';
     
    5250        if(
    5351            ! class_exists( 'StoreSpot_Loader' ) ||
    54             ! class_exists( 'StoreSpot_Product_Feed' ) ||
    5552            ! class_exists( 'StoreSpot_Messages' ) ||
    5653            ! class_exists( 'StoreSpot_API' ) ||
    5754            ! class_exists( 'StoreSpot_Events' ) ||
    58             ! class_exists( 'StoreSpot_Facebook_Pixel' ) ||
    59             ! class_exists( 'StoreSpot_Async' )
     55            ! class_exists( 'StoreSpot_Facebook_Pixel' )
    6056        ) {
    6157            return false;
     
    6864    private function define_admin_hooks() {
    6965            $admin_message = new StoreSpot_Messages();
    70             $async_request = new StoreSpot_Async();
    71             $products_feed = new StoreSpot_Product_Feed();
    7266            $this->loader->add_action( 'admin_notices', $admin_message, 'activation_notice' );
    73             $this->loader->add_action( 'wp_ajax_' . $async_request->get_ajax_action(), $async_request, 'execute' );
    74             $this->loader->add_action( 'wp_ajax_nopriv_' . $async_request->get_ajax_action(), $async_request, 'execute' );
    75             $this->loader->add_action( 'stsp_call_async_feed_update', $async_request, 'call' );
    76             $this->loader->add_action( $async_request->get_feed_action(), $products_feed, 'write_product_feed' );
    7767    }
    7868
  • storespot/tags/1.1.1/public/class-storespot-events.php

    r2042059 r2062753  
    1717
    1818    public function get_facebook_content_id($product) {
    19         $product_id = $product->get_id();
    2019        return 'stsp_' . $product->get_id();
    2120    }
     
    10099        $products = $woocommerce->cart->get_cart();
    101100        $product_ids = array();
     101        $prices = array();
    102102        foreach ( $products as $item ) {
    103             $product_ids[] = $this->get_facebook_content_id( $item['data'] );
    104         }
    105 
    106         $params = array();
    107         $params['content_ids'] = json_encode( $product_ids );
    108         $params['content_type'] = 'product';
    109         $params['value'] = $woocommerce->cart->total;
     103            $product = $item['data'];
     104            $product_ids[] = $this->get_facebook_content_id( $product );
     105            $prices[] = number_format( $product->get_price(), 2) * $item['quantity'];
     106        }
     107
     108        $params = array();
     109        $params['content_ids'] = json_encode( $product_ids );
     110        $params['content_type'] = 'product';
     111        $params['value'] = array_sum( $prices );
    110112        $params['currency'] = get_woocommerce_currency();
    111113        $this->facebook_pixel->event_code( 'AddToCart', $params );
     
    127129
    128130        $product_ids = array();
     131        $prices = array();
    129132        foreach ( $products as $item ) {
    130             $product_ids[] = $this->get_facebook_content_id( $item['data'] );
    131         }
    132 
    133         $params = array();
    134         $params['content_ids'] = json_encode( $product_ids );
    135         $params['content_type'] = 'product';
    136         $params['value'] = $woocommerce->cart->total;
     133            $product = $item['data'];
     134            $product_ids[] = $this->get_facebook_content_id( $product );
     135            $prices[] = number_format( $product->get_price(), 2) * $item['quantity'];
     136        }
     137
     138        $params = array();
     139        $params['content_ids'] = json_encode( $product_ids );
     140        $params['content_type'] = 'product';
     141        $params['value'] = array_sum( $prices );
    137142        $params['currency'] = get_woocommerce_currency();
    138143
     
    151156        $products = $woocommerce->cart->get_cart();
    152157        $product_ids = array();
     158        $prices = array();
    153159        foreach ( $products as $item ) {
    154             $product_id[] = $this->get_facebook_content_id( $item['data'] );
    155         }
    156 
    157         $params = array();
    158         $params['content_ids'] = json_encode( $product_ids );
    159         $params['content_type'] = 'product';
    160         $params['value'] = $woocommerce->cart->total;
     160            $product = $item['data'];
     161            $product_ids[] = $this->get_facebook_content_id( $product );
     162            $prices[] = number_format( $product->get_price(), 2) * $item['quantity'];
     163        }
     164
     165        $params = array();
     166        $params['content_ids'] = json_encode( $product_ids );
     167        $params['content_type'] = 'product';
     168        $params['value'] = array_sum( $prices );
    161169        $params['currency'] = get_woocommerce_currency();
    162170        $params['num_items'] = $woocommerce->cart->get_cart_contents_count();
     
    171179
    172180        $order = wc_get_order( $order_id );
    173         $content_type = 'product';
    174181        $product_ids = array();
    175182        foreach ( $order->get_items() as $item ) {
    176183            $product = $item->get_product();
    177184            $product_ids[] = $this->get_facebook_content_id( $product );
    178             if( $product->get_type() == 'variable' ) {
    179                 $content_type = 'product_group';
    180             }
    181         }
    182 
    183         $params = array();
    184         $params['content_ids'] = json_encode( $product_ids );
    185         $params['content_type'] = $content_type;
     185        }
     186
     187        $params = array();
     188        $params['content_ids'] = json_encode( $product_ids );
     189        $params['content_type'] = 'product';
    186190        $params['value'] = $order->get_total();
    187191        $params['currency'] = get_woocommerce_currency();
  • storespot/tags/1.1.1/readme.txt

    r2042059 r2062753  
    22Contributors: storespot
    33Tags: woocommerce, facebook, dynamic ads, retargeting, woocommerce marketing, remarketing
    4 Requires at least: 4.4.0
     4Requires at least: 4.5.0
    55Tested up to: 5.1
    66Requires PHP: 5.6
    7 Stable tag: 1.1.0
     7Stable tag: 1.1.1
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    4949
    5050== Changelog ==
     51= 1.1.1 =
     52* Support for off-site feed generation
    5153
    5254= 1.1.0 =
  • storespot/tags/1.1.1/storespot.php

    r2042059 r2062753  
    44 * Plugin URI:   https://storespot.io/
    55 * Description:  Stop leaving money on the table. Automate your retargeting ads with StoreSpot.
    6  * Version:      1.1.0
     6 * Version:      1.1.1
    77 * Author:       StoreSpot
    88**/
     
    1111if ( ! defined( 'WPINC' ) ) { die; }
    1212
    13 define( 'STORESPOT_VERSION', '1.1.0' );
     13define( 'STORESPOT_VERSION', '1.1.1' );
    1414
    1515function activate_storespot() {
  • storespot/trunk/admin/class-storespot-api.php

    r2042059 r2062753  
    1616            'permission_callback' => array( $this, 'get_settings_permission_check' ),
    1717        ));
    18 
    19         register_rest_route( $this->namespace, '/storespot/feed/', array(
    20             'methods'                       => WP_REST_SERVER::READABLE,
    21             'callback'                      => array( $this, 'update_storespot_feed' ),
    22             'permission_callback' => array( $this, 'get_settings_permission_check' ),
    23         ) );
    2418    }
    2519
     
    6559
    6660    public function get_storespot_settings($request) {
     61        $custom_logo_id = get_theme_mod( 'custom_logo' );
     62        $image = wp_get_attachment_image_src( $custom_logo_id , 'full' );
     63
    6764        $data = array(
    6865            'settings'      => get_option( 'storespot_settings' ),
    69             'feed'          => get_option( 'storespot_feed' ),
     66            'logo'          => $image[0],
    7067            'stsp_version'  => STORESPOT_VERSION,
    7168            'wp_version'    => get_bloginfo( 'version' ),
     
    7875    }
    7976
    80     public function update_storespot_feed() {
    81         do_action('stsp_call_async_feed_update');
    82         $response = rest_ensure_response(array( 'received' => true ));
    83         $response->set_status(200);
    84         return $response;
    85     }
    86 
    8777}
  • storespot/trunk/includes/class-storespot-activator.php

    r2042059 r2062753  
    1111                'pixel_id' => null,
    1212                'pixel_enabled' => false,
    13                 'feed_enabled' => false,
    14                 'product_category' => 0,
    1513            ];
    1614            add_option( 'storespot_settings', $options );
    17             add_option( 'storespot_feed', null );
    1815        }
    1916
  • storespot/trunk/includes/class-storespot-deactivator.php

    r2042059 r2062753  
    33    public static function deactivate() {
    44        delete_option( 'storespot_settings' );
    5         delete_option( 'storespot_feed' );
    65    }
    76}
  • storespot/trunk/includes/class-storespot.php

    r2042059 r2062753  
    4343    private function load_dependencies() {
    4444        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-storespot-loader.php';
    45         require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-storespot-productfeed.php';
    4645        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-storespot-messages.php';
    4746        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-storespot-api.php';
    48         require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-storespot-async.php';
    4947        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-storespot-events.php';
    5048        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-storespot-facebook-pixel.php';
     
    5250        if(
    5351            ! class_exists( 'StoreSpot_Loader' ) ||
    54             ! class_exists( 'StoreSpot_Product_Feed' ) ||
    5552            ! class_exists( 'StoreSpot_Messages' ) ||
    5653            ! class_exists( 'StoreSpot_API' ) ||
    5754            ! class_exists( 'StoreSpot_Events' ) ||
    58             ! class_exists( 'StoreSpot_Facebook_Pixel' ) ||
    59             ! class_exists( 'StoreSpot_Async' )
     55            ! class_exists( 'StoreSpot_Facebook_Pixel' )
    6056        ) {
    6157            return false;
     
    6864    private function define_admin_hooks() {
    6965            $admin_message = new StoreSpot_Messages();
    70             $async_request = new StoreSpot_Async();
    71             $products_feed = new StoreSpot_Product_Feed();
    7266            $this->loader->add_action( 'admin_notices', $admin_message, 'activation_notice' );
    73             $this->loader->add_action( 'wp_ajax_' . $async_request->get_ajax_action(), $async_request, 'execute' );
    74             $this->loader->add_action( 'wp_ajax_nopriv_' . $async_request->get_ajax_action(), $async_request, 'execute' );
    75             $this->loader->add_action( 'stsp_call_async_feed_update', $async_request, 'call' );
    76             $this->loader->add_action( $async_request->get_feed_action(), $products_feed, 'write_product_feed' );
    7767    }
    7868
  • storespot/trunk/public/class-storespot-events.php

    r2042059 r2062753  
    1717
    1818    public function get_facebook_content_id($product) {
    19         $product_id = $product->get_id();
    2019        return 'stsp_' . $product->get_id();
    2120    }
     
    10099        $products = $woocommerce->cart->get_cart();
    101100        $product_ids = array();
     101        $prices = array();
    102102        foreach ( $products as $item ) {
    103             $product_ids[] = $this->get_facebook_content_id( $item['data'] );
    104         }
    105 
    106         $params = array();
    107         $params['content_ids'] = json_encode( $product_ids );
    108         $params['content_type'] = 'product';
    109         $params['value'] = $woocommerce->cart->total;
     103            $product = $item['data'];
     104            $product_ids[] = $this->get_facebook_content_id( $product );
     105            $prices[] = number_format( $product->get_price(), 2) * $item['quantity'];
     106        }
     107
     108        $params = array();
     109        $params['content_ids'] = json_encode( $product_ids );
     110        $params['content_type'] = 'product';
     111        $params['value'] = array_sum( $prices );
    110112        $params['currency'] = get_woocommerce_currency();
    111113        $this->facebook_pixel->event_code( 'AddToCart', $params );
     
    127129
    128130        $product_ids = array();
     131        $prices = array();
    129132        foreach ( $products as $item ) {
    130             $product_ids[] = $this->get_facebook_content_id( $item['data'] );
    131         }
    132 
    133         $params = array();
    134         $params['content_ids'] = json_encode( $product_ids );
    135         $params['content_type'] = 'product';
    136         $params['value'] = $woocommerce->cart->total;
     133            $product = $item['data'];
     134            $product_ids[] = $this->get_facebook_content_id( $product );
     135            $prices[] = number_format( $product->get_price(), 2) * $item['quantity'];
     136        }
     137
     138        $params = array();
     139        $params['content_ids'] = json_encode( $product_ids );
     140        $params['content_type'] = 'product';
     141        $params['value'] = array_sum( $prices );
    137142        $params['currency'] = get_woocommerce_currency();
    138143
     
    151156        $products = $woocommerce->cart->get_cart();
    152157        $product_ids = array();
     158        $prices = array();
    153159        foreach ( $products as $item ) {
    154             $product_id[] = $this->get_facebook_content_id( $item['data'] );
    155         }
    156 
    157         $params = array();
    158         $params['content_ids'] = json_encode( $product_ids );
    159         $params['content_type'] = 'product';
    160         $params['value'] = $woocommerce->cart->total;
     160            $product = $item['data'];
     161            $product_ids[] = $this->get_facebook_content_id( $product );
     162            $prices[] = number_format( $product->get_price(), 2) * $item['quantity'];
     163        }
     164
     165        $params = array();
     166        $params['content_ids'] = json_encode( $product_ids );
     167        $params['content_type'] = 'product';
     168        $params['value'] = array_sum( $prices );
    161169        $params['currency'] = get_woocommerce_currency();
    162170        $params['num_items'] = $woocommerce->cart->get_cart_contents_count();
     
    171179
    172180        $order = wc_get_order( $order_id );
    173         $content_type = 'product';
    174181        $product_ids = array();
    175182        foreach ( $order->get_items() as $item ) {
    176183            $product = $item->get_product();
    177184            $product_ids[] = $this->get_facebook_content_id( $product );
    178             if( $product->get_type() == 'variable' ) {
    179                 $content_type = 'product_group';
    180             }
    181         }
    182 
    183         $params = array();
    184         $params['content_ids'] = json_encode( $product_ids );
    185         $params['content_type'] = $content_type;
     185        }
     186
     187        $params = array();
     188        $params['content_ids'] = json_encode( $product_ids );
     189        $params['content_type'] = 'product';
    186190        $params['value'] = $order->get_total();
    187191        $params['currency'] = get_woocommerce_currency();
  • storespot/trunk/readme.txt

    r2042059 r2062753  
    22Contributors: storespot
    33Tags: woocommerce, facebook, dynamic ads, retargeting, woocommerce marketing, remarketing
    4 Requires at least: 4.4.0
     4Requires at least: 4.5.0
    55Tested up to: 5.1
    66Requires PHP: 5.6
    7 Stable tag: 1.1.0
     7Stable tag: 1.1.1
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    4949
    5050== Changelog ==
     51= 1.1.1 =
     52* Support for off-site feed generation
    5153
    5254= 1.1.0 =
  • storespot/trunk/storespot.php

    r2042059 r2062753  
    44 * Plugin URI:   https://storespot.io/
    55 * Description:  Stop leaving money on the table. Automate your retargeting ads with StoreSpot.
    6  * Version:      1.1.0
     6 * Version:      1.1.1
    77 * Author:       StoreSpot
    88**/
     
    1111if ( ! defined( 'WPINC' ) ) { die; }
    1212
    13 define( 'STORESPOT_VERSION', '1.1.0' );
     13define( 'STORESPOT_VERSION', '1.1.1' );
    1414
    1515function activate_storespot() {
Note: See TracChangeset for help on using the changeset viewer.