Plugin Directory

Changeset 2632302


Ignore:
Timestamp:
11/18/2021 08:16:39 PM (4 years ago)
Author:
alexx123939
Message:

update widget to verision 1.0.2

Location:
crypto-voucher-widget
Files:
9 added
4 edited

Legend:

Unmodified
Added
Removed
  • crypto-voucher-widget/trunk/cv_widget_image.php

    r2632041 r2632302  
    2323  public function widget( $args, $instance ) {
    2424      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');
    2627
    2728      echo $before_widget;
     
    3132          <?php
    3233            if ( isset( $instance[ 'label' ] ) ) {
    33               echo '<h4
    34                       style="margin-bottom: 10px;"
    35                     >' . $instance['label'] . '</h4>';
     34              echo "<h4
     35                      style='margin-bottom: 10px;'
     36                    >" . esc_attr($instance['label'])."</h4>";
    3637            }
    3738          ?>
    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          ?>
    4952      </div>
    5053
     
    6164   */
    6265  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>
    6575
    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>
    10279  <?php
    10380  }
     
    11491   */
    11592  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';
    12195
    12296      return $instance;
  • crypto-voucher-widget/trunk/cv_widget_text_button.php

    r2631280 r2632302  
    2828      extract( $args );
    2929      $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 );
    3131
    3232      echo $before_widget;
     
    4545                referenceId: '<?php echo esc_attr($instance['referenceId']); ?>',
    4646                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'])."'" : ''; ?>
    4848            })"
    4949            class="cv-widget-text-button"><?php echo $instance['title']; ?>
     
    6363   */
    6464  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>
    7180
    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 ); ?>" />
    7883
    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 ); ?>" />
    8986
    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 ); ?>" />
    9689
    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 ); ?>" />
    10392
    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>
    11896  <?php
    11997  }
     
    133111      $instance['title'] = ( !empty( $new_instance['title'] ) ) ? strip_tags( $new_instance['title'] ) : 'Buy Cryptocurrency Directly';
    134112      $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;
    138116
    139117      return $instance;
  • crypto-voucher-widget/trunk/readme.txt

    r2629823 r2632302  
    44Tags: 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
    55Requires at least: 4.4
    6 Tested up to: 5.8.2
     6Tested up to: 5.7.2
    77Requires PHP: 7.0.1
    88Stable tag: 1.0.1
     
    4141
    4242== Changelog ==
     43= 1.0.2 =
     44* Text Button temporailly removed
     45* Settings moved to one place!
    4346= 1.0.1 =
    4447* ReadMe fix, tags change
     
    4851
    4952== Upgrade Notice ==
     53= 1.0.2 =
     54* Fixed saving widget token to database
    5055= 1.0.1 =
    5156* Nothing changed in widget's logics, no update requried
  • crypto-voucher-widget/trunk/wp-plugin.php

    r2624425 r2632302  
    44Plugin URI:   https://www.npmjs.com/package/@crypto-voucher/widget
    55Description:  A simple hassle-free tool for selling cryptocurrency straight from your website.
    6 Version:      1.0.1
     6Version:      1.0.2
    77Author:       Crypto Voucher Team
    88Author URI:   https://cryptovoucher.io/
     
    1010
    1111require('cv_widget_image.php');
    12 require('cv_widget_text_button.php');
     12// require('cv_widget_text_button.php');
     13
     14
     15/* settings section */
     16
     17function 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}
     20add_action( 'admin_menu', 'dbi_add_settings_page' );
     21
     22function 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
     38function 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}
     46add_action( 'admin_init', 'cv_widget_plugin_register_settings' );
     47
     48function 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
     60function cv_widget_plugin_section_text() {
     61    echo '<p>Here you can set basic widget plugin options</p>';
     62}
     63
     64function 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
     69function 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
     74function 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 */
    1380
    1481function cvvchwgt_register_widgets() {
    1582    register_widget( 'CV_Widget_Image' );
    16     register_widget( 'CV_Widget_Text_Button' );
     83    // register_widget( 'CV_Widget_Text_Button' );
    1784}
    1885add_action('widgets_init', 'cvvchwgt_register_widgets');
     
    2289    ?>
    2390        <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';
    2592
    2693          defineCustomElements();
Note: See TracChangeset for help on using the changeset viewer.