Skip to content

Commit

Permalink
Fixes (#33)
Browse files Browse the repository at this point in the history
* Fixes

* Fixes

---------

Co-authored-by: Adam Wysocki <[email protected]>
  • Loading branch information
s4ddly and Adam Wysocki authored Dec 5, 2024
1 parent 7d1416f commit 6249bb2
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 18 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.7.10]

### Fixed

- Logger implementation
- Notification class
- Plugin activation checks

## [1.7.9]

### Changed
Expand Down
2 changes: 1 addition & 1 deletion includes/Ipn/UpdateOrderStatus.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function parseNotification($response)
}

$order_method = $order->get_payment_method();
$class = TPAY_CLASSMAP[$order_method];
$class = TPAY_CLASSMAP[$order_method] ?? null;

if (!class_exists($class)) {
$class = new class ($order_method) extends \Tpay\TpayGeneric {
Expand Down
17 changes: 9 additions & 8 deletions includes/TpayLogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,47 +5,48 @@
namespace Tpay;

use Tpay\Vendor\Psr\Log\LoggerInterface;
use Tpay\Vendor\Psr\Log\LogLevel;

class TpayLogger implements LoggerInterface
{
public function emergency($message, array $context = [])
{
// TODO: Implement emergency() method.
$this->log(LogLevel::EMERGENCY, $message, $context);
}

public function alert($message, array $context = [])
{
// TODO: Implement alert() method.
$this->log(LogLevel::ALERT, $message, $context);
}

public function critical($message, array $context = [])
{
// TODO: Implement critical() method.
$this->log(LogLevel::CRITICAL, $message, $context);
}

public function error($message, array $context = [])
{
// TODO: Implement error() method.
$this->log(LogLevel::ERROR, $message, $context);
}

public function warning($message, array $context = [])
{
// TODO: Implement warning() method.
$this->log(LogLevel::WARNING, $message, $context);
}

public function notice($message, array $context = [])
{
// TODO: Implement notice() method.
$this->log(LogLevel::NOTICE, $message, $context);
}

public function info($message, array $context = [])
{
// TODO: Implement info() method.
$this->log(LogLevel::INFO, $message, $context);
}

public function debug($message, array $context = [])
{
// TODO: Implement debug() method.
$this->log(LogLevel::DEBUG, $message, $context);
}

public function log($level, $message, array $context = [])
Expand Down
22 changes: 15 additions & 7 deletions tpay-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ function displayChildPluginNotice()
);
}

function displayConfigPluginNotice()
{
echo sprintf('<div class="error"><p>%s</p></div>', 'Cannot modify wp-config.php, you have to do it manually and add WP_TPAY_HASH and WP_TPAY_BLIK_PREFIX');
}

function childPluginHasParentPlugin()
{
if (is_admin() && current_user_can('activate_plugins')) {
Expand Down Expand Up @@ -188,20 +193,23 @@ function tpay_on_activate()
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;';
$wpdb->get_results($sql);
}

function tpay_config_init()
{
if (file_exists(ABSPATH . "wp-config.php") && is_writable(ABSPATH . "wp-config.php")) {
wp_config_put();
} else {
if (file_exists(dirname(ABSPATH) . "/wp-config.php") && is_writable(dirname(ABSPATH) . "/wp-config.php")) {
wp_config_put('/');
} else {
wc_add_notice(
__(
'Cannot modify wp-config.php, you have to do it manually and add WP_TPAY_HASH and WP_TPAY_BLIK_PREFIX',
'tpay'
),
'error'
);
require_once(ABSPATH . 'wp-admin/includes/plugin.php');
add_action('admin_notices', 'displayConfigPluginNotice');
deactivate_plugins(plugin_basename(__DIR__ . '/tpay.php'));

if (filter_input(INPUT_GET, 'activate')) {
unset($_GET['activate']);
}
}
}
}
Expand Down
6 changes: 4 additions & 2 deletions tpay.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Plugin Name: Tpay Payment Gateway
* Plugin URI: https://tpay.com
* Description: Tpay payment gateway for WooCommerce
* Version: 1.7.9
* Version: 1.7.10
* Author: Krajowy Integrator Płatności S.A.
* Author URI: http://www.tpay.com
* License: LGPL 3.0
Expand Down Expand Up @@ -42,7 +42,7 @@

require_once 'tpay-functions.php';

define('TPAY_PLUGIN_VERSION', '1.7.9');
define('TPAY_PLUGIN_VERSION', '1.7.10');
define('TPAY_PLUGIN_DIR', dirname(plugin_basename(__FILE__)));
add_action('plugins_loaded', 'init_gateway_tpay');
register_activation_hook(__FILE__, 'tpay_on_activate');
Expand Down Expand Up @@ -117,6 +117,8 @@ function (PaymentMethodRegistry $paymentMethodRegistry) {

function init_gateway_tpay()
{
tpay_config_init();

if (!class_exists('WC_Payment_Gateway')) {
childPluginHasParentPlugin();

Expand Down

0 comments on commit 6249bb2

Please sign in to comment.