Advertisement
Guest User

Untitled

a guest
May 3rd, 2012
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.22 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement