Rename a 'method' field in a form widget so it doesn't break the WP interactive customizer [MAILPOET-851]

This commit is contained in:
Alexey Stoletniy
2017-04-05 18:35:13 +03:00
parent 53afbea6ec
commit 9d358f74dd
2 changed files with 8 additions and 3 deletions

View File

@ -64,9 +64,13 @@ class API {
$this->_endpoint = isset($data['endpoint'])
? Helpers::underscoreToCamelCase(trim($data['endpoint']))
: null;
$this->_method = isset($data['method'])
? Helpers::underscoreToCamelCase(trim($data['method']))
// JS part of /wp-admin/customize.php does not like a 'method' field in a form widget
$method_param_name = isset($data['mailpoet_method']) ? 'mailpoet_method' : 'method';
$this->_method = isset($data[$method_param_name])
? Helpers::underscoreToCamelCase(trim($data[$method_param_name]))
: null;
$this->_token = isset($data['token'])
? trim($data['token'])
: null;
@ -100,6 +104,7 @@ class API {
'token',
'endpoint',
'method',
'mailpoet_method', // alias of 'method'
'mailpoet_redirect'
);
$this->_data = array_diff_key(