Skip to content
Merged
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
29 changes: 29 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,34 @@ All notable changes to this project will be documented in this file, per [the Ke

## [Unreleased] - TBD

## [2.2.0] - 2025-09-08
**Note that this release bumps the WordPress minimum supported version from 6.5 to 6.6.**

### Added
- The `distributor_register_data` function that enables developers to register stored data references, such as IDs stored in post meta, shortcodes, or block attributes and define custom pre-distribution and post-distribution callbacks to process these references (props [@iamdharmesh](https://github.com/iamdharmesh), [@jeffpaul](https://github.com/jeffpaul), [@peterwilsoncc](https://github.com/peterwilsoncc), [@dkotter](https://github.com/dkotter) via [#1302](https://github.com/10up/distributor/pull/1302)).
- Add some default pre and post callback functions to the `distributor_register_data` function, allowing easy processing of common entities like posts, terms, and media (props [@iamdharmesh](https://github.com/iamdharmesh), [@jeffpaul](https://github.com/jeffpaul), [@peterwilsoncc](https://github.com/peterwilsoncc), [@dkotter](https://github.com/dkotter) via [#1309](https://github.com/10up/distributor/pull/1309)).
- Ability to auto-distribute posts when turned on via a filter, `dt_auto_distribution_enabled` (props [@peterwilsoncc](https://github.com/peterwilsoncc), [@faisal-alvi](https://github.com/faisal-alvi), [@jeffpaul](https://github.com/jeffpaul), [@dkotter](https://github.com/dkotter) via [#1321](https://github.com/10up/distributor/pull/1321)).

### Changed
- Bump WordPress "tested up to" version 6.8 (props [@Sourabh208](https://github.com/Sourabh208), [@dkotter](https://github.com/dkotter) via [#1311](https://github.com/10up/distributor/pull/1311)).
- Bump WordPress minimum to 6.6 (props [@Sourabh208](https://github.com/Sourabh208), [@jeffpaul](https://github.com/jeffpaul), [@peterwilsoncc](https://github.com/peterwilsoncc) via [#1312](https://github.com/10up/distributor/pull/1312)).

### Fixed
- Ensure post data is slashed when sent via a subscription update (props [@chandrapatel](https://github.com/chandrapatel), [@peterwilsoncc](https://github.com/peterwilsoncc) via [#1310](https://github.com/10up/distributor/pull/1310)).
- Broken images in docs (props [@GaryJones](https://github.com/GaryJones), [@jeffpaul](https://github.com/jeffpaul), [@av3nger](https://github.com/av3nger), [@dkotter](https://github.com/dkotter) via [#1319](https://github.com/10up/distributor/pull/1319)).

### Security
- Prevent cross-site scripting vulnerabilities on the pull screen (props [@iamdharmesh](https://github.com/iamdharmesh), [@peterwilsoncc](https://github.com/peterwilsoncc), [@jeffpaul](https://github.com/jeffpaul), [@Sidsector9](https://github.com/Sidsector9), [@dkotter](https://github.com/dkotter) via [#1273](https://github.com/10up/distributor/pull/1273), [#1274](https://github.com/10up/distributor/pull/1274), [#1316](https://github.com/10up/distributor/pull/1316)).
- Bump `ws` from 7.5.10 to 8.18.0 and `@wordpress/scripts` from 26.19.0 to 29.0.0 (props [@dependabot](https://github.com/apps/dependabot), [@Sidsector9](https://github.com/Sidsector9) via [#1270](https://github.com/10up/distributor/pull/1270)).
- Bump `axios` from 1.7.4 to 1.9.0, `body-parser` from 1.20.2 to 1.20.3, `express` from 4.19.2 to 4.21.2, `@wordpress/e2e-test-utils-playwright` from 1.7.0 to 1.23.0, `http-proxy-middleware` from 2.0.6 to 2.0.9, `tar-fs` from 3.0.4 to 3.0.8, `serialize-javascript` from 6.0.1 to 6.0.2, `mocha` from 10.2.0 to 11.3.0 and `send` from 0.18.0 to 0.19.0; also removes `cookie` (props [@dependabot](https://github.com/apps/dependabot), [@peterwilsoncc](https://github.com/peterwilsoncc) via [#1314](https://github.com/10up/distributor/pull/1314)).
- Bump `on-headers` from 1.0.2 to 1.1.0 and `compression` from 1.7.4 to 1.8.1 (props [@dependabot](https://github.com/apps/dependabot), [@dkotter](https://github.com/dkotter) via [#1325](https://github.com/10up/distributor/pull/1325)).
- Bump `tmp` from 0.2.1 to 0.2.5 and `@wordpress/env` from 10.5.0 to 10.29.0 (props [@dependabot](https://github.com/apps/dependabot), [@dkotter](https://github.com/dkotter) via [#1334](https://github.com/10up/distributor/pull/1334)).

### Developer
- Fix eslint errors (props [@GaryJones](https://github.com/GaryJones), [@iamdharmesh](https://github.com/iamdharmesh) via [#1320](https://github.com/10up/distributor/pull/1320)).
- Update all third-party actions our workflows rely on to use versions based on specific commit hashes (props [@dkotter](https://github.com/dkotter), [@jeffpaul](https://github.com/jeffpaul), [@faisal-alvi](https://github.com/faisal-alvi) via [#1305](https://github.com/10up/distributor/pull/1305)).
- Fix featured media E2E tests (props [@peterwilsoncc](https://github.com/peterwilsoncc), [@dkotter](https://github.com/dkotter) via [#1332](https://github.com/10up/distributor/pull/1332)).

## [2.1.0] - 2025-02-10
**Note that this release bumps the WordPress minimum supported version from 6.4 to 6.5.**

Expand Down Expand Up @@ -597,6 +625,7 @@ This adds a post type selector when viewing the Pull Content list for both exter
- Initial closed release.

[Unreleased]: https://github.com/10up/distributor/compare/trunk...develop
[2.2.0]: https://github.com/10up/distributor/compare/2.1.0...2.2.0
[2.1.0]: https://github.com/10up/distributor/compare/2.0.6...2.1.0
[2.0.6]: https://github.com/10up/distributor/compare/2.0.5...2.0.6
[2.0.5]: https://github.com/10up/distributor/compare/2.0.4...2.0.5
Expand Down
2 changes: 1 addition & 1 deletion CREDITS.md

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions distributor.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Plugin URI: https://github.com/10up/distributor
* Update URI: https://distributorplugin.com
* Description: Makes it easy to distribute and reuse content across your websites, whether inside of a multisite or across the web.
* Version: 2.1.0
* Version: 2.2.0
* Requires at least: 6.6
* Requires PHP: 7.4
* Author: 10up Inc.
Expand All @@ -28,7 +28,7 @@
exit; // Exit if accessed directly.
}

define( 'DT_VERSION', '2.1.0' );
define( 'DT_VERSION', '2.2.0' );
define( 'DT_PLUGIN_FILE', preg_replace( '#^.*plugins/(.*)$#i', '$1', __FILE__ ) );
define( 'DT_PLUGIN_PATH', plugin_dir_path( __FILE__ ) );
define( 'DT_PLUGIN_FULL_FILE', __FILE__ );
Expand Down
2 changes: 1 addition & 1 deletion docs/stored-id-handling.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ The `distributor_register_data` function streamlines the process of updating sto
- **Extracting the reference:** Defining how to locate the specific attribute or meta key holding the ID.
- **Processing the data:** Using pre-distribution and post-distribution callbacks to prepare and update the reference IDs, ensuring they point to the correct data on the target site.

#### **Important:** Ensure that this data registration code is added to both the source and target sites. Also, verify that your Distributor plugin version is the same on both sites and equal to or greater than the required version (x.x.x).
#### **Important:** Ensure that this data registration code is added to both the source and target sites. Also, verify that your Distributor plugin version is the same on both sites and equal to or greater than the required version (2.2.0).

## Function Definition

Expand Down
20 changes: 10 additions & 10 deletions includes/auto-distribute.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*
* Runs on the `plugins_loaded, 20` hook.
*
* @since x.x.x
* @since 2.2.0
*/
function setup() {
$n = function( $function ) {
Expand All @@ -32,7 +32,7 @@ function setup() {
*
* Default is false, see the filter `dt_auto_distribution_enabled` to enable it.
*
* @since x.x.x
* @since 2.2.0
*
* @return bool Whether the auto-distribution feature is enabled.
*/
Expand All @@ -49,7 +49,7 @@ function enabled() {
* to all network and external connections that the post had not already been distributed
* to. These posts will be distributed as published posts, not drafts.
*
* @since x.x.x.
* @since 2.2.0
* @hook dt_auto_distribution_enabled
*
* @param {bool} $enabled Whether the auto-distribution feature is enabled. Default false.
Expand All @@ -65,7 +65,7 @@ function enabled() {
* This is the default status that will be applied to auto-distributed posts
* on the distribution site.
*
* @since x.x.x
* @since 2.2.0
*
* @param int|\WP_Post $post Post ID or WP_Post object for the post being pushed.
* @return string Default status for auto-distributed posts.
Expand All @@ -76,7 +76,7 @@ function default_post_status( $post ) {
/**
* Filter the default status for auto-distributed posts.
*
* @since x.x.x
* @since 2.2.0
* @hook dt_auto_distribution_default_status
*
* @param {string} $status Default status for auto-distributed posts. Default 'publish'.
Expand All @@ -92,7 +92,7 @@ function default_post_status( $post ) {
*
* This function checks if the post should be auto-distributed based on filters.
*
* @since x.x.x
* @since 2.2.0
*
* @param int|\WP_Post $post Post ID or WP_Post object for the post being pushed.
* @param int $user_id User ID of the user pushing the post.
Expand All @@ -110,7 +110,7 @@ function auto_distribute_post( $post, $user_id, $connection_type, $connection_id
/**
* Filter to determine if a post should be auto-distributed.
*
* @since x.x.x
* @since 2.2.0
* @hook dt_auto_distribute_post
*
* @param {bool} $should_distribute Whether the post should be auto-distributed.
Expand All @@ -130,7 +130,7 @@ function auto_distribute_post( $post, $user_id, $connection_type, $connection_id
* By default, this is post and page but that
* value can be filtered.
*
* @since x.x.x
* @since 2.2.0
*
* @return string[] Array of post types that can be auto-distributed.
*/
Expand All @@ -139,7 +139,7 @@ function auto_distribute_supported_post_types() {
/**
* Filter the post types that are auto-distributable.
*
* @since x.x.x
* @since 2.2.0
* @hook auto_distribute_supported_post_types
*
* @param {string[]} $post_types Array of post types that can be auto-distributed.
Expand Down Expand Up @@ -320,7 +320,7 @@ function get_external_connections( $post_id = 0, $user_id = 0 ) {
*
* @hook dt_external_connections_per_page
*
* @since x.x.x
* @since 2.2.0
*
* @param {int} $max_connections The maximum number of external connections to load.
* @return {int} The maximum number of external connections to load.
Expand Down
10 changes: 5 additions & 5 deletions includes/classes/DistributorPost.php
Original file line number Diff line number Diff line change
Expand Up @@ -663,7 +663,7 @@ protected function get_media() {
/**
* Get the extra data for the post to be processed on the target site.
*
* @since x.x.x
* @since 2.2.0
*
* @return array[] {
* Array of extra data keyed by the data name.
Expand Down Expand Up @@ -694,7 +694,7 @@ protected function get_extra_data() {
/**
* Filters whether to process extra data for the post.
*
* @since x.x.x
* @since 2.2.0
* @hook dt_process_extra_data
*
* @param {bool} $process_extra_data Whether to process extra data.
Expand Down Expand Up @@ -797,7 +797,7 @@ protected function get_extra_data() {
/**
* Filters the extra data for the post to be processed on the target site.
*
* @since x.x.x
* @since 2.2.0
* @hook dt_extra_data
*
* @param {array} $extra_data Extra data for the post.
Expand All @@ -812,7 +812,7 @@ protected function get_extra_data() {
/**
* Parse blocks to obtain value of given attribute.
*
* @since x.x.x
* @since 2.2.0
*
* @param array $block Block to parse.
* @param string $block_name Block name to look for.
Expand Down Expand Up @@ -849,7 +849,7 @@ protected function parse_blocks_for_attribute_values( $block, $block_name, $bloc
/**
* Get the attribute values of a given shortcode.
*
* @since x.x.x
* @since 2.2.0
*
* @param string $content The post content.
* @param string $shortcode The shortcode to look for.
Expand Down
30 changes: 15 additions & 15 deletions includes/classes/RegisteredDataHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,21 @@
/**
* This class is responsible for processing the registered data for the post content and post meta.
*
* @since x.x.x
* @since 2.2.0
*/
class RegisteredDataHandler {
/**
* The Connection data array.
*
* @since x.x.x
* @since 2.2.0
* @var array
*/
public $connection_data = array();

/**
* Constructor for the RegisteredDataHandler class.
*
* @since x.x.x
* @since 2.2.0
*
* @param array $connection_data The connection data array.
*/
Expand All @@ -35,7 +35,7 @@ public function __construct( $connection_data = array() ) {
/**
* Search and replace inner content of a block with the provided replacements.
*
* @since x.x.x
* @since 2.2.0
*
* @param array $block The block to search and replace inner content.
* @param array $replacement_strings Array of search and replace strings for inner content.
Expand All @@ -58,7 +58,7 @@ public function search_replace_block_inner_content( $block, $replacement_strings
*
* Processes the blocks data recursively and calls the callback function provided in the registered data.
*
* @since x.x.x
* @since 2.2.0
*
* @param array $blocks Array of blocks.
* @param array $registered_data Array of registered data.
Expand Down Expand Up @@ -169,7 +169,7 @@ public function process_blocks_data_recursive( $blocks, $registered_data, $extra
*
* Calls the callback function provided in the registered data and updates the post data.
*
* @since x.x.x
* @since 2.2.0
*
* @param array $post_data The post data.
* @param bool $is_rest Whether the post data is from the REST API.
Expand Down Expand Up @@ -248,7 +248,7 @@ public function process_registered_data( $post_data, $is_rest = false ) {
/**
* Filter the post data after processing the registered data.
*
* @since x.x.x
* @since 2.2.0
* @hook dt_after_registered_data_processed
*
* @param {array} $post_data The post data after processing the registered data.
Expand All @@ -267,7 +267,7 @@ public function process_registered_data( $post_data, $is_rest = false ) {
*
* Calls the callback function provided in the registered data and updates the post meta data.
*
* @since x.x.x
* @since 2.2.0
*
* @param array $post_meta The post meta data.
* @param array $registered_data The distributor registered data.
Expand Down Expand Up @@ -328,7 +328,7 @@ public function process_registered_post_meta_data( $post_meta, $registered_data,
/**
* Filter the post meta data after processing the registered data.
*
* @since x.x.x
* @since 2.2.0
* @hook dt_after_registered_post_meta_processed
*
* @param {array} $post_meta The post meta data.
Expand All @@ -344,7 +344,7 @@ public function process_registered_post_meta_data( $post_meta, $registered_data,
/**
* Process the registered block data for the post content.
*
* @since x.x.x
* @since 2.2.0
*
* @param string $post_content The post content.
* @param array $registered_data The distributor registered data.
Expand All @@ -370,7 +370,7 @@ public function process_registered_block_data( $post_content, $registered_data,
/**
* Filter the post content blocks after processing the registered data.
*
* @since x.x.x
* @since 2.2.0
* @hook dt_after_registered_block_data_processed
*
* @param {array} $post_content The post content.
Expand All @@ -386,7 +386,7 @@ public function process_registered_block_data( $post_content, $registered_data,
/**
* Process the registered shortcode data for the post content.
*
* @since x.x.x
* @since 2.2.0
*
* @param string $post_content The post content.
* @param array $registered_data The distributor registered data.
Expand Down Expand Up @@ -458,7 +458,7 @@ function ( $matches ) use ( &$index, $shortcode, $shortcode_attribute, $callback
/**
* Filter the post content shortcodes after processing the registered data.
*
* @since x.x.x
* @since 2.2.0
* @hook dt_after_registered_shortcode_data_processed
*
* @param {array} $post_content The post content.
Expand All @@ -474,7 +474,7 @@ function ( $matches ) use ( &$index, $shortcode, $shortcode_attribute, $callback
/**
* Prepare the term extra data to be sent to the target site.
*
* @since x.x.x
* @since 2.2.0
*
* @param int $term_id The term ID.
* @param bool $with_parent Whether to include the parent term data.
Expand Down Expand Up @@ -504,7 +504,7 @@ public function prepare_registered_data_term( $term_id, $with_parent = false ) {
/**
* Process the registered data for the term.
*
* @since x.x.x
* @since 2.2.0
*
* @param array $term_data The term data to be processed.
* @param bool $process_parent Whether to process the parent term.
Expand Down
2 changes: 1 addition & 1 deletion includes/debug-info.php
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ function get_formatted_external_connections() {
*
* @hook dt_external_connections_per_page
*
* @since x.x.x
* @since 2.2.0
*
* @param {int} $max_connections The maximum number of external connections to load.
* @return {int} The maximum number of external connections to load.
Expand Down
6 changes: 3 additions & 3 deletions includes/global-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ function str_ends_with( $haystack, $needle ) {
/**
* Register a data field for Stored ID handling.
*
* @since x.x.x
* @since 2.2.0
*
* @global array $distributor_registered_data Global registry for distributor data.
*
Expand Down Expand Up @@ -225,7 +225,7 @@ function distributor_register_data( $data_name, $args ) {
/**
* Get the registered distributor data.
*
* @since x.x.x
* @since 2.2.0
*
* @global array $distributor_registered_data Global registry for distributor data.
*
Expand Down Expand Up @@ -543,7 +543,7 @@ function distributor_term_pre_distribute_callback( $term_id, $source_post_id ) {
* Filter whether to distribute term with parents.
* If set to true, the term will be distributed with its parents.
*
* @since x.x.x
* @since 2.2.0
* @hook dt_registered_data_distribute_term_parent
*
* @param bool $with_parents Whether to distribute term with parents. Default false.
Expand Down
2 changes: 1 addition & 1 deletion includes/pull-ui.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ function setup_list_table() {
*
* @hook dt_external_connections_per_page
*
* @since x.x.x
* @since 2.2.0
*
* @param {int} $max_connections The maximum number of external connections to load.
* @return {int} The maximum number of external connections to load.
Expand Down
2 changes: 1 addition & 1 deletion includes/push-ui.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ function get_connections() {
*
* @hook dt_external_connections_per_page
*
* @since x.x.x
* @since 2.2.0
*
* @param {int} $max_connections The maximum number of external connections to load.
* @return {int} The maximum number of external connections to load.
Expand Down
Loading
Loading