| 1 |
<?php |
| 2 |
|
| 3 |
add_action( 'wp_update_nav_menu_item', 'bogo_update_nav_menu_item', 10, 2 ); |
| 4 |
|
| 5 |
function bogo_update_nav_menu_item( $menu_id, $menu_item_id ) { |
| 6 |
delete_post_meta( $menu_item_id, '_locale' ); |
| 7 |
|
| 8 |
if ( isset( $_POST['menu-item-bogo-locale'][$menu_item_id] ) ) { |
| 9 |
$locales = (array) $_POST['menu-item-bogo-locale'][$menu_item_id]; |
| 10 |
$locales = bogo_filter_locales( $locales ); |
| 11 |
|
| 12 |
foreach ( $locales as $locale ) { |
| 13 |
add_post_meta( $menu_item_id, '_locale', $locale ); |
| 14 |
} |
| 15 |
} |
| 16 |
|
| 17 |
if ( ! metadata_exists( 'post', $menu_item_id, '_locale' ) ) { |
| 18 |
add_post_meta( $menu_item_id, '_locale', 'zxx' ); // special code in ISO 639-2 |
| 19 |
} |
| 20 |
} |
| 21 |
|
| 22 |
?> |