From 1795b57a1fc73b42bb3bff8ed52e253324843b3d Mon Sep 17 00:00:00 2001 From: Lem Smyth Date: Wed, 9 Feb 2022 06:09:27 -0600 Subject: [PATCH 01/11] gitignore rm vscode --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 70d3e4c..835c159 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ !*.* .DS_Store +.vscode/* tmp/* logs/* From 39170a3262cd92ce25f26f947410ca2eb076b434 Mon Sep 17 00:00:00 2001 From: Lem Smyth Date: Wed, 9 Feb 2022 07:13:33 -0600 Subject: [PATCH 02/11] structure for tabbed admin --- classes/LBRY_Admin.php | 16 +++++++++++----- templates/{options_page.php => options-page.php} | 0 2 files changed, 11 insertions(+), 5 deletions(-) rename templates/{options_page.php => options-page.php} (100%) diff --git a/classes/LBRY_Admin.php b/classes/LBRY_Admin.php index 23c5303..a715bf4 100644 --- a/classes/LBRY_Admin.php +++ b/classes/LBRY_Admin.php @@ -41,13 +41,17 @@ class LBRY_Admin public function page_init() { // Register the LBRY Setting array - register_setting(LBRY_SETTINGS_GROUP, LBRY_SETTINGS, array('sanitize_callback' => array($this, 'sanitize'))); + register_setting( + LBRY_SETTINGS_GROUP, + LBRY_SETTINGS, + array( $this, 'sanitize_general_settings' ) + ); // Add Required Settings Sections add_settings_section( LBRY_SETTINGS_SECTION_GENERAL, // ID 'General Settings', // Title - array( $this, 'general_section_info' ), // Callback + array( $this, 'general_section_callback' ), // Callback LBRY_ADMIN_PAGE // Page ); @@ -108,14 +112,16 @@ class LBRY_Admin { // Set class property to be referenced in callbacks $this->options = get_option(LBRY_SETTINGS); - require_once(LBRY_ABSPATH . 'templates/options_page.php'); + require_once( LBRY_ABSPATH . 'templates/options-page.php' ); } + /** * Sanitizes setting input * // COMBAK Potentially sanitize more */ - public function sanitize($input) + + public function sanitize_general_settings( $input ) { if (!empty($input[LBRY_SPEECH_CHANNEL])) { $channel = $input[LBRY_SPEECH_CHANNEL]; @@ -139,7 +145,7 @@ class LBRY_Admin /** * Section info for the General Section */ - public function general_section_info() + public function general_section_callback() { print 'This is where you can configure how LBRYPress will distribute your content:'; } diff --git a/templates/options_page.php b/templates/options-page.php similarity index 100% rename from templates/options_page.php rename to templates/options-page.php From c89405bbd409f7ce777a830552a8e248a66a6a1b Mon Sep 17 00:00:00 2001 From: Lem Smyth Date: Wed, 9 Feb 2022 07:30:41 -0600 Subject: [PATCH 03/11] options-page rewrite --- templates/options-page.php | 86 +++++++++++++++++++------------------- 1 file changed, 42 insertions(+), 44 deletions(-) diff --git a/templates/options-page.php b/templates/options-page.php index a8cf308..23058ce 100644 --- a/templates/options-page.php +++ b/templates/options-page.php @@ -1,52 +1,50 @@ daemon->wallet_balance(); $available_balance = $wallet_balance->result->available; +$lbry_active_tab = isset( $_GET['tab'] ) ? $_GET['tab'] : 'general'; $channel_list = $LBRY->daemon->channel_list(); // TODO: Make this page look cleaner ?> +
-

-

Your wallet amount:

- -
- -
-

Your Publishable Channels

- -
    - -
  • name ?>
  • - -
- -

Looks like you haven't added any channels yet, feel free to do so below:

- -

Add a new channel to publish to:

-
- - - - - - - - - - - - - -
New Channel Name - @ - -
Amount of LBC to Bid - -
- -
-
+

+ +

Wallet Available Balance

+ + +
+ +
+ + From e894c3b6fc24293a4883c7f79bafddff5f95c231 Mon Sep 17 00:00:00 2001 From: Lem Smyth Date: Wed, 9 Feb 2022 07:44:27 -0600 Subject: [PATCH 04/11] comment out unused include --- templates/options-page.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/options-page.php b/templates/options-page.php index 23058ce..25437e7 100644 --- a/templates/options-page.php +++ b/templates/options-page.php @@ -23,7 +23,7 @@ $channel_list = $LBRY->daemon->channel_list();
@@ -34,7 +34,7 @@ $channel_list = $LBRY->daemon->channel_list(); do_settings_sections( LBRY_ADMIN_PAGE ); submit_button(); } elseif ( $lbry_active_tab == 'channels' ) { - include_once( 'partials/channel-page.php' ); +// include_once( 'partials/channel-page.php' ); } elseif ( $lbry_active_tab == 'speech' ) { settings_fields( LBRY_SPEECH_SETTINGS ); do_settings_sections( 'lbrypress-speech' ); From 6657c8281a11a6bfbf7537ae3a5091cf457ef3fc Mon Sep 17 00:00:00 2001 From: Lem Smyth Date: Wed, 9 Feb 2022 07:49:36 -0600 Subject: [PATCH 05/11] define LBRY_SPEECH_SETTINGS --- classes/LBRYPress.php | 1 + 1 file changed, 1 insertion(+) diff --git a/classes/LBRYPress.php b/classes/LBRYPress.php index 02cb819..8feb5d8 100644 --- a/classes/LBRYPress.php +++ b/classes/LBRYPress.php @@ -112,6 +112,7 @@ class LBRYPress $this->define('LBRY_SETTINGS_SECTION_GENERAL', 'lbry_settings_section_general'); $this->define('LBRY_ADMIN_PAGE', 'lbrypress'); $this->define('LBRY_WALLET', 'lbry_wallet'); // the wallet address + $this->define('LBRY_SPEECH_SETTINGS', 'lbry_speech_settings'); $this->define('LBRY_SPEECH', 'lbry_speech'); // the spee.ch address $this->define('LBRY_SPEECH_CHANNEL', 'lbry_speech_channel'); // The spee.ch channel $this->define('LBRY_SPEECH_PW', 'lbry_speech_pw'); // The password for the spee.ch channel From 9b6e6bd7f174309327922260ab24409c79ad2e52 Mon Sep 17 00:00:00 2001 From: Lem Smyth Date: Wed, 9 Feb 2022 07:59:26 -0600 Subject: [PATCH 06/11] rm inline style enqueue admin stylesheet --- admin/css/lbry-admin.css | 10 ++++++++++ classes/LBRY_Admin.php | 17 ++++++++++++++++- templates/options-page.php | 7 +++---- 3 files changed, 29 insertions(+), 5 deletions(-) create mode 100644 admin/css/lbry-admin.css diff --git a/admin/css/lbry-admin.css b/admin/css/lbry-admin.css new file mode 100644 index 0000000..7b261b6 --- /dev/null +++ b/admin/css/lbry-admin.css @@ -0,0 +1,10 @@ +/** + * Stylesheet for the admin options page + * @package LBRYPress + */ + + .wallet-icon-lbc { + height: 1.8em; + margin-right: .5em; + margin-bottom: -.5em; + } \ No newline at end of file diff --git a/classes/LBRY_Admin.php b/classes/LBRY_Admin.php index a715bf4..0e02a9c 100644 --- a/classes/LBRY_Admin.php +++ b/classes/LBRY_Admin.php @@ -25,7 +25,7 @@ class LBRY_Admin */ public function create_options_page() { - add_menu_page( + $hook_suffix = add_menu_page( __('LBRYPress Settings', 'lbrypress'), __('LBRYPress', 'lbrypress'), 'manage_options', @@ -33,6 +33,21 @@ class LBRY_Admin array($this, 'options_page_html'), plugin_dir_url(LBRY_PLUGIN_FILE) . '/admin/images/lbry-logo.svg' ); + + // Admin stylesheet enqueue + function load_admin_stylesheet( $hook ) { + + if ( ( $_GET['page'] == 'lbrypress' ) ) { + wp_enqueue_style( + 'lbry-admin', + plugins_url( '/admin/css/lbry-admin.css', LBRY_PLUGIN_FILE ), + array(), + LBRY_VERSION, + 'all' + ); + } + } + add_action( 'admin_enqueue_scripts', 'load_admin_stylesheet' ); } /** diff --git a/templates/options-page.php b/templates/options-page.php index 25437e7..20c5ffc 100644 --- a/templates/options-page.php +++ b/templates/options-page.php @@ -10,20 +10,19 @@ $wallet_balance = $LBRY->daemon->wallet_balance(); $available_balance = $wallet_balance->result->available; $lbry_active_tab = isset( $_GET['tab'] ) ? $_GET['tab'] : 'general'; $channel_list = $LBRY->daemon->channel_list(); -// TODO: Make this page look cleaner ?>

-

Wallet Available Balance

+

Wallet Available Balance

@@ -34,7 +33,7 @@ $channel_list = $LBRY->daemon->channel_list(); do_settings_sections( LBRY_ADMIN_PAGE ); submit_button(); } elseif ( $lbry_active_tab == 'channels' ) { -// include_once( 'partials/channel-page.php' ); + include_once( 'partials/channel-page.php' ); } elseif ( $lbry_active_tab == 'speech' ) { settings_fields( LBRY_SPEECH_SETTINGS ); do_settings_sections( 'lbrypress-speech' ); From 33fb30ccc91d7f006d671471971b38d2df17b341 Mon Sep 17 00:00:00 2001 From: Lem Smyth Date: Wed, 9 Feb 2022 09:04:03 -0600 Subject: [PATCH 07/11] Print the speech tab inputs --- classes/LBRYPress.php | 12 ++- classes/LBRY_Admin.php | 175 ++++++++++++++++++++++++++-------------- classes/LBRY_Speech.php | 6 +- 3 files changed, 127 insertions(+), 66 deletions(-) diff --git a/classes/LBRYPress.php b/classes/LBRYPress.php index 8feb5d8..4e80554 100644 --- a/classes/LBRYPress.php +++ b/classes/LBRYPress.php @@ -183,7 +183,7 @@ class LBRYPress // Default options $option_defaults = array( - LBRY_SPEECH => null, + LBRY_LICENSE => $this->licenses[0], LBRY_LBC_PUBLISH => 1 ); @@ -191,6 +191,16 @@ class LBRYPress add_option(LBRY_SETTINGS, $option_defaults, false); } + if ( ! get_option( LBRY_SPEECH_SETTINGS ) ) { + // Default Speech Settings + $option_defaults = array( + LBRY_SPEECH =>'', + LBRY_SPEECH_CHANNEL => '', + LBRY_SPEECH_PW => '', + ); + add_option( LBRY_SPEECH_SETTINGS, $option_defaults, false ); + } + // COMBAK: decide if we need to check for missing or corrupt settings. May be unecessary. // Double check we have all settings, if not, update with default // $current_settings = get_option(LBRY_SETTINGS); diff --git a/classes/LBRY_Admin.php b/classes/LBRY_Admin.php index 0e02a9c..56e3033 100644 --- a/classes/LBRY_Admin.php +++ b/classes/LBRY_Admin.php @@ -79,30 +79,6 @@ class LBRY_Admin LBRY_SETTINGS_SECTION_GENERAL ); - add_settings_field( - LBRY_SPEECH, - 'Spee.ch URL', - array( $this, 'speech_callback' ), - LBRY_ADMIN_PAGE, - LBRY_SETTINGS_SECTION_GENERAL - ); - - add_settings_field( - LBRY_SPEECH_CHANNEL, - 'Spee.ch Channel', - array( $this, 'speech_channel_callback' ), - LBRY_ADMIN_PAGE, - LBRY_SETTINGS_SECTION_GENERAL - ); - - add_settings_field( - LBRY_SPEECH_PW, - 'Spee.ch Password', - array( $this, 'speech_pw_callback' ), - LBRY_ADMIN_PAGE, - LBRY_SETTINGS_SECTION_GENERAL - ); - add_settings_field( LBRY_LICENSE, 'LBRY Publishing License', @@ -118,6 +94,47 @@ class LBRY_Admin LBRY_ADMIN_PAGE, LBRY_SETTINGS_SECTION_GENERAL ); + + /** + * Speech Admin Page settings + */ + + register_setting( + LBRY_SPEECH_SETTINGS, + LBRY_SPEECH_SETTINGS, + array( $this, 'sanitize_speech_settings' ) + ); + + add_settings_section( + 'lbry_settings_section_speech', // ID + 'Spee.ch Channel Settings', // Title + array( $this, 'speech_section_callback' ), // Callback + 'lbrypress-speech' // Page + ); + + add_settings_field( + LBRY_SPEECH, + 'Spee.ch URL', + array( $this, 'speech_callback' ), + 'lbrypress-speech', + 'lbry_settings_section_speech' + ); + + add_settings_field( + LBRY_SPEECH_CHANNEL, + 'Spee.ch Channel', + array( $this, 'speech_channel_callback' ), + 'lbrypress-speech', + 'lbry_settings_section_speech' + ); + + add_settings_field( + LBRY_SPEECH_PW, + 'Spee.ch Password', + array( $this, 'speech_pw_callback' ), + 'lbrypress-speech', + 'lbry_settings_section_speech' + ); } /** @@ -153,10 +170,33 @@ class LBRY_Admin $input[LBRY_SPEECH_PW] = get_option(LBRY_SETTINGS)[LBRY_SPEECH_PW]; } } - return $input; } + public function sanitize_speech_settings( $input ) + { + $new_input = get_option( LBRY_SPEECH_SETTINGS ); + if ( isset( $input[LBRY_SPEECH] ) ) { + $new_input[LBRY_SPEECH] = sanitize_text_field( $input[LBRY_SPEECH] ); + } + if ( isset( $input[LBRY_SPEECH_CHANNEL] ) ) { + $channel = $input[LBRY_SPEECH_CHANNEL]; + $channel = str_replace( '@', '', $channel ); + $new_input[LBRY_SPEECH_CHANNEL] = sanitize_user( $channel ); + } + if ( isset( $input[LBRY_SPEECH_PW] ) ) { + $input[LBRY_SPEECH_PW] = sanitize_text_field( $input[LBRY_SPEECH_PW] ); + $encrypted = $this->encrypt( $input[LBRY_SPEECH_PW] ); + $new_input[LBRY_SPEECH_PW] = $encrypted; + } else { + // If we have a password and it's empty, keep original password + if ( empty( $input[LBRY_SPEECH_PW] ) ) + $new_input[LBRY_SPEECH_PW] = get_option( LBRY_SPEECH_SETTINGS[LBRY_SPEECH_PW] ); + } + return $new_input; + update_option( LBRY_SPEECH_SETTINGS, $new_input ); + } + /** * Section info for the General Section */ @@ -164,6 +204,13 @@ class LBRY_Admin { print 'This is where you can configure how LBRYPress will distribute your content:'; } +/** + * Section info for the Speech Channel Section + */ + public function speech_section_callback() + { + print 'If you have a Spee.ch account, you can enter your account details here, if you don\'t already have a Spee.ch account, no need to enter anything here.'; + } /** * Prints Wallet input @@ -181,43 +228,6 @@ class LBRY_Admin ); } - /** - * Prints Spee.ch input - */ - public function speech_callback() - { - printf( - '', - LBRY_SPEECH, - LBRY_SETTINGS, - isset($this->options[LBRY_SPEECH]) ? esc_attr($this->options[LBRY_SPEECH]) : '' - ); - } - - /** - * Prints Spee.ch channel input - */ - public function speech_channel_callback() - { - printf( - '@', - LBRY_SPEECH_CHANNEL, - LBRY_SETTINGS, - isset($this->options[LBRY_SPEECH_CHANNEL]) ? esc_attr($this->options[LBRY_SPEECH_CHANNEL]) : '' - ); - } - - /** - * Prints Spee.ch password input - */ - public function speech_pw_callback() - { - printf( - '', + LBRY_SPEECH, + LBRY_SPEECH_SETTINGS, + isset( $options[LBRY_SPEECH] ) ? $options[LBRY_SPEECH] : '', + ); + } + + /** + * Prints Spee.ch channel input + */ + public function speech_channel_callback() + { + $options = get_option( LBRY_SPEECH_SETTINGS ); + printf( + '', + LBRY_SPEECH_CHANNEL, + LBRY_SPEECH_SETTINGS, + isset( $options[LBRY_SPEECH_CHANNEL] ) ? $options[LBRY_SPEECH_CHANNEL] : '', + ); + } + + /** + * Prints Spee.ch password input + */ + public function speech_pw_callback() + { + printf( + '', + LBRY_SPEECH_PW, + LBRY_SPEECH_SETTINGS, + ); + } + + /** * Handles new channel form submission */ diff --git a/classes/LBRY_Speech.php b/classes/LBRY_Speech.php index 665448d..64b3d33 100644 --- a/classes/LBRY_Speech.php +++ b/classes/LBRY_Speech.php @@ -43,7 +43,7 @@ class LBRY_Speech return false; } - $speech_url = get_option(LBRY_SETTINGS)[LBRY_SPEECH]; + $speech_url = get_option(LBRY_SPEECH_SETTINGS)[LBRY_SPEECH]; // Die if we don't have a spee.ch url if (!$speech_url || $speech_url === '') { @@ -66,7 +66,7 @@ class LBRY_Speech ); // Pull Channel and Password from config file for now - $speech_channel = get_option(LBRY_SETTINGS)[LBRY_SPEECH_CHANNEL]; + $speech_channel = get_option(LBRY_SPEECH_SETTINGS)[LBRY_SPEECH_CHANNEL]; $speech_pw = LBRY()->admin->get_speech_pw(); if (!empty($speech_channel) && !empty($speech_pw)) { $params['channelName'] = '@' . $speech_channel; @@ -229,7 +229,7 @@ class LBRY_Speech */ private function build_request($method, $params = array()) { - $speech_url = get_option(LBRY_SETTINGS)[LBRY_SPEECH]; + $speech_url = get_option(LBRY_SPEECH_SETTINGS)[LBRY_SPEECH]; // Die if no URL if (!$speech_url) { From 1226273a11c34ba9f453c881ad316c5c89c99bba Mon Sep 17 00:00:00 2001 From: Lem Smyth Date: Wed, 9 Feb 2022 10:17:45 -0600 Subject: [PATCH 08/11] build channel-tab --- admin/css/lbry-admin.css | 7 +++- classes/LBRYPress.php | 2 + classes/LBRY_Admin.php | 78 +++++++++++++++++++++++++++++-------- classes/LBRY_Daemon.php | 7 +++- templates/channels-page.php | 71 +++++++++++++++++++++++++++++++++ templates/options-page.php | 4 +- 6 files changed, 148 insertions(+), 21 deletions(-) create mode 100644 templates/channels-page.php diff --git a/admin/css/lbry-admin.css b/admin/css/lbry-admin.css index 7b261b6..c69f6ed 100644 --- a/admin/css/lbry-admin.css +++ b/admin/css/lbry-admin.css @@ -7,4 +7,9 @@ height: 1.8em; margin-right: .5em; margin-bottom: -.5em; - } \ No newline at end of file + } + + .bid-icon-lbc { + height: 1.2em; + margin-bottom: -.2em; + } diff --git a/classes/LBRYPress.php b/classes/LBRYPress.php index 4e80554..95113b7 100644 --- a/classes/LBRYPress.php +++ b/classes/LBRYPress.php @@ -120,6 +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_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 56e3033..826d8c7 100644 --- a/classes/LBRY_Admin.php +++ b/classes/LBRY_Admin.php @@ -95,6 +95,14 @@ class LBRY_Admin LBRY_SETTINGS_SECTION_GENERAL ); + /** + * Channel Page Settings + * We are using a custom page so that we can use the admin-post action and retrieve the $_POST + * global variable to populate the cURL request to create_channel, not saving the inputs to + * our database. + */ + + /** * Speech Admin Page settings */ @@ -204,6 +212,26 @@ class LBRY_Admin { print 'This is where you can configure how LBRYPress will distribute your content:'; } + + /** + * Section info for the Available Channel(s) Section + */ + public function available_channels_callback() + { + $channel_list = LBRY()->daemon->channel_list(); + + if ( $channel_list ) { ?> +
    + +
  • name ) ?>
  • + +
+ +

Looks like you haven't added any channels yet, feel free to do so below:

+ 'lbrypress', 'tab' => 'channels' ), 'options.php' ) ); + // Check that nonce - if (! isset($_POST['_lbrynonce']) || ! wp_verify_nonce($_POST['_lbrynonce'], 'lbry_add_channel')) { - LBRY()->notice->set_notice('error'); - } elseif (! isset($_POST['new_channel']) || ! isset($_POST['bid_amount'])) { - LBRY()->notice->set_notice('error', 'Must supply both channel name and bid amount'); - } else { - $new_channel = $_POST['new_channel']; - $bid_amount = $_POST['bid_amount']; + if ( isset( $_POST['_lbrynonce'] ) && wp_verify_nonce( $_POST['_lbrynonce'], 'add_channel_nonce' ) ) { + if ( empty( $_POST['lbry_new_channel'] ) || empty( $_POST['lbry_channel_bid_amount'] ) ) { + LBRY()->notice->set_notice( 'error', 'Must supply both channel name and bid amount' ); + } elseif ( isset( $_POST['lbry_new_channel'] ) && isset( $_POST['lbry_channel_bid_amount'] ) ) { + $channel = $_POST['lbry_new_channel']; // TODO: sanitize key() only allows for lowercase chars, dashes, and underscores. maybe remove to allow more characters? and use something else for better control? + $channel = trim( $channel ); + $channel = str_replace( '@', '', $channel ); + $channel = str_replace( ' ', '-', $channel ); + $channel = str_replace( '_', '-', $channel ); + $channel_name = sanitize_user( $channel ); - // Try to add the new channel - try { - $result = LBRY()->daemon->channel_new($new_channel, $bid_amount); - // Tell the user it takes some time to go through - LBRY()->notice->set_notice('success', 'Successfully added a new channel! Please wait a few minutes for the bid to process.', true); - } catch (\Exception $e) { - LBRY()->notice->set_notice('error', $e->getMessage(), false); + $bid = $_POST['lbry_channel_bid_amount']; + $channel_bid = number_format( floatval( $bid ), 3, '.', '' ); + + // Try to add the new channel + try { + $result = LBRY()->daemon->channel_new( $channel_name, $channel_bid ); + // Tell the user it takes some time to go through + LBRY()->notice->set_notice( + 'success', 'Successfully added a new channel: @' . esc_html( $channel_name ) . '! Please allow a few minutes for the bid to process.', true ); + + } catch ( \Exception $e ) { + LBRY()->notice->set_notice( 'error', $e->getMessage(), false ); + } } + } else { + LBRY()->notice->set_notice('error', 'Security check failed' ); + die( __( 'Security check failed', 'lbrypress' ) ); } - wp_safe_redirect($redirect_url); + wp_safe_redirect( $redirect_url ); exit(); } diff --git a/classes/LBRY_Daemon.php b/classes/LBRY_Daemon.php index 94c0a26..4cde53d 100644 --- a/classes/LBRY_Daemon.php +++ b/classes/LBRY_Daemon.php @@ -114,7 +114,7 @@ class LBRY_Daemon * https://lbry.tech/api/sdk#channel_create * @return array dictionary containing result of the request */ - public function channel_new($channel_name, $bid_amount) + public function channel_new($channel_name, $channel_bid) { // TODO: Sanitize channel name and bid // Make sure no @ sign, as we will add that @@ -134,10 +134,13 @@ class LBRY_Daemon 'channel_create', array( 'name' => $channel_name, - 'bid' => number_format(floatval($bid_amount), 2, '.', '') + 'bid' => $channel_bid ) ); + + $this->logger->log( 'channel_create success!', 'Successfully created channel with result: ' . print_r( $result->result, true ) ); return $result->result; + } catch (LBRYDaemonException $e) { $this->logger->log('channel_new error', $e->getMessage() . ' | Code: ' . $e->getCode()); throw new \Exception('Issue creating new channel.', 1); diff --git a/templates/channels-page.php b/templates/channels-page.php new file mode 100644 index 0000000..db5b1ac --- /dev/null +++ b/templates/channels-page.php @@ -0,0 +1,71 @@ + + +

