Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c1a389dc17 | ||
|
|
d724958dec | ||
|
|
950031bbaf | ||
|
|
b173364ce2 | ||
|
|
df8c9b1678 | ||
|
|
5356df262f | ||
|
|
df0504f176 | ||
|
|
960efd86ba | ||
|
|
eeb8de17d0 | ||
|
|
6c9042e253 | ||
|
|
d7af14e504 | ||
|
|
68f2813e9c | ||
|
|
2f332c51cc | ||
|
|
961019ef74 | ||
|
|
fb144ebe01 | ||
|
|
e1b2bd3d40 | ||
|
|
2ded7a3412 | ||
|
|
7d64b920eb | ||
|
|
fcf17e44d4 | ||
|
|
355532fa72 | ||
|
|
ed2a53a33d | ||
|
|
b940fd522f | ||
|
|
aca045b5aa | ||
|
|
3eb2a91940 | ||
|
|
eb573e143e | ||
|
|
63f1b9e216 | ||
|
|
7412da0741 | ||
|
|
bf4ca812aa | ||
|
|
9301c8256d | ||
|
|
2cb708f70d | ||
|
|
4166802c89 | ||
|
|
78cbb85de8 | ||
|
|
c23531e890 | ||
|
|
70de78b276 | ||
|
|
4013046e4f | ||
|
|
204c1df755 | ||
|
|
cd55061e69 | ||
|
|
9fee649a64 | ||
|
|
a2d92585ac | ||
|
|
e4af00b43e | ||
|
|
20b2a767f3 | ||
|
|
4dbcddad8d | ||
|
|
5ee99cddd4 | ||
|
|
1f85d65b9b | ||
|
|
1e3195ffc8 | ||
|
|
30db67c055 | ||
|
|
79ed1ffcfd | ||
|
|
6818236f83 |
No files matched your search
@@ -6,6 +6,31 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
|
|||||||
|
|
||||||
## Unreleased
|
## Unreleased
|
||||||
|
|
||||||
|
## 3.0.1 - 2019-01-09
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- fatal error when HTTP request is pre–filtered
|
||||||
|
|
||||||
|
## 3.0 - 2018-12-28
|
||||||
|
|
||||||
|
### Added
|
||||||
|
- call backtraces to SQL records and HTTP calls
|
||||||
|
- new format of hook events
|
||||||
|
- sidebar tracking
|
||||||
|
- list of callbacks to hook events
|
||||||
|
- Server Timing output for Ajax and REST APIs
|
||||||
|
- lazy records collector to pass around instead of whole container
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
- required PHP version to 7.1
|
||||||
|
- organization and names for Record classes
|
||||||
|
|
||||||
|
### Deprecated
|
||||||
|
- old format of hook events
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- error when no SQL queries logged by core
|
||||||
|
|
||||||
## 2.0 - 2018-02-26
|
## 2.0 - 2018-02-26
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|||||||
@@ -1,4 +1,9 @@
|
|||||||
|

