Plugin Directory

Changeset 2505651


Ignore:
Timestamp:
03/30/2021 04:50:23 AM (5 years ago)
Author:
integromat
Message:

Sending proper http status codes

Location:
integromat-connector/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • integromat-connector/trunk/class/RestRequest.php

    r2495726 r2505651  
    5656        }
    5757        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        }
    5961        die($responseJson);
    6062    }
     
    6668        $mediaFileSource = $udir['path'] . '/' . sanitize_file_name($_FILES['file']['name']);
    6769
    68         if ((int) $_FILES['file']['size'] === 0) {
     70        if ((int)$_FILES['file']['size'] === 0) {
    6971            RestResponse::renderError(500, 'The uploaded file exceeds the upload_max_filesize directive in php.ini.', 'rest_upload_unknown_error');
    7072        }
    7173
    72         if ((int) $_FILES['file']['error'] > 0) {
     74        if ((int)$_FILES['file']['error'] > 0) {
    7375            RestResponse::renderError(500, 'An error has occured when uploading file to the server.', 'rest_upload_unknown_error');
    7476        }
     
    8082        $caption = sanitize_text_field($_REQUEST['caption']);
    8183        $alt_text = sanitize_text_field($_REQUEST['alt_text']);
    82         $postId = (int) $_REQUEST['post'];
     84        $postId = (int)$_REQUEST['post'];
    8385
    8486        $uploadDir = wp_upload_dir();
     
    9799        }
    98100
    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',];
    106102        $attachmentId = wp_insert_attachment($attachment, $file);
    107103        if (!empty($alt_text)) {
     
    114110
    115111        // Relate to a post
    116         if (!empty($postId) && (int) $postId > 0) {
     112        if (!empty($postId) && (int)$postId > 0) {
    117113            set_post_thumbnail($postId, $attachmentId);
    118114        }
     
    121117        $post = get_post($attachmentId);
    122118        if (is_array($meta)) {
    123             $responseData = array_merge($meta, (array) $post);
     119            $responseData = array_merge($meta, (array)$post);
    124120        } else {
    125             $responseData = (array) $post;
     121            $responseData = (array)$post;
    126122        }
    127        
    128         self::sendResponse((object) [], wp_json_encode($responseData));
     123
     124        self::sendResponse((object)[], wp_json_encode($responseData));
    129125    }
    130126
  • integromat-connector/trunk/index.php

    r2495774 r2505651  
    33/**
    44 * @package Integromat_Connector
    5  * @version 1.1
     5 * @version 1.2
    66 */
    77
     
    1111Author: Integromat
    1212Author URI: https://www.integromat.com/
    13 Version: 1.1
     13Version: 1.2
    1414*/
    1515
  • integromat-connector/trunk/readme.txt

    r2495726 r2505651  
    33Tags: rest, api, rest api, integromat, endpoint, endpoints, meta, data, meta_data
    44Requires at least: 5.0
    5 Tested up to: 5.6.1
     5Tested up to: 5.7
    66Requires PHP: 5.6
    7 Stable tag: 1.1
     7Stable tag: 1.2
    88License: GPLv2 or later
    99
     
    2424== Changelog ==
    2525
     26= 1.2 =
     27* Sending proper http status codes
     28
    2629= 1.1 =
    2730* Fixed error message when uploading binary media item
Note: See TracChangeset for help on using the changeset viewer.