Yoast\WP\SEO\Actions\Importing\Aioseo

Abstract_Aioseo_Settings_Importing_Action::get_unimported_chunk()protectedYoast 1.0

Retrieves (a chunk of, if limit is applied) the unimported AIOSEO settings. To apply a chunk, we manipulate the cursor to the keys of the AIOSEO settings.

Метод класса: Abstract_Aioseo_Settings_Importing_Action{}

Хуки из метода

Возвращает

Массив. The (chunk of, if limit is applied)) unimported AIOSEO settings.

Использование

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->get_unimported_chunk( $importable_data, $limit );
$importable_data(массив) (обязательный)
All of the available AIOSEO settings.
$limit(int) (обязательный)
The maximum number of unimported objects to be returned.

Код Abstract_Aioseo_Settings_Importing_Action::get_unimported_chunk() Yoast 19.11

protected function get_unimported_chunk( $importable_data, $limit ) {
	\ksort( $importable_data );

	$cursor_id = $this->get_cursor_id();
	$cursor    = $this->import_cursor->get_cursor( $cursor_id, '' );

	/**
	 * Filter 'wpseo_aioseo_<identifier>_import_cursor' - Allow filtering the value of the aioseo settings import cursor.
	 *
	 * @api int The value of the aioseo posttype default settings import cursor.
	 */
	$cursor = \apply_filters( 'wpseo_aioseo_' . $this->get_type() . '_import_cursor', $cursor );

	if ( $cursor === '' ) {
		return \array_slice( $importable_data, 0, $limit, true );
	}

	// Let's find the position of the cursor in the alphabetically sorted importable data, so we can return only the unimported data.
	$keys = \array_flip( \array_keys( $importable_data ) );
	// If the stored cursor now no longer exists in the data, we have no choice but to start over.
	$position = ( isset( $keys[ $cursor ] ) ) ? ( $keys[ $cursor ] + 1 ) : 0;

	return \array_slice( $importable_data, $position, $limit, true );
}