How would I add the capability in Simple Twitter Connect (in the stc-publish.php file) to not tweet pages, either newly published or edited? I don’t need it to be an admin option, just a change for a few of my sites.
It looks like this function would be a good place to add the “don’t tweet pages” capabilty (while retaining the check to prevent edited posts from being tweeted) as it checks for edited posts. How can one differentiate between posts and pages?
// this new function prevents edits to existing posts from auto-posting
add_action('transition_post_status','stc_publish_auto_check',10,3);
function stc_publish_auto_check($new, $old, $post) {
if ($new == 'publish' && $old != 'publish') {
$post_types = get_post_types( array('public' => true), 'objects' );
foreach ( $post_types as $post_type ) {
if ( $post->post_type == $post_type->name ) {
stc_publish_automatic($post->ID, $post);
break;
}
}
}
}
Edit 4/03/11
Answer and better edit below.
Even better answer that doesn’t involve changing the plugin:
Put it in a theme’s functions.php.
Side note: Whenever you’re dealing with a function called by an action or filter hook, then you can easily wrap the call in a different function and add your own code to that function instead. remove_action and remove_filter should be two tools you use a lot in your WP arsenal.
General Disclaimer: This is a plugin edit. Any edits to plugins will be lost when the plugin is updated. Therefore this is not recommended unless you keep good notes and/or remember you did this when the plugin gets updated!! 😉
(@songdogtech, I know you are aware of such things, but I thought it would be irresponsible to post this without that)
http://www.rvoodoo.com/projects/wordpress/wordpress-tip-blocking-a-custom-post-type-from-auto-publish-with-simple-facebook-connect-sfc-plugin/
is how I block a CPT in the SFC plugin, the STC plugin works the same
look for the stc_publish_automatic function I believe it is and add post type page to it…
I’ll find the code real quick, but wanted to point it out…. yer in the right file, and close to the right code
EDIT:
I’d think editing this bit to:
would do it…. (untested, but if worked for blocking a CPT in the SFC plugin)
If you look at the post I linked, @Otto made some recommendation in the comment you may be able to work with in a better way. I just edit the plugin as a quick and dirty, but looks like you can work it from your theme too…..
If anyone can take the info here, and the info from @Otto’s comment on my site, and work it out, I’d love to see that code!