Changeset 2505651
- Timestamp:
- 03/30/2021 04:50:23 AM (5 years ago)
- Location:
- integromat-connector/trunk
- Files:
-
- 3 edited
-
class/RestRequest.php (modified) (6 diffs)
-
index.php (modified) (2 diffs)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
integromat-connector/trunk/class/RestRequest.php
r2495726 r2505651 56 56 } 57 57 header("Content-type: application/json"); 58 http_response_code($responseData->data->status); 58 if (is_object($responseData) && is_object($responseData->data) && (int) $responseData->data->status > 0) { 59 http_response_code($responseData->data->status); 60 } 59 61 die($responseJson); 60 62 } … … 66 68 $mediaFileSource = $udir['path'] . '/' . sanitize_file_name($_FILES['file']['name']); 67 69 68 if ((int) $_FILES['file']['size'] === 0) {70 if ((int)$_FILES['file']['size'] === 0) { 69 71 RestResponse::renderError(500, 'The uploaded file exceeds the upload_max_filesize directive in php.ini.', 'rest_upload_unknown_error'); 70 72 } 71 73 72 if ((int) $_FILES['file']['error'] > 0) {74 if ((int)$_FILES['file']['error'] > 0) { 73 75 RestResponse::renderError(500, 'An error has occured when uploading file to the server.', 'rest_upload_unknown_error'); 74 76 } … … 80 82 $caption = sanitize_text_field($_REQUEST['caption']); 81 83 $alt_text = sanitize_text_field($_REQUEST['alt_text']); 82 $postId = (int) $_REQUEST['post'];84 $postId = (int)$_REQUEST['post']; 83 85 84 86 $uploadDir = wp_upload_dir(); … … 97 99 } 98 100 99 $attachment = [ 100 'post_mime_type' => $wpFiletype['type'], 101 'post_title' => (!empty($title) ? $title : sanitize_file_name($filename)), 102 'post_content' => (!empty($description) ? $description : ''), 103 'post_excerpt' => (!empty($caption) ? $caption : ''), 104 'post_status' => 'inherit', 105 ]; 101 $attachment = ['post_mime_type' => $wpFiletype['type'], 'post_title' => (!empty($title) ? $title : sanitize_file_name($filename)), 'post_content' => (!empty($description) ? $description : ''), 'post_excerpt' => (!empty($caption) ? $caption : ''), 'post_status' => 'inherit',]; 106 102 $attachmentId = wp_insert_attachment($attachment, $file); 107 103 if (!empty($alt_text)) { … … 114 110 115 111 // Relate to a post 116 if (!empty($postId) && (int) $postId > 0) {112 if (!empty($postId) && (int)$postId > 0) { 117 113 set_post_thumbnail($postId, $attachmentId); 118 114 } … … 121 117 $post = get_post($attachmentId); 122 118 if (is_array($meta)) { 123 $responseData = array_merge($meta, (array) $post);119 $responseData = array_merge($meta, (array)$post); 124 120 } else { 125 $responseData = (array) $post;121 $responseData = (array)$post; 126 122 } 127 128 self::sendResponse((object) [], wp_json_encode($responseData));123 124 self::sendResponse((object)[], wp_json_encode($responseData)); 129 125 } 130 126 -
integromat-connector/trunk/index.php
r2495774 r2505651 3 3 /** 4 4 * @package Integromat_Connector 5 * @version 1. 15 * @version 1.2 6 6 */ 7 7 … … 11 11 Author: Integromat 12 12 Author URI: https://www.integromat.com/ 13 Version: 1. 113 Version: 1.2 14 14 */ 15 15 -
integromat-connector/trunk/readme.txt
r2495726 r2505651 3 3 Tags: rest, api, rest api, integromat, endpoint, endpoints, meta, data, meta_data 4 4 Requires at least: 5.0 5 Tested up to: 5. 6.15 Tested up to: 5.7 6 6 Requires PHP: 5.6 7 Stable tag: 1. 17 Stable tag: 1.2 8 8 License: GPLv2 or later 9 9 … … 24 24 == Changelog == 25 25 26 = 1.2 = 27 * Sending proper http status codes 28 26 29 = 1.1 = 27 30 * Fixed error message when uploading binary media item
Note: See TracChangeset
for help on using the changeset viewer.