ACF_Walker_Nav_Menu_Edit::start_el
Starts the element output.
Calls the Walker_Nav_Menu_Edit start_el function and then injects the custom field HTML
Method of the class: ACF_Walker_Nav_Menu_Edit{}
No Hooks.
Returns
null. Nothing (null).
Usage
$ACF_Walker_Nav_Menu_Edit = new ACF_Walker_Nav_Menu_Edit(); $ACF_Walker_Nav_Menu_Edit->start_el( $output, $item, $depth, $args, $id );
- $output(string) (required) (passed by reference — &)
- Used to append additional content (passed by reference).
- $item(WP_Post) (required)
- Menu item data object.
- $depth(int)
- Depth of menu item. Used for padding.
- $args(stdClass)
- An object of wp_nav_menu() arguments.
Default:array() - $id(int)
- Current item ID.
Changelog
| Since 5.0.0 | Introduced. |
| Since 5.7.2 | Added preg_replace based on https://github.com/ineagu/wp-menu-item-custom-fields |
ACF_Walker_Nav_Menu_Edit::start_el() ACF Walker Nav Menu Edit::start el code ACF 6.0.4
function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
// vars
$item_output = '';
// call parent function
parent::start_el( $item_output, $item, $depth, $args, $id );
// inject custom field HTML
$output .= preg_replace(
// NOTE: Check this regex from time to time!
'/(?=<(fieldset|p)[^>]+class="[^"]*field-move)/',
$this->get_fields( $item, $depth, $args, $id ),
$item_output
);
}