Skip to content

Commit

Permalink
remove methods from plugin class
Browse files Browse the repository at this point in the history
  • Loading branch information
mmaymo committed Jul 29, 2021
1 parent dd7fc59 commit 6651151
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 1,240 deletions.
12 changes: 12 additions & 0 deletions mollie-payments-for-woocommerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,13 @@
use Inpsyde\Modularity\Properties\PluginProperties;
use Mollie\WooCommerce\Activation\ActivationModule;
use Mollie\WooCommerce\Activation\ConstraintsChecker;
use Mollie\WooCommerce\Assets\AssetsModule;
use Mollie\WooCommerce\Core\CoreModule;
use Mollie\WooCommerce\Gateway\GatewayModule;
use Mollie\WooCommerce\Gateway\Voucher\VoucherModule;
use Mollie\WooCommerce\Log\LogModule;
use Mollie\WooCommerce\Notice\NoticeModule;
use Mollie\WooCommerce\Settings\SettingsModule;
use Throwable;

require_once(ABSPATH . 'wp-admin/includes/plugin.php');
Expand Down Expand Up @@ -171,6 +177,12 @@ function initialize()
$bootstrap = Package::new($properties);
$bootstrap->boot(
new ActivationModule(),
new CoreModule(),
new AssetsModule(),
new GatewayModule(),
new SettingsModule(),
new LogModule('mollie-payments-for-woocommerce-'),
new NoticeModule(),
new VoucherModule()
);
} catch (Throwable $throwable) {
Expand Down
39 changes: 38 additions & 1 deletion src/Activation/ActivationModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ class ActivationModule implements ExecutableModule
{
use ModuleClassNameIdTrait;

public const DB_VERSION_PARAM_NAME = 'mollie-db-version';
public const PENDING_PAYMENT_DB_TABLE_NAME = 'mollie_pending_payment';
public const DB_VERSION = '1.0';

/**
* @param ContainerInterface $container
*
Expand All @@ -45,12 +49,45 @@ public function run(ContainerInterface $container): bool
'init',
[$this, 'pluginInit']
);

$this->handleTranslations();
$this->mollieWcNoticeApiKeyMissing();
$this->appleValidationFileRewriteRules();
return true;
}

/**
*
*/
public function initDb()
{
global $wpdb;
$wpdb->mollie_pending_payment = $wpdb->prefix . self::PENDING_PAYMENT_DB_TABLE_NAME;
if (get_option(self::DB_VERSION_PARAM_NAME, '') != self::DB_VERSION) {
global $wpdb;
$pendingPaymentConfirmTable = $wpdb->prefix . self::PENDING_PAYMENT_DB_TABLE_NAME;
require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
if ($wpdb->get_var("show tables like '$pendingPaymentConfirmTable'") != $pendingPaymentConfirmTable) {
$sql = "
CREATE TABLE " . $pendingPaymentConfirmTable . " (
id int(11) NOT NULL AUTO_INCREMENT,
post_id bigint NOT NULL,
expired_time int NOT NULL,
PRIMARY KEY id (id)
);";
dbDelta($sql);

/**
* Remove redundant 'DESCRIBE *__mollie_pending_payment' error so it doesn't show up in error logs
*/
global $EZSQL_ERROR;
array_pop($EZSQL_ERROR);
}
update_option(self::DB_VERSION_PARAM_NAME, self::DB_VERSION);
}
}



/**
*
Expand Down Expand Up @@ -156,6 +193,6 @@ public function pluginInit()
false,
dirname(plugin_basename(__FILE__)) . '/languages/'
);
Plugin::init();
$this->initDb();
}
}
Loading

0 comments on commit 6651151

Please sign in to comment.