Skip to content

Commit 74583b5

Browse files
authored
Unify JS-Modal templates (#1774)
1 parent 499bcad commit 74583b5

File tree

6 files changed

+298
-296
lines changed

6 files changed

+298
-296
lines changed

build/follow-me/render.php

Lines changed: 61 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,67 @@
110110
'followers' => Followers::count_followers( $user_id ),
111111
);
112112

113+
ob_start();
114+
?>
115+
<div class="activitypub-dialog__section">
116+
<h4><?php esc_html_e( 'My Profile', 'activitypub' ); ?></h4>
117+
<div class="activitypub-dialog__description">
118+
<?php esc_html_e( 'Copy and paste my profile into the search field of your favorite fediverse app or server.', 'activitypub' ); ?>
119+
</div>
120+
<div class="activitypub-dialog__button-group">
121+
<input
122+
aria-readonly="true"
123+
id="profile-handle"
124+
readonly
125+
tabindex="-1"
126+
type="text"
127+
value="<?php echo esc_attr( '@' . $actor->get_webfinger() ); ?>"
128+
/>
129+
<button
130+
aria-label="<?php esc_attr_e( 'Copy handle to clipboard', 'activitypub' ); ?>"
131+
class="wp-element-button wp-block-button__link"
132+
data-wp-on--click="actions.copyToClipboard"
133+
type="button"
134+
>
135+
<span data-wp-text="context.copyButtonText"></span>
136+
</button>
137+
</div>
138+
</div>
139+
<div class="activitypub-dialog__section">
140+
<h4><?php esc_html_e( 'Your Profile', 'activitypub' ); ?></h4>
141+
<div class="activitypub-dialog__description">
142+
<?php esc_html_e( 'Or, if you know your own profile, we can start things that way!', 'activitypub' ); ?>
143+
</div>
144+
<div class="activitypub-dialog__button-group">
145+
<input
146+
data-wp-bind--aria-invalid="context.isError"
147+
data-wp-bind--value="context.remoteProfile"
148+
data-wp-on--input="actions.updateRemoteProfile"
149+
data-wp-on--keydown="actions.handleKeyDown"
150+
id="remote-profile"
151+
placeholder="<?php esc_attr_e( '@[email protected]', 'activitypub' ); ?>"
152+
type="text"
153+
/>
154+
<button
155+
aria-label="<?php esc_attr_e( 'Follow', 'activitypub' ); ?>"
156+
class="wp-element-button wp-block-button__link"
157+
data-wp-bind--disabled="context.isLoading"
158+
data-wp-on--click="actions.submitRemoteProfile"
159+
type="button"
160+
>
161+
<span data-wp-bind--hidden="context.isLoading"><?php esc_html_e( 'Follow', 'activitypub' ); ?></span>
162+
<span data-wp-bind--hidden="!context.isLoading"><?php esc_html_e( 'Loading&hellip;', 'activitypub' ); ?></span>
163+
</button>
164+
</div>
165+
<div
166+
class="activitypub-dialog__error"
167+
data-wp-bind--hidden="!context.isError"
168+
data-wp-text="context.errorMessage"
169+
></div>
170+
</div>
171+
<?php
172+
$modal_content = ob_get_clean();
173+
113174
?>
114175
<div
115176
<?php echo get_block_wrapper_attributes( $wrapper_attributes ); // phpcs:ignore WordPress.Security.EscapeOutput ?>
@@ -171,65 +232,6 @@ class="activitypub-profile__avatar u-photo"
171232
</div>
172233

