Changeset 2457745
- Timestamp:
- 01/17/2021 05:18:10 AM (5 years ago)
- Location:
- servicebot
- Files:
-
- 8 edited
- 1 copied
-
tags/2.0.1 (copied) (copied from servicebot/trunk)
-
tags/2.0.1/README.txt (modified) (1 diff)
-
tags/2.0.1/public/widgets/class-servicebot-billing-page-widget.php (modified) (2 diffs)
-
tags/2.0.1/public/widgets/js/billflow-widget.js (modified) (3 diffs)
-
tags/2.0.1/servicebot.php (modified) (2 diffs)
-
trunk/README.txt (modified) (1 diff)
-
trunk/public/widgets/class-servicebot-billing-page-widget.php (modified) (2 diffs)
-
trunk/public/widgets/js/billflow-widget.js (modified) (3 diffs)
-
trunk/servicebot.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
servicebot/tags/2.0.1/README.txt
r2457289 r2457745 43 43 * Automatically create your Stripe customers as WordPress users with Stripe Webhooks 44 44 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 = 68 Send basic tier users to an upgrade checkout page 69 70 `[billflow gated="basic_tier" upgrade_url="/upgrade"]` 71 72 Or send any other user / non-users to a sign up pricing page 73 74 `[billflow gated="basic_tier, premium_tier" upgrade_url="/pricing"]` 75 45 76 == Installation == 46 77 STEP-BY-STEP INSTRUCTIONS -
servicebot/tags/2.0.1/public/widgets/class-servicebot-billing-page-widget.php
r2457289 r2457745 112 112 113 113 extract( $args ); 114 114 $current_user = wp_get_current_user(); 115 115 // Check the widget options 116 $user_roles = $current_user->roles; 116 117 $logged_in_only = isset( $instance['logged_in_only'] ) ? apply_filters('widget_logged_in_only', $instance['logged_in_only']) : false; 117 118 $logged_out_only = isset( $instance['logged_out_only'] ) ? apply_filters('widget_logged_out_only', $instance['logged_out_only']) : false; 118 119 $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; 119 121 $billing_page_id = isset( $instance['billing_page_id'] ) ? apply_filters( 'widget_billing_page_id', $instance['billing_page_id'] ) : ''; 120 122 $sb_secret = $this->secret_key; … … 172 174 173 175 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 174 184 $js_settings = array( 185 'can_edit_site' => current_user_can('edit_pages') || current_user_can('edit_posts'), 186 'user_roles' => $user_roles, 175 187 'logged_in_only' => $logged_in_only, 176 188 'logged_out_only' => $logged_out_only, 177 'gated' => $gated, 189 'gated' => $filtered_gated, 190 'upgrade_url' => $upgrade_url, 178 191 'billing_page_id' => $billing_page_id, 179 192 'hash' => isset($hash) ? $hash : '', -
servicebot/tags/2.0.1/public/widgets/js/billflow-widget.js
r2457289 r2457745 33 33 const { subscription_id, create_user, is_logged_in, logged_in_email } = php_props_billflow_settings 34 34 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; 36 36 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){ 39 76 window.location.replace(login_redirect_url + "?redirect_to=" + window.location.pathname + window.location.search) 40 77 }else{ 41 window.location.href = logged_in_only || gated78 window.location.href = logged_in_only 42 79 } 43 80 } 44 if(logged_out_only && is_logged_in){ 81 82 function kick_back(){ 45 83 if(logged_out_only === "true"){ 46 84 window.location.href = '/' … … 48 86 window.location.href = logged_out_only 49 87 } 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 50 98 } 51 99 … … 101 149 } 102 150 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 } 113 163 } 114 }115 164 116 window.servicebotSettings = settings117 window.billflowSettings = settings118 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); 120 169 170 121 171 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 } 131 190 }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.") 139 192 } 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.")142 193 } 143 194 -
servicebot/tags/2.0.1/servicebot.php
r2457289 r2457745 16 16 * Plugin Name: Billflow 17 17 * 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. 018 * Description: Provides NO-CODE integration between WordPress and Billflow, an UI layer on top of Stripe Billing. 19 * Version: 2.0.1 20 20 * Author: Billflow 21 21 * Author URI: https://billflow.io … … 36 36 * Rename this for your plugin and update it as you release new versions. 37 37 */ 38 define( 'SERVICEBOT_VERSION', '2.0. 0' );38 define( 'SERVICEBOT_VERSION', '2.0.1' ); 39 39 40 40 /** -
servicebot/trunk/README.txt
r2457289 r2457745 43 43 * Automatically create your Stripe customers as WordPress users with Stripe Webhooks 44 44 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 = 68 Send basic tier users to an upgrade checkout page 69 70 `[billflow gated="basic_tier" upgrade_url="/upgrade"]` 71 72 Or send any other user / non-users to a sign up pricing page 73 74 `[billflow gated="basic_tier, premium_tier" upgrade_url="/pricing"]` 75 45 76 == Installation == 46 77 STEP-BY-STEP INSTRUCTIONS -
servicebot/trunk/public/widgets/class-servicebot-billing-page-widget.php
r2457289 r2457745 112 112 113 113 extract( $args ); 114 114 $current_user = wp_get_current_user(); 115 115 // Check the widget options 116 $user_roles = $current_user->roles; 116 117 $logged_in_only = isset( $instance['logged_in_only'] ) ? apply_filters('widget_logged_in_only', $instance['logged_in_only']) : false; 117 118 $logged_out_only = isset( $instance['logged_out_only'] ) ? apply_filters('widget_logged_out_only', $instance['logged_out_only']) : false; 118 119 $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; 119 121 $billing_page_id = isset( $instance['billing_page_id'] ) ? apply_filters( 'widget_billing_page_id', $instance['billing_page_id'] ) : ''; 120 122 $sb_secret = $this->secret_key; … … 172 174 173 175 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 174 184 $js_settings = array( 185 'can_edit_site' => current_user_can('edit_pages') || current_user_can('edit_posts'), 186 'user_roles' => $user_roles, 175 187 'logged_in_only' => $logged_in_only, 176 188 'logged_out_only' => $logged_out_only, 177 'gated' => $gated, 189 'gated' => $filtered_gated, 190 'upgrade_url' => $upgrade_url, 178 191 'billing_page_id' => $billing_page_id, 179 192 'hash' => isset($hash) ? $hash : '', -
servicebot/trunk/public/widgets/js/billflow-widget.js
r2457289 r2457745 33 33 const { subscription_id, create_user, is_logged_in, logged_in_email } = php_props_billflow_settings 34 34 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; 36 36 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){ 39 76 window.location.replace(login_redirect_url + "?redirect_to=" + window.location.pathname + window.location.search) 40 77 }else{ 41 window.location.href = logged_in_only || gated78 window.location.href = logged_in_only 42 79 } 43 80 } 44 if(logged_out_only && is_logged_in){ 81 82 function kick_back(){ 45 83 if(logged_out_only === "true"){ 46 84 window.location.href = '/' … … 48 86 window.location.href = logged_out_only 49 87 } 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 50 98 } 51 99 … … 101 149 } 102 150 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 } 113 163 } 114 }115 164 116 window.servicebotSettings = settings117 window.billflowSettings = settings118 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); 120 169 170 121 171 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 } 131 190 }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.") 139 192 } 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.")142 193 } 143 194 -
servicebot/trunk/servicebot.php
r2457289 r2457745 16 16 * Plugin Name: Billflow 17 17 * 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. 018 * Description: Provides NO-CODE integration between WordPress and Billflow, an UI layer on top of Stripe Billing. 19 * Version: 2.0.1 20 20 * Author: Billflow 21 21 * Author URI: https://billflow.io … … 36 36 * Rename this for your plugin and update it as you release new versions. 37 37 */ 38 define( 'SERVICEBOT_VERSION', '2.0. 0' );38 define( 'SERVICEBOT_VERSION', '2.0.1' ); 39 39 40 40 /**
Note: See TracChangeset
for help on using the changeset viewer.