| @@ -12,13 +12,15 @@ | ||
| 12 | 12 | /** |
| 13 | 13 | * Show a table of either payments for subscriptions. |
| 14 | 14 | * |
| 15 | 15 | * @param int $id |
| 16 | + * | |
| 16 | 17 | * @return void |
| 17 | 18 | */ |
| 18 | 19 | public static function show( $id = 0 ) { |
| 19 | 20 | if ( ! $id ) { |
| 20 | 21 | $id = FrmAppHelper::get_param( 'id', 0, 'get', 'absint' ); |
| 22 | + | |
| 21 | 23 | if ( ! $id ) { |
| 22 | 24 | wp_die( esc_html__( 'Please select a payment to view', 'formidable' ) ); |
| 23 | 25 | } |
| 24 | 26 | } |
| @@ -56,8 +58,9 @@ | ||
| 56 | 58 | } |
| 57 | 59 | |
| 58 | 60 | /** |
| 59 | 61 | * @param int $id |
| 62 | + * | |
| 60 | 63 | * @return object|null |
| 61 | 64 | */ |
| 62 | 65 | private static function get_payment_row( $id ) { |
| 63 | 66 | global $wpdb; |
| @@ -64,9 +67,9 @@ | ||
| 64 | 67 | |
| 65 | 68 | $table_name = self::table_name(); |
| 66 | 69 | |
| 67 | 70 | // @codingStandardsIgnoreStart |
| 68 | - $payment = $wpdb->get_row( | |
| 71 | + return $wpdb->get_row( | |
| 69 | 72 | $wpdb->prepare( |
| 70 | 73 | "SELECT |
| 71 | 74 | p.*, e.user_id |
| 72 | 75 | FROM `{$wpdb->prefix}frm_{$table_name}` p |
| @@ -75,10 +78,8 @@ | ||
| 75 | 78 | $id |
| 76 | 79 | ) |
| 77 | 80 | ); |
| 78 | 81 | // @codingStandardsIgnoreEnd |
| 79 | - | |
| 80 | - return $payment; | |
| 81 | 82 | } |
| 82 | 83 | |
| 83 | 84 | /** |
| 84 | 85 | * Handle routing for deleting a payment. |
| @@ -113,13 +114,9 @@ | ||
| 113 | 114 | $allowed = array( 'payments', 'subscriptions' ); |
| 114 | 115 | $default = reset( $allowed ); |
| 115 | 116 | $name = FrmAppHelper::get_param( 'type', $default, 'get', 'sanitize_text_field' ); |
| 116 | 117 | |
| 117 | - if ( ! in_array( $name, $allowed, true ) ) { | |
| 118 | - $name = $default; | |
| 119 | - } | |
| 120 | - | |
| 121 | - return $name; | |
| 118 | + return in_array( $name, $allowed, true ) ? $name : $default; | |
| 122 | 119 | } |
| 123 | 120 | |
| 124 | 121 | /** |
| 125 | 122 | * @return FrmTransLitePayment|FrmTransLiteSubscription |
| @@ -124,8 +121,11 @@ | ||
| 124 | 121 | /** |
| 125 | 122 | * @return FrmTransLitePayment|FrmTransLiteSubscription |
| 126 | 123 | */ |
| 127 | 124 | private static function the_class() { |
| 128 | - $class_name = self::table_name() === 'subscriptions' ? 'FrmTransLiteSubscription' : 'FrmTransLitePayment'; | |
| 129 | - return new $class_name(); | |
| 125 | + if ( self::table_name() === 'subscriptions' ) { | |
| 126 | + return new FrmTransLiteSubscription(); | |
| 127 | + } | |
| 128 | + | |
| 129 | + return new FrmTransLitePayment(); | |
| 130 | 130 | } |
| 131 | 131 | } |