with shortcode_atts
there is no need to check if attr is set
This commit is contained in:
parent
75cc35c66e
commit
3666f89f6e
1 changed files with 29 additions and 22 deletions
|
@ -204,21 +204,24 @@ class Shortcodes {
|
|||
}
|
||||
|
||||
$atts = shortcode_atts(
|
||||
array( 'type' => 'html' ), $atts, $tag );
|
||||
array(
|
||||
'type' => 'html',
|
||||
),
|
||||
$atts,
|
||||
$tag
|
||||
);
|
||||
|
||||
if ( is_array( $atts ) && array_key_exists( 'type', $atts ) ) {
|
||||
if ( $atts['type'] == 'raw' ) {
|
||||
if ( 'raw' === $atts['type'] ) {
|
||||
return \get_permalink( $post->ID );
|
||||
}
|
||||
|
||||
if ( $atts['type'] == 'esc' ) {
|
||||
if ( 'esc' === $atts['type'] ) {
|
||||
return \esc_url( \get_permalink( $post->ID ) );
|
||||
}
|
||||
|
||||
if ( $atts['type'] == 'blank' ) {
|
||||
if ( 'blank' === $atts['type'] ) {
|
||||
return \sprintf( '<a href="%1$s" target="_blank">%1$s</a>', \esc_url( \get_permalink( $post->ID ) ) );
|
||||
}
|
||||
}
|
||||
|
||||
return \sprintf( '<a href="%1$s">%1$s</a>', \esc_url( \get_permalink( $post->ID ) ) );
|
||||
}
|
||||
|
@ -239,21 +242,25 @@ class Shortcodes {
|
|||
return '';
|
||||
}
|
||||
|
||||
$atts = shortcode_atts( array( 'type' => 'html' ), $atts, $tag );
|
||||
$atts = shortcode_atts(
|
||||
array(
|
||||
'type' => 'html',
|
||||
),
|
||||
$atts,
|
||||
$tag
|
||||
);
|
||||
|
||||
if ( is_array( $atts ) && array_key_exists( 'type', $atts ) ) {
|
||||
if ( $atts['type'] == 'raw' ) {
|
||||
if ( 'raw' === $atts['type'] ) {
|
||||
return \wp_get_shortlink( $post->ID );
|
||||
}
|
||||
|
||||
if ( $atts['type'] == 'esc' ) {
|
||||
if ( 'esc' === $atts['type'] ) {
|
||||
return \esc_url( \wp_get_shortlink( $post->ID ) );
|
||||
}
|
||||
|
||||
if ( $atts['type'] == 'blank' ) {
|
||||
if ( 'blank' === $atts['type'] ) {
|
||||
return \sprintf( '<a href="%1$s" target="_blank">%1$s</a>', \esc_url( \wp_get_shortlink( $post->ID ) ) );
|
||||
}
|
||||
}
|
||||
|
||||
return \sprintf( '<a href="%1$s">%1$s</a>', \esc_url( \wp_get_shortlink( $post->ID ) ) );
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue