diff --git a/admin/css/lbry-admin.css b/admin/css/lbry-admin.css index 5fea468..6419836 100644 --- a/admin/css/lbry-admin.css +++ b/admin/css/lbry-admin.css @@ -1,82 +1,47 @@ /** - * Stylesheet for the admin pages LBRYPress uses + * Stylesheet for the admin options page * @package LBRYPress */ -.wallet-icon-lbc { - height: 1.8em; - margin-right: .5em; - margin-bottom: -.5em; -} + .wallet-icon-lbc { + height: 1.8em; + margin-right: .5em; + margin-bottom: -.5em; + } + + .bid-icon-lbc { + height: 1.2em; + margin-bottom: -.2em; + } -.bid-icon-lbc { - height: 1.2em; - margin-bottom: -.2em; -} + .lbry-pub-metabox { + margin: 0 0 0 -.2em; + padding: 0 .2em 0 0 ; + } + .meta-icon-lbry { + height: 1.55em; + margin-bottom: -.4em; + padding-left: .1em; + } + .lbry-meta-checkbox-wrapper { + padding: .5em .8em .6em; + } + + .lbry-meta-checkbox-wrapper-last { + padding: .5em .8em 1.5em; + } + .lbry-meta-label { + padding-left: .3em; + padding-right: .6em; + } -.lbry-pub-metabox { - margin: 0 0 0 -.2em; - padding: 0 .2em 0 0 ; -} -.meta-icon-lbry { - height: 1.55em; - margin-bottom: -.4em; - padding-left: .1em; -} -.lbry-meta-checkbox-wrapper { - padding: .5em .8em .6em; -} + .lbry-meta-bx-label { + margin: .5em .8em .6em; + } -.lbry-meta-wrapper-last { - padding: 0em .8em 1.2em; -} - -.lbry-meta-label { - padding: .3em .6em .6em .1em; - /* padding-left: .3em; - padding-right: .6em; - padding-bottom: .5em; */ -} - -.lbry-meta-bx-label { - margin: .5em .8em .6em; -} - -.lbry-meta-bx-option { - padding: .5em .8em .6em; -} - -.lbry-meta-bx-option-last { - padding: .5em .8em 1.5em; -} - -.lbry-hr-meta { - margin-left: 1em; - margin-right: 1em; -} -.post-lbry-display-before { - color: darkgreen; -} -.post-lbry-display { - color: green; -} - -.lbry-pub-metabox { - margin: 0; - font-size: 1em; -} - -.lbry-claim-id-metabox { - margin: 0; - padding-top: .3em; - font-size: .85em; - line-height: 1em; -} - -.lbry-meta-bx-content { - padding: .2em .8em .6em .1em; -} - -.lbry-meta-bx-content-last { - padding: .2em .8em 1em .1em; -} \ No newline at end of file + .lbry-meta-bx-option { + padding: .5em .8em .6em; + } + .lbry-meta-bx-option-last { + padding: .5em .8em 1.5em; + } diff --git a/admin/images/speech-tab.jpg b/admin/images/speech-tab.jpg deleted file mode 100644 index fb62d8a..0000000 Binary files a/admin/images/speech-tab.jpg and /dev/null differ diff --git a/classes/LBRYPress.php b/classes/LBRYPress.php index 3924077..2220953 100644 --- a/classes/LBRYPress.php +++ b/classes/LBRYPress.php @@ -108,7 +108,7 @@ class LBRYPress $this->define('LBRY_VERSION', $this->version); // Library Options Names - //$this->define('LBRY_SETTINGS_GROUP', 'lbry_settings_group'); + $this->define('LBRY_SETTINGS_GROUP', 'lbry_settings_group'); $this->define('LBRY_SETTINGS', 'lbry_settings'); $this->define('LBRY_SETTINGS_SECTION_GENERAL', 'lbry_settings_section_general'); $this->define('LBRY_ADMIN_PAGE', 'lbrypress'); diff --git a/classes/LBRY_Admin.php b/classes/LBRY_Admin.php index e4a7fcb..51abfdf 100644 --- a/classes/LBRY_Admin.php +++ b/classes/LBRY_Admin.php @@ -208,7 +208,7 @@ class LBRY_Admin $license_array = LBRY()->licenses; if ( isset( $input[LBRY_LICENSE] ) && ( in_array( $input[LBRY_LICENSE], $license_array ) ) ) { $new_input[LBRY_LICENSE] = sanitize_text_field( $input[LBRY_LICENSE] ); - } + } if ( isset( $input[LBRY_LBC_PUBLISH] ) ) { $new_input[LBRY_LBC_PUBLISH] = number_format( floatval( $input[LBRY_LBC_PUBLISH] ), 3, '.', '' ); } @@ -290,6 +290,7 @@ class LBRY_Admin ); } + /** * Checkbox to default to always allow publish on LBRY */ @@ -304,6 +305,7 @@ class LBRY_Admin '

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

