ux_blocks = flatsome_get_block_list_by_id(); add_action( 'admin_enqueue_scripts', [ $this, 'register_assets' ] ); add_action( 'wp_nav_menu_item_custom_fields', [ $this, 'add_menu_fields' ], 10, 5 ); add_action( 'wp_update_nav_menu_item', [ $this, 'update_menu_fields' ], 10, 3 ); } } /** * Adds menu item custom fields. * * @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 add_menu_fields( $item_id, $item, $depth, $args, $id ) { //phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable $design = get_post_meta( $item_id, '_menu_item_design', true ); $width = get_post_meta( $item_id, '_menu_item_width', true ); $height = get_post_meta( $item_id, '_menu_item_height', true ); $block = get_post_meta( $item_id, '_menu_item_block', true ); $behavior = get_post_meta( $item_id, '_menu_item_behavior', true ); $icon_type = get_post_meta( $item_id, '_menu_item_icon-type', true ); $icon_id = get_post_meta( $item_id, '_menu_item_icon-id', true ); $icon_width = get_post_meta( $item_id, '_menu_item_icon-width', true ); $icon_height = get_post_meta( $item_id, '_menu_item_icon-height', true ); $icon_html = get_post_meta( $item_id, '_menu_item_icon-html', true ); ob_start(); ?> menu_divider(); ?>

section_title( __( 'Menu dropdown', 'flatsome' ) ); ?>

field_description( __( 'Select dropdown design.', 'flatsome' ) ); ?>

field_description( 'Select UX Block as dropdown content.' ); ?>

section_title( __( 'Menu icon', 'flatsome' ) ); ?>

field_description( __( 'Icons default (empty) to 20x20.', 'flatsome' ) ); ?>

field_description( __( 'Add any HTML, SVG or shortcode here.', 'flatsome' ) ); ?>

menu_divider(); ?>
fields as $field ) { $key = 'menu-item-' . $field; if ( isset( $_POST[ $key ] ) && ! empty( $_POST[ $key ] ) && is_array( $_POST[ $key ] ) && isset( $_POST[ $key ][ $menu_item_db_id ] ) ) { //phpcs:ignore WordPress.Security $value = wp_unslash( $_POST[ $key ][ $menu_item_db_id ] ); //phpcs:ignore WordPress.Security update_post_meta( $menu_item_db_id, '_menu_item_' . $field, $value ); } } } /** * Divider template */ private function menu_divider() { echo '

'; } /** * Section title. * * @param string $title The title. */ private function section_title( $title ) { echo '

' . $title . '

'; } /** * Menu option field description. * * @param string $description The description. */ private function field_description( $description ) { echo '' . $description . ''; } /** * Media upload/remove view * * @param int $item_id Menu item ID. * @param int $image_id Image ID. * @param string $field_identifier Field identifier string. */ private function media_view_html( $item_id, $image_id, $field_identifier ) { $output = ''; $image = wp_get_attachment_image_src( $image_id, 'full' ); $output .= sprintf( '', ! $image ? 'hidden' : '', $image ? esc_url( $image[0] ) : '' ); $output .= sprintf( '', esc_attr( $item_id ), __( 'Select image', 'flatsome' ) ); $output .= sprintf( '', ! $image ? 'hidden' : '', esc_attr( $item_id ), __( 'Remove', 'flatsome' ) ); $output .= sprintf( '', $field_identifier, esc_attr( $item_id ), $image ? esc_attr( $image_id ) : '' ); echo $output; } /** * Register assets. * * @param string $hook The current hook. */ public function register_assets( $hook ) { if ( 'nav-menus.php' === $hook ) { $theme = wp_get_theme( get_template() ); $version = $theme->get( 'Version' ); wp_enqueue_media(); flatsome_enqueue_asset( 'flatsome-admin-menu', 'admin/admin-menu', array( 'jquery', 'nav-menu' ) ); wp_enqueue_style( 'flatsome-admin-menu', get_template_directory_uri() . '/assets/css/admin/admin-menu.css', null, $version ); } } } new Menu();