Posted By

rccc on 02/04/11


Tagged

wordpress


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

Almaz


wordpress check


 / Published in: PHP
 

URL: http://shibashake.com/wordpress-theme/wordpress-custom-taxonomy-input-panels

  1. function save_taxonomy_data($post_id) {
  2. // verify this came from our screen and with proper authorization.
  3.  
  4. if ( !wp_verify_nonce( $_POST['taxonomy_noncename'], 'taxonomy_theme' )) {
  5. return $post_id;
  6. }
  7.  
  8. // verify if this is an auto save routine. If it is our form has not been submitted, so we dont want to do anything
  9. if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE )
  10. return $post_id;
  11.  
  12.  
  13. // Check permissions
  14. if ( 'page' == $_POST['post_type'] ) {
  15. if ( !current_user_can( 'edit_page', $post_id ) )
  16. return $post_id;
  17. } else {
  18. if ( !current_user_can( 'edit_post', $post_id ) )
  19. return $post_id;
  20. }
  21.  
  22. // OK, we're authenticated: we need to find and save the data
  23. $post = get_post($post_id);
  24. if (($post->post_type == 'post') || ($post->post_type == 'page')) {
  25. // OR $post->post_type != 'revision'
  26. $theme = $_POST['post_theme'];
  27. wp_set_object_terms( $post_id, $theme, 'theme' );
  28. }
  29. return $theme;
  30.  
  31. }

Report this snippet  

You need to login to post a comment.