@@ -43,27 +43,27 @@ public function delete_comment() {
4343 }
4444
4545 function delete_answer () {
46- if ( ! isset ( $ _GET ['_wpnonce ' ] ) || ! wp_verify_nonce ( $ _GET ['_wpnonce ' ], '_dwqa_action_remove_answer_nonce ' ) || 'dwqa_delete_answer ' !== $ _GET ['action ' ] ) {
46+ if ( ! isset ( $ _GET ['_wpnonce ' ] ) || ! wp_verify_nonce ( $ _GET ['_wpnonce ' ], '_dwqa_action_remove_answer_nonce ' ) || 'dwqa_delete_answer ' !== sanitize_text_field ( $ _GET ['action ' ] ) ) {
4747 wp_die ( __ ( 'Are you cheating huh? ' , 'dwqa ' ) );
4848 }
4949
5050 if ( ! isset ( $ _GET ['answer_id ' ] ) ) {
5151 wp_die ( __ ( 'Answer is missing. ' , 'dwqa ' ), 'error ' );
5252 }
5353
54- if ( 'dwqa-answer ' !== get_post_type ( $ _GET ['answer_id ' ] ) ) {
54+ if ( 'dwqa-answer ' !== get_post_type ( intval ( $ _GET ['answer_id ' ] ) ) ) {
5555 wp_die ( __ ( 'This post is not answer. ' , 'dwqa ' ) );
5656 }
5757
5858 if ( !dwqa_current_user_can ( 'delete_answer ' ) ) {
5959 wp_die ( __ ( 'You do not have permission to delete this post. ' , 'dwqa ' ) );
6060 }
6161
62- do_action ( 'dwqa_prepare_delete_answer ' , $ _GET ['answer_id ' ] );
62+ do_action ( 'dwqa_prepare_delete_answer ' , intval ( $ _GET ['answer_id ' ] ) );
6363
64- $ question_id = get_post_meta ( $ _GET ['answer_id ' ], '_question ' , true );
64+ $ question_id = get_post_meta ( intval ( $ _GET ['answer_id ' ] ) , '_question ' , true );
6565
66- $ id = wp_delete_post ( $ _GET ['answer_id ' ] );
66+ $ id = wp_delete_post ( intval ( $ _GET ['answer_id ' ] ) );
6767
6868 if ( is_wp_error ( $ id ) ) {
6969 wp_die ( $ id ->get_error_message () );
@@ -72,7 +72,7 @@ function delete_answer() {
7272 $ answer_count = get_post_meta ( $ question_id , '_dwqa_answers_count ' , true );
7373 update_post_meta ( $ question_id , '_dwqa_answers_count ' , (int ) $ answer_count - 1 );
7474
75- do_action ( 'dwqa_delete_answer ' , $ _GET ['answer_id ' ], $ question_id );
75+ do_action ( 'dwqa_delete_answer ' , intval ( $ _GET ['answer_id ' ] ) , $ question_id );
7676
7777 wp_redirect ( get_permalink ( $ question_id ) );
7878 exit ();
@@ -146,31 +146,31 @@ public function unvote_best_answer() {
146146
147147 public function delete_question () {
148148 global $ dwqa_general_settings ;
149- if ( ! isset ( $ _GET ['_wpnonce ' ] ) || ! wp_verify_nonce ( $ _GET ['_wpnonce ' ], '_dwqa_action_remove_question_nonce ' ) || 'dwqa_delete_question ' !== $ _GET ['action ' ] ) {
149+ if ( ! isset ( $ _GET ['_wpnonce ' ] ) || ! wp_verify_nonce ( sanitize_text_field ( $ _GET ['_wpnonce ' ] ) , '_dwqa_action_remove_question_nonce ' ) || 'dwqa_delete_question ' !== $ _GET ['action ' ] ) {
150150 wp_die ( __ ( 'Are you cheating huh? ' , 'dwqa ' ) );
151151 }
152152
153153 if ( ! isset ( $ _GET ['question_id ' ] ) ) {
154154 wp_die ( __ ( 'Question is missing. ' , 'dwqa ' ), 'error ' );
155155 }
156156
157- if ( 'dwqa-question ' !== get_post_type ( $ _GET ['question_id ' ] ) ) {
157+ if ( 'dwqa-question ' !== get_post_type ( intval ( $ _GET ['question_id ' ] ) ) ) {
158158 wp_die ( __ ( 'This post is not question. ' , 'dwqa ' ) );
159159 }
160160
161161 if ( !dwqa_current_user_can ( 'delete_answer ' ) ) {
162162 wp_die ( __ ( 'You do not have permission to delete this post. ' , 'dwqa ' ) );
163163 }
164164
165- do_action ( 'before_delete_post ' , $ _GET ['question_id ' ] );
165+ do_action ( 'before_delete_post ' , intval ( $ _GET ['question_id ' ] ) );
166166
167- $ id = wp_delete_post ( $ _GET ['question_id ' ] );
167+ $ id = wp_delete_post ( intval ( $ _GET ['question_id ' ] ) );
168168
169169 if ( is_wp_error ( $ id ) ) {
170170 wp_die ( $ id ->get_error_message () );
171171 }
172172
173- do_action ( 'dwqa_delete_question ' , $ _GET ['question_id ' ] );
173+ do_action ( 'dwqa_delete_question ' , intval ( $ _GET ['question_id ' ] ) );
174174
175175 $ url = home_url ();
176176 if ( isset ( $ dwqa_general_settings ['pages ' ]['archive-question ' ] ) ) {
0 commit comments