Remove current classes

@param string $items The menu items, sorted by each menu item's menu order.
@param stdClass $args  An object containing wp_nav_menu() arguments.
@return string
768887
public function _remove_current_classes( $items, $args ) {
		if ( is_customize_preview() ) {
			return $items;
		}

		if ( ! static::_is_caching_nav_menus() ) {
			return $items;
		}

		if ( ! $this->_is_caching_nav_menu( $args->theme_location ) ) {
			return $items;
		}

		foreach ( $items as $items_index => $item ) {
			foreach ( $item->classes as $index => $class ) {
				if ( false === strpos( $class, 'current' ) ) {
					continue;
				}
				unset( $items[ $items_index ]->classes[ $index ] );
			}
		}
		return $items;
	}
1182333
public function removeAttributeClass($classes)
    {
        if ($this->offsetExists('class')) {
            if (is_string($classes)) {
                $classes = explode(',', $classes);
            }

            $classes = array_map('trim', $classes);
            $classes = array_filter($classes);

            foreach ($classes as $class) {
                if (false !== ($key = array_search($class, $this->storage[ 'class' ]))) {
                    unset($this->storage[ 'class' ][ $key ]);
                } elseif (strpos($class, '*') !== false) {
                    $class = str_replace('*', '', $class);
                    foreach ($this->storage[ 'class' ] as $key => $value) {
                        if (preg_match("/\b$class\b/i", $value)) {
                            unset($this->storage[ 'class' ][ $key ]);
                        }
                    }
                }
            }

            if (count($this->storage[ 'class' ]) == 0) {
                unset($this->storage[ 'class' ]);
            }
        }
    }
