Changeset 3087581
- Timestamp:
- 05/16/2024 09:19:38 AM (20 months ago)
- Location:
- cryptocurrency-support-box/tags/1.1
- Files:
-
- 5 edited
-
admin/admin-page.php (modified) (2 diffs)
-
admin/admin-script.js (modified) (5 diffs)
-
crypto-support-box.php (modified) (3 diffs)
-
js/main.js (modified) (2 diffs)
-
readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
cryptocurrency-support-box/tags/1.1/admin/admin-page.php
r3087184 r3087581 26 26 <div class="crypto-address-field"> 27 27 <input type="text" value="381QsjKxhHijnrxnKvnQRmWhjg4sPnhUxu" id="bitcoin-address-input" readonly=""> 28 <button onclick="copy ToClipboard(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"> 29 29 <svg class="copy-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24"> 30 30 <path fill="none" d="M0 0h24v24H0z"></path> … … 45 45 <div class="crypto-address-field"> 46 46 <input type="text" value="6VZ6Ewh94HFX2agxLTFY2G9AvhfjrNCyv6s4ud4aVsGt" id="solana-address-input" readonly=""> 47 <button onclick="copy ToClipboard(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"> 48 48 <svg class="copy-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24"> 49 49 <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'); 1 jQuery(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 3 37 // Toggle between QR codes in the admin preview based on selection 4 $('#crypto-select-preview').change(function () {38 $('#crypto-select-preview').change(function () { 5 39 $('.crypto-option').hide(); 6 40 7 41 var selectedCrypto = $(this).val(); 8 42 $('#crypto-option-' + selectedCrypto).show(); … … 12 46 function refreshCryptoSelect() { 13 47 var $select = $('#default_crypto'); 14 var currentValue = $select.val(); // Capture the current value48 var currentValue = $select.val(); // Capture the current value 15 49 $select.empty(); 16 50 … … 21 55 }; 22 56 23 console.log("Address lengths:", cryptos); 24 25 $.each(cryptos, function(crypto, address) { 57 $.each(cryptos, function (crypto, address) { 26 58 if ((address.length >= 26 && address.length <= 62 && crypto === 'bitcoin') || 27 59 (address.length === 42 && crypto === 'ethereum') || 28 60 (address.length >= 32 && address.length <= 44 && crypto === 'solana')) { 29 console.log("Adding option for:", crypto);30 61 $select.append('<option value="' + crypto + '">' + crypto.charAt(0).toUpperCase() + crypto.slice(1) + '</option>'); 31 62 } … … 36 67 $select.val(currentValue); 37 68 } else { 38 $select.val($select.find('option:first').val()); // Default to the first option if the previous value is not found69 $select.val($select.find('option:first').val()); // Default to the first option if the previous value is not found 39 70 } 40 71 } … … 44 75 45 76 // 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 () { 47 78 refreshCryptoSelect(); 48 79 }); -
cryptocurrency-support-box/tags/1.1/crypto-support-box.php
r3087184 r3087581 75 75 register_setting('crypto_support_box_options', 'default_crypto'); 76 76 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 77 80 // Section for the settings 78 81 add_settings_section('crypto_support_box_section', 'Cryptocurrency Settings', 'crypto_support_box_section_callback', 'crypto_support_box'); 79 82 80 83 // Fields for each setting 81 84 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')); … … 109 112 110 113 function 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 117 function 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>'; 112 125 } 113 126 … … 121 134 include_once plugin_dir_path(__FILE__) . 'admin/admin-page.php'; 122 135 } 136 137 // Add settings link on the plugins page 138 add_filter('plugin_action_links_' . plugin_basename(__FILE__), 'crypto_support_box_action_links'); 139 140 function 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 51 51 } 52 52 53 // Generate QR codes for each crypto if no qr_urlis provided53 // Generate QR codes for each crypto if an address is provided 54 54 var cryptos = ['bitcoin', 'ethereum', 'solana']; 55 55 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 61 68 } 62 69 }); … … 79 86 80 87 88 -
cryptocurrency-support-box/tags/1.1/readme.txt
r3087184 r3087581 1 1 === Cryptocurrency Support Box === 2 Contributors: [joelbooks]2 Contributors: AI Scores 3 3 Tags: cryptocurrency, donations, bitcoin, ethereum, solana 4 4 Requires at least: 5.0
Note: See TracChangeset
for help on using the changeset viewer.