Move league tables and players lists into modules

This commit is contained in:
Brian Miyaji
2015-01-28 14:37:21 +11:00
parent 87baaf7288
commit 52882399c6
9 changed files with 371 additions and 191 deletions

View File

@@ -28,8 +28,15 @@ class SportsPress_League_Tables {
// Define constants
$this->define_constants();
// Mods
add_filter( 'sportspress_team_settings', array( $this, 'add_options' ) );
// Actions
add_action( 'init', array( $this, 'register_post_type' ) );
add_action( 'sportspress_include_post_type_handlers', array( $this, 'include_post_type_handler' ) );
add_action( 'sportspress_widgets', array( $this, 'include_widgets' ) );
// Filters
add_filter( 'sportspress_meta_boxes', array( $this, 'add_meta_boxes' ) );
add_filter( 'sportspress_shortcodes', array( $this, 'add_shortcodes' ) );
add_filter( 'sportspress_team_settings', array( $this, 'add_settings' ) );
}
/**
@@ -47,11 +54,124 @@ class SportsPress_League_Tables {
}
/**
* Add options to settings page.
* Register league tables post type
*/
public static function register_post_type() {
register_post_type( 'sp_table',
apply_filters( 'sportspress_register_post_type_table',
array(
'labels' => array(
'name' => __( 'League Tables', 'sportspress' ),
'singular_name' => __( 'League Table', 'sportspress' ),
'add_new_item' => __( 'Add New League Table', 'sportspress' ),
'edit_item' => __( 'Edit League Table', 'sportspress' ),
'new_item' => __( 'New', 'sportspress' ),
'view_item' => __( 'View League Table', 'sportspress' ),
'search_items' => __( 'Search', 'sportspress' ),
'not_found' => __( 'No results found.', 'sportspress' ),
'not_found_in_trash' => __( 'No results found.', 'sportspress' ),
),
'public' => true,
'show_ui' => true,
'capability_type' => 'sp_table',
'map_meta_cap' => true,
'publicly_queryable' => true,
'exclude_from_search' => false,
'hierarchical' => false,
'rewrite' => array( 'slug' => get_option( 'sportspress_table_slug', 'table' ) ),
'supports' => array( 'title', 'page-attributes', 'thumbnail' ),
'has_archive' => false,
'show_in_nav_menus' => true,
'show_in_menu' => 'edit.php?post_type=sp_team',
'show_in_admin_bar' => true,
)
)
);
}
/**
* Conditonally load the class and functions only needed when viewing this post type.
*/
public function include_post_type_handler() {
include_once( SP()->plugin_path() . '/includes/admin/post-types/class-sp-admin-cpt-table.php' );
}
/**
* Add widgets.
*
* @return array
*/
public function add_options( $settings ) {
public function include_widgets() {
include_once( SP()->plugin_path() . '/includes/widgets/class-sp-widget-league-table.php' );
}
/**
* Add meta boxes.
*
* @return array
*/
public function add_meta_boxes( $meta_boxes ) {
$meta_boxes['sp_team']['columns'] = array(
'title' => __( 'Table Columns', 'sportspress' ),
'output' => 'SP_Meta_Box_Team_Columns::output',
'save' => 'SP_Meta_Box_Team_Columns::save',
'context' => 'normal',
'priority' => 'high',
);
$meta_boxes['sp_team']['tables'] = array(
'title' => __( 'League Tables', 'sportspress' ),
'output' => 'SP_Meta_Box_Team_Tables::output',
'save' => 'SP_Meta_Box_Team_Tables::save',
'context' => 'normal',
'priority' => 'high',
);
$meta_boxes['sp_table'] = array(
'shortcode' => array(
'title' => __( 'Shortcode', 'sportspress' ),
'output' => 'SP_Meta_Box_Table_Shortcode::output',
'context' => 'side',
'priority' => 'default',
),
'details' => array(
'title' => __( 'Details', 'sportspress' ),
'save' => 'SP_Meta_Box_Table_Details::save',
'output' => 'SP_Meta_Box_Table_Details::output',
'context' => 'side',
'priority' => 'default',
),
'data' => array(
'title' => __( 'Events', 'sportspress' ),
'save' => 'SP_Meta_Box_Table_Data::save',
'output' => 'SP_Meta_Box_Table_Data::output',
'context' => 'normal',
'priority' => 'high',
),
'editor' => array(
'title' => __( 'Description', 'sportspress' ),
'output' => 'SP_Meta_Box_Table_Editor::output',
'context' => 'normal',
'priority' => 'low',
),
);
return $meta_boxes;
}
/**
* Add shortcodes.
*
* @return array
*/
public function add_shortcodes( $shortcodes ) {
$shortcodes['table'] = array( 'table' );
return $shortcodes;
}
/**
* Add settings.
*
* @return array
*/
public function add_settings( $settings ) {
return array_merge( $settings,
array(