Enable custom headings for player positions
This commit is contained in:
@@ -19,11 +19,17 @@ class SP_Admin_Taxonomies {
|
|||||||
*/
|
*/
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
|
|
||||||
// Add form
|
// Add venue field
|
||||||
add_action( 'sp_venue_add_form_fields', array( $this, 'add_venue_fields' ) );
|
add_action( 'sp_venue_add_form_fields', array( $this, 'add_venue_fields' ) );
|
||||||
add_action( 'sp_venue_edit_form_fields', array( $this, 'edit_venue_fields' ), 10, 1 );
|
add_action( 'sp_venue_edit_form_fields', array( $this, 'edit_venue_fields' ), 10, 1 );
|
||||||
add_action( 'edited_sp_venue', array( $this, 'save_venue_fields' ), 10, 1 );
|
add_action( 'edited_sp_venue', array( $this, 'save_fields' ), 10, 1 );
|
||||||
add_action( 'create_sp_venue', array( $this, 'save_venue_fields' ), 10, 1 );
|
add_action( 'create_sp_venue', array( $this, 'save_fields' ), 10, 1 );
|
||||||
|
|
||||||
|
// Add position field
|
||||||
|
add_action( 'sp_position_add_form_fields', array( $this, 'add_position_fields' ) );
|
||||||
|
add_action( 'sp_position_edit_form_fields', array( $this, 'edit_position_fields' ), 10, 1 );
|
||||||
|
add_action( 'edited_sp_position', array( $this, 'save_fields' ), 10, 1 );
|
||||||
|
add_action( 'create_sp_position', array( $this, 'save_fields' ), 10, 1 );
|
||||||
|
|
||||||
// Change league and season columns
|
// Change league and season columns
|
||||||
add_filter( 'manage_edit-sp_league_columns', array( $this, 'taxonomy_columns' ) );
|
add_filter( 'manage_edit-sp_league_columns', array( $this, 'taxonomy_columns' ) );
|
||||||
@@ -31,17 +37,18 @@ class SP_Admin_Taxonomies {
|
|||||||
|
|
||||||
// Change venue columns
|
// Change venue columns
|
||||||
add_filter( 'manage_edit-sp_venue_columns', array( $this, 'venue_columns' ) );
|
add_filter( 'manage_edit-sp_venue_columns', array( $this, 'venue_columns' ) );
|
||||||
add_filter( 'manage_sp_venue_custom_column', array( $this, 'venue_column' ), 10, 3 );
|
add_filter( 'manage_sp_venue_custom_column', array( $this, 'column_value' ), 10, 3 );
|
||||||
|
|
||||||
// Change position columns
|
// Change position columns
|
||||||
add_filter( 'manage_edit-sp_position_columns', array( $this, 'position_columns' ) );
|
add_filter( 'manage_edit-sp_position_columns', array( $this, 'position_columns' ) );
|
||||||
|
add_filter( 'manage_sp_position_custom_column', array( $this, 'column_value' ), 10, 3 );
|
||||||
|
|
||||||
// Change role columns
|
// Change role columns
|
||||||
add_filter( 'manage_edit-sp_role_columns', array( $this, 'role_columns' ) );
|
add_filter( 'manage_edit-sp_role_columns', array( $this, 'role_columns' ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Category thumbnail fields.
|
* Add venue fields.
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
* @return void
|
* @return void
|
||||||
@@ -85,7 +92,7 @@ class SP_Admin_Taxonomies {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Edit category thumbnail field.
|
* Edit venue fields.
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
* @param mixed $term Term (category) being edited
|
* @param mixed $term Term (category) being edited
|
||||||
@@ -97,8 +104,8 @@ class SP_Admin_Taxonomies {
|
|||||||
<th scope="row" valign="top"><label for="term_meta[sp_address]"><?php _e( 'Address', 'sportspress' ); ?></label></th>
|
<th scope="row" valign="top"><label for="term_meta[sp_address]"><?php _e( 'Address', 'sportspress' ); ?></label></th>
|
||||||
<td>
|
<td>
|
||||||
<input type="text" class="sp-address" name="term_meta[sp_address]" id="term_meta[sp_address]" value="<?php echo esc_attr( $term_meta['sp_address'] ) ? esc_attr( $term_meta['sp_address'] ) : ''; ?>">
|
<input type="text" class="sp-address" name="term_meta[sp_address]" id="term_meta[sp_address]" value="<?php echo esc_attr( $term_meta['sp_address'] ) ? esc_attr( $term_meta['sp_address'] ) : ''; ?>">
|
||||||
<p><div class="sp-location-picker"></div><br>
|
<p><div class="sp-location-picker"></div></p>
|
||||||
<span class="description"><?php _e( "Drag the marker to the venue's location.", 'sportspress' ); ?></span></p>
|
<p class="description"><?php _e( "Drag the marker to the venue's location.", 'sportspress' ); ?></p>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class="form-field">
|
<tr class="form-field">
|
||||||
@@ -117,13 +124,48 @@ class SP_Admin_Taxonomies {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* save_category_fields function.
|
* Add position fields.
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function add_position_fields() {
|
||||||
|
?>
|
||||||
|
<div class="form-field">
|
||||||
|
<label for="term_meta[sp_caption]"><?php _e( 'Heading', 'sportspress' ); ?></label>
|
||||||
|
<input type="text" name="term_meta[sp_caption]" id="term_meta[sp_caption]" value="">
|
||||||
|
<p class="description"><?php _e( 'Used for events.', 'sportspress' ); ?></p>
|
||||||
|
</div>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Edit position fields.
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @param mixed $term Term (category) being edited
|
||||||
|
*/
|
||||||
|
public function edit_position_fields( $term ) {
|
||||||
|
$t_id = $term->term_id;
|
||||||
|
$term_meta = get_option( "taxonomy_$t_id" ); ?>
|
||||||
|
<tr class="form-field">
|
||||||
|
<th scope="row" valign="top"><label for="term_meta[sp_caption]"><?php _e( 'Heading', 'sportspress' ); ?></label></th>
|
||||||
|
<td>
|
||||||
|
<input type="text" name="term_meta[sp_caption]" id="term_meta[sp_caption]" value="<?php echo esc_attr( $term_meta['sp_caption'] ) ? esc_attr( $term_meta['sp_caption'] ) : ''; ?>">
|
||||||
|
<p class="description"><?php _e( 'Used for events.', 'sportspress' ); ?></p>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Save fields.
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
* @param mixed $term_id Term ID being saved
|
* @param mixed $term_id Term ID being saved
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function save_venue_fields( $term_id ) {
|
public function save_fields( $term_id ) {
|
||||||
if ( isset( $_POST['term_meta'] ) ) {
|
if ( isset( $_POST['term_meta'] ) ) {
|
||||||
$t_id = $term_id;
|
$t_id = $term_id;
|
||||||
$term_meta = get_option( "taxonomy_$t_id" );
|
$term_meta = get_option( "taxonomy_$t_id" );
|
||||||
@@ -157,7 +199,7 @@ class SP_Admin_Taxonomies {
|
|||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function venue_columns( $columns ) {
|
public function venue_columns( $columns ) {
|
||||||
$new_columns = array();
|
$new_columns = array();
|
||||||
$new_columns['sp_address'] = __( 'Address', 'sportspress' );
|
$new_columns['sp_address'] = __( 'Address', 'sportspress' );
|
||||||
$new_columns['posts'] = __( 'Events', 'sportspress' );
|
$new_columns['posts'] = __( 'Events', 'sportspress' );
|
||||||
|
|
||||||
@@ -176,8 +218,15 @@ class SP_Admin_Taxonomies {
|
|||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function position_columns( $columns ) {
|
public function position_columns( $columns ) {
|
||||||
$columns['posts'] = __( 'Players', 'sportspress' );
|
$new_columns = array();
|
||||||
return $columns;
|
$new_columns['sp_caption'] = __( 'Heading', 'sportspress' );
|
||||||
|
$new_columns['posts'] = __( 'Players', 'sportspress' );
|
||||||
|
|
||||||
|
unset( $columns['description'] );
|
||||||
|
unset( $columns['slug'] );
|
||||||
|
unset( $columns['posts'] );
|
||||||
|
|
||||||
|
return array_merge( $columns, $new_columns );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -193,7 +242,7 @@ class SP_Admin_Taxonomies {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Thumbnail column value added to category admin.
|
* Column value added to category admin.
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
* @param mixed $columns
|
* @param mixed $columns
|
||||||
@@ -201,7 +250,7 @@ class SP_Admin_Taxonomies {
|
|||||||
* @param mixed $id
|
* @param mixed $id
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function venue_column( $columns, $column, $id ) {
|
public function column_value( $columns, $column, $id ) {
|
||||||
|
|
||||||
if ( $column == 'sp_address' ) {
|
if ( $column == 'sp_address' ) {
|
||||||
|
|
||||||
@@ -211,6 +260,14 @@ class SP_Admin_Taxonomies {
|
|||||||
|
|
||||||
$columns .= $address;
|
$columns .= $address;
|
||||||
|
|
||||||
|
} elseif ( $column == 'sp_caption' ) {
|
||||||
|
|
||||||
|
$term_meta = get_option( "taxonomy_$id" );
|
||||||
|
|
||||||
|
$caption = ( isset( $term_meta['sp_caption'] ) ? $term_meta['sp_caption'] : '—' );
|
||||||
|
|
||||||
|
$columns .= $caption;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $columns;
|
return $columns;
|
||||||
|
|||||||
@@ -256,3 +256,19 @@ function sp_venue_map( $term = 0 ) {
|
|||||||
$meta = get_option( "taxonomy_$term" );
|
$meta = get_option( "taxonomy_$term" );
|
||||||
sp_get_template( 'venue-map.php', array( 'meta' => $meta ) );
|
sp_get_template( 'venue-map.php', array( 'meta' => $meta ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
function sp_get_position_caption( $term = 0 ) {
|
||||||
|
$meta = get_option( "taxonomy_$term" );
|
||||||
|
$caption = sp_array_value( $meta, 'sp_caption', '' );
|
||||||
|
if ( $caption ) {
|
||||||
|
return $caption;
|
||||||
|
} else {
|
||||||
|
$term = get_term( $term, 'sp_position' );
|
||||||
|
return $term->name;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user