Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function fundcode_association_save_meta_box( $post_id ) {
- $err = false;
- $message = '';
- $type = 'error';
- // Check if our nonce is set.
- if ( ! isset( $_POST['fundcode_post_class_nonce'] ) ) {
- return;
- }
- // Verify that the nonce is valid.
- if ( ! wp_verify_nonce( $_POST['fundcode_post_class_nonce'], basename( __FILE__ ) ) ) {
- return;
- }
- // If this is an autosave, our form has not been submitted, so we don't want to do anything.
- if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
- return;
- }
- // Save occasion
- if ( isset( $_POST['fundcode-occasion'] ) )
- {
- if(!empty($_POST['fundcode-occasion']))
- {
- $my_data = sanitize_text_field( $_POST['fundcode-occasion'] );
- update_post_meta( $post_id, 'fundcode_occasion', $my_data );
- }
- else
- {
- $err = true;
- $message .= "Occasion can't be empty.<br />";
- update_post_meta( $post_id, 'fundcode_occasion', '' );
- }
- }
- // Save association
- if ( isset( $_POST['fundcode-association'] ) ) {
- if(!empty($_POST['fundcode-association']))
- {
- $my_data = sanitize_text_field( $_POST['fundcode-association'] );
- update_post_meta( $post_id, 'fundcode_association', $my_data );
- }
- else
- {
- $err = true;
- $message .= "Association can't be empty.<br />";
- update_post_meta( $post_id, 'fundcode_association', '' );
- }
- }
- if($err)
- {
- EE_Error::add_error( $message, __FILE__, __FUNCTION__, __LINE__ ) ;
- }
- }
- add_action( 'save_post', 'fundcode_association_save_meta_box', 1 );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement