PluginProbe
ActivityPub / trunk
ActivityPub vtrunk
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
activitypub / templates / embed.php

embed.php in ActivityPub trunk, at templates/embed.php

94 lines 3.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Reply embed template.
4 *
5 * @package Activitypub
6 */
7
8 /* @var array $args Template arguments. */
9 $args = wp_parse_args(
10 $args,
11 array(
12 'audio' => null,
13 'author_name' => '',
14 'author_url' => '',
15 'avatar_url' => '',
16 'boosts' => null,
17 'content' => '',
18 'favorites' => null,
19 'image' => '',
20 'published' => '',
21 'title' => '',
22 'url' => '',
23 'video' => null,
24 'webfinger' => '',
25 )
26 );
27
28 \wp_enqueue_style( 'activitypub-embed', ACTIVITYPUB_PLUGIN_URL . 'assets/css/activitypub-embed.css', array(), ACTIVITYPUB_PLUGIN_VERSION );
29 ?>
30
31 <div class="activitypub-embed u-in-reply-to h-cite">
32 <div class="activitypub-embed-header p-author h-card">
33 <?php if ( $args['avatar_url'] ) : ?>
34 <img class="u-photo" src="<?php echo \esc_url( $args['avatar_url'] ); ?>" alt="" />
35 <?php endif; ?>
36 <div class="activitypub-embed-header-text">
37 <h2 class="p-name"><?php echo \esc_html( $args['author_name'] ); ?></h2>
38 <?php if ( $args['author_url'] ) : ?>
39 <a href="<?php echo \esc_url( $args['author_url'] ); ?>" class="ap-account u-url"><?php echo \esc_html( $args['webfinger'] ?? $args['author_url'] ); ?></a>
40 <?php endif; ?>
41 </div>
42 </div>
43
44 <div class="activitypub-embed-content">
45 <?php if ( $args['title'] ) : ?>
46 <h3 class="ap-title p-name"><?php echo \esc_html( $args['title'] ); ?></h3>
47 <?php endif; ?>
48
49 <?php if ( $args['content'] ) : ?>
50 <div class="ap-subtitle p-summary e-content"><?php echo \Activitypub\Sanitize::content( $args['content'] ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Sanitize::content() returns kses-sanitized HTML. ?></div>
51 <?php endif; ?>
52
53 <?php if ( $args['images'] ) : ?>
54 <div class="ap-preview <?php echo \esc_attr( 'layout-' . count( $args['images'] ) ); ?>">
55 <?php foreach ( $args['images'] as $image ) : ?>
56 <img class="u-photo u-featured" src="<?php echo \esc_url( $image['url'] ); ?>" alt="<?php echo \esc_attr( $image['name'] ?? '' ); ?>" />
57 <?php endforeach; ?>
58 </div>
59 <?php elseif ( $args['video'] ) : ?>
60 <div class="ap-preview layout-1">
61 <video controls class="u-photo u-featured" src="<?php echo \esc_url( $args['video']['url'] ); ?>" title="<?php echo \esc_attr( $args['video']['name'] ?? '' ); ?>"></video>
62 </div>
63 <?php elseif ( $args['audio'] ) : ?>
64 <div class="ap-preview layout-1">
65 <audio controls class="u-photo u-featured" src="<?php echo \esc_url( $args['audio']['url'] ); ?>" title="<?php echo \esc_attr( $args['audio']['name'] ?? '' ); ?>"></audio>
66 </div>
67 <?php endif; ?>
68 </div>
69
70 <div class="activitypub-embed-meta">
71 <?php if ( $args['published'] ) : ?>
72 <a href="<?php echo \esc_url( $args['url'] ); ?>" class="ap-stat ap-date dt-published u-in-reply-to"><?php echo \esc_html( $args['published'] ); ?></a>
73 <?php endif; ?>
74
75 <?php if ( null !== $args['boosts'] ) : ?>
76 <span class="ap-stat">
77 <?php
78 /* translators: %s: number of boosts */
79 printf( \esc_html__( '%s boosts', 'activitypub' ), '<strong>' . \esc_html( \number_format_i18n( $args['boosts'] ) ) . '</strong>' );
80 ?>
81 </span>
82 <?php endif; ?>
83
84 <?php if ( null !== $args['favorites'] ) : ?>
85 <span class="ap-stat">
86 <?php
87 /* translators: %s: number of favorites */
88 printf( \esc_html__( '%s favorites', 'activitypub' ), '<strong>' . \esc_html( \number_format_i18n( $args['favorites'] ) ) . '</strong>' );
89 ?>
90 </span>
91 <?php endif; ?>
92 </div>
93 </div>
94