WC_Legacy_Webhook

Legacy Webhook class.


Description Description


Source Source

File: includes/legacy/class-wc-legacy-webhook.php

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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
abstract class WC_Legacy_Webhook extends WC_Data {
 
    /**
     * Magic __isset method for backwards compatibility. Legacy properties which could be accessed directly in the past.
     *
     * @param  string $key Item to check.
     * @return bool
     */
    public function __isset( $key ) {
        $legacy_keys = array(
            'id',
            'status',
            'post_data',
            'delivery_url',
            'secret',
            'topic',
            'hooks',
            'resource',
            'event',
            'failure_count',
            'api_version',
        );
 
        if ( in_array( $key, $legacy_keys, true ) ) {
            return true;
        }
 
        return false;
    }
 
    /**
     * Magic __get method for backwards compatibility. Maps legacy vars to new getters.
     *
     * @param  string $key Item to get.
     * @return mixed
     */
    public function __get( $key ) {
        wc_doing_it_wrong( $key, 'Webhook properties should not be accessed directly.', '3.2' );
 
        switch ( $key ) {
            case 'id' :
                $value = $this->get_id();
                break;
            case 'status' :
                $value = $this->get_status();
                break;
            case 'post_data' :
                $value = null;
                break;
            case 'delivery_url' :
                $value = $this->get_delivery_url();
                break;
            case 'secret' :
                $value = $this->get_secret();
                break;
            case 'topic' :
                $value = $this->get_topic();
                break;
            case 'hooks' :
                $value = $this->get_hooks();
                break;
            case 'resource' :
                $value = $this->get_resource();
                break;
            case 'event' :
                $value = $this->get_event();
                break;
            case 'failure_count' :
                $value = $this->get_failure_count();
                break;
            case 'api_version' :
                $value = $this->get_api_version();
                break;
 
            default :
                $value = '';
                break;
        } // End switch().
 
        return $value;
    }
 
    /**
     * Get the post data for the webhook.
     *
     * @deprecated 3.2.0
     * @since      2.2
     * @return     null|WP_Post
     */
    public function get_post_data() {
        wc_deprecated_function( 'WC_Webhook::get_post_data', '3.2' );
 
        return null;
    }
 
    /**
     * Update the webhook status.
     *
     * @deprecated 3.2.0
     * @since      2.2.0
     * @param      string $status Status to set.
     */
    public function update_status( $status ) {
        wc_deprecated_function( 'WC_Webhook::update_status', '3.2', 'WC_Webhook::set_status' );
 
        $this->set_status( $status );
        $this->save();
    }
}


Top ↑

Methods Methods

  • __get — Magic __get method for backwards compatibility. Maps legacy vars to new getters.
  • __isset — Magic __isset method for backwards compatibility. Legacy properties which could be accessed directly in the past.
  • get_post_data — Get the post data for the webhook. — deprecated
  • update_status — Update the webhook status. — deprecated

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.