Advertisement
Guest User

Untitled

a guest
Oct 8th, 2013
2,093
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. add_action( 'add_meta_boxes', 'cd_meta_box_add' );
  2. function cd_meta_box_add()
  3. {
  4.     add_meta_box( 'mtb-attorney', 'Attorney Info', 'cd_meta_box_cb', 'attorney', 'normal', 'high' );
  5. }
  6.  
  7. function cd_meta_box_cb( $post )
  8. {
  9.     $values = get_post_custom( $post->ID );
  10. $text00 = isset( $values['att_meta_title'] ) ? esc_attr( $values['att_meta_title'][0] ) : '';
  11.     $text0 = isset( $values['att_meta_phone'] ) ? esc_attr( $values['att_meta_phone'][0] ) : '';
  12. $text1 = isset( $values['att_meta_email'] ) ? esc_attr( $values['att_meta_email'][0] ) : '';
  13. $text2 = isset( $values['att_meta_bio'] ) ? esc_attr( $values['att_meta_bio'][0] ) : '';
  14.  
  15. // Not Your Method of retrieving Post Meta, but I personally like it better.
  16. $meta_biography = get_post_meta($post->ID, 'meta_biography', true);
  17.  
  18. $text3 = isset( $values['att_meta_edu'] ) ? esc_attr( $values['att_meta_edu'][0] ) : '';
  19.     wp_nonce_field( 'my_meta_box_nonce', 'meta_box_nonce' );
  20.     ?>
  21. <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>
  22. <p>
  23.         <label class="mtlabel" for="att_meta_title">Name</label>
  24.         <input type="text" class="mtinput" name="post_title" id="att_meta_title" value="<?php echo the_title(); ?>" />
  25.     </p>
  26.     <p>
  27.         <label class="mtlabel" for="att_meta_phone">Phone Number</label>
  28.         <input type="text" class="mtinput" name="att_meta_phone" id="att_meta_phone" value="<?php echo $text0; ?>" />
  29.     </p>
  30.     <p>
  31.         <label class="mtlabel" for="att_meta_email">E Mail</label>
  32.         <input type="text" class="mtinput" name="att_meta_email" id="att_meta_email" value="<?php echo $text1; ?>" />
  33.     </p>
  34. <p>
  35.         <label class="mtlabel" for="att_meta_bio">Biography</label>
  36.         <!-- Create / Call The TinyMCE Editor -->
  37.         <?php wp_editor($meta_additional, 'biography', array(
  38.             'wpautop'       =>  true,
  39.             'media_buttons' =>  false,
  40.             'textarea_name' =>  'meta_biography',
  41.             'textarea_rows' =>  10,
  42.             'teeny'         =>  true
  43.         )); ?>
  44.     </p>
  45. <p>
  46.         <label class="mtlabel" for="att_meta_edu">Education</label>
  47.         <input type="text" class="mtinput" name="att_meta_edu" id="att_meta_edu" value="<?php echo $text3; ?>" />
  48.     </p>
  49.     <?php  
  50. }
  51.  
  52.  
  53. add_action( 'save_post', 'cd_meta_box_save' );
  54. function cd_meta_box_save( $post_id )
  55. {
  56.     // Bail if we're doing an auto save
  57.     if( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) return;
  58.    
  59.     // if our nonce isn't there, or we can't verify it, bail
  60.     if( !isset( $_POST['meta_box_nonce'] ) || !wp_verify_nonce( $_POST['meta_box_nonce'], 'my_meta_box_nonce' ) ) return;
  61.    
  62.     // if our current user can't edit this post, bail
  63.     if( !current_user_can( 'edit_post', $post_id ) ) return;
  64.    
  65.     // now we can actually save the data
  66.     $allowed = array(
  67.         'a' => array( // on allow a tags
  68.             'href' => array() // and those anchords can only have href attribute
  69.         )
  70.     );
  71.    
  72.     // Biography Info Content Check
  73.     if(isset($_POST['meta_biography']) && $_POST['meta_biography'] != '')
  74.         update_post_meta($post_id, 'meta_biography', $_POST['meta_biography']);
  75.     else
  76.         delete_post_meta($post_id, 'meta_biography');
  77.        
  78.        
  79.    
  80.     // Probably a good idea to make sure your data is set
  81. if( isset( $_POST['att_meta_title'] ) )
  82.         update_post_meta( $post_id, 'att_meta_title', wp_kses( $_POST['att_meta_title'], $allowed ) );
  83.  
  84.     if( isset( $_POST['att_meta_phone'] ) )
  85.         update_post_meta( $post_id, 'att_meta_phone', wp_kses( $_POST['att_meta_phone'], $allowed ) );
  86.  
  87. if( isset( $_POST['att_meta_email'] ) )
  88.         update_post_meta( $post_id, 'att_meta_email', wp_kses( $_POST['att_meta_email'], $allowed ) );
  89. if( isset( $_POST['att_meta_bio'] ) )
  90.         update_post_meta( $post_id, 'att_meta_bio', wp_kses( $_POST['att_meta_bio'], $allowed ) );
  91.         if( isset( $_POST['att_meta_edu'] ) )
  92.         update_post_meta( $post_id, 'att_meta_edu', wp_kses( $_POST['att_meta_edu'], $allowed ) );
  93. }
  94.  
  95. // Post Type Practice Area
  96. add_action( 'add_meta_boxes', 'cd_meta_box_add2' );
  97. function cd_meta_box_add2()
  98. {
  99.     add_meta_box( 'mtb-pta', 'Your Practice Areas', 'cd_meta_box_cb2', 'practice-area', 'normal', 'high' );
  100. }
  101.  
  102. function cd_meta_box_cb2( $post )
  103. {
  104.     $values = get_post_custom( $post->ID );
  105.     $text = isset( $values['pa_meta_h1'] ) ? esc_attr( $values['pa_meta_h1'][0] ) : '';
  106. $text1 = isset( $values['pa_meta_desc'] ) ? esc_attr( $values['pa_meta_desc'][0] ) : '';
  107. $text2 = isset( $values['pa_meta_h2'] ) ? esc_attr( $values['pa_meta_h2'][0] ) : '';
  108. $text3 = isset( $values['pa_meta_desc2'] ) ? esc_attr( $values['pa_meta_desc2'][0] ) : '';
  109.     wp_nonce_field( 'my_meta_box2_nonce', 'meta_box_nonce' );
  110.     ?>
  111. <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>
  112.     <p>
  113.         <label class="mtlabel" for="pa_meta_h1">Practice Area Heading 1</label>
  114.         <input type="text" class="mtinput" name="pa_meta_h1" id="pa_meta_h1" value="<?php echo $text; ?>" />
  115.     </p>
  116.     <p>
  117.         <label class="mtlabel" for="pa_meta_desc">Practice Area Description</label>
  118.         <textarea class="mtinput" rows="10" cols="125" name="pa_meta_desc" id="pa_meta_desc"><?php echo $text1; ?></textarea>
  119.     </p>
  120. <p>
  121.         <label class="mtlabel" for="pa_meta_h2">Practice Area Heading 2</label>
  122.         <input type="text" class="mtinput" name="pa_meta_h2" id="pa_meta_h2" value="<?php echo $text2; ?>" />
  123.     </p>
  124. <p>
  125.         <label class="mtlabel" for="pa_meta_desc2">Practice Area Description</label>
  126.         <textarea class="mtinput" rows="10" cols="125" name="pa_meta_desc2" id="pa_meta_desc2"><?php echo $text3; ?></textarea>
  127.     </p>
  128.  
  129.     <?php  
  130. }
  131.  
  132.  
  133. add_action( 'save_post', 'cd_meta_box_save2' );
  134. function cd_meta_box_save2( $post_id )
  135. {
  136.     // Bail if we're doing an auto save
  137.     if( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) return;
  138.    
  139.     // if our nonce isn't there, or we can't verify it, bail
  140.     if( !isset( $_POST['meta_box_nonce'] ) || !wp_verify_nonce( $_POST['meta_box_nonce'], 'my_meta_box2_nonce' ) ) return;
  141.    
  142.     // if our current user can't edit this post, bail
  143.     if( !current_user_can( 'edit_post', $post_id ) ) return;
  144.    
  145.     // now we can actually save the data
  146.     $allowed = array(
  147.         'a' => array( // on allow a tags
  148.             'href' => array() // and those anchords can only have href attribute
  149.         )
  150.     );
  151.    
  152.     // Probably a good idea to make sure your data is set
  153.     if( isset( $_POST['pa_meta_h1'] ) )
  154.         update_post_meta( $post_id, 'pa_meta_h1', wp_kses( $_POST['pa_meta_h1'], $allowed ) );
  155.  
  156. if( isset( $_POST['pa_meta_desc'] ) )
  157.         update_post_meta( $post_id, 'pa_meta_desc', wp_kses( $_POST['pa_meta_desc'], $allowed ) );
  158.  
  159. if( isset( $_POST['pa_meta_h2'] ) )
  160.         update_post_meta( $post_id, 'pa_meta_h2', wp_kses( $_POST['pa_meta_h2'], $allowed ) );
  161.  
  162.         if( isset( $_POST['pa_meta_desc2'] ) )
  163.         update_post_meta( $post_id, 'pa_meta_desc2', wp_kses( $_POST['pa_meta_desc2'], $allowed ) );
  164. }
  165.  
  166. // Post Type About
  167. add_action( 'add_meta_boxes', 'cd_meta_box_add3' );
  168. function cd_meta_box_add3()
  169. {
  170.     add_meta_box( 'mtb-about', 'Add Info', 'cd_meta_box_cb3', 'about', 'normal', 'high' );
  171. }
  172.  
  173. function cd_meta_box_cb3( $post )
  174. {
  175.     $values = get_post_custom( $post->ID );
  176.     $text = isset( $values['bout_meta_rm'] ) ? esc_attr( $values['bout_meta_rm'][0] ) : '';
  177. $text1 = isset( $values['bout_meta_vid'] ) ? esc_attr( $values['bout_meta_vid'][0] ) : '';
  178.     wp_nonce_field( 'my_meta_box3_nonce', 'meta_box_nonce' );
  179.     ?>
  180.  
  181.     <p>
  182.         <label class="mtlabel" for="bout_meta_rm">Recent Matters</label>
  183.         <input type="text" class="mtinput" name="bout_meta_rm" id="bout_meta_rm" value="<?php echo $text; ?>" />
  184.     </p>
  185.     <p>
  186.         <label class="mtlabel" for="bout_meta_vid">Video Embed Code</label>
  187.         <input type="text" class="mtinput" name="bout_meta_vid" id="bout_meta_vid" value="<?php echo $text1; ?>" />
  188.     </p>
  189.  
  190.     <?php  
  191. }
  192.  
  193.  
  194. add_action( 'save_post', 'cd_meta_box_save3' );
  195. function cd_meta_box_save3( $post_id )
  196. {
  197.     // Bail if we're doing an auto save
  198.     if( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) return;
  199.    
  200.     // if our nonce isn't there, or we can't verify it, bail
  201.     if( !isset( $_POST['meta_box_nonce'] ) || !wp_verify_nonce( $_POST['meta_box_nonce'], 'my_meta_box3_nonce' ) ) return;
  202.    
  203.     // if our current user can't edit this post, bail
  204.     if( !current_user_can( 'edit_post', $post_id ) ) return;
  205.    
  206.     // now we can actually save the data
  207.     $allowed = array(
  208.         'a' => array( // on allow a tags
  209.             'href' => array() // and those anchords can only have href attribute
  210.         )
  211.     );
  212.    
  213.     // Probably a good idea to make sure your data is set
  214.     if( isset( $_POST['bout_meta_rm'] ) )
  215.         update_post_meta( $post_id, 'bout_meta_rm', wp_kses( $_POST['bout_meta_rm'], $allowed ) );
  216.  
  217. if( isset( $_POST['bout_meta_vid'] ) )
  218.         update_post_meta( $post_id, 'bout_meta_vid', wp_kses( $_POST['bout_meta_vid'], $allowed ) );
  219.  
  220. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement