diff --git a/includes/admin/post-types/meta-boxes/class-sp-meta-box-team-details.php b/includes/admin/post-types/meta-boxes/class-sp-meta-box-team-details.php index df956cb8..45aec42f 100644 --- a/includes/admin/post-types/meta-boxes/class-sp-meta-box-team-details.php +++ b/includes/admin/post-types/meta-boxes/class-sp-meta-box-team-details.php @@ -52,6 +52,7 @@ class SP_Meta_Box_Team_Details { endif; $abbreviation = get_post_meta( $post->ID, 'sp_abbreviation', true ); + $redirect = get_post_meta( $post->ID, 'sp_redirect', true ); $url = get_post_meta( $post->ID, 'sp_url', true ); ?> @@ -108,9 +109,7 @@ class SP_Meta_Box_Team_Details {
- - - +
@@ -122,6 +121,7 @@ class SP_Meta_Box_Team_Details { */ public static function save( $post_id, $post ) { update_post_meta( $post_id, 'sp_url', esc_url( sp_array_value( $_POST, 'sp_url', '' ) ) ); + update_post_meta( $post_id, 'sp_redirect', sp_array_value( $_POST, 'sp_redirect', 0 ) ); update_post_meta( $post_id, 'sp_abbreviation', esc_attr( sp_array_value( $_POST, 'sp_abbreviation', '' ) ) ); } } \ No newline at end of file diff --git a/includes/sp-template-hooks.php b/includes/sp-template-hooks.php index 5674acf2..99d6b1cf 100644 --- a/includes/sp-template-hooks.php +++ b/includes/sp-template-hooks.php @@ -211,12 +211,20 @@ add_filter( 'gettext', 'sportspress_gettext', 20, 3 ); function sportspress_team_permalink( $permalink, $post ) { if ( ! is_admin() && 'sp_team' == get_post_type( $post ) ): - if ( empty( $post->post_content ) ): - $url = get_post_meta( $post->ID, 'sp_url', true ); - if ( ! empty( $url ) ): - return $url; - endif; - endif; + + $url = get_post_meta( $post->ID, 'sp_url', true ); + + if ( ! empty( $url ) ): + $redirect = get_post_meta( $post->ID, 'sp_redirect', true ); + + if ( $redirect === '' ): + $redirect = ( empty( $post->post_content ) ) ? 1 : 0; + endif; + + if ( $redirect ): + return $url; + endif; + endif; endif; return $permalink; }