function pte_delete_images() { // Require JSON output pte_require_json(); $id = (int) $_GET['id']; if (pte_check_id($id) === false) { return pte_json_error("ID invalid: {$id}"); } // Check nonce if (!check_ajax_referer("pte-delete-{$id}", 'pte-nonce', false)) { return pte_json_error("CSRF Check failed"); } $uploads = wp_upload_dir(); $PTE_TMP_DIR = $uploads['basedir'] . DIRECTORY_SEPARATOR . "ptetmp" . DIRECTORY_SEPARATOR . $id; // Delete tmpdir pte_rmdir($PTE_TMP_DIR); return pte_json_encode(array("success" => "Yay!")); }
function pte_delete_images() { // Require JSON output pte_require_json(); $id = (int) $_GET['id']; if (pte_check_id($id) === false) { return pte_json_error("ID invalid: {$id}"); } // Check nonce if (!check_ajax_referer("pte-delete-{$id}", 'pte-nonce', false)) { return pte_json_error("CSRF Check failed"); } // SETS PTE_TMP_DIR and PTE_TMP_URL extract(pte_tmp_dir()); $PTE_TMP_DIR = $PTE_TMP_DIR . $id . DIRECTORY_SEPARATOR; // Delete tmpdir PteLogger::debug("Deleting [{$PTE_TMP_DIR}]"); pte_rmdir($PTE_TMP_DIR); return pte_json_encode(array("success" => "Yay!")); }
function pte_update_user_options() { require_once PTE_PLUGINPATH . 'php/options.php'; $options = pte_get_user_options(); // Check nonce if (!check_ajax_referer("pte-options", 'pte-nonce', false)) { return pte_json_error("CSRF Check failed"); } if (isset($_REQUEST['pte_crop_save'])) { if (strtolower($_REQUEST['pte_crop_save']) === "true") { $options['pte_crop_save'] = true; } else { $options['pte_crop_save'] = false; } } if (isset($_REQUEST['pte_thumbnail_bar'])) { if (strtolower($_REQUEST['pte_thumbnail_bar']) == 'vertical') { $options['pte_thumbnail_bar'] = 'vertical'; } else { $options['pte_thumbnail_bar'] = 'horizontal'; } } update_option(pte_get_option_name(), $options); }