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

Post abstraction #964

Merged
merged 59 commits into from Dec 12, 2022
Merged

Post abstraction #964

merged 59 commits into from Dec 12, 2022

Conversation

peterwilsoncc
Copy link
Collaborator

Description of the Change

Creates a post abstraction to aid with the distribution of posts without the need to duplicate code across each connection type.

Closes #207

How to test the Change

WIP

Changelog Entry

Added - Post abstraction class.

Credits

Props @peterwilsoncc, @dkotter

Checklist:

  • I agree to follow this project's Code of Conduct.
  • I have updated the documentation accordingly.
  • I have added tests to cover my change.
  • All new and existing tests pass.

@peterwilsoncc peterwilsoncc added this to the 2.0.0 milestone Nov 14, 2022
@peterwilsoncc peterwilsoncc self-assigned this Nov 14, 2022
@peterwilsoncc
Copy link
Collaborator Author

This is how I've been testing, it var_dumps the object in place of the posts content on the front end of the site:

function xu_dist_nope_the_content( $content ) {
	if (
		is_admin()
		|| ( defined( 'REST_REQUEST' ) && REST_REQUEST )
	) {
		return $content;
	}




	if ( is_singular() && in_the_loop() && is_main_query() ) {
		remove_filter( 'the_content', 'xu_dist_nope_the_content' );

		$post = get_post();
		$dt = new Distributor\DistributorPost( $post );
		$t = $dt->original_post_url;
		// $t = $dt_clone->source_site;

		// This is just to get a smaller dump.
		$dt_clone = clone $dt;
		unset( $dt_clone->post->post_content );

		ob_start();
		var_dump( get_post()->ID, $dt_clone );
		var_dump( isset( $dt_clone->original_post_url ) );


		return ob_get_clean();
	}

	return $content;
}

add_filter( 'the_content', 'xu_dist_nope_the_content' );

@peterwilsoncc peterwilsoncc marked this pull request as ready for review December 1, 2022 04:46
@peterwilsoncc
Copy link
Collaborator Author

I think this is in a good spot for an initial review and (hopefully) merge so I can proceed to use it in the connectors in follow up PRs.

I'm sure it will change/expand slightly during implimentation but I think getting it in earlier is probably better than a mega PR.

Prepare media is pretty substantial in that it now parses all media rather than just those attached to the post directly.

dkotter
dkotter previously approved these changes Dec 9, 2022
@peterwilsoncc
Copy link
Collaborator Author

@dkotter Sorry, I managed to dismiss your review wrapping up the tests.

I've got develop-v1 for items that need to be cherry picked so I think that will be fine. If we end up with massive conflicts, patch releases can come from the v1 branch.

Are you happy for this to go in develop given the above or would you still prefer a targeted branch to avoid the potential for a mess.

@dkotter
Copy link
Collaborator

dkotter commented Dec 12, 2022

I've got develop-v1 for items that need to be cherry picked so I think that will be fine. If we end up with massive conflicts, patch releases can come from the v1 branch.

Are you happy for this to go in develop given the above or would you still prefer a targeted branch to avoid the potential for a mess.

Yeah, that sounds good to me

@peterwilsoncc peterwilsoncc merged commit 8a910b1 into develop Dec 12, 2022
@peterwilsoncc peterwilsoncc deleted the feature/207-post-abstraction branch December 12, 2022 22:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Consider a post abstraction
2 participants