Noptin_Background_Sync::task( array $item )

Task


Description Description

Override this method to perform any actions required on each queue item. Return the modified item for further processing in the next pass through. Or, return false to remove the item from the queue.


Top ↑

Parameters Parameters

$item

(array) (Required)


Top ↑

Return Return

(mixed)


Top ↑

Source Source

File: includes/class-noptin-background-sync.php

	public function task( $item ) {

		// Item can either be a subscriber or a WordPress user.

		if( 'subscriber' == $item ) {

			// Fetch the next subscriber to sync.
			$subscriber = $this->get_unsynced_subscriber();

			// If all subscribers are synced, return false to stop the process.
			if ( empty( $subscriber ) ) {
				delete_option( 'noptin_subscribers_syncing' );
				return false;
			}

			// Else, sync the subscriber and move on to the next user on the list.
			sync_noptin_subscribers_to_users( $subscriber );
			return $item;

		} else if ( 'wp_user' == $item ) {

			// Fetch the next user to sync.
			$user = $this->get_unsynced_user();

			// If all users are synced, return false to stop the process.
			if ( empty( $user ) ) {
				delete_option( 'noptin_users_bg_sync' );
				return false;
			}

			// Else, sync the user and move on to the next user on the list.
			sync_users_to_noptin_subscribers( $user );
			return $item;

		}

	}


Top ↑

User Contributed Notes User Contributed Notes

30 day money back guarantee
Safe & Secure online payment
Custom CSS Slide Example
Custom Animation Example
Default Animation