Skip to content

Commit

Permalink
Remove an extract() in Navis_Media_Credit::caption_shortcode()
Browse files Browse the repository at this point in the history
  • Loading branch information
benlk committed Nov 8, 2018
1 parent 351eda7 commit 870fc77
Showing 1 changed file with 20 additions and 13 deletions.
33 changes: 20 additions & 13 deletions lib/navis-media-credit/navis-media-credit.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,26 +180,33 @@ function caption_shortcode( $text, $atts, $content ) {
'caption' => '',
), $atts );
$atts = apply_filters( 'navis_image_layout_defaults', $atts );
extract( $atts );

if ( $id && ! $credit ) {
$post_id = str_replace( 'attachment_', '', $id );
if ( $atts['id'] && empty( $atts['credit'] ) {
$post_id = str_replace( 'attachment_', '', $atts['id'] );
$creditor = navis_get_media_credit( $post_id );
$credit = ! empty( $creditor ) ? $creditor->to_string() : '';
}

if ( $id ) {
$id = 'id="' . esc_attr($id) . '" ';
}

// XXX: maybe remove module and image classes at some point
$out = sprintf( '<div %s class="wp-caption module image %s" style="max-width: %spx;">%s', $id, $align, $width, do_shortcode( $content ) );
if ( $credit ) {
$out .= sprintf( '<p class="wp-media-credit">%s</p>', $credit );
}
if ( $caption ) {
$out .= sprintf( '<p class="wp-caption-text">%s</p>', $caption );
$out = sprintf(
'<div id="%s" class="wp-caption module image %s" style="max-width: %spx;">%s',
esc_attr( $atts['id'] ),
esc_attr( $atts['align'] ),
esc_attr( $atts['width'] ),
do_shortcode( $content )
);

if ( isset( $credit ) ) {
$out .= sprintf(
'<p class="wp-media-credit">%s</p>',
wp_kses_post( $credit )
);
}

if ( !empty( $atts['caption'] ) {
$out .= sprintf( '<p class="wp-caption-text">%s</p>', wp_kses_post( $atts['caption'] ) );
}

$out .= "</div>";

return $out;
Expand Down

0 comments on commit 870fc77

Please sign in to comment.