1 parent
ad246ad1bc
commit
15ff72afb0
4 files changed
+43
No files matched your search
@@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
|
|||||||
|
|
||||||
## Unreleased
|
## Unreleased
|
||||||
|
|
||||||
|
### Added
|
||||||
|
- WooCommerce events
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
- headers error from new line in Server Timing
|
- headers error from new line in Server Timing
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,24 @@
|
|||||||
|
<?php
|
||||||
|
declare( strict_types=1 );
|
||||||
|
|
||||||
|
namespace Rarst\Laps\Event;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Events for Yoast plugins
|
||||||
|
*/
|
||||||
|
class WooCommerce_Events implements Hook_Event_Config_Interface {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function get_events(): array {
|
||||||
|
|
||||||
|
return class_exists( 'WooCommerce' ) ? [
|
||||||
|
[ 'WooCommerce Init', 'plugin', 'before_woocommerce_init', 'woocommerce_init' ],
|
||||||
|
[ 'WooCommerce Shop Loop', 'plugin', 'woocommerce_before_shop_loop', 'woocommerce_after_shop_loop' ],
|
||||||
|
[ 'WooCommerce Single Product', 'plugin', 'woocommerce_before_single_product', 'woocommerce_after_single_product' ],
|
||||||
|
[ 'WooCommerce Cart', 'plugin', 'woocommerce_before_cart', 'woocommerce_after_cart' ],
|
||||||
|
[ 'WooCommerce Checkout', 'plugin', 'woocommerce_before_checkout_form', 'woocommerce_after_checkout_form' ],
|
||||||
|
] : [];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -9,6 +9,7 @@ use Rarst\Laps\Event\Core_Events;
|
|||||||
use Rarst\Laps\Event\Genesis_Events;
|
use Rarst\Laps\Event\Genesis_Events;
|
||||||
use Rarst\Laps\Event\Hybrid_Events;
|
use Rarst\Laps\Event\Hybrid_Events;
|
||||||
use Rarst\Laps\Event\THA_Events;
|
use Rarst\Laps\Event\THA_Events;
|
||||||
|
use Rarst\Laps\Event\WooCommerce_Events;
|
||||||
use Rarst\Laps\Event\Yoast_Events;
|
use Rarst\Laps\Event\Yoast_Events;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -27,6 +28,7 @@ class Hook_Event_Provider implements ServiceProviderInterface {
|
|||||||
'genesis' => new Genesis_Events(),
|
'genesis' => new Genesis_Events(),
|
||||||
'hybrid' => new Hybrid_Events(),
|
'hybrid' => new Hybrid_Events(),
|
||||||
'tha' => new THA_Events(),
|
'tha' => new THA_Events(),
|
||||||
|
'woocommerce' => new WooCommerce_Events(),
|
||||||
'yoast' => new Yoast_Events(),
|
'yoast' => new Yoast_Events(),
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ use Rarst\Laps\Event\Core_Events;
|
|||||||
use Rarst\Laps\Event\Genesis_Events;
|
use Rarst\Laps\Event\Genesis_Events;
|
||||||
use Rarst\Laps\Event\Hybrid_Events;
|
use Rarst\Laps\Event\Hybrid_Events;
|
||||||
use Rarst\Laps\Event\THA_Events;
|
use Rarst\Laps\Event\THA_Events;
|
||||||
|
use Rarst\Laps\Event\WooCommerce_Events;
|
||||||
use Rarst\Laps\Event\Yoast_Events;
|
use Rarst\Laps\Event\Yoast_Events;
|
||||||
use Rarst\Laps\Tests\LapsTestCase;
|
use Rarst\Laps\Tests\LapsTestCase;
|
||||||
|
|
||||||
@@ -62,6 +63,19 @@ class EventTest extends LapsTestCase {
|
|||||||
$this->assertNotEmpty( $events );
|
$this->assertNotEmpty( $events );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testWooCommerce() {
|
||||||
|
|
||||||
|
$woocommerce = new WooCommerce_Events();
|
||||||
|
$this->assertEmpty( $woocommerce->get_events() );
|
||||||
|
|
||||||
|
$this->getMockBuilder( 'WooCommerce' )->allowMockingUnknownTypes()->getMock();
|
||||||
|
|
||||||
|
$events = $woocommerce->get_events();
|
||||||
|
|
||||||
|
$this->assertInternalType( 'array', $events );
|
||||||
|
$this->assertNotEmpty( $events );
|
||||||
|
}
|
||||||
|
|
||||||
public function testYoast() {
|
public function testYoast() {
|
||||||
|
|
||||||
$yoast = new Yoast_Events();
|
$yoast = new Yoast_Events();
|
||||||
|
|||||||
Reference in new issue
Block a user