PluginProbe
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses / 4.4.8
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses v4.4.8
4.4.8 4.4.7 4.4.6 4.4.5 4.4.4 4.4.3 4.4.2 4.4.1 4.4.0 4.3.9.1 4.3.9 4.3.8 4.3.7 4.1.6.9 4.1.6.9.1 4.1.6.9.2 4.1.6.9.3 4.1.6.9.4 4.1.7 4.1.7.1 4.1.7.2 4.1.7.3 4.1.7.3.1 4.1.7.3.2 4.2.0 All 139 releases
← All changes | inc/order/class-lp-order.php +29 -9 4.4.04.4.8 View file →
@@ -113,9 +113,9 @@
113 113
114 114 /**
115 115 * Set order date.
116 116 *
117 - * @param int|string $date
117 + * @param int|string $date Date time string is time zone of WP setting
118 118 */
119 119 public function set_order_date( $date ): LP_Order {
120 120 $this->set_data_date( 'order_date', $date );
121 121
@@ -1317,8 +1317,9 @@
1317 1317 * @throws Exception
1318 1318 */
1319 1319 public function save() {
1320 1320 $old_status = '';
1321 + $is_created = ! $this->get_id();
1321 1322
1322 1323 if ( $this->get_id() ) {
1323 1324 $old_status_post = get_post_status( $this->get_id() );
1324 1325 if ( ! in_array( $old_status_post, array( 'trash', 'auto-draft' ) ) ) {
@@ -1341,8 +1342,12 @@
1341 1342 }
1342 1343
1343 1344 $order_id = $this->get_id();
1344 1345
1346 + if ( $is_created && $order_id ) {
1347 + do_action( 'learn-press/order/created', $order_id, $this );
1348 + }
1349 +
1345 1350 if ( $new_status !== $old_status ) {
1346 1351 do_action( 'learn-press/order/status-changed', $order_id, $old_status, $new_status );
1347 1352 do_action( 'learn-press/order/status-' . $new_status, $order_id, $old_status );
1348 1353 do_action( 'learn-press/order/status-' . $old_status . '-to-' . $new_status, $order_id );
@@ -1500,9 +1505,9 @@
1500 1505 *
1501 1506 * @return void
1502 1507 * @throws Exception
1503 1508 * @since 4.3.2.8
1504 - * @version 1.0.0
1509 + * @version 1.0.2
1505 1510 */
1506 1511 public static function handle_params_query_list_orders( PostFilter &$post_filter, array $param = array() ) {
1507 1512 $post_db = PostDB::getInstance();
1508 1513 $user_of_order = absint( $param['author'] ?? 0 );
@@ -1511,9 +1516,9 @@
1511 1516 $month = $param['m'] ?? '';
1512 1517 $limit = $param['posts_per_page'] ?? 20;
1513 1518 $paged = $param['paged'] ?? 1;
1514 1519 $refund_request_status = sanitize_key( (string) ( $param['refund_request_status'] ?? '' ) );
1515 - $order_by = $param['orderby'] ?? 'date';
1520 + $order_by = $param['orderby'] ?? 'menu_order';
1516 1521 if ( empty( $order_by ) ) {
1517 1522 $order_by = 'ID';
1518 1523 } else {
1519 1524 switch ( $order_by ) {
@@ -1519,10 +1524,20 @@
1519 1524 switch ( $order_by ) {
1520 1525 case 'date':
1521 1526 $order_by = 'post_date';
1522 1527 break;
1523 - case 'title':
1524 - $order_by = 'ID';
1528 + default:
1529 + $allowed_key = array(
1530 + 'ID',
1531 + 'post_title',
1532 + 'post_author',
1533 + 'post_status',
1534 + 'order_total',
1535 + 'menu_order'
1536 + );
1537 + if ( ! in_array( $order_by, $allowed_key ) ) {
1538 + $order_by = 'ID';
1539 + }
1525 1540 break;
1526 1541 }
1527 1542 }
1528 1543
@@ -1530,10 +1545,9 @@
1530 1545 // End convert params
1531 1546
1532 1547 if ( $order_by === 'order_total' ) {
1533 1548 $post_filter->join[] = "INNER JOIN {$post_db->tb_postmeta} pm2 ON p.ID = pm2.post_id AND pm2.meta_key = '_order_total'";
1534 - $post_filter->where[] = 'AND CAST(pm2.meta_value AS UNSIGNED)';
1535 - $post_filter->order_by = 'pm2.meta_value';
1549 + $post_filter->order_by = 'CAST(pm2.meta_value AS DECIMAL(10,2))';
1536 1550 } else {
1537 1551 $post_filter->order_by = $order_by;
1538 1552 }
1539 1553
@@ -1565,12 +1579,18 @@
1565 1579 }
1566 1580
1567 1581 if ( ! empty( $month ) ) {
1568 1582 $year = substr( $month, 0, 4 );
1569 - $post_filter->where[] = "AND YEAR(p.post_date) = $year";
1583 + $post_filter->where[] = $post_db->wpdb->prepare(
1584 + 'AND YEAR(p.post_date) = %s',
1585 + $year
1586 + );
1570 1587 if ( strlen( $month ) > 5 ) {
1571 1588 $mon = substr( $month, 4, 2 );
1572 - $post_filter->where[] = "AND MONTH(p.post_date) = $mon";
1589 + $post_filter->where[] = $post_db->wpdb->prepare(
1590 + 'AND MONTH(p.post_date) = %s',
1591 + $mon
1592 + );
1573 1593 }
1574 1594 }
1575 1595
1576 1596 $post_filter->order = $order;