@@ -29,9 +29,9 @@ discard block |
||
| 29 | 29 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 30 | 30 | */ |
| 31 | 31 | |
| 32 | -add_action( 'admin_init', function () { |
|
| 33 | - if ( is_admin() && current_user_can( 'activate_plugins' ) && ( ! is_plugin_active( 'eduadmin-booking/eduadmin.php' ) && ! is_plugin_active( 'eduadmin/eduadmin.php' ) ) ) { |
|
| 34 | - add_action( 'admin_notices', function () { |
|
| 32 | +add_action( 'admin_init', function() { |
|
| 33 | + if ( is_admin() && current_user_can( 'activate_plugins' ) && ( !is_plugin_active( 'eduadmin-booking/eduadmin.php' ) && !is_plugin_active( 'eduadmin/eduadmin.php' ) ) ) { |
|
| 34 | + add_action( 'admin_notices', function() { |
|
| 35 | 35 | ?> |
| 36 | 36 | <div class="error"> |
| 37 | 37 | <p><?php esc_html_e( 'This plugin requires the EduAdmin-WordPress-plugin to be installed and activated.', 'eduadmin-wp-klarna-checkout' ); ?></p> |
@@ -45,14 +45,14 @@ discard block |
||
| 45 | 45 | } |
| 46 | 46 | } ); |
| 47 | 47 | |
| 48 | -if ( ! class_exists( 'EDU_KlarnaCheckout_Loader' ) ) { |
|
| 48 | +if ( !class_exists( 'EDU_KlarnaCheckout_Loader' ) ) { |
|
| 49 | 49 | final class EDU_KlarnaCheckout_Loader { |
| 50 | 50 | public function __construct() { |
| 51 | 51 | add_action( 'plugins_loaded', array( $this, 'init' ) ); |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | public function init() { |
| 55 | - if ( ! class_exists( 'Klarna_Checkout_Connector' ) ) { |
|
| 55 | + if ( !class_exists( 'Klarna_Checkout_Connector' ) ) { |
|
| 56 | 56 | require_once __DIR__ . '/klarna_kco_php_4.0.0/src/Klarna/Checkout.php'; |
| 57 | 57 | } |
| 58 | 58 | |
@@ -1,7 +1,7 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | defined( 'ABSPATH' ) || die( 'This plugin must be run within the scope of WordPress.' ); |
| 3 | 3 | |
| 4 | -if ( ! class_exists( 'EDU_KlarnaCheckout' ) ) { |
|
| 4 | +if ( !class_exists( 'EDU_KlarnaCheckout' ) ) { |
|
| 5 | 5 | class EDU_KlarnaCheckout extends EDU_Integration { |
| 6 | 6 | public function __construct() { |
| 7 | 7 | $this->id = 'eduadmin-klarnacheckout'; |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | |
| 65 | 65 | $ebi = new EduAdmin_BookingInfo( $event_booking, $_customer, $_contact ); |
| 66 | 66 | |
| 67 | - if ( ! empty( EDU()->session['klarna-order-id'] ) && ! empty( $_GET['klarna_order_id'] ) && EDU()->session['klarna-order-id'] === $_GET['klarna_order_id'] ) { |
|
| 67 | + if ( !empty( EDU()->session['klarna-order-id'] ) && !empty( $_GET['klarna_order_id'] ) && EDU()->session['klarna-order-id'] === $_GET['klarna_order_id'] ) { |
|
| 68 | 68 | do_action( 'eduadmin-bookingcompleted', $ebi ); |
| 69 | 69 | } else { |
| 70 | 70 | do_action( 'eduadmin-processbooking', $ebi ); |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | return; |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | - if ( ! empty( $_POST['act'] ) && ( 'bookCourse' === $_POST['act'] || 'bookProgramme' === $_POST['act'] ) ) { |
|
| 82 | + if ( !empty( $_POST['act'] ) && ( 'bookCourse' === $_POST['act'] || 'bookProgramme' === $_POST['act'] ) ) { |
|
| 83 | 83 | $ebi->NoRedirect = true; |
| 84 | 84 | } |
| 85 | 85 | } |
@@ -106,10 +106,10 @@ discard block |
||
| 106 | 106 | if ( 'no' === $this->get_option( 'enabled', 'no' ) ) { |
| 107 | 107 | return; |
| 108 | 108 | } |
| 109 | - $checkout_url = ! checked( $this->get_option( 'test_mode', 'no' ), '1', false ) ? Klarna_Checkout_Connector::BASE_URL : Klarna_Checkout_Connector::BASE_TEST_URL; |
|
| 109 | + $checkout_url = !checked( $this->get_option( 'test_mode', 'no' ), '1', false ) ? Klarna_Checkout_Connector::BASE_URL : Klarna_Checkout_Connector::BASE_TEST_URL; |
|
| 110 | 110 | $shared_secret = $this->get_option( 'shared_secret', '' ); |
| 111 | 111 | |
| 112 | - if ( ! empty( $_GET['klarna_order_id'] ) && ! empty( EDU()->session['klarna-order-id'] ) && EDU()->session['klarna-order-id'] === $_GET['klarna_order_id'] ) { |
|
| 112 | + if ( !empty( $_GET['klarna_order_id'] ) && !empty( EDU()->session['klarna-order-id'] ) && EDU()->session['klarna-order-id'] === $_GET['klarna_order_id'] ) { |
|
| 113 | 113 | try { |
| 114 | 114 | $connector = Klarna_Checkout_Connector::create( |
| 115 | 115 | $shared_secret, |
@@ -175,7 +175,7 @@ discard block |
||
| 175 | 175 | */ |
| 176 | 176 | public function create_checkout( $ebi = null ) { |
| 177 | 177 | |
| 178 | - $checkout_url = ! checked( $this->get_option( 'test_mode', 'no' ), '1', false ) ? Klarna_Checkout_Connector::BASE_URL : Klarna_Checkout_Connector::BASE_TEST_URL; |
|
| 178 | + $checkout_url = !checked( $this->get_option( 'test_mode', 'no' ), '1', false ) ? Klarna_Checkout_Connector::BASE_URL : Klarna_Checkout_Connector::BASE_TEST_URL; |
|
| 179 | 179 | $shared_secret = $this->get_option( 'shared_secret', '' ); |
| 180 | 180 | |
| 181 | 181 | $create = array(); |
@@ -197,14 +197,14 @@ discard block |
||
| 197 | 197 | |
| 198 | 198 | $_event = null; |
| 199 | 199 | |
| 200 | - if ( ! empty( $ebi->EventBooking['BookingId'] ) ) { |
|
| 200 | + if ( !empty( $ebi->EventBooking['BookingId'] ) ) { |
|
| 201 | 201 | $booking_id = intval( $ebi->EventBooking['BookingId'] ); |
| 202 | 202 | $reference_id = $booking_id; |
| 203 | 203 | |
| 204 | 204 | $_event = EDUAPI()->OData->Events->GetItem( $ebi->EventBooking['EventId'] ); |
| 205 | 205 | } |
| 206 | 206 | |
| 207 | - if ( ! empty( $ebi->EventBooking['ProgrammeBookingId'] ) ) { |
|
| 207 | + if ( !empty( $ebi->EventBooking['ProgrammeBookingId'] ) ) { |
|
| 208 | 208 | $programme_booking_id = intval( $ebi->EventBooking['ProgrammeBookingId'] ); |
| 209 | 209 | $reference_id = $programme_booking_id; |
| 210 | 210 | |
@@ -214,15 +214,15 @@ discard block |
||
| 214 | 214 | $rowExtraInfo = ""; |
| 215 | 215 | |
| 216 | 216 | if ( null != $_event ) { |
| 217 | - if ( ! empty( $_event['City'] ) ) { |
|
| 217 | + if ( !empty( $_event['City'] ) ) { |
|
| 218 | 218 | $rowExtraInfo .= ';' . $_event['City']; |
| 219 | 219 | } |
| 220 | 220 | |
| 221 | - if ( ! empty( $_event['StartDate'] ) ) { |
|
| 221 | + if ( !empty( $_event['StartDate'] ) ) { |
|
| 222 | 222 | $rowExtraInfo .= ';' . date( "Y-m-d", strtotime( $_event['StartDate'] ) ); |
| 223 | 223 | } |
| 224 | 224 | |
| 225 | - if ( ! empty( $_event['EndDate'] ) ) { |
|
| 225 | + if ( !empty( $_event['EndDate'] ) ) { |
|
| 226 | 226 | $rowExtraInfo .= ';' . date( "Y-m-d", strtotime( $_event['EndDate'] ) ); |
| 227 | 227 | } |
| 228 | 228 | } |
@@ -268,7 +268,7 @@ discard block |
||
| 268 | 268 | $cart_item['name'] = $order_row['Description'] . $rowExtraInfo; |
| 269 | 269 | $cart_item['quantity'] = intval( $order_row['Quantity'] ); |
| 270 | 270 | |
| 271 | - if ( ! $order_row['PriceIncVat'] ) { |
|
| 271 | + if ( !$order_row['PriceIncVat'] ) { |
|
| 272 | 272 | $price_per_unit = $order_row['PricePerUnit'] * ( 1 + ( $order_row['VatPercent'] / 100 ) ) * 100; |
| 273 | 273 | } else { |
| 274 | 274 | $price_per_unit = $order_row['PricePerUnit'] * 100; |
@@ -305,8 +305,8 @@ discard block |
||
| 305 | 305 | } |
| 306 | 306 | |
| 307 | 307 | public function process_paymentstatus() { |
| 308 | - if ( ! empty( $_GET['klarna_order_id'] ) && ! empty( $_GET['status'] ) ) { |
|
| 309 | - $checkout_url = ! checked( $this->get_option( 'test_mode', 'no' ), '1', false ) ? Klarna_Checkout_Connector::BASE_URL : Klarna_Checkout_Connector::BASE_TEST_URL; |
|
| 308 | + if ( !empty( $_GET['klarna_order_id'] ) && !empty( $_GET['status'] ) ) { |
|
| 309 | + $checkout_url = !checked( $this->get_option( 'test_mode', 'no' ), '1', false ) ? Klarna_Checkout_Connector::BASE_URL : Klarna_Checkout_Connector::BASE_TEST_URL; |
|
| 310 | 310 | $shared_secret = $this->get_option( 'shared_secret', '' ); |
| 311 | 311 | |
| 312 | 312 | try { |