Merge branch 'lbryio:master' into master
This commit is contained in:
commit
6d39f496d2
3 changed files with 75 additions and 58 deletions
|
@ -164,6 +164,7 @@ class LBRYPress
|
|||
{
|
||||
register_activation_hook( LBRY_PLUGIN_FILE, array( $this, 'activate' ) );
|
||||
register_deactivation_hook( LBRY_PLUGIN_FILE, array( $this, 'deactivate' ) );
|
||||
add_filter( 'kses_allowed_protocols' , array( $this, 'lbry_add_additional_protocols' ) );
|
||||
|
||||
// Banner output for published posts
|
||||
// NOTE: move this to its own class to reduce clutter?
|
||||
|
@ -227,6 +228,19 @@ class LBRYPress
|
|||
error_log( 'Deactivated LBRYPress' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Allowing additional URL protocols to list of allowed protocols.
|
||||
*
|
||||
* @param array $protocols List of protocols allowed by (default WordPress.)
|
||||
*
|
||||
* @return array $protocols Updated list including additional protocols.
|
||||
*/
|
||||
public function lbry_add_additional_protocols( $protocols )
|
||||
{
|
||||
$protocols[] = 'lbry';
|
||||
return $protocols;
|
||||
}
|
||||
|
||||
public function published_on_lbry_banner($content)
|
||||
{
|
||||
if ( ! is_single() || ! in_the_loop() || ! is_main_query() ) {
|
||||
|
|
|
@ -267,61 +267,7 @@ class LBRY_Admin
|
|||
*/
|
||||
public function available_channels_callback()
|
||||
{
|
||||
$channel_list = LBRY()->daemon->channel_list();
|
||||
if ( $channel_list ) { ?>
|
||||
<table class="lbry-channel-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th data-sort="channel">Channel</th>
|
||||
<th data-sort="lbryurl">LBRY URL</th>
|
||||
<th data-sort="claim">Claim ID</th>
|
||||
<th data-sort="date">~ Date Created</th>
|
||||
<th data-sort="posts">Posts</th>
|
||||
<th data-sort="support" colspan="2">Supports</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ( $channel_list as $channel ):
|
||||
$claim_id = $channel->claim_id;
|
||||
$results = LBRY()->daemon->claim_search( $claim_id );
|
||||
$lbry_url = $results->items[0]->canonical_url;
|
||||
if ( $lbry_url ) {
|
||||
$open_url = str_replace( 'lbry://', 'open.lbry.com/', $lbry_url );
|
||||
}
|
||||
$timestamp = $results->items[0]->meta->creation_timestamp;
|
||||
$created_date = date( 'm-d-y', $timestamp );
|
||||
$support_amount = $results->items[0]->meta->support_amount;
|
||||
$claims_published = $results->items[0]->meta->claims_in_channel;
|
||||
if ( ( $support_amount < 0.001 ) ) {
|
||||
( $support_amount = '0' );
|
||||
} elseif ( ( $support_amount < 0.01 ) && ( $support_amount >= 0.001 ) ) {
|
||||
( $support_amount = '<0.01' );
|
||||
} elseif ( ( $support_amount <= 0.099 ) && ( $support_amount >= 0.01) ) {
|
||||
( $support_amount = number_format( floatval( $support_amount ), 2, '.', '' ) );
|
||||
} elseif ( ( $support_amount <= 0.999 ) && ( $support_amount >= 0.1 ) ) {
|
||||
( $support_amount = number_format( floatval( $support_amount ), 1, '.', '' ) );
|
||||
} else {
|
||||
( $support_amount = number_format( intval( $support_amount ) ) );
|
||||
}
|
||||
$init_bid = $results->items[0]->amount; ?>
|
||||
<tr>
|
||||
<td><a href="<?php echo esc_url( $open_url, 'lbrypress' ); ?>"><?php esc_html_e( $channel->name, 'lbrypress' ); ?></a></td>
|
||||
<td><?php esc_html_e( $lbry_url, 'lbrypress' ); ?></td>
|
||||
<td><?php esc_html_e( $claim_id, 'lbrypress' ); ?></td>
|
||||
<td><?php esc_html_e( $created_date, 'lbrypress' ); ?></td>
|
||||
<td><?php esc_html_e( $claims_published, 'lbrypress' ); ?></td>
|
||||
<td><span title="Initial Bid Amount: <?php esc_html_e( $init_bid, 'lbrypress' ); ?>"><img src="<?php echo esc_url( plugin_dir_url( LBRY_PLUGIN_FILE ) . 'admin/images/lbc.png' ) ?>" class="icon icon-lbc bid-icon-lbc channel-bid-icon-lbc"><?php esc_html_e( $support_amount, 'lbrypress' ); ?></span></td>
|
||||
<td><a href="<?php echo admin_url( add_query_arg( array( 'page' => 'lbrypress', 'tab' => 'supports', 'claim_id' => $claim_id, 'current_support' => $support_amount, 'init_bid' => $init_bid, 'lbry_url' => urlencode($lbry_url), 'return_page' => 'channels' ), 'admin.php' ) ); ?>">Add</a></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr><th colspan="7">LBRYPress</th></tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
<?php } else { ?>
|
||||
<p>Looks like you haven't added any channels yet, feel free to do so below:</p>
|
||||
<?php }
|
||||
// Moved to channels-page.php
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -17,8 +17,9 @@ if ( current_user_can( 'manage_options' ) ) {
|
|||
?>
|
||||
|
||||
<h3><?php _e( 'Available Channels To Publish', 'lbrypress' ); ?></h3>
|
||||
<?php LBRY()->admin->available_channels_callback(); ?>
|
||||
<?php if ( isset( $_POST['lbry_new_channel'] ) ) {
|
||||
<?php //LBRY()->admin->available_channels_callback(); ?>
|
||||
<?php
|
||||
if ( isset( $_POST['lbry_new_channel'] ) ) {
|
||||
$channel = $_POST['lbry_new_channel'];
|
||||
$channel = str_replace( '@', '', $channel );
|
||||
$channel = str_replace( ' ', '-', $channel );
|
||||
|
@ -28,6 +29,62 @@ if ( current_user_can( 'manage_options' ) ) {
|
|||
$channel_bid = $_POST['lbry_channel_bid_amount'];
|
||||
$clean_input['lbry_channel_bid_amount'] = number_format( floatval( $channel_bid ), 3, '.', '' );
|
||||
}
|
||||
|
||||
$channel_list = LBRY()->daemon->channel_list();
|
||||
if ( $channel_list ) { ?>
|
||||
<table class="lbry-channel-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th data-sort="channel">Channel</th>
|
||||
<th data-sort="lbryurl">LBRY URL</th>
|
||||
<th data-sort="claim">Claim ID</th>
|
||||
<th data-sort="date">~ Date Created</th>
|
||||
<th data-sort="posts">Posts</th>
|
||||
<th data-sort="support" colspan="2">Supports</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ( $channel_list as $channel ):
|
||||
$claim_id = $channel->claim_id;
|
||||
$results = LBRY()->daemon->claim_search( $claim_id );
|
||||
$lbry_url = $results->items[0]->canonical_url;
|
||||
if ( $lbry_url ) {
|
||||
$open_url = str_replace( 'lbry://', 'https://open.lbry.com/', $lbry_url );
|
||||
}
|
||||
$timestamp = $results->items[0]->meta->creation_timestamp;
|
||||
$created_date = date( 'm-d-y', $timestamp );
|
||||
$support_amount = $results->items[0]->meta->support_amount;
|
||||
$claims_published = $results->items[0]->meta->claims_in_channel;
|
||||
if ( ( $support_amount < 0.001 ) ) {
|
||||
( $support_amount = '0' );
|
||||
} elseif ( ( $support_amount < 0.01 ) && ( $support_amount >= 0.001 ) ) {
|
||||
( $support_amount = '<0.01' );
|
||||
} elseif ( ( $support_amount <= 0.099 ) && ( $support_amount >= 0.01) ) {
|
||||
( $support_amount = number_format( floatval( $support_amount ), 2, '.', '' ) );
|
||||
} elseif ( ( $support_amount <= 0.999 ) && ( $support_amount >= 0.1 ) ) {
|
||||
( $support_amount = number_format( floatval( $support_amount ), 1, '.', '' ) );
|
||||
} else {
|
||||
( $support_amount = number_format( intval( $support_amount ) ) );
|
||||
}
|
||||
$init_bid = $results->items[0]->amount; ?>
|
||||
<tr>
|
||||
<td><a href="<?php echo esc_url( $open_url, 'lbrypress' ); ?>"><?php esc_html_e( $channel->name, 'lbrypress' ); ?></a></td>
|
||||
<td><?php esc_html_e( esc_url( $lbry_url ), 'lbrypress' ); ?></td>
|
||||
<td><?php esc_html_e( $claim_id, 'lbrypress' ); ?></td>
|
||||
<td><?php esc_html_e( $created_date, 'lbrypress' ); ?></td>
|
||||
<td><?php esc_html_e( $claims_published, 'lbrypress' ); ?></td>
|
||||
<td><span title="Initial Bid Amount: <?php esc_html_e( $init_bid, 'lbrypress' ); ?>"><img src="<?php echo esc_url( plugin_dir_url( LBRY_PLUGIN_FILE ) . 'admin/images/lbc.png' ) ?>" class="icon icon-lbc bid-icon-lbc channel-bid-icon-lbc"><?php esc_html_e( $support_amount, 'lbrypress' ); ?></span></td>
|
||||
<td><a href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'lbrypress', 'tab' => 'supports', 'claim_id' => urlencode( esc_html__( $claim_id, 'lbrypress' ) ), 'supporting_channel' => urlencode( esc_html__($channel->name, 'lbrypress' ) ), 'current_support' => urlencode( floatval($support_amount) ), 'init_bid' => urlencode( floatval($init_bid) ), 'lbry_url' => urlencode( esc_url($lbry_url) ) ), 'admin.php' ) ) ); ?>">Add</a></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr><th colspan="7">LBRYPress</th></tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
<?php } else { ?>
|
||||
<p>Looks like you haven't added any channels yet, feel free to do so below:</p>
|
||||
<?php }
|
||||
?>
|
||||
|
||||
<form action="<?php echo esc_url( admin_url( 'admin-post.php' ) ); ?>" method="post" id="lbry_add_channel_form">
|
||||
|
@ -66,6 +123,6 @@ if ( current_user_can( 'manage_options' ) ) {
|
|||
<?php
|
||||
} else {
|
||||
?>
|
||||
<p> <?php __( "You are not authorized to perform this operation.", $this->plugin_name ) ?> </p>
|
||||
<p> <?php __( "You are not authorized to perform this operation.", 'lbrypress' ) ?> </p>
|
||||
<?php
|
||||
}
|
Loading…
Reference in a new issue