-
Notifications
You must be signed in to change notification settings - Fork 0
/
wp_all_export_csv_rows.php
55 lines (47 loc) · 1.42 KB
/
wp_all_export_csv_rows.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
<?php
/**
* ==================================
* Filter: wp_all_export_csv_rows
* ==================================
*
* Filters CSV rows to export.
*
* See 'wp_all_export_xml_rows' for XML data. (which get passed a single
* record instead of an array of records)
*
* @param $articles
* @param $options
* @param $export_id
*
* @return array - the records to import
*/
function wp_all_export_csv_rows($articles, $options, $export_id)
{
// Unless you want this code to execute for every export, be sure to check the export id
//
// if ($export_id === 5) { ...
// $articles contains on array of records for importing.
// Loop through the array and unset() any entries you don't
// want imported
return $articles; // Return the array of records to import
}
add_filter('wp_all_export_csv_rows', 'wp_all_export_csv_rows', 10, 2);
// ----------------------------
// Example uses below
// ----------------------------
/**
* Import based on some criteria. In this case pricing.
*
*/
function my_export_csv_rows($articles, $options, $export_id)
{
foreach ($articles as $key => $article) {
if (!empty($article['Regular Price'] && !empty($article['Sale Price']))) {
if ($article['Sale Price'] < ($article['Regular Price'] / 2)) {
unset($articles[$key]);
}
}
}
return $articles;
}
add_filter('wp_all_export_csv_rows', 'my_export_csv_rows', 10, 2);