PluginProbe ʕ •ᴥ•ʔ
WP All Export – Drag & Drop Export to Any Custom CSV, XML & Excel / 1.3.1
WP All Export – Drag & Drop Export to Any Custom CSV, XML & Excel v1.3.1
trunk 0.9.0 0.9.1 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.2.0 1.2.1 1.2.10 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 1.4.1 1.4.10 1.4.11 1.4.12 1.4.13 1.4.14 1.4.15 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.4.8 1.4.9 1.5.0
wp-all-export / actions / wp_loaded.php
wp-all-export / actions Last commit date
admin_head.php 9 years ago admin_init.php 5 years ago admin_menu.php 4 years ago admin_notices.php 8 years ago init.php 8 years ago pmxe_after_export.php 8 years ago pmxe_before_export.php 8 years ago pmxe_exported_post.php 10 years ago wp_ajax_dismiss_export_warnings.php 9 years ago wp_ajax_dismiss_warnings.php 4 years ago wp_ajax_generate_zapier_api_key.php 10 years ago wp_ajax_redirect_after_addon_installed.php 6 years ago wp_ajax_save_scheduling.php 8 years ago wp_ajax_scheduling_dialog_content.php 5 years ago wp_ajax_wpae_available_rules.php 8 years ago wp_ajax_wpae_filtering.php 4 years ago wp_ajax_wpae_filtering_count.php 4 years ago wp_ajax_wpae_preview.php 8 years ago wp_ajax_wpae_upgrade_notice.php 4 years ago wp_ajax_wpallexport.php 8 years ago wp_loaded.php 4 years ago wpmu_new_blog.php 10 years ago
wp_loaded.php
269 lines
1 <?php
2
3 function pmxe_wp_loaded() {
4
5 @ini_set("max_input_time", PMXE_Plugin::getInstance()->getOption('max_input_time'));
6
7 $maxExecutionTime = PMXE_Plugin::getInstance()->getOption('max_execution_time');
8 if($maxExecutionTime == -1) {
9 $maxExecutionTime = 0;
10 }
11
12 $scheduledExport = new \Wpae\Scheduling\Export();
13
14 if ( ! empty($_GET['zapier_subscribe']) and ! empty($_GET['api_key']) )
15 {
16 pmxe_set_max_execution_time();
17 $zapier_api_key = PMXE_Plugin::getInstance()->getOption('zapier_api_key');
18
19 if ( ! empty($zapier_api_key) and $zapier_api_key == $_GET['api_key'] )
20 {
21 $subscriptions = get_option('zapier_subscribe', array());
22
23 $body = json_decode(file_get_contents("php://input"), true);
24
25 if ( ! empty($body))
26 {
27 $subscriptions[basename($body['target_url'])] = $body;
28 }
29
30 update_option('zapier_subscribe', $subscriptions);
31
32 exit(json_encode(array('status' => 200)));
33 }
34 else
35 {
36 http_response_code(401);
37 exit(json_encode(array('status' => 'error')));
38 }
39 }
40
41 if ( ! empty($_GET['zapier_unsubscribe']) and ! empty($_GET['api_key']) )
42 {
43 pmxe_set_max_execution_time();
44 $zapier_api_key = PMXE_Plugin::getInstance()->getOption('zapier_api_key');
45
46 if ( ! empty($zapier_api_key) and $zapier_api_key == $_GET['api_key'] )
47 {
48 $subscriptions = get_option('zapier_subscribe', array());
49
50 $body = json_decode(file_get_contents("php://input"), true);
51
52 if ( ! empty($subscriptions[basename($body['target_url'])]) ) unset($subscriptions[basename($body['target_url'])]);
53
54 update_option('zapier_subscribe', $subscriptions);
55
56 exit(json_encode(array('status' => 200)));
57 }
58 else
59 {
60 http_response_code(401);
61 exit(json_encode(array('status' => 'error')));
62 }
63 }
64
65 if ( ! empty($_GET['export_completed']) and ! empty($_GET['api_key']))
66 {
67 pmxe_set_max_execution_time();
68
69 $zapier_api_key = PMXE_Plugin::getInstance()->getOption('zapier_api_key');
70
71 if ( ! empty($zapier_api_key) and $zapier_api_key == $_GET['api_key'] )
72 {
73
74 global $wpdb;
75
76 $table_prefix = PMXE_Plugin::getInstance()->getTablePrefix();
77
78 $export = $wpdb->get_row("SELECT * FROM {$table_prefix}exports ORDER BY `id` DESC LIMIT 1");
79
80 if ( ! empty($export) and ! is_wp_error($export) )
81 {
82 $child_export = new PMXE_Export_Record();
83 $child_export->getById( $export->id );
84
85 if ( ! $child_export->isEmpty())
86 {
87 $wp_uploads = wp_upload_dir();
88
89 $is_secure_import = PMXE_Plugin::getInstance()->getOption('secure');
90
91 if ( ! $is_secure_import)
92 {
93 $filepath = get_attached_file($child_export->attch_id);
94 }
95 else
96 {
97 $filepath = wp_all_export_get_absolute_path($child_export->options['filepath']);
98 }
99
100 $fileurl = str_replace($wp_uploads['basedir'], $wp_uploads['baseurl'], $filepath);
101
102 $response = array(
103 'website_url' => home_url(),
104 'export_id' => $child_export->id,
105 'export_name' => $child_export->friendly_name,
106 'file_name' => basename($filepath),
107 'file_type' => $child_export->options['export_to'],
108 'post_types_exported' => empty($child_export->options['cpt']) ? $child_export->options['wp_query'] : implode($child_export->options['cpt'], ','),
109 'export_created_date' => $child_export->registered_on,
110 'export_last_run_date' => date('Y-m-d H:i:s'),
111 'export_trigger_type' => 'manual',
112 'records_exported' => $child_export->exported,
113 'export_file' => ''
114 );
115
116 if (file_exists($filepath))
117 {
118 $response['export_file_url'] = $fileurl;
119 $response['status'] = 200;
120 $response['message'] = 'OK';
121 }
122 else
123 {
124 $response['export_file_url'] = '';
125 $response['status'] = 300;
126 $response['message'] = 'File doesn\'t exist';
127 }
128
129 $response = apply_filters('wp_all_export_zapier_response', $response);
130
131 wp_send_json(array($response));
132 }
133 }
134
135 }
136 else
137 {
138 http_response_code(401);
139 exit(json_encode(array('status' => 'error')));
140 }
141 }
142
143 /* Check if cron is manualy, then execute export */
144 $cron_job_key = PMXE_Plugin::getInstance()->getOption('cron_job_key');
145
146 if ( ! empty($_GET['action']) && ! empty($_GET['export_id']) && (!empty($_GET['export_hash']) || !empty($_GET['security_token'])))
147 {
148 pmxe_set_max_execution_time();
149
150 if(empty($_GET['export_hash'])) {
151 $securityToken = $_GET['security_token'];
152 } else {
153 $securityToken = $_GET['export_hash'];
154 }
155
156 if ( $securityToken == substr(md5($cron_job_key . $_GET['export_id']), 0, 16) )
157 {
158 $export = new PMXE_Export_Record();
159
160 $export->getById($_GET['export_id']);
161
162 if ( ! $export->isEmpty())
163 {
164 switch ($_GET['action'])
165 {
166 case 'get_data':
167
168 if ( ! empty($export->options['current_filepath']) and @file_exists($export->options['current_filepath']))
169 {
170 $filepath = $export->options['current_filepath'];
171 }
172 else
173 {
174 $is_secure_import = PMXE_Plugin::getInstance()->getOption('secure');
175
176 if ( ! $is_secure_import)
177 {
178 $filepath = get_attached_file($export->attch_id);
179 }
180 else
181 {
182 $filepath = wp_all_export_get_absolute_path($export->options['filepath']);
183 }
184 }
185
186 if ( ! empty($_GET['part']) and is_numeric($_GET['part'])) $filepath = str_replace(basename($filepath), str_replace('.' . $export->options['export_to'], '', basename($filepath)) . '-' . $_GET['part'] . '.' . $export->options['export_to'], $filepath);
187
188 break;
189
190 case 'get_bundle':
191
192 $filepath = wp_all_export_get_absolute_path($export->options['bundlepath']);
193
194 break;
195 }
196
197 if (file_exists($filepath))
198 {
199 $uploads = wp_upload_dir();
200 $fileurl = $uploads['baseurl'] . str_replace($uploads['basedir'], '', str_replace(basename($filepath), rawurlencode(basename($filepath)), $filepath));
201
202 if($export['options']['export_to'] == XmlExportEngine::EXPORT_TYPE_XML && $export['options']['xml_template_type'] == XmlExportEngine::EXPORT_TYPE_GOOLE_MERCHANTS) {
203
204 // If we are doing a google merchants export, send the file as a download.
205 header("Content-type: text/plain");
206 header("Content-Disposition: attachment; filename=".basename($filepath));
207 readfile($filepath);
208
209 die;
210 }
211
212 if(apply_filters('wp_all_export_no_cache', false)) {
213
214 // If we are doing a google merchants export, send the file as a download.
215 header("Content-type: " . mime_content_type($filepath));
216 header("Content-Disposition: attachment; filename=" . basename($filepath));
217 header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
218 header("Cache-Control: post-check=0, pre-check=0", false);
219 header("Pragma: no-cache");
220
221 readfile($filepath);
222
223 die;
224 }
225
226 $fileurl = str_replace( "\\", "/", $fileurl );
227
228 wp_redirect($fileurl);
229 }
230 else
231 {
232 wp_send_json(array(
233 'status' => 403,
234 'message' => __('File doesn\'t exist', 'wp_all_export_plugin')
235 ));
236 }
237 }
238 }
239 else
240 {
241 wp_send_json(array(
242 'status' => 403,
243 'message' => __('Export hash is not valid.', 'wp_all_export_plugin')
244 ));
245 }
246 }
247
248 if(isset($_GET['action']) && $_GET['action'] == 'wpae_public_api') {
249
250 pmxe_set_max_execution_time();
251
252 $router = new \Wpae\Http\Router();
253 $router->route($_GET['q'], false);
254 }
255 }
256
257 if(!function_exists('pmxe_set_max_execution_time')) {
258 function pmxe_set_max_execution_time()
259 {
260 @ini_set("max_input_time", PMXE_Plugin::getInstance()->getOption('max_input_time'));
261
262 $maxExecutionTime = PMXE_Plugin::getInstance()->getOption('max_execution_time');
263 if ($maxExecutionTime == -1) {
264 $maxExecutionTime = 0;
265 }
266
267 @ini_set("max_execution_time", $maxExecutionTime);
268 }
269 }