Site icon Hip-Hop Website Design and Development

Plugin Choices Not Saving to Database in WP 4.5

WordPress 4.5 broke my plugin and there aren’t any apparent clues why within the change log

The plugin controls the visibility of menu objects. Customers choose a number of international locations and whether or not to indicate or disguise the menu merchandise.

The setting to indicate or disguise nonetheless works:

add_action( 'wp_update_nav_menu_item', array( $this, 'csmi_update_visibility' ), 10, 3 );
...
<enter
sort="radio"
id="edit-menu-item-visibility-<?php echo $item_id;?>"
identify="menu-item-show-hide[<?php echo $item_id; ?>]" 
worth="disguise" <?php checked( get_post_meta( $item_id, 'hide_show', true ), 'disguise', true ); ?>
/>Conceal from these international locations.</br>
<enter
sort="radio"
id="edit-menu-item-visibility-<?php echo $item_id; ?>"
identify="menu-item-show-hide[<?php echo $item_id; ?>]"
worth="present" <?php checked( get_post_meta( $item_id, 'hide_show', true ), 'present', true ); ?>
/>Solely present to those international locations.</br>
...
/* Put visibility settings within the database. */
operate csmi_update_visibility( $menu_id, $menu_item_db_id, $args ) {
    $meta_value = get_post_meta( $menu_item_db_id, 'hide_show', true );
    if ( isset( $_POST[ 'menu-item-show-hide' ][ $menu_item_db_id ] ) ) {
        $new_meta_value = $_POST[ 'menu-item-show-hide' ][ $menu_item_db_id ];
    }
    if ( $meta_value !== $new_meta_value ) {
        update_post_meta( $menu_item_db_id, 'hide_show', $new_meta_value );
    }
}

However location(s) will not be being saved:

add_action( 'wp_update_nav_menu_item', array( $this, 'csmi_update_locations' ), 10, 3 );
...
<choose identify="menu-item-visibility[<?php echo $item_id; ?>][]" id="edit-menu-item-visibility-<?php echo $item_id; ?>" class="chzn-select" a number of="true">
<?php
$vals = get_post_meta( $item_id, 'areas', true );
foreach( $international locations as $key => $worth ) { 
?>
    <possibility worth="<?php echo $key;?>"<?php echo is_array( $vals ) && in_array( $key, $vals ) ? "chosen='chosen'" : ''; ?>> <?php echo $worth;?> </possibility>
<?php
}
?>
</choose>
...
/* Put areas within the database. */
operate csmi_update_locations( $menu_id, $menu_item_db_id, $args ) {
    $meta_value = get_post_meta( $menu_item_db_id, 'areas', true );
    if ( isset( $_POST[ 'menu-item-visibility' ][ $menu_item_db_id ] ) ) { 
        $new_meta_value = $_POST[ 'menu-item-visibility' ][ $menu_item_db_id ];
    }
    if ( !isset($new_meta_value ) ) {
        delete_post_meta( $menu_item_db_id, 'areas', $meta_value );
    }
    elseif ( $meta_value !== $new_meta_value ) {
        update_post_meta( $menu_item_db_id, 'areas', $new_meta_value );
    }
}

Any concepts how WP 4.5 may need damaged it? I am about at my wits finish.

Supply code accessible right here: https://plugins.trac.wordpress.org/browser/location-specific-menu-items-by-country/tags/1.0.3