Skip to content

Commit

Permalink
Merge branch 'develop' into trunk
Browse files Browse the repository at this point in the history
  • Loading branch information
dkotter committed Jan 18, 2024
2 parents 5d24078 + 9c08f77 commit e0d8218
Show file tree
Hide file tree
Showing 10 changed files with 8,379 additions and 4,324 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:
- name: Checkout
uses: actions/checkout@v2
- id: changed-files
uses: tj-actions/changed-files@v36
uses: tj-actions/changed-files@v41
with:
files: |
**/*.php
Expand Down
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,17 @@ All notable changes to this project will be documented in this file, per [the Ke

## [Unreleased] - TBD

## [2.0.3] - 2024-01-18
### Added
- New filter, `dt_post_to_pull`, that allows modifying the post to be pulled (props [@leogermani](https://github.com/leogermani), [@peterwilsoncc](https://github.com/peterwilsoncc), [@dkotter](https://github.com/dkotter) via [#1181](https://github.com/10up/distributor/pull/1181)).

### Fixed
- Ensure the code snippet for keeping the original post date is correct (props [@leogermani](https://github.com/leogermani), [@peterwilsoncc](https://github.com/peterwilsoncc) via [#1160](https://github.com/10up/distributor/pull/1160)).

### Security
- Bump `tj-actions/changed-files` from 36 to 41 (props [@dependabot[bot]](https://github.com/apps/dependabot), [@peterwilsoncc](https://github.com/peterwilsoncc) via [#1172](https://github.com/10up/distributor/pull/1172)).
- Bump `@wordpress/scripts` from 26.6.0 to 26.19.0 (props [@dependabot[bot]](https://github.com/apps/dependabot), [@iamdharmesh](https://github.com/iamdharmesh) via [#1174](https://github.com/10up/distributor/pull/1174)).

## [2.0.2] - 2023-11-29
### Added
- New snippet detailing how to disable automatic content updates (props [@dkotter](https://github.com/dkotter), [@peterwilsoncc](https://github.com/peterwilsoncc) via [#1145](https://github.com/10up/distributor/pull/1145)).
Expand Down Expand Up @@ -504,6 +515,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.0.3]: https://github.com/10up/distributor/compare/2.0.2...2.0.3
[2.0.2]: https://github.com/10up/distributor/compare/2.0.1...2.0.2
[2.0.1]: https://github.com/10up/distributor/compare/2.0.0...2.0.1
[2.0.0]: https://github.com/10up/distributor/compare/1.9.1...2.0.0
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.0.2
* Version: 2.0.3
* Requires at least: 5.7
* Requires PHP: 7.4
* Author: 10up Inc.
Expand All @@ -28,7 +28,7 @@
exit; // Exit if accessed directly.
}

define( 'DT_VERSION', '2.0.2' );
define( 'DT_VERSION', '2.0.3' );
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
22 changes: 19 additions & 3 deletions docs/snippets.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,27 @@ add_action( 'plugins_loaded', function() {
*
* This filter is used to filter the arguments sent to the remote server during a push. The below code snippet passes the original published date to the new pushed post and sets the same published date instead of setting it as per the current time.
*/
add_filter( 'dt_push_post_args', function( $post_body, $post ) {
$post_body['post_date'] = $post->post_date;
add_filter( 'dt_push_post_args', function( $post_body, $post, $args, $connection ) {

// When pushing to an external connection, we use the REST API, so the name of the field is `date`.
// But when pushing to an internal connection, the attributes are sent to wp_insert_post, which expects `post_date`.
$field_prefix =( $connection instanceof \Distributor\ExternalConnections\WordPressExternalConnection ) ? '' : 'post_';

$post_body[ $field_prefix . 'date'] = $post->post_date;
$post_body[ $field_prefix . 'date_gmt'] = $post->post_date_gmt;

return $post_body;
}, 10, 2 );
}, 10, 4 );

/**
* This filters the the arguments passed into wp_insert_post during a pull
*/
add_filter( 'dt_pull_post_args', function( $post_array, $remote_id, $post ) {
$post_array['post_date'] = $post->post_date;
$post_array['post_date_gmt'] = $post->post_date_gmt;

return $post_array;
}, 10, 3 );
```

### Automatically unlink posts
Expand Down
12 changes: 11 additions & 1 deletion includes/classes/DistributorPost.php
Original file line number Diff line number Diff line change
Expand Up @@ -918,7 +918,17 @@ protected function to_pull_list( $args = array() ) {
$display_data['distributor_original_site_name'] = $this->source_site['name'];
$display_data['distributor_original_site_url'] = $this->source_site['home_url'];

return $display_data;
/**
* Filters the post data for when they are being formated for a pull
*
* @since 2.0.3
* @hook dt_post_to_pull
*
* @param {array} $display_data The post data.
*
* @return {array} Modified post data.
*/
return apply_filters( 'dt_post_to_pull', $display_data );
}

/**
Expand Down
Loading

0 comments on commit e0d8218

Please sign in to comment.