If published meta box #65

Merged
lemsmyth merged 34 commits from if-published into master 2022-02-16 21:52:43 +01:00
14 changed files with 168 additions and 136 deletions
Showing only changes of commit a00f979bf3 - Show all commits

1
.gitignore vendored
View file

@ -4,7 +4,6 @@
!*.* !*.*
.DS_Store .DS_Store
extensions.json
.vscode/* .vscode/*
tmp/* tmp/*

2
admin/index.php Normal file
View file

@ -0,0 +1,2 @@
<?php
// Silence is golden

View file

@ -120,8 +120,9 @@ class LBRYPress
$this->define('LBRY_LICENSE', 'lbry_license'); // the license to publish with to the LBRY network $this->define('LBRY_LICENSE', 'lbry_license'); // the license to publish with to the LBRY network
$this->define('LBRY_LBC_PUBLISH', 'lbry_lbc_publish'); // amount of lbc to use per publish $this->define('LBRY_LBC_PUBLISH', 'lbry_lbc_publish'); // amount of lbc to use per publish
$this->define('LBRY_WILL_PUBLISH', '_lbry_will_publish'); // The meta key for if to publish to LBRY Network or not $this->define('LBRY_WILL_PUBLISH', '_lbry_will_publish'); // The meta key for if to publish to LBRY Network or not
$this->define('LBRY_POST_CHANNEL', '_lbry_post_pub_channel'); // The meta key for which channel to publish $this->define('LBRY_POST_CHANNEL', '_lbry_channel'); // The meta key for which channel to publish
$this->define('LBRY_POST_LICENSE', '_lbry_post_pub_license'); // The meta key for which license to publish on $this->define('LBRY_POST_PUB_CHANNEL', '_lbry_post_pub_channel'); // The meta key for which channel to publish on
$this->define('LBRY_POST_PUB_LICENSE', '_lbry_post_pub_license'); // The meta key for which license to publish on
$this->define('LBRY_CLAIM_ID', '_lbry_claim_id'); // The Claim ID for the post as it was published on LBRY $this->define('LBRY_CLAIM_ID', '_lbry_claim_id'); // The Claim ID for the post as it was published on LBRY
$this->define('LBRY_CANONICAL_URL', '_lbry_canonical_url'); // The canonical url for the published lbry post $this->define('LBRY_CANONICAL_URL', '_lbry_canonical_url'); // The canonical url for the published lbry post
$this->define('LBRY_SPEECH_ASSET_URL', 'speech_asset_url'); // The meta key for an asset's speech url $this->define('LBRY_SPEECH_ASSET_URL', 'speech_asset_url'); // The meta key for an asset's speech url

View file

@ -27,14 +27,14 @@ class LBRY_Admin
public function create_options_page() public function create_options_page()
{ {
$hook_suffix = add_menu_page( add_menu_page(
__( 'LBRYPress Settings', 'lbrypress' ), __( 'LBRYPress Settings', 'lbrypress' ),
__( 'LBRYPress', 'lbrypress' ), __( 'LBRYPress', 'lbrypress' ),
'manage_options', 'manage_options',
LBRY_ADMIN_PAGE, LBRY_ADMIN_PAGE,
array( $this, 'options_page_html' ), array( $this, 'options_page_html' ),
plugin_dir_url( LBRY_PLUGIN_FILE ) . '/admin/images/lbry-icon.png' plugin_dir_url( LBRY_PLUGIN_FILE ) . '/admin/images/lbry-icon.png'
); );
// Admin stylesheet enqueue // Admin stylesheet enqueue
function load_admin_stylesheet( $hook ) { function load_admin_stylesheet( $hook ) {
@ -69,11 +69,10 @@ class LBRY_Admin
/** /**
* Returns the Options Page HTML for the plugin * Returns the Options Page HTML for the plugin
*/ */
public function options_page_html() { public function options_page_html()
//$LBRY = LBRY(); {
// Set class properties to be referenced in callbacks // Set class properties to be referenced in callbacks
$this->options = get_option( LBRY_SETTINGS ); $this->options = get_option( LBRY_SETTINGS );
//$this->options_channel = get_option( 'lbry_channel_settings' );
$this->options_speech = get_option( LBRY_SPEECH_SETTINGS ); $this->options_speech = get_option( LBRY_SPEECH_SETTINGS );
require_once( LBRY_ABSPATH . 'templates/options-page.php' ); require_once( LBRY_ABSPATH . 'templates/options-page.php' );
} }
@ -115,14 +114,6 @@ class LBRY_Admin
LBRY_SETTINGS_SECTION_GENERAL LBRY_SETTINGS_SECTION_GENERAL
); );
add_settings_field(
'lbry_default_publish_setting',
'Always Publish to LBRY',
array( $this, 'lbry_always_pub_callback' ),
LBRY_ADMIN_PAGE,
LBRY_SETTINGS_SECTION_GENERAL
);
add_settings_field( add_settings_field(
'default_lbry_channel', 'default_lbry_channel',
'Default Publish Channel', 'Default Publish Channel',
@ -130,14 +121,6 @@ class LBRY_Admin
LBRY_ADMIN_PAGE, LBRY_ADMIN_PAGE,
LBRY_SETTINGS_SECTION_GENERAL LBRY_SETTINGS_SECTION_GENERAL
); );
// remove from commit:
add_settings_field(
'lbry_default_publish_setting',
'Always Publish to LBRY',
array( $this, 'lbry_always_pub_callback' ),
LBRY_ADMIN_PAGE,
LBRY_SETTINGS_SECTION_GENERAL
);
add_settings_field( add_settings_field(
'lbry_default_publish_setting', 'lbry_default_publish_setting',
@ -232,7 +215,7 @@ class LBRY_Admin
return $new_input; return $new_input;
} }
public function sanitize_speech_settings( $input ) public function sanitize_speech_settings( $input )
{ {
$new_input = get_option( LBRY_SPEECH_SETTINGS ); $new_input = get_option( LBRY_SPEECH_SETTINGS );
if ( isset( $input[LBRY_SPEECH] ) ) { if ( isset( $input[LBRY_SPEECH] ) ) {
@ -306,7 +289,7 @@ class LBRY_Admin
$address $address
); );
} }
// remove from commit:
/** /**
* Checkbox to default to always allow publish on LBRY * Checkbox to default to always allow publish on LBRY
*/ */
@ -324,7 +307,7 @@ class LBRY_Admin
); );
} }
/** /**
* Prints select to choose a default to publish to channel * Prints select to choose a default to publish to channel
*/ */
@ -382,7 +365,6 @@ class LBRY_Admin
$options $options
); );
} }
/** /**
* Prints LBC per publish input * Prints LBC per publish input
@ -396,7 +378,7 @@ class LBRY_Admin
$this->options[LBRY_LBC_PUBLISH], $this->options[LBRY_LBC_PUBLISH],
plugin_dir_url( LBRY_PLUGIN_FILE ) . 'admin/images/lbc.png' plugin_dir_url( LBRY_PLUGIN_FILE ) . 'admin/images/lbc.png'
); );
} }
/** /**
@ -441,10 +423,9 @@ class LBRY_Admin
'<input type="password" id="' . esc_attr('%1$s') . '" name="' . esc_attr('%2$s[%1$s]') . '" placeholder="Leave empty for same password">', '<input type="password" id="' . esc_attr('%1$s') . '" name="' . esc_attr('%2$s[%1$s]') . '" placeholder="Leave empty for same password">',
LBRY_SPEECH_PW, LBRY_SPEECH_PW,
LBRY_SPEECH_SETTINGS, LBRY_SPEECH_SETTINGS,
); );
} }
/** /**
* Handles new channel form submission * Handles new channel form submission
*/ */

