| 1 |
<?php |
| 2 |
if ( ! defined( 'ABSPATH' ) ) { |
| 3 |
exit; // Exit if accessed directly |
| 4 |
} |
| 5 |
global $current_user,$wppmfunction,$wpdb; |
| 6 |
$id = isset($_POST['id']) ? intval(sanitize_text_field(wp_unslash($_POST['id']))) : '0'; |
| 7 |
$project = $wpdb->get_row( "SELECT * FROM {$wpdb->prefix}wppm_project where id = '".esc_sql($id)."'"); |
| 8 |
$wppm_current_user_capability = get_user_meta( $current_user->ID, 'wppm_capability', true ); |
| 9 |
if (!(($current_user->ID && $current_user->has_cap('manage_options')) || $wppmfunction->has_project_permission('delete_project',$id) || ($project->created_by==$current_user->ID && $wppm_current_user_capability == 'wppm_manager') || ($current_user->ID && $current_user->has_cap('wppm_admin')))) {exit;} |
| 10 |
ob_start(); |
| 11 |
?> |
| 12 |
<form id="frm_delete_project" method="post"> |
| 13 |
<div class="form-group"> |
| 14 |
<p><?php echo esc_html_e('Are you sure to delete this project?','taskbuilder');?></p> |
| 15 |
</div> |
| 16 |
<input type="hidden" name="action" value="wppm_set_delete_project" /> |
| 17 |
<input type="hidden" name="_ajax_nonce" value="<?php echo esc_attr( wp_create_nonce( 'wppm_set_delete_project' ) ); ?>"> |
| 18 |
<input type="hidden" name="project_id" value="<?php echo (esc_attr($id))?>" /> |
| 19 |
</form> |
| 20 |
<?php |
| 21 |
$body = ob_get_clean(); |
| 22 |
ob_start(); |
| 23 |
?> |
| 24 |
<button type="button" class="btn wppm_popup_close" onclick="wppm_modal_close();"><?php echo esc_html_e('Cancel','taskbuilder');?></button> |
| 25 |
<button type="button" class="btn wppm_popup_action" type="submit" onclick="wppm_set_delete_project();"><?php echo esc_html_e('Confirm','taskbuilder');?></button> |
| 26 |
<?php |
| 27 |
$footer = ob_get_clean(); |
| 28 |
$response = array( |
| 29 |
'body' => $body, |
| 30 |
'footer' => $footer |
| 31 |
); |
| 32 |
echo wp_json_encode($response); |
| 33 |
|