', 'lbry_default_publish_setting', LBRY_SETTINGS, + ); } @@ -363,6 +365,7 @@ class LBRY_Admin $options ); } + /** * Prints LBC per publish input @@ -421,9 +424,9 @@ class LBRY_Admin '', LBRY_SPEECH_PW, LBRY_SPEECH_SETTINGS, - ); + ); } - + /** * Handles new channel form submission */ diff --git a/classes/LBRY_Daemon.php b/classes/LBRY_Daemon.php index 92e6966..26fd78e 100644 --- a/classes/LBRY_Daemon.php +++ b/classes/LBRY_Daemon.php @@ -33,7 +33,8 @@ class LBRY_Daemon * https://lbry.tech/api/sdk#address_unused * @return string Unused wallet address in base58 */ - public function wallet_unused_address() { + public function wallet_unused_address() + { try { $result = $this->request( 'address_unused' ); return $result->result; @@ -66,30 +67,6 @@ class LBRY_Daemon } } - /** - * Returns the info about a claim can get supports and initial bid amount when claim created among other information about a claim. - * TODO Can be build out later to accept more params - * @param string $claim_id - * @return object $result - */ - public function claim_search( $claim_id ) - { - $params = array( - 'claim_id' => $claim_id, - // 'name' => $norm_name, - // 'claim_type' => $claim_type, - ); - try { - $result = $this->request( 'claim_search', $params ); - $this->logger->log( 'Claim Search Results: ' . print_r( $result->result, true ) ); - return $result->result; - } catch ( LBRYDaemonException $e ) { - $this->logger->log( 'claim_search error', $e->getMessage() . ' | Code: ' . $e->getCode() ); - LBRY()->notice->set_notice( 'error', 'Issue getting claim search info' ); - return; - } - } - /** * Returns the available balance of a current LBRY account * https://lbry.tech/api/sdk#wallet_balance @@ -145,12 +122,12 @@ class LBRY_Daemon if ( strpos( $channel_name, '@' ) ) { throw new \Exception( 'Illegal character "@" in channel name', 1 ); } - + // No white space allowed if ( strpos( $channel_name, ' ' ) ) { throw new \Exception( "No spaces allowed in channel name", 1 ); } - + $channel_name = '@' . $channel_name; try { diff --git a/classes/LBRY_Network.php b/classes/LBRY_Network.php index b64481b..789d56a 100644 --- a/classes/LBRY_Network.php +++ b/classes/LBRY_Network.php @@ -39,7 +39,6 @@ class LBRY_Network // Save the post meta on 'save_post' hook add_action( 'wp_insert_post', array( $this, 'save_post_meta' ), 11, 2 ); - // Checkbox inside the WordPres meta box near "Publish" button add_action( 'post_submitbox_misc_actions', array( $this, 'publish_to_lbry_checkbox' ) ); } @@ -120,27 +119,11 @@ class LBRY_Network public function publish_to_lbry_checkbox( $post ) { + $post_id = $post->ID; + if ( get_post_type( $post_id ) != 'post' ) { return $post; } - $post_id = $post->ID; - $lbry_claim_id = get_post_meta( $post_id, '_lbry_claim_id', true ); - if ( $_GET['action'] === 'edit' ) { - if ( get_post_meta( $post_id, '_lbry_canonical_url', true ) == null || empty( get_post_meta( $post_id, '_lbry_canonical_url', true ) ) ) { - $canonical_url = LBRY()->daemon->canonical_url( $lbry_claim_id ); - update_post_meta( $post_id, '_lbry_canonical_url', $canonical_url ); - } - } - if ( ( get_post_meta( $post_id, '_lbry_will_publish', true ) == true ) && (isset( $lbry_claim_id ) ) ) { - update_post_meta( $post_id, '_lbry_is_published', true ); - } - $lbry_published = get_post_meta( $post_id, '_lbry_is_published', true ); - $lbry_url = ( get_post_meta( $post_id, '_lbry_canonical_url', true ) ); - - if ($lbry_url) { - $open_url = str_replace('lbry://', 'open.lbry.com/', $lbry_url ); - } - $default_value = get_option( LBRY_SETTINGS )['lbry_default_publish_setting']; $new_value = get_post_meta( $post_id, LBRY_WILL_PUBLISH, true ); if ( ( $new_value ) ? $new_value : $new_value = $default_value ); @@ -148,38 +131,17 @@ class LBRY_Network if ( ( $value ) ? $value : 0 ); // nonce set on page meta-box.php - if ( ( $lbry_published ) && ( ( $lbry_url) || ( $lbry_claim_id ) ) ) { - printf( - '
-
- Published on: LBRY -
-
- LBRY URL: ' . esc_html__( '%3$s', 'lbrypress' ) . ' -
-
- LBRY claim ID:

' . esc_html__( '%4$s', 'lbrypress' ) . '

