Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump Min WP Version to 6.4 #1287

Draft
wants to merge 2 commits into
base: trunk
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/phpunit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
php-versions: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4']
include:
- wp-version: latest
- wp-version: '5.9'
- wp-version: '6.4'
php-versions: '7.2'
steps:
- name: Install svn
Expand Down
3 changes: 1 addition & 2 deletions includes/collection/class-extra-fields.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,7 @@ public static function fields_to_attachments( $fields ) {
if (
\stripos( $link_content, '<a' ) === 0 &&
\stripos( $link_content, '<a', 3 ) === false &&
\stripos( $link_content, '</a>', \strlen( $link_content ) - 4 ) !== false &&
\class_exists( '\WP_HTML_Tag_Processor' )
\stripos( $link_content, '</a>', \strlen( $link_content ) - 4 ) !== false
) {
$tags = new \WP_HTML_Tag_Processor( $link_content );
$tags->next_tag( 'A' );
Expand Down
11 changes: 0 additions & 11 deletions includes/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -553,17 +553,6 @@ function is_single_user() {
* @return boolean True if the site supports the block editor, false otherwise.
*/
function site_supports_blocks() {
if ( \version_compare( \get_bloginfo( 'version' ), '5.9', '<' ) ) {
return false;
}

if (
! \function_exists( 'register_block_type_from_metadata' ) ||
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's keep that, so that it will still work with classicpress or the classic editor enabled.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The functions exist with the classic editor enabled. Should ClassicPress be a consideration?

! \function_exists( 'do_blocks' )
) {
return false;
}

/**
* Allow plugins to disable block editor support,
* thus disabling blocks registered by the ActivityPub plugin.
Expand Down
43 changes: 1 addition & 42 deletions includes/transformer/class-post.php
Original file line number Diff line number Diff line change
Expand Up @@ -794,11 +794,7 @@ protected function get_classic_editor_images( $media, $max_images ) {
}

if ( \count( $media['image'] ) <= $max_images ) {
if ( \class_exists( '\WP_HTML_Tag_Processor' ) ) {
$media['image'] = \array_merge( $media['image'], $this->get_classic_editor_image_embeds( $max_images ) );
} else {
$media['image'] = \array_merge( $media['image'], $this->get_classic_editor_image_attachments( $max_images ) );
}
$media['image'] = \array_merge( $media['image'], $this->get_classic_editor_image_embeds( $max_images ) );
}

return $media;
Expand Down Expand Up @@ -884,43 +880,6 @@ protected function get_classic_editor_image_embeds( $max_images ) {
return $images;
}

/**
* Get image attachments from the classic editor.
* This is imperfect as the contained images aren't necessarily the
* same as the attachments.
*
* @param int $max_images The maximum number of images to return.
*
* @return array The attachment IDs.
*/
protected function get_classic_editor_image_attachments( $max_images ) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's keep that, for people that still use the classic editor

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, this is only about the attachments 🤔

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good to remove?

// Max images can't be negative or zero.
if ( $max_images <= 0 ) {
return array();
}

$images = array();
$query = new \WP_Query(
array(
'post_parent' => $this->item->ID,
'post_status' => 'inherit',
'post_type' => 'attachment',
'post_mime_type' => 'image',
'order' => 'ASC',
'orderby' => 'menu_order ID',
'posts_per_page' => $max_images,
)
);

foreach ( $query->get_posts() as $attachment ) {
if ( ! \in_array( $attachment->ID, $images, true ) ) {
$images[] = array( 'id' => $attachment->ID );
}
}

return $images;
}

/**
* Filter media IDs by object type.
*
Expand Down
2 changes: 1 addition & 1 deletion phpcs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<rule ref="PHPCompatibility"/>
<config name="testVersion" value="7.2-"/>
<rule ref="PHPCompatibilityWP"/>
<config name="minimum_supported_wp_version" value="5.5"/>
<config name="minimum_supported_wp_version" value="6.4"/>

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

Expand Down
2 changes: 1 addition & 1 deletion readme.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
=== ActivityPub ===
Contributors: automattic, pfefferle, mattwiebe, obenland, akirk, jeherve, mediaformat, nuriapena, cavalierlife, andremenrath
Tags: OStatus, fediverse, activitypub, activitystream
Requires at least: 5.5
Requires at least: 6.4
Tested up to: 6.7
Stable tag: 5.1.0
Requires PHP: 7.2
Expand Down
4 changes: 0 additions & 4 deletions tests/includes/collection/class-test-extra-fields.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@ class Test_Extra_Fields extends \WP_UnitTestCase {
* @covers ::get_attachment
*/
public function test_get_attachment() {
if ( ! class_exists( '\WP_HTML_Tag_Processor' ) ) {
$this->markTestSkipped( 'WP_HTML_Tag_Processor not available' );
}

$post = self::factory()->post->create_and_get(
array(
'post_type' => Extra_Fields::BLOG_POST_TYPE,
Expand Down
4 changes: 0 additions & 4 deletions tests/includes/rest/class-test-actors-controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,6 @@ public function test_get_item_schema() {
* @covers ::get_item_schema
*/
public function test_response_matches_schema() {
if ( ! class_exists( '\WP_HTML_Tag_Processor' ) ) {
$this->markTestSkipped( 'WP_HTML_Tag_Processor not available' );
}

$request = new \WP_REST_Request( 'GET', '/' . ACTIVITYPUB_REST_NAMESPACE . '/users/' . self::$user_id );
$response = rest_get_server()->dispatch( $request );
$data = $response->get_data();
Expand Down
10 changes: 0 additions & 10 deletions tests/includes/transformer/class-test-post.php
Original file line number Diff line number Diff line change
Expand Up @@ -370,16 +370,6 @@ public function test_block_attachments_with_fallback() {
)
);

// For WP versions 6.1 and prior, we only look for attached images.
if ( ! class_exists( 'WP_HTML_Tag_Processor' ) ) {
wp_update_post(
array(
'ID' => $attachment_id,
'post_parent' => $post_id,
)
);
}

$object = Post::transform( get_post( $post_id ) )->to_object();

$this->assertEquals(
Expand Down
Loading