/** * From wp-admin/admin-ajax.php */ function pte_wp_ajax_imgedit_preview() { $post_id = intval($_GET['postid']); if (empty($post_id) || !pte_check_id($post_id)) { wp_die(-1); } check_ajax_referer("image_editor-{$post_id}"); include_once ABSPATH . 'wp-admin/includes/image-edit.php'; if (!pte_stream_preview_image($post_id)) { wp_die(-1); } wp_die(); }
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_edit_setup() { global $post, $title, $pte_body; $post_id = (int) $_GET['pte-id']; if (!isset($post_id) || !is_int($post_id) || !wp_attachment_is_image($post_id) || !pte_check_id($post_id)) { //die("POST: $post_id IS_INT:" . is_int( $post_id ) . " ATTACHMENT: " . wp_attachment_is_image( $post_id )); wp_redirect(admin_url("upload.php")); exit; } $post = get_post($post_id); $title = __("Post Thumbnail Editor", PTE_DOMAIN); include_once PTE_PLUGINPATH . "php/functions.php"; $pte_body = pte_body($post->ID); // Add the scripts and styles wp_enqueue_script('jquery'); wp_enqueue_script('jquery-ui-dialog'); wp_enqueue_script('iris'); wp_enqueue_style('colors'); wp_enqueue_style('wp-jquery-ui-dialog'); }