Astra_Ext_Nav_Menu_Markup::save_menu_options()

Save menu item meta options.


Description


Return

(void)


Source

File: addons/nav-menu/classes/class-astra-ext-nav-menu-markup.php

		public function save_menu_options() {

			$menu_id = sanitize_text_field( $_POST['menu_item_id'] );

			check_ajax_referer( 'ast-save-opts-' . $menu_id, 'security_nonce' );

			if ( ! current_user_can( 'edit_theme_options' ) ) {
				wp_die();
			}

			$nav_id  = sanitize_text_field( $_POST['nav_id'] );
			$fields  = isset( $_POST['options'] ) ? $_POST['options'] : array();
			$widgets = isset( $_POST['widgets'] ) ? $_POST['widgets'] : array();

			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 = sanitize_text_field( wp_unslash( $value ) );
					}

					update_post_meta( $menu_id, '_menu_item_' . $key, $value );
				}
			}

			wp_send_json_success();
		}

Changelog

Changelog
Version Description
1.6.0 Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.