options-page rewrite

This commit is contained in:
Lem Smyth 2022-02-09 07:30:41 -06:00
parent 39170a3262
commit c89405bbd4

View file

@ -1,52 +1,50 @@
<?php <?php
/**
* The Options Page with tabs
* @package LBRYPress
*/
defined('ABSPATH') || die(); // Exit if accessed directly
$LBRY = LBRY(); $LBRY = LBRY();
$wallet_balance = $LBRY->daemon->wallet_balance(); $wallet_balance = $LBRY->daemon->wallet_balance();
$available_balance = $wallet_balance->result->available; $available_balance = $wallet_balance->result->available;
$lbry_active_tab = isset( $_GET['tab'] ) ? $_GET['tab'] : 'general';
$channel_list = $LBRY->daemon->channel_list(); $channel_list = $LBRY->daemon->channel_list();
// TODO: Make this page look cleaner // TODO: Make this page look cleaner
?> ?>
<div class="wrap"> <div class="wrap">
<h1><?= esc_html(get_admin_page_title()); ?></h1> <h1><?php esc_html_e( get_admin_page_title(), 'lbrypress' ); ?></h1>
<h2>Your wallet amount:</h2>
<img src="<?php echo esc_url( plugin_dir_url(LBRY_PLUGIN_FILE) . 'admin/images/lbc.png') ?>" class="icon icon-lbc wallet-icon-lbc" style="height: 1.8em; margin-right: .5em; margin-bottom: -.5em;"><code><?= number_format($available_balance, 2, '.', ','); ?></code> <h2 title="<?php echo esc_attr( number_format( $total_balance, 3, '.', ',' ) ); ?> Wallet Total Balance"><img src="<?php echo esc_url( plugin_dir_url( LBRY_PLUGIN_FILE ) . 'admin/images/lbc.png' ) ?>" class="icon icon-lbc wallet-icon-lbc" style="height: 1.8em; margin-right: .5em; margin-bottom: -.5em;"><code><?php esc_html_e( number_format( $available_balance, 3, '.', ',' ) ); ?></code> Wallet Available Balance</h2>
<form action="options.php" method="post"> <nav class="nav-tab-wrapper">
<?php <a href="<?php echo esc_url( admin_url( 'options.php?page=lbrypress&tab=general' ) ); ?>" class="nav-tab <?php echo $lbry_active_tab == 'general' || '' ? 'nav-tab-active' : ''; ?>"><?php esc_html_e( 'Settings' ); ?></a>
settings_fields(LBRY_SETTINGS_GROUP); <a href="<?php echo esc_url( admin_url( 'admin.php?page=lbrypress&tab=channels' ) ); ?>" class="nav-tab <?php echo $lbry_active_tab == 'channels' ? 'nav-tab-active' : ''; ?>"><?php esc_html_e( 'Channels' ); ?></a>
do_settings_sections(LBRY_ADMIN_PAGE); <a href="<?php echo esc_url( admin_url( 'options.php?page=lbrypress&tab=speech' ) ); ?>" class="nav-tab <?php echo $lbry_active_tab == 'speech' ? 'nav-tab-active' : ''; ?>"><?php esc_html_e( 'Spee.ch' ); ?></a>
submit_button('Save Settings'); </nav>
?> <?php if ( $lbry_active_tab == 'channels' ) {
</form> include_once( 'partials/channel-page.php' );
<h2>Your Publishable Channels</h2> } else {
<?php if ($channel_list): ?> ?>
<ul class="lbry-channel-list"> <form class="form-table" action="<?php echo esc_url( admin_url( 'options.php' ) ); ?>" method="post">
<?php foreach ($channel_list as $channel): ?> <?php
<li><?= $channel->name ?></li> }
<?php endforeach; ?> if ( $lbry_active_tab == 'general' ) {
</ul> settings_fields( 'lbry_general_settings' );
<?php else: ?> do_settings_sections( LBRY_ADMIN_PAGE );
<p>Looks like you haven't added any channels yet, feel free to do so below:</p> submit_button();
<?php endif; ?> } elseif ( $lbry_active_tab == 'channels' ) {
<h2>Add a new channel to publish to:</h2> include_once( 'partials/channel-page.php' );
<form action="<?php echo esc_url(admin_url('admin-post.php')); ?>" method="post"> } elseif ( $lbry_active_tab == 'speech' ) {
<?php wp_nonce_field('lbry_add_channel', '_lbrynonce'); ?> settings_fields( LBRY_SPEECH_SETTINGS );
<input type="hidden" name="action" value="lbry_add_channel"> do_settings_sections( 'lbrypress-speech' );
<table class="form-table"> submit_button();
<tbody> } else {
<tr> settings_fields( 'lbry_general_settings' );
<th scope="row">New Channel Name</th> do_settings_sections( LBRY_ADMIN_PAGE );
<td> submit_button();
<span>@</span> }
<input type="text" name="new_channel" value="" placeholder="your-new-channel" required> ?>
</td> </form>
</tr> </div><!-- wrap -->
<tr>
<th scope="row">Amount of LBC to Bid</th>
<td>
<input type="number" step="0.1" min="0.1" name="bid_amount" value="10" required>
</td>
</tr>
</tbody>
</table>
<?php submit_button('Add New Channel'); ?>
</form>
</div>