From d8cc3ff96fdf28e0d154a81830321c9aa876cfa0 Mon Sep 17 00:00:00 2001 From: Lem Smyth Date: Sat, 12 Feb 2022 17:26:37 -0600 Subject: [PATCH] creates and prints the meta box --- classes/LBRYPress.php | 4 +-- classes/LBRY_Admin.php | 2 +- classes/LBRY_Network.php | 8 ++--- templates/meta-box.php | 69 ++++++++++++++++++++++++++++++++++++++++ templates/meta_box.php | 42 ------------------------ 5 files changed, 76 insertions(+), 49 deletions(-) create mode 100644 templates/meta-box.php delete mode 100644 templates/meta_box.php diff --git a/classes/LBRYPress.php b/classes/LBRYPress.php index 21706fd..89369d0 100644 --- a/classes/LBRYPress.php +++ b/classes/LBRYPress.php @@ -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 diff --git a/classes/LBRY_Admin.php b/classes/LBRY_Admin.php index 93550c3..1aa235f 100644 --- a/classes/LBRY_Admin.php +++ b/classes/LBRY_Admin.php @@ -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 ), diff --git a/classes/LBRY_Network.php b/classes/LBRY_Network.php index 4b4de01..5d88d04 100644 --- a/classes/LBRY_Network.php +++ b/classes/LBRY_Network.php @@ -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' ); } } diff --git a/templates/meta-box.php b/templates/meta-box.php new file mode 100644 index 0000000..0bf75c8 --- /dev/null +++ b/templates/meta-box.php @@ -0,0 +1,69 @@ + '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' ) ); +?> + +
+ +
$channel ) { + $options .= ''; + } + printf( + '', + LBRY_POST_PUB_CHANNEL, + $options + ); + } ?> +
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 .= '
diff --git a/templates/meta_box.php b/templates/meta_box.php deleted file mode 100644 index 336469f..0000000 --- a/templates/meta_box.php +++ /dev/null @@ -1,42 +0,0 @@ - '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); -?> - -
- -
-