Move league tables and players lists into modules
This commit is contained in:
@@ -11,15 +11,6 @@ $options = array(
|
||||
),
|
||||
);
|
||||
|
||||
if ( 'yes' == get_option( 'sportspress_load_league_tables_module', 'yes' ) ) {
|
||||
$options['table'] = array( 'table' );
|
||||
}
|
||||
|
||||
if ( 'yes' == get_option( 'sportspress_load_player_lists_module', 'yes' ) ) {
|
||||
$options['player'][] = 'list';
|
||||
$options['player'][] = 'gallery';
|
||||
}
|
||||
|
||||
$options = apply_filters( 'sportspress_shortcodes', $options );
|
||||
|
||||
foreach ( $options as $name => $group ) {
|
||||
|
||||
@@ -39,11 +39,7 @@ class SP_Admin_Post_Types {
|
||||
include_once( 'post-types/class-sp-admin-cpt-statistic.php' );
|
||||
include_once( 'post-types/class-sp-admin-cpt-event.php' );
|
||||
include_once( 'post-types/class-sp-admin-cpt-team.php' );
|
||||
if ( 'yes' == get_option( 'sportspress_load_league_tables_module', 'yes' ) )
|
||||
include_once( 'post-types/class-sp-admin-cpt-table.php' );
|
||||
include_once( 'post-types/class-sp-admin-cpt-player.php' );
|
||||
if ( 'yes' == get_option( 'sportspress_load_player_lists_module', 'yes' ) )
|
||||
include_once( 'post-types/class-sp-admin-cpt-list.php' );
|
||||
include_once( 'post-types/class-sp-admin-cpt-staff.php' );
|
||||
do_action( 'sportspress_include_post_type_handlers' );
|
||||
}
|
||||
|
||||
@@ -132,6 +132,20 @@ class SP_Admin_Meta_Boxes {
|
||||
'context' => 'side',
|
||||
'priority' => 'default',
|
||||
),
|
||||
'results' => array(
|
||||
'title' => __( 'Event Results', 'sportspress' ),
|
||||
'save' => 'SP_Meta_Box_Event_Results::save',
|
||||
'output' => 'SP_Meta_Box_Event_Results::output',
|
||||
'context' => 'side',
|
||||
'priority' => 'default',
|
||||
),
|
||||
'performance' => array(
|
||||
'title' => __( 'Player Performance', 'sportspress' ),
|
||||
'save' => 'SP_Meta_Box_Event_Performance::save',
|
||||
'output' => 'SP_Meta_Box_Event_Performance::output',
|
||||
'context' => 'side',
|
||||
'priority' => 'default',
|
||||
),
|
||||
'editor' => array(
|
||||
'title' => __( 'Article', 'sportspress' ),
|
||||
'output' => 'SP_Meta_Box_Event_Editor::output',
|
||||
@@ -158,10 +172,6 @@ class SP_Admin_Meta_Boxes {
|
||||
add_action( 'add_meta_boxes', array( $this, 'add_meta_boxes' ), 30 );
|
||||
add_action( 'save_post', array( $this, 'save_meta_boxes' ), 1, 2 );
|
||||
|
||||
// Save Event Meta Boxes
|
||||
add_action( 'sportspress_process_sp_event_meta', 'SP_Meta_Box_Event_Results::save', 50, 2 );
|
||||
add_action( 'sportspress_process_sp_event_meta', 'SP_Meta_Box_Event_Performance::save', 60, 2 );
|
||||
|
||||
// Save Calendar Meta Boxes
|
||||
add_action( 'sportspress_process_sp_calendar_meta', 'SP_Meta_Box_Calendar_Format::save', 10, 2 );
|
||||
add_action( 'sportspress_process_sp_calendar_meta', 'SP_Meta_Box_Calendar_Details::save', 20, 2 );
|
||||
@@ -169,13 +179,6 @@ class SP_Admin_Meta_Boxes {
|
||||
|
||||
// Save Team Meta Boxes
|
||||
add_action( 'sportspress_process_sp_team_meta', 'SP_Meta_Box_Team_Details::save', 10, 2 );
|
||||
if ( 'yes' == get_option( 'sportspress_load_league_tables_module', 'yes' ) ) {
|
||||
add_action( 'sportspress_process_sp_team_meta', 'SP_Meta_Box_Team_Columns::save', 20, 2 );
|
||||
add_action( 'sportspress_process_sp_team_meta', 'SP_Meta_Box_Team_Tables::save', 40, 2 );
|
||||
}
|
||||
if ( 'yes' == get_option( 'sportspress_load_player_lists_module', 'yes' ) ) {
|
||||
add_action( 'sportspress_process_sp_team_meta', 'SP_Meta_Box_Team_Lists::save', 30, 2 );
|
||||
}
|
||||
|
||||
// Save Table Meta Boxes
|
||||
add_action( 'sportspress_process_sp_table_meta', 'SP_Meta_Box_Table_Details::save', 10, 2 );
|
||||
@@ -217,37 +220,10 @@ class SP_Admin_Meta_Boxes {
|
||||
else
|
||||
$post_meta = array();
|
||||
|
||||
// Events
|
||||
$teams = array_filter( sp_array_value( $post_meta, 'sp_team', array() ), 'sp_filter_positive' );
|
||||
if ( ! empty( $teams ) ) {
|
||||
add_meta_box( 'sp_resultsdiv', __( 'Event Results', 'sportspress' ), 'SP_Meta_Box_Event_Results::output', 'sp_event', 'normal', 'high' );
|
||||
}
|
||||
$players = array_filter( sp_array_value( $post_meta, 'sp_player', array() ), 'sp_filter_positive' );
|
||||
if ( ! empty( $players ) ) {
|
||||
add_meta_box( 'sp_performancediv', __( 'Player Performance', 'sportspress' ), 'SP_Meta_Box_Event_Performance::output', 'sp_event', 'normal', 'high' );
|
||||
}
|
||||
|
||||
// Teams
|
||||
add_meta_box( 'sp_detailsdiv', __( 'Details', 'sportspress' ), 'SP_Meta_Box_Team_Details::output', 'sp_team', 'side', 'default' );
|
||||
if ( isset( $post ) && isset( $post->ID ) ):
|
||||
if ( 'yes' == get_option( 'sportspress_load_player_lists_module', 'yes' ) ) {
|
||||
add_meta_box( 'sp_listsdiv', __( 'Player Lists', 'sportspress' ), 'SP_Meta_Box_Team_Lists::output', 'sp_team', 'normal', 'high' );
|
||||
}
|
||||
if ( 'yes' == get_option( 'sportspress_load_league_tables_module', 'yes' ) ) {
|
||||
add_meta_box( 'sp_tablesdiv', __( 'League Tables', 'sportspress' ), 'SP_Meta_Box_Team_Tables::output', 'sp_team', 'normal', 'high' );
|
||||
add_meta_box( 'sp_columnssdiv', __( 'Table Columns', 'sportspress' ), 'SP_Meta_Box_Team_Columns::output', 'sp_team', 'normal', 'high' );
|
||||
}
|
||||
endif;
|
||||
add_meta_box( 'sp_editordiv', __( 'Profile', 'sportspress' ), 'SP_Meta_Box_Team_Editor::output', 'sp_team', 'normal', 'low' );
|
||||
|
||||
if ( 'yes' == get_option( 'sportspress_load_league_tables_module', 'yes' ) ) {
|
||||
// Tables
|
||||
add_meta_box( 'sp_shortcodediv', __( 'Shortcode', 'sportspress' ), 'SP_Meta_Box_Table_Shortcode::output', 'sp_table', 'side', 'default' );
|
||||
add_meta_box( 'sp_detailsdiv', __( 'Details', 'sportspress' ), 'SP_Meta_Box_Table_Details::output', 'sp_table', 'side', 'default' );
|
||||
add_meta_box( 'sp_datadiv', __( 'League Table', 'sportspress' ), 'SP_Meta_Box_Table_Data::output', 'sp_table', 'normal', 'high' );
|
||||
add_meta_box( 'sp_editordiv', __( 'Description', 'sportspress' ), 'SP_Meta_Box_Table_Editor::output', 'sp_table', 'normal', 'low' );
|
||||
}
|
||||
|
||||
// Players
|
||||
add_meta_box( 'sp_shortcodediv', __( 'Shortcodes', 'sportspress' ), 'SP_Meta_Box_Player_Shortcode::output', 'sp_player', 'side', 'default' );
|
||||
add_meta_box( 'sp_columnsdiv', __( 'Columns', 'sportspress' ), 'SP_Meta_Box_Player_Columns::output', 'sp_player', 'side', 'default' );
|
||||
@@ -258,16 +234,6 @@ class SP_Admin_Meta_Boxes {
|
||||
endif;
|
||||
add_meta_box( 'sp_editordiv', __( 'Profile', 'sportspress' ), 'SP_Meta_Box_Player_Editor::output', 'sp_player', 'normal', 'low' );
|
||||
|
||||
if ( 'yes' == get_option( 'sportspress_load_player_lists_module', 'yes' ) ) {
|
||||
// Lists
|
||||
add_meta_box( 'sp_shortcodediv', __( 'Shortcode', 'sportspress' ), 'SP_Meta_Box_List_Shortcode::output', 'sp_list', 'side', 'default' );
|
||||
add_meta_box( 'sp_formatdiv', __( 'Layout', 'sportspress' ), 'SP_Meta_Box_List_Format::output', 'sp_list', 'side', 'default' );
|
||||
add_meta_box( 'sp_columnsdiv', __( 'Columns', 'sportspress' ), 'SP_Meta_Box_List_Columns::output', 'sp_list', 'side', 'default' );
|
||||
add_meta_box( 'sp_detailsdiv', __( 'Details', 'sportspress' ), 'SP_Meta_Box_List_Details::output', 'sp_list', 'side', 'default' );
|
||||
add_meta_box( 'sp_datadiv', __( 'Player List', 'sportspress' ), 'SP_Meta_Box_List_Data::output', 'sp_list', 'normal', 'high' );
|
||||
add_meta_box( 'sp_editordiv', __( 'Description', 'sportspress' ), 'SP_Meta_Box_List_Editor::output', 'sp_list', 'normal', 'low' );
|
||||
}
|
||||
|
||||
// Staff
|
||||
add_meta_box( 'sp_shortcodediv', __( 'Shortcode', 'sportspress' ), 'SP_Meta_Box_Staff_Shortcode::output', 'sp_staff', 'side', 'default' );
|
||||
add_meta_box( 'sp_detailsdiv', __( 'Details', 'sportspress' ), 'SP_Meta_Box_Staff_Details::output', 'sp_staff', 'side', 'default' );
|
||||
|
||||
@@ -91,53 +91,6 @@ class SP_Settings_Players extends SP_Settings_Page {
|
||||
|
||||
);
|
||||
|
||||
if ( 'yes' == get_option( 'sportspress_load_player_lists_module', 'yes' ) ) {
|
||||
|
||||
$settings = array_merge( $settings, array_merge(
|
||||
|
||||
array(
|
||||
array( 'title' => __( 'Player Lists', 'sportspress' ), 'type' => 'title', 'id' => 'list_options' ),
|
||||
),
|
||||
|
||||
apply_filters( 'sportspress_player_list_options', array(
|
||||
array(
|
||||
'title' => __( 'Players', 'sportspress' ),
|
||||
'desc' => __( 'Display photos', 'sportspress' ),
|
||||
'id' => 'sportspress_list_show_photos',
|
||||
'default' => 'no',
|
||||
'type' => 'checkbox',
|
||||
),
|
||||
|
||||
array(
|
||||
'title' => __( 'Pagination', 'sportspress' ),
|
||||
'desc' => __( 'Paginate', 'sportspress' ),
|
||||
'id' => 'sportspress_list_paginated',
|
||||
'default' => 'yes',
|
||||
'type' => 'checkbox',
|
||||
),
|
||||
|
||||
array(
|
||||
'title' => __( 'Limit', 'sportspress' ),
|
||||
'id' => 'sportspress_list_rows',
|
||||
'class' => 'small-text',
|
||||
'default' => '10',
|
||||
'desc' => __( 'players', 'sportspress' ),
|
||||
'type' => 'number',
|
||||
'custom_attributes' => array(
|
||||
'min' => 1,
|
||||
'step' => 1
|
||||
),
|
||||
),
|
||||
) ),
|
||||
|
||||
array(
|
||||
array( 'type' => 'sectionend', 'id' => 'list_options' ),
|
||||
)
|
||||
|
||||
));
|
||||
|
||||
} // End player settings
|
||||
|
||||
return apply_filters( 'sportspress_player_settings', $settings );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -426,39 +426,6 @@ class SP_Post_types {
|
||||
)
|
||||
);
|
||||
|
||||
if ( 'yes' == get_option( 'sportspress_load_league_tables_module', 'yes' ) ) {
|
||||
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,
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
register_post_type( 'sp_player',
|
||||
apply_filters( 'sportspress_register_post_type_player',
|
||||
array(
|
||||
@@ -489,39 +456,6 @@ class SP_Post_types {
|
||||
)
|
||||
);
|
||||
|
||||
if ( 'yes' == get_option( 'sportspress_load_player_lists_module', 'yes' ) ) {
|
||||
register_post_type( 'sp_list',
|
||||
apply_filters( 'sportspress_register_post_type_list',
|
||||
array(
|
||||
'labels' => array(
|
||||
'name' => __( 'Player Lists', 'sportspress' ),
|
||||
'singular_name' => __( 'Player List', 'sportspress' ),
|
||||
'add_new_item' => __( 'Add New Player List', 'sportspress' ),
|
||||
'edit_item' => __( 'Edit Player List', 'sportspress' ),
|
||||
'new_item' => __( 'New', 'sportspress' ),
|
||||
'view_item' => __( 'View Player List', '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_list',
|
||||
'map_meta_cap' => true,
|
||||
'publicly_queryable' => true,
|
||||
'exclude_from_search' => false,
|
||||
'hierarchical' => false,
|
||||
'rewrite' => array( 'slug' => get_option( 'sportspress_list_slug', 'list' ) ),
|
||||
'supports' => array( 'title', 'page-attributes', 'author', 'thumbnail' ),
|
||||
'has_archive' => false,
|
||||
'show_in_nav_menus' => true,
|
||||
'show_in_menu' => 'edit.php?post_type=sp_player',
|
||||
'show_in_admin_bar' => true,
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
register_post_type( 'sp_staff',
|
||||
apply_filters( 'sportspress_register_post_type_staff',
|
||||
array(
|
||||
|
||||
@@ -57,12 +57,8 @@ add_action( 'sportspress_single_calendar_content', 'sportspress_output_calendar'
|
||||
*/
|
||||
add_action( 'sportspress_single_team_content', 'sportspress_output_team_logo', 0 );
|
||||
add_action( 'sportspress_single_team_content', 'sportspress_output_team_details', 10 );
|
||||
if ( 'yes' == get_option( 'sportspress_load_player_lists_module', 'yes' ) ) {
|
||||
add_action( 'sportspress_single_team_content', 'sportspress_output_team_lists', 20 );
|
||||
}
|
||||
if ( 'yes' == get_option( 'sportspress_load_league_tables_module', 'yes' ) ) {
|
||||
add_action( 'sportspress_single_team_content', 'sportspress_output_team_tables', 30 );
|
||||
}
|
||||
|
||||
/**
|
||||
* After Single Team
|
||||
|
||||
@@ -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(
|
||||
|
||||
231
modules/sportspress-player-lists.php
Normal file
231
modules/sportspress-player-lists.php
Normal file
@@ -0,0 +1,231 @@
|
||||
<?php
|
||||
/*
|
||||
Plugin Name: SportsPress Player Lists
|
||||
Plugin URI: http://themeboy.com/
|
||||
Description: Add player lists to SportsPress.
|
||||
Author: ThemeBoy
|
||||
Author URI: http://themeboy.com/
|
||||
Version: 1.6
|
||||
*/
|
||||
|
||||
// Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
|
||||
if ( ! class_exists( 'SportsPress_Player_Lists' ) ) :
|
||||
|
||||
/**
|
||||
* Main SportsPress Player Lists Class
|
||||
*
|
||||
* @class SportsPress_Player_Lists
|
||||
* @version 1.6
|
||||
*/
|
||||
class SportsPress_Player_Lists {
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct() {
|
||||
// Define constants
|
||||
$this->define_constants();
|
||||
|
||||
// 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_player_settings', array( $this, 'add_settings' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Define constants.
|
||||
*/
|
||||
private function define_constants() {
|
||||
if ( !defined( 'SP_PLAYER_LISTS_VERSION' ) )
|
||||
define( 'SP_PLAYER_LISTS_VERSION', '1.6' );
|
||||
|
||||
if ( !defined( 'SP_PLAYER_LISTS_URL' ) )
|
||||
define( 'SP_PLAYER_LISTS_URL', plugin_dir_url( __FILE__ ) );
|
||||
|
||||
if ( !defined( 'SP_PLAYER_LISTS_DIR' ) )
|
||||
define( 'SP_PLAYER_LISTS_DIR', plugin_dir_path( __FILE__ ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Register league tables post type
|
||||
*/
|
||||
public static function register_post_type() {
|
||||
register_post_type( 'sp_list',
|
||||
apply_filters( 'sportspress_register_post_type_list',
|
||||
array(
|
||||
'labels' => array(
|
||||
'name' => __( 'Player Lists', 'sportspress' ),
|
||||
'singular_name' => __( 'Player List', 'sportspress' ),
|
||||
'add_new_item' => __( 'Add New Player List', 'sportspress' ),
|
||||
'edit_item' => __( 'Edit Player List', 'sportspress' ),
|
||||
'new_item' => __( 'New', 'sportspress' ),
|
||||
'view_item' => __( 'View Player List', '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_list',
|
||||
'map_meta_cap' => true,
|
||||
'publicly_queryable' => true,
|
||||
'exclude_from_search' => false,
|
||||
'hierarchical' => false,
|
||||
'rewrite' => array( 'slug' => get_option( 'sportspress_list_slug', 'list' ) ),
|
||||
'supports' => array( 'title', 'page-attributes', 'author', 'thumbnail' ),
|
||||
'has_archive' => false,
|
||||
'show_in_nav_menus' => true,
|
||||
'show_in_menu' => 'edit.php?post_type=sp_player',
|
||||
'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-list.php' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Add widgets.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function include_widgets() {
|
||||
include_once( SP()->plugin_path() . '/includes/widgets/class-sp-widget-player-list.php' );
|
||||
include_once( SP()->plugin_path() . '/includes/widgets/class-sp-widget-player-gallery.php' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Add meta boxes.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function add_meta_boxes( $meta_boxes ) {
|
||||
$meta_boxes['sp_team']['lists'] = array(
|
||||
'title' => __( 'Player Lists', 'sportspress' ),
|
||||
'output' => 'SP_Meta_Box_Team_Lists::output',
|
||||
'save' => 'SP_Meta_Box_Team_Lists::save',
|
||||
'context' => 'normal',
|
||||
'priority' => 'high',
|
||||
);
|
||||
$meta_boxes['sp_list'] = array(
|
||||
'shortcode' => array(
|
||||
'title' => __( 'Shortcode', 'sportspress' ),
|
||||
'output' => 'SP_Meta_Box_List_Shortcode::output',
|
||||
'context' => 'side',
|
||||
'priority' => 'default',
|
||||
),
|
||||
'format' => array(
|
||||
'title' => __( 'Layout', 'sportspress' ),
|
||||
'save' => 'SP_Meta_Box_List_Format::save',
|
||||
'output' => 'SP_Meta_Box_List_Format::output',
|
||||
'context' => 'side',
|
||||
'priority' => 'default',
|
||||
),
|
||||
'columns' => array(
|
||||
'title' => __( 'Columns', 'sportspress' ),
|
||||
'save' => 'SP_Meta_Box_List_Columns::save',
|
||||
'output' => 'SP_Meta_Box_List_Columns::output',
|
||||
'context' => 'side',
|
||||
'priority' => 'default',
|
||||
),
|
||||
'details' => array(
|
||||
'title' => __( 'Details', 'sportspress' ),
|
||||
'save' => 'SP_Meta_Box_List_Details::save',
|
||||
'output' => 'SP_Meta_Box_List_Details::output',
|
||||
'context' => 'side',
|
||||
'priority' => 'default',
|
||||
),
|
||||
'data' => array(
|
||||
'title' => __( 'Player List', 'sportspress' ),
|
||||
'save' => 'SP_Meta_Box_List_Data::save',
|
||||
'output' => 'SP_Meta_Box_List_Data::output',
|
||||
'context' => 'normal',
|
||||
'priority' => 'high',
|
||||
),
|
||||
'editor' => array(
|
||||
'title' => __( 'Description', 'sportspress' ),
|
||||
'output' => 'SP_Meta_Box_List_Editor::output',
|
||||
'context' => 'normal',
|
||||
'priority' => 'low',
|
||||
),
|
||||
);
|
||||
return $meta_boxes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add shortcodes.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function add_shortcodes( $shortcodes ) {
|
||||
$shortcodes['player'][] = 'list';
|
||||
$shortcodes['player'][] = 'gallery';
|
||||
return $shortcodes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add settings.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function add_settings( $settings ) {
|
||||
return array_merge( $settings, array_merge(
|
||||
array(
|
||||
array( 'title' => __( 'Player Lists', 'sportspress' ), 'type' => 'title', 'id' => 'list_options' ),
|
||||
),
|
||||
|
||||
apply_filters( 'sportspress_player_list_options', array(
|
||||
array(
|
||||
'title' => __( 'Players', 'sportspress' ),
|
||||
'desc' => __( 'Display photos', 'sportspress' ),
|
||||
'id' => 'sportspress_list_show_photos',
|
||||
'default' => 'no',
|
||||
'type' => 'checkbox',
|
||||
),
|
||||
|
||||
array(
|
||||
'title' => __( 'Pagination', 'sportspress' ),
|
||||
'desc' => __( 'Paginate', 'sportspress' ),
|
||||
'id' => 'sportspress_list_paginated',
|
||||
'default' => 'yes',
|
||||
'type' => 'checkbox',
|
||||
),
|
||||
|
||||
array(
|
||||
'title' => __( 'Limit', 'sportspress' ),
|
||||
'id' => 'sportspress_list_rows',
|
||||
'class' => 'small-text',
|
||||
'default' => '10',
|
||||
'desc' => __( 'players', 'sportspress' ),
|
||||
'type' => 'number',
|
||||
'custom_attributes' => array(
|
||||
'min' => 1,
|
||||
'step' => 1
|
||||
),
|
||||
),
|
||||
) ),
|
||||
|
||||
array(
|
||||
array( 'type' => 'sectionend', 'id' => 'list_options' ),
|
||||
)
|
||||
) );
|
||||
}
|
||||
}
|
||||
|
||||
endif;
|
||||
|
||||
if ( get_option( 'sportspress_load_player_lists_module', 'yes' ) == 'yes' ) {
|
||||
new SportsPress_Player_Lists();
|
||||
}
|
||||
@@ -265,13 +265,6 @@ final class SportsPress {
|
||||
*/
|
||||
public function include_widgets() {
|
||||
include_once( 'includes/widgets/class-sp-widget-countdown.php' );
|
||||
if ( 'yes' == get_option( 'sportspress_load_league_tables_module', 'yes' ) ) {
|
||||
include_once( 'includes/widgets/class-sp-widget-league-table.php' );
|
||||
}
|
||||
if ( 'yes' == get_option( 'sportspress_load_player_lists_module', 'yes' ) ) {
|
||||
include_once( 'includes/widgets/class-sp-widget-player-list.php' );
|
||||
include_once( 'includes/widgets/class-sp-widget-player-gallery.php' );
|
||||
}
|
||||
include_once( 'includes/widgets/class-sp-widget-staff.php' );
|
||||
|
||||
do_action( 'sportspress_widgets' );
|
||||
|
||||
Reference in New Issue
Block a user