# wordpress-seo/18.2/src/actions/importing/import-cursor-manager-trait.php

Yoast SEO – Advanced SEO with real-time guidance and built-in AI, version 18.2. 46 lines.

- Page: https://pluginprobe.com/plugins/wordpress-seo/18.2/code/src/actions/importing/import-cursor-manager-trait.php
- Raw: https://pluginprobe.com/plugins/wordpress-seo/18.2/raw/src/actions/importing/import-cursor-manager-trait.php
- Modified: 2021-12-21T10:29:22+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/wordpress-seo/18.2/code/src/actions/importing/import-cursor-manager-trait.php#L10-L20`.

```php
<?php

namespace Yoast\WP\SEO\Actions\Importing;

use Yoast\WP\SEO\Helpers\Options_Helper;

/**
 * The Cursor Manager trait.
 * @phpcs:disable Yoast.NamingConventions.ObjectNameDepth.MaxExceeded
 */
trait Import_Cursor_Manager_Trait {

	/**
	 * Returns the stored cursor value.
	 *
	 * @param Options_Helper $options_helper The options helper.
	 * @param string         $cursor_id      The cursor id.
	 * @param mixed          $default        The default value if no cursor has been set yet.
	 *
	 * @return int The stored cursor value.
	 */
	public function get_cursor( $options_helper, $cursor_id, $default = 0 ) {
		$import_cursors = $options_helper->get( 'import_cursors', [] );

		return ( isset( $import_cursors[ $cursor_id ] ) ) ? $import_cursors[ $cursor_id ] : $default;
	}

	/**
	 * Stores the current cursor value.
	 *
	 * @param Options_Helper $options_helper   The options helper.
	 * @param string         $cursor_id        The cursor id.
	 * @param int            $last_imported_id The id of the lastly imported entry.
	 *
	 * @return void.
	 */
	public function set_cursor( $options_helper, $cursor_id, $last_imported_id ) {
		$current_cursors = $options_helper->get( 'import_cursors', [] );

		if ( ! isset( $current_cursors[ $cursor_id ] ) || $current_cursors[ $cursor_id ] < $last_imported_id ) {
			$current_cursors[ $cursor_id ] = $last_imported_id;
			$options_helper->set( 'import_cursors', $current_cursors );
		}
	}
}

```
