README update use local images #62
5 changed files with 76 additions and 49 deletions
|
@ -120,8 +120,8 @@ class LBRYPress
|
|||
$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_POST_CHANNEL', '_lbry_channel'); // The meta key for which channel to publish
|
||||
$this->define('LBRY_POST_PUB_CHANNEL', '_lbry_post_pub_channel'); // The meta key for which channel to publish
|
||||
$this->define('LBRY_POST_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_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
|
||||
|
|
|
@ -37,7 +37,7 @@ class LBRY_Admin
|
|||
// Admin stylesheet enqueue
|
||||
function load_admin_stylesheet( $hook ) {
|
||||
|
||||
if ( ( $_GET['page'] == 'lbrypress' ) ) {
|
||||
if ( ( $hook == 'post.php' ) || ( $hook == 'post-new.php' ) || ( $_GET['page'] == 'lbrypress' ) ) {
|
||||
wp_enqueue_style(
|
||||
'lbry-admin',
|
||||
plugins_url( '/admin/css/lbry-admin.css', LBRY_PLUGIN_FILE ),
|
||||
|
|
|
@ -34,7 +34,7 @@ class LBRY_Network
|
|||
private function post_meta_setup()
|
||||
{
|
||||
// Add the meta boxes
|
||||
add_action('add_meta_boxes', array($this, 'add_meta_boxes'));
|
||||
add_action( 'add_meta_boxes', array( $this, 'lbry_meta_boxes' ) );
|
||||
|
||||
// Save the post meta on 'save_post' hook
|
||||
add_action('wp_insert_post', array($this, 'save_post_meta'), 11, 2);
|
||||
|
@ -43,12 +43,12 @@ class LBRY_Network
|
|||
/**
|
||||
* Adds the meta boxes to the post editing backend
|
||||
*/
|
||||
public function add_meta_boxes()
|
||||
public function lbry_meta_boxes( $post )
|
||||
{
|
||||
// IDEA: Support post types based on user selection
|
||||
add_meta_box(
|
||||
'lbry-network-publishing', // Unique ID
|
||||
'LBRY Network', // Title
|
||||
__('LBRY Network', 'lbrypress'), // Title
|
||||
array($this, 'meta_box_html'), // Callback function
|
||||
'post', // Screen Options (or post type)
|
||||
'side', // Context
|
||||
|
@ -107,6 +107,6 @@ class LBRY_Network
|
|||
*/
|
||||
public function meta_box_html( $post )
|
||||
{
|
||||
require_once(LBRY_ABSPATH . 'templates/meta_box.php');
|
||||
require_once( LBRY_ABSPATH . 'templates/meta-box.php' );
|
||||
}
|
||||
}
|
||||
|
|
69
templates/meta-box.php
Normal file
69
templates/meta-box.php
Normal file
|
@ -0,0 +1,69 @@
|
|||
<?php
|
||||
/**
|
||||
* ============================
|
||||
* META BOX FOR POST PAGE
|
||||
* Prints the post meta box
|
||||
* @package LBRYPress
|
||||
* ============================
|
||||
*/
|
||||
defined('ABSPATH') || die(); // Exit if accessed directly
|
||||
|
||||
$unnatributed = (object) array(
|
||||
'name' => 'none (anonymous)',
|
||||
'claim_id' => 'null'
|
||||
);
|
||||
// Generate a custom nonce
|
||||
$lbrynonce = wp_create_nonce( 'lbry_publish_post_nonce' );
|
||||
|
||||
$channels = LBRY()->daemon->channel_list();
|
||||
$channels[] = $unnatributed;
|
||||
$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 ) );
|
||||
$default_channel = get_option( LBRY_SETTINGS )['default_lbry_channel'];
|
||||
|
||||
// Sort the channels in a natural way
|
||||
usort( $channels, array( 'LBRYPress', 'channel_name_comp' ) );
|
||||
?>
|
||||
|
||||
<section>
|
||||
<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
|
||||
|
||||
$options = '';
|
||||
if ( $channels ) {
|
||||
foreach ( $channels as $index=>$channel ) {
|
||||
$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 ) {
|
||||
$options .= selected( $cur_channel, $channel->claim_id, false );
|
||||
}
|
||||
$options .= '>' . esc_html__( $channel->name, 'lbrypress' ) . '</option>';
|
||||
}
|
||||
printf(
|
||||
'<select id="' . esc_attr('%1$s') . '" name="' . esc_attr('%1$s') . '">' . esc_html('%2$s') . '</select>',
|
||||
LBRY_POST_PUB_CHANNEL,
|
||||
$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
|
||||
$licenses = LBRY()->licenses;
|
||||
$options = '';
|
||||
$default_license = get_option(LBRY_SETTINGS)[LBRY_LICENSE];
|
||||
$cur_license = get_post_meta( $post_id, LBRY_POST_PUB_LICENSE, true );
|
||||
|
||||
// Create options list, select current license
|
||||
if ( $licenses ) {
|
||||
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 ) . '"';
|
||||
if ( ( $cur_license ) ? $cur_license : $cur_license = $default_license ) {
|
||||
$options .= selected( $cur_license, $value, false );
|
||||
}
|
||||
$options .= '>'. esc_html__( $name, 'lbrypress' ) . '</option>';
|
||||
}
|
||||
}
|
||||
printf(
|
||||
'<select class="" id="'.esc_attr('%1$s').'" name="'. esc_attr('%1$s') .'">' . esc_html('%2$s') . '</select>',
|
||||
LBRY_POST_PUB_LICENSE,
|
||||
$options
|
||||
);
|
||||
?>
|
||||
</section>
|
|
@ -1,42 +0,0 @@
|
|||
<?php
|
||||
$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>
|
Loading…
Reference in a new issue