Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // META BOX INTRO
- add_action( 'add_meta_boxes', 'intro_select_box' );
- function intro_select_box() {
- add_meta_box(
- 'intro_select_box', // id, used as the html id att
- __( 'Introduzione' ), // meta box title
- 'intro_select_cb', // callback function, spits out the content
- 'post', // post type or page. This adds to posts only
- 'side', // context, where on the screen
- );
- }
- function intro_select_cb( $post ) {
- global $wpdb;
- $value = get_post_meta($post->ID, 'intro', true);
- $intros = array(
- __('The apartment consists of','sacconicase') => ' L\'appartamento si compone di',
- __('The house comprises of','sacconicase') => 'La casa si compone di',
- __('The bungalow comprises of','sacconicase') => 'Il bungalow si compone di',
- __('The apartment comprises of 1 room with living area/sleeping area + 1 bathroom','sacconicase') => 'L\'appartamento si compone di un unico ambiente zona giorno/notte + 1 bagno',
- );
- echo '<select name="intro">';
- echo '<option value=""' . ((($value == '') || !isset($intros[$value])) ? ' selected="selected"' : '') . '> ----</option>';
- // output each floor as an option
- foreach ($intros as $id => $text) {
- echo '<option value="' . $id . '"' . (($value == $id) ? ' selected="selected"' : '') . '">' . $text. '</option>';
- }
- echo '</select>';
- }
- add_action( 'save_post', 'save_metadata_intro');
- function save_metadata_intro($postid)
- {
- if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) return false;
- if ( !current_user_can( 'edit_page', $postid ) ) return false;
- if( empty($postid) ) return false;
- if ( is_null($_REQUEST["intro"]) ) {
- delete_post_meta($postid, 'intro');
- } else {
- update_post_meta($postid, 'intro', $_REQUEST['intro']);
- }
- }
- // END INTRO
Advertisement
Add Comment
Please, Sign In to add comment