Тема: Помилка Server responded with 500 code
Добрий день!
Є сайт https://rahmenfrei.live/ua/podelitsya/ на Wordpress. Розробник його толком не доробив. Кілька функцій не працює. Знайома просить розібратись з помилкою. При спробі вкласти файл видається помилка "Server responded with 500 code". Доступ до хостингу/коду є. Але я не спец в PHP. Не усе зрозуміло, а часу на пошуки не дуже є. Бажано сайт запустити
Це код з шаблона сторінки
[code=PHP]<?php
get_header(); ?>
    <main class="main upload">
        <div class="upload__wrap">
            <h1 class="upload__h"><?php echo __('Мы очень благодарны всем, кто хочет поделиться', 'rahmenfrei'); ?> </h1>
            <h5 class="upload__hel"><?php echo __('Расскажите о своем материале - и он обязательно будет рассмотрен', 'rahmenfrei'); ?></h5>
            <form class="form"  method="post" id="message_form" action="/wp-admin/admin-ajax.php">
                <?php wp_nonce_field('user_message_form', 'user_message_form_nonce'); ?>
                <input type="hidden" name="action" value="user_message_form">
                <div class="form__fldst form__fldst--h">
                    <label for="name" class="form__l"><?php echo __('Меня зовут (подпись автора)', 'rahmenfrei'); ?></label>
                    <span class="name-c">
                        <input class="form__i" name="name" id="name" type="text">
                    </span>
                </div>
                <div class="form__fldst form__fldst--h">
                    <label for="email" class="form__l"><?php echo __('Мой контактный e-mail', 'rahmenfrei'); ?></label>
                    <span class="email-c">
                        <input class="form__i" type="email" name="email" id="email">
                    </span>
                </div>
                <div class="form__fldst">
                    <label for="subject" class="form__l"><?php echo __('Заголовок', 'rahmenfrei'); ?></label>
                    <span class="textarea-c">
                        <input class="form__i" name="subject" id="subject" type="text">
                    </span>
                </div>
                <div class="my-dz"></div>
                <div class="form__fldst form__fldst--btn"><button class="btn" type="submit"><?php echo __('Поделиться', 'rahmenfrei'); ?></button></div>
                <div class="form-d">
                    <img class="dz-message needsclick" src="<?php echo get_template_directory_uri(); ?>/assets/img/upload.svg" alt="dropzone">
                    <div class="dz-message needsclick"><?php echo __('Перетащите сюда файл или <span>откройте с компьютера</span>', 'rahmenfrei'); ?>
                    </div>
                </div>
            </form>
        </div>
    </main>
<style>
    #ifile{
        display:none;
    }
