Plugin Directory

Changeset 3087581


Ignore:
Timestamp:
05/16/2024 09:19:38 AM (20 months ago)
Author:
joelbooks
Message:

update 1.1

Location:
cryptocurrency-support-box/tags/1.1
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • cryptocurrency-support-box/tags/1.1/admin/admin-page.php

    r3087184 r3087581  
    2626                    <div class="crypto-address-field">
    2727                        <input type="text" value="381QsjKxhHijnrxnKvnQRmWhjg4sPnhUxu" id="bitcoin-address-input" readonly="">
    28                         <button onclick="copyToClipboard(this, 'bitcoin-address-input')" class="copy-address-button" data-copied="false">
     28                        <button onclick="copyCodeToClipboard(this, 'bitcoin-address-input')" class="copy-address-button" data-copied="false">
    2929                            <svg class="copy-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24">
    3030                                <path fill="none" d="M0 0h24v24H0z"></path>
     
    4545                    <div class="crypto-address-field">
    4646                        <input type="text" value="6VZ6Ewh94HFX2agxLTFY2G9AvhfjrNCyv6s4ud4aVsGt" id="solana-address-input" readonly="">
    47                         <button onclick="copyToClipboard(this, 'solana-address-input')" class="copy-address-button" data-copied="false">
     47                        <button onclick="copyCodeToClipboard(this, 'solana-address-input')" class="copy-address-button" data-copied="false">
    4848                            <svg class="copy-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24">
    4949                                <path fill="none" d="M0 0h24v24H0z"></path>
  • cryptocurrency-support-box/tags/1.1/admin/admin-script.js

    r3087184 r3087581  
    1 jQuery(document).ready(function($) {
    2     console.log('Loaded');
     1jQuery(document).ready(function ($) {
     2    // Function to copy text to clipboard
     3    function copyCodeToClipboard(button, elementId) {
     4        console.log("copyCodeToClipboard called", button, elementId);
     5
     6        var copyText = document.getElementById(elementId);
     7        var textToCopy;
     8
     9        // Check if the element is an input or textarea
     10        if (copyText.tagName === 'INPUT' || copyText.tagName === 'TEXTAREA') {
     11            textToCopy = copyText.value;
     12            console.log("Right", textToCopy);
     13        } else {
     14
     15            textToCopy = copyText.textContent;
     16            console.log("Else", textToCopy);
     17        }
     18
     19        navigator.clipboard.writeText(textToCopy)
     20        .then(() => {
     21            // Hide the copy icon and show the done icon
     22            button.querySelector('.copy-icon').style.display = 'none';
     23            button.querySelector('.done-icon').style.display = 'block';
     24
     25            // Optionally, revert the icons after some time
     26            setTimeout(() => {
     27                button.querySelector('.copy-icon').style.display = 'block';
     28                button.querySelector('.done-icon').style.display = 'none';
     29            }, 2000); // 2 seconds delay
     30        })
     31        .catch(err => {
     32            console.error('Error in copying text: ', err);
     33        });
     34    }
     35    window.copyCodeToClipboard = copyCodeToClipboard;
     36   
    337    // Toggle between QR codes in the admin preview based on selection
    4     $('#crypto-select-preview').change(function() {
     38    $('#crypto-select-preview').change(function () {
    539        $('.crypto-option').hide();
    6        
     40
    741        var selectedCrypto = $(this).val();
    842        $('#crypto-option-' + selectedCrypto).show();
     
    1246    function refreshCryptoSelect() {
    1347        var $select = $('#default_crypto');
    14         var currentValue = $select.val();  // Capture the current value
     48        var currentValue = $select.val(); // Capture the current value
    1549        $select.empty();
    1650
     
    2155        };
    2256
    23         console.log("Address lengths:", cryptos);
    24 
    25         $.each(cryptos, function(crypto, address) {
     57        $.each(cryptos, function (crypto, address) {
    2658            if ((address.length >= 26 && address.length <= 62 && crypto === 'bitcoin') ||
    2759                (address.length === 42 && crypto === 'ethereum') ||
    2860                (address.length >= 32 && address.length <= 44 && crypto === 'solana')) {
    29                 console.log("Adding option for:", crypto);
    3061                $select.append('<option value="' + crypto + '">' + crypto.charAt(0).toUpperCase() + crypto.slice(1) + '</option>');
    3162            }
     
    3667            $select.val(currentValue);
    3768        } else {
    38             $select.val($select.find('option:first').val());  // Default to the first option if the previous value is not found
     69            $select.val($select.find('option:first').val()); // Default to the first option if the previous value is not found
    3970        }
    4071    }
     
    4475
    4576    // Attach event listeners to address fields
    46     $(document).on('input', '#crypto_bitcoin_address, #crypto_ethereum_address, #crypto_solana_address', function() {
     77    $(document).on('input', '#crypto_bitcoin_address, #crypto_ethereum_address, #crypto_solana_address', function () {
    4778        refreshCryptoSelect();
    4879    });
  • cryptocurrency-support-box/tags/1.1/crypto-support-box.php

    r3087184 r3087581  
    7575    register_setting('crypto_support_box_options', 'default_crypto');
    7676
     77    // Section to show the shortcode
     78    add_settings_section('crypto_support_box_shortcode_section', 'Use Shortcode to Display the Box', 'display_shortcode_with_copy_button', 'crypto_support_box');
     79   
    7780    // Section for the settings
    7881    add_settings_section('crypto_support_box_section', 'Cryptocurrency Settings', 'crypto_support_box_section_callback', 'crypto_support_box');
    79 
     82   
    8083    // Fields for each setting
    8184    add_settings_field('crypto_title', 'Crypto Support Box Title', 'crypto_support_box_field_callback', 'crypto_support_box', 'crypto_support_box_section', array('label_for' => 'crypto_title'));
     
    109112
    110113function crypto_support_box_section_callback() {
    111     echo '<p>Enter your cryptocurrency address details and the title of the widget. If you need any further help check the <a href="https://aiscores.com/crypto-donation-widget-guide" target="_blank">visual guide</a> for this plugin.</p>';
     114    echo '<p>Enter your cryptocurrency address details and the title of the widget. If you need any further help check the <a href="https://aiscores.com/crypto-donation-widget-guide" target="_blank">visual guide</a> for this plugin. If you have any questions, suggestions, or feedback, don\'t hesitate to contact the developer using this <a href="https://joelbooks.com/contact/?topic=Crypto%20Support%20Box" target="_blank">link</a>.</p>';
     115}
     116
     117function display_shortcode_with_copy_button() {
     118    echo '<div class="shortcode-container">';
     119    echo '<code id="crypto-shortcode">[crypto_support_box]</code>';
     120    echo '<button class="copy-shortcode-button" style="margin-left:10px;" onclick="copyCodeToClipboard(this, \'crypto-shortcode\')">';
     121    echo '<span class="copy-code-icon">📋 Copy</span>';
     122    echo '<span class="done-code-icon" style="display:none;">✔️ Copied</span>';
     123    echo '</button>';
     124    echo '</div>';
    112125}
    113126
     
    121134    include_once plugin_dir_path(__FILE__) . 'admin/admin-page.php';
    122135}
     136
     137// Add settings link on the plugins page
     138add_filter('plugin_action_links_' . plugin_basename(__FILE__), 'crypto_support_box_action_links');
     139
     140function crypto_support_box_action_links($links) {
     141    $settings_link = '<a href="admin.php?page=crypto-support-box">' . __('Settings') . '</a>';
     142    array_unshift($links, $settings_link);
     143    return $links;
     144}
  • cryptocurrency-support-box/tags/1.1/js/main.js

    r3087184 r3087581  
    5151    }
    5252
    53     // Generate QR codes for each crypto if no qr_url is provided
     53    // Generate QR codes for each crypto if an address is provided
    5454    var cryptos = ['bitcoin', 'ethereum', 'solana'];
    5555    cryptos.forEach(function(crypto) {
    56         var address = document.getElementById(crypto + '-address-input').value;
    57         var qrElement = document.getElementById('qrcode-' + crypto);
    58         var logoUrl = crypto_addresses.plugin_url + 'assets/' + crypto + '-logo.png'; // Use localized plugin URL
    59         if (address && qrElement && !qrElement.hasChildNodes()) {
    60             generateQRCode('qrcode-' + crypto, address, logoUrl);
     56        var addressInput = document.getElementById(crypto + '-address-input');
     57        if (addressInput) {
     58            var address = addressInput.value;
     59            var qrElement = document.getElementById('qrcode-' + crypto);
     60            var logoUrl = crypto_addresses.plugin_url + 'assets/' + crypto + '-logo.png'; // Use localized plugin URL
     61            if (address && qrElement && !qrElement.hasChildNodes()) {
     62                generateQRCode('qrcode-' + crypto, address, logoUrl);
     63            } else {
     64                console.log('No address found for:', crypto); // Debug log
     65            }
     66        } else {
     67            console.log('Address input not found for:', crypto); // Debug log
    6168        }
    6269    });
     
    7986
    8087
     88
  • cryptocurrency-support-box/tags/1.1/readme.txt

    r3087184 r3087581  
    11=== Cryptocurrency Support Box ===
    2 Contributors: [joelbooks]
     2Contributors: AI Scores
    33Tags: cryptocurrency, donations, bitcoin, ethereum, solana
    44Requires at least: 5.0
Note: See TracChangeset for help on using the changeset viewer.