예제 #1
0
     } else {
         $updated = true;
         $message = __('Main image changed.', 'idp-theme');
     }
 } else {
     if (isset($_POST['delete_image_nonce']) && wp_verify_nonce($_POST['delete_image_nonce'], 'delete_image')) {
         $result = Idp_Main::deleteBuildingImage($_POST['building_id'], $_POST['image_id'], $user_id);
         if ($result === false) {
             $error = true;
         } else {
             $updated = true;
             $message = __('Image deleted.', 'idp-theme');
         }
     } else {
         if (isset($_POST['image_category_nonce']) && wp_verify_nonce($_POST['image_category_nonce'], 'image_category')) {
             Idp_Main::setImageCategory($_POST['building_id'], $_POST['image_id'], $_POST['image_category'], $user_id);
         } else {
             if (isset($_POST['crop_nonce']) && wp_verify_nonce($_POST['crop_nonce'], 'crop')) {
                 if (!empty($_POST['cropPoints']) && !empty($_POST['cropImage'])) {
                     $crop_points = array_map('intval', explode(',', $_POST['cropPoints']));
                     $crop_image_path = str_replace("http://haeuserbuch.de/", "", $_POST['cropImage']);
                     $result = idp_crop_image($crop_points, $crop_image_path);
                     if ($result === true) {
                         $updated = true;
                         $message = __('Image cropped. You maybe need to clear your browsers cache or at least reload the page to see the result.', 'idp-theme');
                     } else {
                         $error = true;
                         $message = $result;
                     }
                 } else {
                     $error = true;
예제 #2
0
function saveImageCategory()
{
    $result = false;
    if (isset($_POST['image_category_nonce']) && wp_verify_nonce($_POST['image_category_nonce'], 'image_category')) {
        $image_id = $_POST['image_id'];
        $building_id = $_POST['building_id'];
        $user_id = $_POST['user_id'];
        $image_category = $_POST['image_category'];
        $result = Idp_Main::setImageCategory($building_id, $image_id, $image_category, $user_id);
    }
    if ($result !== false) {
        echo "<span class=\"glyphicon glyphicon-ok\" aria-hidden=\"true\" title=\"Kategorie gespeichert\"></span>";
    } else {
        echo "<span class=\"glyphicon glyphicon-remove-sign\" aria-hidden=\"true\" title=\"Fehler\"></span>";
    }
    wp_die();
    // this is required to terminate immediately and return a proper response
}