Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?
- // --- METABOX CREATE --- //
- add_action('admin_init', 'page_spec_meta');
- function page_spec_meta(){
- $post_id = $_GET['post'] ? $_GET['post'] : $_POST['post_ID'] ; $template_file = get_post_meta($post_id,'_wp_page_template',TRUE);
- if ($template_file == 'talenten.php')
- {
- add_meta_box("career-meta", "Career", "career_meta", "page", "normal", "high");
- add_meta_box("business-meta", "Business", "business_meta", "page", "normal", "high");
- add_meta_box("inspired-meta", "inspired", "inspired_meta", "page", "normal", "high");
- add_meta_box("network-meta", "Network", "network_meta", "page", "normal", "high");
- add_meta_box("future-meta", "Future", "future_meta", "page", "normal", "high");
- }
- if ($template_file == 'bedrijven.php')
- {
- add_meta_box("unique-meta", "Unique", "unique_meta", "page", "normal", "high");
- add_meta_box("providing-meta", "Providing", "providing_meta", "page", "normal", "high");
- add_meta_box("inspired-meta", "inspired", "inspired_meta", "page", "normal", "high");
- add_meta_box("network-meta", "Network", "network_meta", "page", "normal", "high");
- add_meta_box("future-meta", "Future", "future_meta", "page", "normal", "high");
- }
- }
- // --- METABOX: CAREER ... CONTENTS --- //
- function career_meta(){
- global $post;
- $career1 = get_post_meta( $post->ID, 'career1', true );
- $career2 = get_post_meta( $post->ID, 'career2', true );
- $career3 = get_post_meta( $post->ID, 'career3', true );
- ?>
- <label for="career1">Subtitel</label><input type="text" class="widefat" id="career1" name="career1" value="<?php echo $career1; ?>" />
- <label for="career2">Textveld Links</label>
- <textarea id="career2" name="career2"><?php echo $career2; ?></textarea>
- <label for="career3">Textveld Rechts</label>
- <textarea id="career3" name="career3"><?php echo $career3; ?></textarea>
- <?php }
- // --- METABOX: CAREER ... SAVE --- //
- add_action('save_post', 'save_career');
- function save_career(){
- global $post;
- update_post_meta($post->ID, "career1", $_POST["career1"]);
- update_post_meta($post->ID, "career2", $_POST["career2"]);
- update_post_meta($post->ID, "career3", $_POST["career3"]);
- }
- // --- METABOX: BUSINESS ... CONTENTS --- //
- function business_meta(){
- global $post;
- $business1 = get_post_meta( $post->ID, 'business1', true );
- $business2 = get_post_meta( $post->ID, 'business2', true );
- $business3 = get_post_meta( $post->ID, 'business3', true );
- $business4 = get_post_meta( $post->ID, 'business4', true );
- $business5 = get_post_meta( $post->ID, 'business5', true );
- $business6 = get_post_meta( $post->ID, 'business6', true );
- ?>
- <label for="business1">Subtitel</label><input type="text" class="widefat" id="business1" name="business1" value="<?php echo $business1; ?>" />
- <label for="business2">Textveld Links</label>
- <textarea id="business2" name="business2"><?php echo $business2; ?></textarea>
- <label for="business3">Textveld Rechts</label>
- <textarea id="business3" name="business3"><?php echo $business3; ?></textarea>
- <label for="business4">Textveld Links</label>
- <textarea id="business4" name="business4"><?php echo $business4; ?></textarea>
- <label for="business5">Textveld Rechts</label>
- <textarea id="business5" name="business5"><?php echo $business5; ?></textarea>
- <label for="business6">Textveld Links</label>
- <textarea id="business6" name="business6"><?php echo $business6; ?></textarea>
- <?php }
- // --- METABOX: BUSINESS ... SAVE --- //
- add_action('save_post', 'save_business');
- function save_business(){
- global $post;
- update_post_meta($post->ID, "business1", $_POST["business1"]);
- update_post_meta($post->ID, "business2", $_POST["business2"]);
- update_post_meta($post->ID, "business3", $_POST["business3"]);
- update_post_meta($post->ID, "business4", $_POST["business4"]);
- update_post_meta($post->ID, "business5", $_POST["business5"]);
- update_post_meta($post->ID, "business6", $_POST["business6"]);
- }
- // --- METABOX: INSPIRED ... CONTENTS --- //
- function inspired_meta(){
- global $post;
- $inspired1 = get_post_meta( $post->ID, 'inspired1', true );
- $inspired2 = get_post_meta( $post->ID, 'inspired2', true );
- ?>
- <label for="inspired1">Subtitel</label><input type="text" class="widefat" id="inspired1" name="inspired1" value="<?php echo $inspired1; ?>" />
- <label for="inspired2">Textveld Links</label>
- <textarea id="inspired2" name="inspired2"><?php echo $inspired2; ?></textarea>
- <?php }
- // --- METABOX: INSPIRED ... SAVE --- //
- add_action('save_post', 'save_inspired');
- function save_inspired(){
- global $post;
- update_post_meta($post->ID, "inspired1", $_POST["inspired1"]);
- update_post_meta($post->ID, "inspired2", $_POST["inspired2"]);
- }
- // --- METABOX: NETWORK ... CONTENTS --- //
- function network_meta(){
- global $post;
- $network1 = get_post_meta( $post->ID, 'network1', true );
- $network2 = get_post_meta( $post->ID, 'network2', true );
- ?>
- <label for="network1">Subtitel</label><input type="text" class="widefat" id="network1" name="network1" value="<?php echo $network1; ?>" />
- <label for="network2">Textveld Links</label>
- <textarea id="network2" name="network2"><?php echo $network2; ?></textarea>
- <?php }
- // --- METABOX: NETWORK ... SAVE --- //
- add_action('save_post', 'save_network');
- function save_network(){
- global $post;
- update_post_meta($post->ID, "network1", $_POST["network1"]);
- update_post_meta($post->ID, "network2", $_POST["network2"]);
- }
- // --- METABOX: FUTURE ... CONTENTS --- //
- function future_meta(){
- global $post;
- $future1 = get_post_meta( $post->ID, 'future1', true );
- $future2 = get_post_meta( $post->ID, 'future2', true );
- ?>
- <label for="future1">Subtitel</label><input type="text" class="widefat" id="future1" name="future1" value="<?php echo $future1; ?>" />
- <label for="future2">Textveld Links</label>
- <textarea id="future2" name="future2"><?php echo $future2; ?></textarea>
- <?php }
- // --- METABOX: FUTURE ... SAVE --- //
- add_action('save_post', 'save_future');
- function save_future(){
- global $post;
- update_post_meta($post->ID, "future1", $_POST["future1"]);
- update_post_meta($post->ID, "future2", $_POST["future2"]);
- }
- // --- METABOX: UNIQUE ... CONTENTS --- //
- function unique_meta(){
- global $post;
- $unique1 = get_post_meta( $post->ID, 'unique1', true );
- $unique2 = get_post_meta( $post->ID, 'unique2', true );
- ?>
- <label for="unique1">Subtitel</label><input type="text" class="widefat" id="unique1" name="unique1" value="<?php echo $unique1; ?>" />
- <label for="unique2">Textveld Links</label>
- <textarea id="unique2" name="unique2"><?php echo $unique2; ?></textarea>
- <?php }
- // --- METABOX: UNIQUE ... SAVE --- //
- add_action('save_post', 'save_unique');
- function save_unique(){
- global $post;
- update_post_meta($post->ID, "unique1", $_POST["unique1"]);
- update_post_meta($post->ID, "unique2", $_POST["unique2"]);
- }
- // --- METABOX: PROVIDING ... CONTENTS --- //
- function providing_meta(){
- global $post;
- $providing1 = get_post_meta( $post->ID, 'providing1', true );
- $providing2 = get_post_meta( $post->ID, 'providing2', true );
- $providing3 = get_post_meta( $post->ID, 'providing3', true );
- $providing4 = get_post_meta( $post->ID, 'providing4', true );
- ?>
- <label for="providing1">Subtitel</label><input type="text" class="widefat" id="providing1" name="providing1" value="<?php echo $providing1; ?>" />
- <label for="providing2">Textveld Links</label>
- <textarea id="providing2" name="providing2"><?php echo $providing2; ?></textarea>
- <label for="providing3">Textveld Rechts</label>
- <textarea id="providing3" name="providing3"><?php echo $providing3; ?></textarea>
- <label for="providing4">Textveld Links</label>
- <textarea id="providing4" name="providing4"><?php echo $providing4; ?></textarea>
- <?php }
- // --- METABOX: PROVIDING ... SAVE --- //
- add_action('save_post', 'save_providing');
- function save_providing(){
- global $post;
- update_post_meta($post->ID, "providing1", $_POST["providing1"]);
- update_post_meta($post->ID, "providing2", $_POST["providing2"]);
- update_post_meta($post->ID, "providing3", $_POST["providing3"]);
- update_post_meta($post->ID, "providing4", $_POST["providing4"]);
- }
- // Save the Data
- function save_custom_meta($post_id) {
- global $custom_meta_fields;
- // verify nonce
- if (!wp_verify_nonce($_POST['custom_meta_box_nonce'], basename(__FILE__)))
- return $post_id;
- // check autosave
- if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)
- return $post_id;
- // check permissions
- if ('page' == $_POST['post_type']) {
- if (!current_user_can('edit_page', $post_id))
- return $post_id;
- } elseif (!current_user_can('edit_post', $post_id)) {
- return $post_id;
- }
- // loop through fields and save the data
- foreach ($custom_meta_fields as $field) {
- $old = get_post_meta($post_id, $field['id'], true);
- $new = $_POST[$field['id']];
- if ($new && $new != $old) {
- update_post_meta($post_id, $field['id'], $new);
- } elseif ('' == $new && $old) {
- delete_post_meta($post_id, $field['id'], $old);
- }
- } // end foreach
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement