Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on May 3rd, 2012  |  syntax: PHP  |  size: 1.22 KB  |  views: 32  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. add_action( 'add_meta_boxes', 'vclAdminConfig' );
  2. add_action( 'save_post', 'vclSavePostData' );
  3.  
  4. function vclAdminConfig() {
  5.         add_meta_box(  'vclConfigBox', 'New Box','vclMetaBoxCallback', 'post');        
  6. }
  7.  
  8.  
  9. function vclMetaBoxCallback(){
  10.         $post_id = get_the_ID();
  11.         wp_nonce_field( plugin_basename( __FILE__ ), 'vclNoncename' );
  12.         $vclLockedContent= get_post_meta($post_id, 'vclLockedContent', TRUE);
  13.         wp_editor( $vclLockedContent, 'vclLockedContent');
  14. }
  15.  
  16. function vclSavePostData(){
  17.         $post_id = get_the_ID();
  18.         if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE )
  19.         return;
  20.         if ( !wp_verify_nonce( $_POST['vclNoncename'], plugin_basename( __FILE__ ) ) )
  21.         return;
  22.          // Check permissions
  23.         if ( ( isset ( $_POST['post_type'] ) ) && ( 'page' == $_POST['post_type'] )  ) {
  24.                 if ( ! current_user_can( 'edit_page', $post_id ) ) {
  25.                         return;
  26.                 }              
  27.         }
  28.         else {
  29.                 if ( ! current_user_can( 'edit_post', $post_id ) ) {
  30.                         return;
  31.                 }
  32.         }
  33.         $vclLockedContent = $_POST['vclLockedContent'];  //lockedcontent
  34.         if (get_post_meta($post_id, 'vclLockedContent', TRUE) != ''){
  35.                 update_post_meta($post_id, 'vclLockedContent',$vclLockedContent);
  36.         }      
  37.         else{
  38.                 add_post_meta($post_id, 'vclLockedContent', $vclLockedContent);
  39.         }
  40.        
  41. }
  42.  
  43. }