</style>
<?php
get_footer();[/code]
Це код з upload.php. Підключний в function.php теми
[code=PHP]<?php
add_action('init', 'register_upload_post_type');
function register_upload_post_type()
{
    register_post_type('user_message', array(
        'label' => null,
        'labels' => array(
            'name' => 'Сообщение',
            'singular_name' => 'Сообщение',
            'add_new' => 'Добавить Сообщение',
            'add_new_item' => 'Добавление Сообщение',
            'edit_item' => 'Редактирование Сообщение',
            'new_item' => 'Новое Сообщение',
            'view_item' => 'Смотреть Сообщение',
            'search_items' => 'Искать Сообщение',
            'not_found' => 'Не найдено',
            'not_found_in_trash' => 'Не найдено в корзине',
            'parent_item_colon' => '',
            'menu_name' => 'Сообщения',
        ),
        'public' => true,
        'publicly_queryable' => true,
        'show_ui' => true,
        'show_in_menu' => true,
        'menu_icon' => 'dashicons-id-alt',
        'query_var' => true,
        'capability_type' => 'post',
        'has_archive' => false,
        'hierarchical' => false,
        'menu_position' => 10,
        'supports' => array('title'),
    ));
}
add_action('wp_ajax_nopriv_user_message_file_upload', 'user_message_file_upload');
add_action('wp_ajax_user_message_file_upload', 'user_message_file_upload');
function user_message_file_upload()
{
    $status = 0;
    $message = '';
    $allowed_myme_types = [
        'application/msword',
        'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
        'application/vnd.ms-excel',
        'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
        'image/gif',
        'image/jpeg',
        'image/png',
        'application/pdf',
        'text/plain'
    ];
    if (!empty($_FILES)) {
        $files = $_FILES;
        foreach ($files as $file) {
            $newfile = array(
                'name' => $file['name'],
                'type' => $file['type'],
                'tmp_name' => $file['tmp_name'],
                'error' => $file['error'],
                'size' => $file['size']
            );
            $mime_type = mime_content_type($file['tmp_name']);
            if (!in_array($mime_type, $allowed_myme_types)) {
                $message = __('type not allowed', 'rahmenfrei');
            } else {
                $_FILES = array('upload' => $newfile);
                foreach ($_FILES as $file => $array) {
                    $id = media_handle_upload($file, 0);
                    if ($id) {
                        $status = 1;
                        $message = $id;
                    }
                }
            }
        }
    }
    wp_send_json(['status' => $status, 'message' => $message]);
}
add_action('wp_ajax_nopriv_user_message_file_delete', 'user_message_file_delete');
add_action('wp_ajax_user_message_file_delete', 'user_message_file_delete');
function user_message_file_delete()
{
    $responce = ['status' => 'FAILED'];
    if (isset($_REQUEST['media_id'])) {
        $post_id = absint($_REQUEST['media_id']);
        $status = wp_delete_attachment($post_id, true);
        if ($status) {
            $responce['status'] = 'DELETED';
        }
    }
    wp_send_json($responce);
}
add_action('wp_ajax_nopriv_user_message_form', 'user_message_form');
add_action('wp_ajax_user_message_form', 'user_message_form');
function user_message_form()
{
    if ( empty($_POST) || !wp_verify_nonce($_POST['user_message_form_nonce'],'user_message_form') )
    {
        die('invalid nonce field');
    }
    $s = false;
    $errors = array();
    $message = '';
    $data = rahmenfrei_sanitize_data($_POST);
    if (empty($data['name'])) {
        $errors['name'] = __('Ім\'я не може бути пустим', 'rahmenfrei');
    } else if (mb_strlen($data['name']) > 100) {
        $errors['name'] = __('Name can not be longest then 100 symbols', 'rahmenfrei');
    }
    if (empty($data['email'])) {
        $errors['email'] = __('Емейл не може бути пустим', 'rahmenfrei');
    } else if (!preg_match('/^\S+@\S+\.\S+$/isD', $data['email'])) {
        $errors['email'] = __('Incorrect email', 'rahmenfrei');
    }
    if (empty($data['subject'])) {
        $errors['subject'] = __('Заголовок не може бути пустим', 'rahmenfrei');
    }
//    if (!empty($data['name']) && !preg_match('/^[\'\p{L}.\-\s]+$/i', str_replace("\'", "'", $data['name']))) {
//        $errors['name'] = __('You have invalid symbols in this field', 'rahmenfrei');
//    }
    if (empty($errors)) {
        $id = wp_insert_post(array(
            'post_title' => date('d.m.Y H:i:s') . ' ' . $data['name'] . ' (' . $data['email'] . ')',
            'post_type' => 'user_message',
            'post_status' => 'publish'
        ));
        if ($id > 0) {
            $unreaded_messages = get_option('unreaded_messages', 0);
            update_option('unreaded_messages', $unreaded_messages + 1);
            update_post_meta($id, 'message_name', $data['name']);
            update_post_meta($id, 'message_email', $data['email']);
            update_post_meta($id, 'message_subject', $data['subject']);
            if (!empty($data['file'])) {
                foreach ($data['file'] as $file) {
                    add_post_meta($id, 'message_attachment', $file);
                }
            }
            $from_name = get_option('blogname');
            $from_email = 'no-reply@rahmenfrei.com';
            $mail_headers = "From: " . $from_name . " <" . $from_email . ">" . "\r\n";
            $mail_headers .= "MIME-Version: 1.0\r\n";
            $mail_headers .= "Content-Type: text/html; charset=utf-8\r\n";
//            $mail_headers .= "Content-type: text/html; charset=iso-8859-1" . "\r\n";
            $mail_headers .= "Reply-To: {$from_email}" . "\r\n" . $mail_headers .= "X-Mailer: PHP/" . phpversion();
            $mail_body = "<p><strong>" . __('Name:', 'rahmenfrei'). " </strong>{$data['name']}</p>";
            $mail_body .= "<p><strong>" . __('E-mail:', 'rahmenfrei'). " </strong>{$data['email']}</p>";
            $mail_body .= "<p><strong>" . __('Subject:', 'rahmenfrei'). " </strong>{$data['subject']}</p>";
            if (!empty($data['files'])) {
                $mail_body .= "<h2>" . __('Attachments', 'rahmenfrei') . "</h2>";
                foreach ($data['file'] as $file) {
                    $mail_body .= "<p><a href='" . wp_get_attachment_url($file)  ."' download>" . wp_get_attachment_url($file) . "</a></p>";
                }
            }
            wp_mail(get_option('admin_email'), 'New Message', $mail_body, $mail_headers);
            $s = true;
            $message =  __("Your message was send. We'll be in touch with you soon", 'rahmenfrei') ;
        }
    }
    $response = json_encode(array(
        'status' => $s,
        'errors' => $errors,
        'message' => $message
    ));
    die($response);
}
if (!function_exists('rahmenfrei_sanitize_data')) {
    function rahmenfrei_sanitize_data($data_to_sanitize)
    {
        if (!$data_to_sanitize) {
            return null;
        }
        $sanitized_data = [];
        foreach ($data_to_sanitize as $k => $v) {
            if (is_array($v)) {
                $sanitized_data[$k] = rahmenfrei_sanitize_data($v);
            } else {
                $sanitized_data[$k] = trim(strip_tags($v));
            }
        }
        return $sanitized_data;
    }
}
add_action('add_meta_boxes', 'user_message_metabox');
function user_message_metabox()
{
    add_meta_box(
        'message_metabox_id',           // Unique ID
        'Данные сообщения',  // Box title
        'message_metabox_html',
        'user_message'
    );
    add_meta_box(
        'attachment_metabox_id',           // Unique ID
        'Файлы',  // Box title
        'attachment_metabox_html',
        'user_message'
    );
}
function message_metabox_html($post)
{
    ?>
    <p>
        <label for="user_name"
               style="width:150px; display:inline-block;"> <?php echo esc_html__('User name', 'text-domain') ?></label>
        <input type="text" name="order_meta[user_name]" id="user_name" class="title_field"
               value="<?php echo get_post_meta($post->ID, 'message_name', true); ?>"
               style="width:300px;"/>
    </p>
    <p>
        <label for="user_name"
               style="width:150px; display:inline-block;"> <?php echo esc_html__('User email', 'text-domain') ?></label>
        <input type="text" name="order_meta[user_name]" id="user_name" class="title_field"
               value="<?php echo get_post_meta($post->ID, 'message_email', true); ?>"
               style="width:300px;"/>
    </p>
    <p>
        <label for="user_name"
               style="width:150px; display:inline-block;"> <?php echo esc_html__('subject', 'text-domain') ?></label>
        <input type="text" name="order_meta[user_name]" id="user_name" class="title_field"
               value="<?php echo get_post_meta($post->ID, 'message_subject', true); ?>"
               style="width:300px;"/>
    </p>
    <?php
}
function attachment_metabox_html($post)
{
$attachments = get_post_meta($post->ID, 'message_attachment');
?>
<?php if (!empty($attachments)): ?>
    <ul>
        <?php foreach ($attachments as $attachment): ?>
            <li> <a href="<?php echo wp_get_attachment_url($attachment); ?>" download><?php echo wp_get_attachment_url($attachment); ?></a></li>
        <?php endforeach; ?>
    </ul>
<?php endif; ?>
<?php
}
add_action('admin_init', 'cancel_unreaded_messages');
function cancel_unreaded_messages()
{
    // Global object containing current admin page
    global $pagenow;
    if ($pagenow === 'edit.php' && isset($_GET['post_type']) && $_GET['post_type'] == 'user_message') {
        update_option('unreaded_messages', 0);
    }
}
function unreaded_messages_menu_bubble()
{
    global $menu;
    $count = get_option("unreaded_messages", 0);
    if ($count) {
        foreach ($menu as $k => $v) {
            if ($v[0] == 'Сообщения') {
                $menu[$k][0] .= ' <span class="update-plugins"><span class="application_menu_counter">' . $count . '</span></span>';
                return;
            }
        }
    }
}
add_action('admin_menu', 'unreaded_messages_menu_bubble');
[/code]
Був би дуже вдячний за допомогу. Підштовхніть куди рити? Науковим медотом закоментарення рядків так і толком не прийшов до якогось результату. Що можу давати цю помилку?