Skip to content

Commit 49de60c

Browse files
author
10upbot on GitHub
committed
Committing built version of 90a5629
1 parent a0fbe31 commit 49de60c

File tree

10 files changed

+336
-19
lines changed

10 files changed

+336
-19
lines changed

.github/workflows/cypress.yml

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,11 @@ jobs:
4747
- {name: 'PHP Default', version: null}
4848
core:
4949
- {name: 'WP stable', version: 'latest'}
50-
- {name: 'WP 6.4', version: 'WordPress/WordPress#6.4'}
50+
- {name: 'WP minimum', version: 'WordPress/WordPress#6.5'}
5151
- {name: 'WP trunk', version: 'WordPress/WordPress#master'}
5252
include:
5353
- php: {name: 'PHP 7.4', version: '7.4'}
54-
core: {name: 'WP 6.4', version: 'WordPress/WordPress#6.4'}
54+
core: {name: 'WP minimum', version: 'WordPress/WordPress#6.5'}
5555
- php: {name: 'PHP 8.1', version: '8.1'}
5656
core: {name: 'WP stable', version: 'latest'}
5757
steps:
@@ -78,6 +78,26 @@ jobs:
7878
- name: Install dependencies
7979
run: npm install
8080

81+
- name: Get composer cache directory
82+
id: composer-cache
83+
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
84+
85+
- name: Cache dependencies
86+
id: cache-composer
87+
uses: actions/cache@v4
88+
env:
89+
cache-name: cache-composer
90+
with:
91+
path: ${{ steps.composer-cache.outputs.dir }}
92+
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/composer.lock') }}
93+
94+
- name: Set PHP version
95+
uses: shivammathur/setup-php@v2
96+
with:
97+
php-version: ${{ matrix.php.version }}
98+
coverage: none
99+
tools: composer:v2
100+
81101
- name: Composer install
82102
run: composer install
83103

