Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
remcotolsma committed Mar 19, 2024
1 parent 184e206 commit 0e3f020
Show file tree
Hide file tree
Showing 10 changed files with 93 additions and 51 deletions.
4 changes: 2 additions & 2 deletions .wp-env.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
{
"core": null,
"plugins": [
"./tests/wp-env-helper.php",
"pronamic/wp-env-quick-login",
"pronamic/wp-pronamic-pay-test-helper",
"https://downloads.wordpress.org/plugin/woocommerce.zip",
"https://downloads.wordpress.org/plugin/pronamic-client.zip",
"https://downloads.wordpress.org/plugin/pronamic-ideal.zip",
"https://downloads.wordpress.org/plugin/query-monitor.zip",
"https://downloads.wordpress.org/plugin/one-time-login.zip",
"https://downloads.wordpress.org/plugin/wp-plugin-dependencies.zip"
],
"mappings": {
"wp-content/plugins/pronamic-ideal": "../../../",
"wp-content/plugins/pronamic-pay-woocommerce": ".",
"wp-content/plugins/woocommerce-subscriptions": "https://github.com/pronamic/woocommerce-subscriptions/releases/download/v5.4.0/woocommerce-subscriptions-5.4.0.zip"
},
Expand Down
30 changes: 2 additions & 28 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,32 +33,6 @@
{
"type": "composer",
"url": "https://wpackagist.org/"
},
{
"type": "package",
"package": {
"name": "wp-premium/woocommerce-subscriptions",
"version": "3.0.9",
"type": "wordpress-plugin",
"dist": {
"url": "https://github.com/wp-premium/woocommerce-subscriptions/archive/3.0.9.zip",
"type": "zip"
},
"source": {
"url": "https://github.com/wp-premium/woocommerce-subscriptions",
"type": "github",
"reference": "tags/3.0.9"
},
"autoload": {
"classmap": [
"includes/"
],
"exclude-from-classmap": [
"includes/api/legacy/",
"includes/libraries/"
]
}
}
}
],
"config": {
Expand All @@ -73,8 +47,9 @@
},
"require": {
"php": ">=7.4",
"automattic/jetpack-autoloader": "^3.0",
"pronamic/wp-html": "^2.2",
"wp-pay/core": "^4.9"
"wp-pay/core": "^4.15"
},
"require-dev": {
"bamarni/composer-bin-plugin": "^1.4",
Expand All @@ -88,7 +63,6 @@
"roots/wordpress": "^6.0",
"wp-cli/wp-cli": "^2.6",
"wp-phpunit/wp-phpunit": "^6.1",
"wp-premium/woocommerce-subscriptions": "^3.0",
"wpackagist-plugin/woocommerce": "^7.5",
"yoast/phpunit-polyfills": "^1.0",
"yoast/wordpress-seo": "^19.6"
Expand Down
1 change: 1 addition & 0 deletions js/dist/admin.asset.php
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<?php return array('dependencies' => array(), 'version' => '588af650ccb9df87238c');
1 change: 1 addition & 0 deletions js/dist/admin.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 32 additions & 0 deletions js/src/admin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
function test() {
const displayElement = document.getElementById( 'woocommerce_pronamic_pay_ideal_icon_display' );
const iconElement = document.getElementById( 'woocommerce_pronamic_pay_ideal_icon' );

if ( ! displayElement ) {
return;
}

if ( ! iconElement ) {
return;
}

const iconElementRow = iconElement.closest( 'tr' );

if ( ! iconElementRow ) {
return;
}

function update() {
iconElementRow.style.display = ( 'custom' === displayElement.value ) ? '' : 'none';

console.log( iconElementRow.display );
}

displayElement.addEventListener( 'change', function ( event ) {
update();
} );

update();
}

test();
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"eslint-plugin-json": "^3.1.0"
},
"scripts": {
"build": "wp-scripts build ./js/src/index.js --output-path=./js/dist/",
"build": "wp-scripts build ./js/src/index.js ./js/src/admin.js --output-path=./js/dist/",
"lint:js": "wp-scripts lint-js ./js/src",
"start": "wp-scripts start ./js/src/index.js --output-path=./js/dist"
}
Expand Down
10 changes: 9 additions & 1 deletion pronamic-pay-woocommerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,15 @@
if ( ! defined( 'ABSPATH' ) ) {
exit;
}


/**
* Autoload.
*/
require_once __DIR__ . '/vendor/autoload_packages.php';

/**
* Bootstrap.
*/
add_filter(
'pronamic_pay_plugin_integrations',
function ( $integrations ) {
Expand Down
19 changes: 19 additions & 0 deletions src/Extension.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ public function setup() {
* @link https://github.com/pronamic/wp-pronamic-pay-mollie/issues/18#issuecomment-1373362874
*/
\add_action( 'woocommerce_order_status_completed', [ $this, 'trigger_payment_fulfilled_action' ], 10, 2 );

\add_action( 'admin_enqueue_scripts', [ $this, 'register_scripts' ] );
}

/**
Expand Down Expand Up @@ -1437,4 +1439,21 @@ function () use ( $order ) {
'default'
);
}

/**
* Register scripts.
*
* @return void
*/
public function register_scripts() {
$asset_file = include __DIR__ . '/../js/dist/admin.asset.php';

\wp_register_script(
'pronamic-pay-woocommerce-admin',
\plugins_url( '../js/dist/admin.js', __FILE__ ),
$asset_file['dependencies'],
$asset_file['version'],
true
);
}
}
26 changes: 26 additions & 0 deletions src/Gateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,21 @@ public function init_form_fields() {
),
'default' => '',
],
'icon_display' => [
'title' => __( 'Icon display', 'pronamic_ideal' ),
'type' => 'select',
'options' => [
'default' => 'default',
'none' => 'none',
'custom' => 'custom',
],
'description' => sprintf(
'%s%s',
$description_prefix,
__( 'This controls the icon which the user sees during checkout.', 'pronamic_ideal' )
),
'default' => '',
],
'icon' => [
'title' => __( 'Icon', 'pronamic_ideal' ),
'type' => 'text',
Expand Down Expand Up @@ -332,6 +347,17 @@ public function init_form_fields() {
}
}

/**
* Admin options.
*
* @return void
*/
public function admin_options() {
parent::admin_options();

\wp_enqueue_script( 'pronamic-pay-woocommerce-admin' );
}

/**
* Process the payment and return the result.
*
Expand Down
19 changes: 0 additions & 19 deletions tests/wp-env-helper.php

This file was deleted.

0 comments on commit 0e3f020

Please sign in to comment.