Я создаю плагин для фильтраций тегов
вот упрощенный код
session_start();
if ($_POST['filter1']){
$_SESSION['filter1'] = $_POST['filter1'];
}
if ($_POST['filter2']){
$_SESSION['filter2'] = $_POST['filter2'];
}
add_shortcode ('wp-r_dop_filter_ise','A2');
function A2(){
$R1='
<form method="POST" >
<p>Option filter</p>
<p>Filter 1</p>
level 1: <input type="radio" name="filter1" value="1"' . ($_SESSION["filter1"] == 1 ? 'checked' : '') . '/>
level 2: <input type="radio" name="filter1" value="2"' . ($_SESSION["filter1"] == 2 ? 'checked' : '') . '/>
<p>Filter 2</p>
level 1: <input type="radio" name="filter2" value="1"' . ($_SESSION["filter2"] == 1 ? 'checked' : '') . '/>
level 2: <input type="radio" name="filter2" value="2"' . ($_SESSION["filter2"] == 2 ? 'checked' : '') . '/>
<p><input type="submit" value="User"></p>
</form>
';
return $R1;
}
function exc_post($filter, $file) {
if ($filter->is_category || ($filter->is_home || ($filter->is_feed) || ($filter->is_tag)))
{
$dir = plugin_dir_url( __FILE__ );
$content = file_get_contents( $dir . $file);
$terms = explode (",", $content);
$filter->set('tax_query', array(
array(
'taxonomy' => 'post_tag',
'field' => 'slug',
'terms' => $terms,
'operator' => 'NOT IN'
)
));
}
return $filter;
}
if ($_SESSION['filter1'] == '') {
$file = 'filter1/level_1.txt';
} else if ($_SESSION['filter1'] == 1) {
$file = 'filter1/level_1.txt';
} else if ($_SESSION['filter1'] == 2) {
$file = 'filter1/level_2.txt';
}
add_filter('pre_get_posts','exc_post', function($filter) use ($file) {
return exc_post($filter, $file);
});
if ($_SESSION['filter2'] == 1){
$file = 'filter2/level_1.txt';
} else if ($_SESSION['filter2'] == 2){
$file = 'filter2/level_1.txt';
} else if ($_SESSION['filter2'] == ''){
$file = 'filter2/level_2.txt';
}
add_filter('pre_get_posts','exc_post', function($filter) use ($file) {
return exc_post($filter, $file);
});
Но он вызывает ошибку
Warning: Illegal offset type in isset or empty in C:\xampp\htdocs\wor\wp-includes\class-wp-hook.php on line 75
Warning: Illegal offset type in C:\xampp\htdocs\wor\wp-includes\class-wp-hook.php on line 77
Warning: Illegal offset type in isset or empty in C:\xampp\htdocs\wor\wp-includes\class-wp-hook.php on line 75
Warning: Illegal offset type in C:\xampp\htdocs\wor\wp-includes\class-wp-hook.php on line 77
Иза чего это происходит и можно ли это как то исправить