+ admin->available_channels_callback(); ?> + + + + + + +

+ + + + + + + + + + + + +

+ + +

plugin_name ) ?>

+daemon->channel_list();
@@ -33,7 +33,7 @@ $channel_list = $LBRY->daemon->channel_list(); do_settings_sections( LBRY_ADMIN_PAGE ); submit_button(); } elseif ( $lbry_active_tab == 'channels' ) { - include_once( 'partials/channel-page.php' ); + include_once( 'channels-page.php' ); } elseif ( $lbry_active_tab == 'speech' ) { settings_fields( LBRY_SPEECH_SETTINGS ); do_settings_sections( 'lbrypress-speech' ); From 06fed9faf9f197340828fe4d9ee5c1e47079b909 Mon Sep 17 00:00:00 2001 From: Lem Smyth Date: Sat, 12 Feb 2022 13:20:25 -0600 Subject: [PATCH 09/11] rm duplicate function calls --- classes/LBRY_Admin.php | 52 ++---------------------------------------- 1 file changed, 2 insertions(+), 50 deletions(-) diff --git a/classes/LBRY_Admin.php b/classes/LBRY_Admin.php index 92d0f58..91adc83 100644 --- a/classes/LBRY_Admin.php +++ b/classes/LBRY_Admin.php @@ -213,7 +213,7 @@ class LBRY_Admin { print 'This is where you can configure how LBRYPress will distribute your content:'; } -/** + /** * Section info for the Speech Channel Section */ public function speech_section_callback() @@ -239,14 +239,6 @@ class LBRY_Admin ', - LBRY_SPEECH, - LBRY_SPEECH_SETTINGS, - isset( $options[LBRY_SPEECH] ) ? $options[LBRY_SPEECH] : '', - ); - } - - /** - * Prints Spee.ch channel input - */ - public function speech_channel_callback() - { - $options = get_option( LBRY_SPEECH_SETTINGS ); - printf( - '', - LBRY_SPEECH_CHANNEL, - LBRY_SPEECH_SETTINGS, - isset( $options[LBRY_SPEECH_CHANNEL] ) ? $options[LBRY_SPEECH_CHANNEL] : '', - ); - } - - /** - * Prints Spee.ch password input - */ - public function speech_pw_callback() - { - printf( - '', - LBRY_SPEECH_PW, - LBRY_SPEECH_SETTINGS, - ); - } - /** * Channels Page * Channels page uses admin.php so we are able to use the admin-post action instead of options.php */ - /** + /** * Prints Spee.ch input */ public function speech_callback() From f35484d13e555e42b0ea9f4b35a9eafa1691e381 Mon Sep 17 00:00:00 2001 From: Lem Smyth Date: Sat, 12 Feb 2022 13:30:08 -0600 Subject: [PATCH 10/11] rm unused hook mv options page call --- classes/LBRY_Admin.php | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/classes/LBRY_Admin.php b/classes/LBRY_Admin.php index 91adc83..3952e3b 100644 --- a/classes/LBRY_Admin.php +++ b/classes/LBRY_Admin.php @@ -25,7 +25,7 @@ class LBRY_Admin */ public function create_options_page() { - $hook_suffix = add_menu_page( + add_menu_page( __('LBRYPress Settings', 'lbrypress'), __('LBRYPress', 'lbrypress'), 'manage_options', @@ -50,6 +50,17 @@ class LBRY_Admin add_action( 'admin_enqueue_scripts', 'load_admin_stylesheet' ); } + /** + * Returns the Options Page HTML for the plugin + */ + public function options_page_html() + { + // Set class properties to be referenced in callbacks + $this->options = get_option( LBRY_SETTINGS ); + $this->options_speech = get_option( LBRY_SPEECH_SETTINGS ); + require_once( LBRY_ABSPATH . 'templates/options-page.php' ); + } + /** * Registers all settings for the plugin */ @@ -146,17 +157,6 @@ class LBRY_Admin ); } - /** - * Returns the Options Page HTML for the plugin - */ - public function options_page_html() - { - // Set class property to be referenced in callbacks - $this->options = get_option(LBRY_SETTINGS); - require_once( LBRY_ABSPATH . 'templates/options-page.php' ); - } - - /** * Sanitizes setting input * // COMBAK Potentially sanitize more @@ -341,7 +341,6 @@ class LBRY_Admin ); } - /** * Handles new channel form submission */ From 87a0c132fa97e7f21ae46db68543bbc599ba62c0 Mon Sep 17 00:00:00 2001 From: Lem Smyth Date: Sat, 12 Feb 2022 13:55:16 -0600 Subject: [PATCH 11/11] rm unused hook mv options page call --- classes/LBRY_Admin.php | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/classes/LBRY_Admin.php b/classes/LBRY_Admin.php index 91adc83..3952e3b 100644 --- a/classes/LBRY_Admin.php +++ b/classes/LBRY_Admin.php @@ -25,7 +25,7 @@ class LBRY_Admin */ public function create_options_page() { - $hook_suffix = add_menu_page( + add_menu_page( __('LBRYPress Settings', 'lbrypress'), __('LBRYPress', 'lbrypress'), 'manage_options', @@ -50,6 +50,17 @@ class LBRY_Admin add_action( 'admin_enqueue_scripts', 'load_admin_stylesheet' ); } + /** + * Returns the Options Page HTML for the plugin + */ + public function options_page_html() + { + // Set class properties to be referenced in callbacks + $this->options = get_option( LBRY_SETTINGS ); + $this->options_speech = get_option( LBRY_SPEECH_SETTINGS ); + require_once( LBRY_ABSPATH . 'templates/options-page.php' ); + } + /** * Registers all settings for the plugin */ @@ -146,17 +157,6 @@ class LBRY_Admin ); } - /** - * Returns the Options Page HTML for the plugin - */ - public function options_page_html() - { - // Set class property to be referenced in callbacks - $this->options = get_option(LBRY_SETTINGS); - require_once( LBRY_ABSPATH . 'templates/options-page.php' ); - } - - /** * Sanitizes setting input * // COMBAK Potentially sanitize more @@ -341,7 +341,6 @@ class LBRY_Admin ); } - /** * Handles new channel form submission */