Skip to content

Instantly share code, notes, and snippets.

@zogot
Last active December 31, 2015 12:19
Show Gist options
  • Save zogot/7985104 to your computer and use it in GitHub Desktop.
Save zogot/7985104 to your computer and use it in GitHub Desktop.
Custom Meta Box Skeleton Code.
<?php
// Just replace pronamic with an unique identifier.
// and replace video with a slugname for your function of the box.
add_action( 'add_meta_boxes', 'wp_pronamic_add_meta_boxes' );
add_action( 'save_post', 'wp_pronamic_video_meta_box_save', 10, 2 );
function wp_pronamic_add_meta_boxes() {
add_meta_box( 'pronamic_video_meta_box', __( 'Review Rating', 'wp_vision' ), 'wp_pronamic_video_meta_box_show', 'pronamic', 'normal' );
}
function wp_pronamic_video_meta_box_show( WP_Post $post ) {
$nonce = wp_nonce_field( 'wp_pronamic_video_meta_box_nonce', 'wp_pronamic_video_meta_box', true, false );
include 'views/wp_pronamic_video_meta_box_show.php';
}
function wp_pronamic_video_meta_box_save( $post_id, WP_Post $post ) {
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE )
return;
if ( ! filter_has_var( INPUT_POST, 'wp_pronamic_video_meta_box' ) )
return;
if ( ! wp_verify_nonce( $_POST['wp_pronamic_video_meta_box'], 'wp_pronamic_video_meta_box_nonce' ) )
return;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment