AnsPress_Query::add_pos( string $type, integer $ref_id, mixed $key )

Description #

Add position of reference in objects.

Parameters #

  • $type
    string (Required) ids type.
  • $ref_id
    integer (Required) Reference ID.
  • $key
    mixed (Required) Object key.

Source #

File: includes/class-query.php

	public function add_pos( $type, $ref_id, $key ) {
		if ( ! isset( $this->pos[ $type ] ) ) {
			$this->pos[ $type ] = array();
		}

		if ( ! isset( $this->pos[ $type ][ $ref_id ] ) ) {
			$this->pos[ $type ][ $ref_id ] = $key;
			return;
		}

		$prev_val = $this->pos[ $type ][ $ref_id ];

		if ( ! is_array( $prev_val ) ) {
			$this->pos[ $type ][ $ref_id ] = array( $prev_val, $key );
			return;
		}

		if ( is_array( $prev_val ) ) {
			$this->pos[ $type ][ $ref_id ][] = $key;
		}
	}

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