Expand theme prefix and clean up file structure
This commit is contained in:
6
admin/actions/admin-enqueue-scripts.php
Normal file
6
admin/actions/admin-enqueue-scripts.php
Normal file
@@ -0,0 +1,6 @@
|
||||
<?php
|
||||
function sportspress_admin_enqueue_scripts() {
|
||||
wp_enqueue_script( 'jquery' );
|
||||
wp_enqueue_script( 'sportspress-admin', SPORTSPRESS_PLUGIN_URL .'/assets/js/admin.js', array( 'jquery' ), time(), true );
|
||||
}
|
||||
add_action( 'admin_enqueue_scripts', 'sportspress_admin_enqueue_scripts' );
|
||||
10
admin/actions/admin-head.php
Normal file
10
admin/actions/admin-head.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
function sportspress_admin_head() {
|
||||
global $typenow;
|
||||
|
||||
if ( in_array( $typenow, array( 'sp_result', 'sp_outcome', 'sp_column', 'sp_statistic' ) ) ):
|
||||
sportspress_highlight_admin_menu();
|
||||
endif;
|
||||
}
|
||||
add_action( 'admin_head-edit.php', 'sportspress_admin_head', 10, 2 );
|
||||
add_action( 'admin_head-post.php', 'sportspress_admin_head', 10, 2 );
|
||||
162
admin/actions/admin-init.php
Normal file
162
admin/actions/admin-init.php
Normal file
@@ -0,0 +1,162 @@
|
||||
<?php
|
||||
function sportspress_admin_init() {
|
||||
|
||||
$installed = get_option( 'sportspress_installed', false );
|
||||
|
||||
// Define roles and capabilities
|
||||
if ( ! $installed ):
|
||||
|
||||
$role = get_role( 'administrator' );
|
||||
|
||||
// Events
|
||||
$role->add_cap( 'edit_sp_event' );
|
||||
$role->add_cap( 'edit_sp_events' );
|
||||
$role->add_cap( 'edit_others_sp_events' );
|
||||
$role->add_cap( 'delete_sp_event' );
|
||||
$role->add_cap( 'publish_sp_events' );
|
||||
$role->add_cap( 'read_sp_events' );
|
||||
$role->add_cap( 'read_private_sp_events' );
|
||||
|
||||
// Teams
|
||||
$role->add_cap( 'edit_sp_team' );
|
||||
$role->add_cap( 'edit_sp_teams' );
|
||||
$role->add_cap( 'edit_others_sp_teams' );
|
||||
$role->add_cap( 'delete_sp_team' );
|
||||
$role->add_cap( 'publish_sp_teams' );
|
||||
$role->add_cap( 'read_sp_teams' );
|
||||
$role->add_cap( 'read_private_sp_teams' );
|
||||
|
||||
// League Tables
|
||||
$role->add_cap( 'edit_sp_table' );
|
||||
$role->add_cap( 'edit_sp_tables' );
|
||||
$role->add_cap( 'edit_others_sp_tables' );
|
||||
$role->add_cap( 'delete_sp_table' );
|
||||
$role->add_cap( 'publish_sp_tables' );
|
||||
$role->add_cap( 'read_sp_tables' );
|
||||
$role->add_cap( 'read_private_sp_tables' );
|
||||
|
||||
// Players
|
||||
$role->add_cap( 'edit_sp_player' );
|
||||
$role->add_cap( 'edit_sp_players' );
|
||||
$role->add_cap( 'edit_others_sp_players' );
|
||||
$role->add_cap( 'delete_sp_player' );
|
||||
$role->add_cap( 'publish_sp_players' );
|
||||
$role->add_cap( 'read_sp_players' );
|
||||
$role->add_cap( 'read_private_sp_players' );
|
||||
|
||||
// Player Lists
|
||||
$role->add_cap( 'edit_sp_list' );
|
||||
$role->add_cap( 'edit_sp_lists' );
|
||||
$role->add_cap( 'edit_others_sp_lists' );
|
||||
$role->add_cap( 'delete_sp_list' );
|
||||
$role->add_cap( 'publish_sp_lists' );
|
||||
$role->add_cap( 'read_sp_lists' );
|
||||
$role->add_cap( 'read_private_sp_lists' );
|
||||
|
||||
// Staff
|
||||
$role->add_cap( 'edit_sp_staff' );
|
||||
$role->add_cap( 'edit_sp_staffs' );
|
||||
$role->add_cap( 'edit_others_sp_staffs' );
|
||||
$role->add_cap( 'delete_sp_staff' );
|
||||
$role->add_cap( 'publish_sp_staffs' );
|
||||
$role->add_cap( 'read_sp_staffs' );
|
||||
$role->add_cap( 'read_private_sp_staffs' );
|
||||
|
||||
// Settings
|
||||
$role->add_cap( 'read_sp_configs' );
|
||||
$role->add_cap( 'read_private_sp_configs' );
|
||||
$role->add_cap( 'edit_sp_config' );
|
||||
$role->add_cap( 'edit_sp_configs' );
|
||||
$role->add_cap( 'edit_published_sp_configs' );
|
||||
$role->add_cap( 'edit_private_sp_configs' );
|
||||
$role->add_cap( 'edit_others_sp_configs' );
|
||||
$role->add_cap( 'delete_sp_config' );
|
||||
$role->add_cap( 'delete_published_sp_configs' );
|
||||
$role->add_cap( 'delete_private_sp_configs' );
|
||||
$role->add_cap( 'delete_others_sp_configs' );
|
||||
$role->add_cap( 'publish_sp_configs' );
|
||||
|
||||
// Team Manager
|
||||
remove_role( 'sp_team_manager' );
|
||||
add_role(
|
||||
'sp_team_manager',
|
||||
__( 'Team Manager', 'sportspress' ),
|
||||
array(
|
||||
'read' => true,
|
||||
'edit_posts' => true,
|
||||
'delete_posts' => true,
|
||||
'read_sp_players' => true,
|
||||
'edit_sp_players' => true,
|
||||
'edit_others_sp_players' => true,
|
||||
'delete_sp_player' => true,
|
||||
'publish_sp_players' => true,
|
||||
'read_sp_staffs' => true,
|
||||
'edit_sp_staffs' => true,
|
||||
'edit_others_sp_staffs' => true,
|
||||
'delete_sp_staff' => true,
|
||||
'publish_sp_staffs' => true
|
||||
)
|
||||
);
|
||||
|
||||
// Staff
|
||||
remove_role( 'sp_staff' );
|
||||
add_role(
|
||||
'sp_staff',
|
||||
__( 'Staff', 'sportspress' ),
|
||||
array(
|
||||
'read' => true,
|
||||
'edit_posts' => true,
|
||||
'delete_posts' => true,
|
||||
'read_sp_staffs' => true,
|
||||
'edit_sp_staffs' => true,
|
||||
'delete_sp_staff' => true
|
||||
)
|
||||
);
|
||||
|
||||
// Player
|
||||
remove_role( 'sp_player' );
|
||||
add_role(
|
||||
'sp_player',
|
||||
__( 'Player', 'sportspress' ),
|
||||
array(
|
||||
'read' => true,
|
||||
'edit_posts' => true,
|
||||
'delete_posts' => true,
|
||||
'read_sp_players' => true,
|
||||
'edit_sp_players' => true,
|
||||
'delete_sp_player' => true
|
||||
)
|
||||
);
|
||||
|
||||
update_option( 'sportspress_installed', 1 );
|
||||
|
||||
endif;
|
||||
|
||||
// Load admin styles
|
||||
wp_register_style( 'sportspress-admin', SPORTSPRESS_PLUGIN_URL . 'assets/css/admin.css', array(), '1.0' );
|
||||
wp_enqueue_style( 'sportspress-admin');
|
||||
|
||||
// Add settings sections
|
||||
register_setting(
|
||||
'sportspress_general',
|
||||
'sportspress',
|
||||
'sportspress_validate'
|
||||
);
|
||||
|
||||
add_settings_section(
|
||||
'general',
|
||||
'',
|
||||
'',
|
||||
'sportspress_general'
|
||||
);
|
||||
|
||||
add_settings_field(
|
||||
'sport',
|
||||
__( 'Sport', 'sportspress' ),
|
||||
'sportspress_sport_callback',
|
||||
'sportspress_general',
|
||||
'general'
|
||||
);
|
||||
|
||||
}
|
||||
add_action( 'admin_init', 'sportspress_admin_init', 1 );
|
||||
@@ -1,5 +1,13 @@
|
||||
<?php
|
||||
function sp_admin_menu( $position ) {
|
||||
function sportspress_admin_menu( $position ) {
|
||||
add_options_page(
|
||||
__( 'SportsPress', 'sportspress' ),
|
||||
__( 'SportsPress', 'sportspress' ),
|
||||
'manage_options',
|
||||
'sportspress',
|
||||
'sportspress_settings'
|
||||
);
|
||||
|
||||
if ( ! current_user_can( 'manage_options' ) )
|
||||
return;
|
||||
|
||||
@@ -28,4 +36,4 @@ function sp_admin_menu( $position ) {
|
||||
// Remove "Seasons" link under Staff
|
||||
unset( $submenu['edit.php?post_type=sp_staff'][15] );
|
||||
}
|
||||
add_action( 'admin_menu', 'sp_admin_menu' );
|
||||
add_action( 'admin_menu', 'sportspress_admin_menu' );
|
||||
5
admin/actions/after-setup-theme.php
Normal file
5
admin/actions/after-setup-theme.php
Normal file
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
function sportspress_after_setup_theme() {
|
||||
add_theme_support( 'post-thumbnails' );
|
||||
}
|
||||
add_action( 'after_setup_theme', 'sportspress_after_setup_theme' );
|
||||
@@ -1,5 +0,0 @@
|
||||
<?php
|
||||
function sp_after_theme_setup() {
|
||||
add_theme_support( 'post-thumbnails' );
|
||||
}
|
||||
add_action( 'after_theme_setup', 'sp_after_theme_setup' );
|
||||
4
admin/actions/manage-posts-columns.php
Normal file
4
admin/actions/manage-posts-columns.php
Normal file
@@ -0,0 +1,4 @@
|
||||
<?php
|
||||
function sp_manage_posts_columns() {
|
||||
sportspress_highlight_admin_menu();
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
function sp_manage_posts_custom_column( $column, $post_id ) {
|
||||
function sportspress_manage_posts_custom_column( $column, $post_id ) {
|
||||
global $post;
|
||||
switch ( $column ):
|
||||
case 'sp_logo':
|
||||
@@ -16,7 +16,7 @@ function sp_manage_posts_custom_column( $column, $post_id ) {
|
||||
foreach( $teams as $team_id ):
|
||||
if ( ! $team_id ) continue;
|
||||
$team = get_post( $team_id );
|
||||
$outcome_slug = sp_array_value( sp_array_value( $results, $team_id, null ), 'outcome', null );
|
||||
$outcome_slug = sportspress_array_value( sportspress_array_value( $results, $team_id, null ), 'outcome', null );
|
||||
|
||||
$args=array(
|
||||
'name' => $outcome_slug,
|
||||
@@ -32,7 +32,7 @@ function sp_manage_posts_custom_column( $column, $post_id ) {
|
||||
foreach( $teams as $team_id ):
|
||||
if ( ! $team_id ) continue;
|
||||
$team = get_post( $team_id );
|
||||
$outcome_slug = sp_array_value( sp_array_value( $results, $team_id, null ), 'outcome', null );
|
||||
$outcome_slug = sportspress_array_value( sportspress_array_value( $results, $team_id, null ), 'outcome', null );
|
||||
|
||||
$args=array(
|
||||
'name' => $outcome_slug,
|
||||
@@ -51,19 +51,19 @@ function sp_manage_posts_custom_column( $column, $post_id ) {
|
||||
endif;
|
||||
break;
|
||||
case 'sp_equation':
|
||||
echo sp_get_post_equation( $post_id );
|
||||
echo sportspress_get_post_equation( $post_id );
|
||||
break;
|
||||
case 'sp_order':
|
||||
echo sp_get_post_order( $post_id );
|
||||
echo sportspress_get_post_order( $post_id );
|
||||
break;
|
||||
case 'sp_key':
|
||||
echo $post->post_name;
|
||||
break;
|
||||
case 'sp_format':
|
||||
echo sp_get_post_format( $post_id );
|
||||
echo sportspress_get_post_format( $post_id );
|
||||
break;
|
||||
case 'sp_player':
|
||||
echo sp_the_posts( $post_id, 'sp_player' );
|
||||
echo sportspress_the_posts( $post_id, 'sp_player' );
|
||||
break;
|
||||
case 'sp_event':
|
||||
echo get_post_meta ( $post_id, 'sp_event' ) ? sizeof( get_post_meta ( $post_id, 'sp_event' ) ) : '—';
|
||||
@@ -82,5 +82,5 @@ function sp_manage_posts_custom_column( $column, $post_id ) {
|
||||
break;
|
||||
endswitch;
|
||||
}
|
||||
add_action( 'manage_posts_custom_column', 'sp_manage_posts_custom_column', 10, 2 );
|
||||
add_action( 'manage_pages_custom_column', 'sp_manage_posts_custom_column', 10, 2 );
|
||||
add_action( 'manage_posts_custom_column', 'sportspress_manage_posts_custom_column', 10, 2 );
|
||||
add_action( 'manage_pages_custom_column', 'sportspress_manage_posts_custom_column', 10, 2 );
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
function sp_plugins_loaded() {
|
||||
load_plugin_textdomain ( 'sportspress', false, dirname( SPORTSPRESS_PLUGIN_BASENAME ) . '/i18n/languages/' );
|
||||
function sportspress_plugins_loaded() {
|
||||
load_plugin_textdomain ( 'sportspress', false, dirname( SPORTSPRESS_PLUGIN_BASENAME ) . '/languages/' );
|
||||
add_image_size( 'sp_icon', 32, 32, false );
|
||||
}
|
||||
add_action( 'plugins_loaded', 'sp_plugins_loaded' );
|
||||
add_action( 'plugins_loaded', 'sportspress_plugins_loaded' );
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
function sp_post_thumbnail_html( $html, $post_id, $post_thumbnail_id, $size, $attr ) {
|
||||
function sportspress_post_thumbnail_html( $html, $post_id, $post_thumbnail_id, $size, $attr ) {
|
||||
if( empty ( $html ) && in_array( get_post_type( $post_id ), array( 'sp_team', 'sp_tournament' ) ) ) {
|
||||
$parents = get_post_ancestors( $post_id );
|
||||
foreach ( $parents as $parent ) {
|
||||
@@ -11,4 +11,4 @@ function sp_post_thumbnail_html( $html, $post_id, $post_thumbnail_id, $size, $at
|
||||
}
|
||||
return $html;
|
||||
}
|
||||
add_filter( 'post_thumbnail_html', 'sp_post_thumbnail_html', 10, 5 );
|
||||
add_filter( 'post_thumbnail_html', 'sportspress_post_thumbnail_html', 10, 5 );
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
function sp_restrict_manage_posts() {
|
||||
sp_highlight_admin_menu();
|
||||
function sportspress_restrict_manage_posts() {
|
||||
sportspress_highlight_admin_menu();
|
||||
global $typenow, $wp_query;
|
||||
if ( in_array( $typenow, array( 'sp_event', 'sp_player', 'sp_staff', 'sp_table', 'sp_list' ) ) ):
|
||||
$selected = isset( $_REQUEST['sp_team'] ) ? $_REQUEST['sp_team'] : null;
|
||||
@@ -20,7 +20,7 @@ function sp_restrict_manage_posts() {
|
||||
'name' => 'sp_position',
|
||||
'selected' => $selected
|
||||
);
|
||||
sp_dropdown_taxonomies( $args );
|
||||
sportspress_dropdown_taxonomies( $args );
|
||||
endif;
|
||||
if ( in_array( $typenow, array( 'sp_team', 'sp_event', 'sp_player', 'sp_staff', 'sp_table', 'sp_list' ) ) ):
|
||||
$selected = isset( $_REQUEST['sp_season'] ) ? $_REQUEST['sp_season'] : null;
|
||||
@@ -30,7 +30,7 @@ function sp_restrict_manage_posts() {
|
||||
'name' => 'sp_season',
|
||||
'selected' => $selected
|
||||
);
|
||||
sp_dropdown_taxonomies( $args );
|
||||
sportspress_dropdown_taxonomies( $args );
|
||||
endif;
|
||||
}
|
||||
add_action( 'restrict_manage_posts', 'sp_restrict_manage_posts' );
|
||||
add_action( 'restrict_manage_posts', 'sportspress_restrict_manage_posts' );
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
function sp_save_post( $post_id ) {
|
||||
function sportspress_save_post( $post_id ) {
|
||||
global $post, $typenow;
|
||||
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) return $post_id;
|
||||
if ( !current_user_can( 'edit_post', $post_id ) ) return $post_id;
|
||||
@@ -8,129 +8,129 @@ function sp_save_post( $post_id ) {
|
||||
case ( 'sp_team' ):
|
||||
|
||||
// Update columns
|
||||
update_post_meta( $post_id, 'sp_columns', sp_array_value( $_POST, 'sp_columns', array() ) );
|
||||
update_post_meta( $post_id, 'sp_columns', sportspress_array_value( $_POST, 'sp_columns', array() ) );
|
||||
|
||||
break;
|
||||
|
||||
case ( 'sp_event' ):
|
||||
|
||||
// Get results
|
||||
$results = (array)sp_array_value( $_POST, 'sp_results', array() );
|
||||
$results = (array)sportspress_array_value( $_POST, 'sp_results', array() );
|
||||
|
||||
// Update results
|
||||
update_post_meta( $post_id, 'sp_results', $results );
|
||||
|
||||
// Update player statistics
|
||||
update_post_meta( $post_id, 'sp_players', sp_array_value( $_POST, 'sp_players', array() ) );
|
||||
update_post_meta( $post_id, 'sp_players', sportspress_array_value( $_POST, 'sp_players', array() ) );
|
||||
|
||||
// Update team array
|
||||
sp_update_post_meta_recursive( $post_id, 'sp_team', sp_array_value( $_POST, 'sp_team', array() ) );
|
||||
sportspress_update_post_meta_recursive( $post_id, 'sp_team', sportspress_array_value( $_POST, 'sp_team', array() ) );
|
||||
|
||||
// Update player array
|
||||
sp_update_post_meta_recursive( $post_id, 'sp_player', sp_array_value( $_POST, 'sp_player', array() ) );
|
||||
sportspress_update_post_meta_recursive( $post_id, 'sp_player', sportspress_array_value( $_POST, 'sp_player', array() ) );
|
||||
|
||||
// Update staff array
|
||||
sp_update_post_meta_recursive( $post_id, 'sp_staff', sp_array_value( $_POST, 'sp_staff', array() ) );
|
||||
sportspress_update_post_meta_recursive( $post_id, 'sp_staff', sportspress_array_value( $_POST, 'sp_staff', array() ) );
|
||||
|
||||
break;
|
||||
|
||||
case ( 'sp_column' ):
|
||||
|
||||
// Update format as string
|
||||
update_post_meta( $post_id, 'sp_format', sp_array_value( $_POST, 'sp_format', 'integer' ) );
|
||||
update_post_meta( $post_id, 'sp_format', sportspress_array_value( $_POST, 'sp_format', 'integer' ) );
|
||||
|
||||
// Update precision as integer
|
||||
update_post_meta( $post_id, 'sp_precision', (int) sp_array_value( $_POST, 'sp_precision', 1 ) );
|
||||
update_post_meta( $post_id, 'sp_precision', (int) sportspress_array_value( $_POST, 'sp_precision', 1 ) );
|
||||
|
||||
// Update equation as string
|
||||
update_post_meta( $post_id, 'sp_equation', implode( ' ', sp_array_value( $_POST, 'sp_equation', array() ) ) );
|
||||
update_post_meta( $post_id, 'sp_equation', implode( ' ', sportspress_array_value( $_POST, 'sp_equation', array() ) ) );
|
||||
|
||||
// Update sort order as string
|
||||
update_post_meta( $post_id, 'sp_priority', sp_array_value( $_POST, 'sp_priority', '0' ) );
|
||||
update_post_meta( $post_id, 'sp_priority', sportspress_array_value( $_POST, 'sp_priority', '0' ) );
|
||||
|
||||
// Update sort order as string
|
||||
update_post_meta( $post_id, 'sp_order', sp_array_value( $_POST, 'sp_order', 'DESC' ) );
|
||||
update_post_meta( $post_id, 'sp_order', sportspress_array_value( $_POST, 'sp_order', 'DESC' ) );
|
||||
|
||||
break;
|
||||
|
||||
case ( 'sp_statistic' ):
|
||||
|
||||
// Update format as string
|
||||
update_post_meta( $post_id, 'sp_format', sp_array_value( $_POST, 'sp_format', 'integer' ) );
|
||||
update_post_meta( $post_id, 'sp_format', sportspress_array_value( $_POST, 'sp_format', 'integer' ) );
|
||||
|
||||
// Update precision as integer
|
||||
update_post_meta( $post_id, 'sp_precision', (int) sp_array_value( $_POST, 'sp_precision', 1 ) );
|
||||
update_post_meta( $post_id, 'sp_precision', (int) sportspress_array_value( $_POST, 'sp_precision', 1 ) );
|
||||
|
||||
// Update equation as string
|
||||
update_post_meta( $post_id, 'sp_equation', implode( ' ', sp_array_value( $_POST, 'sp_equation', array() ) ) );
|
||||
update_post_meta( $post_id, 'sp_equation', implode( ' ', sportspress_array_value( $_POST, 'sp_equation', array() ) ) );
|
||||
|
||||
// Update sort order as string
|
||||
update_post_meta( $post_id, 'sp_priority', sp_array_value( $_POST, 'sp_priority', '0' ) );
|
||||
update_post_meta( $post_id, 'sp_priority', sportspress_array_value( $_POST, 'sp_priority', '0' ) );
|
||||
|
||||
// Update sort order as string
|
||||
update_post_meta( $post_id, 'sp_order', sp_array_value( $_POST, 'sp_order', 'DESC' ) );
|
||||
update_post_meta( $post_id, 'sp_order', sportspress_array_value( $_POST, 'sp_order', 'DESC' ) );
|
||||
|
||||
break;
|
||||
|
||||
case ( 'sp_result' ):
|
||||
|
||||
// Update format as string
|
||||
update_post_meta( $post_id, 'sp_format', sp_array_value( $_POST, 'sp_format', 'integer' ) );
|
||||
update_post_meta( $post_id, 'sp_format', sportspress_array_value( $_POST, 'sp_format', 'integer' ) );
|
||||
|
||||
break;
|
||||
|
||||
case ( 'sp_player' ):
|
||||
|
||||
// Update player statistics
|
||||
update_post_meta( $post_id, 'sp_statistics', sp_array_value( $_POST, 'sp_statistics', array() ) );
|
||||
update_post_meta( $post_id, 'sp_statistics', sportspress_array_value( $_POST, 'sp_statistics', array() ) );
|
||||
|
||||
// Update team array
|
||||
sp_update_post_meta_recursive( $post_id, 'sp_team', sp_array_value( $_POST, 'sp_team', array() ) );
|
||||
sportspress_update_post_meta_recursive( $post_id, 'sp_team', sportspress_array_value( $_POST, 'sp_team', array() ) );
|
||||
|
||||
// Update player number
|
||||
update_post_meta( $post_id, 'sp_number', sp_array_value( $_POST, 'sp_number', '' ) );
|
||||
update_post_meta( $post_id, 'sp_number', sportspress_array_value( $_POST, 'sp_number', '' ) );
|
||||
|
||||
// Update player details array
|
||||
update_post_meta( $post_id, 'sp_details', sp_array_value( $_POST, 'sp_details', array() ) );
|
||||
update_post_meta( $post_id, 'sp_details', sportspress_array_value( $_POST, 'sp_details', array() ) );
|
||||
|
||||
break;
|
||||
|
||||
case ( 'sp_staff' ):
|
||||
|
||||
// Update team array
|
||||
sp_update_post_meta_recursive( $post_id, 'sp_team', sp_array_value( $_POST, 'sp_team', array() ) );
|
||||
sportspress_update_post_meta_recursive( $post_id, 'sp_team', sportspress_array_value( $_POST, 'sp_team', array() ) );
|
||||
|
||||
break;
|
||||
|
||||
case ( 'sp_table' ):
|
||||
|
||||
// Update teams array
|
||||
update_post_meta( $post_id, 'sp_teams', sp_array_value( $_POST, 'sp_teams', array() ) );
|
||||
update_post_meta( $post_id, 'sp_teams', sportspress_array_value( $_POST, 'sp_teams', array() ) );
|
||||
|
||||
// Update season taxonomy
|
||||
wp_set_post_terms( $post_id, sp_array_value( $_POST, 'sp_season', 0 ), 'sp_season' );
|
||||
wp_set_post_terms( $post_id, sportspress_array_value( $_POST, 'sp_season', 0 ), 'sp_season' );
|
||||
|
||||
// Update team array
|
||||
sp_update_post_meta_recursive( $post_id, 'sp_team', sp_array_value( $_POST, 'sp_team', array() ) );
|
||||
sportspress_update_post_meta_recursive( $post_id, 'sp_team', sportspress_array_value( $_POST, 'sp_team', array() ) );
|
||||
|
||||
break;
|
||||
|
||||
case ( 'sp_list' ):
|
||||
|
||||
// Update players array
|
||||
update_post_meta( $post_id, 'sp_players', sp_array_value( $_POST, 'sp_players', array() ) );
|
||||
update_post_meta( $post_id, 'sp_players', sportspress_array_value( $_POST, 'sp_players', array() ) );
|
||||
|
||||
// Update team array
|
||||
update_post_meta( $post_id, 'sp_team', sp_array_value( $_POST, 'sp_team', array() ) );
|
||||
update_post_meta( $post_id, 'sp_team', sportspress_array_value( $_POST, 'sp_team', array() ) );
|
||||
|
||||
// Update season taxonomy
|
||||
wp_set_post_terms( $post_id, sp_array_value( $_POST, 'sp_season', 0 ), 'sp_season' );
|
||||
wp_set_post_terms( $post_id, sportspress_array_value( $_POST, 'sp_season', 0 ), 'sp_season' );
|
||||
|
||||
//Update player array
|
||||
sp_update_post_meta_recursive( $post_id, 'sp_player', sp_array_value( $_POST, 'sp_player', array() ) );
|
||||
sportspress_update_post_meta_recursive( $post_id, 'sp_player', sportspress_array_value( $_POST, 'sp_player', array() ) );
|
||||
|
||||
break;
|
||||
|
||||
endswitch;
|
||||
}
|
||||
add_action( 'save_post', 'sp_save_post' );
|
||||
add_action( 'save_post', 'sportspress_save_post' );
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
function sp_admin_post_thumbnail_html( $translated_text, $post_id ) {
|
||||
function sportspress_admin_post_thumbnail_html( $translated_text, $post_id ) {
|
||||
$texts = array(
|
||||
'sp_team' => array(
|
||||
'Set featured image' => 'Select Logo',
|
||||
@@ -23,4 +23,4 @@ function sp_admin_post_thumbnail_html( $translated_text, $post_id ) {
|
||||
endif;
|
||||
return $translated_text;
|
||||
}
|
||||
add_filter( 'admin_post_thumbnail_html', 'sp_admin_post_thumbnail_html', 10, 2 );
|
||||
add_filter( 'admin_post_thumbnail_html', 'sportspress_admin_post_thumbnail_html', 10, 2 );
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
function sp_gettext( $translated_text, $untranslated_text, $domain ) {
|
||||
function sportspress_gettext( $translated_text, $untranslated_text, $domain ) {
|
||||
global $typenow;
|
||||
|
||||
$texts = array(
|
||||
@@ -40,4 +40,4 @@ function sp_gettext( $translated_text, $untranslated_text, $domain ) {
|
||||
else
|
||||
return $translated_text;
|
||||
}
|
||||
add_filter( 'gettext', 'sp_gettext', 20, 3 );
|
||||
add_filter( 'gettext', 'sportspress_gettext', 20, 3 );
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
function sp_pre_get_posts( $wp_query ) {
|
||||
function sportspress_pre_get_posts( $wp_query ) {
|
||||
if ( is_admin() ):
|
||||
$post_type = $wp_query->query['post_type'];
|
||||
|
||||
@@ -12,4 +12,4 @@ function sp_pre_get_posts( $wp_query ) {
|
||||
endif;
|
||||
endif;
|
||||
}
|
||||
add_filter('pre_get_posts', 'sp_pre_get_posts');
|
||||
add_filter('pre_get_posts', 'sportspress_pre_get_posts');
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
function sp_sanitize_title( $title ) {
|
||||
function sportspress_sanitize_title( $title ) {
|
||||
|
||||
if ( isset( $_POST ) && array_key_exists( 'post_type', $_POST ) && in_array( $_POST['post_type'], array( 'sp_result', 'sp_outcome', 'sp_column', 'sp_statistic' ) ) ):
|
||||
|
||||
@@ -7,7 +7,7 @@ function sp_sanitize_title( $title ) {
|
||||
|
||||
if ( ! $key ) $key = $_POST['post_title'];
|
||||
|
||||
$title = sp_get_eos_safe_slug( $key, sp_array_value( $_POST, 'ID', 'var' ) );
|
||||
$title = sportspress_get_eos_safe_slug( $key, sportspress_array_value( $_POST, 'ID', 'var' ) );
|
||||
|
||||
elseif ( isset( $_POST ) && array_key_exists( 'post_type', $_POST ) && $_POST['post_type'] == 'sp_event' ):
|
||||
|
||||
@@ -22,4 +22,4 @@ function sp_sanitize_title( $title ) {
|
||||
|
||||
return $title;
|
||||
}
|
||||
add_filter( 'sanitize_title', 'sp_sanitize_title' );
|
||||
add_filter( 'sanitize_title', 'sportspress_sanitize_title' );
|
||||
|
||||
@@ -7,14 +7,14 @@ function sportspress_the_content( $content ) {
|
||||
global $post;
|
||||
|
||||
// Display league table
|
||||
$content .= '<p>' . sp_get_table_html( $post->ID ) . '</p>';
|
||||
$content .= '<p>' . sportspress_league_table( $post->ID ) . '</p>';
|
||||
|
||||
elseif ( is_singular( 'sp_list' ) && in_the_loop() ):
|
||||
|
||||
global $post;
|
||||
|
||||
// Display player list
|
||||
$content .= '<p>' . sp_get_list_html( $post->ID ) . '</p>';
|
||||
$content .= '<p>' . sportspress_player_list( $post->ID ) . '</p>';
|
||||
|
||||
endif;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
function sp_insert_post_data( $data, $postarr ) {
|
||||
function sportspress_insert_post_data( $data, $postarr ) {
|
||||
|
||||
if( $data['post_type'] == 'sp_event' && $data['post_title'] == '' ):
|
||||
|
||||
@@ -16,4 +16,4 @@ function sp_insert_post_data( $data, $postarr ) {
|
||||
|
||||
return $data;
|
||||
}
|
||||
add_filter( 'wp_insert_post_data' , 'sp_insert_post_data' , '99', 2 );
|
||||
add_filter( 'wp_insert_post_data' , 'sportspress_insert_post_data' , '99', 2 );
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<?php
|
||||
function sp_column_cpt_init() {
|
||||
function sportspress_column_post_init() {
|
||||
$name = __( 'Table Columns', 'sportspress' );
|
||||
$singular_name = __( 'Table Column', 'sportspress' );
|
||||
$lowercase_name = __( 'table columns', 'sportspress' );
|
||||
$labels = sp_cpt_labels( $name, $singular_name, $lowercase_name, true );
|
||||
$labels = sportspress_get_post_labels( $name, $singular_name, $lowercase_name, true );
|
||||
$args = array(
|
||||
'label' => $name,
|
||||
'labels' => $labels,
|
||||
@@ -17,7 +17,7 @@ function sp_column_cpt_init() {
|
||||
);
|
||||
register_post_type( 'sp_column', $args );
|
||||
}
|
||||
add_action( 'init', 'sp_column_cpt_init' );
|
||||
add_action( 'init', 'sportspress_column_post_init' );
|
||||
|
||||
function sp_column_edit_columns() {
|
||||
$columns = array(
|
||||
@@ -37,7 +37,7 @@ function sp_column_meta_init() {
|
||||
}
|
||||
|
||||
function sp_column_details_meta( $post ) {
|
||||
$formats = sp_get_config_formats();
|
||||
$formats = sportspress_get_config_formats();
|
||||
|
||||
$equation = explode( ' ', get_post_meta( $post->ID, 'sp_equation', true ) );
|
||||
$order = get_post_meta( $post->ID, 'sp_order', true );
|
||||
@@ -69,7 +69,7 @@ function sp_column_details_meta( $post ) {
|
||||
<p class="sp-equation-selector">
|
||||
<?php
|
||||
foreach ( $equation as $piece ):
|
||||
sp_get_equation_selector( $post->ID, $piece, array( 'team_event', 'result', 'outcome' ) );
|
||||
sportspress_get_equation_selector( $post->ID, $piece, array( 'team_event', 'result', 'outcome' ) );
|
||||
endforeach;
|
||||
?>
|
||||
</p>
|
||||
@@ -93,5 +93,5 @@ function sp_column_details_meta( $post ) {
|
||||
</select>
|
||||
</p>
|
||||
<?php
|
||||
sp_nonce();
|
||||
sportspress_nonce();
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<?php
|
||||
function sp_event_cpt_init() {
|
||||
function sportspress_event_post_init() {
|
||||
$name = __( 'Events', 'sportspress' );
|
||||
$singular_name = __( 'Event', 'sportspress' );
|
||||
$lowercase_name = __( 'events', 'sportspress' );
|
||||
$labels = sp_cpt_labels( $name, $singular_name, $lowercase_name );
|
||||
$labels = sportspress_get_post_labels( $name, $singular_name, $lowercase_name );
|
||||
$args = array(
|
||||
'label' => $name,
|
||||
'labels' => $labels,
|
||||
@@ -17,7 +17,7 @@ function sp_event_cpt_init() {
|
||||
);
|
||||
register_post_type( 'sp_event', $args );
|
||||
}
|
||||
add_action( 'init', 'sp_event_cpt_init' );
|
||||
add_action( 'init', 'sportspress_event_post_init' );
|
||||
|
||||
function sp_event_display_scheduled( $posts ) {
|
||||
global $wp_query, $wpdb;
|
||||
@@ -65,8 +65,8 @@ function sp_event_team_meta( $post ) {
|
||||
<li class="wp-tab"><a href="#sp_staff-all"><?php _e( 'Staff', 'sportspress' ); ?></a></li>
|
||||
</ul>
|
||||
<?php
|
||||
sp_post_checklist( $post->ID, 'sp_player', 'block', 'sp_team', $key );
|
||||
sp_post_checklist( $post->ID, 'sp_staff', 'none', 'sp_team', $key );
|
||||
sportspress_post_checklist( $post->ID, 'sp_player', 'block', 'sp_team', $key );
|
||||
sportspress_post_checklist( $post->ID, 'sp_staff', 'none', 'sp_team', $key );
|
||||
?>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
@@ -85,8 +85,8 @@ function sp_event_team_meta( $post ) {
|
||||
</p>
|
||||
</div>
|
||||
<?php
|
||||
sp_post_adder( 'sp_team' );
|
||||
sp_nonce();
|
||||
sportspress_post_adder( 'sp_team' );
|
||||
sportspress_nonce();
|
||||
}
|
||||
|
||||
function sp_event_players_meta( $post ) {
|
||||
@@ -94,19 +94,19 @@ function sp_event_players_meta( $post ) {
|
||||
$stats = (array)get_post_meta( $post->ID, 'sp_players', true );
|
||||
|
||||
// Get columns from result variables
|
||||
$columns = sp_get_var_labels( 'sp_statistic', true );
|
||||
$columns = sportspress_get_var_labels( 'sp_statistic', true );
|
||||
|
||||
foreach ( $teams as $key => $team_id ):
|
||||
if ( ! $team_id ) continue;
|
||||
|
||||
// Get results for players in the team
|
||||
$players = sp_array_between( (array)get_post_meta( $post->ID, 'sp_player', false ), 0, $key );
|
||||
$data = sp_array_combine( $players, sp_array_value( $stats, $team_id, array() ) );
|
||||
$players = sportspress_array_between( (array)get_post_meta( $post->ID, 'sp_player', false ), 0, $key );
|
||||
$data = sportspress_array_combine( $players, sportspress_array_value( $stats, $team_id, array() ) );
|
||||
|
||||
?>
|
||||
<div>
|
||||
<p><strong><?php echo get_the_title( $team_id ); ?></strong></p>
|
||||
<?php sp_event_players_table( $columns, $data, $team_id ); ?>
|
||||
<?php sportspress_event_players_table( $columns, $data, $team_id ); ?>
|
||||
</div>
|
||||
<?php
|
||||
|
||||
@@ -120,14 +120,14 @@ function sp_event_results_meta( $post ) {
|
||||
$results = (array)get_post_meta( $post->ID, 'sp_results', true );
|
||||
|
||||
// Get columns from result variables
|
||||
$columns = sp_get_var_labels( 'sp_result' );
|
||||
$columns = sportspress_get_var_labels( 'sp_result' );
|
||||
|
||||
// Get results for all teams
|
||||
$data = sp_array_combine( $teams, $results );
|
||||
$data = sportspress_array_combine( $teams, $results );
|
||||
|
||||
?>
|
||||
<div>
|
||||
<?php sp_event_results_table( $columns, $data ); ?>
|
||||
<?php sportspress_edit_event_results_table( $columns, $data ); ?>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<?php
|
||||
function sp_list_cpt_init() {
|
||||
function sportspress_list_post_init() {
|
||||
$name = __( 'Player Lists', 'sportspress' );
|
||||
$singular_name = __( 'Player List', 'sportspress' );
|
||||
$lowercase_name = __( 'player lists', 'sportspress' );
|
||||
$labels = sp_cpt_labels( $name, $singular_name, $lowercase_name, true );
|
||||
$labels = sportspress_get_post_labels( $name, $singular_name, $lowercase_name, true );
|
||||
$args = array(
|
||||
'label' => $name,
|
||||
'labels' => $labels,
|
||||
@@ -17,7 +17,7 @@ function sp_list_cpt_init() {
|
||||
);
|
||||
register_post_type( 'sp_list', $args );
|
||||
}
|
||||
add_action( 'init', 'sp_list_cpt_init' );
|
||||
add_action( 'init', 'sportspress_list_post_init' );
|
||||
|
||||
function sp_list_edit_columns() {
|
||||
$columns = array(
|
||||
@@ -42,7 +42,7 @@ function sp_list_meta_init( $post ) {
|
||||
}
|
||||
|
||||
function sp_list_player_meta( $post ) {
|
||||
$season_id = sp_get_the_term_id( $post->ID, 'sp_season', 0 );
|
||||
$season_id = sportspress_get_the_term_id( $post->ID, 'sp_season', 0 );
|
||||
$team_id = get_post_meta( $post->ID, 'sp_team', true );
|
||||
?>
|
||||
<div>
|
||||
@@ -54,7 +54,7 @@ function sp_list_player_meta( $post ) {
|
||||
'selected' => $season_id,
|
||||
'value' => 'term_id'
|
||||
);
|
||||
sp_dropdown_taxonomies( $args );
|
||||
sportspress_dropdown_taxonomies( $args );
|
||||
?>
|
||||
</p>
|
||||
<p class="sp-tab-select">
|
||||
@@ -68,18 +68,18 @@ function sp_list_player_meta( $post ) {
|
||||
?>
|
||||
</p>
|
||||
<?php
|
||||
sp_post_checklist( $post->ID, 'sp_player', 'block', 'sp_team' );
|
||||
sp_post_adder( 'sp_player' );
|
||||
sportspress_post_checklist( $post->ID, 'sp_player', 'block', 'sp_team' );
|
||||
sportspress_post_adder( 'sp_player' );
|
||||
?>
|
||||
</div>
|
||||
<?php
|
||||
sp_nonce();
|
||||
sportspress_nonce();
|
||||
}
|
||||
|
||||
function sp_list_stats_meta( $post ) {
|
||||
|
||||
list( $columns, $data, $placeholders, $merged ) = sp_get_list( $post->ID, true );
|
||||
list( $columns, $data, $placeholders, $merged ) = sportspress_get_list( $post->ID, true );
|
||||
|
||||
sp_player_table( $columns, $data, $placeholders );
|
||||
sp_nonce();
|
||||
sportspress_edit_player_table( $columns, $data, $placeholders );
|
||||
sportspress_nonce();
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<?php
|
||||
function sp_outcome_cpt_init() {
|
||||
function sportspress_outcome_post_init() {
|
||||
$name = __( 'Outcomes', 'sportspress' );
|
||||
$singular_name = __( 'Outcome', 'sportspress' );
|
||||
$lowercase_name = __( 'outcome', 'sportspress' );
|
||||
$labels = sp_cpt_labels( $name, $singular_name, $lowercase_name, true );
|
||||
$labels = sportspress_get_post_labels( $name, $singular_name, $lowercase_name, true );
|
||||
$args = array(
|
||||
'label' => $name,
|
||||
'labels' => $labels,
|
||||
@@ -17,7 +17,7 @@ function sp_outcome_cpt_init() {
|
||||
);
|
||||
register_post_type( 'sp_outcome', $args );
|
||||
}
|
||||
add_action( 'init', 'sp_outcome_cpt_init' );
|
||||
add_action( 'init', 'sportspress_outcome_post_init' );
|
||||
|
||||
function sp_outcome_edit_columns() {
|
||||
$columns = array(
|
||||
@@ -40,5 +40,5 @@ function sp_outcome_details_meta( $post ) {
|
||||
<input name="sp_key" type="text" id="sp_key" value="<?php echo $post->post_name; ?>">
|
||||
</p>
|
||||
<?php
|
||||
sp_nonce();
|
||||
sportspress_nonce();
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<?php
|
||||
function sp_player_cpt_init() {
|
||||
function sportspress_player_post_init() {
|
||||
$name = __( 'Players', 'sportspress' );
|
||||
$singular_name = __( 'Player', 'sportspress' );
|
||||
$lowercase_name = __( 'players', 'sportspress' );
|
||||
$labels = sp_cpt_labels( $name, $singular_name, $lowercase_name );
|
||||
$labels = sportspress_get_post_labels( $name, $singular_name, $lowercase_name );
|
||||
$args = array(
|
||||
'label' => $name,
|
||||
'labels' => $labels,
|
||||
@@ -17,7 +17,7 @@ function sp_player_cpt_init() {
|
||||
);
|
||||
register_post_type( 'sp_player', $args );
|
||||
}
|
||||
add_action( 'init', 'sp_player_cpt_init' );
|
||||
add_action( 'init', 'sportspress_player_post_init' );
|
||||
|
||||
function sp_player_edit_columns() {
|
||||
$columns = array(
|
||||
@@ -51,8 +51,8 @@ function sp_player_meta_init( $post ) {
|
||||
}
|
||||
|
||||
function sp_player_team_meta( $post ) {
|
||||
sp_post_checklist( $post->ID, 'sp_team' );
|
||||
sp_post_adder( 'sp_team' );
|
||||
sportspress_post_checklist( $post->ID, 'sp_team' );
|
||||
sportspress_post_adder( 'sp_team' );
|
||||
}
|
||||
|
||||
function sp_player_stats_meta( $post ) {
|
||||
@@ -64,7 +64,7 @@ function sp_player_stats_meta( $post ) {
|
||||
$eos = new eqEOS();
|
||||
|
||||
// Get labels from statistic variables
|
||||
$statistic_labels = (array)sp_get_var_labels( 'sp_statistic' );
|
||||
$statistic_labels = (array)sportspress_get_var_labels( 'sp_statistic' );
|
||||
|
||||
// Generate array of all league ids
|
||||
$div_ids = array();
|
||||
@@ -93,10 +93,10 @@ function sp_player_stats_meta( $post ) {
|
||||
$data = array();
|
||||
|
||||
// Get all leagues populated with stats where available
|
||||
$data[ $team_id ] = sp_array_combine( $div_ids, sp_array_value( $stats, $team_id, array() ) );
|
||||
$data[ $team_id ] = sportspress_array_combine( $div_ids, sportspress_array_value( $stats, $team_id, array() ) );
|
||||
|
||||
// Get equations from statistics variables
|
||||
$equations = sp_get_var_equations( 'sp_statistic' );
|
||||
$equations = sportspress_get_var_equations( 'sp_statistic' );
|
||||
|
||||
foreach ( $div_ids as $div_id ):
|
||||
|
||||
@@ -135,9 +135,9 @@ function sp_player_stats_meta( $post ) {
|
||||
$totals['eventsplayed']++; // TODO: create tab for substitutes in sidebar
|
||||
$team_statistics = (array)get_post_meta( $event->ID, 'sp_players', true );
|
||||
if ( array_key_exists( $team_id, $team_statistics ) ):
|
||||
$players = sp_array_value( $team_statistics, $team_id, array() );
|
||||
$players = sportspress_array_value( $team_statistics, $team_id, array() );
|
||||
if ( array_key_exists( $post->ID, $players ) ):
|
||||
$player_statistics = sp_array_value( $players, $post->ID, array() );
|
||||
$player_statistics = sportspress_array_value( $players, $post->ID, array() );
|
||||
foreach ( $player_statistics as $key => $value ):
|
||||
if ( array_key_exists( $key, $totals ) ):
|
||||
$totals[ $key ] += $value;
|
||||
@@ -154,13 +154,13 @@ function sp_player_stats_meta( $post ) {
|
||||
if ( empty( $value ) ):
|
||||
|
||||
// Reflect totals
|
||||
$placeholders[ $team_id ][ $div_id ][ $key ] = sp_array_value( $totals, $key, 0 );
|
||||
$placeholders[ $team_id ][ $div_id ][ $key ] = sportspress_array_value( $totals, $key, 0 );
|
||||
|
||||
else:
|
||||
|
||||
// Calculate value
|
||||
if ( sizeof( $events ) > 0 ):
|
||||
$placeholders[ $team_id ][ $div_id ][ $key ] = sp_solve( $value, $totals );
|
||||
$placeholders[ $team_id ][ $div_id ][ $key ] = sportspress_solve( $value, $totals );
|
||||
else:
|
||||
$placeholders[ $team_id ][ $div_id ][ $key ] = 0;
|
||||
endif;
|
||||
@@ -172,7 +172,7 @@ function sp_player_stats_meta( $post ) {
|
||||
endforeach;
|
||||
|
||||
// Get columns from statistics variables
|
||||
$columns = sp_get_var_labels( 'sp_statistic' );
|
||||
$columns = sportspress_get_var_labels( 'sp_statistic' );
|
||||
|
||||
if ( $team_num > 1 ):
|
||||
?>
|
||||
@@ -180,7 +180,7 @@ function sp_player_stats_meta( $post ) {
|
||||
<?php
|
||||
endif;
|
||||
|
||||
sp_player_statistics_table( $columns, $data, $placeholders );
|
||||
sportspress_edit_player_statistics_table( $columns, $data, $placeholders );
|
||||
|
||||
endforeach;
|
||||
}
|
||||
@@ -222,9 +222,9 @@ function sp_player_details_meta( $post ) {
|
||||
?>
|
||||
<p><strong><?php echo $var->post_title; ?></strong></p>
|
||||
<p>
|
||||
<input name="sp_details[<?php echo $var->post_name; ?>]" type="text" value="<?php echo sp_array_value( $details, $var->post_name, ''); ?>">
|
||||
<input name="sp_details[<?php echo $var->post_name; ?>]" type="text" value="<?php echo sportspress_array_value( $details, $var->post_name, ''); ?>">
|
||||
</p>
|
||||
<?php
|
||||
endforeach;
|
||||
sp_nonce();
|
||||
sportspress_nonce();
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<?php
|
||||
function sp_result_cpt_init() {
|
||||
function sportspress_result_post_init() {
|
||||
$name = __( 'Results', 'sportspress' );
|
||||
$singular_name = __( 'Result', 'sportspress' );
|
||||
$lowercase_name = __( 'result', 'sportspress' );
|
||||
$labels = sp_cpt_labels( $name, $singular_name, $lowercase_name, true );
|
||||
$labels = sportspress_get_post_labels( $name, $singular_name, $lowercase_name, true );
|
||||
$args = array(
|
||||
'label' => $name,
|
||||
'labels' => $labels,
|
||||
@@ -17,7 +17,7 @@ function sp_result_cpt_init() {
|
||||
);
|
||||
register_post_type( 'sp_result', $args );
|
||||
}
|
||||
add_action( 'init', 'sp_result_cpt_init' );
|
||||
add_action( 'init', 'sportspress_result_post_init' );
|
||||
|
||||
function sp_result_edit_columns() {
|
||||
$columns = array(
|
||||
@@ -35,7 +35,7 @@ function sp_result_meta_init() {
|
||||
}
|
||||
|
||||
function sp_result_details_meta( $post ) {
|
||||
$formats = sp_get_config_formats();
|
||||
$formats = sportspress_get_config_formats();
|
||||
?>
|
||||
<p><strong><?php _e( 'Key', 'sportspress' ); ?></strong></p>
|
||||
<p>
|
||||
@@ -52,5 +52,5 @@ function sp_result_details_meta( $post ) {
|
||||
</select>
|
||||
</p>
|
||||
<?php
|
||||
sp_nonce();
|
||||
sportspress_nonce();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
function sp_separator_cpt_init() {
|
||||
function sportspress_separator_post_init() {
|
||||
$args = array(
|
||||
'public' => false,
|
||||
'show_ui' => true,
|
||||
@@ -7,4 +7,4 @@ function sp_separator_cpt_init() {
|
||||
);
|
||||
register_post_type( 'sp_separator', $args );
|
||||
}
|
||||
add_action( 'init', 'sp_separator_cpt_init' );
|
||||
add_action( 'init', 'sportspress_separator_post_init' );
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<?php
|
||||
function sp_staff_cpt_init() {
|
||||
function sportspress_staff_post_init() {
|
||||
$name = __( 'Staff', 'sportspress' );
|
||||
$singular_name = __( 'Staff', 'sportspress' );
|
||||
$lowercase_name = __( 'staff', 'sportspress' );
|
||||
$labels = sp_cpt_labels( $name, $singular_name, $lowercase_name );
|
||||
$labels = sportspress_get_post_labels( $name, $singular_name, $lowercase_name );
|
||||
$args = array(
|
||||
'label' => $name,
|
||||
'labels' => $labels,
|
||||
@@ -17,7 +17,7 @@ function sp_staff_cpt_init() {
|
||||
);
|
||||
register_post_type( 'sp_staff', $args );
|
||||
}
|
||||
add_action( 'init', 'sp_staff_cpt_init' );
|
||||
add_action( 'init', 'sportspress_staff_post_init' );
|
||||
|
||||
function sp_staff_meta_init() {
|
||||
remove_meta_box( 'submitdiv', 'sp_staff', 'side' );
|
||||
@@ -28,9 +28,9 @@ function sp_staff_meta_init() {
|
||||
add_meta_box( 'sp_profilediv', __( 'Profile' ), 'sp_staff_profile_meta', 'sp_staff', 'normal', 'high' );
|
||||
}
|
||||
function sp_staff_team_meta( $post ) {
|
||||
sp_post_checklist( $post->ID, 'sp_team' );
|
||||
sp_post_adder( 'sp_team' );
|
||||
sp_nonce();
|
||||
sportspress_post_checklist( $post->ID, 'sp_team' );
|
||||
sportspress_post_adder( 'sp_team' );
|
||||
sportspress_nonce();
|
||||
}
|
||||
|
||||
function sp_staff_profile_meta( $post ) {
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<?php
|
||||
function sp_statistic_cpt_init() {
|
||||
function sportspress_statistic_post_init() {
|
||||
$name = __( 'Statistics', 'sportspress' );
|
||||
$singular_name = __( 'Statistic', 'sportspress' );
|
||||
$lowercase_name = __( 'statistics', 'sportspress' );
|
||||
$labels = sp_cpt_labels( $name, $singular_name, $lowercase_name, true );
|
||||
$labels = sportspress_get_post_labels( $name, $singular_name, $lowercase_name, true );
|
||||
$args = array(
|
||||
'label' => $name,
|
||||
'labels' => $labels,
|
||||
@@ -17,7 +17,7 @@ function sp_statistic_cpt_init() {
|
||||
);
|
||||
register_post_type( 'sp_statistic', $args );
|
||||
}
|
||||
add_action( 'init', 'sp_statistic_cpt_init' );
|
||||
add_action( 'init', 'sportspress_statistic_post_init' );
|
||||
|
||||
function sp_statistic_edit_columns() {
|
||||
$columns = array(
|
||||
@@ -37,7 +37,7 @@ function sp_statistic_meta_init() {
|
||||
}
|
||||
|
||||
function sp_statistic_equation_meta( $post ) {
|
||||
$formats = sp_get_config_formats();
|
||||
$formats = sportspress_get_config_formats();
|
||||
|
||||
$equation = explode( ' ', get_post_meta( $post->ID, 'sp_equation', true ) );
|
||||
$order = get_post_meta( $post->ID, 'sp_order', true );
|
||||
@@ -69,7 +69,7 @@ function sp_statistic_equation_meta( $post ) {
|
||||
<p class="sp-equation-selector">
|
||||
<?php
|
||||
foreach ( $equation as $piece ):
|
||||
sp_get_equation_selector( $post->ID, $piece, array( 'player_event' ) );
|
||||
sportspress_get_equation_selector( $post->ID, $piece, array( 'player_event' ) );
|
||||
endforeach;
|
||||
?>
|
||||
</p>
|
||||
@@ -93,5 +93,5 @@ function sp_statistic_equation_meta( $post ) {
|
||||
</select>
|
||||
</p>
|
||||
<?php
|
||||
sp_nonce();
|
||||
sportspress_nonce();
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<?php
|
||||
function sp_table_cpt_init() {
|
||||
function sportspress_table_post_init() {
|
||||
$name = __( 'League Tables', 'sportspress' );
|
||||
$singular_name = __( 'League Table', 'sportspress' );
|
||||
$lowercase_name = __( 'league tables', 'sportspress' );
|
||||
$labels = sp_cpt_labels( $name, $singular_name, $lowercase_name, true );
|
||||
$labels = sportspress_get_post_labels( $name, $singular_name, $lowercase_name, true );
|
||||
$args = array(
|
||||
'label' => $name,
|
||||
'labels' => $labels,
|
||||
@@ -17,7 +17,7 @@ function sp_table_cpt_init() {
|
||||
);
|
||||
register_post_type( 'sp_table', $args );
|
||||
}
|
||||
add_action( 'init', 'sp_table_cpt_init' );
|
||||
add_action( 'init', 'sportspress_table_post_init' );
|
||||
|
||||
function sp_table_edit_columns() {
|
||||
$columns = array(
|
||||
@@ -41,7 +41,7 @@ function sp_table_meta_init( $post ) {
|
||||
}
|
||||
|
||||
function sp_table_team_meta( $post, $test ) {
|
||||
$league_id = sp_get_the_term_id( $post->ID, 'sp_season', 0 );
|
||||
$league_id = sportspress_get_the_term_id( $post->ID, 'sp_season', 0 );
|
||||
?>
|
||||
<div>
|
||||
<p class="sp-tab-select">
|
||||
@@ -52,23 +52,23 @@ function sp_table_team_meta( $post, $test ) {
|
||||
'selected' => $league_id,
|
||||
'value' => 'term_id'
|
||||
);
|
||||
sp_dropdown_taxonomies( $args );
|
||||
sportspress_dropdown_taxonomies( $args );
|
||||
?>
|
||||
</p>
|
||||
<?php
|
||||
sp_post_checklist( $post->ID, 'sp_team', 'block', 'sp_season' );
|
||||
sp_post_adder( 'sp_team' );
|
||||
sportspress_post_checklist( $post->ID, 'sp_team', 'block', 'sp_season' );
|
||||
sportspress_post_adder( 'sp_team' );
|
||||
?>
|
||||
</div>
|
||||
<?php
|
||||
sp_nonce();
|
||||
sportspress_nonce();
|
||||
}
|
||||
|
||||
function sp_table_columns_meta( $post ) {
|
||||
|
||||
list( $columns, $data, $placeholders, $merged ) = sp_get_table( $post->ID, true );
|
||||
list( $columns, $data, $placeholders, $merged ) = sportspress_get_table( $post->ID, true );
|
||||
|
||||
sp_league_table( $columns, $data, $placeholders );
|
||||
sportspress_edit_league_table( $columns, $data, $placeholders );
|
||||
|
||||
sp_nonce();
|
||||
sportspress_nonce();
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<?php
|
||||
function sp_team_cpt_init() {
|
||||
function sportspress_team_post_init() {
|
||||
$name = __( 'Teams', 'sportspress' );
|
||||
$singular_name = __( 'Team', 'sportspress' );
|
||||
$lowercase_name = __( 'teams', 'sportspress' );
|
||||
$labels = sp_cpt_labels( $name, $singular_name, $lowercase_name );
|
||||
$labels = sportspress_get_post_labels( $name, $singular_name, $lowercase_name );
|
||||
$args = array(
|
||||
'label' => $name,
|
||||
'labels' => $labels,
|
||||
@@ -17,7 +17,7 @@ function sp_team_cpt_init() {
|
||||
);
|
||||
register_post_type( 'sp_team', $args );
|
||||
}
|
||||
add_action( 'init', 'sp_team_cpt_init' );
|
||||
add_action( 'init', 'sportspress_team_post_init' );
|
||||
|
||||
function sp_team_meta_init( $post ) {
|
||||
$leagues = (array)get_the_terms( $post->ID, 'sp_season' );
|
||||
@@ -51,10 +51,10 @@ function sp_team_columns_meta( $post ) {
|
||||
$eos = new eqEOS();
|
||||
|
||||
// Get labels from result variables
|
||||
$result_labels = (array)sp_get_var_labels( 'sp_result' );
|
||||
$result_labels = (array)sportspress_get_var_labels( 'sp_result' );
|
||||
|
||||
// Get labels from outcome variables
|
||||
$outcome_labels = (array)sp_get_var_labels( 'sp_outcome' );
|
||||
$outcome_labels = (array)sportspress_get_var_labels( 'sp_outcome' );
|
||||
|
||||
// Generate array of all league ids
|
||||
$div_ids = array();
|
||||
@@ -64,10 +64,10 @@ function sp_team_columns_meta( $post ) {
|
||||
endforeach;
|
||||
|
||||
// Get all leagues populated with columns where available
|
||||
$data = sp_array_combine( $div_ids, $columns );
|
||||
$data = sportspress_array_combine( $div_ids, $columns );
|
||||
|
||||
// Get equations from column variables
|
||||
$equations = sp_get_var_equations( 'sp_column' );
|
||||
$equations = sportspress_get_var_equations( 'sp_column' );
|
||||
|
||||
// Initialize placeholders array
|
||||
$placeholders = array();
|
||||
@@ -161,7 +161,7 @@ function sp_team_columns_meta( $post ) {
|
||||
$placeholders[ $div_id ] = array();
|
||||
foreach ( $equations as $key => $value ):
|
||||
if ( $totals['eventsplayed'] > 0 ):
|
||||
$placeholders[ $div_id ][ $key ] = sp_solve( $value, $totals );
|
||||
$placeholders[ $div_id ][ $key ] = sportspress_solve( $value, $totals );
|
||||
else:
|
||||
$placeholders[ $div_id ][ $key ] = 0;
|
||||
endif;
|
||||
@@ -170,8 +170,8 @@ function sp_team_columns_meta( $post ) {
|
||||
endforeach;
|
||||
|
||||
// Get columns from statistics variables
|
||||
$columns = sp_get_var_labels( 'sp_column' );
|
||||
$columns = sportspress_get_var_labels( 'sp_column' );
|
||||
|
||||
sp_team_columns_table( $columns, $data, $placeholders );
|
||||
sp_nonce();
|
||||
sportspress_edit_team_columns_table( $columns, $data, $placeholders );
|
||||
sportspress_nonce();
|
||||
}
|
||||
|
||||
@@ -23,9 +23,9 @@
|
||||
<tr<?php if ( $i % 2 == 0 ) echo ' class="alternate"'; ?>>
|
||||
<td class="row-title"><?php echo $row->post_title; ?></td>
|
||||
<td><?php echo $row->post_name; ?></td>
|
||||
<td><?php echo sp_get_post_format( $row->ID ); ?></td>
|
||||
<td><?php echo sp_get_post_equation( $row->ID ); ?></td>
|
||||
<td><?php echo sp_get_post_order( $row->ID ); ?></td>
|
||||
<td><?php echo sportspress_get_post_format( $row->ID ); ?></td>
|
||||
<td><?php echo sportspress_get_post_equation( $row->ID ); ?></td>
|
||||
<td><?php echo sportspress_get_post_order( $row->ID ); ?></td>
|
||||
</tr>
|
||||
<?php $i++; endforeach; ?>
|
||||
<tfoot>
|
||||
@@ -60,9 +60,9 @@
|
||||
<tr<?php if ( $i % 2 == 0 ) echo ' class="alternate"'; ?>>
|
||||
<td class="row-title"><?php echo $row->post_title; ?></td>
|
||||
<td><?php echo $row->post_name; ?></td>
|
||||
<td><?php echo sp_get_post_format( $row->ID ); ?></td>
|
||||
<td><?php echo sp_get_post_equation( $row->ID ); ?></td>
|
||||
<td><?php echo sp_get_post_order( $row->ID ); ?></td>
|
||||
<td><?php echo sportspress_get_post_format( $row->ID ); ?></td>
|
||||
<td><?php echo sportspress_get_post_equation( $row->ID ); ?></td>
|
||||
<td><?php echo sportspress_get_post_order( $row->ID ); ?></td>
|
||||
</tr>
|
||||
<?php $i++; endforeach; ?>
|
||||
<tfoot>
|
||||
@@ -97,7 +97,7 @@
|
||||
<tr<?php if ( $i % 2 == 0 ) echo ' class="alternate"'; ?>>
|
||||
<td class="row-title"><?php echo $row->post_title; ?></td>
|
||||
<td><?php echo $row->post_name; ?></td>
|
||||
<td><?php echo sp_get_post_format( $row->ID ); ?></td>
|
||||
<td><?php echo sportspress_get_post_format( $row->ID ); ?></td>
|
||||
<td>—</td>
|
||||
<td>—</td>
|
||||
</tr>
|
||||
|
||||
@@ -1,17 +1,4 @@
|
||||
<?php
|
||||
function sportspress_admin_menu() {
|
||||
|
||||
add_options_page(
|
||||
__( 'SportsPress', 'sportspress' ),
|
||||
__( 'SportsPress', 'sportspress' ),
|
||||
'manage_options',
|
||||
'sportspress',
|
||||
'sportspress_settings'
|
||||
);
|
||||
|
||||
}
|
||||
add_action( 'admin_menu', 'sportspress_admin_menu' );
|
||||
|
||||
function sportspress_settings() {
|
||||
|
||||
$active_tab = isset( $_GET[ 'tab' ] ) ? $_GET[ 'tab' ] : 'general';
|
||||
@@ -45,7 +32,7 @@ function sportspress_validate( $input ) {
|
||||
$options = get_option( 'sportspress' );
|
||||
|
||||
// Do nothing if sport is the same as currently selected
|
||||
if ( sp_array_value( $options, 'sport', null ) == sp_array_value( $input, 'sport', null ) )
|
||||
if ( sportspress_array_value( $options, 'sport', null ) == sportspress_array_value( $input, 'sport', null ) )
|
||||
|
||||
return $input;
|
||||
|
||||
@@ -53,7 +40,7 @@ function sportspress_validate( $input ) {
|
||||
global $sportspress_sports;
|
||||
|
||||
// Get array of post types to insert
|
||||
$post_groups = sp_array_value( sp_array_value( $sportspress_sports, sp_array_value( $input, 'sport', null ), array() ), 'posts', array() );
|
||||
$post_groups = sportspress_array_value( sportspress_array_value( $sportspress_sports, sportspress_array_value( $input, 'sport', null ), array() ), 'posts', array() );
|
||||
|
||||
// Loop through each post type
|
||||
foreach( $post_groups as $post_type => $posts ):
|
||||
@@ -117,32 +104,6 @@ function sportspress_validate( $input ) {
|
||||
return $input;
|
||||
}
|
||||
|
||||
function sportspress_register_settings() {
|
||||
|
||||
register_setting(
|
||||
'sportspress_general',
|
||||
'sportspress',
|
||||
'sportspress_validate'
|
||||
);
|
||||
|
||||
add_settings_section(
|
||||
'general',
|
||||
'',
|
||||
'',
|
||||
'sportspress_general'
|
||||
);
|
||||
|
||||
add_settings_field(
|
||||
'sport',
|
||||
__( 'Sport', 'sportspress' ),
|
||||
'sportspress_sport_callback',
|
||||
'sportspress_general',
|
||||
'general'
|
||||
);
|
||||
|
||||
}
|
||||
add_action( 'admin_init', 'sportspress_register_settings' );
|
||||
|
||||
function sportspress_sport_callback() {
|
||||
global $sportspress_sports;
|
||||
$options = get_option( 'sportspress' );
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
<?php
|
||||
function sp_position_term_init() {
|
||||
function sportspress_position_term_init() {
|
||||
$name = __( 'Positions', 'sportspress' );
|
||||
$singular_name = __( 'Position', 'sportspress' );
|
||||
$lowercase_name = __( 'position', 'sportspress' );
|
||||
$object_type = array( 'sp_player' );
|
||||
$labels = sp_tax_labels( $name, $singular_name, $lowercase_name );
|
||||
$labels = sportspress_get_term_labels( $name, $singular_name, $lowercase_name );
|
||||
$args = array(
|
||||
'label' => $name,
|
||||
'labels' => $labels,
|
||||
@@ -15,4 +15,4 @@ function sp_position_term_init() {
|
||||
register_taxonomy( 'sp_position', $object_type, $args );
|
||||
register_taxonomy_for_object_type( 'sp_position', 'sp_player' );
|
||||
}
|
||||
add_action( 'init', 'sp_position_term_init' );
|
||||
add_action( 'init', 'sportspress_position_term_init' );
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
<?php
|
||||
function sp_season_term_init() {
|
||||
function sportspress_season_term_init() {
|
||||
$name = __( 'Seasons', 'sportspress' );
|
||||
$singular_name = __( 'Season', 'sportspress' );
|
||||
$lowercase_name = __( 'season', 'sportspress' );
|
||||
$object_type = array( 'sp_team', 'sp_event', 'sp_player', 'sp_staff' );
|
||||
$labels = sp_tax_labels( $name, $singular_name, $lowercase_name );
|
||||
$labels = sportspress_get_term_labels( $name, $singular_name, $lowercase_name );
|
||||
$args = array(
|
||||
'label' => $name,
|
||||
'labels' => $labels,
|
||||
@@ -18,4 +18,4 @@ function sp_season_term_init() {
|
||||
register_taxonomy_for_object_type( 'sp_season', 'sp_player' );
|
||||
register_taxonomy_for_object_type( 'sp_season', 'sp_staff' );
|
||||
}
|
||||
add_action( 'init', 'sp_season_term_init' );
|
||||
add_action( 'init', 'sportspress_season_term_init' );
|
||||
|
||||
Reference in New Issue
Block a user