| 1 |
<?php |
| 2 |
|
| 3 |
namespace FL\Assistant\Hooks\Actions; |
| 4 |
|
| 5 |
use FL\Assistant\Data\Repository\NotationsRepository; |
| 6 |
|
| 7 |
/** |
| 8 |
* Class OnDeleteTerm |
| 9 |
* @package FL\Assistant\Hooks\Actions |
| 10 |
*/ |
| 11 |
class OnDeleteTerm { |
| 12 |
|
| 13 |
protected $notations; |
| 14 |
|
| 15 |
public function __construct( NotationsRepository $notations ) { |
| 16 |
$this->notations = $notations; |
| 17 |
} |
| 18 |
|
| 19 |
public function __invoke( $term_id ) { |
| 20 |
$results = $this->notations->get_labels_by_id( 'post', $term_id ); |
| 21 |
|
| 22 |
foreach ( $results as $label ) { |
| 23 |
wp_delete_post( $label['id'] ); |
| 24 |
} |
| 25 |
} |
| 26 |
} |
| 27 |
|