CHANGELOG.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,24 @@ All notable changes to this project will be documented in this file, per [the Ke
44

55
## [Unreleased] - TBD
66

7+
## [2.1.0] - 2025-02-10
8+
**Note that this release bumps the WordPress minimum supported version from 6.4 to 6.5.**
9+
10+
### Added
11+
- When the setting to distribute all images is turned on, do a search/replace on the distributed content to update the image URLs from the origin site to the destination site (props [@dkotter](https://github.com/dkotter), [@iamdharmesh](https://github.com/iamdharmesh), [@willemb2](https://github.com/willemb2), [@dcarrionc](https://github.com/dcarrionc), [@lucymtc](https://github.com/lucymtc), [@Sidsector9](https://github.com/Sidsector9) via [#1283](https://github.com/10up/distributor/pull/1283)).
12+
13+
### Changed
14+
- The default value of the filter `dt_sync_media_delete_and_replace` has been updated from `true` to `false`. This means by default, if an existing media item is found, it is not deleted and replaced, whereas previously it was (props [@philbraun](https://github.com/philbraun), [@iamdharmesh](https://github.com/iamdharmesh), [@jeffpaul](https://github.com/jeffpaul), [@peterwilsoncc](https://github.com/peterwilsoncc) via [#1296](https://github.com/10up/distributor/pull/1296)).
15+
- Bump WordPress "tested up to" version 6.7 (props [@jeffpaul](https://github.com/jeffpaul), [@qasumitbagthariya](https://github.com/qasumitbagthariya), [@iamdharmesh](https://github.com/iamdharmesh) via [#1290](https://github.com/10up/distributor/pull/1214)).
16+
- Bump WordPress minimum from 6.4 to 6.5 (props [@jeffpaul](https://github.com/jeffpaul), [@qasumitbagthariya](https://github.com/qasumitbagthariya), [@iamdharmesh](https://github.com/iamdharmesh) via [#1290](https://github.com/10up/distributor/pull/1214)).
17+
18+
### Fixed
19+
- Resolved the media duplication issue when the same image is used in multiple posts (props [@philbraun](https://github.com/philbraun), [@iamdharmesh](https://github.com/iamdharmesh), [@jeffpaul](https://github.com/jeffpaul), [@peterwilsoncc](https://github.com/peterwilsoncc) via [#1296](https://github.com/10up/distributor/pull/1296)).
20+
- Update the Show Connections AMP template to avoid a JS error (props [@s3rgiosan](https://github.com/s3rgiosan), [@dkotter](https://github.com/dkotter) via [#1293](https://github.com/10up/distributor/pull/1293)).
21+
22+
### Developer
23+
- Add WordPress Playground integration (props [@dottxado](https://github.com/dottxado), [@jeffpaul](https://github.com/jeffpaul), [@dkotter](https://github.com/dkotter) via [#1282](https://github.com/10up/distributor/pull/1282)).
24+
725
## [2.0.6] - 2024-09-26
826
### Changed
927
- Improved the management of pulled content both from the admin post list view and from the admin single post view, making it easier to see what content has been pulled and what content is linked or not linked, as well as making linking and unlinking clearer (props [@roshniahuja](https://github.com/roshniahuja), [@faisal-alvi](https://github.com/faisal-alvi), [@ravinderk](https://github.com/ravinderk), [@iamdharmesh](https://github.com/iamdharmesh), [@Sidsector9](https://github.com/Sidsector9), [@dkotter](https://github.com/dkotter), [@jeffpaul](https://github.com/jeffpaul), [@oszkarnagy](https://github.com/oszkarnagy) via [#1036](https://github.com/10up/distributor/pull/1036)).
@@ -579,6 +597,7 @@ This adds a post type selector when viewing the Pull Content list for both exter
579597
- Initial closed release.
580598

581599
[Unreleased]: https://github.com/10up/distributor/compare/trunk...develop
600+
[2.1.0]: https://github.com/10up/distributor/compare/2.0.6...2.1.0
582601
[2.0.6]: https://github.com/10up/distributor/compare/2.0.5...2.0.6
583602
[2.0.5]: https://github.com/10up/distributor/compare/2.0.4...2.0.5
584603
[2.0.4]: https://github.com/10up/distributor/compare/2.0.3...2.0.4

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
![Distributor](https://github.com/10up/distributor/blob/develop/assets/img/banner-1544x500.png)
44

5-
[![Support Level](https://img.shields.io/badge/support-active-green.svg)](#support-level) [![Release Version](https://img.shields.io/github/release/10up/distributor.svg)](https://github.com/10up/distributor/releases/latest) ![WordPress tested up to version](https://img.shields.io/badge/WordPress-v6.6%20tested-success.svg) [![License](https://img.shields.io/github/license/10up/distributor.svg)](https://github.com/10up/distributor/blob/develop/LICENSE.md) [![Dependency Review](https://github.com/10up/distributor/actions/workflows/dependency-review.yml/badge.svg)](https://github.com/10up/distributor/actions/workflows/dependency-review.yml)
5+
[![Support Level](https://img.shields.io/badge/support-active-green.svg)](#support-level) [![Release Version](https://img.shields.io/github/release/10up/distributor.svg)](https://github.com/10up/distributor/releases/latest) ![WordPress tested up to version](https://img.shields.io/badge/WordPress-v6.7%20tested-success.svg) [![License](https://img.shields.io/github/license/10up/distributor.svg)](https://github.com/10up/distributor/blob/develop/LICENSE.md) [![Dependency Review](https://github.com/10up/distributor/actions/workflows/dependency-review.yml/badge.svg)](https://github.com/10up/distributor/actions/workflows/dependency-review.yml) [![WordPress Playground Demo](https://img.shields.io/badge/Playground_Demo-8A2BE2?logo=wordpress&logoColor=FFFFFF&labelColor=3858E9&color=3858E9)](https://playground.wordpress.net/?blueprint-url=https://raw.githubusercontent.com/10up/distributor/refs/heads/develop/docs/blueprint.json)
66
[![E2E Tests](https://github.com/10up/distributor/actions/workflows/cypress.yml/badge.svg)](https://github.com/10up/distributor/actions/workflows/cypress.yml) [![PHPUnit Tests](https://github.com/10up/distributor/actions/workflows/test.yml/badge.svg)](https://github.com/10up/distributor/actions/workflows/test.yml) [![Linting](https://github.com/10up/distributor/actions/workflows/lint.yml/badge.svg)](https://github.com/10up/distributor/actions/workflows/lint.yml) [![Code scanning](https://github.com/10up/distributor/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/10up/distributor/actions/workflows/codeql-analysis.yml)
77

88
> Distributor is a WordPress plugin that makes it easy to distribute and reuse content across your websites — whether in a single multisite or across the web.
@@ -38,7 +38,7 @@ Distributor is built with the same extensible approach as WordPress itself, with
3838
## Requirements
3939

4040
* PHP 7.4+
41-
* [WordPress](http://wordpress.org) 6.4+
41+
* [WordPress](http://wordpress.org) 6.5+
4242
* External connections require HTTP Basic Authentication or [WordPress.com OAuth2](https://developer.wordpress.com/docs/oauth2/) (must be on [WordPress VIP](https://wpvip.com/)) be set up on the remote website. For Basic Auth, we recommend using [Application Passwords](https://make.wordpress.org/core/2020/11/05/application-passwords-integration-guide/#Getting-Credentials) built in to WordPress.
4343
* For external connections, Distributor needs to be installed on BOTH sides of the connection.
4444
* Version 2.0.0 of Distributor requires version 2.0.0 on BOTH sides of all connections. For other version 2.0.0 specific changes, please see our [migration guide](https://10up.github.io/distributor/tutorial-migration-guide-version-1-to-version-2.html).

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"require-dev": {
2424
"10up/phpcs-composer": "dev-master",
2525
"10up/wp_mock": "~0.4",
26-
"phpunit/phpunit": ">=7.0 <9.0",
26+
"phpunit/phpunit": "^8.5",
2727
"yoast/phpunit-polyfills": "^1.0",
2828
"automattic/vipwpcs": "^2.3"
2929
},

distributor.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
* Plugin URI: https://github.com/10up/distributor
55
* Update URI: https://distributorplugin.com
66
* Description: Makes it easy to distribute and reuse content across your websites, whether inside of a multisite or across the web.
7-
* Version: 2.0.6
8-
* Requires at least: 6.4
7+
* Version: 2.1.0
8+
* Requires at least: 6.5
99
* Requires PHP: 7.4
1010
* Author: 10up Inc.
1111
* Author URI: https://distributorplugin.com
@@ -28,7 +28,7 @@
2828
exit; // Exit if accessed directly.
2929
}
3030

31-
define( 'DT_VERSION', '2.0.6' );
31+
define( 'DT_VERSION', '2.1.0' );
3232
define( 'DT_PLUGIN_FILE', preg_replace( '#^.*plugins/(.*)$#i', '$1', __FILE__ ) );
3333
define( 'DT_PLUGIN_PATH', plugin_dir_path( __FILE__ ) );
3434
define( 'DT_PLUGIN_FULL_FILE', __FILE__ );
@@ -50,7 +50,7 @@
5050
* @return string Minimum version required.
5151
*/
5252
function minimum_wp_requirement() {
53-
return '6.4';
53+
return '6.5';
5454
}
5555

5656
/**
@@ -88,7 +88,7 @@ function site_meets_php_requirements() {
8888
}
8989

9090
/**
91-
* Require PHP 7.4+, WP 6.4+ - throw an error if the plugin is activated on an older version.
91+
* Require PHP 7.4+, WP 6.5+ - throw an error if the plugin is activated on an older version.
9292
*/
9393
register_activation_hook(
9494
__FILE__,

includes/classes/DistributorPost.php

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -626,6 +626,11 @@ protected function get_media() {
626626
$raw_media = $this->parse_media_blocks();
627627
} else {
628628
$raw_media = get_attached_media( get_allowed_mime_types(), $post_id );
629+
// Parse images from post content.
630+
$parsed_media = $this->parse_images_from_post_content();
631+
foreach ( $parsed_media as $media_post ) {
632+
$raw_media[ $media_post->ID ] = $media_post;
633+
}
629634
}
630635

631636
$featured_image_id = $this->get_post_thumbnail_id();
@@ -652,6 +657,49 @@ protected function get_media() {
652657
return $media_array;
653658
}
654659

660+
/**
661+
* Parse the post's content to obtain media items by image tags.
662+
*
663+
* @return array<WP_Post> Array of media posts.
664+
*/
665+
protected function parse_images_from_post_content() {
666+
$processor = new \WP_HTML_Tag_Processor( $this->post->post_content );
667+
668+
$media = array();
669+
while ( $processor->next_tag( 'img' ) ) {
670+
$classes = explode( ' ', $processor->get_attribute( 'class' ) ?? ' ' );
671+
672+
if ( ! is_array( $classes ) ) {
673+
continue;
674+
}
675+
676+
// Filter out classes that are not image classes.
677+
$classes = array_filter(
678+
$classes,
679+
function( $class ) {
680+
return strpos( $class, 'wp-image-' ) === 0;
681+
}
682+
);
683+
684+
if ( empty( $classes ) ) {
685+
continue;
686+
}
687+
688+
$image_id = (int) str_replace( 'wp-image-', '', current( $classes ) );
689+
$media_post = get_post( $image_id );
690+
691+
if ( empty( $media_post ) ) {
692+
continue;
693+
}
694+
695+
$media[ $media_post->ID ] = $media_post;
696+
}
697+
698+
$media = array_filter( $media );
699+
700+
return $media;
701+
}
702+
655703
/**
656704
* Parse the post's content to obtain media items.
657705
*

includes/classes/InternalConnections/NetworkSiteConnection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ public function push( $post, $args = array() ) {
180180
*/
181181
if ( apply_filters( 'dt_push_post_media', true, $new_post_id, $post_media, $post_id, $args, $this ) ) {
182182
Utils\set_media( $new_post_id, $post_media, [ 'use_filesystem' => true ] );
183-
};
183+
}
184184

185185
$media_errors = get_transient( 'dt_media_errors_' . $new_post_id );
186186

0 commit comments

Comments
 (0)