mirror of
https://github.com/10h30/ultimatemember.git
synced 2026-06-05 15:09:37 +09:00
Fix menu roles
This commit is contained in:
@@ -29,16 +29,27 @@ class UM_Menu_Item_Custom_Fields_Editor {
|
||||
|
||||
foreach ( self::$fields as $_key => $label ) {
|
||||
$key = sprintf( 'menu-item-%s', $_key );
|
||||
if( $_key == 'um_nav_roles' ){
|
||||
$key = sprintf( 'menu-item-%s%d', $_key, $menu_item_db_id );
|
||||
// Sanitize
|
||||
if ( ! empty( $_POST[ $key ] ) ) {
|
||||
// Do some checks here...
|
||||
$value = $_POST[ $key ];
|
||||
}
|
||||
else {
|
||||
$value = null;
|
||||
}
|
||||
|
||||
// Sanitize
|
||||
if ( ! empty( $_POST[ $key ][ $menu_item_db_id ] ) ) {
|
||||
// Do some checks here...
|
||||
$value = $_POST[ $key ][ $menu_item_db_id ];
|
||||
}else{
|
||||
// Sanitize
|
||||
if ( ! empty( $_POST[ $key ][ $menu_item_db_id ] ) ) {
|
||||
// Do some checks here...
|
||||
$value = $_POST[ $key ][ $menu_item_db_id ];
|
||||
}
|
||||
else {
|
||||
$value = null;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$value = null;
|
||||
}
|
||||
|
||||
// Update
|
||||
if ( ! is_null( $value ) ) {
|
||||
update_post_meta( $menu_item_db_id, $key, $value );
|
||||
@@ -47,6 +58,7 @@ class UM_Menu_Item_Custom_Fields_Editor {
|
||||
delete_post_meta( $menu_item_db_id, $key );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static function _fields( $id, $item, $depth, $args ) {
|
||||
@@ -66,6 +78,10 @@ class UM_Menu_Item_Custom_Fields_Editor {
|
||||
$id = sprintf( 'edit-%s-%s', $key, $item->ID );
|
||||
$name = sprintf( '%s[%s]', $key, $item->ID );
|
||||
$value = get_post_meta( $item->ID, $key, true );
|
||||
|
||||
$role_key = sprintf( 'menu-item-%s%d', $_key,$item->ID );
|
||||
$role_name = sprintf( '%s%s[]', $key, $item->ID );
|
||||
$role_value = get_post_meta( $item->ID, $role_key, true );
|
||||
$class = sprintf( 'field-%s', $_key );
|
||||
?>
|
||||
|
||||
@@ -98,7 +114,7 @@ class UM_Menu_Item_Custom_Fields_Editor {
|
||||
<p class="description">
|
||||
|
||||
<?php foreach($ultimatemember->query->get_roles() as $role_id => $role) { ?>
|
||||
<label><input type="checkbox" name="<?php echo $name; ?>[]" value="<?php echo $role_id; ?>" <?php if ( ( is_array($value) && in_array($role_id, $value ) ) || ( isset($value) && $role_id == $value ) ) echo 'checked="checked"'; ?> /> <?php echo $role; ?></label>
|
||||
<label><input type="checkbox" data-raw="<?php echo $role_id.'='.$role.'='.$value; ?>" name="<?php echo $role_name; ?>" value="<?php echo $role_id; ?>" <?php if ( ( is_array( $role_value) && in_array($role_id, $role_value ) ) || ( isset( $role_value) && $role_id == $role_value ) ) echo 'checked="checked"'; ?> /> <?php echo $role; ?></label>
|
||||
<?php } ?>
|
||||
|
||||
</p>
|
||||
@@ -122,4 +138,5 @@ class UM_Menu_Item_Custom_Fields_Editor {
|
||||
return $columns;
|
||||
}
|
||||
}
|
||||
UM_Menu_Item_Custom_Fields_Editor::init();
|
||||
UM_Menu_Item_Custom_Fields_Editor::init();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user