Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // META BOX POSTO AUTO
- add_action( 'add_meta_boxes', 'postoauto_select_box' );
- function postoauto_select_box() {
- add_meta_box(
- 'postoauto_select_box', // id, used as the html id att
- __( 'descrizione posto auto' ), // meta box title
- 'postoauto_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 postoauto_select_cb( $post ) {
- global $wpdb;
- $value = get_post_meta($post->ID, 'postoauto', true);
- $postiauto = array(
- __('1 parking lot','sacconicase') => '1 posto auto',
- __('1 parking space in the garage (normal car, no SUVs and minibuses) or sometimes outside','sacconicase') => ' 1 posto auto nel garage (per auto utilitarie, no Suv e minibus) o talvolta esterno ',
- __('1 parking lot on request','sacconicase') => '1 posto auto su richiesta',
- __('2 parking lots','sacconicase') => '2 posti auto',
- __('garage for 2 cars','sacconicase') => 'garage per 2 auto',
- __('garage on demand','sacconicase') => 'garage su richiesta',
- __('garage','sacconicase') => 'garage',
- __('parking area','sacconicase') => 'parcheggio',
- __('private parking','sacconicase') => 'parcheggio privato',
- __('public outdoor parking','sacconicase') => 'parcheggio pubblico',
- __('private parking places outside','sacconicase') => 'posti auto privati esterni',
- __('parking spaces reserved for the condominium\, parking space not guaranteed','sacconicase') => 'posti auto riservati al condominio, posto auto non garantito',
- __('parking places','sacconicase') => 'posti auto',
- __('parking place 50 m. away','sacconicase') => 'posto auto a 50 m.',
- __('closed parking place','sacconicase') => 'posto auto chiuso',
- __('parking in the yard','sacconicase') => 'posto auto in cortile',
- __('no parking place','sacconicase') => 'posto auto non disponibile',
- );
- echo '<select name="postoauto">';
- echo '<option value=""' . ((($value == '') || !isset($postiauto[$value])) ? ' selected="selected"' : '') . '> ----</option>';
- // output each description of the parking place as an option
- foreach ($postiauto as $id => $text) {
- echo '<option value="' . $id . '"' . (($value == $id) ? ' selected="selected"' : '') . '">' . $text. '</option>';
- }
- echo '</select>';
- }
- add_action( 'save_post', 'save_metadata_postoauto');
- function save_metadata_postoauto($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["postoauto"]) ) {
- delete_post_meta($postid, 'postoauto');
- } else {
- update_post_meta($postid, 'postoauto', $_REQUEST['postoauto']);
- }
- }
- // END META BOX POSTO AUTO
Advertisement
Add Comment
Please, Sign In to add comment