View file

@ -9,7 +9,8 @@ defined('ABSPATH') || die(); // Exit if accessed directly
class LBRY_Admin_Notice class LBRY_Admin_Notice
{ {
public function __construct() { public function __construct()
{
add_action( 'admin_notices', array( $this, 'admin_notices' ) ); add_action( 'admin_notices', array( $this, 'admin_notices' ) );
} }

View file

@ -74,10 +74,9 @@ class LBRY_Daemon
* *
*/ */
public function wallet_balance() public function wallet_balance()
{ {
try { // Convert JSON string to an object try { // Convert JSON string to an object
$result = $this->request( 'wallet_balance', array() ); $result = $this->request( 'wallet_balance' );
return $result; return $result;
} catch (LBRYDaemonException $e) { } catch (LBRYDaemonException $e) {
$this->logger->log('wallet_balance error', $e->getMessage() . ' | Code: ' . $e->getCode()); $this->logger->log('wallet_balance error', $e->getMessage() . ' | Code: ' . $e->getCode());
@ -138,7 +137,7 @@ class LBRY_Daemon
'bid' => $channel_bid 'bid' => $channel_bid
) )
); );
$this->logger->log( 'channel_create success!', 'Successfully created channel with result: ' . print_r( $result->result, true ) ); $this->logger->log( 'channel_create success!', 'Successfully created channel with result: ' . print_r( $result->result, true ) );
return $result->result; return $result->result;

View file

@ -39,10 +39,9 @@ class LBRY_Network
// Save the post meta on 'save_post' hook // Save the post meta on 'save_post' hook
add_action( 'wp_insert_post', array( $this, 'save_post_meta' ), 11, 2 ); add_action( 'wp_insert_post', array( $this, 'save_post_meta' ), 11, 2 );
// Checkbox inside the WordPres meta box near "Publish" button // Checkbox inside the WordPres meta box near "Publish" button
add_action( 'post_submitbox_misc_actions', array( $this, 'publish_to_lbry_checkbox' ) ); add_action( 'post_submitbox_misc_actions', array( $this, 'publish_to_lbry_checkbox' ) );
} }
/** /**
@ -84,48 +83,34 @@ class LBRY_Network
if ( ! current_user_can( $post_type->cap->edit_post, $post_id ) ) { if ( ! current_user_can( $post_type->cap->edit_post, $post_id ) ) {
return $post_id; return $post_id;
} }
if ( ( $_POST['_lbry_will_publish'] ) && $_POST['_lbry_will_publish'] != get_post_meta( $post_id, '_lbry_will_publish', true ) ) { if ( ( $_POST[LBRY_WILL_PUBLISH] ) && $_POST[LBRY_WILL_PUBLISH] != get_post_meta( $post_id, LBRY_WILL_PUBLISH, true ) ) {
update_post_meta( $post_id, '_lbry_will_publish', $_POST['_lbry_will_publish'] ); update_post_meta( $post_id, LBRY_WILL_PUBLISH, $_POST[LBRY_WILL_PUBLISH] );
} elseif ( ! isset( $_POST['_lbry_will_publish'] ) ) { } elseif ( ! isset( $_POST[LBRY_WILL_PUBLISH] ) ) {
update_post_meta( $post_id, '_lbry_will_publish', 0 ); update_post_meta( $post_id, LBRY_WILL_PUBLISH, 0 );
} }
$channel = $_POST[LBRY_POST_CHANNEL]; $channel = $_POST[LBRY_POST_PUB_CHANNEL];
$cur_channel = ( get_post_meta( $post_id, LBRY_POST_CHANNEL, true ) ? get_post_meta( $post_id,LBRY_POST_CHANNEL, true ) : get_post_meta( $post_id, '_lbry_channel', true ) ); $cur_channel = ( get_post_meta( $post_id, LBRY_POST_PUB_CHANNEL, true ) ? get_post_meta( $post_id, LBRY_POST_PUB_CHANNEL, true ) : get_post_meta( $post_id, '_lbry_channel', true ) );
$license = $_POST['_lbry_post_pub_license']; $license = $_POST[LBRY_POST_PUB_LICENSE];
$cur_license = get_post_meta( $post_id, '_lbry_post_pub_license', true ); $cur_license = get_post_meta( $post_id, LBRY_POST_PUB_LICENSE, true );
$will_publish = $_POST['_lbry_will_publish']; $will_publish = $_POST[LBRY_WILL_PUBLISH];
// Update meta acordingly // Update meta acordingly
if ( $channel !== $cur_channel ) { if ( $channel !== $cur_channel ) {
update_post_meta( $post_id, LBRY_POST_CHANNEL, $channel ); update_post_meta( $post_id, LBRY_POST_PUB_CHANNEL, $channel );
delete_post_meta( $post_id, '_lbry_channel'); // remove the _lbry_channel if already set from the post and replaces with _lbry_post_pub_channel to avoid confusion delete_post_meta( $post_id, '_lbry_channel'); // remove the _lbry_channel if already set from the post and replaces with _lbry_post_pub_channel to avoid confusion
} elseif ( $channel === $cur_channel && ( $cur_channel === get_post_meta( $post_id, '_lbry_channel', true ) ) ) { } elseif ( $channel === $cur_channel && ( $cur_channel === get_post_meta( $post_id, '_lbry_channel', true ) ) ) {
update_post_meta( $post_id, LBRY_POST_CHANNEL, $channel ); update_post_meta( $post_id, LBRY_POST_PUB_CHANNEL, $channel );
delete_post_meta( $post_id, '_lbry_channel'); // remove the _lbry_channel if already set from the post and replaces with _lbry_post_pub_channel to avoid confusion delete_post_meta( $post_id, '_lbry_channel'); // remove the _lbry_channel if already set from the post and replaces with _lbry_post_pub_channel to avoid confusion
} }
if ( $license !== $cur_license ) { if ( $license !== $cur_license ) {
update_post_meta( $post_id, '_lbry_post_pub_license', $license ); update_post_meta( $post_id, LBRY_POST_PUB_LICENSE, $license );
} }
if ( ( $will_publish ) && ( $will_publish == 1 ) && $post->post_status == 'publish') { if ( ( $will_publish ) && ( $will_publish == 1 ) && $post->post_status == 'publish') {
// Publish the post on the LBRY Network // Publish the post on the LBRY Network
$this->publisher->publish( $post, $channel, $license ); $this->publisher->publish( $post, $channel, $license );
} }
}
/**
* Creates a checkbox that changes the default setting to always publish to LBRY,
* can be reverted individually to not publish on a per post basis. Saves to options table.
*/
public function publish_to_lbry_checkbox( $post )
{
$post_id = $post->ID;
if ( get_post_type( $post_id ) != 'post' ) {
return $post;
}
$default_value = get_option( LBRY_SETTINGS )['lbry_default_publish_setting']; $default_value = get_option( LBRY_SETTINGS )['lbry_default_publish_setting'];
$new_value = get_post_meta( $post_id, '_lbry_will_publish', true ); $new_value = get_post_meta( $post_id, '_lbry_will_publish', true );
if ( ( $new_value ) ? $new_value : $new_value = $default_value ); if ( ( $new_value ) ? $new_value : $new_value = $default_value );
@ -145,6 +130,38 @@ class LBRY_Network
); );
} }
/**
* Creates a checkbox that changes the default setting to always publish to LBRY,
* can be reverted individually to not publish on a per post basis. Saves to options table.
*/
public function publish_to_lbry_checkbox( $post )
{
$post_id = $post->ID;
if ( get_post_type( $post_id ) != 'post' ) {
return $post;
}
$default_value = get_option( LBRY_SETTINGS )['lbry_default_publish_setting'];
$new_value = get_post_meta( $post_id, LBRY_WILL_PUBLISH, true );
if ( ( $new_value ) ? $new_value : $new_value = $default_value );
$value = $new_value;
if ( ( $value ) ? $value : 0 );
// nonce set on page meta-box.php
printf (
'<div class="lbry-meta-checkbox-wrapper lbry-meta-checkbox-wrapper-last">
<span class="lbry-pub-metabox"><img src="' . __( '%1$s', '%4$s' ) . '" class="icon icon-lbry meta-icon-lbry"></span><label class="lbry-meta-label">' . esc_html__('%2$s', '%4$s' ) . ' <strong>' . esc_html__('%3$s', '%4$s') . '</strong></label><input type="checkbox" class="lbry-meta-checkbox" value="1"' . esc_attr('%5$s') . ' name="' . esc_attr('%6$s') . '">
</div>',
plugin_dir_url( LBRY_PLUGIN_FILE ) . 'admin/images/lbry.png',
'Publish to',
'LBRY',
'lbrypress',
checked( $value, true, false ),
LBRY_WILL_PUBLISH
);
}
/** /**
* Returns the HTML for the LBRY Meta Box * Returns the HTML for the LBRY Meta Box
* @param WP_POST $post * @param WP_POST $post

View file

@ -10,7 +10,6 @@ use League\HTMLToMarkdown\HtmlConverter;
*/ */
defined('ABSPATH') || die(); // Exit if accessed directly defined('ABSPATH') || die(); // Exit if accessed directly
class LBRY_Network_Parser class LBRY_Network_Parser
{ {
public $converter = null; public $converter = null;

View file

@ -14,7 +14,7 @@ class LBRY_Network_Publisher
* @param string $channel The Claim ID of the channel we are posting to * @param string $channel The Claim ID of the channel we are posting to
*/ */
// NOTE: This is currently sitting at about 150ms, mostly the post parsing // NOTE: This is currently sitting at about 150ms, mostly the post parsing
public function publish( $post, $channel, $license ) { public function publish( $post, $channel = null, $license ) {
$post_id = $post->ID; $post_id = $post->ID;
// Get converted markdown into a file // Get converted markdown into a file

View file

@ -0,0 +1,71 @@
<?php
/**
* ============================
* CHANNELS SETTINGS ADMIN PAGE
* Uses the post-admin action so we can use the $_POST global variable to build our cURL request and the settings are not saved to the datbase
* @package LBRYPress
* ============================
*/
defined('ABSPATH') || die(); // Exit if accessed directly
if ( current_user_can( 'manage_options' ) ) {
// Generate a custom nonce
$lbrynonce = wp_create_nonce( 'add_channel_nonce' );
// Build the page
?>
<h3><?php _e( 'Available Channels To Publish', 'lbrypress' ); ?></h3>
<?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 );
$clean_input['lbry_new_channel'] = sanitize_user( $channel );
}
if ( isset( $_POST['lbry_channel_bid_amount'] ) ) {
$channel_bid = $_POST['lbry_channel_bid_amount'];
$clean_input['lbry_channel_bid_amount'] = number_format( floatval( $channel_bid ), 3, '.', '' );
}
?>
<form action="<?php echo esc_url( admin_url( 'admin-post.php' ) ); ?>" method="post" id="lbry_add_channel_form">
<input type="hidden" name="action" value="lbry_add_channel">
<input type="hidden" name="_lbrynonce" value="<?php echo $lbrynonce ?>">
<h3><?php echo _e( 'Create a New Channel', 'lbrypress' ); ?></h3>
<table class="form-table" role="presentation">
<tbody>
<tr>
<th scope="row">New Channel Name</th>
<td>
<?php printf(
'<input type="text" id="' . esc_attr('%1$s') . '" name="' . esc_attr('%1$s') . '" value="@' . esc_attr('%2$s') . '" placeholder="your-new-channel" required>',
'lbry_new_channel',
$clean_input['lbry_new_channel'],
); ?>
<p>No Spaces in Channel Names</p>
</td>
</tr>
<tr>
<th scope="row">Amount of LBC to Bid</th>
<td>
<?php printf(
'<input type="number" step="0.001" min="0.001" id="' . esc_attr('%1$s') . '" name="' . esc_attr('%1$s') . '" value="' . esc_attr('%2$.3f') . '" required>',
'lbry_channel_bid_amount',
$clean_input['lbry_channel_bid_amount'],
); ?>
<p>Current minimum bid <img src="<?php echo esc_url( plugin_dir_url( LBRY_PLUGIN_FILE ) . 'admin/images/lbc.png' ) ?>" class="icon icon-lbc bid-icon-lbc"> 0.001</p>
</td>
</tr>
</tbody>
</table>
<p class="submit"><input type="submit" name="submit" id="submit" class="button button-primary" value="Create New Channel"></p>
</form>
<?php
} else {
?>
<p> <?php __( "You are not authorized to perform this operation.", $this->plugin_name ) ?> </p>
<?php
}

View file

@ -1,4 +1,11 @@
<?php <?php
/**
* ============================
* META BOX FOR POST PAGE
* Prints the post meta box
* @package LBRYPress
* ============================
*/
defined('ABSPATH') || die(); // Exit if accessed directly defined('ABSPATH') || die(); // Exit if accessed directly
$unnatributed = (object) array( $unnatributed = (object) array(
@ -11,7 +18,7 @@ $lbrynonce = wp_create_nonce( 'lbry_publish_post_nonce' );
$channels = LBRY()->daemon->channel_list(); $channels = LBRY()->daemon->channel_list();
$channels[] = $unnatributed; $channels[] = $unnatributed;
$post_id = $post->ID; $post_id = $post->ID;
$cur_channel = ( get_post_meta( $post_id, '_lbry_post_pub_channel', true ) ? get_post_meta( $post_id, '_lbry_post_pub_channel', true ) : get_post_meta( $post_id, '_lbry_channel', true ) ); $cur_channel = ( get_post_meta( $post_id, LBRY_POST_PUB_CHANNEL, true ) ? get_post_meta( $post_id, LBRY_POST_PUB_CHANNEL, true ) : get_post_meta( $post_id, '_lbry_channel', true ) );
$default_channel = get_option( LBRY_SETTINGS )['default_lbry_channel']; $default_channel = get_option( LBRY_SETTINGS )['default_lbry_channel'];
// Sort the channels in a natural way // Sort the channels in a natural way
@ -20,43 +27,43 @@ usort( $channels, array( 'LBRYPress', 'channel_name_comp' ) );
<section> <section>
<input type="hidden" id="_lbrynonce" name="_lbrynonce" value="<?php echo $lbrynonce ?>"> <input type="hidden" id="_lbrynonce" name="_lbrynonce" value="<?php echo $lbrynonce ?>">
<div><label for="_lbry_post_pub_channel" class="lbry-meta-bx-label lbry-meta-bx-channel"><?php esc_html_e( 'Channel to Publish: ', 'lbrypress' ); ?></label></div><?php <div><label for="LBRY_POST_PUB_CHANNEL" class="lbry-meta-bx-label lbry-meta-bx-channel"><?php esc_html_e( 'Channel to Publish: ', 'lbrypress' ); ?></label></div><?php
$options = ''; $options = '';
if ( $channels ) { if ( $channels ) {
foreach ( $channels as $index=>$channel ) { foreach ( $channels as $index=>$channel ) {
$options .= '<option class="lbry-meta-bx-option lbry-meta-option-channel" value="' . esc_attr( $channel->claim_id ) . '"'; $options .= '<option class="lbry-meta-bx-option lbry-meta-option-channel" value="' . esc_attr( $channel->claim_id ) . '"';
if ( ( $cur_channel ) ? $cur_channel : $cur_channel = $default_channel ) { if ( isset( $cur_channel ) ? $cur_channel : $cur_channel = $default_channel ) {
$options .= selected( $cur_channel, $channel->claim_id, false ); $options .= selected( $cur_channel, $channel->claim_id, false );
}
$options .= '>' . esc_html__( $channel->name, 'lbrypress' ) . '</option>';
} }
$options .= '>' . esc_html__( $channel->name, 'lbrypress' ) . '</option>';
}
printf( printf(
'<select id="' . esc_attr('%1$s') . '" name="' . esc_attr('%1$s') . '">' . esc_html('%2$s') . '</select>', '<select id="' . esc_attr('%1$s') . '" name="' . esc_attr('%1$s') . '">' . esc_html('%2$s') . '</select>',
'_lbry_post_pub_channel', LBRY_POST_PUB_CHANNEL,
$options $options
); );
} ?> } ?>
<div><label for="_lbry_post_pub_license" class="lbry-meta-bx-label lbry-meta-bx-license"><?php esc_html_e( 'Publish License: ', 'lbrypress' ); ?></label></div><?php <div><label for="LBRY_POST_PUB_LICENSE" class="lbry-meta-bx-label lbry-meta-bx-license"><?php esc_html_e( 'Publish License: ', 'lbrypress' ); ?></label></div><?php
$licenses = LBRY()->licenses; $licenses = LBRY()->licenses;
$options = ''; $options = '';
$default_license = get_option(LBRY_SETTINGS)[LBRY_LICENSE]; $default_license = get_option(LBRY_SETTINGS)[LBRY_LICENSE];
$cur_license = get_post_meta( $post_id, '_lbry_post_pub_license', true ); $cur_license = get_post_meta( $post_id, LBRY_POST_PUB_LICENSE, true );
// Create options list, select current license // Create options list, select current license
if ( $licenses ) { if ( $licenses ) {
foreach ( $licenses as $value => $name ) { foreach ( $licenses as $value => $name ) {
$options .= '<option class="lbry-meta-bx-option lbry-meta-bx-option-last lbry-meta-option-license" value="' . esc_attr( $value ) . '"'; $options .= '<option class="lbry-meta-bx-option lbry-meta-bx-option-last lbry-meta-option-license" value="' . esc_attr( $value ) . '"';
if ( ( $cur_license ) ? $cur_license : $cur_license = $default_license ) { if ( isset( $cur_license ) ? $cur_license : $cur_license = $default_license ) {
$options .= selected( $cur_license, $value, false ); $options .= selected( $cur_license, $value, false );
} }
$options .= '>'. esc_html__( $name, 'lbrypress' ) . '</option>'; $options .= '>'. esc_html__( $name, 'lbrypress' ) . '</option>';
} }
} }
printf( printf(
'<select class="" id="'.esc_attr('%1$s').'" name="'. esc_attr('%1$s') .'">' . esc_html('%2$s') . '</select>', '<select class="" id="'.esc_attr('%1$s').'" name="'. esc_attr('%1$s') .'">' . esc_html('%2$s') . '</select>',
'_lbry_post_pub_license', LBRY_POST_PUB_LICENSE,
$options $options
); );
?> ?>
</section> </section>

View file

@ -1,44 +0,0 @@
<?php
defined('ABSPATH') || die(); // Exit if accessed directly
$unnatributed = (object) array(
'name' => 'none (anonymous)',
'claim_id' => 'null'
);
$channels = LBRY()->daemon->channel_list();
$channels[] = $unnatributed;
// Sort the channels in a natural way
usort($channels, array('LBRYPress', 'channel_name_comp'));
$cur_channel = get_post_meta($post->ID, LBRY_POST_CHANNEL, true);
$will_publish = get_post_meta($post->ID, LBRY_WILL_PUBLISH, true);
?>
<?php wp_nonce_field('lbry_publish_channels', '_lbrynonce'); ?>
<div class="lbry-meta-checkbox-wrapper">
<label class="lbry-meta-label">
<input type="checkbox" class="lbry-meta-checkbox" name="<?= LBRY_WILL_PUBLISH ?>" value="true"
<?php
if ($will_publish === 'true' || $will_publish === '') {
echo 'checked';
}
?>
>
Sync this post on channel:
</label>
</div>
<select class="lbry-meta-select" name="<?= LBRY_POST_CHANNEL ?>">
<?php foreach ($channels as $index=>$channel): ?>
<option value="<?= $channel->claim_id ?>"
<?php
if ($cur_channel) {
if ($cur_channel === $channel->claim_id) {
echo 'selected';
}
} elseif ($index === 0) {
echo 'selected';
}
?>
>
<?= $channel->name ?>
</option>
<?php endforeach; ?>
</select>

View file

@ -14,15 +14,14 @@ $lbry_active_tab = isset( $_GET['tab'] ) ? $_GET['tab'] : 'general';
<div class="wrap"> <div class="wrap">
<h1><?php esc_html_e( get_admin_page_title(), 'lbrypress' ); ?></h1> <h1><?php esc_html_e( get_admin_page_title(), 'lbrypress' ); ?></h1>
<h2><img src="<?php echo esc_url( plugin_dir_url( LBRY_PLUGIN_FILE ) . 'admin/images/lbc.png' ) ?>" class="icon icon-lbc wallet-icon-lbc" title="<?php echo esc_attr( number_format( $total_balance, 3, '.', ',' ) ); ?> Wallet Total Balance"><code title="<?php echo esc_attr( number_format( $total_balance, 3, '.', ',' ) ); ?> Wallet Total Balance"><?php esc_html_e( number_format( $available_balance, 3, '.', ',' ) ); ?></code> Wallet Available Balance</h2>
<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"><code><?php esc_html_e( number_format( $available_balance, 3, '.', ',' ) ); ?></code> Wallet Available Balance</h2>
<nav class="nav-tab-wrapper"> <nav class="nav-tab-wrapper">
<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> <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>
<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> <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>
<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> <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>
</nav> </nav>
<?php if ( $lbry_active_tab == 'channels' ) { <?php if ( $lbry_active_tab == 'channels' ) {
include_once( 'partials/channel-page.php' ); include_once( 'channels-page.php' );
} else { } else {
?> ?>
<form class="form-table" action="<?php echo esc_url( admin_url( 'options.php' ) ); ?>" method="post"> <form class="form-table" action="<?php echo esc_url( admin_url( 'options.php' ) ); ?>" method="post">
@ -33,7 +32,7 @@ $lbry_active_tab = isset( $_GET['tab'] ) ? $_GET['tab'] : 'general';
do_settings_sections( LBRY_ADMIN_PAGE ); do_settings_sections( LBRY_ADMIN_PAGE );
submit_button(); submit_button();
} elseif ( $lbry_active_tab == 'channels' ) { } elseif ( $lbry_active_tab == 'channels' ) {
include_once( 'partials/channel-page.php' ); include_once( 'channels-page.php' );
} elseif ( $lbry_active_tab == 'speech' ) { } elseif ( $lbry_active_tab == 'speech' ) {
settings_fields( LBRY_SPEECH_SETTINGS ); settings_fields( LBRY_SPEECH_SETTINGS );
do_settings_sections( 'lbrypress-speech' ); do_settings_sections( 'lbrypress-speech' );

View file

@ -4,7 +4,7 @@ defined('ABSPATH') || die(); // Exit if accessed directly
$url = get_post_meta(get_the_id(), LBRY_CANONICAL_URL, true); $url = get_post_meta(get_the_id(), LBRY_CANONICAL_URL, true);
if (!$url) { if (!$url) {
// Get channel canonical for backwards compatibility // Get channel canonical for backwards compatibility
$channel_id = get_post_meta(get_the_id(), LBRY_POST_CHANNEL, true); $channel_id = ( get_post_meta( get_the_id(), LBRY_POST_PUB_CHANNEL, true ) ? get_post_meta( get_the_id(), LBRY_POST_PUB_CHANNEL, true ) : get_post_meta( get_the_id(), '_lbry_channel', true ) );
$url = LBRY()->daemon->canonical_url($channel_id); $url = LBRY()->daemon->canonical_url($channel_id);
} }