Plugin Directory

Changeset 1546006


Ignore:
Timestamp:
12/05/2016 04:23:48 PM (9 years ago)
Author:
fomo
Message:

Added support for Yotpo integration

Location:
fomo/trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • fomo/trunk/phpseclib/Crypt/Base.php

    r1473013 r1546006  
    505505     * @access public
    506506     */
    507     function Crypt_Base($mode = CRYPT_MODE_CBC)
     507    function __construct($mode = CRYPT_MODE_CBC)
    508508    {
    509509        // $mode dependent settings
  • fomo/trunk/phpseclib/Crypt/Hash.php

    r1473013 r1546006  
    153153     * @access public
    154154     */
    155     function Crypt_Hash($hash = 'sha1')
     155    function __construct($hash = 'sha1')
    156156    {
    157157        if (!defined('CRYPT_HASH_MODE')) {
  • fomo/trunk/phpseclib/Crypt/RSA.php

    r1473013 r1546006  
    493493     * @access public
    494494     */
    495     function Crypt_RSA()
     495    function __construct()
    496496    {
    497497        if (!class_exists('Math_BigInteger')) {
  • fomo/trunk/phpseclib/File/ANSI.php

    r1473013 r1546006  
    181181     * @access public
    182182     */
    183     function File_ANSI()
     183    function __construct()
    184184    {
    185185        $attr_cell = new stdClass();
  • fomo/trunk/phpseclib/File/ASN1.php

    r1473013 r1546006  
    247247     * @access public
    248248     */
    249     function File_ASN1()
     249    function __construct()
    250250    {
    251251        static $static_init = null;
  • fomo/trunk/phpseclib/File/X509.php

    r1473013 r1546006  
    319319     * @access public
    320320     */
    321     function File_X509()
     321    function __construct()
    322322    {
    323323        if (!class_exists('Math_BigInteger')) {
  • fomo/trunk/phpseclib/Math/BigInteger.php

    r1473013 r1546006  
    245245     * @access public
    246246     */
    247     function Math_BigInteger($x = 0, $base = 10)
     247    function __construct($x = 0, $base = 10)
    248248    {
    249249        if (!defined('MATH_BIGINTEGER_MODE')) {
  • fomo/trunk/readme.txt

    r1541822 r1546006  
    102102== Changelog ==
    103103
     104= 1.0.9 =
     105* Added support for Yotpo reviews
     106
    104107= 1.0.8 =
    105108* Fixed error handling on Wordpress error
  • fomo/trunk/woocommerce-plugin-fomo.php

    r1541822 r1546006  
    44Plugin URI: https://www.usefomo.com
    55Description: Fomo displays recent orders on your WooCommerce storefront
    6 Version: 1.0.8
     6Version: 1.0.9
    77Author: fomo
    88Author URI: https://www.usefomo.com
     
    1616    $fomofwc_domain = 'https://notifyapp.io';
    1717    global $fomofwc_version;
    18     $fomofwc_version = '1.0.7';
     18    $fomofwc_version = '1.0.9';
    1919    $fomofwc_public_key = "-----BEGIN PUBLIC KEY-----
    2020MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAwKXALE9j5lHEVt6Yj1hK
     
    268268    });
    269269
     270    function fomofwc_rest_product($request)
     271    {
     272        $data = json_decode($request->get_body(), true);
     273        if (count($data) == 0) {
     274            header('HTTP/1.0 401 Unauthorized');
     275            die();
     276        }
     277
     278        $timestamp = isset($data['timestamp']) ? $data['timestamp'] : null;
     279        $signature = isset($data['signature']) ? $data['signature'] : null;
     280        $product_id = isset($data['product_id']) ? $data['product_id'] : null;
     281
     282        if (!class_exists('Crypt_RSA')) {
     283            include_once('phpseclib/Crypt/RSA.php');
     284        }
     285        $rsa = new Crypt_RSA();
     286        global $fomofwc_public_key;
     287        $rsa->loadKey($fomofwc_public_key);
     288        if ($rsa->verify($timestamp . $product_id, base64_decode($signature))) {
     289            $product = new WC_Product($product_id);
     290            $result = [
     291                'product_name' => $product->get_title(),
     292                'id' => $product_id,
     293                'product_image_url' => wp_get_attachment_url($product->get_image_id()),
     294                'product_url' => $product->get_permalink()
     295            ];
     296            return $result;
     297        } else {
     298            header('HTTP/1.0 401 Unauthorized');
     299            die();
     300        }
     301    }
     302
     303    // Access via /wp-json/fomofwc/v1/product
     304    add_action('rest_api_init', function () {
     305        register_rest_route('fomofwc', '/v1/product/', [
     306            'methods' => 'POST',
     307            'callback' => 'fomofwc_rest_product',
     308        ]);
     309    });
     310
    270311    function fomofwc_process_new_order($order_id)
    271312    {
Note: See TracChangeset for help on using the changeset viewer.