Clean up for initial release

This commit is contained in:
Takumi
2013-08-23 19:39:04 +10:00
parent b295248749
commit 6a55bdbaa5
7 changed files with 67 additions and 273 deletions

View File

@@ -65,12 +65,12 @@ if ( !function_exists( 'sp_num_to_letter' ) ) {
}
if ( !function_exists( 'sp_cpt_labels' ) ) {
function sp_cpt_labels( $name, $singular_name, $lowercase_name = null ) {
function sp_cpt_labels( $name, $singular_name, $lowercase_name = null, $is_submenu = false ) {
if ( !$lowercase_name ) $lowercase_name = $name;
$labels = array(
'name' => $name,
'singular_name' => $singular_name,
'all_items' => sprintf( __( 'All %s', 'sportspress' ), $name ),
'all_items' => $is_submenu ? $name : sprintf( __( 'All %s', 'sportspress' ), $name ),
'add_new_item' => sprintf( __( 'Add New %s', 'sportspress' ), $singular_name ),
'edit_item' => sprintf( __( 'Edit %s', 'sportspress' ), $singular_name ),
'new_item' => sprintf( __( 'New %s', 'sportspress' ), $singular_name ),
@@ -543,7 +543,10 @@ if ( !function_exists( 'sportspress_render_option_field' ) ) {
switch ( $type ):
case 'textarea':
echo '<textarea id="' . $group . '" name="' . $group . '[' . $name . ']" rows="10" cols="50">' . $value . '</textarea>';
echo '<textarea id="' . $name . '" name="' . $group . '[' . $name . ']" rows="10" cols="50">' . $value . '</textarea>';
break;
case 'checkbox':
echo '<input type="checkbox" id="' . $name . '" name="' . $group . '[' . $name . ']" value="1" ' . checked( 1, isset( $value ) ? $value : 0, false ) . '/>';
break;
default:
echo '<input type="text" id="' . $name . '" name="' . $group . '[' . $name . ']" value="' . $value . '" />';

Binary file not shown.

View File

@@ -2,8 +2,8 @@ msgid ""
msgstr ""
"Project-Id-Version: SportsPress 0.1\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2013-08-23 02:04+1000\n"
"PO-Revision-Date: 2013-08-23 02:06+1000\n"
"POT-Creation-Date: 2013-08-23 19:38+1000\n"
"PO-Revision-Date: 2013-08-23 19:38+1000\n"
"Last-Translator: ThemeBoy <translate@themeboy.com>\n"
"Language-Team: ThemeBoy <translate@themeboy.com>\n"
"Language: ja\n"
@@ -29,15 +29,15 @@ msgid "M j, Y @ G:i"
msgstr "Y年n月j日 @ G:i"
#: ../actions.php:54 ../actions.php:64 ../actions.php:74 ../actions.php:84
#: ../helpers.php:73 ../helpers.php:93 ../list.php:45 ../list.php:56
#: ../table.php:43
#: ../helpers.php:73 ../helpers.php:93 ../list.php:46 ../list.php:57
#: ../table.php:44
#, php-format
msgid "All %s"
msgstr "すべての%s"
#: ../actions.php:54 ../event.php:32 ../event.php:133 ../list.php:25
#: ../list.php:56 ../player.php:25 ../player.php:140 ../settings.php:188
#: ../staff.php:25 ../staff.php:43 ../table.php:24 ../table.php:32
#: ../actions.php:54 ../event.php:32 ../event.php:133 ../list.php:26
#: ../list.php:57 ../player.php:25 ../player.php:140 ../settings.php:78
#: ../staff.php:25 ../staff.php:43 ../table.php:25 ../table.php:33
#: ../team.php:3
msgid "Teams"
msgstr "チーム"
@@ -46,9 +46,9 @@ msgstr "チーム"
msgid "Positions"
msgstr "ポジション"
#: ../actions.php:74 ../event.php:134 ../league.php:3 ../list.php:26
#: ../list.php:45 ../player.php:141 ../staff.php:44 ../table.php:25
#: ../table.php:43 ../team.php:33
#: ../actions.php:74 ../event.php:134 ../league.php:3 ../list.php:27
#: ../list.php:46 ../player.php:141 ../staff.php:44 ../table.php:26
#: ../table.php:44 ../team.php:33
msgid "Leagues"
msgstr "リーグ"
@@ -57,7 +57,7 @@ msgstr "リーグ"
msgid "Sponsors"
msgstr "スポンサー"
#: ../event.php:3 ../settings.php:196
#: ../event.php:3 ../settings.php:86
msgid "Events"
msgstr "試合"
@@ -77,7 +77,7 @@ msgstr "戦評"
msgid "Results"
msgstr "結果"
#: ../event.php:35 ../player.php:26 ../settings.php:35 ../team.php:25
#: ../event.php:35 ../player.php:26 ../team.php:25
msgid "Statistics"
msgstr "成績表"
@@ -86,21 +86,21 @@ msgstr "成績表"
msgid "Select %s"
msgstr "%sを選択"
#: ../event.php:59 ../list.php:24 ../list.php:33 ../player.php:3
#: ../settings.php:204
#: ../event.php:59 ../list.php:25 ../list.php:34 ../player.php:3
#: ../settings.php:94
msgid "Players"
msgstr "選手"
#: ../event.php:60 ../settings.php:136 ../staff.php:3 ../staff.php:4
#: ../event.php:60 ../staff.php:3 ../staff.php:4
msgid "Staff"
msgstr "スタッフ"
#: ../event.php:90 ../globals.php:4 ../globals.php:7 ../table.php:93
#: ../event.php:90 ../globals.php:4 ../globals.php:7 ../table.php:94
#: ../team.php:4 ../team.php:32
msgid "Team"
msgstr "チーム"
#: ../event.php:109 ../list.php:108 ../player.php:4
#: ../event.php:109 ../list.php:109 ../player.php:4
msgid "Player"
msgstr "選手"
@@ -208,11 +208,11 @@ msgstr "リーグ"
msgid "leagues"
msgstr "リーグ"
#: ../list.php:3 ../settings.php:152
#: ../list.php:3
msgid "Player Lists"
msgstr "選手名鑑"
#: ../list.php:4 ../list.php:34
#: ../list.php:4 ../list.php:35
msgid "Player List"
msgstr "選手名鑑"
@@ -220,7 +220,7 @@ msgstr "選手名鑑"
msgid "player lists"
msgstr "選手名鑑"
#: ../list.php:23 ../table.php:23
#: ../list.php:24 ../table.php:24
msgid "Title"
msgstr "タイトル"
@@ -256,70 +256,62 @@ msgstr "SportsPress 設定"
msgid "SportsPress"
msgstr "SportsPress"
#: ../settings.php:34 ../settings.php:128
msgid "Display Options"
msgstr "表示設定"
#: ../settings.php:88
#: ../settings.php:39
msgid "P"
msgstr "P"
#: ../settings.php:89
#: ../settings.php:40
msgid "W"
msgstr "W"
#: ../settings.php:90
#: ../settings.php:41
msgid "D"
msgstr "D"
#: ../settings.php:91
#: ../settings.php:42
msgid "L"
msgstr "L"
#: ../settings.php:92
#: ../settings.php:43
msgid "F"
msgstr "F"
#: ../settings.php:93
#: ../settings.php:44
msgid "A"
msgstr "A"
#: ../settings.php:94
#: ../settings.php:45
msgid "GD"
msgstr "GD"
#: ../settings.php:95
#: ../settings.php:46
msgid "PTS"
msgstr "PTS"
#: ../settings.php:97 ../settings.php:101
#: ../settings.php:48 ../settings.php:52
msgid "Goals"
msgstr "ゴール"
#: ../settings.php:98
#: ../settings.php:49
msgid "1st Half"
msgstr "前半"
#: ../settings.php:99
#: ../settings.php:50
msgid "2nd Half"
msgstr "後半"
#: ../settings.php:102
#: ../settings.php:53
msgid "Assists"
msgstr "アシスト"
#: ../settings.php:103
#: ../settings.php:54
msgid "Yellow Cards"
msgstr "警告"
#: ../settings.php:104
#: ../settings.php:55
msgid "Red Cards"
msgstr "退場"
#: ../settings.php:144 ../table.php:3
msgid "League Tables"
msgstr "順位表"
#: ../sponsor.php:4
msgid "Sponsor"
msgstr "スポンサー"
@@ -332,7 +324,11 @@ msgstr "スポンサー"
msgid "staff"
msgstr "スタッフ"
#: ../table.php:4 ../table.php:33
#: ../table.php:3
msgid "League Tables"
msgstr "順位表"
#: ../table.php:4 ../table.php:34
msgid "League Table"
msgstr "順位表"
@@ -343,28 +339,3 @@ msgstr "順位表"
#: ../team.php:5
msgid "teams"
msgstr "チーム"
#~ msgid "Header"
#~ msgstr "ヘッダー"
#, fuzzy
#~ msgid "Select Element"
#~ msgstr "%sを選択"
#~ msgid "Auto"
#~ msgstr "自動"
#~ msgid "Tournaments"
#~ msgstr "大会"
#~ msgid "Tournament"
#~ msgstr "大会"
#~ msgid "Venues"
#~ msgstr "会場"
#~ msgid "Venue"
#~ msgstr "会場"
#~ msgid "Address"
#~ msgstr "住所"

View File

@@ -3,7 +3,7 @@ function sp_list_cpt_init() {
$name = __( 'Player Lists', 'sportspress' );
$singular_name = __( 'Player List', 'sportspress' );
$lowercase_name = __( 'player lists', 'sportspress' );
$labels = sp_cpt_labels( $name, $singular_name, $lowercase_name );
$labels = sp_cpt_labels( $name, $singular_name, $lowercase_name, true );
$args = array(
'label' => $name,
'labels' => $labels,
@@ -11,7 +11,8 @@ function sp_list_cpt_init() {
'hierarchical' => false,
'supports' => array( 'title', 'author' ),
'register_meta_box_cb' => 'sp_list_meta_init',
'rewrite' => array( 'slug' => 'list' )
'rewrite' => array( 'slug' => 'list' ),
'show_in_menu' => 'edit.php?post_type=sp_player'
);
register_post_type( 'sp_list', $args );
}

View File

@@ -12,75 +12,26 @@ function sportspress_admin_menu() {
}
add_action( 'admin_menu', 'sportspress_admin_menu' );
function sportspress_settings( $tab = '' ) {
function sportspress_settings() {
?>
<div class="wrap">
<div id="icon-themes" class="icon32"></div>
<h2><?php _e( 'SportsPress Settings', 'sportspress' ); ?></h2>
<?php settings_errors(); ?>
<?php
if( isset( $_GET[ 'tab' ] ) ) {
$tab = $_GET[ 'tab' ];
} else if( $tab == 'stats' ) {
$tab = 'stats';
} else {
$tab = 'display_options';
}
?>
<h2 class="nav-tab-wrapper">
<a href="?page=sportspress&tab=display_options" class="nav-tab <?php echo $tab == 'display_options' ? 'nav-tab-active' : ''; ?>"><?php _e( 'Display Options', 'sportspress' ); ?></a>
<a href="?page=sportspress&tab=stats" class="nav-tab <?php echo $tab == 'stats' ? 'nav-tab-active' : ''; ?>"><?php _e( 'Statistics', 'sportspress' ); ?></a>
</h2>
<form method="post" action="options.php">
<?php
if( $tab == 'display_options' ) {
settings_fields( 'sportspress_options' );
do_settings_sections( 'sportspress_options' );
} else {
settings_fields( 'sportspress_stats' );
do_settings_sections( 'sportspress_stats' );
}
submit_button();
settings_fields( 'sportspress_stats' );
do_settings_sections( 'sportspress_stats' );
submit_button();
?>
</form>
</div><!-- /.wrap -->
</div>
<?php
} // end sportspress_settings
}
/* ------------------------------------------------------------------------ *
* Setting Registration
* ------------------------------------------------------------------------ */
/**
* Provides default values for the Display Options.
*/
function sportspress_default_display_options() {
$defaults = array(
'staff' => '',
'table' => '',
'list' => ''
);
return apply_filters( 'sportspress_default_display_options', $defaults );
} // end sportspress_default_display_options
/**
* Provides default values for the Statistics.
*/
function sportspress_default_stats() {
$defaults = array(
@@ -107,80 +58,19 @@ function sportspress_default_stats() {
return apply_filters( 'sportspress_default_stats', $defaults );
} // end sportspress_default_stats
}
/**
* Initializes the theme's display options page by registering the Sections,
* Fields, and Settings.
*
* This function is registered with the 'admin_init' hook.
*/
function sportspress_initialize_theme_options() {
// If the theme options don't exist, create them.
if ( false == get_option( 'sportspress_options' ) ) {
add_option( 'sportspress_options', apply_filters( 'sportspress_default_display_options', sportspress_default_display_options() ) );
} // end if
// First, we register a section. This is necessary since all future options must belong to a
add_settings_section(
'general_settings_section', // ID used to identify this section and with which to register options
__( 'Display Options', 'sportspress' ), // Title to be displayed on the administration page
'', // Callback used to render the description of the section
'sportspress_options' // Page on which to add this section of options
);
// Next, we'll introduce the fields for toggling the visibility of content elements.
add_settings_field(
'staff', // ID used to identify the field throughout the theme
__( 'Staff', 'sportspress' ), // The label to the left of the option interface element
'sportspress_toggle_staff_callback', // The name of the function responsible for rendering the option interface
'sportspress_options', // The page on which this option will be displayed
'general_settings_section'
);
add_settings_field(
'table',
__( 'League Tables', 'sportspress' ),
'sportspress_toggle_table_callback',
'sportspress_options',
'general_settings_section'
);
add_settings_field(
'list',
__( 'Player Lists', 'sportspress' ),
'sportspress_toggle_list_callback',
'sportspress_options',
'general_settings_section'
);
// Finally, we register the fields with WordPress
register_setting(
'sportspress_options',
'sportspress_options'
);
} // end sportspress_initialize_theme_options
add_action( 'admin_init', 'sportspress_initialize_theme_options' );
/**
* Initializes the theme's social options by registering the Sections,
* Fields, and Settings.
*
* This function is registered with the 'admin_init' hook.
*/
function sportspress_intialize_stats() {
if( false == get_option( 'sportspress_stats' ) ) {
add_option( 'sportspress_stats', apply_filters( 'sportspress_default_stats', sportspress_default_stats() ) );
} // end if
}
add_settings_section(
'sportspress_stats', // ID used to identify this section and with which to register options
'', // Title to be displayed on the administration page
'', // Callback used to render the description of the section
'sportspress_stats' // Page on which to add this section of options
'sportspress_stats',
'',
'',
'sportspress_stats'
);
add_settings_field(
@@ -212,49 +102,9 @@ function sportspress_intialize_stats() {
'sportspress_stats'
);
} // end sportspress_intialize_stats
}
add_action( 'admin_init', 'sportspress_intialize_stats' );
/* ------------------------------------------------------------------------ *
* Field Callbacks
* ------------------------------------------------------------------------ */
/**
* This function renders the interface elements for toggling the visibility of the header element.
*
* It accepts an array or arguments and expects the first element in the array to be the description
* to be displayed next to the checkbox.
*/
function sportspress_toggle_staff_callback() {
$options = get_option('sportspress_options');
$html = '<input type="checkbox" id="staff" name="sportspress_options[staff]" value="1" ' . checked( 1, isset( $options['staff'] ) ? $options['staff'] : 0, false ) . '/>';
echo $html;
} // end sportspress_toggle_staff_callback
function sportspress_toggle_table_callback() {
$options = get_option('sportspress_options');
$html = '<input type="checkbox" id="show_content" name="sportspress_options[show_content]" value="1" ' . checked( 1, isset( $options['show_content'] ) ? $options['show_content'] : 0, false ) . '/>';
echo $html;
} // end sportspress_toggle_table_callback
function sportspress_toggle_list_callback() {
$options = get_option('sportspress_options');
$html = '<input type="checkbox" id="show_footer" name="sportspress_options[show_footer]" value="1" ' . checked( 1, isset( $options['show_footer'] ) ? $options['show_footer'] : 0, false ) . '/>';
echo $html;
} // end sportspress_toggle_list_callback
function sportspress_team_stats_callback() {
sportspress_render_option_field( 'sportspress_stats', 'team', 'textarea' );
}
@@ -267,36 +117,4 @@ function sportspress_player_stats_callback() {
sportspress_render_option_field( 'sportspress_stats', 'player', 'textarea' );
}
/* ------------------------------------------------------------------------ *
* Setting Callbacks
* ------------------------------------------------------------------------ */
/**
* Sanitization callback for the social options. Since each of the social options are text inputs,
* this function loops through the incoming option and strips all tags and slashes from the value
* before serializing it.
*
* @params $input The unsanitized collection of options.
*
* @returns The collection of sanitized values.
*/
function sportspress_sanitize_stats( $input ) {
// Define the array for the updated options
$output = array();
// Loop through each of the options sanitizing the data
foreach( $input as $key => $val ) {
if( isset ( $input[$key] ) ) {
$output[$key] = esc_url_raw( strip_tags( stripslashes( $input[$key] ) ) );
} // end if
} // end foreach
// Return the new collection
return apply_filters( 'sportspress_sanitize_stats', $output, $input );
} // end sportspress_sanitize_stats
?>

View File

@@ -6,7 +6,7 @@
Plugin Name: SportsPress
Plugin URI: http://sportspress.com/sportspress
Description: Currently in development.
Version: 0.1
Version: 1.0
Author: ThemeBoy
Author URI: http://sportspress.com
License: GPL2
@@ -18,7 +18,7 @@ if ( !function_exists( 'add_action' ) ) {
exit;
}
define( 'SPORTSPRESS_VERSION', '0.1' );
define( 'SPORTSPRESS_VERSION', '1.0' );
define( 'SPORTSPRESS_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
// Libraries

View File

@@ -3,7 +3,7 @@ function sp_table_cpt_init() {
$name = __( 'League Tables', 'sportspress' );
$singular_name = __( 'League Table', 'sportspress' );
$lowercase_name = __( 'league tables', 'sportspress' );
$labels = sp_cpt_labels( $name, $singular_name, $lowercase_name );
$labels = sp_cpt_labels( $name, $singular_name, $lowercase_name, true );
$args = array(
'label' => $name,
'labels' => $labels,
@@ -11,7 +11,8 @@ function sp_table_cpt_init() {
'hierarchical' => false,
'supports' => array( 'title', 'author' ),
'register_meta_box_cb' => 'sp_table_meta_init',
'rewrite' => array( 'slug' => 'table' )
'rewrite' => array( 'slug' => 'table' ),
'show_in_menu' => 'edit.php?post_type=sp_team'
);
register_post_type( 'sp_table', $args );
}