Add option to redirect team pages to site url
This commit is contained in:
@@ -52,6 +52,7 @@ class SP_Meta_Box_Team_Details {
|
|||||||
endif;
|
endif;
|
||||||
|
|
||||||
$abbreviation = get_post_meta( $post->ID, 'sp_abbreviation', true );
|
$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 );
|
$url = get_post_meta( $post->ID, 'sp_url', true );
|
||||||
?>
|
?>
|
||||||
|
|
||||||
@@ -108,9 +109,7 @@ class SP_Meta_Box_Team_Details {
|
|||||||
|
|
||||||
<p><strong><?php _e( 'Site URL', 'sportspress' ); ?></strong></p>
|
<p><strong><?php _e( 'Site URL', 'sportspress' ); ?></strong></p>
|
||||||
<p><input type="text" class="widefat" id="sp_url" name="sp_url" value="<?php echo esc_url( $url ); ?>"></p>
|
<p><input type="text" class="widefat" id="sp_url" name="sp_url" value="<?php echo esc_url( $url ); ?>"></p>
|
||||||
<?php if ( $url ): ?>
|
<p><label class="selectit"><input type="checkbox" name="sp_redirect" value="1" <?php checked( $redirect ); ?>> <?php _e( 'Redirect', 'sportspress' ); ?></label></p>
|
||||||
<p><a class="sp-link" title="<?php _e( 'Visit Site', 'sportspress' ); ?>" href="<?php echo $url; ?>" target="_blank"><?php _e( 'Visit Site', 'sportspress' ); ?></a></p>
|
|
||||||
<?php endif; ?>
|
|
||||||
|
|
||||||
<p><strong><?php _e( 'Abbreviation', 'sportspress' ); ?></strong></p>
|
<p><strong><?php _e( 'Abbreviation', 'sportspress' ); ?></strong></p>
|
||||||
<p><input type="text" id="sp_abbreviation" name="sp_abbreviation" value="<?php echo esc_attr( $abbreviation ); ?>"></p>
|
<p><input type="text" id="sp_abbreviation" name="sp_abbreviation" value="<?php echo esc_attr( $abbreviation ); ?>"></p>
|
||||||
@@ -122,6 +121,7 @@ class SP_Meta_Box_Team_Details {
|
|||||||
*/
|
*/
|
||||||
public static function save( $post_id, $post ) {
|
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_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', '' ) ) );
|
update_post_meta( $post_id, 'sp_abbreviation', esc_attr( sp_array_value( $_POST, 'sp_abbreviation', '' ) ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -211,9 +211,17 @@ add_filter( 'gettext', 'sportspress_gettext', 20, 3 );
|
|||||||
|
|
||||||
function sportspress_team_permalink( $permalink, $post ) {
|
function sportspress_team_permalink( $permalink, $post ) {
|
||||||
if ( ! is_admin() && 'sp_team' == get_post_type( $post ) ):
|
if ( ! is_admin() && 'sp_team' == get_post_type( $post ) ):
|
||||||
if ( empty( $post->post_content ) ):
|
|
||||||
$url = get_post_meta( $post->ID, 'sp_url', true );
|
$url = get_post_meta( $post->ID, 'sp_url', true );
|
||||||
|
|
||||||
if ( ! empty( $url ) ):
|
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;
|
return $url;
|
||||||
endif;
|
endif;
|
||||||
endif;
|
endif;
|
||||||
|
|||||||
Reference in New Issue
Block a user