PluginProbe
ActivityPub / 7.7.0
ActivityPub v7.7.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 | integration/class-classic-editor.php +16 -59 9.2.07.7.0 View file →
@@ -19,14 +19,10 @@
19 19 */
20 20 public static function init() {
21 21 \add_filter( 'activitypub_attachments_media_markup', array( self::class, 'filter_attachments_media_markup' ), 10, 2 );
22 22 \add_filter( 'activitypub_attachment_ids', array( self::class, 'filter_attached_media_ids' ), 10, 2 );
23 - \add_action( 'add_meta_boxes', array( self::class, 'add_meta_box' ), 10, 2 );
23 + \add_action( 'add_meta_boxes', array( self::class, 'add_meta_box' ) );
24 24 \add_action( 'save_post', array( self::class, 'save_meta_data' ) );
25 -
26 - if ( \function_exists( 'classicpress_version' ) ) {
27 - \add_filter( 'activitypub_site_supports_blocks', '__return_false' );
28 - }
29 25 }
30 26
31 27 /**
32 28 * Filter attachment media markup to use shortcodes instead of blocks.
@@ -40,13 +36,13 @@
40 36 if ( empty( $attachment_ids ) ) {
41 37 return $markup;
42 38 }
43 39
44 - $type = \strtok( \get_post_mime_type( $attachment_ids[0] ), '/' );
40 + $type = strtok( \get_post_mime_type( $attachment_ids[0] ), '/' );
45 41
46 42 // Single video or audio file: use media shortcode.
47 43 if ( 1 === \count( $attachment_ids ) && ( 'video' === $type || 'audio' === $type ) ) {
48 - return \sprintf(
44 + return sprintf(
49 45 '[%1$s src="%2$s"]',
50 46 \esc_attr( $type ),
51 47 \esc_url( \wp_get_attachment_url( $attachment_ids[0] ) )
52 48 );
@@ -52,9 +48,9 @@
52 48 );
53 49 }
54 50
55 51 // Multiple attachments or images: use gallery shortcode.
56 - return '[gallery ids="' . \implode( ',', $attachment_ids ) . '" link="none"]';
52 + return '[gallery ids="' . implode( ',', $attachment_ids ) . '" link="none"]';
57 53 }
58 54
59 55 /**
60 56 * Filter to add attached media IDs from the post's media library.
@@ -91,9 +87,9 @@
91 87 );
92 88
93 89 // Transform IDs into associative arrays.
94 90 $media_ids = \array_map(
95 - static function ( $id ) {
91 + function ( $id ) {
96 92 return array( 'id' => $id );
97 93 },
98 94 $query->get_posts()
99 95 );
@@ -103,28 +99,16 @@
103 99
104 100 /**
105 101 * Add ActivityPub meta box to the post editor.
106 102 *
107 - * @param string $post_type The post type.
108 - * @param \WP_Post|null $post The post being edited.
103 + * @param string $post_type The post type.
109 104 */
110 - public static function add_meta_box( $post_type, $post = null ) {
105 + public static function add_meta_box( $post_type ) {
111 106 // Only add for post types that support ActivityPub.
112 107 if ( ! \post_type_supports( $post_type, 'activitypub' ) ) {
113 108 return;
114 109 }
115 110
116 - /*
117 - * The block editor ships its own ActivityPub panel, so the classic meta box must not be
118 - * added there. With the Classic Editor plugin in switchable mode a post can still open in
119 - * the block editor, where both would otherwise render and the meta box's save_post handler
120 - * would overwrite the panel's value. The function_exists() check keeps ClassicPress and
121 - * other block-less setups (where use_block_editor_for_post() is absent) safe.
122 - */
123 - if ( $post instanceof \WP_Post && \function_exists( 'use_block_editor_for_post' ) && \use_block_editor_for_post( $post ) ) {
124 - return;
125 - }
126 -
127 111 \add_meta_box(
128 112 'activitypub-settings',
129 113 \__( 'Fediverse ⁂', 'activitypub' ),
130 114 array( self::class, 'render_meta_box' ),
@@ -146,10 +130,9 @@
146 130 // Get current values.
147 131 $content_warning = \get_post_meta( $post->ID, 'activitypub_content_warning', true );
148 132 $max_image_attachments = \get_post_meta( $post->ID, 'activitypub_max_image_attachments', true );
149 133 $content_visibility = self::get_default_visibility( $post );
150 - $default_quote_policy = \get_option( 'activitypub_default_quote_policy', ACTIVITYPUB_INTERACTION_POLICY_ANYONE );
151 - $quote_interaction = \get_post_meta( $post->ID, 'activitypub_interaction_policy_quote', true ) ?: $default_quote_policy;
134 + $quote_interaction = \get_post_meta( $post->ID, 'activitypub_interaction_policy_quote', true ) ?: ACTIVITYPUB_INTERACTION_POLICY_ANYONE;
152 135
153 136 ?>
154 137 <p>
155 138 <label for="activitypub_content_warning">
@@ -169,17 +152,17 @@
169 152
170 153 <p>
171 154 <strong><?php \esc_html_e( 'Visibility', 'activitypub' ); ?></strong><br />
172 155 <label>
173 - <input type="radio" name="activitypub_content_visibility" value="<?php echo \esc_attr( ACTIVITYPUB_CONTENT_VISIBILITY_PUBLIC ); ?>" <?php \checked( $content_visibility, ACTIVITYPUB_CONTENT_VISIBILITY_PUBLIC ); ?> />
156 + <input type="radio" name="activitypub_content_visibility" value="public" <?php \checked( $content_visibility, ACTIVITYPUB_CONTENT_VISIBILITY_PUBLIC ); ?> />
174 157 <?php \esc_html_e( 'Public', 'activitypub' ); ?>
175 158 </label><br />
176 159 <label>
177 - <input type="radio" name="activitypub_content_visibility" value="<?php echo \esc_attr( ACTIVITYPUB_CONTENT_VISIBILITY_QUIET_PUBLIC ); ?>" <?php \checked( $content_visibility, ACTIVITYPUB_CONTENT_VISIBILITY_QUIET_PUBLIC ); ?> />
160 + <input type="radio" name="activitypub_content_visibility" value="quiet_public" <?php \checked( $content_visibility, ACTIVITYPUB_CONTENT_VISIBILITY_QUIET_PUBLIC ); ?> />
178 161 <?php \esc_html_e( 'Quiet public', 'activitypub' ); ?>
179 162 </label><br />
180 163 <label>
181 - <input type="radio" name="activitypub_content_visibility" value="<?php echo \esc_attr( ACTIVITYPUB_CONTENT_VISIBILITY_LOCAL ); ?>" <?php \checked( $content_visibility, ACTIVITYPUB_CONTENT_VISIBILITY_LOCAL ); ?> />
164 + <input type="radio" name="activitypub_content_visibility" value="local" <?php \checked( $content_visibility, ACTIVITYPUB_CONTENT_VISIBILITY_LOCAL ); ?> />
182 165 <?php \esc_html_e( 'Do not federate', 'activitypub' ); ?>
183 166 </label><br />
184 167 <span class="howto"><?php \esc_html_e( 'This adjusts the visibility of a post in the fediverse, but note that it won\'t affect how the post appears on the blog.', 'activitypub' ); ?></span>
185 168 </p>
@@ -188,44 +171,18 @@
188 171 <label for="activitypub_interaction_policy_quote">
189 172 <strong><?php \esc_html_e( 'Who can quote this post?', 'activitypub' ); ?></strong>
190 173 </label><br />
191 174 <select id="activitypub_interaction_policy_quote" name="activitypub_interaction_policy_quote" class="widefat">
192 - <option value="<?php echo \esc_attr( ACTIVITYPUB_INTERACTION_POLICY_ANYONE ); ?>" <?php \selected( $quote_interaction, ACTIVITYPUB_INTERACTION_POLICY_ANYONE ); ?>><?php \esc_html_e( 'Anyone', 'activitypub' ); ?></option>
193 - <option value="<?php echo \esc_attr( ACTIVITYPUB_INTERACTION_POLICY_FOLLOWERS ); ?>" <?php \selected( $quote_interaction, ACTIVITYPUB_INTERACTION_POLICY_FOLLOWERS ); ?>><?php \esc_html_e( 'Followers only', 'activitypub' ); ?></option>
194 - <option value="<?php echo \esc_attr( ACTIVITYPUB_INTERACTION_POLICY_ME ); ?>" <?php \selected( $quote_interaction, ACTIVITYPUB_INTERACTION_POLICY_ME ); ?>><?php \esc_html_e( 'Just me', 'activitypub' ); ?></option>
175 + <option value="anyone" <?php \selected( $quote_interaction, ACTIVITYPUB_INTERACTION_POLICY_ANYONE ); ?>><?php \esc_html_e( 'Anyone', 'activitypub' ); ?></option>
176 + <option value="followers" <?php \selected( $quote_interaction, ACTIVITYPUB_INTERACTION_POLICY_FOLLOWERS ); ?>><?php \esc_html_e( 'Followers only', 'activitypub' ); ?></option>
177 + <option value="me" <?php \selected( $quote_interaction, ACTIVITYPUB_INTERACTION_POLICY_ME ); ?>><?php \esc_html_e( 'Just me', 'activitypub' ); ?></option>
195 178 </select>
196 - <span class="howto">
197 - <?php \esc_html_e( 'Quoting allows others to cite your post while adding their own commentary.', 'activitypub' ); ?>
198 - <?php
199 - \printf(
200 - /* translators: %s: The current site default quote policy. Note the leading space. */
201 - \esc_html__( ' Site default: %s', 'activitypub' ),
202 - \esc_html( self::get_quote_policy_label( $default_quote_policy ) )
203 - );
204 - ?>
205 - </span>
179 + <span class="howto"><?php \esc_html_e( 'Quoting allows others to cite your post while adding their own commentary.', 'activitypub' ); ?></span>
206 180 </p>
207 181 <?php
208 182 }
209 183
210 184 /**
211 - * Get the label for a quote policy value.
212 - *
213 - * @param string $policy The policy value.
214 - *
215 - * @return string The translated label.
216 - */
217 - private static function get_quote_policy_label( $policy ) {
218 - $labels = array(
219 - ACTIVITYPUB_INTERACTION_POLICY_ANYONE => \__( 'Anyone', 'activitypub' ),
220 - ACTIVITYPUB_INTERACTION_POLICY_FOLLOWERS => \__( 'Followers only', 'activitypub' ),
221 - ACTIVITYPUB_INTERACTION_POLICY_ME => \__( 'Just me', 'activitypub' ),
222 - );
223 -
224 - return $labels[ $policy ] ?? $labels[ ACTIVITYPUB_INTERACTION_POLICY_ANYONE ];
225 - }
226 -
227 - /**
228 185 * Get default visibility based on post age and federation status.
229 186 *
230 187 * @param \WP_Post $post The post object.
231 188 *
@@ -239,9 +196,9 @@
239 196 }
240 197
241 198 // If post is federated, use public.
242 199 $status = \get_post_meta( $post->ID, 'activitypub_status', true );
243 - if ( ACTIVITYPUB_OBJECT_STATE_FEDERATED === $status ) {
200 + if ( 'federated' === $status ) {
244 201 return ACTIVITYPUB_CONTENT_VISIBILITY_PUBLIC;
245 202 }
246 203
247 204 // If post is older than 1 month, default to local.