Add custom order to staff jobs
This commit is contained in:
@@ -39,11 +39,15 @@ class SP_Admin_Taxonomies {
|
|||||||
add_action( 'edited_sp_position', array( $this, 'save_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 );
|
add_action( 'create_sp_position', array( $this, 'save_fields' ), 10, 1 );
|
||||||
|
|
||||||
|
// Add job field
|
||||||
|
add_action( 'sp_role_edit_form_fields', array( $this, 'edit_taxonomy_fields' ), 10, 1 );
|
||||||
|
add_action( 'edited_sp_role', array( $this, 'save_fields' ), 10, 1 );
|
||||||
|
|
||||||
// Change league columns
|
// Change league columns
|
||||||
add_filter( 'manage_edit-sp_league_columns', array( $this, 'taxonomy_columns' ) );
|
add_filter( 'manage_edit-sp_league_columns', array( $this, 'taxonomy_columns' ) );
|
||||||
add_filter( 'manage_sp_league_custom_column', array( $this, 'column_value' ), 10, 3 );
|
add_filter( 'manage_sp_league_custom_column', array( $this, 'column_value' ), 10, 3 );
|
||||||
|
|
||||||
// Change league columns
|
// Change season columns
|
||||||
add_filter( 'manage_edit-sp_season_columns', array( $this, 'taxonomy_columns' ) );
|
add_filter( 'manage_edit-sp_season_columns', array( $this, 'taxonomy_columns' ) );
|
||||||
add_filter( 'manage_sp_season_custom_column', array( $this, 'column_value' ), 10, 3 );
|
add_filter( 'manage_sp_season_custom_column', array( $this, 'column_value' ), 10, 3 );
|
||||||
|
|
||||||
@@ -54,6 +58,10 @@ class SP_Admin_Taxonomies {
|
|||||||
// 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 );
|
add_filter( 'manage_sp_position_custom_column', array( $this, 'column_value' ), 10, 3 );
|
||||||
|
|
||||||
|
// Change job columns
|
||||||
|
add_filter( 'manage_edit-sp_role_columns', array( $this, 'taxonomy_columns' ) );
|
||||||
|
add_filter( 'manage_sp_role_custom_column', array( $this, 'column_value' ), 10, 3 );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -53,6 +53,7 @@ function sp_get_screen_ids() {
|
|||||||
'edit-sp_venue',
|
'edit-sp_venue',
|
||||||
'edit-sp_league',
|
'edit-sp_league',
|
||||||
'edit-sp_season',
|
'edit-sp_season',
|
||||||
'edit-sp_position',
|
'edit-sp_position',
|
||||||
|
'edit-sp_role',
|
||||||
) );
|
) );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ class SP_Staff extends SP_Custom_Post {
|
|||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function role() {
|
public function role() {
|
||||||
$roles = get_the_terms( $this->ID, 'sp_role' );
|
$roles = $this->get_roles();
|
||||||
if ( $roles && ! is_wp_error( $roles ) ):
|
if ( $roles && ! is_wp_error( $roles ) ):
|
||||||
return array_shift( $roles );
|
return array_shift( $roles );
|
||||||
else:
|
else:
|
||||||
@@ -64,11 +64,37 @@ class SP_Staff extends SP_Custom_Post {
|
|||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function roles() {
|
public function roles() {
|
||||||
$roles = get_the_terms( $this->ID, 'sp_role' );
|
$roles = $this->get_roles();
|
||||||
if ( $roles && ! is_wp_error( $roles ) ):
|
if ( $roles && ! is_wp_error( $roles ) ):
|
||||||
return (array) $roles;
|
return (array) $roles;
|
||||||
else:
|
else:
|
||||||
return array();
|
return array();
|
||||||
endif;
|
endif;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function get_roles() {
|
||||||
|
$roles = get_the_terms( $this->ID, 'sp_role' );
|
||||||
|
|
||||||
|
if ( ! is_array( $roles ) || ! sizeof( $roles ) ) return array();
|
||||||
|
|
||||||
|
$include = wp_list_pluck( $roles, 'term_id' );
|
||||||
|
|
||||||
|
return get_terms( array(
|
||||||
|
'taxonomy' => 'sp_role',
|
||||||
|
'hide_empty' => false,
|
||||||
|
'orderby' => 'meta_value_num',
|
||||||
|
'include' => $include,
|
||||||
|
'meta_query' => array(
|
||||||
|
'relation' => 'OR',
|
||||||
|
array(
|
||||||
|
'key' => 'sp_order',
|
||||||
|
'compare' => 'NOT EXISTS'
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'key' => 'sp_order',
|
||||||
|
'compare' => 'EXISTS'
|
||||||
|
),
|
||||||
|
),
|
||||||
|
) );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,11 +44,9 @@ function sportspress_the_title( $title, $id = null ) {
|
|||||||
endif;
|
endif;
|
||||||
elseif ( is_singular( 'sp_staff' ) ):
|
elseif ( is_singular( 'sp_staff' ) ):
|
||||||
$staff = new SP_Staff( $id );
|
$staff = new SP_Staff( $id );
|
||||||
$roles = $staff->roles();
|
$role = $staff->role();
|
||||||
if ( ! empty( $roles ) ):
|
if ( $role )
|
||||||
$roles = wp_list_pluck( $roles, 'name' );
|
$title = '<strong class="sp-staff-role">' . $role->name . '</strong> ' . $title;
|
||||||
$title = '<strong class="sp-staff-role">' . implode( '<span class="sp-staff-role-delimiter">/</span>', $roles ) . '</strong> ' . $title;
|
|
||||||
endif;
|
|
||||||
endif;
|
endif;
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user