Changeset 3461995
- Timestamp:
- 02/15/2026 06:19:20 PM (7 weeks ago)
- Location:
- coinsnap-bitcoin-voting
- Files:
-
- 36 added
- 9 edited
-
tags/1.2.3 (added)
-
tags/1.2.3/assets (added)
-
tags/1.2.3/assets/css (added)
-
tags/1.2.3/assets/css/admin-style.css (added)
-
tags/1.2.3/assets/css/index.php (added)
-
tags/1.2.3/assets/css/style.css (added)
-
tags/1.2.3/assets/images (added)
-
tags/1.2.3/assets/images/bitcoin.svg (added)
-
tags/1.2.3/assets/images/bitcoinqr.svg (added)
-
tags/1.2.3/assets/images/checkmark.svg (added)
-
tags/1.2.3/assets/images/index.php (added)
-
tags/1.2.3/assets/index.php (added)
-
tags/1.2.3/assets/js (added)
-
tags/1.2.3/assets/js/admin.js (added)
-
tags/1.2.3/assets/js/index.php (added)
-
tags/1.2.3/assets/js/popup.js (added)
-
tags/1.2.3/assets/js/shared.js (added)
-
tags/1.2.3/assets/js/voting.js (added)
-
tags/1.2.3/coinsnap-bitcoin-voting.php (added)
-
tags/1.2.3/includes (added)
-
tags/1.2.3/includes/class-coinsnap-bitcoin-voting-client.php (added)
-
tags/1.2.3/includes/class-coinsnap-bitcoin-voting-list.php (added)
-
tags/1.2.3/includes/class-coinsnap-bitcoin-voting-polls.php (added)
-
tags/1.2.3/includes/class-coinsnap-bitcoin-voting-public-donors.php (added)
-
tags/1.2.3/includes/class-coinsnap-bitcoin-voting-settings.php (added)
-
tags/1.2.3/includes/class-coinsnap-bitcoin-voting-shortcode-voting.php (added)
-
tags/1.2.3/includes/class-coinsnap-bitcoin-voting-webhooks.php (added)
-
tags/1.2.3/includes/index.php (added)
-
tags/1.2.3/index.php (added)
-
tags/1.2.3/languages (added)
-
tags/1.2.3/languages/index.php (added)
-
tags/1.2.3/readme.txt (added)
-
tags/1.2.3/templates (added)
-
tags/1.2.3/templates/coinsnap-bitcoin-voting-modal.php (added)
-
tags/1.2.3/templates/index.php (added)
-
tags/1.2.3/uninstall.php (added)
-
trunk/assets/css/style.css (modified) (9 diffs)
-
trunk/assets/js/admin.js (modified) (3 diffs)
-
trunk/assets/js/popup.js (modified) (5 diffs)
-
trunk/assets/js/shared.js (modified) (13 diffs)
-
trunk/assets/js/voting.js (modified) (3 diffs)
-
trunk/coinsnap-bitcoin-voting.php (modified) (8 diffs)
-
trunk/includes/class-coinsnap-bitcoin-voting-shortcode-voting.php (modified) (1 diff)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/templates/coinsnap-bitcoin-voting-modal.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
coinsnap-bitcoin-voting/trunk/assets/css/style.css
r3355796 r3461995 335 335 transform: translate(-50%, -50%); 336 336 background: white; 337 padding: 58px 28px;338 337 box-shadow: 0 0 10px rgba(0, 0, 0, 0.3); 339 338 z-index: 99999; … … 342 341 flex-direction: column; 343 342 align-items: center; 344 width: 340px; 343 width: 90%; 344 max-width: 720px; 345 max-height: 95%; 346 overflow: auto; 347 box-sizing: border-box; 345 348 gap: 12px; 346 349 } … … 349 352 max-width: 200px !important; 350 353 } 354 355 351 356 352 357 .close-popup { … … 602 607 } 603 608 609 #blur-overlay-outer { 610 z-index: 99998; 611 } 612 613 #coinsnap-popup-outer { 614 z-index: 99999; 615 } 616 604 617 .blur-overlay { 605 618 display: none; … … 621 634 flex-direction: column; 622 635 width: -webkit-fill-available; 623 margin: 0px 24px;636 margin: 20px; 624 637 } 625 638 626 639 .payment-loading { 627 640 display: none; 641 padding:20px; 628 642 } 629 643 … … 633 647 justify-content: center; 634 648 align-items: center; 649 padding:20px; 635 650 } 636 651 … … 644 659 justify-content: center; 645 660 align-items: center; 646 661 padding:20px; 647 662 } 648 663 … … 689 704 } 690 705 706 .person-grid { 707 display: flex; 708 gap: 8px; 709 } 710 711 @media screen and (max-width: 600px) { 712 .person-grid { 713 flex-direction: column; 714 } 715 } 716 691 717 .address-grid { 692 718 display: flex; … … 700 726 gap: 8px; 701 727 justify-content: space-between; 728 } 729 730 .address-row .address-cell.half { 731 width:50%; 732 } 733 734 .address-row .address-cell.quart { 735 width:25%; 702 736 } 703 737 -
coinsnap-bitcoin-voting/trunk/assets/js/admin.js
r3355796 r3461995 174 174 175 175 async function handleCheckConnection(isSubmit = false) { 176 event.preventDefault();177 var connection = false 176 //event.preventDefault(); 177 var connection = false; 178 178 const ngrokLiveUrl = document.getElementById('ngrok_url')?.value; 179 179 const origin = ngrokLiveUrl ? ngrokLiveUrl : new URL(window.location.href).origin; 180 const webhookUrl = `${origin}/wp-json/coinsnap-bitcoin-voting/v1/webhook` 181 if ($providerSelector?.val() == 'coinsnap') {180 const webhookUrl = `${origin}/wp-json/coinsnap-bitcoin-voting/v1/webhook`; 181 if ($providerSelector?.val() === 'coinsnap') { 182 182 const coinsnapStoreId = $('#coinsnap_store_id').val(); 183 183 const coinsnapApiKey = $('#coinsnap_api_key').val(); 184 connection = await checkConnection(coinsnapStoreId, coinsnapApiKey) 184 connection = await checkConnection(coinsnapStoreId, coinsnapApiKey); 185 185 if (connection) { 186 const webhooks = await checkWebhooks(coinsnapStoreId, coinsnapApiKey) 186 const webhooks = await checkWebhooks(coinsnapStoreId, coinsnapApiKey); 187 187 const webhookFound = webhooks?.find(webhook => webhook.url === webhookUrl); 188 188 if (!webhookFound) { 189 await createWebhook(coinsnapStoreId, coinsnapApiKey, webhookUrl) 189 await createWebhook(coinsnapStoreId, coinsnapApiKey, webhookUrl); 190 190 } else { 191 await updateWebhook(coinsnapStoreId, coinsnapApiKey, webhookUrl, webhookFound.id) 191 await updateWebhook(coinsnapStoreId, coinsnapApiKey, webhookUrl, webhookFound.id); 192 192 } 193 193 } … … 207 207 } 208 208 } 209 setCookie('coinsnap_ connection_', JSON.stringify({ 'connection': connection }), 20)209 setCookie('coinsnap_bitcoin_voting_connection', JSON.stringify({ 'connection': connection }), 20); 210 210 if (!isSubmit) { 211 211 $('#submit').click(); … … 223 223 $checkConnectionBtcPayButton.on('click', async (event) => { await handleCheckConnection(); }); 224 224 225 const connectionCookie = getCookie('coinsnap_ connection_');225 const connectionCookie = getCookie('coinsnap_bitcoin_voting_connection'); 226 226 if (connectionCookie) { 227 227 const connectionState = JSON.parse(connectionCookie)?.connection -
coinsnap-bitcoin-voting/trunk/assets/js/popup.js
r3355796 r3461995 47 47 } 48 48 49 const popupButtonListener = ( exchangeRates,pollId, amount, amountFiat, currency, publicDonor) => {49 const popupButtonListener = (pollId, amount, amountFiat, currency, publicDonor) => { 50 50 51 51 document.getElementById(`coinsnap-bitcoin-voting-public-donors-pay${pollId}`)?.addEventListener('click', async () => { … … 71 71 donorName: `${firstNameField.value} ${lastNameField?.value ?? ''}`, 72 72 donorEmail: emailField?.value, 73 donorAddress: address != ' , , '? address : '',73 donorAddress: (address !== ' , , ')? address : '', 74 74 donorCustom: customContent, 75 75 formType: 'Coinsnap Bitcoin Voting', … … 119 119 120 120 // Add fiat amount 121 //if (exchangeRates['EUR']) { 122 document.getElementById(`coinsnap-bitcoin-voting-qr-fiat${pollId}`).textContent = `≈ ${(res.amount * exchangeRates['EUR'])?.toFixed(3)} EUR`; 121 document.getElementById(`coinsnap-bitcoin-voting-qr-fiat${pollId}`).textContent = `≈ ${amountFiat} ${currency}`; 123 122 document.getElementById(`coinsnap-bitcoin-voting-pay-in-wallet${pollId}`).setAttribute('href', `lightning:${qrLightning}`); 124 //}123 125 124 126 125 // Reset retry counter … … 146 145 147 146 148 } else if (qrContainer.style.display != 'flex') {147 } else if (qrContainer.style.display !== 'flex') { 149 148 retryId = ''; 150 149 } 151 else if (retryNum < 180 && retryId == res.id) {150 else if (retryNum < 180 && retryId === res.id) { 152 151 retryNum++; 153 152 checkPaymentStatus(); … … 159 158 console.error('Error checking payment status:', error); 160 159 retryNum++; 161 if (retryId == res.id) {160 if (retryId === res.id) { 162 161 setTimeout(checkPaymentStatus, 5000); 163 162 } 164 163 }); 165 164 } 166 checkPaymentStatus() 165 checkPaymentStatus(); 167 166 168 167 } 169 168 else { 170 console.error('Error creating invoice') 169 console.error('Error creating invoice'); 171 170 } 172 171 -
coinsnap-bitcoin-voting/trunk/assets/js/shared.js
r3355796 r3461995 14 14 const expires = "expires=" + d.toUTCString(); 15 15 document.cookie = name + "=" + value + ";" + expires + ";path=/"; 16 }17 18 async function fetchCoinsnapExchangeRates() {19 const exchangeRates = {}20 try {21 const response = await fetch(`https://app.coinsnap.io/api/v1/stores/${sharedData.coinsnapStoreId}/rates`, {22 method: 'GET',23 headers: {24 'Content-Type': 'application/json',25 'x-api-key': sharedData.coinsnapApiKey26 }27 });28 29 if (!response.ok) {30 throw new Error(`HTTP error! Status: ${response.status}`);31 }32 33 const data = await response.json();34 data35 .filter(item => item.currencyPair.includes("SATS")) // Filter only SATS rates36 .forEach(item => {37 const currency = item.currencyPair.replace("SATS_", ""); // Remove "SATS_" prefix38 exchangeRates[currency] = parseFloat(item.rate); // Update exchangeRates39 });40 41 return exchangeRates;42 } catch (error) {43 console.error('Error fetching exchange rates:', error);44 return null;45 }46 16 } 47 17 … … 62 32 63 33 const createActualVotingInvoice = async (amount, message, lastInputCurrency, name, coinsnap, type, redirect, metadata) => { 64 deleteCookie('coinsnap_invoice_'); 34 deleteCookie('coinsnap_invoice_voting'); 35 36 var orderId = 'VTNG_' + (Date.now()).toString(36); 37 38 var provider = (coinsnap === true)? 'coinsnap' : 'btcpay'; 39 40 if(provider === 'btcpay'){ 41 metadata.orderId = orderId; 42 } 65 43 66 44 const requestData = { 67 45 amount: amount, 68 46 currency: lastInputCurrency, 47 buyerEmail: metadata.donorEmail, 69 48 redirectAutomatically: true, 49 checkout: { 50 redirectAutomatically: true 51 }, 52 orderId: orderId, 53 walletMessage: message, 70 54 metadata: { 71 55 orderNumber: message, … … 73 57 type: type, 74 58 name: name, 75 ...metadata //TEST with voting59 ...metadata 76 60 } 77 61 }; 78 62 63 requestData.provider = (provider === 'coinsnap')? 'coinsnap' : 'btcpay'; 64 79 65 if (type === 'Coinsnap Bitcoin Voting') { 80 // requestData.metadata.optionId = metadata.optionId 81 // requestData.metadata.option = metadata.option 82 // requestData.metadata.pollId = metadata.pollId 83 requestData.metadata.orderNumber = `Voted for ${metadata.option}` 84 redirectAutomatically = false //TODO test 85 } 86 66 requestData.redirectUrl = requestData.checkout.redirectUrl = Coinsnap_Bitcoin_Voting_sharedData?.redirectUrl || window.location.href; 67 requestData.metadata.orderNumber = `Voted for ${metadata.option}`; 68 } 69 87 70 if (window.location.href.includes("localhost")) { 88 requestData.redirectUrl = "https://coinsnap.io";89 } 90 91 if ( coinsnap) {71 requestData.redirectUrl = requestData.checkout.redirectUrl = "https://coinsnap.io"; 72 } 73 74 if (provider === 'coinsnap') { 92 75 requestData.referralCode = 'D19833'; 93 76 } 94 77 95 const url = coinsnap96 ? `https://app.coinsnap.io/api/v1/stores/${ sharedData?.coinsnapStoreId}/invoices`97 : `${ sharedData?.btcpayUrl}/api/v1/stores/${sharedData?.btcpayStoreId}/invoices`;98 99 const headers = coinsnap78 const url = (provider === 'coinsnap') 79 ? `https://app.coinsnap.io/api/v1/stores/${Coinsnap_Bitcoin_Voting_sharedData?.coinsnapStoreId}/invoices` 80 : `${Coinsnap_Bitcoin_Voting_sharedData?.btcpayUrl}/api/v1/stores/${Coinsnap_Bitcoin_Voting_sharedData?.btcpayStoreId}/invoices`; 81 82 const headers = (provider === 'coinsnap') 100 83 ? { 101 'x-api-key': sharedData?.coinsnapApiKey,84 'x-api-key': Coinsnap_Bitcoin_Voting_sharedData?.coinsnapApiKey, 102 85 'Content-Type': 'application/json' 103 86 } 104 87 : { 105 'Authorization': 'token '+ sharedData?.btcpayApiKey,88 'Authorization': 'token '+Coinsnap_Bitcoin_Voting_sharedData?.btcpayApiKey, 106 89 'Content-Type': 'application/json' 107 90 }; … … 129 112 }; 130 113 131 setCookie('coinsnap_invoice_ ', JSON.stringify(invoiceCookieData), 15);132 if ( !coinsnap) {133 const url = `${ sharedData?.btcpayUrl}/api/v1/stores/${sharedData?.btcpayStoreId}/invoices/${responseData.id}/payment-methods`;114 setCookie('coinsnap_invoice_voting', JSON.stringify(invoiceCookieData), 15); 115 if (provider === 'btcpay') { 116 const url = `${Coinsnap_Bitcoin_Voting_sharedData?.btcpayUrl}/api/v1/stores/${Coinsnap_Bitcoin_Voting_sharedData?.btcpayStoreId}/invoices/${responseData.id}/payment-methods`; 134 117 const response2 = await fetch(url, { 135 118 method: 'GET', 136 headers: headers ,119 headers: headers 137 120 }); 138 121 const responseData2 = await response2.json(); 139 const paymentLink = responseData2[0].paymentLink 140 console.log('Payment Link:', paymentLink) 141 responseData.lightningInvoice = paymentLink?.replace('lightning:', '') 142 responseData.onchainAddress = '' 122 const paymentLink = responseData2[0].paymentLink; 123 responseData.lightningInvoice = paymentLink?.replace('lightning:', ''); 124 responseData.onchainAddress = ''; 143 125 144 126 // Generate QR code image from lightning invoice … … 146 128 responseData.qrCodes = { 147 129 lightningQR: qrCodeImage || paymentLink 148 } 130 }; 149 131 } 150 132 if (redirect) { … … 161 143 const checkVotingInvoiceStatus = async (invoiceId, amount, message, lastInputCurrency, name, coinsnap, type, redirect, metadata) => { 162 144 163 const url = coinsnap 164 ? `https://app.coinsnap.io/api/v1/stores/${sharedData.coinsnapStoreId}/invoices/${invoiceId}` 165 : `${sharedData.btcpayUrl}/api/v1/stores/${sharedData.btcpayStoreId}/invoices/${invoiceId}`; 166 167 const headers = coinsnap 145 var provider = (coinsnap === true)? 'coinsnap' : 'btcpay'; 146 147 const url = (provider === 'coinsnap') 148 ? `https://app.coinsnap.io/api/v1/stores/${Coinsnap_Bitcoin_Voting_sharedData.coinsnapStoreId}/invoices/${invoiceId}` 149 : `${Coinsnap_Bitcoin_Voting_sharedData.btcpayUrl}/api/v1/stores/${Coinsnap_Bitcoin_Voting_sharedData.btcpayStoreId}/invoices/${invoiceId}`; 150 151 const headers = (provider === 'coinsnap') 168 152 ? { 169 'x-api-key': sharedData.coinsnapApiKey,153 'x-api-key': Coinsnap_Bitcoin_Voting_sharedData.coinsnapApiKey, 170 154 'Content-Type': 'application/json' 171 155 172 156 } 173 157 : { 174 'Authorization': 'token '+ sharedData.btcpayApiKey,158 'Authorization': 'token '+Coinsnap_Bitcoin_Voting_sharedData.btcpayApiKey, 175 159 'Content-Type': 'application/json' 176 160 }; … … 188 172 var responseData = await response.json(); 189 173 190 if ( !coinsnap) {191 const url = `${ sharedData?.btcpayUrl}/api/v1/stores/${sharedData?.btcpayStoreId}/invoices/${responseData.id}/payment-methods`;174 if (provider === 'btcpay') { 175 const url = `${Coinsnap_Bitcoin_Voting_sharedData?.btcpayUrl}/api/v1/stores/${Coinsnap_Bitcoin_Voting_sharedData?.btcpayStoreId}/invoices/${responseData.id}/payment-methods`; 192 176 const response2 = await fetch(url, { 193 177 method: 'GET', 194 headers: headers ,178 headers: headers 195 179 }); 196 180 const responseData2 = await response2.json(); 197 const paymentLink = responseData2[0].paymentLink 198 console.log('Payment Link:', paymentLink) 199 responseData.lightningInvoice = paymentLink?.replace('lightning:', '') 200 responseData.onchainAddress = '' 181 const paymentLink = responseData2[0].paymentLink; 182 responseData.lightningInvoice = paymentLink?.replace('lightning:', ''); 183 responseData.onchainAddress = ''; 201 184 202 185 // Generate QR code image from lightning invoice … … 213 196 window.location.href = responseData.checkoutLink; 214 197 } 215 return responseData 198 return responseData; 216 199 } 217 200 … … 222 205 }; 223 206 207 // Invoice creation 224 208 const createVotingInvoice = async (amount, message, amountFiat, lastInputCurrency, name, type, redirect = true, metadata) => { 225 existingInvoice = getCookie('coinsnap_invoice_ ');209 existingInvoice = getCookie('coinsnap_invoice_voting'); 226 210 lastInputCurrency = 'SATS'; 227 211 if (existingInvoice) { … … 241 225 lastInputCurrency, 242 226 name, 243 sharedData.provider== 'coinsnap',227 Coinsnap_Bitcoin_Voting_sharedData.provider === 'coinsnap', 244 228 type, 245 229 redirect, 246 230 metadata 247 ) 248 return cs 231 ); 232 return cs; 249 233 } 250 234 else { … … 254 238 lastInputCurrency, 255 239 name, 256 sharedData.provider== 'coinsnap',240 Coinsnap_Bitcoin_Voting_sharedData.provider === 'coinsnap', 257 241 type, 258 242 redirect, 259 243 metadata 260 ) 244 ); 261 245 } 262 246 } … … 267 251 lastInputCurrency, 268 252 name, 269 sharedData.provider== 'coinsnap',253 Coinsnap_Bitcoin_Voting_sharedData.provider === 'coinsnap', 270 254 type, 271 255 redirect, 272 256 metadata 273 ) 274 } 275 } 257 ); 258 } 259 }; 276 260 277 261 const hideVotingElementById = (id, prefix = '', sufix = '') => { … … 282 266 hideVotingElementById(id, prefix, sufix) 283 267 }) 284 } 268 }; 285 269 const showVotingElementById = (id, display, prefix = '', sufix = '') => { 286 document.getElementById(`${prefix}${id}${sufix}`).style.display = display 287 } 270 document.getElementById(`${prefix}${id}${sufix}`).style.display = display; 271 }; 288 272 const showVotingElementsById = (ids, display, prefix = '', sufix = '') => { 289 273 ids.forEach(id => { 290 showVotingElementById(id, display, prefix, sufix) 274 showVotingElementById(id, display, prefix, sufix); 291 275 }) 292 } 276 }; -
coinsnap-bitcoin-voting/trunk/assets/js/voting.js
r3355796 r3461995 1 jQuery(document).ready(function ($) {1 jQuery(document).ready(function($) { 2 2 3 if(!$('#blur-overlay-outer').length){ 4 $('body').append('<div id="blur-overlay-outer"></div><div id="coinsnap-popup-outer"></div>'); 5 } 6 3 7 if (document.getElementsByClassName('coinsnap-bitcoin-voting-form')?.length > 0) { 8 9 var overlayContainer = $('.blur-overlay.coinsnap-bitcoin-voting').detach(); 10 $('#blur-overlay-outer').append(overlayContainer); 11 var qrContainer = $('.qr-container.coinsnap-bitcoin-voting').detach(); 12 $('#coinsnap-popup-outer').append(qrContainer); 4 13 5 fetchCoinsnapExchangeRates().then(rates => {14 //fetchCoinsnapExchangeRates().then(rates => { 6 15 addWindowListeners(); 7 16 const votingForms = document.getElementsByClassName('coinsnap-bitcoin-voting-form'); … … 13 22 const currency = votingForm.dataset.pollCurrency; 14 23 const donorInfo = votingForm.dataset.donorInfo; 15 popupButtonListener( rates,pollId, amount, amountFiat, currency, donorInfo);24 popupButtonListener(pollId, amount, amountFiat, currency, donorInfo); 16 25 } 17 });26 //}); 18 27 19 28 … … 61 70 fetchResultsFromDb(pollId, votingForm); 62 71 }; 63 64 const votingForms = document.getElementsByClassName('coinsnap-bitcoin-voting-form');65 72 66 73 for (let i = 0; i < votingForms.length; i++) { -
coinsnap-bitcoin-voting/trunk/coinsnap-bitcoin-voting.php
r3412858 r3461995 4 4 * Plugin URI: https://coinsnap.io/coinsnap-bitcoin-voting-plugin/ 5 5 * Description: Easy Bitcoin voting on a WordPress website 6 * Version: 1.2. 16 * Version: 1.2.3 7 7 * Author: Coinsnap 8 8 * Author URI: https://coinsnap.io/ … … 19 19 20 20 if(!defined( 'COINSNAP_BITCOIN_VOTING_REFERRAL_CODE' ) ) { define( 'COINSNAP_BITCOIN_VOTING_REFERRAL_CODE', 'D46835' );} 21 if(!defined( 'COINSNAP_BITCOIN_VOTING_VERSION' ) ) { define( 'COINSNAP_BITCOIN_VOTING_VERSION', '1.2. 1' );}21 if(!defined( 'COINSNAP_BITCOIN_VOTING_VERSION' ) ) { define( 'COINSNAP_BITCOIN_VOTING_VERSION', '1.2.3' );} 22 22 if(!defined( 'COINSNAP_BITCOIN_VOTING_PHP_VERSION' ) ) { define( 'COINSNAP_BITCOIN_VOTING_PHP_VERSION', '8.0' );} 23 23 if(!defined( 'COINSNAP_BITCOIN_VOTING_PLUGIN_DIR' ) ){ define('COINSNAP_BITCOIN_VOTING_PLUGIN_DIR',plugin_dir_url(__FILE__));} … … 213 213 214 214 // Store the host to options before we leave the site. 215 coinsnap_settings_update( ['btcpay_url' => $host]);215 coinsnap_settings_update('coinsnap_bitcoin_voting_options',['btcpay_url' => $host]); 216 216 217 217 // Return the redirect url. … … 226 226 } 227 227 228 function coinsnap_bitcoin_voting_enqueue_scripts() 229 { 230 231 wp_enqueue_style('coinsnap-bitcoin-voting-style', plugin_dir_url(__FILE__) . 'assets/css/style.css', [], COINSNAP_BITCOIN_VOTING_VERSION); 232 wp_enqueue_script('coinsnap-bitcoin-voting-script', plugin_dir_url(__FILE__) . 'assets/js/voting.js', ['jquery'], COINSNAP_BITCOIN_VOTING_VERSION, true); 233 234 $provider_defaults = [ 235 'provider' => 'coinsnap', 236 'coinsnap_store_id' => '', 237 'coinsnap_api_key' => '', 238 'btcpay_store_id' => '', 239 'btcpay_api_key' => '', 240 'btcpay_url' => '' 241 ]; 242 $provider_options = array_merge($provider_defaults, (array) get_option('coinsnap_bitcoin_voting_options', [])); 243 wp_enqueue_script('coinsnap-bitcoin-voting-popup-script', plugin_dir_url(__FILE__) . 'assets/js/popup.js', ['jquery'], COINSNAP_BITCOIN_VOTING_VERSION, true); 244 245 // Localize script for sharedData 246 wp_enqueue_script('coinsnap-bitcoin-voting-shared-script', plugin_dir_url(__FILE__) . 'assets/js/shared.js', ['jquery'], COINSNAP_BITCOIN_VOTING_VERSION, true); 247 wp_localize_script('coinsnap-bitcoin-voting-shared-script', 'sharedData', [ 248 'provider' => $provider_options['provider'], 249 'coinsnapStoreId' => $provider_options['coinsnap_store_id'], 250 'coinsnapApiKey' => $provider_options['coinsnap_api_key'], 251 'btcpayStoreId' => $provider_options['btcpay_store_id'], 252 'btcpayApiKey' => $provider_options['btcpay_api_key'], 253 'btcpayUrl' => $provider_options['btcpay_url'], 254 'nonce' => wp_create_nonce('wp_rest') 255 ]); 228 function coinsnap_bitcoin_voting_enqueue_scripts(){ 229 230 global $post; 231 232 if ( is_a($post, 'WP_Post') && has_shortcode($post->post_content, 'coinsnap_bitcoin_voting') ) { 233 wp_enqueue_style('coinsnap-bitcoin-voting-style', plugin_dir_url(__FILE__) . 'assets/css/style.css', [], COINSNAP_BITCOIN_VOTING_VERSION); 234 wp_enqueue_script('coinsnap-bitcoin-voting-script', plugin_dir_url(__FILE__) . 'assets/js/voting.js', ['jquery'], COINSNAP_BITCOIN_VOTING_VERSION, true); 235 236 $provider_defaults = [ 237 'provider' => 'coinsnap', 238 'coinsnap_store_id' => '', 239 'coinsnap_api_key' => '', 240 'btcpay_store_id' => '', 241 'btcpay_api_key' => '', 242 'btcpay_url' => '' 243 ]; 244 $provider_options = array_merge($provider_defaults, (array) get_option('coinsnap_bitcoin_voting_options', [])); 245 wp_enqueue_script('coinsnap-bitcoin-voting-popup-script', plugin_dir_url(__FILE__) . 'assets/js/popup.js', ['jquery'], COINSNAP_BITCOIN_VOTING_VERSION, true); 246 247 $sharedDataArray = [ 248 'provider' => $provider_options['provider'], 249 'nonce' => wp_create_nonce('wp_rest') 250 ]; 251 252 if($provider_options['provider'] === 'btcpay'){ 253 $sharedDataArray['btcpayStoreId'] = $provider_options['btcpay_store_id']; 254 $sharedDataArray['btcpayApiKey'] = $provider_options['btcpay_api_key']; 255 $sharedDataArray['btcpayUrl'] = $provider_options['btcpay_url']; 256 } 257 else { 258 $sharedDataArray['coinsnapStoreId'] = $provider_options['coinsnap_store_id']; 259 $sharedDataArray['coinsnapApiKey'] = $provider_options['coinsnap_api_key']; 260 } 261 262 // Localize script for sharedData 263 wp_enqueue_script('coinsnap-bitcoin-voting-shared-script', plugin_dir_url(__FILE__) . 'assets/js/shared.js', ['jquery'], COINSNAP_BITCOIN_VOTING_VERSION, true); 264 wp_localize_script('coinsnap-bitcoin-voting-shared-script', 'Coinsnap_Bitcoin_Voting_sharedData', $sharedDataArray); 265 } 266 267 268 256 269 257 270 } … … 259 272 function coinsnap_bitcoin_voting_enqueue_admin_styles($hook){ 260 273 $post_id = (filter_input(INPUT_GET,'post',FILTER_SANITIZE_FULL_SPECIAL_CHARS ))? filter_input(INPUT_GET,'post',FILTER_SANITIZE_FULL_SPECIAL_CHARS ) : ''; 261 wp_enqueue_script('coinsnap-bitcoin-voting-admin-script', plugin_dir_url(__FILE__) . 'assets/js/admin.js', ['jquery'], COINSNAP_BITCOIN_VOTING_VERSION, true); 262 wp_localize_script('coinsnap-bitcoin-voting-admin-script', 'coinsnap_bitcoin_voting_ajax', array( 263 'ajax_url' => admin_url('admin-ajax.php'), 264 'nonce' => wp_create_nonce( 'coinsnap-ajax-nonce' ), 265 'post' => $post_id 266 )); 274 $post_type = (filter_input(INPUT_GET,'post_type',FILTER_SANITIZE_FULL_SPECIAL_CHARS ))? filter_input(INPUT_GET,'post_type',FILTER_SANITIZE_FULL_SPECIAL_CHARS ) : 275 ((!empty($post_id))? get_post_type($post_id) : ''); 276 $page = (filter_input(INPUT_GET,'page',FILTER_SANITIZE_FULL_SPECIAL_CHARS ))? filter_input(INPUT_GET,'page',FILTER_SANITIZE_FULL_SPECIAL_CHARS ) : ''; 277 278 if($page === 'coinsnap-bitcoin-voting' || $post_type === 'coinsnap-polls'){ 279 wp_enqueue_script('coinsnap-bitcoin-voting-admin-script', plugin_dir_url(__FILE__) . 'assets/js/admin.js', ['jquery'], COINSNAP_BITCOIN_VOTING_VERSION, true); 280 wp_localize_script('coinsnap-bitcoin-voting-admin-script', 'coinsnap_bitcoin_voting_ajax', array( 281 'ajax_url' => admin_url('admin-ajax.php'), 282 'nonce' => wp_create_nonce( 'coinsnap-ajax-nonce' ), 283 'post' => $post_id 284 )); 285 } 267 286 268 287 wp_enqueue_style('coinsnap-bitcoin-voting-admin-style', plugin_dir_url(__FILE__) . 'assets/css/admin-style.css', [], COINSNAP_BITCOIN_VOTING_VERSION); … … 338 357 }); 339 358 340 function coinsnap_settings_update($data){ 341 342 $form_data = get_option('coinsnap_bitcoin_voting_options', []); 359 if(!function_exists('coinsnap_settings_update')){ 360 function coinsnap_settings_update($option,$data){ 361 362 $form_data = get_option($option, []); 343 363 344 364 foreach($data as $key => $value){ … … 346 366 } 347 367 348 update_option('coinsnap_bitcoin_voting_options',$form_data); 349 } 368 update_option($option,$form_data); 369 } 370 } 350 371 351 372 // Adding template redirect handling for voting-btcpay-settings-callback. … … 433 454 if ($hasSingleStore && $hasRequiredPermissions) { 434 455 435 coinsnap_settings_update( [456 coinsnap_settings_update('coinsnap_bitcoin_voting_options',[ 436 457 'btcpay_api_key' => $data['apiKey'], 437 458 'btcpay_store_id' => explode(':', $btcpay_server_permissions[0])[1], -
coinsnap-bitcoin-voting/trunk/includes/class-coinsnap-bitcoin-voting-shortcode-voting.php
r3412858 r3461995 239 239 </div> 240 240 </div> 241 <div id="coinsnap-bitcoin-voting-blur-overlay<?php echo esc_html($poll_id); ?>" class="blur-overlay"></div> 241 <?php ?> 242 <div id="coinsnap-bitcoin-voting-blur-overlay<?php echo esc_html($poll_id); ?>" class="blur-overlay coinsnap-bitcoin-voting"></div> 242 243 <?php 243 244 $this->get_template('coinsnap-bitcoin-voting-modal', [ -
coinsnap-bitcoin-voting/trunk/readme.txt
r3438837 r3461995 4 4 Tags: Lightning, bitcoin, voting, polling, BTCPay 5 5 Tested up to: 6.9 6 Stable tag: 1.2. 16 Stable tag: 1.2.3 7 7 License: GPL2 8 8 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 188 188 * Fixed Wordpress Plugin Check warnings. 189 189 * Compatibility with Wordpress 6.9 is tested. 190 191 = 1.2.2 :: 2025-02-04 = 192 * Updated interface of donor information form. 193 * Compatibility with Wordpress 6.9.1 is tested. 194 195 = 1.2.3 :: 2025-02-15 = 196 * Update: Added order ID and all the standard fields for invoice request. 197 * Update: Added plugin isolation from other Coinsnap plugins in backend. 198 * Update: Deleted currency exchange check on frontend. 199 * Update: Added plugin isolation from other plugins in backend. -
coinsnap-bitcoin-voting/trunk/templates/coinsnap-bitcoin-voting-modal.php
r3300564 r3461995 1 1 <?php if (!defined('ABSPATH')){ exit;} ?> 2 2 3 <div id="<?php echo esc_html($prefix); ?>qr-container<?php echo esc_html($sufix); ?>" class="qr-container " data-public-donors="<?php echo esc_attr($public_donors); ?>">3 <div id="<?php echo esc_html($prefix); ?>qr-container<?php echo esc_html($sufix); ?>" class="qr-container coinsnap-bitcoin-voting" data-public-donors="<?php echo esc_attr($public_donors); ?>"> 4 4 <div class="close-popup">×</div> 5 5 <div id="<?php echo esc_html($prefix); ?>public-donor-popup<?php echo esc_html($sufix); ?>" class="public-donor-popup"> 6 <h3 style="margin-bottom: 24px; font-weight: bold">Donor Information</h3>6 7 7 <form class="public-donor-form"> 8 <?php if ($first_name !== 'hidden' || $last_name !== 'hidden' || $email !== 'hidden'){?> 9 <label><?php esc_html_e('Donor Information', 'coinsnap-bitcoin-voting');?></label> 10 <div class="person-grid"> 8 11 <?php if ($first_name !== 'hidden'): ?> 9 <label for="<?php echo esc_html($prefix); ?>first-name<?php echo esc_html($sufix); ?>">First Name</label> 10 <input <?php echo $first_name === 'mandatory' ? 'required' : ''; ?> 11 type="text" 12 <div class="person-cell"> 13 <input <?php echo $first_name === 'mandatory' ? 'required="required"' : ''; ?> type="text" 12 14 id="<?php echo esc_html($prefix); ?>first-name<?php echo esc_html($sufix); ?>" 13 placeholder="<?php echo $first_name === 'mandatory' ? 'Required' : 'Optional'; ?>"> 15 placeholder="<?php esc_html_e('First Name', 'coinsnap-bitcoin-voting'); echo $first_name === 'mandatory' ? '*' : ''; ?>"> 16 </div> 14 17 <?php endif; ?> 15 18 16 19 <?php if ($last_name !== 'hidden'): ?> 17 <label for="<?php echo esc_html($prefix); ?>last-name<?php echo esc_html($sufix); ?>">Last Name</label> 18 <input <?php echo $last_name === 'mandatory' ? 'required' : ''; ?> 19 type="text" 20 <div class="person-cell"> 21 <input <?php echo $last_name === 'mandatory' ? 'required="required"' : ''; ?> type="text" 20 22 id="<?php echo esc_html($prefix); ?>last-name<?php echo esc_html($sufix); ?>" 21 placeholder="<?php echo $last_name === 'mandatory' ? 'Required' : 'Optional'; ?>"> 23 placeholder="<?php esc_html_e('Last Name', 'coinsnap-bitcoin-voting'); echo $last_name === 'mandatory' ? '*' : ''; ?>"> 24 </div> 22 25 <?php endif; ?> 23 26 24 27 <?php if ($email !== 'hidden'): ?> 25 <label for="<?php echo esc_html($prefix); ?>donor-email<?php echo esc_html($sufix); ?>">Email</label> 26 <input <?php echo $email === 'mandatory' ? 'required' : ''; ?> 27 type="email" 28 <div class="person-cell"> 29 <input <?php echo $email === 'mandatory' ? 'required' : ''; ?> type="email" 28 30 id="<?php echo esc_html($prefix); ?>donor-email<?php echo esc_html($sufix); ?>" 29 placeholder="<?php echo $email === 'mandatory' ? 'Required' : 'Optional'; ?>"> 31 placeholder="<?php esc_html_e('Email', 'coinsnap-bitcoin-voting'); echo $email === 'mandatory' ? '*' : ''; ?>"> 32 </div> 30 33 <?php endif; ?> 34 </div> 35 36 <?php 37 38 }?> 31 39 32 40 <?php if ($address !== 'hidden'): ?> 33 <label> Address</label>41 <label><?php esc_html_e('Address', 'coinsnap-bitcoin-voting');?></label> 34 42 <div class="address-grid"> 35 43 <div class="address-row"> 36 < input <?php echo $address === 'mandatory' ? 'required' : ''; ?>37 type="text"44 <div class="address-cell half"> 45 <input <?php echo $address === 'mandatory' ? 'required="required"' : ''; ?> type="text" 38 46 id="<?php echo esc_html($prefix); ?>street<?php echo esc_html($sufix); ?>" 39 placeholder=" Street"40 style="width: 50%;">41 < input <?php echo $address === 'mandatory' ? 'required' : ''; ?>42 type="text"47 placeholder="<?php esc_html_e('Street', 'coinsnap-bitcoin-voting'); echo ($address === 'mandatory')? '*' : '';?>" /> 48 </div> 49 <div class="address-cell quart"> 50 <input <?php echo $address === 'mandatory' ? 'required="required"' : ''; ?> type="text" 43 51 id="<?php echo esc_html($prefix); ?>house-number<?php echo esc_html($sufix); ?>" 44 placeholder=" No."45 style="width: 24%;">46 < input <?php echo $address === 'mandatory' ? 'required' : ''; ?>47 type="text"52 placeholder="<?php esc_html_e('No.', 'coinsnap-bitcoin-voting'); echo ($address === 'mandatory')? '*' : '';?>" /> 53 </div> 54 <div class="address-cell quart"> 55 <input <?php echo $address === 'mandatory' ? 'required="required"' : ''; ?> type="text" 48 56 id="<?php echo esc_html($prefix); ?>postal<?php echo esc_html($sufix); ?>" 49 placeholder="ZIP" 50 style="width: 26%;"> 51 57 placeholder="<?php esc_html_e('ZIP', 'coinsnap-bitcoin-voting'); echo ($address === 'mandatory')? '*' : '';?>" /> 58 </div> 52 59 </div> 53 60 <div class="address-row"> 54 <input <?php echo $address === 'mandatory' ? 'required' : ''; ?> 61 <div class="address-cell half"> 62 <input <?php echo $address === 'mandatory' ? 'required="required"' : ''; ?> 55 63 type="text" 56 64 id="<?php echo esc_html($prefix); ?>town<?php echo esc_html($sufix); ?>" 57 placeholder=" Town"58 style="width: 50%;">59 < input <?php echo $address === 'mandatory' ? 'required' : ''; ?>60 type="text"65 placeholder="<?php esc_html_e('Town', 'coinsnap-bitcoin-voting'); echo ($address === 'mandatory')? '*' : '';?>" /> 66 </div> 67 <div class="address-cell half"> 68 <input <?php echo $address === 'mandatory' ? 'required="required"' : ''; ?> type="text" 61 69 id="<?php echo esc_html($prefix); ?>country<?php echo esc_html($sufix); ?>" 62 placeholder=" Country"63 style="width: 50%;">70 placeholder="<?php esc_html_e('Country', 'coinsnap-bitcoin-voting'); echo ($address === 'mandatory')? '*' : '';?>" /> 71 </div> 64 72 </div> 65 73 </div> 66 74 <?php endif; ?> 67 68 <?php if ($custom !== 'hidden'): ?> 69 <label id="<?php echo esc_html($prefix); ?>custom-name<?php echo esc_html($sufix); ?>" for="<?php echo esc_html($prefix); ?>custom<?php echo esc_html($sufix); ?>"><?php echo esc_html($custom_name); ?></label> 70 <input <?php echo $custom === 'mandatory' ? 'required' : ''; ?> 71 type="text" 75 76 <?php if ($custom !== 'hidden'): ?> 77 <label for="<?php echo esc_html($prefix); ?>custom<?php echo esc_html($sufix); ?>"><?php echo esc_html($custom_name);?></label> 78 <input <?php echo $custom === 'mandatory' ? 'required="required"' : ''; ?> type="text" 72 79 id="<?php echo esc_html($prefix); ?>custom<?php echo esc_html($sufix); ?>" 73 placeholder="<?php echo $custom === 'mandatory' ? 'Required' : 'Optional';?>">74 <?php endif; ?>75 <button type="submit" id="<?php echo esc_html($prefix); ?>public-donors-pay<?php echo esc_html($sufix); ?>"> Pay</button>80 placeholder="<?php echo esc_html($custom_name); echo ($custom === 'mandatory')? '*' : '';?>"> 81 <?php endif; ?> 82 <button type="submit" id="<?php echo esc_html($prefix); ?>public-donors-pay<?php echo esc_html($sufix); ?>"><?php esc_html_e('Pay with Bitcoin', 'coinsnap-bitcoin-voting');?></button> 76 83 </form> 77 84 </div> … … 90 97 <div class="qr-address-wrapper" id="<?php echo esc_html($prefix); ?>lightning-wrapper<?php echo esc_html($sufix); ?>" style="display: none; margin-top:8px"> 91 98 <div class="qr-address-title"> 92 Lightning:99 <?php esc_html_e('Lightning', 'coinsnap-bitcoin-voting');?>: 93 100 </div> 94 101 <div id="<?php echo esc_html($prefix); ?>qr-lightning-container<?php echo esc_html($sufix); ?>" style="display: none;" class="qr-lightning-container"> … … 102 109 <div id="<?php echo esc_html($prefix); ?>btc-wrapper<?php echo esc_html($sufix); ?>" style="display: none; margin-top:12px" class="qr-address-wrapper"> 103 110 <div class="qr-address-title"> 104 Address:111 <?php esc_html_e('Address', 'coinsnap-bitcoin-voting');?>: 105 112 </div> 106 113 <div id="<?php echo esc_html($prefix); ?>qr-btc-container<?php echo esc_html($sufix); ?>" style="display: none;" class="qr-lightning-container"> … … 113 120 </div> 114 121 </details> 115 <a id="<?php echo esc_html($prefix);?>pay-in-wallet<?php echo esc_html($sufix);?>" class="qr-pay-in-wallet"><?php e cho esc_html__('Pay in wallet','coinsnap-bitcoin-voting'); ?></a>122 <a id="<?php echo esc_html($prefix);?>pay-in-wallet<?php echo esc_html($sufix);?>" class="qr-pay-in-wallet"><?php esc_html_e('Pay in wallet','coinsnap-bitcoin-voting'); ?></a> 116 123 </div> 117 124 <div id="<?php echo esc_html($prefix); ?>thank-you-popup<?php echo esc_html($sufix); ?>" class="thank-you-popup">
Note: See TracChangeset
for help on using the changeset viewer.