Advertisement
Guest User

Untitled

a guest
Mar 24th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. // Add form
  2. function wpse261260_add_checkbox_thumbnail ($content) {
  3. global $post;
  4. $text = __( 'Link to full image', 'your-textdomain' );
  5. $id = 'link_to_featured_image';
  6. $value = esc_attr (get_post_meta ($post->ID, $id, true) );
  7. $label = '<label for="' . $id . '"><input name="' . $id . '" type="checkbox" id="' . $id . '" value="' . $value . ' "'. checked( $value, 1, false) .'> ' . $text .'</label>';
  8. return $content .= $label;
  9. }
  10. add_filter ('admin_post_thumbnail_html', 'wpse261260_add_checkbox_thumbnail');
  11.  
  12. // Save form
  13. function wpse261260_save_checkbox_thumbnail ($post_id, $post, $update) {
  14. $value = 0;
  15. if (isset ($_REQUEST['link_to_featured_image'])) {
  16. $value = 1;
  17. }
  18. update_post_meta ($post_id, 'link_to_featured_image', $value);
  19. }
  20. add_action ('save_post', 'wpse261260_save_checkbox_thumbnail', 10, 3);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement