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

Fix auto-posting tweets for automatically published posts. #294

Merged
merged 4 commits into from Nov 29, 2023

Conversation

iamdharmesh
Copy link
Member

@iamdharmesh iamdharmesh commented Nov 23, 2023

Description of the Change

The PR addresses issues with auto-posting tweets for automatically published posts. Currently, tweets are posted based only on tweet accounts saved in post meta, and these tweet accounts are saved to post meta in the edit post screen. Because of this, when posts are automatically published, they don't get tweeted. The PR resolves this issue by tweeting posts to accounts with auto-share enabled by default when post meta is not saved in the post.

Closes #287
Closes #286

How to test the Change

  1. Install and set up the plugin.
  2. Connect Twitter account.
  3. Enabled Autoshare by default on the connected account.
  4. Automatically publish post, It can be done via the below code snippet or you can follow any other way to do this.
add_action( 'init', function(){
	// Create a new post.
	wp_insert_post(
		array(
			'post_title'  => 'Test Title',
			'post_status' => 'publish',
		)
	);
});
  1. Verify that the post has been tweeted.

Changelog Entry

Fixed - Auto-posting tweets for automatically published posts.

Credits

Props @iamdharmesh @sunnmagic

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.

@github-actions github-actions bot added this to the 2.2.0 milestone Nov 23, 2023
@github-actions github-actions bot added needs:refresh This requires a refreshed PR to resolve. needs:code-review This requires code review. labels Nov 23, 2023
@github-actions github-actions bot removed the needs:refresh This requires a refreshed PR to resolve. label Nov 23, 2023
@iamdharmesh iamdharmesh requested review from a team and peterwilsoncc and removed request for a team November 23, 2023 10:35
@iamdharmesh iamdharmesh mentioned this pull request Nov 23, 2023
17 tasks
@sunnmagic
Copy link

Hi,

Great, how can we install the new version?

@peterwilsoncc
Copy link
Contributor

@iamdharmesh I tested this but it doesn't appear to be working for me, see the gif below.

auto-share-generated

Along with WP CLI, I also tried the code above using the init hook but without success.

@jeffpaul
Copy link
Member

@sunnmagic this fix is not yet ready or part of a released version but for now we're targeting this in the 2.2.0 release.

@sunnmagic
Copy link

sunnmagic commented Nov 27, 2023 via email

Copy link
Contributor

@peterwilsoncc peterwilsoncc left a comment

Choose a reason for hiding this comment

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

This LGTM.

I re-tested and discovered I was hitting a false negative in AST_Staging::is_production_site() when testing via WP-CLI earlier.

The code wasn't working for me on init as I was registering it as an mu-plugin on init, 10 so it running prior to the plugin registering post support (as discussed offline yesterday).

@iamdharmesh, you mentioned changing the post type support function to run earlier on init but I don't think that will work as the common code example for registering post type is:

add_action( 'init', /* register_post_type() */ );

So registering post type support prior to init, 10 will miss any CPTs that are registered by plugins. If anything we should probably register it later on the init hook.

It might be worth testing that in a follow up issue though. I think this can be merged as is.

@iamdharmesh iamdharmesh merged commit 2bcd494 into develop Nov 29, 2023
16 checks passed
@iamdharmesh iamdharmesh deleted the fix/287 branch November 29, 2023 05:21
@Sreejith00000 Sreejith00000 mentioned this pull request Nov 29, 2023
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs:code-review This requires code review.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

WP Automatic posts not autoshared auto sharing not working
4 participants