From 3e68befdc128dda8b371d86cf5c5ced4f247e8a4 Mon Sep 17 00:00:00 2001 From: Lemuel Smyth <36257395+lemsmyth@users.noreply.github.com> Date: Sun, 13 Feb 2022 10:39:42 -0600 Subject: [PATCH] Default license selector (#51) * default license select option * default channel selector --- classes/LBRY_Admin.php | 44 +++++++++++++++++++++++++++++++++++++--- classes/LBRY_Network.php | 8 +++++--- 2 files changed, 46 insertions(+), 6 deletions(-) diff --git a/classes/LBRY_Admin.php b/classes/LBRY_Admin.php index 8578b91..7cb8b03 100644 --- a/classes/LBRY_Admin.php +++ b/classes/LBRY_Admin.php @@ -68,7 +68,7 @@ class LBRY_Admin { // Register the LBRY Setting array register_setting( - LBRY_SETTINGS_GROUP, + 'lbry_general_settings', LBRY_SETTINGS, array( $this, 'sanitize_general_settings' ) ); @@ -90,6 +90,13 @@ class LBRY_Admin LBRY_SETTINGS_SECTION_GENERAL ); + add_settings_field( + 'default_lbry_channel', + 'Default Publish Channel', + array( $this, 'default_channel_callback' ), + LBRY_ADMIN_PAGE, + LBRY_SETTINGS_SECTION_GENERAL + ); add_settings_field( LBRY_LICENSE, 'LBRY Publishing License', @@ -115,7 +122,6 @@ class LBRY_Admin /** - * Speech Admin Page settings */ @@ -255,6 +261,37 @@ class LBRY_Admin ); } + /** + * Prints select to choose a default to publish to channel + */ + public function default_channel_callback() + { + $options = ''; + $channel_list = LBRY()->daemon->channel_list(); + + if ( $channel_list ) { + foreach ( $channel_list as $channel ) { + $selected = $this->options['default_lbry_channel'] === $channel->claim_id; + + $options .= ''; + } + + printf( + '', + 'default_lbry_channel', + LBRY_SETTINGS, + $options + ); + } else { ?> +
Looks like you haven't added any channels yet, you can do that now on the Channels Tab
+ %3$s', + '', LBRY_LICENSE, LBRY_SETTINGS, $options ); } + /** * Prints LBC per publish input */ diff --git a/classes/LBRY_Network.php b/classes/LBRY_Network.php index a32db37..4b4de01 100644 --- a/classes/LBRY_Network.php +++ b/classes/LBRY_Network.php @@ -79,9 +79,11 @@ class LBRY_Network return $post_id; } - $will_publish = (isset($_POST[LBRY_WILL_PUBLISH]) ? $_POST[LBRY_WILL_PUBLISH] : false); - $new_channel = (isset($_POST[LBRY_POST_CHANNEL]) ? $_POST[LBRY_POST_CHANNEL] : null); - $cur_channel = get_post_meta($post_id, LBRY_POST_CHANNEL, true); + $channel = $_POST[LBRY_POST_PUB_CHANNEL]; + $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]; + $cur_license = get_post_meta( $post_id, LBRY_POST_PUB_LICENSE, true ); + $will_publish = $_POST[LBRY_WILL_PUBLISH]; // Update meta acordingly if (!$will_publish) {