array($this, 'sanitize'))); // Add Required Settings Sections add_settings_section( LBRY_SETTINGS_SECTION_GENERAL, // ID 'General Settings', // Title array( $this, 'general_section_info' ), // Callback LBRY_ADMIN_PAGE // Page ); // Add all settings fields add_settings_field( LBRY_WALLET, 'LBRY Wallet Address', array( $this, 'wallet_callback' ), LBRY_ADMIN_PAGE, 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', array( $this, 'license_callback' ), LBRY_ADMIN_PAGE, LBRY_SETTINGS_SECTION_GENERAL ); add_settings_field( LBRY_LBC_PUBLISH, 'LBC Per Publish', array( $this, 'lbc_publish_callback' ), LBRY_ADMIN_PAGE, LBRY_SETTINGS_SECTION_GENERAL ); } /** * 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 */ 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; } /** * Section info for the General Section */ public function general_section_info() { print 'This is where you can configure how LBRYPress will distribute your content:'; } /** * Prints Wallet input */ public function wallet_callback() { // Get first available account address from Daemon $address = LBRY()->daemon->address_list()->items; $address = is_array($address) && !empty($address) ? $address[0]->address : ''; printf( '', LBRY_WALLET, LBRY_SETTINGS, $address ); } /** * 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( 'licenses as $value => $name) { $selected = $this->options[LBRY_LICENSE] === $value; $options .= '