Astra_Ext_Nav_Menu_Markup::set_mega_menu_option( array $req )
Mega set configs
Description
Parameters
- $req
-
(array) (Required) Megamenu request payload.
Return
(string)
Source
File: addons/nav-menu/classes/class-astra-ext-nav-menu-markup.php
public function set_mega_menu_option( $req ) { $fields = isset( $req['options'] ) ? $req['options'] : array(); $nav_id = isset( $req['nav_id'] ) ? sanitize_text_field( $req['nav_id'] ) : ''; $menu_id = isset( $req['menu_id'] ) ? sanitize_text_field( $req['menu_id'] ) : ''; $widgets = isset( $req['widgets'] ) ? $req['widgets'] : array(); if ( ! current_user_can( 'edit_theme_options' ) ) { wp_die(); } if ( ! empty( $widgets ) ) { $fields['megamenu_widgets_list'] = implode( ',', $widgets ); } if ( ! empty( $fields ) ) { // Update meta values. foreach ( $fields as $key => $value ) { $key = sanitize_text_field( str_replace( 'menu-item-', '', $key ) ); if ( 'megamenu_custom_text' == $key ) { $value = wp_kses_post( wp_unslash( $value ) ); } else { $value = wp_unslash( $value ); } update_post_meta( $menu_id, '_menu_item_' . $key, $value ); } } return rest_ensure_response( 'success' ); }
Expand full source code Collapse full source code View on Trac
Changelog
Version | Description |
---|---|
4.0.0 | Introduced. |