Adjusted hook events for a simpler interface and wrapped in a provider.

This commit is contained in:
Andrey Savchenko committed 2018-02-13 17:26:41 +02:00
1 parent 06e3bb4657
commit c74051e87d
13 files changed
+223 -234

No files matched your search

+107
View File
@@ -0,0 +1,107 @@
<?php
namespace Rarst\Laps\Event;
/**
* Main set of events for WordPress core
*/
class Core_Events implements Hook_Event_Config_Interface {
/**
* @return array
*/
public function get_events() {
$stops = [];
$stops['plugins_loaded'][-2] = [
'action' => 'stop',
'event' => 'Plugins Load',
'category' => 'plugin',
];
$stops['plugins_loaded'][-1] = [
'event' => 'Plugins Loaded Hook',
'category' => 'plugin',
];
$stops['plugins_loaded'][20] = [
'action' => 'stop',
'event' => 'Plugins Loaded Hook',
'category' => 'plugin',
];
$stops['setup_theme'][0] = [
'event' => 'Themes Load',
'category' => 'theme',
];
$stops['after_setup_theme'][20] = [
'action' => 'stop',
'event' => 'Themes Load',
'category' => 'theme',
];
$stops['init'][-1] = [
'event' => 'Core Init',
'category' => 'core',
];
$stops['wp_loaded'][20] = [
'action' => 'stop',
'event' => 'Core Init',
'category' => 'core',
];
$stops['admin_init'][-1] = [
'event' => 'Core Admin Init',
'category' => 'core',
];
$stops['admin_init'][ PHP_INT_MAX - 1 ] = [
'action' => 'stop',
'event' => 'Core Admin Init',
'category' => 'core',
];
$stops['_admin_menu'][-1] = [
'event' => 'Admin Menu',
'category' => 'core',
];
$stops['admin_menu'][ PHP_INT_MAX - 1 ] = [
'action' => 'stop',
'event' => 'Admin Menu',
'category' => 'core',
];
$stops['admin_bar_menu'][-1] = [
'event' => 'Toolbar',
'category' => 'core',
];
$stops['loop_start'][10] = [
'event' => 'Main Loop',
'category' => 'theme',
];
$stops['loop_end'][10] = [
'action' => 'stop',
'event' => 'Main Loop',
'category' => 'theme',
];
$stops['admin_enqueue_scripts'][10] = [
'event' => 'Admin Print Scripts',
'category' => 'core',
];
$stops['admin_print_scripts'][10] = [
'action' => 'stop',
'event' => 'Admin Print Scripts',
'category' => 'core',
];
return $stops;
}
}
+59
View File
@@ -0,0 +1,59 @@
<?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();
}
+57
View File
@@ -0,0 +1,57 @@
<?php
namespace Rarst\Laps\Event;
/**
* Events for Hybrid Core based themes
*
* @link http://themehybrid.com/hybrid-core
*/
class Hybrid_Events implements Hook_Event_Config_Interface {
/**
* @return array
*/
public function get_events() {
$events = [];
if ( ! function_exists( 'hybrid_get_prefix' ) ) {
return $events;
}
$prefix = hybrid_get_prefix();
$events["{$prefix}_before_header"][10] = [
'event' => 'Header',
'category' => 'theme',
];
$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] = [
'event' => "Sidebar ({$sidebar})",
'category' => 'theme',
];
$events["{$prefix}_after_{$sidebar}"][10] = [
'action' => 'stop',
'event' => "Sidebar ({$sidebar})",
'category' => 'theme',
];
}
}
return $events;
}
}
+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;
}
}