Advertisement
Guest User

Untitled

a guest
Sep 22nd, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. /**
  2. * Copyrightfeld
  3. */
  4.  
  5. function be_attachment_field_credit( $form_fields, $post ) {
  6. $form_fields['be-photographer-name'] = array(
  7. 'label' => 'Copyright',
  8. 'input' => 'text',
  9. 'value' => get_post_meta( $post->ID, 'be_photographer_name', true ),
  10. );
  11.  
  12. return $form_fields;
  13. }
  14.  
  15. add_filter( 'attachment_fields_to_edit', 'be_attachment_field_credit', 10, 2 );
  16.  
  17. /**
  18. * Save values of Photographer Name and URL in media uploader
  19. *
  20. * @param $post array, the post data for database
  21. * @param $attachment array, attachment fields from $_POST form
  22. * @return $post array, modified post data
  23. */
  24.  
  25. function be_attachment_field_credit_save( $post, $attachment ) {
  26. if( isset( $attachment['be-photographer-name'] ) )
  27. update_post_meta( $post['ID'], 'be_photographer_name', $attachment['be-photographer-name'] );
  28.  
  29. return $post;
  30. }
  31.  
  32. add_filter( 'attachment_fields_to_save', 'be_attachment_field_credit_save', 10, 2 );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement