<?php

namespace Easymailing\App\Core\Provider\Woocommerce\Widgets;

class SynchronizationAction
{
	public function postActions($acciones, $post)
	{
		if (in_array($post->post_type, ['product'])) {
			// Añade una nueva acción al array de acciones
			$acciones['synchronize_easymailing'] = '<a data-type="'.esc_attr($post->post_type).'" data-id="'.esc_attr($post->ID).'"  class="em-synchronize-resource-button" href="#">' . __('Sincronizar en Easymailing', 'easymailing') . '</a>';
		}
		return $acciones;
	}

	public function userActions($acciones, $user)
	{
		$acciones['synchronize_easymailing'] = '<a data-type="customer" data-id="'.esc_attr($user->ID).'"  class="em-synchronize-resource-button" href="#">' . __('Sincronizar en Easymailing', 'easymailing') . '</a>';

		return $acciones;
	}

	public function categoryActions($acciones, $term)
	{
		if ($term->taxonomy === 'product_cat') {
			$acciones['synchronize_easymailing'] = '<a data-type="category" data-id="'.esc_attr($term->term_id).'"  class="em-synchronize-resource-button" href="#">' . __('Sincronizar en Easymailing', 'easymailing') . '</a>';
		}
		return $acciones;
	}

}
