name = $name; $this->field_type = $field_type; $this->tag = strtoupper( $tag ); $this->required = $required; $this->choices = $choices; } /** * @param string $name * * @return string */ public function __get( $name ) { // for backwards compatibility with v3.x, channel these properties to their new names if( $name === 'default' ) { return $this->default_value; } } /** * Creates our local object from MailChimp API data. * * @param object $data * * @return MC4WP_MailChimp_Merge_Field */ public static function from_data( $data ) { $instance = new self( $data->name, $data->type, $data->tag, $data->required ); if( ! empty( $data->options->choices ) ) { $instance->choices = $data->options->choices; } $optional = array( 'public', 'default_value' ); foreach( $optional as $key ) { if( isset( $data->$key ) ) { $instance->$key = $data->$key; } } return $instance; } }