Deprecated

This method has been deprecated.

AnsPress_Hooks::update_menu_url( array $items )

Description #

Update AnsPress pages URL dynimacally

Parameters #

  • $items
    array (Required) Menu item.

Changelog #

VersionDescription
4.1.1Introduced.

Source #

File: includes/hooks.php

	public static function update_menu_url( $items ) {
		// If this is admin then we dont want to update url.
		if ( is_admin() ) {
			return $items;
		}

		$pages = anspress()->pages;

		foreach ( (array) $items as $key => $item ) {

			if ( 'anspress-links' === $item->type ) {
				if ( isset( $pages[ $item->object ]['private'] ) && $pages[ $item->object ]['private'] && ! is_user_logged_in() ) {
					unset( $items[ $key ] );
				} else {
					if ( 'base' === $item->object ) {
						$item->url = ap_get_link_to( '/' );
					} else {
						$item->url = apply_filters( 'ap_menu_link', ap_get_link_to( ap_get_page_slug( $item->object ) ), $item );
					}
				}
			}
		}

		return apply_filters( 'ap_menu_items', $items );
	}

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Add your comment