Plugin Directory

Changeset 2846570


Ignore:
Timestamp:
01/11/2023 08:01:35 AM (3 years ago)
Author:
rider7991
Message:

Global version variable added.
Tested with new WP versions.

Location:
share-that-cart/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • share-that-cart/trunk/copy.js

    r2633979 r2846570  
    1 function copy() {
    2     const input = document.getElementById('sc__link');
    3     input.focus();
    4     input.select();
    5     document.execCommand('copy');
    6 }
     1(function () {
     2    function copy() {
     3        const input = document.getElementById('sc__link');
     4        input.focus();
     5        input.select();
     6        document.execCommand('copy');
     7    }
    78
    8 const callback = function(mutationsList, observer) {
    9     const popup = document.querySelector('#sc__popup');
    10     const button = document.getElementById('sc__button');
    11     button.addEventListener('click', (e)=>{
    12         e.preventDefault();
    13         copy();
    14         popup.style.display = "block";
    15     });
     9    const callback = function(mutationsList, observer) {
     10        const popup = document.querySelector('#sc__popup');
     11        const button = document.getElementById('sc__button');
     12        button.addEventListener('click', (e)=>{
     13            e.preventDefault();
     14            copy();
     15            popup.style.display = "block";
     16        });
    1617
    17     popup.addEventListener('click', ()=>{
    18         popup.style.display = "none";
    19     });
    20 };
     18        popup.addEventListener('click', ()=>{
     19            popup.style.display = "none";
     20        });
     21    };
    2122
    22 if (document.getElementById('sc__button')){
    23     //
    24     const popup = document.querySelector('#sc__popup');
    25     const button = document.getElementById('sc__button');
    26     button.addEventListener('click', (e)=>{
    27         e.preventDefault();
    28         copy();
    29         popup.style.display = "block";
    30     });
     23    if (document.getElementById('sc__button')){
     24        const popup = document.querySelector('#sc__popup');
     25        const button = document.getElementById('sc__button');
     26        button.addEventListener('click', (e)=>{
     27            e.preventDefault();
     28            copy();
     29            popup.style.display = "block";
     30        });
    3131
    32     popup.addEventListener('click', ()=>{
    33         popup.style.display = "none";
    34     });
    35     //
     32        popup.addEventListener('click', ()=>{
     33            popup.style.display = "none";
     34        });
    3635
    37     const target_block = document.querySelector('.entry-content');
    38     const config = { attributes: true, childList: true, subtree: true };
    39     const observer = new MutationObserver(callback);
    40     observer.observe(target_block, config);
    41 }
     36        const target_block = document.querySelector('.entry-content');
     37        const config = { attributes: true, childList: true, subtree: true };
     38        const observer = new MutationObserver(callback);
     39        observer.observe(target_block, config);
     40    }
     41})();
  • share-that-cart/trunk/readme.txt

    r2693569 r2846570  
    44Donate link: https://www.paypal.me/Rider7991
    55Requires at least: 4.0
    6 Tested up to: 5.9
     6Tested up to: 6.1
    77Requires PHP: 7.0
    88Stable tag: trunk
  • share-that-cart/trunk/share-that-cart.php

    r2693568 r2846570  
    99*/
    1010defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
     11
     12if ( !defined( 'SC_VERSION' ) ) {
     13    define( 'SC_VERSION', '1.0.1' );
     14}
    1115
    1216add_action('woocommerce_after_cart_contents', 'sc_button');
     
    2731function sc_load_scripts() {
    2832    if ( is_cart() ) {
    29         wp_enqueue_style( 'sc-css', plugins_url('/style.css', __FILE__), '', '1.0.0', false );
    30         wp_enqueue_script( 'sc-js', plugins_url('/copy.js', __FILE__), '', '1.0.0', true );
     33        wp_enqueue_style( 'sc-css', plugins_url('/style.css', __FILE__), '', SC_VERSION, false );
     34        wp_enqueue_script( 'sc-js', plugins_url('/copy.js', __FILE__), '', SC_VERSION, true );
    3135    }
    3236}
Note: See TracChangeset for help on using the changeset viewer.