I would keep it simple for now

This commit is contained in:
Matthias Pfefferle 2023-01-23 20:47:02 +01:00
parent 092a6bd3ca
commit fe4e0961c8
2 changed files with 15 additions and 49 deletions

View file

@ -266,31 +266,6 @@ class Shortcodes {
return \sprintf( '<a href="%1$s">%1$s</a>', \esc_url( \wp_get_shortlink( $post->ID ) ) );
}
/**
* Generates output for the ap_thumbnail shortcode
*
* @param array $atts shortcode attributes
* @param string $content shortcode content
* @param string $tag shortcode tag name
*
* @return string
*/
public static function thumbnail( $atts, $content, $tag ) {
$post_id = get_the_ID();
if ( ! $post_id ) {
return '';
}
$image = \get_the_post_thumbnail_url( $post_id, 'thumbnail' );
if ( ! $image ) {
return '';
}
return $image;
}
/**
* Generates output for the ap_image shortcode
*
@ -307,18 +282,22 @@ class Shortcodes {
return '';
}
$atts = shortcode_atts( array( 'size' => 'full' ), $atts, $tag );
$atts = shortcode_atts(
array(
'type' => 'full',
),
$atts,
$tag
);
if ( is_array( $atts ) && array_key_exists( 'size', $atts ) ) {
$registered_sizes = wp_get_registered_image_subsizes();
if ( array_key_exists( $atts['size'], $registered_sizes ) ) {
$size = intval( $atts['size'] );
}
}
if ( ! $size ) {
$size = 'full';
if ( in_array(
$atts['type'],
array( 'thumbnail', 'medium', 'large', 'full' ),
true
) ) {
$size = $atts['type'];
}
$image = \get_the_post_thumbnail_url( $post_id, $size );

View file

@ -7,18 +7,6 @@
'welcome' => '',
)
);
$image_sizes = wp_get_registered_image_subsizes();
$thumbnail_size = $image_sizes['thumbnail']['width'] . 'x' . $image_sizes['thumbnail']['height'] . ' px';
$registered_sizes = '';
foreach ( $image_sizes as $name => $size ) {
$registered_sizes .= $name . ', ';
}
$registered_sizes = trim( $registered_sizes, ', ' );
$registered_sizes .= '.';
?>
<div class="privacy-settings-body hide-if-no-js">
@ -81,8 +69,7 @@ $registered_sizes .= '.';
<li><code>[ap_shortlink <i>type=xxx</i>]</code> - <?php echo \wp_kses( \__( 'The post\'s shortlink. I can recommend <a href="https://wordpress.org/plugins/hum/" target="_blank">Hum</a>, to prettify the Shortlinks. Type can be either: raw (the raw url, no escaping), esc (the html escaped url), html (default, an a tag to the url).', 'activitypub' ), 'default' ); ?></li>
<li><code>[ap_hashtags]</code> - <?php \esc_html_e( 'The post\'s tags as hashtags.', 'activitypub' ); ?></li>
<li><code>[ap_hashcats]</code> - <?php \esc_html_e( 'The post\'s categories as hashtags.', 'activitypub' ); ?></li>
<li><code>[ap_image <i>size=xxx</i>]</code> - <?php \esc_html_e( 'The URL for the post\'s featured image, defaults to full size. The size attribute can be any of the following:', 'activitypub' ); echo esc_html( $registered_sizes ); ?></li>
<li><code>[ap_thumbnail]</code> - <?php echo \wp_kses( sprintf( __( 'The URL for the post\'s featured image thumbnail size (%s).', 'activitypub'), $thumbnail_size ), 'default' ); ?></li>
<li><code>[ap_image <i>type=full</i>]</code> - <?php \esc_html_e( 'The URL for the post\'s featured image, defaults to full size. The type attribute can be any of the following: thumbnail, medium, large, full', 'activitypub' ); ?></li>
<li><code>[ap_author]</code> - <?php \esc_html_e( 'The author\'s name.', 'activitypub' ); ?></li>
<li><code>[ap_authorurl]</code> - <?php \esc_html_e( 'The URL to the author\'s profile page.', 'activitypub' ); ?></li>
<li><code>[ap_date]</code> - <?php \esc_html_e( 'The post\'s date.', 'activitypub' ); ?></li>