ajax-handler.php ➔ give_set_notification_status_handler()   A
last analyzed

Complexity

Conditions 4
Paths 4

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
nc 4
nop 0
dl 0
loc 8
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * This file contain code to handle email notification setting ajax.
4
 *
5
 * Register settings Include and setup custom metaboxes and fields.
6
 *
7
 * @package    Give
8
 * @subpackage Classes/Emails
9
 * @license    https://opensource.org/licenses/gpl-license GNU Public License
10
 * @link       https://github.com/webdevstudios/Custom-Metaboxes-and-Fields-for-WordPress
11
 */
12
13
/**
14
 * Enabled & disable notification
15
 *
16
 * @since 2.0
17
 */
18
function give_set_notification_status_handler() {
19
	$notification_id = isset( $_POST['notification_id'] ) ? give_clean( $_POST['notification_id'] ) : '';
0 ignored issues
show
introduced by
Detected access of super global var $_POST, probably need manual inspection.
Loading history...
introduced by
Detected usage of a non-sanitized input variable: $_POST
Loading history...
20
	if ( ! empty( $notification_id ) && give_update_option( "{$notification_id}_notification", give_clean( $_POST['status'] ) ) ) {
0 ignored issues
show
Bug introduced by
It seems like give_clean($_POST['status']) targeting give_clean() can also be of type array; however, give_update_option() does only seem to accept string|boolean|integer, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
introduced by
Detected access of super global var $_POST, probably need manual inspection.
Loading history...
introduced by
Detected usage of a non-validated input variable: $_POST
Loading history...
introduced by
Detected usage of a non-sanitized input variable: $_POST
Loading history...
21
		wp_send_json_success();
22
	}
23
24
	wp_send_json_error();
25
}
26
27
add_action( 'wp_ajax_give_set_notification_status', 'give_set_notification_status_handler' );
28