PluginProbe
ActivityPub / 2.6.0
ActivityPub v2.6.0
9.3.1 9.3.0 9.2.2 9.2.1 9.2.0 9.1.0 9.0.2 9.0.1 9.0.0 8.3.0 8.2.1 8.2.0 8.1.1 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.2.0 1.3.0 2.0.0 2.0.1 2.1.0 2.1.1 All 160 releases
← All changes | includes/class-shortcodes.php +31 -17 1.2.0 → 2.6.0 View file →
@@ -109,10 +109,15 @@
109 109 }
110 110
111 111 $excerpt = \get_post_field( 'post_excerpt', $item );
112 112
113 - if ( '' === $excerpt ) {
114 -
113 + if ( 'attachment' === $item->post_type ) {
114 + // get title of attachment with fallback to alt text.
115 + $content = wp_get_attachment_caption( $item->ID );
116 + if ( empty( $content ) ) {
117 + $content = get_post_meta( $item->ID, '_wp_attachment_image_alt', true );
118 + }
119 + } elseif ( '' === $excerpt ) {
115 120 $content = \get_post_field( 'post_content', $item );
116 121
117 122 // An empty string will make wp_trim_excerpt do stuff we do not want.
118 123 if ( '' !== $content ) {
@@ -126,10 +131,9 @@
126 131
127 132 // Strip out any remaining tags.
128 133 $excerpt = \wp_strip_all_tags( $excerpt );
129 134
130 - /** This filter is documented in wp-includes/formatting.php */
131 - $excerpt_more = \apply_filters( 'excerpt_more', ' [...]' );
135 + $excerpt_more = \apply_filters( 'activitypub_excerpt_more', ' […]' );
132 136 $excerpt_more_len = strlen( $excerpt_more );
133 137
134 138 // We now have a excerpt, but we need to check it's length, it may be longer than we want for two reasons:
135 139 //
@@ -207,23 +211,33 @@
207 211 $atts,
208 212 $tag
209 213 );
210 214
211 - $content = \get_post_field( 'post_content', $item );
215 + $content = '';
212 216
213 - if ( 'yes' === $atts['apply_filters'] ) {
214 - $content = \apply_filters( 'the_content', $content );
217 + if ( 'attachment' === $item->post_type ) {
218 + // get title of attachment with fallback to alt text.
219 + $content = wp_get_attachment_caption( $item->ID );
220 + if ( empty( $content ) ) {
221 + $content = get_post_meta( $item->ID, '_wp_attachment_image_alt', true );
222 + }
215 223 } else {
216 - $content = do_blocks( $content );
217 - $content = wptexturize( $content );
218 - $content = wp_filter_content_tags( $content );
224 + $content = \get_post_field( 'post_content', $item );
225 +
226 + if ( 'yes' === $atts['apply_filters'] ) {
227 + $content = \apply_filters( 'the_content', $content );
228 + } else {
229 + $content = do_blocks( $content );
230 + $content = wptexturize( $content );
231 + $content = wp_filter_content_tags( $content );
232 + }
233 +
234 + // replace script and style elements
235 + $content = \preg_replace( '@<(script|style)[^>]*?>.*?</\\1>@si', '', $content );
236 + $content = strip_shortcodes( $content );
237 + $content = \trim( \preg_replace( '/[\n\r\t]/', '', $content ) );
219 238 }
220 239
221 - // replace script and style elements
222 - $content = \preg_replace( '@<(script|style)[^>]*?>.*?</\\1>@si', '', $content );
223 - $content = strip_shortcodes( $content );
224 - $content = \trim( \preg_replace( '/[\n\r\t]/', '', $content ) );
225 -
226 240 add_shortcode( 'ap_content', array( 'Activitypub\Shortcodes', 'content' ) );
227 241
228 242 return $content;
229 243 }
@@ -256,9 +270,9 @@
256 270 return \esc_url( \get_permalink( $item->ID ) );
257 271 }
258 272
259 273 return \sprintf(
260 - '<a href="%1$s">%1$s</a>',
274 + '<a href="%1$s" class="status-link unhandled-link">%1$s</a>',
261 275 \esc_url( \get_permalink( $item->ID ) )
262 276 );
263 277 }
264 278
@@ -290,9 +304,9 @@
290 304 return \esc_url( \wp_get_shortlink( $item->ID ) );
291 305 }
292 306
293 307 return \sprintf(
294 - '<a href="%1$s">%1$s</a>',
308 + '<a href="%1$s" class="status-link unhandled-link">%1$s</a>',
295 309 \esc_url( \wp_get_shortlink( $item->ID ) )
296 310 );
297 311 }
298 312