Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b4c49f3c67 | ||
|
|
4d93d2542d | ||
|
|
e1176b7f67 | ||
|
|
828d70cdd1 | ||
|
|
15ff72afb0 | ||
|
|
ad246ad1bc |
No files matched your search
@@ -6,6 +6,16 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
|
|||||||
|
|
||||||
## Unreleased
|
## Unreleased
|
||||||
|
|
||||||
|
## 3.1 - 2019-01-22
|
||||||
|
|
||||||
|
### Added
|
||||||
|
- WooCommerce events
|
||||||
|
- PHP version and OPcache status information
|
||||||
|
- error message on incomplete install
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- headers error from new line in Server Timing
|
||||||
|
|
||||||
## 3.0.1 - 2019-01-09
|
## 3.0.1 - 2019-01-09
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ Plugin Name: Laps
|
|||||||
Plugin URI: https://github.com/Rarst/laps
|
Plugin URI: https://github.com/Rarst/laps
|
||||||
Description: Light WordPress profiler.
|
Description: Light WordPress profiler.
|
||||||
Author: Andrey “Rarst” Savchenko
|
Author: Andrey “Rarst” Savchenko
|
||||||
Version: 3.0.1
|
Version: 3.1
|
||||||
Author URI: https://www.rarst.net/
|
Author URI: https://www.rarst.net/
|
||||||
Text Domain: laps
|
Text Domain: laps
|
||||||
Domain Path: /lang
|
Domain Path: /lang
|
||||||
@@ -16,6 +16,10 @@ if ( file_exists( __DIR__ . '/vendor/autoload.php' ) ) {
|
|||||||
require __DIR__ . '/vendor/autoload.php';
|
require __DIR__ . '/vendor/autoload.php';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( ! class_exists( '\Rarst\Laps\Plugin' ) ) {
|
||||||
|
trigger_error( 'Laps not fully installed! Please install with Composer or download full release archive.', E_USER_ERROR );
|
||||||
|
}
|
||||||
|
|
||||||
$laps = new \Rarst\Laps\Plugin();
|
$laps = new \Rarst\Laps\Plugin();
|
||||||
|
|
||||||
$laps->run();
|
$laps->run();
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
<?php
|
||||||
|
declare( strict_types=1 );
|
||||||
|
|
||||||
|
namespace Rarst\Laps\Event;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Events for WooCommerce plugin
|
||||||
|
*/
|
||||||
|
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' ],
|
||||||
|
] : [];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -64,7 +64,7 @@ class Server_Timing_Manager {
|
|||||||
$header .= sprintf( '%s;dur=%.2f;desc="%s", ', $record->get_category(), $duration, $record->get_name() );
|
$header .= sprintf( '%s;dur=%.2f;desc="%s", ', $record->get_category(), $duration, $record->get_name() );
|
||||||
}
|
}
|
||||||
|
|
||||||
header( 'Server-Timing: ' . $header );
|
header( 'Server-Timing: ' . preg_replace( '/\R/', '', $header ) );
|
||||||
|
|
||||||
return $input;
|
return $input;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -23,11 +24,12 @@ class Hook_Event_Provider implements ServiceProviderInterface {
|
|||||||
|
|
||||||
$pimple['hook.events'] = function (): array {
|
$pimple['hook.events'] = function (): array {
|
||||||
return [
|
return [
|
||||||
'core' => new Core_Events(),
|
'core' => new Core_Events(),
|
||||||
'genesis' => new Genesis_Events(),
|
'genesis' => new Genesis_Events(),
|
||||||
'hybrid' => new Hybrid_Events(),
|
'hybrid' => new Hybrid_Events(),
|
||||||
'tha' => new THA_Events(),
|
'tha' => new THA_Events(),
|
||||||
'yoast' => new Yoast_Events(),
|
'woocommerce' => new WooCommerce_Events(),
|
||||||
|
'yoast' => new Yoast_Events(),
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,12 +30,19 @@ class Core_Load_Collector implements Record_Collector_Interface {
|
|||||||
|
|
||||||
$request_time = filter_var( $_SERVER['REQUEST_TIME_FLOAT'], FILTER_VALIDATE_FLOAT );
|
$request_time = filter_var( $_SERVER['REQUEST_TIME_FLOAT'], FILTER_VALIDATE_FLOAT );
|
||||||
|
|
||||||
|
$php = 'PHP Load – ' . PHP_VERSION;
|
||||||
|
|
||||||
|
if ( function_exists( 'opcache_get_status' ) ) {
|
||||||
|
$zend_status = opcache_get_status();
|
||||||
|
$php .= empty( $zend_status['opcache_enabled'] ) ? '' : ' – OPcache';
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var float $request_time
|
* @var float $request_time
|
||||||
* @var float $timestart
|
* @var float $timestart
|
||||||
*/
|
*/
|
||||||
return [
|
return [
|
||||||
new Record( 'PHP Load', $request_time, $timestart - $request_time, '', 'php' ),
|
new Record( $php, $request_time, $timestart - $request_time, '', 'php' ),
|
||||||
// TODO This includes network plugins on multisite, need conditional label if Laps is network–activated.
|
// TODO This includes network plugins on multisite, need conditional label if Laps is network–activated.
|
||||||
new Record( 'Core and MU Plugins Load', $timestart, $this->timeload - $timestart, '', 'core' ),
|
new Record( 'Core and MU Plugins Load', $timestart, $this->timeload - $timestart, '', 'core' ),
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -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