-
Notifications
You must be signed in to change notification settings - Fork 19
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
Add filter to allow autoshare to be enabled by default for a post type #71
Add filter to allow autoshare to be enabled by default for a post type #71
Conversation
@johnwatkins0 Should we be showing checkbox as checked in Classic Editor once filter is in place as well as allow user to toggle off? |
@johnwatkins0 Checkbox is now checked but on Publish it doesn't tweet. |
includes/utils.php
Outdated
@@ -68,7 +100,7 @@ function delete_autoshare_for_twitter_meta( $id, $key ) { | |||
* @return bool | |||
*/ | |||
function maybe_autoshare( $post_id ) { | |||
return ( 1 === intval( get_autoshare_for_twitter_meta( $post_id, ENABLE_AUTOSHARE_FOR_TWITTER_KEY ) ) ) ? true : false; | |||
return ( 1 === intval( autoshare_enabled( $post_id ) ) ) ? true : false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we remove this function? maybe_autoshare()
is only used in post-transition.php:88
. And it's just a wrapper for autoshare_enabled
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, good idea. I have updated in bf7f444
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work, John!
Description of the Change
This adds a filter,
autoshare_for_twitter_enabled_default
, that receives the post type of the current post and allows the default enabled value for the post type to be overridden. Without the filter applied, the default is false.Alternate Designs
#57 should introduce a corresponding UI component for this -- e.g., a series of checkboxes for public post types.
Benefits
Less work for editors when they know a post type will always be shared.
Possible Drawbacks
Using the update requires a small amount of engineering effort to apply the filter.
Verification Process
Add this filter to a theme or plugin on the same site:
(This example is also included in this PR in README.md.)
When this filter is active, autoshare should be enabled by default for the core
post
post type but not on any other post types. When the filter is removed, autoshare should again be disabled by default.Checklist:
Applicable Issues
Resolves #68
Changelog Entry
Add filter to allow autoshare to be enabled by default for a post type.