From c9c575c7637687b96b498db1a43f70b06d64fce6 Mon Sep 17 00:00:00 2001 From: Brian Miyaji Date: Thu, 23 Mar 2017 10:47:04 +1100 Subject: [PATCH] Add template hooks for 3rd party integration --- includes/class-sp-template-loader.php | 31 ++------ includes/sp-template-hooks.php | 103 -------------------------- 2 files changed, 8 insertions(+), 126 deletions(-) diff --git a/includes/class-sp-template-loader.php b/includes/class-sp-template-loader.php index 7f4650ae..d57334a1 100644 --- a/includes/class-sp-template-loader.php +++ b/includes/class-sp-template-loader.php @@ -42,29 +42,6 @@ class SP_Template_Loader { $content = '
' . $content . '
'; } - - 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 '
'; if ( 'content' === $key ) { echo $content; + // Template content hook + do_action( 'sportspress_single_' . $type . '_content' ); } else { call_user_func( $template['action'] ); } echo '
'; } } + + // After template hook + do_action( 'sportspress_after_single_' . $type ); $ob = ob_get_clean(); diff --git a/includes/sp-template-hooks.php b/includes/sp-template-hooks.php index 32802509..b4d0250a 100644 --- a/includes/sp-template-hooks.php +++ b/includes/sp-template-hooks.php @@ -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 */