updated plugin ActivityPub version 8.3.0
This commit is contained in:
@ -72,13 +72,13 @@ class Shortcodes {
|
||||
/**
|
||||
* Generates output for the 'ap_title' Shortcode
|
||||
*
|
||||
* @param array $atts The Shortcode attributes.
|
||||
* @param string $content The ActivityPub post-content.
|
||||
* @param string $tag The tag/name of the Shortcode.
|
||||
* @param array $attributes The Shortcode attributes.
|
||||
* @param string $content The ActivityPub post-content.
|
||||
* @param string $tag The tag/name of the Shortcode.
|
||||
*
|
||||
* @return string The post title.
|
||||
*/
|
||||
public static function title( $atts, $content, $tag ) {
|
||||
public static function title( $attributes, $content, $tag ) {
|
||||
$item = self::get_item();
|
||||
|
||||
if ( ! $item ) {
|
||||
@ -91,13 +91,13 @@ class Shortcodes {
|
||||
return '';
|
||||
}
|
||||
|
||||
$atts = shortcode_atts(
|
||||
$attributes = shortcode_atts(
|
||||
array( 'type' => 'plain' ),
|
||||
$atts,
|
||||
$attributes,
|
||||
$tag
|
||||
);
|
||||
|
||||
if ( 'html' !== $atts['type'] ) {
|
||||
if ( 'html' !== $attributes['type'] ) {
|
||||
return $title;
|
||||
}
|
||||
|
||||
@ -107,26 +107,26 @@ class Shortcodes {
|
||||
/**
|
||||
* Generates output for the 'ap_excerpt' Shortcode
|
||||
*
|
||||
* @param array $atts The Shortcode attributes.
|
||||
* @param string $content The ActivityPub post-content.
|
||||
* @param string $tag The tag/name of the Shortcode.
|
||||
* @param array $attributes The Shortcode attributes.
|
||||
* @param string $content The ActivityPub post-content.
|
||||
* @param string $tag The tag/name of the Shortcode.
|
||||
*
|
||||
* @return string The post excerpt.
|
||||
*/
|
||||
public static function excerpt( $atts, $content, $tag ) {
|
||||
public static function excerpt( $attributes, $content, $tag ) {
|
||||
$item = self::get_item();
|
||||
|
||||
if ( ! $item ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$atts = shortcode_atts(
|
||||
$attributes = shortcode_atts(
|
||||
array( 'length' => ACTIVITYPUB_EXCERPT_LENGTH ),
|
||||
$atts,
|
||||
$attributes,
|
||||
$tag
|
||||
);
|
||||
|
||||
$excerpt_length = intval( $atts['length'] );
|
||||
$excerpt_length = intval( $attributes['length'] );
|
||||
|
||||
if ( 0 === $excerpt_length ) {
|
||||
$excerpt_length = ACTIVITYPUB_EXCERPT_LENGTH;
|
||||
@ -141,13 +141,13 @@ class Shortcodes {
|
||||
/**
|
||||
* Generates output for the 'ap_content' Shortcode.
|
||||
*
|
||||
* @param array $atts The Shortcode attributes.
|
||||
* @param string $content The ActivityPub post-content.
|
||||
* @param string $tag The tag/name of the Shortcode.
|
||||
* @param array $attributes The Shortcode attributes.
|
||||
* @param string $content The ActivityPub post-content.
|
||||
* @param string $tag The tag/name of the Shortcode.
|
||||
*
|
||||
* @return string The post content.
|
||||
*/
|
||||
public static function content( $atts, $content, $tag ) {
|
||||
public static function content( $attributes, $content, $tag ) {
|
||||
$item = self::get_item();
|
||||
|
||||
if ( ! $item ) {
|
||||
@ -157,9 +157,9 @@ class Shortcodes {
|
||||
// Prevent inception.
|
||||
remove_shortcode( 'ap_content' );
|
||||
|
||||
$atts = shortcode_atts(
|
||||
$attributes = shortcode_atts(
|
||||
array( 'apply_filters' => 'yes' ),
|
||||
$atts,
|
||||
$attributes,
|
||||
$tag
|
||||
);
|
||||
|
||||
@ -177,7 +177,7 @@ class Shortcodes {
|
||||
$content = \get_post_field( 'post_content', $item );
|
||||
}
|
||||
|
||||
if ( 'yes' === $atts['apply_filters'] ) {
|
||||
if ( 'yes' === $attributes['apply_filters'] ) {
|
||||
/** This filter is documented in wp-includes/post-template.php */
|
||||
$content = \apply_filters( 'the_content', $content );
|
||||
} else {
|
||||
@ -188,10 +188,9 @@ class Shortcodes {
|
||||
$content = \wp_filter_content_tags( $content );
|
||||
}
|
||||
|
||||
// Replace script and style elements.
|
||||
$content = \preg_replace( '@<(script|style)[^>]*?>.*?</\\1>@si', '', $content );
|
||||
$content = \strip_shortcodes( $content );
|
||||
$content = \trim( \preg_replace( '/[\n\r\t]/', '', $content ) );
|
||||
$content = Sanitize::clean_html( $content );
|
||||
$content = Sanitize::strip_whitespace( $content );
|
||||
|
||||
add_shortcode( 'ap_content', array( 'Activitypub\Shortcodes', 'content' ) );
|
||||
|
||||
@ -201,28 +200,28 @@ class Shortcodes {
|
||||
/**
|
||||
* Generates output for the 'ap_permalink' Shortcode.
|
||||
*
|
||||
* @param array $atts The Shortcode attributes.
|
||||
* @param string $content The ActivityPub post-content.
|
||||
* @param string $tag The tag/name of the Shortcode.
|
||||
* @param array $attributes The Shortcode attributes.
|
||||
* @param string $content The ActivityPub post-content.
|
||||
* @param string $tag The tag/name of the Shortcode.
|
||||
*
|
||||
* @return string The post permalink.
|
||||
*/
|
||||
public static function permalink( $atts, $content, $tag ) {
|
||||
public static function permalink( $attributes, $content, $tag ) {
|
||||
$item = self::get_item();
|
||||
|
||||
if ( ! $item ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$atts = shortcode_atts(
|
||||
$attributes = shortcode_atts(
|
||||
array(
|
||||
'type' => 'url',
|
||||
),
|
||||
$atts,
|
||||
$attributes,
|
||||
$tag
|
||||
);
|
||||
|
||||
if ( 'html' !== $atts['type'] ) {
|
||||
if ( 'html' !== $attributes['type'] ) {
|
||||
return \esc_url( \get_permalink( $item->ID ) );
|
||||
}
|
||||
|
||||
@ -235,28 +234,28 @@ class Shortcodes {
|
||||
/**
|
||||
* Generates output for the 'ap_shortlink' Shortcode.
|
||||
*
|
||||
* @param array $atts The Shortcode attributes.
|
||||
* @param string $content The ActivityPub post-content.
|
||||
* @param string $tag The tag/name of the Shortcode.
|
||||
* @param array $attributes The Shortcode attributes.
|
||||
* @param string $content The ActivityPub post-content.
|
||||
* @param string $tag The tag/name of the Shortcode.
|
||||
*
|
||||
* @return string The post shortlink.
|
||||
*/
|
||||
public static function shortlink( $atts, $content, $tag ) {
|
||||
public static function shortlink( $attributes, $content, $tag ) {
|
||||
$item = self::get_item();
|
||||
|
||||
if ( ! $item ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$atts = shortcode_atts(
|
||||
$attributes = shortcode_atts(
|
||||
array(
|
||||
'type' => 'url',
|
||||
),
|
||||
$atts,
|
||||
$attributes,
|
||||
$tag
|
||||
);
|
||||
|
||||
if ( 'html' !== $atts['type'] ) {
|
||||
if ( 'html' !== $attributes['type'] ) {
|
||||
return \esc_url( \wp_get_shortlink( $item->ID ) );
|
||||
}
|
||||
|
||||
@ -269,35 +268,35 @@ class Shortcodes {
|
||||
/**
|
||||
* Generates output for the 'ap_image' Shortcode.
|
||||
*
|
||||
* @param array $atts The Shortcode attributes.
|
||||
* @param string $content The ActivityPub post-content.
|
||||
* @param string $tag The tag/name of the Shortcode.
|
||||
* @param array $attributes The Shortcode attributes.
|
||||
* @param string $content The ActivityPub post-content.
|
||||
* @param string $tag The tag/name of the Shortcode.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function image( $atts, $content, $tag ) {
|
||||
public static function image( $attributes, $content, $tag ) {
|
||||
$item = self::get_item();
|
||||
|
||||
if ( ! $item ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$atts = shortcode_atts(
|
||||
$attributes = shortcode_atts(
|
||||
array(
|
||||
'type' => 'full',
|
||||
),
|
||||
$atts,
|
||||
$attributes,
|
||||
$tag
|
||||
);
|
||||
|
||||
$size = 'full';
|
||||
|
||||
if ( in_array(
|
||||
$atts['type'],
|
||||
$attributes['type'],
|
||||
array( 'thumbnail', 'medium', 'large', 'full' ),
|
||||
true
|
||||
) ) {
|
||||
$size = $atts['type'];
|
||||
$size = $attributes['type'];
|
||||
}
|
||||
|
||||
$image = \get_the_post_thumbnail_url( $item->ID, $size );
|
||||
@ -312,32 +311,12 @@ class Shortcodes {
|
||||
/**
|
||||
* Generates output for the 'ap_hashcats' Shortcode.
|
||||
*
|
||||
* @deprecated 7.0.0
|
||||
*
|
||||
* @return string The post categories as hashtags.
|
||||
*/
|
||||
public static function hashcats() {
|
||||
$item = self::get_item();
|
||||
|
||||
if ( ! $item ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$categories = \get_the_category( $item->ID );
|
||||
|
||||
if ( ! $categories ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$hash_tags = array();
|
||||
|
||||
foreach ( $categories as $category ) {
|
||||
$hash_tags[] = \sprintf(
|
||||
'<a rel="tag" class="hashtag u-tag u-category" href="%s">%s</a>',
|
||||
\esc_url( \get_category_link( $category ) ),
|
||||
esc_hashtag( $category->name )
|
||||
);
|
||||
}
|
||||
|
||||
return \implode( ' ', $hash_tags );
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
@ -447,10 +426,8 @@ class Shortcodes {
|
||||
return '';
|
||||
}
|
||||
|
||||
$datetime = \get_post_datetime( $item );
|
||||
$timeformat = \get_option( 'time_format' );
|
||||
|
||||
$date = $datetime->format( $timeformat );
|
||||
$datetime = \get_post_datetime( $item );
|
||||
$date = $datetime->format( \get_option( 'time_format' ) );
|
||||
|
||||
if ( ! $date ) {
|
||||
return '';
|
||||
@ -471,11 +448,11 @@ class Shortcodes {
|
||||
return '';
|
||||
}
|
||||
|
||||
$datetime = \get_post_datetime( $item );
|
||||
$dateformat = \get_option( 'date_format' );
|
||||
$timeformat = \get_option( 'time_format' );
|
||||
$datetime = \get_post_datetime( $item );
|
||||
$date_format = \get_option( 'date_format' );
|
||||
$time_format = \get_option( 'time_format' );
|
||||
|
||||
$date = $datetime->format( $dateformat . ' @ ' . $timeformat );
|
||||
$date = $datetime->format( $date_format . ' @ ' . $time_format );
|
||||
|
||||
if ( ! $date ) {
|
||||
return '';
|
||||
|
||||
Reference in New Issue
Block a user