diff --git a/classes/LBRYPress.php b/classes/LBRYPress.php
index 4d9fed2..808cf41 100644
--- a/classes/LBRYPress.php
+++ b/classes/LBRYPress.php
@@ -113,6 +113,8 @@ class LBRYPress
$this->define('LBRY_ADMIN_PAGE', 'lbrypress');
$this->define('LBRY_WALLET', 'lbry_wallet'); // the wallet address
$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
$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_WILL_PUBLISH', '_lbry_will_publish'); // The meta key for if to publish to LBRY Network or not
diff --git a/classes/LBRY_Admin.php b/classes/LBRY_Admin.php
index bde034e..18cdac2 100644
--- a/classes/LBRY_Admin.php
+++ b/classes/LBRY_Admin.php
@@ -40,7 +40,7 @@ class LBRY_Admin
public function page_init()
{
// Register the LBRY Setting array
- register_setting(LBRY_SETTINGS_GROUP, LBRY_SETTINGS, array($this, 'sanitize'));
+ register_setting(LBRY_SETTINGS_GROUP, LBRY_SETTINGS, array('sanitize_callback' => array($this, 'sanitize')));
// Add Required Settings Sections
add_settings_section(
@@ -60,11 +60,27 @@ class LBRY_Admin
);
add_settings_field(
- LBRY_SPEECH, // ID
- 'Spee.ch URL', // Title
- array( $this, 'speech_callback' ), // Callback
- LBRY_ADMIN_PAGE, // Page
- LBRY_SETTINGS_SECTION_GENERAL // Section
+ 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(
@@ -96,10 +112,26 @@ class LBRY_Admin
/**
* Sanitizes setting input
- * // TODO Actually sanitize the input
+ * // COMBAK Potentially sanitize more
*/
public function sanitize($input)
{
+ if (!empty($input[LBRY_SPEECH_CHANNEL])) {
+ $channel = $input[LBRY_SPEECH_CHANNEL];
+ $channel = str_replace('@', '', $channel);
+ $input[LBRY_SPEECH_CHANNEL] = $channel;
+ }
+
+ if (!empty($input[LBRY_SPEECH_PW])) {
+ $encrypted = $this->encrypt($input['lbry_speech_pw']);
+ $input[LBRY_SPEECH_PW] = $encrypted;
+ } else {
+ // If we have a password and its empty, keep orginal password
+ if (!empty(get_option(LBRY_SETTINGS)[LBRY_SPEECH_PW])) {
+ $input[LBRY_SPEECH_PW] = get_option(LBRY_SETTINGS)[LBRY_SPEECH_PW];
+ }
+ }
+
return $input;
}
@@ -140,6 +172,31 @@ class LBRY_Admin
);
}
+ /**
+ * 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(
+ 'decrypt($ciphertext);
+ }
}
diff --git a/classes/LBRY_Speech.php b/classes/LBRY_Speech.php
index 43ebd52..f88929b 100644
--- a/classes/LBRY_Speech.php
+++ b/classes/LBRY_Speech.php
@@ -67,10 +67,14 @@ class LBRY_Speech
);
// Pull Channel and Password from config file for now
- // COMBAK: This will change in the future
- if (LBRY_SPEECH_CHANNEL && LBRY_SPEECH_CHANNEL_PASSWORD) {
- $params['channelName'] = LBRY_SPEECH_CHANNEL;
- $params['channelPassword'] = LBRY_SPEECH_CHANNEL_PASSWORD;
+ $speech_channel = get_option(LBRY_SETTINGS)[LBRY_SPEECH_CHANNEL];
+ $speech_pw = LBRY()->admin->get_speech_pw();
+ if (!empty($speech_channel) && !empty($speech_pw)) {
+ $params['channelName'] = '@' . $speech_channel;
+ $params['channelPassword'] = $speech_pw;
+
+ error_log($params['channelName']);
+ error_log($params['channelPassword']);
}
$ch = $this->build_request('publish', $params);
@@ -160,7 +164,6 @@ class LBRY_Speech
}
}
// Don't forget the featured image
- error_log($post_id);
if ($featured_id = get_post_thumbnail_id($post_id)) {
$image_ids = array_merge($image_ids, array($featured_id));
}
diff --git a/lbry_config.example.php b/lbry_config.example.php
deleted file mode 100644
index cc9afd9..0000000
--- a/lbry_config.example.php
+++ /dev/null
@@ -1,4 +0,0 @@
-