Skip to content

Commit 5b89e8d

Browse files
obenlandpfefferle
andauthored
Bump Min WP Version to 6.4 (#1287)
* Bump Min WP Version to 6.4 * Add changelog * Remove unneeded fallback get_self_link() was introduced in 5.3. * update changelog * remove extra layer * Add missing phpdoc * Keep Tag Processor check for a while longer --------- Co-authored-by: Matthias Pfefferle <[email protected]>
1 parent afdf7f3 commit 5b89e8d

File tree

10 files changed

+13
-117
lines changed

10 files changed

+13
-117
lines changed

.github/workflows/phpunit.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
php-versions: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4']
2121
include:
2222
- wp-version: latest
23-
- wp-version: '5.9'
23+
- wp-version: '6.4'
2424
php-versions: '7.2'
2525
steps:
2626
- name: Install svn

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3535

3636
* Outbox now precesses the first batch of followers right away to avoid delays in processing new Activities.
3737
* Post bulk edits no longer create Outbox items, unless author or post status change.
38+
* Bumped minimum required WordPress version to 6.4.
3839
* Properly process `Update` activities on profiles and ensure all properties of a followed person are updated accordingly.
3940
* Outbox processing accounts for shared inboxes again.
4041
* Improved check for `?activitypub` query-var.

includes/compat.php

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -25,25 +25,6 @@ function str_starts_with( $haystack, $needle ) {
2525
}
2626
}
2727

