Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_action( 'add_meta_boxes', 'vclAdminConfig' );
- add_action( 'save_post', 'vclSavePostData' );
- function vclAdminConfig() {
- add_meta_box( 'vclConfigBox', 'New Box','vclMetaBoxCallback', 'post');
- }
- function vclMetaBoxCallback(){
- $post_id = get_the_ID();
- wp_nonce_field( plugin_basename( __FILE__ ), 'vclNoncename' );
- $vclLockedContent= get_post_meta($post_id, 'vclLockedContent', TRUE);
- wp_editor( $vclLockedContent, 'vclLockedContent');
- }
- function vclSavePostData(){
- $post_id = get_the_ID();
- if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE )
- return;
- if ( !wp_verify_nonce( $_POST['vclNoncename'], plugin_basename( __FILE__ ) ) )
- return;
- // Check permissions
- if ( ( isset ( $_POST['post_type'] ) ) && ( 'page' == $_POST['post_type'] ) ) {
- if ( ! current_user_can( 'edit_page', $post_id ) ) {
- return;
- }
- }
- else {
- if ( ! current_user_can( 'edit_post', $post_id ) ) {
- return;
- }
- }
- $vclLockedContent = $_POST['vclLockedContent']; //lockedcontent
- if (get_post_meta($post_id, 'vclLockedContent', TRUE) != ''){
- update_post_meta($post_id, 'vclLockedContent',$vclLockedContent);
- }
- else{
- add_post_meta($post_id, 'vclLockedContent', $vclLockedContent);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement