Plugin Directory

Changeset 3273939


Ignore:
Timestamp:
04/15/2025 09:22:48 PM (12 months ago)
Author:
marknokes
Message:

Version 2.5.5

Location:
subscriptions-for-woo
Files:
44 added
7 edited

Legend:

Unmodified
Added
Removed
  • subscriptions-for-woo/trunk/classes/PPSFWOO/class-ppsfwoo-pay-pal.php

    r3262268 r3273939  
    4747     * Displays a PayPal button for a specific product, allowing customers to subscribe to a subscription product.
    4848     *
    49      * @param null|int $product_id The ID of the product to display the button for. Defaults to the current product ID if not provided.
    50      */
    51     public static function button($product_id = null)
     49     * @param null|int $product_id  The ID of the product to display the button for. Defaults to the current product ID if not provided.
     50     * @param mixed    $button_text
     51     */
     52    public static function button($product_id = null, $button_text = '')
    5253    {
    5354        $product_id = !empty($product_id) ? $product_id : get_the_ID();
     55
     56        $button_text = !empty($button_text) ? $button_text : PluginMain::get_option('ppsfwoo_button_text');
    5457
    5558        $product = wc_get_product($product_id);
     
    8184                .addEventListener('click', function() {
    8285                    this.style.display = 'none';
    83                     document.getElementById('lds-ellipsis-{$product_id}').style.setProperty('display', 'inline-block', 'important');
     86                    document.getElementById('lds-ellipsis-{$product_id}').style.setProperty('display', 'block');
    8487                    ppsfwooInitializePayPalSubscription({$product_id}, this);
    8588                });
     
    9194
    9295        PluginMain::display_template('paypal-button', [
    93             'button_text' => PluginMain::get_option('ppsfwoo_button_text'),
     96            'button_text' => $button_text,
    9497            'product_id' => $product_id,
    9598        ]);
  • subscriptions-for-woo/trunk/css/frontend.css

    r3258064 r3273939  
    33  font-size:1.5em;
    44  word-break: normal;
     5  width: 100%;
    56}
    67.ppsfwoo-quantity-input {
     
    3031}
    3132.lds-ellipsis {
    32   display: none !important;
     33  display: none;
    3334  position: relative;
    3435  width: 80px;
    3536  height: 80px;
     37  margin: auto;
    3638}
    3739.lds-ellipsis div {
  • subscriptions-for-woo/trunk/css/frontend.min.css

    r3254343 r3273939  
    1 .ppsfwoo-subscribe-button{margin-bottom:15px;font-size:1.5em;word-break:normal}.ppsfwoo-quantity-input{margin-bottom:15px}.inactive-subscription,.ppsfwoo-cancelled{display:none}.subs-actions a{margin-right:10px;padding:10px}p.order-again{display:none}.please-wait{font-weight:bold}#waiting-ellipsis::after{content:'';animation:ellipsis-animation 2s infinite}.lds-ellipsis,.lds-ellipsis div{box-sizing:border-box}.lds-ellipsis{display:none !important;position:relative;width:80px;height:80px}.lds-ellipsis div{position:absolute;top:33.33333px;width:13.33333px;height:13.33333px;border-radius:50%;background:currentColor;animation-timing-function:cubic-bezier(0, 1, 1, 0)}.lds-ellipsis div:nth-child(1){left:8px;animation:lds-ellipsis1 0.6s infinite}.lds-ellipsis div:nth-child(2){left:8px;animation:lds-ellipsis2 0.6s infinite}.lds-ellipsis div:nth-child(3){left:32px;animation:lds-ellipsis2 0.6s infinite}.lds-ellipsis div:nth-child(4){left:56px;animation:lds-ellipsis3 0.6s infinite}@keyframes lds-ellipsis1{0%{transform:scale(0)}100%{transform:scale(1)}}@keyframes lds-ellipsis3{0%{transform:scale(1)}100%{transform:scale(0)}}@keyframes lds-ellipsis2{0%{transform:translate(0, 0)}100%{transform:translate(24px, 0)}}@keyframes ellipsis-animation{25%{content:'. '}50%{content:'. .'}75%{content:'. . .'}}@media screen and (max-width:673px){.subs-actions a{display:block;margin-bottom:3px;text-align:center !important}.subs-actions::before{content:"" !important}.subs-actions a.inactive-subscription,.subs-actions a.ppsfwoo-cancelled{display:none}}
     1.ppsfwoo-subscribe-button{margin-bottom:15px;font-size:1.5em;word-break:normal;width:100%}.ppsfwoo-quantity-input{margin-bottom:15px}.inactive-subscription,.ppsfwoo-cancelled{display:none}.subs-actions a{margin-right:10px;padding:10px}p.order-again{display:none}.please-wait{font-weight:bold}#waiting-ellipsis::after{content:'';animation:ellipsis-animation 2s infinite}.lds-ellipsis,.lds-ellipsis div{box-sizing:border-box}.lds-ellipsis{display:none;position:relative;width:80px;height:80px;margin:auto}.lds-ellipsis div{position:absolute;top:33.33333px;width:13.33333px;height:13.33333px;border-radius:50%;background:currentColor;animation-timing-function:cubic-bezier(0, 1, 1, 0)}.lds-ellipsis div:nth-child(1){left:8px;animation:lds-ellipsis1 0.6s infinite}.lds-ellipsis div:nth-child(2){left:8px;animation:lds-ellipsis2 0.6s infinite}.lds-ellipsis div:nth-child(3){left:32px;animation:lds-ellipsis2 0.6s infinite}.lds-ellipsis div:nth-child(4){left:56px;animation:lds-ellipsis3 0.6s infinite}@keyframes lds-ellipsis1{0%{transform:scale(0)}100%{transform:scale(1)}}@keyframes lds-ellipsis3{0%{transform:scale(1)}100%{transform:scale(0)}}@keyframes lds-ellipsis2{0%{transform:translate(0, 0)}100%{transform:translate(24px, 0)}}@keyframes ellipsis-animation{25%{content:'. '}50%{content:'. .'}75%{content:'. . .'}}@media screen and (max-width:673px){.subs-actions a{display:block;margin-bottom:3px;text-align:center !important}.subs-actions::before{content:"" !important}.subs-actions a.inactive-subscription,.subs-actions a.ppsfwoo-cancelled{display:none}}
  • subscriptions-for-woo/trunk/js/paypal-button.js

    r3258064 r3273939  
    127127            throw new Error("No plan id found for product with ID " + product_id);
    128128        } else {
    129             document.getElementById('lds-ellipsis-' + product_id).style.setProperty("display", "none", "important");
     129            document.getElementById('lds-ellipsis-' + product_id).style.setProperty("display", "none");
    130130            if(response.quantity_supported) {
    131131                ppsfwooCreateQuantityInput(product_id);
  • subscriptions-for-woo/trunk/js/paypal-button.min.js

    r3254343 r3273939  
    1 function ppsfwooGetQuantityInputId(e){return"ppsfwoo-quantity-input-"+e}function ppsfwooCreateQuantityInput(e){var t=document.getElementById("ppsfwoo-quantity-input-container-"+e),n=document.createElement("input"),o=document.createElement("label"),e=ppsfwooGetQuantityInputId(e);n.type="number",n.id=e,n.classList.add("ppsfwoo-quantity-input"),n.name="quantity",n.min="1",n.value="1",o.setAttribute("for",e),o.innerHTML="Quantity: ",t?t.appendChild(o).appendChild(n):alert("Unable to render PayPal button")}function ppsfwooSendPostRequest(a,p){return new Promise((t,n)=>{var e,o=new XMLHttpRequest,r=(o.onreadystatechange=function(){if(o.readyState===XMLHttpRequest.DONE)if(200===o.status)try{var e=JSON.parse(o.responseText);t(e)}catch(e){n(new Error("Invalid JSON response"))}else n(new Error("Request failed: "+o.status))},o.onerror=function(){n(new Error("Network error occurred"))},new URLSearchParams);for(e in p)r.append(e,p[e]);o.open("POST",a,!0),o.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),o.send(r.toString())})}function ppsfwooLogButtonError(e){ppsfwooSendPostRequest("/wp-admin/admin-ajax.php",{action:"ppsfwoo_admin_ajax_callback",method:"log_paypal_buttons_error",message:e}).then(e=>{console.log(e)}).catch(e=>{console.log(e)})}function ppsfwooCreateBtnContainer(o,e,r){return new Promise((e,t)=>{var n=document.createElement("div");n.setAttribute("id","paypal-button-container-"+o),r?r.insertAdjacentElement("afterend",n):alert("Unable to render PayPal button"),requestAnimationFrame(()=>e(n))})}function ppsfwooRender(n,r,a,e){ppsfwooCreateBtnContainer(r,a,e).then(e=>{paypal.Buttons({style:{shape:"rect",layout:"vertical",color:"gold",label:"subscribe"},createSubscription:function(e,t){var n=document.getElementById(ppsfwooGetQuantityInputId(a)),o={plan_id:r};return n&&(o.quantity=n.value),t.subscription.create(o)},onApprove:function(e,t){e=ppsfwoo_paypal_ajax_var.redirect+"?subs_id="+e.subscriptionID+"&subs_id_redirect_nonce="+n;window.location.assign(e)},onError:function(e){e.message&&ppsfwooLogButtonError(e.message)}}).render("#"+e.id)})}function ppsfwooInitializePayPalSubscription(t,n){ppsfwooSendPostRequest("/wp-admin/admin-ajax.php",{action:"ppsfwoo_admin_ajax_callback",method:"subs_id_redirect_nonce",product_id:t}).then(async e=>{if(e.error)throw new Error("No plan id found for product with ID "+t);document.getElementById("lds-ellipsis-"+t).style.setProperty("display","none","important"),e.quantity_supported&&ppsfwooCreateQuantityInput(t),ppsfwooRender(e.nonce,e.plan_id,t,n)}).catch(e=>{console.log(e),ppsfwooLogButtonError(e),alert("There has been an unexpeced error. Please refresh and try again.")})}
     1function ppsfwooGetQuantityInputId(e){return"ppsfwoo-quantity-input-"+e}function ppsfwooCreateQuantityInput(e){var t=document.getElementById("ppsfwoo-quantity-input-container-"+e),n=document.createElement("input"),o=document.createElement("label"),e=ppsfwooGetQuantityInputId(e);n.type="number",n.id=e,n.classList.add("ppsfwoo-quantity-input"),n.name="quantity",n.min="1",n.value="1",o.setAttribute("for",e),o.innerHTML="Quantity: ",t?t.appendChild(o).appendChild(n):alert("Unable to render PayPal button")}function ppsfwooSendPostRequest(a,p){return new Promise((t,n)=>{var e,o=new XMLHttpRequest,r=(o.onreadystatechange=function(){if(o.readyState===XMLHttpRequest.DONE)if(200===o.status)try{var e=JSON.parse(o.responseText);t(e)}catch(e){n(new Error("Invalid JSON response"))}else n(new Error("Request failed: "+o.status))},o.onerror=function(){n(new Error("Network error occurred"))},new URLSearchParams);for(e in p)r.append(e,p[e]);o.open("POST",a,!0),o.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),o.send(r.toString())})}function ppsfwooLogButtonError(e){ppsfwooSendPostRequest("/wp-admin/admin-ajax.php",{action:"ppsfwoo_admin_ajax_callback",method:"log_paypal_buttons_error",message:e}).then(e=>{console.log(e)}).catch(e=>{console.log(e)})}function ppsfwooCreateBtnContainer(o,e,r){return new Promise((e,t)=>{var n=document.createElement("div");n.setAttribute("id","paypal-button-container-"+o),r?r.insertAdjacentElement("afterend",n):alert("Unable to render PayPal button"),requestAnimationFrame(()=>e(n))})}function ppsfwooRender(n,r,a,e){ppsfwooCreateBtnContainer(r,a,e).then(e=>{paypal.Buttons({style:{shape:"rect",layout:"vertical",color:"gold",label:"subscribe"},createSubscription:function(e,t){var n=document.getElementById(ppsfwooGetQuantityInputId(a)),o={plan_id:r};return n&&(o.quantity=n.value),t.subscription.create(o)},onApprove:function(e,t){e=ppsfwoo_paypal_ajax_var.redirect+"?subs_id="+e.subscriptionID+"&subs_id_redirect_nonce="+n;window.location.assign(e)},onError:function(e){e.message&&ppsfwooLogButtonError(e.message)}}).render("#"+e.id)})}function ppsfwooInitializePayPalSubscription(t,n){ppsfwooSendPostRequest("/wp-admin/admin-ajax.php",{action:"ppsfwoo_admin_ajax_callback",method:"subs_id_redirect_nonce",product_id:t}).then(async e=>{if(e.error)throw new Error("No plan id found for product with ID "+t);document.getElementById("lds-ellipsis-"+t).style.setProperty("display","none"),e.quantity_supported&&ppsfwooCreateQuantityInput(t),ppsfwooRender(e.nonce,e.plan_id,t,n)}).catch(e=>{console.log(e),ppsfwooLogButtonError(e),alert("There has been an unexpeced error. Please refresh and try again.")})}
  • subscriptions-for-woo/trunk/readme.txt

    r3270663 r3273939  
    44License: GPLv2 or later
    55License URI: http://www.gnu.org/licenses/gpl-2.0.html
    6 Stable tag: 2.5.4
     6Stable tag: 2.5.5
    77WC tested up to: 9.7.1
    88Requires at least: 6.4.3
     
    123123== Changelog ==
    124124
     125= 2.5.5 =
     126* Improvement: update paypal subscribe button to 100% of container
     127* Improvement: center waiting elipsis on subscribe button click
     128
    125129= 2.5.4 =
    126130* Bugfix: deleted products cause error on order template in admin area
    127 * Improvemnet: add missing css identifier in js
    128 * Improvemnet: add missing docblock
    129 * Improvemnet: check for tab content before attempting to include in options page menu
    130 * Improvemnet: add min and max to number type for options page
    131 * Improvemnet: move localize script for paypal button to paypal class
     131* Improvement: add missing css identifier in js
     132* Improvement: add missing docblock
     133* Improvement: check for tab content before attempting to include in options page menu
     134* Improvement: add min and max to number type for options page
     135* Improvement: move localize script for paypal button to paypal class
    132136
    133137= 2.5.3 =
    134 * Improvemnet: remove superfluous import statements
     138* Improvement: remove superfluous import statements
    135139* Improvement: remove superfluous period after required PHP version
    136140* Improvement: move plugin init to PluginMain class
  • subscriptions-for-woo/trunk/subscriptions-for-woo.php

    r3270659 r3273939  
    1111 * License: GPLv2 or later
    1212 * License URI: https://www.gnu.org/licenses/gpl-2.0.html
    13  * Version: 2.5.4
     13 * Version: 2.5.5
    1414 * WC requires at least: 8.6.0
    1515 * WC tested up to: 9.7.1
Note: See TracChangeset for help on using the changeset viewer.