I have a simple WordPress plugin (let it be "my-plugin"). I made a WordPress page with url "plugin". In plugins/my-plugin I made a new PHP file page-plugin.php. So when I enter link www.domain.com/plugin, this file is being loaded (page-plugin.php). Evrything was working for a long time. But in past few days or weeks it doesn't work.
Problem is that when I enter www.domain.com/plugin?parameters=any-get-parameters, it redirects to www.domain.com/plugin. WordPress doesn't keep the GET parameters link. But this script works only with GET parameters.
Please help me. I tried many things, nothing helps me.
I tried init, ChatGPT help, Google search results help, I tried to turn of WordEfence, I tried to turn on/off plugin...
EDIT: I just tried to use this plugin in another WordPress website and it works with GET parameters. So not sure what to do. Even trying to change a WP Template doesn't help.
SOURCE:
<?php
/*
Plugin Name: TEST
Description: Adds a custom parameter to all links on the site, excluding specific URLs.
Version: 1.0
Author: TEST
*/
add_filter('query_vars', 'parameter_queryvars' );
function parameter_queryvars( $qvars )
{
$qvars[] = 'kl';
return $qvars;
}
function add_custom_parameter_script() {
?>
<script>
jQuery(document).ready(function ($) {
// Add your custom parameter to all links
var customParameter = 'custom_param=123';
$('a').each(function () {
var href = $(this).attr('href');
$(this).attr('href', href + (href.indexOf('?') !== -1 ? '&' : '?') + customParameter);
});
});
</script>
<?php
}
// init
add_action('init', 'add_custom_parameter_script');
// Shortcode to load custom script
function load_custom_script_shortcode() {
ob_start();
// Include the custom script content
include(plugin_dir_path(__FILE__) . 'page-test2.php');
return ob_get_clean();
}
add_shortcode('load_custom_script', 'load_custom_script_shortcode');
add_action('wp_footer', 'add_custom_parameter_script');
?>
IMPORTANT UPDATE: I found that when I turn off "All in One SEO" plugin. Evrything works. So at least I know who breaks it, but how to fix it?