martedì 25 agosto 2015

wp_nav_menu

l'argomento $fallback_cb indica la funzione che si svolge in assenza di un menu (iniziale, cioè l'impostazione base di wordpress), mettere false per lasciare vuoto. Se si mette una funzione $args sono passati a tale funzione.

giovedì 20 agosto 2015

Menu allineato verticale

Usando il line-height di a:

ul
e li: 
0 padding
height: 50px (esempio)

ul li a
line-height: 50px (lo stesso dell'altezza del menu)

martedì 18 agosto 2015

Modificare popup media

1) Aggiungere un tab
//Assegnare un nome al tab
function upload_test_media_menu($tabs) {
$tabs['test_upload']='Test Upload';
return $tabs;
}
//Needed script to make sure wordpresses media upload scripts are inplace
wp_enqueue_script('media-upload');

//Adds your tab to the media upload button
add_filter('media_upload_tabs', 'upload_test_media_menu');

2) Aggiungere un field
function my_add_attachment_location_field( $form_fields, $post ) {
    $field_value = get_post_meta( $post->ID, 'location', true );
    $form_fields['location'] = array(
        'value' => $field_value ? $field_value : '',
        'label' => __( 'Location' ),
        'helps' => __( 'Set a location for this attachment' )
    );
    return $form_fields;
}
add_filter( 'attachment_fields_to_edit', 'my_add_attachment_location_field', 10, 2 );

function my_save_attachment_location( $attachment_id ) {
    if ( isset( $_REQUEST['attachments'][$attachment_id]['location'] ) ) {
        $location = $_REQUEST['attachments'][$attachment_id]['location'];
        update_post_meta( $attachment_id, 'location', $location );
    }
}
add_action( 'edit_attachment', 'my_save_attachment_location' );