Plugin Directory

Changeset 1574681


Ignore:
Timestamp:
01/14/2017 03:38:17 PM (9 years ago)
Author:
scor2k
Message:

0.4.0

Location:
nxtbridge
Files:
7 edited
17 copied

Legend:

Unmodified
Added
Removed
  • nxtbridge/tags/0.4.0/config.php

    r1572680 r1574681  
    1717add_action('wp_enqueue_scripts', 'nxter_scripts');
    1818add_action('wp_footer', 'nxter_footer');
    19 //add_action('wp', 'nxter_catch_404');
    2019
    2120register_activation_hook( __FILE__, 'nxter_activation');
     
    2423
    2524function nxter_scripts() {
    26   wp_register_script('mdl', plugins_url('/bower_components/material-design-lite/material.min.js', __FILE__), '', false, true); // in footer
    27   wp_register_script('highstock', plugins_url('/bower_components/highcharts/highstock.js', __FILE__), '', false, true); // in footer
    28   wp_register_script('momentjs', plugins_url('/bower_components/moment/min/moment.min.js', __FILE__), '', false, true); // in footer
    29   //wp_register_script('nxtbridge', plugins_url('nxtbridge.js', __FILE__), '', false, true); // in footer
     25  wp_register_script('mdl', plugins_url('/bower_components/material-design-lite/material.min.js', __FILE__), array('jquery'), false, true); // in footer
     26  wp_register_script('bootstrap', plugins_url('/bower_components/bootstrap/dist/js/bootstrap.min.js', __FILE__), array('jquery'), false, true); // in footer
     27  wp_register_script('highstock', plugins_url('/bower_components/highcharts/highstock.js', __FILE__), array('jquery'), false, true); // in footer
     28  wp_register_script('momentjs', plugins_url('/bower_components/moment/min/moment.min.js', __FILE__), array('jquery'), false, true); // in footer
     29  wp_register_script('nxtbridge', plugins_url('nxtbridge.js', __FILE__), array('jquery'), false, true); // in footer
    3030
    3131  wp_enqueue_script('mdl');
    3232  wp_enqueue_script('highstock');
    3333  wp_enqueue_script('momentjs');
    34   //wp_enqueue_script('nxtbridge');
     34  wp_enqueue_script('nxtbridge');
    3535}
    3636
     
    3838function nxter_styles() {
    3939  wp_register_style('mdl', plugins_url('/bower_components/material-design-lite/material.min.css', __FILE__), '', false, 'all');
     40  wp_register_style('bootstrap', plugins_url('/bower_components/bootstrap/dist/css/bootstrap.min.css', __FILE__), '', false, 'all');
    4041  wp_register_style('nxtbridge', plugins_url('style.css', __FILE__), '', false, 'all');
    4142
     
    4950  $prefix = isset( $opt['NXTBridge_top50_prefix'] ) ? esc_attr( $opt['NXTBridge_top50_prefix']) : '/';
    5051   
     52  //TODO: Remove prefix
    5153  printf('<input type="hidden" id="nxter-asset-prefix" value="%s" />', $prefix);
    5254  printf('<input type="hidden" id="nxter-api" value="%s" />', $api);
     
    6264  <?php
    6365  endif;
    64 }
    65 
    66 
    67 function nxter_catch_404() {
    68   if ( is_404() ) {
    69     $opt = get_option('NXTBridge');
    70     $prefix = isset( $opt['NXTBridge_top50_prefix'] ) ? esc_attr( $opt['NXTBridge_top50_prefix']) : '/';
    71     $default = isset( $opt['NXTBridge_top50_default'] ) ? esc_attr( $opt['NXTBridge_top50_default']) : '/';
    72     $url = $_SERVER["REQUEST_URI"];
    73 
    74     if ( preg_match( $prefix , $url ) == 1 ) {
    75       // redirect to default page
    76       header('HTTP/1.1 302 Moved Temporarily');
    77       header('Location: '.$default);
    78     }
    79   }
    8066}
    8167
  • nxtbridge/tags/0.4.0/nxtbridge.php

    r1573114 r1574681  
    33/*
    44  Plugin Name: NXTBridge
    5   Plugin URI: http://nxter.org/nxtbridge
    6   Version: 0.3.6
     5  Plugin URI: https://nxter.org/nxtbridge
     6  Version: 0.4.0
    77  Author: scor2k
    88  Description: Show Nxt asset information on your Wordpress sites.
     
    1111*/
    1212global $api;
    13 $version = '0.3.6'; // NOT FORGET TO CHANGE !!!
     13$version = '0.4.0'; // NOT FORGET TO CHANGE !!!
    1414
    1515$api = '//api.nxter.org/v1';
    16 //$api = '//nxtbridge-srv.corp.comindware.com:8080/v1';
    1716//$api = '//localhost:8080/v1';
    1817
     
    2019require ('lib/assets-info.php');        // NXTBridgeAssetInfo and NXTBridgeAssetPrices and NXTBridgeTop50
    2120require ('lib/assets-graphics.php');    // NXTBridgeAssetStock and NXTBridgeAssetCandlestick
    22 require ('lib/assets-auto.php');        // NXTBridgeAuto
     21require ('lib/tip.php');                // NXTBridgeTip button
     22//require ('lib/assets-auto.php');      // NXTBridgeAuto. Disabled in 0.4 version.
    2323/*****************************************************************************************************/
    2424require ('config.php');                 // actions and registered scripts and hooks
    2525/*****************************************************************************************************/
    26 require('lib/options.php');           // NXTBridge Admin settings
    27 require('wallet/main.php');              // NXTBridge wallet
     26require('lib/options.php');             // NXTBridge Admin settings
     27require('wallet/main.php');             // NXTBridge wallet
    2828/*****************************************************************************************************/
    29 require('lib/fakepage.php');           // NXTBridge Fake Page
     29require('lib/fakepage.php');            // NXTBridge Fake Page
    3030/*****************************************************************************************************/
    3131
     
    3737add_filter('the_content', 'nxtbridge_stockchart');
    3838add_filter('the_content', 'nxtbridge_candlestick');
    39 add_filter('the_content', 'nxtbridge_auto');
     39add_filter('the_content', 'nxtbridge_tip');
     40//add_filter('the_content', 'nxtbridge_auto'); // Disabled in 0.4 version.
    4041/*****************************************************************************************************/
    4142
  • nxtbridge/tags/0.4.0/readme.txt

    r1573114 r1574681  
    7272== Changelog ==
    7373
     74= 0.4.0 =
     75* Disabled shortcut NXTBridgeAuto. Not needed with fake pages.
     76* Create new shortcut [NXTBridgeTip account=NXT-FRNZ-PDJF-2CQT-DQ4WQ]. It'll show button with input box on the page.
     77
    7478= 0.3.6 =
    7579* Bugfix for compatibility with WPML plugin
  • nxtbridge/tags/0.4.0/style.css

    r1558887 r1574681  
    6262      filter: alpha(opacity=100); }
    6363
     64/**************TIP******************/
     65.NXTBridge-tip-field {
     66  width: 100px !important;
     67  margin-right: 0.2rem !important; }
     68
     69.NXTBridge-tip-button {
     70  width: 100px; }
     71
    6472/*# sourceMappingURL=style.css.map */
  • nxtbridge/tags/0.4.0/style.scss

    r1558887 r1574681  
    102102}
    103103
     104
     105/**************TIP******************/
     106.NXTBridge-tip-field {
     107  width: 100px !important;
     108  margin-right: 0.2rem !important;
     109}
     110
     111.NXTBridge-tip-button {
     112  width: 100px;
     113}
  • nxtbridge/tags/0.4.0/wallet/main.php

    r1558887 r1574681  
    174174          break;
    175175
     176        case 'NXTBridge_send':
     177          //var_dump($_POST);
     178
     179          $proto = 'http:'; if ( is_ssl() ) { $proto = 'https:'; }
     180          if ( isset($_POST['recipient']) && isset($_POST['amount']) ) {
     181
     182            $tmp = file_get_contents( $proto . $this->api . '/peer' );
     183            $nxt_node = json_decode($tmp, true);
     184
     185            $user_message = '';
     186
     187            if ( $nxt_node ==  false ) {
     188              $this->log('Some error while decode API answer');
     189              $user_message = 'Error was happen while trying to decode answer from nxter API server';
     190            } else {
     191              $random_node  = $nxt_node['data'];
     192              $url = 'http://' . $random_node . ':7876' . '/nxt?requestType=getAccountPublicKey&account=' . $this->options['account'];
     193
     194              $pub = file_get_contents( $url );
     195              $pub_key = json_decode($pub, true);
     196
     197              if ( isset($pub_key['publicKey']) ) {
     198                $url = 'http://' . $random_node . ':7876/nxt';
     199                $data = array('requestType' => 'sendMoney', 'recipient' => $_POST['recipient'], 'amountNQT' => $_POST['amount'] * 100000000, 'publicKey' => $pub_key['publicKey'], 'feeNQT' => 100000000, 'deadline' => 720, 'broadcast' => 'false', 'message' => 'Sent using NXTBridge' );
     200
     201                $rr = $this->sendPOST( $url, $data );
     202
     203                //var_dump($rr);
     204                $rr_descr = json_decode($rr, true);
     205
     206                if ( $rr_descr ) {
     207                  $rr_code = $rr_descr['errorCode'];
     208                  switch ($rr_code) {
     209                    case '4':
     210                      $user_message = $rr_descr['errorDescription'];
     211                      break;
     212
     213                    default:
     214                      $user_message = print_r($rr, true);
     215                  }
     216
     217                  if ( $rr_descr['unsignedTransactionBytes'] ) {
     218                    $user_message = $rr_descr['unsignedTransactionBytes'];
     219                  }
     220                }
     221
     222              } // end isset
     223            } // end esle
     224           
     225            $this->response = $user_message;
     226            //var_dump($this->response);
     227          }
     228          break;
    176229
    177230        default:
     
    183236      $this->page[1] = $this->agree ? '-active' : '';
    184237      $this->page[2] = '';
     238      $this->page[3] = '';
     239      $this->page[4] = '';
    185240     
    186241      if ( $this->agree ) {
     
    188243        $this->url[2] = '/wp-admin/admin.php?page=nxtbridge_wallet&sub=broadcast';
    189244        $this->url[3] = '/wp-admin/admin.php?page=nxtbridge_wallet&sub=ledger';
     245        $this->url[4] = '/wp-admin/admin.php?page=nxtbridge_wallet&sub=send';
    190246
    191247        //************************************************************************************************** PAGE SWITCH THERE
     
    193249
    194250          $sub = $_GET['sub'];
    195           $this->page[1] = '';
    196           $this->page[2] = '';
     251          $this->page[1] = ''; $this->page[2] = ''; $this->page[3] = ''; $this->page[4] = '';
    197252
    198253          switch ( $sub ) {
     
    209264              break;
    210265
     266            case 'send':
     267              $this->page[4] = '-active';
     268              break;
     269
    211270            default:
    212271              $this->page[1] = '-active';
     
    229288          <a href='<?php echo $this->url[2]; ?>' class='nav-tab nav-tab<?php echo $this->page[2]; ?>'>Broadcast</a>
    230289          <a href='<?php echo $this->url[3]; ?>' class='nav-tab nav-tab<?php echo $this->page[3]; ?>'>Ledger</a>
     290          <a href='<?php echo $this->url[4]; ?>' class='nav-tab nav-tab<?php echo $this->page[4]; ?>'>Send Nxt</a>
    231291        </h2>
    232292
     
    258318
    259319
    260         <?php if ( strlen($this->page[3]) > 0 ) : //******************************************************************************** WALLET ?>
     320        <?php if ( strlen($this->page[3]) > 0 ) : //******************************************************************************** LEDGER ?>
    261321          <?php if ( $this->options['account'] ) : ?>
    262322
     
    267327
    268328        <?php endif; // page[3] ?>
     329
     330        <?php if ( strlen($this->page[4]) > 0 ) : //******************************************************************************** SEND NXT ?>
     331          <?php if ( $this->options['account'] ) : ?>
     332
     333            <form method='POST' action=''>
     334              <?php settings_fields('NXTBridge_send'); ?>
     335              <?php do_settings_sections('nxtbridge_send_account');?>
     336              <?php submit_button('Generate unsigned TX bytes'); ?>
     337            </form>
     338
     339          <?php else: ?>
     340            <p>Please, enter your prefered Nxt account in Reed-Solomon style on the 'Account' page.</p>
     341          <?php endif; ?>
     342
     343        <?php endif; // page[3] ?>
     344
     345
    269346
    270347      </div>
     
    504581      );
    505582
     583      //****************************************************************************************************************************** SEND NXT SECTION
     584      register_setting(
     585        'NXTBridge_send',                       // option group
     586        'NXTBridge_'.$this->id,                 // option name
     587        array( $this, 'sanitize' )
     588      );
     589
     590      add_settings_section(
     591        'NXTBridge_send_section',            // Section name
     592        'NXTBridge Send NXT section',            // Section Title
     593        array( $this, 'print_send_info'),    // Section callback
     594        'nxtbridge_send_account'                      // Page where Section will be display
     595      );
     596
     597      add_settings_field(
     598        'NXTBridge_recipient_account',                  // Setting ID
     599        'Recipient NXT account',                        // Setting title
     600        array( $this, 'recipient_account_callback' ),   // Setting callback
     601        'nxtbridge_send_account',                       // Page where setting will be display
     602        'NXTBridge_send_section'                        // Section name
     603      );
     604
     605      add_settings_field(
     606        'NXTBridge_amount_account',                  // Setting ID
     607        'Recipient NXT amount',                        // Setting title
     608        array( $this, 'amount_account_callback' ),   // Setting callback
     609        'nxtbridge_send_account',                       // Page where setting will be display
     610        'NXTBridge_send_section'                        // Section name
     611      );
     612
     613      add_settings_field(
     614        'NXTBridge_tx_account',                  // Setting ID
     615        'Unsigned TX bytes',                        // Setting title
     616        array( $this, 'tx_account_callback' ),   // Setting callback
     617        'nxtbridge_send_account',                       // Page where setting will be display
     618        'NXTBridge_send_section'                        // Section name
     619      );
    506620    }
    507621
     
    576690    }
    577691
    578 
    579 
     692    /*****************************************************************************************************************/
     693    //
     694    //                                      SEND NXT
     695    //
     696    /*****************************************************************************************************************/
     697    public function print_send_info() {
     698      printf("<p>In this section you can generate unsigned TX bytes for send Nxt action. Then you should sign this bytes with <a href='https://bitbucket.org/scor2k/nxtbridge-offline/downloads/index.min.html' target=_blank>NXTBridge-offline</a> and <a href='/wp-admin/admin.php?page=nxtbridge_wallet&sub=broadcast'>broadcast</a> to the Nxt network.</p>");
     699    }
     700
     701    public function recipient_account_callback() {
     702      printf("<input name='recipient' type='text' size='30' value='%s' />", isset( $_COOKIE['NXTBridgeTip_addr'] ) ? sanitize_text_field( $_COOKIE['NXTBridgeTip_addr'] ): '' );
     703    }
     704
     705    public function amount_account_callback() {
     706      printf("<input name='amount' type='text' size='30' value='%s' />", isset( $_COOKIE['NXTBridgeTip_amount'] ) ? sanitize_text_field( $_COOKIE['NXTBridgeTip_amount'] ): '' );
     707    }
     708
     709    public function tx_account_callback() {
     710      printf("<textarea name='tx' rows='5' cols='30' class='large-text code' readonly>%s</textarea>", $this->response );
     711    }
    580712  } // end class
    581713
  • nxtbridge/trunk/config.php

    r1572680 r1574681  
    1717add_action('wp_enqueue_scripts', 'nxter_scripts');
    1818add_action('wp_footer', 'nxter_footer');
    19 //add_action('wp', 'nxter_catch_404');
    2019
    2120register_activation_hook( __FILE__, 'nxter_activation');
     
    2423
    2524function nxter_scripts() {
    26   wp_register_script('mdl', plugins_url('/bower_components/material-design-lite/material.min.js', __FILE__), '', false, true); // in footer
    27   wp_register_script('highstock', plugins_url('/bower_components/highcharts/highstock.js', __FILE__), '', false, true); // in footer
    28   wp_register_script('momentjs', plugins_url('/bower_components/moment/min/moment.min.js', __FILE__), '', false, true); // in footer
    29   //wp_register_script('nxtbridge', plugins_url('nxtbridge.js', __FILE__), '', false, true); // in footer
     25  wp_register_script('mdl', plugins_url('/bower_components/material-design-lite/material.min.js', __FILE__), array('jquery'), false, true); // in footer
     26  wp_register_script('bootstrap', plugins_url('/bower_components/bootstrap/dist/js/bootstrap.min.js', __FILE__), array('jquery'), false, true); // in footer
     27  wp_register_script('highstock', plugins_url('/bower_components/highcharts/highstock.js', __FILE__), array('jquery'), false, true); // in footer
     28  wp_register_script('momentjs', plugins_url('/bower_components/moment/min/moment.min.js', __FILE__), array('jquery'), false, true); // in footer
     29  wp_register_script('nxtbridge', plugins_url('nxtbridge.js', __FILE__), array('jquery'), false, true); // in footer
    3030
    3131  wp_enqueue_script('mdl');
    3232  wp_enqueue_script('highstock');
    3333  wp_enqueue_script('momentjs');
    34   //wp_enqueue_script('nxtbridge');
     34  wp_enqueue_script('nxtbridge');
    3535}
    3636
     
    3838function nxter_styles() {
    3939  wp_register_style('mdl', plugins_url('/bower_components/material-design-lite/material.min.css', __FILE__), '', false, 'all');
     40  wp_register_style('bootstrap', plugins_url('/bower_components/bootstrap/dist/css/bootstrap.min.css', __FILE__), '', false, 'all');
    4041  wp_register_style('nxtbridge', plugins_url('style.css', __FILE__), '', false, 'all');
    4142
     
    4950  $prefix = isset( $opt['NXTBridge_top50_prefix'] ) ? esc_attr( $opt['NXTBridge_top50_prefix']) : '/';
    5051   
     52  //TODO: Remove prefix
    5153  printf('<input type="hidden" id="nxter-asset-prefix" value="%s" />', $prefix);
    5254  printf('<input type="hidden" id="nxter-api" value="%s" />', $api);
     
    6264  <?php
    6365  endif;
    64 }
    65 
    66 
    67 function nxter_catch_404() {
    68   if ( is_404() ) {
    69     $opt = get_option('NXTBridge');
    70     $prefix = isset( $opt['NXTBridge_top50_prefix'] ) ? esc_attr( $opt['NXTBridge_top50_prefix']) : '/';
    71     $default = isset( $opt['NXTBridge_top50_default'] ) ? esc_attr( $opt['NXTBridge_top50_default']) : '/';
    72     $url = $_SERVER["REQUEST_URI"];
    73 
    74     if ( preg_match( $prefix , $url ) == 1 ) {
    75       // redirect to default page
    76       header('HTTP/1.1 302 Moved Temporarily');
    77       header('Location: '.$default);
    78     }
    79   }
    8066}
    8167
  • nxtbridge/trunk/nxtbridge.php

    r1573114 r1574681  
    33/*
    44  Plugin Name: NXTBridge
    5   Plugin URI: http://nxter.org/nxtbridge
    6   Version: 0.3.6
     5  Plugin URI: https://nxter.org/nxtbridge
     6  Version: 0.4.0
    77  Author: scor2k
    88  Description: Show Nxt asset information on your Wordpress sites.
     
    1111*/
    1212global $api;
    13 $version = '0.3.6'; // NOT FORGET TO CHANGE !!!
     13$version = '0.4.0'; // NOT FORGET TO CHANGE !!!
    1414
    1515$api = '//api.nxter.org/v1';
    16 //$api = '//nxtbridge-srv.corp.comindware.com:8080/v1';
    1716//$api = '//localhost:8080/v1';
    1817
     
    2019require ('lib/assets-info.php');        // NXTBridgeAssetInfo and NXTBridgeAssetPrices and NXTBridgeTop50
    2120require ('lib/assets-graphics.php');    // NXTBridgeAssetStock and NXTBridgeAssetCandlestick
    22 require ('lib/assets-auto.php');        // NXTBridgeAuto
     21require ('lib/tip.php');                // NXTBridgeTip button
     22//require ('lib/assets-auto.php');      // NXTBridgeAuto. Disabled in 0.4 version.
    2323/*****************************************************************************************************/
    2424require ('config.php');                 // actions and registered scripts and hooks
    2525/*****************************************************************************************************/
    26 require('lib/options.php');           // NXTBridge Admin settings
    27 require('wallet/main.php');              // NXTBridge wallet
     26require('lib/options.php');             // NXTBridge Admin settings
     27require('wallet/main.php');             // NXTBridge wallet
    2828/*****************************************************************************************************/
    29 require('lib/fakepage.php');           // NXTBridge Fake Page
     29require('lib/fakepage.php');            // NXTBridge Fake Page
    3030/*****************************************************************************************************/
    3131
     
    3737add_filter('the_content', 'nxtbridge_stockchart');
    3838add_filter('the_content', 'nxtbridge_candlestick');
    39 add_filter('the_content', 'nxtbridge_auto');
     39add_filter('the_content', 'nxtbridge_tip');
     40//add_filter('the_content', 'nxtbridge_auto'); // Disabled in 0.4 version.
    4041/*****************************************************************************************************/
    4142
  • nxtbridge/trunk/readme.txt

    r1573114 r1574681  
    7272== Changelog ==
    7373
     74= 0.4.0 =
     75* Disabled shortcut NXTBridgeAuto. Not needed with fake pages.
     76* Create new shortcut [NXTBridgeTip account=NXT-FRNZ-PDJF-2CQT-DQ4WQ]. It'll show button with input box on the page.
     77
    7478= 0.3.6 =
    7579* Bugfix for compatibility with WPML plugin
  • nxtbridge/trunk/style.css

    r1558887 r1574681  
    6262      filter: alpha(opacity=100); }
    6363
     64/**************TIP******************/
     65.NXTBridge-tip-field {
     66  width: 100px !important;
     67  margin-right: 0.2rem !important; }
     68
     69.NXTBridge-tip-button {
     70  width: 100px; }
     71
    6472/*# sourceMappingURL=style.css.map */
  • nxtbridge/trunk/style.scss

    r1558887 r1574681  
    102102}
    103103
     104
     105/**************TIP******************/
     106.NXTBridge-tip-field {
     107  width: 100px !important;
     108  margin-right: 0.2rem !important;
     109}
     110
     111.NXTBridge-tip-button {
     112  width: 100px;
     113}
  • nxtbridge/trunk/wallet/main.php

    r1558887 r1574681  
    174174          break;
    175175
     176        case 'NXTBridge_send':
     177          //var_dump($_POST);
     178
     179          $proto = 'http:'; if ( is_ssl() ) { $proto = 'https:'; }
     180          if ( isset($_POST['recipient']) && isset($_POST['amount']) ) {
     181
     182            $tmp = file_get_contents( $proto . $this->api . '/peer' );
     183            $nxt_node = json_decode($tmp, true);
     184
     185            $user_message = '';
     186
     187            if ( $nxt_node ==  false ) {
     188              $this->log('Some error while decode API answer');
     189              $user_message = 'Error was happen while trying to decode answer from nxter API server';
     190            } else {
     191              $random_node  = $nxt_node['data'];
     192              $url = 'http://' . $random_node . ':7876' . '/nxt?requestType=getAccountPublicKey&account=' . $this->options['account'];
     193
     194              $pub = file_get_contents( $url );
     195              $pub_key = json_decode($pub, true);
     196
     197              if ( isset($pub_key['publicKey']) ) {
     198                $url = 'http://' . $random_node . ':7876/nxt';
     199                $data = array('requestType' => 'sendMoney', 'recipient' => $_POST['recipient'], 'amountNQT' => $_POST['amount'] * 100000000, 'publicKey' => $pub_key['publicKey'], 'feeNQT' => 100000000, 'deadline' => 720, 'broadcast' => 'false', 'message' => 'Sent using NXTBridge' );
     200
     201                $rr = $this->sendPOST( $url, $data );
     202
     203                //var_dump($rr);
     204                $rr_descr = json_decode($rr, true);
     205
     206                if ( $rr_descr ) {
     207                  $rr_code = $rr_descr['errorCode'];
     208                  switch ($rr_code) {
     209                    case '4':
     210                      $user_message = $rr_descr['errorDescription'];
     211                      break;
     212
     213                    default:
     214                      $user_message = print_r($rr, true);
     215                  }
     216
     217                  if ( $rr_descr['unsignedTransactionBytes'] ) {
     218                    $user_message = $rr_descr['unsignedTransactionBytes'];
     219                  }
     220                }
     221
     222              } // end isset
     223            } // end esle
     224           
     225            $this->response = $user_message;
     226            //var_dump($this->response);
     227          }
     228          break;
    176229
    177230        default:
     
    183236      $this->page[1] = $this->agree ? '-active' : '';
    184237      $this->page[2] = '';
     238      $this->page[3] = '';
     239      $this->page[4] = '';
    185240     
    186241      if ( $this->agree ) {
     
    188243        $this->url[2] = '/wp-admin/admin.php?page=nxtbridge_wallet&sub=broadcast';
    189244        $this->url[3] = '/wp-admin/admin.php?page=nxtbridge_wallet&sub=ledger';
     245        $this->url[4] = '/wp-admin/admin.php?page=nxtbridge_wallet&sub=send';
    190246
    191247        //************************************************************************************************** PAGE SWITCH THERE
     
    193249
    194250          $sub = $_GET['sub'];
    195           $this->page[1] = '';
    196           $this->page[2] = '';
     251          $this->page[1] = ''; $this->page[2] = ''; $this->page[3] = ''; $this->page[4] = '';
    197252
    198253          switch ( $sub ) {
     
    209264              break;
    210265
     266            case 'send':
     267              $this->page[4] = '-active';
     268              break;
     269
    211270            default:
    212271              $this->page[1] = '-active';
     
    229288          <a href='<?php echo $this->url[2]; ?>' class='nav-tab nav-tab<?php echo $this->page[2]; ?>'>Broadcast</a>
    230289          <a href='<?php echo $this->url[3]; ?>' class='nav-tab nav-tab<?php echo $this->page[3]; ?>'>Ledger</a>
     290          <a href='<?php echo $this->url[4]; ?>' class='nav-tab nav-tab<?php echo $this->page[4]; ?>'>Send Nxt</a>
    231291        </h2>
    232292
     
    258318
    259319
    260         <?php if ( strlen($this->page[3]) > 0 ) : //******************************************************************************** WALLET ?>
     320        <?php if ( strlen($this->page[3]) > 0 ) : //******************************************************************************** LEDGER ?>
    261321          <?php if ( $this->options['account'] ) : ?>
    262322
     
    267327
    268328        <?php endif; // page[3] ?>
     329
     330        <?php if ( strlen($this->page[4]) > 0 ) : //******************************************************************************** SEND NXT ?>
     331          <?php if ( $this->options['account'] ) : ?>
     332
     333            <form method='POST' action=''>
     334              <?php settings_fields('NXTBridge_send'); ?>
     335              <?php do_settings_sections('nxtbridge_send_account');?>
     336              <?php submit_button('Generate unsigned TX bytes'); ?>
     337            </form>
     338
     339          <?php else: ?>
     340            <p>Please, enter your prefered Nxt account in Reed-Solomon style on the 'Account' page.</p>
     341          <?php endif; ?>
     342
     343        <?php endif; // page[3] ?>
     344
     345
    269346
    270347      </div>
     
    504581      );
    505582
     583      //****************************************************************************************************************************** SEND NXT SECTION
     584      register_setting(
     585        'NXTBridge_send',                       // option group
     586        'NXTBridge_'.$this->id,                 // option name
     587        array( $this, 'sanitize' )
     588      );
     589
     590      add_settings_section(
     591        'NXTBridge_send_section',            // Section name
     592        'NXTBridge Send NXT section',            // Section Title
     593        array( $this, 'print_send_info'),    // Section callback
     594        'nxtbridge_send_account'                      // Page where Section will be display
     595      );
     596
     597      add_settings_field(
     598        'NXTBridge_recipient_account',                  // Setting ID
     599        'Recipient NXT account',                        // Setting title
     600        array( $this, 'recipient_account_callback' ),   // Setting callback
     601        'nxtbridge_send_account',                       // Page where setting will be display
     602        'NXTBridge_send_section'                        // Section name
     603      );
     604
     605      add_settings_field(
     606        'NXTBridge_amount_account',                  // Setting ID
     607        'Recipient NXT amount',                        // Setting title
     608        array( $this, 'amount_account_callback' ),   // Setting callback
     609        'nxtbridge_send_account',                       // Page where setting will be display
     610        'NXTBridge_send_section'                        // Section name
     611      );
     612
     613      add_settings_field(
     614        'NXTBridge_tx_account',                  // Setting ID
     615        'Unsigned TX bytes',                        // Setting title
     616        array( $this, 'tx_account_callback' ),   // Setting callback
     617        'nxtbridge_send_account',                       // Page where setting will be display
     618        'NXTBridge_send_section'                        // Section name
     619      );
    506620    }
    507621
     
    576690    }
    577691
    578 
    579 
     692    /*****************************************************************************************************************/
     693    //
     694    //                                      SEND NXT
     695    //
     696    /*****************************************************************************************************************/
     697    public function print_send_info() {
     698      printf("<p>In this section you can generate unsigned TX bytes for send Nxt action. Then you should sign this bytes with <a href='https://bitbucket.org/scor2k/nxtbridge-offline/downloads/index.min.html' target=_blank>NXTBridge-offline</a> and <a href='/wp-admin/admin.php?page=nxtbridge_wallet&sub=broadcast'>broadcast</a> to the Nxt network.</p>");
     699    }
     700
     701    public function recipient_account_callback() {
     702      printf("<input name='recipient' type='text' size='30' value='%s' />", isset( $_COOKIE['NXTBridgeTip_addr'] ) ? sanitize_text_field( $_COOKIE['NXTBridgeTip_addr'] ): '' );
     703    }
     704
     705    public function amount_account_callback() {
     706      printf("<input name='amount' type='text' size='30' value='%s' />", isset( $_COOKIE['NXTBridgeTip_amount'] ) ? sanitize_text_field( $_COOKIE['NXTBridgeTip_amount'] ): '' );
     707    }
     708
     709    public function tx_account_callback() {
     710      printf("<textarea name='tx' rows='5' cols='30' class='large-text code' readonly>%s</textarea>", $this->response );
     711    }
    580712  } // end class
    581713
Note: See TracChangeset for help on using the changeset viewer.