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;
|
namespace Rarst\Laps;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Main set of events for WordPress core
|
||||||
|
*/
|
||||||
class Core_Events extends Laps_Events {
|
class Core_Events extends Laps_Events {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
public function get_events() {
|
public function get_events() {
|
||||||
|
|
||||||
$stops = array();
|
$stops = array();
|
||||||
|
|||||||
+21
-11
@@ -2,9 +2,28 @@
|
|||||||
|
|
||||||
namespace Rarst\Laps;
|
namespace Rarst\Laps;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Base class for bulk event providers
|
||||||
|
*/
|
||||||
abstract class Laps_Events {
|
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
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function is_applicable() {
|
protected function is_applicable() {
|
||||||
@@ -13,17 +32,8 @@ abstract class Laps_Events {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return array
|
* Inherit with internal events compiling and return
|
||||||
*/
|
*
|
||||||
public function get() {
|
|
||||||
|
|
||||||
if( $this->is_applicable() )
|
|
||||||
return $this->get_events();
|
|
||||||
|
|
||||||
return array();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return array()
|
* @return array()
|
||||||
*/
|
*/
|
||||||
abstract protected function get_events();
|
abstract protected function get_events();
|
||||||
|
|||||||
@@ -2,13 +2,24 @@
|
|||||||
|
|
||||||
namespace Rarst\Laps;
|
namespace Rarst\Laps;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Events for Genesis Framework based themes
|
||||||
|
*
|
||||||
|
* @link http://my.studiopress.com/themes/genesis/
|
||||||
|
*/
|
||||||
class Genesis_Events extends Laps_Events {
|
class Genesis_Events extends Laps_Events {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
protected function is_applicable() {
|
protected function is_applicable() {
|
||||||
|
|
||||||
return function_exists( 'genesis' );
|
return function_exists( 'genesis' );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
protected function get_events() {
|
protected function get_events() {
|
||||||
|
|
||||||
$events = array();
|
$events = array();
|
||||||
|
|||||||
@@ -2,13 +2,24 @@
|
|||||||
|
|
||||||
namespace Rarst\Laps;
|
namespace Rarst\Laps;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Events for Hybrid Core based themes
|
||||||
|
*
|
||||||
|
* @link http://themehybrid.com/hybrid-core
|
||||||
|
*/
|
||||||
class Hybrid_Events extends Laps_Events {
|
class Hybrid_Events extends Laps_Events {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
protected function is_applicable() {
|
protected function is_applicable() {
|
||||||
|
|
||||||
return defined( 'HYBRID_VERSION' );
|
return defined( 'HYBRID_VERSION' );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
protected function get_events() {
|
protected function get_events() {
|
||||||
|
|
||||||
$events = array();
|
$events = array();
|
||||||
@@ -27,7 +38,7 @@ class Hybrid_Events extends Laps_Events {
|
|||||||
|
|
||||||
$sidebars = get_theme_support( 'hybrid-core-sidebars' );
|
$sidebars = get_theme_support( 'hybrid-core-sidebars' );
|
||||||
|
|
||||||
if ( ! empty( $sidebars[0] ) )
|
if ( ! empty( $sidebars[0] ) ) {
|
||||||
foreach ( $sidebars[0] as $sidebar ) {
|
foreach ( $sidebars[0] as $sidebar ) {
|
||||||
|
|
||||||
$events["{$prefix}_before_{$sidebar}"][10] = array(
|
$events["{$prefix}_before_{$sidebar}"][10] = array(
|
||||||
@@ -41,6 +52,7 @@ class Hybrid_Events extends Laps_Events {
|
|||||||
'category' => 'theme',
|
'category' => 'theme',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return $events;
|
return $events;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -127,6 +127,15 @@ class Laps {
|
|||||||
return $query;
|
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 ) {
|
static function pre_http_request( $false, $args, $url ) {
|
||||||
|
|
||||||
self::$stopwatch->start( $url, 'http' );
|
self::$stopwatch->start( $url, 'http' );
|
||||||
@@ -134,6 +143,17 @@ class Laps {
|
|||||||
return $false;
|
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 ) {
|
static function http_api_debug( $response, $type, $class, $args, $url ) {
|
||||||
|
|
||||||
self::$stopwatch->stop( $url );
|
self::$stopwatch->stop( $url );
|
||||||
|
|||||||
+35
-24
@@ -2,39 +2,50 @@
|
|||||||
|
|
||||||
namespace Rarst\Laps;
|
namespace Rarst\Laps;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Events for Theme Hook Alliance
|
||||||
|
*
|
||||||
|
* @link http://zamoose.github.io/themehookalliance/
|
||||||
|
*/
|
||||||
class THA_Events extends Laps_Events {
|
class THA_Events extends Laps_Events {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
protected function is_applicable() {
|
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(
|
$events['tha_header_before'][10] = array(
|
||||||
'event' => 'Header',
|
'event' => 'Header',
|
||||||
'category' => 'theme',
|
'category' => 'theme',
|
||||||
);
|
);
|
||||||
|
|
||||||
$events['tha_header_after'][10] = array(
|
$events['tha_header_after'][10] = array(
|
||||||
'action' => 'stop',
|
'action' => 'stop',
|
||||||
'event' => 'Header',
|
'event' => 'Header',
|
||||||
'category' => 'theme',
|
'category' => 'theme',
|
||||||
);
|
);
|
||||||
|
|
||||||
$events['tha_sidebars_before'][10] = array(
|
$events['tha_sidebars_before'][10] = array(
|
||||||
'event' => 'Sidebars',
|
'event' => 'Sidebars',
|
||||||
'category' => 'theme',
|
'category' => 'theme',
|
||||||
);
|
);
|
||||||
|
|
||||||
$events['tha_sidebars_after'][10] = array(
|
$events['tha_sidebars_after'][10] = array(
|
||||||
'action' => 'stop',
|
'action' => 'stop',
|
||||||
'event' => 'Sidebars',
|
'event' => 'Sidebars',
|
||||||
'category' => 'theme',
|
'category' => 'theme',
|
||||||
);
|
);
|
||||||
|
|
||||||
return $events;
|
return $events;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2,13 +2,24 @@
|
|||||||
|
|
||||||
namespace Rarst\Laps;
|
namespace Rarst\Laps;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Events for Thematic Framework based themes
|
||||||
|
*
|
||||||
|
* @link http://thematictheme.com/
|
||||||
|
*/
|
||||||
class Thematic_Events extends Laps_Events {
|
class Thematic_Events extends Laps_Events {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
protected function is_applicable() {
|
protected function is_applicable() {
|
||||||
|
|
||||||
return function_exists( 'thematic_init' );
|
return function_exists( 'thematic_init' );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
protected function get_events() {
|
protected function get_events() {
|
||||||
|
|
||||||
$events = array();
|
$events = array();
|
||||||
|
|||||||
Reference in new issue
Block a user