lightspeeddevelopment /
lsx-health-plan
| 1 | <?php |
||||||
|
0 ignored issues
–
show
Coding Style
introduced
by
Loading history...
|
|||||||
| 2 | namespace lsx_health_plan\classes\frontend; |
||||||
| 3 | |||||||
| 4 | /** |
||||||
| 5 | * Holds the functionality to check and control your status with the current plan. |
||||||
| 6 | * |
||||||
| 7 | * @package lsx-health-plan |
||||||
| 8 | */ |
||||||
| 9 | class Plan_Status { |
||||||
| 10 | |||||||
| 11 | /** |
||||||
| 12 | * Holds class instance |
||||||
| 13 | * |
||||||
| 14 | * @since 1.0.0 |
||||||
| 15 | * |
||||||
| 16 | * @var object \lsx_health_plan\classes\frontend\Plan_Status() |
||||||
| 17 | */ |
||||||
| 18 | protected static $instance = null; |
||||||
| 19 | |||||||
| 20 | /** |
||||||
| 21 | * Constructor |
||||||
| 22 | */ |
||||||
| 23 | public function __construct() { |
||||||
|
0 ignored issues
–
show
|
|||||||
| 24 | add_action( 'init', array( $this, 'handle_day_action' ), 100 ); |
||||||
| 25 | } |
||||||
|
0 ignored issues
–
show
|
|||||||
| 26 | |||||||
| 27 | /** |
||||||
| 28 | * Return an instance of this class. |
||||||
| 29 | * |
||||||
| 30 | * @since 1.0.0 |
||||||
| 31 | * |
||||||
| 32 | * @return object \lsx_health_plan\classes\frontend\Plan_Status() A single instance of this class. |
||||||
| 33 | */ |
||||||
| 34 | public static function get_instance() { |
||||||
| 35 | // If the single instance hasn't been set, set it now. |
||||||
| 36 | if ( null === self::$instance ) { |
||||||
|
0 ignored issues
–
show
|
|||||||
| 37 | self::$instance = new self(); |
||||||
| 38 | } |
||||||
|
0 ignored issues
–
show
|
|||||||
| 39 | return self::$instance; |
||||||
| 40 | } |
||||||
|
0 ignored issues
–
show
|
|||||||
| 41 | |||||||
| 42 | /** |
||||||
| 43 | * Registers the rewrites. |
||||||
| 44 | */ |
||||||
| 45 | public function handle_day_action() { |
||||||
| 46 | if ( isset( $_POST['lsx-health-plan-actions'] ) && wp_verify_nonce( $_POST['lsx-health-plan-actions'], 'complete' ) ) { |
||||||
|
0 ignored issues
–
show
|
|||||||
| 47 | update_user_meta( get_current_user_id(), 'day_' . sanitize_key( $_POST['lsx-health-plan-id'] ) . '_complete', true ); |
||||||
|
0 ignored issues
–
show
|
|||||||
| 48 | $plan_id = sanitize_key( $_POST['lsx-health-plan-id'] ); |
||||||
|
0 ignored issues
–
show
|
|||||||
| 49 | $plan_parent = wp_get_post_parent_id( $plan_id ); |
||||||
|
0 ignored issues
–
show
$plan_id of type string is incompatible with the type WP_Post|integer|null expected by parameter $post of wp_get_post_parent_id().
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 50 | if ( 0 !== $plan_parent ) { |
||||||
|
0 ignored issues
–
show
|
|||||||
| 51 | $plan_id = $plan_parent; |
||||||
| 52 | } |
||||||
|
0 ignored issues
–
show
|
|||||||
| 53 | wp_safe_redirect( get_permalink( $plan_id ) ); |
||||||
|
0 ignored issues
–
show
It seems like
get_permalink($plan_id) can also be of type false; however, parameter $location of wp_safe_redirect() does only seem to accept string, maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
It seems like
$plan_id can also be of type false and string; however, parameter $post of get_permalink() does only seem to accept WP_Post|integer, maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 54 | } |
||||||
| 55 | |||||||
| 56 | if ( isset( $_POST['lsx-health-plan-actions'] ) && wp_verify_nonce( $_POST['lsx-health-plan-actions'], 'unlock' ) ) { |
||||||
|
0 ignored issues
–
show
|
|||||||
| 57 | delete_user_meta( get_current_user_id(), 'day_' . sanitize_key( $_POST['lsx-health-plan-id'] ) . '_complete' ); |
||||||
|
0 ignored issues
–
show
|
|||||||
| 58 | } |
||||||
| 59 | } |
||||||
|
0 ignored issues
–
show
|
|||||||
| 60 | } |
||||||
| 61 |