Add content position hooks
This commit is contained in:
@@ -24,54 +24,77 @@ class SP_Template_Loader {
|
||||
add_filter( 'the_content', array( $this, 'staff_content' ) );
|
||||
}
|
||||
|
||||
public function add_content( $content, $template, $append = false ) {
|
||||
public function add_content( $content, $template, $position = 10 ) {
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
if ( ! in_the_loop() ) return; // Return if not in main loop
|
||||
|
||||
ob_start();
|
||||
call_user_func( 'sp_get_template_part', 'content', 'single-' . $template );
|
||||
if ( $append )
|
||||
return $content . ob_get_clean();
|
||||
else
|
||||
return ob_get_clean() . $content;
|
||||
|
||||
if ( $position <= 0 )
|
||||
echo $content;
|
||||
|
||||
do_action( 'sportspress_before_single_' . $template );
|
||||
|
||||
if ( post_password_required() ) {
|
||||
echo get_the_password_form();
|
||||
return;
|
||||
}
|
||||
|
||||
if ( $position > 0 && $position <= 5 )
|
||||
echo $content;
|
||||
|
||||
do_action( 'sportspress_single_' . $template . '_content' );
|
||||
|
||||
if ( $position > 5 && $position <= 10 )
|
||||
echo $content;
|
||||
|
||||
do_action( 'sportspress_after_single_' . $template );
|
||||
|
||||
if ( $position > 10 )
|
||||
echo $content;
|
||||
|
||||
return ob_get_clean();
|
||||
}
|
||||
|
||||
public function event_content( $content ) {
|
||||
if ( is_singular( 'sp_event' ) )
|
||||
$content = self::add_content( $content, 'event' );
|
||||
$content = self::add_content( $content, 'event', apply_filters( 'sportspress_event_content_priority', 10 ) );
|
||||
return $content;
|
||||
}
|
||||
|
||||
public function calendar_content( $content ) {
|
||||
if ( is_singular( 'sp_calendar' ) )
|
||||
$content = self::add_content( $content, 'calendar' );
|
||||
$content = self::add_content( $content, 'calendar', apply_filters( 'sportspress_calendar_content_priority', 10 ) );
|
||||
return $content;
|
||||
}
|
||||
|
||||
public function team_content( $content ) {
|
||||
if ( is_singular( 'sp_team' ) )
|
||||
$content = self::add_content( $content, 'team' );
|
||||
$content = self::add_content( $content, 'team', apply_filters( 'sportspress_team_content_priority', 10 ) );
|
||||
return $content;
|
||||
}
|
||||
|
||||
public function table_content( $content ) {
|
||||
if ( is_singular( 'sp_table' ) )
|
||||
$content = self::add_content( $content, 'table' );
|
||||
$content = self::add_content( $content, 'table', apply_filters( 'sportspress_table_content_priority', 10 ) );
|
||||
return $content;
|
||||
}
|
||||
|
||||
public function player_content( $content ) {
|
||||
if ( is_singular( 'sp_player' ) )
|
||||
$content = self::add_content( $content, 'player' );
|
||||
$content = self::add_content( $content, 'player', apply_filters( 'sportspress_player_content_priority', 10 ) );
|
||||
return $content;
|
||||
}
|
||||
|
||||
public function list_content( $content ) {
|
||||
if ( is_singular( 'sp_list' ) )
|
||||
$content = self::add_content( $content, 'list' );
|
||||
$content = self::add_content( $content, 'list', apply_filters( 'sportspress_list_content_priority', 10 ) );
|
||||
return $content;
|
||||
}
|
||||
|
||||
public function staff_content( $content ) {
|
||||
if ( is_singular( 'sp_staff' ) )
|
||||
$content = self::add_content( $content, 'staff' );
|
||||
$content = self::add_content( $content, 'staff', apply_filters( 'sportspress_staff_content_priority', 10 ) );
|
||||
return $content;
|
||||
}
|
||||
|
||||
|
||||
@@ -36,8 +36,7 @@ add_action( 'sportspress_single_event_content', 'sportspress_output_event_result
|
||||
add_action( 'sportspress_single_event_content', 'sportspress_output_event_details', 30 );
|
||||
add_action( 'sportspress_single_event_content', 'sportspress_output_event_venue', 40 );
|
||||
add_action( 'sportspress_single_event_content', 'sportspress_output_event_performance', 50 );
|
||||
|
||||
add_action( 'sportspress_after_single_event', 'sportspress_output_br_tag', 100 );
|
||||
add_action( 'sportspress_single_event_content', 'sportspress_output_br_tag', 100 );
|
||||
|
||||
/**
|
||||
* Single Calendar Content
|
||||
@@ -45,8 +44,7 @@ add_action( 'sportspress_after_single_event', 'sportspress_output_br_tag', 100 )
|
||||
* @see sportspress_output_calendar()
|
||||
*/
|
||||
add_action( 'sportspress_single_calendar_content', 'sportspress_output_calendar', 10 );
|
||||
|
||||
add_action( 'sportspress_after_single_calendar', 'sportspress_output_br_tag', 100 );
|
||||
add_action( 'sportspress_single_calendar_content', 'sportspress_output_br_tag', 100 );
|
||||
|
||||
/**
|
||||
* Single Team Content
|
||||
@@ -55,11 +53,11 @@ add_action( 'sportspress_after_single_calendar', 'sportspress_output_br_tag', 10
|
||||
* @see sportspress_output_team_columns()
|
||||
* @see sportspress_output_team_lists()
|
||||
*/
|
||||
add_action( 'sportspress_single_team_content', 'sportspress_output_team_link', 10 );
|
||||
add_action( 'sportspress_single_team_content', 'sportspress_output_team_columns', 20 );
|
||||
add_action( 'sportspress_single_team_content', 'sportspress_output_team_lists', 30 );
|
||||
add_action( 'sportspress_single_team_content', 'sportspress_output_br_tag', 100 );
|
||||
|
||||
add_action( 'sportspress_after_single_team', 'sportspress_output_br_tag', 100 );
|
||||
add_action( 'sportspress_after_single_team', 'sportspress_output_team_link', 10 );
|
||||
|
||||
/**
|
||||
* Single Table Content
|
||||
@@ -67,8 +65,7 @@ add_action( 'sportspress_after_single_team', 'sportspress_output_br_tag', 100 );
|
||||
* @see sportspress_output_league_table()
|
||||
*/
|
||||
add_action( 'sportspress_single_table_content', 'sportspress_output_league_table', 10 );
|
||||
|
||||
add_action( 'sportspress_after_single_table', 'sportspress_output_br_tag', 100 );
|
||||
add_action( 'sportspress_single_table_content', 'sportspress_output_br_tag', 100 );
|
||||
|
||||
/**
|
||||
* Single Player Content
|
||||
@@ -78,8 +75,7 @@ add_action( 'sportspress_after_single_table', 'sportspress_output_br_tag', 100 )
|
||||
*/
|
||||
add_action( 'sportspress_single_player_content', 'sportspress_output_player_details', 10 );
|
||||
add_action( 'sportspress_single_player_content', 'sportspress_output_player_statistics', 20 );
|
||||
|
||||
add_action( 'sportspress_after_single_player', 'sportspress_output_br_tag', 100 );
|
||||
add_action( 'sportspress_single_player_content', 'sportspress_output_br_tag', 100 );
|
||||
|
||||
/**
|
||||
* Single List Content
|
||||
@@ -87,8 +83,7 @@ add_action( 'sportspress_after_single_player', 'sportspress_output_br_tag', 100
|
||||
* @see sportspress_output_player_list()
|
||||
*/
|
||||
add_action( 'sportspress_single_list_content', 'sportspress_output_player_list', 10 );
|
||||
|
||||
add_action( 'sportspress_after_single_list', 'sportspress_output_br_tag', 100 );
|
||||
add_action( 'sportspress_single_list_content', 'sportspress_output_br_tag', 100 );
|
||||
|
||||
/**
|
||||
* Single Staff Content
|
||||
@@ -96,8 +91,7 @@ add_action( 'sportspress_after_single_list', 'sportspress_output_br_tag', 100 );
|
||||
* @see sportspress_output_staff_details()
|
||||
*/
|
||||
add_action( 'sportspress_single_staff_content', 'sportspress_output_staff_details', 10 );
|
||||
|
||||
add_action( 'sportspress_after_single_staff', 'sportspress_output_br_tag', 100 );
|
||||
add_action( 'sportspress_single_staff_content', 'sportspress_output_br_tag', 100 );
|
||||
|
||||
/**
|
||||
* Venue Archive Content
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* The template for displaying calendar content.
|
||||
*
|
||||
* Override this template by copying it to yourtheme/sportspress/content-single-calendar.php
|
||||
*
|
||||
* @author ThemeBoy
|
||||
* @package SportsPress/Templates
|
||||
* @version 0.9
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
if ( ! in_the_loop() ) return; // Return if not in main loop
|
||||
|
||||
/**
|
||||
* sportspress_before_single_calendar hook
|
||||
*/
|
||||
do_action( 'sportspress_before_single_calendar' );
|
||||
|
||||
if ( post_password_required() ) {
|
||||
echo get_the_password_form();
|
||||
return;
|
||||
}
|
||||
|
||||
do_action( 'sportspress_single_calendar_content' );
|
||||
|
||||
do_action( 'sportspress_after_single_calendar' );
|
||||
@@ -1,27 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* The template for displaying event content.
|
||||
*
|
||||
* Override this template by copying it to yourtheme/sportspress/content-single-event.php
|
||||
*
|
||||
* @author ThemeBoy
|
||||
* @package SportsPress/Templates
|
||||
* @version 0.9
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
if ( ! in_the_loop() ) return; // Return if not in main loop
|
||||
|
||||
/**
|
||||
* sportspress_before_single_event hook
|
||||
*/
|
||||
do_action( 'sportspress_before_single_event' );
|
||||
|
||||
if ( post_password_required() ) {
|
||||
echo get_the_password_form();
|
||||
return;
|
||||
}
|
||||
|
||||
do_action( 'sportspress_single_event_content' );
|
||||
|
||||
do_action( 'sportspress_after_single_event' );
|
||||
@@ -1,27 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* The template for displaying list content.
|
||||
*
|
||||
* Override this template by copying it to yourtheme/sportspress/content-single-list.php
|
||||
*
|
||||
* @author ThemeBoy
|
||||
* @package SportsPress/Templates
|
||||
* @version 0.9
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
if ( ! in_the_loop() ) return; // Return if not in main loop
|
||||
|
||||
/**
|
||||
* sportspress_before_single_list hook
|
||||
*/
|
||||
do_action( 'sportspress_before_single_list' );
|
||||
|
||||
if ( post_password_required() ) {
|
||||
echo get_the_password_form();
|
||||
return;
|
||||
}
|
||||
|
||||
do_action( 'sportspress_single_list_content' );
|
||||
|
||||
do_action( 'sportspress_after_single_list' );
|
||||
@@ -1,27 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* The template for displaying player content.
|
||||
*
|
||||
* Override this template by copying it to yourtheme/sportspress/content-single-player.php
|
||||
*
|
||||
* @author ThemeBoy
|
||||
* @package SportsPress/Templates
|
||||
* @version 0.9
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
if ( ! in_the_loop() ) return; // Return if not in main loop
|
||||
|
||||
/**
|
||||
* sportspress_before_single_player hook
|
||||
*/
|
||||
do_action( 'sportspress_before_single_player' );
|
||||
|
||||
if ( post_password_required() ) {
|
||||
echo get_the_password_form();
|
||||
return;
|
||||
}
|
||||
|
||||
do_action( 'sportspress_single_player_content' );
|
||||
|
||||
do_action( 'sportspress_after_single_player' );
|
||||
@@ -1,27 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* The template for displaying staff content.
|
||||
*
|
||||
* Override this template by copying it to yourtheme/sportspress/content-single-staff.php
|
||||
*
|
||||
* @author ThemeBoy
|
||||
* @package SportsPress/Templates
|
||||
* @version 0.9
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
if ( ! in_the_loop() ) return; // Return if not in main loop
|
||||
|
||||
/**
|
||||
* sportspress_before_single_staff hook
|
||||
*/
|
||||
do_action( 'sportspress_before_single_staff' );
|
||||
|
||||
if ( post_password_required() ) {
|
||||
echo get_the_password_form();
|
||||
return;
|
||||
}
|
||||
|
||||
do_action( 'sportspress_single_staff_content' );
|
||||
|
||||
do_action( 'sportspress_after_single_staff' );
|
||||
@@ -1,27 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* The template for displaying table content.
|
||||
*
|
||||
* Override this template by copying it to yourtheme/sportspress/content-single-table.php
|
||||
*
|
||||
* @author ThemeBoy
|
||||
* @package SportsPress/Templates
|
||||
* @version 0.9
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
if ( ! in_the_loop() ) return; // Return if not in main loop
|
||||
|
||||
/**
|
||||
* sportspress_before_single_table hook
|
||||
*/
|
||||
do_action( 'sportspress_before_single_table' );
|
||||
|
||||
if ( post_password_required() ) {
|
||||
echo get_the_password_form();
|
||||
return;
|
||||
}
|
||||
|
||||
do_action( 'sportspress_single_table_content' );
|
||||
|
||||
do_action( 'sportspress_after_single_table' );
|
||||
@@ -1,27 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* The template for displaying team content.
|
||||
*
|
||||
* Override this template by copying it to yourtheme/sportspress/content-single-team.php
|
||||
*
|
||||
* @author ThemeBoy
|
||||
* @package SportsPress/Templates
|
||||
* @version 0.9
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
if ( ! in_the_loop() ) return; // Return if not in main loop
|
||||
|
||||
/**
|
||||
* sportspress_before_single_team hook
|
||||
*/
|
||||
do_action( 'sportspress_before_single_team' );
|
||||
|
||||
if ( post_password_required() ) {
|
||||
echo get_the_password_form();
|
||||
return;
|
||||
}
|
||||
|
||||
do_action( 'sportspress_single_team_content' );
|
||||
|
||||
do_action( 'sportspress_after_single_team' );
|
||||
Reference in New Issue
Block a user