This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Oct 30th, 2012  |  syntax: PHP  |  size: 9.01 KB  |  views: 39  |  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. <?
  2. // --- METABOX CREATE --- //
  3. add_action('admin_init', 'page_spec_meta');
  4.  
  5. function page_spec_meta(){
  6.         $post_id = $_GET['post'] ? $_GET['post'] : $_POST['post_ID'] ; $template_file = get_post_meta($post_id,'_wp_page_template',TRUE);
  7.         if ($template_file == 'talenten.php')
  8.     {
  9.                 add_meta_box("career-meta", "Career", "career_meta", "page", "normal", "high");
  10.         add_meta_box("business-meta", "Business", "business_meta", "page", "normal", "high");
  11.         add_meta_box("inspired-meta", "inspired", "inspired_meta", "page", "normal", "high");
  12.         add_meta_box("network-meta", "Network", "network_meta", "page", "normal", "high");
  13.         add_meta_box("future-meta", "Future", "future_meta", "page", "normal", "high");
  14.     }
  15.         if ($template_file == 'bedrijven.php')
  16.     {
  17.                 add_meta_box("unique-meta", "Unique", "unique_meta", "page", "normal", "high");
  18.         add_meta_box("providing-meta", "Providing", "providing_meta", "page", "normal", "high");
  19.         add_meta_box("inspired-meta", "inspired", "inspired_meta", "page", "normal", "high");
  20.         add_meta_box("network-meta", "Network", "network_meta", "page", "normal", "high");
  21.         add_meta_box("future-meta", "Future", "future_meta", "page", "normal", "high");
  22.     }
  23. }
  24.  
  25. // --- METABOX: CAREER ... CONTENTS --- //
  26. function career_meta(){
  27.        
  28.         global $post;
  29.         $career1 = get_post_meta( $post->ID, 'career1', true );
  30.         $career2 = get_post_meta( $post->ID, 'career2', true );
  31.         $career3 = get_post_meta( $post->ID, 'career3', true );
  32. ?>
  33.         <label for="career1">Subtitel</label><input type="text" class="widefat" id="career1" name="career1" value="<?php echo $career1; ?>" />
  34.         <label for="career2">Textveld Links</label>
  35.         <textarea id="career2" name="career2"><?php echo $career2; ?></textarea>
  36.         <label for="career3">Textveld Rechts</label>
  37.         <textarea id="career3" name="career3"><?php echo $career3; ?></textarea>
  38. <?php }
  39.  
  40. // --- METABOX: CAREER ... SAVE --- //
  41. add_action('save_post', 'save_career');
  42.         function save_career(){
  43.                 global $post;
  44.                 update_post_meta($post->ID, "career1", $_POST["career1"]);
  45.                 update_post_meta($post->ID, "career2", $_POST["career2"]);
  46.                 update_post_meta($post->ID, "career3", $_POST["career3"]);
  47.         }
  48.        
  49. // --- METABOX: BUSINESS ... CONTENTS --- //
  50. function business_meta(){
  51.         global $post;
  52.         $business1 = get_post_meta( $post->ID, 'business1', true );
  53.         $business2 = get_post_meta( $post->ID, 'business2', true );
  54.         $business3 = get_post_meta( $post->ID, 'business3', true );
  55.         $business4 = get_post_meta( $post->ID, 'business4', true );
  56.         $business5 = get_post_meta( $post->ID, 'business5', true );
  57.         $business6 = get_post_meta( $post->ID, 'business6', true );
  58. ?>
  59.         <label for="business1">Subtitel</label><input type="text" class="widefat" id="business1" name="business1" value="<?php echo $business1; ?>" />
  60.         <label for="business2">Textveld Links</label>
  61.         <textarea id="business2" name="business2"><?php echo $business2; ?></textarea>
  62.         <label for="business3">Textveld Rechts</label>
  63.         <textarea id="business3" name="business3"><?php echo $business3; ?></textarea>
  64.         <label for="business4">Textveld Links</label>
  65.         <textarea id="business4" name="business4"><?php echo $business4; ?></textarea>
  66.         <label for="business5">Textveld Rechts</label>
  67.         <textarea id="business5" name="business5"><?php echo $business5; ?></textarea>
  68.         <label for="business6">Textveld Links</label>
  69.         <textarea id="business6" name="business6"><?php echo $business6; ?></textarea>
  70. <?php }
  71.  
  72. // --- METABOX: BUSINESS ... SAVE --- //
  73. add_action('save_post', 'save_business');
  74.         function save_business(){
  75.                 global $post;
  76.                 update_post_meta($post->ID, "business1", $_POST["business1"]);
  77.                 update_post_meta($post->ID, "business2", $_POST["business2"]);
  78.                 update_post_meta($post->ID, "business3", $_POST["business3"]);
  79.                 update_post_meta($post->ID, "business4", $_POST["business4"]);
  80.                 update_post_meta($post->ID, "business5", $_POST["business5"]);
  81.                 update_post_meta($post->ID, "business6", $_POST["business6"]);
  82.         }
  83.  
  84. // --- METABOX: INSPIRED ... CONTENTS --- //
  85. function inspired_meta(){
  86.         global $post;
  87.         $inspired1 = get_post_meta( $post->ID, 'inspired1', true );
  88.         $inspired2 = get_post_meta( $post->ID, 'inspired2', true );
  89. ?>
  90.         <label for="inspired1">Subtitel</label><input type="text" class="widefat" id="inspired1" name="inspired1" value="<?php echo $inspired1; ?>" />
  91.         <label for="inspired2">Textveld Links</label>
  92.         <textarea id="inspired2" name="inspired2"><?php echo $inspired2; ?></textarea>
  93. <?php }
  94.  
  95. // --- METABOX: INSPIRED ... SAVE --- //
  96. add_action('save_post', 'save_inspired');
  97.         function save_inspired(){
  98.                 global $post;
  99.                 update_post_meta($post->ID, "inspired1", $_POST["inspired1"]);
  100.                 update_post_meta($post->ID, "inspired2", $_POST["inspired2"]);
  101.         }
  102.        
  103. // --- METABOX: NETWORK ... CONTENTS --- //
  104. function network_meta(){
  105.         global $post;
  106.         $network1 = get_post_meta( $post->ID, 'network1', true );
  107.         $network2 = get_post_meta( $post->ID, 'network2', true );
  108. ?>
  109.         <label for="network1">Subtitel</label><input type="text" class="widefat" id="network1" name="network1" value="<?php echo $network1; ?>" />
  110.         <label for="network2">Textveld Links</label>
  111.         <textarea id="network2" name="network2"><?php echo $network2; ?></textarea>
  112. <?php }
  113.  
  114. // --- METABOX: NETWORK ... SAVE --- //
  115. add_action('save_post', 'save_network');
  116.         function save_network(){
  117.                 global $post;
  118.                 update_post_meta($post->ID, "network1", $_POST["network1"]);
  119.                 update_post_meta($post->ID, "network2", $_POST["network2"]);
  120.         }
  121.  
  122. // --- METABOX: FUTURE ... CONTENTS --- //
  123. function future_meta(){
  124.         global $post;
  125.         $future1 = get_post_meta( $post->ID, 'future1', true );
  126.         $future2 = get_post_meta( $post->ID, 'future2', true );
  127. ?>
  128.         <label for="future1">Subtitel</label><input type="text" class="widefat" id="future1" name="future1" value="<?php echo $future1; ?>" />
  129.         <label for="future2">Textveld Links</label>
  130.         <textarea id="future2" name="future2"><?php echo $future2; ?></textarea>
  131. <?php }
  132.  
  133. // --- METABOX: FUTURE ... SAVE --- //
  134. add_action('save_post', 'save_future');
  135.         function save_future(){
  136.                 global $post;
  137.                 update_post_meta($post->ID, "future1", $_POST["future1"]);
  138.                 update_post_meta($post->ID, "future2", $_POST["future2"]);
  139.         }
  140.        
  141. // --- METABOX: UNIQUE ... CONTENTS --- //
  142. function unique_meta(){
  143.         global $post;
  144.         $unique1 = get_post_meta( $post->ID, 'unique1', true );
  145.         $unique2 = get_post_meta( $post->ID, 'unique2', true );
  146. ?>
  147.         <label for="unique1">Subtitel</label><input type="text" class="widefat" id="unique1" name="unique1" value="<?php echo $unique1; ?>" />
  148.         <label for="unique2">Textveld Links</label>
  149.         <textarea id="unique2" name="unique2"><?php echo $unique2; ?></textarea>
  150. <?php }
  151.  
  152. // --- METABOX: UNIQUE ... SAVE --- //
  153. add_action('save_post', 'save_unique');
  154.         function save_unique(){
  155.                 global $post;
  156.                 update_post_meta($post->ID, "unique1", $_POST["unique1"]);
  157.                 update_post_meta($post->ID, "unique2", $_POST["unique2"]);
  158.         }
  159.        
  160. // --- METABOX: PROVIDING ... CONTENTS --- //
  161. function providing_meta(){
  162.         global $post;
  163.         $providing1 = get_post_meta( $post->ID, 'providing1', true );
  164.         $providing2 = get_post_meta( $post->ID, 'providing2', true );
  165.         $providing3 = get_post_meta( $post->ID, 'providing3', true );
  166.         $providing4 = get_post_meta( $post->ID, 'providing4', true );
  167. ?>
  168.         <label for="providing1">Subtitel</label><input type="text" class="widefat" id="providing1" name="providing1" value="<?php echo $providing1; ?>" />
  169.         <label for="providing2">Textveld Links</label>
  170.         <textarea id="providing2" name="providing2"><?php echo $providing2; ?></textarea>
  171.         <label for="providing3">Textveld Rechts</label>
  172.         <textarea id="providing3" name="providing3"><?php echo $providing3; ?></textarea>
  173.         <label for="providing4">Textveld Links</label>
  174.         <textarea id="providing4" name="providing4"><?php echo $providing4; ?></textarea>
  175. <?php }
  176.  
  177. // --- METABOX: PROVIDING ... SAVE --- //
  178. add_action('save_post', 'save_providing');
  179.         function save_providing(){
  180.                 global $post;
  181.                 update_post_meta($post->ID, "providing1", $_POST["providing1"]);
  182.                 update_post_meta($post->ID, "providing2", $_POST["providing2"]);
  183.                 update_post_meta($post->ID, "providing3", $_POST["providing3"]);
  184.                 update_post_meta($post->ID, "providing4", $_POST["providing4"]);
  185.         }
  186.        
  187. // Save the Data
  188. function save_custom_meta($post_id) {
  189.     global $custom_meta_fields;
  190.         // verify nonce
  191.         if (!wp_verify_nonce($_POST['custom_meta_box_nonce'], basename(__FILE__)))
  192.                 return $post_id;
  193.         // check autosave
  194.         if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)
  195.                 return $post_id;
  196.         // check permissions
  197.         if ('page' == $_POST['post_type']) {
  198.                 if (!current_user_can('edit_page', $post_id))
  199.                         return $post_id;
  200.                 } elseif (!current_user_can('edit_post', $post_id)) {
  201.                         return $post_id;
  202.         }
  203.         // loop through fields and save the data
  204.         foreach ($custom_meta_fields as $field) {
  205.                 $old = get_post_meta($post_id, $field['id'], true);
  206.                 $new = $_POST[$field['id']];
  207.                 if ($new && $new != $old) {
  208.                         update_post_meta($post_id, $field['id'], $new);
  209.                 } elseif ('' == $new && $old) {
  210.                         delete_post_meta($post_id, $field['id'], $old);
  211.                 }
  212.         } // end foreach
  213. }
  214. ?>
clone this paste RAW Paste Data