Plugin Directory

Changeset 2457745


Ignore:
Timestamp:
01/17/2021 05:18:10 AM (5 years ago)
Author:
servicebot
Message:

Update to version 2.0.1 from GitHub

Location:
servicebot
Files:
8 edited
1 copied

Legend:

Unmodified
Added
Removed
  • servicebot/tags/2.0.1/README.txt

    r2457289 r2457745  
    4343 * Automatically create your Stripe customers as WordPress users with Stripe Webhooks
    4444
     45== How To Use Shortcodes ==
     46 * Install this plugin
     47 * Create a billing page at dashboard.billflow.io
     48 * Insert a shortcode and embed one any of the billflow embeds, pricing, checkout, customer portal etc.
     49
     50== Shortcodes Examples ==
     51
     52= Embed a page. =
     53`[billflow billing_page_id="1234567890"]`
     54
     55= Embed a page and gate it behind a login. =
     56`[billflow billing_page_id="1234567890" logged_in_only="true"]`
     57
     58= Embed a page that is only for non-users and send user to another page if logged in. =
     59`[billflow billing_page_id="1234567890" logged_out_only="/my-account"]`
     60
     61= Embed a page that is only for users with certain role =
     62`[billflow billing_page_id="1234567890" logged_in_only="true" gated="basic_tier"]`
     63
     64= Or embed a page for users with any of the listed roles =
     65`[billflow billing_page_id="1234567890" logged_in_only="true" gated="basic_tier, premium_tier"]`
     66
     67= Gate any page to a specific role =
     68Send basic tier users to an upgrade checkout page
     69
     70`[billflow gated="basic_tier" upgrade_url="/upgrade"]`
     71
     72Or send any other user / non-users to a sign up pricing page
     73
     74`[billflow gated="basic_tier, premium_tier" upgrade_url="/pricing"]`
     75
    4576== Installation ==
    4677STEP-BY-STEP INSTRUCTIONS
  • servicebot/tags/2.0.1/public/widgets/class-servicebot-billing-page-widget.php

    r2457289 r2457745  
    112112
    113113        extract( $args );
    114 
     114        $current_user = wp_get_current_user();
    115115        // Check the widget options
     116        $user_roles       = $current_user->roles;
    116117        $logged_in_only  = isset( $instance['logged_in_only'] ) ? apply_filters('widget_logged_in_only', $instance['logged_in_only']) : false;
    117118        $logged_out_only = isset( $instance['logged_out_only'] ) ? apply_filters('widget_logged_out_only', $instance['logged_out_only']) : false;
    118119        $gated = isset( $instance['gated'] ) ? apply_filters('widget_gated', $instance['gated']) : false;
     120        $upgrade_url = isset( $instance['upgrade_url'] ) ? apply_filters('widget_upgrade_url', $instance['upgrade_url']) : false;
    119121        $billing_page_id = isset( $instance['billing_page_id'] ) ? apply_filters( 'widget_billing_page_id', $instance['billing_page_id'] ) : '';
    120122        $sb_secret       = $this->secret_key;
     
    172174       
    173175
     176        $gated_array = explode(',', $gated);
     177        $clean_gated = array_map(function($role){
     178            return trim($role);
     179        }, $gated_array);
     180        $filtered_gated = array_filter($clean_gated, function($role){
     181            return $role != "";
     182        });
     183
    174184        $js_settings = array(
     185            'can_edit_site'   => current_user_can('edit_pages') || current_user_can('edit_posts'),
     186            'user_roles'       => $user_roles,
    175187            'logged_in_only'  => $logged_in_only,
    176188            'logged_out_only' => $logged_out_only,
    177             'gated'           => $gated,
     189            'gated'           => $filtered_gated,
     190            'upgrade_url'     => $upgrade_url,
    178191            'billing_page_id' => $billing_page_id,
    179192            'hash'            => isset($hash) ? $hash : '',
  • servicebot/tags/2.0.1/public/widgets/js/billflow-widget.js

    r2457289 r2457745  
    3333    const { subscription_id, create_user, is_logged_in, logged_in_email } = php_props_billflow_settings
    3434    const { login_redirect_url, admin_ajax_url, embed_type, js_version } = php_props_billflow_settings;
    35     const { logged_out_only, logged_in_only, gated } = php_props_billflow_settings;
     35    const { logged_out_only, logged_in_only, gated, user_roles, upgrade_url, can_edit_site } = php_props_billflow_settings;
    3636
    37     if((logged_in_only || gated) && !is_logged_in){
    38         if(logged_in_only === "true" || gated === "true"){
     37    /**
     38     * Gating logics
     39     */
     40    //console.log("gated", gated)
     41    //console.log("roles", user_roles)
     42
     43    if(!can_edit_site){
     44        if(!is_logged_in){
     45            if((logged_in_only || gated.length)){
     46                kick_out()
     47            }
     48        }else{
     49            if(logged_out_only){
     50                kick_back()
     51            }else{
     52                if(gated.length){
     53                    if( !user_roles || !user_roles.length){
     54                        kick_out()
     55                    }else if(!hasRole()){
     56                        upgrade()
     57                    }
     58                }
     59            }
     60        }
     61    }
     62
     63    /**
     64     * functions
     65     */
     66    function upgrade(){
     67        if(upgrade_url){
     68            window.location.replace(upgrade_url + "?redirect_to=" + window.location.pathname + window.location.search)
     69        }else{
     70            // alert("Please add upgrade_url to the billflow shortcode with the upgrade checkout page to send this user to upgrade, otherwise, it goes to home page by default")
     71        }
     72    }
     73
     74    function kick_out(){
     75        if(logged_in_only === "true" || gated.length){
    3976            window.location.replace(login_redirect_url + "?redirect_to=" + window.location.pathname + window.location.search)
    4077        }else{
    41             window.location.href = logged_in_only || gated
     78            window.location.href = logged_in_only
    4279        }
    4380    }
    44     if(logged_out_only && is_logged_in){
     81
     82    function kick_back(){
    4583        if(logged_out_only === "true"){
    4684            window.location.href = '/'
     
    4886            window.location.href = logged_out_only
    4987        }
     88    }
     89
     90    function hasRole(){
     91
     92        for(let i = 0; i < gated.length; i++){
     93            if(user_roles.find( role => role == gated[i] )){
     94                return true
     95            }
     96        }
     97        return false
    5098    }
    5199
     
    101149    }
    102150
    103     const settings = {
    104         'billing_page_id': billing_page_id,
    105         'email': logged_in_email || email || '',
    106         'hash': hash,
    107         'handleResponse' : handleResponse,
    108         'metadata': {
    109             'serverside_config': true,
    110             'widget_type': embed_type,
    111             'plugin_type': 'wordpress',
    112             'plugin_version': js_version,
     151    if(billing_page_id){
     152        const settings = {
     153            'billing_page_id': billing_page_id,
     154            'email': logged_in_email || email || '',
     155            'hash': hash,
     156            'handleResponse' : handleResponse,
     157            'metadata': {
     158                'serverside_config': true,
     159                'widget_type': embed_type,
     160                'plugin_type': 'wordpress',
     161                'plugin_version': js_version,
     162            }
    113163        }
    114     }
    115164
    116     window.servicebotSettings = settings
    117     window.billflowSettings = settings
    118     customer_id && (window.servicebotSettings.customer_id = customer_id);
    119     subscription_id && (window.servicebotSettings.subscription_id = subscription_id);
     165        window.servicebotSettings = settings
     166        window.billflowSettings = settings
     167        customer_id && (window.servicebotSettings.customer_id = customer_id);
     168        subscription_id && (window.servicebotSettings.subscription_id = subscription_id);
    120169
     170       
    121171
    122     if(document.querySelector("#billflow-embed")){
    123         if(window.location.host == 'servicebot-wordpress.docksal'){
    124             (function () {
    125                 var s = document.createElement("script");
    126                 s.src = "/wp-content/themes/twentynineteen/js/build/servicebot-billing-settings-embed.js";
    127                 s.async = true;
    128                 s.type = "text/javascript";
    129                 var x = document.getElementsByTagName("script")[0];
    130                 x.parentNode.insertBefore(s, x); })();
     172        if(document.querySelector("#billflow-embed")){
     173            if(window.location.host == 'servicebot-wordpress.docksal'){
     174                (function () {
     175                    var s = document.createElement("script");
     176                    s.src = "/wp-content/themes/twentynineteen/js/build/servicebot-billing-settings-embed.js";
     177                    s.async = true;
     178                    s.type = "text/javascript";
     179                    var x = document.getElementsByTagName("script")[0];
     180                    x.parentNode.insertBefore(s, x); })();
     181            }else{
     182                (function () {
     183                    var s = document.createElement('script');
     184                    s.src = 'https://js.billflow.io/billflow-embed.js';
     185                    s.async = true;
     186                    s.type = 'text/javascript';
     187                    var x = document.getElementsByTagName('script')[0];
     188                    x.parentNode.insertBefore(s, x); })();
     189            }
    131190        }else{
    132             (function () {
    133                 var s = document.createElement('script');
    134                 s.src = 'https://js.billflow.io/billflow-embed.js';
    135                 s.async = true;
    136                 s.type = 'text/javascript';
    137                 var x = document.getElementsByTagName('script')[0];
    138                 x.parentNode.insertBefore(s, x); })();
     191            console.log("Please make sure <div id='billflow-embed'></div> is on the page. You can ignore this warning if you are on the Wordpress editor.")
    139192        }
    140     }else{
    141         console.log("Please make sure <div id='billflow-embed'></div> is on the page. You can ignore this warning if you are on the Wordpress editor.")
    142193    }
    143194   
  • servicebot/tags/2.0.1/servicebot.php

    r2457289 r2457745  
    1616 * Plugin Name:       Billflow
    1717 * Plugin URI:        http://www.wpexplorer.com/servicebot/
    18  * Description:       Breaking Change!! If you are on version 1.x.x, please perform a full test on this version 2.0.0 update in your test site before going live!! We rebranded Servicebot to become Billflow starting in 2021.
    19  * Version:           2.0.0
     18 * Description:       Provides NO-CODE integration between WordPress and Billflow, an UI layer on top of Stripe Billing.
     19 * Version:           2.0.1
    2020 * Author:            Billflow
    2121 * Author URI:        https://billflow.io
     
    3636 * Rename this for your plugin and update it as you release new versions.
    3737 */
    38 define( 'SERVICEBOT_VERSION', '2.0.0' );
     38define( 'SERVICEBOT_VERSION', '2.0.1' );
    3939
    4040/**
  • servicebot/trunk/README.txt

    r2457289 r2457745  
    4343 * Automatically create your Stripe customers as WordPress users with Stripe Webhooks
    4444
     45== How To Use Shortcodes ==
     46 * Install this plugin
     47 * Create a billing page at dashboard.billflow.io
     48 * Insert a shortcode and embed one any of the billflow embeds, pricing, checkout, customer portal etc.
     49
     50== Shortcodes Examples ==
     51
     52= Embed a page. =
     53`[billflow billing_page_id="1234567890"]`
     54
     55= Embed a page and gate it behind a login. =
     56`[billflow billing_page_id="1234567890" logged_in_only="true"]`
     57
     58= Embed a page that is only for non-users and send user to another page if logged in. =
     59`[billflow billing_page_id="1234567890" logged_out_only="/my-account"]`
     60
     61= Embed a page that is only for users with certain role =
     62`[billflow billing_page_id="1234567890" logged_in_only="true" gated="basic_tier"]`
     63
     64= Or embed a page for users with any of the listed roles =
     65`[billflow billing_page_id="1234567890" logged_in_only="true" gated="basic_tier, premium_tier"]`
     66
     67= Gate any page to a specific role =
     68Send basic tier users to an upgrade checkout page
     69
     70`[billflow gated="basic_tier" upgrade_url="/upgrade"]`
     71
     72Or send any other user / non-users to a sign up pricing page
     73
     74`[billflow gated="basic_tier, premium_tier" upgrade_url="/pricing"]`
     75
    4576== Installation ==
    4677STEP-BY-STEP INSTRUCTIONS
  • servicebot/trunk/public/widgets/class-servicebot-billing-page-widget.php

    r2457289 r2457745  
    112112
    113113        extract( $args );
    114 
     114        $current_user = wp_get_current_user();
    115115        // Check the widget options
     116        $user_roles       = $current_user->roles;
    116117        $logged_in_only  = isset( $instance['logged_in_only'] ) ? apply_filters('widget_logged_in_only', $instance['logged_in_only']) : false;
    117118        $logged_out_only = isset( $instance['logged_out_only'] ) ? apply_filters('widget_logged_out_only', $instance['logged_out_only']) : false;
    118119        $gated = isset( $instance['gated'] ) ? apply_filters('widget_gated', $instance['gated']) : false;
     120        $upgrade_url = isset( $instance['upgrade_url'] ) ? apply_filters('widget_upgrade_url', $instance['upgrade_url']) : false;
    119121        $billing_page_id = isset( $instance['billing_page_id'] ) ? apply_filters( 'widget_billing_page_id', $instance['billing_page_id'] ) : '';
    120122        $sb_secret       = $this->secret_key;
     
    172174       
    173175
     176        $gated_array = explode(',', $gated);
     177        $clean_gated = array_map(function($role){
     178            return trim($role);
     179        }, $gated_array);
     180        $filtered_gated = array_filter($clean_gated, function($role){
     181            return $role != "";
     182        });
     183
    174184        $js_settings = array(
     185            'can_edit_site'   => current_user_can('edit_pages') || current_user_can('edit_posts'),
     186            'user_roles'       => $user_roles,
    175187            'logged_in_only'  => $logged_in_only,
    176188            'logged_out_only' => $logged_out_only,
    177             'gated'           => $gated,
     189            'gated'           => $filtered_gated,
     190            'upgrade_url'     => $upgrade_url,
    178191            'billing_page_id' => $billing_page_id,
    179192            'hash'            => isset($hash) ? $hash : '',
  • servicebot/trunk/public/widgets/js/billflow-widget.js

    r2457289 r2457745  
    3333    const { subscription_id, create_user, is_logged_in, logged_in_email } = php_props_billflow_settings
    3434    const { login_redirect_url, admin_ajax_url, embed_type, js_version } = php_props_billflow_settings;
    35     const { logged_out_only, logged_in_only, gated } = php_props_billflow_settings;
     35    const { logged_out_only, logged_in_only, gated, user_roles, upgrade_url, can_edit_site } = php_props_billflow_settings;
    3636
    37     if((logged_in_only || gated) && !is_logged_in){
    38         if(logged_in_only === "true" || gated === "true"){
     37    /**
     38     * Gating logics
     39     */
     40    //console.log("gated", gated)
     41    //console.log("roles", user_roles)
     42
     43    if(!can_edit_site){
     44        if(!is_logged_in){
     45            if((logged_in_only || gated.length)){
     46                kick_out()
     47            }
     48        }else{
     49            if(logged_out_only){
     50                kick_back()
     51            }else{
     52                if(gated.length){
     53                    if( !user_roles || !user_roles.length){
     54                        kick_out()
     55                    }else if(!hasRole()){
     56                        upgrade()
     57                    }
     58                }
     59            }
     60        }
     61    }
     62
     63    /**
     64     * functions
     65     */
     66    function upgrade(){
     67        if(upgrade_url){
     68            window.location.replace(upgrade_url + "?redirect_to=" + window.location.pathname + window.location.search)
     69        }else{
     70            // alert("Please add upgrade_url to the billflow shortcode with the upgrade checkout page to send this user to upgrade, otherwise, it goes to home page by default")
     71        }
     72    }
     73
     74    function kick_out(){
     75        if(logged_in_only === "true" || gated.length){
    3976            window.location.replace(login_redirect_url + "?redirect_to=" + window.location.pathname + window.location.search)
    4077        }else{
    41             window.location.href = logged_in_only || gated
     78            window.location.href = logged_in_only
    4279        }
    4380    }
    44     if(logged_out_only && is_logged_in){
     81
     82    function kick_back(){
    4583        if(logged_out_only === "true"){
    4684            window.location.href = '/'
     
    4886            window.location.href = logged_out_only
    4987        }
     88    }
     89
     90    function hasRole(){
     91
     92        for(let i = 0; i < gated.length; i++){
     93            if(user_roles.find( role => role == gated[i] )){
     94                return true
     95            }
     96        }
     97        return false
    5098    }
    5199
     
    101149    }
    102150
    103     const settings = {
    104         'billing_page_id': billing_page_id,
    105         'email': logged_in_email || email || '',
    106         'hash': hash,
    107         'handleResponse' : handleResponse,
    108         'metadata': {
    109             'serverside_config': true,
    110             'widget_type': embed_type,
    111             'plugin_type': 'wordpress',
    112             'plugin_version': js_version,
     151    if(billing_page_id){
     152        const settings = {
     153            'billing_page_id': billing_page_id,
     154            'email': logged_in_email || email || '',
     155            'hash': hash,
     156            'handleResponse' : handleResponse,
     157            'metadata': {
     158                'serverside_config': true,
     159                'widget_type': embed_type,
     160                'plugin_type': 'wordpress',
     161                'plugin_version': js_version,
     162            }
    113163        }
    114     }
    115164
    116     window.servicebotSettings = settings
    117     window.billflowSettings = settings
    118     customer_id && (window.servicebotSettings.customer_id = customer_id);
    119     subscription_id && (window.servicebotSettings.subscription_id = subscription_id);
     165        window.servicebotSettings = settings
     166        window.billflowSettings = settings
     167        customer_id && (window.servicebotSettings.customer_id = customer_id);
     168        subscription_id && (window.servicebotSettings.subscription_id = subscription_id);
    120169
     170       
    121171
    122     if(document.querySelector("#billflow-embed")){
    123         if(window.location.host == 'servicebot-wordpress.docksal'){
    124             (function () {
    125                 var s = document.createElement("script");
    126                 s.src = "/wp-content/themes/twentynineteen/js/build/servicebot-billing-settings-embed.js";
    127                 s.async = true;
    128                 s.type = "text/javascript";
    129                 var x = document.getElementsByTagName("script")[0];
    130                 x.parentNode.insertBefore(s, x); })();
     172        if(document.querySelector("#billflow-embed")){
     173            if(window.location.host == 'servicebot-wordpress.docksal'){
     174                (function () {
     175                    var s = document.createElement("script");
     176                    s.src = "/wp-content/themes/twentynineteen/js/build/servicebot-billing-settings-embed.js";
     177                    s.async = true;
     178                    s.type = "text/javascript";
     179                    var x = document.getElementsByTagName("script")[0];
     180                    x.parentNode.insertBefore(s, x); })();
     181            }else{
     182                (function () {
     183                    var s = document.createElement('script');
     184                    s.src = 'https://js.billflow.io/billflow-embed.js';
     185                    s.async = true;
     186                    s.type = 'text/javascript';
     187                    var x = document.getElementsByTagName('script')[0];
     188                    x.parentNode.insertBefore(s, x); })();
     189            }
    131190        }else{
    132             (function () {
    133                 var s = document.createElement('script');
    134                 s.src = 'https://js.billflow.io/billflow-embed.js';
    135                 s.async = true;
    136                 s.type = 'text/javascript';
    137                 var x = document.getElementsByTagName('script')[0];
    138                 x.parentNode.insertBefore(s, x); })();
     191            console.log("Please make sure <div id='billflow-embed'></div> is on the page. You can ignore this warning if you are on the Wordpress editor.")
    139192        }
    140     }else{
    141         console.log("Please make sure <div id='billflow-embed'></div> is on the page. You can ignore this warning if you are on the Wordpress editor.")
    142193    }
    143194   
  • servicebot/trunk/servicebot.php

    r2457289 r2457745  
    1616 * Plugin Name:       Billflow
    1717 * Plugin URI:        http://www.wpexplorer.com/servicebot/
    18  * Description:       Breaking Change!! If you are on version 1.x.x, please perform a full test on this version 2.0.0 update in your test site before going live!! We rebranded Servicebot to become Billflow starting in 2021.
    19  * Version:           2.0.0
     18 * Description:       Provides NO-CODE integration between WordPress and Billflow, an UI layer on top of Stripe Billing.
     19 * Version:           2.0.1
    2020 * Author:            Billflow
    2121 * Author URI:        https://billflow.io
     
    3636 * Rename this for your plugin and update it as you release new versions.
    3737 */
    38 define( 'SERVICEBOT_VERSION', '2.0.0' );
     38define( 'SERVICEBOT_VERSION', '2.0.1' );
    3939
    4040/**
Note: See TracChangeset for help on using the changeset viewer.