845965
public function pagination(array $args = [])
    {
        $defaults = [
            'range'          => 2,
            'pages'          => null,
            'containerEl'    => 'div',
            'containerId'    => 'pagination-container',
            'containerClass' => 'pagination-container',
            'listEl'         => 'ul',
            'listClass'      => 'pagination',
            'itemEl'         => 'li',
            'innerEl'        => 'span',
            'activeClass'    => 'active',
            'disabledClass'  => 'disabled',
            'overview'       => false
        ];

        $args = wp_parse_args($args, $defaults);
        extract($args, EXTR_SKIP);

        $output = [];

        if (is_singular()) {
            global $page, $numpages;

            if ($overview) {
                $before = sprintf(
                    '<%s class="%s"><%s class="%s"><%s>%s</%s></%s><%s>',
                    $listEl,
                    $listClass,
                    $itemEl,
                    $disabledClass,
                    $innerEl,
                    sprintf(__('Page %d of %d', 'novusopress'), $page, $numpages),
                    $innerEl,
                    $itemEl,
                    $itemEl
                );
            } else {
                $before = sprintf('<%s class="%s"><%s>', $listEl, $listClass, $itemEl);
            }

            add_filter('wp_link_pages_link', function ($link, $i) use ($activeClass, $innerEl) {
                global $page;

                if ($i === $page) {
                    return sprintf('<%s class="%s">%s</%s>', $innerEl, $activeClass, $link, $innerEl);
                }

                return $link;
            }, 10, 2);

            $links = wp_link_pages([
                'before'         => $before,
                'after'          => sprintf('</%s></%s>', $itemEl, $listEl),
                'next_or_number' => 'number',
                'separator'      => sprintf('</%s><%s>', $itemEl, $itemEl),
                'echo'           => false
            ]);

            $output[] = preg_replace(
                sprintf('#<%s>[\s]*<%s class="%s">#', $itemEl, $innerEl, $activeClass),
                sprintf('<%s class="%s"><%s>', $itemEl, $activeClass, $innerEl),
                $links
            );
        } else {
            global $paged;

            $range = (integer) $range;
            $show = ($range * 2) + 1;

            if (empty($paged)) $paged = 1;

            if (null === $pages) {
                global $wp_query;

                $pages = $wp_query->max_num_pages;

                if (!$pages) {
                    $pages = 1;
                }
            }

            $paged = (integer) $paged;
            $pages = (integer) $pages;

            if (1 !== $pages) {
                $output[] = sprintf('<%s class="%s">', $listEl, $listClass);

                if ($overview) {
                    $output[] = sprintf(
                        '<%s class="%s"><%s>%s</%s></%s>',
                        $itemEl,
                        $disabledClass,
                        $innerEl,
                        sprintf(__('Page %d of %d', 'novusopress'), $paged, $pages),
                        $innerEl,
                        $itemEl
                    );
                }

                if ($paged > 2 && $paged > $range + 1 && $show < $pages) {
                    $output[] = sprintf(
                        '<%s><a href="%s">%s %s</a></%s>',
                        $itemEl,
                        get_pagenum_link(1),
                        '&laquo;',
                        __('First', 'novusopress'),
                        $itemEl
                    );
                }

                if ($paged > 1 && $show < $pages) {
                    $output[] = sprintf(
                        '<%s><a href="%s">%s %s</a></%s>',
                        $itemEl,
                        get_pagenum_link($paged - 1),
                        '&lsaquo;',
                        __('Previous', 'novusopress'),
                        $itemEl
                    );
                }

                for ($i = 1; $i <= $pages; $i++) {
                    if (1 !== $pages && (!($i >= $paged + $range + 1 || $i <= $paged - $range - 1) || $pages <= $show)) {
                        if ($paged === $i) {
                            $output[] = sprintf(
                                '<%s class="%s"><%s>%s</%s></%s>',
                                $itemEl,
                                $activeClass,
                                $innerEl,
                                $i,
                                $innerEl,
                                $itemEl
                            );
                        } else {
                            $output[] = sprintf(
                                '<%s><a href="%s">%s</a></%s>',
                                $itemEl,
                                get_pagenum_link($i),
                                $i,
                                $itemEl
                            );
                        }
                    }
                }

                if ($paged < $pages && $show < $pages) {
                    $output[] = sprintf(
                        '<%s><a href="%s">%s %s</a></%s>',
                        $itemEl,
                        get_pagenum_link($paged + 1),
                        __('Next', 'novusopress'),
                        '&rsaquo;',
                        $itemEl
                    );
                }

                if ($paged < $pages - 1 && $paged + $range - 1 < $pages && $show < $pages) {
                    $output[] = sprintf(
                        '<%s><a href="%s">%s %s</a></%s>',
                        $itemEl,
                        get_pagenum_link($pages),
                        __('Last', 'novusopress'),
                        '&raquo;',
                        $itemEl
                    );
                }

                $output[] = sprintf('</%s>', $listEl);
            }
        }

        $output = implode('', $output);

        if (!empty($output)) {
            $output = sprintf(
                '<%s id="%s" class="%s">%s</%s>',
                $containerEl,
                $containerId,
                $containerClass,
                $output,
                $containerEl
            );
        }

        return apply_filters('novusopress_view_pagination_output', $output);
    }
124448
public function remove($item)
    {
        if (!($item instanceof $this->dataClass)) {
            throw new InvalidArgumentException(
                "HasManyList::remove() expecting a $this->dataClass object, or ID",
                E_USER_ERROR
            );
        }

        // Don't remove item with unrelated class key
        $foreignClass = $this->getForeignClass();
        $classNames = ClassInfo::subclassesFor($foreignClass);
        $classForeignKey = $this->classForeignKey;
        $classValueLower = strtolower($item->$classForeignKey);
        if (!array_key_exists($classValueLower, $classNames)) {
            return;
        }

        // Don't remove item which doesn't belong to this list
        $foreignID = $this->getForeignID();
        $foreignKey = $this->foreignKey;

        if (empty($foreignID)
            || $foreignID == $item->$foreignKey
            || (is_array($foreignID) && in_array($item->$foreignKey, $foreignID))
        ) {
            $item->$foreignKey = null;
            $item->$classForeignKey = null;
            $item->write();
        }
    }