173234
<?php
174-
$modal_content = '
175-
<div class="activitypub-dialog__section">
176-
<h4>' . esc_html__( 'My Profile', 'activitypub' ) . '</h4>
177-
<div class="activitypub-dialog__description">
178-
' . esc_html__( 'Copy and paste my profile into the search field of your favorite fediverse app or server.', 'activitypub' ) . '
179-
</div>
180-
<div class="activitypub-dialog__button-group">
181-
<input
182-
type="text"
183-
id="profile-handle"
184-
value="' . esc_attr( '@' . $actor->get_webfinger() ) . '"
185-
tabindex="-1"
186-
readonly
187-
aria-readonly="true"
188-
/>
189-
<button
190-
type="button"
191-
class="wp-element-button wp-block-button__link"
192-
data-wp-on--click="actions.copyToClipboard"
193-
aria-label="' . esc_attr__( 'Copy handle to clipboard', 'activitypub' ) . '"
194-
>
195-
<span data-wp-text="context.copyButtonText"></span>
196-
</button>
197-
</div>
198-
</div>
199-
<div class="activitypub-dialog__section">
200-
<h4>' . esc_html__( 'Your Profile', 'activitypub' ) . '</h4>
201-
<div class="activitypub-dialog__description">
202-
' . esc_html__( 'Or, if you know your own profile, we can start things that way!', 'activitypub' ) . '
203-
</div>
204-
<div class="activitypub-dialog__button-group">
205-
<input
206-
type="text"
207-
id="remote-profile"
208-
placeholder="' . esc_attr__( '@[email protected]', 'activitypub' ) . '"
209-
data-wp-bind--value="context.remoteProfile"
210-
data-wp-on--input="actions.updateRemoteProfile"
211-
data-wp-on--keydown="actions.handleKeyDown"
212-
data-wp-bind--aria-invalid="context.isError"
213-
/>
214-
<button
215-
type="button"
216-
class="wp-element-button wp-block-button__link"
217-
data-wp-on--click="actions.submitRemoteProfile"
218-
aria-label="' . esc_attr__( 'Follow', 'activitypub' ) . '"
219-
data-wp-bind--disabled="context.isLoading"
220-
>
221-
<span data-wp-bind--hidden="context.isLoading">' . esc_html__( 'Follow', 'activitypub' ) . '</span>
222-
<span data-wp-bind--hidden="!context.isLoading">' . esc_html__( 'Loading&hellip;', 'activitypub' ) . '</span>
223-
</button>
224-
</div>
225-
<div
226-
class="activitypub-dialog__error"
227-
data-wp-bind--hidden="!context.isError"
228-
data-wp-text="context.errorMessage"
229-
></div>
230-
</div>
231-
';
232-
233235
// Render the modal using the Blocks class.
234236
Blocks::render_modal(
235237
array(

build/reactions/render.php

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,28 @@ function ( $reaction ) use ( $attributes ) {
138138
'data-wp-init' => 'callbacks.initReactions',
139139
)
140140
);
141+
142+
ob_start();
143+
?>
144+
<ul class="reactions-list">
145+
<template data-wp-each="context.modal.items">
146+
<li class="reaction-item">
147+
<a data-wp-bind--href="context.item.url" target="_blank" rel="noopener noreferrer">
148+
<img
149+
alt=""
150+
data-wp-bind--alt="context.item.name"
151+
data-wp-bind--src="context.item.avatar"
152+
data-wp-on--error="callbacks.setDefaultAvatar"
153+
src=""
154+
/>
155+
<span class="reaction-name" data-wp-text="context.item.name"></span>
156+
</a>
157+
</li>
158+
</template>
159+
</ul>
160+
<?php
161+
$modal_content = ob_get_clean();
162+
141163
?>
142164

143165
<div <?php echo $wrapper_attributes; // phpcs:ignore WordPress.Security.EscapeOutput ?>>
@@ -186,25 +208,6 @@ class="reaction-label wp-element-button"
186208
</div>
187209

188210
<?php
189-
$modal_content = '
190-
<ul class="reactions-list">
191-
<template data-wp-each="context.modal.items">
192-
<li class="reaction-item">
193-
<a data-wp-bind--href="context.item.url" target="_blank" rel="noopener noreferrer">
194-
<img
195-
data-wp-bind--src="context.item.avatar"
196-
data-wp-bind--alt="context.item.name"
197-
data-wp-on--error="callbacks.setDefaultAvatar"
198-
src=""
199-
alt=""
200-
/>
201-
<span class="reaction-name" data-wp-text="context.item.name"></span>
202-
</a>
203-
</li>
204-
</template>
205-
</ul>
206-
';
207-
208211
// Render the modal using the Blocks class.
209212
Blocks::render_modal(
210213
array(

build/remote-reply/render.php

Lines changed: 66 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -62,77 +62,73 @@
6262

6363
ob_start();
6464
?>
65-
<div class="activitypub-dialog__section">
66-
<h4><?php echo esc_html__( 'Original Comment URL', 'activitypub' ); ?></h4>
67-
<div class="activitypub-dialog__description">
68-
<?php echo esc_html__( 'Copy and paste the Comment URL into the search field of your favorite fediverse app or server.', 'activitypub' ); ?>
69-
</div>
70-
<div class="activitypub-dialog__button-group">
71-
<input
72-
type="text"
73-
id="profile-handle"
74-
value="<?php echo esc_attr( $selected_comment ); ?>"
75-
tabindex="-1"
76-
readonly
77-
aria-readonly="true"
78-
/>
79-
<button
80-
type="button"
81-
class="wp-element-button wp-block-button__link"
82-
data-wp-on--click="actions.copyToClipboard"
83-
aria-label="<?php echo esc_attr__( 'Copy URL to clipboard', 'activitypub' ); ?>"
84-
>
85-
<span data-wp-text="context.copyButtonText"></span>
86-
</button>
87-
</div>
65+
<div class="activitypub-dialog__section">
66+
<h4><?php esc_html_e( 'Original Comment URL', 'activitypub' ); ?></h4>
67+
<div class="activitypub-dialog__description">
68+
<?php esc_html_e( 'Copy and paste the Comment URL into the search field of your favorite fediverse app or server.', 'activitypub' ); ?>
69+
</div>
70+
<div class="activitypub-dialog__button-group">
71+
<input
72+
aria-readonly="true"
73+
id="profile-handle"
74+
readonly
75+
tabindex="-1"
76+
type="text"
77+
value="<?php echo esc_attr( $selected_comment ); ?>"
78+
/>
79+
<button
80+
aria-label="<?php esc_attr_e( 'Copy URL to clipboard', 'activitypub' ); ?>"
81+
class="wp-element-button wp-block-button__link"
82+
data-wp-on--click="actions.copyToClipboard"
83+
type="button"
84+
>
85+
<span data-wp-text="context.copyButtonText"></span>
86+
</button>
8887
</div>
89-
<div class="activitypub-dialog__section">
90-
<h4><?php echo esc_html__( 'Your Profile', 'activitypub' ); ?></h4>
91-
<div class="activitypub-dialog__description">
92-
<?php echo esc_html__( 'Or, if you know your own profile, we can start things that way!', 'activitypub' ); ?>
93-
</div>
94-
<div class="activitypub-dialog__button-group">
88+
</div>
89+
<div class="activitypub-dialog__section">
90+
<h4><?php esc_html_e( 'Your Profile', 'activitypub' ); ?></h4>
91+
<div class="activitypub-dialog__description">
92+
<?php esc_html_e( 'Or, if you know your own profile, we can start things that way!', 'activitypub' ); ?>
93+
</div>
94+
<div class="activitypub-dialog__button-group">
95+
<input
96+
data-wp-bind--aria-invalid="context.isError"
97+
data-wp-bind--value="context.remoteProfile"
98+
data-wp-on--input="actions.updateRemoteProfile"
99+
data-wp-on--keydown="actions.onInputKeydown"
100+
id="remote-profile"
101+
placeholder="<?php esc_attr_e( '@[email protected]', 'activitypub' ); ?>"
102+
type="text"
103+
/>
104+
<button
105+
aria-label="<?php esc_attr_e( 'Reply', 'activitypub' ); ?>"
106+
class="wp-element-button wp-block-button__link"
107+
data-wp-bind--disabled="context.isLoading"
108+
data-wp-on--click="actions.submitRemoteProfile"
109+
type="button"
110+
>
111+
<span data-wp-bind--hidden="context.isLoading"><?php esc_html_e( 'Reply', 'activitypub' ); ?></span>
112+
<span data-wp-bind--hidden="!context.isLoading"><?php esc_html_e( 'Loading&hellip;', 'activitypub' ); ?></span>
113+
</button>
114+
</div>
115+
<div
116+
class="activitypub-dialog__error"
117+
data-wp-bind--hidden="!context.isError"
118+
data-wp-text="context.errorMessage"
119+
></div>
120+
<div class="activitypub-dialog__remember">
121+
<label>
95122
<input
96-
type="text"
97-
id="remote-profile"
98-
placeholder="<?php echo esc_attr__( '@[email protected]', 'activitypub' ); ?>"
99-
data-wp-bind--value="context.remoteProfile"
100-
data-wp-on--input="actions.updateRemoteProfile"
101-
data-wp-on--keydown="actions.onInputKeydown"
102-
data-wp-bind--aria-invalid="context.isError"
123+
checked
124+
data-wp-bind--checked="context.shouldSaveProfile"
125+
data-wp-on--change="actions.toggleRememberProfile"
126+
type="checkbox"
103127
/>
104-
<button
105-
type="button"
106-
class="wp-element-button wp-block-button__link"
107-
data-wp-on--click="actions.submitRemoteProfile"
108-
aria-label="<?php echo esc_attr__( 'Reply', 'activitypub' ); ?>"
109-
data-wp-bind--disabled="context.isLoading"
110-
>
111-
<span data-wp-bind--hidden="context.isLoading">
112-
<?php echo esc_html__( 'Reply', 'activitypub' ); ?>
113-
</span>
114-
<span data-wp-bind--hidden="!context.isLoading">
115-
<?php echo esc_html__( 'Loading...', 'activitypub' ); ?>
116-
</span>
117-
</button>
118-
</div>
119-
<div
120-
class="activitypub-dialog__error"
121-
data-wp-bind--hidden="!context.isError"
122-
data-wp-text="context.errorMessage"
123-
></div>
124-
<div class="activitypub-dialog__remember">
125-
<label>
126-
<input
127-
type="checkbox"
128-
checked
129-
data-wp-bind--checked="context.shouldSaveProfile"
130-
data-wp-on--change="actions.toggleRememberProfile"
131-
/>
132-
<?php echo esc_html__( 'Save my profile for future comments.', 'activitypub' ); ?>
133-
</label>
134-
</div>
128+
<?php esc_html_e( 'Save my profile for future comments.', 'activitypub' ); ?>
129+
</label>
135130
</div>
131+
</div>
136132
<?php
137133
$modal_content = ob_get_clean();
138134

@@ -160,7 +156,7 @@ class="comment-reply-link activitypub-remote-profile__link"
160156
type="button"
161157
class="activitypub-remote-profile__close wp-element-button wp-block-button__link"
162158
data-wp-on--click="actions.deleteRemoteUser"
163-
title="<?php echo esc_attr__( 'Delete Remote Profile', 'activitypub' ); ?>"
159+
title="<?php esc_attr_e( 'Delete Remote Profile', 'activitypub' ); ?>"
164160
>
165161
<svg fill="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" width="18" height="18" role="img" aria-hidden="true" focusable="false">
166162
<path d="M12 13.06l3.712 3.713 1.061-1.06L13.061 12l3.712-3.712-1.06-1.06L12 10.938 8.288 7.227l-1.061 1.06L10.939 12l-3.712 3.712 1.06 1.061L12 13.061z"></path>
@@ -174,14 +170,14 @@ class="comment-reply-link activitypub-remote-reply__link"
174170
data-wp-on-async--keydown="actions.onReplyLinkKeydown"
175171
data-wp-bind--hidden="context.hasRemoteUser"
176172
data-wp-bind--aria-expanded="context.modal.isOpen"
177-
aria-label="<?php echo esc_attr__( 'Reply on the Fediverse', 'activitypub' ); ?>"
173+
aria-label="<?php esc_attr_e( 'Reply on the Fediverse', 'activitypub' ); ?>"
178174
aria-haspopup="dialog"
179175
aria-controls="modal-heading"
180176
role="button"
181177
tabindex="0"
182178
hidden
183179
>
184-
<?php echo esc_html__( 'Reply on the Fediverse', 'activitypub' ); ?>
180+
<?php esc_html_e( 'Reply on the Fediverse', 'activitypub' ); ?>
185181
</a>
186182

187183
<?php

0 commit comments

Comments
 (0)