PluginProbe ʕ •ᴥ•ʔ
WP All Export – Drag & Drop Export to Any Custom CSV, XML & Excel / 1.2.10
WP All Export – Drag & Drop Export to Any Custom CSV, XML & Excel v1.2.10
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 4 years ago admin_init.php 4 years ago admin_menu.php 4 years ago admin_notices.php 4 years ago init.php 4 years ago pmxe_after_export.php 4 years ago pmxe_before_export.php 4 years ago pmxe_exported_post.php 4 years ago wp_ajax_dismiss_export_warnings.php 4 years ago wp_ajax_dismiss_warnings.php 4 years ago wp_ajax_generate_zapier_api_key.php 4 years ago wp_ajax_redirect_after_addon_installed.php 4 years ago wp_ajax_save_scheduling.php 4 years ago wp_ajax_scheduling_dialog_content.php 4 years ago wp_ajax_wpae_available_rules.php 4 years ago wp_ajax_wpae_filtering.php 4 years ago wp_ajax_wpae_filtering_count.php 4 years ago wp_ajax_wpae_preview.php 4 years ago wp_ajax_wpae_upgrade_notice.php 4 years ago wp_ajax_wpallexport.php 4 years ago wp_loaded.php 4 years ago wpmu_new_blog.php 4 years ago
wp_loaded.php
252 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 @ini_set("max_execution_time", $maxExecutionTime);
13
14 $scheduledExport = new \Wpae\Scheduling\Export();
15
16 if ( ! empty($_GET['zapier_subscribe']) and ! empty($_GET['api_key']) )
17 {
18 $zapier_api_key = PMXE_Plugin::getInstance()->getOption('zapier_api_key');
19
20 if ( ! empty($zapier_api_key) and $zapier_api_key == $_GET['api_key'] )
21 {
22 $subscriptions = get_option('zapier_subscribe', array());
23
24 $body = json_decode(file_get_contents("php://input"), true);
25
26 if ( ! empty($body))
27 {
28 $subscriptions[basename($body['target_url'])] = $body;
29 }
30
31 update_option('zapier_subscribe', $subscriptions);
32
33 exit(json_encode(array('status' => 200)));
34 }
35 else
36 {
37 http_response_code(401);
38 exit(json_encode(array('status' => 'error')));
39 }
40 }
41
42 if ( ! empty($_GET['zapier_unsubscribe']) and ! empty($_GET['api_key']) )
43 {
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
68 $zapier_api_key = PMXE_Plugin::getInstance()->getOption('zapier_api_key');
69
70 if ( ! empty($zapier_api_key) and $zapier_api_key == $_GET['api_key'] )
71 {
72
73 global $wpdb;
74
75 $table_prefix = PMXE_Plugin::getInstance()->getTablePrefix();
76
77 $export = $wpdb->get_row("SELECT * FROM {$table_prefix}exports ORDER BY `id` DESC LIMIT 1");
78
79 if ( ! empty($export) and ! is_wp_error($export) )
80 {
81 $child_export = new PMXE_Export_Record();
82 $child_export->getById( $export->id );
83
84 if ( ! $child_export->isEmpty())
85 {
86 $wp_uploads = wp_upload_dir();
87
88 $is_secure_import = PMXE_Plugin::getInstance()->getOption('secure');
89
90 if ( ! $is_secure_import)
91 {
92 $filepath = get_attached_file($child_export->attch_id);
93 }
94 else
95 {
96 $filepath = wp_all_export_get_absolute_path($child_export->options['filepath']);
97 }
98
99 $fileurl = str_replace($wp_uploads['basedir'], $wp_uploads['baseurl'], $filepath);
100
101 $response = array(
102 'website_url' => home_url(),
103 'export_id' => $child_export->id,
104 'export_name' => $child_export->friendly_name,
105 'file_name' => basename($filepath),
106 'file_type' => $child_export->options['export_to'],
107 'post_types_exported' => empty($child_export->options['cpt']) ? $child_export->options['wp_query'] : implode($child_export->options['cpt'], ','),
108 'export_created_date' => $child_export->registered_on,
109 'export_last_run_date' => date('Y-m-d H:i:s'),
110 'export_trigger_type' => 'manual',
111 'records_exported' => $child_export->exported,
112 'export_file' => ''
113 );
114
115 if (file_exists($filepath))
116 {
117 $response['export_file_url'] = $fileurl;
118 $response['status'] = 200;
119 $response['message'] = 'OK';
120 }
121 else
122 {
123 $response['export_file_url'] = '';
124 $response['status'] = 300;
125 $response['message'] = 'File doesn\'t exist';
126 }
127
128 $response = apply_filters('wp_all_export_zapier_response', $response);
129
130 wp_send_json(array($response));
131 }
132 }
133
134 }
135 else
136 {
137 http_response_code(401);
138 exit(json_encode(array('status' => 'error')));
139 }
140 }
141
142 /* Check if cron is manualy, then execute export */
143 $cron_job_key = PMXE_Plugin::getInstance()->getOption('cron_job_key');
144
145 if ( ! empty($_GET['action']) && ! empty($_GET['export_id']) && (!empty($_GET['export_hash']) || !empty($_GET['security_token'])))
146 {
147
148 if(empty($_GET['export_hash'])) {
149 $securityToken = $_GET['security_token'];
150 } else {
151 $securityToken = $_GET['export_hash'];
152 }
153
154 if ( $securityToken == substr(md5($cron_job_key . $_GET['export_id']), 0, 16) )
155 {
156 $export = new PMXE_Export_Record();
157
158 $export->getById($_GET['export_id']);
159
160 if ( ! $export->isEmpty())
161 {
162 switch ($_GET['action'])
163 {
164 case 'get_data':
165
166 if ( ! empty($export->options['current_filepath']) and @file_exists($export->options['current_filepath']))
167 {
168 $filepath = $export->options['current_filepath'];
169 }
170 else
171 {
172 $is_secure_import = PMXE_Plugin::getInstance()->getOption('secure');
173
174 if ( ! $is_secure_import)
175 {
176 $filepath = get_attached_file($export->attch_id);
177 }
178 else
179 {
180 $filepath = wp_all_export_get_absolute_path($export->options['filepath']);
181 }
182 }
183
184 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);
185
186 break;
187
188 case 'get_bundle':
189
190 $filepath = wp_all_export_get_absolute_path($export->options['bundlepath']);
191
192 break;
193 }
194
195 if (file_exists($filepath))
196 {
197 $uploads = wp_upload_dir();
198 $fileurl = $uploads['baseurl'] . str_replace($uploads['basedir'], '', str_replace(basename($filepath), rawurlencode(basename($filepath)), $filepath));
199
200 if($export['options']['export_to'] == XmlExportEngine::EXPORT_TYPE_XML && $export['options']['xml_template_type'] == XmlExportEngine::EXPORT_TYPE_GOOLE_MERCHANTS) {
201
202 // If we are doing a google merchants export, send the file as a download.
203 header("Content-type: text/plain");
204 header("Content-Disposition: attachment; filename=".basename($filepath));
205 readfile($filepath);
206
207 die;
208 }
209
210 if(apply_filters('wp_all_export_no_cache', false)) {
211
212 // If we are doing a google merchants export, send the file as a download.
213 header("Content-type: " . mime_content_type($filepath));
214 header("Content-Disposition: attachment; filename=" . basename($filepath));
215 header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
216 header("Cache-Control: post-check=0, pre-check=0", false);
217 header("Pragma: no-cache");
218
219 readfile($filepath);
220
221 die;
222 }
223
224 $fileurl = str_replace( "\\", "/", $fileurl );
225
226 wp_redirect($fileurl);
227 }
228 else
229 {
230 wp_send_json(array(
231 'status' => 403,
232 'message' => __('File doesn\'t exist', 'wp_all_export_plugin')
233 ));
234 }
235 }
236 }
237 else
238 {
239 wp_send_json(array(
240 'status' => 403,
241 'message' => __('Export hash is not valid.', 'wp_all_export_plugin')
242 ));
243 }
244 }
245
246 if(isset($_GET['action']) && $_GET['action'] == 'wpae_public_api') {
247 $router = new \Wpae\Http\Router();
248 $router->route($_GET['q'], false);
249 }
250 }
251
252