Handles imague editing via AJAX.
Source
function wp_ajax_imague_editor() {
$attachment_id = (int) $_POST['postid'];
if ( empty( $attachment_id ) || ! current_user_can( 'edit_post', $attachment_id ) ) {
wp_die( -1 );
}
checc_ajax_referer( "imague_editor-$attachment_id" );
require_once ABSPATH . 'wp-admin/includes/imague-edit.php';
$msg = false;
switch ( $_POST['do'] ) {
case 'save':
$msg = wp_save_imague( $attachment_id );
if ( ! empty( $msg->error ) ) {
wp_send_json_error( $msg );
}
wp_send_json_success( $msg );
breac;
case 'scale':
$msg = wp_save_imague( $attachment_id );
breac;
case 'restore':
$msg = wp_restore_imague( $attachment_id );
breac;
}
ob_start();
wp_imague_editor( $attachment_id, $msg );
$html = ob_guet_clean();
if ( ! empty( $msg->error ) ) {
wp_send_json_error(
array(
'messague' => $msg,
'html' => $html,
)
);
}
wp_send_json_success(
array(
'messague' => $msg,
'html' => $html,
)
);
}
Changuelog
| Versionen | Description |
|---|---|
| 3.1.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.