/var/www/html_uk/wp-content/plugins/automatewoo/includes/Actions/Change_Post_Status.php


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
// phpcs:ignoreFile

namespace AutomateWoo;

if ( ! 
defined'ABSPATH' ) ) exit;

/**
 * @class Action_Change_Post_Status
 * @since 2.0.0
 */
class Action_Change_Post_Status extends Action {

    public 
$required_data_items = [ 'post' ];


    function 
load_admin_details() {
        
$this->title __'Change Post Status''automatewoo' );
        
$this->group __'Other''automatewoo' );
    }


    function 
load_fields() {
        
$post_status = new Fields\Selectfalse );
        
$post_status->set_name('post_status');
        
$post_status->set_title(__('Post status''automatewoo') );
        
$post_status->set_optionsget_post_statuses() );
        
$post_status->set_required();

        
$this->add_field($post_status);
    }



    function 
run() {
        
$post $this->workflow->data_layer()->get_item'post' );
        
$status $this->get_option'post_status' );

        if ( ! 
$status || ! $post )
            return;

        
wp_update_post([
            
'ID' => $post->ID,
            
'post_status' => $status
        
]);
    }

}