protected function prepare_link_array( $link, $slug ) {
		$array  = is_array( $link );
		$values = (array) $link;

		foreach ( $values as $key => $val ) {
			unset( $values[$key] );
			$key = preg_replace( '/^' . $slug . '\_/', '', $key );
			$values[$key] = $val;
		}

		$link = (object) $values;

		// Don't continue without a url.
		if ( ! isset( $link->url ) || empty( $link->url ) ) {
			return $array ? (array) $link : $link;
		}

		// Don't overwrite existing post id.
		if ( ! isset( $link->post_id ) || empty( $link->post_id ) ) {
			$link->post_id = url_to_postid( $link->url );
		}

		// If empty target set `_self` as default target.
		if ( empty( $link->target ) ) {
			$link->target = '_self';
		}

		// Remove slug if it exists.
		if ( isset( $link->$slug ) && is_numeric( $link->$slug ) ) {
			unset( $link->$slug );
		}

		return $array ? (array) $link : $link;
	}
protected function prepare_link_array( $link, $slug ) {
		$array  = is_array( $link );
		$values = (array) $link;

		foreach ( $values as $key => $val ) {
			unset( $values[$key] );
			$key = preg_replace( '/^' . $slug . '\_/', '', $key );
			$values[$key] = $val;
		}

		$link = (object) $values;

		// Don't continue without a url.
		if ( ! isset( $link->url ) || empty( $link->url ) ) {
			return $array ? (array) $link : $link;
		}

		// Don't overwrite existing post id.
		if ( ! isset( $link->post_id ) || empty( $link->post_id ) ) {
			$link->post_id = url_to_postid( $link->url );
		}

		// If empty target set `_self` as default target.
		if ( empty( $link->target ) ) {
			$link->target = '_self';
		}

		// Remove slug if it exists.
		if ( isset( $link->$slug ) && is_numeric( $link->$slug ) ) {
			unset( $link->$slug );
		}

		return $array ? (array) $link : $link;
	}
protected function prepare_link_array ( $ link , $ slug ) { $ array = is_array ( $ link ) ; $ values = ( array ) $ link ; foreach ( $ values as $ key => $ val ) { unset ( $ values [ $ key ] ) ; $ key = preg_replace ( '/^' . $ slug . '\_/' , '' , $ key ) ; $ values [ $ key ] = $ val ; } $ link = ( object ) $ values ; // Don't continue without a url. if ( ! isset ( $ link -> url ) || empty ( $ link -> url ) ) { return $ array ? ( array ) $ link : $ link ; } // Don't overwrite existing post id. if ( ! isset ( $ link -> post_id ) || empty ( $ link -> post_id ) ) { $ link -> post_id = url_to_postid ( $ link -> url ) ; } // If empty target set `_self` as default target. if ( empty ( $ link -> target ) ) { $ link -> target = '_self' ; } // Remove slug if it exists. if ( isset ( $ link -> $ slug ) && is_numeric ( $ link -> $ slug ) ) { unset ( $ link -> $ slug ) ; } return $ array ? ( array ) $ link : $ link ; }
Prepare link array with post id. If it gets a post id
bigger then zero it will use the permalink as url.

@param  array|object $link
@param  string       $slug

@return array|object
Prepare link array with post id . If it gets a post id bigger then zero it will use the permalink as url .