Data Validation in wordpress


In my theme, i am grabbing user input with get_option() and according to that input i want to i want to declare a new variable and print in my single.php file. For example:

$tutorial_condition = get_option( 'tutorials_creater' );

if ( $tutorial_condition == 1 ) {
    $second_col_class = 'col-9';
} else {
    $second_col_class = 'col-2';

now when i echo $second_col_class variable in my php files it works fine. But when i run themecheck plugin it shows an error like this.

"Possible data validation issues found. All dynamic data must be correctly escaped for the context where it is rendered."

i want to echo that variable like below.

 <div class="<?php echo $second_col_class; ?>">
     //my code here..

I cannot use isset() function because it just returning true or false. Is there any alternative to this?

sahan 3 months 0 Answers 12 views 0

Leave an answer