741341
public function addTranslate($items, $args = null)
    {
        if (!is_object($args)) {
            $args = (object)$args;
        }
        
        if ($args && $args->theme_location != get_field('google_translate_menu', 'option')) {
            return $items;
        }

        //Not in child (if inherited from main)
        if ($args && (isset($args->child_menu) && $args->child_menu == true) && $args->theme_location == "main-menu") {
            return $items;
        }

        $label = 'Translate';
        if (get_field('google_translate_show_as', 'option') == 'icon') {
            $label = '<span data-tooltip="Translate"><i class="pricon pricon-globe"></i></span>';
        } elseif (get_field('google_translate_show_as', 'option') == 'combined') {
            $label = '<i class="pricon pricon-globe"></i> Translate';
        }

        $translate = '<li class="menu-item-translate"><a href="#translate" class="translate-icon-btn" aria-label="translate">' . $label . '</a></li>';

        if (isset($args->include_top_level)) {
            $items = $translate . $items;
        } else {
            $items .= $translate;
        }

        return $items;
    }
728752
public function getParametersDictionary(array $args = [])
    {
        $dictionary = [];

        foreach ($args as $parameter) {
            if (!is_object($parameter)) continue;
            $dictionary[get_class($parameter)] = $parameter;
        }

        return array_merge($args, $dictionary);
    }
1252284
public function remove(string ...$args): self
    {
        $classes = $this->getClasses();

        $classes = array_diff($classes, $args);

        $this->html->setAttribute('class', implode(' ', $classes));

        return $this;
    }
559044
public function clear($args = array(), $assoc_args = array())
    {
        if (defined('WP_CACHE') && WP_CACHE && class_exists('\zencache')) {
            $wiped = zencache::wipe();
            WP_CLI::success("$wiped file(s) were cleared from the cache.");
        } else {
            WP_CLI::warning('ZenCache is not installed or enabled');
        }
    }
371431
public static function ul( $items, $options = [] ) {
		$tag         = ArrayHelper::remove( $options, 'tag', 'ul');
		$encode      = ArrayHelper::remove( $options, 'encode', FALSE );
		$formatter   = ArrayHelper::remove( $options, 'item');
		$separator   = ArrayHelper::remove( $options, 'separator', "\n");
		$itemOptions = ArrayHelper::remove( $options, 'itemOptions', []);
		$classFor    = ArrayHelper::remove( $itemOptions, 'class_for', null );

		if ( empty( $items ) ) {
			return static::tag( $tag, '', $options );
		}
		$results = [];
		foreach ( $items as $i => $item ) {
			if ( $formatter !== NULL ) {
				$results[] = call_user_func( $formatter, $item, $i );
			} else {
				$_itemOptions = $itemOptions;
				if ( isset( $classFor ) && array_key_exists( $i, $classFor ) ) {
					static::addCssClass( $_itemOptions, $classFor[ $i ] );
				}
				$results[] = static::tag('li', $encode ? static::encode( $item ) : $item, $_itemOptions );
			}
		}

		return static::tag( $tag, $separator . join( $separator, $results ) . $separator, $options );
	}
100236
public function deleteItems( stdClass $params )
	{
		$this->_checkParams( $params, array( 'items' ) );

		foreach( (array) $params->items as $id ) {
			$this->_getManager()->deleteItem( $id );
		}

		return array(
			'success' => true,
		);
	}
136069
public function getOrderedArray($items = [])
    {
        $ordered = [];
        if (empty($items)) {
            $items = $this->_menuItems;
        }

        foreach ($items as $item) {
            $ordered[] = $item;
        }

        $ordered = Hash::sort($ordered, '{n}.priority', 'ASC');

        foreach ($ordered as &$item) {
            if (isset($item['children']) && !empty($item['children'])) {
                $item['children'] = $this->getOrderedArray($item['children']);
            }
        }

        return $ordered;
    }
495197
private function buildMenuItems(array $items)
    {
        $html = '';

        foreach ($items as $item) {

            if ($this->multilevel && $item->hasChilds()) {
                $html .= '
				<li class="navbar-parent">
					<a href="' . $item->getUrl() . '">' . $item->getText() . '</a>
					<ul>';

                $html .= $this->buildMenuItems($item->getChilds());

                $html .= '
					</ul>
				</li>';
            } else {

                $url = $item->getUrl();

                if ($url) {
                    $html .= '<li><a href="' . $url . '">' . $item->getText() . '</a></li>';
                } else {
                    $html .= '<li><a href="#" onClick="return false">' . $item->getText() . '</a></li>';
                }
            }
        }

        return $html;
    }
