@@ -1,5 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
2 | +if ( ! defined( 'ABSPATH' ) ) { |
|
3 | + exit; |
|
4 | +} |
|
3 | 5 | |
4 | 6 | /** |
5 | 7 | * Build a sample metabox in editor screen |
@@ -52,16 +54,22 @@ discard block |
||
52 | 54 | function save( $post_id, $post ) { |
53 | 55 | |
54 | 56 | //Check if doing autosave |
55 | - if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) return; |
|
57 | + if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) { |
|
58 | + return; |
|
59 | + } |
|
56 | 60 | |
57 | 61 | //Verify the nonce before proceeding. |
58 | - if ( !isset( $_POST['metabox_name_nonce'] ) || !wp_verify_nonce( $_POST['metabox_name_nonce'], basename( __FILE__ ) ) ) return; |
|
62 | + if ( !isset( $_POST['metabox_name_nonce'] ) || !wp_verify_nonce( $_POST['metabox_name_nonce'], basename( __FILE__ ) ) ) { |
|
63 | + return; |
|
64 | + } |
|
59 | 65 | |
60 | 66 | //Get the post type object. |
61 | 67 | $post_type = get_post_type_object( $post->post_type ); |
62 | 68 | |
63 | 69 | //Check if the current user has permission to edit the post. |
64 | - if ( !current_user_can( $post_type->cap->edit_post, $post_id ) ) return $post_id; |
|
70 | + if ( !current_user_can( $post_type->cap->edit_post, $post_id ) ) { |
|
71 | + return $post_id; |
|
72 | + } |
|
65 | 73 | |
66 | 74 | if ( isset( $_POST['metabox_field_name'] ) ) { |
67 | 75 | update_post_meta( $post_id, 'metabox_field_name', esc_attr($_POST['metabox_field_name']) ); |