MOON
Server: Apache
System: Linux server.royaltuning.hu 4.18.0-425.13.1.el8_7.x86_64 #1 SMP Tue Feb 21 04:20:52 EST 2023 x86_64
User: royaltuning (1001)
PHP: 8.2.30
Disabled: exec,passthru,shell_exec,system
Upload Files
File: /home/royaltuning/www/public/wp-content/plugins/izzo-kereso/includes/class-abfinder-rewrite.php
<?php
if (!defined('ABSPATH')) exit;

class ABFinder_Rewrite {

	public function register() {
		add_action('init', [$this, 'add_rules']);
		add_filter('query_vars', [$this, 'query_vars']);
		add_filter('template_include', [$this, 'template']);
	}

	public function add_rules() {

		// /izzo-kereso/
		add_rewrite_rule(
			'^izzo-kereso/?$',
			'index.php?abfinder=1',
			'top'
		);

		// /izzo-kereso/make/
		add_rewrite_rule(
			'^izzo-kereso/([^/]+)/?$',
			'index.php?abfinder=1&ab_make=$matches[1]',
			'top'
		);

		// /izzo-kereso/make/model/
		add_rewrite_rule(
			'^izzo-kereso/([^/]+)/([^/]+)/?$',
			'index.php?abfinder=1&ab_make=$matches[1]&ab_model=$matches[2]',
			'top'
		);

		// /izzo-kereso/make/model/year/
		add_rewrite_rule(
			'^izzo-kereso/([^/]+)/([^/]+)/([0-9]{4})/?$',
			'index.php?abfinder=1&ab_make=$matches[1]&ab_model=$matches[2]&ab_year=$matches[3]',
			'top'
		);

		// /izzo-kereso/make/model/year/variant/
		add_rewrite_rule(
			'^izzo-kereso/([^/]+)/([^/]+)/([0-9]{4})/([^/]+)/?$',
			'index.php?abfinder=1&ab_make=$matches[1]&ab_model=$matches[2]&ab_year=$matches[3]&ab_variant=$matches[4]',
			'top'
		);
	}

	public function query_vars($vars) {
		$vars[] = 'abfinder';
		$vars[] = 'ab_make';
		$vars[] = 'ab_model';
		$vars[] = 'ab_year';
		$vars[] = 'ab_variant';
		return $vars;
	}

	public function template($template) {
		if (intval(get_query_var('abfinder')) === 1) {
			return ABFINDER_PATH . 'templates/page-abfinder.php';
		}
		return $template;
	}
}