212538
public function mainMenu(array $args = [])
    {
        $defaults = [
            'searchForm'     => false,
            'btnColor'       => 'default',
            'containerEl'    => 'div',
            'containerId'    => 'navbar-collapse-main-menu',
            'containerClass' => 'navbar-collapse-main-menu navbar-collapse collapse',
            'menuEl'         => 'ul',
            'menuId'         => 'navbar-main-menu',
            'menuClass'      => 'navbar-main-menu navbar-nav nav',
            'depth'          => 2,
            'indent'         => 2
        ];

        $args = wp_parse_args($args, $defaults);
        extract($args, EXTR_SKIP);

        $tab = '    ';
        $indent = (integer) $indent;

        $wrap = [];
        $wrap[] = PHP_EOL;
        $wrap[] = str_repeat($tab, $indent + 1);
        $wrap[] = sprintf('<%s id="%%1$s" class="%%2$s">', $menuEl);
        $wrap[] = PHP_EOL;
        $wrap[] = '%3$s';
        $wrap[] = str_repeat($tab, $indent + 1);
        $wrap[] = sprintf('</%s><!-- #%s -->', $menuEl, $menuId);

        if ($searchForm) {
            $wrap[] = $this->getNavbarSearchForm($btnColor);
        }

        $wrap[] = PHP_EOL;
        $wrap[] = str_repeat($tab, $indent);

        $output = [];
        $output[] = wp_nav_menu([
            'theme_location'  => 'main-menu',
            'container'       => $containerEl,
            'container_id'    => $containerId,
            'container_class' => $containerClass,
            'menu_id'         => $menuId,
            'menu_class'      => $menuClass,
            'items_wrap'      => implode('', $wrap),
            'depth'           => $depth,
            'echo'            => false,
            'walker'          => new NavbarWalker($indent + 2)
        ]);
        $output[] = sprintf('<!-- #%s -->', $containerId);

        return apply_filters('novusopress_view_main_menu_output', implode('', $output));
    }
714977
public function items($arguments = [])
    {
        return $this->plugger
            ->setModel($this)
            ->setAdapter(Menu::class)
            ->plugIn(wp_get_nav_menu_items($this->getNavigation()->name, $arguments))
            ->getConnected();
    }
1296122
public function adminBarSetting($args)
    {
        if (empty($args)) {
            return;
        }

        add_action('wp_before_admin_bar_render', function () use ($args) {
            global $wp_admin_bar;

            // Iterate on all
            foreach ($args as $item) {
                $wp_admin_bar->remove_menu($item);
            }
        });
    }
1133283
public function renderMenuPart($items)
    {
        $items = $this->normalizeItems($items, $hasActiveChild);

        $lines = '';
        foreach ($items as $i => $item) {
            Html::addCssClass($item['options'], 'item');
            if ($item['active']) {
                Html::addCssClass($item['options'], 'active');
            }

            if (isset($item['items'])) {
                Html::addCssClass($item['options'], 'ui simple dropdown');
                $item['label'] =
                    $item['label'] .
                    Elements::icon('dropdown') .
                    Html::tag('div', $this->renderMenuPart($item['items']), ['class' => 'menu']);

                $menu = $this->renderItem($item);
            } else {
                $menu = $this->renderItem($item);
            }
            $lines .= $menu;
        }
        return $lines;
    }
172957
public function removeItems( $items ) {
		foreach ( $items as $item ) {
			$index = array_search( $item, $this->items, true );
			if ( $index !== false ) {
				$item->setElementGroup( null );
				array_splice( $this->items, $index, 1 );
			}
		}

		// Update actual target element contents to reflect our list
		$this->group->clearContent();
		$this->group->appendContent( $this->items );

		return $this;
	}