-
-
- Update Post on: ' . esc_html__('LBRY', 'lbrypress') . ' -
', - plugin_dir_url( LBRY_PLUGIN_FILE ) . 'admin/images/lbry.png', - $open_url, - $lbry_url, - $lbry_claim_id, - checked( $value, true, false ), - LBRY_WILL_PUBLISH - ); - } else { - printf ( - '
- Publish to: ' . esc_html__('LBRY', 'lbrypress') . ' -
', - plugin_dir_url( LBRY_PLUGIN_FILE ) . 'admin/images/lbry.png', - checked( $value, true, false ), - LBRY_WILL_PUBLISH - ); - } + printf ( + '
+ +
', + plugin_dir_url( LBRY_PLUGIN_FILE ) . 'admin/images/lbry.png', + 'Publish to', + 'LBRY', + 'lbrypress', + checked( $value, true, false ), + LBRY_WILL_PUBLISH + ); } /** diff --git a/classes/LBRY_Network_Publisher.php b/classes/LBRY_Network_Publisher.php index 3f8ccda..0007b03 100644 --- a/classes/LBRY_Network_Publisher.php +++ b/classes/LBRY_Network_Publisher.php @@ -84,24 +84,9 @@ class LBRY_Network_Publisher // Set Claim ID update_post_meta( $post->ID, LBRY_CLAIM_ID, $claim_id ); - // Set Channel Name Published under - $published_channel = $output->signing_channel->name; - $channel_claim_id = $output->signing_channel->claim_id; - update_post_meta( $post->ID, '_lbry_post_published_channel', $published_channel ); - update_post_meta( $post->ID, '_lbry_post_pub_channel_claim_id', $channel_claim_id ); - - // Set License Published under - $published_license = $output->value->license; - if ( ( $published_license ) && ( $published_license !== null ) ) { - update_post_meta( $post->ID, '_lbry_post_published_license', $published_license ); - } - // Set Canonical URL $canonical_url = LBRY()->daemon->canonical_url( $claim_id ); update_post_meta( $post->ID, LBRY_CANONICAL_URL, $canonical_url ); - - // Set _lbry_is_published to true - update_post_meta( $post->ID, '_lbry_is_published', true ); } } catch (Exception $e) { error_log( 'Issue publishing post ' . $post->ID . ' to LBRY: ' . $e->getMessage() ); diff --git a/templates/meta-box.php b/templates/meta-box.php index d50abb2..68d51f1 100644 --- a/templates/meta-box.php +++ b/templates/meta-box.php @@ -12,80 +12,58 @@ $unnatributed = (object) array( 'name' => 'none (anonymous)', 'claim_id' => 'null' ); -$post_id = $post->ID; // Generate a custom nonce $lbrynonce = wp_create_nonce( 'lbry_publish_post_nonce' ); -$lbry_published = get_post_meta( $post_id, '_lbry_is_published', true ); -$lbry_claim_id = get_post_meta( $post_id, '_lbry_claim_id', true ); -// $lbry_url = get_post_meta( $post_id, '_lbry_canonical_url', true ); -$lbry_published_channel = get_post_meta( $post_id, '_lbry_post_published_channel', true ); -if ( ! ( $lbry_published_channel ) ) { - LBRY()->daemon->claim_search( $lbry_claim_id ); -} -$lbry_channel_claim_id = get_post_meta( $post_id, '_lbry_post_pub_channel', true ); -//if ( $lbry_channel_claim_id === null ? 'Anonymously' : $lbry_channel_claim_id); -$lbry_published_license = get_post_meta( $post_id, '_lbry_post_pub_license', true ); - $channels = LBRY()->daemon->channel_list(); $channels[] = $unnatributed; +$post_id = $post->ID; $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 ) ); $default_channel = get_option( LBRY_SETTINGS )['default_lbry_channel']; -$chan_open_url = ( 'open.lbry.com/'. $lbry_published_channel .'#' . $lbry_channel_claim_id . ''); // Sort the channels in a natural way usort( $channels, array( 'LBRYPress', 'channel_name_comp' ) ); ?> - + +
' . __( 'LBRY channel published at:', 'lbrypress' ) . '
' . esc_html__( '%1$s', 'lbrypress' ) . '
' . __( 'License published under:', 'lbrypress' ) .'
' . esc_html__( '%3$s', 'lbrypress' ) . '
', - $lbry_published_channel, - $chan_open_url, - $lbry_published_license, - ); - } else { ?> -
$channel ) { - $options .= ''; - } - printf( - '', - LBRY_POST_PUB_CHANNEL, - $options - ); - } - ?> -
licenses; - $options = ''; - $default_license = get_option(LBRY_SETTINGS)[LBRY_LICENSE]; - $cur_license = get_post_meta( $post_id, LBRY_POST_PUB_LICENSE, true ); - - // Create options list, select current license - if ( $licenses ) { - foreach ( $licenses as $value => $name ) { - $options .= ''; + } + printf( + '', + LBRY_POST_PUB_CHANNEL, + $options + ); + } ?> +
licenses; + $options = ''; + $default_license = get_option(LBRY_SETTINGS)[LBRY_LICENSE]; + $cur_license = get_post_meta( $post_id, LBRY_POST_PUB_LICENSE, true ); + + // Create options list, select current license + if ( $licenses ) { + foreach ( $licenses as $value => $name ) { + $options .= '