__( 'Display Mode', 'ultimate-member' ), 'um_nav_roles' => __( 'By Role', 'ultimate-member' ), ); add_action( 'customize_controls_print_footer_scripts', array( &$this, '_wp_template' ) ); add_action( 'wp_update_nav_menu_item', array( &$this, '_save' ), 10, 3 ); add_action( 'wp_nav_menu_item_custom_fields', array( $this, 'wp_nav_menu_item_custom_fields' ), 20, 5 ); } /** * Fires just before the move buttons of a nav menu item in the menu editor. * Adds block "Ultimate Member Menu Settings" * * @param int $item_id Menu item ID. * @param \WP_Post $item Menu item data object. * @param int $depth Depth of menu item. Used for padding. * @param \stdClass $args An object of menu item arguments. * @param int $id Nav menu ID. */ public function wp_nav_menu_item_custom_fields( $item_id, $item, $depth, $args, $id = null ) { $um_nav_public = get_post_meta( $item->ID, 'menu-item-um_nav_public', true ); $_nav_roles_meta = get_post_meta( $item->ID, 'menu-item-um_nav_roles', true ); $um_nav_roles = array(); if ( $_nav_roles_meta ) { foreach ( $_nav_roles_meta as $key => $value ) { if ( is_int( $key ) ) { $um_nav_roles[] = $value; } } } $options = UM()->roles()->get_roles( false ); ?>

>
'; foreach ( $section_fields_per_page as $k => $title ) { $id_attr = ' id="edit-menu-item-um_nav_roles-' . $item_id . '_' . $k . '" '; $for_attr = ' for="edit-menu-item-um_nav_roles-' . $item_id . '_' . $k . '" '; $checked_attr = checked( in_array($k,$um_nav_roles), true, false ); $html .= ""; } $html .= ''; $i++; } echo $html; ?>

$label ) { $key = sprintf( 'menu-item-%s', $_key ); // Sanitize if ( ! empty( $_POST[ $key ][ $menu_item_db_id ] ) ) { // Do some checks here... if ( is_array( $_POST[ $key ][ $menu_item_db_id ] ) ) { $value = $_POST[ $key ][ $menu_item_db_id ]; $sanitized_keys = array_map( 'sanitize_key', array_keys( $value ) ); $value = $sanitized_keys; } else { if ( 'on' === $_POST[ $key ][ $menu_item_db_id ] ) { $value = 1; } else { $value = (int) $_POST[ $key ][ $menu_item_db_id ]; } } } else { $value = null; } // phpcs:enable WordPress.Security.NonceVerification // Update if ( ! is_null( $value ) ) { update_post_meta( $menu_item_db_id, $key, $value ); } else { delete_post_meta( $menu_item_db_id, $key ); } } } /** * */ function _wp_template() { ?>