1 | <?php |
||
2 | /** |
||
3 | * This is the main GeoDirectory plugin file, here we declare and call the important stuff |
||
4 | * |
||
5 | * @package GeoDirectory |
||
6 | * @copyright 2016 AyeCode Ltd |
||
7 | * @license GPL-2.0+ |
||
8 | * @since 1.0.0 |
||
9 | * |
||
10 | * @wordpress-plugin |
||
11 | * Plugin Name: GeoDirectory |
||
12 | * Plugin URI: https://wpgeodirectory.com/ |
||
13 | * Description: GeoDirectory plugin for WordPress. |
||
14 | * Version: 1.6.38 |
||
15 | * Author: GeoDirectory |
||
16 | * Author URI: https://wpgeodirectory.com |
||
17 | * Text Domain: geodirectory |
||
18 | * Domain Path: /geodirectory-languages |
||
19 | * Requires at least: 3.1 |
||
20 | * Tested up to: 5.1 |
||
21 | * Update URL: https://github.com/GeoDirectory/geodirectory/ |
||
22 | */ |
||
23 | |||
24 | /** |
||
25 | * The current version number of GeoDirectory. |
||
26 | * |
||
27 | * @since 1.0.0 |
||
28 | */ |
||
29 | define("GEODIRECTORY_VERSION", "1.6.38"); |
||
30 | |||
31 | /* |
||
32 | * CHECK FOR OLD COMPATIBILITY PACKS AND DISABLE IF THEY ARE ACTIVE |
||
33 | */ |
||
34 | if (is_admin()) { |
||
35 | /** |
||
36 | * Include WordPress core file so we can use core functions to check for active plugins. |
||
37 | */ |
||
38 | include_once(ABSPATH . 'wp-admin/includes/plugin.php'); |
||
39 | |||
40 | if (is_plugin_active('geodirectory-genesis-compatibility-pack/geodir_genesis_compatibility.php')) { |
||
41 | deactivate_plugins('geodirectory-genesis-compatibility-pack/geodir_genesis_compatibility.php'); |
||
42 | } |
||
43 | |||
44 | if (is_plugin_active('geodirectory-x-theme-compatibility-pack/geodir_x_compatibility.php')) { |
||
45 | deactivate_plugins('geodirectory-x-theme-compatibility-pack/geodir_x_compatibility.php'); |
||
46 | } |
||
47 | |||
48 | if (is_plugin_active('geodirectory-enfold-theme-compatibility-pack/geodir_enfold_compatibility.php')) { |
||
49 | deactivate_plugins('geodirectory-enfold-theme-compatibility-pack/geodir_enfold_compatibility.php'); |
||
50 | } |
||
51 | |||
52 | if (is_plugin_active('geodir_avada_compatibility/geodir_avada_compatibility.php')) { |
||
53 | deactivate_plugins('geodir_avada_compatibility/geodir_avada_compatibility.php'); |
||
54 | } |
||
55 | |||
56 | if (is_plugin_active('geodir_compat_pack_divi/geodir_divi_compatibility.php')) { |
||
57 | deactivate_plugins('geodir_compat_pack_divi/geodir_divi_compatibility.php'); |
||
58 | } |
||
59 | |||
60 | } |
||
61 | |||
62 | /** |
||
63 | * Declare some global variables for later use. |
||
64 | * |
||
65 | * @since 1.0.0 |
||
66 | * @global object $wpdb WordPress Database object. |
||
67 | * @global string $plugin_prefix Geodirectory plugin table prefix. |
||
68 | * @global array $geodir_addon_list List of active GeoDirectory extensions. |
||
69 | * @global string $plugin_file_name Base file name. 'geodirectory/geodirectory.php'. |
||
70 | */ |
||
71 | global $wpdb, $plugin_prefix, $geodir_addon_list, $plugin_file_name; |
||
72 | $plugin_prefix = $wpdb->prefix . 'geodir_'; |
||
73 | $plugin_file_name = basename(plugin_dir_path(__FILE__)) . '/' . basename(__FILE__); |
||
74 | |||
75 | /* |
||
76 | * This will store the cached post custom fields per package for each page load so not to run for each listing. |
||
77 | */ |
||
78 | $geodir_post_custom_fields_cache = array(); |
||
79 | |||
80 | /** |
||
81 | * Do not store any revisions (except the one autosave per post). |
||
82 | */ |
||
83 | if (!defined('WP_POST_REVISIONS')) define('WP_POST_REVISIONS', 0); |
||
84 | |||
85 | /** |
||
86 | * Define constants |
||
87 | */ |
||
88 | if(!defined('GEODIRECTORY_PLUGIN_DIR')) define('GEODIRECTORY_PLUGIN_DIR', plugin_dir_path( __FILE__ )); |
||
89 | |||
90 | /* |
||
91 | * Declare database table names. All since version 1.0.0 |
||
92 | */ |
||
93 | |||
94 | /** Define the database name for the countries table. */ |
||
95 | if (!defined('GEODIR_COUNTRIES_TABLE')) define('GEODIR_COUNTRIES_TABLE', $plugin_prefix . 'countries'); |
||
96 | /** Define the database name for the custom fields table. */ |
||
97 | if (!defined('GEODIR_CUSTOM_FIELDS_TABLE')) define('GEODIR_CUSTOM_FIELDS_TABLE', $plugin_prefix . 'custom_fields'); |
||
98 | /** Define the database name for the icons table. */ |
||
99 | if (!defined('GEODIR_ICON_TABLE')) define('GEODIR_ICON_TABLE', $plugin_prefix . 'post_icon'); |
||
100 | /** Define the database name for the attachments table. */ |
||
101 | if (!defined('GEODIR_ATTACHMENT_TABLE')) define('GEODIR_ATTACHMENT_TABLE', $plugin_prefix . 'attachments'); |
||
102 | /** Define the database name for the review table. */ |
||
103 | if (!defined('GEODIR_REVIEW_TABLE')) define('GEODIR_REVIEW_TABLE', $plugin_prefix . 'post_review'); |
||
104 | /** Define the database name for the custom sort fields table. */ |
||
105 | if (!defined('GEODIR_CUSTOM_SORT_FIELDS_TABLE')) define('GEODIR_CUSTOM_SORT_FIELDS_TABLE', $plugin_prefix . 'custom_sort_fields'); |
||
106 | |||
107 | /* |
||
108 | * Define our Google Analytic app settings |
||
109 | */ |
||
110 | if (!defined('GEODIR_GA_CLIENTID')) define('GEODIR_GA_CLIENTID', '687912069872-sdpsjssrdt7t3ao1dnv1ib71hkckbt5s.apps.googleusercontent.com'); |
||
111 | if (!defined('GEODIR_GA_CLIENTSECRET')) define('GEODIR_GA_CLIENTSECRET', 'yBVkDpqJ1B9nAETHy738Zn8C'); //don't worry - this don't need to be secret in our case |
||
112 | if (!defined('GEODIR_GA_REDIRECT')) define('GEODIR_GA_REDIRECT', 'urn:ietf:wg:oauth:2.0:oob'); |
||
113 | if (!defined('GEODIR_GA_SCOPE')) define('GEODIR_GA_SCOPE', 'https://www.googleapis.com/auth/analytics');//.readonly |
||
114 | |||
115 | |||
116 | /* |
||
117 | * Localisation items. |
||
118 | */ |
||
119 | if (!defined('GEODIRECTORY_TEXTDOMAIN')) define('GEODIRECTORY_TEXTDOMAIN', 'geodirectory'); |
||
120 | |||
121 | // Load geodirectory plugin textdomain. |
||
122 | add_action( 'init', 'geodir_load_textdomain' ); |
||
123 | |||
124 | /* |
||
125 | * A function to log GD errors no matter the type given. |
||
126 | * |
||
127 | * This function will log GD errors if the WP_DEBUG constant is true, it can be filtered. |
||
128 | * |
||
129 | * @since 1.5.7 |
||
130 | * @param mixed $log The thing that should be logged. |
||
131 | * @package GeoDirectory |
||
132 | */ |
||
133 | function geodir_error_log($log){ |
||
134 | /* |
||
135 | * A filter to override the WP_DEBUG setting for function geodir_error_log(). |
||
136 | * |
||
137 | * @since 1.5.7 |
||
138 | */ |
||
139 | $should_log = apply_filters( 'geodir_log_errors', WP_DEBUG); |
||
140 | if ( true === $should_log ) { |
||
141 | if ( is_array( $log ) || is_object( $log ) ) { |
||
142 | error_log( print_r( $log, true ) ); |
||
143 | } else { |
||
144 | error_log( $log ); |
||
145 | } |
||
146 | } |
||
147 | } |
||
148 | /** |
||
149 | * Include all plugin functions. |
||
150 | * |
||
151 | * @since 1.0.0 |
||
152 | */ |
||
153 | include_once('geodirectory_functions.php'); |
||
154 | /** |
||
155 | * Most actions/hooks are called from here. |
||
156 | * |
||
157 | * @since 1.0.0 |
||
158 | */ |
||
159 | include_once('geodirectory_hooks_actions.php'); |
||
160 | /** |
||
161 | * Include all plugin widgets. |
||
162 | * |
||
163 | * @since 1.0.0 |
||
164 | */ |
||
165 | include_once('geodirectory_widgets.php'); |
||
166 | /** |
||
167 | * Most JS and CSS in added or enqueued from here. |
||
168 | * |
||
169 | * @since 1.0.0 |
||
170 | */ |
||
171 | include_once('geodirectory_template_tags.php'); |
||
172 | /** |
||
173 | * Most of the plugins templates are added from here via hooks. |
||
174 | * |
||
175 | * @since 1.0.0 |
||
176 | */ |
||
177 | include_once('geodirectory_template_actions.php'); |
||
178 | |||
179 | /** |
||
180 | * Font Awesome Settings. |
||
181 | * |
||
182 | * @since 1.6.36 |
||
183 | */ |
||
184 | require_once('geodirectory-admin/wp-font-awesome-settings.php'); |
||
185 | |||
186 | /* |
||
187 | * Admin init + activation hooks |
||
188 | */ |
||
189 | if (is_admin() || defined( 'GD_TESTING_MODE' ) || ( defined( 'WP_CLI' ) && WP_CLI )) { |
||
190 | |||
191 | /** |
||
192 | * Include functions used in admin area only. |
||
193 | * |
||
194 | * @since 1.0.0 |
||
195 | */ |
||
196 | require_once('geodirectory-admin/admin_functions.php'); |
||
197 | /** |
||
198 | * Most actions/hooks used in admin area only are called from here. |
||
199 | * |
||
200 | * @since 1.6.11 |
||
201 | */ |
||
202 | require_once('geodirectory-admin/admin_dummy_data_functions.php'); |
||
203 | /** |
||
204 | * Most actions/hooks used in admin area only are called from here. |
||
205 | * |
||
206 | * @since 1.0.0 |
||
207 | */ |
||
208 | require_once('geodirectory-admin/admin_hooks_actions.php'); |
||
209 | /** |
||
210 | * Most admin JS and CSS is called from here. |
||
211 | * |
||
212 | * @since 1.0.0 |
||
213 | */ |
||
214 | require_once('geodirectory-admin/admin_template_tags.php'); |
||
215 | /** |
||
216 | * Include Google Analytics Class. |
||
217 | * |
||
218 | * @since 1.6.11 |
||
219 | */ |
||
220 | require_once('geodirectory-admin/class.analytics.stats.php'); |
||
221 | /** |
||
222 | * Include any functions needed for upgrades. |
||
223 | * |
||
224 | * @since 1.0.0 |
||
225 | */ |
||
226 | require_once(geodir_plugin_path() . '/upgrade.php'); |
||
227 | if (get_option('geodir_installed') != 1) { |
||
228 | /** |
||
229 | * Define language constants, here as they are not loaded yet. |
||
230 | * |
||
231 | * @since 1.0.0 |
||
232 | */ |
||
233 | require_once(geodir_plugin_path() . '/language.php'); |
||
234 | /** |
||
235 | * Include the plugin install file that sets up the databases and any options on first run. |
||
236 | * |
||
237 | * @since 1.0.0 |
||
238 | */ |
||
239 | require_once('geodirectory-admin/admin_install.php'); |
||
240 | register_activation_hook(__FILE__, 'geodir_activation'); |
||
241 | } |
||
242 | register_deactivation_hook(__FILE__, 'geodir_deactivation'); |
||
243 | |||
244 | /* |
||
245 | * Show a upgrade warning message if applicable. |
||
246 | * |
||
247 | * @since 1.5.6 |
||
248 | */ |
||
249 | global $pagenow; |
||
250 | if ( 'plugins.php' === $pagenow ) |
||
251 | { |
||
252 | // Better update message |
||
253 | $file = basename( __FILE__ ); |
||
254 | $folder = basename( dirname( __FILE__ ) ); |
||
255 | $hook = "in_plugin_update_message-{$folder}/{$file}"; |
||
256 | add_action( $hook, 'geodire_admin_upgrade_notice', 20, 2 ); |
||
257 | } |
||
258 | |||
259 | } |