28-
if ( ! function_exists( 'get_self_link' ) ) {
29-
/**
30-
* Returns the link for the currently displayed feed.
31-
*
32-
* @return string Correct link for the atom:self element.
33-
*/
34-
function get_self_link() {
35-
$host = wp_parse_url( home_url() );
36-
$path = isset( $_SERVER['REQUEST_URI'] ) ? sanitize_text_field( wp_unslash( $_SERVER['REQUEST_URI'] ) ) : '';
37-
38-
/**
39-
* Filters the self link.
40-
*
41-
* @param string $link The self link.
42-
*/
43-
return esc_url( apply_filters( 'self_link', set_url_scheme( 'http://' . $host['host'] . $path ) ) );
44-
}
45-
}
46-
4728
if ( ! function_exists( 'is_countable' ) ) {
4829
/**
4930
* Polyfill for `is_countable()` function added in PHP 7.3.

includes/functions.php

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -471,17 +471,6 @@ function is_single_user() {
471471
* @return boolean True if the site supports the block editor, false otherwise.
472472
*/
473473
function site_supports_blocks() {
474-
if ( \version_compare( \get_bloginfo( 'version' ), '5.9', '<' ) ) {
475-
return false;
476-
}
477-
478-
if (
479-
! \function_exists( 'register_block_type_from_metadata' ) ||
480-
! \function_exists( 'do_blocks' )
481-
) {
482-
return false;
483-
}
484-
485474
/**
486475
* Allow plugins to disable block editor support,
487476
* thus disabling blocks registered by the ActivityPub plugin.

includes/transformer/class-post.php

Lines changed: 8 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ protected function get_attachment() {
315315
if ( site_supports_blocks() && \has_blocks( $this->item->post_content ) ) {
316316
$media = $this->get_block_attachments( $media, $max_media );
317317
} else {
318-
$media = $this->get_classic_editor_images( $media, $max_media );
318+
$media = $this->get_classic_editor_image_embeds( $media, $max_media );
319319
}
320320

321321
$media = $this->filter_media_by_object_type( $media, \get_post_format( $this->item ), $this->item );
@@ -785,47 +785,22 @@ function ( $id ) {
785785
}
786786

787787
/**
788-
* Get post images from the classic editor.
789-
* Note that audio/video attachments are only supported in the block editor.
788+
* Get image embeds from the classic editor by parsing HTML.
790789
*
791790
* @param array $media The media array grouped by type.
792791
* @param int $max_images The maximum number of images to return.
793792
*
794793
* @return array The attachments.
795794
*/
796-
protected function get_classic_editor_images( $media, $max_images ) {
797-
// Max images can't be negative or zero.
798-
if ( $max_images <= 0 ) {
799-
return array();
800-
}
801-
802-
if ( \count( $media['image'] ) <= $max_images ) {
803-
if ( \class_exists( '\WP_HTML_Tag_Processor' ) ) {
804-
$media['image'] = \array_merge( $media['image'], $this->get_classic_editor_image_embeds( $max_images ) );
805-
} else {
806-
$media['image'] = \array_merge( $media['image'], $this->get_classic_editor_image_attachments( $max_images ) );
807-
}
808-
}
809-
810-
return $media;
811-
}
812-
813-
/**
814-
* Get image embeds from the classic editor by parsing HTML.
815-
*
816-
* @param int $max_images The maximum number of images to return.
817-
*
818-
* @return array The attachments.
819-
*/
820-
protected function get_classic_editor_image_embeds( $max_images ) {
795+
protected function get_classic_editor_image_embeds( $media, $max_images ) {
821796
// If someone calls that function directly, bail.
822797
if ( ! \class_exists( '\WP_HTML_Tag_Processor' ) ) {
823-
return array();
798+
return $media;
824799
}
825800

826801
// Max images can't be negative or zero.
827802
if ( $max_images <= 0 ) {
828-
return array();
803+
return $media;
829804
}
830805

831806
$images = array();
@@ -887,44 +862,11 @@ protected function get_classic_editor_image_embeds( $max_images ) {
887862
}
888863
}
889864

890-
return $images;
891-
}
892-
893-
/**
894-
* Get image attachments from the classic editor.
895-
* This is imperfect as the contained images aren't necessarily the
896-
* same as the attachments.
897-
*
898-
* @param int $max_images The maximum number of images to return.
899-
*
900-
* @return array The attachment IDs.
901-
*/
902-
protected function get_classic_editor_image_attachments( $max_images ) {
903-
// Max images can't be negative or zero.
904-
if ( $max_images <= 0 ) {
905-
return array();
906-
}
907-
908-
$images = array();
909-
$query = new \WP_Query(
910-
array(
911-
'post_parent' => $this->item->ID,
912-
'post_status' => 'inherit',
913-
'post_type' => 'attachment',
914-
'post_mime_type' => 'image',
915-
'order' => 'ASC',
916-
'orderby' => 'menu_order ID',
917-
'posts_per_page' => $max_images,
918-
)
919-
);
920-
921-
foreach ( $query->get_posts() as $attachment ) {
922-
if ( ! \in_array( $attachment->ID, $images, true ) ) {
923-
$images[] = array( 'id' => $attachment->ID );
924-
}
865+
if ( \count( $media['image'] ) <= $max_images ) {
866+
$media['image'] = \array_merge( $media['image'], $images );
925867
}
926868

927-
return $images;
869+
return $media;
928870
}
929871

930872
/**

phpcs.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<rule ref="PHPCompatibility"/>
1818
<config name="testVersion" value="7.2-"/>
1919
<rule ref="PHPCompatibilityWP"/>
20-
<config name="minimum_supported_wp_version" value="5.5"/>
20+
<config name="minimum_supported_wp_version" value="6.4"/>
2121

2222
<config name="text_domain" value="activitypub,default"/>
2323

readme.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
=== ActivityPub ===
22
Contributors: automattic, pfefferle, mattwiebe, obenland, akirk, jeherve, mediaformat, nuriapena, cavalierlife, andremenrath
33
Tags: OStatus, fediverse, activitypub, activitystream
4-
Requires at least: 5.5
4+
Requires at least: 6.4
55
Tested up to: 6.7
66
Stable tag: 5.3.0
77
Requires PHP: 7.2
@@ -147,6 +147,7 @@ For reasons of data protection, it is not possible to see the followers of other
147147
* Added: Outbox Activity IDs can now be resolved when the ActivityPub `Accept header is used.
148148
* Added: Labels to add context to visibility settings in the block editor.
149149
* Added: WP CLI command to reschedule Outbox-Activities.
150+
* Changed: Bumped minimum required WordPress version to 6.4.
150151
* Changed: Properly process `Update` activities on profiles and ensure all properties of a followed person are updated accordingly.
151152
* Changed: Outbox now precesses the first batch of followers right away to avoid delays in processing new Activities.
152153
* Changed: Post bulk edits no longer create Outbox items, unless author or post status change.

tests/includes/collection/class-test-extra-fields.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,6 @@ class Test_Extra_Fields extends \WP_UnitTestCase {
2222
* @covers ::get_attachment
2323
*/
2424
public function test_get_attachment() {
25-
if ( ! class_exists( '\WP_HTML_Tag_Processor' ) ) {
26-
$this->markTestSkipped( 'WP_HTML_Tag_Processor not available' );
27-
}
28-
2925
$post = self::factory()->post->create_and_get(
3026
array(
3127
'post_type' => Extra_Fields::BLOG_POST_TYPE,

tests/includes/rest/class-test-actors-controller.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -167,10 +167,6 @@ public function test_get_item_schema() {
167167
* @covers ::get_item_schema
168168
*/
169169
public function test_response_matches_schema() {
170-
if ( ! class_exists( '\WP_HTML_Tag_Processor' ) ) {
171-
$this->markTestSkipped( 'WP_HTML_Tag_Processor not available' );
172-
}
173-
174170
$request = new \WP_REST_Request( 'GET', '/' . ACTIVITYPUB_REST_NAMESPACE . '/users/' . self::$user_id );
175171
$response = rest_get_server()->dispatch( $request );
176172
$data = $response->get_data();

tests/includes/transformer/class-test-post.php

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -370,16 +370,6 @@ public function test_block_attachments_with_fallback() {
370370
)
371371
);
372372

373-
// For WP versions 6.1 and prior, we only look for attached images.
374-
if ( ! class_exists( 'WP_HTML_Tag_Processor' ) ) {
375-
wp_update_post(
376-
array(
377-
'ID' => $attachment_id,
378-
'post_parent' => $post_id,
379-
)
380-
);
381-
}
382-
383373
$object = Post::transform( get_post( $post_id ) )->to_object();
384374

385375
$this->assertEquals(

0 commit comments

Comments
 (0)