get_render_attribute_string( 'wrapper' ) ); ?>>
add_vertical_toggler();
}
if ( 'wordpress_menu' === $menu_type ) {
$args = array(
'container' => '',
'menu' => $menu_id,
'menu_class' => 'premium-nav-menu premium-main-nav-menu',
'echo' => false,
'fallback_cb' => 'wp_page_menu',
'walker' => new Pa_Nav_Menu_Walker( $settings ),
);
$menu_html = wp_nav_menu( $args );
if ( in_array( $settings['pa_nav_menu_layout'], array( 'hor', 'ver' ), true ) ) {
?>
';
?>
get_settings_for_display();
$id = $this->get_id();
?>
'true' ) ); ?>
'true' ) ); ?>
'true' ) ); ?>
count;
if ( 0 < $item_count ) {
$is_valid = true;
}
return $is_valid;
}
/**
* Filters mobile menus.
* Changes the menu id to prevent duplicated ids in the DOM.
*
* @access private.
*
* @param string $menu_html desktop menu html.
* @param stirng|int $menu_id menu id.
*
* @return string
*/
private function mobile_menu_filter( $menu_html, $menu_id ) {
// Increment the mobile menu id & change its classes to mobile menu classes.
$slug = 'menu-' . wp_get_nav_menu_object( $menu_id )->slug;
$search = array( 'id="' . $slug . '"', 'class="premium-nav-menu premium-main-nav-menu"' );
$replace = array( 'id="' . $slug . '-1"', 'class="premium-mobile-menu premium-main-mobile-menu premium-main-nav-menu"' );
$menu_html = $this->fix_duplicated_ids( $menu_html, 'premium-nav-menu-item-' ); // fixes's the items duplicated ids.
$menu_html = $this->fix_duplicated_ids( $menu_html, 'premium-mega-content-' ); // fixes's the items duplicated ids.
return str_replace( $search, $replace, $menu_html );
}
/**
* Filters mobile menus.
* Changes the menu id to prevent duplicated ids in the DOM.
*
* @access private
*
* @param string $menu_html desktop menu html.
* @param string $slug menu item id.
*
* @return string
*/
private function fix_duplicated_ids( $html, $slug ) {
$pattern = '/id="' . $slug . '(\d+)"/';
$id_counter = 1;
// Replace duplicated IDs
return preg_replace_callback(
$pattern,
function ( $matches ) use ( &$id_counter, &$slug ) {
$id = $matches[1];
$new_id = $slug . $id . $id_counter++;
return 'id="' . $new_id . '"';
},
$html
);
}
/**
* Get Custom Menu.
*
* @access private
* @since 4.9.4
*/
private function get_custom_menu() {
$settings = $this->get_settings_for_display();
$papro_activated = apply_filters( 'papro_activated', false );
$badge_effect = $settings['sub_badge_hv_effects'];
if ( ! $papro_activated ) {
return;
}
$menu_items = $settings['menu_items'];
$is_sub_menu = false;
$i = 0;
$is_child = false;
$is_link = false;
$html_output = '';
foreach ( $menu_items as $index => $item ) {
$item_link = $this->get_repeater_setting_key( 'link', 'menu_items', $index );
if ( ! empty( $item['link']['url'] ) ) {
$this->add_link_attributes( $item_link, $item['link'] );
$current_link = get_permalink();
$is_active_item = $item['link']['url'] === $current_link;
/** handling active anchor links which redirects to an id in a page */
$is_anchor = false !== strpos( $item['link']['url'], '#' );
// we can later add other classes here based on the user settings.
if ( ! $is_anchor && $is_active_item ) {
$this->add_render_attribute( 'menu-item-' . $index, 'class', 'premium-active-item' );
}
if ( $is_anchor ) { // the active class will be added via js.
$this->add_render_attribute( 'menu-item-' . $index, 'class', 'premium-item-anchor' );
}
}
$this->add_render_attribute(
'menu-item-' . $index,
array(
// 'id' => 'premium-nav-menu-item-' . $item['_id'],
'class' => array(
'menu-item',
'premium-nav-menu-item',
'elementor-repeater',
'elementor-repeater-item-' . $item['_id'],
// $is_active_item ? 'premium-active-item' : ''
),
)
);
if ( 'submenu' === $item['item_type'] ) {
if ( 'link' === $item['menu_content_type'] ) {
// If no submenu items was rendered before.
if ( false === $is_child ) {
$html_output .= "';
$is_link = false;
}
$html_output .= '';
}
$html_output .= '
get_render_attribute_string( 'menu-item-' . $index ) . '>';
$html_output .= 'get_render_attribute_string( $item_link ) . " class='premium-menu-link premium-menu-link-parent'>";
$html_output .= $this->get_icon_html( $item );
$html_output .= esc_html( $item['text'] );
if ( array_key_exists( $index + 1, $menu_items ) ) {
$has_icon = ! empty( $settings['submenu_icon']['value'] );
if ( 'submenu' === $menu_items[ $index + 1 ]['item_type'] && $has_icon ) {
$icon_class = 'premium-dropdown-icon ' . esc_attr( $settings['submenu_icon']['value'] );
$html_output .= sprintf( '', $icon_class );
}
}
$html_output .= $this->get_badge_html( $item );
$html_output .= '';
}
?>
', esc_attr( $icon_class ) );
} elseif ( 'image' === $item['icon_type'] ) {
$html .= '';
} else {
$html .= '';
}
return $html;
}
/**
* Get Badge HTML.
*
* @access private
* @since 4.9.4
*
* @param array $item repeater item.
* @param string $type type.
*
* @return string
*/
private function get_badge_html( $item, $type = '' ) {
if ( 'yes' !== $item['badge_switcher'] ) {
return '';
}
$class = 'premium-' . $type . 'item-badge';
$html = '' . wp_kses_post( $item['badge_text'] ) . '';
return $html;
}
}