| 1 |
<?php |
| 2 |
namespace LWS\WOOREWARDS\PointsFlow\Methods; |
| 3 |
|
| 4 |
// don't call the file directly |
| 5 |
if( !defined( 'ABSPATH' ) ) exit(); |
| 6 |
|
| 7 |
class WooRewards extends \LWS\WOOREWARDS\PointsFlow\ExportMethod |
| 8 |
{ |
| 9 |
/** @return (array) the json that will be send, |
| 10 |
* An array with each entries as {email, points} */ |
| 11 |
public function export($value, $arg) |
| 12 |
{ |
| 13 |
$stackName = $value; |
| 14 |
if (\class_exists('\LWS\WOOREWARDS\PRO\Core\Pool')) { |
| 15 |
$pool = \LWS\WOOREWARDS\PRO\Core\Pool::getOrLoad($value, false); |
| 16 |
} else { |
| 17 |
$pool = \apply_filters('lws_woorewards_get_pools_by_args', false, array( |
| 18 |
'system' => $value, |
| 19 |
'force' => true, |
| 20 |
)); |
| 21 |
if ($pool) |
| 22 |
$pool = $pool->last(); |
| 23 |
} |
| 24 |
if ($pool) |
| 25 |
$stackName = $pool->getStackId(); |
| 26 |
|
| 27 |
global $wpdb; |
| 28 |
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching |
| 29 |
return $wpdb->get_results($wpdb->prepare("SELECT user_email as `email`, meta_value as `points` FROM {$wpdb->users} LEFT JOIN {$wpdb->usermeta} ON ID=user_id AND `meta_key`=%s", 'lws_wre_points_' . $stackName)); |
| 30 |
} |
| 31 |
|
| 32 |
/** @return (string) human readable name */ |
| 33 |
public function getTitle() |
| 34 |
{ |
| 35 |
return __("MyRewards", 'woorewards-lite'); |
| 36 |
} |
| 37 |
|
| 38 |
/** @return (bool) appear in method combobox */ |
| 39 |
public function isVisible() |
| 40 |
{ |
| 41 |
return false; |
| 42 |
} |
| 43 |
} |
| 44 |
|