129 Commits
Author SHA1 Message Date
Andrey Savchenko c874c19c91 Updated documentation for v2 release. 2018-02-26 10:42:11 +02:00
Andrey Savchenko 221a902671 Adjusted SQL and default colors. 2018-02-26 09:17:39 +02:00
Andrey Savchenko ac0a187ec4 Excluded mustache cache from code coverage. 2018-02-23 17:06:53 +02:00
Andrey Savchenko 06d2136528 Dropped flat style from badges. 2018-02-23 17:06:37 +02:00
Andrey Savchenko beb68aede2 Added explicit PHP version requirement and updated badges. 2018-02-23 16:38:15 +02:00
Andrey Savchenko b837508181 Updated event colors. 2018-02-23 16:28:55 +02:00
Andrey Savchenko d92a778d10 Adjusted structure for PDS skeleton. 2018-02-23 15:32:18 +02:00
Andrey Savchenko 4238509861 Added PHP and core load collector. 2018-02-23 15:12:29 +02:00
Andrey Savchenko e74777c2a9 Added generic constructor–centric record class. 2018-02-23 14:40:45 +02:00
Andrey Savchenko 3cae2765cb Fixed stopwatch record duration test that didn’t test properly. 2018-02-22 18:19:34 +02:00
Andrey Savchenko 35e8caf1e4 Fixed stopwatch record test for origin time. 2018-02-22 18:04:00 +02:00
Andrey Savchenko 7cc65ca1a2 Fixed stacking of events that are just very close to each other. 2018-02-22 18:01:46 +02:00
Andrey Savchenko 1e75033f25 Normalized on operating in float seconds rather than milliseconds. 2018-02-22 13:14:15 +02:00
Andrey Savchenko 624e282905 Added container test. 2018-02-22 12:34:47 +02:00
Andrey Savchenko 56e9447dce Renamed manager tests for consistency. 2018-02-22 12:25:14 +02:00
Andrey Savchenko 560eb85f4b Added provider tests. 2018-02-22 12:23:47 +02:00
Andrey Savchenko 801f6585cb Added missing namespace in test. 2018-02-21 16:16:57 +02:00
Andrey Savchenko 61dd387484 Added SQL and iterators tests. 2018-02-21 16:12:34 +02:00
Andrey Savchenko 420305143b Added generic stopwatch collector and tests. 2018-02-20 18:09:44 +02:00
Andrey Savchenko 7020e84b2d Added hook event tests. 2018-02-19 16:50:38 +02:00
Andrey Savchenko 5ec0f6c677 Added manager tests. 2018-02-19 16:12:01 +02:00
Andrey Savchenko 1bf5e5c5ad Set up unit tests. 2018-02-16 20:19:16 +02:00
Andrey Savchenko 8cd280f12a Added inline documentation. 2018-02-14 17:54:28 +02:00
Andrey Savchenko d850fa1b02 Renamed main class to Plugin for more clear role. 2018-02-13 18:22:35 +02:00
Andrey Savchenko a19e4fb019 Moved timeline iterator to record namespace. 2018-02-13 18:18:36 +02:00
Andrey Savchenko 53efcd28af Added keys to collectors array. 2018-02-13 18:16:41 +02:00
Andrey Savchenko c74051e87d Adjusted hook events for a simpler interface and wrapped in a provider. 2018-02-13 17:26:41 +02:00
Andrey Savchenko 06e3bb4657 Added proper providers to handle registration and boot. 2018-02-13 11:37:54 +02:00
Andrey Savchenko 48b3383e06 Introduced explicit record interface for event results. 2018-02-12 18:30:00 +02:00
Andrey Savchenko ce7cf8eade Reorganized code to designate events as input and records as results. 2018-02-12 17:12:58 +02:00
Andrey Savchenko 67d686f601 Split functionality from container to manager classes. 2018-02-12 17:02:17 +02:00
Andrey Savchenko 2c074c1cea Simplified processing nested events to a single pass. 2018-02-12 15:53:40 +02:00
Andrey Savchenko a9484ed4ee Added timeline iterator for automatic splitting of nested events. 2018-02-09 18:47:13 +02:00
Andrey Savchenko bee765071b Implemented initial handling of arbitrary nesting events.
See #11
2018-02-09 15:15:23 +02:00
Andrey Savchenko baf5d293a1 Fixed screen reader text. 2018-02-08 21:17:25 +02:00
Andrey Savchenko 36e0d14c48 Fixed empty timelines filter. 2018-02-08 19:11:14 +02:00
Andrey Savchenko 228ea99b43 Dropped any events that aren't properly stopped. 2018-02-08 19:10:57 +02:00
Andrey Savchenko 79e197c4cc Moved another leftover action. 2018-02-08 18:36:31 +02:00
Andrey Savchenko 8396888ee2 Moved leftover event stop to the provider. 2018-02-08 18:10:01 +02:00
Andrey Savchenko d8febfeb3a Moved SQL events to a provider and simplified template. 2018-02-08 18:08:01 +02:00
Andrey Savchenko 31b80d0413 Adjusted from returning raw Stopwatch event objects from providers. 2018-02-08 17:07:35 +02:00
Andrey Savchenko c93249875b Changed Stopwatch service to a factory. 2018-02-08 16:20:30 +02:00
Andrey Savchenko 054bf2e0df Moved HTTP requests events to a provider. 2018-02-08 16:08:39 +02:00
Andrey Savchenko 267f389a40 Moved hooks events to a provider. 2018-02-08 15:00:57 +02:00
Andrey Savchenko 39f03e02bf Added provider interfaces. 2018-02-08 14:58:43 +02:00
Andrey Savchenko 6fc8a648ad Made main class into Pimple container. 2018-02-08 14:29:10 +02:00
Andrey Savchenko b709f968f9 Moved events classes. 2018-02-08 10:57:20 +02:00
Andrey Savchenko c966fb1552 Dropped Thematic events as the theme is obsolete. 2018-02-07 22:55:51 +02:00
Andrey Savchenko 62ea1f4246 Changed main class to concrete instance. 2018-02-07 22:08:41 +02:00
Andrey Savchenko 9527ad1508 Bumped Stopwatch version and updated dependencies. 2018-02-07 21:57:19 +02:00
Andrey Savchenko a77dd9e4c8 Renamed class files for PSR-4. 2018-02-07 21:53:22 +02:00
Andrey Savchenko 03ff2b61ff Updated header version to 1.4.4 2017-07-05 21:45:39 +03:00
Andrey Savchenko 3c0ae866e0 Added Robo tag task and updated changelog for 1.4.4
Fixes #10
2017-07-05 21:45:27 +03:00
Andrey Savchenko d2bece68e5 Added sanity check for invalid priority returned by core
Fixes #9
2017-06-28 14:25:45 +03:00
Andrey Savchenko f50faf6ba6 Added downloads badge to readme. 2016-12-06 21:32:31 +02:00
Andrey Savchenko bca3f42ee5 Updated version and change log for 1.4.2 release. 2016-12-02 19:18:58 +02:00
Andrey Savchenko 68302633c0 Restored functionality on WP 4.7 beta with new current_priority() method. 2016-12-02 19:18:41 +02:00
Andrey Savchenko 67ad1370ef Added Scrutinizer badge to readme. 2016-12-01 22:10:39 +02:00
Andrey Savchenko 4b7ee062c8 Updated change log and version for release 1.4.1. 2016-12-01 20:35:19 +02:00
Andrey Savchenko 2e7a948bfe Added access modifier to methods. 2016-12-01 20:34:15 +02:00
Andrey Savchenko 68ae657962 Added check for Toolbar event start before closing it. 2016-12-01 20:33:55 +02:00
Andrey Savchenko 3edaf2dbc9 Added check for hook priority failing on WP 4.7. 2016-12-01 20:30:48 +02:00
Andrey Savchenko fa155f00e7 Fixed return type hint. 2016-12-01 20:30:15 +02:00
Andrey Savchenko 82b3d1e4e3 Moved license to a separate file. 2016-12-01 20:29:52 +02:00
Andrey Savchenko 0984debd79 Release 1.4 2016-10-01 20:17:36 +03:00
Andrey Savchenko 2ddbd04b29 Colorized SQL writes as warnings. 2016-10-01 20:16:17 +03:00
Andrey Savchenko a16eebd026 Corrected change log heading markup. 2016-10-01 15:34:47 +03:00
Andrey Savchenko 274d294a65 Added screen reader text to events. 2016-10-01 15:29:06 +03:00
Andrey Savchenko ec5adbf47a Recompiled assets. 2016-10-01 14:59:11 +03:00
Andrey Savchenko b26ea48216 Updated dependencies. 2016-10-01 14:58:55 +03:00
Andrey Savchenko 711371c226 Removed release Robo task. 2016-10-01 14:52:48 +03:00
Andrey Savchenko 72ff60fe6e Updated change log to keepachangelog format. 2016-10-01 14:51:22 +03:00
Andrey Savchenko 357753f84b Updated changelog and version for 1.3.2 2015-08-27 14:06:08 +03:00
Andrey Savchenko 9d1dddb462 Normalized slashing on adding files to release zip file. 2015-08-27 14:05:48 +03:00
Andrey Savchenko d88a566aee Fixed dynamic method call to prevent crash on PHP 7. 2015-08-27 14:05:19 +03:00
Andrey Savchenko b976b26454 Updated version in header 2015-08-15 21:06:35 +03:00
Andrey Savchenko a00b11f78a Updated changelog for 1.3.1 2015-08-12 00:15:24 +03:00
Andrey Savchenko 32f300af7f Added check to catch event stops without matching starts
Fixes #7
2015-08-12 00:14:33 +03:00
Andrey Savchenko a3572063d2 Updated changelog and version 2015-06-12 22:06:33 +03:00
Andrey Savchenko e8f8e9a4b6 Implemented release command in robo 2015-06-12 21:06:07 +03:00
Andrey Savchenko cf44efbe64 Added version getter to robo file 2015-06-12 21:05:50 +03:00
Andrey Savchenko 2289923666 Updated main file for code style 2015-06-12 21:05:24 +03:00
Andrey Savchenko b82cd35cf8 Updated gitignore 2015-06-12 20:58:52 +03:00
Andrey Savchenko 8e441c935f Added task to set plugin version 2015-06-11 17:23:31 +03:00
Andrey Savchenko 7dfea751f5 Made method calls more compact 2015-06-11 12:40:19 +03:00
Andrey Savchenko a3cc36b661 Removed commented out debug code 2015-06-11 12:40:07 +03:00
Andrey Savchenko 47caf94cfe Another end of file new line 2015-06-11 12:33:45 +03:00
Andrey Savchenko d8298b1700 Made comparisons strict 2015-06-11 12:27:28 +03:00
Andrey Savchenko 5072bbbaad Added new lines to end of files for code style 2015-06-11 12:26:27 +03:00
Andrey Savchenko b32d60dfce Updated Stopwatch dependency 2015-06-11 12:26:00 +03:00
Andrey Savchenko c593e1e925 Tightened condition on Hybrid events to prevent breakage with v3
Fixes #4
2015-06-11 11:56:02 +03:00
Andrey Savchenko 112c14fde3 Added events class for Yoast plugins 2015-04-06 10:19:57 +03:00
Andrey Savchenko df40e389ad Precompiled Mustache template 2015-04-06 09:46:09 +03:00
Andrey Savchenko fb7b2f025a Added Robo task for precompiling Mustache cache 2015-04-06 09:45:44 +03:00
Andrey Savchenko b87ce58f4a Implemented class for loading precompiled Mustache cache 2015-04-06 09:45:12 +03:00
Andrey Savchenko 424fb74b29 Updated dependencies 2015-04-06 09:44:18 +03:00
Andrey Savchenko 5ed687499f Recompiled assets after dependencies update 2015-03-28 23:36:08 +02:00
Andrey Savchenko 1db8318edb Updated dependencies 2015-03-28 23:35:05 +02:00
Andrey Savchenko edb804d35f Update README.md
Added link to releases section for archive download.
2015-02-06 23:20:32 +01:00
Andrey Savchenko ce265e6dd2 Updated array keys for coding style. 2015-01-03 21:24:58 +02:00
Andrey Savchenko f3438de84b Implemented minified assets in queue. 2015-01-03 21:06:32 +02:00
Andrey Savchenko d0d70fddaf Recompiled assets. 2015-01-03 21:06:11 +02:00
Andrey Savchenko 48424c2b4c Updated RoboFile for less sourcemap and minified assets. 2015-01-03 21:05:40 +02:00
Andrey Savchenko b3be169798 Updated dependencies. 2015-01-03 20:49:14 +02:00
Andrey Savchenko 5a33c9329b Split plugins load into file load and following hook. 2014-11-07 20:55:37 +02:00
Andrey Savchenko 6fda82d443 Recompiled assets after Bootstrap update. 2014-10-30 17:34:15 +02:00
Andrey Savchenko c912f263a2 Updated Bootstrap dependency to 3.3.0 2014-10-30 17:32:56 +02:00
Andrey Savchenko 6c75879465 Adjusted command name in RoboFile to make what, not what from. 2014-10-24 15:42:22 +03:00
Andrey Savchenko db87114e3f Elaborated on Composer code use in license section. 2014-10-24 15:10:12 +03:00
Andrey Savchenko 6c7b6d6195 Added links to themes and docs. 2014-10-24 15:09:47 +03:00
Andrey Savchenko 40fd25490b Moved screenshot up for eye candy. 2014-10-24 15:09:22 +03:00
Andrey Savchenko f2f3c4f474 Updated dependencies. 2014-10-23 22:38:26 +03:00
Andrey Savchenko 59bc49bd56 Updated readme and moved changelog to separate file. 2014-10-23 22:15:24 +03:00
Andrey Savchenko 234ed808aa Recompiled JS and updated for new script name. 2014-10-23 22:11:53 +03:00
Andrey Savchenko b5161c2955 Updated compilation and watch commands in RoboFile. 2014-10-23 22:11:06 +03:00
Andrey Savchenko 4cdf206de9 Moved JS from inline PHP to own source file. 2014-10-23 22:09:48 +03:00
Andrey Savchenko 1d87865377 Updated readme. 2014-07-11 17:48:19 +03:00
Andrey Savchenko 283f8632df Disabled tooltip animation to fix JS error and UI disappearing from under cursor. 2014-07-11 17:47:54 +03:00
Andrey Savchenko eac2ab5fad Simplified robo task for tooltip to single write. 2014-06-29 00:25:59 +03:00
Andrey Savchenko 26df4f5579 Updated Bootstrap license info in readme. 2014-06-28 23:25:50 +03:00
Andrey Savchenko 83972fdb69 Updated tooltip script. 2014-06-28 23:25:02 +03:00
Andrey Savchenko e42787ec16 Added robo task to generate edited tooltip script from Bootstrap source. 2014-06-28 23:10:48 +03:00
Andrey Savchenko 174b171cdd Refactored less workflow to reference Bootstrap sources. 2014-06-28 22:26:26 +03:00
Andrey Savchenko 2a6c9339d3 Added Robo configuration file for automation. 2014-06-28 22:24:48 +03:00
Andrey Savchenko 103e0c36f5 Committed composer.lock file. 2014-06-28 22:24:05 +03:00
Andrey Savchenko 0e48a61157 Added Bootstrap as development dependency. 2014-06-28 22:23:39 +03:00
Andrey Savchenko 68f8ae42e9 Updated plugin header 2014-05-31 21:36:04 +03:00
Andrey Savchenko f8fa008ec7 Updated links in composer.json for GitHub 2014-05-31 21:32:59 +03:00
Andrey Savchenko b0d376ea8c Updated version in plugin header. 2014-05-24 19:09:54 +03:00
73 changed files with 3768 additions and 1330 deletions

No files matched your search

