Remove unused settings and post types
This commit is contained in:
@@ -78,7 +78,7 @@ function sp_restrict_manage_posts() {
|
|||||||
);
|
);
|
||||||
sp_dropdown_taxonomies( $args );
|
sp_dropdown_taxonomies( $args );
|
||||||
endif;
|
endif;
|
||||||
if ( in_array( $typenow, array( 'sp_team', 'sp_event', 'sp_player', 'sp_tournament', 'sp_venue' ) ) ):
|
if ( in_array( $typenow, array( 'sp_team', 'sp_event', 'sp_player' ) ) ):
|
||||||
$selected = isset( $_REQUEST['sp_sponsor'] ) ? $_REQUEST['sp_sponsor'] : null;
|
$selected = isset( $_REQUEST['sp_sponsor'] ) ? $_REQUEST['sp_sponsor'] : null;
|
||||||
$args = array(
|
$args = array(
|
||||||
'show_option_all' => sprintf( __( 'All %s', 'sportspress' ), __( 'Sponsors', 'sportspress' ) ),
|
'show_option_all' => sprintf( __( 'All %s', 'sportspress' ), __( 'Sponsors', 'sportspress' ) ),
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ function sp_event_cpt_init() {
|
|||||||
'labels' => $labels,
|
'labels' => $labels,
|
||||||
'public' => true,
|
'public' => true,
|
||||||
'hierarchical' => false,
|
'hierarchical' => false,
|
||||||
'supports' => array( 'title', 'author', 'comments', 'page-attributes' ),
|
'supports' => array( 'title', 'author', 'comments' ),
|
||||||
'register_meta_box_cb' => 'sp_event_meta_init',
|
'register_meta_box_cb' => 'sp_event_meta_init',
|
||||||
'rewrite' => array( 'slug' => 'event' )
|
'rewrite' => array( 'slug' => 'event' )
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
function sp_post_thumbnail_html( $html, $post_id, $post_thumbnail_id, $size, $attr ) {
|
function sp_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', 'sp_venue' ) ) ) {
|
if( empty ( $html ) && in_array( get_post_type( $post_id ), array( 'sp_team', 'sp_tournament' ) ) ) {
|
||||||
$parents = get_post_ancestors( $post_id );
|
$parents = get_post_ancestors( $post_id );
|
||||||
foreach ( $parents as $parent ) {
|
foreach ( $parents as $parent ) {
|
||||||
if( has_post_thumbnail( $parent ) ) {
|
if( has_post_thumbnail( $parent ) ) {
|
||||||
|
|||||||
@@ -175,7 +175,7 @@ if ( !function_exists( 'sp_the_posts' ) ) {
|
|||||||
endforeach;
|
endforeach;
|
||||||
$title = get_the_title( $id );
|
$title = get_the_title( $id );
|
||||||
if ( empty( $title ) )
|
if ( empty( $title ) )
|
||||||
$title = __( '(no title)' );
|
$title = __( '(no title)', 'sportspress' );
|
||||||
edit_post_link( $title, '', '', $id );
|
edit_post_link( $title, '', '', $id );
|
||||||
if ( !empty( $after ) ):
|
if ( !empty( $after ) ):
|
||||||
if ( is_array( $after ) ):
|
if ( is_array( $after ) ):
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ function sp_player_cpt_init() {
|
|||||||
'labels' => $labels,
|
'labels' => $labels,
|
||||||
'public' => true,
|
'public' => true,
|
||||||
'hierarchical' => false,
|
'hierarchical' => false,
|
||||||
'supports' => array( 'title', 'author', 'thumbnail', 'page-attributes' ),
|
'supports' => array( 'title', 'author', 'thumbnail' ),
|
||||||
'register_meta_box_cb' => 'sp_player_meta_init',
|
'register_meta_box_cb' => 'sp_player_meta_init',
|
||||||
'rewrite' => array( 'slug' => 'player' )
|
'rewrite' => array( 'slug' => 'player' )
|
||||||
);
|
);
|
||||||
|
|||||||
311
settings.php
311
settings.php
@@ -25,8 +25,6 @@ function sportspress_settings( $tab = '' ) {
|
|||||||
$tab = $_GET[ 'tab' ];
|
$tab = $_GET[ 'tab' ];
|
||||||
} else if( $tab == 'stats' ) {
|
} else if( $tab == 'stats' ) {
|
||||||
$tab = 'stats';
|
$tab = 'stats';
|
||||||
} else if( $tab == 'input_examples' ) {
|
|
||||||
$tab = 'input_examples';
|
|
||||||
} else {
|
} else {
|
||||||
$tab = 'display_options';
|
$tab = 'display_options';
|
||||||
}
|
}
|
||||||
@@ -35,7 +33,6 @@ function sportspress_settings( $tab = '' ) {
|
|||||||
<h2 class="nav-tab-wrapper">
|
<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=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>
|
<a href="?page=sportspress&tab=stats" class="nav-tab <?php echo $tab == 'stats' ? 'nav-tab-active' : ''; ?>"><?php _e( 'Statistics', 'sportspress' ); ?></a>
|
||||||
<a href="?page=sportspress&tab=input_examples" class="nav-tab <?php echo $tab == 'input_examples' ? 'nav-tab-active' : ''; ?>"><?php _e( 'Input Examples', 'sportspress' ); ?></a>
|
|
||||||
</h2>
|
</h2>
|
||||||
|
|
||||||
<form method="post" action="options.php">
|
<form method="post" action="options.php">
|
||||||
@@ -43,20 +40,15 @@ function sportspress_settings( $tab = '' ) {
|
|||||||
|
|
||||||
if( $tab == 'display_options' ) {
|
if( $tab == 'display_options' ) {
|
||||||
|
|
||||||
settings_fields( 'sportspress_settings_options' );
|
settings_fields( 'sportspress_options' );
|
||||||
do_settings_sections( 'sportspress_settings_options' );
|
do_settings_sections( 'sportspress_options' );
|
||||||
|
|
||||||
} elseif( $tab == 'stats' ) {
|
} else {
|
||||||
|
|
||||||
settings_fields( 'sportspress_stats' );
|
settings_fields( 'sportspress_stats' );
|
||||||
do_settings_sections( 'sportspress_stats' );
|
do_settings_sections( 'sportspress_stats' );
|
||||||
|
|
||||||
} else {
|
}
|
||||||
|
|
||||||
settings_fields( 'sportspress_input_examples' );
|
|
||||||
do_settings_sections( 'sportspress_input_examples' );
|
|
||||||
|
|
||||||
} // end if/else
|
|
||||||
|
|
||||||
submit_button();
|
submit_button();
|
||||||
|
|
||||||
@@ -71,31 +63,15 @@ function sportspress_settings( $tab = '' ) {
|
|||||||
* Setting Registration
|
* Setting Registration
|
||||||
* ------------------------------------------------------------------------ */
|
* ------------------------------------------------------------------------ */
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Provides default values for the Statistics.
|
|
||||||
*/
|
|
||||||
function sportspress_default_stats() {
|
|
||||||
|
|
||||||
$defaults = array(
|
|
||||||
'team' => '',
|
|
||||||
'event' => '',
|
|
||||||
'player' => ''
|
|
||||||
);
|
|
||||||
|
|
||||||
return apply_filters( 'sportspress_default_stats', $defaults );
|
|
||||||
|
|
||||||
} // end sportspress_default_stats
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides default values for the Display Options.
|
* Provides default values for the Display Options.
|
||||||
*/
|
*/
|
||||||
function sportspress_default_display_options() {
|
function sportspress_default_display_options() {
|
||||||
|
|
||||||
$defaults = array(
|
$defaults = array(
|
||||||
'show_header' => '',
|
'staff' => '',
|
||||||
'show_content' => '',
|
'table' => '',
|
||||||
'show_footer' => ''
|
'list' => ''
|
||||||
);
|
);
|
||||||
|
|
||||||
return apply_filters( 'sportspress_default_display_options', $defaults );
|
return apply_filters( 'sportspress_default_display_options', $defaults );
|
||||||
@@ -103,21 +79,35 @@ function sportspress_default_display_options() {
|
|||||||
} // end sportspress_default_display_options
|
} // end sportspress_default_display_options
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides default values for the Input Options.
|
* Provides default values for the Statistics.
|
||||||
*/
|
*/
|
||||||
function sportspress_default_input_options() {
|
function sportspress_default_stats() {
|
||||||
|
|
||||||
$defaults = array(
|
$defaults = array(
|
||||||
'input_example' => '',
|
|
||||||
'textarea_example' => '',
|
'team' => __( 'P', 'sportspress' ) . ': $appearances' . "\r\n" .
|
||||||
'checkbox_example' => '',
|
__( 'W', 'sportspress' ) . ': $greater' . "\r\n" .
|
||||||
'radio_example' => '',
|
__( 'D', 'sportspress' ) . ': $equal' . "\r\n" .
|
||||||
'time_options' => 'default'
|
__( 'L', 'sportspress' ) . ': $less' . "\r\n" .
|
||||||
|
__( 'F', 'sportspress' ) . ': $for' . "\r\n" .
|
||||||
|
__( 'A', 'sportspress' ) . ': $against' . "\r\n" .
|
||||||
|
__( 'GD', 'sportspress' ) . ': $for - $against' . "\r\n" .
|
||||||
|
__( 'PTS', 'sportspress' ) . ': 3 * $greater + $equal',
|
||||||
|
|
||||||
|
'event' => __( 'Goals', 'sportspress' ) . ': $goals' . "\r\n" .
|
||||||
|
__( '1st Half', 'sportspress' ) . ': $firsthalf' . "\r\n" .
|
||||||
|
__( '2nd Half', 'sportspress' ) . ': $secondhalf',
|
||||||
|
|
||||||
|
'player' => __( 'Goals', 'sportspress' ) . ': $goals' . "\r\n" .
|
||||||
|
__( 'Assists', 'sportspress' ) . ': $assists' . "\r\n" .
|
||||||
|
__( 'Yellow Cards', 'sportspress' ) . ': $yellowcards' . "\r\n" .
|
||||||
|
__( 'Red Cards', 'sportspress' ) . ': $redcards'
|
||||||
|
|
||||||
);
|
);
|
||||||
|
|
||||||
return apply_filters( 'sportspress_default_input_options', $defaults );
|
return apply_filters( 'sportspress_default_stats', $defaults );
|
||||||
|
|
||||||
} // end sportspress_default_input_options
|
} // end sportspress_default_stats
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes the theme's display options page by registering the Sections,
|
* Initializes the theme's display options page by registering the Sections,
|
||||||
@@ -128,8 +118,8 @@ function sportspress_default_input_options() {
|
|||||||
function sportspress_initialize_theme_options() {
|
function sportspress_initialize_theme_options() {
|
||||||
|
|
||||||
// If the theme options don't exist, create them.
|
// If the theme options don't exist, create them.
|
||||||
if ( false == get_option( 'sportspress_settings_options' ) ) {
|
if ( false == get_option( 'sportspress_options' ) ) {
|
||||||
add_option( 'sportspress_settings_options', apply_filters( 'sportspress_default_display_options', sportspress_default_display_options() ) );
|
add_option( 'sportspress_options', apply_filters( 'sportspress_default_display_options', sportspress_default_display_options() ) );
|
||||||
} // end if
|
} // end if
|
||||||
|
|
||||||
// First, we register a section. This is necessary since all future options must belong to a
|
// First, we register a section. This is necessary since all future options must belong to a
|
||||||
@@ -137,47 +127,38 @@ function sportspress_initialize_theme_options() {
|
|||||||
'general_settings_section', // ID used to identify this section and with which to register options
|
'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
|
__( 'Display Options', 'sportspress' ), // Title to be displayed on the administration page
|
||||||
'', // Callback used to render the description of the section
|
'', // Callback used to render the description of the section
|
||||||
'sportspress_settings_options' // Page on which to add this section of options
|
'sportspress_options' // Page on which to add this section of options
|
||||||
);
|
);
|
||||||
|
|
||||||
// Next, we'll introduce the fields for toggling the visibility of content elements.
|
// Next, we'll introduce the fields for toggling the visibility of content elements.
|
||||||
add_settings_field(
|
add_settings_field(
|
||||||
'show_header', // ID used to identify the field throughout the theme
|
'staff', // ID used to identify the field throughout the theme
|
||||||
__( 'Header', 'sportspress' ), // The label to the left of the option interface element
|
__( 'Staff', 'sportspress' ), // The label to the left of the option interface element
|
||||||
'sportspress_toggle_header_callback', // The name of the function responsible for rendering the option interface
|
'sportspress_toggle_staff_callback', // The name of the function responsible for rendering the option interface
|
||||||
'sportspress_settings_options', // The page on which this option will be displayed
|
'sportspress_options', // The page on which this option will be displayed
|
||||||
'general_settings_section', // The name of the section to which this field belongs
|
'general_settings_section'
|
||||||
array( // The array of arguments to pass to the callback. In this case, just a description.
|
|
||||||
__( 'Activate this setting to display the header.', 'sportspress' ),
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
add_settings_field(
|
add_settings_field(
|
||||||
'show_content',
|
'table',
|
||||||
__( 'Content', 'sportspress' ),
|
__( 'League Tables', 'sportspress' ),
|
||||||
'sportspress_toggle_content_callback',
|
'sportspress_toggle_table_callback',
|
||||||
'sportspress_settings_options',
|
'sportspress_options',
|
||||||
'general_settings_section',
|
'general_settings_section'
|
||||||
array(
|
|
||||||
__( 'Activate this setting to display the content.', 'sportspress' ),
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
add_settings_field(
|
add_settings_field(
|
||||||
'show_footer',
|
'list',
|
||||||
__( 'Footer', 'sportspress' ),
|
__( 'Player Lists', 'sportspress' ),
|
||||||
'sportspress_toggle_footer_callback',
|
'sportspress_toggle_list_callback',
|
||||||
'sportspress_settings_options',
|
'sportspress_options',
|
||||||
'general_settings_section',
|
'general_settings_section'
|
||||||
array(
|
|
||||||
__( 'Activate this setting to display the footer.', 'sportspress' ),
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// Finally, we register the fields with WordPress
|
// Finally, we register the fields with WordPress
|
||||||
register_setting(
|
register_setting(
|
||||||
'sportspress_settings_options',
|
'sportspress_options',
|
||||||
'sportspress_settings_options'
|
'sportspress_options'
|
||||||
);
|
);
|
||||||
|
|
||||||
} // end sportspress_initialize_theme_options
|
} // end sportspress_initialize_theme_options
|
||||||
@@ -225,14 +206,6 @@ function sportspress_intialize_stats() {
|
|||||||
'sportspress_stats',
|
'sportspress_stats',
|
||||||
'sportspress_stats'
|
'sportspress_stats'
|
||||||
);
|
);
|
||||||
|
|
||||||
add_settings_field(
|
|
||||||
'staff',
|
|
||||||
__( 'Staff', 'sportspress' ),
|
|
||||||
'sportspress_staff_stats_callback',
|
|
||||||
'sportspress_stats',
|
|
||||||
'sportspress_stats'
|
|
||||||
);
|
|
||||||
|
|
||||||
register_setting(
|
register_setting(
|
||||||
'sportspress_stats',
|
'sportspress_stats',
|
||||||
@@ -242,75 +215,6 @@ function sportspress_intialize_stats() {
|
|||||||
} // end sportspress_intialize_stats
|
} // end sportspress_intialize_stats
|
||||||
add_action( 'admin_init', 'sportspress_intialize_stats' );
|
add_action( 'admin_init', 'sportspress_intialize_stats' );
|
||||||
|
|
||||||
/**
|
|
||||||
* Initializes the theme's input example by registering the Sections,
|
|
||||||
* Fields, and Settings. This particular group of options is used to demonstration
|
|
||||||
* validation and sanitization.
|
|
||||||
*
|
|
||||||
* This function is registered with the 'admin_init' hook.
|
|
||||||
*/
|
|
||||||
function sportspress_initialize_input_examples() {
|
|
||||||
|
|
||||||
if( false == get_option( 'sportspress_input_examples' ) ) {
|
|
||||||
add_option( 'sportspress_input_examples', apply_filters( 'sportspress_default_input_options', sportspress_default_input_options() ) );
|
|
||||||
} // end if
|
|
||||||
|
|
||||||
add_settings_section(
|
|
||||||
'input_examples_section',
|
|
||||||
__( 'Input Examples', 'sportspress' ),
|
|
||||||
'',
|
|
||||||
'sportspress_input_examples'
|
|
||||||
);
|
|
||||||
|
|
||||||
add_settings_field(
|
|
||||||
'Input Element',
|
|
||||||
__( 'Input Element', 'sportspress' ),
|
|
||||||
'sportspress_input_element_callback',
|
|
||||||
'sportspress_input_examples',
|
|
||||||
'input_examples_section'
|
|
||||||
);
|
|
||||||
|
|
||||||
add_settings_field(
|
|
||||||
'Textarea Element',
|
|
||||||
__( 'Textarea Element', 'sportspress' ),
|
|
||||||
'sportspress_textarea_element_callback',
|
|
||||||
'sportspress_input_examples',
|
|
||||||
'input_examples_section'
|
|
||||||
);
|
|
||||||
|
|
||||||
add_settings_field(
|
|
||||||
'Checkbox Element',
|
|
||||||
__( 'Checkbox Element', 'sportspress' ),
|
|
||||||
'sportspress_checkbox_element_callback',
|
|
||||||
'sportspress_input_examples',
|
|
||||||
'input_examples_section'
|
|
||||||
);
|
|
||||||
|
|
||||||
add_settings_field(
|
|
||||||
'Radio Button Elements',
|
|
||||||
__( 'Radio Button Elements', 'sportspress' ),
|
|
||||||
'sportspress_radio_element_callback',
|
|
||||||
'sportspress_input_examples',
|
|
||||||
'input_examples_section'
|
|
||||||
);
|
|
||||||
|
|
||||||
add_settings_field(
|
|
||||||
'Select Element',
|
|
||||||
__( 'Select Element', 'sportspress' ),
|
|
||||||
'sportspress_select_element_callback',
|
|
||||||
'sportspress_input_examples',
|
|
||||||
'input_examples_section'
|
|
||||||
);
|
|
||||||
|
|
||||||
register_setting(
|
|
||||||
'sportspress_input_examples',
|
|
||||||
'sportspress_input_examples',
|
|
||||||
'sportspress_validate_input_examples'
|
|
||||||
);
|
|
||||||
|
|
||||||
} // end sportspress_initialize_input_examples
|
|
||||||
add_action( 'admin_init', 'sportspress_initialize_input_examples' );
|
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------ *
|
/* ------------------------------------------------------------------------ *
|
||||||
* Field Callbacks
|
* Field Callbacks
|
||||||
* ------------------------------------------------------------------------ */
|
* ------------------------------------------------------------------------ */
|
||||||
@@ -321,43 +225,35 @@ add_action( 'admin_init', 'sportspress_initialize_input_examples' );
|
|||||||
* It accepts an array or arguments and expects the first element in the array to be the description
|
* 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.
|
* to be displayed next to the checkbox.
|
||||||
*/
|
*/
|
||||||
function sportspress_toggle_header_callback($args) {
|
function sportspress_toggle_staff_callback() {
|
||||||
|
|
||||||
// First, we read the options collection
|
$options = get_option('sportspress_options');
|
||||||
$options = get_option('sportspress_settings_options');
|
|
||||||
|
|
||||||
// Next, we update the name attribute to access this element's ID in the context of the display options array
|
$html = '<input type="checkbox" id="staff" name="sportspress_options[staff]" value="1" ' . checked( 1, isset( $options['staff'] ) ? $options['staff'] : 0, false ) . '/>';
|
||||||
// We also access the show_header element of the options collection in the call to the checked() helper function
|
|
||||||
$html = '<input type="checkbox" id="show_header" name="sportspress_settings_options[show_header]" value="1" ' . checked( 1, isset( $options['show_header'] ) ? $options['show_header'] : 0, false ) . '/>';
|
|
||||||
|
|
||||||
// Here, we'll take the first argument of the array and add it to a label next to the checkbox
|
|
||||||
$html .= '<label for="show_header"> ' . $args[0] . '</label>';
|
|
||||||
|
|
||||||
echo $html;
|
echo $html;
|
||||||
|
|
||||||
} // end sportspress_toggle_header_callback
|
} // end sportspress_toggle_staff_callback
|
||||||
|
|
||||||
function sportspress_toggle_content_callback($args) {
|
function sportspress_toggle_table_callback() {
|
||||||
|
|
||||||
$options = get_option('sportspress_settings_options');
|
$options = get_option('sportspress_options');
|
||||||
|
|
||||||
$html = '<input type="checkbox" id="show_content" name="sportspress_settings_options[show_content]" value="1" ' . checked( 1, isset( $options['show_content'] ) ? $options['show_content'] : 0, false ) . '/>';
|
$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 ) . '/>';
|
||||||
$html .= '<label for="show_content"> ' . $args[0] . '</label>';
|
|
||||||
|
|
||||||
echo $html;
|
echo $html;
|
||||||
|
|
||||||
} // end sportspress_toggle_content_callback
|
} // end sportspress_toggle_table_callback
|
||||||
|
|
||||||
function sportspress_toggle_footer_callback($args) {
|
function sportspress_toggle_list_callback() {
|
||||||
|
|
||||||
$options = get_option('sportspress_settings_options');
|
$options = get_option('sportspress_options');
|
||||||
|
|
||||||
$html = '<input type="checkbox" id="show_footer" name="sportspress_settings_options[show_footer]" value="1" ' . checked( 1, isset( $options['show_footer'] ) ? $options['show_footer'] : 0, false ) . '/>';
|
$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 ) . '/>';
|
||||||
$html .= '<label for="show_footer"> ' . $args[0] . '</label>';
|
|
||||||
|
|
||||||
echo $html;
|
echo $html;
|
||||||
|
|
||||||
} // end sportspress_toggle_footer_callback
|
} // end sportspress_toggle_list_callback
|
||||||
|
|
||||||
function sportspress_team_stats_callback() {
|
function sportspress_team_stats_callback() {
|
||||||
sportspress_render_option_field( 'sportspress_stats', 'team', 'textarea' );
|
sportspress_render_option_field( 'sportspress_stats', 'team', 'textarea' );
|
||||||
@@ -371,66 +267,6 @@ function sportspress_player_stats_callback() {
|
|||||||
sportspress_render_option_field( 'sportspress_stats', 'player', 'textarea' );
|
sportspress_render_option_field( 'sportspress_stats', 'player', 'textarea' );
|
||||||
}
|
}
|
||||||
|
|
||||||
function sportspress_input_element_callback() {
|
|
||||||
|
|
||||||
$options = get_option( 'sportspress_input_examples' );
|
|
||||||
|
|
||||||
// Render the output
|
|
||||||
echo '<input type="text" id="input_example" name="sportspress_input_examples[input_example]" value="' . $options['input_example'] . '" />';
|
|
||||||
|
|
||||||
} // end sportspress_input_element_callback
|
|
||||||
|
|
||||||
function sportspress_textarea_element_callback() {
|
|
||||||
|
|
||||||
$options = get_option( 'sportspress_input_examples' );
|
|
||||||
|
|
||||||
// Render the output
|
|
||||||
echo '<textarea id="textarea_example" name="sportspress_input_examples[textarea_example]" rows="5" cols="50">' . $options['textarea_example'] . '</textarea>';
|
|
||||||
|
|
||||||
} // end sportspress_textarea_element_callback
|
|
||||||
|
|
||||||
function sportspress_checkbox_element_callback() {
|
|
||||||
|
|
||||||
$options = get_option( 'sportspress_input_examples' );
|
|
||||||
|
|
||||||
$html = '<input type="checkbox" id="checkbox_example" name="sportspress_input_examples[checkbox_example]" value="1"' . checked( 1, $options['checkbox_example'], false ) . '/>';
|
|
||||||
$html .= ' ';
|
|
||||||
$html .= '<label for="checkbox_example">This is an example of a checkbox</label>';
|
|
||||||
|
|
||||||
echo $html;
|
|
||||||
|
|
||||||
} // end sportspress_checkbox_element_callback
|
|
||||||
|
|
||||||
function sportspress_radio_element_callback() {
|
|
||||||
|
|
||||||
$options = get_option( 'sportspress_input_examples' );
|
|
||||||
|
|
||||||
$html = '<input type="radio" id="radio_example_one" name="sportspress_input_examples[radio_example]" value="1"' . checked( 1, $options['radio_example'], false ) . '/>';
|
|
||||||
$html .= ' ';
|
|
||||||
$html .= '<label for="radio_example_one">Option One</label>';
|
|
||||||
$html .= ' ';
|
|
||||||
$html .= '<input type="radio" id="radio_example_two" name="sportspress_input_examples[radio_example]" value="2"' . checked( 2, $options['radio_example'], false ) . '/>';
|
|
||||||
$html .= ' ';
|
|
||||||
$html .= '<label for="radio_example_two">Option Two</label>';
|
|
||||||
|
|
||||||
echo $html;
|
|
||||||
|
|
||||||
} // end sportspress_radio_element_callback
|
|
||||||
|
|
||||||
function sportspress_select_element_callback() {
|
|
||||||
|
|
||||||
$options = get_option( 'sportspress_input_examples' );
|
|
||||||
|
|
||||||
$html = '<select id="time_options" name="sportspress_input_examples[time_options]">';
|
|
||||||
$html .= '<option value="default">' . __( 'Select a time option...', 'sportspress' ) . '</option>';
|
|
||||||
$html .= '<option value="never"' . selected( $options['time_options'], 'never', false) . '>' . __( 'Never', 'sportspress' ) . '</option>';
|
|
||||||
$html .= '<option value="sometimes"' . selected( $options['time_options'], 'sometimes', false) . '>' . __( 'Sometimes', 'sportspress' ) . '</option>';
|
|
||||||
$html .= '<option value="always"' . selected( $options['time_options'], 'always', false) . '>' . __( 'Always', 'sportspress' ) . '</option>'; $html .= '</select>';
|
|
||||||
|
|
||||||
echo $html;
|
|
||||||
|
|
||||||
} // end sportspress_radio_element_callback
|
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------ *
|
/* ------------------------------------------------------------------------ *
|
||||||
* Setting Callbacks
|
* Setting Callbacks
|
||||||
* ------------------------------------------------------------------------ */
|
* ------------------------------------------------------------------------ */
|
||||||
@@ -463,27 +299,4 @@ function sportspress_sanitize_stats( $input ) {
|
|||||||
|
|
||||||
} // end sportspress_sanitize_stats
|
} // end sportspress_sanitize_stats
|
||||||
|
|
||||||
function sportspress_validate_input_examples( $input ) {
|
|
||||||
|
|
||||||
// Create our array for storing the validated options
|
|
||||||
$output = array();
|
|
||||||
|
|
||||||
// Loop through each of the incoming options
|
|
||||||
foreach( $input as $key => $value ) {
|
|
||||||
|
|
||||||
// Check to see if the current option has a value. If so, process it.
|
|
||||||
if( isset( $input[$key] ) ) {
|
|
||||||
|
|
||||||
// Strip all HTML and PHP tags and properly handle quoted strings
|
|
||||||
$output[$key] = strip_tags( stripslashes( $input[ $key ] ) );
|
|
||||||
|
|
||||||
} // end if
|
|
||||||
|
|
||||||
} // end foreach
|
|
||||||
|
|
||||||
// Return the array processing any additional functions filtered by this action
|
|
||||||
return apply_filters( 'sportspress_validate_input_examples', $output, $input );
|
|
||||||
|
|
||||||
} // end sportspress_validate_input_examples
|
|
||||||
|
|
||||||
?>
|
?>
|
||||||
@@ -3,7 +3,7 @@ function sp_sponsor_tax_init() {
|
|||||||
$name = __( 'Sponsors', 'sportspress' );
|
$name = __( 'Sponsors', 'sportspress' );
|
||||||
$singular_name = __( 'Sponsor', 'sportspress' );
|
$singular_name = __( 'Sponsor', 'sportspress' );
|
||||||
$lowercase_name = __( 'sponsors', 'sportspress' );
|
$lowercase_name = __( 'sponsors', 'sportspress' );
|
||||||
$object_type = array( 'sp_team', 'sp_event', 'sp_player', 'sp_tournament', 'sp_venue' );
|
$object_type = array( 'sp_team', 'sp_event', 'sp_player', 'sp_tournament' );
|
||||||
$labels = sp_tax_labels( $name, $singular_name, $lowercase_name );
|
$labels = sp_tax_labels( $name, $singular_name, $lowercase_name );
|
||||||
$args = array(
|
$args = array(
|
||||||
'label' => $name,
|
'label' => $name,
|
||||||
|
|||||||
@@ -40,11 +40,9 @@ require_once dirname( __FILE__ ) . '/player.php';
|
|||||||
require_once dirname( __FILE__ ) . '/staff.php';
|
require_once dirname( __FILE__ ) . '/staff.php';
|
||||||
require_once dirname( __FILE__ ) . '/table.php';
|
require_once dirname( __FILE__ ) . '/table.php';
|
||||||
require_once dirname( __FILE__ ) . '/list.php';
|
require_once dirname( __FILE__ ) . '/list.php';
|
||||||
require_once dirname( __FILE__ ) . '/tournament.php';
|
|
||||||
|
|
||||||
// Taxonomies
|
// Taxonomies
|
||||||
require_once dirname( __FILE__ ) . '/league.php';
|
require_once dirname( __FILE__ ) . '/league.php';
|
||||||
require_once dirname( __FILE__ ) . '/venue.php';
|
|
||||||
require_once dirname( __FILE__ ) . '/position.php';
|
require_once dirname( __FILE__ ) . '/position.php';
|
||||||
require_once dirname( __FILE__ ) . '/sponsor.php';
|
require_once dirname( __FILE__ ) . '/sponsor.php';
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ function sp_staff_cpt_init() {
|
|||||||
'labels' => $labels,
|
'labels' => $labels,
|
||||||
'public' => true,
|
'public' => true,
|
||||||
'hierarchical' => false,
|
'hierarchical' => false,
|
||||||
'supports' => array( 'title', 'author', 'thumbnail', 'page-attributes' ),
|
'supports' => array( 'title', 'author', 'thumbnail' ),
|
||||||
'register_meta_box_cb' => 'sp_staff_meta_init',
|
'register_meta_box_cb' => 'sp_staff_meta_init',
|
||||||
'rewrite' => array( 'slug' => 'staff' )
|
'rewrite' => array( 'slug' => 'staff' )
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,30 +0,0 @@
|
|||||||
<?php
|
|
||||||
function sp_tournament_cpt_init() {
|
|
||||||
$name = __( 'Tournaments', 'sportspress' );
|
|
||||||
$singular_name = __( 'Tournament', 'sportspress' );
|
|
||||||
$lowercase_name = __( 'tournaments', 'sportspress' );
|
|
||||||
$labels = sp_cpt_labels( $name, $singular_name, $lowercase_name );
|
|
||||||
$args = array(
|
|
||||||
'label' => $name,
|
|
||||||
'labels' => $labels,
|
|
||||||
'public' => true,
|
|
||||||
'hierarchical' => true,
|
|
||||||
'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'comments', 'page-attributes' ),
|
|
||||||
'rewrite' => array( 'slug' => 'tournament' )
|
|
||||||
);
|
|
||||||
register_post_type( 'sp_tournament', $args );
|
|
||||||
}
|
|
||||||
add_action( 'init', 'sp_tournament_cpt_init' );
|
|
||||||
|
|
||||||
function sp_tournament_edit_columns() {
|
|
||||||
$columns = array(
|
|
||||||
'cb' => '<input type="checkbox" />',
|
|
||||||
'title' => __( 'Title' ),
|
|
||||||
'sp_team' => __( 'Teams', 'sportspress' ),
|
|
||||||
'sp_event' => __( 'Events', 'sportspress' ),
|
|
||||||
'sp_sponsor' => __( 'Sponsors', 'sportspress' )
|
|
||||||
);
|
|
||||||
return $columns;
|
|
||||||
}
|
|
||||||
add_filter( 'manage_edit-sp_tournament_columns', 'sp_tournament_edit_columns' );
|
|
||||||
?>
|
|
||||||
29
venue.php
29
venue.php
@@ -1,29 +0,0 @@
|
|||||||
<?php
|
|
||||||
function sp_venue_cpt_init() {
|
|
||||||
$name = __( 'Venues', 'sportspress' );
|
|
||||||
$singular_name = __( 'Venue', 'sportspress' );
|
|
||||||
$lowercase_name = __( 'venues', 'sportspress' );
|
|
||||||
$labels = sp_cpt_labels( $name, $singular_name, $lowercase_name );
|
|
||||||
$args = array(
|
|
||||||
'label' => $name,
|
|
||||||
'labels' => $labels,
|
|
||||||
'public' => true,
|
|
||||||
'hierarchical' => true,
|
|
||||||
'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'page-attributes' ),
|
|
||||||
'rewrite' => array( 'slug' => 'venue' )
|
|
||||||
);
|
|
||||||
register_post_type( 'sp_venue', $args );
|
|
||||||
}
|
|
||||||
add_action( 'init', 'sp_venue_cpt_init' );
|
|
||||||
|
|
||||||
function sp_venue_edit_columns() {
|
|
||||||
$columns = array(
|
|
||||||
'cb' => '<input type="checkbox" />',
|
|
||||||
'title' => __( 'Venue', 'sportspress' ),
|
|
||||||
'sp_address' => __( 'Address', 'sportspress' ),
|
|
||||||
'sp_sponsor' => __( 'Sponsors', 'sportspress' )
|
|
||||||
);
|
|
||||||
return $columns;
|
|
||||||
}
|
|
||||||
add_filter( 'manage_edit-sp_venue_columns', 'sp_venue_edit_columns' );
|
|
||||||
?>
|
|
||||||
Reference in New Issue
Block a user