Plugin Directory

Changeset 1695978


Ignore:
Timestamp:
07/13/2017 09:17:01 PM (9 years ago)
Author:
trustedsite
Message:

Detech woocommerce

Location:
trustedsite-reviews/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trustedsite-reviews/trunk/js/overview.js

    r1658867 r1695978  
    88    var endpointUrl = "https://www.trustedsite.com"
    99
    10     var refreshInterval;
     10    var refreshInterval;   
    1111
    1212    function refresh(){
    1313        var apiUrl = endpointUrl + '/rpc/ajax?do=lookup-site-status&jsoncallback=?&rand='+new Date().getTime()+'&host=' + encodeURIComponent(host);
     14        var woocommerce = parseInt($("#ts-data").attr("data-woocommerce"));
    1415        jQuery.getJSON(apiUrl,function(data) {
    1516            console.log(data);
     
    1718            if(status === 'none'){
    1819                jQuery("#manage").hide();
     20                jQuery("#settings").hide();
     21
     22                jQuery("#pitch").show();
    1923                jQuery("#activation").show();
    2024            }else{
    2125                siteId = data['siteId'];
     26
    2227                jQuery("#activation").hide();
     28                jQuery("#pitch").hide();
     29
     30                if(woocommerce && false){
     31                    jQuery("#settings").show();
     32                }else{
     33                    jQuery("#pitch").show();
     34                }
     35               
    2336                jQuery("#manage").show();
     37
    2438                setTimeout(function(){
    2539                    clearInterval(refreshInterval);
     
    4357            var host = $("#host").val();
    4458            var email = $("#email").val();
    45             var signupUrl = endpointUrl + "/app/partner/signup?ctx=popup&host=" + encodeURIComponent(host) + "&email=" + encodeURIComponent(email) + "&aff=472614&platform=5&ctx=popup";
     59            var signupUrl = endpointUrl + "/app/partner/signup?ctx=popup&host=" + encodeURIComponent(host) + "&email=" + encodeURIComponent(email) + "&platformId=5&ctx=popup&affId=6";
    4660            var signupWindow = window.open(signupUrl, "_blank", "width=900 height=700 left=" + left + " top=" + top);
    4761        });
     
    5266            window.open(endpointUrl + "/user/reviews/?siteId="+ siteId, "_blank", "width=900 height=700 left=" + left + " top=" + top);
    5367        });
     68
     69        jQuery("#ts-product-reviews-gallery").change(updateSettings);
     70        jQuery("#ts-product-stars").change(updateSettings);
     71
    5472        refreshInterval = setInterval(refresh, 1000);
     73    }
     74
     75    function updateSettings(){
     76        var postData = {
     77            action: 'ts_reviews_update_settings',
     78            ts_product_reviews_gallery_enabled: jQuery("#ts-product-reviews-gallery").is(":checked") ? 1 : 0,
     79            ts_product_stars_enabled: jQuery("#ts-product-stars").is(":checked") ? 1 : 0
     80        }; 
     81        console.log(ajaxObj.ajax_url);
     82        console.log(postData);
     83
     84        $.post(ajaxObj.ajax_url, postData, function (data) {
     85            console.log(data);
     86        });
    5587    }
    5688
  • trustedsite-reviews/trunk/lib/App.php

    r1658870 r1695978  
    33if ( ! defined( 'ABSPATH' ) ) exit;
    44
     5require_once('AdminApi.php');
    56class  App
    67{
     
    1516        add_action('admin_menu', 'TSReviews\App::adminMenus');
    1617        add_action('wp_footer', 'TSReviews\App::injectMainCode');
    17         add_action('admin_enqueue_scripts', 'TSReviews\App::scripts');
     18        add_action('admin_enqueue_scripts', 'TSReviews\App::scripts');       
    1819
    19         if (in_array('woocommerce/woocommerce.php', apply_filters('active_plugins', get_option('active_plugins')))) {
    20             App::install_woocommerce();
     20        if (App::hasWoocommerce()) {
     21            add_action('wp_ajax_ts_reviews_update_settings', 'TSReviews\AdminApi::updateSettings');
     22            App::installWoocommerce();
    2123        }
    2224    }
    2325
    24     public static function post_purchase_review($order_id)
     26    public static function hasWoocommerce(){
     27        return in_array('woocommerce/woocommerce.php', apply_filters('active_plugins', get_option('active_plugins')));
     28    }
     29
     30    public static function postPurchaseReview($order_id)
    2531    {
    2632        $endpoint_host = "https://www.trustedsite.com";
     
    5056    }
    5157
    52     public static function install_woocommerce()
     58    public static function installWoocommerce()
    5359    {
    54         add_action('woocommerce_thankyou', 'TSReviews\App::post_purchase_review');
     60        add_action('woocommerce_thankyou', 'TSReviews\App::postPurchaseReview');   
     61        if(intval(get_option(AdminApi::PRODUCT_REVIEWS_GALLERY_ENABLED_OPT)) == 1){
     62            add_action('woocommerce_after_single_product', 'TSReviews\App::installProductReviewsGallery');
     63        }
     64
     65        if(intval(get_option(AdminApi::PRODUCT_STARS_ENABLED_OPT)) == 1){
     66            add_action('woocommerce_single_product_summary', 'TSReviews\App::installProductPageStars');
     67        }
    5568    }
    5669
     
    6477       
    6578    }
     79
     80    public static function installProductPageStars(){
     81        global $product;
     82        $id = $product->id;
     83
     84        echo "<div class=\"trustedsite-widget\" data-type=\"7\" data-product-id=\"".$id."\"></div>";
     85    }
     86
     87    public static function installProductReviewsGallery()
     88    {
     89        global $product;
     90        $id = $product->id;
     91        echo "<div class=\"trustedsite-widget\" data-type=\"5\" data-product-id=\"".$id."\"></div><script src='".plugins_url('../widgets/product_review_gallery.js', __FILE__)."'></script>";
     92    }   
    6693
    6794    public static function scripts($hook) {
  • trustedsite-reviews/trunk/readme.txt

    r1678590 r1695978  
    44Requires at least: 4.2.0
    55Tested up to: 4.8.0
    6 Stable tag: 1.0.0
     6Stable tag: 1.0.1
    77License: GPLv2 or later
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    6565== Changelog ==
    6666
     67= 1.1 =
     68* Add settings page and affiliate ID
     69
    6770= 1.0 =
    6871* The initial release
  • trustedsite-reviews/trunk/trustedsite-reviews.php

    r1658867 r1695978  
    55 * ------------------------------------------------------------------------------------------------------------------
    66 * @package trustedsite-reviews
    7  * @version 1.0.0
     7 * @version 1.0.1
    88 * Plugin Name: TrustedSite Reviews
    99 * Description: Add TrustedSite Reviews to your site and start showing visitors how great your business is.
    1010 * Author: TrustedSite
    11  * Version: 1.0.0
     11 * Version: 1.0.1
    1212 * Author URI: https://www.trustedsite.com/
    1313 * ------------------------------------------------------------------------------------------------------------------
     
    1717    return;
    1818}
    19 define('TS_REVIEWS', '1.0.0');
     19define('TS_REVIEWS', '1.0.1');
    2020
    2121add_action('activated_plugin','ts_reviews_save_activation_error');
  • trustedsite-reviews/trunk/views/overview.php

    r1658867 r1695978  
    55$arrHost = parse_url(home_url('', $scheme = 'http'));
    66$host = $arrHost['host'];
    7 
     7$woocommerce = in_array('woocommerce/woocommerce.php', apply_filters('active_plugins', get_option('active_plugins'))) ? 1 : 0;
     8$ts_product_reviews_gallery_enabled = intval(get_option('ts_product_reviews_gallery_enabled', 0));
     9$ts_product_stars_enabled = intval(get_option('ts_product_stars_enabled', 0));
    810?>
    9 <div id="ts-data" data-host="<?php echo $host; ?>" data-emai="<?php echo $email; ?>"></div>
     11<div id="ts-data" data-host="<?php echo $host; ?>" data-email="<?php echo $email; ?>" data-woocommerce="<?php echo $woocommerce; ?>"></div>
    1012<div class="wrap" id="overview">
    1113
     
    1719            <div id="postbox-container-2" class="postbox-container">
    1820                <div class="postbox">
    19                     <div class="meta-box-sortables">
     21                    <div class="meta-box-sortables" style="display:none;" id="pitch">
    2022                        <h2 class="hndle"><span>About TrustedSite Reviews</span></h2>
    2123
     
    5153                        </div>
    5254                    </div>
     55
     56                    <div class="meta-box-sortables" style="display:none;" id="settings">
     57                        <h2 class="hndle"><span>Widget Settings</span></h2>
     58
     59                        <div class="inside">
     60                            <table class="form-table">
     61                                <tbody>
     62                                <tr valign="top">
     63                                    <th scope="row" class="titledesc" style="width: 40%">
     64                                        <label >Product Reviews Gallery</label>
     65                                    </th>
     66                                    <td class="forminp forminp-checkbox">
     67                                        <label>
     68                                            <input type="checkbox" id="ts-product-reviews-gallery" value="1" <?php echo $ts_product_reviews_gallery_enabled == 1 ? "checked" : "" ?>>
     69                                            Enable
     70                                        </label>                                       
     71                                    </td>
     72                                </tr>
     73                                <tr valign="top">
     74                                    <th scope="row" class="titledesc">
     75                                        <label >Product Stars</label>
     76                                    </th>
     77                                    <td class="forminp forminp-checkbox">
     78                                        <label>
     79                                            <input type="checkbox" id="ts-product-stars" value="1" <?php echo $ts_product_stars_enabled == 1 ? "checked" : "" ?>>
     80                                            Enable
     81                                        </label>                                       
     82                                    </td>
     83                                </tr>
     84                                </tbody>
     85                            </table>
     86                        </div>
     87                    </div>
    5388                </div>
    5489            </div>
     90
    5591            <div id="activation" style="display:none;">
    5692                <div id="postbox-container-1" class="postbox-container">
     
    103139                                    <input type="submit" class="button button-primary" value="Manage Account" style="margin-top: 8px; display: inline-block;" id="manage-account">
    104140                                </div>
    105 
    106141                            </div>
    107142                        </div>
Note: See TracChangeset for help on using the changeset viewer.