diff --git a/src/class-core-events.php b/src/class-core-events.php index 6443792..77d504f 100644 --- a/src/class-core-events.php +++ b/src/class-core-events.php @@ -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(); diff --git a/src/class-events.php b/src/class-events.php index 77fbe9a..f80eed9 100644 --- a/src/class-events.php +++ b/src/class-events.php @@ -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(); diff --git a/src/class-genesis-events.php b/src/class-genesis-events.php index 8cab03d..138c40a 100644 --- a/src/class-genesis-events.php +++ b/src/class-genesis-events.php @@ -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(); diff --git a/src/class-hybrid-events.php b/src/class-hybrid-events.php index d81b1d7..53bd3c2 100644 --- a/src/class-hybrid-events.php +++ b/src/class-hybrid-events.php @@ -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; } diff --git a/src/class-laps.php b/src/class-laps.php index 0613fb0..8486dcd 100644 --- a/src/class-laps.php +++ b/src/class-laps.php @@ -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 ); diff --git a/src/class-tha-events.php b/src/class-tha-events.php index e85ffac..0f321f4 100644 --- a/src/class-tha-events.php +++ b/src/class-tha-events.php @@ -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; + } } \ No newline at end of file diff --git a/src/class-thematic-events.php b/src/class-thematic-events.php index 869bbca..b128dd9 100644 --- a/src/class-thematic-events.php +++ b/src/class-thematic-events.php @@ -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();