|
||||||
|
|
||||||
# Laps — light WordPress profiler
|
# Laps — light WordPress profiler
|
||||||
|
|
||||||
|
_Make a site, make it fast._
|
||||||
|
|
||||||
[](https://scrutinizer-ci.com/g/Rarst/laps/?branch=master)
|
[](https://scrutinizer-ci.com/g/Rarst/laps/?branch=master)
|
||||||
[](https://scrutinizer-ci.com/g/Rarst/laps/build-status/master)
|
[](https://scrutinizer-ci.com/g/Rarst/laps/build-status/master)
|
||||||
[](https://scrutinizer-ci.com/g/Rarst/laps/?branch=master)
|
[](https://scrutinizer-ci.com/g/Rarst/laps/?branch=master)
|
||||||
@@ -6,36 +11,36 @@
|
|||||||
[](https://packagist.org/packages/rarst/laps)
|
[](https://packagist.org/packages/rarst/laps)
|
||||||
[](https://packagist.org/packages/rarst/laps)
|
[](https://packagist.org/packages/rarst/laps)
|
||||||
[](https://github.com/php-pds/skeleton)
|
[](https://github.com/php-pds/skeleton)
|
||||||
|
[](https://www.rarst.net/download/laps)
|
||||||
_Make a site, make it fast._
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
Laps is a plugin that **shows performance information** about WordPress page load.
|
Laps is a plugin that **shows performance information** about WordPress page load.
|
||||||
|
|
||||||
It provides a visual summary in toolbar that is quick and easy to inspect.
|
It provides a visual summary in toolbar that is quick and easy to inspect.
|
||||||
|
|
||||||
Laps tracks many events, such as:
|
## Page profiling
|
||||||
- PHP, core, plugins, and themes load
|
|
||||||
|
Laps automatically tracks many events, such as:
|
||||||
|
- PHP, core, plugins, and themes load, main posts loop, sidebars
|
||||||
- database queries (with [`SAVEQUERIES` constant](http://codex.wordpress.org/Editing_wp-config.php#Save_queries_for_analysis) enabled)
|
- database queries (with [`SAVEQUERIES` constant](http://codex.wordpress.org/Editing_wp-config.php#Save_queries_for_analysis) enabled)
|
||||||
- network requests to other sites
|
- network requests to other sites
|
||||||
- main posts loop
|
|
||||||
- events for supported theme frameworks:
|
## API profiling
|
||||||
- [Theme Hook Alliance](http://zamoose.github.io/themehookalliance/)
|
|
||||||
- [Hybrid](http://themehybrid.com/)
|
For Ajax and REST API — Laps outputs performance information by Server Timing API, for use with clients such as Chrome Dev Tools.
|
||||||
- [Genesis](http://my.studiopress.com/themes/genesis/)
|
|
||||||
- events for supported plugins:
|

|
||||||
- [Yoast SEO](https://wordpress.org/plugins/wordpress-seo/)
|
|
||||||
|
### API authentication
|
||||||
|
|
||||||
|
API requests need to be authenticated as admin for performance data to be sent. For Ajax requests cookies are sufficient. REST API requests also [need nonce passed](https://developer.wordpress.org/rest-api/using-the-rest-api/authentication/#cookie-authentication).
|
||||||
|
|
||||||
|
`laps_can_see` check can be filtered to relax required permissions on the plugin’s side.
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
Require with [Composer](https://getcomposer.org/):
|
| [Composer](https://getcomposer.org/) (recommended) | Release archive |
|
||||||
|
| -------------------------------------------------- | -------- |
|
||||||
```bash
|
| `composer require rarst/laps` | [](https://www.rarst.net/download/laps) |
|
||||||
composer require rarst/laps
|
|
||||||
```
|
|
||||||
|
|
||||||
Or download plugin archive from [releases section](https://github.com/Rarst/laps/releases).
|
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
|
|||||||
+19
-5
@@ -25,15 +25,29 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"require" : {
|
"require" : {
|
||||||
"php" : ">=5.6",
|
"php" : "^7.1.3",
|
||||||
"composer/installers": "~1.0",
|
"composer/installers": "^1.6",
|
||||||
"symfony/stopwatch" : "^3.4.4",
|
"symfony/stopwatch" : "^4.2.1",
|
||||||
"mustache/mustache" : "~2.4",
|
"mustache/mustache" : "^2.12",
|
||||||
"pimple/pimple" : "^3.2.3"
|
"pimple/pimple" : "^3.2.3"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"twbs/bootstrap": "~3.2",
|
"twbs/bootstrap": "^3.4",
|
||||||
"brain/monkey" : "^2.2",
|
"brain/monkey" : "^2.2",
|
||||||
"pds/skeleton": "^1.0"
|
"pds/skeleton": "^1.0"
|
||||||
|
},
|
||||||
|
"extra" : {
|
||||||
|
"light-ignore-plugin": {
|
||||||
|
"mustache/mustache": [
|
||||||
|
"test"
|
||||||
|
],
|
||||||
|
"pimple/pimple" : [
|
||||||
|
"ext",
|
||||||
|
"src/Pimple/Tests"
|
||||||
|
],
|
||||||
|
"symfony/stopwatch": [
|
||||||
|
"Tests"
|
||||||
|
]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Generated
+101
-32
@@ -1,23 +1,23 @@
|
|||||||
{
|
{
|
||||||
"_readme": [
|
"_readme": [
|
||||||
"This file locks the dependencies of your project to a known state",
|
"This file locks the dependencies of your project to a known state",
|
||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"content-hash": "b88211148a5c0893e190e574ac18bd30",
|
"content-hash": "185526a596d05cc666426641f175a314",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "composer/installers",
|
"name": "composer/installers",
|
||||||
"version": "v1.5.0",
|
"version": "v1.6.0",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/composer/installers.git",
|
"url": "https://github.com/composer/installers.git",
|
||||||
"reference": "049797d727261bf27f2690430d935067710049c2"
|
"reference": "cfcca6b1b60bc4974324efb5783c13dca6932b5b"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/composer/installers/zipball/049797d727261bf27f2690430d935067710049c2",
|
"url": "https://api.github.com/repos/composer/installers/zipball/cfcca6b1b60bc4974324efb5783c13dca6932b5b",
|
||||||
"reference": "049797d727261bf27f2690430d935067710049c2",
|
"reference": "cfcca6b1b60bc4974324efb5783c13dca6932b5b",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
@@ -124,7 +124,7 @@
|
|||||||
"zend",
|
"zend",
|
||||||
"zikula"
|
"zikula"
|
||||||
],
|
],
|
||||||
"time": "2017-12-29T09:13:20+00:00"
|
"time": "2018-08-27T06:10:37+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "mustache/mustache",
|
"name": "mustache/mustache",
|
||||||
@@ -272,26 +272,95 @@
|
|||||||
"time": "2017-02-14T16:28:37+00:00"
|
"time": "2017-02-14T16:28:37+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "symfony/stopwatch",
|
"name": "symfony/contracts",
|
||||||
"version": "v3.4.4",
|
"version": "v1.0.2",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/symfony/stopwatch.git",
|
"url": "https://github.com/symfony/contracts.git",
|
||||||
"reference": "c865551df7c17e63fc1f09f763db04387f91ae4d"
|
"reference": "1aa7ab2429c3d594dd70689604b5cf7421254cdf"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/symfony/stopwatch/zipball/c865551df7c17e63fc1f09f763db04387f91ae4d",
|
"url": "https://api.github.com/repos/symfony/contracts/zipball/1aa7ab2429c3d594dd70689604b5cf7421254cdf",
|
||||||
"reference": "c865551df7c17e63fc1f09f763db04387f91ae4d",
|
"reference": "1aa7ab2429c3d594dd70689604b5cf7421254cdf",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
"php": "^5.5.9|>=7.0.8"
|
"php": "^7.1.3"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"psr/cache": "^1.0",
|
||||||
|
"psr/container": "^1.0"
|
||||||
|
},
|
||||||
|
"suggest": {
|
||||||
|
"psr/cache": "When using the Cache contracts",
|
||||||
|
"psr/container": "When using the Service contracts",
|
||||||
|
"symfony/cache-contracts-implementation": "",
|
||||||
|
"symfony/service-contracts-implementation": "",
|
||||||
|
"symfony/translation-contracts-implementation": ""
|
||||||
},
|
},
|
||||||
"type": "library",
|
"type": "library",
|
||||||
"extra": {
|
"extra": {
|
||||||
"branch-alias": {
|
"branch-alias": {
|
||||||
"dev-master": "3.4-dev"
|
"dev-master": "1.0-dev"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"Symfony\\Contracts\\": ""
|
||||||
|
},
|
||||||
|
"exclude-from-classmap": [
|
||||||
|
"**/Tests/"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Nicolas Grekas",
|
||||||
|
"email": "p@tchwork.com"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Symfony Community",
|
||||||
|
"homepage": "https://symfony.com/contributors"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "A set of abstractions extracted out of the Symfony components",
|
||||||
|
"homepage": "https://symfony.com",
|
||||||
|
"keywords": [
|
||||||
|
"abstractions",
|
||||||
|
"contracts",
|
||||||
|
"decoupling",
|
||||||
|
"interfaces",
|
||||||
|
"interoperability",
|
||||||
|
"standards"
|
||||||
|
],
|
||||||
|
"time": "2018-12-05T08:06:11+00:00"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "symfony/stopwatch",
|
||||||
|
"version": "v4.2.1",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/symfony/stopwatch.git",
|
||||||
|
"reference": "ec076716412274e51f8a7ea675d9515e5c311123"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/symfony/stopwatch/zipball/ec076716412274e51f8a7ea675d9515e5c311123",
|
||||||
|
"reference": "ec076716412274e51f8a7ea675d9515e5c311123",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"php": "^7.1.3",
|
||||||
|
"symfony/contracts": "^1.0"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"extra": {
|
||||||
|
"branch-alias": {
|
||||||
|
"dev-master": "4.2-dev"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
@@ -318,7 +387,7 @@
|
|||||||
],
|
],
|
||||||
"description": "Symfony Stopwatch Component",
|
"description": "Symfony Stopwatch Component",
|
||||||
"homepage": "https://symfony.com",
|
"homepage": "https://symfony.com",
|
||||||
"time": "2018-01-03T07:37:34+00:00"
|
"time": "2018-11-11T19:52:12+00:00"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"packages-dev": [
|
"packages-dev": [
|
||||||
@@ -477,16 +546,16 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "mockery/mockery",
|
"name": "mockery/mockery",
|
||||||
"version": "1.0",
|
"version": "1.2.0",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/mockery/mockery.git",
|
"url": "https://github.com/mockery/mockery.git",
|
||||||
"reference": "1bac8c362b12f522fdd1f1fa3556284c91affa38"
|
"reference": "100633629bf76d57430b86b7098cd6beb996a35a"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/mockery/mockery/zipball/1bac8c362b12f522fdd1f1fa3556284c91affa38",
|
"url": "https://api.github.com/repos/mockery/mockery/zipball/100633629bf76d57430b86b7098cd6beb996a35a",
|
||||||
"reference": "1bac8c362b12f522fdd1f1fa3556284c91affa38",
|
"reference": "100633629bf76d57430b86b7098cd6beb996a35a",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
@@ -495,7 +564,7 @@
|
|||||||
"php": ">=5.6.0"
|
"php": ">=5.6.0"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"phpunit/phpunit": "~5.7|~6.1"
|
"phpunit/phpunit": "~5.7.10|~6.5|~7.0"
|
||||||
},
|
},
|
||||||
"type": "library",
|
"type": "library",
|
||||||
"extra": {
|
"extra": {
|
||||||
@@ -524,8 +593,8 @@
|
|||||||
"homepage": "http://davedevelopment.co.uk"
|
"homepage": "http://davedevelopment.co.uk"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"description": "Mockery is a simple yet flexible PHP mock object framework for use in unit testing with PHPUnit, PHPSpec or any other testing framework. Its core goal is to offer a test double framework with a succinct API capable of clearly defining all possible object operations and interactions using a human readable Domain Specific Language (DSL). Designed as a drop in alternative to PHPUnit's phpunit-mock-objects library, Mockery is easy to integrate with PHPUnit and can operate alongside phpunit-mock-objects without the World ending.",
|
"description": "Mockery is a simple yet flexible PHP mock object framework",
|
||||||
"homepage": "http://github.com/mockery/mockery",
|
"homepage": "https://github.com/mockery/mockery",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"BDD",
|
"BDD",
|
||||||
"TDD",
|
"TDD",
|
||||||
@@ -538,7 +607,7 @@
|
|||||||
"test double",
|
"test double",
|
||||||
"testing"
|
"testing"
|
||||||
],
|
],
|
||||||
"time": "2017-10-06T16:20:43+00:00"
|
"time": "2018-10-02T21:52:37+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "pds/skeleton",
|
"name": "pds/skeleton",
|
||||||
@@ -573,16 +642,16 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "twbs/bootstrap",
|
"name": "twbs/bootstrap",
|
||||||
"version": "v3.3.7",
|
"version": "v3.4.0",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/twbs/bootstrap.git",
|
"url": "https://github.com/twbs/bootstrap.git",
|
||||||
"reference": "0b9c4a4007c44201dce9a6cc1a38407005c26c86"
|
"reference": "4c547f2175b9a05aa43551f6927da83fe249ce42"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/twbs/bootstrap/zipball/0b9c4a4007c44201dce9a6cc1a38407005c26c86",
|
"url": "https://api.github.com/repos/twbs/bootstrap/zipball/4c547f2175b9a05aa43551f6927da83fe249ce42",
|
||||||
"reference": "0b9c4a4007c44201dce9a6cc1a38407005c26c86",
|
"reference": "4c547f2175b9a05aa43551f6927da83fe249ce42",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"replace": {
|
"replace": {
|
||||||
@@ -591,7 +660,7 @@
|
|||||||
"type": "library",
|
"type": "library",
|
||||||
"extra": {
|
"extra": {
|
||||||
"branch-alias": {
|
"branch-alias": {
|
||||||
"dev-master": "3.3.x-dev"
|
"dev-master": "3.4.x-dev"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"notification-url": "https://packagist.org/downloads/",
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
@@ -609,7 +678,7 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"description": "The most popular front-end framework for developing responsive, mobile first projects on the web.",
|
"description": "The most popular front-end framework for developing responsive, mobile first projects on the web.",
|
||||||
"homepage": "http://getbootstrap.com",
|
"homepage": "https://getbootstrap.com/",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"JS",
|
"JS",
|
||||||
"css",
|
"css",
|
||||||
@@ -620,7 +689,7 @@
|
|||||||
"responsive",
|
"responsive",
|
||||||
"web"
|
"web"
|
||||||
],
|
],
|
||||||
"time": "2016-07-25T15:51:55+00:00"
|
"time": "2018-12-13T23:45:51+00:00"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"aliases": [],
|
"aliases": [],
|
||||||
@@ -629,7 +698,7 @@
|
|||||||
"prefer-stable": false,
|
"prefer-stable": false,
|
||||||
"prefer-lowest": false,
|
"prefer-lowest": false,
|
||||||
"platform": {
|
"platform": {
|
||||||
"php": ">=5.6"
|
"php": "^7.1.3"
|
||||||
},
|
},
|
||||||
"platform-dev": []
|
"platform-dev": []
|
||||||
}
|
}
|
||||||
@@ -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: 2.0
|
Version: 3.0.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
|
||||||
|
|||||||
@@ -0,0 +1,43 @@
|
|||||||
|
<?xml version="1.0"?>
|
||||||
|
<psalm
|
||||||
|
totallyTyped="true"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xmlns="https://getpsalm.org/schema/config"
|
||||||
|
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
|
||||||
|
>
|
||||||
|
<projectFiles>
|
||||||
|
<directory name="src"/>
|
||||||
|
<ignoreFiles>
|
||||||
|
<directory name="vendor"/>
|
||||||
|
<directory name="src/mustache/cache"/>
|
||||||
|
</ignoreFiles>
|
||||||
|
</projectFiles>
|
||||||
|
|
||||||
|
<issueHandlers>
|
||||||
|
<LessSpecificReturnType errorLevel="info"/>
|
||||||
|
<UndefinedFunction errorLevel="suppress"/>
|
||||||
|
<UndefinedClass>
|
||||||
|
<errorLevel type="suppress">
|
||||||
|
<referencedClass name="WP_Admin_Bar"/>
|
||||||
|
<referencedClass name="WP_Error"/>
|
||||||
|
<referencedClass name="WP_Hook"/>
|
||||||
|
</errorLevel>
|
||||||
|
</UndefinedClass>
|
||||||
|
<MixedArgument>
|
||||||
|
<errorLevel type="suppress">
|
||||||
|
<file name="src/Provider/Record_Provider.php" />
|
||||||
|
<file name="src/Record/Collector/Hook_Collector.php" />
|
||||||
|
</errorLevel>
|
||||||
|
</MixedArgument>
|
||||||
|
<MissingClosureParamType>
|
||||||
|
<errorLevel type="suppress">
|
||||||
|
<file name="src/Record/Collector/Hook_Collector.php" />
|
||||||
|
</errorLevel>
|
||||||
|
</MissingClosureParamType>
|
||||||
|
<MissingClosureReturnType>
|
||||||
|
<errorLevel type="suppress">
|
||||||
|
<file name="src/Record/Collector/Hook_Collector.php" />
|
||||||
|
</errorLevel>
|
||||||
|
</MissingClosureReturnType>
|
||||||
|
</issueHandlers>
|
||||||
|
</psalm>
|
||||||
+32
-29
@@ -17,9 +17,9 @@
|
|||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
#wpadminbar .laps-timeline {
|
#wpadminbar .laps-timeline {
|
||||||
overflow: hidden;
|
|
||||||
height: 20px;
|
height: 20px;
|
||||||
margin-bottom: 20px;
|
margin-bottom: 20px;
|
||||||
|
overflow: hidden;
|
||||||
background-color: #f5f5f5;
|
background-color: #f5f5f5;
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
-webkit-box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1);
|
-webkit-box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1);
|
||||||
@@ -70,8 +70,8 @@
|
|||||||
position: absolute;
|
position: absolute;
|
||||||
width: 1px;
|
width: 1px;
|
||||||
height: 1px;
|
height: 1px;
|
||||||
margin: -1px;
|
|
||||||
padding: 0;
|
padding: 0;
|
||||||
|
margin: -1px;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
clip: rect(0, 0, 0, 0);
|
clip: rect(0, 0, 0, 0);
|
||||||
border: 0;
|
border: 0;
|
||||||
@@ -82,57 +82,42 @@
|
|||||||
display: block;
|
display: block;
|
||||||
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
|
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
|
||||||
font-style: normal;
|
font-style: normal;
|
||||||
font-weight: normal;
|
font-weight: 400;
|
||||||
letter-spacing: normal;
|
|
||||||
line-break: auto;
|
|
||||||
line-height: 1.42857143;
|
line-height: 1.42857143;
|
||||||
|
line-break: auto;
|
||||||
text-align: left;
|
text-align: left;
|
||||||
text-align: start;
|
text-align: start;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
text-shadow: none;
|
text-shadow: none;
|
||||||
text-transform: none;
|
text-transform: none;
|
||||||
white-space: normal;
|
letter-spacing: normal;
|
||||||
word-break: normal;
|
word-break: normal;
|
||||||
word-spacing: normal;
|
word-spacing: normal;
|
||||||
word-wrap: normal;
|
word-wrap: normal;
|
||||||
|
white-space: normal;
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
opacity: 0;
|
|
||||||
filter: alpha(opacity=0);
|
filter: alpha(opacity=0);
|
||||||
|
opacity: 0;
|
||||||
}
|
}
|
||||||
#wpadminbar .tooltip.in {
|
#wpadminbar .tooltip.in {
|
||||||
opacity: 0.9;
|
|
||||||
filter: alpha(opacity=90);
|
filter: alpha(opacity=90);
|
||||||
|
opacity: 0.9;
|
||||||
}
|
}
|
||||||
#wpadminbar .tooltip.top {
|
#wpadminbar .tooltip.top {
|
||||||
margin-top: -3px;
|
|
||||||
padding: 5px 0;
|
padding: 5px 0;
|
||||||
|
margin-top: -3px;
|
||||||
}
|
}
|
||||||
#wpadminbar .tooltip.right {
|
#wpadminbar .tooltip.right {
|
||||||
margin-left: 3px;
|
|
||||||
padding: 0 5px;
|
padding: 0 5px;
|
||||||
|
margin-left: 3px;
|
||||||
}
|
}
|
||||||
#wpadminbar .tooltip.bottom {
|
#wpadminbar .tooltip.bottom {
|
||||||
margin-top: 3px;
|
|
||||||
padding: 5px 0;
|
padding: 5px 0;
|
||||||
|
margin-top: 3px;
|
||||||
}
|
}
|
||||||
#wpadminbar .tooltip.left {
|
#wpadminbar .tooltip.left {
|
||||||
margin-left: -3px;
|
|
||||||
padding: 0 5px;
|
padding: 0 5px;
|
||||||
}
|
margin-left: -3px;
|
||||||
#wpadminbar .tooltip-inner {
|
|
||||||
max-width: 300px;
|
|
||||||
padding: 3px 8px;
|
|
||||||
color: #eee;
|
|
||||||
text-align: center;
|
|
||||||
background-color: #464646;
|
|
||||||
border-radius: 4px;
|
|
||||||
}
|
|
||||||
#wpadminbar .tooltip-arrow {
|
|
||||||
position: absolute;
|
|
||||||
width: 0;
|
|
||||||
height: 0;
|
|
||||||
border-color: transparent;
|
|
||||||
border-style: solid;
|
|
||||||
}
|
}
|
||||||
#wpadminbar .tooltip.top .tooltip-arrow {
|
#wpadminbar .tooltip.top .tooltip-arrow {
|
||||||
bottom: 0;
|
bottom: 0;
|
||||||
@@ -142,8 +127,8 @@
|
|||||||
border-top-color: #464646;
|
border-top-color: #464646;
|
||||||
}
|
}
|
||||||
#wpadminbar .tooltip.top-left .tooltip-arrow {
|
#wpadminbar .tooltip.top-left .tooltip-arrow {
|
||||||
bottom: 0;
|
|
||||||
right: 5px;
|
right: 5px;
|
||||||
|
bottom: 0;
|
||||||
margin-bottom: -5px;
|
margin-bottom: -5px;
|
||||||
border-width: 5px 5px 0;
|
border-width: 5px 5px 0;
|
||||||
border-top-color: #464646;
|
border-top-color: #464646;
|
||||||
@@ -190,12 +175,30 @@
|
|||||||
border-width: 0 5px 5px;
|
border-width: 0 5px 5px;
|
||||||
border-bottom-color: #464646;
|
border-bottom-color: #464646;
|
||||||
}
|
}
|
||||||
|
#wpadminbar .tooltip-inner {
|
||||||
|
max-width: 300px;
|
||||||
|
padding: 3px 8px;
|
||||||
|
color: #eee;
|
||||||
|
text-align: center;
|
||||||
|
background-color: #464646;
|
||||||
|
border-radius: 4px;
|
||||||
|
}
|
||||||
|
#wpadminbar .tooltip-arrow {
|
||||||
|
position: absolute;
|
||||||
|
width: 0;
|
||||||
|
height: 0;
|
||||||
|
border-color: transparent;
|
||||||
|
border-style: solid;
|
||||||
|
}
|
||||||
#wpadminbar .tooltip.in {
|
#wpadminbar .tooltip.in {
|
||||||
opacity: 1;
|
|
||||||
filter: alpha(opacity=100);
|
filter: alpha(opacity=100);
|
||||||
|
opacity: 1;
|
||||||
}
|
}
|
||||||
#wpadminbar .tooltip-inner {
|
#wpadminbar .tooltip-inner {
|
||||||
line-height: 20px;
|
line-height: 20px;
|
||||||
text-align: left;
|
text-align: left;
|
||||||
}
|
}
|
||||||
|
#wpadminbar .tooltip-inner br {
|
||||||
|
line-height: inherit;
|
||||||
|
}
|
||||||
/*# sourceMappingURL=laps.css.map */
|
/*# sourceMappingURL=laps.css.map */
|
||||||
@@ -1 +1 @@
|
|||||||
{"version":3,"sources":["laps.less","C:/server/www/dev/wp-content/plugins/laps/vendor/twbs/bootstrap/less/progress-bars.less","C:/server/www/dev/wp-content/plugins/laps/vendor/twbs/bootstrap/less/mixins/vendor-prefixes.less","C:/server/www/dev/wp-content/plugins/laps/vendor/twbs/bootstrap/less/scaffolding.less","C:/server/www/dev/wp-content/plugins/laps/vendor/twbs/bootstrap/less/tooltip.less","C:/server/www/dev/wp-content/plugins/laps/vendor/twbs/bootstrap/less/mixins/reset-text.less","C:/server/www/dev/wp-content/plugins/laps/vendor/twbs/bootstrap/less/variables.less","C:/server/www/dev/wp-content/plugins/laps/vendor/twbs/bootstrap/less/mixins/opacity.less"],"names":[],"mappings":"AAMA,WAEC,mBAEC;EACC,cAAA;EACA,UAAA;EACA,eAAA;EACA,QAAA;;AARH,WAEC,mBASC;EACC,UAAA;;AAZH,WAgBC;EAEC,eAAA;;AAEA,WAJD,0BAIE;EACA,6BAAA;;AArBH,WAgBC,0BAQC;EACC,aAAA;;AAzBH,WA6BC;ECTC,gBAAA;EACA,YAAA;EACA,mBAAA;EACA,yBAAA;EACA,kBAAA;ECsCA,sDAAA;EACQ,8CAAA;EFhCR,aAAA;EACA,kBAAA;;AAhCF,WA6BC,eAKC;ECJA,WAAA;EACA,SAAA;EACA,YAAA;EACA,eAAA;EACA,iBAAA;EACA,WAAA;EACA,kBAAA;EACA,yBAAA;ECyBA,sDAAA;EACQ,8CAAA;EAyHR,mCAAA;EACK,8BAAA;EACG,2BAAA;EFtJP,kBAAA;EACA,8BAAA;EACA,cAAA;;AAtCH,WA6BC,eAYC;EACC,yBAAA;;AA1CH,WA6BC,eAeC;EACC,yBAAA;;AA7CH,WA6BC,eAkBC;EACC,yBAAA;;AAhDH,WA6BC,eAqBC;EACC,yBAAA;;AAnDH,WA6BC,eAwBC;EACC,yBAAA;;AAtDH,WA6BC,eA2BC;EACC,yBAAA;;AAzDH,WA6BC,eA8BC;EACC,yBAAA;;AA5DH,WA6BC,eAkCC;EGwDA,kBAAA;EACA,UAAA;EACA,WAAA;EACA,YAAA;EACA,UAAA;EACA,gBAAA;EACA,MAAM,gBAAN;EACA,SAAA;;AH9HF,WIAA;EACE,kBAAA;EACA,eAAA;EACA,cAAA;ECRA,aC2CwB,8CD3CxB;EAEA,kBAAA;EACA,mBAAA;EACA,sBAAA;EACA,gBAAA;EACA,uBAAA;EACA,gBAAA;EACA,iBAAA;EACA,qBAAA;EACA,iBAAA;EACA,oBAAA;EACA,mBAAA;EACA,kBAAA;EACA,oBAAA;EACA,iBAAA;EDHA,eAAA;EGVA,UAAA;EAGA,wBAAA;;AHWA,WAXF,SAWG;EGdD,YAAA;EAGA,yBAAA;;AHYA,WAZF,SAYG;EAAU,gBAAA;EAAmB,cAAA;;AAC9B,WAbF,SAaG;EAAU,gBAAA;EAAmB,cAAA;;AAC9B,WAdF,SAcG;EAAU,eAAA;EAAmB,cAAA;;AAC9B,WAfF,SAeG;EAAU,iBAAA;EAAmB,cAAA;;AJfhC,WImBA;EACE,gBAAA;EACA,gBAAA;EACA,WAAA;EACA,kBAAA;EACA,yBAAA;EACA,kBAAA;;AJzBF,WI6BA;EACE,kBAAA;EACA,QAAA;EACA,SAAA;EACA,yBAAA;EACA,mBAAA;;AAIA,WADF,SACG,IAAK;EACJ,SAAA;EACA,SAAA;EACA,iBAAA;EACA,uBAAA;EACA,yBAAA;;AAEF,WARF,SAQG,SAAU;EACT,SAAA;EACA,UAAA;EACA,mBAAA;EACA,uBAAA;EACA,yBAAA;;AAEF,WAfF,SAeG,UAAW;EACV,SAAA;EACA,SAAA;EACA,mBAAA;EACA,uBAAA;EACA,yBAAA;;AAEF,WAtBF,SAsBG,MAAO;EACN,QAAA;EACA,OAAA;EACA,gBAAA;EACA,2BAAA;EACA,2BAAA;;AAEF,WA7BF,SA6BG,KAAM;EACL,QAAA;EACA,QAAA;EACA,gBAAA;EACA,2BAAA;EACA,0BAAA;;AAEF,WApCF,SAoCG,OAAQ;EACP,MAAA;EACA,SAAA;EACA,iBAAA;EACA,uBAAA;EACA,4BAAA;;AAEF,WA3CF,SA2CG,YAAa;EACZ,MAAA;EACA,UAAA;EACA,gBAAA;EACA,uBAAA;EACA,4BAAA;;AAEF,WAlDF,SAkDG,aAAc;EACb,MAAA;EACA,SAAA;EACA,gBAAA;EACA,uBAAA;EACA,4BAAA;;AJ5FJ,WAsEC,SAAQ;EOzEP,UAAA;EAGA,0BAAA;;APAF,WA0EC;EACC,iBAAA;EACA,gBAAA","file":"laps.css"}
|
{"version":3,"sources":["laps.less","C:/server/www/dev/wp-content/plugins/laps/vendor/twbs/bootstrap/less/progress-bars.less","C:/server/www/dev/wp-content/plugins/laps/vendor/twbs/bootstrap/less/mixins/vendor-prefixes.less","C:/server/www/dev/wp-content/plugins/laps/vendor/twbs/bootstrap/less/scaffolding.less","C:/server/www/dev/wp-content/plugins/laps/vendor/twbs/bootstrap/less/tooltip.less","C:/server/www/dev/wp-content/plugins/laps/vendor/twbs/bootstrap/less/mixins/reset-text.less","C:/server/www/dev/wp-content/plugins/laps/vendor/twbs/bootstrap/less/variables.less","C:/server/www/dev/wp-content/plugins/laps/vendor/twbs/bootstrap/less/mixins/opacity.less"],"names":[],"mappings":"AAMA,WAEC,mBAEC;EACC,cAAA;EACA,UAAA;EACA,eAAA;EACA,QAAA;;AARH,WAEC,mBASC;EACC,UAAA;;AAZH,WAgBC;EAEC,eAAA;;AAEA,WAJD,0BAIE;EACA,6BAAA;;AArBH,WAgBC,0BAQC;EACC,aAAA;;AAzBH,WA6BC;ECPC,YAAA;EACA,mBAAA;EACA,gBAAA;EACA,yBAAA;EACA,kBAAA;ECsCA,sDAAA;EACQ,8CAAA;EFlCR,aAAA;EACA,kBAAA;;AAhCF,WA6BC,eAKC;ECFA,WAAA;EACA,SAAA;EACA,YAAA;EACA,eAAA;EACA,iBAAA;EACA,WAAA;EACA,kBAAA;EACA,yBAAA;ECyBA,sDAAA;EACQ,8CAAA;EAyHR,mCAAA;EACK,8BAAA;EACG,2BAAA;EFxJP,kBAAA;EACA,8BAAA;EACA,cAAA;;AAtCH,WA6BC,eAYC;EACC,yBAAA;;AA1CH,WA6BC,eAeC;EACC,yBAAA;;AA7CH,WA6BC,eAkBC;EACC,yBAAA;;AAhDH,WA6BC,eAqBC;EACC,yBAAA;;AAnDH,WA6BC,eAwBC;EACC,yBAAA;;AAtDH,WA6BC,eA2BC;EACC,yBAAA;;AAzDH,WA6BC,eA8BC;EACC,yBAAA;;AA5DH,WA6BC,eAkCC;EGwDA,kBAAA;EACA,UAAA;EACA,WAAA;EACA,UAAA;EACA,YAAA;EACA,gBAAA;EACA,MAAM,gBAAN;EACA,SAAA;;AH9HF,WIAA;EACE,kBAAA;EACA,eAAA;EACA,cAAA;ECRA,aC6CwB,8CD7CxB;EAEA,kBAAA;EACA,gBAAA;EACA,uBAAA;EACA,gBAAA;EACA,gBAAA;EACA,iBAAA;EACA,qBAAA;EACA,iBAAA;EACA,oBAAA;EACA,sBAAA;EACA,kBAAA;EACA,oBAAA;EACA,iBAAA;EACA,mBAAA;EDHA,eAAA;EGTA,wBAAA;EACA,UAAA;;AHYA,WAXF,SAWG;EGbD,yBAAA;EACA,YAAA;;AHaA,WAZF,SAYG;EACC,cAAA;EACA,gBAAA;;AAEF,WAhBF,SAgBG;EACC,cAAA;EACA,gBAAA;;AAEF,WApBF,SAoBG;EACC,cAAA;EACA,eAAA;;AAEF,WAxBF,SAwBG;EACC,cAAA;EACA,iBAAA;;AAIF,WA9BF,SA8BG,IAAK;EACJ,SAAA;EACA,SAAA;EACA,iBAAA;EACA,uBAAA;EACA,yBAAA;;AAEF,WArCF,SAqCG,SAAU;EACT,UAAA;EACA,SAAA;EACA,mBAAA;EACA,uBAAA;EACA,yBAAA;;AAEF,WA5CF,SA4CG,UAAW;EACV,SAAA;EACA,SAAA;EACA,mBAAA;EACA,uBAAA;EACA,yBAAA;;AAEF,WAnDF,SAmDG,MAAO;EACN,QAAA;EACA,OAAA;EACA,gBAAA;EACA,2BAAA;EACA,2BAAA;;AAEF,WA1DF,SA0DG,KAAM;EACL,QAAA;EACA,QAAA;EACA,gBAAA;EACA,2BAAA;EACA,0BAAA;;AAEF,WAjEF,SAiEG,OAAQ;EACP,MAAA;EACA,SAAA;EACA,iBAAA;EACA,uBAAA;EACA,4BAAA;;AAEF,WAxEF,SAwEG,YAAa;EACZ,MAAA;EACA,UAAA;EACA,gBAAA;EACA,uBAAA;EACA,4BAAA;;AAEF,WA/EF,SA+EG,aAAc;EACb,MAAA;EACA,SAAA;EACA,gBAAA;EACA,uBAAA;EACA,4BAAA;;AJpFJ,WIyFA;EACE,gBAAA;EACA,gBAAA;EACA,WAAA;EACA,kBAAA;EACA,yBAAA;EACA,kBAAA;;AJ/FF,WImGA;EACE,kBAAA;EACA,QAAA;EACA,SAAA;EACA,yBAAA;EACA,mBAAA;;AJxGF,WAsEC,SAAQ;EOxEP,0BAAA;EACA,UAAA;;APCF,WA0EC;EACC,iBAAA;EACA,gBAAA;;AA5EF,WA0EC,eAIC;EACC,oBAAA","file":"laps.css"}
|
||||||
@@ -81,6 +81,10 @@
|
|||||||
.tooltip-inner {
|
.tooltip-inner {
|
||||||
line-height: 20px;
|
line-height: 20px;
|
||||||
text-align: left;
|
text-align: left;
|
||||||
|
|
||||||
|
br {
|
||||||
|
line-height: inherit;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Vendored
+1
-1
@@ -1 +1 @@
|
|||||||
#wpadminbar #wp-admin-bar-laps .ab-sub-wrapper{min-width:90%;width:90%;position:fixed;left:5%}#wpadminbar #wp-admin-bar-laps .ab-submenu{padding:0}#wpadminbar #wp-admin-bar-laps_output{padding:0 10px}#wpadminbar #wp-admin-bar-laps_output:hover{background-color:transparent}#wpadminbar #wp-admin-bar-laps_output .ab-empty-item{display:none}#wpadminbar .laps-timeline{overflow:hidden;height:20px;margin-bottom:20px;background-color:#f5f5f5;border-radius:4px;-webkit-box-shadow:inset 0 1px 2px rgba(0, 0, 0, 0.1);box-shadow:inset 0 1px 2px rgba(0, 0, 0, 0.1);margin:6px 0;position:relative}#wpadminbar .laps-timeline .event{float:left;width:0%;height:100%;font-size:12px;line-height:20px;color:#fff;text-align:center;background-color:#AAAAAA;-webkit-box-shadow:inset 0 -1px 0 rgba(0, 0, 0, 0.15);box-shadow:inset 0 -1px 0 rgba(0, 0, 0, 0.15);-webkit-transition:width 0.6s ease;-o-transition:width 0.6s ease;transition:width 0.6s ease;position:absolute;border-left:1px solid #f5f5f5;min-width:2px}#wpadminbar .laps-timeline .event-php{background-color:#B10DC9}#wpadminbar .laps-timeline .event-theme{background-color:#2ECC40}#wpadminbar .laps-timeline .event-plugin{background-color:#0074D9}#wpadminbar .laps-timeline .event-core{background-color:#FF851B}#wpadminbar .laps-timeline .event-sql-read{background-color:#7FDBFF}#wpadminbar .laps-timeline .event-sql-write{background-color:#FF4136}#wpadminbar .laps-timeline .event-http{background-color:#FF4136}#wpadminbar .laps-timeline .sr-only{position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0, 0, 0, 0);border:0}#wpadminbar .tooltip{position:absolute;z-index:100000;display:block;font-family:"Helvetica Neue", Helvetica, Arial, sans-serif;font-style:normal;font-weight:normal;letter-spacing:normal;line-break:auto;line-height:1.42857143;text-align:left;text-align:start;text-decoration:none;text-shadow:none;text-transform:none;white-space:normal;word-break:normal;word-spacing:normal;word-wrap:normal;font-size:12px;opacity:0;filter:alpha(opacity=0)}#wpadminbar .tooltip.in{opacity:0.9;filter:alpha(opacity=90)}#wpadminbar .tooltip.top{margin-top:-3px;padding:5px 0}#wpadminbar .tooltip.right{margin-left:3px;padding:0 5px}#wpadminbar .tooltip.bottom{margin-top:3px;padding:5px 0}#wpadminbar .tooltip.left{margin-left:-3px;padding:0 5px}#wpadminbar .tooltip-inner{max-width:300px;padding:3px 8px;color:#eee;text-align:center;background-color:#464646;border-radius:4px}#wpadminbar .tooltip-arrow{position:absolute;width:0;height:0;border-color:transparent;border-style:solid}#wpadminbar .tooltip.top .tooltip-arrow{bottom:0;left:50%;margin-left:-5px;border-width:5px 5px 0;border-top-color:#464646}#wpadminbar .tooltip.top-left .tooltip-arrow{bottom:0;right:5px;margin-bottom:-5px;border-width:5px 5px 0;border-top-color:#464646}#wpadminbar .tooltip.top-right .tooltip-arrow{bottom:0;left:5px;margin-bottom:-5px;border-width:5px 5px 0;border-top-color:#464646}#wpadminbar .tooltip.right .tooltip-arrow{top:50%;left:0;margin-top:-5px;border-width:5px 5px 5px 0;border-right-color:#464646}#wpadminbar .tooltip.left .tooltip-arrow{top:50%;right:0;margin-top:-5px;border-width:5px 0 5px 5px;border-left-color:#464646}#wpadminbar .tooltip.bottom .tooltip-arrow{top:0;left:50%;margin-left:-5px;border-width:0 5px 5px;border-bottom-color:#464646}#wpadminbar .tooltip.bottom-left .tooltip-arrow{top:0;right:5px;margin-top:-5px;border-width:0 5px 5px;border-bottom-color:#464646}#wpadminbar .tooltip.bottom-right .tooltip-arrow{top:0;left:5px;margin-top:-5px;border-width:0 5px 5px;border-bottom-color:#464646}#wpadminbar .tooltip.in{opacity:1;filter:alpha(opacity=100)}#wpadminbar .tooltip-inner{line-height:20px;text-align:left}
|
#wpadminbar #wp-admin-bar-laps .ab-sub-wrapper{min-width:90%;width:90%;position:fixed;left:5%}#wpadminbar #wp-admin-bar-laps .ab-submenu{padding:0}#wpadminbar #wp-admin-bar-laps_output{padding:0 10px}#wpadminbar #wp-admin-bar-laps_output:hover{background-color:transparent}#wpadminbar #wp-admin-bar-laps_output .ab-empty-item{display:none}#wpadminbar .laps-timeline{height:20px;margin-bottom:20px;overflow:hidden;background-color:#f5f5f5;border-radius:4px;-webkit-box-shadow:inset 0 1px 2px rgba(0, 0, 0, 0.1);box-shadow:inset 0 1px 2px rgba(0, 0, 0, 0.1);margin:6px 0;position:relative}#wpadminbar .laps-timeline .event{float:left;width:0%;height:100%;font-size:12px;line-height:20px;color:#fff;text-align:center;background-color:#AAAAAA;-webkit-box-shadow:inset 0 -1px 0 rgba(0, 0, 0, 0.15);box-shadow:inset 0 -1px 0 rgba(0, 0, 0, 0.15);-webkit-transition:width 0.6s ease;-o-transition:width 0.6s ease;transition:width 0.6s ease;position:absolute;border-left:1px solid #f5f5f5;min-width:2px}#wpadminbar .laps-timeline .event-php{background-color:#B10DC9}#wpadminbar .laps-timeline .event-theme{background-color:#2ECC40}#wpadminbar .laps-timeline .event-plugin{background-color:#0074D9}#wpadminbar .laps-timeline .event-core{background-color:#FF851B}#wpadminbar .laps-timeline .event-sql-read{background-color:#7FDBFF}#wpadminbar .laps-timeline .event-sql-write{background-color:#FF4136}#wpadminbar .laps-timeline .event-http{background-color:#FF4136}#wpadminbar .laps-timeline .sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0, 0, 0, 0);border:0}#wpadminbar .tooltip{position:absolute;z-index:100000;display:block;font-family:"Helvetica Neue", Helvetica, Arial, sans-serif;font-style:normal;font-weight:400;line-height:1.42857143;line-break:auto;text-align:left;text-align:start;text-decoration:none;text-shadow:none;text-transform:none;letter-spacing:normal;word-break:normal;word-spacing:normal;word-wrap:normal;white-space:normal;font-size:12px;filter:alpha(opacity=0);opacity:0}#wpadminbar .tooltip.in{filter:alpha(opacity=90);opacity:0.9}#wpadminbar .tooltip.top{padding:5px 0;margin-top:-3px}#wpadminbar .tooltip.right{padding:0 5px;margin-left:3px}#wpadminbar .tooltip.bottom{padding:5px 0;margin-top:3px}#wpadminbar .tooltip.left{padding:0 5px;margin-left:-3px}#wpadminbar .tooltip.top .tooltip-arrow{bottom:0;left:50%;margin-left:-5px;border-width:5px 5px 0;border-top-color:#464646}#wpadminbar .tooltip.top-left .tooltip-arrow{right:5px;bottom:0;margin-bottom:-5px;border-width:5px 5px 0;border-top-color:#464646}#wpadminbar .tooltip.top-right .tooltip-arrow{bottom:0;left:5px;margin-bottom:-5px;border-width:5px 5px 0;border-top-color:#464646}#wpadminbar .tooltip.right .tooltip-arrow{top:50%;left:0;margin-top:-5px;border-width:5px 5px 5px 0;border-right-color:#464646}#wpadminbar .tooltip.left .tooltip-arrow{top:50%;right:0;margin-top:-5px;border-width:5px 0 5px 5px;border-left-color:#464646}#wpadminbar .tooltip.bottom .tooltip-arrow{top:0;left:50%;margin-left:-5px;border-width:0 5px 5px;border-bottom-color:#464646}#wpadminbar .tooltip.bottom-left .tooltip-arrow{top:0;right:5px;margin-top:-5px;border-width:0 5px 5px;border-bottom-color:#464646}#wpadminbar .tooltip.bottom-right .tooltip-arrow{top:0;left:5px;margin-top:-5px;border-width:0 5px 5px;border-bottom-color:#464646}#wpadminbar .tooltip-inner{max-width:300px;padding:3px 8px;color:#eee;text-align:center;background-color:#464646;border-radius:4px}#wpadminbar .tooltip-arrow{position:absolute;width:0;height:0;border-color:transparent;border-style:solid}#wpadminbar .tooltip.in{filter:alpha(opacity=100);opacity:1}#wpadminbar .tooltip-inner{line-height:20px;text-align:left}#wpadminbar .tooltip-inner br{line-height:inherit}
|
||||||
+6
-6
@@ -1,9 +1,9 @@
|
|||||||
/* ========================================================================
|
/* ========================================================================
|
||||||
* Bootstrap: tooltip.js v3.3.7
|
* Bootstrap: tooltip.js v3.4.0
|
||||||
* http://getbootstrap.com/javascript/#tooltip
|
* https://getbootstrap.com/docs/3.4/javascript/#tooltip
|
||||||
* Inspired by the original jQuery.tipsy by Jason Frame
|
* Inspired by the original jQuery.tipsy by Jason Frame
|
||||||
* ========================================================================
|
* ========================================================================
|
||||||
* Copyright 2011-2016 Twitter, Inc.
|
* Copyright 2011-2018 Twitter, Inc.
|
||||||
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
|
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
|
||||||
* ======================================================================== */
|
* ======================================================================== */
|
||||||
|
|
||||||
@@ -26,7 +26,7 @@
|
|||||||
this.init('tooltip', element, options)
|
this.init('tooltip', element, options)
|
||||||
}
|
}
|
||||||
|
|
||||||
Tooltip.VERSION = '3.3.7'
|
Tooltip.VERSION = '3.4.0'
|
||||||
|
|
||||||
Tooltip.TRANSITION_DURATION = 150
|
Tooltip.TRANSITION_DURATION = 150
|
||||||
|
|
||||||
@@ -51,7 +51,7 @@
|
|||||||
this.type = type
|
this.type = type
|
||||||
this.$element = $(element)
|
this.$element = $(element)
|
||||||
this.options = this.getOptions(options)
|
this.options = this.getOptions(options)
|
||||||
this.$viewport = this.options.viewport && $($.isFunction(this.options.viewport) ? this.options.viewport.call(this, this.$element) : (this.options.viewport.selector || this.options.viewport))
|
this.$viewport = this.options.viewport && $(document).find($.isFunction(this.options.viewport) ? this.options.viewport.call(this, this.$element) : (this.options.viewport.selector || this.options.viewport))
|
||||||
this.inState = { click: false, hover: false, focus: false }
|
this.inState = { click: false, hover: false, focus: false }
|
||||||
|
|
||||||
if (this.$element[0] instanceof document.constructor && !this.options.selector) {
|
if (this.$element[0] instanceof document.constructor && !this.options.selector) {
|
||||||
@@ -204,7 +204,7 @@
|
|||||||
.addClass(placement)
|
.addClass(placement)
|
||||||
.data('bs.' + this.type, this)
|
.data('bs.' + this.type, this)
|
||||||
|
|
||||||
this.options.container ? $tip.appendTo(this.options.container) : $tip.insertAfter(this.$element)
|
this.options.container ? $tip.appendTo($(document).find(this.options.container)) : $tip.insertAfter(this.$element)
|
||||||
this.$element.trigger('inserted.bs.' + this.type)
|
this.$element.trigger('inserted.bs.' + this.type)
|
||||||
|
|
||||||
var pos = this.getPosition()
|
var pos = this.getPosition()
|
||||||
|
|||||||
Vendored
+2
-2
@@ -1,5 +1,5 @@
|
|||||||
+function(t){'use strict';var e=function(t,e){this.type=null;this.options=null;this.enabled=null;this.timeout=null;this.hoverState=null;this.$element=null;this.inState=null;this.init('tooltip',t,e)};e.VERSION='3.3.7';e.TRANSITION_DURATION=150;e.DEFAULTS={animation:!0,placement:'top',selector:!1,template:'<div class="tooltip" role="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>',trigger:'hover focus',title:'',delay:0,html:!1,container:!1,viewport:{selector:'body',padding:0}};e.prototype.init=function(e,i,o){this.enabled=!0;this.type=e;this.$element=t(i);this.options=this.getOptions(o);this.$viewport=this.options.viewport&&t(t.isFunction(this.options.viewport)?this.options.viewport.call(this,this.$element):(this.options.viewport.selector||this.options.viewport));this.inState={click:!1,hover:!1,focus:!1};if(this.$element[0]instanceof document.constructor&&!this.options.selector){throw new Error('`selector` option must be specified when initializing '+this.type+' on the window.document object!')};var r=this.options.trigger.split(' ');for(var s=r.length;s--;){var n=r[s];if(n=='click'){this.$element.on('click.'+this.type,this.options.selector,t.proxy(this.toggle,this))}
|
+function(t){'use strict';var e=function(t,e){this.type=null;this.options=null;this.enabled=null;this.timeout=null;this.hoverState=null;this.$element=null;this.inState=null;this.init('tooltip',t,e)};e.VERSION='3.4.0';e.TRANSITION_DURATION=150;e.DEFAULTS={animation:!0,placement:'top',selector:!1,template:'<div class="tooltip" role="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>',trigger:'hover focus',title:'',delay:0,html:!1,container:!1,viewport:{selector:'body',padding:0}};e.prototype.init=function(e,i,o){this.enabled=!0;this.type=e;this.$element=t(i);this.options=this.getOptions(o);this.$viewport=this.options.viewport&&t(document).find(t.isFunction(this.options.viewport)?this.options.viewport.call(this,this.$element):(this.options.viewport.selector||this.options.viewport));this.inState={click:!1,hover:!1,focus:!1};if(this.$element[0]instanceof document.constructor&&!this.options.selector){throw new Error('`selector` option must be specified when initializing '+this.type+' on the window.document object!')};var r=this.options.trigger.split(' ');for(var s=r.length;s--;){var n=r[s];if(n=='click'){this.$element.on('click.'+this.type,this.options.selector,t.proxy(this.toggle,this))}
|
||||||
else if(n!='manual'){var l=n=='hover'?'mouseenter':'focusin',a=n=='hover'?'mouseleave':'focusout';this.$element.on(l+'.'+this.type,this.options.selector,t.proxy(this.enter,this));this.$element.on(a+'.'+this.type,this.options.selector,t.proxy(this.leave,this))}};this.options.selector?(this._options=t.extend({},this.options,{trigger:'manual',selector:''})):this.fixTitle()};e.prototype.getDefaults=function(){return e.DEFAULTS};e.prototype.getOptions=function(e){e=t.extend({},this.getDefaults(),this.$element.data(),e);if(e.delay&&typeof e.delay=='number'){e.delay={show:e.delay,hide:e.delay}};return e};e.prototype.getDelegateOptions=function(){var e={};var i=this.getDefaults();this._options&&t.each(this._options,function(t,o){if(i[t]!=o)e[t]=o});return e};e.prototype.enter=function(e){var i=e instanceof this.constructor?e:t(e.currentTarget).data('bs.'+this.type);if(!i){i=new this.constructor(e.currentTarget,this.getDelegateOptions());t(e.currentTarget).data('bs.'+this.type,i)};if(e instanceof t.Event){i.inState[e.type=='focusin'?'focus':'hover']=!0};if(i.tip().hasClass('in')||i.hoverState=='in'){i.hoverState='in';return};clearTimeout(i.timeout);i.hoverState='in';if(!i.options.delay||!i.options.delay.show)return i.show();i.timeout=setTimeout(function(){if(i.hoverState=='in')i.show()},i.options.delay.show)};e.prototype.isInStateTrue=function(){for(var t in this.inState){if(this.inState[t])return!0};return!1};e.prototype.leave=function(e){var i=e instanceof this.constructor?e:t(e.currentTarget).data('bs.'+this.type);if(!i){i=new this.constructor(e.currentTarget,this.getDelegateOptions());t(e.currentTarget).data('bs.'+this.type,i)};if(e instanceof t.Event){i.inState[e.type=='focusout'?'focus':'hover']=!1};if(i.isInStateTrue())return;clearTimeout(i.timeout);i.hoverState='out';if(!i.options.delay||!i.options.delay.hide)return i.hide();i.timeout=setTimeout(function(){if(i.hoverState=='out')i.hide()},i.options.delay.hide)};e.prototype.show=function(){var c=t.Event('show.bs.'+this.type);if(this.hasContent()&&this.enabled){this.$element.trigger(c);var v=t.contains(this.$element[0].ownerDocument.documentElement,this.$element[0]);if(c.isDefaultPrevented()||!v)return;var n=this,o=this.tip(),u=this.getUID(this.type);this.setContent();o.attr('id',u);this.$element.attr('aria-describedby',u);if(this.options.animation)o.addClass('fade');var i=typeof this.options.placement=='function'?this.options.placement.call(this,o[0],this.$element[0]):this.options.placement,h=/\s?auto?\s?/i,f=h.test(i);if(f)i=i.replace(h,'')||'top';o.detach().css({top:0,left:0,display:'block'}).addClass(i).data('bs.'+this.type,this);this.options.container?o.appendTo(this.options.container):o.insertAfter(this.$element);this.$element.trigger('inserted.bs.'+this.type);var s=this.getPosition(),l=o[0].offsetWidth,a=o[0].offsetHeight;if(f){var m=i,r=this.getPosition(this.$viewport);i=i=='bottom'&&s.bottom+a>r.bottom?'top':i=='top'&&s.top-a<r.top?'bottom':i=='right'&&s.right+l>r.width?'left':i=='left'&&s.left-l<r.left?'right':i;o.removeClass(m).addClass(i)};var d=this.getCalculatedOffset(i,s,l,a);this.applyPlacement(d,i);var p=function(){var t=n.hoverState;n.$element.trigger('shown.bs.'+n.type);n.hoverState=null;if(t=='out')n.leave(n)};t.support.transition&&this.$tip.hasClass('fade')?o.one('bsTransitionEnd',p).emulateTransitionEnd(e.TRANSITION_DURATION):p()}};e.prototype.applyPlacement=function(e,o){var i=this.tip(),c=i[0].offsetWidth,l=i[0].offsetHeight,a=parseInt(i.css('margin-top'),10),p=parseInt(i.css('margin-left'),10);if(isNaN(a))a=0;if(isNaN(p))p=0;e.top+=a;e.left+=p;t.offset.setOffset(i[0],t.extend({using:function(t){i.css({top:Math.round(t.top),left:Math.round(t.left)})}},e),0);i.addClass('in');var h=i[0].offsetWidth,s=i[0].offsetHeight;if(o=='top'&&s!=l){e.top=e.top+l-s};var n=this.getViewportAdjustedDelta(o,e,h,s);if(n.left)e.left+=n.left;else e.top+=n.top;var r=/top|bottom/.test(o),f=r?n.left*2-c+h:n.top*2-l+s,u=r?'offsetWidth':'offsetHeight';i.offset(e);this.replaceArrow(f,i[0][u],r)};e.prototype.replaceArrow=function(t,e,i){this.arrow().css(i?'left':'top',50*(1-t/e)+'%').css(i?'top':'left','')};e.prototype.setContent=function(){var t=this.tip(),e=this.getTitle();t.find('.tooltip-inner')[this.options.html?'html':'text'](e);t.removeClass('fade in top bottom left right')};e.prototype.hide=function(i){var o=this,n=t(this.$tip),s=t.Event('hide.bs.'+this.type);function r(){if(o.hoverState!='in')n.detach();if(o.$element){o.$element.removeAttr('aria-describedby').trigger('hidden.bs.'+o.type)};i&&i()};this.$element.trigger(s);if(s.isDefaultPrevented())return;n.removeClass('in');t.support.transition&&n.hasClass('fade')?n.one('bsTransitionEnd',r).emulateTransitionEnd(e.TRANSITION_DURATION):r();this.hoverState=null;return this};e.prototype.fixTitle=function(){var t=this.$element;if(t.attr('title')||typeof t.attr('data-original-title')!='string'){t.attr('data-original-title',t.attr('title')||'').attr('title','')}};e.prototype.hasContent=function(){return this.getTLine truncated
|
else if(n!='manual'){var l=n=='hover'?'mouseenter':'focusin',a=n=='hover'?'mouseleave':'focusout';this.$element.on(l+'.'+this.type,this.options.selector,t.proxy(this.enter,this));this.$element.on(a+'.'+this.type,this.options.selector,t.proxy(this.leave,this))}};this.options.selector?(this._options=t.extend({},this.options,{trigger:'manual',selector:''})):this.fixTitle()};e.prototype.getDefaults=function(){return e.DEFAULTS};e.prototype.getOptions=function(e){e=t.extend({},this.getDefaults(),this.$element.data(),e);if(e.delay&&typeof e.delay=='number'){e.delay={show:e.delay,hide:e.delay}};return e};e.prototype.getDelegateOptions=function(){var e={};var i=this.getDefaults();this._options&&t.each(this._options,function(t,o){if(i[t]!=o)e[t]=o});return e};e.prototype.enter=function(e){var i=e instanceof this.constructor?e:t(e.currentTarget).data('bs.'+this.type);if(!i){i=new this.constructor(e.currentTarget,this.getDelegateOptions());t(e.currentTarget).data('bs.'+this.type,i)};if(e instanceof t.Event){i.inState[e.type=='focusin'?'focus':'hover']=!0};if(i.tip().hasClass('in')||i.hoverState=='in'){i.hoverState='in';return};clearTimeout(i.timeout);i.hoverState='in';if(!i.options.delay||!i.options.delay.show)return i.show();i.timeout=setTimeout(function(){if(i.hoverState=='in')i.show()},i.options.delay.show)};e.prototype.isInStateTrue=function(){for(var t in this.inState){if(this.inState[t])return!0};return!1};e.prototype.leave=function(e){var i=e instanceof this.constructor?e:t(e.currentTarget).data('bs.'+this.type);if(!i){i=new this.constructor(e.currentTarget,this.getDelegateOptions());t(e.currentTarget).data('bs.'+this.type,i)};if(e instanceof t.Event){i.inState[e.type=='focusout'?'focus':'hover']=!1};if(i.isInStateTrue())return;clearTimeout(i.timeout);i.hoverState='out';if(!i.options.delay||!i.options.delay.hide)return i.hide();i.timeout=setTimeout(function(){if(i.hoverState=='out')i.hide()},i.options.delay.hide)};e.prototype.show=function(){var c=t.Event('show.bs.'+this.type);if(this.hasContent()&&this.enabled){this.$element.trigger(c);var v=t.contains(this.$element[0].ownerDocument.documentElement,this.$element[0]);if(c.isDefaultPrevented()||!v)return;var n=this,o=this.tip(),u=this.getUID(this.type);this.setContent();o.attr('id',u);this.$element.attr('aria-describedby',u);if(this.options.animation)o.addClass('fade');var i=typeof this.options.placement=='function'?this.options.placement.call(this,o[0],this.$element[0]):this.options.placement,h=/\s?auto?\s?/i,f=h.test(i);if(f)i=i.replace(h,'')||'top';o.detach().css({top:0,left:0,display:'block'}).addClass(i).data('bs.'+this.type,this);this.options.container?o.appendTo(t(document).find(this.options.container)):o.insertAfter(this.$element);this.$element.trigger('inserted.bs.'+this.type);var s=this.getPosition(),l=o[0].offsetWidth,a=o[0].offsetHeight;if(f){var m=i,r=this.getPosition(this.$viewport);i=i=='bottom'&&s.bottom+a>r.bottom?'top':i=='top'&&s.top-a<r.top?'bottom':i=='right'&&s.right+l>r.width?'left':i=='left'&&s.left-l<r.left?'right':i;o.removeClass(m).addClass(i)};var d=this.getCalculatedOffset(i,s,l,a);this.applyPlacement(d,i);var p=function(){var t=n.hoverState;n.$element.trigger('shown.bs.'+n.type);n.hoverState=null;if(t=='out')n.leave(n)};t.support.transition&&this.$tip.hasClass('fade')?o.one('bsTransitionEnd',p).emulateTransitionEnd(e.TRANSITION_DURATION):p()}};e.prototype.applyPlacement=function(e,o){var i=this.tip(),c=i[0].offsetWidth,l=i[0].offsetHeight,a=parseInt(i.css('margin-top'),10),p=parseInt(i.css('margin-left'),10);if(isNaN(a))a=0;if(isNaN(p))p=0;e.top+=a;e.left+=p;t.offset.setOffset(i[0],t.extend({using:function(t){i.css({top:Math.round(t.top),left:Math.round(t.left)})}},e),0);i.addClass('in');var h=i[0].offsetWidth,s=i[0].offsetHeight;if(o=='top'&&s!=l){e.top=e.top+l-s};var n=this.getViewportAdjustedDelta(o,e,h,s);if(n.left)e.left+=n.left;else e.top+=n.top;var r=/top|bottom/.test(o),f=r?n.left*2-c+h:n.top*2-l+s,u=r?'offsetWidth':'offsetHeight';i.offset(e);this.replaceArrow(f,i[0][u],r)};e.prototype.replaceArrow=function(t,e,i){this.arrow().css(i?'left':'top',50*(1-t/e)+'%').css(i?'top':'left','')};e.prototype.setContent=function(){var t=this.tip(),e=this.getTitle();t.find('.tooltip-inner')[this.options.html?'html':'text'](e);t.removeClass('fade in top bottom left right')};e.prototype.hide=function(i){var o=this,n=t(this.$tip),s=t.Event('hide.bs.'+this.type);function r(){if(o.hoverState!='in')n.detach();if(o.$element){o.$element.removeAttr('aria-describedby').trigger('hidden.bs.'+o.type)};i&&i()};this.$element.trigger(s);if(s.isDefaultPrevented())return;n.removeClass('in');t.support.transition&&n.hasClass('fade')?n.one('bsTransitionEnd',r).emulateTransitionEnd(e.TRANSITION_DURATION):r();this.hoverState=null;return this};e.prototype.fixTitle=function(){var t=this.$element;if(t.attr('title')||typeof t.attr('data-original-title')!='string'){t.attr('data-original-title',t.attr('title')||'').attr('title','')}};e.prototype.hasContent=function(Line truncated
|
||||||
else if(h>e.top+e.height){o.top=e.top+e.height-h}}
|
else if(h>e.top+e.height){o.top=e.top+e.height-h}}
|
||||||
else{var l=i.left-s,a=i.left+s+n;if(l<e.left){o.left=e.left-l}
|
else{var l=i.left-s,a=i.left+s+n;if(l<e.left){o.left=e.left-l}
|
||||||
else if(a>e.right){o.left=e.left+e.width-a}};return o};e.prototype.getTitle=function(){var e,i=this.$element,t=this.options;e=i.attr('data-original-title')||(typeof t.title=='function'?t.title.call(i[0]):t.title);return e};e.prototype.getUID=function(t){do t+=~~(Math.random()*1000000);while(document.getElementById(t))return t};e.prototype.tip=function(){if(!this.$tip){this.$tip=t(this.options.template);if(this.$tip.length!=1){throw new Error(this.type+' `template` option must consist of exactly 1 top-level element!')}};return this.$tip};e.prototype.arrow=function(){return(this.$arrow=this.$arrow||this.tip().find('.tooltip-arrow'))};e.prototype.enable=function(){this.enabled=!0};e.prototype.disable=function(){this.enabled=!1};e.prototype.toggleEnabled=function(){this.enabled=!this.enabled};e.prototype.toggle=function(e){var i=this;if(e){i=t(e.currentTarget).data('bs.'+this.type);if(!i){i=new this.constructor(e.currentTarget,this.getDelegateOptions());t(e.currentTarget).data('bs.'+this.type,i)}};if(e){i.inState.click=!i.inState.click;if(i.isInStateTrue())i.enter(i);else i.leave(i)}
|
else if(a>e.right){o.left=e.left+e.width-a}};return o};e.prototype.getTitle=function(){var e,i=this.$element,t=this.options;e=i.attr('data-original-title')||(typeof t.title=='function'?t.title.call(i[0]):t.title);return e};e.prototype.getUID=function(t){do t+=~~(Math.random()*1000000);while(document.getElementById(t))return t};e.prototype.tip=function(){if(!this.$tip){this.$tip=t(this.options.template);if(this.$tip.length!=1){throw new Error(this.type+' `template` option must consist of exactly 1 top-level element!')}};return this.$tip};e.prototype.arrow=function(){return(this.$arrow=this.$arrow||this.tip().find('.tooltip-arrow'))};e.prototype.enable=function(){this.enabled=!0};e.prototype.disable=function(){this.enabled=!1};e.prototype.toggleEnabled=function(){this.enabled=!this.enabled};e.prototype.toggle=function(e){var i=this;if(e){i=t(e.currentTarget).data('bs.'+this.type);if(!i){i=new this.constructor(e.currentTarget,this.getDelegateOptions());t(e.currentTarget).data('bs.'+this.type,i)}};if(e){i.inState.click=!i.inState.click;if(i.isInStateTrue())i.enter(i);else i.leave(i)}
|
||||||
|
|||||||
+18
-91
@@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
declare( strict_types=1 );
|
||||||
|
|
||||||
namespace Rarst\Laps\Event;
|
namespace Rarst\Laps\Event;
|
||||||
|
|
||||||
@@ -10,98 +11,24 @@ class Core_Events implements Hook_Event_Config_Interface {
|
|||||||
/**
|
/**
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function get_events() {
|
public function get_events(): array {
|
||||||
|
|
||||||
$stops = [];
|
return [
|
||||||
|
[ 'Plugins Load', 'plugin', '', 'plugins_loaded', - 1, - 2 ],
|
||||||
$stops['plugins_loaded'][-2] = [
|
[ 'Plugins Loaded Hook', 'plugin', 'plugins_loaded' ],
|
||||||
'action' => 'stop',
|
[ 'Themes Load', 'theme', 'setup_theme', 'after_setup_theme' ],
|
||||||
'event' => 'Plugins Load',
|
[ 'Init Hook', 'core', 'init' ],
|
||||||
'category' => 'plugin',
|
[ 'WP Loaded Hook', 'core', 'wp_loaded' ],
|
||||||
|
[ 'Query Setup', 'core', 'wp_loaded', 'template_redirect', PHP_INT_MAX, -1 ],
|
||||||
|
[ 'Template Loader', 'theme', 'template_redirect', 'template_include' ],
|
||||||
|
[ 'Admin Init Hook', 'core', 'admin_init' ],
|
||||||
|
[ 'Admin Menu', 'core', '_admin_menu', 'admin_menu' ],
|
||||||
|
[ 'Admin Print Scripts', 'core', 'admin_enqueue_scripts', 'admin_print_scripts' ],
|
||||||
|
[ 'Head Hook', 'theme', 'wp_head' ],
|
||||||
|
[ 'Main Loop', 'theme', 'loop_start', 'loop_end' ],
|
||||||
|
[ 'Sidebar', 'theme', 'dynamic_sidebar_before', 'dynamic_sidebar_after' ],
|
||||||
|
[ 'Toolbar', 'core', 'admin_bar_menu', '' ],
|
||||||
|
[ 'Footer Hook', 'theme', 'wp_footer' ],
|
||||||
];
|
];
|
||||||
|
|
||||||
$stops['plugins_loaded'][-1] = [
|
|
||||||
'event' => 'Plugins Loaded Hook',
|
|
||||||
'category' => 'plugin',
|
|
||||||
];
|
|
||||||
|
|
||||||
$stops['plugins_loaded'][20] = [
|
|
||||||
'action' => 'stop',
|
|
||||||
'event' => 'Plugins Loaded Hook',
|
|
||||||
'category' => 'plugin',
|
|
||||||
];
|
|
||||||
|
|
||||||
$stops['setup_theme'][0] = [
|
|
||||||
'event' => 'Themes Load',
|
|
||||||
'category' => 'theme',
|
|
||||||
];
|
|
||||||
|
|
||||||
$stops['after_setup_theme'][20] = [
|
|
||||||
'action' => 'stop',
|
|
||||||
'event' => 'Themes Load',
|
|
||||||
'category' => 'theme',
|
|
||||||
];
|
|
||||||
|
|
||||||
$stops['init'][-1] = [
|
|
||||||
'event' => 'Core Init',
|
|
||||||
'category' => 'core',
|
|
||||||
];
|
|
||||||
|
|
||||||
$stops['wp_loaded'][20] = [
|
|
||||||
'action' => 'stop',
|
|
||||||
'event' => 'Core Init',
|
|
||||||
'category' => 'core',
|
|
||||||
];
|
|
||||||
|
|
||||||
$stops['admin_init'][-1] = [
|
|
||||||
'event' => 'Core Admin Init',
|
|
||||||
'category' => 'core',
|
|
||||||
];
|
|
||||||
|
|
||||||
$stops['admin_init'][ PHP_INT_MAX - 1 ] = [
|
|
||||||
'action' => 'stop',
|
|
||||||
'event' => 'Core Admin Init',
|
|
||||||
'category' => 'core',
|
|
||||||
];
|
|
||||||
|
|
||||||
$stops['_admin_menu'][-1] = [
|
|
||||||
'event' => 'Admin Menu',
|
|
||||||
'category' => 'core',
|
|
||||||
];
|
|
||||||
|
|
||||||
$stops['admin_menu'][ PHP_INT_MAX - 1 ] = [
|
|
||||||
'action' => 'stop',
|
|
||||||
'event' => 'Admin Menu',
|
|
||||||
'category' => 'core',
|
|
||||||
];
|
|
||||||
|
|
||||||
$stops['admin_bar_menu'][-1] = [
|
|
||||||
'event' => 'Toolbar',
|
|
||||||
'category' => 'core',
|
|
||||||
];
|
|
||||||
|
|
||||||
$stops['loop_start'][10] = [
|
|
||||||
'event' => 'Main Loop',
|
|
||||||
'category' => 'theme',
|
|
||||||
];
|
|
||||||
|
|
||||||
$stops['loop_end'][10] = [
|
|
||||||
'action' => 'stop',
|
|
||||||
'event' => 'Main Loop',
|
|
||||||
'category' => 'theme',
|
|
||||||
];
|
|
||||||
|
|
||||||
$stops['admin_enqueue_scripts'][10] = [
|
|
||||||
'event' => 'Admin Print Scripts',
|
|
||||||
'category' => 'core',
|
|
||||||
];
|
|
||||||
|
|
||||||
$stops['admin_print_scripts'][10] = [
|
|
||||||
'action' => 'stop',
|
|
||||||
'event' => 'Admin Print Scripts',
|
|
||||||
'category' => 'core',
|
|
||||||
];
|
|
||||||
|
|
||||||
return $stops;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
declare( strict_types=1 );
|
||||||
|
|
||||||
namespace Rarst\Laps\Event;
|
namespace Rarst\Laps\Event;
|
||||||
|
|
||||||
@@ -12,47 +13,17 @@ class Genesis_Events implements Hook_Event_Config_Interface {
|
|||||||
/**
|
/**
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function get_events() {
|
public function get_events(): array {
|
||||||
|
|
||||||
$events = [];
|
return \function_exists( 'genesis' ) ? [
|
||||||
|
[ 'Header', 'theme', 'genesis_before_header', 'genesis_after_header' ],
|
||||||
if ( ! function_exists( 'genesis' ) ) {
|
[ 'Sidebar', 'theme', 'genesis_before_sidebar_widget_area', 'genesis_after_sidebar_widget_area' ],
|
||||||
return $events;
|
[
|
||||||
}
|
'Sidebar (alternate)',
|
||||||
|
'theme',
|
||||||
$events['genesis_before_header'][10] = [
|
'genesis_before_sidebar_alt_widget_area',
|
||||||
'event' => 'Header',
|
'genesis_after_sidebar_alt_widget_area',
|
||||||
'category' => 'theme',
|
],
|
||||||
];
|
] : [];
|
||||||
|
|
||||||
$events['genesis_after_header'][10] = [
|
|
||||||
'action' => 'stop',
|
|
||||||
'event' => 'Header',
|
|
||||||
'category' => 'theme',
|
|
||||||
];
|
|
||||||
|
|
||||||
$events['genesis_before_sidebar_widget_area'][10] = [
|
|
||||||
'event' => 'Sidebar',
|
|
||||||
'category' => 'theme',
|
|
||||||
];
|
|
||||||
|
|
||||||
$events['genesis_after_sidebar_widget_area'][10] = [
|
|
||||||
'action' => 'stop',
|
|
||||||
'event' => 'Sidebar',
|
|
||||||
'category' => 'theme',
|
|
||||||
];
|
|
||||||
|
|
||||||
$events['genesis_before_sidebar_alt_widget_area'][10] = [
|
|
||||||
'event' => 'Sidebar (alternate)',
|
|
||||||
'category' => 'theme',
|
|
||||||
];
|
|
||||||
|
|
||||||
$events['genesis_after_sidebar_alt_widget_area'][10] = [
|
|
||||||
'action' => 'stop',
|
|
||||||
'event' => 'Sidebar (alternate)',
|
|
||||||
'category' => 'theme',
|
|
||||||
];
|
|
||||||
|
|
||||||
return $events;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,11 +1,19 @@
|
|||||||
<?php
|
<?php
|
||||||
|
declare( strict_types=1 );
|
||||||
|
|
||||||
namespace Rarst\Laps\Event;
|
namespace Rarst\Laps\Event;
|
||||||
|
|
||||||
|
use Rarst\Laps\Record\Collector\Hook_Collector;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Interface to retrieve configuration array of hook events to track.
|
||||||
|
*/
|
||||||
interface Hook_Event_Config_Interface {
|
interface Hook_Event_Config_Interface {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return array
|
* @see Hook_Collector::add_event()
|
||||||
|
*
|
||||||
|
* @return array[]
|
||||||
*/
|
*/
|
||||||
public function get_events();
|
public function get_events(): array;
|
||||||
}
|
}
|
||||||
+13
-21
@@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
declare( strict_types=1 );
|
||||||
|
|
||||||
namespace Rarst\Laps\Event;
|
namespace Rarst\Laps\Event;
|
||||||
|
|
||||||
@@ -12,41 +13,32 @@ class Hybrid_Events implements Hook_Event_Config_Interface {
|
|||||||
/**
|
/**
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function get_events() {
|
public function get_events(): array {
|
||||||
|
|
||||||
$events = [];
|
$events = [];
|
||||||
|
|
||||||
if ( ! function_exists( 'hybrid_get_prefix' ) ) {
|
if ( ! \function_exists( 'hybrid_get_prefix' ) ) {
|
||||||
return $events;
|
return $events;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @var string $prefix */
|
||||||
$prefix = hybrid_get_prefix();
|
$prefix = hybrid_get_prefix();
|
||||||
|
|
||||||
$events["{$prefix}_before_header"][10] = [
|
$events = [
|
||||||
'event' => 'Header',
|
[ 'Header', 'theme', "{$prefix}_before_header", "{$prefix}_after_header" ],
|
||||||
'category' => 'theme',
|
|
||||||
];
|
|
||||||
|
|
||||||
$events["{$prefix}_after_header"][10] = [
|
|
||||||
'action' => 'stop',
|
|
||||||
'event' => 'Header',
|
|
||||||
'category' => 'theme',
|
|
||||||
];
|
];
|
||||||
|
|
||||||
|
/** @var array $sidebars */
|
||||||
$sidebars = get_theme_support( 'hybrid-core-sidebars' );
|
$sidebars = get_theme_support( 'hybrid-core-sidebars' );
|
||||||
|
|
||||||
if ( ! empty( $sidebars[0] ) ) {
|
if ( ! empty( $sidebars[0] ) ) {
|
||||||
|
/** @var string $sidebar */
|
||||||
foreach ( $sidebars[0] as $sidebar ) {
|
foreach ( $sidebars[0] as $sidebar ) {
|
||||||
|
$events[] = [
|
||||||
$events["{$prefix}_before_{$sidebar}"][10] = [
|
"Sidebar ({$sidebar})",
|
||||||
'event' => "Sidebar ({$sidebar})",
|
'theme',
|
||||||
'category' => 'theme',
|
"{$prefix}_before_{$sidebar}",
|
||||||
];
|
"{$prefix}_after_{$sidebar}",
|
||||||
|
|
||||||
$events["{$prefix}_after_{$sidebar}"][10] = [
|
|
||||||
'action' => 'stop',
|
|
||||||
'event' => "Sidebar ({$sidebar})",
|
|
||||||
'category' => 'theme',
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
declare( strict_types=1 );
|
||||||
|
|
||||||
namespace Rarst\Laps\Event;
|
namespace Rarst\Laps\Event;
|
||||||
|
|
||||||
@@ -12,36 +13,11 @@ class THA_Events implements Hook_Event_Config_Interface {
|
|||||||
/**
|
/**
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function get_events() {
|
public function get_events(): array {
|
||||||
|
|
||||||
$events = [];
|
return \defined( 'THA_HOOKS_VERSION' ) ? [
|
||||||
|
[ 'Header', 'theme', 'tha_header_before', 'tha_header_after' ],
|
||||||
if ( ! defined( 'THA_HOOKS_VERSION' ) ) {
|
[ 'Sidebars', 'theme', 'tha_sidebars_before', 'tha_sidebars_after' ],
|
||||||
return $events;
|
] : [];
|
||||||
}
|
|
||||||
|
|
||||||
$events['tha_header_before'][10] = [
|
|
||||||
'event' => 'Header',
|
|
||||||
'category' => 'theme',
|
|
||||||
];
|
|
||||||
|
|
||||||
$events['tha_header_after'][10] = [
|
|
||||||
'action' => 'stop',
|
|
||||||
'event' => 'Header',
|
|
||||||
'category' => 'theme',
|
|
||||||
];
|
|
||||||
|
|
||||||
$events['tha_sidebars_before'][10] = [
|
|
||||||
'event' => 'Sidebars',
|
|
||||||
'category' => 'theme',
|
|
||||||
];
|
|
||||||
|
|
||||||
$events['tha_sidebars_after'][10] = [
|
|
||||||
'action' => 'stop',
|
|
||||||
'event' => 'Sidebars',
|
|
||||||
'category' => 'theme',
|
|
||||||
];
|
|
||||||
|
|
||||||
return $events;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
declare( strict_types=1 );
|
||||||
|
|
||||||
namespace Rarst\Laps\Event;
|
namespace Rarst\Laps\Event;
|
||||||
|
|
||||||
@@ -10,25 +11,10 @@ class Yoast_Events implements Hook_Event_Config_Interface {
|
|||||||
/**
|
/**
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function get_events() {
|
public function get_events(): array {
|
||||||
|
|
||||||
$stops = [];
|
return class_exists( 'WPSEO_Frontend' ) ? [
|
||||||
|
[ 'WP SEO head hook', 'plugin', 'wpseo_head' ],
|
||||||
if ( ! class_exists( 'WPSEO_Frontend' ) ) {
|
] : [];
|
||||||
return $stops;
|
|
||||||
}
|
|
||||||
|
|
||||||
$stops['wpseo_head'][1] = [
|
|
||||||
'event' => 'WP SEO head hook',
|
|
||||||
'category' => 'plugin',
|
|
||||||
];
|
|
||||||
|
|
||||||
$stops['wpseo_head'][100] = [
|
|
||||||
'action' => 'stop',
|
|
||||||
'event' => 'WP SEO head hook',
|
|
||||||
'category' => 'plugin',
|
|
||||||
];
|
|
||||||
|
|
||||||
return $stops;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,104 @@
|
|||||||
|
<?php
|
||||||
|
declare( strict_types=1 );
|
||||||
|
|
||||||
|
namespace Rarst\Laps\Formatter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Formatter to adjust WP backtrace output to be more short and concise.
|
||||||
|
*/
|
||||||
|
class Backtrace_Formatter {
|
||||||
|
|
||||||
|
/** @var string[] $skip String matches to omit. */
|
||||||
|
protected static $skip = [
|
||||||
|
'wp-blog-header.php',
|
||||||
|
'wp-load.php',
|
||||||
|
'wp-config.php',
|
||||||
|
'admin.php',
|
||||||
|
'template-loader.php',
|
||||||
|
'locate_template',
|
||||||
|
'load_template',
|
||||||
|
'_wp_get_current_user',
|
||||||
|
'WP_Hook',
|
||||||
|
];
|
||||||
|
|
||||||
|
/** @var array $truncate_paths Paths to truncate from includes. */
|
||||||
|
protected $truncate_paths = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set up object properties.
|
||||||
|
*/
|
||||||
|
public function __construct() {
|
||||||
|
|
||||||
|
$this->truncate_paths = [
|
||||||
|
wp_normalize_path( WP_CONTENT_DIR ),
|
||||||
|
wp_normalize_path( ABSPATH ),
|
||||||
|
'wp-admin/',
|
||||||
|
'themes/',
|
||||||
|
'plugins/',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array|string $backtrace Backtrace input as produced by WP.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function format( $backtrace ): array {
|
||||||
|
|
||||||
|
if ( \is_string( $backtrace ) ) {
|
||||||
|
$backtrace = explode( ', ', $backtrace );
|
||||||
|
} else {
|
||||||
|
$backtrace = array_reverse( $backtrace );
|
||||||
|
}
|
||||||
|
|
||||||
|
$backtrace = array_filter( $backtrace, [ $this, 'filter' ] );
|
||||||
|
$backtrace = array_map( [ $this, 'shorten_include' ], $backtrace );
|
||||||
|
|
||||||
|
// TODO compact redunant function sequences, such as transient into option calls.
|
||||||
|
|
||||||
|
return $backtrace;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $item Backtrace item.
|
||||||
|
*
|
||||||
|
* @return bool Keep or drop.
|
||||||
|
*/
|
||||||
|
protected function filter( string $item ): bool {
|
||||||
|
|
||||||
|
foreach ( self::$skip as $match ) {
|
||||||
|
if ( false !== strpos( $item, $match ) ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param string $item Backtrace item.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*
|
||||||
|
* @psalm-suppress PossiblyFalseOperand
|
||||||
|
* @psalm-suppress MixedInferredReturnType
|
||||||
|
*/
|
||||||
|
protected function shorten_include( string $item ): string {
|
||||||
|
|
||||||
|
if ( 0 === strpos( $item, 'include' ) || 0 === strpos( $item, 'require' ) ) {
|
||||||
|
|
||||||
|
$path = substr( $item, strpos( $item, '(\'' ) + 2, - 2 );
|
||||||
|
$path = wp_normalize_path( $path );
|
||||||
|
$path = str_replace( $this->truncate_paths, '', $path );
|
||||||
|
if ( ':' === $path[1] ) {
|
||||||
|
$path = substr( $path, 2 );
|
||||||
|
}
|
||||||
|
$path = ltrim( $path, '/' );
|
||||||
|
|
||||||
|
return $path;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $item;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,120 @@
|
|||||||
|
<?php
|
||||||
|
declare( strict_types=1 );
|
||||||
|
|
||||||
|
namespace Rarst\Laps\Formatter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Formatter to process callbacks from a hook instance.
|
||||||
|
*/
|
||||||
|
class Hook_Formatter {
|
||||||
|
|
||||||
|
/** @var array $truncate_paths Paths to truncate from includes. */
|
||||||
|
protected $truncate_paths = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set up object properties.
|
||||||
|
*/
|
||||||
|
public function __construct() {
|
||||||
|
|
||||||
|
$this->truncate_paths = [
|
||||||
|
wp_normalize_path( WP_CONTENT_DIR ),
|
||||||
|
wp_normalize_path( ABSPATH ),
|
||||||
|
'wp-admin/',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \WP_Hook|array $hook Hook instance.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function format( $hook ): array {
|
||||||
|
|
||||||
|
$callbacks = [];
|
||||||
|
|
||||||
|
if ( $hook instanceof \WP_Hook ) {
|
||||||
|
$hook = $hook->callbacks;
|
||||||
|
}
|
||||||
|
ksort( $hook );
|
||||||
|
|
||||||
|
$functions = array_merge( ...$hook );
|
||||||
|
|
||||||
|
foreach ( $functions as $function ) {
|
||||||
|
$callback = $this->get_callback_name( $function['function'], $function['accepted_args'] );
|
||||||
|
|
||||||
|
if ( false !== strpos( $callback, 'Hook_Collector' ) ) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$callbacks[] = $callback;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $callbacks;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string|object|array $callback Hook callback.
|
||||||
|
* @param int $args Number of accepted arguments.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
protected function get_callback_name( $callback, int $args ): string {
|
||||||
|
|
||||||
|
switch ( gettype( $callback ) ) {
|
||||||
|
case 'object':
|
||||||
|
$callback = $this->get_class_name( $callback );
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'array':
|
||||||
|
$class = is_string( $callback[0] )
|
||||||
|
? $callback[0] . '::'
|
||||||
|
: $this->get_class_name( $callback[0] ) . '->';
|
||||||
|
$callback = $class . $callback[1];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
$callback .= ( 1 === $args ) ? '' : "({$args})";
|
||||||
|
|
||||||
|
return $callback;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param object $object Object to retrieve name for.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
protected function get_class_name( $object ): string {
|
||||||
|
|
||||||
|
if ( is_a( $object, 'CLosure' ) ) {
|
||||||
|
$class = new \ReflectionFunction( $object );
|
||||||
|
|
||||||
|
return 'closure from ' . $this->shorten_path( $class->getFileName() ) . ':' . $class->getStartLine();
|
||||||
|
}
|
||||||
|
|
||||||
|
$class = new \ReflectionClass( $object );
|
||||||
|
$name = $class->getName();
|
||||||
|
|
||||||
|
if ( 0 === strpos( $name, 'class@anonymous' ) ) {
|
||||||
|
return 'anonymous class from ' . $this->shorten_path( $class->getFileName() ) . ':' . $class->getStartLine();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $path Path to shorten.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
protected function shorten_path( string $path ): string {
|
||||||
|
$path = wp_normalize_path( $path );
|
||||||
|
$path = str_replace( $this->truncate_paths, '', $path );
|
||||||
|
if ( ':' === $path[1] ) {
|
||||||
|
$path = substr( $path, 2 );
|
||||||
|
}
|
||||||
|
$path = ltrim( $path, '/' );
|
||||||
|
|
||||||
|
return $path;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
declare( strict_types=1 );
|
||||||
|
|
||||||
namespace Rarst\Laps\Manager;
|
namespace Rarst\Laps\Manager;
|
||||||
|
|
||||||
@@ -19,10 +20,10 @@ class Asset_Manager {
|
|||||||
/**
|
/**
|
||||||
* Registers assets and queues as necessary.
|
* Registers assets and queues as necessary.
|
||||||
*/
|
*/
|
||||||
public function enqueue_scripts() {
|
public function enqueue_scripts(): void {
|
||||||
|
|
||||||
$suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
|
$suffix = ( \defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
|
||||||
wp_register_script( 'laps', plugins_url( "public/js/laps{$suffix}.js", dirname( __DIR__ ) ), [ 'jquery' ], '3.3.1', true );
|
wp_register_script( 'laps', plugins_url( "public/js/laps{$suffix}.js", dirname( __DIR__ ) ), [ 'jquery' ], '3.4.0', true );
|
||||||
wp_register_style( 'laps', plugins_url( "public/css/laps{$suffix}.css", dirname( __DIR__ ) ) );
|
wp_register_style( 'laps', plugins_url( "public/css/laps{$suffix}.css", dirname( __DIR__ ) ) );
|
||||||
|
|
||||||
if ( is_admin_bar_showing() ) {
|
if ( is_admin_bar_showing() ) {
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
declare( strict_types=1 );
|
||||||
|
|
||||||
namespace Rarst\Laps\Manager;
|
namespace Rarst\Laps\Manager;
|
||||||
|
|
||||||
@@ -23,9 +24,9 @@ class Load_Order_Manager {
|
|||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function pre_update_option_active_plugins( $plugins ) {
|
public function pre_update_option_active_plugins( array $plugins ): array {
|
||||||
|
|
||||||
$plugin = plugin_basename( dirname( dirname( __DIR__ ) ) . '/laps.php' );
|
$plugin = plugin_basename( \dirname( __DIR__, 2 ) . '/laps.php' );
|
||||||
$key = array_search( $plugin, $plugins, true );
|
$key = array_search( $plugin, $plugins, true );
|
||||||
|
|
||||||
if ( false !== $key && $key > 0 ) {
|
if ( false !== $key && $key > 0 ) {
|
||||||
|
|||||||
@@ -0,0 +1,71 @@
|
|||||||
|
<?php
|
||||||
|
declare( strict_types=1 );
|
||||||
|
|
||||||
|
namespace Rarst\Laps\Manager;
|
||||||
|
|
||||||
|
use Rarst\Laps\Plugin;
|
||||||
|
use Rarst\Laps\Record\Collector\Record_Collector_Interface;
|
||||||
|
use Rarst\Laps\Record\Record_Interface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implements Server Timing API headers.
|
||||||
|
*/
|
||||||
|
class Server_Timing_Manager {
|
||||||
|
|
||||||
|
/** @var Record_Collector_Interface */
|
||||||
|
private $collector;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Record_Collector_Interface $collector Collector of all records.
|
||||||
|
*/
|
||||||
|
public function __construct( Record_Collector_Interface $collector ) {
|
||||||
|
|
||||||
|
$this->collector = $collector;
|
||||||
|
|
||||||
|
add_action( 'admin_init', [ $this, 'send_timing_header' ], PHP_INT_MAX );
|
||||||
|
add_action( 'rest_pre_serve_request', [ $this, 'send_timing_header' ] );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sends Server Timing API header with records data.
|
||||||
|
*
|
||||||
|
* @param mixed $input Pass-through input for attaching to a filter hook.
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function send_timing_header( $input ) {
|
||||||
|
|
||||||
|
if ( headers_sent() ) {
|
||||||
|
return $input;
|
||||||
|
}
|
||||||
|
|
||||||
|
$ajax = defined( 'DOING_AJAX' ) && DOING_AJAX;
|
||||||
|
$rest = defined( 'REST_REQUEST' ) && REST_REQUEST;
|
||||||
|
|
||||||
|
if ( ! $ajax && ! $rest ) {
|
||||||
|
return $input;
|
||||||
|
}
|
||||||
|
|
||||||
|
// This will be false in REST API w/o nonce, even with valid cookie. Might make sense to filter to true in dev.
|
||||||
|
if ( ! apply_filters( 'laps_can_see', current_user_can( 'manage_options' ) ) ) {
|
||||||
|
return $input;
|
||||||
|
}
|
||||||
|
|
||||||
|
$header = '';
|
||||||
|
|
||||||
|
/** @var Record_Interface $record */
|
||||||
|
foreach ( $this->collector->get_records() as $record ) {
|
||||||
|
$duration = $record->get_duration() * 1000;
|
||||||
|
|
||||||
|
if ( $duration < 1 ) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$header .= sprintf( '%s;dur=%.2f;desc="%s", ', $record->get_category(), $duration, $record->get_name() );
|
||||||
|
}
|
||||||
|
|
||||||
|
header( 'Server-Timing: ' . $header );
|
||||||
|
|
||||||
|
return $input;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,35 +1,45 @@
|
|||||||
<?php
|
<?php
|
||||||
|
declare( strict_types=1 );
|
||||||
|
|
||||||
namespace Rarst\Laps\Manager;
|
namespace Rarst\Laps\Manager;
|
||||||
|
|
||||||
use Rarst\Laps\Record\Recursive_Record_Iterator;
|
use Mustache_Engine;
|
||||||
|
use Rarst\Laps\Record\Collector\Record_Collector_Interface;
|
||||||
|
use Rarst\Laps\Record\Iterator\Recursive_Record_Iterator;
|
||||||
use Rarst\Laps\Plugin;
|
use Rarst\Laps\Plugin;
|
||||||
use Rarst\Laps\Record\Timeline_Iterator;
|
use Rarst\Laps\Record\Iterator\Timeline_Iterator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implements toolbar menu and visualization.
|
* Implements toolbar menu and visualization.
|
||||||
*/
|
*/
|
||||||
class Toolbar_Manager {
|
class Toolbar_Manager {
|
||||||
|
|
||||||
/** @var Plugin $laps */
|
/** @var Record_Collector_Interface $collector */
|
||||||
protected $laps;
|
protected $collector;
|
||||||
|
|
||||||
|
/** @var Mustache_Engine */
|
||||||
|
private $mustache;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Plugin $laps Container instance.
|
* @param Record_Collector_Interface $collector Collector of all records..
|
||||||
|
* @param Mustache_Engine $mustache Mustache instance.
|
||||||
*/
|
*/
|
||||||
public function __construct( Plugin $laps ) {
|
public function __construct( Record_Collector_Interface $collector, Mustache_Engine $mustache ) {
|
||||||
|
|
||||||
$this->laps = $laps;
|
$this->collector = $collector;
|
||||||
|
$this->mustache = $mustache;
|
||||||
|
|
||||||
add_action( 'admin_bar_menu', [ $this, 'admin_bar_menu' ], 100 );
|
add_action( 'admin_bar_menu', [ $this, 'admin_bar_menu' ], 1000 );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Render interface and add to the toolbar.
|
* Render interface and add to the toolbar.
|
||||||
*
|
*
|
||||||
* @param \WP_Admin_Bar $wp_admin_bar WordPress core toolbar object.
|
* @param \WP_Admin_Bar $wp_admin_bar WordPress core toolbar object.
|
||||||
|
*
|
||||||
|
* @psalm-suppress MixedArgument
|
||||||
*/
|
*/
|
||||||
public function admin_bar_menu( $wp_admin_bar ) {
|
public function admin_bar_menu( \WP_Admin_Bar $wp_admin_bar ): void {
|
||||||
|
|
||||||
if ( ! apply_filters( 'laps_can_see', current_user_can( 'manage_options' ) ) ) {
|
if ( ! apply_filters( 'laps_can_see', current_user_can( 'manage_options' ) ) ) {
|
||||||
return;
|
return;
|
||||||
@@ -45,9 +55,9 @@ class Toolbar_Manager {
|
|||||||
$wp_admin_bar->add_node( [
|
$wp_admin_bar->add_node( [
|
||||||
'id' => 'laps_output',
|
'id' => 'laps_output',
|
||||||
'parent' => 'laps',
|
'parent' => 'laps',
|
||||||
'meta' => [
|
'meta' => [ // TODO consider doing render lazily, but might not be worth the effort.
|
||||||
'html' => $this->laps['mustache']->render( 'laps', [
|
'html' => $this->mustache->render( 'laps', [
|
||||||
'timelines' => new Timeline_Iterator( new Recursive_Record_Iterator( $this->laps['records'] ) ),
|
'timelines' => new Timeline_Iterator( new Recursive_Record_Iterator( $this->collector->get_records() ) ),
|
||||||
] ),
|
] ),
|
||||||
],
|
],
|
||||||
] );
|
] );
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
declare( strict_types=1 );
|
||||||
|
|
||||||
namespace Rarst\Laps;
|
namespace Rarst\Laps;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -13,8 +15,10 @@ class Mustache_Cache_FrozenCache extends \Mustache_Cache_FilesystemCache {
|
|||||||
* @param string $value Value.
|
* @param string $value Value.
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
|
*
|
||||||
|
* @psalm-suppress InvalidScalarArgument
|
||||||
*/
|
*/
|
||||||
public function cache( $key, $value ) {
|
public function cache( $key, $value ): void {
|
||||||
|
|
||||||
$this->log(
|
$this->log(
|
||||||
\Mustache_Logger::WARNING,
|
\Mustache_Logger::WARNING,
|
||||||
|
|||||||
+9
-7
@@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
declare( strict_types=1 );
|
||||||
|
|
||||||
namespace Rarst\Laps;
|
namespace Rarst\Laps;
|
||||||
|
|
||||||
@@ -19,6 +20,9 @@ class Plugin extends Container {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $values Configuration values to apply.
|
* @param array $values Configuration values to apply.
|
||||||
|
*
|
||||||
|
* @psalm-suppress MixedArgument
|
||||||
|
* @psalm-suppress MixedAssignment
|
||||||
*/
|
*/
|
||||||
public function __construct( array $values = [] ) {
|
public function __construct( array $values = [] ) {
|
||||||
|
|
||||||
@@ -26,7 +30,7 @@ class Plugin extends Container {
|
|||||||
|
|
||||||
$laps = $this;
|
$laps = $this;
|
||||||
|
|
||||||
$laps['mustache'] = function () {
|
$laps['mustache'] = function (): \Mustache_Engine {
|
||||||
return new \Mustache_Engine( [
|
return new \Mustache_Engine( [
|
||||||
'loader' => new \Mustache_Loader_FilesystemLoader( dirname( __DIR__ ) . '/src/mustache' ),
|
'loader' => new \Mustache_Loader_FilesystemLoader( dirname( __DIR__ ) . '/src/mustache' ),
|
||||||
'cache' => new Mustache_Cache_FrozenCache( dirname( __DIR__ ) . '/src/mustache/cache' ),
|
'cache' => new Mustache_Cache_FrozenCache( dirname( __DIR__ ) . '/src/mustache/cache' ),
|
||||||
@@ -48,7 +52,7 @@ class Plugin extends Container {
|
|||||||
*
|
*
|
||||||
* @return $this|static
|
* @return $this|static
|
||||||
*/
|
*/
|
||||||
public function register( ServiceProviderInterface $provider, array $values = [] ) {
|
public function register( ServiceProviderInterface $provider, array $values = [] ): self {
|
||||||
|
|
||||||
$this->providers[] = $provider;
|
$this->providers[] = $provider;
|
||||||
|
|
||||||
@@ -59,12 +63,10 @@ class Plugin extends Container {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Start Stopwatch and timing plugin load immediately, then set up core events and needed hooks.
|
* Start Stopwatch and timing plugin load immediately, then set up core events and needed hooks.
|
||||||
|
*
|
||||||
|
* @psalm-suppress MixedAssignment
|
||||||
*/
|
*/
|
||||||
public function run() {
|
public function run(): void {
|
||||||
|
|
||||||
if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ( $this->providers as $provider ) {
|
foreach ( $this->providers as $provider ) {
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,13 @@
|
|||||||
<?php
|
<?php
|
||||||
|
declare( strict_types=1 );
|
||||||
|
|
||||||
namespace Rarst\Laps\Provider;
|
namespace Rarst\Laps\Provider;
|
||||||
|
|
||||||
use Rarst\Laps\Plugin;
|
use Rarst\Laps\Plugin;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Interface for providers that need to boot up once plugin is ready to start.
|
||||||
|
*/
|
||||||
interface Bootable_Provider_Interface {
|
interface Bootable_Provider_Interface {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -11,5 +15,5 @@ interface Bootable_Provider_Interface {
|
|||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function boot( Plugin $laps );
|
public function boot( Plugin $laps ): void;
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
declare( strict_types=1 );
|
||||||
|
|
||||||
namespace Rarst\Laps\Provider;
|
namespace Rarst\Laps\Provider;
|
||||||
|
|
||||||
@@ -18,9 +19,9 @@ class Hook_Event_Provider implements ServiceProviderInterface {
|
|||||||
/**
|
/**
|
||||||
* @param Container $pimple Container instance.
|
* @param Container $pimple Container instance.
|
||||||
*/
|
*/
|
||||||
public function register( Container $pimple ) {
|
public function register( Container $pimple ): void {
|
||||||
|
|
||||||
$pimple['hook.events'] = function () {
|
$pimple['hook.events'] = function (): array {
|
||||||
return [
|
return [
|
||||||
'core' => new Core_Events(),
|
'core' => new Core_Events(),
|
||||||
'genesis' => new Genesis_Events(),
|
'genesis' => new Genesis_Events(),
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
<?php
|
<?php
|
||||||
|
declare( strict_types=1 );
|
||||||
|
|
||||||
namespace Rarst\Laps\Provider;
|
namespace Rarst\Laps\Provider;
|
||||||
|
|
||||||
use Pimple\Container;
|
use Pimple\Container;
|
||||||
use Pimple\ServiceProviderInterface;
|
use Pimple\ServiceProviderInterface;
|
||||||
|
use Rarst\Laps\Manager\Server_Timing_Manager;
|
||||||
use Rarst\Laps\Plugin;
|
use Rarst\Laps\Plugin;
|
||||||
use Rarst\Laps\Manager\Asset_Manager;
|
use Rarst\Laps\Manager\Asset_Manager;
|
||||||
use Rarst\Laps\Manager\Load_Order_Manager;
|
use Rarst\Laps\Manager\Load_Order_Manager;
|
||||||
@@ -17,13 +19,14 @@ class Manager_Provider implements ServiceProviderInterface, Bootable_Provider_In
|
|||||||
/**
|
/**
|
||||||
* @param Container $pimple Container instance.
|
* @param Container $pimple Container instance.
|
||||||
*/
|
*/
|
||||||
public function register( Container $pimple ) {
|
public function register( Container $pimple ): void {
|
||||||
|
|
||||||
$pimple['managers'] = function ( Plugin $laps ) {
|
$pimple['managers'] = function ( Plugin $laps ): array {
|
||||||
return [
|
return [
|
||||||
new Load_Order_Manager(),
|
new Load_Order_Manager(),
|
||||||
new Asset_Manager(),
|
new Asset_Manager(),
|
||||||
new Toolbar_Manager( $laps ),
|
new Toolbar_Manager( $laps['records.lazy'], $laps['mustache'] ),
|
||||||
|
new Server_Timing_Manager( $laps['records.lazy'] ),
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -31,7 +34,7 @@ class Manager_Provider implements ServiceProviderInterface, Bootable_Provider_In
|
|||||||
/**
|
/**
|
||||||
* @param Plugin $laps Container instance.
|
* @param Plugin $laps Container instance.
|
||||||
*/
|
*/
|
||||||
public function boot( Plugin $laps ) {
|
public function boot( Plugin $laps ): void {
|
||||||
$laps['managers'];
|
$laps['managers'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,15 +1,16 @@
|
|||||||
<?php
|
<?php
|
||||||
|
declare( strict_types=1 );
|
||||||
|
|
||||||
namespace Rarst\Laps\Provider;
|
namespace Rarst\Laps\Provider;
|
||||||
|
|
||||||
use Pimple\Container;
|
use Pimple\Container;
|
||||||
use Pimple\ServiceProviderInterface;
|
use Pimple\ServiceProviderInterface;
|
||||||
use Rarst\Laps\Plugin;
|
use Rarst\Laps\Plugin;
|
||||||
use Rarst\Laps\Record\Core_Load_Collector;
|
use Rarst\Laps\Record\Collector\Core_Load_Collector;
|
||||||
use Rarst\Laps\Record\Hook_Record_Collector;
|
use Rarst\Laps\Record\Collector\Hook_Collector;
|
||||||
use Rarst\Laps\Record\Http_Record_Collector;
|
use Rarst\Laps\Record\Collector\Http_Collector;
|
||||||
use Rarst\Laps\Record\Record_Collector_Interface;
|
use Rarst\Laps\Record\Collector\Lazy_Proxy_Collector;
|
||||||
use Rarst\Laps\Record\Sql_Record_Collector;
|
use Rarst\Laps\Record\Collector\Sql_Collector;
|
||||||
use Symfony\Component\Stopwatch\Stopwatch;
|
use Symfony\Component\Stopwatch\Stopwatch;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -20,38 +21,34 @@ class Record_Provider implements ServiceProviderInterface, Bootable_Provider_Int
|
|||||||
/**
|
/**
|
||||||
* @param Container $pimple Container instance.
|
* @param Container $pimple Container instance.
|
||||||
*/
|
*/
|
||||||
public function register( Container $pimple ) {
|
public function register( Container $pimple ): void {
|
||||||
|
|
||||||
$pimple['stopwatch'] = $pimple->factory( function () {
|
$pimple['stopwatch'] = $pimple->factory( function (): Stopwatch {
|
||||||
return new Stopwatch( true );
|
return new Stopwatch( true );
|
||||||
} );
|
} );
|
||||||
|
|
||||||
$pimple['collectors'] = function ( Plugin $laps ) {
|
$pimple['collectors'] = function ( Plugin $laps ): array {
|
||||||
return [
|
return [
|
||||||
'core' => new Core_Load_Collector(),
|
'core' => new Core_Load_Collector(),
|
||||||
'hook' => new Hook_Record_Collector( $laps['stopwatch'], $laps['hook.events'] ),
|
'hook' => new Hook_Collector( $laps['stopwatch'], $laps['hook.events'] ),
|
||||||
'http' => new Http_Record_Collector( $laps['stopwatch'] ),
|
'http' => new Http_Collector( $laps['stopwatch'] ),
|
||||||
'sql' => new Sql_Record_Collector(),
|
'sql' => new Sql_Collector(),
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
$pimple['records'] = function ( Plugin $laps ) {
|
$pimple['records.lazy'] = function ( Plugin $laps ): Lazy_Proxy_Collector {
|
||||||
|
return new Lazy_Proxy_Collector( $laps['collectors'] );
|
||||||
|
};
|
||||||
|
|
||||||
$records = [];
|
$pimple['records'] = function ( Plugin $laps ): array {
|
||||||
|
return $laps['records.lazy']->get_records();
|
||||||
/** @var Record_Collector_Interface $collector */
|
|
||||||
foreach ( $laps['collectors'] as $collector ) {
|
|
||||||
$records[] = $collector->get_records();
|
|
||||||
}
|
|
||||||
|
|
||||||
return array_merge( ...$records );
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Plugin $laps Container instance.
|
* @param Plugin $laps Container instance.
|
||||||
*/
|
*/
|
||||||
public function boot( Plugin $laps ) {
|
public function boot( Plugin $laps ): void {
|
||||||
$laps['collectors'];
|
$laps['collectors'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
|
declare( strict_types=1 );
|
||||||
|
|
||||||
namespace Rarst\Laps\Record;
|
namespace Rarst\Laps\Record\Collector;
|
||||||
|
|
||||||
|
use Rarst\Laps\Record\Record;
|
||||||
|
use Rarst\Laps\Record\Record_Interface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Covers pre–plugin load time from available data.
|
* Covers pre–plugin load time from available data.
|
||||||
@@ -20,12 +24,16 @@ class Core_Load_Collector implements Record_Collector_Interface {
|
|||||||
/**
|
/**
|
||||||
* @return Record_Interface[]
|
* @return Record_Interface[]
|
||||||
*/
|
*/
|
||||||
public function get_records() {
|
public function get_records(): array {
|
||||||
|
|
||||||
global $timestart;
|
global $timestart;
|
||||||
|
|
||||||
$request_time = $_SERVER['REQUEST_TIME_FLOAT'];
|
$request_time = filter_var( $_SERVER['REQUEST_TIME_FLOAT'], FILTER_VALIDATE_FLOAT );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var float $request_time
|
||||||
|
* @var float $timestart
|
||||||
|
*/
|
||||||
return [
|
return [
|
||||||
new Record( 'PHP Load', $request_time, $timestart - $request_time, '', 'php' ),
|
new Record( 'PHP Load', $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.
|
||||||
@@ -0,0 +1,209 @@
|
|||||||
|
<?php
|
||||||
|
declare( strict_types=1 );
|
||||||
|
|
||||||
|
namespace Rarst\Laps\Record\Collector;
|
||||||
|
|
||||||
|
use Rarst\Laps\Event\Hook_Event_Config_Interface;
|
||||||
|
use Rarst\Laps\Formatter\Hook_Formatter;
|
||||||
|
use Rarst\Laps\Record\Stopwatch_Record;
|
||||||
|
use Symfony\Component\Stopwatch\Stopwatch;
|
||||||
|
use Symfony\Component\Stopwatch\StopwatchEvent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Processes events based on hooked starts and stops.
|
||||||
|
*/
|
||||||
|
class Hook_Collector extends Stopwatch_Collector {
|
||||||
|
|
||||||
|
/** @var Hook_Event_Config_Interface[] $event_configs */
|
||||||
|
protected $event_configs = [];
|
||||||
|
|
||||||
|
/** @var array $events */
|
||||||
|
protected $events = [];
|
||||||
|
|
||||||
|
/** @var array */
|
||||||
|
protected $callbacks = [];
|
||||||
|
|
||||||
|
/** @var Hook_Formatter */
|
||||||
|
protected $formatter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Stopwatch $stopwatch Stopwatch instance.
|
||||||
|
* @param Hook_Event_Config_Interface[] $event_configs Starts and stops configuration.
|
||||||
|
*/
|
||||||
|
public function __construct( Stopwatch $stopwatch, array $event_configs ) {
|
||||||
|
|
||||||
|
parent::__construct( $stopwatch );
|
||||||
|
|
||||||
|
$this->start( 'Plugins Load', 'plugin' );
|
||||||
|
$this->add_events( $event_configs['core']->get_events() );
|
||||||
|
unset( $event_configs['core'] );
|
||||||
|
$this->event_configs = $event_configs;
|
||||||
|
|
||||||
|
add_action( 'after_setup_theme', [ $this, 'after_setup_theme' ], 15 );
|
||||||
|
|
||||||
|
$this->formatter = new Hook_Formatter();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hook events by name and priority from array.
|
||||||
|
*
|
||||||
|
* @param array $stops Starts and stops to hook.
|
||||||
|
*/
|
||||||
|
public function add_events( array $stops ): void {
|
||||||
|
|
||||||
|
$this->events = array_merge( $this->events, $stops );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var int|string $key
|
||||||
|
* @var array $data
|
||||||
|
*/
|
||||||
|
foreach ( $stops as $key => $data ) {
|
||||||
|
|
||||||
|
if ( is_int( $key ) ) {
|
||||||
|
/** @var array{0:string} $data */
|
||||||
|
$this->add_event( ...$data );
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @var int $priority */
|
||||||
|
foreach ( array_keys( $data ) as $priority ) {
|
||||||
|
add_action( $key, [ $this, 'tick' ], $priority );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a start/stop pair of hook event.
|
||||||
|
*
|
||||||
|
* @param string $event Hook event name.
|
||||||
|
* @param string $category Hook event category.
|
||||||
|
* @param string $start Start hook name. Pass empty string to ignore.
|
||||||
|
* @param string|null $stop Stop hook name (defaults to start name). Pass empty string to ignore.
|
||||||
|
* @param int $start_priority Start hook priority (defaults to -1).
|
||||||
|
* @param int $stop_priority Stop hook priority (defaults to max int).
|
||||||
|
*/
|
||||||
|
private function add_event(
|
||||||
|
string $event,
|
||||||
|
string $category,
|
||||||
|
string $start,
|
||||||
|
?string $stop = null,
|
||||||
|
int $start_priority = - 1,
|
||||||
|
int $stop_priority = PHP_INT_MAX
|
||||||
|
): void {
|
||||||
|
if ( null === $stop ) {
|
||||||
|
$stop = $start;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( '' !== $start ) {
|
||||||
|
add_action( $start, function ( $input = null ) use ( $event, $category, $start, $stop ) {
|
||||||
|
|
||||||
|
if ( 'Sidebar' === $event ) {
|
||||||
|
$event = $input;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( $start === $stop ) {
|
||||||
|
global $wp_filter;
|
||||||
|
$this->callbacks[ $event ] = $wp_filter[ $start ];
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->start( $event, $category );
|
||||||
|
|
||||||
|
return $input;
|
||||||
|
}, $start_priority );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( '' !== $stop ) {
|
||||||
|
add_action( $stop, function ( $input = null ) use ( $event ) {
|
||||||
|
|
||||||
|
if ( 'Sidebar' === $event ) {
|
||||||
|
$event = $input;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->stop( $event );
|
||||||
|
|
||||||
|
return $input;
|
||||||
|
}, $stop_priority );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* When theme is done possibly add vendor-specific events.
|
||||||
|
*/
|
||||||
|
public function after_setup_theme(): void {
|
||||||
|
|
||||||
|
foreach ( $this->event_configs as $config ) {
|
||||||
|
$this->add_events( $config->get_events() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mark action for the event on Stopwatch.
|
||||||
|
*
|
||||||
|
* @deprecated 3.0:4.0 Deprecated in favor of the new format.
|
||||||
|
* @codeCoverageIgnore
|
||||||
|
*
|
||||||
|
* @param mixed $input Pass through if added to filter.
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function tick( $input = null ) {
|
||||||
|
|
||||||
|
global $wp_filter;
|
||||||
|
|
||||||
|
/** @var string $filter_name */
|
||||||
|
$filter_name = current_filter();
|
||||||
|
/**
|
||||||
|
* @var \WP_Hook|array $filter_instance
|
||||||
|
* @var array<string,\WP_hook|array> $wp_filter
|
||||||
|
*/
|
||||||
|
$filter_instance = $wp_filter[ $filter_name ];
|
||||||
|
/** @var int $priority */
|
||||||
|
$priority = $filter_instance instanceof \WP_Hook ? $filter_instance->current_priority() : key( $filter_instance );
|
||||||
|
|
||||||
|
// See https://core.trac.wordpress.org/ticket/41185 on broken priority, but more general sanity check.
|
||||||
|
if ( empty( $this->events[ $filter_name ][ $priority ] ) ) {
|
||||||
|
return $input;
|
||||||
|
}
|
||||||
|
|
||||||
|
$event = \wp_parse_args( $this->events[ $filter_name ][ $priority ], [
|
||||||
|
'action' => 'start',
|
||||||
|
'category' => null,
|
||||||
|
] );
|
||||||
|
|
||||||
|
if ( 'start' === $event['action'] ) {
|
||||||
|
$this->start( $event['event'], $event['category'] );
|
||||||
|
} else {
|
||||||
|
$this->stop( $event['event'] );
|
||||||
|
}
|
||||||
|
|
||||||
|
return $input;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Stopwatch_Record[]
|
||||||
|
*/
|
||||||
|
public function get_records(): array {
|
||||||
|
|
||||||
|
$this->stop( 'Toolbar' );
|
||||||
|
$this->stop( 'Footer Hook' );
|
||||||
|
|
||||||
|
return parent::get_records();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $name Event name.
|
||||||
|
* @param StopwatchEvent $event Stopwatch event instance.
|
||||||
|
*
|
||||||
|
* @return Stopwatch_Record
|
||||||
|
*/
|
||||||
|
protected function transform( string $name, StopwatchEvent $event ): Stopwatch_Record {
|
||||||
|
|
||||||
|
$description = '';
|
||||||
|
|
||||||
|
if ( isset( $this->callbacks[ $name ] ) ) {
|
||||||
|
$description = implode( '<br />', $this->formatter->format( $this->callbacks[ $name ] ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
return new Stopwatch_Record( $name, $event, $description );
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,84 @@
|
|||||||
|
<?php
|
||||||
|
declare( strict_types=1 );
|
||||||
|
|
||||||
|
namespace Rarst\Laps\Record\Collector;
|
||||||
|
|
||||||
|
use Rarst\Laps\Formatter\Backtrace_Formatter;
|
||||||
|
use Rarst\Laps\Record\Stopwatch_Record;
|
||||||
|
use Symfony\Component\Stopwatch\Stopwatch;
|
||||||
|
use Symfony\Component\Stopwatch\StopwatchEvent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Captures time of network requests made with HTTP API.
|
||||||
|
*/
|
||||||
|
class Http_Collector extends Stopwatch_Collector {
|
||||||
|
|
||||||
|
/** @var Backtrace_Formatter */
|
||||||
|
private $formatter;
|
||||||
|
|
||||||
|
/** @var array */
|
||||||
|
private $callers = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Stopwatch $stopwatch Stopwatch instance.
|
||||||
|
*/
|
||||||
|
public function __construct( Stopwatch $stopwatch ) {
|
||||||
|
|
||||||
|
parent::__construct( $stopwatch );
|
||||||
|
|
||||||
|
$this->formatter = new Backtrace_Formatter();
|
||||||
|
|
||||||
|
add_action( 'pre_http_request', [ $this, 'pre_http_request' ], 10, 3 );
|
||||||
|
add_action( 'http_api_debug', [ $this, 'http_api_debug' ], 10, 5 );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Capture start time of HTTP request
|
||||||
|
*
|
||||||
|
* @param false|array|\WP_Error $false Whether to preempt an HTTP request's return value. Default false.
|
||||||
|
* @param array $args HTTP request arguments.
|
||||||
|
* @param string $url The request URL.
|
||||||
|
*
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
public function pre_http_request( $false, array $args, string $url ) {
|
||||||
|
|
||||||
|
$this->start( $url, 'http' );
|
||||||
|
$this->callers[ $url ] = wp_debug_backtrace_summary( __CLASS__, 5 );
|
||||||
|
|
||||||
|
return $false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Capture end time of HTTP request
|
||||||
|
*
|
||||||
|
* @param array|\WP_Error $response HTTP response or WP_Error object.
|
||||||
|
* @param string $type Context under which the hook is fired.
|
||||||
|
* @param object $class HTTP transport used.
|
||||||
|
* @param array $args HTTP request arguments.
|
||||||
|
* @param string $url The request URL.
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
*
|
||||||
|
* @noinspection MoreThanThreeArgumentsInspection
|
||||||
|
*/
|
||||||
|
public function http_api_debug( $response, string $type, $class, array $args, string $url ) {
|
||||||
|
|
||||||
|
$this->stop( $url );
|
||||||
|
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $name Event name.
|
||||||
|
* @param StopwatchEvent $event Stopwatch event instance.
|
||||||
|
*
|
||||||
|
* @return Stopwatch_Record
|
||||||
|
*/
|
||||||
|
public function transform( string $name, StopwatchEvent $event ): Stopwatch_Record {
|
||||||
|
|
||||||
|
$backtrace = $this->formatter->format( $this->callers[ $name ] );
|
||||||
|
|
||||||
|
return new Stopwatch_Record( $name, $event, implode( '<br />', $backtrace ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
<?php
|
||||||
|
declare( strict_types=1 );
|
||||||
|
|
||||||
|
namespace Rarst\Laps\Record\Collector;
|
||||||
|
|
||||||
|
use Rarst\Laps\Record\Record_Interface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Collects records from concrete collectors set on access.
|
||||||
|
*/
|
||||||
|
class Lazy_Proxy_Collector implements Record_Collector_Interface {
|
||||||
|
|
||||||
|
/** @var array|Record_Collector_Interface[] */
|
||||||
|
private $collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Lazy_Proxy_Collector constructor.
|
||||||
|
*
|
||||||
|
* @param Record_Collector_Interface[] $collectors Array of collectors to store for processing.
|
||||||
|
*/
|
||||||
|
public function __construct( array $collectors ) {
|
||||||
|
$this->collectors = $collectors;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Record_Interface[]
|
||||||
|
*/
|
||||||
|
public function get_records(): array {
|
||||||
|
$records = [];
|
||||||
|
|
||||||
|
/** @var Record_Collector_Interface $collector */
|
||||||
|
foreach ( $this->collectors as $collector ) {
|
||||||
|
$records[] = $collector->get_records();
|
||||||
|
}
|
||||||
|
|
||||||
|
return count( $records ) ? array_merge( ...$records ) : [];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
<?php
|
||||||
|
declare( strict_types=1 );
|
||||||
|
|
||||||
|
namespace Rarst\Laps\Record\Collector;
|
||||||
|
|
||||||
|
use Rarst\Laps\Record\Record_Interface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Interface to retrieve a set of records form collector.
|
||||||
|
*/
|
||||||
|
interface Record_Collector_Interface {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Record_Interface[]
|
||||||
|
*/
|
||||||
|
public function get_records(): array;
|
||||||
|
}
|
||||||
@@ -0,0 +1,108 @@
|
|||||||
|
<?php
|
||||||
|
declare( strict_types=1 );
|
||||||
|
|
||||||
|
namespace Rarst\Laps\Record\Collector;
|
||||||
|
|
||||||
|
use Rarst\Laps\Formatter\Backtrace_Formatter;
|
||||||
|
use Rarst\Laps\Record\Record;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Processes SQL events from data logged by wpdb.
|
||||||
|
*/
|
||||||
|
class Sql_Collector implements Record_Collector_Interface {
|
||||||
|
|
||||||
|
/** @var array $query_starts Log of query start times. */
|
||||||
|
protected $query_starts = [];
|
||||||
|
|
||||||
|
/** @var Backtrace_Formatter $formatter */
|
||||||
|
protected $formatter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets up the query start time log.
|
||||||
|
*/
|
||||||
|
public function __construct() {
|
||||||
|
|
||||||
|
$this->formatter = new Backtrace_Formatter();
|
||||||
|
|
||||||
|
if ( $this->is_savequeries() ) {
|
||||||
|
add_filter( 'query', [ $this, 'query' ], 20 ); // TODO refactor when core provides time start data in 5.0.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Capture SQL queries start times
|
||||||
|
*
|
||||||
|
* @param string $query SQL query.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*
|
||||||
|
* @psalm-suppress MixedPropertyFetch
|
||||||
|
*/
|
||||||
|
public function query( $query ): string {
|
||||||
|
|
||||||
|
global $wpdb;
|
||||||
|
|
||||||
|
if ( empty( $this->query_starts ) && ! empty( $wpdb->queries ) ) {
|
||||||
|
/** @var array $wpdb->queries */
|
||||||
|
$this->query_starts[ count( $wpdb->queries ) ] = microtime( true );
|
||||||
|
} else {
|
||||||
|
$this->query_starts[] = microtime( true );
|
||||||
|
}
|
||||||
|
|
||||||
|
return $query;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Record[]
|
||||||
|
*/
|
||||||
|
public function get_records(): array {
|
||||||
|
|
||||||
|
global $wpdb;
|
||||||
|
|
||||||
|
if ( empty( $wpdb->queries ) ) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @var array $wpdb->queries */
|
||||||
|
return array_map( [ $this, 'transform' ], array_keys( $wpdb->queries ), $wpdb->queries );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
protected function is_savequeries(): bool {
|
||||||
|
|
||||||
|
return \defined( 'SAVEQUERIES' ) && SAVEQUERIES;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Transform query data, captured by core, into a Record.
|
||||||
|
*
|
||||||
|
* @param int $key Query key in captured data.
|
||||||
|
* @param array $query_data Array of captured query data.
|
||||||
|
* @psalm-param array{0: string, 1: float, 2: string} $query_data
|
||||||
|
*
|
||||||
|
* @return Record
|
||||||
|
*/
|
||||||
|
protected function transform( int $key, array $query_data ): Record {
|
||||||
|
|
||||||
|
static $last_query_end = 0;
|
||||||
|
|
||||||
|
[ $sql, $duration, $caller ] = $query_data;
|
||||||
|
|
||||||
|
/** @var float $query_start */
|
||||||
|
$query_start = $this->query_starts[ $key ] ?? $last_query_end;
|
||||||
|
$sql = trim( $sql );
|
||||||
|
$category = 'sql-read';
|
||||||
|
if ( 0 === stripos( $sql, 'INSERT' ) || 0 === stripos( $sql, 'UPDATE' ) ) {
|
||||||
|
$category = 'sql-write';
|
||||||
|
}
|
||||||
|
$last_query_end = $query_start + $duration;
|
||||||
|
|
||||||
|
$desc_duration = round( $duration * 1000 );
|
||||||
|
$backtrace = $this->formatter->format( $caller );
|
||||||
|
$description = $sql . ' – ' . $desc_duration . 'ms<hr />' . implode( '<br />', $backtrace );
|
||||||
|
|
||||||
|
return new Record( $sql, $query_start, $duration, $description, $category );
|
||||||
|
}
|
||||||
|
}
|
||||||
+8
-5
@@ -1,14 +1,16 @@
|
|||||||
<?php
|
<?php
|
||||||
|
declare( strict_types=1 );
|
||||||
|
|
||||||
namespace Rarst\Laps\Record;
|
namespace Rarst\Laps\Record\Collector;
|
||||||
|
|
||||||
|
use Rarst\Laps\Record\Stopwatch_Record;
|
||||||
use Symfony\Component\Stopwatch\Stopwatch;
|
use Symfony\Component\Stopwatch\Stopwatch;
|
||||||
use Symfony\Component\Stopwatch\StopwatchEvent;
|
use Symfony\Component\Stopwatch\StopwatchEvent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generic Stopwatch–based collector. Can be used by itself or extended.
|
* Generic Stopwatch–based collector. Can be used by itself or extended.
|
||||||
*/
|
*/
|
||||||
class Stopwatch_Record_Collector implements Record_Collector_Interface {
|
class Stopwatch_Collector implements Record_Collector_Interface {
|
||||||
|
|
||||||
/** @var Stopwatch $stopwatch */
|
/** @var Stopwatch $stopwatch */
|
||||||
protected $stopwatch;
|
protected $stopwatch;
|
||||||
@@ -26,7 +28,7 @@ class Stopwatch_Record_Collector implements Record_Collector_Interface {
|
|||||||
*
|
*
|
||||||
* @return StopwatchEvent
|
* @return StopwatchEvent
|
||||||
*/
|
*/
|
||||||
public function start( $name, $category = null ) {
|
public function start( $name, $category = null ): StopwatchEvent {
|
||||||
return $this->stopwatch->start( $name, $category );
|
return $this->stopwatch->start( $name, $category );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -47,10 +49,11 @@ class Stopwatch_Record_Collector implements Record_Collector_Interface {
|
|||||||
/**
|
/**
|
||||||
* @return Stopwatch_Record[]
|
* @return Stopwatch_Record[]
|
||||||
*/
|
*/
|
||||||
public function get_records() {
|
public function get_records(): array {
|
||||||
|
|
||||||
$events = $this->stopwatch->getSectionEvents( '__root__' );
|
$events = $this->stopwatch->getSectionEvents( '__root__' );
|
||||||
|
|
||||||
|
/** @var string $name */
|
||||||
foreach ( array_keys( $events ) as $name ) {
|
foreach ( array_keys( $events ) as $name ) {
|
||||||
if ( $this->stopwatch->isStarted( $name ) ) {
|
if ( $this->stopwatch->isStarted( $name ) ) {
|
||||||
unset( $events[ $name ] );
|
unset( $events[ $name ] );
|
||||||
@@ -66,7 +69,7 @@ class Stopwatch_Record_Collector implements Record_Collector_Interface {
|
|||||||
*
|
*
|
||||||
* @return Stopwatch_Record
|
* @return Stopwatch_Record
|
||||||
*/
|
*/
|
||||||
protected function transform( $name, StopwatchEvent $event ) {
|
protected function transform( string $name, StopwatchEvent $event ): Stopwatch_Record {
|
||||||
|
|
||||||
return new Stopwatch_Record( $name, $event );
|
return new Stopwatch_Record( $name, $event );
|
||||||
}
|
}
|
||||||
@@ -1,104 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Rarst\Laps\Record;
|
|
||||||
|
|
||||||
use Rarst\Laps\Event\Hook_Event_Config_Interface;
|
|
||||||
use Symfony\Component\Stopwatch\Stopwatch;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Processes events based on hooked starts and stops.
|
|
||||||
*/
|
|
||||||
class Hook_Record_Collector extends Stopwatch_Record_Collector {
|
|
||||||
|
|
||||||
/** @var Hook_Event_Config_Interface[] $event_configs */
|
|
||||||
protected $event_configs = [];
|
|
||||||
|
|
||||||
/** @var array $events */
|
|
||||||
protected $events = [];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Stopwatch $stopwatch Stopwatch instance.
|
|
||||||
* @param array $event_configs Starts and stops configuration.
|
|
||||||
*/
|
|
||||||
public function __construct( Stopwatch $stopwatch, array $event_configs ) {
|
|
||||||
|
|
||||||
parent::__construct( $stopwatch );
|
|
||||||
|
|
||||||
$this->start( 'Plugins Load', 'plugin' );
|
|
||||||
$this->add_events( $event_configs['core']->get_events() );
|
|
||||||
unset( $event_configs['core'] );
|
|
||||||
$this->event_configs = $event_configs;
|
|
||||||
|
|
||||||
add_action( 'after_setup_theme', [ $this, 'after_setup_theme' ], 15 );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Hook events by name and priority from array.
|
|
||||||
*
|
|
||||||
* @param array $stops Starts and stops to hook.
|
|
||||||
*/
|
|
||||||
public function add_events( $stops ) {
|
|
||||||
|
|
||||||
$this->events = array_merge( $this->events, $stops );
|
|
||||||
|
|
||||||
foreach ( $stops as $hook_name => $data ) {
|
|
||||||
foreach ( array_keys( $data ) as $priority ) {
|
|
||||||
add_action( $hook_name, [ $this, 'tick' ], $priority );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* When theme is done possibly add vendor-specific events.
|
|
||||||
*/
|
|
||||||
public function after_setup_theme() {
|
|
||||||
|
|
||||||
foreach ( $this->event_configs as $config ) {
|
|
||||||
$this->add_events( $config->get_events() );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Mark action for the event on Stopwatch.
|
|
||||||
*
|
|
||||||
* @param mixed $input Pass through if added to filter.
|
|
||||||
*
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public function tick( $input = null ) {
|
|
||||||
|
|
||||||
global $wp_filter;
|
|
||||||
|
|
||||||
$filter_name = current_filter();
|
|
||||||
$filter_instance = $wp_filter[ $filter_name ];
|
|
||||||
$priority = $filter_instance instanceof \WP_Hook ? $filter_instance->current_priority() : key( $filter_instance );
|
|
||||||
|
|
||||||
// See https://core.trac.wordpress.org/ticket/41185 on broken priority, but more general sanity check.
|
|
||||||
if ( empty( $this->events[ $filter_name ][ $priority ] ) ) {
|
|
||||||
return $input;
|
|
||||||
}
|
|
||||||
|
|
||||||
$event = wp_parse_args( $this->events[ $filter_name ][ $priority ], [
|
|
||||||
'action' => 'start',
|
|
||||||
'category' => null,
|
|
||||||
] );
|
|
||||||
|
|
||||||
if ( 'start' === $event['action'] ) {
|
|
||||||
$this->start( $event['event'], $event['category'] );
|
|
||||||
} else {
|
|
||||||
$this->stop( $event['event'] );
|
|
||||||
}
|
|
||||||
|
|
||||||
return $input;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return Stopwatch_Record[]
|
|
||||||
*/
|
|
||||||
public function get_records() {
|
|
||||||
|
|
||||||
$this->stopwatch->stop( 'Toolbar' );
|
|
||||||
|
|
||||||
return parent::get_records();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,58 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Rarst\Laps\Record;
|
|
||||||
|
|
||||||
use Symfony\Component\Stopwatch\Stopwatch;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Captures time of network requests made with HTTP API.
|
|
||||||
*/
|
|
||||||
class Http_Record_Collector extends Stopwatch_Record_Collector {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Stopwatch $stopwatch Stopwatch instance.
|
|
||||||
*/
|
|
||||||
public function __construct( Stopwatch $stopwatch ) {
|
|
||||||
|
|
||||||
parent::__construct( $stopwatch );
|
|
||||||
|
|
||||||
add_action( 'pre_http_request', [ $this, 'pre_http_request' ], 10, 3 );
|
|
||||||
add_action( 'http_api_debug', [ $this, 'http_api_debug' ], 10, 5 );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Capture start time of HTTP request
|
|
||||||
*
|
|
||||||
* @param boolean $false Whether to preempt an HTTP request's return value. Default false.
|
|
||||||
* @param array $args HTTP request arguments.
|
|
||||||
* @param string $url The request URL.
|
|
||||||
*
|
|
||||||
* @return boolean
|
|
||||||
*/
|
|
||||||
public function pre_http_request( $false, $args, $url ) {
|
|
||||||
|
|
||||||
$this->start( $url, 'http' );
|
|
||||||
|
|
||||||
return $false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Capture end time of HTTP request
|
|
||||||
*
|
|
||||||
* @param array|\WP_Error $response HTTP response or WP_Error object.
|
|
||||||
* @param string $type Context under which the hook is fired.
|
|
||||||
* @param object $class HTTP transport used.
|
|
||||||
* @param array $args HTTP request arguments.
|
|
||||||
* @param string $url The request URL.
|
|
||||||
*
|
|
||||||
* @return mixed
|
|
||||||
*
|
|
||||||
* @noinspection MoreThanThreeArgumentsInspection
|
|
||||||
*/
|
|
||||||
public function http_api_debug( $response, $type, $class, $args, $url ) {
|
|
||||||
|
|
||||||
$this->stop( $url );
|
|
||||||
|
|
||||||
return $response;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+9
-6
@@ -1,20 +1,23 @@
|
|||||||
<?php
|
<?php
|
||||||
|
declare( strict_types=1 );
|
||||||
|
|
||||||
namespace Rarst\Laps\Record;
|
namespace Rarst\Laps\Record\Iterator;
|
||||||
|
|
||||||
|
use Rarst\Laps\Record\Record_Interface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Processes records, recursively bumping overlapping ones to children.
|
* Processes records, recursively bumping overlapping ones to children.
|
||||||
*/
|
*/
|
||||||
class Recursive_Record_Iterator extends \ArrayIterator implements \RecursiveIterator {
|
class Recursive_Record_Iterator extends \ArrayIterator implements \RecursiveIterator {
|
||||||
|
|
||||||
/** @var array $children */
|
/** @var Record_Interface[] $children */
|
||||||
protected $children = [];
|
protected $children = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Record_Interface[] $records Records to process.
|
* @param Record_Interface[] $records Records to process.
|
||||||
* @param int $flags Configuration flags.
|
* @param int $flags Configuration flags.
|
||||||
*/
|
*/
|
||||||
public function __construct( array $records, $flags = 0 ) {
|
public function __construct( array $records, int $flags = 0 ) {
|
||||||
|
|
||||||
usort( $records, [ $this, 'sort_origin' ] );
|
usort( $records, [ $this, 'sort_origin' ] );
|
||||||
$end = 0;
|
$end = 0;
|
||||||
@@ -43,12 +46,12 @@ class Recursive_Record_Iterator extends \ArrayIterator implements \RecursiveIter
|
|||||||
*
|
*
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
protected function sort_origin( Record_Interface $record_a, Record_Interface $record_b ) {
|
protected function sort_origin( Record_Interface $record_a, Record_Interface $record_b ): int {
|
||||||
|
|
||||||
$origin_a = $record_a->get_origin();
|
$origin_a = $record_a->get_origin();
|
||||||
$origin_b = $record_b->get_origin();
|
$origin_b = $record_b->get_origin();
|
||||||
|
|
||||||
if ( $origin_a === $origin_b ) {
|
if ( abs( $origin_a - $origin_b ) < 0.0001 ) { // Float math! Makes nesting results more sane.
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -58,7 +61,7 @@ class Recursive_Record_Iterator extends \ArrayIterator implements \RecursiveIter
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function hasChildren() {
|
public function hasChildren(): bool {
|
||||||
|
|
||||||
return ! empty( $this->children );
|
return ! empty( $this->children );
|
||||||
}
|
}
|
||||||
@@ -1,9 +1,16 @@
|
|||||||
<?php
|
<?php
|
||||||
|
declare( strict_types=1 );
|
||||||
|
|
||||||
namespace Rarst\Laps\Record;
|
namespace Rarst\Laps\Record\Iterator;
|
||||||
|
|
||||||
|
use Rarst\Laps\Record\Record;
|
||||||
|
use Rarst\Laps\Record\Record_Interface;
|
||||||
|
use Rarst\Laps\Record\Iterator\Recursive_Record_Iterator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Processes records into sets for display by template.
|
* Processes records into sets for display by template.
|
||||||
|
*
|
||||||
|
* @psalm-suppress PropertyNotSetInConstructor
|
||||||
*/
|
*/
|
||||||
class Timeline_Iterator implements \Iterator {
|
class Timeline_Iterator implements \Iterator {
|
||||||
|
|
||||||
@@ -21,20 +28,23 @@ class Timeline_Iterator implements \Iterator {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Recursive_Record_Iterator $iterator Record iterator.
|
* @param Recursive_Record_Iterator $iterator Record iterator.
|
||||||
|
*
|
||||||
|
* @psalm-suppress PossiblyFalsePropertyAssignmentValue
|
||||||
*/
|
*/
|
||||||
public function __construct( Recursive_Record_Iterator $iterator ) {
|
public function __construct( Recursive_Record_Iterator $iterator ) {
|
||||||
|
|
||||||
$this->origin = $_SERVER['REQUEST_TIME_FLOAT'];
|
$this->origin = filter_var( $_SERVER['REQUEST_TIME_FLOAT'], FILTER_VALIDATE_FLOAT );
|
||||||
$this->iterator = $iterator;
|
$this->iterator = $iterator;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function current() {
|
public function current(): array {
|
||||||
|
|
||||||
$data = [];
|
$data = [];
|
||||||
|
|
||||||
|
/** @var Record $record */
|
||||||
foreach ( $this->current as $record ) {
|
foreach ( $this->current as $record ) {
|
||||||
$data[] = $this->prepare( $record );
|
$data[] = $this->prepare( $record );
|
||||||
}
|
}
|
||||||
@@ -45,7 +55,7 @@ class Timeline_Iterator implements \Iterator {
|
|||||||
/**
|
/**
|
||||||
* Sets current context to the next set of nested records.
|
* Sets current context to the next set of nested records.
|
||||||
*/
|
*/
|
||||||
public function next() {
|
public function next(): void {
|
||||||
$this->current = $this->current->getChildren();
|
$this->current = $this->current->getChildren();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -54,21 +64,21 @@ class Timeline_Iterator implements \Iterator {
|
|||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function key() {
|
public function key(): void {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return bool If current set contains records.
|
* @return bool If current set contains records.
|
||||||
*/
|
*/
|
||||||
public function valid() {
|
public function valid(): bool {
|
||||||
return (bool) count( $this->current );
|
return (bool) count( $this->current );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Rewind to a topmost record set.
|
* Rewind to a topmost record set.
|
||||||
*/
|
*/
|
||||||
public function rewind() {
|
public function rewind(): void {
|
||||||
$this->total = microtime( true ) - $this->origin;
|
$this->total = microtime( true ) - $this->origin;
|
||||||
$this->current = $this->iterator;
|
$this->current = $this->iterator;
|
||||||
}
|
}
|
||||||
@@ -78,7 +88,7 @@ class Timeline_Iterator implements \Iterator {
|
|||||||
*
|
*
|
||||||
* @return array Record data for display by the template.
|
* @return array Record data for display by the template.
|
||||||
*/
|
*/
|
||||||
protected function prepare( Record_Interface $record ) {
|
protected function prepare( Record_Interface $record ): array {
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'description' => $record->get_description(),
|
'description' => $record->get_description(),
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
declare( strict_types=1 );
|
||||||
|
|
||||||
namespace Rarst\Laps\Record;
|
namespace Rarst\Laps\Record;
|
||||||
|
|
||||||
@@ -29,7 +30,7 @@ class Record implements Record_Interface {
|
|||||||
* @param string $description Optional description.
|
* @param string $description Optional description.
|
||||||
* @param string $category Optional category.
|
* @param string $category Optional category.
|
||||||
*/
|
*/
|
||||||
public function __construct( $name, $origin, $duration, $description = '', $category = '' ) {
|
public function __construct( string $name, float $origin, float $duration, string $description = '', string $category = '' ) {
|
||||||
$this->name = $name;
|
$this->name = $name;
|
||||||
$this->origin = $origin;
|
$this->origin = $origin;
|
||||||
$this->duration = $duration;
|
$this->duration = $duration;
|
||||||
@@ -40,14 +41,14 @@ class Record implements Record_Interface {
|
|||||||
/**
|
/**
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function get_name() {
|
public function get_name(): string {
|
||||||
return $this->name;
|
return $this->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function get_description() {
|
public function get_description(): string {
|
||||||
|
|
||||||
if ( empty( $this->description ) ) {
|
if ( empty( $this->description ) ) {
|
||||||
$duration = round( $this->get_duration() * 1000 );
|
$duration = round( $this->get_duration() * 1000 );
|
||||||
@@ -61,21 +62,21 @@ class Record implements Record_Interface {
|
|||||||
/**
|
/**
|
||||||
* @return float
|
* @return float
|
||||||
*/
|
*/
|
||||||
public function get_origin() {
|
public function get_origin(): float {
|
||||||
return $this->origin;
|
return $this->origin;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return float
|
* @return float
|
||||||
*/
|
*/
|
||||||
public function get_duration() {
|
public function get_duration(): float {
|
||||||
return $this->duration;
|
return $this->duration;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function get_category() {
|
public function get_category(): string {
|
||||||
return $this->category;
|
return $this->category;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Rarst\Laps\Record;
|
|
||||||
|
|
||||||
interface Record_Collector_Interface {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return Record_Interface[]
|
|
||||||
*/
|
|
||||||
public function get_records();
|
|
||||||
}
|
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
declare( strict_types=1 );
|
||||||
|
|
||||||
namespace Rarst\Laps\Record;
|
namespace Rarst\Laps\Record;
|
||||||
|
|
||||||
@@ -10,25 +11,25 @@ interface Record_Interface {
|
|||||||
/**
|
/**
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function get_name();
|
public function get_name(): string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function get_description();
|
public function get_description(): string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return float Timestamp of record start.
|
* @return float Timestamp of record start.
|
||||||
*/
|
*/
|
||||||
public function get_origin();
|
public function get_origin(): float;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return float Record duration in seconds.
|
* @return float Record duration in seconds.
|
||||||
*/
|
*/
|
||||||
public function get_duration();
|
public function get_duration(): float;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function get_category();
|
public function get_category(): string;
|
||||||
}
|
}
|
||||||
@@ -1,82 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Rarst\Laps\Record;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Processes SQL events from data logged by wpdb.
|
|
||||||
*/
|
|
||||||
class Sql_Record_Collector implements Record_Collector_Interface {
|
|
||||||
|
|
||||||
/** @var array $query_starts Log of query start times. */
|
|
||||||
protected $query_starts = [];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets up the query start time log.
|
|
||||||
*/
|
|
||||||
public function __construct() {
|
|
||||||
|
|
||||||
if ( $this->is_savequeries() ) {
|
|
||||||
add_filter( 'query', [ $this, 'query' ], 20 );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Capture SQL queries start times
|
|
||||||
*
|
|
||||||
* @param string $query SQL query.
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function query( $query ) {
|
|
||||||
|
|
||||||
global $wpdb;
|
|
||||||
|
|
||||||
if ( empty( $this->query_starts ) && ! empty( $wpdb->queries ) ) {
|
|
||||||
$this->query_starts[ count( $wpdb->queries ) ] = microtime( true );
|
|
||||||
} else {
|
|
||||||
$this->query_starts[] = microtime( true );
|
|
||||||
}
|
|
||||||
|
|
||||||
return $query;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return Record[]
|
|
||||||
*/
|
|
||||||
public function get_records() {
|
|
||||||
|
|
||||||
if ( ! $this->is_savequeries() ) {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
global $wpdb;
|
|
||||||
|
|
||||||
$query_data = [];
|
|
||||||
$last_query_end = 0;
|
|
||||||
|
|
||||||
// TODO process call trace from the data.
|
|
||||||
foreach ( $wpdb->queries as $key => list( $sql, $duration ) ) {
|
|
||||||
$query_start = isset( $this->query_starts[ $key ] ) ? $this->query_starts[ $key ] : $last_query_end;
|
|
||||||
$sql = trim( $sql );
|
|
||||||
$category = 'sql-read';
|
|
||||||
|
|
||||||
if ( 0 === stripos( $sql, 'INSERT' ) || 0 === stripos( $sql, 'UPDATE' ) ) {
|
|
||||||
$category = 'sql-write';
|
|
||||||
}
|
|
||||||
|
|
||||||
$last_query_end = $query_start + $duration;
|
|
||||||
|
|
||||||
$query_data[] = new Record( $sql, $query_start, $duration, '', $category );
|
|
||||||
}
|
|
||||||
|
|
||||||
return $query_data;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
protected function is_savequeries() {
|
|
||||||
|
|
||||||
return defined( 'SAVEQUERIES' ) && SAVEQUERIES;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
declare( strict_types=1 );
|
||||||
|
|
||||||
namespace Rarst\Laps\Record;
|
namespace Rarst\Laps\Record;
|
||||||
|
|
||||||
@@ -15,51 +16,57 @@ class Stopwatch_Record implements Record_Interface {
|
|||||||
/** @var StopwatchEvent */
|
/** @var StopwatchEvent */
|
||||||
protected $stopwatch_event;
|
protected $stopwatch_event;
|
||||||
|
|
||||||
|
/** @var string */
|
||||||
|
protected $description = '';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $name Event name.
|
* @param string $name Event name.
|
||||||
* @param StopwatchEvent $stopwatch_event Stopwatch event instance.
|
* @param StopwatchEvent $stopwatch_event Stopwatch event instance.
|
||||||
|
* @param string $description Optional description for the event.
|
||||||
*/
|
*/
|
||||||
public function __construct( $name, StopwatchEvent $stopwatch_event ) {
|
public function __construct( string $name, StopwatchEvent $stopwatch_event, string $description = '' ) {
|
||||||
$this->name = $name;
|
$this->name = $name;
|
||||||
$this->stopwatch_event = $stopwatch_event;
|
$this->stopwatch_event = $stopwatch_event;
|
||||||
|
$this->description = $description;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function get_name() {
|
public function get_name(): string {
|
||||||
return $this->name;
|
return $this->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function get_description() {
|
public function get_description(): string {
|
||||||
|
|
||||||
$duration = round( $this->stopwatch_event->getDuration() );
|
$duration = round( $this->stopwatch_event->getDuration() );
|
||||||
$memory = $this->stopwatch_event->getMemory() / 1024 / 1024;
|
$memory = round( $this->stopwatch_event->getMemory() / 1024 / 1024, 2 );
|
||||||
|
$description = '' !== $this->description ? "<hr />{$this->description}" : '';
|
||||||
|
|
||||||
return "{$this->name} – {$duration} ms – {$memory} MB";
|
return "{$this->name} – {$duration} ms – {$memory} MB{$description}";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return float Timestamp of record start.
|
* @return float Timestamp of record start.
|
||||||
*/
|
*/
|
||||||
public function get_origin() {
|
public function get_origin(): float {
|
||||||
return $this->stopwatch_event->getOrigin() / 1000; // ms to s.
|
return $this->stopwatch_event->getOrigin() / 1000; // ms to s.
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return float Record duration in seconds.
|
* @return float Record duration in seconds.
|
||||||
*/
|
*/
|
||||||
public function get_duration() {
|
public function get_duration(): float {
|
||||||
return $this->stopwatch_event->getDuration() / 1000; // ms to s.
|
return $this->stopwatch_event->getDuration() / 1000; // ms to s.
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function get_category() {
|
public function get_category(): string {
|
||||||
return $this->stopwatch_event->getCategory();
|
return $this->stopwatch_event->getCategory();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,58 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Rarst\Laps\Tests\Formatter;
|
||||||
|
|
||||||
|
use Brain\Monkey\Functions;
|
||||||
|
use Rarst\Laps\Formatter\Backtrace_Formatter;
|
||||||
|
use Rarst\Laps\Tests\LapsTestCase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @coversDefaultClass Rarst\Laps\Formatter\Backtrace_Formatter
|
||||||
|
*/
|
||||||
|
class BacktraceTest extends LapsTestCase {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers ::__construct
|
||||||
|
*
|
||||||
|
* @return Backtrace_Formatter
|
||||||
|
*/
|
||||||
|
public function test__construct() {
|
||||||
|
|
||||||
|
if ( ! defined( 'ABSPATH' ) ) {
|
||||||
|
define( 'ABSPATH', '/wp' );
|
||||||
|
define( 'WP_CONTENT_DIR', '/wp-content/' );
|
||||||
|
}
|
||||||
|
|
||||||
|
Functions\expect( 'wp_normalize_path' )->zeroOrMoreTimes()->andReturnFirstArg();
|
||||||
|
|
||||||
|
return new Backtrace_Formatter();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @depends test__construct
|
||||||
|
*/
|
||||||
|
public function testFormat( Backtrace_Formatter $formatter ) {
|
||||||
|
|
||||||
|
if ( ! defined( 'ABSPATH' ) ) {
|
||||||
|
define( 'ABSPATH', '/wp' );
|
||||||
|
define( 'WP_CONTENT_DIR', '/wp-content/' );
|
||||||
|
}
|
||||||
|
|
||||||
|
Functions\expect( 'wp_normalize_path' )->zeroOrMoreTimes()->andReturnFirstArg();
|
||||||
|
|
||||||
|
$backtrace = [
|
||||||
|
'template-loader.php',
|
||||||
|
'WP_Hook->do_action',
|
||||||
|
'foo',
|
||||||
|
"include('C:/wp/path.php')",
|
||||||
|
];
|
||||||
|
|
||||||
|
$backtrace = implode( ', ', $backtrace );
|
||||||
|
|
||||||
|
$result = $formatter->format( $backtrace );
|
||||||
|
|
||||||
|
$this->assertInternalType( 'array', $result );
|
||||||
|
$this->assertArraySubset( [ 'foo', 'path.php' ], array_values( $result ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
<?php
|
||||||
|
declare( strict_types=1 );
|
||||||
|
|
||||||
|
namespace Rarst\Laps\Tests\Formatter;
|
||||||
|
|
||||||
|
use Brain\Monkey\Functions;
|
||||||
|
use Rarst\Laps\Formatter\Hook_Formatter;
|
||||||
|
use Rarst\Laps\Tests\LapsTestCase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @coversDefaultClass \Rarst\Laps\Formatter\Hook_Formatter
|
||||||
|
*/
|
||||||
|
class HookTest extends LapsTestCase {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers ::__construct
|
||||||
|
*
|
||||||
|
* @return Hook_Formatter
|
||||||
|
*/
|
||||||
|
public function test__construct() {
|
||||||
|
|
||||||
|
if ( ! defined( 'ABSPATH' ) ) {
|
||||||
|
define( 'ABSPATH', '/wp' );
|
||||||
|
define( 'WP_CONTENT_DIR', '/wp-content/' );
|
||||||
|
}
|
||||||
|
|
||||||
|
Functions\expect( 'wp_normalize_path' )->zeroOrMoreTimes()->andReturnFirstArg();
|
||||||
|
|
||||||
|
return new Hook_Formatter();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @depends test__construct
|
||||||
|
*/
|
||||||
|
public function testFormat( Hook_Formatter $formatter ) {
|
||||||
|
|
||||||
|
if ( ! defined( 'ABSPATH' ) ) {
|
||||||
|
define( 'ABSPATH', '/wp' );
|
||||||
|
define( 'WP_CONTENT_DIR', '/wp-content/' );
|
||||||
|
}
|
||||||
|
|
||||||
|
Functions\expect( 'wp_normalize_path' )->zeroOrMoreTimes()->andReturnFirstArg();
|
||||||
|
|
||||||
|
$hook = [
|
||||||
|
[ [ 'function' => 'function', 'accepted_args' => 2 ] ],
|
||||||
|
[ [ 'function' => [ 'class', 'method' ], 'accepted_args' => 1 ] ],
|
||||||
|
[ [ 'function' => function() {}, 'accepted_args' => 1 ] ],
|
||||||
|
[ [ 'function' => new class(){}, 'accepted_args' => 1 ] ],
|
||||||
|
];
|
||||||
|
|
||||||
|
$result = $formatter->format( $hook );
|
||||||
|
|
||||||
|
$this->assertInternalType( 'array', $result );
|
||||||
|
$this->assertArraySubset( [ 'function(2)', 'class::method' ], $result );
|
||||||
|
$this->assertStringStartsWith( 'closure from', $result[2] );
|
||||||
|
$this->assertStringStartsWith( 'anonymous class from', $result[3] );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -1,14 +1,15 @@
|
|||||||
<?php
|
<?php
|
||||||
|
declare( strict_types=1 );
|
||||||
|
|
||||||
namespace Rarst\Laps\Tests\Manager;
|
namespace Rarst\Laps\Tests\Manager;
|
||||||
|
|
||||||
use Brain\Monkey\Functions;
|
use Brain\Monkey\Functions;
|
||||||
use Rarst\Laps\Manager\Toolbar_Manager;
|
use Rarst\Laps\Manager\Toolbar_Manager;
|
||||||
use Rarst\Laps\Plugin;
|
use Rarst\Laps\Record\Collector\Lazy_Proxy_Collector;
|
||||||
use Rarst\Laps\Tests\LapsTestCase;
|
use Rarst\Laps\Tests\LapsTestCase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @coversDefaultClass Rarst\Laps\Manager\Toolbar_Manager
|
* @coversDefaultClass \Rarst\Laps\Manager\Toolbar_Manager
|
||||||
*/
|
*/
|
||||||
class ToolbarTest extends LapsTestCase {
|
class ToolbarTest extends LapsTestCase {
|
||||||
|
|
||||||
@@ -19,8 +20,8 @@ class ToolbarTest extends LapsTestCase {
|
|||||||
*/
|
*/
|
||||||
public function test__construct() {
|
public function test__construct() {
|
||||||
|
|
||||||
$laps = new Plugin( [ 'records' => [] ] );
|
$collector = new Lazy_Proxy_Collector( [] );
|
||||||
$manager = new Toolbar_Manager( $laps );
|
$manager = new Toolbar_Manager( $collector, new \Mustache_Engine() );
|
||||||
|
|
||||||
$this->assertTrue( has_action( 'admin_bar_menu', [ $manager, 'admin_bar_menu' ] ) );
|
$this->assertTrue( has_action( 'admin_bar_menu', [ $manager, 'admin_bar_menu' ] ) );
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace Rarst\Laps\Tests;
|
namespace Rarst\Laps\Tests;
|
||||||
|
|
||||||
|
use Brain\Monkey\Functions;
|
||||||
use Pimple\ServiceProviderInterface;
|
use Pimple\ServiceProviderInterface;
|
||||||
use Rarst\Laps\Provider\Bootable_Provider_Interface;
|
use Rarst\Laps\Provider\Bootable_Provider_Interface;
|
||||||
|
|
||||||
@@ -24,6 +25,12 @@ class PluginTest extends LapsTestCase {
|
|||||||
->method( 'boot' )
|
->method( 'boot' )
|
||||||
->with( $container );
|
->with( $container );
|
||||||
|
|
||||||
|
if ( ! defined( 'ABSPATH' ) ) {
|
||||||
|
define( 'ABSPATH', '/wp' );
|
||||||
|
define( 'WP_CONTENT_DIR', '/wp-content/' );
|
||||||
|
}
|
||||||
|
Functions\expect( 'wp_normalize_path' )->zeroOrMoreTimes()->andReturnFirstArg();
|
||||||
|
|
||||||
$container->run();
|
$container->run();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
declare( strict_types=1 );
|
||||||
|
|
||||||
namespace Rarst\Laps\Tests\Provider;
|
namespace Rarst\Laps\Tests\Provider;
|
||||||
|
|
||||||
|
use function Brain\Monkey\Functions\expect;
|
||||||
use Pimple\Exception\FrozenServiceException;
|
use Pimple\Exception\FrozenServiceException;
|
||||||
use Rarst\Laps\Plugin;
|
use Rarst\Laps\Plugin;
|
||||||
use Rarst\Laps\Provider\Manager_Provider;
|
use Rarst\Laps\Provider\Manager_Provider;
|
||||||
@@ -14,6 +16,8 @@ class ManagerTest extends LapsTestCase {
|
|||||||
*/
|
*/
|
||||||
public function testProvider() {
|
public function testProvider() {
|
||||||
|
|
||||||
|
expect( 'wp_normalize_path' )->zeroOrMoreTimes()->andReturnFirstArg();
|
||||||
|
|
||||||
$container = new Plugin();
|
$container = new Plugin();
|
||||||
$provider = new Manager_Provider();
|
$provider = new Manager_Provider();
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace Rarst\Laps\Tests\Provider;
|
namespace Rarst\Laps\Tests\Provider;
|
||||||
|
|
||||||
|
use Brain\Monkey\Functions;
|
||||||
use Pimple\Exception\FrozenServiceException;
|
use Pimple\Exception\FrozenServiceException;
|
||||||
use Rarst\Laps\Plugin;
|
use Rarst\Laps\Plugin;
|
||||||
use Rarst\Laps\Provider\Record_Provider;
|
use Rarst\Laps\Provider\Record_Provider;
|
||||||
@@ -24,6 +25,12 @@ class RecordTest extends LapsTestCase {
|
|||||||
|
|
||||||
$this->assertNotSame( $stopwatch_a, $stopwatch_b );
|
$this->assertNotSame( $stopwatch_a, $stopwatch_b );
|
||||||
|
|
||||||
|
if ( ! defined( 'ABSPATH' ) ) {
|
||||||
|
define( 'ABSPATH', '/wp' );
|
||||||
|
define( 'WP_CONTENT_DIR', '/wp-content/' );
|
||||||
|
}
|
||||||
|
Functions\expect( 'wp_normalize_path' )->zeroOrMoreTimes()->andReturnFirstArg();
|
||||||
|
|
||||||
$this->assertArrayHasKey( 'records', $container );
|
$this->assertArrayHasKey( 'records', $container );
|
||||||
|
|
||||||
$container->extend( 'collectors', function () {} );
|
$container->extend( 'collectors', function () {} );
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace Rarst\Laps\Tests\Record;
|
namespace Rarst\Laps\Tests\Record;
|
||||||
|
|
||||||
use Rarst\Laps\Record\Core_Load_Collector;
|
use Rarst\Laps\Record\Collector\Core_Load_Collector;
|
||||||
use Rarst\Laps\Record\Record_Interface;
|
use Rarst\Laps\Record\Record_Interface;
|
||||||
use Rarst\Laps\Tests\LapsTestCase;
|
use Rarst\Laps\Tests\LapsTestCase;
|
||||||
|
|
||||||
@@ -10,6 +10,9 @@ class CoreTest extends LapsTestCase {
|
|||||||
|
|
||||||
public function testCollector() {
|
public function testCollector() {
|
||||||
|
|
||||||
|
global $timestart;
|
||||||
|
$timestart = microtime( true );;
|
||||||
|
|
||||||
$collector = new Core_Load_Collector();
|
$collector = new Core_Load_Collector();
|
||||||
|
|
||||||
$records = $collector->get_records();
|
$records = $collector->get_records();
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
<?php
|
<?php
|
||||||
|
declare( strict_types=1 );
|
||||||
|
|
||||||
namespace Rarst\Laps\Tests\Record;
|
namespace Rarst\Laps\Tests\Record;
|
||||||
|
|
||||||
use Brain\Monkey\Functions;
|
use function Brain\Monkey\Functions\expect;
|
||||||
use Rarst\Laps\Event\Core_Events;
|
use Rarst\Laps\Event\Core_Events;
|
||||||
use Rarst\Laps\Record\Hook_Record_Collector;
|
use Rarst\Laps\Record\Collector\Hook_Collector;
|
||||||
use Rarst\Laps\Tests\LapsTestCase;
|
use Rarst\Laps\Tests\LapsTestCase;
|
||||||
use Symfony\Component\Stopwatch\Stopwatch;
|
use Symfony\Component\Stopwatch\Stopwatch;
|
||||||
|
|
||||||
@@ -12,32 +13,17 @@ class HookTest extends LapsTestCase {
|
|||||||
|
|
||||||
public function testCollector() {
|
public function testCollector() {
|
||||||
|
|
||||||
|
expect( 'wp_normalize_path' )->zeroOrMoreTimes()->andReturnFirstArg();
|
||||||
|
|
||||||
$stopwatch = new Stopwatch();
|
$stopwatch = new Stopwatch();
|
||||||
$collector = new Hook_Record_Collector( $stopwatch, [ 'core' => new Core_Events() ] );
|
$collector = new Hook_Collector( $stopwatch, [ 'core' => new Core_Events() ] );
|
||||||
|
|
||||||
$this->assertTrue( $stopwatch->isStarted( 'Plugins Load' ) );
|
$this->assertTrue( $stopwatch->isStarted( 'Plugins Load' ) );
|
||||||
$this->assertTrue( has_action( 'after_setup_theme', [ $collector, 'after_setup_theme' ] ) );
|
$this->assertTrue( has_action( 'after_setup_theme', [ $collector, 'after_setup_theme' ] ) );
|
||||||
|
|
||||||
|
$this->assertTrue( has_action( 'plugins_loaded', 'function ($input)' ) );
|
||||||
|
|
||||||
$collector->after_setup_theme();
|
$collector->after_setup_theme();
|
||||||
|
|
||||||
Functions\expect( 'current_filter' )->once()->andReturn( 'plugins_loaded' );
|
|
||||||
Functions\expect( 'wp_parse_args' )->once()->andReturnFirstArg();
|
|
||||||
|
|
||||||
global $wp_filter;
|
|
||||||
|
|
||||||
$wp_hook = $this->getMockBuilder( 'WP_Hook' )
|
|
||||||
->allowMockingUnknownTypes()
|
|
||||||
->setMethods( [ 'current_priority' ] )
|
|
||||||
->getMock();
|
|
||||||
|
|
||||||
$wp_hook->method( 'current_priority' )->willReturn( - 2 );
|
|
||||||
|
|
||||||
$wp_filter['plugins_loaded'] = $wp_hook;
|
|
||||||
|
|
||||||
$collector->tick();
|
|
||||||
|
|
||||||
$this->assertFalse( $stopwatch->isStarted( 'Plugins Load' ) );
|
|
||||||
|
|
||||||
$stopwatch->start( 'Toolbar' );
|
$stopwatch->start( 'Toolbar' );
|
||||||
$collector->get_records();
|
$collector->get_records();
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,8 @@
|
|||||||
|
|
||||||
namespace Rarst\Laps\Tests\Record;
|
namespace Rarst\Laps\Tests\Record;
|
||||||
|
|
||||||
use Rarst\Laps\Record\Http_Record_Collector;
|
use Brain\Monkey\Functions;
|
||||||
|
use Rarst\Laps\Record\Collector\Http_Collector;
|
||||||
use Rarst\Laps\Tests\LapsTestCase;
|
use Rarst\Laps\Tests\LapsTestCase;
|
||||||
use Symfony\Component\Stopwatch\Stopwatch;
|
use Symfony\Component\Stopwatch\Stopwatch;
|
||||||
|
|
||||||
@@ -10,9 +11,12 @@ class HttpTest extends LapsTestCase {
|
|||||||
|
|
||||||
public function testCollector() {
|
public function testCollector() {
|
||||||
|
|
||||||
|
Functions\expect( 'wp_normalize_path' )->zeroOrMoreTimes()->andReturnFirstArg();
|
||||||
|
Functions\expect( 'wp_debug_backtrace_summary' )->zeroOrMoreTimes()->andReturn( [] );
|
||||||
|
|
||||||
$stopwatch = new Stopwatch();
|
$stopwatch = new Stopwatch();
|
||||||
$url = 'https://example.com/';
|
$url = 'https://example.com/';
|
||||||
$collector = new Http_Record_Collector( $stopwatch );
|
$collector = new Http_Collector( $stopwatch );
|
||||||
|
|
||||||
$this->assertTrue( has_action( 'pre_http_request', [ $collector, 'pre_http_request' ] ) );
|
$this->assertTrue( has_action( 'pre_http_request', [ $collector, 'pre_http_request' ] ) );
|
||||||
$this->assertTrue( has_action( 'http_api_debug', [ $collector, 'http_api_debug' ] ) );
|
$this->assertTrue( has_action( 'http_api_debug', [ $collector, 'http_api_debug' ] ) );
|
||||||
|
|||||||
@@ -2,17 +2,17 @@
|
|||||||
|
|
||||||
namespace Rarst\Laps\Tests\Record;
|
namespace Rarst\Laps\Tests\Record;
|
||||||
|
|
||||||
use Rarst\Laps\Record\Recursive_Record_Iterator;
|
use Rarst\Laps\Record\Iterator\Recursive_Record_Iterator;
|
||||||
use Rarst\Laps\Record\Record;
|
use Rarst\Laps\Record\Record;
|
||||||
use Rarst\Laps\Record\Timeline_Iterator;
|
use Rarst\Laps\Record\Iterator\Timeline_Iterator;
|
||||||
use Rarst\Laps\Tests\LapsTestCase;
|
use Rarst\Laps\Tests\LapsTestCase;
|
||||||
|
|
||||||
class IteratorTest extends LapsTestCase {
|
class IteratorTest extends LapsTestCase {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers \Rarst\Laps\Record\Recursive_Record_Iterator
|
* @covers \Rarst\Laps\Record\Iterator\Recursive_Record_Iterator
|
||||||
*
|
*
|
||||||
* @return Recursive_Record_Iterator
|
* @return \Rarst\Laps\Record\Iterator\Recursive_Record_Iterator
|
||||||
*/
|
*/
|
||||||
public function testRecord() {
|
public function testRecord() {
|
||||||
|
|
||||||
@@ -41,7 +41,7 @@ class IteratorTest extends LapsTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers \Rarst\Laps\Record\Timeline_Iterator
|
* @covers \Rarst\Laps\Record\Iterator\Timeline_Iterator
|
||||||
*
|
*
|
||||||
* @depends testRecord
|
* @depends testRecord
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -2,20 +2,27 @@
|
|||||||
|
|
||||||
namespace Rarst\Laps\Tests\Record;
|
namespace Rarst\Laps\Tests\Record;
|
||||||
|
|
||||||
|
use Brain\Monkey\Functions;
|
||||||
use Rarst\Laps\Record\Record;
|
use Rarst\Laps\Record\Record;
|
||||||
use Rarst\Laps\Record\Sql_Record_Collector;
|
use Rarst\Laps\Record\Collector\Sql_Collector;
|
||||||
use Rarst\Laps\Tests\LapsTestCase;
|
use Rarst\Laps\Tests\LapsTestCase;
|
||||||
|
|
||||||
class SqlTest extends LapsTestCase {
|
class SqlTest extends LapsTestCase {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers \Rarst\Laps\Record\Sql_Record_Collector
|
* @covers \Rarst\Laps\Record\Collector\Sql_Collector
|
||||||
*/
|
*/
|
||||||
public function testCollector() {
|
public function testCollector() {
|
||||||
|
|
||||||
define( 'SAVEQUERIES', true );
|
define( 'SAVEQUERIES', true );
|
||||||
|
|
||||||
$collector = new Sql_Record_Collector();
|
if ( ! defined( 'ABSPATH' ) ) {
|
||||||
|
define( 'ABSPATH', '/wp' );
|
||||||
|
define( 'WP_CONTENT_DIR', '/wp-content/' );
|
||||||
|
}
|
||||||
|
Functions\expect( 'wp_normalize_path' )->zeroOrMoreTimes()->andReturnFirstArg();
|
||||||
|
|
||||||
|
$collector = new Sql_Collector();
|
||||||
|
|
||||||
$this->assertTrue( has_filter( 'query', [ $collector, 'query' ] ) );
|
$this->assertTrue( has_filter( 'query', [ $collector, 'query' ] ) );
|
||||||
|
|
||||||
@@ -27,7 +34,7 @@ class SqlTest extends LapsTestCase {
|
|||||||
|
|
||||||
$wpdb = new \stdClass();
|
$wpdb = new \stdClass();
|
||||||
$duration = 100;
|
$duration = 100;
|
||||||
$wpdb->queries[] = [ $query, $duration ];
|
$wpdb->queries[] = [ $query, $duration, 'foo(), bar()' ];
|
||||||
|
|
||||||
$records = $collector->get_records();
|
$records = $collector->get_records();
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
namespace Rarst\Laps\Tests\Record;
|
namespace Rarst\Laps\Tests\Record;
|
||||||
|
|
||||||
use Rarst\Laps\Record\Stopwatch_Record;
|
use Rarst\Laps\Record\Stopwatch_Record;
|
||||||
use Rarst\Laps\Record\Stopwatch_Record_Collector;
|
use Rarst\Laps\Record\Collector\Stopwatch_Collector;
|
||||||
use Rarst\Laps\Tests\LapsTestCase;
|
use Rarst\Laps\Tests\LapsTestCase;
|
||||||
use Symfony\Component\Stopwatch\Stopwatch;
|
use Symfony\Component\Stopwatch\Stopwatch;
|
||||||
use Symfony\Component\Stopwatch\StopwatchEvent;
|
use Symfony\Component\Stopwatch\StopwatchEvent;
|
||||||
@@ -11,11 +11,11 @@ use Symfony\Component\Stopwatch\StopwatchEvent;
|
|||||||
class StopwatchTest extends LapsTestCase {
|
class StopwatchTest extends LapsTestCase {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers \Rarst\Laps\Record\Stopwatch_Record_Collector
|
* @covers \Rarst\Laps\Record\Collector\Stopwatch_Collector
|
||||||
*/
|
*/
|
||||||
public function testCollector() {
|
public function testCollector() {
|
||||||
|
|
||||||
$collector = new Stopwatch_Record_Collector( new Stopwatch() );
|
$collector = new Stopwatch_Collector( new Stopwatch() );
|
||||||
|
|
||||||
$collector->start( 'Event', 'info' );
|
$collector->start( 'Event', 'info' );
|
||||||
$collector->start( 'Not stopped', 'info' );
|
$collector->start( 'Not stopped', 'info' );
|
||||||
|
|||||||
Reference in new issue
Block a user