-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy pathgeodirectory.php
259 lines (235 loc) · 8.42 KB
/
geodirectory.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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
<?php
/**
* This is the main GeoDirectory plugin file, here we declare and call the important stuff
*
* @package GeoDirectory
* @copyright 2016 AyeCode Ltd
* @license GPL-2.0+
* @since 1.0.0
*
* @wordpress-plugin
* Plugin Name: GeoDirectory
* Plugin URI: https://wpgeodirectory.com/
* Description: GeoDirectory plugin for WordPress.
* Version: 1.6.38
* Author: GeoDirectory
* Author URI: https://wpgeodirectory.com
* Text Domain: geodirectory
* Domain Path: /geodirectory-languages
* Requires at least: 3.1
* Tested up to: 5.1
* Update URL: https://github.com/GeoDirectory/geodirectory/
*/
/**
* The current version number of GeoDirectory.
*
* @since 1.0.0
*/
define("GEODIRECTORY_VERSION", "1.6.38");
/*
* CHECK FOR OLD COMPATIBILITY PACKS AND DISABLE IF THEY ARE ACTIVE
*/
if (is_admin()) {
/**
* Include WordPress core file so we can use core functions to check for active plugins.
*/
include_once(ABSPATH . 'wp-admin/includes/plugin.php');
if (is_plugin_active('geodirectory-genesis-compatibility-pack/geodir_genesis_compatibility.php')) {
deactivate_plugins('geodirectory-genesis-compatibility-pack/geodir_genesis_compatibility.php');
}
if (is_plugin_active('geodirectory-x-theme-compatibility-pack/geodir_x_compatibility.php')) {
deactivate_plugins('geodirectory-x-theme-compatibility-pack/geodir_x_compatibility.php');
}
if (is_plugin_active('geodirectory-enfold-theme-compatibility-pack/geodir_enfold_compatibility.php')) {
deactivate_plugins('geodirectory-enfold-theme-compatibility-pack/geodir_enfold_compatibility.php');
}
if (is_plugin_active('geodir_avada_compatibility/geodir_avada_compatibility.php')) {
deactivate_plugins('geodir_avada_compatibility/geodir_avada_compatibility.php');
}
if (is_plugin_active('geodir_compat_pack_divi/geodir_divi_compatibility.php')) {
deactivate_plugins('geodir_compat_pack_divi/geodir_divi_compatibility.php');
}
}
/**
* Declare some global variables for later use.
*
* @since 1.0.0
* @global object $wpdb WordPress Database object.
* @global string $plugin_prefix Geodirectory plugin table prefix.
* @global array $geodir_addon_list List of active GeoDirectory extensions.
* @global string $plugin_file_name Base file name. 'geodirectory/geodirectory.php'.
*/
global $wpdb, $plugin_prefix, $geodir_addon_list, $plugin_file_name;
$plugin_prefix = $wpdb->prefix . 'geodir_';
$plugin_file_name = basename(plugin_dir_path(__FILE__)) . '/' . basename(__FILE__);
/*
* This will store the cached post custom fields per package for each page load so not to run for each listing.
*/
$geodir_post_custom_fields_cache = array();
/**
* Do not store any revisions (except the one autosave per post).
*/
if (!defined('WP_POST_REVISIONS')) define('WP_POST_REVISIONS', 0);
/**
* Define constants
*/
if(!defined('GEODIRECTORY_PLUGIN_DIR')) define('GEODIRECTORY_PLUGIN_DIR', plugin_dir_path( __FILE__ ));
/*
* Declare database table names. All since version 1.0.0
*/
/** Define the database name for the countries table. */
if (!defined('GEODIR_COUNTRIES_TABLE')) define('GEODIR_COUNTRIES_TABLE', $plugin_prefix . 'countries');
/** Define the database name for the custom fields table. */
if (!defined('GEODIR_CUSTOM_FIELDS_TABLE')) define('GEODIR_CUSTOM_FIELDS_TABLE', $plugin_prefix . 'custom_fields');
/** Define the database name for the icons table. */
if (!defined('GEODIR_ICON_TABLE')) define('GEODIR_ICON_TABLE', $plugin_prefix . 'post_icon');
/** Define the database name for the attachments table. */
if (!defined('GEODIR_ATTACHMENT_TABLE')) define('GEODIR_ATTACHMENT_TABLE', $plugin_prefix . 'attachments');
/** Define the database name for the review table. */
if (!defined('GEODIR_REVIEW_TABLE')) define('GEODIR_REVIEW_TABLE', $plugin_prefix . 'post_review');
/** Define the database name for the custom sort fields table. */
if (!defined('GEODIR_CUSTOM_SORT_FIELDS_TABLE')) define('GEODIR_CUSTOM_SORT_FIELDS_TABLE', $plugin_prefix . 'custom_sort_fields');
/*
* Define our Google Analytic app settings
*/
if (!defined('GEODIR_GA_CLIENTID')) define('GEODIR_GA_CLIENTID', '687912069872-sdpsjssrdt7t3ao1dnv1ib71hkckbt5s.apps.googleusercontent.com');
if (!defined('GEODIR_GA_CLIENTSECRET')) define('GEODIR_GA_CLIENTSECRET', 'yBVkDpqJ1B9nAETHy738Zn8C'); //don't worry - this don't need to be secret in our case
if (!defined('GEODIR_GA_REDIRECT')) define('GEODIR_GA_REDIRECT', 'urn:ietf:wg:oauth:2.0:oob');
if (!defined('GEODIR_GA_SCOPE')) define('GEODIR_GA_SCOPE', 'https://www.googleapis.com/auth/analytics');//.readonly
/*
* Localisation items.
*/
if (!defined('GEODIRECTORY_TEXTDOMAIN')) define('GEODIRECTORY_TEXTDOMAIN', 'geodirectory');
// Load geodirectory plugin textdomain.
add_action( 'init', 'geodir_load_textdomain' );
/*
* A function to log GD errors no matter the type given.
*
* This function will log GD errors if the WP_DEBUG constant is true, it can be filtered.
*
* @since 1.5.7
* @param mixed $log The thing that should be logged.
* @package GeoDirectory
*/
function geodir_error_log($log){
/*
* A filter to override the WP_DEBUG setting for function geodir_error_log().
*
* @since 1.5.7
*/
$should_log = apply_filters( 'geodir_log_errors', WP_DEBUG);
if ( true === $should_log ) {
if ( is_array( $log ) || is_object( $log ) ) {
error_log( print_r( $log, true ) );
} else {
error_log( $log );
}
}
}
/**
* Include all plugin functions.
*
* @since 1.0.0
*/
include_once('geodirectory_functions.php');
/**
* Most actions/hooks are called from here.
*
* @since 1.0.0
*/
include_once('geodirectory_hooks_actions.php');
/**
* Include all plugin widgets.
*
* @since 1.0.0
*/
include_once('geodirectory_widgets.php');
/**
* Most JS and CSS in added or enqueued from here.
*
* @since 1.0.0
*/
include_once('geodirectory_template_tags.php');
/**
* Most of the plugins templates are added from here via hooks.
*
* @since 1.0.0
*/
include_once('geodirectory_template_actions.php');
/**
* Font Awesome Settings.
*
* @since 1.6.36
*/
require_once('geodirectory-admin/wp-font-awesome-settings.php');
/*
* Admin init + activation hooks
*/
if (is_admin() || defined( 'GD_TESTING_MODE' ) || ( defined( 'WP_CLI' ) && WP_CLI )) {
/**
* Include functions used in admin area only.
*
* @since 1.0.0
*/
require_once('geodirectory-admin/admin_functions.php');
/**
* Most actions/hooks used in admin area only are called from here.
*
* @since 1.6.11
*/
require_once('geodirectory-admin/admin_dummy_data_functions.php');
/**
* Most actions/hooks used in admin area only are called from here.
*
* @since 1.0.0
*/
require_once('geodirectory-admin/admin_hooks_actions.php');
/**
* Most admin JS and CSS is called from here.
*
* @since 1.0.0
*/
require_once('geodirectory-admin/admin_template_tags.php');
/**
* Include Google Analytics Class.
*
* @since 1.6.11
*/
require_once('geodirectory-admin/class.analytics.stats.php');
/**
* Include any functions needed for upgrades.
*
* @since 1.0.0
*/
require_once(geodir_plugin_path() . '/upgrade.php');
if (get_option('geodir_installed') != 1) {
/**
* Define language constants, here as they are not loaded yet.
*
* @since 1.0.0
*/
require_once(geodir_plugin_path() . '/language.php');
/**
* Include the plugin install file that sets up the databases and any options on first run.
*
* @since 1.0.0
*/
require_once('geodirectory-admin/admin_install.php');
register_activation_hook(__FILE__, 'geodir_activation');
}
register_deactivation_hook(__FILE__, 'geodir_deactivation');
/*
* Show a upgrade warning message if applicable.
*
* @since 1.5.6
*/
global $pagenow;
if ( 'plugins.php' === $pagenow )
{
// Better update message
$file = basename( __FILE__ );
$folder = basename( dirname( __FILE__ ) );
$hook = "in_plugin_update_message-{$folder}/{$file}";
add_action( $hook, 'geodire_admin_upgrade_notice', 20, 2 );
}
}