AnsPress_Uploader::upload_modal()
Description #
Ajax callback for image upload form.
Source #
File: includes/upload.php
public static function upload_modal() {
// Check nonce.
if ( ! anspress_verify_nonce( 'ap_upload_image' ) ) {
ap_ajax_json( 'something_wrong' );
}
// Check if user have permission to upload tem image.
if ( ! ap_user_can_upload() ) {
ap_send_json(
array(
'success' => false,
'snackbar' => array(
'message' => __( 'Sorry! you do not have permission to upload image.', 'anspress-question-answer' ),
),
)
);
}
$image_for = ap_sanitize_unslash( 'image_for', 'r' );
ob_start();
anspress()->get_form( 'image_upload' )->generate(
array(
'hidden_fields' => array(
array(
'name' => 'action',
'value' => 'ap_image_upload',
),
array(
'name' => 'image_for',
'value' => $image_for,
),
),
)
);
$html = ob_get_clean();
ap_send_json(
array(
'success' => true,
'action' => 'ap_upload_modal',
'html' => $html,
'title' => __( 'Select media file to upload', 'anspress-question-answer' ),
)
);
}
Expand full source code Collapse full source code View on GitHub: includes/upload.php:138
Add your comment