+2 -2
View File
@@ -1,2 +1,2 @@
vendor
composer.lock
/vendor
/release
+121
View File
@@ -0,0 +1,121 @@
# Change Log
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).
## Unreleased
## 2.0 - 2018-02-26
### Added
- unified processing of events from arbitrary sources
- unit tests
- tracking PHP and WP core load times
### Changed
- minimum PHP version requirement to >=5.6
- class files names to PSR–4
- main class into concrete instance and Pimple container
- timeline to unified processing with as necessary nesting
- directory structure to PDS skeleton
- baseline timings to float in seconds (from milliseconds)
- color scheme
### Removed
- Thematic hook events
### Fixed
- handling or not properly started/stopped hook events
## 1.4.4 - 2017-07-05
### Added
- Robo task to update header version and tag in Git
### Fixed
- version in header
## 1.4.3 - 2017-06-28
### Fixed
- sanity check for invalid priority returned by core
## 1.4.2 - 2016-12-02
### Fixed
- back to fully functional on WP 4.7 beta
## 1.4.1 - 2016-12-01
### Fixed
- errors and crash on WP 4.7 beta (not fully functional yet)
## 1.4 - 2016-10-01
### Added
- added screen reader text to events
- colorized writing SQL queries to warning color
### Changed
- updated change log format to Keep a Changelog
- updated dependencies (Stopwatch 2.8.11, Mustache 2.11.1, Bootstrap 3.3.7)
- updated assets
### Removed
- removed release Robo task
## 1.3.2 - 2015-08-27
### Fixed
- fixed dynamic method call crash on PHP 7
- fixed issue with slashes in generated release archives
## 1.3.1 - 2015-08-12
### Fixed
- fixed crash on event stop without matching start
## 1.3 - 2015-06-12
### Added
- implemented minified assets
- implemented pre-cached template
- implemented release build command
- added WP SEO event
### Changed
- split plugins_loaded hook into separate event
### Fixed
- fixed crash with upcoming Hybrid Core v3
## 1.2.1 - 2014-07-12
### Fixed
- disabled tooltip animation to fix JS errors and UI disappearing from under cursor
## 1.2 - 2014-05-18
### Added
- implemented (ballpark) toolbar event
### Changed
- merged RP with additional core events in admin
### Fixed
- fixed issue with event offsets in timelines
## 1.1 - 2013-12-11
### Added
- added SQL timeline
- added HTTP timeline
### Changed
- switched tooltips implementation to Bootstrap script
## 1.0 - 2013-04-22
### Added
- Initial public release
+21
View File
@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2013 Andrey Savchenko
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+42
View File
@@ -0,0 +1,42 @@
# Laps — light WordPress profiler
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/Rarst/laps/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/Rarst/laps/?branch=master)
[![Build Status](https://scrutinizer-ci.com/g/Rarst/laps/badges/build.png?b=master)](https://scrutinizer-ci.com/g/Rarst/laps/build-status/master)
[![Code Coverage](https://scrutinizer-ci.com/g/Rarst/laps/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/Rarst/laps/?branch=master)
[![Total Downloads](https://img.shields.io/packagist/dt/rarst/laps.svg)](https://packagist.org/packages/rarst/laps)
[![Latest Stable Version](https://img.shields.io/packagist/v/rarst/laps.svg?label=version)](https://packagist.org/packages/rarst/laps)
[![PHP from Packagist](https://img.shields.io/packagist/php-v/rarst/laps.svg)](https://packagist.org/packages/rarst/laps)
[![PDS Skeleton](https://img.shields.io/badge/pds-skeleton-blue.svg)](https://github.com/php-pds/skeleton)
_Make a site, make it fast._
![Laps v2 screenshot](https://i.imgur.com/6n36KPE.png)
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.
Laps tracks many events, such as:
- PHP, core, plugins, and themes load
- database queries (with [`SAVEQUERIES` constant](http://codex.wordpress.org/Editing_wp-config.php#Save_queries_for_analysis) enabled)
- network requests to other sites
- main posts loop
- events for supported theme frameworks:
- [Theme Hook Alliance](http://zamoose.github.io/themehookalliance/)
- [Hybrid](http://themehybrid.com/)
- [Genesis](http://my.studiopress.com/themes/genesis/)
- events for supported plugins:
- [Yoast SEO](https://wordpress.org/plugins/wordpress-seo/)
## Installation
Require with [Composer](https://getcomposer.org/):
```bash
composer require rarst/laps
```
Or download plugin archive from [releases section](https://github.com/Rarst/laps/releases).
## License
MIT
+108
View File
@@ -0,0 +1,108 @@
<?php
require __DIR__ . '/vendor/autoload.php';
/**
* This is project's console commands configuration for Robo task runner.
*
* @see http://robo.li/
*/
class RoboFile extends \Robo\Tasks {
/**
* Watches for changes.
*/
public function watch() {
$this->taskWatch()
->monitor( [ 'public/css/variables.less', 'public/css/laps.less' ], function () {
$this->makeCss();
} )
->monitor( 'public/js/source.js', function () {
$this->makeJs();
} )
->run();
}
/**
* Compiles all assets.
*/
public function makeAll() {
$this->makeCss();
$this->makeJs();
$this->makeMustache();
}
/**
* Compiles plugin's css file from less.
*/
public function makeCss() {
$this->taskExec( 'lessc public/css/laps.less public/css/laps.css --source-map=public/css/laps.css.map' )->run();
$this->taskMinify( 'public/css/laps.css' )
->run();
}
/**
* Creates plugin's script file.
*/
public function makeJs() {
$this->taskConcat( [
'vendor/twbs/bootstrap/js/tooltip.js',
'public/js/source.js',
] )
->to( 'public/js/laps.js' )
->run();
$this->taskMinify( 'public/js/laps.js' )
->run();
}
/**
* Compiles plugin's mustache template
*/
public function makeMustache() {
$dir = __DIR__ . '/src/mustache/cache';
$this->_cleanDir( $dir );
$mustache = new \Mustache_Engine(
array(
'loader' => new \Mustache_Loader_FilesystemLoader( __DIR__ . '/src/mustache' ),
'cache' => $dir,
)
);
$mustache->loadTemplate( 'laps' );
}
/**
* Updates version in header and makes git version tag.
*
* @param string $version Version string.
*/
public function tag( $version ) {
$this->versionSet( $version );
$this->taskGitStack()
->stopOnFail()
->add( 'laps.php' )
->commit( "Updated header version to {$version}" )
->tag( $version )
->run();
}
/**
* Sets the plugin version in header.
*
* @param string $version Version string.
*/
public function versionSet( $version ) {
$this->taskReplaceInFile( 'laps.php' )
->regex( '|^Version:.*$|m' )
->to( 'Version: ' . $version )
->run();
}
}
+19 -7
View File
@@ -3,25 +3,37 @@
"description": "Light WordPress profiler.",
"keywords" : ["wordpress", "performance"],
"type" : "wordpress-plugin",
"homepage" : "https://bitbucket.org/Rarst/laps",
"homepage" : "https://github.com/Rarst/laps",
"license" : "MIT",
"authors" : [
{
"name" : "Andrey Savchenko",
"email" : "contact@rarst.net",
"homepage": "http://www.Rarst.net/"
}
],
"support" : {
"issues": "https://bitbucket.org/Rarst/laps/issues",
"source": "https://bitbucket.org/Rarst/laps/src"
"issues": "https://github.com/Rarst/laps/issues"
},
"autoload" : {
"classmap": ["src/"]
"psr-4": {
"Rarst\\Laps\\" : "src/"
}
},
"autoload-dev": {
"psr-4": {
"Rarst\\Laps\\Tests\\": "tests/"
}
},
"require" : {
"php" : ">=5.6",
"composer/installers": "~1.0",
"symfony/stopwatch" : "~2.4",
"mustache/mustache" : "~2.4"
"symfony/stopwatch" : "^3.4.4",
"mustache/mustache" : "~2.4",
"pimple/pimple" : "^3.2.3"
},
"require-dev": {
"twbs/bootstrap": "~3.2",
"brain/monkey" : "^2.2",
"pds/skeleton": "^1.0"
}
}
Generated
+635
View File
@@ -0,0 +1,635 @@
{
"_readme": [
"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",
"This file is @generated automatically"
],
"content-hash": "b88211148a5c0893e190e574ac18bd30",
"packages": [
{
"name": "composer/installers",
"version": "v1.5.0",
"source": {
"type": "git",
"url": "https://github.com/composer/installers.git",
"reference": "049797d727261bf27f2690430d935067710049c2"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/composer/installers/zipball/049797d727261bf27f2690430d935067710049c2",
"reference": "049797d727261bf27f2690430d935067710049c2",
"shasum": ""
},
"require": {
"composer-plugin-api": "^1.0"
},
"replace": {
"roundcube/plugin-installer": "*",
"shama/baton": "*"
},
"require-dev": {
"composer/composer": "1.0.*@dev",
"phpunit/phpunit": "^4.8.36"
},
"type": "composer-plugin",
"extra": {
"class": "Composer\\Installers\\Plugin",
"branch-alias": {
"dev-master": "1.0-dev"
}
},
"autoload": {
"psr-4": {
"Composer\\Installers\\": "src/Composer/Installers"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Kyle Robinson Young",
"email": "kyle@dontkry.com",
"homepage": "https://github.com/shama"
}
],
"description": "A multi-framework Composer library installer",
"homepage": "https://composer.github.io/installers/",
"keywords": [
"Craft",
"Dolibarr",
"Eliasis",
"Hurad",
"ImageCMS",
"Kanboard",
"Lan Management System",
"MODX Evo",
"Mautic",
"Maya",
"OXID",
"Plentymarkets",
"Porto",
"RadPHP",
"SMF",
"Thelia",
"WolfCMS",
"agl",
"aimeos",
"annotatecms",
"attogram",
"bitrix",
"cakephp",
"chef",
"cockpit",
"codeigniter",
"concrete5",
"croogo",
"dokuwiki",
"drupal",
"eZ Platform",
"elgg",
"expressionengine",
"fuelphp",
"grav",
"installer",
"itop",
"joomla",
"kohana",
"laravel",
"lavalite",
"lithium",
"magento",
"majima",
"mako",
"mediawiki",
"modulework",
"modx",
"moodle",
"osclass",
"phpbb",
"piwik",
"ppi",
"puppet",
"pxcms",
"reindex",
"roundcube",
"shopware",
"silverstripe",
"sydes",
"symfony",
"typo3",
"wordpress",
"yawik",
"zend",
"zikula"
],
"time": "2017-12-29T09:13:20+00:00"
},
{
"name": "mustache/mustache",
"version": "v2.12.0",
"source": {
"type": "git",
"url": "https://github.com/bobthecow/mustache.php.git",
"reference": "fe8fe72e9d580591854de404cc59a1b83ca4d19e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/bobthecow/mustache.php/zipball/fe8fe72e9d580591854de404cc59a1b83ca4d19e",
"reference": "fe8fe72e9d580591854de404cc59a1b83ca4d19e",
"shasum": ""
},
"require": {
"php": ">=5.2.4"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "~1.11",
"phpunit/phpunit": "~3.7|~4.0|~5.0"
},
"type": "library",
"autoload": {
"psr-0": {
"Mustache": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Justin Hileman",
"email": "justin@justinhileman.info",
"homepage": "http://justinhileman.com"
}
],
"description": "A Mustache implementation in PHP.",
"homepage": "https://github.com/bobthecow/mustache.php",
"keywords": [
"mustache",
"templating"
],
"time": "2017-07-11T12:54:05+00:00"
},
{
"name": "pimple/pimple",
"version": "v3.2.3",
"source": {
"type": "git",
"url": "https://github.com/silexphp/Pimple.git",
"reference": "9e403941ef9d65d20cba7d54e29fe906db42cf32"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/silexphp/Pimple/zipball/9e403941ef9d65d20cba7d54e29fe906db42cf32",
"reference": "9e403941ef9d65d20cba7d54e29fe906db42cf32",
"shasum": ""
},
"require": {
"php": ">=5.3.0",
"psr/container": "^1.0"
},
"require-dev": {
"symfony/phpunit-bridge": "^3.2"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.2.x-dev"
}
},
"autoload": {
"psr-0": {
"Pimple": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
}
],
"description": "Pimple, a simple Dependency Injection Container",
"homepage": "http://pimple.sensiolabs.org",
"keywords": [
"container",
"dependency injection"
],
"time": "2018-01-21T07:42:36+00:00"
},
{
"name": "psr/container",
"version": "1.0.0",
"source": {
"type": "git",
"url": "https://github.com/php-fig/container.git",
"reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-fig/container/zipball/b7ce3b176482dbbc1245ebf52b181af44c2cf55f",
"reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f",
"shasum": ""
},
"require": {
"php": ">=5.3.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
}
},
"autoload": {
"psr-4": {
"Psr\\Container\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "PHP-FIG",
"homepage": "http://www.php-fig.org/"
}
],
"description": "Common Container Interface (PHP FIG PSR-11)",
"homepage": "https://github.com/php-fig/container",
"keywords": [
"PSR-11",
"container",
"container-interface",
"container-interop",
"psr"
],
"time": "2017-02-14T16:28:37+00:00"
},
{
"name": "symfony/stopwatch",
"version": "v3.4.4",
"source": {
"type": "git",
"url": "https://github.com/symfony/stopwatch.git",
"reference": "c865551df7c17e63fc1f09f763db04387f91ae4d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/stopwatch/zipball/c865551df7c17e63fc1f09f763db04387f91ae4d",
"reference": "c865551df7c17e63fc1f09f763db04387f91ae4d",
"shasum": ""
},
"require": {
"php": "^5.5.9|>=7.0.8"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.4-dev"
}
},
"autoload": {
"psr-4": {
"Symfony\\Component\\Stopwatch\\": ""
},
"exclude-from-classmap": [
"/Tests/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony Stopwatch Component",
"homepage": "https://symfony.com",
"time": "2018-01-03T07:37:34+00:00"
}
],
"packages-dev": [
{
"name": "antecedent/patchwork",
"version": "2.1.8",
"source": {
"type": "git",
"url": "https://github.com/antecedent/patchwork.git",
"reference": "3bb81ace3914c220aa273d1c0603d5e1b454c0d7"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/antecedent/patchwork/zipball/3bb81ace3914c220aa273d1c0603d5e1b454c0d7",
"reference": "3bb81ace3914c220aa273d1c0603d5e1b454c0d7",
"shasum": ""
},
"require": {
"php": ">=5.4.0"
},
"type": "library",
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Ignas Rudaitis",
"email": "ignas.rudaitis@gmail.com"
}
],
"description": "Method redefinition (monkey-patching) functionality for PHP.",
"homepage": "http://patchwork2.org/",
"keywords": [
"aop",
"aspect",
"interception",
"monkeypatching",
"redefinition",
"runkit",
"testing"
],
"time": "2018-02-19T18:52:50+00:00"
},
{
"name": "brain/monkey",
"version": "2.2.0",
"source": {
"type": "git",
"url": "https://github.com/Brain-WP/BrainMonkey.git",
"reference": "ed9e0698bc1292f33698719da8ca1aa2e18acc51"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Brain-WP/BrainMonkey/zipball/ed9e0698bc1292f33698719da8ca1aa2e18acc51",
"reference": "ed9e0698bc1292f33698719da8ca1aa2e18acc51",
"shasum": ""
},
"require": {
"antecedent/patchwork": "^2.0",
"mockery/mockery": ">=0.9 <2",
"php": ">=5.6.0"
},
"require-dev": {
"phpunit/phpunit": "~5.7.9"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-version/1": "1.x-dev",
"dev-master": "2.0.x-dev"
}
},
"autoload": {
"psr-4": {
"Brain\\Monkey\\": "src/"
},
"files": [
"inc/api.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Giuseppe Mazzapica",
"email": "giuseppe.mazzapica@gmail.com",
"homepage": "https://gmazzap.me",
"role": "Developer"
}
],
"description": "Mocking utility for PHP functions and WordPress plugin API",
"keywords": [
"Monkey Patching",
"interception",
"mock",
"mock functions",
"mockery",
"patchwork",
"redefinition",
"runkit",
"test",
"testing"
],
"time": "2017-12-01T16:32:09+00:00"
},
{
"name": "hamcrest/hamcrest-php",
"version": "v2.0.0",
"source": {
"type": "git",
"url": "https://github.com/hamcrest/hamcrest-php.git",
"reference": "776503d3a8e85d4f9a1148614f95b7a608b046ad"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/hamcrest/hamcrest-php/zipball/776503d3a8e85d4f9a1148614f95b7a608b046ad",
"reference": "776503d3a8e85d4f9a1148614f95b7a608b046ad",
"shasum": ""
},
"require": {
"php": "^5.3|^7.0"
},
"replace": {
"cordoval/hamcrest-php": "*",
"davedevelopment/hamcrest-php": "*",
"kodova/hamcrest-php": "*"
},
"require-dev": {
"phpunit/php-file-iterator": "1.3.3",
"phpunit/phpunit": "~4.0",
"satooshi/php-coveralls": "^1.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.0-dev"
}
},
"autoload": {
"classmap": [
"hamcrest"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD"
],
"description": "This is the PHP port of Hamcrest Matchers",
"keywords": [
"test"
],
"time": "2016-01-20T08:20:44+00:00"
},
{
"name": "mockery/mockery",
"version": "1.0",
"source": {
"type": "git",
"url": "https://github.com/mockery/mockery.git",
"reference": "1bac8c362b12f522fdd1f1fa3556284c91affa38"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/mockery/mockery/zipball/1bac8c362b12f522fdd1f1fa3556284c91affa38",
"reference": "1bac8c362b12f522fdd1f1fa3556284c91affa38",
"shasum": ""
},
"require": {
"hamcrest/hamcrest-php": "~2.0",
"lib-pcre": ">=7.0",
"php": ">=5.6.0"
},
"require-dev": {
"phpunit/phpunit": "~5.7|~6.1"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
}
},
"autoload": {
"psr-0": {
"Mockery": "library/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Pádraic Brady",
"email": "padraic.brady@gmail.com",
"homepage": "http://blog.astrumfutura.com"
},
{
"name": "Dave Marshall",
"email": "dave.marshall@atstsolutions.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.",
"homepage": "http://github.com/mockery/mockery",
"keywords": [
"BDD",
"TDD",
"library",
"mock",
"mock objects",
"mockery",
"stub",
"test",
"test double",
"testing"
],
"time": "2017-10-06T16:20:43+00:00"
},
{
"name": "pds/skeleton",
"version": "1.0.0",
"source": {
"type": "git",
"url": "https://github.com/php-pds/skeleton.git",
"reference": "95e476e5d629eadacbd721c5a9553e537514a231"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-pds/skeleton/zipball/95e476e5d629eadacbd721c5a9553e537514a231",
"reference": "95e476e5d629eadacbd721c5a9553e537514a231",
"shasum": ""
},
"bin": [
"bin/pds-skeleton"
],
"type": "standard",
"autoload": {
"psr-4": {
"Pds\\Skeleton\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"CC-BY-SA-4.0"
],
"description": "Standard for PHP package skeletons.",
"homepage": "https://github.com/php-pds/skeleton",
"time": "2017-01-25T23:30:41+00:00"
},
{
"name": "twbs/bootstrap",
"version": "v3.3.7",
"source": {
"type": "git",
"url": "https://github.com/twbs/bootstrap.git",
"reference": "0b9c4a4007c44201dce9a6cc1a38407005c26c86"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/twbs/bootstrap/zipball/0b9c4a4007c44201dce9a6cc1a38407005c26c86",
"reference": "0b9c4a4007c44201dce9a6cc1a38407005c26c86",
"shasum": ""
},
"replace": {
"twitter/bootstrap": "self.version"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.3.x-dev"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Jacob Thornton",
"email": "jacobthornton@gmail.com"
},
{
"name": "Mark Otto",
"email": "markdotto@gmail.com"
}
],
"description": "The most popular front-end framework for developing responsive, mobile first projects on the web.",
"homepage": "http://getbootstrap.com",
"keywords": [
"JS",
"css",
"framework",
"front-end",
"less",
"mobile-first",
"responsive",
"web"
],
"time": "2016-07-25T15:51:55+00:00"
}
],
"aliases": [],
"minimum-stability": "stable",
"stability-flags": [],
"prefer-stable": false,
"prefer-lowest": false,
"platform": {
"php": ">=5.6"
},
"platform-dev": []
}
-89
View File
@@ -1,89 +0,0 @@
@import "variables.less";
@import "mixins.less";
#wpadminbar {
#wp-admin-bar-laps {
.ab-sub-wrapper {
min-width: 90%;
width: 90%;
position: fixed;
left: 5%;
}
.ab-submenu {
padding: 0;
}
}
#wp-admin-bar-laps_output {
padding: 0 10px;
&:hover {
background-color: transparent;
}
.ab-empty-item {
display: none;
}
}
.laps-timeline {
overflow: hidden;
height: 20px;
margin: 6px 0;
background-color: @timeline-bg;
border-radius: 4px;
.box-shadow(inset 0 1px 2px rgba(0,0,0,.1));
position: relative;
}
.laps-timeline .event {
float: left;
width: 0%;
height: 20px;
font-size: @font-size-small;
color: #fff;
text-align: center;
background-color: @event-info-color;
.box-shadow(inset 0 -1px 0 rgba(0, 0, 0, .15));
.transition(width .6s ease);
position: absolute; // disable stacking at start
border-left: 1px solid @timeline-bg;
min-width: 2px;
}
.laps-timeline .event-theme {
background-color: @event-theme-color;
}
.laps-timeline .event-plugin {
background-color: @event-plugin-color;
}
.laps-timeline .event-core {
background-color: @event-core-color;
}
.laps-timeline .event-query {
background-color: @event-info-color;
}
.laps-timeline .event-http {
background-color: @event-warning-color;
}
@import "tooltip.less";
.tooltip.in {
.opacity(1);
}
.tooltip-inner {
line-height: 20px;
text-align: left;
}
}
-16
View File
@@ -1,16 +0,0 @@
.transition(@transition) {
-webkit-transition: @transition;
transition: @transition;
}
.box-shadow(@shadow) {
-webkit-box-shadow: @shadow; // iOS <4.3 & Android <4.1
box-shadow: @shadow;
}
.opacity(@opacity) {
opacity: @opacity;
// IE8 filter
@opacity-ie: (@opacity * 100);
filter: ~"alpha(opacity=@{opacity-ie})";
}
-94
View File
@@ -1,94 +0,0 @@
//
// Tooltips
// --------------------------------------------------
// Base class
.tooltip {
position: absolute;
z-index: @zindex-tooltip;
display: block;
visibility: visible;
font-size: @font-size-small;
line-height: 1.4;
.opacity(0);
&.in { .opacity(.9); }
&.top { margin-top: -3px; padding: @tooltip-arrow-width 0; }
&.right { margin-left: 3px; padding: 0 @tooltip-arrow-width; }
&.bottom { margin-top: 3px; padding: @tooltip-arrow-width 0; }
&.left { margin-left: -3px; padding: 0 @tooltip-arrow-width; }
}
// Wrapper for the tooltip content
.tooltip-inner {
max-width: @tooltip-max-width;
padding: 3px 8px;
color: @tooltip-color;
text-align: center;
text-decoration: none;
background-color: @tooltip-bg;
border-radius: @border-radius-base;
}
// Arrows
.tooltip-arrow {
position: absolute;
width: 0;
height: 0;
border-color: transparent;
border-style: solid;
}
.tooltip {
&.top .tooltip-arrow {
bottom: 0;
left: 50%;
margin-left: -@tooltip-arrow-width;
border-width: @tooltip-arrow-width @tooltip-arrow-width 0;
border-top-color: @tooltip-arrow-color;
}
&.top-left .tooltip-arrow {
bottom: 0;
left: @tooltip-arrow-width;
border-width: @tooltip-arrow-width @tooltip-arrow-width 0;
border-top-color: @tooltip-arrow-color;
}
&.top-right .tooltip-arrow {
bottom: 0;
right: @tooltip-arrow-width;
border-width: @tooltip-arrow-width @tooltip-arrow-width 0;
border-top-color: @tooltip-arrow-color;
}
&.right .tooltip-arrow {
top: 50%;
left: 0;
margin-top: -@tooltip-arrow-width;
border-width: @tooltip-arrow-width @tooltip-arrow-width @tooltip-arrow-width 0;
border-right-color: @tooltip-arrow-color;
}
&.left .tooltip-arrow {
top: 50%;
right: 0;
margin-top: -@tooltip-arrow-width;
border-width: @tooltip-arrow-width 0 @tooltip-arrow-width @tooltip-arrow-width;
border-left-color: @tooltip-arrow-color;
}
&.bottom .tooltip-arrow {
top: 0;
left: 50%;
margin-left: -@tooltip-arrow-width;
border-width: 0 @tooltip-arrow-width @tooltip-arrow-width;
border-bottom-color: @tooltip-arrow-color;
}
&.bottom-left .tooltip-arrow {
top: 0;
left: @tooltip-arrow-width;
border-width: 0 @tooltip-arrow-width @tooltip-arrow-width;
border-bottom-color: @tooltip-arrow-color;
}
&.bottom-right .tooltip-arrow {
top: 0;
right: @tooltip-arrow-width;
border-width: 0 @tooltip-arrow-width @tooltip-arrow-width;
border-bottom-color: @tooltip-arrow-color;
}
}
-18
View File
@@ -1,18 +0,0 @@
@font-size-small: 12px;
// colors
@timeline-bg: #f5f5f5;
@event-theme-color: #5cb85c;
@event-plugin-color: #428bca;
@event-core-color: #f0ad4e;
@event-info-color: #5bc0de;
@event-warning-color: #d9534f;
// because admin bar is 99999
@zindex-tooltip: 100000;
@tooltip-max-width: 300px;
@tooltip-color: #ccc;
@tooltip-bg: #464646;
@tooltip-arrow-width: 5px;
@tooltip-arrow-color: @tooltip-bg;
@border-radius-base: 4px;
-387
View File
@@ -1,387 +0,0 @@
/* ========================================================================
* Bootstrap: tooltip.js v3.0.2
* http://getbootstrap.com/javascript/#tooltip
* Inspired by the original jQuery.tipsy by Jason Frame
* ========================================================================
* Copyright 2013 Twitter, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ======================================================================== */
// modified to use lapstooltip as name
+function ($) { "use strict";
// TOOLTIP PUBLIC CLASS DEFINITION
// ===============================
var Tooltip = function (element, options) {
this.type =
this.options =
this.enabled =
this.timeout =
this.hoverState =
this.$element = null
this.init('lapstooltip', element, options)
}
Tooltip.DEFAULTS = {
animation: true
, placement: 'top'
, selector: false
, template: '<div class="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>'
, trigger: 'hover focus'
, title: ''
, delay: 0
, html: false
, container: false
}
Tooltip.prototype.init = function (type, element, options) {
this.enabled = true
this.type = type
this.$element = $(element)
this.options = this.getOptions(options)
var triggers = this.options.trigger.split(' ')
for (var i = triggers.length; i--;) {
var trigger = triggers[i]
if (trigger == 'click') {
this.$element.on('click.' + this.type, this.options.selector, $.proxy(this.toggle, this))
} else if (trigger != 'manual') {
var eventIn = trigger == 'hover' ? 'mouseenter' : 'focus'
var eventOut = trigger == 'hover' ? 'mouseleave' : 'blur'
this.$element.on(eventIn + '.' + this.type, this.options.selector, $.proxy(this.enter, this))
this.$element.on(eventOut + '.' + this.type, this.options.selector, $.proxy(this.leave, this))
}
}
this.options.selector ?
(this._options = $.extend({}, this.options, { trigger: 'manual', selector: '' })) :
this.fixTitle()
}
Tooltip.prototype.getDefaults = function () {
return Tooltip.DEFAULTS
}
Tooltip.prototype.getOptions = function (options) {
options = $.extend({}, this.getDefaults(), this.$element.data(), options)
if (options.delay && typeof options.delay == 'number') {
options.delay = {
show: options.delay
, hide: options.delay
}
}
return options
}
Tooltip.prototype.getDelegateOptions = function () {
var options = {}
var defaults = this.getDefaults()
this._options && $.each(this._options, function (key, value) {
if (defaults[key] != value) options[key] = value
})
return options
}
Tooltip.prototype.enter = function (obj) {
var self = obj instanceof this.constructor ?
obj : $(obj.currentTarget)[this.type](this.getDelegateOptions()).data('bs.' + this.type)
clearTimeout(self.timeout)
self.hoverState = 'in'
if (!self.options.delay || !self.options.delay.show) return self.show()
self.timeout = setTimeout(function () {
if (self.hoverState == 'in') self.show()
}, self.options.delay.show)
}
Tooltip.prototype.leave = function (obj) {
var self = obj instanceof this.constructor ?
obj : $(obj.currentTarget)[this.type](this.getDelegateOptions()).data('bs.' + this.type)
clearTimeout(self.timeout)
self.hoverState = 'out'
if (!self.options.delay || !self.options.delay.hide) return self.hide()
self.timeout = setTimeout(function () {
if (self.hoverState == 'out') self.hide()
}, self.options.delay.hide)
}
Tooltip.prototype.show = function () {
var e = $.Event('show.bs.'+ this.type)
if (this.hasContent() && this.enabled) {
this.$element.trigger(e)
if (e.isDefaultPrevented()) return
var $tip = this.tip()
this.setContent()
if (this.options.animation) $tip.addClass('fade')
var placement = typeof this.options.placement == 'function' ?
this.options.placement.call(this, $tip[0], this.$element[0]) :
this.options.placement
var autoToken = /\s?auto?\s?/i
var autoPlace = autoToken.test(placement)
if (autoPlace) placement = placement.replace(autoToken, '') || 'top'
$tip
.detach()
.css({ top: 0, left: 0, display: 'block' })
.addClass(placement)
this.options.container ? $tip.appendTo(this.options.container) : $tip.insertAfter(this.$element)
var pos = this.getPosition()
var actualWidth = $tip[0].offsetWidth
var actualHeight = $tip[0].offsetHeight
if (autoPlace) {
var $parent = this.$element.parent()
var orgPlacement = placement
var docScroll = document.documentElement.scrollTop || document.body.scrollTop
var parentWidth = this.options.container == 'body' ? window.innerWidth : $parent.outerWidth()
var parentHeight = this.options.container == 'body' ? window.innerHeight : $parent.outerHeight()
var parentLeft = this.options.container == 'body' ? 0 : $parent.offset().left
placement = placement == 'bottom' && pos.top + pos.height + actualHeight - docScroll > parentHeight ? 'top' :
placement == 'top' && pos.top - docScroll - actualHeight < 0 ? 'bottom' :
placement == 'right' && pos.right + actualWidth > parentWidth ? 'left' :
placement == 'left' && pos.left - actualWidth < parentLeft ? 'right' :
placement
$tip
.removeClass(orgPlacement)
.addClass(placement)
}
var calculatedOffset = this.getCalculatedOffset(placement, pos, actualWidth, actualHeight)
this.applyPlacement(calculatedOffset, placement)
this.$element.trigger('shown.bs.' + this.type)
}
}
Tooltip.prototype.applyPlacement = function(offset, placement) {
var replace
var $tip = this.tip()
var width = $tip[0].offsetWidth
var height = $tip[0].offsetHeight
// manually read margins because getBoundingClientRect includes difference
var marginTop = parseInt($tip.css('margin-top'), 10)
var marginLeft = parseInt($tip.css('margin-left'), 10)
// we must check for NaN for ie 8/9
if (isNaN(marginTop)) marginTop = 0
if (isNaN(marginLeft)) marginLeft = 0
offset.top = offset.top + marginTop
offset.left = offset.left + marginLeft
$tip
.offset(offset)
.addClass('in')
// check to see if placing tip in new offset caused the tip to resize itself
var actualWidth = $tip[0].offsetWidth
var actualHeight = $tip[0].offsetHeight
if (placement == 'top' && actualHeight != height) {
replace = true
offset.top = offset.top + height - actualHeight
}
if (/bottom|top/.test(placement)) {
var delta = 0
if (offset.left < 0) {
delta = offset.left * -2
offset.left = 0
$tip.offset(offset)
actualWidth = $tip[0].offsetWidth
actualHeight = $tip[0].offsetHeight
}
this.replaceArrow(delta - width + actualWidth, actualWidth, 'left')
} else {
this.replaceArrow(actualHeight - height, actualHeight, 'top')
}
if (replace) $tip.offset(offset)
}
Tooltip.prototype.replaceArrow = function(delta, dimension, position) {
this.arrow().css(position, delta ? (50 * (1 - delta / dimension) + "%") : '')
}
Tooltip.prototype.setContent = function () {
var $tip = this.tip()
var title = this.getTitle()
$tip.find('.tooltip-inner')[this.options.html ? 'html' : 'text'](title)
$tip.removeClass('fade in top bottom left right')
}
Tooltip.prototype.hide = function () {
var that = this
var $tip = this.tip()
var e = $.Event('hide.bs.' + this.type)
function complete() {
if (that.hoverState != 'in') $tip.detach()
}
this.$element.trigger(e)
if (e.isDefaultPrevented()) return
$tip.removeClass('in')
$.support.transition && this.$tip.hasClass('fade') ?
$tip
.one($.support.transition.end, complete)
.emulateTransitionEnd(150) :
complete()
this.$element.trigger('hidden.bs.' + this.type)
return this
}
Tooltip.prototype.fixTitle = function () {
var $e = this.$element
if ($e.attr('title') || typeof($e.attr('data-original-title')) != 'string') {
$e.attr('data-original-title', $e.attr('title') || '').attr('title', '')
}
}
Tooltip.prototype.hasContent = function () {
return this.getTitle()
}
Tooltip.prototype.getPosition = function () {
var el = this.$element[0]
return $.extend({}, (typeof el.getBoundingClientRect == 'function') ? el.getBoundingClientRect() : {
width: el.offsetWidth
, height: el.offsetHeight
}, this.$element.offset())
}
Tooltip.prototype.getCalculatedOffset = function (placement, pos, actualWidth, actualHeight) {
return placement == 'bottom' ? { top: pos.top + pos.height, left: pos.left + pos.width / 2 - actualWidth / 2 } :
placement == 'top' ? { top: pos.top - actualHeight, left: pos.left + pos.width / 2 - actualWidth / 2 } :
placement == 'left' ? { top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left - actualWidth } :
/* placement == 'right' */ { top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left + pos.width }
}
Tooltip.prototype.getTitle = function () {
var title
var $e = this.$element
var o = this.options
title = $e.attr('data-original-title')
|| (typeof o.title == 'function' ? o.title.call($e[0]) : o.title)
return title
}
Tooltip.prototype.tip = function () {
return this.$tip = this.$tip || $(this.options.template)
}
Tooltip.prototype.arrow = function () {
return this.$arrow = this.$arrow || this.tip().find('.tooltip-arrow')
}
Tooltip.prototype.validate = function () {
if (!this.$element[0].parentNode) {
this.hide()
this.$element = null
this.options = null
}
}
Tooltip.prototype.enable = function () {
this.enabled = true
}
Tooltip.prototype.disable = function () {
this.enabled = false
}
Tooltip.prototype.toggleEnabled = function () {
this.enabled = !this.enabled
}
Tooltip.prototype.toggle = function (e) {
var self = e ? $(e.currentTarget)[this.type](this.getDelegateOptions()).data('bs.' + this.type) : this
self.tip().hasClass('in') ? self.leave(self) : self.enter(self)
}
Tooltip.prototype.destroy = function () {
this.hide().$element.off('.' + this.type).removeData('bs.' + this.type)
}
// TOOLTIP PLUGIN DEFINITION
// =========================
var old = $.fn.lapstooltip
$.fn.lapstooltip = function (option) {
return this.each(function () {
var $this = $(this)
var data = $this.data('bs.lapstooltip')
var options = typeof option == 'object' && option
if (!data) $this.data('bs.lapstooltip', (data = new Tooltip(this, options)))
if (typeof option == 'string') data[option]()
})
}
$.fn.lapstooltip.Constructor = Tooltip
// TOOLTIP NO CONFLICT
// ===================
$.fn.lapstooltip.noConflict = function () {
$.fn.lapstooltip = old
return this
}
}(jQuery);
+10 -24
View File
@@ -1,35 +1,21 @@
<?php
/*
Plugin Name: Laps
Plugin URI: https://bitbucket.org/Rarst/laps/
Plugin URI: https://github.com/Rarst/laps
Description: Light WordPress profiler.
Author: Andrey "Rarst" Savchenko
Version: 1.1
Author URI: http://www.rarst.net/
Author: Andrey “Rarst” Savchenko
Version: 2.0
Author URI: https://www.rarst.net/
Text Domain: laps
Domain Path: /lang
License: MIT
Copyright (c) 2013 Andrey "Rarst" Savchenko
Permission is hereby granted, free of charge, to any person obtaining a copy of this
software and associated documentation files (the "Software"), to deal in the Software
without restriction, including without limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies
or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/
if ( file_exists( __DIR__ . '/vendor/autoload.php' ) )
if ( file_exists( __DIR__ . '/vendor/autoload.php' ) ) {
require __DIR__ . '/vendor/autoload.php';
}
Rarst\Laps\Laps::on_load();
$laps = new \Rarst\Laps\Plugin();
$laps->run();
+15
View File
@@ -0,0 +1,15 @@
<phpunit bootstrap="vendor/autoload.php">
<testsuites>
<testsuite name="Laps">
<directory>tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">src</directory>
<exclude>
<directory suffix=".php">src/mustache/cache</directory>
</exclude>
</whitelist>
</filter>
</phpunit>
+53 -17
View File
@@ -19,51 +19,83 @@
#wpadminbar .laps-timeline {
overflow: hidden;
height: 20px;
margin: 6px 0;
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: 20px;
height: 100%;
font-size: 12px;
line-height: 20px;
color: #fff;
text-align: center;
background-color: #5bc0de;
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: #5cb85c;
background-color: #2ECC40;
}
#wpadminbar .laps-timeline .event-plugin {
background-color: #428bca;
background-color: #0074D9;
}
#wpadminbar .laps-timeline .event-core {
background-color: #f0ad4e;
background-color: #FF851B;
}
#wpadminbar .laps-timeline .event-query {
background-color: #5bc0de;
#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: #d9534f;
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;
visibility: visible;
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;
line-height: 1.4;
opacity: 0;
filter: alpha(opacity=0);
}
@@ -90,9 +122,8 @@
#wpadminbar .tooltip-inner {
max-width: 300px;
padding: 3px 8px;
color: #cccccc;
color: #eee;
text-align: center;
text-decoration: none;
background-color: #464646;
border-radius: 4px;
}
@@ -112,13 +143,15 @@
}
#wpadminbar .tooltip.top-left .tooltip-arrow {
bottom: 0;
left: 5px;
right: 5px;
margin-bottom: -5px;
border-width: 5px 5px 0;
border-top-color: #464646;
}
#wpadminbar .tooltip.top-right .tooltip-arrow {
bottom: 0;
right: 5px;
left: 5px;
margin-bottom: -5px;
border-width: 5px 5px 0;
border-top-color: #464646;
}
@@ -145,13 +178,15 @@
}
#wpadminbar .tooltip.bottom-left .tooltip-arrow {
top: 0;
left: 5px;
right: 5px;
margin-top: -5px;
border-width: 0 5px 5px;
border-bottom-color: #464646;
}
#wpadminbar .tooltip.bottom-right .tooltip-arrow {
top: 0;
right: 5px;
left: 5px;
margin-top: -5px;
border-width: 0 5px 5px;
border-bottom-color: #464646;
}
@@ -163,3 +198,4 @@
line-height: 20px;
text-align: left;
}
/*# sourceMappingURL=laps.css.map */
+1
View File
@@ -0,0 +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"}
+86
View File
@@ -0,0 +1,86 @@
@import (reference) "../../vendor/twbs/bootstrap/less/variables.less";
@import (reference) "../../vendor/twbs/bootstrap/less/mixins.less";
@import (reference) "../../vendor/twbs/bootstrap/less/progress-bars.less";
@import (reference) "../../vendor/twbs/bootstrap/less/scaffolding.less";
@import "variables.less";
#wpadminbar {
#wp-admin-bar-laps {
.ab-sub-wrapper {
min-width: 90%;
width: 90%;
position: fixed;
left: 5%;
}
.ab-submenu {
padding: 0;
}
}
#wp-admin-bar-laps_output {
padding: 0 10px;
&:hover {
background-color: transparent;
}
.ab-empty-item {
display: none;
}
}
.laps-timeline {
.progress;
margin: 6px 0;
position: relative;
.event {
.progress-bar;
position: absolute; // disable stacking at start
border-left: 1px solid @timeline-bg;
min-width: 2px;
}
.event-php {
background-color: @event-php-color;
}
.event-theme {
background-color: @event-theme-color;
}
.event-plugin {
background-color: @event-plugin-color;
}
.event-core {
background-color: @event-core-color;
}
.event-sql-read {
background-color: @event-sql-color;
}
.event-sql-write {
background-color: @event-warning-color;
}
.event-http {
background-color: @event-warning-color;
}
.sr-only {
.sr-only;
}
}
@import "../../vendor/twbs/bootstrap/less/tooltip.less";
.tooltip.in {
.opacity(1);
}
.tooltip-inner {
line-height: 20px;
text-align: left;
}
}
+1
View File
@@ -0,0 +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}
+23
View File
@@ -0,0 +1,23 @@
@font-size-small: 12px;
@line-height-computed: 20px;
// colors
@timeline-bg: #f5f5f5;
@event-php-color: #B10DC9;
@event-theme-color: #2ECC40;
@event-plugin-color: #0074D9;
@event-core-color: #FF851B;
@event-sql-color: #7FDBFF;
@event-info-color: #AAAAAA;
@event-warning-color: #FF4136;
@progress-bg: @timeline-bg;
@progress-bar-bg: @event-info-color;
// because admin bar is 99999
@zindex-tooltip: 100000;
@tooltip-max-width: 300px;
@tooltip-color: #eee;
@tooltip-bg: #464646;
@tooltip-arrow-width: 5px;
@tooltip-arrow-color: @tooltip-bg;
@border-radius-base: 4px;
+533
View File
@@ -0,0 +1,533 @@
/* ========================================================================
* Bootstrap: tooltip.js v3.3.7
* http://getbootstrap.com/javascript/#tooltip
* Inspired by the original jQuery.tipsy by Jason Frame
* ========================================================================
* Copyright 2011-2016 Twitter, Inc.
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
* ======================================================================== */
+function ($) {
'use strict';
// TOOLTIP PUBLIC CLASS DEFINITION
// ===============================
var Tooltip = function (element, options) {
this.type = null
this.options = null
this.enabled = null
this.timeout = null
this.hoverState = null
this.$element = null
this.inState = null
this.init('tooltip', element, options)
}
Tooltip.VERSION = '3.3.7'
Tooltip.TRANSITION_DURATION = 150
Tooltip.DEFAULTS = {
animation: true,
placement: 'top',
selector: false,
template: '<div class="tooltip" role="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>',
trigger: 'hover focus',
title: '',
delay: 0,
html: false,
container: false,
viewport: {
selector: 'body',
padding: 0
}
}
Tooltip.prototype.init = function (type, element, options) {
this.enabled = true
this.type = type
this.$element = $(element)
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.inState = { click: false, hover: false, focus: false }
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 triggers = this.options.trigger.split(' ')
for (var i = triggers.length; i--;) {
var trigger = triggers[i]
if (trigger == 'click') {
this.$element.on('click.' + this.type, this.options.selector, $.proxy(this.toggle, this))
} else if (trigger != 'manual') {
var eventIn = trigger == 'hover' ? 'mouseenter' : 'focusin'
var eventOut = trigger == 'hover' ? 'mouseleave' : 'focusout'
this.$element.on(eventIn + '.' + this.type, this.options.selector, $.proxy(this.enter, this))
this.$element.on(eventOut + '.' + this.type, this.options.selector, $.proxy(this.leave, this))
}
}
this.options.selector ?
(this._options = $.extend({}, this.options, { trigger: 'manual', selector: '' })) :
this.fixTitle()
}
Tooltip.prototype.getDefaults = function () {
return Tooltip.DEFAULTS
}
Tooltip.prototype.getOptions = function (options) {
options = $.extend({}, this.getDefaults(), this.$element.data(), options)
if (options.delay && typeof options.delay == 'number') {
options.delay = {
show: options.delay,
hide: options.delay
}
}
return options
}
Tooltip.prototype.getDelegateOptions = function () {
var options = {}
var defaults = this.getDefaults()
this._options && $.each(this._options, function (key, value) {
if (defaults[key] != value) options[key] = value
})
return options
}
Tooltip.prototype.enter = function (obj) {
var self = obj instanceof this.constructor ?
obj : $(obj.currentTarget).data('bs.' + this.type)
if (!self) {
self = new this.constructor(obj.currentTarget, this.getDelegateOptions())
$(obj.currentTarget).data('bs.' + this.type, self)
}
if (obj instanceof $.Event) {
self.inState[obj.type == 'focusin' ? 'focus' : 'hover'] = true
}
if (self.tip().hasClass('in') || self.hoverState == 'in') {
self.hoverState = 'in'
return
}
clearTimeout(self.timeout)
self.hoverState = 'in'
if (!self.options.delay || !self.options.delay.show) return self.show()
self.timeout = setTimeout(function () {
if (self.hoverState == 'in') self.show()
}, self.options.delay.show)
}
Tooltip.prototype.isInStateTrue = function () {
for (var key in this.inState) {
if (this.inState[key]) return true
}
return false
}
Tooltip.prototype.leave = function (obj) {
var self = obj instanceof this.constructor ?
obj : $(obj.currentTarget).data('bs.' + this.type)
if (!self) {
self = new this.constructor(obj.currentTarget, this.getDelegateOptions())
$(obj.currentTarget).data('bs.' + this.type, self)
}
if (obj instanceof $.Event) {
self.inState[obj.type == 'focusout' ? 'focus' : 'hover'] = false
}
if (self.isInStateTrue()) return
clearTimeout(self.timeout)
self.hoverState = 'out'
if (!self.options.delay || !self.options.delay.hide) return self.hide()
self.timeout = setTimeout(function () {
if (self.hoverState == 'out') self.hide()
}, self.options.delay.hide)
}
Tooltip.prototype.show = function () {
var e = $.Event('show.bs.' + this.type)
if (this.hasContent() && this.enabled) {
this.$element.trigger(e)
var inDom = $.contains(this.$element[0].ownerDocument.documentElement, this.$element[0])
if (e.isDefaultPrevented() || !inDom) return
var that = this
var $tip = this.tip()
var tipId = this.getUID(this.type)
this.setContent()
$tip.attr('id', tipId)
this.$element.attr('aria-describedby', tipId)
if (this.options.animation) $tip.addClass('fade')
var placement = typeof this.options.placement == 'function' ?
this.options.placement.call(this, $tip[0], this.$element[0]) :
this.options.placement
var autoToken = /\s?auto?\s?/i
var autoPlace = autoToken.test(placement)
if (autoPlace) placement = placement.replace(autoToken, '') || 'top'
$tip
.detach()
.css({ top: 0, left: 0, display: 'block' })
.addClass(placement)
.data('bs.' + this.type, this)
this.options.container ? $tip.appendTo(this.options.container) : $tip.insertAfter(this.$element)
this.$element.trigger('inserted.bs.' + this.type)
var pos = this.getPosition()
var actualWidth = $tip[0].offsetWidth
var actualHeight = $tip[0].offsetHeight
if (autoPlace) {
var orgPlacement = placement
var viewportDim = this.getPosition(this.$viewport)
placement = placement == 'bottom' && pos.bottom + actualHeight > viewportDim.bottom ? 'top' :
placement == 'top' && pos.top - actualHeight < viewportDim.top ? 'bottom' :
placement == 'right' && pos.right + actualWidth > viewportDim.width ? 'left' :
placement == 'left' && pos.left - actualWidth < viewportDim.left ? 'right' :
placement
$tip
.removeClass(orgPlacement)
.addClass(placement)
}
var calculatedOffset = this.getCalculatedOffset(placement, pos, actualWidth, actualHeight)
this.applyPlacement(calculatedOffset, placement)
var complete = function () {
var prevHoverState = that.hoverState
that.$element.trigger('shown.bs.' + that.type)
that.hoverState = null
if (prevHoverState == 'out') that.leave(that)
}
$.support.transition && this.$tip.hasClass('fade') ?
$tip
.one('bsTransitionEnd', complete)
.emulateTransitionEnd(Tooltip.TRANSITION_DURATION) :
complete()
}
}
Tooltip.prototype.applyPlacement = function (offset, placement) {
var $tip = this.tip()
var width = $tip[0].offsetWidth
var height = $tip[0].offsetHeight
// manually read margins because getBoundingClientRect includes difference
var marginTop = parseInt($tip.css('margin-top'), 10)
var marginLeft = parseInt($tip.css('margin-left'), 10)
// we must check for NaN for ie 8/9
if (isNaN(marginTop)) marginTop = 0
if (isNaN(marginLeft)) marginLeft = 0
offset.top += marginTop
offset.left += marginLeft
// $.fn.offset doesn't round pixel values
// so we use setOffset directly with our own function B-0
$.offset.setOffset($tip[0], $.extend({
using: function (props) {
$tip.css({
top: Math.round(props.top),
left: Math.round(props.left)
})
}
}, offset), 0)
$tip.addClass('in')
// check to see if placing tip in new offset caused the tip to resize itself
var actualWidth = $tip[0].offsetWidth
var actualHeight = $tip[0].offsetHeight
if (placement == 'top' && actualHeight != height) {
offset.top = offset.top + height - actualHeight
}
var delta = this.getViewportAdjustedDelta(placement, offset, actualWidth, actualHeight)
if (delta.left) offset.left += delta.left
else offset.top += delta.top
var isVertical = /top|bottom/.test(placement)
var arrowDelta = isVertical ? delta.left * 2 - width + actualWidth : delta.top * 2 - height + actualHeight
var arrowOffsetPosition = isVertical ? 'offsetWidth' : 'offsetHeight'
$tip.offset(offset)
this.replaceArrow(arrowDelta, $tip[0][arrowOffsetPosition], isVertical)
}
Tooltip.prototype.replaceArrow = function (delta, dimension, isVertical) {
this.arrow()
.css(isVertical ? 'left' : 'top', 50 * (1 - delta / dimension) + '%')
.css(isVertical ? 'top' : 'left', '')
}
Tooltip.prototype.setContent = function () {
var $tip = this.tip()
var title = this.getTitle()
$tip.find('.tooltip-inner')[this.options.html ? 'html' : 'text'](title)
$tip.removeClass('fade in top bottom left right')
}
Tooltip.prototype.hide = function (callback) {
var that = this
var $tip = $(this.$tip)
var e = $.Event('hide.bs.' + this.type)
function complete() {
if (that.hoverState != 'in') $tip.detach()
if (that.$element) { // TODO: Check whether guarding this code with this `if` is really necessary.
that.$element
.removeAttr('aria-describedby')
.trigger('hidden.bs.' + that.type)
}
callback && callback()
}
this.$element.trigger(e)
if (e.isDefaultPrevented()) return
$tip.removeClass('in')
$.support.transition && $tip.hasClass('fade') ?
$tip
.one('bsTransitionEnd', complete)
.emulateTransitionEnd(Tooltip.TRANSITION_DURATION) :
complete()
this.hoverState = null
return this
}
Tooltip.prototype.fixTitle = function () {
var $e = this.$element
if ($e.attr('title') || typeof $e.attr('data-original-title') != 'string') {
$e.attr('data-original-title', $e.attr('title') || '').attr('title', '')
}
}
Tooltip.prototype.hasContent = function () {
return this.getTitle()
}
Tooltip.prototype.getPosition = function ($element) {
$element = $element || this.$element
var el = $element[0]
var isBody = el.tagName == 'BODY'
var elRect = el.getBoundingClientRect()
if (elRect.width == null) {
// width and height are missing in IE8, so compute them manually; see https://github.com/twbs/bootstrap/issues/14093
elRect = $.extend({}, elRect, { width: elRect.right - elRect.left, height: elRect.bottom - elRect.top })
}
var isSvg = window.SVGElement && el instanceof window.SVGElement
// Avoid using $.offset() on SVGs since it gives incorrect results in jQuery 3.
// See https://github.com/twbs/bootstrap/issues/20280
var elOffset = isBody ? { top: 0, left: 0 } : (isSvg ? null : $element.offset())
var scroll = { scroll: isBody ? document.documentElement.scrollTop || document.body.scrollTop : $element.scrollTop() }
var outerDims = isBody ? { width: $(window).width(), height: $(window).height() } : null
return $.extend({}, elRect, scroll, outerDims, elOffset)
}
Tooltip.prototype.getCalculatedOffset = function (placement, pos, actualWidth, actualHeight) {
return placement == 'bottom' ? { top: pos.top + pos.height, left: pos.left + pos.width / 2 - actualWidth / 2 } :
placement == 'top' ? { top: pos.top - actualHeight, left: pos.left + pos.width / 2 - actualWidth / 2 } :
placement == 'left' ? { top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left - actualWidth } :
/* placement == 'right' */ { top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left + pos.width }
}
Tooltip.prototype.getViewportAdjustedDelta = function (placement, pos, actualWidth, actualHeight) {
var delta = { top: 0, left: 0 }
if (!this.$viewport) return delta
var viewportPadding = this.options.viewport && this.options.viewport.padding || 0
var viewportDimensions = this.getPosition(this.$viewport)
if (/right|left/.test(placement)) {
var topEdgeOffset = pos.top - viewportPadding - viewportDimensions.scroll
var bottomEdgeOffset = pos.top + viewportPadding - viewportDimensions.scroll + actualHeight
if (topEdgeOffset < viewportDimensions.top) { // top overflow
delta.top = viewportDimensions.top - topEdgeOffset
} else if (bottomEdgeOffset > viewportDimensions.top + viewportDimensions.height) { // bottom overflow
delta.top = viewportDimensions.top + viewportDimensions.height - bottomEdgeOffset
}
} else {
var leftEdgeOffset = pos.left - viewportPadding
var rightEdgeOffset = pos.left + viewportPadding + actualWidth
if (leftEdgeOffset < viewportDimensions.left) { // left overflow
delta.left = viewportDimensions.left - leftEdgeOffset
} else if (rightEdgeOffset > viewportDimensions.right) { // right overflow
delta.left = viewportDimensions.left + viewportDimensions.width - rightEdgeOffset
}
}
return delta
}
Tooltip.prototype.getTitle = function () {
var title
var $e = this.$element
var o = this.options
title = $e.attr('data-original-title')
|| (typeof o.title == 'function' ? o.title.call($e[0]) : o.title)
return title
}
Tooltip.prototype.getUID = function (prefix) {
do prefix += ~~(Math.random() * 1000000)
while (document.getElementById(prefix))
return prefix
}
Tooltip.prototype.tip = function () {
if (!this.$tip) {
this.$tip = $(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
}
Tooltip.prototype.arrow = function () {
return (this.$arrow = this.$arrow || this.tip().find('.tooltip-arrow'))
}
Tooltip.prototype.enable = function () {
this.enabled = true
}
Tooltip.prototype.disable = function () {
this.enabled = false
}
Tooltip.prototype.toggleEnabled = function () {
this.enabled = !this.enabled
}
Tooltip.prototype.toggle = function (e) {
var self = this
if (e) {
self = $(e.currentTarget).data('bs.' + this.type)
if (!self) {
self = new this.constructor(e.currentTarget, this.getDelegateOptions())
$(e.currentTarget).data('bs.' + this.type, self)
}
}
if (e) {
self.inState.click = !self.inState.click
if (self.isInStateTrue()) self.enter(self)
else self.leave(self)
} else {
self.tip().hasClass('in') ? self.leave(self) : self.enter(self)
}
}
Tooltip.prototype.destroy = function () {
var that = this
clearTimeout(this.timeout)
this.hide(function () {
that.$element.off('.' + that.type).removeData('bs.' + that.type)
if (that.$tip) {
that.$tip.detach()
}
that.$tip = null
that.$arrow = null
that.$viewport = null
that.$element = null
})
}
// TOOLTIP PLUGIN DEFINITION
// =========================
function Plugin(option) {
return this.each(function () {
var $this = $(this)
var data = $this.data('bs.tooltip')
var options = typeof option == 'object' && option
if (!data && /destroy|hide/.test(option)) return
if (!data) $this.data('bs.tooltip', (data = new Tooltip(this, options)))
if (typeof option == 'string') data[option]()
})
}
var old = $.fn.tooltip
$.fn.tooltip = Plugin
$.fn.tooltip.Constructor = Tooltip
// TOOLTIP NO CONFLICT
// ===================
$.fn.tooltip.noConflict = function () {
$.fn.tooltip = old
return this
}
}(jQuery);
jQuery.fn.lapstooltip = jQuery.fn.tooltip.noConflict();
jQuery(document).ready(function () {
jQuery(".laps-timeline .event").lapstooltip({
container: '#wpadminbar',
placement: 'bottom',
html : true,
animation: false
});
});
+6
View File
@@ -0,0 +1,6 @@
+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))}
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(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 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{i.tip().hasClass('in')?i.leave(i):i.enter(i)}};e.prototype.destroy=function(){var t=this;clearTimeout(this.timeout);this.hide(function(){t.$element.off('.'+t.type).removeData('bs.'+t.type);if(t.$tip){t.$tip.detach()};t.$tip=null;t.$arrow=null;t.$viewport=null;t.$element=null})};function o(i){return this.each(function(){var n=t(this),o=n.data('bs.tooltip'),s=typeof i=='object'&&i;if(!o&&/destroy|hide/.test(i))return;if(!o)n.data('bs.tooltip',(o=new e(this,s)));if(typeof i=='string')o[i]()})};var i=t.fn.tooltip;t.fn.tooltip=o;t.fn.tooltip.Constructor=e;t.fn.tooltip.noConflict=function(){t.fn.tooltip=i;return this}}(jQuery);jQuery.fn.lapstooltip=jQuery.fn.tooltip.noConflict();jQuery(document).ready(function(){jQuery('.laps-timeline .event').lapstooltip({container:'#wpadminbar',placement:'bottom',html:!0,animation:!1})});
+11
View File
@@ -0,0 +1,11 @@
jQuery.fn.lapstooltip = jQuery.fn.tooltip.noConflict();
jQuery(document).ready(function () {
jQuery(".laps-timeline .event").lapstooltip({
container: '#wpadminbar',
placement: 'bottom',
html : true,
animation: false
});
});
-68
View File
@@ -1,68 +0,0 @@
# Description
Laps is light WordPress profiler (in a plugin), which aims to be:
- always on and zero click (just hover on toolbar entry) away
- quick indicator of what hogs page in general or right now
It is no match or replacement for *real* profiler, but is friendly and cute.
Out of the box Laps supports common stage of WordPress page life cycle:
- plugins load
- themes load
- core init
- main loop
And some of third party hooks conventions for themes using:
- Theme Hook Alliance
- Hybrid
- Genesis
- Thematic
There are also additional optional timelines, displaying:
- SQL queries (with `SAVEQUERIES` constant enabled)
- HTTP requests performed
# Screenshot
![Laps screenshot](http://i.imgur.com/zFokmkU.png)
# Installation
Laps is a Composer package and can be installed in plugin directory via:
composer create-project rarst/laps --no-dev
# Frequently Asked Questions
None... Yet.
# Changelog
## 1.2
- merged RP with additional core events in admin
- implemented (ballpark) toolbar event
- fixed issue with event offsets in timelines
## 1.1
- added SQL timeline
- added HTTP timeline
- switched tooltips implementation to Bootstrap script
## 1.0
- Initial public release
# License Info
Laps own code is licensed under MIT and it makes use of code from:
- Composer (MIT)
- Symfony Stopwatch (MIT)
- Mustache.php (MIT)
- Twitter Bootstrap (Apache License 2.0)
@@ -1,94 +1,106 @@
<?php
namespace Rarst\Laps;
namespace Rarst\Laps\Event;
/**
* Main set of events for WordPress core
*/
class Core_Events extends Laps_Events {
class Core_Events implements Hook_Event_Config_Interface {
/**
* @return array
*/
public function get_events() {
$stops = array();
$stops = [];
$stops['plugins_loaded'][20] = array(
$stops['plugins_loaded'][-2] = [
'action' => 'stop',
'event' => 'Plugins Load',
'category' => 'plugin',
);
];
$stops['setup_theme'][0] = array(
$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] = array(
$stops['after_setup_theme'][20] = [
'action' => 'stop',
'event' => 'Themes Load',
'category' => 'theme',
);
];
$stops['init'][- 1] = array(
$stops['init'][-1] = [
'event' => 'Core Init',
'category' => 'core',
);
];
$stops['wp_loaded'][20] = array(
$stops['wp_loaded'][20] = [
'action' => 'stop',
'event' => 'Core Init',
'category' => 'core',
);
];
$stops['admin_init'][- 1] = array(
$stops['admin_init'][-1] = [
'event' => 'Core Admin Init',
'category' => 'core',
);
];
$stops['admin_init'][ PHP_INT_MAX -1 ] = array(
$stops['admin_init'][ PHP_INT_MAX - 1 ] = [
'action' => 'stop',
'event' => 'Core Admin Init',
'category' => 'core',
);
];
$stops['_admin_menu'][- 1] = array(
$stops['_admin_menu'][-1] = [
'event' => 'Admin Menu',
'category' => 'core',
);
$stops['admin_menu'][ PHP_INT_MAX -1 ] = array(
];
$stops['admin_menu'][ PHP_INT_MAX - 1 ] = [
'action' => 'stop',
'event' => 'Admin Menu',
'category' => 'core',
);
];
$stops['admin_bar_menu'][-1] = array(
$stops['admin_bar_menu'][-1] = [
'event' => 'Toolbar',
'category' => 'core',
);
];
$stops['loop_start'][10] = array(
$stops['loop_start'][10] = [
'event' => 'Main Loop',
'category' => 'theme',
);
];
$stops['loop_end'][10] = array(
$stops['loop_end'][10] = [
'action' => 'stop',
'event' => 'Main Loop',
'category' => 'theme',
);
];
$stops['admin_enqueue_scripts'][10] = array(
$stops['admin_enqueue_scripts'][10] = [
'event' => 'Admin Print Scripts',
'category' => 'core',
);
];
$stops['admin_print_scripts'][10] = array(
$stops['admin_print_scripts'][10] = [
'action' => 'stop',
'event' => 'Admin Print Scripts',
'category' => 'core',
);
];
return $stops;
}
+58
View File
@@ -0,0 +1,58 @@
<?php
namespace Rarst\Laps\Event;
/**
* Events for Genesis Framework based themes
*
* @link http://my.studiopress.com/themes/genesis/
*/
class Genesis_Events implements Hook_Event_Config_Interface {
/**
* @return array
*/
public function get_events() {
$events = [];
if ( ! function_exists( 'genesis' ) ) {
return $events;
}
$events['genesis_before_header'][10] = [
'event' => 'Header',
'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;
}
}
+11
View File
@@ -0,0 +1,11 @@
<?php
namespace Rarst\Laps\Event;
interface Hook_Event_Config_Interface {
/**
* @return array
*/
public function get_events();
}
@@ -1,56 +1,53 @@
<?php
namespace Rarst\Laps;
namespace Rarst\Laps\Event;
/**
* Events for Hybrid Core based themes
*
* @link http://themehybrid.com/hybrid-core
*/
class Hybrid_Events extends Laps_Events {
/**
* @return bool
*/
protected function is_applicable() {
return defined( 'HYBRID_VERSION' );
}
class Hybrid_Events implements Hook_Event_Config_Interface {
/**
* @return array
*/
protected function get_events() {
public function get_events() {
$events = [];
if ( ! function_exists( 'hybrid_get_prefix' ) ) {
return $events;
}
$events = array();
$prefix = hybrid_get_prefix();
$events["{$prefix}_before_header"][10] = array(
$events["{$prefix}_before_header"][10] = [
'event' => 'Header',
'category' => 'theme',
);
];
$events["{$prefix}_after_header"][10] = array(
$events["{$prefix}_after_header"][10] = [
'action' => 'stop',
'event' => 'Header',
'category' => 'theme',
);
];
$sidebars = get_theme_support( 'hybrid-core-sidebars' );
if ( ! empty( $sidebars[0] ) ) {
foreach ( $sidebars[0] as $sidebar ) {
$events["{$prefix}_before_{$sidebar}"][10] = array(
$events["{$prefix}_before_{$sidebar}"][10] = [
'event' => "Sidebar ({$sidebar})",
'category' => 'theme',
);
];
$events["{$prefix}_after_{$sidebar}"][10] = array(
$events["{$prefix}_after_{$sidebar}"][10] = [
'action' => 'stop',
'event' => "Sidebar ({$sidebar})",
'category' => 'theme',
);
];
}
}
+47
View File
@@ -0,0 +1,47 @@
<?php
namespace Rarst\Laps\Event;
/**
* Events for Theme Hook Alliance
*
* @link http://zamoose.github.io/themehookalliance/
*/
class THA_Events implements Hook_Event_Config_Interface {
/**
* @return array
*/
public function get_events() {
$events = [];
if ( ! defined( 'THA_HOOKS_VERSION' ) ) {
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;
}
}
+34
View File
@@ -0,0 +1,34 @@
<?php
namespace Rarst\Laps\Event;
/**
* Events for Yoast plugins
*/
class Yoast_Events implements Hook_Event_Config_Interface {
/**
* @return array
*/
public function get_events() {
$stops = [];
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;
}
}
+33
View File
@@ -0,0 +1,33 @@
<?php
namespace Rarst\Laps\Manager;
/**
* Implements load of necessary front–end assets.
*/
class Asset_Manager {
/**
* Sets up the hooks.
*/
public function __construct() {
add_action( 'wp_enqueue_scripts', [ $this, 'enqueue_scripts' ] );
add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_scripts' ] );
}
/**
* Registers assets and queues as necessary.
*/
public function enqueue_scripts() {
$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_style( 'laps', plugins_url( "public/css/laps{$suffix}.css", dirname( __DIR__ ) ) );
if ( is_admin_bar_showing() ) {
wp_enqueue_script( 'laps' );
wp_enqueue_style( 'laps' );
}
}
}
+40
View File
@@ -0,0 +1,40 @@
<?php
namespace Rarst\Laps\Manager;
/**
* Reorders plugin load to put Laps first and time this core boot stage.
*/
class Load_Order_Manager {
/**
* Sets up the hooks.
*/
public function __construct() {
add_action( 'pre_update_option_active_plugins', [ $this, 'pre_update_option_active_plugins' ] );
add_action( 'pre_update_site_option_active_sitewide_plugins', [ $this, 'pre_update_option_active_plugins' ] );
}
/**
* Reorder active plugins so Laps is first and starts timing load early.
*
* @param array $plugins Filtered array of active plugins’ basenames.
*
* @return array
*/
public function pre_update_option_active_plugins( $plugins ) {
$plugin = plugin_basename( dirname( dirname( __DIR__ ) ) . '/laps.php' );
$key = array_search( $plugin, $plugins, true );
if ( false !== $key && $key > 0 ) {
unset( $plugins[ $key ] );
array_unshift( $plugins, $plugin );
$plugins = array_values( $plugins );
}
return $plugins;
}
}
+55
View File
@@ -0,0 +1,55 @@
<?php
namespace Rarst\Laps\Manager;
use Rarst\Laps\Record\Recursive_Record_Iterator;
use Rarst\Laps\Plugin;
use Rarst\Laps\Record\Timeline_Iterator;
/**
* Implements toolbar menu and visualization.
*/
class Toolbar_Manager {
/** @var Plugin $laps */
protected $laps;
/**
* @param Plugin $laps Container instance.
*/
public function __construct( Plugin $laps ) {
$this->laps = $laps;
add_action( 'admin_bar_menu', [ $this, 'admin_bar_menu' ], 100 );
}
/**
* Render interface and add to the toolbar.
*
* @param \WP_Admin_Bar $wp_admin_bar WordPress core toolbar object.
*/
public function admin_bar_menu( $wp_admin_bar ) {
if ( ! apply_filters( 'laps_can_see', current_user_can( 'manage_options' ) ) ) {
return;
}
global $timestart;
$wp_admin_bar->add_node( [
'id' => 'laps',
'title' => sprintf( 'Lap: %ss', round( microtime( true ) - $timestart, 3 ) ),
] );
$wp_admin_bar->add_node( [
'id' => 'laps_output',
'parent' => 'laps',
'meta' => [
'html' => $this->laps['mustache']->render( 'laps', [
'timelines' => new Timeline_Iterator( new Recursive_Record_Iterator( $this->laps['records'] ) ),
] ),
],
] );
}
}
+27
View File
@@ -0,0 +1,27 @@
<?php
namespace Rarst\Laps;
/**
* Implements read-only filesystem cache
*/
class Mustache_Cache_FrozenCache extends \Mustache_Cache_FilesystemCache {
/**
* Cache and load a compiled Mustache_Template class.
*
* @param string $key Key.
* @param string $value Value.
*
* @return void
*/
public function cache( $key, $value ) {
$this->log(
\Mustache_Logger::WARNING,
'Read only cache file missing, evaluating "{className}" class at runtime',
array( 'className' => $key )
);
eval( '?>' . $value );
}
}
+76
View File
@@ -0,0 +1,76 @@
<?php
namespace Rarst\Laps;
use Pimple\Container;
use Pimple\ServiceProviderInterface;
use Rarst\Laps\Provider\Bootable_Provider_Interface;
use Rarst\Laps\Provider\Hook_Event_Provider;
use Rarst\Laps\Provider\Manager_Provider;
use Rarst\Laps\Provider\Record_Provider;
/**
* Main plugin's class.
*/
class Plugin extends Container {
/** @var array $providers */
protected $providers = [];
/**
* @param array $values Configuration values to apply.
*/
public function __construct( array $values = [] ) {
parent::__construct();
$laps = $this;
$laps['mustache'] = function () {
return new \Mustache_Engine( [
'loader' => new \Mustache_Loader_FilesystemLoader( dirname( __DIR__ ) . '/src/mustache' ),
'cache' => new Mustache_Cache_FrozenCache( dirname( __DIR__ ) . '/src/mustache/cache' ),
] );
};
$laps->register( new Manager_Provider() );
$laps->register( new Hook_Event_Provider() );
$laps->register( new Record_Provider() );
foreach ( $values as $key => $value ) {
$this->offsetSet( $key, $value );
}
}
/**
* @param ServiceProviderInterface $provider Provider.
* @param array $values Optional configuration.
*
* @return $this|static
*/
public function register( ServiceProviderInterface $provider, array $values = [] ) {
$this->providers[] = $provider;
parent::register( $provider, $values );
return $this;
}
/**
* Start Stopwatch and timing plugin load immediately, then set up core events and needed hooks.
*/
public function run() {
if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
return;
}
foreach ( $this->providers as $provider ) {
if ( $provider instanceof Bootable_Provider_Interface ) {
$provider->boot( $this );
}
}
}
}
@@ -0,0 +1,15 @@
<?php
namespace Rarst\Laps\Provider;
use Rarst\Laps\Plugin;
interface Bootable_Provider_Interface {
/**
* @param Plugin $laps Container instance.
*
* @return void
*/
public function boot( Plugin $laps );
}
+33
View File
@@ -0,0 +1,33 @@
<?php
namespace Rarst\Laps\Provider;
use Pimple\Container;
use Pimple\ServiceProviderInterface;
use Rarst\Laps\Event\Core_Events;
use Rarst\Laps\Event\Genesis_Events;
use Rarst\Laps\Event\Hybrid_Events;
use Rarst\Laps\Event\THA_Events;
use Rarst\Laps\Event\Yoast_Events;
/**
* Registers hook event configuration for bundled vendor events.
*/
class Hook_Event_Provider implements ServiceProviderInterface {
/**
* @param Container $pimple Container instance.
*/
public function register( Container $pimple ) {
$pimple['hook.events'] = function () {
return [
'core' => new Core_Events(),
'genesis' => new Genesis_Events(),
'hybrid' => new Hybrid_Events(),
'tha' => new THA_Events(),
'yoast' => new Yoast_Events(),
];
};
}
}
+37
View File
@@ -0,0 +1,37 @@
<?php
namespace Rarst\Laps\Provider;
use Pimple\Container;
use Pimple\ServiceProviderInterface;
use Rarst\Laps\Plugin;
use Rarst\Laps\Manager\Asset_Manager;
use Rarst\Laps\Manager\Load_Order_Manager;
use Rarst\Laps\Manager\Toolbar_Manager;
/**
* Registers manager classes that implement functionality.
*/
class Manager_Provider implements ServiceProviderInterface, Bootable_Provider_Interface {
/**
* @param Container $pimple Container instance.
*/
public function register( Container $pimple ) {
$pimple['managers'] = function ( Plugin $laps ) {
return [
new Load_Order_Manager(),
new Asset_Manager(),
new Toolbar_Manager( $laps ),
];
};
}
/**
* @param Plugin $laps Container instance.
*/
public function boot( Plugin $laps ) {
$laps['managers'];
}
}
+57
View File
@@ -0,0 +1,57 @@
<?php
namespace Rarst\Laps\Provider;
use Pimple\Container;
use Pimple\ServiceProviderInterface;
use Rarst\Laps\Plugin;
use Rarst\Laps\Record\Core_Load_Collector;
use Rarst\Laps\Record\Hook_Record_Collector;
use Rarst\Laps\Record\Http_Record_Collector;
use Rarst\Laps\Record\Record_Collector_Interface;
use Rarst\Laps\Record\Sql_Record_Collector;
use Symfony\Component\Stopwatch\Stopwatch;
/**
* Registers record collectors (responsible to gather and compile event data) and their dependencies.
*/
class Record_Provider implements ServiceProviderInterface, Bootable_Provider_Interface {
/**
* @param Container $pimple Container instance.
*/
public function register( Container $pimple ) {
$pimple['stopwatch'] = $pimple->factory( function () {
return new Stopwatch( true );
} );
$pimple['collectors'] = function ( Plugin $laps ) {
return [
'core' => new Core_Load_Collector(),
'hook' => new Hook_Record_Collector( $laps['stopwatch'], $laps['hook.events'] ),
'http' => new Http_Record_Collector( $laps['stopwatch'] ),
'sql' => new Sql_Record_Collector(),
];
};
$pimple['records'] = function ( Plugin $laps ) {
$records = [];
/** @var Record_Collector_Interface $collector */
foreach ( $laps['collectors'] as $collector ) {
$records[] = $collector->get_records();
}
return array_merge( ...$records );
};
}
/**
* @param Plugin $laps Container instance.
*/
public function boot( Plugin $laps ) {
$laps['collectors'];
}
}
+35
View File
@@ -0,0 +1,35 @@
<?php
namespace Rarst\Laps\Record;
/**
* Covers pre–plugin load time from available data.
*/
class Core_Load_Collector implements Record_Collector_Interface {
/** @var float $timeload */
protected $timeload;
/**
* Store core load end, plugin load start mark.
*/
public function __construct() {
$this->timeload = microtime( true );
}
/**
* @return Record_Interface[]
*/
public function get_records() {
global $timestart;
$request_time = $_SERVER['REQUEST_TIME_FLOAT'];
return [
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.
new Record( 'Core and MU Plugins Load', $timestart, $this->timeload - $timestart, '', 'core' ),
];
}
}
+104
View File
@@ -0,0 +1,104 @@
<?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();
}
}
+58
View File
@@ -0,0 +1,58 @@
<?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;
}
}
+81
View File
@@ -0,0 +1,81 @@
<?php
namespace Rarst\Laps\Record;
/**
* Generic record with all properties set by constructor.
*/
class Record implements Record_Interface {
/** @var string $name */
protected $name;
/** @var float $origin */
protected $origin;
/** @var float $duration */
protected $duration;
/** @var string $description */
protected $description;
/** @var string $category */
protected $category;
/**
* @param string $name Name.
* @param float $origin Start time.
* @param float $duration Duration.
* @param string $description Optional description.
* @param string $category Optional category.
*/
public function __construct( $name, $origin, $duration, $description = '', $category = '' ) {
$this->name = $name;
$this->origin = $origin;
$this->duration = $duration;
$this->description = $description;
$this->category = $category;
}
/**
* @return string
*/
public function get_name() {
return $this->name;
}
/**
* @return string
*/
public function get_description() {
if ( empty( $this->description ) ) {
$duration = round( $this->get_duration() * 1000 );
return "{$this->name} – {$duration}&nbsp;ms";
}
return $this->description;
}
/**
* @return float
*/
public function get_origin() {
return $this->origin;
}
/**
* @return float
*/
public function get_duration() {
return $this->duration;
}
/**
* @return string
*/
public function get_category() {
return $this->category;
}
}
+11
View File
@@ -0,0 +1,11 @@
<?php
namespace Rarst\Laps\Record;
interface Record_Collector_Interface {
/**
* @return Record_Interface[]
*/
public function get_records();
}
+34
View File
@@ -0,0 +1,34 @@
<?php
namespace Rarst\Laps\Record;
/**
* Interface for recorded results of individual event.
*/
interface Record_Interface {
/**
* @return string
*/
public function get_name();
/**
* @return string
*/
public function get_description();
/**
* @return float Timestamp of record start.
*/
public function get_origin();
/**
* @return float Record duration in seconds.
*/
public function get_duration();
/**
* @return string
*/
public function get_category();
}
+73
View File
@@ -0,0 +1,73 @@
<?php
namespace Rarst\Laps\Record;
/**
* Processes records, recursively bumping overlapping ones to children.
*/
class Recursive_Record_Iterator extends \ArrayIterator implements \RecursiveIterator {
/** @var array $children */
protected $children = [];
/**
* @param Record_Interface[] $records Records to process.
* @param int $flags Configuration flags.
*/
public function __construct( array $records, $flags = 0 ) {
usort( $records, [ $this, 'sort_origin' ] );
$end = 0;
foreach ( $records as $key => $record ) {
$origin = $record->get_origin();
$overlaps = $origin < $end; // Float comparison alarm.
$borders = abs( $origin - $end ) < 0.0001; // If effectively equal.
if ( $overlaps && ! $borders ) {
unset( $records[ $key ] );
$this->children[] = $record;
continue;
}
$end = $origin + $record->get_duration();
}
parent::__construct( $records, $flags );
}
/**
* @param Record_Interface $record_a Record to compare.
* @param Record_Interface $record_b Record to compare.
*
* @return int
*/
protected function sort_origin( Record_Interface $record_a, Record_Interface $record_b ) {
$origin_a = $record_a->get_origin();
$origin_b = $record_b->get_origin();
if ( $origin_a === $origin_b ) {
return 0;
}
return ( $origin_a < $origin_b ) ? - 1 : 1;
}
/**
* @return bool
*/
public function hasChildren() {
return ! empty( $this->children );
}
/**
* @return static
*/
public function getChildren() {
return new static( $this->children );
}
}
+82
View File
@@ -0,0 +1,82 @@
<?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;
}
}
+65
View File
@@ -0,0 +1,65 @@
<?php
namespace Rarst\Laps\Record;
use Symfony\Component\Stopwatch\StopwatchEvent;
/**
* Record wrapper for an event recorded with Stopwatch.
*/
class Stopwatch_Record implements Record_Interface {
/** @var string $name */
protected $name;
/** @var StopwatchEvent */
protected $stopwatch_event;
/**
* @param string $name Event name.
* @param StopwatchEvent $stopwatch_event Stopwatch event instance.
*/
public function __construct( $name, StopwatchEvent $stopwatch_event ) {
$this->name = $name;
$this->stopwatch_event = $stopwatch_event;
}
/**
* @return string
*/
public function get_name() {
return $this->name;
}
/**
* @return string
*/
public function get_description() {
$duration = round( $this->stopwatch_event->getDuration() );
$memory = $this->stopwatch_event->getMemory() / 1024 / 1024;
return "{$this->name} – {$duration} ms – {$memory} MB";
}
/**
* @return float Timestamp of record start.
*/
public function get_origin() {
return $this->stopwatch_event->getOrigin() / 1000; // ms to s.
}
/**
* @return float Record duration in seconds.
*/
public function get_duration() {
return $this->stopwatch_event->getDuration() / 1000; // ms to s.
}
/**
* @return string
*/
public function get_category() {
return $this->stopwatch_event->getCategory();
}
}
+73
View File
@@ -0,0 +1,73 @@
<?php
namespace Rarst\Laps\Record;
use Symfony\Component\Stopwatch\Stopwatch;
use Symfony\Component\Stopwatch\StopwatchEvent;
/**
* Generic Stopwatch–based collector. Can be used by itself or extended.
*/
class Stopwatch_Record_Collector implements Record_Collector_Interface {
/** @var Stopwatch $stopwatch */
protected $stopwatch;
/**
* @param Stopwatch $stopwatch Stopwatch instance.
*/
public function __construct( Stopwatch $stopwatch ) {
$this->stopwatch = $stopwatch;
}
/**
* @param string $name The event name.
* @param string $category The event category.
*
* @return StopwatchEvent
*/
public function start( $name, $category = null ) {
return $this->stopwatch->start( $name, $category );
}
/**
* @param string $name The event name.
*
* @return bool|StopwatchEvent
*/
public function stop( $name ) {
if ( $this->stopwatch->isStarted( $name ) ) {
return $this->stopwatch->stop( $name );
}
return false;
}
/**
* @return Stopwatch_Record[]
*/
public function get_records() {
$events = $this->stopwatch->getSectionEvents( '__root__' );
foreach ( array_keys( $events ) as $name ) {
if ( $this->stopwatch->isStarted( $name ) ) {
unset( $events[ $name ] );
}
}
return array_map( [ $this, 'transform' ], array_keys( $events ), $events );
}
/**
* @param string $name Event name.
* @param StopwatchEvent $event Stopwatch event instance.
*
* @return Stopwatch_Record
*/
protected function transform( $name, StopwatchEvent $event ) {
return new Stopwatch_Record( $name, $event );
}
}
+92
View File
@@ -0,0 +1,92 @@
<?php
namespace Rarst\Laps\Record;
/**
* Processes records into sets for display by template.
*/
class Timeline_Iterator implements \Iterator {
/** @var float $origin Start point for the timeline. */
protected $origin;
/** @var float $end Timeline duration. */
protected $total;
/** @var Recursive_Record_Iterator */
protected $iterator;
/** @var Recursive_Record_Iterator */
protected $current;
/**
* @param Recursive_Record_Iterator $iterator Record iterator.
*/
public function __construct( Recursive_Record_Iterator $iterator ) {
$this->origin = $_SERVER['REQUEST_TIME_FLOAT'];
$this->iterator = $iterator;
}
/**
* @return array
*/
public function current() {
$data = [];
foreach ( $this->current as $record ) {
$data[] = $this->prepare( $record );
}
return $data;
}
/**
* Sets current context to the next set of nested records.
*/
public function next() {
$this->current = $this->current->getChildren();
}
/**
* @codeCoverageIgnore
*
* @return void
*/
public function key() {
}
/**
* @return bool If current set contains records.
*/
public function valid() {
return (bool) count( $this->current );
}
/**
* Rewind to a topmost record set.
*/
public function rewind() {
$this->total = microtime( true ) - $this->origin;
$this->current = $this->iterator;
}
/**
* @param Record_Interface $record Record instance.
*
* @return array Record data for display by the template.
*/
protected function prepare( Record_Interface $record ) {
$data = [
'description' => $record->get_description(),
'category' => $record->get_category(),
'offset' => round( ( $record->get_origin() - $this->origin ) / $this->total * 100, 2 ),
'width' => round( $record->get_duration() / $this->total * 100, 2 ),
];
return $data;
}
}
-40
View File
@@ -1,40 +0,0 @@
<?php
namespace Rarst\Laps;
/**
* Base class for bulk event providers
*/
abstract class Laps_Events {
/**
* Retrieve array of event data
*
* @return array
*/
public function get() {
if ( $this->is_applicable() ) {
return $this->get_events();
}
return array();
}
/**
* Is event pack relevant to current runtime
*
* @return bool
*/
protected function is_applicable() {
return true;
}
/**
* Inherit with internal events compiling and return
*
* @return array()
*/
abstract protected function get_events();
}
-62
View File
@@ -1,62 +0,0 @@
<?php
namespace Rarst\Laps;
/**
* Events for Genesis Framework based themes
*
* @link http://my.studiopress.com/themes/genesis/
*/
class Genesis_Events extends Laps_Events {
/**
* @return bool
*/
protected function is_applicable() {
return function_exists( 'genesis' );
}
/**
* @return array
*/
protected function get_events() {
$events = array();
$events['genesis_before_header'][10] = array(
'event' => 'Header',
'category' => 'theme',
);
$events['genesis_after_header'][10] = array(
'action' => 'stop',
'event' => 'Header',
'category' => 'theme',
);
$events['genesis_before_sidebar_widget_area'][10] = array(
'event' => 'Sidebar',
'category' => 'theme',
);
$events['genesis_after_sidebar_widget_area'][10] = array(
'action' => 'stop',
'event' => 'Sidebar',
'category' => 'theme',
);
$events['genesis_before_sidebar_alt_widget_area'][10] = array(
'event' => 'Sidebar (alternate)',
'category' => 'theme',
);
$events['genesis_after_sidebar_alt_widget_area'][10] = array(
'action' => 'stop',
'event' => 'Sidebar (alternate)',
'category' => 'theme',
);
return $events;
}
}
-321
View File
@@ -1,321 +0,0 @@
<?php
namespace Rarst\Laps;
use Symfony\Component\Stopwatch\Stopwatch;
/**
* Main plugin's class.
*/
class Laps {
/** @var Stopwatch $stopwatch */
public static $stopwatch;
public static $events = array();
public static $query_starts = array();
/**
* Start Stopwatch and timing plugin load immediately, then set up core events and needed hooks.
*/
static function on_load() {
if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
return;
}
self::$stopwatch = new Stopwatch();
self::$stopwatch->start( 'Plugins Load', 'plugin' );
$events = new Core_Events();
self::add_events( $events->get() );
add_action( 'pre_update_option_active_plugins', array( __CLASS__, 'pre_update_option_active_plugins' ) );
add_action( 'pre_update_site_option_active_sitewide_plugins', array( __CLASS__, 'pre_update_option_active_plugins' ) );
add_action( 'pre_http_request', array( __CLASS__, 'pre_http_request' ), 10, 3 );
add_action( 'http_api_debug', array( __CLASS__, 'http_api_debug' ), 10, 5 );
add_action( 'after_setup_theme', array( __CLASS__, 'after_setup_theme' ), 15 );
add_action( 'init', array( __CLASS__, 'init' ) );
if ( defined( 'SAVEQUERIES' ) && SAVEQUERIES ) {
add_filter( 'query', array( __CLASS__, 'query' ), 20 );
}
}
/**
* Hook events by name and priority from array.
*
* @param array $stops
*/
static function add_events( $stops ) {
self::$events = array_merge( self::$events, $stops );
foreach ( $stops as $hook_name => $data ) {
foreach ( array_keys( $data ) as $priority ) {
add_action( $hook_name, array( __CLASS__, 'tick' ), $priority );
}
}
}
/**
* Reorder active plugins so Laps is first and starts timing load early.
*
* @param array $plugins
*
* @return array
*/
static function pre_update_option_active_plugins( $plugins ) {
$plugin = plugin_basename( dirname( __DIR__ ) . '/laps.php' );
$key = array_search( $plugin, $plugins );
if ( false !== $key && $key > 0 ) {
unset( $plugins[$key] );
array_unshift( $plugins, $plugin );
$plugins = array_values( $plugins );
}
return $plugins;
}
/**
* Mark action for the event on Stopwatch.
*
* @param mixed $input pass through if added to filter
*
* @return mixed
*/
static function tick( $input = null ) {
global $wp_filter;
$filter = current_filter();
$priority = key( $wp_filter[$filter] );
$event = wp_parse_args(
self::$events[$filter][$priority],
array(
'action' => 'start',
'category' => null,
)
);
self::$stopwatch->$event['action']( $event['event'], $event['category'] );
return $input;
}
/**
* Capture SQL queries start times
*
* @param string $query
*
* @return string
*/
static function query( $query ) {
global $wpdb;
if ( empty( self::$query_starts ) && ! empty( $wpdb->queries ) ) {
self::$query_starts[count( $wpdb->queries )] = microtime( true ) * 1000;
} else {
self::$query_starts[] = microtime( true ) * 1000;
}
return $query;
}
/**
* Capture start time of HTTP request
*
* @param boolean $false
* @param array $args
* @param string $url
*
* @return boolean
*/
static function pre_http_request( $false, $args, $url ) {
self::$stopwatch->start( $url, 'http' );
return $false;
}
/**
* Capture end time of HTTP request
*
* @param array|\WP_Error $response
* @param string $type
* @param object $class
* @param array $args
* @param string $url
*
* @return mixed
*/
static function http_api_debug( $response, $type, $class, $args, $url ) {
self::$stopwatch->stop( $url );
return $response;
}
/**
* When theme is done possibly add theme-specific events.
*/
static function after_setup_theme() {
foreach ( array( 'THA', 'Hybrid', 'Genesis', 'Thematic' ) as $theme ) {
$class = "Rarst\\Laps\\{$theme}_Events";
/** @var Laps_Events $events */
$events = new $class;
self::add_events( $events->get() );
}
}
static function init() {
add_action( 'wp_enqueue_scripts', array( __CLASS__, 'enqueue_scripts' ) );
add_action( 'admin_enqueue_scripts', array( __CLASS__, 'enqueue_scripts' ) );
add_action( 'admin_bar_menu', array( __CLASS__, 'admin_bar_menu' ), 100 );
add_action( 'wp_print_footer_scripts', array( __CLASS__, 'print_footer_scripts' ), 11 );
add_action( 'admin_print_footer_scripts', array( __CLASS__, 'print_footer_scripts' ), 11 );
}
static function enqueue_scripts() {
wp_register_script( 'laps-tooltip', plugins_url( 'js/tooltip.js', __DIR__ ), array( 'jquery' ), '3.0.2', true );
wp_register_style( 'laps', plugins_url( 'css/laps.css', __DIR__ ) );
if ( is_admin_bar_showing() ) {
wp_enqueue_script( 'laps-tooltip' );
wp_enqueue_style( 'laps' );
}
}
static function print_footer_scripts() {
if ( wp_script_is( 'laps-tooltip', 'done' ) ) {
?>
<script type="text/javascript">
jQuery(document).ready(function () {
jQuery(".laps-timeline .event").lapstooltip({
container: '#wpadminbar', placement: 'bottom', html: true
// , trigger: 'click'
});
});
</script><?php
}
}
/**
* Render interface and add to the toolbar.
*
* @param \WP_Admin_Bar $wp_admin_bar
*/
static function admin_bar_menu( $wp_admin_bar ) {
if ( ! apply_filters( 'laps_can_see', current_user_can( 'manage_options' ) ) ) {
return;
}
global $timestart, $wpdb;
$mustache = new \Mustache_Engine(
array(
'loader' => new \Mustache_Loader_FilesystemLoader( dirname( __DIR__ ) . '/views' ),
)
);
self::$stopwatch->stop( 'Toolbar' );
$events = self::$stopwatch->getSectionEvents( '__root__' );
$start = $timestart * 1000;
$end = microtime( true ) * 1000;
$total = $end - $start;
$event_data = array();
$http_data = array();
foreach ( $events as $name => $event ) {
$offset = round( ( $event->getOrigin() - $start ) / $total * 100, 2 );
$duration = $event->getDuration();
$width = round( $duration / $total * 100, 2 );
$category = $event->getCategory();
if ( 'http' == $category ) {
$http_data[] = compact( 'name', 'offset', 'duration', 'width', 'category' );
continue;
}
$memory = $event->getMemory() / 1024 / 1024;
$event_data[] = compact( 'name', 'offset', 'duration', 'width', 'category', 'memory' );
}
$query_data = array();
$last_query_end = 0;
$last_offset = 0;
$last_duration = 0;
$category = 'query';
if ( defined( 'SAVEQUERIES' ) && SAVEQUERIES ) {
foreach ( $wpdb->queries as $key => $query ) {
$query_start = isset( self::$query_starts[$key] ) ? self::$query_starts[$key] : $last_query_end;
list( $sql, $duration, $trace ) = $query;
$duration *= 1000;
$last_query_end = $query_start + $duration;
$offset = round( ( $query_start - $start ) / $total * 100, 2 );
// if query is indistinguishably close to previous then stack it
if ( $offset == $last_offset ) {
$key = count( $query_data ) - 1;
$query_data[$key]['sql'] .= '<br />' . $sql;
$last_duration += $duration;
$width = round( $last_duration / $total * 100, 2 );
$query_data[$key]['width'] = $width;
continue;
}
$width = round( $duration / $total * 100, 2 );
$last_offset = $offset;
$last_duration = $duration;
$query_data[] = compact( 'sql', 'duration', 'offset', 'width', 'category' );
}
}
// !d( self::$query_starts, $wpdb->queries, $query_data );
$html = $mustache->render(
'laps',
array(
'events' => $event_data,
'queries' => $query_data,
'savequeries' => defined( 'SAVEQUERIES' ) && SAVEQUERIES,
'http' => $http_data,
'savehttp' => ! empty( $http_data ),
)
);
$wp_admin_bar->add_node(
array(
'id' => 'laps',
'title' => sprintf( 'Lap: %ss', round( $total / 1000, 3 ) ),
)
);
$wp_admin_bar->add_node(
array(
'id' => 'laps_output',
'parent' => 'laps',
'meta' => array( 'html' => $html ),
)
);
}
}
-51
View File
@@ -1,51 +0,0 @@
<?php
namespace Rarst\Laps;
/**
* Events for Theme Hook Alliance
*
* @link http://zamoose.github.io/themehookalliance/
*/
class THA_Events extends Laps_Events {
/**
* @return bool
*/
protected function is_applicable() {
return defined( 'THA_HOOKS_VERSION' );
}
/**
* @return array
*/
protected function get_events() {
$events = array();
$events['tha_header_before'][10] = array(
'event' => 'Header',
'category' => 'theme',
);
$events['tha_header_after'][10] = array(
'action' => 'stop',
'event' => 'Header',
'category' => 'theme',
);
$events['tha_sidebars_before'][10] = array(
'event' => 'Sidebars',
'category' => 'theme',
);
$events['tha_sidebars_after'][10] = array(
'action' => 'stop',
'event' => 'Sidebars',
'category' => 'theme',
);
return $events;
}
}
-62
View File
@@ -1,62 +0,0 @@
<?php
namespace Rarst\Laps;
/**
* Events for Thematic Framework based themes
*
* @link http://thematictheme.com/
*/
class Thematic_Events extends Laps_Events {
/**
* @return bool
*/
protected function is_applicable() {
return function_exists( 'thematic_init' );
}
/**
* @return array
*/
protected function get_events() {
$events = array();
$events['thematic_aboveheader'][10] = array(
'event' => 'Header',
'category' => 'theme',
);
$events['thematic_belowheader'][10] = array(
'action' => 'stop',
'event' => 'Header',
'category' => 'theme',
);
$events['widget_area_primary_aside'][10] = array(
'event' => 'Sidebar (primary aside)',
'category' => 'theme',
);
$events['thematic_betweenmainasides'][10] = array(
'action' => 'stop',
'event' => 'Sidebar (primary aside)',
'category' => 'theme',
);
$events['widget_area_secondary_aside'][10] = array(
'event' => 'Sidebar (secondary aside)',
'category' => 'theme',
);
$events['thematic_belowmainasides'][10] = array(
'action' => 'stop',
'event' => 'Sidebar (secondary aside)',
'category' => 'theme',
);
return $events;
}
}
@@ -0,0 +1,111 @@
<?php
class __Mustache_a04731de0bb9e043ecde3814b3a901bb extends Mustache_Template
{
private $lambdaHelper;
public function renderInternal(Mustache_Context $context, $indent = '')
{
$this->lambdaHelper = new Mustache_LambdaHelper($this->mustache, $context);
$buffer = '';
// 'timelines' section
$value = $context->find('timelines');
$buffer .= $this->sectionAdac57c50f147efcda3ea1c17e7a6c61($context, $indent, $value);
return $buffer;
}
private function section9f1840fed1e29fb14453f0ea2bfe30ad(Mustache_Context $context, $indent, $value)
{
$buffer = '';
if (!is_string($value) && is_callable($value)) {
$source = '
<div class="event event-{{category}}" data-toggle="tooltip" title="{{description}}" style="width:{{width}}%; left:{{offset}}%;">
<span class="sr-only">{{description}}</span>
</div>
';
$result = call_user_func($value, $source, $this->lambdaHelper);
if (strpos($result, '{{') === false) {
$buffer .= $result;
} else {
$buffer .= $this->mustache
->loadLambda((string) $result)
->renderInternal($context);
}
} elseif (!empty($value)) {
$values = $this->isIterable($value) ? $value : array($value);
foreach ($values as $value) {
$context->push($value);
$buffer .= $indent . ' <div class="event event-';
$value = $this->resolveValue($context->find('category'), $context);
$buffer .= htmlspecialchars($value, 2, 'UTF-8');
$buffer .= '" data-toggle="tooltip" title="';
$value = $this->resolveValue($context->find('description'), $context);
$buffer .= htmlspecialchars($value, 2, 'UTF-8');
$buffer .= '" style="width:';
$value = $this->resolveValue($context->find('width'), $context);
$buffer .= htmlspecialchars($value, 2, 'UTF-8');
$buffer .= '%; left:';
$value = $this->resolveValue($context->find('offset'), $context);
$buffer .= htmlspecialchars($value, 2, 'UTF-8');
$buffer .= '%;">
';
$buffer .= $indent . ' <span class="sr-only">';
$value = $this->resolveValue($context->find('description'), $context);
$buffer .= htmlspecialchars($value, 2, 'UTF-8');
$buffer .= '</span>
';
$buffer .= $indent . ' </div>
';
$context->pop();
}
}
return $buffer;
}
private function sectionAdac57c50f147efcda3ea1c17e7a6c61(Mustache_Context $context, $indent, $value)
{
$buffer = '';
if (!is_string($value) && is_callable($value)) {
$source = '
<div class="laps-timeline">
{{#.}}
<div class="event event-{{category}}" data-toggle="tooltip" title="{{description}}" style="width:{{width}}%; left:{{offset}}%;">
<span class="sr-only">{{description}}</span>
</div>
{{/.}}
</div>
';
$result = call_user_func($value, $source, $this->lambdaHelper);
if (strpos($result, '{{') === false) {
$buffer .= $result;
} else {
$buffer .= $this->mustache
->loadLambda((string) $result)
->renderInternal($context);
}
} elseif (!empty($value)) {
$values = $this->isIterable($value) ? $value : array($value);
foreach ($values as $value) {
$context->push($value);
$buffer .= $indent . ' <div class="laps-timeline">
';
// '.' section
$value = $context->last('.');
$buffer .= $this->section9f1840fed1e29fb14453f0ea2bfe30ad($context, $indent, $value);
$buffer .= $indent . ' </div>
';
$context->pop();
}
}
return $buffer;
}
}
+9
View File
@@ -0,0 +1,9 @@
{{#timelines}}
<div class="laps-timeline">
{{#.}}
<div class="event event-{{category}}" data-toggle="tooltip" title="{{description}}" style="width:{{width}}%; left:{{offset}}%;">
<span class="sr-only">{{description}}</span>
</div>
{{/.}}
</div>
{{/timelines}}
+77
View File
@@ -0,0 +1,77 @@
<?php
namespace Rarst\Laps\Tests\Event;
use Brain\Monkey\Functions;
use Rarst\Laps\Event\Core_Events;
use Rarst\Laps\Event\Genesis_Events;
use Rarst\Laps\Event\Hybrid_Events;
use Rarst\Laps\Event\THA_Events;
use Rarst\Laps\Event\Yoast_Events;
use Rarst\Laps\Tests\LapsTestCase;
class EventTest extends LapsTestCase {
public function testCore() {
$events = ( new Core_Events() )->get_events();
$this->assertInternalType( 'array', $events );
$this->assertNotEmpty( $events );
}
public function testGenesis() {
$genesis = new Genesis_Events();
$this->assertEmpty( $genesis->get_events() );
Functions\expect( 'genesis' )->zeroOrMoreTimes();
$events = $genesis->get_events();
$this->assertInternalType( 'array', $events );
$this->assertNotEmpty( $events );
}
public function testHybrid() {
$hybrid = new Hybrid_Events();
$this->assertEmpty( $hybrid->get_events() );
Functions\expect( 'hybrid_get_prefix' )->once()->andReturn( 'hybrid' );
Functions\expect( 'get_theme_support' )
->once()
->with( 'hybrid-core-sidebars' )
->andReturn( [ [ 'primary' ] ] );
$events = $hybrid->get_events();
$this->assertInternalType( 'array', $events );
$this->assertNotEmpty( $events );
}
public function testTha() {
$tha = new THA_Events();
$this->assertEmpty( $tha->get_events() );
define( 'THA_HOOKS_VERSION', '1.0' );
$events = $tha->get_events();
$this->assertInternalType( 'array', $events );
$this->assertNotEmpty( $events );
}
public function testYoast() {
$yoast = new Yoast_Events();
$this->assertEmpty( $yoast->get_events() );
$this->getMockBuilder( 'WPSEO_Frontend' )->allowMockingUnknownTypes()->getMock();
$events = $yoast->get_events();
$this->assertInternalType( 'array', $events );
$this->assertNotEmpty( $events );
}
}
+22
View File
@@ -0,0 +1,22 @@
<?php
namespace Rarst\Laps\Tests;
use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
use PHPUnit\Framework\TestCase;
use Brain\Monkey;
class LapsTestCase extends TestCase {
use MockeryPHPUnitIntegration;
protected function setUp() {
parent::setUp();
Monkey\setUp();
}
protected function tearDown() {
Monkey\tearDown();
parent::tearDown();
}
}
+44
View File
@@ -0,0 +1,44 @@
<?php
namespace Rarst\Laps\Tests\Manager;
use Brain\Monkey\Functions;
use Rarst\Laps\Manager\Asset_Manager;
use Rarst\Laps\Tests\LapsTestCase;
/**
* @coversDefaultClass Rarst\Laps\Manager\Asset_Manager
*/
class AssetTest extends LapsTestCase {
/**
* @covers ::__construct
*
* @return Asset_Manager
*/
public function test__construct() {
$manager = new Asset_Manager();
$this->assertTrue( has_action( 'wp_enqueue_scripts', [ $manager, 'enqueue_scripts' ] ) );
$this->assertTrue( has_action( 'admin_enqueue_scripts', [ $manager, 'enqueue_scripts' ] ) );
return $manager;
}
/**
* @covers ::enqueue_scripts
* @depends test__construct
*/
public function testEnqueue_scripts( Asset_Manager $manager ) {
Functions\expect( 'wp_register_script' )->once();
Functions\expect( 'wp_register_style' )->once();
Functions\expect( 'plugins_url' )->zeroOrMoreTimes();
Functions\expect( 'is_admin_bar_showing' )->once()->andReturn( true );
Functions\expect( 'wp_enqueue_script' )->once();
Functions\expect( 'wp_enqueue_style' )->once();
$manager->enqueue_scripts();
}
}
+50
View File
@@ -0,0 +1,50 @@
<?php
namespace Rarst\Laps\Tests\Manager;
use Brain\Monkey\Functions;
use Rarst\Laps\Manager\Load_Order_Manager;
use Rarst\Laps\Tests\LapsTestCase;
/**
* @coversDefaultClass Rarst\Laps\Manager\Load_Order_Manager
*/
class LoadOrderTest extends LapsTestCase {
/**
* @covers ::__construct
*
* @return Load_Order_Manager
*/
public function test__construct() {
$manager = new Load_Order_Manager();
$this->assertTrue( has_action( 'pre_update_option_active_plugins', [ $manager, 'pre_update_option_active_plugins' ] ) );
$this->assertTrue( has_action( 'pre_update_site_option_active_sitewide_plugins', [ $manager, 'pre_update_option_active_plugins' ] ) );
return $manager;
}
/**
* @covers ::pre_update_option_active_plugins
* @depends test__construct
*/
public function testPre_update_option_active_plugins( Load_Order_Manager $manager ) {
$plugins = [
'foo/bar.php',
'laps/laps.php',
'baz/qux.php',
];
Functions\expect( 'plugin_basename' )->once()->andReturn( 'laps/laps.php' );
$plugins = $manager->pre_update_option_active_plugins( $plugins );
$this->assertInternalType( 'array', $plugins );
$this->assertCount( 3, $plugins );
$this->assertEquals( 'laps/laps.php', $plugins[0] );
}
}
+58
View File
@@ -0,0 +1,58 @@
<?php
namespace Rarst\Laps\Tests\Manager;
use Brain\Monkey\Functions;
use Rarst\Laps\Manager\Toolbar_Manager;
use Rarst\Laps\Plugin;
use Rarst\Laps\Tests\LapsTestCase;
/**
* @coversDefaultClass Rarst\Laps\Manager\Toolbar_Manager
*/
class ToolbarTest extends LapsTestCase {
/**
* @covers ::__construct
*
* @return Toolbar_Manager
*/
public function test__construct() {
$laps = new Plugin( [ 'records' => [] ] );
$manager = new Toolbar_Manager( $laps );
$this->assertTrue( has_action( 'admin_bar_menu', [ $manager, 'admin_bar_menu' ] ) );
return $manager;
}
/**
* @covers ::admin_bar_menu
*
* @depends test__construct
*/
public function testAdmin_bar_menu( Toolbar_Manager $manager ) {
$wp_admin_bar = $this->getMockBuilder( 'WP_Admin_Bar' )
->allowMockingUnknownTypes()
->setMethods( [ 'add_node' ] )
->getMock();
$wp_admin_bar->method( 'add_node' )->willReturn( null );
$wp_admin_bar->expects( $this->exactly( 2 ) )
->method( 'add_node' )
->withConsecutive(
[ $this->isType( 'array' ) ],
[ $this->isType( 'array' ) ]
);
Functions\expect( 'current_user_can' )
->once()
->with( 'manage_options' )
->andReturn( true );
$manager->admin_bar_menu( $wp_admin_bar );
}
}
+29
View File
@@ -0,0 +1,29 @@
<?php
namespace Rarst\Laps\Tests;
use Pimple\ServiceProviderInterface;
use Rarst\Laps\Provider\Bootable_Provider_Interface;
class PluginTest extends LapsTestCase {
public function testContainer() {
$container = new \Rarst\Laps\Plugin();
$service = $this->getMockBuilder( [ ServiceProviderInterface::class, Bootable_Provider_Interface::class ] )
->getMock();
$service->expects( $this->once() )
->method( 'register' )
->with( $container );
$container->register( $service );
$service->expects( $this->once() )
->method( 'boot' )
->with( $container );
$container->run();
}
}
+25
View File
@@ -0,0 +1,25 @@
<?php
namespace Rarst\Laps\Tests\Provider;
use Pimple\Container;
use Rarst\Laps\Event\Hook_Event_Config_Interface;
use Rarst\Laps\Provider\Hook_Event_Provider;
use Rarst\Laps\Tests\LapsTestCase;
class EventTest extends LapsTestCase {
public function testProvider() {
$container = new Container();
$provider = new Hook_Event_Provider();
$provider->register( $container );
$this->assertArrayHasKey( 'hook.events', $container );
foreach ( $container['hook.events'] as $config ) {
$this->assertInstanceOf( Hook_Event_Config_Interface::class, $config );
}
}
}
+29
View File
@@ -0,0 +1,29 @@
<?php
namespace Rarst\Laps\Tests\Provider;
use Pimple\Exception\FrozenServiceException;
use Rarst\Laps\Plugin;
use Rarst\Laps\Provider\Manager_Provider;
use Rarst\Laps\Tests\LapsTestCase;
class ManagerTest extends LapsTestCase {
/**
* @covers \Rarst\Laps\Provider\Manager_Provider
*/
public function testProvider() {
$container = new Plugin();
$provider = new Manager_Provider();
$provider->register( $container );
$this->assertArrayHasKey( 'managers', $container );
$container->extend( 'managers', function () {} );
$provider->boot( $container );
$this->expectException( FrozenServiceException::class );
$container->extend( 'managers', function () {} );
}
}
+35
View File
@@ -0,0 +1,35 @@
<?php
namespace Rarst\Laps\Tests\Provider;
use Pimple\Exception\FrozenServiceException;
use Rarst\Laps\Plugin;
use Rarst\Laps\Provider\Record_Provider;
use Rarst\Laps\Tests\LapsTestCase;
class RecordTest extends LapsTestCase {
/**
* @covers \Rarst\Laps\Provider\Record_Provider
*/
public function testProvider() {
$container = new Plugin();
$provider = new Record_Provider();
$provider->register( $container );
$stopwatch_a = $container['stopwatch'];
$stopwatch_b = $container['stopwatch'];
$this->assertNotSame( $stopwatch_a, $stopwatch_b );
$this->assertArrayHasKey( 'records', $container );
$container->extend( 'collectors', function () {} );
$provider->boot( $container );
$this->expectException( FrozenServiceException::class );
$container->extend( 'collectors', function () {} );
}
}
+21
View File
@@ -0,0 +1,21 @@
<?php
namespace Rarst\Laps\Tests\Record;
use Rarst\Laps\Record\Core_Load_Collector;
use Rarst\Laps\Record\Record_Interface;
use Rarst\Laps\Tests\LapsTestCase;
class CoreTest extends LapsTestCase {
public function testCollector() {
$collector = new Core_Load_Collector();
$records = $collector->get_records();
$this->assertInternalType( 'array', $records );
$this->assertCount( 2, $records );
$this->assertInstanceOf( Record_Interface::class, $records[0] );
}
}
+46
View File
@@ -0,0 +1,46 @@
<?php
namespace Rarst\Laps\Tests\Record;
use Brain\Monkey\Functions;
use Rarst\Laps\Event\Core_Events;
use Rarst\Laps\Record\Hook_Record_Collector;
use Rarst\Laps\Tests\LapsTestCase;
use Symfony\Component\Stopwatch\Stopwatch;
class HookTest extends LapsTestCase {
public function testCollector() {
$stopwatch = new Stopwatch();
$collector = new Hook_Record_Collector( $stopwatch, [ 'core' => new Core_Events() ] );
$this->assertTrue( $stopwatch->isStarted( 'Plugins Load' ) );
$this->assertTrue( has_action( 'after_setup_theme', [ $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' );
$collector->get_records();
$this->assertFalse( $stopwatch->isStarted( 'Toolbar' ) );
}
}
+28
View File
@@ -0,0 +1,28 @@
<?php
namespace Rarst\Laps\Tests\Record;
use Rarst\Laps\Record\Http_Record_Collector;
use Rarst\Laps\Tests\LapsTestCase;
use Symfony\Component\Stopwatch\Stopwatch;
class HttpTest extends LapsTestCase {
public function testCollector() {
$stopwatch = new Stopwatch();
$url = 'https://example.com/';
$collector = new Http_Record_Collector( $stopwatch );
$this->assertTrue( has_action( 'pre_http_request', [ $collector, 'pre_http_request' ] ) );
$this->assertTrue( has_action( 'http_api_debug', [ $collector, 'http_api_debug' ] ) );
$collector->pre_http_request( false, [], $url );
$this->assertTrue( $stopwatch->isStarted( $url ) );
$collector->http_api_debug( [], '', new \stdClass(), [], $url );
$this->assertFalse( $stopwatch->isStarted( $url ) );
}
}
+72
View File
@@ -0,0 +1,72 @@
<?php
namespace Rarst\Laps\Tests\Record;
use Rarst\Laps\Record\Recursive_Record_Iterator;
use Rarst\Laps\Record\Record;
use Rarst\Laps\Record\Timeline_Iterator;
use Rarst\Laps\Tests\LapsTestCase;
class IteratorTest extends LapsTestCase {
/**
* @covers \Rarst\Laps\Record\Recursive_Record_Iterator
*
* @return Recursive_Record_Iterator
*/
public function testRecord() {
$record_a = new Record( 'Parent', 0, 100 );
$record_b = new Record( 'Child', 50, 100 );
$records = [ $record_b, $record_a ];
$iterator = new Recursive_Record_Iterator( $records );
$this->assertCount( 1, $iterator->getArrayCopy() );
foreach ( $iterator as $record ) {
$this->assertEquals( 'Parent', $record->get_name() );
}
$this->assertTrue( $iterator->hasChildren() );
$children = $iterator->getChildren();
$this->assertCount( 1, $children );
foreach ( $children as $record ) {
$this->assertEquals( 'Child', $record->get_name() );
}
return $iterator;
}
/**
* @covers \Rarst\Laps\Record\Timeline_Iterator
*
* @depends testRecord
*/
public function testTimeline( Recursive_Record_Iterator $iterator ) {
$iterator = new Timeline_Iterator( $iterator );
$iterator->rewind();
$this->assertTrue( $iterator->valid() );
$records = $iterator->current();
$this->assertInternalType( 'array', $records );
$this->assertArrayHasKey( 'description', $records[0] );
$this->assertArrayHasKey( 'category', $records[0] );
$this->assertArrayHasKey( 'offset', $records[0] );
$this->assertArrayHasKey( 'width', $records[0] );
$iterator->next();
$this->assertTrue( $iterator->valid() );
$records = $iterator->current();
$this->assertInternalType( 'array', $records );
$iterator->next();
$this->assertFalse( $iterator->valid() );
}
}
+36
View File
@@ -0,0 +1,36 @@
<?php
namespace Rarst\Laps\Tests\Record;
use Rarst\Laps\Record\Record;
use Rarst\Laps\Tests\LapsTestCase;
class RecordTest extends LapsTestCase {
/**
* @covers \Rarst\Laps\Record\Record
*/
public function testRecord() {
$name = 'Name';
$origin = 0;
$duration = 1;
$description = 'description';
$category = 'info';
$record = new Record( $name, $origin, $duration );
$this->assertEquals( $name, $record->get_name() );
$this->assertEquals( $origin, $record->get_origin() );
$this->assertEquals( $duration, $record->get_duration() );
$this->assertContains( $name, $record->get_description() );
$this->assertContains( (string) ( $duration * 1000 ), $record->get_description() );
$this->assertEmpty( $record->get_category() );
$record = new Record( $name, $origin, $duration, $description, $category );
$this->assertEquals( $description, $record->get_description() );
$this->assertEquals( $category, $record->get_category() );
}
}
+46
View File
@@ -0,0 +1,46 @@
<?php
namespace Rarst\Laps\Tests\Record;
use Rarst\Laps\Record\Record;
use Rarst\Laps\Record\Sql_Record_Collector;
use Rarst\Laps\Tests\LapsTestCase;
class SqlTest extends LapsTestCase {
/**
* @covers \Rarst\Laps\Record\Sql_Record_Collector
*/
public function testCollector() {
define( 'SAVEQUERIES', true );
$collector = new Sql_Record_Collector();
$this->assertTrue( has_filter( 'query', [ $collector, 'query' ] ) );
$query = 'SELECT * FROM wp_posts';
$collector->query( $query );
global $wpdb;
$wpdb = new \stdClass();
$duration = 100;
$wpdb->queries[] = [ $query, $duration ];
$records = $collector->get_records();
$this->assertInternalType( 'array', $records );
$this->assertCount( 1, $records );
$record = $records[0];
$this->assertInstanceOf( Record::class, $record );
$this->assertEquals( $query, $record->get_name() );
$this->assertContains( $query, $record->get_description() );
$this->assertInternalType( 'float', $record->get_origin() );
$this->assertEquals( $duration, $record->get_duration() );
$this->assertEquals( 'sql-read', $record->get_category() );
}
}
+52
View File
@@ -0,0 +1,52 @@
<?php
namespace Rarst\Laps\Tests\Record;
use Rarst\Laps\Record\Stopwatch_Record;
use Rarst\Laps\Record\Stopwatch_Record_Collector;
use Rarst\Laps\Tests\LapsTestCase;
use Symfony\Component\Stopwatch\Stopwatch;
use Symfony\Component\Stopwatch\StopwatchEvent;
class StopwatchTest extends LapsTestCase {
/**
* @covers \Rarst\Laps\Record\Stopwatch_Record_Collector
*/
public function testCollector() {
$collector = new Stopwatch_Record_Collector( new Stopwatch() );
$collector->start( 'Event', 'info' );
$collector->start( 'Not stopped', 'info' );
usleep( 1000 );
$event = $collector->stop( 'Event' );
$this->assertFalse( $collector->stop( 'Not event' ) );
$records = $collector->get_records();
$this->assertInternalType( 'array', $records );
$this->assertCount( 1, $records );
$this->assertInstanceOf( Stopwatch_Record::class, $records[0] );
return $event;
}
/**
* @depends testCollector
* @covers \Rarst\Laps\Record\Stopwatch_Record
*
* @param StopwatchEvent $event Event instance.
*/
public function testRecord( StopwatchEvent $event ) {
$record = new Stopwatch_Record( 'Event', $event );
$this->assertEquals( 'Event', $record->get_name() );
$this->assertEquals( 'info', $record->get_category() );
$this->assertEquals( $event->getOrigin() / 1000, $record->get_origin() );
$this->assertEquals( $event->getDuration() / 1000, $record->get_duration() );
$this->assertContains( 'Event', $record->get_description() );
}
}
-21
View File
@@ -1,21 +0,0 @@
<div class="laps-timeline">
{{#events}}
<div class="event event-{{category}}" data-toggle="tooltip" title="{{name}} - {{duration}} ms - {{memory}} MB" style="width:{{width}}%; left:{{offset}}%;"></div>
{{/events}}
</div>
{{#savequeries}}
<div class="laps-timeline">
{{#queries}}
<div class="event event-{{category}}" title="{{sql}}" style="width:{{width}}%; left:{{offset}}%;"></div>
{{/queries}}
</div>
{{/savequeries}}
{{#savehttp}}
<div class="laps-timeline">
{{#http}}
<div class="event event-{{category}}" title="{{name}} - {{duration}} ms" style="width:{{width}}%; left:{{offset}}%;"></div>
{{/http}}
</div>
{{/savehttp}}