Skip to content

Instantly share code, notes, and snippets.

@tommcfarlin
Created November 29, 2017 14:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tommcfarlin/356c70c37202d3b93ba31dd5ee981e8c to your computer and use it in GitHub Desktop.
Save tommcfarlin/356c70c37202d3b93ba31dd5ee981e8c to your computer and use it in GitHub Desktop.
<?php
/**
* Save the options in the meta box.
*
* @since 1.0.0
*
* @param int $post_id The ID of the current post
*/
public function save( $post_id ) {
// Note: Guard clauses removed for readability.
// Assume $metadata is set earlier in this function.
update_post_meta( $post_id, 'acme-custom-meta-data', $metadata );
}
<?php
/**
* Save the options in the meta box. Ignore the action if it's coming from the
* Bulk Edit screen.
*
* @since 1.0.0
*
* @param int $post_id The ID of the current post
*/
public function save( $post_id ) {
// Note: Guard clauses removed for readability.
// Assume $metadata is set earlier in this function.
if ( isset( $_POST['_inline_edit'] ) ) {
return;
}
update_post_meta( $post_id, 'acme-custom-meta-data', $metadata );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment