bp_admin_wp_nav_menu_restrict_items()

Restrict various items from view if editing a BuddyPress menu.


Description Description

If a person is editing a BP menu item, that person should not be able to see or edit the following fields:

  • CSS Classes – We use the ‘bp-menu’ CSS class to determine if the menu item belongs to BP, so we cannot allow manipulation of this field to occur.
  • URL – This field is automatically generated by BP on output, so this field is useless and can cause confusion.

Note: These restrictions are only enforced if JavaScript is enabled.


Source Source

File: bp-core/admin/bp-core-admin-functions.php

function bp_admin_wp_nav_menu_restrict_items() {
?>
	<script type="text/javascript">
	jQuery( '#menu-to-edit').on( 'click', 'a.item-edit', function() {
		var settings  = jQuery(this).closest( '.menu-item-bar' ).next( '.menu-item-settings' );
		var css_class = settings.find( '.edit-menu-item-classes' );

		if( css_class.val().indexOf( 'bp-menu' ) === 0 ) {
			css_class.attr( 'readonly', 'readonly' );
			settings.find( '.field-url' ).css( 'display', 'none' );
		}
	});
	</script>
<?php
}

Top ↑

Changelog Changelog

Changelog
Version Description
1.9.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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