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 */ public function page_init() { // Register the LBRY Setting array register_setting( 'lbry_general_settings', 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_callback' ), // 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_default_publish_setting', 'Always Publish to LBRY', array( $this, 'lbry_always_pub_callback' ), LBRY_ADMIN_PAGE, 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', 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 ); /** * 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 */ 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' ); } /** * Sanitizes setting input * // COMBAK Potentially sanitize more */ public function sanitize_general_settings( $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; } 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 */ public function general_section_callback() { 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.'; } /** * Section info for the Available Channel(s) Section */ public function available_channels_callback() { $channel_list = LBRY()->daemon->channel_list(); if ( $channel_list ) { ?>

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

daemon->address_list(); $address = is_array( $address ) && ! empty( $address ) ? $address[0]->address : ''; printf( '', LBRY_WALLET, LBRY_SETTINGS, $address ); } /** * Checkbox to default to always allow publish on LBRY */ public function lbry_always_pub_callback() { $options = get_option( LBRY_SETTINGS )['lbry_default_publish_setting']; if ( ! isset( $options ) ) { $options = 0; } $checked = checked( $options, 1, false ); printf( '

Set Default to always Publish to LBRY, this can be adjusted when publishing a New Post.

', 'lbry_default_publish_setting', LBRY_SETTINGS, ); } /** * 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

licenses as $value => $name ) { $selected = $this->options[LBRY_LICENSE] === $value; $options .= '