Add template hooks for 3rd party integration

This commit is contained in:
Brian Miyaji
2017-03-23 10:47:04 +11:00
parent bd8352c812
commit c9c575c763
2 changed files with 8 additions and 126 deletions

View File

@@ -42,29 +42,6 @@ class SP_Template_Loader {
$content = '<div class="sp-post-content">' . $content . '</div>';
}
global $wp_filter;
// Array of hooks associated with this post type
$hooks = array(
'sportspress_before_single_' . $type,
'sportspress_single_' . $type . '_content',
'sportspress_after_single_' . $type,
);
$actions = array();
// Find all actions associated with those hooks
foreach ( $hooks as $hook ) {
$priorities = sp_array_value( $wp_filter, $hook, array() );
foreach ( $priorities as $priority => $action ) {
$a = reset( $action );
$function = sp_array_value( $a, 'function', false );
remove_action( $hook, $function, $priority );
$actions[] = $function;
}
}
// Get layout setting
$layout = (array) get_option( 'sportspress_' . $type . '_template_order', array() );
@@ -88,6 +65,9 @@ class SP_Template_Loader {
}
ob_start();
// Before template hook
do_action( 'sportspress_before_single_' . $type );
// Loop through sections
if ( ! empty( $section_templates ) ) {
@@ -101,12 +81,17 @@ class SP_Template_Loader {
echo '<div class="sp-section-content sp-section-content-' . $key . '">';
if ( 'content' === $key ) {
echo $content;
// Template content hook
do_action( 'sportspress_single_' . $type . '_content' );
} else {
call_user_func( $template['action'] );
}
echo '</div>';
}
}
// After template hook
do_action( 'sportspress_after_single_' . $type );
$ob = ob_get_clean();

View File

@@ -22,109 +22,6 @@ add_filter( 'body_class', 'sp_body_class' );
add_action( 'get_the_generator_html', 'sp_generator_tag', 10, 2 );
add_action( 'get_the_generator_xhtml', 'sp_generator_tag', 10, 2 );
/**
* Before Single Event
* @see sportspress_output_event_logos()
* @see sportspress_output_post_excerpt()
*/
add_action( 'sportspress_before_single_event', 'sportspress_output_event_logos', 10 );
add_action( 'sportspress_before_single_event', 'sportspress_output_post_excerpt', 20 );
/**
* Single Event Content
*
* @see sportspress_output_event_video()
* @see sportspress_output_event_overview()
* @see sportspress_output_event_performance()
*/
add_action( 'sportspress_single_event_content', 'sportspress_output_event_video', 10 );
add_action( 'sportspress_single_event_content', 'sportspress_output_event_overview', 30 );
add_action( 'sportspress_single_event_content', 'sportspress_output_event_performance', 50 );
/**
* Event Overview Content
*
* @see sportspress_output_event_details()
* @see sportspress_output_event_venue()
* @see sportspress_output_event_results()
*/
add_action( 'sportspress_event_overview_content', 'sportspress_output_event_details', 10 );
add_action( 'sportspress_event_overview_content', 'sportspress_output_event_venue', 20 );
add_action( 'sportspress_event_overview_content', 'sportspress_output_event_results', 30 );
/**
* Single Calendar Content
*
* @see sportspress_output_calendar()
*/
add_action( 'sportspress_single_calendar_content', 'sportspress_output_calendar', 10 );
/**
* Before Single Team
* @see sportspress_output_team_logo()
* @see sportspress_output_post_excerpt()
*/
add_action( 'sportspress_before_single_team', 'sportspress_output_team_logo', 10 );
add_action( 'sportspress_before_single_team', 'sportspress_output_post_excerpt', 20 );
/**
* Single Team Content
*
* @see sportspress_output_team_link()
* @see sportspress_output_team_details()
* @see sportspress_output_team_staff()
* @see sportspress_output_team_lists()
* @see sportspress_output_team_tables()
* @see sportspress_output_team_events()
*/
add_action( 'sportspress_single_team_content', 'sportspress_output_team_link', 0 );
add_action( 'sportspress_single_team_content', 'sportspress_output_team_details', 10 );
add_action( 'sportspress_single_team_content', 'sportspress_output_team_staff', 15 );
add_action( 'sportspress_single_team_content', 'sportspress_output_team_lists', 20 );
add_action( 'sportspress_single_team_content', 'sportspress_output_team_tables', 30 );
add_action( 'sportspress_single_team_content', 'sportspress_output_team_events', 40 );
/**
* Single Table Content
*
* @see sportspress_output_league_table()
*/
add_action( 'sportspress_single_table_content', 'sportspress_output_league_table', 10 );
/**
* Before Single Player
* @see sportspress_output_player_photo()
* @see sportspress_output_player_details()
* @see sportspress_output_post_excerpt()
*/
add_action( 'sportspress_before_single_player', 'sportspress_output_player_photo', 10 );
add_action( 'sportspress_before_single_player', 'sportspress_output_player_details', 15 );
add_action( 'sportspress_before_single_player', 'sportspress_output_post_excerpt', 20 );
/**
* Single Player Content
*
* @see sportspress_output_player_statistics()
*/
add_action( 'sportspress_single_player_content', 'sportspress_output_player_statistics', 20 );
/**
* Single List Content
*
* @see sportspress_output_player_list()
*/
add_action( 'sportspress_single_list_content', 'sportspress_output_player_list', 10 );
/**
* Before Single Staff
* @see sportspress_output_staff_photo()
* @see sportspress_output_staff_details()
* @see sportspress_output_post_excerpt()
*/
add_action( 'sportspress_before_single_staff', 'sportspress_output_staff_photo', 10 );
add_action( 'sportspress_before_single_staff', 'sportspress_output_staff_details', 15 );
add_action( 'sportspress_before_single_staff', 'sportspress_output_post_excerpt', 20 );
/**
* Venue Archive Content
*/