__( 'Display Mode' ), 'um_nav_roles' => __( 'By Role' ) ); //add_action( 'wp_nav_menu_item_custom_fields', array( __CLASS__, '_fields' ), 1, 4 ); add_action( 'wp_update_nav_menu_item', array( __CLASS__, '_save' ), 10, 3 ); add_filter( 'manage_nav-menus_columns', array( __CLASS__, '_columns' ), 99 ); add_action( 'load-nav-menus.php', array( __CLASS__, 'enqueue_nav_menus_scripts' ) ); add_action( 'admin_footer-nav-menus.php', array( __CLASS__, '_wp_template' ) ); } public static function _save( $menu_id, $menu_item_db_id, $menu_item_args ) { if (defined( 'DOING_AJAX' ) && DOING_AJAX) { return; } foreach (self::$fields as $_key => $label) { if ($_key == 'um_nav_roles') { $key = sprintf( 'menu-item-%s', $_key ); // Sanitize if (!empty( $_POST[$key][$menu_item_db_id] )) { // Do some checks here... $value = $_POST[$key][$menu_item_db_id]; } else { $value = null; } } else { $key = sprintf( 'menu-item-%s', $_key ); // Sanitize if (!empty( $_POST[$key][$menu_item_db_id] )) { // Do some checks here... $value = $_POST[$key][$menu_item_db_id]; } else { $value = null; } } // Update if (!is_null( $value )) { update_post_meta( $menu_item_db_id, $key, $value ); } else { delete_post_meta( $menu_item_db_id, $key ); } } } public static function _fields( $id, $item, $depth, $args ) { ?>
roles()->get_roles();
$i = 0;
$html = '';
$columns = 2;
while ($i < $columns) {
$per_page = ceil( count( $options ) / $columns );
$section_fields_per_page = array_slice( $options, $i * $per_page, $per_page );
$html .= '';
foreach ($section_fields_per_page as $k => $title) {
$id_attr = ' id="' . $id . '_' . $k . '" ';
$for_attr = ' for="' . $id . '_' . $k . '" ';
$name_attr = ' name="' . $role_name . '" ';
$html .= "";
}
$html .= '';
$i++;
}
echo $html; ?>