Changeset 2632302
- Timestamp:
- 11/18/2021 08:16:39 PM (4 years ago)
- Location:
- crypto-voucher-widget
- Files:
-
- 9 added
- 4 edited
-
tags/1.0.1 (added)
-
tags/1.0.1/assets (added)
-
tags/1.0.1/assets/screenshot.png (added)
-
tags/1.0.1/cv_widget_image.php (added)
-
tags/1.0.1/cv_widget_text_button.php (added)
-
tags/1.0.1/images (added)
-
tags/1.0.1/images/buy_cv.svg (added)
-
tags/1.0.1/readme.txt (added)
-
tags/1.0.1/wp-plugin.php (added)
-
trunk/cv_widget_image.php (modified) (4 diffs)
-
trunk/cv_widget_text_button.php (modified) (4 diffs)
-
trunk/readme.txt (modified) (3 diffs)
-
trunk/wp-plugin.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
crypto-voucher-widget/trunk/cv_widget_image.php
r2632041 r2632302 23 23 public function widget( $args, $instance ) { 24 24 extract( $args ); 25 $title = apply_filters( 'widget_title', $instance['title'] ); 25 $label = apply_filters( 'widget_title', $instance['label'] ); 26 $options = get_option('cv_widget_plugin_options'); 26 27 27 28 echo $before_widget; … … 31 32 <?php 32 33 if ( isset( $instance[ 'label' ] ) ) { 33 echo '<h434 style= "margin-bottom: 10px;"35 > ' . $instance['label'] . '</h4>';34 echo "<h4 35 style='margin-bottom: 10px;' 36 >" . esc_attr($instance['label'])."</h4>"; 36 37 } 37 38 ?> 38 <img 39 src="<?php echo esc_attr(plugin_dir_url( __FILE__ )."images/buy_cv.svg"); ?>" 40 alt="Buy Cryptocurrency Directly" 41 onclick="startTransaction({ 42 referenceId: '<?php echo esc_attr($instance['referenceId']); ?>', 43 primaryColor: '<?php echo esc_attr($instance['primaryColor']); ?>', 44 logo: '<?php echo esc_attr($instance['logo']); ?>' 45 })" 46 class="cv-widget-image-button" 47 style="cursor: pointer;" 48 /> 39 <?php 40 echo "<img 41 src='".esc_attr(plugin_dir_url( __FILE__ )."images/buy_cv.svg")."' 42 alt='Buy Cryptocurrency Directly' 43 onclick=\"startTransaction({ 44 referenceId: '".esc_attr($options['widget_token'])."', 45 primaryColor: '".esc_attr($options['base_color'])."', 46 logo: '".esc_attr($options['logo_url'])."' 47 })\" 48 class='cv-widget-image-button' 49 style='cursor: pointer;' 50 />"; 51 ?> 49 52 </div> 50 53 … … 61 64 */ 62 65 public function form( $instance ) { 63 $label = ! empty( $instance['label'] ) ? $instance['label'] : __( 'Buy Cryptocurrency Directly', 'text_domain' ); 64 $referenceId = ! empty( $instance['referenceId'] ) ? $instance['referenceId'] : ''; 66 if ( isset( $instance[ 'label' ] ) ) { 67 $label = $instance[ 'label' ]; 68 } 69 else { 70 $label = __( 'Buy Cryptocurrency Directly', 'text_domain' ); 71 } 72 ?> 73 <p> 74 <h3>Crypto Voucher Widget (Text Button)</h3> 65 75 66 67 register_setting( 'first_tab_options', 'first_tab_items' ); 68 ?> 69 <div 70 style="display: grid; grid-template-columns: 100%; grid-auto-rows: min-content; row-gap: 10px;" 71 > 72 <h3>Crypto Voucher Widget (Image Button)</h3> 73 74 <div 75 style="display: grid; grid-template-columns: 100%; grid-template-rows: min-content min-content; row-gap: 5px;" 76 > 77 <label for="<?php echo esc_attr($this->get_field_name( 'label' )); ?>"><?php _e( 'Enter title:' ); ?></label> 78 <input class="widefat" id="<?php echo$this->get_field_id( 'label' ); ?>" name="<?php echo esc_attr($this->get_field_name( 'label' )); ?>" type="text" value="<?php echo esc_attr( $label ); ?>" /> 79 </div> 80 81 <div 82 style="display: grid; grid-template-columns: 100%; grid-template-rows: min-content min-content; row-gap: 5px;" 83 > 84 <label for="<?php echo esc_attr($this->get_field_name( 'referenceId' )); ?>"><?php _e( 'Enter your reference identificator (required):' ); ?></label> 85 <input class="widefat" placeholder="widget token" id="<?php echo $this->get_field_id( 'referenceId' ); ?>" name="<?php echo esc_attr($this->get_field_name( 'referenceId' )); ?>" type="text" value="<?php echo esc_attr( $referenceId ); ?>" /> 86 </div> 87 88 <div 89 style="display: grid; grid-template-columns: 100%; grid-template-rows: min-content min-content; row-gap: 5px;" 90 > 91 <label for="<?php echo esc_attr($this->get_field_name( 'primaryColor' )); ?>"><?php _e( 'Enter primary color of widget (optional):' ); ?></label> 92 <input class="widefat" id="<?php echo $this->get_field_id( 'primaryColor' ); ?>" name="<?php echo esc_attr($this->get_field_name( 'primaryColor' )); ?>" type="text" value="<?php echo esc_attr( $primaryColor ); ?>" /> 93 </div> 94 95 <div 96 style="display: grid; grid-template-columns: 100%; grid-template-rows: min-content min-content; row-gap: 5px;" 97 > 98 <label for="<?php echo esc_attr($this->get_field_name( 'logo' )); ?>"><?php _e( 'Enter URL to your logo (optional):' ); ?></label> 99 <input class="widefat" id="<?php echo $this->get_field_id( 'logo' ); ?>" name="<?php echo esc_attr($this->get_field_name( 'logo' )); ?>" type="text" value="<?php echo esc_attr( $logo ); ?>" /> 100 </div> 101 </div> 76 <label for="<?php echo esc_attr($this->get_field_name( 'label' )); ?>"><?php _e( 'Enter title:' ); ?></label> 77 <input class="widefat" id="<?php echo esc_attr($this->get_field_id( 'label' )); ?>" name="<?php echo esc_attr($this->get_field_name( 'label' )); ?>" type="text" value="<?php echo esc_attr( $label ); ?>" /> 78 </p> 102 79 <?php 103 80 } … … 114 91 */ 115 92 public function update( $new_instance, $old_instance ) { 116 $instance = $old_instance; 117 $instance['title'] = ( !empty( $$new_instance['title'] ) ) ? strip_tags( $new_instance['title'] ) : 'Buy Cryptocurrency Directly'; 118 $instance['referenceId'] = strip_tags( $new_instance['referenceId'] ); 119 $instance['primaryColor'] = strip_tags( $new_instance['primaryColor'] ); 120 $instance['logo'] = strip_tags( $new_instance['logo'] ); 93 $instance = array(); 94 $instance['label'] = ( !empty( $new_instance['label'] ) ) ? strip_tags( $new_instance['label'] ) : 'Buy Cryptocurrency Directly'; 121 95 122 96 return $instance; -
crypto-voucher-widget/trunk/cv_widget_text_button.php
r2631280 r2632302 28 28 extract( $args ); 29 29 $title = $instance['title']; 30 $referenceId = apply_filters( 'trim_and_lowercase', $instance['referenceId'] or 'null');30 $referenceId = apply_filters( 'trim_and_lowercase', $instance['referenceId'] or null ); 31 31 32 32 echo $before_widget; … … 45 45 referenceId: '<?php echo esc_attr($instance['referenceId']); ?>', 46 46 primaryColor: '<?php echo esc_attr($instance['primaryColor']); ?>', 47 logo: '<?php echo esc_attr($instance['logo']); ?>'47 <?php echo (is_null($instance['logo'])) ? "logo: '".esc_attr($instance['logo'])."'" : ''; ?> 48 48 })" 49 49 class="cv-widget-text-button"><?php echo $instance['title']; ?> … … 63 63 */ 64 64 public function form( $instance ) { 65 if ( isset( $instance[ 'label' ] ) ) { 66 $label = $instance[ 'label' ]; 67 } 68 else { 69 $label = __( 'Buy Cryptocurrency Directly', 'text_domain' ); 70 } 65 if ( isset( $instance[ 'label' ] ) ) { 66 $label = $instance[ 'label' ]; 67 } 68 else { 69 $label = __( 'Buy Cryptocurrency Directly', 'text_domain' ); 70 } 71 if ( isset( $instance[ 'title' ] ) ) { 72 $title = $instance[ 'title' ]; 73 } 74 else { 75 $title = __( 'Buy Now', 'text_domain' ); 76 } 77 ?> 78 <p> 79 <h3>Crypto Voucher Widget (Text Button)</h3> 71 80 72 if ( isset( $instance[ 'title' ] ) ) { 73 $title = $instance[ 'title' ]; 74 } 75 else { 76 $title = __( 'Buy Now', 'text_domain' ); 77 } 81 <label for="<?php echo esc_attr($this->get_field_name( 'label' )); ?>"><?php _e( 'Enter title:' ); ?></label> 82 <input class="widefat" id="<?php echo esc_attr($this->get_field_id( 'label' )); ?>" name="<?php echo $this->get_field_name( 'label' ); ?>" type="text" value="<?php echo esc_attr( $label ); ?>" /> 78 83 79 if ( isset( $istance[ 'referenceId' ] ) ) { 80 $referenceId = $instance[ 'referenceId' ]; 81 } else { 82 $referenceId = null; 83 } 84 ?> 85 <div 86 style="display: grid; grid-template-columns: 100%; grid-auto-rows: min-content; row-gap: 10px;" 87 > 88 <h3>Crypto Voucher Widget (Text Button)</h3> 84 <label for="<?php echo esc_attr($this->get_field_name( 'title' )); ?>"><?php _e( 'Text to display inside button:' ); ?></label> 85 <input class="widefat" id="<?php echo esc_attr($this->get_field_id( 'title' )); ?>" name="<?php echo esc_attr($this->get_field_name( 'title' )); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" /> 89 86 90 <div 91 style="display: grid; grid-template-columns: 100%; grid-template-rows: min-content min-content; row-gap: 5px;" 92 > 93 <label for="<?php echo esc_attr($this->get_field_name( 'label' )); ?>"><?php _e( 'Enter title:' ); ?></label> 94 <input class="widefat" id="<?php echo esc_attr($this->get_field_id( 'label' )); ?>" name="<?php echo esc_attr($this->get_field_name( 'label' )); ?>" type="text" value="<?php echo esc_attr( $label ); ?>" /> 95 </div> 87 <label for="<?php echo esc_attr($this->get_field_name( 'referenceId' )); ?>"><?php _e( 'Enter your reference identificator (required):' ); ?></label> 88 <input class="widefat" id="<?php echo esc_attr($this->get_field_id( 'referenceId' )); ?>" name="<?php echo esc_attr($this->get_field_name( 'referenceId' )); ?>" type="text" value="<?php echo esc_attr( $referenceId ); ?>" /> 96 89 97 <div 98 style="display: grid; grid-template-columns: 100%; grid-template-rows: min-content min-content; row-gap: 5px;" 99 > 100 <label for="<?php echo esc_attr($this->get_field_name( 'referenceId' )); ?>"><?php _e( 'Enter your reference identificator (required):' ); ?></label> 101 <input class="widefat" placeholder="widget token" id="<?php echo esc_attr($this->get_field_id( 'referenceId' )); ?>" name="<?php echo esc_attr($this->get_field_name( 'referenceId' )); ?>" type="text" value="<?php echo esc_attr( $referenceId ); ?>" /> 102 </div> 90 <label for="<?php echo esc_attr($this->get_field_name( 'primaryColor' )); ?>"><?php _e( 'Enter primary color of widget (optional):' ); ?></label> 91 <input class="widefat" id="<?php echo esc_attr($this->get_field_id( 'primaryColor' )); ?>" name="<?php echo esc_attr($this->get_field_name( 'primaryColor' )); ?>" type="text" value="<?php echo esc_attr( $primaryColor ); ?>" /> 103 92 104 <div 105 style="display: grid; grid-template-columns: 100%; grid-template-rows: min-content min-content; row-gap: 5px;" 106 > 107 <label for="<?php echo esc_attr($this->get_field_name( 'primaryColor' )); ?>"><?php _e( 'Enter primary color of widget (optional):' ); ?></label> 108 <input class="widefat" id="<?php echo esc_attr($this->get_field_id( 'primaryColor' )); ?>" name="<?php echo esc_attr($this->get_field_name( 'primaryColor' )); ?>" type="text" value="<?php echo esc_attr( $primaryColor ); ?>" /> 109 </div> 110 111 <div 112 style="display: grid; grid-template-columns: 100%; grid-template-rows: min-content min-content; row-gap: 5px;" 113 > 114 <label for="<?php echo esc_attr($this->get_field_name( 'logo' )); ?>"><?php _e( 'Enter URL to your logo (optional):' ); ?></label> 115 <input class="widefat" id="<?php echo esc_attr($this->get_field_id( 'logo' )); ?>" name="<?php echo esc_attr($this->get_field_name( 'logo' )); ?>" type="text" value="<?php echo esc_attr( $logo ); ?>" /> 116 </div> 117 </div> 93 <label for="<?php echo esc_attr($this->get_field_name( 'logo' )); ?>"><?php _e( 'Enter URL to your logo (optional):' ); ?></label> 94 <input class="widefat" id="<?php echo esc_attr($this->get_field_id( 'logo' )); ?>" name="<?php echo esc_attr($this->get_field_name( 'logo' )); ?>" type="text" value="<?php echo esc_attr( $logo ); ?>" /> 95 </p> 118 96 <?php 119 97 } … … 133 111 $instance['title'] = ( !empty( $new_instance['title'] ) ) ? strip_tags( $new_instance['title'] ) : 'Buy Cryptocurrency Directly'; 134 112 $instance['label'] = ( !empty( $new_instance['label'] ) ) ? strip_tags( $new_instance['label'] ) : ''; 135 $instance['referenceId'] = ( !empty( $new_instance['referenceId'] ) ) ? strip_tags( $new_instance['referenceId'] ) : 'null';136 $instance['primaryColor'] = ( !empty( $new_instance['primaryColor'] ) ) ? strip_tags( $new_instance['primaryColor'] ) : 'null';137 $instance['logo'] = ( !empty( $new_instance['logo'] ) ) ? strip_tags( $new_instance['logo'] ) : 'null';113 $instance['referenceId'] = ( !empty( $new_instance['referenceId'] ) ) ? strip_tags( $new_instance['referenceId'] ) : NULL; 114 $instance['primaryColor'] = ( !empty( $new_instance['primaryColor'] ) ) ? strip_tags( $new_instance['primaryColor'] ) : NULL; 115 $instance['logo'] = ( !empty( $new_instance['logo'] ) ) ? strip_tags( $new_instance['logo'] ) : NULL; 138 116 139 117 return $instance; -
crypto-voucher-widget/trunk/readme.txt
r2629823 r2632302 4 4 Tags: crypto, cryptocurrency, widget, cryptovoucher, voucher, btc, bitcoin, eth, ethereum, ltc, litecoin, bnb, binance coin, binance, coin, usdc, usd coin, usd, matic, polygon matic, polygon, doge, doge coin, card payment, card payments, cards 5 5 Requires at least: 4.4 6 Tested up to: 5. 8.26 Tested up to: 5.7.2 7 7 Requires PHP: 7.0.1 8 8 Stable tag: 1.0.1 … … 41 41 42 42 == Changelog == 43 = 1.0.2 = 44 * Text Button temporailly removed 45 * Settings moved to one place! 43 46 = 1.0.1 = 44 47 * ReadMe fix, tags change … … 48 51 49 52 == Upgrade Notice == 53 = 1.0.2 = 54 * Fixed saving widget token to database 50 55 = 1.0.1 = 51 56 * Nothing changed in widget's logics, no update requried -
crypto-voucher-widget/trunk/wp-plugin.php
r2624425 r2632302 4 4 Plugin URI: https://www.npmjs.com/package/@crypto-voucher/widget 5 5 Description: A simple hassle-free tool for selling cryptocurrency straight from your website. 6 Version: 1.0. 16 Version: 1.0.2 7 7 Author: Crypto Voucher Team 8 8 Author URI: https://cryptovoucher.io/ … … 10 10 11 11 require('cv_widget_image.php'); 12 require('cv_widget_text_button.php'); 12 // require('cv_widget_text_button.php'); 13 14 15 /* settings section */ 16 17 function dbi_add_settings_page() { 18 add_options_page( 'CV Widget Settings', 'CV Widget Settings', 'manage_options', 'dbi-example-plugin', 'dbi_render_plugin_settings_page' ); 19 } 20 add_action( 'admin_menu', 'dbi_add_settings_page' ); 21 22 function dbi_render_plugin_settings_page() { 23 ?> 24 <div 25 style="display: grid; grid-template-columns: 100%; grid-auto-rows: min-content; row-gap: 12px;" 26 > 27 <h2>Crypto Voucher Widget Settings</h2> 28 <form action="options.php" method="post"> 29 <?php 30 settings_fields( 'cv_widget_plugin_options' ); 31 do_settings_sections( 'cv_widget_plugin' ); ?> 32 <input name="submit" class="button button-primary" type="submit" value="<?php esc_attr_e( 'Save' ); ?>" /> 33 </form> 34 </div> 35 <?php 36 } 37 38 function cv_widget_plugin_register_settings() { 39 register_setting( 'cv_widget_plugin_options', 'cv_widget_plugin_options', 'cv_widget_plugin_options_validate' ); 40 add_settings_section( 'api_settings', 'API Settings', 'cv_widget_plugin_section_text', 'cv_widget_plugin' ); 41 42 add_settings_field( 'cv_widget_plugin_options_widget_token', 'Widget TOKEN *required', 'cv_widget_plugin_options_widget_token', 'cv_widget_plugin', 'api_settings' ); 43 add_settings_field( 'cv_widget_plugin_options_base_color', 'Base color', 'cv_widget_plugin_options_base_color', 'cv_widget_plugin', 'api_settings' ); 44 add_settings_field( 'cv_widget_plugin_options_logo_url', 'Logo URL', 'cv_widget_plugin_options_logo_url', 'cv_widget_plugin', 'api_settings' ); 45 } 46 add_action( 'admin_init', 'cv_widget_plugin_register_settings' ); 47 48 function cv_widget_plugin_options_validate( $input ) { 49 $newinput['widget_token'] = trim( $input['widget_token'] ); 50 if ( ! preg_match( '/^[a-z0-9]{24}$/i', $newinput['widget_token'] ) ) { 51 $newinput['widget_token'] = ''; 52 } 53 if ( ! preg_match('/^#(?:[0-9a-fA-F]{3,4}){1,2}$/i', $newinput['base_color'] ) ) { 54 $newinput['base_color'] = ''; 55 } 56 57 return $newinput; 58 } 59 60 function cv_widget_plugin_section_text() { 61 echo '<p>Here you can set basic widget plugin options</p>'; 62 } 63 64 function cv_widget_plugin_options_widget_token() { 65 $options = get_option( 'cv_widget_plugin_options' ); 66 echo "<input id='cv_widget_plugin_options_widget_token' placeholder='widget token here...' name='cv_widget_plugin_options[widget_token]' type='text' value='" . esc_attr( $options['widget_token'] ) . "' />"; 67 } 68 69 function cv_widget_plugin_options_base_color() { 70 $options = get_option( 'cv_widget_plugin_options' ); 71 echo "<input id='cv_widget_plugin_options_base_color' placeholder='eg. #425DG332' name='cv_widget_plugin_options[base_color]' type='text' value='" . esc_attr( $options['base_color'] ) . "' />"; 72 } 73 74 function cv_widget_plugin_options_logo_url() { 75 $options = get_option( 'cv_widget_plugin_options' ); 76 echo "<input id='cv_widget_plugin_options_logo_url' name='cv_widget_plugin_options[logo_url]' type='text' value='" . esc_attr( $options['logo_url'] ) . "' />"; 77 } 78 79 /* end of settings */ 13 80 14 81 function cvvchwgt_register_widgets() { 15 82 register_widget( 'CV_Widget_Image' ); 16 register_widget( 'CV_Widget_Text_Button' );83 // register_widget( 'CV_Widget_Text_Button' ); 17 84 } 18 85 add_action('widgets_init', 'cvvchwgt_register_widgets'); … … 22 89 ?> 23 90 <script type="module"> 24 import { defineCustomElements } from 'https://cdn.jsdelivr.net/npm/@crypto-voucher/widget@ latest/loader/index.es2017.js';91 import { defineCustomElements } from 'https://cdn.jsdelivr.net/npm/@crypto-voucher/widget@0.3.5/loader/index.es2017.js'; 25 92 26 93 defineCustomElements();
Note: See TracChangeset
for help on using the changeset viewer.