How to implement a custom taxonomy task using hooks?

Home Forums WordPress Plugins Bulk Task Editor How to implement a custom taxonomy task using hooks?

Tagged: ,

Viewing 0 reply threads
  • Author
    Posts
    • #8907
      Rafasashi
      Keymaster

      To implement a custom taxonomy task using hooks with Bulk Task Editor register the task:

      add_action( 'rewbe_taxonomy_actions', function($actions,$taxonomy){
      
           if( $taxonomy == 'your-custom-taxonomy' ){
      
                $actions[] = array(
      
                     'label'  => 'Name of your task',
                     'id'     => 'bulk_task_name',
                     'fields' => array(
                          array(
                               'name'    => 'var_1',
                               'type'    => 'select',
                               'options' => array(
                                    'value_1' => 'Option 1',
                                    'value_2' => 'Option 2',
                                    'value_3' => 'Option 3',
                               ),                    
                          ),
                          array(
                               'name' => 'var_2',
                               'type' => 'text',
                          ),
                     ),
                );
           }
           
           return $actions;
           
      },10,2);
      

      Add the callback function of your task:

      add_action('rewbe_do_term_{bulk_task_name}',function($term,$args){
           
           if( !empty($args['var_1']) && !empty($args['var_2']) ){
                
                $var_1 = sanitize_title($args['var_1']);
      
                $var_2 = sanitize_text_field($args['var_2']);
                
                // your logic here
           }
           
           return $term;
           
      },10,2);
Viewing 0 reply threads
  • You must be logged in to reply to this topic.