Cleaned up for inspection (coding style, PHPDoc)
This commit is contained in:
1 parent
68d6154a5e
commit
edb6941eb7
7 files changed
+117
-36
No files matched your search
@@ -2,8 +2,14 @@
|
||||
|
||||
namespace Rarst\Laps;
|
||||
|
||||
/**
|
||||
* Main set of events for WordPress core
|
||||
*/
|
||||
class Core_Events extends Laps_Events {
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function get_events() {
|
||||
|
||||
$stops = array();
|
||||
|
||||
+21
-11
@@ -2,9 +2,28 @@
|
||||
|
||||
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() {
|
||||
@@ -13,17 +32,8 @@ abstract class Laps_Events {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function get() {
|
||||
|
||||
if( $this->is_applicable() )
|
||||
return $this->get_events();
|
||||
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Inherit with internal events compiling and return
|
||||
*
|
||||
* @return array()
|
||||
*/
|
||||
abstract protected function get_events();
|
||||
|
||||
@@ -2,13 +2,24 @@
|
||||
|
||||
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();
|
||||
|
||||
@@ -2,13 +2,24 @@
|
||||
|
||||
namespace Rarst\Laps;
|
||||
|
||||
/**
|
||||
* 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' );
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function get_events() {
|
||||
|
||||
$events = array();
|
||||
@@ -27,7 +38,7 @@ class Hybrid_Events extends Laps_Events {
|
||||
|
||||
$sidebars = get_theme_support( 'hybrid-core-sidebars' );
|
||||
|
||||
if ( ! empty( $sidebars[0] ) )
|
||||
if ( ! empty( $sidebars[0] ) ) {
|
||||
foreach ( $sidebars[0] as $sidebar ) {
|
||||
|
||||
$events["{$prefix}_before_{$sidebar}"][10] = array(
|
||||
@@ -41,6 +52,7 @@ class Hybrid_Events extends Laps_Events {
|
||||
'category' => 'theme',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return $events;
|
||||
}
|
||||
|
||||
@@ -127,6 +127,15 @@ class Laps {
|
||||
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' );
|
||||
@@ -134,6 +143,17 @@ class Laps {
|
||||
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 );
|
||||
|
||||
+35
-24
@@ -2,39 +2,50 @@
|
||||
|
||||
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 defined( 'THA_HOOKS_VERSION' );
|
||||
}
|
||||
|
||||
protected function get_events() {
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function get_events() {
|
||||
|
||||
$events = array();
|
||||
$events = array();
|
||||
|
||||
$events['tha_header_before'][10] = array(
|
||||
'event' => 'Header',
|
||||
'category' => 'theme',
|
||||
);
|
||||
$events['tha_header_before'][10] = array(
|
||||
'event' => 'Header',
|
||||
'category' => 'theme',
|
||||
);
|
||||
|
||||
$events['tha_header_after'][10] = array(
|
||||
'action' => 'stop',
|
||||
'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_before'][10] = array(
|
||||
'event' => 'Sidebars',
|
||||
'category' => 'theme',
|
||||
);
|
||||
|
||||
$events['tha_sidebars_after'][10] = array(
|
||||
'action' => 'stop',
|
||||
'event' => 'Sidebars',
|
||||
'category' => 'theme',
|
||||
);
|
||||
$events['tha_sidebars_after'][10] = array(
|
||||
'action' => 'stop',
|
||||
'event' => 'Sidebars',
|
||||
'category' => 'theme',
|
||||
);
|
||||
|
||||
return $events;
|
||||
}
|
||||
return $events;
|
||||
}
|
||||
}
|
||||
@@ -2,13 +2,24 @@
|
||||
|
||||
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();
|
||||
|
||||
Reference in new issue
Block a user