data[ $key ] = $data; return $this; } /** * Dispatch. * * @since 1.8 * @access public * @author Grégory Viguier * * @return array|WP_Error */ public function dispatch() { if ( ! empty( $this->data ) ) { return parent::dispatch(); } } /** * Tell if a task is already in the queue. * * @since 1.8 * @access public * @author Grégory Viguier * * @param array $data { * The data to test against the queue. * * @type int $id The image ID. Required. * @type string $size The thumbnail size. Required. * } * @return bool */ public function is_in_queue( $data ) { $key = $data['id'] . '|' . $data['size']; return isset( $this->data[ $key ] ); } /** * Task: optimize the thumbnail. * * @since 1.8 * @access public * @author Grégory Viguier * * @param array $item { * The data to test against the queue. * * @type int $id The image ID. Required. * @type string $size The thumbnail size. Required. * } * @return bool False to remove the item from the queue. */ protected function task( $item ) { $attachment_id = absint( $item['id'] ); $size = sanitize_text_field( $item['size'] ); if ( ! $attachment_id || ! $size ) { return false; } $attachment = get_imagify_attachment( 'NGG', $attachment_id, 'ngg_optimize_dynamic_thumbnail' ); $attachment->optimize_new_thumbnail( $size ); return false; } }