Plugin Directory

Changeset 1774331


Ignore:
Timestamp:
11/23/2017 08:17:52 PM (8 years ago)
Author:
truvisibility
Message:
  • Added available subscriptions information
  • Fixed bug at new user creation
Location:
truvisibility-plagiarism-checker/trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • truvisibility-plagiarism-checker/trunk/css/common.css

    r1773200 r1774331  
    2424    display: none;
    2525}
     26
     27td.rast-row {
     28    padding: 5px 10px;
     29}
  • truvisibility-plagiarism-checker/trunk/js/settings.js

    r1773200 r1774331  
    1717        $("#auth-code").show();
    1818        $("#auth-code-apply").click(function () {
    19             var code = $("#auth-code-value").val();
    20 
    21             $.get(restUrl + "auth/" + code)
    22                 .done(function (data, statusText, xhr) {
    23                     if (xhr.status === 200) {
    24                         window.location.reload();
    25                     }
    26                 });
     19            $.get(restUrl + "auth/" + $("#auth-code-value").val()).done(function() {
     20                $.post(restUrl + "account/ensure").done(function() {
     21                    window.location.reload();
     22                });
     23            });
    2724        });
    2825    });
     
    3936                }
    4037            });
     38    });
     39
     40    $.get(restUrl + "plans").done(function (plans) {
     41        $("#rast-plans-loading").remove();
     42       
     43        var header = $("<tr>").css("font-weight", "600")
     44            .append($("<td>").text("Name").addClass("rast-row"))
     45            .append($("<td>").text("Checks included").addClass("rast-row"))
     46            .append($("<td>").text("Price").addClass("rast-row"))
     47            .append($("<td>").text("Cost of additional check").addClass("rast-row"));
     48
     49        var table = $("#rast-plans").append(header);
     50
     51        var isFreePlanActive = plans.some(function(p) { return p.code.startsWith("free") && p.isActive; });
     52
     53        plans = plans
     54            .filter(function(p) { return p.code !== "free-12" && p.code !== "free-24" && p.code !== "free-36"; })
     55            .sort(function(a, b) { return a.price - b.price; });
     56       
     57        for (var j = 0; j < plans.length; j++) {
     58            var plan = plans[j];
     59           
     60            if (plan.code === "free-1") plan.isActive = isFreePlanActive;
     61            if (plan.code.endsWith("-1")) plan.name += " (monthly)";
     62           
     63            var subscriptionUpgradeLink = "https://sites." + umbrellaRoot + "/client/purchase#plagiarism-packages:" + plan.code.replace("-", ":");
     64           
     65            var row = $("<tr>").css("font-weight", plan.isActive ? "600" : "normal");
     66            row.append($("<td>").text(plan.name).addClass("rast-row"));
     67            row.append($("<td>").text(plan.checksPerMonth + " per month").addClass("rast-row"));
     68            row.append($("<td>").text("$" + plan.price.toFixed(2)).addClass("rast-row"));
     69            row.append($("<td>").text("$" + getExtraCheckPrice(plan.code).toFixed(2)).addClass("rast-row"));
     70            row.append($("<td>").html(plan.isActive ? 'current' : '<a href="' + subscriptionUpgradeLink + '" target="_blank">select</a>').addClass("rast-row"));
     71            table.append(row);
     72        }
     73
     74        function getExtraCheckPrice(planCode) {
     75            if (planCode.startsWith("basic")) return 1.0;
     76            if (planCode.startsWith("pro")) return 0.9;
     77            return 1.3;
     78        }
    4179    });
    4280
  • truvisibility-plagiarism-checker/trunk/readme.txt

    r1773200 r1774331  
    1313TruVisibility Plagiarism Checker plugin for WordPress helps you find out which pages on the Web have quoted or copied your original content and whether they have violated your intellectual property and publishing permissions. It also helps you ensure that your content is original as well.
    1414
    15 When TruVisibility Plagiarism Checker detects a page which used your content against permitted usage, a single click enables you to obtain this user’s “WHOIS” information such as name, email, phone and address, enabling you to send a DMCA notice in order to take down that pages.
     15When TruVisibility Plagiarism Checker detects a page which used your content against permitted usage, a single click enables you to obtain this user's WHOIS information such as name, email, phone and address, enabling you to send a DMCA notice in order to take down that pages.
    1616
    1717Not only does TruVisibility Plagiarism Checker help protect your content, but it also provides you with a valuable tool to track the way others react to your content in order to understand how to improve your publishing experience.
     
    3030* Disable email alerts for specific domains.
    3131* Ability to exclude certain categories and posts from schedule check.
    32 * Easily grab user’s WHOIS information for domains that contains pirated pages to help you send DMCA notification.
     32* Easily grab user's WHOIS information for domains that contains pirated pages to help you send DMCA notification.
    3333
    3434== Installation ==
  • truvisibility-plagiarism-checker/trunk/services/TruVisibilityPlagiarismRestApi.php

    r1773200 r1774331  
    1818        register_rest_route('truvisibility/plagiarism/v1', '/auth/(?P<code>[\\w\\d]+)', array('methods' => 'GET', 'callback' => array($this, 'complete_authorization')));
    1919        register_rest_route('truvisibility/plagiarism/v1', '/auth/clean', array('methods' => 'POST', 'callback' => array($this, 'clean_authorization')));
     20        register_rest_route('truvisibility/plagiarism/v1', '/plans', array('methods' => 'GET', 'callback' => array($this, 'get_plans')));
    2021        register_rest_route('truvisibility/plagiarism/v1', '/account', array('methods' => 'GET', 'callback' => array($this, 'get_account')));
     22        register_rest_route('truvisibility/plagiarism/v1', '/account/ensure', array('methods' => 'POST', 'callback' => array($this, 'ensure_account')));
    2123        register_rest_route('truvisibility/plagiarism/v1', '/history', array('methods' => 'GET', 'callback' => array($this, 'get_history')));
    2224        register_rest_route('truvisibility/plagiarism/v1', '/checks/quota', array('methods' => 'GET', 'callback' => array($this, 'get_quota')));
     
    2931    }
    3032
     33    function get_plans()
     34    {
     35        return $this->plagiarism_client->get_plans();
     36    }
     37
    3138    function get_account()
    3239    {
     
    3643
    3744        return $account;
     45    }
     46
     47    function ensure_account()
     48    {
     49        return $this->auth_client->ensure_account();
    3850    }
    3951
  • truvisibility-plagiarism-checker/trunk/services/TruVisibilityPlagiarismSettings.php

    r1773200 r1774331  
    3333        register_setting('plagiarism', 'truvisibility_plagiarism_usage', array($this, 'sanitize_settings'));
    3434 
    35         add_settings_section('plagiarism_section_account', 'Account', array($this, 'plagiarism_section_account_cb'), 'truvisibility_plagiarism_settings');
     35        add_settings_section('section_account', 'Account', array($this, 'section_account_cb'), 'truvisibility_plagiarism_settings');
    3636
    3737        if (get_option('truvisibility_plagiarism_account') != false)
    3838        {
    39             add_settings_section('plagiarism_section_usage', 'Usage', array($this, 'plagiarism_section_usage_cb'), 'truvisibility_plagiarism_settings');
     39            add_settings_section('section_usage', 'Usage', array($this, 'section_usage_cb'), 'truvisibility_plagiarism_settings');
    4040
    4141            $usage = get_option('truvisibility_plagiarism_usage');
    4242
    4343            add_settings_field(
    44                 'plagiarism_field_enabled',
     44                'field_enabled',
    4545                'Plagiarism checking is enabled',
    46                 array($this, 'plagiarism_field_enabled_cb'),
    47                 'truvisibility_plagiarism_settings',
    48                 'plagiarism_section_usage',
     46                array($this, 'field_enabled_cb'),
     47                'truvisibility_plagiarism_settings',
     48                'section_usage',
    4949                $usage);
    5050
    5151            add_settings_field(
    52                 'plagiarism_field_send_notif',
     52                'field_send_notif',
    5353                'Send notification to site owner',
    54                 array($this, 'plagiarism_field_send_notif_cb'),
    55                 'truvisibility_plagiarism_settings',
    56                 'plagiarism_section_usage',
     54                array($this, 'field_send_notif_cb'),
     55                'truvisibility_plagiarism_settings',
     56                'section_usage',
    5757                $usage);
    5858
    5959            add_settings_field(
    60                 'plagiarism_field_stop_limit',
     60                'field_stop_limit',
    6161                'Minimum acceptable uniqueness',
    62                 array($this, 'plagiarism_field_stop_limit_cb'),
    63                 'truvisibility_plagiarism_settings',
    64                 'plagiarism_section_usage',
     62                array($this, 'field_stop_limit_cb'),
     63                'truvisibility_plagiarism_settings',
     64                'section_usage',
    6565                $usage);
    6666
    67             add_settings_field(
    68                 'plagiarism_field_quota',
    69                 'Quota usage',
    70                 array($this, 'plagiarism_field_quota_cb'),
    71                 'truvisibility_plagiarism_settings',
    72                 'plagiarism_section_usage');
     67            add_settings_section('section_subscription', 'Subscription', array($this, 'section_subscription_cb'), 'truvisibility_plagiarism_settings');
     68           
     69            add_settings_field(
     70                'field_quota',
     71                'Current usage',
     72                array($this, 'field_quota_cb'),
     73                'truvisibility_plagiarism_settings',
     74                'section_subscription');
     75
     76            add_settings_field(
     77                'field_plans',
     78                'Available subscriptions',
     79                array($this, 'field_plans_cb'),
     80                'truvisibility_plagiarism_settings',
     81                'section_subscription');
     82
     83           
    7384        }
    7485    }
     
    8293    }
    8394
    84     public function plagiarism_section_usage_cb( $args ) {}
    85     public function plagiarism_section_account_cb($args)
     95    public function section_usage_cb( $args ) {}
     96    public function section_subscription_cb($args) {}
     97    public function section_account_cb($args)
    8698    {
    8799        $account = get_option('truvisibility_plagiarism_account');
     
    103115            <b><?php echo $account['name']; ?></b> <i>(<?php echo $account['email']; ?>)</i><br/>
    104116            <div style="padding: 10px 0;">
    105                 <a href="https://auth.<?php echo TruVisibilityPlagiarismConfig::$TvUmbrellaRoot ?>/account/profile#products" target="_blank" class="button button-primary">Manage Subscriptions</a>
    106117                <div id="clean-auth-button" class="button">Sign Out</div>
    107118            </div>
     
    109120        }
    110121    }
    111    
    112     public function plagiarism_field_enabled_cb($usage)
     122
     123    public function field_enabled_cb($usage)
    113124    {
    114125        echo '<input type="checkbox" '.checked($usage['checking_enabled'], 'on', false).' name="truvisibility_plagiarism_usage[checking_enabled]" />';
    115126    }
    116127
    117     public function plagiarism_field_send_notif_cb($usage)
     128    public function field_send_notif_cb($usage)
    118129    {
    119130        echo '<input type="checkbox" '.checked($usage['notification_enabled'], 'on', false).' name="truvisibility_plagiarism_usage[notification_enabled]" style="position: relative; top: -2px;" /> ';
     
    122133    }
    123134
    124     public function plagiarism_field_stop_limit_cb($usage)
     135    public function field_stop_limit_cb($usage)
    125136    {
    126137        echo '<input type="number" min="0", max="100" name="truvisibility_plagiarism_usage[min_uniqueness]" value="'.esc_attr($usage['min_uniqueness']).'" /> %';
    127138    }
    128139
    129     public function plagiarism_field_quota_cb($args)
     140    public function field_plans_cb($args)
     141    {
     142        ?>
     143        <img id="rast-plans-loading" src="<?php echo get_admin_url(); ?>images/loading.gif" />
     144        <table id="rast-plans" style="margin: 0 0 0 -10px;"></table>
     145        <?php
     146    }
     147
     148    public function field_quota_cb($args)
    130149    {
    131150        ?>
    132         <div id="rast-quota-loading">Loading...</div>
     151        <img id="rast-quota-loading" src="<?php echo get_admin_url(); ?>images/loading.gif" />
    133152        <div id="rast-quota-view" style="display: none;">
    134153            <span id="rast-quota-used"></span> of <span id="rast-quota-limit"></span> checks used. <span id="rast-purchase-info"></span>
    135154            <p id="rast-purchasing-ok" class="description" style="display: none;">
    136                 You can <a href="javascript:void()" id="rast-upgrade"><strong>upgrade</strong></a> your quota by purchasing an additional checks.
     155                You can <a href="javascript:void()" id="rast-upgrade"><strong>increase</strong></a> your quota by purchasing additional checks.
    137156            </p>
    138157            <p id="rast-purchasing-no-card" class="description" style="display: none;">
    139                 For purchasing an additional checks you should enter credit card into your <a href="https://auth.<?php echo TruVisibilityPlagiarismConfig::$TvUmbrellaRoot; ?>/account/profile#credit-card" target="_blank">TruVisibility account</a>.
     158                Please update your <a href="https://auth.<?php echo TruVisibilityPlagiarismConfig::$TvUmbrellaRoot; ?>/account/profile#credit-card" target="_blank">TruVisibility account</a> with credit card information to unblock additional checks.
    140159            </p>
    141160        </div>
  • truvisibility-plagiarism-checker/trunk/services/clients/TruVisibilityAuthClient.php

    r1773200 r1774331  
    55
    66    private $redirect_uri;
     7
     8    private $api_endpoint;
    79
    810    private $client_id = '6202f4a6-c009-4ff8-8cec-60b120119577';
     
    1416        $this->auth_token_endpoint = 'https://auth.'.TruVisibilityPlagiarismConfig::$TvUmbrellaRoot.'/oauth/token';
    1517        $this->redirect_uri = 'https://auth.'.TruVisibilityPlagiarismConfig::$TvUmbrellaRoot.'/oauth/authorization-code';
     18        $this->api_endpoint = 'https://auth.'.TruVisibilityPlagiarismConfig::$TvUmbrellaRoot.'/account/api';
     19    }
     20
     21    public function ensure_account()
     22    {
     23        $response = wp_remote_post($this->api_endpoint.'/charge/customer/ensure', $this->default_args());
     24
     25        return self::parse($response);
    1626    }
    1727
     
    8393        return json_decode($response['body']); ;
    8494    }
     95
     96    private static function parse($response)
     97    {
     98        return (is_wp_error($response) || wp_remote_retrieve_response_code($response) != 200) ? $response : json_decode($response['body']);
     99    }
     100
     101    private function default_args()
     102    {
     103        return array(
     104            'timeout' => 30,
     105            'sslverify' => TruVisibilityPlagiarismConfig::$SslVerify,
     106            'headers' => array('Authorization' => 'Bearer '.get_option('truvisibility_plagiarism_account')['access-token']));
     107    }
    85108}
    86109?>
  • truvisibility-plagiarism-checker/trunk/services/clients/TruVisibilityPlagiarismClient.php

    r1773200 r1774331  
    8888    }
    8989
     90    public function get_plans()
     91    {
     92        $this->auth_client->update_access_if_expired();
     93
     94        $response = wp_remote_get($this->plagiarism_endpoint.'/plans', $this->default_args());
     95
     96        return self::parse($response);
     97    }
     98
    9099    public function notify_about_plagiarized_post($email, $title, $url, $uniqueness, $min_uniqueness)
    91100    {
Note: See TracChangeset for help on using the changeset viewer.