Skip to content

Commit

Permalink
Update readme docs to describe the usage of autoshare_for_twitter_pos…
Browse files Browse the repository at this point in the history
…t_tweet_status_updated with added parameters.
  • Loading branch information
elvismdev committed Jan 21, 2025
1 parent bf7f66b commit 761a210
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ function opt_my_cpt_into_autoshare() {
}
add_action( 'init', 'opt_my_cpt_into_autoshare' );
```
### `autoshare_for_twitter_enabled_default` Filter

In addition, adding support while registering custom post types also works. Post types are automatically set to autopost. Future versions of this plugin could allow this to be set manually.

Expand All @@ -84,6 +85,19 @@ function enable_autoshare_by_default_for_core_post_type( $enabled, $post_type )
add_filter( 'autoshare_for_twitter_enabled_default', 'enable_autoshare_by_default_for_core_post_type', 10, 2 );
```

### `autoshare_for_twitter_post_tweet_status_updated` Action

The plugin also passes the **$post_id** and **$tweet_meta** array to hooked functions immediately after the response from X/Twitter is written to post meta. Any function hooked to this action can use these parameters to manage custom integration flows (for example, saving Twitter URLs into other plugins’ metadata).

Example:

```php
function my_custom_action_handler( $post_id, $tweet_meta ) {
// Use $post_id and $tweet_meta to perform custom logic.
}
add_action( 'autoshare_for_twitter_post_tweet_status_updated', 'my_custom_action_handler', 10, 2 );
```

## FAQs

### Does this plugin work with Gutenberg?
Expand Down
15 changes: 15 additions & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ function opt_my_cpt_into_autoshare() {
add_action( 'init', 'opt_my_cpt_into_autoshare' );
`

**autoshare_for_twitter_enabled_default** Filter

In addition, adding support while registering custom post types also works. Post types are automatically set to autopost. Future versions of this plugin could allow this to be set manually.

While the autopost feature can be opted into for post types using the above filter, by default the editor still has to manually enable autopost during the post prepublish flow. The `autoshare_for_twitter_enabled_default` filter allows autopost to be enabled by default for all posts of a given post type. Editors can still manually uncheck the option during the publishing flow.
Expand All @@ -72,6 +74,19 @@ function enable_autoshare_by_default_for_core_post_type( $enabled, $post_type )
add_filter( 'autoshare_for_twitter_enabled_default', 'enable_autoshare_by_default_for_core_post_type', 10, 2 );
`

**autoshare_for_twitter_post_tweet_status_updated** Action

The plugin also passes the **$post_id** and **$tweet_meta** array to hooked functions immediately after the response from X/Twitter is written to post meta. Any function hooked to this action can use these parameters to manage custom integration flows (for example, saving Twitter URLs into other plugins’ metadata).

Example:

`
function my_custom_action_handler( $post_id, $tweet_meta ) {
// Use $post_id and $tweet_meta to perform custom logic.
}
add_action( 'autoshare_for_twitter_post_tweet_status_updated', 'my_custom_action_handler', 10, 2 );
`

Additional technical details can be found in [our GitHub repository](https://github.com/10up/autoshare-for-twitter#overview).

== Frequently Asked Questions ==
Expand Down

0 comments on commit 761a210

Please sign in to comment.