-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathyachtino-boat-listing.php
147 lines (128 loc) · 4.92 KB
/
yachtino-boat-listing.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
<?php
/**
* Plugin Name: Yachtino boat listing
* Plugin URI: https://update.yachtino.com/wordpress-plugin
* Description: Display your boats and yachts for sale from yachtall.com or yacht charter offers from happycharter.com in your own website.
* Version: 1.5.1
* Requires at least: 6.0
* Rquires PHP: 8.0
* Author: Yachtino GmbH
* Author URI: https://www.yachtino.com
* License: GPL-2.0+
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
* Text Domain: yachtino-boat-listing
* Domain Path: /languages
*/
// If this file is called directly, abort.
if (!defined('WPINC')) {
die;
}
/**
* Current plugin version.
*/
define('YACHTINO_VERSION', '1.5.1');
define('YACHTINO_MIN_PHP_VERSION', '8.0');
define('YACHTINO_MIN_WP_VERSION', '6.0');
define('YACHTINO_DIR_PATH', __DIR__); // NO trailing slash
// Because WP automatically adds </p> to every line ending, remove that function completely on yachtino pages.
add_filter('the_content', 'yachtino_remove_autop', 0);
function yachtino_remove_autop($content)
{
'yachtino_page' === get_post_type() && remove_filter('the_content', 'wpautop');
return $content;
}
function yachtino_define_uri()
{
if (defined('YACHTINO_REQUEST_URI')) {
return;
}
// global $wp; - $wp is set too late, we need the server variable earlier
// // $requestUri = home_url($wp->request);
// $requestUri = add_query_arg($wp->query_vars, home_url($wp->request));
$requestUri = filter_input(INPUT_SERVER, 'REQUEST_URI');
if (!$requestUri && !empty($_SERVER['REQUEST_URI'])) {
$requestUri = $_SERVER['REQUEST_URI'];
}
if (!$requestUri) {
if (!empty($_SERVER['HTTP_X_ORIGINAL_URL'])) {
// IIS Mod-Rewrite.
$requestUri = $_SERVER['HTTP_X_ORIGINAL_URL'];
} elseif (!empty($_SERVER['HTTP_X_REWRITE_URL'])) {
// IIS Isapi_Rewrite.
$requestUri = $_SERVER['HTTP_X_REWRITE_URL'];
} else {
// Use ORIG_PATH_INFO if there is no PATH_INFO.
if (!isset($_SERVER['PATH_INFO']) && isset($_SERVER['ORIG_PATH_INFO'])) {
$_SERVER['PATH_INFO'] = $_SERVER['ORIG_PATH_INFO'];
}
// Some IIS + PHP configurations put the script-name in the path-info (no need to append it twice).
if (isset($_SERVER['PATH_INFO'])) {
if ($_SERVER['PATH_INFO'] == $_SERVER['SCRIPT_NAME']) {
$requestUri = $_SERVER['PATH_INFO'];
} else {
$requestUri = $_SERVER['SCRIPT_NAME'] . $_SERVER['PATH_INFO'];
}
}
// Append the query string if it exists and isn't null.
if (!empty($_SERVER['QUERY_STRING'])) {
$requestUri .= '?' . $_SERVER['QUERY_STRING'];
}
}
}
if (!$requestUri) {
$requestUri = '/';
}
define('YACHTINO_REQUEST_URI', $requestUri);
}
// add_action('pre_get_posts', 'yachtino_define_uri', 10, 1);
// add_action('wp', 'yachtino_define_uri', 10, 0);
yachtino_define_uri();
/**
* The code that runs during plugin activation.
* This action is documented in included file.
*/
function yachtino_activate_plugin()
{
// yachtino_define_uri();
/* First check prerequisites (PHP version, WP version)
prerequisites class is compatible also with older PHP versions */
require_once YACHTINO_DIR_PATH . '/includes/basics/class-yachtino-prerequisites.php';
$isOk = Yachtino_Prerequisites::check_prerequisites();
if ($isOk) {
require_once YACHTINO_DIR_PATH . '/includes/basics/class-yachtino-activator.php';
$classActivator = new Yachtino_Activator();
$classActivator->activate();
}
}
register_activation_hook(__FILE__, 'yachtino_activate_plugin');
/**
* The code that runs during plugin deactivation.
* This action is documented in included file.
*/
function yachtino_deactivate_plugin()
{
// yachtino_define_uri();
require_once YACHTINO_DIR_PATH . '/includes/basics/class-yachtino-deactivator.php';
$classActivator = new Yachtino_Deactivator();
$classActivator->deactivate();
}
register_deactivation_hook(__FILE__, 'yachtino_deactivate_plugin');
require_once(ABSPATH . 'wp-admin/includes/plugin.php');
/**
* Run plugin only if this plugin is active.
*/
function yachtino_run_plugin()
{
// We try to call as few functions as possible, not to create unnecessary hooks.
require_once YACHTINO_DIR_PATH . '/includes/class-yachtino.php';
require_once YACHTINO_DIR_PATH . '/includes/basics/class-yachtino-router.php';
require_once YACHTINO_DIR_PATH . '/includes/class-yachtino-public.php';
add_shortcode('yachtino_module', 'Yachtino_Public::get_shortcode');
$plugin = new Yachtino_Router();
$plugin->run();
// Run plugin.
Yachtino::get_instance();
}
if (is_plugin_active('yachtino-boat-listing/yachtino-boat-listing.php')) {
yachtino_run_plugin();
}