| | |
| | | exit; |
| | | } |
| | | |
| | | use JVBase\managers\queue\Queue; |
| | | use JVBase\registrar\Registrar; |
| | | use WP_Error; |
| | | use Exception; |
| | |
| | | { |
| | | public function __construct() |
| | | { |
| | | if (empty(Registrar::getFeatured('is_content', 'term'))){ |
| | | if (empty(Registrar::withFeature('is_content', 'term'))){ |
| | | return; |
| | | } |
| | | add_filter(BASE.'handle_bulk_operation', [ $this, 'processOperation' ], 10, 3); |
| | |
| | | </thead> |
| | | <tbody> |
| | | <?php |
| | | $taxonomies = Registrar::getFeatured('is_content', 'term'); |
| | | $taxonomies = Registrar::withFeature('is_content', 'term'); |
| | | foreach ($taxonomies as $slug): |
| | | $registrar = Registrar::getInstance($slug); |
| | | $taxonomy = BASE . $slug; |
| | |
| | | $results['total'] = count($terms); |
| | | $results['messages'][] = "Found {$results['total']} terms to process"; |
| | | |
| | | JVB()->queue()->queueOperation( |
| | | Queue::getInstance()->queueOperation( |
| | | 'sync_content_taxonomy_tables', |
| | | 0, |
| | | [ |
| | |
| | | |
| | | public function processOperation(WP_Error $result, object $operation, array $data):WP_Error|array |
| | | { |
| | | switch ($operation->type) { |
| | | case 'sync_content_taxonomy_tables': |
| | | return $this->processContentTaxonomyTableSync($operation, $data); |
| | | default: |
| | | return $result; |
| | | } |
| | | return match ($operation->type) { |
| | | 'sync_content_taxonomy_tables' => $this->processContentTaxonomyTableSync($operation, $data), |
| | | default => $result, |
| | | }; |
| | | } |
| | | |
| | | public function processContentTaxonomyTableSync(object $operation, array $data):array |
| | | { |
| | | //TODO: This won't work currently |
| | | $taxonomy = $data['taxonomy']; |
| | | $registrar = new TaxonomyRegistrar($taxonomy, JVB_TAXONOMY[$taxonomy]); |
| | | $registrar = Registrar::getInstance($taxonomy); |
| | | $results = ['errors' => 0, 'success' => 0]; |
| | | foreach ($data['terms'] as $term) { |
| | | try { |