Move add post helper into its own function
This commit is contained in:
@@ -28,7 +28,7 @@ add_filter( 'the_posts', 'sp_event_display_scheduled' );
|
||||
function sp_event_meta_init() {
|
||||
remove_meta_box( 'submitdiv', 'sp_event', 'side' );
|
||||
add_meta_box( 'submitdiv', __( 'Event', 'sportspress' ), 'post_submit_meta_box', 'sp_event', 'side', 'high' );
|
||||
add_meta_box( 'sp_teamdiv', __( 'Teams', 'sportspress' ), 'sp_event_team_meta', 'sp_event', 'normal', 'high' );
|
||||
add_meta_box( 'sp_teamdiv', __( 'Teams', 'sportspress' ), 'sp_event_team_meta', 'sp_event', 'side', 'high' );
|
||||
add_meta_box( 'sp_articlediv', __( 'Article', 'sportspress' ), 'sp_event_article_meta', 'sp_event', 'normal', 'high' );
|
||||
}
|
||||
|
||||
@@ -59,12 +59,13 @@ function sp_event_team_meta( $post ) {
|
||||
<li class="wp-tab"><a href="#sp_staff-all"><?php _e( 'Staff', 'sportspress' ); ?></a></li>
|
||||
</ul>
|
||||
<?php
|
||||
sp_post_checklist( $post->ID, 'sp_player', false, 'block', 'sp_team', $i );
|
||||
sp_post_checklist( $post->ID, 'sp_staff', $i == $limit - 1, 'none', 'sp_team', $i );
|
||||
sp_post_checklist( $post->ID, 'sp_player', 'block', 'sp_team', $i );
|
||||
sp_post_checklist( $post->ID, 'sp_staff', 'none', 'sp_team', $i );
|
||||
?>
|
||||
</div>
|
||||
<?php
|
||||
endfor;
|
||||
sp_post_adder( 'sp_team' );
|
||||
sp_nonce();
|
||||
}
|
||||
|
||||
|
||||
12
helpers.php
12
helpers.php
@@ -104,7 +104,7 @@ if ( ! function_exists( 'sp_the_posts' ) ) {
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'sp_post_checklist' ) ) {
|
||||
function sp_post_checklist( $post_id = null, $meta = 'post', $add_new_item = true, $display = 'block', $data = null, $index = null ) {
|
||||
function sp_post_checklist( $post_id = null, $meta = 'post', $display = 'block', $data = null, $index = null ) {
|
||||
if ( ! isset( $post_id ) )
|
||||
global $post_id;
|
||||
$obj = get_post_type_object( $meta );
|
||||
@@ -153,7 +153,14 @@ if ( ! function_exists( 'sp_post_checklist' ) ) {
|
||||
?>
|
||||
</ul>
|
||||
</div>
|
||||
<?php if ( $add_new_item ): ?>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'sp_post_adder' ) ) {
|
||||
function sp_post_adder( $meta = 'post' ) {
|
||||
$obj = get_post_type_object( $meta );
|
||||
?>
|
||||
<div id="<?php echo $meta; ?>-adder">
|
||||
<h4>
|
||||
<a title="<?php echo sprintf( esc_attr__( 'Add New %s', 'sportspress' ), esc_attr__( 'Team', 'sportspress' ) ); ?>" href="<?php echo admin_url( 'post-new.php?post_type=' . $meta ); ?>" target="_blank">
|
||||
@@ -162,7 +169,6 @@ if ( ! function_exists( 'sp_post_checklist' ) ) {
|
||||
</h4>
|
||||
</div>
|
||||
<?php
|
||||
endif;
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -26,7 +26,8 @@ function sp_player_meta_init() {
|
||||
}
|
||||
|
||||
function sp_player_team_meta( $post ) {
|
||||
sp_post_checklist( $post->ID, 'sp_team', true );
|
||||
sp_post_checklist( $post->ID, 'sp_team' );
|
||||
sp_post_adder( 'sp_team' );
|
||||
sp_nonce();
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,8 @@ function sp_staff_meta_init() {
|
||||
add_meta_box( 'sp_profilediv', __( 'Profile' ), 'sp_staff_profile_meta', 'sp_staff', 'normal', 'high' );
|
||||
}
|
||||
function sp_staff_team_meta( $post ) {
|
||||
sp_post_checklist( $post->ID, 'sp_team', true );
|
||||
sp_post_checklist( $post->ID, 'sp_team' );
|
||||
sp_post_adder( 'sp_team' );
|
||||
sp_nonce();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user