Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_action( 'add_meta_boxes', 'cd_meta_box_add' );
- function cd_meta_box_add()
- {
- add_meta_box( 'mtb-attorney', 'Attorney Info', 'cd_meta_box_cb', 'attorney', 'normal', 'high' );
- }
- function cd_meta_box_cb( $post )
- {
- $values = get_post_custom( $post->ID );
- $text00 = isset( $values['att_meta_title'] ) ? esc_attr( $values['att_meta_title'][0] ) : '';
- $text0 = isset( $values['att_meta_phone'] ) ? esc_attr( $values['att_meta_phone'][0] ) : '';
- $text1 = isset( $values['att_meta_email'] ) ? esc_attr( $values['att_meta_email'][0] ) : '';
- $text2 = isset( $values['att_meta_bio'] ) ? esc_attr( $values['att_meta_bio'][0] ) : '';
- // Not Your Method of retrieving Post Meta, but I personally like it better.
- $meta_biography = get_post_meta($post->ID, 'meta_biography', true);
- $text3 = isset( $values['att_meta_edu'] ) ? esc_attr( $values['att_meta_edu'][0] ) : '';
- wp_nonce_field( 'my_meta_box_nonce', 'meta_box_nonce' );
- ?>
- <h3>Complete the below contact, biography, and education fields for each attorney in your firm. When complete, press the Save Draft button and then press Add New Attorney to add more.</h3>
- <p>
- <label class="mtlabel" for="att_meta_title">Name</label>
- <input type="text" class="mtinput" name="post_title" id="att_meta_title" value="<?php echo the_title(); ?>" />
- </p>
- <p>
- <label class="mtlabel" for="att_meta_phone">Phone Number</label>
- <input type="text" class="mtinput" name="att_meta_phone" id="att_meta_phone" value="<?php echo $text0; ?>" />
- </p>
- <p>
- <label class="mtlabel" for="att_meta_email">E Mail</label>
- <input type="text" class="mtinput" name="att_meta_email" id="att_meta_email" value="<?php echo $text1; ?>" />
- </p>
- <p>
- <label class="mtlabel" for="att_meta_bio">Biography</label>
- <!-- Create / Call The TinyMCE Editor -->
- <?php wp_editor($meta_additional, 'biography', array(
- 'wpautop' => true,
- 'media_buttons' => false,
- 'textarea_name' => 'meta_biography',
- 'textarea_rows' => 10,
- 'teeny' => true
- )); ?>
- </p>
- <p>
- <label class="mtlabel" for="att_meta_edu">Education</label>
- <input type="text" class="mtinput" name="att_meta_edu" id="att_meta_edu" value="<?php echo $text3; ?>" />
- </p>
- <?php
- }
- add_action( 'save_post', 'cd_meta_box_save' );
- function cd_meta_box_save( $post_id )
- {
- // Bail if we're doing an auto save
- if( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) return;
- // if our nonce isn't there, or we can't verify it, bail
- if( !isset( $_POST['meta_box_nonce'] ) || !wp_verify_nonce( $_POST['meta_box_nonce'], 'my_meta_box_nonce' ) ) return;
- // if our current user can't edit this post, bail
- if( !current_user_can( 'edit_post', $post_id ) ) return;
- // now we can actually save the data
- $allowed = array(
- 'a' => array( // on allow a tags
- 'href' => array() // and those anchords can only have href attribute
- )
- );
- // Biography Info Content Check
- if(isset($_POST['meta_biography']) && $_POST['meta_biography'] != '')
- update_post_meta($post_id, 'meta_biography', $_POST['meta_biography']);
- else
- delete_post_meta($post_id, 'meta_biography');
- // Probably a good idea to make sure your data is set
- if( isset( $_POST['att_meta_title'] ) )
- update_post_meta( $post_id, 'att_meta_title', wp_kses( $_POST['att_meta_title'], $allowed ) );
- if( isset( $_POST['att_meta_phone'] ) )
- update_post_meta( $post_id, 'att_meta_phone', wp_kses( $_POST['att_meta_phone'], $allowed ) );
- if( isset( $_POST['att_meta_email'] ) )
- update_post_meta( $post_id, 'att_meta_email', wp_kses( $_POST['att_meta_email'], $allowed ) );
- if( isset( $_POST['att_meta_bio'] ) )
- update_post_meta( $post_id, 'att_meta_bio', wp_kses( $_POST['att_meta_bio'], $allowed ) );
- if( isset( $_POST['att_meta_edu'] ) )
- update_post_meta( $post_id, 'att_meta_edu', wp_kses( $_POST['att_meta_edu'], $allowed ) );
- }
- // Post Type Practice Area
- add_action( 'add_meta_boxes', 'cd_meta_box_add2' );
- function cd_meta_box_add2()
- {
- add_meta_box( 'mtb-pta', 'Your Practice Areas', 'cd_meta_box_cb2', 'practice-area', 'normal', 'high' );
- }
- function cd_meta_box_cb2( $post )
- {
- $values = get_post_custom( $post->ID );
- $text = isset( $values['pa_meta_h1'] ) ? esc_attr( $values['pa_meta_h1'][0] ) : '';
- $text1 = isset( $values['pa_meta_desc'] ) ? esc_attr( $values['pa_meta_desc'][0] ) : '';
- $text2 = isset( $values['pa_meta_h2'] ) ? esc_attr( $values['pa_meta_h2'][0] ) : '';
- $text3 = isset( $values['pa_meta_desc2'] ) ? esc_attr( $values['pa_meta_desc2'][0] ) : '';
- wp_nonce_field( 'my_meta_box2_nonce', 'meta_box_nonce' );
- ?>
- <h3>Complete the below fields to add information about your areas of practice To add more, save draft and then press the Add New Practice Area button.</h3>
- <p>
- <label class="mtlabel" for="pa_meta_h1">Practice Area Heading 1</label>
- <input type="text" class="mtinput" name="pa_meta_h1" id="pa_meta_h1" value="<?php echo $text; ?>" />
- </p>
- <p>
- <label class="mtlabel" for="pa_meta_desc">Practice Area Description</label>
- <textarea class="mtinput" rows="10" cols="125" name="pa_meta_desc" id="pa_meta_desc"><?php echo $text1; ?></textarea>
- </p>
- <p>
- <label class="mtlabel" for="pa_meta_h2">Practice Area Heading 2</label>
- <input type="text" class="mtinput" name="pa_meta_h2" id="pa_meta_h2" value="<?php echo $text2; ?>" />
- </p>
- <p>
- <label class="mtlabel" for="pa_meta_desc2">Practice Area Description</label>
- <textarea class="mtinput" rows="10" cols="125" name="pa_meta_desc2" id="pa_meta_desc2"><?php echo $text3; ?></textarea>
- </p>
- <?php
- }
- add_action( 'save_post', 'cd_meta_box_save2' );
- function cd_meta_box_save2( $post_id )
- {
- // Bail if we're doing an auto save
- if( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) return;
- // if our nonce isn't there, or we can't verify it, bail
- if( !isset( $_POST['meta_box_nonce'] ) || !wp_verify_nonce( $_POST['meta_box_nonce'], 'my_meta_box2_nonce' ) ) return;
- // if our current user can't edit this post, bail
- if( !current_user_can( 'edit_post', $post_id ) ) return;
- // now we can actually save the data
- $allowed = array(
- 'a' => array( // on allow a tags
- 'href' => array() // and those anchords can only have href attribute
- )
- );
- // Probably a good idea to make sure your data is set
- if( isset( $_POST['pa_meta_h1'] ) )
- update_post_meta( $post_id, 'pa_meta_h1', wp_kses( $_POST['pa_meta_h1'], $allowed ) );
- if( isset( $_POST['pa_meta_desc'] ) )
- update_post_meta( $post_id, 'pa_meta_desc', wp_kses( $_POST['pa_meta_desc'], $allowed ) );
- if( isset( $_POST['pa_meta_h2'] ) )
- update_post_meta( $post_id, 'pa_meta_h2', wp_kses( $_POST['pa_meta_h2'], $allowed ) );
- if( isset( $_POST['pa_meta_desc2'] ) )
- update_post_meta( $post_id, 'pa_meta_desc2', wp_kses( $_POST['pa_meta_desc2'], $allowed ) );
- }
- // Post Type About
- add_action( 'add_meta_boxes', 'cd_meta_box_add3' );
- function cd_meta_box_add3()
- {
- add_meta_box( 'mtb-about', 'Add Info', 'cd_meta_box_cb3', 'about', 'normal', 'high' );
- }
- function cd_meta_box_cb3( $post )
- {
- $values = get_post_custom( $post->ID );
- $text = isset( $values['bout_meta_rm'] ) ? esc_attr( $values['bout_meta_rm'][0] ) : '';
- $text1 = isset( $values['bout_meta_vid'] ) ? esc_attr( $values['bout_meta_vid'][0] ) : '';
- wp_nonce_field( 'my_meta_box3_nonce', 'meta_box_nonce' );
- ?>
- <p>
- <label class="mtlabel" for="bout_meta_rm">Recent Matters</label>
- <input type="text" class="mtinput" name="bout_meta_rm" id="bout_meta_rm" value="<?php echo $text; ?>" />
- </p>
- <p>
- <label class="mtlabel" for="bout_meta_vid">Video Embed Code</label>
- <input type="text" class="mtinput" name="bout_meta_vid" id="bout_meta_vid" value="<?php echo $text1; ?>" />
- </p>
- <?php
- }
- add_action( 'save_post', 'cd_meta_box_save3' );
- function cd_meta_box_save3( $post_id )
- {
- // Bail if we're doing an auto save
- if( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) return;
- // if our nonce isn't there, or we can't verify it, bail
- if( !isset( $_POST['meta_box_nonce'] ) || !wp_verify_nonce( $_POST['meta_box_nonce'], 'my_meta_box3_nonce' ) ) return;
- // if our current user can't edit this post, bail
- if( !current_user_can( 'edit_post', $post_id ) ) return;
- // now we can actually save the data
- $allowed = array(
- 'a' => array( // on allow a tags
- 'href' => array() // and those anchords can only have href attribute
- )
- );
- // Probably a good idea to make sure your data is set
- if( isset( $_POST['bout_meta_rm'] ) )
- update_post_meta( $post_id, 'bout_meta_rm', wp_kses( $_POST['bout_meta_rm'], $allowed ) );
- if( isset( $_POST['bout_meta_vid'] ) )
- update_post_meta( $post_id, 'bout_meta_vid', wp_kses( $_POST['bout_meta_vid'], $allowed ) );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement