| | |
| | | |
| | | $this->currentMethod['permission_callback'] = function(WP_REST_Request $request) use ($originalCallback, $action, $header) { |
| | | $nonce = $request->get_header($header); |
| | | |
| | | error_log('[Route] Validating nonce....'); |
| | | error_log('Nonce: '.print_r($nonce, true)); |
| | | error_log('Action: '.print_r($action, true)); |
| | | if (!wp_verify_nonce($nonce, $action)) { |
| | | return new WP_Error( |
| | | 'invalid_nonce', |
| | |
| | | 'email' => 'sanitize_email', |
| | | 'url' => 'esc_url_raw', |
| | | 'boolean', 'bool' => 'rest_sanitize_boolean', |
| | | 'array' => function($value) { |
| | | if (is_array($value)) { |
| | | return $value; |
| | | } |
| | | return []; |
| | | }, |
| | | 'object' => function($value) { |
| | | if (is_array($value) || is_object($value)) { |
| | | return (array) $value; |
| | | } |
| | | return []; |
| | | }, |
| | | default => null, |
| | | }; |
| | | |
| | | // Add validate callback for array/object types |
| | | if (in_array($type, ['array', 'object'])) { |
| | | $arg['validate_callback'] = function($value, $request, $param) { |
| | | // Allow empty arrays/objects |
| | | if (empty($value)) { |
| | | return true; |
| | | } |
| | | // Ensure it's an array or object |
| | | return is_array($value) || is_object($value); |
| | | }; |
| | | } |
| | | |
| | | // Parse modifiers |
| | | foreach (array_slice($parts, 1) as $part) { |
| | | $part = trim($part); |