encode/escape properly save canonical as post meta

This commit is contained in:
Lem Smyth 2022-02-23 14:49:50 -06:00
parent 6d39f496d2
commit 524147d0a9
2 changed files with 16 additions and 11 deletions

View file

@ -19,13 +19,13 @@ if ( current_user_can( 'manage_options' ) ) {
<h3><?php _e( 'Available Channels To Publish', 'lbrypress' ); ?></h3> <h3><?php _e( 'Available Channels To Publish', 'lbrypress' ); ?></h3>
<?php //LBRY()->admin->available_channels_callback(); ?> <?php //LBRY()->admin->available_channels_callback(); ?>
<?php <?php
if ( isset( $_POST['lbry_new_channel'] ) ) { if ( $_POST['lbry_new_channel'] ) {
$channel = $_POST['lbry_new_channel']; $channel = $_POST['lbry_new_channel'];
$channel = str_replace( '@', '', $channel ); $channel = str_replace( '@', '', $channel );
$channel = str_replace( ' ', '-', $channel ); $channel = str_replace( ' ', '-', $channel );
$clean_input['lbry_new_channel'] = sanitize_user( $channel ); $clean_input['lbry_new_channel'] = sanitize_user( $channel );
} }
if ( isset( $_POST['lbry_channel_bid_amount'] ) ) { if ( $_POST['lbry_channel_bid_amount'] ) {
$channel_bid = $_POST['lbry_channel_bid_amount']; $channel_bid = $_POST['lbry_channel_bid_amount'];
$clean_input['lbry_channel_bid_amount'] = number_format( floatval( $channel_bid ), 3, '.', '' ); $clean_input['lbry_channel_bid_amount'] = number_format( floatval( $channel_bid ), 3, '.', '' );
} }
@ -68,8 +68,8 @@ if ( current_user_can( 'manage_options' ) ) {
} }
$init_bid = $results->items[0]->amount; ?> $init_bid = $results->items[0]->amount; ?>
<tr> <tr>
<td><a href="<?php echo esc_url( $open_url, 'lbrypress' ); ?>"><?php esc_html_e( $channel->name, 'lbrypress' ); ?></a></td> <td><a href=""><?php esc_html_e( $channel->name, 'lbrypress' ); ?></a></td>
<td><?php esc_html_e( esc_url( $lbry_url ), 'lbrypress' ); ?></td> <td><a href="<?php echo esc_url( $open_url, 'lbrypress' ); ?>"><?php esc_html_e( esc_url( $lbry_url ), 'lbrypress' ); ?></a></td>
<td><?php esc_html_e( $claim_id, 'lbrypress' ); ?></td> <td><?php esc_html_e( $claim_id, 'lbrypress' ); ?></td>
<td><?php esc_html_e( $created_date, 'lbrypress' ); ?></td> <td><?php esc_html_e( $created_date, 'lbrypress' ); ?></td>
<td><?php esc_html_e( $claims_published, 'lbrypress' ); ?></td> <td><?php esc_html_e( $claims_published, 'lbrypress' ); ?></td>

View file

@ -32,7 +32,12 @@ if ( ( $lbry_published == true ) && ( ( $lbry_claim_id ) ) && ( ! ( $lbry_publis
update_post_meta( $post_id, '_lbry_post_pub_license', $license ); update_post_meta( $post_id, '_lbry_post_pub_license', $license );
} }
$lbry_canonical_url = get_post_meta( $post_id, '_lbry_canonical_url', true ); $lbry_canonical_url = get_post_meta( $post_id, '_lbry_canonical_url', true );
$lbry_url = ( ($lbry_canonical_url) ? $lbry_canonical_url : 'lbry://' . $lbry_published_channel . '#' . $lbry_claim_id ); if ( ! $lbry_canonical_url ) {
$result = LBRY()->daemon->claim_search( $lbry_claim_id );
$canonical_url = $result->items[0]->canonical_url;
update_post_meta( $post_id, '_lbry_canonical_url', $canonical_url );
}
$lbry_url = $lbry_canonical_url;
$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 ) ); $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']; $default_channel = get_option( LBRY_SETTINGS )['default_lbry_channel'];
$chan_open_url = ( 'open.lbry.com/'. $lbry_published_channel .'#' . $lbry_channel_claim_id . ''); $chan_open_url = ( 'open.lbry.com/'. $lbry_published_channel .'#' . $lbry_channel_claim_id . '');
@ -63,13 +68,13 @@ $chan_open_url = ( 'open.lbry.com/'. $lbry_published_channel .'#' . $lbry_channe
); );
printf( printf(
'<div class="lbry-meta-label lbry-meta-bx-channel"><strong>' . __( 'Supports:', 'lbrypress' ) . ' </strong> '<div class="lbry-meta-label lbry-meta-bx-channel"><strong>' . __( 'Supports:', 'lbrypress' ) . ' </strong>
<span class="lbry-meta-bx-content lbry-meta-bx-channel"><img src="' . esc_url( plugin_dir_url( LBRY_PLUGIN_FILE ) ) . 'admin/images/lbc.png" class="icon icon-lbc bid-icon-lbc bid-icon-lbc"> ' . esc_html__( '%1$s', 'lbrypress' ) . '</span><a href="' . admin_url( add_query_arg( array( 'page' => 'lbrypress', 'tab' => 'supports', 'post_id' => $post_id, 'claim_id' => '%2$s', 'lbry_url' => '%3$s', 'supporting_channel' => '%4$s', 'current_support' => '%5$.3f', 'init_bid' => '%6$.3f' ), 'admin.php' ) ) . '">' . __( 'Add', 'lbrypress' ) . '</a></div>', <span class="lbry-meta-bx-content lbry-meta-bx-channel"><img src="' . esc_url( plugin_dir_url( LBRY_PLUGIN_FILE ) ) . 'admin/images/lbc.png" class="icon icon-lbc bid-icon-lbc bid-icon-lbc"> ' . esc_html__( '%1$s', 'lbrypress' ) . '</span><a href="' . esc_url( admin_url( add_query_arg( array( 'page' => 'lbrypress', 'tab' => 'supports', 'post_id' => intval($post_id), 'claim_id' => esc_html__( '%2$s', 'lbrypress' ), 'lbry_url' => '%3$s', 'supporting_channel' => esc_html__( '%4$s', 'lbrypress' ), 'current_support' => '%5$.3f', 'init_bid' => '%6$.3f'), 'admin.php' ) ) ) . '">' . __( 'Add', 'lbrypress' ) . '</a></div>',
$support_amount, $support_amount,
$lbry_claim_id, urlencode( $lbry_claim_id ),
urlencode($lbry_url), urlencode( esc_url( $lbry_url ) ),
$lbry_published_channel, urlencode( $lbry_published_channel ),
$support_amount, urlencode( $support_amount ),
$init_bid urlencode( $init_bid )
); );
printf( printf(
'<div class="lbry-meta-label lbry-meta-bx-channel"><strong>' . __( 'LBRY channel published to:', 'lbrypress' ) . '</strong></div> '<div class="lbry-meta-label lbry-meta-bx-channel"><strong>' . __( 'LBRY channel published to:', 'lbrypress' ) . '</strong></div>