Complete refactoring and add style settings
This commit is contained in:
@@ -1,17 +0,0 @@
|
|||||||
<?php
|
|
||||||
function sportspress_admin_head() {
|
|
||||||
global $typenow;
|
|
||||||
if ( in_array( $typenow, array( 'sp_result', 'sp_outcome', 'sp_column', 'sp_performance', 'sp_metric' ) ) )
|
|
||||||
sportspress_highlight_admin_menu();
|
|
||||||
elseif ( $typenow == 'sp_table' )
|
|
||||||
sportspress_highlight_admin_menu( 'edit.php?post_type=sp_team', 'edit.php?post_type=sp_table' );
|
|
||||||
elseif ( $typenow == 'sp_list' )
|
|
||||||
sportspress_highlight_admin_menu( 'edit.php?post_type=sp_player', 'edit.php?post_type=sp_list' );
|
|
||||||
elseif ( $typenow == 'sp_staff' )
|
|
||||||
sportspress_highlight_admin_menu( 'edit.php?post_type=sp_player', 'edit.php?post_type=sp_staff' );
|
|
||||||
elseif ( $typenow == 'sp_directory' )
|
|
||||||
sportspress_highlight_admin_menu( 'edit.php?post_type=sp_player', 'edit.php?post_type=sp_directory' );
|
|
||||||
}
|
|
||||||
add_action( 'admin_head-edit.php', 'sportspress_admin_head', 10, 2 );
|
|
||||||
add_action( 'admin_head-post.php', 'sportspress_admin_head', 10, 2 );
|
|
||||||
add_action( 'admin_head-post-new.php', 'sportspress_admin_head', 10, 2 );
|
|
||||||
@@ -1,43 +0,0 @@
|
|||||||
<?php
|
|
||||||
function sportspress_admin_init() {
|
|
||||||
$post_types = array(
|
|
||||||
'sp_event',
|
|
||||||
'sp_calendar',
|
|
||||||
'sp_team',
|
|
||||||
'sp_table',
|
|
||||||
'sp_player',
|
|
||||||
'sp_list',
|
|
||||||
'sp_staff',
|
|
||||||
'sp_directory',
|
|
||||||
'sp_config',
|
|
||||||
);
|
|
||||||
|
|
||||||
$caps = array(
|
|
||||||
'read',
|
|
||||||
'read_private',
|
|
||||||
'edit',
|
|
||||||
'edit_others',
|
|
||||||
'edit_private',
|
|
||||||
'edit_published',
|
|
||||||
'publish',
|
|
||||||
'delete',
|
|
||||||
'delete_others',
|
|
||||||
'delete_private',
|
|
||||||
'delete_published',
|
|
||||||
);
|
|
||||||
|
|
||||||
// Site Admin
|
|
||||||
$administrator = get_role( 'administrator' );
|
|
||||||
|
|
||||||
foreach( $post_types as $post_type ):
|
|
||||||
$administrator->add_cap( 'read_' . $post_type );
|
|
||||||
$administrator->add_cap( 'edit_' . $post_type );
|
|
||||||
$administrator->add_cap( 'delete_' . $post_type );
|
|
||||||
foreach ( $caps as $cap ):
|
|
||||||
$administrator->add_cap( $cap . '_' . $post_type . 's' );
|
|
||||||
endforeach;
|
|
||||||
endforeach;
|
|
||||||
|
|
||||||
$administrator->add_cap( 'view_sportspress_reports' );
|
|
||||||
}
|
|
||||||
add_action( 'admin_init', 'sportspress_admin_init' );
|
|
||||||
@@ -1,66 +0,0 @@
|
|||||||
<?php
|
|
||||||
function sportspress_admin_menu( $position ) {
|
|
||||||
|
|
||||||
global $menu, $submenu;
|
|
||||||
|
|
||||||
// Find where our separator is in the menu
|
|
||||||
foreach( $menu as $key => $data ):
|
|
||||||
if ( is_array( $data ) && array_key_exists( 2, $data ) && $data[2] == 'edit.php?post_type=sp_separator' )
|
|
||||||
$separator_position = $key;
|
|
||||||
endforeach;
|
|
||||||
|
|
||||||
// Swap our separator post type with a menu separator
|
|
||||||
if ( isset( $separator_position ) ):
|
|
||||||
$menu[ $separator_position ] = array( '', 'read', 'separator-sportspress', '', 'wp-menu-separator sportspress' );
|
|
||||||
endif;
|
|
||||||
|
|
||||||
// Remove "Venues" and "Positions" links from Media submenu
|
|
||||||
if ( isset( $submenu['upload.php'] ) ):
|
|
||||||
$submenu['upload.php'] = array_filter( $submenu['upload.php'], 'sportspress_admin_menu_remove_venues' );
|
|
||||||
$submenu['upload.php'] = array_filter( $submenu['upload.php'], 'sportspress_admin_menu_remove_positions' );
|
|
||||||
endif;
|
|
||||||
|
|
||||||
// Remove "Leagues" and "Seasons" links from Schedule submenu
|
|
||||||
if ( isset( $submenu['edit.php?post_type=sp_event'] ) ):
|
|
||||||
$submenu['edit.php?post_type=sp_event'] = array_filter( $submenu['edit.php?post_type=sp_event'], 'sportspress_admin_menu_remove_leagues' );
|
|
||||||
$submenu['edit.php?post_type=sp_event'] = array_filter( $submenu['edit.php?post_type=sp_event'], 'sportspress_admin_menu_remove_seasons' );
|
|
||||||
endif;
|
|
||||||
|
|
||||||
// Remove "Leagues" and "Seasons" links from Players submenu
|
|
||||||
if ( isset( $submenu['edit.php?post_type=sp_player'] ) ):
|
|
||||||
$submenu['edit.php?post_type=sp_player'] = array_filter( $submenu['edit.php?post_type=sp_player'], 'sportspress_admin_menu_remove_leagues' );
|
|
||||||
$submenu['edit.php?post_type=sp_player'] = array_filter( $submenu['edit.php?post_type=sp_player'], 'sportspress_admin_menu_remove_seasons' );
|
|
||||||
endif;
|
|
||||||
|
|
||||||
}
|
|
||||||
add_action( 'admin_menu', 'sportspress_admin_menu' );
|
|
||||||
|
|
||||||
if ( ! function_exists( 'sportspress_admin_menu_remove_add_new' ) ) {
|
|
||||||
function sportspress_admin_menu_remove_add_new( $arr = array() ) {
|
|
||||||
return $arr[0] != __( 'Add New', 'sportspress' );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( ! function_exists( 'sportspress_admin_menu_remove_leagues' ) ) {
|
|
||||||
function sportspress_admin_menu_remove_leagues( $arr = array() ) {
|
|
||||||
return $arr[0] != __( 'Leagues', 'sportspress' );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( ! function_exists( 'sportspress_admin_menu_remove_positions' ) ) {
|
|
||||||
function sportspress_admin_menu_remove_positions( $arr = array() ) {
|
|
||||||
return $arr[0] != __( 'Positions', 'sportspress' );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( ! function_exists( 'sportspress_admin_menu_remove_seasons' ) ) {
|
|
||||||
function sportspress_admin_menu_remove_seasons( $arr = array() ) {
|
|
||||||
return $arr[0] != __( 'Seasons', 'sportspress' );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( ! function_exists( 'sportspress_admin_menu_remove_venues' ) ) {
|
|
||||||
function sportspress_admin_menu_remove_venues( $arr = array() ) {
|
|
||||||
return $arr[0] != __( 'Venues', 'sportspress' );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
<?php
|
|
||||||
function sportspress_admin_post_thumbnail_html( $translated_text, $post_id ) {
|
|
||||||
$texts = array(
|
|
||||||
'sp_team' => array(
|
|
||||||
'Set featured image' => sprintf( __( 'Select %s', 'sportspress' ), __( 'Logo', 'sportspress' ) ),
|
|
||||||
'Remove featured image' => sprintf( __( 'Remove %s', 'sportspress' ), __( 'Logo', 'sportspress' ) ),
|
|
||||||
),
|
|
||||||
'sp_player' => array(
|
|
||||||
'Set featured image' => sprintf( __( 'Select %s', 'sportspress' ), __( 'Photo', 'sportspress' ) ),
|
|
||||||
'Remove featured image' => sprintf( __( 'Remove %s', 'sportspress' ), __( 'Photo', 'sportspress' ) ),
|
|
||||||
),
|
|
||||||
'sp_staff' => array(
|
|
||||||
'Set featured image' => sprintf( __( 'Select %s', 'sportspress' ), __( 'Photo', 'sportspress' ) ),
|
|
||||||
'Remove featured image' => sprintf( __( 'Remove %s', 'sportspress' ), __( 'Photo', 'sportspress' ) ),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
$typenow = get_post_type( $post_id );
|
|
||||||
if ( is_admin() && array_key_exists( $typenow, $texts ) ):
|
|
||||||
foreach ( $texts[ $typenow ] as $key => $value ):
|
|
||||||
$translated_text = str_replace( __( $key ), $value, $translated_text );
|
|
||||||
endforeach;
|
|
||||||
endif;
|
|
||||||
return $translated_text;
|
|
||||||
}
|
|
||||||
add_filter( 'admin_post_thumbnail_html', 'sportspress_admin_post_thumbnail_html', 10, 2 );
|
|
||||||
@@ -1,48 +0,0 @@
|
|||||||
<?php
|
|
||||||
function sportspress_admin_notices_styles() {
|
|
||||||
$screen = get_current_screen();
|
|
||||||
|
|
||||||
if ( $screen->id != 'settings_page_sportspress' ):
|
|
||||||
if ( isset( $_REQUEST['sportspress_installed'] ) ):
|
|
||||||
update_option( 'sportspress_installed', $_REQUEST['sportspress_installed'] );
|
|
||||||
endif;
|
|
||||||
|
|
||||||
if ( ! get_option( 'sportspress_installed' ) ):
|
|
||||||
add_action( 'admin_notices', 'sportspress_admin_install_notices' );
|
|
||||||
endif;
|
|
||||||
endif;
|
|
||||||
|
|
||||||
$template = get_option( 'template' );
|
|
||||||
|
|
||||||
if ( ! current_theme_supports( 'sportspress' ) && ! in_array( $template, array( 'twentyfourteen', 'twentythirteen', 'twentyeleven', 'twentytwelve', 'twentyten' ) ) ):
|
|
||||||
if ( ! empty( $_GET['hide_sportspress_theme_support_check'] ) ):
|
|
||||||
update_option( 'sportspress_theme_support_check', $template );
|
|
||||||
return;
|
|
||||||
endif;
|
|
||||||
|
|
||||||
if ( get_option( 'sportspress_theme_support_check' ) !== $template ):
|
|
||||||
add_action( 'admin_notices', 'sportspress_theme_check_notice' );
|
|
||||||
endif;
|
|
||||||
endif;
|
|
||||||
}
|
|
||||||
add_action( 'admin_print_styles', 'sportspress_admin_notices_styles' );
|
|
||||||
|
|
||||||
/**
|
|
||||||
* sportspress_admin_install_notices function.
|
|
||||||
*
|
|
||||||
* @access public
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
function sportspress_admin_install_notices() {
|
|
||||||
// include( dirname( SP_PLUGIN_FILE ) . '/includes/admin/views/notice-install.php' );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* sportspress_theme_check_notice function.
|
|
||||||
*
|
|
||||||
* @access public
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
function sportspress_theme_check_notice() {
|
|
||||||
// include( dirname( SP_PLUGIN_FILE ) . '/includes/admin/views/notice-theme-support.php' );
|
|
||||||
}
|
|
||||||
@@ -1,84 +0,0 @@
|
|||||||
<?php
|
|
||||||
function sportspress_gettext( $translated_text, $untranslated_text, $domain ) {
|
|
||||||
if ( $domain != 'sportspress' )
|
|
||||||
return $translated_text;
|
|
||||||
|
|
||||||
global $typenow, $sportspress_options;
|
|
||||||
|
|
||||||
if ( is_admin() ):
|
|
||||||
if ( in_array( $typenow, array( 'sp_team' ) ) ):
|
|
||||||
switch ( $untranslated_text ):
|
|
||||||
case 'Set featured image':
|
|
||||||
$translated_text = __( 'Select Logo', 'sportspress' );
|
|
||||||
break;
|
|
||||||
case 'Featured Image':
|
|
||||||
$translated_text = __( 'Logo', 'sportspress' );
|
|
||||||
break;
|
|
||||||
case 'Set Featured Image':
|
|
||||||
$translated_text = __( 'Select Logo', 'sportspress' );
|
|
||||||
break;
|
|
||||||
case 'Remove featured image':
|
|
||||||
$translated_text = __( 'Remove Logo', 'sportspress' );
|
|
||||||
break;
|
|
||||||
case 'Author':
|
|
||||||
$translated_text = __( 'User', 'sportspress' );
|
|
||||||
break;
|
|
||||||
endswitch;
|
|
||||||
elseif ( in_array( $typenow, array( 'sp_event', 'sp_player', 'sp_staff' ) ) ):
|
|
||||||
switch ( $untranslated_text ):
|
|
||||||
case 'Enter title here':
|
|
||||||
$translated_text = __( '(Auto)', 'sportspress' );
|
|
||||||
break;
|
|
||||||
case 'Publish <b>immediately</b>':
|
|
||||||
$translated_text = __( 'Date/Time:', 'sportspress' ) . ' <b>' . __( 'Now', 'sportspress' ) . '</b>';
|
|
||||||
break;
|
|
||||||
case 'Author':
|
|
||||||
$translated_text = __( 'User', 'sportspress' );
|
|
||||||
break;
|
|
||||||
endswitch;
|
|
||||||
endif;
|
|
||||||
|
|
||||||
if ( in_array( $typenow, array( 'sp_team' ) ) ):
|
|
||||||
switch ( $untranslated_text ):
|
|
||||||
case 'Enter title here':
|
|
||||||
$translated_text = __( 'Team', 'sportspress' );
|
|
||||||
break;
|
|
||||||
endswitch;
|
|
||||||
endif;
|
|
||||||
|
|
||||||
if ( in_array( $typenow, array( 'sp_player', 'sp_staff' ) ) ):
|
|
||||||
switch ( $untranslated_text ):
|
|
||||||
case 'Featured Image':
|
|
||||||
$translated_text = __( 'Photo', 'sportspress' );
|
|
||||||
break;
|
|
||||||
case 'Set featured image':
|
|
||||||
$translated_text = __( 'Select Photo', 'sportspress' );
|
|
||||||
break;
|
|
||||||
case 'Set Featured Image':
|
|
||||||
$translated_text = __( 'Select Photo', 'sportspress' );
|
|
||||||
break;
|
|
||||||
case 'Remove featured image':
|
|
||||||
$translated_text = __( 'Remove Photo', 'sportspress' );
|
|
||||||
break;
|
|
||||||
endswitch;
|
|
||||||
endif;
|
|
||||||
else:
|
|
||||||
if ( $untranslated_text == 'Archives' && is_tax( 'sp_venue' ) ):
|
|
||||||
$slug = get_query_var( 'sp_venue' );
|
|
||||||
if ( $slug ):
|
|
||||||
$venue = get_term_by( 'slug', $slug, 'sp_venue' );
|
|
||||||
$translated_text = $venue->name;
|
|
||||||
endif;
|
|
||||||
endif;
|
|
||||||
if ( isset( $sportspress_options['text'] ) ):
|
|
||||||
foreach( $sportspress_options['text'] as $key => $value ):
|
|
||||||
if ( $translated_text == $key ):
|
|
||||||
$translated_text = $value;
|
|
||||||
endif;
|
|
||||||
endforeach;
|
|
||||||
endif;
|
|
||||||
endif;
|
|
||||||
|
|
||||||
return $translated_text;
|
|
||||||
}
|
|
||||||
add_filter( 'gettext', 'sportspress_gettext', 20, 3 );
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
<?php
|
|
||||||
function sportspress_default_venue_content( $query ) {
|
|
||||||
if ( ! is_tax( 'sp_venue' ) )
|
|
||||||
return;
|
|
||||||
|
|
||||||
$slug = sportspress_array_value( $query->query, 'sp_venue', null );
|
|
||||||
|
|
||||||
if ( ! $slug )
|
|
||||||
return;
|
|
||||||
|
|
||||||
$venue = get_term_by( 'slug', $slug, 'sp_venue' );
|
|
||||||
$t_id = $venue->term_id;
|
|
||||||
$venue_meta = get_option( "taxonomy_$t_id" );
|
|
||||||
$address = sportspress_array_value( $venue_meta, 'sp_address', null );
|
|
||||||
$latitude = sportspress_array_value( $venue_meta, 'sp_latitude', null );
|
|
||||||
$longitude = sportspress_array_value( $venue_meta, 'sp_longitude', null );
|
|
||||||
|
|
||||||
if ( $latitude != null && $longitude != null )
|
|
||||||
echo '<div class="sp-google-map" data-address="' . $address . '" data-latitude="' . $latitude . '" data-longitude="' . $longitude . '"></div>';
|
|
||||||
}
|
|
||||||
add_action( 'loop_start', 'sportspress_default_venue_content' );
|
|
||||||
@@ -1,143 +0,0 @@
|
|||||||
<?php
|
|
||||||
function sportspress_manage_posts_columns( $defaults ){
|
|
||||||
$defaults['sp_views'] = __( 'Views', 'sportspress' );
|
|
||||||
return $defaults;
|
|
||||||
}
|
|
||||||
add_filter( 'manage_posts_columns', 'sportspress_manage_posts_columns' );
|
|
||||||
add_filter( 'manage_page_posts_columns', 'sportspress_manage_posts_columns' );
|
|
||||||
|
|
||||||
function sportspress_manage_posts_custom_column( $column, $post_id ) {
|
|
||||||
global $post;
|
|
||||||
switch ( $column ):
|
|
||||||
case 'sp_format':
|
|
||||||
$format = get_post_meta( $post_id, 'sp_format', true );
|
|
||||||
switch ( $format ):
|
|
||||||
case 'league':
|
|
||||||
echo '<span class="dashicons sp-icon-crown tips" title="' . __( 'League', 'sportspress' ) . '"></span>';
|
|
||||||
break;
|
|
||||||
case 'friendly':
|
|
||||||
echo '<span class="dashicons sp-icon-smile tips" title="' . __( 'Friendly', 'sportspress' ) . '"></span>';
|
|
||||||
break;
|
|
||||||
endswitch;
|
|
||||||
break;
|
|
||||||
case 'sp_icon':
|
|
||||||
edit_post_link( get_the_post_thumbnail( $post_id, 'sportspress-fit-icon' ), '', '', $post_id );
|
|
||||||
break;
|
|
||||||
case 'sp_number':
|
|
||||||
$number = get_post_meta( $post_id, 'sp_number', true );
|
|
||||||
if ( $number != null ):
|
|
||||||
echo '<strong>' . $number . '</strong>';
|
|
||||||
endif;
|
|
||||||
break;
|
|
||||||
case 'sp_views':
|
|
||||||
echo sportspress_get_post_views( $post_id );
|
|
||||||
break;
|
|
||||||
case 'sp_position':
|
|
||||||
echo get_the_terms( $post_id, 'sp_position' ) ? the_terms( $post_id, 'sp_position' ) : '—';
|
|
||||||
break;
|
|
||||||
case 'sp_positions':
|
|
||||||
echo get_the_terms( $post_id, 'sp_position' ) ? the_terms( $post_id, 'sp_position' ) : '—';
|
|
||||||
break;
|
|
||||||
case 'sp_team':
|
|
||||||
$post_type = get_post_type( $post );
|
|
||||||
$teams = (array)get_post_meta( $post_id, 'sp_team', false );
|
|
||||||
$teams = array_filter( $teams );
|
|
||||||
if ( empty( $teams ) ):
|
|
||||||
echo '—';
|
|
||||||
break;
|
|
||||||
elseif ( $post_type == 'sp_event' ):
|
|
||||||
$results = get_post_meta( $post_id, 'sp_results', true );
|
|
||||||
global $sportspress_options;
|
|
||||||
$main_result = sportspress_array_value( $sportspress_options, 'main_result', null );
|
|
||||||
foreach( $teams as $team_id ):
|
|
||||||
if ( ! $team_id ) continue;
|
|
||||||
$team = get_post( $team_id );
|
|
||||||
|
|
||||||
if ( $team ):
|
|
||||||
$team_results = sportspress_array_value( $results, $team_id, null );
|
|
||||||
|
|
||||||
if ( $main_result ):
|
|
||||||
$team_result = sportspress_array_value( $team_results, $main_result, null );
|
|
||||||
else:
|
|
||||||
if ( is_array( $team_results ) ):
|
|
||||||
end( $team_results );
|
|
||||||
$team_result = prev( $team_results );
|
|
||||||
else:
|
|
||||||
$team_result = null;
|
|
||||||
endif;
|
|
||||||
endif;
|
|
||||||
|
|
||||||
if ( $team_result != null ):
|
|
||||||
unset( $team_results['outcome'] );
|
|
||||||
$team_results = implode( ' | ', $team_results );
|
|
||||||
echo '<a class="result tips" title="' . $team_results . '" href="' . get_edit_post_link( $post_id ) . '">' . $team_result . '</a> ';
|
|
||||||
endif;
|
|
||||||
|
|
||||||
echo $team->post_title;
|
|
||||||
|
|
||||||
echo '<br>';
|
|
||||||
endif;
|
|
||||||
endforeach;
|
|
||||||
elseif ( $post_type == 'sp_player' ):
|
|
||||||
$current_team = get_post_meta( $post_id, 'sp_current_team', true );
|
|
||||||
foreach( $teams as $team_id ):
|
|
||||||
if ( ! $team_id ) continue;
|
|
||||||
$team = get_post( $team_id );
|
|
||||||
if ( $team ):
|
|
||||||
echo $team->post_title;
|
|
||||||
if ( $team_id == $current_team ):
|
|
||||||
echo '<span class="dashicons dashicons-yes" title="' . __( 'Current Team', 'sportspress' ) . '"></span>';
|
|
||||||
endif;
|
|
||||||
echo '<br>';
|
|
||||||
endif;
|
|
||||||
endforeach;
|
|
||||||
elseif ( $post_type == 'sp_table' ):
|
|
||||||
echo sportspress_posts( $post_id, 'sp_team' );
|
|
||||||
else:
|
|
||||||
foreach( $teams as $team_id ):
|
|
||||||
if ( ! $team_id ) continue;
|
|
||||||
$team = get_post( $team_id );
|
|
||||||
if ( $team ) echo $team->post_title . '<br>';
|
|
||||||
endforeach;
|
|
||||||
endif;
|
|
||||||
break;
|
|
||||||
case 'sp_equation':
|
|
||||||
echo sportspress_get_post_equation( $post_id );
|
|
||||||
break;
|
|
||||||
case 'sp_order':
|
|
||||||
echo sportspress_get_post_order( $post_id );
|
|
||||||
break;
|
|
||||||
case 'sp_key':
|
|
||||||
echo $post->post_name;
|
|
||||||
break;
|
|
||||||
case 'sp_precision':
|
|
||||||
echo sportspress_get_post_precision( $post_id );
|
|
||||||
break;
|
|
||||||
case 'sp_calculate':
|
|
||||||
echo sportspress_get_post_calculate( $post_id );
|
|
||||||
break;
|
|
||||||
case 'sp_player':
|
|
||||||
echo sportspress_posts( $post_id, 'sp_player' );
|
|
||||||
break;
|
|
||||||
case 'sp_league':
|
|
||||||
echo get_the_terms ( $post_id, 'sp_league' ) ? the_terms( $post_id, 'sp_league' ) : '—';
|
|
||||||
break;
|
|
||||||
case 'sp_season':
|
|
||||||
echo get_the_terms ( $post_id, 'sp_season' ) ? the_terms( $post_id, 'sp_season' ) : '—';
|
|
||||||
break;
|
|
||||||
case 'sp_venue':
|
|
||||||
echo get_the_terms ( $post_id, 'sp_venue' ) ? the_terms( $post_id, 'sp_venue' ) : '—';
|
|
||||||
break;
|
|
||||||
case 'sp_time':
|
|
||||||
echo get_post_time( 'H:i', false, $post );
|
|
||||||
break;
|
|
||||||
case 'sp_events':
|
|
||||||
echo sizeof( sportspress_get_calendar_data( $post_id ) );
|
|
||||||
break;
|
|
||||||
case 'sp_address':
|
|
||||||
echo get_post_meta( $post_id, 'sp_address', true ) ? get_post_meta( $post_id, 'sp_address', true ) : '—';
|
|
||||||
break;
|
|
||||||
endswitch;
|
|
||||||
}
|
|
||||||
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,13 +0,0 @@
|
|||||||
<?php
|
|
||||||
function sportspress_parse_query( $query ) {
|
|
||||||
global $pagenow, $typenow;
|
|
||||||
|
|
||||||
if ( is_admin() && $pagenow == 'edit.php' ):
|
|
||||||
|
|
||||||
if( in_array( $typenow, array( 'sp_event', 'sp_table', 'sp_player', 'sp_list', 'sp_staff' ) ) && isset( $_GET['team'] ) && $_GET['team'] != null ):
|
|
||||||
$query->query_vars['meta_key'] = 'sp_team';
|
|
||||||
$query->query_vars['meta_value'] = $_GET['team'];
|
|
||||||
endif;
|
|
||||||
endif;
|
|
||||||
}
|
|
||||||
add_filter('parse_query', 'sportspress_parse_query');
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
<?php
|
|
||||||
function sportspress_plugins_loaded() {
|
|
||||||
|
|
||||||
// Load plugin textdomain
|
|
||||||
if ( function_exists( 'load_plugin_textdomain' ) ) {
|
|
||||||
load_plugin_textdomain ( 'sportspress', false, dirname( plugin_basename( SP_PLUGIN_FILE ) ) . '/languages/' );
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add image sizes
|
|
||||||
if ( function_exists( 'add_image_size' ) ) {
|
|
||||||
|
|
||||||
// Standard (3:2)
|
|
||||||
add_image_size( 'sportspress-standard', 637, 425, true );
|
|
||||||
add_image_size( 'sportspress-standard-thumbnail', 303, 202, true );
|
|
||||||
|
|
||||||
// Wide (16:9)
|
|
||||||
add_image_size( 'sportspress-wide-header', 1600, 900, true );
|
|
||||||
add_image_size( 'sportspress-wide', 637, 358, true );
|
|
||||||
add_image_size( 'sportspress-wide-thumbnail', 303, 170, true );
|
|
||||||
|
|
||||||
// Square (1:1)
|
|
||||||
add_image_size( 'sportspress-square', 637, 637, true );
|
|
||||||
add_image_size( 'sportspress-square-thumbnail', 303, 303, true );
|
|
||||||
|
|
||||||
// Fit (Proportional)
|
|
||||||
add_image_size( 'sportspress-fit', 637, 637, false );
|
|
||||||
add_image_size( 'sportspress-fit-thumbnail', 303, 303, false );
|
|
||||||
add_image_size( 'sportspress-fit-icon', 32, 32, false );
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
add_action( 'plugins_loaded', 'sportspress_plugins_loaded' );
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
<?php
|
|
||||||
function sportspress_post_thumbnail_html( $html, $post_id, $post_thumbnail_id, $size, $attr ) {
|
|
||||||
if( empty ( $html ) && get_post_type( $post_id ) == 'sp_team' ) {
|
|
||||||
$parents = get_post_ancestors( $post_id );
|
|
||||||
foreach ( $parents as $parent ) {
|
|
||||||
if( has_post_thumbnail( $parent ) ) {
|
|
||||||
$html = get_the_post_thumbnail( $parent, $size, $attr );
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return $html;
|
|
||||||
}
|
|
||||||
add_filter( 'post_thumbnail_html', 'sportspress_post_thumbnail_html', 10, 5 );
|
|
||||||
@@ -1,48 +0,0 @@
|
|||||||
<?php
|
|
||||||
function sportspress_post_updated_messages( $messages ) {
|
|
||||||
|
|
||||||
global $typenow, $post;
|
|
||||||
|
|
||||||
if ( in_array( $typenow, array( 'sp_result', 'sp_outcome', 'sp_column', 'sp_metric', 'sp_performance' ) ) ):
|
|
||||||
$obj = get_post_type_object( $typenow );
|
|
||||||
|
|
||||||
for ( $i = 0; $i <= 10; $i++ ):
|
|
||||||
$messages['post'][ $i ] = __( 'Settings saved.', 'sportspress' ) .
|
|
||||||
' <a href="' . esc_url( admin_url( 'edit.php?post_type=' . $typenow ) ) . '">' .
|
|
||||||
__( 'View All', 'sportspress' ) . '</a>';
|
|
||||||
endfor;
|
|
||||||
|
|
||||||
elseif ( in_array( $typenow, array( 'sp_event', 'sp_team', 'sp_table', 'sp_player', 'sp_list', 'sp_staff' ) ) ):
|
|
||||||
$obj = get_post_type_object( $typenow );
|
|
||||||
|
|
||||||
$messages['post'][1] = __( 'Changes saved.', 'sportspress' ) .
|
|
||||||
' <a href="' . esc_url( get_permalink($post->ID) ) . '">' . $obj->labels->view_item . '</a>';
|
|
||||||
|
|
||||||
$messages['post'][4] = __( 'Changes saved.', 'sportspress' );
|
|
||||||
|
|
||||||
$messages['post'][6] = __( 'Success!', 'sportspress' ) .
|
|
||||||
' <a href="' . esc_url( get_permalink($post->ID) ) . '">' . $obj->labels->view_item . '</a>';
|
|
||||||
|
|
||||||
$messages['post'][7] = __( 'Changes saved.', 'sportspress' );
|
|
||||||
|
|
||||||
$messages['post'][8] = __( 'Success!', 'sportspress' ) .
|
|
||||||
' <a target="_blank" href="' . esc_url( add_query_arg( 'preview', 'true', get_permalink($post->ID) ) ) . '">' .
|
|
||||||
sprintf( __( 'Preview %s', 'sportspress' ), $obj->labels->singular_name ) . '</a>';
|
|
||||||
|
|
||||||
$messages['post'][9] = sprintf(
|
|
||||||
__( 'Scheduled for: <b>%1$s</b>.', 'sportspress' ),
|
|
||||||
date_i18n( __( 'M j, Y @ G:i', 'sportspress' ), strtotime( $post->post_date ) ), esc_url( get_permalink($post->ID) ) ) .
|
|
||||||
' <a target="_blank" href="' . esc_url( get_permalink($post->ID) ) . '">' .
|
|
||||||
sprintf( __( 'Preview %s', 'sportspress' ), $obj->labels->singular_name ) . '</a>';
|
|
||||||
|
|
||||||
$messages['post'][10] = __( 'Success!', 'sportspress' ) .
|
|
||||||
' <a target="_blank" href="' . esc_url( add_query_arg( 'preview', 'true', get_permalink($post->ID) ) ) . '">' .
|
|
||||||
sprintf( __( 'Preview %s', 'sportspress' ), $obj->labels->singular_name ) . '</a>';
|
|
||||||
|
|
||||||
endif;
|
|
||||||
|
|
||||||
return $messages;
|
|
||||||
}
|
|
||||||
|
|
||||||
add_filter('post_updated_messages', 'sportspress_post_updated_messages');
|
|
||||||
?>
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
<?php
|
|
||||||
function sportspress_pre_get_posts( $query ) {
|
|
||||||
|
|
||||||
if ( is_admin() ):
|
|
||||||
if ( isset( $query->query[ 'orderby' ] ) || isset( $query->query[ 'order' ] ) ):
|
|
||||||
return $query;
|
|
||||||
endif;
|
|
||||||
$post_type = $query->query['post_type'];
|
|
||||||
|
|
||||||
if ( in_array( $post_type, array( 'sp_result', 'sp_outcome', 'sp_column', 'sp_performance' ) ) ):
|
|
||||||
$query->set( 'orderby', 'menu_order' );
|
|
||||||
$query->set( 'order', 'ASC' );
|
|
||||||
elseif ( $post_type == 'sp_event' ):
|
|
||||||
$query->set( 'orderby', 'post_date' );
|
|
||||||
$query->set( 'order', 'ASC' );
|
|
||||||
endif;
|
|
||||||
else:
|
|
||||||
$post_type = $query->get( 'post_type' );
|
|
||||||
if ( $query->is_post_type_archive && $post_type == 'sp_event' ):
|
|
||||||
$query->set( 'order' , 'ASC' );
|
|
||||||
endif;
|
|
||||||
endif;
|
|
||||||
|
|
||||||
return $query;
|
|
||||||
}
|
|
||||||
add_filter('pre_get_posts', 'sportspress_pre_get_posts');
|
|
||||||
@@ -1,165 +0,0 @@
|
|||||||
<?php
|
|
||||||
function sportspress_activation_hook() {
|
|
||||||
|
|
||||||
// League Manager
|
|
||||||
remove_role( 'sp_league_manager' );
|
|
||||||
add_role(
|
|
||||||
'sp_league_manager',
|
|
||||||
__( 'League Manager', 'sportspress' ),
|
|
||||||
array(
|
|
||||||
'read' => true,
|
|
||||||
'edit_posts' => true,
|
|
||||||
'delete_posts' => true,
|
|
||||||
'upload_files' => true,
|
|
||||||
|
|
||||||
'edit_sp_player' => true,
|
|
||||||
'edit_sp_players' => true,
|
|
||||||
'edit_others_sp_players' => true,
|
|
||||||
'edit_private_sp_players' => true,
|
|
||||||
'edit_published_sp_players' => true,
|
|
||||||
'read_sp_players' => true,
|
|
||||||
'read_private_sp_players' => true,
|
|
||||||
'publish_sp_players' => true,
|
|
||||||
'delete_sp_players' => true,
|
|
||||||
'delete_others_sp_players' => true,
|
|
||||||
'delete_private_sp_players' => true,
|
|
||||||
'delete_published_sp_players' => true,
|
|
||||||
|
|
||||||
'edit_sp_staff' => true,
|
|
||||||
'edit_sp_staffs' => true,
|
|
||||||
'edit_others_sp_staffs' => true,
|
|
||||||
'edit_private_sp_staffs' => true,
|
|
||||||
'edit_published_sp_staffs' => true,
|
|
||||||
'read_sp_staffs' => true,
|
|
||||||
'read_private_sp_staffs' => true,
|
|
||||||
'publish_sp_staffs' => true,
|
|
||||||
'delete_sp_staffs' => true,
|
|
||||||
'delete_others_sp_staffs' => true,
|
|
||||||
'delete_private_sp_staffs' => true,
|
|
||||||
'delete_published_sp_staffs' => true,
|
|
||||||
|
|
||||||
'edit_sp_team' => true,
|
|
||||||
'edit_sp_teams' => true,
|
|
||||||
'edit_others_sp_teams' => true,
|
|
||||||
'edit_private_sp_teams' => true,
|
|
||||||
'edit_published_sp_teams' => true,
|
|
||||||
'read_sp_teams' => true,
|
|
||||||
'read_private_sp_teams' => true,
|
|
||||||
'publish_sp_teams' => true,
|
|
||||||
'delete_sp_teams' => true,
|
|
||||||
'delete_others_sp_teams' => true,
|
|
||||||
'delete_private_sp_teams' => true,
|
|
||||||
'delete_published_sp_teams' => true,
|
|
||||||
|
|
||||||
'edit_sp_list' => true,
|
|
||||||
'edit_sp_lists' => true,
|
|
||||||
'edit_others_sp_lists' => true,
|
|
||||||
'edit_private_sp_lists' => true,
|
|
||||||
'edit_published_sp_lists' => true,
|
|
||||||
'read_sp_lists' => true,
|
|
||||||
'read_private_sp_lists' => true,
|
|
||||||
'publish_sp_lists' => true,
|
|
||||||
'delete_sp_lists' => true,
|
|
||||||
'delete_others_sp_lists' => true,
|
|
||||||
'delete_private_sp_lists' => true,
|
|
||||||
'delete_published_sp_lists' => true,
|
|
||||||
|
|
||||||
'edit_sp_table' => true,
|
|
||||||
'edit_sp_tables' => true,
|
|
||||||
'edit_private_sp_tables' => true,
|
|
||||||
'edit_published_sp_tables' => true,
|
|
||||||
'read_sp_tables' => true,
|
|
||||||
'read_private_sp_tables' => true,
|
|
||||||
'publish_sp_tables' => true,
|
|
||||||
'delete_sp_tables' => true,
|
|
||||||
'delete_private_sp_tables' => true,
|
|
||||||
'delete_published_sp_tables' => true,
|
|
||||||
|
|
||||||
'view_sportspress_reports' => true,
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
// Team Manager
|
|
||||||
remove_role( 'sp_team_manager' );
|
|
||||||
add_role(
|
|
||||||
'sp_team_manager',
|
|
||||||
__( 'Team Manager', 'sportspress' ),
|
|
||||||
array(
|
|
||||||
'read' => true,
|
|
||||||
'edit_posts' => true,
|
|
||||||
'delete_posts' => true,
|
|
||||||
'upload_files' => true,
|
|
||||||
|
|
||||||
'edit_sp_player' => true,
|
|
||||||
'edit_sp_players' => true,
|
|
||||||
'edit_private_sp_players' => true,
|
|
||||||
'edit_published_sp_players' => true,
|
|
||||||
'read_sp_players' => true,
|
|
||||||
'read_private_sp_players' => true,
|
|
||||||
'publish_sp_players' => true,
|
|
||||||
'delete_sp_players' => true,
|
|
||||||
'delete_private_sp_players' => true,
|
|
||||||
'delete_published_sp_players' => true,
|
|
||||||
|
|
||||||
'edit_sp_staff' => true,
|
|
||||||
'edit_sp_staffs' => true,
|
|
||||||
'edit_private_sp_staffs' => true,
|
|
||||||
'edit_published_sp_staffs' => true,
|
|
||||||
'read_sp_staffs' => true,
|
|
||||||
'read_private_sp_staffs' => true,
|
|
||||||
'publish_sp_staffs' => true,
|
|
||||||
'delete_sp_staffs' => true,
|
|
||||||
'delete_private_sp_staffs' => true,
|
|
||||||
'delete_published_sp_staffs' => true,
|
|
||||||
|
|
||||||
'edit_sp_team' => true,
|
|
||||||
'edit_sp_teams' => true,
|
|
||||||
'read_sp_teams' => true,
|
|
||||||
'delete_sp_teams' => true,
|
|
||||||
|
|
||||||
'edit_sp_list' => true,
|
|
||||||
'edit_sp_lists' => true,
|
|
||||||
'read_sp_lists' => true,
|
|
||||||
'delete_sp_lists' => true,
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
// Staff
|
|
||||||
remove_role( 'sp_staff' );
|
|
||||||
add_role(
|
|
||||||
'sp_staff',
|
|
||||||
__( 'Staff', 'sportspress' ),
|
|
||||||
array(
|
|
||||||
'read' => true,
|
|
||||||
'edit_posts' => true,
|
|
||||||
'delete_posts' => true,
|
|
||||||
'upload_files' => true,
|
|
||||||
|
|
||||||
'edit_sp_staff' => true,
|
|
||||||
'edit_sp_staffs' => true,
|
|
||||||
'read_sp_staffs' => true,
|
|
||||||
'delete_sp_staffs' => true,
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
// Player
|
|
||||||
remove_role( 'sp_player' );
|
|
||||||
add_role(
|
|
||||||
'sp_player',
|
|
||||||
__( 'Player', 'sportspress' ),
|
|
||||||
array(
|
|
||||||
'read' => true,
|
|
||||||
'edit_posts' => true,
|
|
||||||
'delete_posts' => true,
|
|
||||||
'upload_files' => true,
|
|
||||||
|
|
||||||
'edit_sp_player' => true,
|
|
||||||
'edit_sp_players' => true,
|
|
||||||
'read_sp_players' => true,
|
|
||||||
'delete_sp_players' => true,
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
sportspress_flush_rewrite_rules();
|
|
||||||
}
|
|
||||||
register_activation_hook( SP_PLUGIN_FILE, 'sportspress_activation_hook' );
|
|
||||||
@@ -1,47 +0,0 @@
|
|||||||
<?php
|
|
||||||
function sportspress_restrict_manage_posts() {
|
|
||||||
sportspress_highlight_admin_menu();
|
|
||||||
global $typenow, $wp_query;
|
|
||||||
if ( in_array( $typenow, array( 'sp_player' ) ) ):
|
|
||||||
$selected = isset( $_REQUEST['sp_position'] ) ? $_REQUEST['sp_position'] : null;
|
|
||||||
$args = array(
|
|
||||||
'show_option_all' => __( 'Show all positions', 'sportspress' ),
|
|
||||||
'taxonomy' => 'sp_position',
|
|
||||||
'name' => 'sp_position',
|
|
||||||
'selected' => $selected
|
|
||||||
);
|
|
||||||
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_league'] ) ? $_REQUEST['sp_league'] : null;
|
|
||||||
$args = array(
|
|
||||||
'show_option_all' => __( 'Show all leagues', 'sportspress' ),
|
|
||||||
'taxonomy' => 'sp_league',
|
|
||||||
'name' => 'sp_league',
|
|
||||||
'selected' => $selected
|
|
||||||
);
|
|
||||||
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;
|
|
||||||
$args = array(
|
|
||||||
'show_option_all' => __( 'Show all seasons', 'sportspress' ),
|
|
||||||
'taxonomy' => 'sp_season',
|
|
||||||
'name' => 'sp_season',
|
|
||||||
'selected' => $selected
|
|
||||||
);
|
|
||||||
sportspress_dropdown_taxonomies( $args );
|
|
||||||
endif;
|
|
||||||
if ( in_array( $typenow, array( 'sp_event', 'sp_table', 'sp_player', 'sp_list', 'sp_staff' ) ) ):
|
|
||||||
$selected = isset( $_REQUEST['team'] ) ? $_REQUEST['team'] : null;
|
|
||||||
$args = array(
|
|
||||||
'post_type' => 'sp_team',
|
|
||||||
'name' => 'team',
|
|
||||||
'show_option_none' => __( 'Show all teams', 'sportspress' ),
|
|
||||||
'selected' => $selected,
|
|
||||||
'values' => 'ID',
|
|
||||||
);
|
|
||||||
wp_dropdown_pages( $args );
|
|
||||||
endif;
|
|
||||||
}
|
|
||||||
add_action( 'restrict_manage_posts', 'sportspress_restrict_manage_posts' );
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
<?php
|
|
||||||
function sportspress_sanitize_title( $title ) {
|
|
||||||
|
|
||||||
if ( isset( $_POST ) && array_key_exists( 'taxonomy', $_POST ) ):
|
|
||||||
|
|
||||||
return $title;
|
|
||||||
|
|
||||||
elseif ( isset( $_POST ) && array_key_exists( 'post_type', $_POST ) && in_array( $_POST['post_type'], array( 'sp_result', 'sp_outcome', 'sp_column', 'sp_performance', 'sp_metric' ) ) ):
|
|
||||||
|
|
||||||
$key = isset( $_POST['sp_key'] ) ? $_POST['sp_key'] : null;
|
|
||||||
|
|
||||||
if ( ! $key ) $key = $_POST['post_title'];
|
|
||||||
|
|
||||||
$id = sportspress_array_value( $_POST, 'post_ID', 'var' );
|
|
||||||
|
|
||||||
$title = sportspress_get_eos_safe_slug( $key, $id );
|
|
||||||
|
|
||||||
elseif ( isset( $_POST ) && array_key_exists( 'post_type', $_POST ) && $_POST['post_type'] == 'sp_event' ):
|
|
||||||
|
|
||||||
// Auto slug generation
|
|
||||||
if ( $_POST['post_title'] == '' && ( $_POST['post_name'] == '' || is_int( $_POST['post_name'] ) ) ):
|
|
||||||
|
|
||||||
$title = '';
|
|
||||||
|
|
||||||
endif;
|
|
||||||
|
|
||||||
endif;
|
|
||||||
|
|
||||||
return $title;
|
|
||||||
}
|
|
||||||
add_filter( 'sanitize_title', 'sportspress_sanitize_title' );
|
|
||||||
@@ -1,210 +0,0 @@
|
|||||||
<?php
|
|
||||||
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;
|
|
||||||
if ( !isset( $_POST['sportspress_nonce'] ) || ! wp_verify_nonce( $_POST['sportspress_nonce'], plugin_basename( SP_PLUGIN_FILE ) ) ) return $post_id;
|
|
||||||
switch ( $_POST['post_type'] ):
|
|
||||||
|
|
||||||
case ( 'sp_team' ):
|
|
||||||
|
|
||||||
// Update leagues seasons to show
|
|
||||||
update_post_meta( $post_id, 'sp_leagues_seasons', sportspress_array_value( $_POST, 'sp_leagues_seasons', array() ) );
|
|
||||||
|
|
||||||
// Update team columns array
|
|
||||||
if ( current_user_can( 'edit_sp_tables' ) )
|
|
||||||
update_post_meta( $post_id, 'sp_columns', sportspress_array_value( $_POST, 'sp_columns', array() ) );
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
case ( 'sp_event' ):
|
|
||||||
|
|
||||||
// Get results
|
|
||||||
$results = (array)sportspress_array_value( $_POST, 'sp_results', array() );
|
|
||||||
|
|
||||||
// Update results
|
|
||||||
update_post_meta( $post_id, 'sp_results', $results );
|
|
||||||
|
|
||||||
// Update player performance
|
|
||||||
update_post_meta( $post_id, 'sp_players', sportspress_array_value( $_POST, 'sp_players', array() ) );
|
|
||||||
|
|
||||||
// Update team array
|
|
||||||
sportspress_update_post_meta_recursive( $post_id, 'sp_team', sportspress_array_value( $_POST, 'sp_team', array() ) );
|
|
||||||
|
|
||||||
// Update player array
|
|
||||||
sportspress_update_post_meta_recursive( $post_id, 'sp_player', sportspress_array_value( $_POST, 'sp_player', array() ) );
|
|
||||||
|
|
||||||
// Update staff array
|
|
||||||
sportspress_update_post_meta_recursive( $post_id, 'sp_staff', sportspress_array_value( $_POST, 'sp_staff', array() ) );
|
|
||||||
|
|
||||||
// Update format
|
|
||||||
update_post_meta( $post_id, 'sp_format', sportspress_array_value( $_POST, 'sp_format', 'league' ) );
|
|
||||||
|
|
||||||
// Update league taxonomy
|
|
||||||
wp_set_post_terms( $post_id, sportspress_array_value( $_POST, 'sp_league', 0 ), 'sp_league' );
|
|
||||||
|
|
||||||
// Update season taxonomy
|
|
||||||
wp_set_post_terms( $post_id, sportspress_array_value( $_POST, 'sp_season', 0 ), 'sp_season' );
|
|
||||||
|
|
||||||
// Update venue taxonomy
|
|
||||||
wp_set_post_terms( $post_id, sportspress_array_value( $_POST, 'sp_venue', 0 ), 'sp_venue' );
|
|
||||||
|
|
||||||
// Update video
|
|
||||||
update_post_meta( $post_id, 'sp_video', sportspress_array_value( $_POST, 'sp_video', null ) );
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
case ( 'sp_calendar' ):
|
|
||||||
|
|
||||||
// Update columns array
|
|
||||||
update_post_meta( $post_id, 'sp_columns', sportspress_array_value( $_POST, 'sp_columns', array() ) );
|
|
||||||
|
|
||||||
// Update format
|
|
||||||
update_post_meta( $post_id, 'sp_format', sportspress_array_value( $_POST, 'sp_format', 'calendar' ) );
|
|
||||||
|
|
||||||
// Update league taxonomy
|
|
||||||
wp_set_post_terms( $post_id, sportspress_array_value( $_POST, 'sp_league', 0 ), 'sp_league' );
|
|
||||||
|
|
||||||
// Update season taxonomy
|
|
||||||
wp_set_post_terms( $post_id, sportspress_array_value( $_POST, 'sp_season', 0 ), 'sp_season' );
|
|
||||||
|
|
||||||
// Update venue taxonomy
|
|
||||||
wp_set_post_terms( $post_id, sportspress_array_value( $_POST, 'sp_venue', 0 ), 'sp_venue' );
|
|
||||||
|
|
||||||
// Update team
|
|
||||||
update_post_meta( $post_id, 'sp_team', sportspress_array_value( $_POST, 'sp_team', 0 ) );
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
case ( 'sp_result' ):
|
|
||||||
|
|
||||||
// Delete posts with duplicate key
|
|
||||||
sportspress_delete_duplicate_post( $_POST );
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
case ( 'sp_outcome' ):
|
|
||||||
|
|
||||||
// Delete posts with duplicate key
|
|
||||||
sportspress_delete_duplicate_post( $_POST );
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
case ( 'sp_column' ):
|
|
||||||
|
|
||||||
// Delete posts with duplicate key
|
|
||||||
sportspress_delete_duplicate_post( $_POST );
|
|
||||||
|
|
||||||
// Update equation as string
|
|
||||||
update_post_meta( $post_id, 'sp_equation', implode( ' ', sportspress_array_value( $_POST, 'sp_equation', array() ) ) );
|
|
||||||
|
|
||||||
// Update precision as integer
|
|
||||||
update_post_meta( $post_id, 'sp_precision', (int) sportspress_array_value( $_POST, 'sp_precision', 1 ) );
|
|
||||||
|
|
||||||
// Update sort order as string
|
|
||||||
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', sportspress_array_value( $_POST, 'sp_order', 'DESC' ) );
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
case ( 'sp_performance' ):
|
|
||||||
|
|
||||||
// Delete posts with duplicate key
|
|
||||||
sportspress_delete_duplicate_post( $_POST );
|
|
||||||
|
|
||||||
// Update calculation method as string
|
|
||||||
update_post_meta( $post_id, 'sp_calculate', sportspress_array_value( $_POST, 'sp_calculate', 'DESC' ) );
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
case ( 'sp_player' ):
|
|
||||||
|
|
||||||
// Update teams to show
|
|
||||||
update_post_meta( $post_id, 'sp_leagues', sportspress_array_value( $_POST, 'sp_leagues', array() ) );
|
|
||||||
|
|
||||||
// Update current team
|
|
||||||
update_post_meta( $post_id, 'sp_current_team', sportspress_array_value( $_POST, 'sp_current_team', null ) );
|
|
||||||
|
|
||||||
// Update past team array
|
|
||||||
sportspress_update_post_meta_recursive( $post_id, 'sp_past_team', sportspress_array_value( $_POST, 'sp_past_team', array() ) );
|
|
||||||
|
|
||||||
// Update team array
|
|
||||||
sportspress_update_post_meta_recursive( $post_id, 'sp_team', array_merge( array( sportspress_array_value( $_POST, 'sp_current_team', null ) ), sportspress_array_value( $_POST, 'sp_past_team', array() ) ) );
|
|
||||||
|
|
||||||
// Update player number
|
|
||||||
update_post_meta( $post_id, 'sp_number', sportspress_array_value( $_POST, 'sp_number', '' ) );
|
|
||||||
|
|
||||||
// Update nationality
|
|
||||||
update_post_meta( $post_id, 'sp_nationality', sportspress_array_value( $_POST, 'sp_nationality', '' ) );
|
|
||||||
|
|
||||||
// Update player metrics array
|
|
||||||
update_post_meta( $post_id, 'sp_metrics', sportspress_array_value( $_POST, 'sp_metrics', array() ) );
|
|
||||||
|
|
||||||
// Update player performance array
|
|
||||||
if ( current_user_can( 'edit_sp_teams' ) )
|
|
||||||
update_post_meta( $post_id, 'sp_performance', sportspress_array_value( $_POST, 'sp_performance', array() ) );
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
case ( 'sp_staff' ):
|
|
||||||
|
|
||||||
// Update team array
|
|
||||||
sportspress_update_post_meta_recursive( $post_id, 'sp_team', sportspress_array_value( $_POST, 'sp_team', array() ) );
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
case ( 'sp_table' ):
|
|
||||||
|
|
||||||
// Update columns array
|
|
||||||
update_post_meta( $post_id, 'sp_columns', sportspress_array_value( $_POST, 'sp_columns', array() ) );
|
|
||||||
|
|
||||||
// Update teams array
|
|
||||||
update_post_meta( $post_id, 'sp_teams', sportspress_array_value( $_POST, 'sp_teams', array() ) );
|
|
||||||
|
|
||||||
// Update league taxonomy
|
|
||||||
wp_set_post_terms( $post_id, sportspress_array_value( $_POST, 'sp_league', 0 ), 'sp_league' );
|
|
||||||
|
|
||||||
// Update season taxonomy
|
|
||||||
wp_set_post_terms( $post_id, sportspress_array_value( $_POST, 'sp_season', 0 ), 'sp_season' );
|
|
||||||
|
|
||||||
// Update team array
|
|
||||||
sportspress_update_post_meta_recursive( $post_id, 'sp_team', sportspress_array_value( $_POST, 'sp_team', array() ) );
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
case ( 'sp_list' ):
|
|
||||||
|
|
||||||
// Update performance array
|
|
||||||
update_post_meta( $post_id, 'sp_columns', sportspress_array_value( $_POST, 'sp_columns', array() ) );
|
|
||||||
|
|
||||||
// Update 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', sportspress_array_value( $_POST, 'sp_team', array() ) );
|
|
||||||
|
|
||||||
// Update format
|
|
||||||
update_post_meta( $post_id, 'sp_format', sportspress_array_value( $_POST, 'sp_format', 'list' ) );
|
|
||||||
|
|
||||||
// Update league taxonomy
|
|
||||||
wp_set_post_terms( $post_id, sportspress_array_value( $_POST, 'sp_league', 0 ), 'sp_league' );
|
|
||||||
|
|
||||||
// Update season taxonomy
|
|
||||||
wp_set_post_terms( $post_id, sportspress_array_value( $_POST, 'sp_season', 0 ), 'sp_season' );
|
|
||||||
|
|
||||||
// Update orderby
|
|
||||||
update_post_meta( $post_id, 'sp_orderby', sportspress_array_value( $_POST, 'sp_orderby', array() ) );
|
|
||||||
|
|
||||||
// Update order
|
|
||||||
update_post_meta( $post_id, 'sp_order', sportspress_array_value( $_POST, 'sp_order', array() ) );
|
|
||||||
|
|
||||||
//Update player array
|
|
||||||
sportspress_update_post_meta_recursive( $post_id, 'sp_player', sportspress_array_value( $_POST, 'sp_player', array() ) );
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
endswitch;
|
|
||||||
}
|
|
||||||
add_action( 'save_post', 'sportspress_save_post' );
|
|
||||||
@@ -1,121 +0,0 @@
|
|||||||
<?php
|
|
||||||
function sportspress_the_content( $content ) {
|
|
||||||
if ( is_single() || is_page() )
|
|
||||||
sportspress_set_post_views( get_the_ID() );
|
|
||||||
return $content;
|
|
||||||
}
|
|
||||||
add_filter( 'the_content', 'sportspress_the_content' );
|
|
||||||
add_filter( 'get_the_content', 'sportspress_the_content' );
|
|
||||||
|
|
||||||
function sportspress_default_event_content( $content ) {
|
|
||||||
if ( is_singular( 'sp_event' ) && in_the_loop() ):
|
|
||||||
$id = get_the_ID();
|
|
||||||
|
|
||||||
// Video
|
|
||||||
$video_url = get_post_meta( $id, 'sp_video', true );
|
|
||||||
if ( $video_url ):
|
|
||||||
global $wp_embed;
|
|
||||||
echo $wp_embed->autoembed( $video_url );
|
|
||||||
endif;
|
|
||||||
|
|
||||||
// Results
|
|
||||||
sp_get_template( 'event-results.php' );
|
|
||||||
|
|
||||||
// Details
|
|
||||||
sp_get_template( 'event-details.php' );
|
|
||||||
|
|
||||||
// Venue
|
|
||||||
sp_get_template( 'event-venue.php' );
|
|
||||||
|
|
||||||
// Performance
|
|
||||||
sp_get_template( 'event-performance.php' );
|
|
||||||
|
|
||||||
// Staff
|
|
||||||
sp_get_template( 'event-staff.php' );
|
|
||||||
endif;
|
|
||||||
|
|
||||||
return $content;
|
|
||||||
}
|
|
||||||
add_filter( 'the_content', 'sportspress_default_event_content', 7 );
|
|
||||||
|
|
||||||
function sportspress_default_calendar_content( $content ) {
|
|
||||||
if ( is_singular( 'sp_calendar' ) && in_the_loop() ):
|
|
||||||
$id = get_the_ID();
|
|
||||||
$format = get_post_meta( $id, 'sp_format', true );
|
|
||||||
switch ( $format ):
|
|
||||||
case 'list':
|
|
||||||
sp_get_template( 'event-list.php', array(
|
|
||||||
'id' => $id
|
|
||||||
) );
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
sp_get_template( 'event-calendar.php', array(
|
|
||||||
'id' => $id,
|
|
||||||
'initial' => false
|
|
||||||
) );
|
|
||||||
break;
|
|
||||||
endswitch;
|
|
||||||
endif;
|
|
||||||
return $content;
|
|
||||||
}
|
|
||||||
add_filter( 'the_content', 'sportspress_default_calendar_content' );
|
|
||||||
|
|
||||||
function sportspress_default_team_content( $content ) {
|
|
||||||
if ( is_singular( 'sp_team' ) && in_the_loop() ):
|
|
||||||
sp_get_template( 'team-columns.php' );
|
|
||||||
endif;
|
|
||||||
return $content;
|
|
||||||
}
|
|
||||||
add_filter( 'the_content', 'sportspress_default_team_content' );
|
|
||||||
|
|
||||||
function sportspress_default_table_content( $content ) {
|
|
||||||
if ( is_singular( 'sp_table' ) && in_the_loop() ):
|
|
||||||
$id = get_the_ID();
|
|
||||||
$leagues = get_the_terms( $id, 'sp_league' );
|
|
||||||
$seasons = get_the_terms( $id, 'sp_season' );
|
|
||||||
$terms = array();
|
|
||||||
if ( $leagues ):
|
|
||||||
$league = reset( $leagues );
|
|
||||||
$terms[] = $league->name;
|
|
||||||
endif;
|
|
||||||
if ( $seasons ):
|
|
||||||
$season = reset( $seasons );
|
|
||||||
$terms[] = $season->name;
|
|
||||||
endif;
|
|
||||||
$title = '';
|
|
||||||
if ( sizeof( $terms ) )
|
|
||||||
echo '<h4 class="sp-table-caption">' . implode( ' — ', $terms ) . '</h4>';
|
|
||||||
|
|
||||||
sp_get_template( 'league-table.php' );
|
|
||||||
$excerpt = has_excerpt() ? wpautop( get_the_excerpt() ) : '';
|
|
||||||
$content = $content . $excerpt;
|
|
||||||
endif;
|
|
||||||
return $content;
|
|
||||||
}
|
|
||||||
add_filter( 'the_content', 'sportspress_default_table_content' );
|
|
||||||
|
|
||||||
function sportspress_default_player_content( $content ) {
|
|
||||||
if ( is_singular( 'sp_player' ) && in_the_loop() ):
|
|
||||||
sp_get_template( 'player-metrics.php' );
|
|
||||||
sp_get_template( 'player-performance.php' );
|
|
||||||
endif;
|
|
||||||
return $content;
|
|
||||||
}
|
|
||||||
add_filter( 'the_content', 'sportspress_default_player_content' );
|
|
||||||
|
|
||||||
function sportspress_default_list_content( $content ) {
|
|
||||||
if ( is_singular( 'sp_list' ) && in_the_loop() ):
|
|
||||||
$id = get_the_ID();
|
|
||||||
$format = get_post_meta( $id, 'sp_format', true );
|
|
||||||
switch ( $format ):
|
|
||||||
case 'gallery':
|
|
||||||
sp_get_template( 'player-gallery.php' );
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
sp_get_template( 'player-list.php' );
|
|
||||||
break;
|
|
||||||
endswitch;
|
|
||||||
endif;
|
|
||||||
return $content;
|
|
||||||
}
|
|
||||||
add_filter( 'the_content', 'sportspress_default_list_content' );
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
<?php
|
|
||||||
function sportspress_posts_where( $where, $that ) {
|
|
||||||
global $wpdb;
|
|
||||||
if( 'sp_event' == $that->query_vars['post_type'] && is_archive() )
|
|
||||||
$where = str_replace( "{$wpdb->posts}.post_status = 'publish'", "{$wpdb->posts}.post_status = 'publish' OR $wpdb->posts.post_status = 'future'", $where );
|
|
||||||
return $where;
|
|
||||||
}
|
|
||||||
add_filter( 'posts_where', 'sportspress_posts_where', 2, 10 );
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
<?php
|
|
||||||
function sportspress_the_title( $title, $id ) {
|
|
||||||
if ( is_singular( 'sp_player' ) && in_the_loop() && $id == get_the_ID() ):
|
|
||||||
$number = get_post_meta( $id, 'sp_number', true );
|
|
||||||
if ( $number != null ):
|
|
||||||
$title = '<strong>' . $number . '</strong> ' . $title;
|
|
||||||
endif;
|
|
||||||
endif;
|
|
||||||
return $title;
|
|
||||||
}
|
|
||||||
add_filter( 'the_title', 'sportspress_the_title', 10, 2 );
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
<?php
|
|
||||||
function sportspress_widget_text( $content ) {
|
|
||||||
if ( ! preg_match( '/\[[\r\n\t ]*(countdown|league_table|event(s)_(calendar|list)|player_(list|gallery))?[\r\n\t ].*?\]/', $content ) )
|
|
||||||
return $content;
|
|
||||||
|
|
||||||
$content = do_shortcode( $content );
|
|
||||||
|
|
||||||
return $content;
|
|
||||||
}
|
|
||||||
add_filter( 'widget_text', 'sportspress_widget_text', 9 );
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
<?php
|
|
||||||
function sportspress_enqueue_scripts() {
|
|
||||||
// Styles
|
|
||||||
wp_enqueue_style( 'sportspress', plugin_dir_url( SP_PLUGIN_FILE ) . 'assets/css/sportspress.css', array( 'dashicons' ), time() );
|
|
||||||
|
|
||||||
// Scripts
|
|
||||||
wp_enqueue_script( 'jquery' );
|
|
||||||
wp_enqueue_script( 'google-maps', 'https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false', array(), '3.exp', true );
|
|
||||||
wp_enqueue_script( 'jquery-datatables', plugin_dir_url( SP_PLUGIN_FILE ) .'assets/js/jquery.dataTables.min.js', array( 'jquery' ), '1.9.4', true );
|
|
||||||
wp_enqueue_script( 'jquery-countdown', plugin_dir_url( SP_PLUGIN_FILE ) .'assets/js/jquery.countdown.min.js', array( 'jquery' ), '2.0.2', true );
|
|
||||||
wp_enqueue_script( 'sportspress', plugin_dir_url( SP_PLUGIN_FILE ) .'assets/js/sportspress.js', array( 'jquery' ), time(), true );
|
|
||||||
|
|
||||||
// Localize scripts.
|
|
||||||
wp_localize_script( 'sportspress', 'localized_strings', array( 'days' => __( 'days', 'sportspress' ), 'hrs' => __( 'hrs', 'sportspress' ), 'mins' => __( 'mins', 'sportspress' ), 'secs' => __( 'secs', 'sportspress' ) ) );
|
|
||||||
}
|
|
||||||
add_action( 'wp_enqueue_scripts', 'sportspress_enqueue_scripts' );
|
|
||||||
@@ -68,9 +68,58 @@
|
|||||||
.sportspress table.form-table, .sportspress table.form-table .forminp-radio ul {
|
.sportspress table.form-table, .sportspress table.form-table .forminp-radio ul {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
|
.sportspress table.form-table fieldset {
|
||||||
|
margin-top: 4px;
|
||||||
|
}
|
||||||
|
.sportspress table.form-table fieldset:first-child {
|
||||||
|
margin-top: 0;
|
||||||
|
}
|
||||||
|
.sportspress table.form-table fieldset p.description {
|
||||||
|
margin-bottom: 8px;
|
||||||
|
}
|
||||||
.sportspress table.sp-admin-config-table .edit {
|
.sportspress table.sp-admin-config-table .edit {
|
||||||
text-align: right;
|
text-align: right;
|
||||||
}
|
}
|
||||||
|
.sportspress table.form-table .sp-color-box {
|
||||||
|
border: 1px solid #ccc;
|
||||||
|
box-shadow: 1px 1px 3px rgba(0,0,0,.2);
|
||||||
|
-webkit-box-shadow: 1px 1px 3px rgba(0,0,0,.2);
|
||||||
|
-moz-box-shadow: 1px 1px 3px rgba(0,0,0,.2);
|
||||||
|
-webkit-border-radius: 3px;
|
||||||
|
-moz-border-radius: 3px;
|
||||||
|
border-radius: 3px;
|
||||||
|
padding: 4px 6px;
|
||||||
|
float: left;
|
||||||
|
width: 90px;
|
||||||
|
margin: 0 10px 0 0;
|
||||||
|
}
|
||||||
|
.sportspress table.form-table .sp-color-box strong {
|
||||||
|
text-align: left;
|
||||||
|
display: block;
|
||||||
|
padding: 0 0 2px;
|
||||||
|
font-size: .92em;
|
||||||
|
}
|
||||||
|
.sportspress table.form-table .sp-color-box input.colorpick {
|
||||||
|
width: 100%;
|
||||||
|
margin: 0;
|
||||||
|
font-family: monospace;
|
||||||
|
-webkit-box-sizing: border-box;
|
||||||
|
-moz-box-sizing: border-box;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
.sportspress table.form-table .sp-color-box .iris-picker {
|
||||||
|
z-index: 100;
|
||||||
|
position: absolute;
|
||||||
|
display: none;
|
||||||
|
border: 1px solid #ccc;
|
||||||
|
box-shadow: 1px 1px 3px rgba(0,0,0,.2);
|
||||||
|
-webkit-box-shadow: 1px 1px 3px rgba(0,0,0,.2);
|
||||||
|
-moz-box-shadow: 1px 1px 3px rgba(0,0,0,.2);
|
||||||
|
-webkit-border-radius: 3px;
|
||||||
|
-moz-border-radius: 3px;
|
||||||
|
border-radius: 3px;
|
||||||
|
margin: 15px 0 0 -7px;
|
||||||
|
}
|
||||||
|
|
||||||
/* Messages */
|
/* Messages */
|
||||||
.sportspress-message {
|
.sportspress-message {
|
||||||
|
|||||||
@@ -109,6 +109,7 @@
|
|||||||
.sp-responsive-table .data-number,
|
.sp-responsive-table .data-number,
|
||||||
.sp-responsive-table .data-name,
|
.sp-responsive-table .data-name,
|
||||||
.sp-responsive-table .data-rank,
|
.sp-responsive-table .data-rank,
|
||||||
|
.sp-responsive-table .data-date,
|
||||||
.sp-responsive-.sp-pinned-table td {
|
.sp-responsive-.sp-pinned-table td {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|||||||
11
assets/js/admin/dashboard.js
Normal file
11
assets/js/admin/dashboard.js
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
jQuery(document).ready(function($){
|
||||||
|
|
||||||
|
// Dashboard countdown
|
||||||
|
$("#sportspress_dashboard_status .sp_status_list li.countdown").each(function() {
|
||||||
|
var $this = $(this), finalDate = $(this).data('countdown');
|
||||||
|
$this.countdown(finalDate, function(event) {
|
||||||
|
$this.find('strong').html(event.strftime("%D "+localized_strings.days+" %H:%M:%S"));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
64
assets/js/admin/settings.js
Normal file
64
assets/js/admin/settings.js
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
jQuery(document).ready(function($){
|
||||||
|
|
||||||
|
// Display custom sport name field as needed
|
||||||
|
$("body.settings_page_sportspress #sportspress_sport").change(function() {
|
||||||
|
$target = $("#sportspress_custom_sport_name");
|
||||||
|
if ( $(this).val() == "custom" )
|
||||||
|
$target.show();
|
||||||
|
else
|
||||||
|
$target.hide();
|
||||||
|
});
|
||||||
|
|
||||||
|
// Color picker
|
||||||
|
$('.colorpick').iris( {
|
||||||
|
change: function(event, ui){
|
||||||
|
$(this).css( { backgroundColor: ui.color.toString() } );
|
||||||
|
},
|
||||||
|
hide: true,
|
||||||
|
border: true
|
||||||
|
} ).each( function() {
|
||||||
|
$(this).css( { backgroundColor: $(this).val() } );
|
||||||
|
})
|
||||||
|
.click(function(){
|
||||||
|
$('.iris-picker').hide();
|
||||||
|
$(this).closest('.sp-color-box, td').find('.iris-picker').show();
|
||||||
|
});
|
||||||
|
|
||||||
|
$('body').click(function() {
|
||||||
|
$('.iris-picker').hide();
|
||||||
|
});
|
||||||
|
|
||||||
|
$('.sp-color-box, .colorpick').click(function(event){
|
||||||
|
event.stopPropagation();
|
||||||
|
});
|
||||||
|
|
||||||
|
// Chosen select
|
||||||
|
$(".chosen-select").chosen({
|
||||||
|
allow_single_deselect: true,
|
||||||
|
single_backstroke_delete: false,
|
||||||
|
placeholder_text_multiple: localized_strings.none
|
||||||
|
});
|
||||||
|
|
||||||
|
// Preset field modifier
|
||||||
|
$(".sp-custom-input-wrapper .preset").click(function() {
|
||||||
|
val = $(this).val();
|
||||||
|
if(val == "\\c\\u\\s\\t\\o\\m") return true;
|
||||||
|
example = $(this).attr("data-example");
|
||||||
|
$(this).closest(".sp-custom-input-wrapper").find(".value").val(val).siblings(".example").html(example);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Select custom preset when field is brought to focus
|
||||||
|
$(".sp-custom-input-wrapper .value").focus(function() {
|
||||||
|
$(this).siblings("label").find(".preset").prop("checked", true);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Adjust example field when custom preset is entered
|
||||||
|
$(".sp-custom-input-wrapper .value").on("keyup", function() {
|
||||||
|
val = $(this).val();
|
||||||
|
if ( val === undefined ) return true;
|
||||||
|
format = $(this).attr("data-example-format");
|
||||||
|
example = format.replace("__val__", val);
|
||||||
|
$(this).siblings(".example").html(example);
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
@@ -83,7 +83,7 @@ function viewport() {
|
|||||||
original.wrap("<div class='sp-responsive-table-wrapper' />");
|
original.wrap("<div class='sp-responsive-table-wrapper' />");
|
||||||
|
|
||||||
var copy = original.clone();
|
var copy = original.clone();
|
||||||
copy.find("td:not(.data-number):not(.data-name):not(.data-rank), th:not(.data-number):not(.data-name):not(.data-rank)").css("display", "none");
|
copy.find("td:not(.data-number):not(.data-name):not(.data-rank):not(.data-date), th:not(.data-number):not(.data-name):not(.data-rank):not(.data-date)").css("display", "none");
|
||||||
copy.removeClass("sp-responsive-table");
|
copy.removeClass("sp-responsive-table");
|
||||||
|
|
||||||
original.closest(".sp-responsive-table-wrapper").append(copy);
|
original.closest(".sp-responsive-table-wrapper").append(copy);
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ class SP_Admin_Assets {
|
|||||||
$screen = get_current_screen();
|
$screen = get_current_screen();
|
||||||
|
|
||||||
// Register scripts
|
// Register scripts
|
||||||
wp_register_script( 'jquery-chosen', SP()->plugin_url() . '/assets/js/chosen.jquery.min.js', array( 'jquery' ), '1.1.0', true );
|
wp_register_script( 'chosen', SP()->plugin_url() . '/assets/js/chosen.jquery.min.js', array( 'jquery' ), '1.1.0', true );
|
||||||
|
|
||||||
wp_register_script( 'jquery-tiptip', SP()->plugin_url() . '/assets/js/jquery.tipTip.min.js', array( 'jquery' ), '1.3', true );
|
wp_register_script( 'jquery-tiptip', SP()->plugin_url() . '/assets/js/jquery.tipTip.min.js', array( 'jquery' ), '1.3', true );
|
||||||
|
|
||||||
@@ -72,15 +72,15 @@ class SP_Admin_Assets {
|
|||||||
|
|
||||||
wp_register_script( 'jquery-locationpicker', SP()->plugin_url() . '/assets/js/locationpicker.jquery.js', array( 'jquery', 'google-maps' ), '0.1.6', true );
|
wp_register_script( 'jquery-locationpicker', SP()->plugin_url() . '/assets/js/locationpicker.jquery.js', array( 'jquery', 'google-maps' ), '0.1.6', true );
|
||||||
|
|
||||||
wp_register_script( 'sportspress-admin-locationpicker', SP()->plugin_url() . '/assets/js/admin-locationpicker.js', array( 'jquery', 'google-maps', 'jquery-locationpicker' ), SP_VERSION, true );
|
wp_register_script( 'sportspress-admin-locationpicker', SP()->plugin_url() . '/assets/js/admin/locationpicker.js', array( 'jquery', 'google-maps', 'jquery-locationpicker' ), SP_VERSION, true );
|
||||||
|
|
||||||
wp_register_script( 'sportspress-admin', SP()->plugin_url() . '/assets/js/admin.js', array( 'jquery', 'jquery-chosen', 'jquery-tiptip', 'jquery-caret', 'jquery-countdown' ), SP_VERSION, true );
|
wp_register_script( 'sportspress-admin', SP()->plugin_url() . '/assets/js/admin/sportspress-admin.js', array( 'jquery', 'chosen', 'jquery-tiptip', 'jquery-caret', 'jquery-countdown' ), SP_VERSION, true );
|
||||||
|
|
||||||
// SportsPress admin pages
|
// SportsPress admin pages
|
||||||
if ( in_array( $screen->id, sp_get_screen_ids() ) ) {
|
if ( in_array( $screen->id, sp_get_screen_ids() ) ) {
|
||||||
|
|
||||||
wp_enqueue_script( 'jquery' );
|
wp_enqueue_script( 'jquery' );
|
||||||
wp_enqueue_script( 'jquery-chosen' );
|
wp_enqueue_script( 'chosen' );
|
||||||
wp_enqueue_script( 'jquery-tiptip' );
|
wp_enqueue_script( 'jquery-tiptip' );
|
||||||
wp_enqueue_script( 'jquery-caret' );
|
wp_enqueue_script( 'jquery-caret' );
|
||||||
wp_enqueue_script( 'jquery-countdown' );
|
wp_enqueue_script( 'jquery-countdown' );
|
||||||
@@ -99,6 +99,10 @@ class SP_Admin_Assets {
|
|||||||
wp_localize_script( 'sportspress-admin', 'localized_strings', $params );
|
wp_localize_script( 'sportspress-admin', 'localized_strings', $params );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( in_array( $screen->id, array( 'dashboard' ) ) ) {
|
||||||
|
//wp_enqueue_style( 'sportspress-admin-dashboard' );
|
||||||
|
}
|
||||||
|
|
||||||
// Edit venue pages
|
// Edit venue pages
|
||||||
if ( in_array( $screen->id, array( 'edit-sp_venue' ) ) ) {
|
if ( in_array( $screen->id, array( 'edit-sp_venue' ) ) ) {
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,25 @@
|
|||||||
<?php
|
<?php
|
||||||
class SportsPressPermalinkSettingsSection {
|
/**
|
||||||
|
* Adds settings to the permalinks admin settings page.
|
||||||
|
*
|
||||||
|
* @author ThemeBoy
|
||||||
|
* @category Admin
|
||||||
|
* @package SportsPress/Admin
|
||||||
|
* @version 0.7
|
||||||
|
*/
|
||||||
|
|
||||||
|
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||||
|
|
||||||
|
if ( ! class_exists( 'SP_Admin_Permalink_Settings' ) ) :
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SP_Admin_Permalink_Settings Class
|
||||||
|
*/
|
||||||
|
class SP_Admin_Permalink_Settings {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hook in tabs.
|
||||||
|
*/
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
$this->slugs = array(
|
$this->slugs = array(
|
||||||
array( 'events', __( 'Events', 'sportspress' ) ),
|
array( 'events', __( 'Events', 'sportspress' ) ),
|
||||||
@@ -19,36 +39,45 @@ class SportsPressPermalinkSettingsSection {
|
|||||||
add_action( 'admin_init', array( $this, 'settings_save' ) );
|
add_action( 'admin_init', array( $this, 'settings_save' ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
function settings_init() {
|
/**
|
||||||
add_settings_section(
|
* Init our settings
|
||||||
'sportspress',
|
*/
|
||||||
__( 'SportsPress', 'sportspress' ),
|
public function settings_init() {
|
||||||
array( $this, 'settings' ),
|
// Add a section to the permalinks page
|
||||||
'permalink'
|
add_settings_section( 'sportspress-permalink', __( 'SportsPress', 'sportspress' ), array( $this, 'settings' ), 'permalink' );
|
||||||
);
|
|
||||||
|
|
||||||
|
// Add our settings
|
||||||
foreach ( $this->slugs as $slug ):
|
foreach ( $this->slugs as $slug ):
|
||||||
add_settings_field(
|
add_settings_field(
|
||||||
$slug[0],
|
$slug[0], // id
|
||||||
$slug[1],
|
$slug[1], // setting title
|
||||||
array( $this, 'slug_callback' ),
|
array( $this, 'slug_input' ), // display callback
|
||||||
'permalink',
|
'permalink', // settings page
|
||||||
'sportspress'
|
'sportspress-permalink' // settings section
|
||||||
);
|
);
|
||||||
endforeach;
|
endforeach;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function settings() {
|
/**
|
||||||
echo wpautop( __( 'These settings control the permalinks used for SportsPress. These settings only apply when <strong>not using "default" permalinks above</strong>.', 'sportspress' ) );
|
* Show a slug input box.
|
||||||
}
|
*/
|
||||||
|
public function slug_input() {
|
||||||
public function slug_callback( $test ) {
|
|
||||||
$slug = array_shift( $this->slugs );
|
$slug = array_shift( $this->slugs );
|
||||||
$key = $slug[0];
|
$key = $slug[0];
|
||||||
$text = get_option( 'sportspress_' . $key . '_slug', null );
|
$text = get_option( 'sportspress_' . $key . '_slug', null );
|
||||||
?><fieldset><input id="sportspress_<?php echo $key; ?>_slug" name="sportspress_<?php echo $key; ?>_slug" type="text" class="regular-text code" value="<?php echo $text; ?>" placeholder="<?php echo $key; ?>"></fieldset><?php
|
?><fieldset><input id="sportspress_<?php echo $key; ?>_slug" name="sportspress_<?php echo $key; ?>_slug" type="text" class="regular-text code" value="<?php echo $text; ?>" placeholder="<?php echo $key; ?>"></fieldset><?php
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the settings
|
||||||
|
*/
|
||||||
|
public function settings() {
|
||||||
|
echo wpautop( __( 'These settings control the permalinks used for SportsPress. These settings only apply when <strong>not using "default" permalinks above</strong>.', 'sportspress' ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Save the settings
|
||||||
|
*/
|
||||||
public function settings_save() {
|
public function settings_save() {
|
||||||
if ( ! is_admin() )
|
if ( ! is_admin() )
|
||||||
return;
|
return;
|
||||||
@@ -67,5 +96,6 @@ class SportsPressPermalinkSettingsSection {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( is_admin() )
|
endif;
|
||||||
$sportspress_permalink_settings_section = new SportsPressPermalinkSettingsSection();
|
|
||||||
|
return new SP_Admin_Permalink_Settings();
|
||||||
@@ -34,7 +34,6 @@ class SP_Admin_Settings {
|
|||||||
$settings[] = include( 'settings/class-sp-settings-events.php' );
|
$settings[] = include( 'settings/class-sp-settings-events.php' );
|
||||||
$settings[] = include( 'settings/class-sp-settings-teams.php' );
|
$settings[] = include( 'settings/class-sp-settings-teams.php' );
|
||||||
$settings[] = include( 'settings/class-sp-settings-players.php' );
|
$settings[] = include( 'settings/class-sp-settings-players.php' );
|
||||||
$settings[] = include( 'settings/class-sp-settings-text.php' );
|
|
||||||
$settings[] = include( 'settings/class-sp-settings-config.php' );
|
$settings[] = include( 'settings/class-sp-settings-config.php' );
|
||||||
|
|
||||||
self::$settings = apply_filters( 'sportspress_get_settings_pages', $settings );
|
self::$settings = apply_filters( 'sportspress_get_settings_pages', $settings );
|
||||||
@@ -103,10 +102,10 @@ class SP_Admin_Settings {
|
|||||||
|
|
||||||
do_action( 'sportspress_settings_start' );
|
do_action( 'sportspress_settings_start' );
|
||||||
|
|
||||||
wp_enqueue_script( 'sportspress_settings', SP()->plugin_url() . '/assets/js/admin/settings.min.js', array( 'jquery', 'jquery-ui-datepicker', 'jquery-ui-sortable', 'iris', 'chosen' ), SP()->version, true );
|
wp_enqueue_script( 'sportspress_settings', SP()->plugin_url() . '/assets/js/admin/settings.js', array( 'jquery', 'wp-color-picker', 'jquery-ui-datepicker', 'jquery-ui-sortable', 'iris', 'chosen' ), SP()->version, true );
|
||||||
|
|
||||||
wp_localize_script( 'sportspress_settings', 'sportspress_settings_params', array(
|
wp_localize_script( 'sportspress_settings', 'localized_strings', array(
|
||||||
'i18n_nav_warning' => __( 'The changes you made will be lost if you navigate away from this page.', 'sportspress' )
|
'none' => __( 'None', 'sportspress' )
|
||||||
) );
|
) );
|
||||||
|
|
||||||
// Include settings pages
|
// Include settings pages
|
||||||
@@ -464,102 +463,6 @@ class SP_Admin_Settings {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// Image width settings
|
|
||||||
case 'image_width' :
|
|
||||||
|
|
||||||
$width = self::get_option( $value['id'] . '[width]', $value['default']['width'] );
|
|
||||||
$height = self::get_option( $value['id'] . '[height]', $value['default']['height'] );
|
|
||||||
$crop = checked( 1, self::get_option( $value['id'] . '[crop]', $value['default']['crop'] ), false );
|
|
||||||
|
|
||||||
?><tr valign="top">
|
|
||||||
<th scope="row" class="titledesc"><?php echo esc_html( $value['title'] ) ?> <?php echo $tip; ?></th>
|
|
||||||
<td class="forminp image_width_settings">
|
|
||||||
|
|
||||||
<input name="<?php echo esc_attr( $value['id'] ); ?>[width]" id="<?php echo esc_attr( $value['id'] ); ?>-width" type="text" size="3" value="<?php echo $width; ?>" /> × <input name="<?php echo esc_attr( $value['id'] ); ?>[height]" id="<?php echo esc_attr( $value['id'] ); ?>-height" type="text" size="3" value="<?php echo $height; ?>" />px
|
|
||||||
|
|
||||||
<label><input name="<?php echo esc_attr( $value['id'] ); ?>[crop]" id="<?php echo esc_attr( $value['id'] ); ?>-crop" type="checkbox" <?php echo $crop; ?> /> <?php _e( 'Hard Crop?', 'sportspress' ); ?></label>
|
|
||||||
|
|
||||||
</td>
|
|
||||||
</tr><?php
|
|
||||||
break;
|
|
||||||
|
|
||||||
// Single page selects
|
|
||||||
case 'single_select_page' :
|
|
||||||
|
|
||||||
$args = array( 'name' => $value['id'],
|
|
||||||
'id' => $value['id'],
|
|
||||||
'sort_column' => 'menu_order',
|
|
||||||
'sort_order' => 'ASC',
|
|
||||||
'show_option_none' => ' ',
|
|
||||||
'class' => $value['class'],
|
|
||||||
'echo' => false,
|
|
||||||
'selected' => absint( self::get_option( $value['id'] ) )
|
|
||||||
);
|
|
||||||
|
|
||||||
if( isset( $value['args'] ) )
|
|
||||||
$args = wp_parse_args( $value['args'], $args );
|
|
||||||
|
|
||||||
?><tr valign="top" class="single_select_page">
|
|
||||||
<th scope="row" class="titledesc"><?php echo esc_html( $value['title'] ) ?> <?php echo $tip; ?></th>
|
|
||||||
<td class="forminp">
|
|
||||||
<?php echo str_replace(' id=', " data-placeholder='" . __( 'Select a page…', 'sportspress' ) . "' style='" . $value['css'] . "' class='" . $value['class'] . "' id=", wp_dropdown_pages( $args ) ); ?> <?php echo $description; ?>
|
|
||||||
</td>
|
|
||||||
</tr><?php
|
|
||||||
break;
|
|
||||||
|
|
||||||
// Single country selects
|
|
||||||
case 'single_select_country' :
|
|
||||||
$country_setting = (string) self::get_option( $value['id'] );
|
|
||||||
$countries = SP()->countries->countries;
|
|
||||||
|
|
||||||
if ( strstr( $country_setting, ':' ) ) {
|
|
||||||
$country_setting = explode( ':', $country_setting );
|
|
||||||
$country = current( $country_setting );
|
|
||||||
$state = end( $country_setting );
|
|
||||||
} else {
|
|
||||||
$country = $country_setting;
|
|
||||||
$state = '*';
|
|
||||||
}
|
|
||||||
?><tr valign="top">
|
|
||||||
<th scope="row" class="titledesc">
|
|
||||||
<label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo esc_html( $value['title'] ); ?></label>
|
|
||||||
<?php echo $tip; ?>
|
|
||||||
</th>
|
|
||||||
<td class="forminp"><select name="<?php echo esc_attr( $value['id'] ); ?>" style="<?php echo esc_attr( $value['css'] ); ?>" data-placeholder="<?php _e( 'Choose a country…', 'sportspress' ); ?>" title="Country" class="chosen_select">
|
|
||||||
<?php SP()->countries->country_dropdown_options( $country, $state ); ?>
|
|
||||||
</select> <?php echo $description; ?>
|
|
||||||
</td>
|
|
||||||
</tr><?php
|
|
||||||
break;
|
|
||||||
|
|
||||||
// Country multiselects
|
|
||||||
case 'multi_select_countries' :
|
|
||||||
|
|
||||||
$selections = (array) self::get_option( $value['id'] );
|
|
||||||
|
|
||||||
if ( ! empty( $value['options'] ) )
|
|
||||||
$countries = $value['options'];
|
|
||||||
else
|
|
||||||
$countries = SP()->countries->countries;
|
|
||||||
|
|
||||||
asort( $countries );
|
|
||||||
?><tr valign="top">
|
|
||||||
<th scope="row" class="titledesc">
|
|
||||||
<label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo esc_html( $value['title'] ); ?></label>
|
|
||||||
<?php echo $tip; ?>
|
|
||||||
</th>
|
|
||||||
<td class="forminp">
|
|
||||||
<select multiple="multiple" name="<?php echo esc_attr( $value['id'] ); ?>[]" style="width:350px" data-placeholder="<?php _e( 'Choose countries…', 'sportspress' ); ?>" title="Country" class="chosen_select">
|
|
||||||
<?php
|
|
||||||
if ( $countries )
|
|
||||||
foreach ( $countries as $key => $val )
|
|
||||||
echo '<option value="' . esc_attr( $key ) . '" ' . selected( in_array( $key, $selections ), true, false ).'>' . $val . '</option>';
|
|
||||||
?>
|
|
||||||
</select> <?php if ( $description ) echo $description; ?> </br><a class="select_all button" href="#"><?php _e( 'Select all', 'sportspress' ); ?></a> <a class="select_none button" href="#"><?php _e( 'Select none', 'sportspress' ); ?></a>
|
|
||||||
</td>
|
|
||||||
</tr><?php
|
|
||||||
break;
|
|
||||||
|
|
||||||
// Default: run an action
|
// Default: run an action
|
||||||
default:
|
default:
|
||||||
do_action( 'sportspress_admin_field_' . $value['type'], $value );
|
do_action( 'sportspress_admin_field_' . $value['type'], $value );
|
||||||
@@ -598,7 +501,7 @@ class SP_Admin_Settings {
|
|||||||
switch ( $type ) {
|
switch ( $type ) {
|
||||||
|
|
||||||
// Standard types
|
// Standard types
|
||||||
case "checkbox" :
|
case 'checkbox' :
|
||||||
|
|
||||||
if ( isset( $_POST[ $value['id'] ] ) ) {
|
if ( isset( $_POST[ $value['id'] ] ) ) {
|
||||||
$option_value = 'yes';
|
$option_value = 'yes';
|
||||||
@@ -608,7 +511,7 @@ class SP_Admin_Settings {
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "textarea" :
|
case 'textarea' :
|
||||||
|
|
||||||
if ( isset( $_POST[$value['id']] ) ) {
|
if ( isset( $_POST[$value['id']] ) ) {
|
||||||
$option_value = wp_kses_post( trim( stripslashes( $_POST[ $value['id'] ] ) ) );
|
$option_value = wp_kses_post( trim( stripslashes( $_POST[ $value['id'] ] ) ) );
|
||||||
@@ -618,14 +521,12 @@ class SP_Admin_Settings {
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "text" :
|
case 'text' :
|
||||||
case 'email':
|
case 'email':
|
||||||
case 'number':
|
case 'number':
|
||||||
case "select" :
|
case 'select' :
|
||||||
case "color" :
|
case 'color' :
|
||||||
case 'password' :
|
case 'password' :
|
||||||
case "single_select_page" :
|
|
||||||
case "single_select_country" :
|
|
||||||
case 'radio' :
|
case 'radio' :
|
||||||
|
|
||||||
if ( isset( $_POST[$value['id']] ) ) {
|
if ( isset( $_POST[$value['id']] ) ) {
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ class SP_Admin {
|
|||||||
// include( 'class-sp-admin-welcome.php' );
|
// include( 'class-sp-admin-welcome.php' );
|
||||||
// include( 'class-sp-admin-notices.php' );
|
// include( 'class-sp-admin-notices.php' );
|
||||||
include( 'class-sp-admin-assets.php' );
|
include( 'class-sp-admin-assets.php' );
|
||||||
// include( 'class-sp-admin-permalink-settings.php' );
|
include( 'class-sp-admin-permalink-settings.php' );
|
||||||
// include( 'class-sp-admin-editor.php' );
|
// include( 'class-sp-admin-editor.php' );
|
||||||
|
|
||||||
// Help
|
// Help
|
||||||
|
|||||||
@@ -535,7 +535,7 @@ if ( class_exists( 'WP_Importer' ) ) {
|
|||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<th>
|
<th>
|
||||||
<label for="upload"><?php _e( 'Choose a file from your computer:' ); ?></label>
|
<label for="upload"><?php _e( 'Choose a file from your computer:', 'sportspress' ); ?></label>
|
||||||
</th>
|
</th>
|
||||||
<td>
|
<td>
|
||||||
<input type="file" id="upload" name="import" size="25" />
|
<input type="file" id="upload" name="import" size="25" />
|
||||||
|
|||||||
@@ -98,7 +98,7 @@ class SP_Admin_Meta_Boxes {
|
|||||||
|
|
||||||
// Calendars
|
// Calendars
|
||||||
add_meta_box( 'sp_shortcodediv', __( 'Shortcode', 'sportspress' ), 'SP_Meta_Box_Calendar_Shortcode::output', 'sp_calendar', 'side', 'default' );
|
add_meta_box( 'sp_shortcodediv', __( 'Shortcode', 'sportspress' ), 'SP_Meta_Box_Calendar_Shortcode::output', 'sp_calendar', 'side', 'default' );
|
||||||
add_meta_box( 'sp_formatdiv', __( 'Format', 'sportspress' ), 'SP_Meta_Box_Calendar_Format::output', 'sp_calendar', 'side', 'default' );
|
add_meta_box( 'sp_formatdiv', __( 'Layout', 'sportspress' ), 'SP_Meta_Box_Calendar_Format::output', 'sp_calendar', 'side', 'default' );
|
||||||
add_meta_box( 'sp_detailsdiv', __( 'Details', 'sportspress' ), 'SP_Meta_Box_Calendar_Details::output', 'sp_calendar', 'side', 'default' );
|
add_meta_box( 'sp_detailsdiv', __( 'Details', 'sportspress' ), 'SP_Meta_Box_Calendar_Details::output', 'sp_calendar', 'side', 'default' );
|
||||||
add_meta_box( 'sp_datadiv', __( 'Events', 'sportspress' ), 'SP_Meta_Box_Calendar_Data::output', 'sp_calendar', 'normal', 'high' );
|
add_meta_box( 'sp_datadiv', __( 'Events', 'sportspress' ), 'SP_Meta_Box_Calendar_Data::output', 'sp_calendar', 'normal', 'high' );
|
||||||
add_meta_box( 'sp_descriptiondiv', __( 'Description', 'sportspress' ), 'SP_Meta_Box_Calendar_Description::output', 'sp_calendar', 'normal', 'high' );
|
add_meta_box( 'sp_descriptiondiv', __( 'Description', 'sportspress' ), 'SP_Meta_Box_Calendar_Description::output', 'sp_calendar', 'normal', 'high' );
|
||||||
@@ -119,10 +119,10 @@ class SP_Admin_Meta_Boxes {
|
|||||||
|
|
||||||
// Lists
|
// Lists
|
||||||
add_meta_box( 'sp_shortcodediv', __( 'Shortcode', 'sportspress' ), 'SP_Meta_Box_List_Shortcode::output', 'sp_list', 'side', 'default' );
|
add_meta_box( 'sp_shortcodediv', __( 'Shortcode', 'sportspress' ), 'SP_Meta_Box_List_Shortcode::output', 'sp_list', 'side', 'default' );
|
||||||
add_meta_box( 'sp_formatdiv', __( 'Format', 'sportspress' ), 'SP_Meta_Box_List_Format::output', 'sp_list', 'side', 'default' );
|
add_meta_box( 'sp_formatdiv', __( 'Layout', 'sportspress' ), 'SP_Meta_Box_List_Format::output', 'sp_list', 'side', 'default' );
|
||||||
add_meta_box( 'sp_detailsdiv', __( 'Details', 'sportspress' ), 'SP_Meta_Box_List_Details::output', 'sp_list', 'side', 'default' );
|
add_meta_box( 'sp_detailsdiv', __( 'Details', 'sportspress' ), 'SP_Meta_Box_List_Details::output', 'sp_list', 'side', 'default' );
|
||||||
add_meta_box( 'sp_datadiv', __( 'Player List', 'sportspress' ), 'SP_Meta_Box_List_Data::output', 'sp_list', 'normal', 'default' );
|
add_meta_box( 'sp_datadiv', __( 'Player List', 'sportspress' ), 'SP_Meta_Box_List_Data::output', 'sp_list', 'normal', 'default' );
|
||||||
add_meta_box( 'sp_descriptiondiv', __( 'Description', 'sportspress' ), 'SP_Meta_Box_List_::output', 'sp_list', 'normal', 'high' );
|
add_meta_box( 'sp_descriptiondiv', __( 'Description', 'sportspress' ), 'SP_Meta_Box_List_Description::output', 'sp_list', 'normal', 'high' );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -0,0 +1,24 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* List Description
|
||||||
|
*
|
||||||
|
* @author ThemeBoy
|
||||||
|
* @category Admin
|
||||||
|
* @package SportsPress/Admin/Meta Boxes
|
||||||
|
* @version 0.7
|
||||||
|
*/
|
||||||
|
|
||||||
|
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SP_Meta_Box_List_Description
|
||||||
|
*/
|
||||||
|
class SP_Meta_Box_List_Description {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Output the metabox
|
||||||
|
*/
|
||||||
|
public static function output( $post ) {
|
||||||
|
wp_editor( $post->post_content, 'content' );
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* List Shortcode
|
||||||
|
*
|
||||||
|
* @author ThemeBoy
|
||||||
|
* @category Admin
|
||||||
|
* @package SportsPress/Admin/Meta Boxes
|
||||||
|
* @version 0.7
|
||||||
|
*/
|
||||||
|
|
||||||
|
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SP_Meta_Box_List_Shortcode
|
||||||
|
*/
|
||||||
|
class SP_Meta_Box_List_Shortcode {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Output the metabox
|
||||||
|
*/
|
||||||
|
public static function output( $post ) {
|
||||||
|
$the_format = get_post_meta( $post->ID, 'sp_format', true );
|
||||||
|
?>
|
||||||
|
<p class="howto">
|
||||||
|
<?php _e( 'Copy this code and paste it into your post, page or text widget content.', 'sportspress' ); ?>
|
||||||
|
</p>
|
||||||
|
<p><input type="text" value="[player_<?php echo $the_format; ?> <?php echo $post->ID; ?>]" readonly="readonly" class="wp-ui-text-highlight code"></p>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,162 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* SportsPress Account Settings
|
|
||||||
*
|
|
||||||
* @author ThemeBoy
|
|
||||||
* @category Admin
|
|
||||||
* @package SportsPress/Admin
|
|
||||||
* @version 0.7
|
|
||||||
*/
|
|
||||||
|
|
||||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
|
||||||
|
|
||||||
if ( ! class_exists( 'SP_Settings_Accounts' ) ) :
|
|
||||||
|
|
||||||
/**
|
|
||||||
* SP_Settings_Accounts
|
|
||||||
*/
|
|
||||||
class SP_Settings_Accounts extends SP_Settings_Page {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor.
|
|
||||||
*/
|
|
||||||
public function __construct() {
|
|
||||||
$this->id = 'account';
|
|
||||||
$this->label = __( 'Accounts', 'sportspress' );
|
|
||||||
|
|
||||||
add_filter( 'sportspress_settings_tabs_array', array( $this, 'add_settings_page' ), 20 );
|
|
||||||
add_action( 'sportspress_settings_' . $this->id, array( $this, 'output' ) );
|
|
||||||
add_action( 'sportspress_settings_save_' . $this->id, array( $this, 'save' ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get settings array
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function get_settings() {
|
|
||||||
|
|
||||||
return apply_filters( 'sportspress_' . $this->id . '_settings', array(
|
|
||||||
|
|
||||||
array( 'title' => __( 'Account Pages', 'sportspress' ), 'type' => 'title', 'desc' => __( 'These pages need to be set so that SportsPress knows where to send users to access account related functionality.', 'sportspress' ), 'id' => 'account_page_options' ),
|
|
||||||
|
|
||||||
array(
|
|
||||||
'title' => __( 'My Account Page', 'sportspress' ),
|
|
||||||
'desc' => __( 'Page contents:', 'sportspress' ) . ' [' . apply_filters( 'sportspress_my_account_shortcode_tag', 'sportspress_my_account' ) . ']',
|
|
||||||
'id' => 'sportspress_myaccount_page_id',
|
|
||||||
'type' => 'single_select_page',
|
|
||||||
'default' => '',
|
|
||||||
'class' => 'chosen_select_nostd',
|
|
||||||
'css' => 'min-width:300px;',
|
|
||||||
'desc_tip' => true,
|
|
||||||
),
|
|
||||||
|
|
||||||
array( 'type' => 'sectionend', 'id' => 'account_page_options' ),
|
|
||||||
|
|
||||||
array( 'title' => __( 'My Account Endpoints', 'sportspress' ), 'type' => 'title', 'desc' => __( 'Endpoints are appended to your page URLs to handle specific actions on the accounts pages. They should be unique.', 'sportspress' ), 'id' => 'account_endpoint_options' ),
|
|
||||||
|
|
||||||
array(
|
|
||||||
'title' => __( 'View Order', 'sportspress' ),
|
|
||||||
'desc' => __( 'Endpoint for the My Account → View Order page', 'sportspress' ),
|
|
||||||
'id' => 'sportspress_myaccount_view_order_endpoint',
|
|
||||||
'type' => 'text',
|
|
||||||
'default' => 'view-order',
|
|
||||||
'desc_tip' => true,
|
|
||||||
),
|
|
||||||
|
|
||||||
array(
|
|
||||||
'title' => __( 'Edit Account', 'sportspress' ),
|
|
||||||
'desc' => __( 'Endpoint for the My Account → Edit Account page', 'sportspress' ),
|
|
||||||
'id' => 'sportspress_myaccount_edit_account_endpoint',
|
|
||||||
'type' => 'text',
|
|
||||||
'default' => 'edit-account',
|
|
||||||
'desc_tip' => true,
|
|
||||||
),
|
|
||||||
|
|
||||||
array(
|
|
||||||
'title' => __( 'Edit Address', 'sportspress' ),
|
|
||||||
'desc' => __( 'Endpoint for the My Account → Edit Address page', 'sportspress' ),
|
|
||||||
'id' => 'sportspress_myaccount_edit_address_endpoint',
|
|
||||||
'type' => 'text',
|
|
||||||
'default' => 'edit-address',
|
|
||||||
'desc_tip' => true,
|
|
||||||
),
|
|
||||||
|
|
||||||
array(
|
|
||||||
'title' => __( 'Lost Password', 'sportspress' ),
|
|
||||||
'desc' => __( 'Endpoint for the My Account → Lost Password page', 'sportspress' ),
|
|
||||||
'id' => 'sportspress_myaccount_lost_password_endpoint',
|
|
||||||
'type' => 'text',
|
|
||||||
'default' => 'lost-password',
|
|
||||||
'desc_tip' => true,
|
|
||||||
),
|
|
||||||
|
|
||||||
array(
|
|
||||||
'title' => __( 'Logout', 'sportspress' ),
|
|
||||||
'desc' => __( 'Endpoint for the triggering logout. You can add this to your menus via a custom link: yoursite.com/?customer-logout=true', 'sportspress' ),
|
|
||||||
'id' => 'sportspress_logout_endpoint',
|
|
||||||
'type' => 'text',
|
|
||||||
'default' => 'customer-logout',
|
|
||||||
'desc_tip' => true,
|
|
||||||
),
|
|
||||||
|
|
||||||
array( 'type' => 'sectionend', 'id' => 'account_endpoint_options' ),
|
|
||||||
|
|
||||||
array( 'title' => __( 'Registration Options', 'sportspress' ), 'type' => 'title', 'id' => 'account_registration_options' ),
|
|
||||||
|
|
||||||
array(
|
|
||||||
'title' => __( 'Enable Registration', 'sportspress' ),
|
|
||||||
'desc' => __( 'Enable registration on the "Checkout" page', 'sportspress' ),
|
|
||||||
'id' => 'sportspress_enable_signup_and_login_from_checkout',
|
|
||||||
'default' => 'yes',
|
|
||||||
'type' => 'checkbox',
|
|
||||||
'checkboxgroup' => 'start',
|
|
||||||
'autoload' => false
|
|
||||||
),
|
|
||||||
|
|
||||||
array(
|
|
||||||
'desc' => __( 'Enable registration on the "My Account" page', 'sportspress' ),
|
|
||||||
'id' => 'sportspress_enable_myaccount_registration',
|
|
||||||
'default' => 'no',
|
|
||||||
'type' => 'checkbox',
|
|
||||||
'checkboxgroup' => 'end',
|
|
||||||
'autoload' => false
|
|
||||||
),
|
|
||||||
|
|
||||||
array(
|
|
||||||
'desc' => __( 'Display returning customer login reminder on the "Checkout" page', 'sportspress' ),
|
|
||||||
'id' => 'sportspress_enable_checkout_login_reminder',
|
|
||||||
'default' => 'yes',
|
|
||||||
'type' => 'checkbox',
|
|
||||||
'checkboxgroup' => 'start',
|
|
||||||
'autoload' => false
|
|
||||||
),
|
|
||||||
|
|
||||||
array(
|
|
||||||
'title' => __( 'Account Creation', 'sportspress' ),
|
|
||||||
'desc' => __( 'Automatically generate username from customer email', 'sportspress' ),
|
|
||||||
'id' => 'sportspress_registration_generate_username',
|
|
||||||
'default' => 'yes',
|
|
||||||
'type' => 'checkbox',
|
|
||||||
'checkboxgroup' => 'start',
|
|
||||||
'autoload' => false
|
|
||||||
),
|
|
||||||
|
|
||||||
array(
|
|
||||||
'desc' => __( 'Automatically generate customer password', 'sportspress' ),
|
|
||||||
'id' => 'sportspress_registration_generate_password',
|
|
||||||
'default' => 'no',
|
|
||||||
'type' => 'checkbox',
|
|
||||||
'checkboxgroup' => 'end',
|
|
||||||
'autoload' => false
|
|
||||||
),
|
|
||||||
|
|
||||||
array( 'type' => 'sectionend', 'id' => 'account_registration_options'),
|
|
||||||
|
|
||||||
)); // End pages settings
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
endif;
|
|
||||||
|
|
||||||
return new SP_Settings_Accounts();
|
|
||||||
@@ -1,322 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* SportsPress Shipping Settings
|
|
||||||
*
|
|
||||||
* @author ThemeBoy
|
|
||||||
* @category Admin
|
|
||||||
* @package SportsPress/Admin
|
|
||||||
* @version 0.7
|
|
||||||
*/
|
|
||||||
|
|
||||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
|
||||||
|
|
||||||
if ( ! class_exists( 'SP_Settings_Payment_Gateways' ) ) :
|
|
||||||
|
|
||||||
/**
|
|
||||||
* SP_Settings_Payment_Gateways
|
|
||||||
*/
|
|
||||||
class SP_Settings_Payment_Gateways extends SP_Settings_Page {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor.
|
|
||||||
*/
|
|
||||||
public function __construct() {
|
|
||||||
$this->id = 'checkout';
|
|
||||||
$this->label = _x( 'Checkout', 'Settings tab label', 'sportspress' );
|
|
||||||
|
|
||||||
add_filter( 'sportspress_settings_tabs_array', array( $this, 'add_settings_page' ), 20 );
|
|
||||||
add_action( 'sportspress_sections_' . $this->id, array( $this, 'output_sections' ) );
|
|
||||||
add_action( 'sportspress_settings_' . $this->id, array( $this, 'output' ) );
|
|
||||||
add_action( 'sportspress_admin_field_payment_gateways', array( $this, 'payment_gateways_setting' ) );
|
|
||||||
add_action( 'sportspress_settings_save_' . $this->id, array( $this, 'save' ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get sections
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function get_sections() {
|
|
||||||
$sections = array(
|
|
||||||
'' => __( 'Checkout Options', 'sportspress' )
|
|
||||||
);
|
|
||||||
|
|
||||||
// Load shipping methods so we can show any global options they may have
|
|
||||||
$payment_gateways = SP()->payment_gateways->payment_gateways();
|
|
||||||
|
|
||||||
foreach ( $payment_gateways as $gateway ) {
|
|
||||||
|
|
||||||
$title = empty( $gateway->method_title ) ? ucfirst( $gateway->id ) : $gateway->method_title;
|
|
||||||
|
|
||||||
$sections[ strtolower( get_class( $gateway ) ) ] = esc_html( $title );
|
|
||||||
}
|
|
||||||
|
|
||||||
return $sections;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get settings array
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function get_settings() {
|
|
||||||
return apply_filters( 'sportspress_payment_gateways_settings', array(
|
|
||||||
|
|
||||||
array( 'title' => __( 'Checkout Process', 'sportspress' ), 'type' => 'title', 'id' => 'checkout_process_options' ),
|
|
||||||
|
|
||||||
array(
|
|
||||||
'title' => __( 'Coupons', 'sportspress' ),
|
|
||||||
'desc' => __( 'Enable the use of coupons', 'sportspress' ),
|
|
||||||
'id' => 'sportspress_enable_coupons',
|
|
||||||
'default' => 'yes',
|
|
||||||
'type' => 'checkbox',
|
|
||||||
'desc_tip' => __( 'Coupons can be applied from the cart and checkout pages.', 'sportspress' ),
|
|
||||||
'autoload' => false
|
|
||||||
),
|
|
||||||
|
|
||||||
array(
|
|
||||||
'title' => _x( 'Checkout', 'Settings group label', 'sportspress' ),
|
|
||||||
'desc' => __( 'Enable guest checkout', 'sportspress' ),
|
|
||||||
'desc_tip' => __( 'Allows customers to checkout without creating an account.', 'sportspress' ),
|
|
||||||
'id' => 'sportspress_enable_guest_checkout',
|
|
||||||
'default' => 'yes',
|
|
||||||
'type' => 'checkbox',
|
|
||||||
'checkboxgroup' => 'start',
|
|
||||||
'autoload' => false
|
|
||||||
),
|
|
||||||
|
|
||||||
array(
|
|
||||||
'desc' => __( 'Force secure checkout', 'sportspress' ),
|
|
||||||
'id' => 'sportspress_force_ssl_checkout',
|
|
||||||
'default' => 'no',
|
|
||||||
'type' => 'checkbox',
|
|
||||||
'checkboxgroup' => '',
|
|
||||||
'show_if_checked' => 'option',
|
|
||||||
'desc_tip' => __( 'Force SSL (HTTPS) on the checkout pages (an SSL Certificate is required).', 'sportspress' ),
|
|
||||||
),
|
|
||||||
|
|
||||||
array(
|
|
||||||
'desc' => __( 'Un-force HTTPS when leaving the checkout', 'sportspress' ),
|
|
||||||
'id' => 'sportspress_unforce_ssl_checkout',
|
|
||||||
'default' => 'no',
|
|
||||||
'type' => 'checkbox',
|
|
||||||
'checkboxgroup' => 'end',
|
|
||||||
'show_if_checked' => 'yes',
|
|
||||||
),
|
|
||||||
|
|
||||||
array( 'type' => 'sectionend', 'id' => 'checkout_process_options'),
|
|
||||||
|
|
||||||
array( 'title' => __( 'Checkout Pages', 'sportspress' ), 'desc' => __( 'These pages need to be set so that SportsPress knows where to send users to checkout.', 'sportspress' ), 'type' => 'title', 'id' => 'checkout_page_options' ),
|
|
||||||
|
|
||||||
array(
|
|
||||||
'title' => __( 'Cart Page', 'sportspress' ),
|
|
||||||
'desc' => __( 'Page contents:', 'sportspress' ) . ' [' . apply_filters( 'sportspress_cart_shortcode_tag', 'sportspress_cart' ) . ']',
|
|
||||||
'id' => 'sportspress_cart_page_id',
|
|
||||||
'type' => 'single_select_page',
|
|
||||||
'default' => '',
|
|
||||||
'class' => 'chosen_select_nostd',
|
|
||||||
'css' => 'min-width:300px;',
|
|
||||||
'desc_tip' => true,
|
|
||||||
),
|
|
||||||
|
|
||||||
array(
|
|
||||||
'title' => __( 'Checkout Page', 'sportspress' ),
|
|
||||||
'desc' => __( 'Page contents:', 'sportspress' ) . ' [' . apply_filters( 'sportspress_checkout_shortcode_tag', 'sportspress_checkout' ) . ']',
|
|
||||||
'id' => 'sportspress_checkout_page_id',
|
|
||||||
'type' => 'single_select_page',
|
|
||||||
'default' => '',
|
|
||||||
'class' => 'chosen_select_nostd',
|
|
||||||
'css' => 'min-width:300px;',
|
|
||||||
'desc_tip' => true,
|
|
||||||
),
|
|
||||||
|
|
||||||
array(
|
|
||||||
'title' => __( 'Terms and Conditions', 'sportspress' ),
|
|
||||||
'desc' => __( 'If you define a "Terms" page the customer will be asked if they accept them when checking out.', 'sportspress' ),
|
|
||||||
'id' => 'sportspress_terms_page_id',
|
|
||||||
'default' => '',
|
|
||||||
'class' => 'chosen_select_nostd',
|
|
||||||
'css' => 'min-width:300px;',
|
|
||||||
'type' => 'single_select_page',
|
|
||||||
'desc_tip' => true,
|
|
||||||
'autoload' => false
|
|
||||||
),
|
|
||||||
|
|
||||||
array( 'type' => 'sectionend', 'id' => 'checkout_page_options' ),
|
|
||||||
|
|
||||||
array( 'title' => __( 'Checkout Endpoints', 'sportspress' ), 'type' => 'title', 'desc' => __( 'Endpoints are appended to your page URLs to handle specific actions during the checkout process. They should be unique.', 'sportspress' ), 'id' => 'account_endpoint_options' ),
|
|
||||||
|
|
||||||
array(
|
|
||||||
'title' => __( 'Pay', 'sportspress' ),
|
|
||||||
'desc' => __( 'Endpoint for the Checkout → Pay page', 'sportspress' ),
|
|
||||||
'id' => 'sportspress_checkout_pay_endpoint',
|
|
||||||
'type' => 'text',
|
|
||||||
'default' => 'order-pay',
|
|
||||||
'desc_tip' => true,
|
|
||||||
),
|
|
||||||
|
|
||||||
array(
|
|
||||||
'title' => __( 'Order Received', 'sportspress' ),
|
|
||||||
'desc' => __( 'Endpoint for the Checkout → Pay page', 'sportspress' ),
|
|
||||||
'id' => 'sportspress_checkout_order_received_endpoint',
|
|
||||||
'type' => 'text',
|
|
||||||
'default' => 'order-received',
|
|
||||||
'desc_tip' => true,
|
|
||||||
),
|
|
||||||
|
|
||||||
array(
|
|
||||||
'title' => __( 'Add Payment Method', 'sportspress' ),
|
|
||||||
'desc' => __( 'Endpoint for the Checkout → Add Payment Method page', 'sportspress' ),
|
|
||||||
'id' => 'sportspress_myaccount_add_payment_method_endpoint',
|
|
||||||
'type' => 'text',
|
|
||||||
'default' => 'add-payment-method',
|
|
||||||
'desc_tip' => true,
|
|
||||||
),
|
|
||||||
|
|
||||||
array( 'type' => 'sectionend', 'id' => 'checkout_endpoint_options' ),
|
|
||||||
|
|
||||||
array( 'title' => __( 'Payment Gateways', 'sportspress' ), 'desc' => __( 'Installed gateways are listed below. Drag and drop gateways to control their display order on the frontend.', 'sportspress' ), 'type' => 'title', 'id' => 'payment_gateways_options' ),
|
|
||||||
|
|
||||||
array( 'type' => 'payment_gateways' ),
|
|
||||||
|
|
||||||
array( 'type' => 'sectionend', 'id' => 'payment_gateways_options' ),
|
|
||||||
|
|
||||||
)); // End payment_gateway settings
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Output the settings
|
|
||||||
*/
|
|
||||||
public function output() {
|
|
||||||
global $current_section;
|
|
||||||
|
|
||||||
// Load shipping methods so we can show any global options they may have
|
|
||||||
$payment_gateways = SP()->payment_gateways->payment_gateways();
|
|
||||||
|
|
||||||
if ( $current_section ) {
|
|
||||||
foreach ( $payment_gateways as $gateway ) {
|
|
||||||
if ( strtolower( get_class( $gateway ) ) == strtolower( $current_section ) ) {
|
|
||||||
$gateway->admin_options();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$settings = $this->get_settings();
|
|
||||||
|
|
||||||
SP_Admin_Settings::output_fields( $settings );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Output payment gateway settings.
|
|
||||||
*
|
|
||||||
* @access public
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function payment_gateways_setting() {
|
|
||||||
?>
|
|
||||||
<tr valign="top">
|
|
||||||
<th scope="row" class="titledesc"><?php _e( 'Gateway Display', 'sportspress' ) ?></th>
|
|
||||||
<td class="forminp">
|
|
||||||
<table class="sp_gateways widefat" cellspacing="0">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<?php
|
|
||||||
$columns = apply_filters( 'sportspress_payment_gateways_setting_columns', array(
|
|
||||||
'default' => __( 'Default', 'sportspress' ),
|
|
||||||
'name' => __( 'Gateway', 'sportspress' ),
|
|
||||||
'id' => __( 'Gateway ID', 'sportspress' ),
|
|
||||||
'status' => __( 'Status', 'sportspress' ),
|
|
||||||
'settings' => ''
|
|
||||||
) );
|
|
||||||
|
|
||||||
foreach ( $columns as $key => $column ) {
|
|
||||||
echo '<th class="' . esc_attr( $key ) . '">' . esc_html( $column ) . '</th>';
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<?php
|
|
||||||
$default_gateway = get_option( 'sportspress_default_gateway' );
|
|
||||||
|
|
||||||
foreach ( SP()->payment_gateways->payment_gateways() as $gateway ) {
|
|
||||||
|
|
||||||
echo '<tr>';
|
|
||||||
|
|
||||||
foreach ( $columns as $key => $column ) {
|
|
||||||
switch ( $key ) {
|
|
||||||
case 'default' :
|
|
||||||
echo '<td width="1%" class="default">
|
|
||||||
<input type="radio" name="default_gateway" value="' . esc_attr( $gateway->id ) . '" ' . checked( $default_gateway, esc_attr( $gateway->id ), false ) . ' />
|
|
||||||
<input type="hidden" name="gateway_order[]" value="' . esc_attr( $gateway->id ) . '" />
|
|
||||||
</td>';
|
|
||||||
break;
|
|
||||||
case 'name' :
|
|
||||||
echo '<td class="name">
|
|
||||||
' . $gateway->get_title() . '
|
|
||||||
</td>';
|
|
||||||
break;
|
|
||||||
case 'id' :
|
|
||||||
echo '<td class="id">
|
|
||||||
' . esc_html( $gateway->id ) . '
|
|
||||||
</td>';
|
|
||||||
break;
|
|
||||||
case 'status' :
|
|
||||||
echo '<td class="status">';
|
|
||||||
|
|
||||||
if ( $gateway->enabled == 'yes' )
|
|
||||||
echo '<span class="status-enabled tips" data-tip="' . __ ( 'Enabled', 'sportspress' ) . '">' . __ ( 'Enabled', 'sportspress' ) . '</span>';
|
|
||||||
else
|
|
||||||
echo '-';
|
|
||||||
|
|
||||||
echo '</td>';
|
|
||||||
break;
|
|
||||||
case 'settings' :
|
|
||||||
echo '<td class="settings">
|
|
||||||
<a class="button" href="' . admin_url( 'admin.php?page=sp-settings&tab=checkout§ion=' . strtolower( get_class( $gateway ) ) ) . '">' . __( 'Settings', 'sportspress' ) . '</a>
|
|
||||||
</td>';
|
|
||||||
break;
|
|
||||||
default :
|
|
||||||
do_action( 'sportspress_payment_gateways_setting_column_' . $key, $gateway );
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
echo '</tr>';
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Save settings
|
|
||||||
*/
|
|
||||||
public function save() {
|
|
||||||
global $current_section;
|
|
||||||
|
|
||||||
if ( ! $current_section ) {
|
|
||||||
|
|
||||||
$settings = $this->get_settings();
|
|
||||||
|
|
||||||
SP_Admin_Settings::save_fields( $settings );
|
|
||||||
SP()->payment_gateways->process_admin_options();
|
|
||||||
|
|
||||||
} elseif ( class_exists( $current_section ) ) {
|
|
||||||
|
|
||||||
$current_section_class = new $current_section();
|
|
||||||
|
|
||||||
do_action( 'sportspress_update_options_payment_gateways_' . $current_section_class->id );
|
|
||||||
|
|
||||||
SP()->payment_gateways()->init();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
endif;
|
|
||||||
|
|
||||||
return new SP_Settings_Payment_Gateways();
|
|
||||||
@@ -51,9 +51,9 @@ class SP_Settings_Config extends SP_Settings_Page {
|
|||||||
'type' => 'select',
|
'type' => 'select',
|
||||||
'options' => SP()->sports->options,
|
'options' => SP()->sports->options,
|
||||||
),
|
),
|
||||||
|
|
||||||
array( 'type' => 'results' ),
|
array( 'type' => 'results' ),
|
||||||
|
|
||||||
array( 'type' => 'outcomes' ),
|
array( 'type' => 'outcomes' ),
|
||||||
|
|
||||||
array( 'type' => 'columns' ),
|
array( 'type' => 'columns' ),
|
||||||
@@ -69,51 +69,110 @@ class SP_Settings_Config extends SP_Settings_Page {
|
|||||||
)); // End event settings
|
)); // End event settings
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Output the settings
|
|
||||||
*/
|
|
||||||
public function output() {
|
|
||||||
global $current_section;
|
|
||||||
|
|
||||||
$tax_classes = array_filter( array_map( 'trim', explode( "\n", get_option('sportspress_tax_classes' ) ) ) );
|
|
||||||
|
|
||||||
if ( $current_section == 'standard' || in_array( $current_section, array_map( 'sanitize_title', $tax_classes ) ) ) {
|
|
||||||
$this->output_tax_rates();
|
|
||||||
} else {
|
|
||||||
$settings = $this->get_settings();
|
|
||||||
|
|
||||||
SP_Admin_Settings::output_fields( $settings );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Save settings
|
* Save settings
|
||||||
*/
|
*/
|
||||||
public function save() {
|
public function save() {
|
||||||
global $current_section, $wpdb;
|
$settings = $this->get_settings();
|
||||||
|
SP_Admin_Settings::save_fields( $settings );
|
||||||
|
|
||||||
|
if ( isset( $_POST['sportspress_primary_result'] ) )
|
||||||
|
update_option( 'sportspress_primary_result', $_POST['sportspress_primary_result'] );
|
||||||
|
|
||||||
if ( ! $current_section ) {
|
if ( isset( $_POST['sportspress_sport'] ) && ! empty( $_POST['sportspress_sport'] ) && get_option( 'sportspress_sport', null ) != $_POST['sportspress_sport'] ):
|
||||||
|
|
||||||
$settings = $this->get_settings();
|
$sport = SP()->sports->$_POST['sportspress_sport'];
|
||||||
SP_Admin_Settings::save_fields( $settings );
|
|
||||||
|
|
||||||
} else {
|
// Get array of taxonomies to insert
|
||||||
|
$term_groups = sp_array_value( $sport, 'term', array() );
|
||||||
|
|
||||||
$this->save_tax_rates();
|
foreach( $term_groups as $taxonomy => $terms ):
|
||||||
|
// Find empty terms and destroy
|
||||||
|
$allterms = get_terms( $taxonomy, 'hide_empty=0' );
|
||||||
|
|
||||||
}
|
foreach( $allterms as $term ):
|
||||||
|
if ( $term->count == 0 )
|
||||||
|
wp_delete_term( $term->term_id, $taxonomy );
|
||||||
|
endforeach;
|
||||||
|
|
||||||
$wpdb->query( "DELETE FROM `$wpdb->options` WHERE `option_name` LIKE ('_transient_sp_tax_rates_%') OR `option_name` LIKE ('_transient_timeout_sp_tax_rates_%')" );
|
// Insert terms
|
||||||
|
foreach( $terms as $term ):
|
||||||
|
wp_insert_term( $term['name'], $taxonomy, array( 'slug' => $term['slug'] ) );
|
||||||
|
endforeach;
|
||||||
|
endforeach;
|
||||||
|
|
||||||
|
// Get array of post types to insert
|
||||||
|
$post_groups = sp_array_value( $sport, 'posts', array() );
|
||||||
|
|
||||||
|
// Loop through each post type
|
||||||
|
foreach( $post_groups as $post_type => $posts ):
|
||||||
|
|
||||||
|
$args = array(
|
||||||
|
'post_type' => $post_type,
|
||||||
|
'numberposts' => -1,
|
||||||
|
'posts_per_page' => -1,
|
||||||
|
'meta_query' => array(
|
||||||
|
array(
|
||||||
|
'key' => '_sp_preset',
|
||||||
|
'value' => 1
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
// Delete posts
|
||||||
|
$old_posts = get_posts( $args );
|
||||||
|
|
||||||
|
foreach( $old_posts as $post ):
|
||||||
|
wp_delete_post( $post->ID, true);
|
||||||
|
endforeach;
|
||||||
|
|
||||||
|
// Add posts
|
||||||
|
foreach( $posts as $index => $post ):
|
||||||
|
|
||||||
|
// Make sure post doesn't overlap
|
||||||
|
if ( ! get_page_by_path( $post['post_name'], OBJECT, $post_type ) ):
|
||||||
|
|
||||||
|
// Translate post title
|
||||||
|
$post['post_title'] = __( $post['post_title'], 'sportspress' );
|
||||||
|
|
||||||
|
// Set post type
|
||||||
|
$post['post_type'] = $post_type;
|
||||||
|
|
||||||
|
// Increment menu order by 2 and publish post
|
||||||
|
$post['menu_order'] = $index * 2 + 2;
|
||||||
|
$post['post_status'] = 'publish';
|
||||||
|
$id = wp_insert_post( $post );
|
||||||
|
|
||||||
|
// Flag as preset
|
||||||
|
update_post_meta( $id, '_sp_preset', 1 );
|
||||||
|
|
||||||
|
// Update meta
|
||||||
|
if ( array_key_exists( 'meta', $post ) ):
|
||||||
|
foreach ( $post['meta'] as $key => $value ):
|
||||||
|
update_post_meta( $id, $key, $value );
|
||||||
|
endforeach;
|
||||||
|
endif;
|
||||||
|
|
||||||
|
// Update terms
|
||||||
|
if ( array_key_exists( 'tax_input', $post ) ):
|
||||||
|
foreach ( $post['tax_input'] as $taxonomy => $terms ):
|
||||||
|
wp_set_object_terms( $id, $terms, $taxonomy, false );
|
||||||
|
endforeach;
|
||||||
|
endif;
|
||||||
|
endif;
|
||||||
|
endforeach;
|
||||||
|
endforeach;
|
||||||
|
endif;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Output results settings.
|
* Results settings
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function results_setting() {
|
public function results_setting() {
|
||||||
$main_result = get_option( 'sportspress_main_result', 0 );
|
$selection = get_option( 'sportspress_primary_result', 0 );
|
||||||
|
|
||||||
$args = array(
|
$args = array(
|
||||||
'post_type' => 'sp_result',
|
'post_type' => 'sp_result',
|
||||||
@@ -127,54 +186,57 @@ class SP_Settings_Config extends SP_Settings_Page {
|
|||||||
<tr valign="top">
|
<tr valign="top">
|
||||||
<th scope="row" class="titledesc"><?php _e( 'Results', 'sportspress' ) ?></th>
|
<th scope="row" class="titledesc"><?php _e( 'Results', 'sportspress' ) ?></th>
|
||||||
<td class="forminp">
|
<td class="forminp">
|
||||||
<table class="widefat sp-admin-config-table">
|
<fieldset>
|
||||||
<thead>
|
<legend class="screen-reader-text"><span><?php _e( 'Results', 'sportspress' ) ?></span></legend>
|
||||||
<tr>
|
<table class="widefat sp-admin-config-table">
|
||||||
<th scope="col"><?php _e( 'Primary', 'sportspress' ); ?></th>
|
<thead>
|
||||||
<th scope="col"><?php _e( 'Label', 'sportspress' ); ?></th>
|
<tr>
|
||||||
<th scope="col"><?php _e( 'Key', 'sportspress' ); ?></th>
|
<th scope="col"><?php _e( 'Primary', 'sportspress' ); ?></th>
|
||||||
<th scope="col" class="edit"></th>
|
<th scope="col"><?php _e( 'Label', 'sportspress' ); ?></th>
|
||||||
</tr>
|
<th scope="col"><?php _e( 'Key', 'sportspress' ); ?></th>
|
||||||
</thead>
|
<th scope="col" class="edit"></th>
|
||||||
<tfoot>
|
</tr>
|
||||||
<tr>
|
</thead>
|
||||||
<th class="radio"><input type="radio" id="sportspress_main_result_0" name="main_result" value="0" <?php checked( $main_result, 0 ); ?>></th>
|
<tfoot>
|
||||||
<th colspan="3"><label for="main_result_0">
|
<tr>
|
||||||
<?php
|
<th class="radio"><input type="radio" id="sportspress_primary_result_0" name="sportspress_primary_result" value="0" <?php checked( $selection, 0 ); ?>></th>
|
||||||
if ( sizeof( $data ) > 0 ):
|
<th colspan="3"><label for="sportspress_primary_result_0">
|
||||||
$default = end( $data );
|
<?php
|
||||||
reset( $data );
|
if ( sizeof( $data ) > 0 ):
|
||||||
printf( __( 'Default (%s)', 'sportspress' ), $default->post_title );
|
$default = end( $data );
|
||||||
else:
|
reset( $data );
|
||||||
_e( 'Default', 'sportspress' );
|
printf( __( 'Default (%s)', 'sportspress' ), $default->post_title );
|
||||||
endif;
|
else:
|
||||||
?>
|
_e( 'Default', 'sportspress' );
|
||||||
</label></th>
|
endif;
|
||||||
</tr>
|
?>
|
||||||
</tfoot>
|
</label></th>
|
||||||
<?php $i = 0; foreach ( $data as $row ): ?>
|
</tr>
|
||||||
<tr<?php if ( $i % 2 == 0 ) echo ' class="alternate"'; ?>>
|
</tfoot>
|
||||||
<td class="radio"><input type="radio" id="main_result_<?php echo $row->post_name; ?>" name="main_result" value="<?php echo $row->post_name; ?>" <?php checked( $main_result, $row->post_name ); ?>></td>
|
<?php $i = 0; foreach ( $data as $row ): ?>
|
||||||
<td class="row-title"><label for="sportspress_main_result_<?php echo $row->post_name; ?>"><?php echo $row->post_title; ?></label></td>
|
<tr<?php if ( $i % 2 == 0 ) echo ' class="alternate"'; ?>>
|
||||||
<td><?php echo $row->post_name; ?>for / <?php echo $row->post_name; ?>against</td>
|
<td class="radio"><input type="radio" id="sportspress_primary_result_<?php echo $row->post_name; ?>" name="sportspress_primary_result" value="<?php echo $row->post_name; ?>" <?php checked( $selection, $row->post_name ); ?>></td>
|
||||||
<td class="edit"><a class="button" href="<?php echo get_edit_post_link( $row->ID ); ?>"><?php _e( 'Edit', 'sportspress' ); ?></s></td>
|
<td class="row-title"><label for="sportspress_primary_result_<?php echo $row->post_name; ?>"><?php echo $row->post_title; ?></label></td>
|
||||||
</tr>
|
<td><?php echo $row->post_name; ?>for / <?php echo $row->post_name; ?>against</td>
|
||||||
<?php $i++; endforeach; ?>
|
<td class="edit"><a class="button" href="<?php echo get_edit_post_link( $row->ID ); ?>"><?php _e( 'Edit', 'sportspress' ); ?></s></td>
|
||||||
</table>
|
</tr>
|
||||||
<div class="tablenav bottom">
|
<?php $i++; endforeach; ?>
|
||||||
<div class="alignleft actions">
|
</table>
|
||||||
<a class="button" id="doaction" href="<?php echo admin_url( 'edit.php?post_type=sp_result' ); ?>"><?php _e( 'View All', 'sportspress' ); ?></a>
|
<div class="tablenav bottom">
|
||||||
<a class="button" id="doaction2" href="<?php echo admin_url( 'post-new.php?post_type=sp_result' ); ?>"><?php _e( 'Add New', 'sportspress' ); ?></a>
|
<div class="alignleft actions">
|
||||||
|
<a class="button" id="doaction" href="<?php echo admin_url( 'edit.php?post_type=sp_result' ); ?>"><?php _e( 'View All', 'sportspress' ); ?></a>
|
||||||
|
<a class="button" id="doaction2" href="<?php echo admin_url( 'post-new.php?post_type=sp_result' ); ?>"><?php _e( 'Add New', 'sportspress' ); ?></a>
|
||||||
|
</div>
|
||||||
|
<br class="clear">
|
||||||
</div>
|
</div>
|
||||||
<br class="clear">
|
</fieldset>
|
||||||
</div>
|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Output outcomes settings.
|
* Output outcomes settings
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
* @return void
|
* @return void
|
||||||
@@ -221,7 +283,7 @@ class SP_Settings_Config extends SP_Settings_Page {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Output columns settings.
|
* Output columns settings
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
* @return void
|
* @return void
|
||||||
@@ -275,7 +337,7 @@ class SP_Settings_Config extends SP_Settings_Page {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Output metrics settings.
|
* Output metrics settings
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
* @return void
|
* @return void
|
||||||
@@ -324,7 +386,7 @@ class SP_Settings_Config extends SP_Settings_Page {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Output performance settings.
|
* Output performance settings
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
* @return void
|
* @return void
|
||||||
@@ -375,4 +437,4 @@ class SP_Settings_Config extends SP_Settings_Page {
|
|||||||
|
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
return new SP_Settings_Config();
|
return new SP_Settings_Config();
|
||||||
|
|||||||
@@ -1,213 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* SportsPress Email Settings
|
|
||||||
*
|
|
||||||
* @author ThemeBoy
|
|
||||||
* @category Admin
|
|
||||||
* @package SportsPress/Admin
|
|
||||||
* @version 0.7
|
|
||||||
*/
|
|
||||||
|
|
||||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
|
||||||
|
|
||||||
if ( ! class_exists( 'SP_Settings_Emails' ) ) :
|
|
||||||
|
|
||||||
/**
|
|
||||||
* SP_Settings_Emails
|
|
||||||
*/
|
|
||||||
class SP_Settings_Emails extends SP_Settings_Page {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor.
|
|
||||||
*/
|
|
||||||
public function __construct() {
|
|
||||||
$this->id = 'email';
|
|
||||||
$this->label = __( 'Emails', 'sportspress' );
|
|
||||||
|
|
||||||
add_filter( 'sportspress_settings_tabs_array', array( $this, 'add_settings_page' ), 20 );
|
|
||||||
add_action( 'sportspress_sections_' . $this->id, array( $this, 'output_sections' ) );
|
|
||||||
add_action( 'sportspress_settings_' . $this->id, array( $this, 'output' ) );
|
|
||||||
add_action( 'sportspress_settings_save_' . $this->id, array( $this, 'save' ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get sections
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function get_sections() {
|
|
||||||
$sections = array(
|
|
||||||
'' => __( 'Email Options', 'sportspress' )
|
|
||||||
);
|
|
||||||
|
|
||||||
// Define emails that can be customised here
|
|
||||||
$mailer = SP()->mailer();
|
|
||||||
$email_templates = $mailer->get_emails();
|
|
||||||
|
|
||||||
foreach ( $email_templates as $email ) {
|
|
||||||
$title = empty( $email->title ) ? ucfirst( $email->id ) : ucfirst( $email->title );
|
|
||||||
|
|
||||||
$sections[ strtolower( get_class( $email ) ) ] = esc_html( $title );
|
|
||||||
}
|
|
||||||
|
|
||||||
return $sections;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get settings array
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function get_settings() {
|
|
||||||
return apply_filters('sportspress_email_settings', array(
|
|
||||||
|
|
||||||
array( 'type' => 'sectionend', 'id' => 'email_recipient_options' ),
|
|
||||||
|
|
||||||
array( 'title' => __( 'Email Sender Options', 'sportspress' ), 'type' => 'title', 'desc' => __( 'The following options affect the sender (email address and name) used in SportsPress emails.', 'sportspress' ), 'id' => 'email_options' ),
|
|
||||||
|
|
||||||
array(
|
|
||||||
'title' => __( '"From" Name', 'sportspress' ),
|
|
||||||
'desc' => '',
|
|
||||||
'id' => 'sportspress_email_from_name',
|
|
||||||
'type' => 'text',
|
|
||||||
'css' => 'min-width:300px;',
|
|
||||||
'default' => esc_attr(get_bloginfo('title')),
|
|
||||||
'autoload' => false
|
|
||||||
),
|
|
||||||
|
|
||||||
array(
|
|
||||||
'title' => __( '"From" Email Address', 'sportspress' ),
|
|
||||||
'desc' => '',
|
|
||||||
'id' => 'sportspress_email_from_address',
|
|
||||||
'type' => 'email',
|
|
||||||
'custom_attributes' => array(
|
|
||||||
'multiple' => 'multiple'
|
|
||||||
),
|
|
||||||
'css' => 'min-width:300px;',
|
|
||||||
'default' => get_option('admin_email'),
|
|
||||||
'autoload' => false
|
|
||||||
),
|
|
||||||
|
|
||||||
array( 'type' => 'sectionend', 'id' => 'email_options' ),
|
|
||||||
|
|
||||||
array( 'title' => __( 'Email Template', 'sportspress' ), 'type' => 'title', 'desc' => sprintf(__( 'This section lets you customise the SportsPress emails. <a href="%s" target="_blank">Click here to preview your email template</a>. For more advanced control copy <code>sportspress/templates/emails/</code> to <code>yourtheme/sportspress/emails/</code>.', 'sportspress' ), wp_nonce_url(admin_url('?preview_sportspress_mail=true'), 'preview-mail')), 'id' => 'email_template_options' ),
|
|
||||||
|
|
||||||
array(
|
|
||||||
'title' => __( 'Header Image', 'sportspress' ),
|
|
||||||
'desc' => sprintf(__( 'Enter a URL to an image you want to show in the email\'s header. Upload your image using the <a href="%s">media uploader</a>.', 'sportspress' ), admin_url('media-new.php')),
|
|
||||||
'id' => 'sportspress_email_header_image',
|
|
||||||
'type' => 'text',
|
|
||||||
'css' => 'min-width:300px;',
|
|
||||||
'default' => '',
|
|
||||||
'autoload' => false
|
|
||||||
),
|
|
||||||
|
|
||||||
array(
|
|
||||||
'title' => __( 'Email Footer Text', 'sportspress' ),
|
|
||||||
'desc' => __( 'The text to appear in the footer of SportsPress emails.', 'sportspress' ),
|
|
||||||
'id' => 'sportspress_email_footer_text',
|
|
||||||
'css' => 'width:100%; height: 75px;',
|
|
||||||
'type' => 'textarea',
|
|
||||||
'default' => get_bloginfo('title') . ' - ' . __( 'Powered by SportsPress', 'sportspress' ),
|
|
||||||
'autoload' => false
|
|
||||||
),
|
|
||||||
|
|
||||||
array(
|
|
||||||
'title' => __( 'Base Colour', 'sportspress' ),
|
|
||||||
'desc' => __( 'The base colour for SportsPress email templates. Default <code>#557da1</code>.', 'sportspress' ),
|
|
||||||
'id' => 'sportspress_email_base_color',
|
|
||||||
'type' => 'color',
|
|
||||||
'css' => 'width:6em;',
|
|
||||||
'default' => '#557da1',
|
|
||||||
'autoload' => false
|
|
||||||
),
|
|
||||||
|
|
||||||
array(
|
|
||||||
'title' => __( 'Background Colour', 'sportspress' ),
|
|
||||||
'desc' => __( 'The background colour for SportsPress email templates. Default <code>#f5f5f5</code>.', 'sportspress' ),
|
|
||||||
'id' => 'sportspress_email_background_color',
|
|
||||||
'type' => 'color',
|
|
||||||
'css' => 'width:6em;',
|
|
||||||
'default' => '#f5f5f5',
|
|
||||||
'autoload' => false
|
|
||||||
),
|
|
||||||
|
|
||||||
array(
|
|
||||||
'title' => __( 'Email Body Background Colour', 'sportspress' ),
|
|
||||||
'desc' => __( 'The main body background colour. Default <code>#fdfdfd</code>.', 'sportspress' ),
|
|
||||||
'id' => 'sportspress_email_body_background_color',
|
|
||||||
'type' => 'color',
|
|
||||||
'css' => 'width:6em;',
|
|
||||||
'default' => '#fdfdfd',
|
|
||||||
'autoload' => false
|
|
||||||
),
|
|
||||||
|
|
||||||
array(
|
|
||||||
'title' => __( 'Email Body Text Colour', 'sportspress' ),
|
|
||||||
'desc' => __( 'The main body text colour. Default <code>#505050</code>.', 'sportspress' ),
|
|
||||||
'id' => 'sportspress_email_text_color',
|
|
||||||
'type' => 'color',
|
|
||||||
'css' => 'width:6em;',
|
|
||||||
'default' => '#505050',
|
|
||||||
'autoload' => false
|
|
||||||
),
|
|
||||||
|
|
||||||
array( 'type' => 'sectionend', 'id' => 'email_template_options' ),
|
|
||||||
|
|
||||||
)); // End email settings
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Output the settings
|
|
||||||
*/
|
|
||||||
public function output() {
|
|
||||||
global $current_section;
|
|
||||||
|
|
||||||
// Define emails that can be customised here
|
|
||||||
$mailer = SP()->mailer();
|
|
||||||
$email_templates = $mailer->get_emails();
|
|
||||||
|
|
||||||
if ( $current_section ) {
|
|
||||||
foreach ( $email_templates as $email ) {
|
|
||||||
if ( strtolower( get_class( $email ) ) == $current_section ) {
|
|
||||||
$email->admin_options();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$settings = $this->get_settings();
|
|
||||||
|
|
||||||
SP_Admin_Settings::output_fields( $settings );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Save settings
|
|
||||||
*/
|
|
||||||
public function save() {
|
|
||||||
global $current_section;
|
|
||||||
|
|
||||||
if ( ! $current_section ) {
|
|
||||||
|
|
||||||
$settings = $this->get_settings();
|
|
||||||
SP_Admin_Settings::save_fields( $settings );
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
// Load mailer
|
|
||||||
$mailer = SP()->mailer();
|
|
||||||
|
|
||||||
if ( class_exists( $current_section ) ) {
|
|
||||||
$current_section_class = new $current_section();
|
|
||||||
do_action( 'sportspress_update_options_' . $this->id . '_' . $current_section_class->id );
|
|
||||||
SP()->mailer()->init();
|
|
||||||
} else {
|
|
||||||
do_action( 'sportspress_update_options_' . $this->id . '_' . $current_section );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
endif;
|
|
||||||
|
|
||||||
return new SP_Settings_Emails();
|
|
||||||
@@ -18,7 +18,7 @@ if ( ! class_exists( 'SP_Settings_Events' ) ) :
|
|||||||
class SP_Settings_Events extends SP_Settings_Page {
|
class SP_Settings_Events extends SP_Settings_Page {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor
|
||||||
*/
|
*/
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
$this->id = 'events';
|
$this->id = 'events';
|
||||||
@@ -26,6 +26,7 @@ class SP_Settings_Events extends SP_Settings_Page {
|
|||||||
|
|
||||||
add_filter( 'sportspress_settings_tabs_array', array( $this, 'add_settings_page' ), 20 );
|
add_filter( 'sportspress_settings_tabs_array', array( $this, 'add_settings_page' ), 20 );
|
||||||
add_action( 'sportspress_settings_' . $this->id, array( $this, 'output' ) );
|
add_action( 'sportspress_settings_' . $this->id, array( $this, 'output' ) );
|
||||||
|
add_action( 'sportspress_admin_field_delimiter', array( $this, 'delimiter_setting' ) );
|
||||||
add_action( 'sportspress_settings_save_' . $this->id, array( $this, 'save' ) );
|
add_action( 'sportspress_settings_save_' . $this->id, array( $this, 'save' ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -35,674 +36,112 @@ class SP_Settings_Events extends SP_Settings_Page {
|
|||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function get_settings() {
|
public function get_settings() {
|
||||||
$tax_classes = array_filter( array_map( 'trim', explode( "\n", get_option( 'sportspress_tax_classes' ) ) ) );
|
|
||||||
$classes_options = array();
|
|
||||||
if ( $tax_classes )
|
|
||||||
foreach ( $tax_classes as $class )
|
|
||||||
$classes_options[ sanitize_title( $class ) ] = esc_html( $class );
|
|
||||||
|
|
||||||
return apply_filters('sportspress_event_settings', array(
|
$settings = array(
|
||||||
|
|
||||||
array( 'title' => __( 'Event Options', 'sportspress' ), 'type' => 'title','desc' => '', 'id' => 'tax_options' ),
|
array( 'title' => __( 'Event Options', 'sportspress' ), 'type' => 'title','desc' => '', 'id' => 'event_options' ),
|
||||||
|
|
||||||
array(
|
array(
|
||||||
'title' => __( 'Delimiter', 'sportspress' ),
|
'title' => __( 'Number of Teams', 'sportspress' ),
|
||||||
'id' => 'sportspress_event_teams_delimiter',
|
'id' => 'sportspress_event_num_teams',
|
||||||
'default' => 'vs',
|
'css' => 'width:50px;',
|
||||||
'type' => 'radio',
|
'default' => '2',
|
||||||
'options' => array(
|
'type' => 'number',
|
||||||
'vs' => sprintf( '%s vs %s', __( 'Team', 'sportspress' ), __( 'Team', 'sportspress' ) ),
|
'custom_attributes' => array(
|
||||||
'v' => sprintf( '%s v %s', __( 'Team', 'sportspress' ), __( 'Team', 'sportspress' ) ),
|
'min' => 0,
|
||||||
'—' => sprintf( '%s — %s', __( 'Team', 'sportspress' ), __( 'Team', 'sportspress' ) ),
|
'step' => 1
|
||||||
'/' => sprintf( '%s / %s', __( 'Team', 'sportspress' ), __( 'Team', 'sportspress' ) )
|
)
|
||||||
),
|
),
|
||||||
|
|
||||||
|
array( 'type' => 'delimiter' ),
|
||||||
|
|
||||||
|
array(
|
||||||
|
'title' => __( 'Venue', 'sportspress' ),
|
||||||
|
'desc' => __( 'Display maps', 'sportspress' ),
|
||||||
|
'id' => 'sportspress_event_show_map',
|
||||||
|
'default' => 'yes',
|
||||||
|
'type' => 'checkbox',
|
||||||
|
'checkboxgroup' => 'start',
|
||||||
),
|
),
|
||||||
|
|
||||||
array(
|
array(
|
||||||
'title' => __( 'Calculate Tax Based On:', 'sportspress' ),
|
'desc' => __( 'Link venues', 'sportspress' ),
|
||||||
'id' => 'sportspress_tax_based_on',
|
'id' => 'sportspress_event_link_venues',
|
||||||
'desc_tip' => __( 'This option determines which address is used to calculate tax.', 'sportspress' ),
|
|
||||||
'default' => 'shipping',
|
|
||||||
'type' => 'select',
|
|
||||||
'options' => array(
|
|
||||||
'shipping' => __( 'Customer shipping address', 'sportspress' ),
|
|
||||||
'billing' => __( 'Customer billing address', 'sportspress' ),
|
|
||||||
'base' => __( 'Shop base address', 'sportspress' )
|
|
||||||
),
|
|
||||||
),
|
|
||||||
|
|
||||||
array(
|
|
||||||
'title' => __( 'Default Customer Address:', 'sportspress' ),
|
|
||||||
'id' => 'sportspress_default_customer_address',
|
|
||||||
'desc_tip' => __( 'This option determines the customers default address (before they input their own).', 'sportspress' ),
|
|
||||||
'default' => 'base',
|
|
||||||
'type' => 'select',
|
|
||||||
'options' => array(
|
|
||||||
'' => __( 'No address', 'sportspress' ),
|
|
||||||
'base' => __( 'Shop base address', 'sportspress' ),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
|
|
||||||
array(
|
|
||||||
'title' => __( 'Shipping Tax Class:', 'sportspress' ),
|
|
||||||
'desc' => __( 'Optionally control which tax class shipping gets, or leave it so shipping tax is based on the cart items themselves.', 'sportspress' ),
|
|
||||||
'id' => 'sportspress_shipping_tax_class',
|
|
||||||
'css' => 'min-width:150px;',
|
|
||||||
'default' => 'title',
|
|
||||||
'type' => 'select',
|
|
||||||
'options' => array( '' => __( 'Shipping tax class based on cart items', 'sportspress' ), 'standard' => __( 'Standard', 'sportspress' ) ) + $classes_options,
|
|
||||||
'desc_tip' => true,
|
|
||||||
),
|
|
||||||
|
|
||||||
array(
|
|
||||||
'title' => __( 'Rounding', 'sportspress' ),
|
|
||||||
'desc' => __( 'Round tax at subtotal level, instead of rounding per line', 'sportspress' ),
|
|
||||||
'id' => 'sportspress_tax_round_at_subtotal',
|
|
||||||
'default' => 'no',
|
'default' => 'no',
|
||||||
'type' => 'checkbox',
|
'type' => 'checkbox',
|
||||||
|
'checkboxgroup' => 'end',
|
||||||
|
),
|
||||||
|
|
||||||
|
array(
|
||||||
|
'title' => __( 'Performance', 'sportspress' ),
|
||||||
|
'desc' => __( 'Link players', 'sportspress' ),
|
||||||
|
'id' => 'sportspress_event_link_players',
|
||||||
|
'default' => 'yes',
|
||||||
|
'type' => 'checkbox',
|
||||||
),
|
),
|
||||||
|
|
||||||
array(
|
|
||||||
'title' => __( 'Additional Tax Classes', 'sportspress' ),
|
|
||||||
'desc' => __( 'List additonal tax classes below (1 per line). This is in addition to the default <code>Standard Rate</code>. Tax classes can be assigned to products.', 'sportspress' ),
|
|
||||||
'id' => 'sportspress_tax_classes',
|
|
||||||
'css' => 'width:100%; height: 65px;',
|
|
||||||
'type' => 'textarea',
|
|
||||||
'default' => sprintf( __( 'Reduced Rate%sZero Rate', 'sportspress' ), PHP_EOL )
|
|
||||||
),
|
|
||||||
|
|
||||||
array(
|
|
||||||
'title' => __( 'Display prices in the shop:', 'sportspress' ),
|
|
||||||
'id' => 'sportspress_tax_display_shop',
|
|
||||||
'default' => 'excl',
|
|
||||||
'type' => 'select',
|
|
||||||
'options' => array(
|
|
||||||
'incl' => __( 'Including tax', 'sportspress' ),
|
|
||||||
'excl' => __( 'Excluding tax', 'sportspress' ),
|
|
||||||
)
|
|
||||||
),
|
|
||||||
|
|
||||||
array(
|
|
||||||
'title' => __( 'Price display suffix:', 'sportspress' ),
|
|
||||||
'id' => 'sportspress_price_display_suffix',
|
|
||||||
'default' => '',
|
|
||||||
'type' => 'text',
|
|
||||||
'desc' => __( 'Define text to show after your product prices. This could be, for example, "inc. Vat" to explain your pricing. You can also have prices substituted here using one of the following: <code>{price_including_tax}, {price_excluding_tax}</code>.', 'sportspress' ),
|
|
||||||
),
|
|
||||||
|
|
||||||
array(
|
|
||||||
'title' => __( 'Display prices during cart/checkout:', 'sportspress' ),
|
|
||||||
'id' => 'sportspress_tax_display_cart',
|
|
||||||
'default' => 'excl',
|
|
||||||
'type' => 'select',
|
|
||||||
'options' => array(
|
|
||||||
'incl' => __( 'Including tax', 'sportspress' ),
|
|
||||||
'excl' => __( 'Excluding tax', 'sportspress' ),
|
|
||||||
),
|
|
||||||
'autoload' => false
|
|
||||||
),
|
|
||||||
|
|
||||||
array(
|
|
||||||
'title' => __( 'Display tax totals:', 'sportspress' ),
|
|
||||||
'id' => 'sportspress_tax_total_display',
|
|
||||||
'default' => 'itemized',
|
|
||||||
'type' => 'select',
|
|
||||||
'options' => array(
|
|
||||||
'single' => __( 'As a single total', 'sportspress' ),
|
|
||||||
'itemized' => __( 'Itemized', 'sportspress' ),
|
|
||||||
),
|
|
||||||
'autoload' => false
|
|
||||||
),
|
|
||||||
|
|
||||||
array( 'type' => 'results' ),
|
|
||||||
|
|
||||||
array( 'type' => 'sectionend', 'id' => 'event_options' ),
|
array( 'type' => 'sectionend', 'id' => 'event_options' ),
|
||||||
|
|
||||||
)); // End event settings
|
array( 'title' => __( 'Text', 'sportspress' ), 'type' => 'title', 'desc' => __( 'The following options affect how words are displayed on the frontend.', 'sportspress' ), 'id' => 'text_options' ),
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
);
|
||||||
* Output the settings
|
|
||||||
*/
|
|
||||||
public function output() {
|
|
||||||
global $current_section;
|
|
||||||
|
|
||||||
$tax_classes = array_filter( array_map( 'trim', explode( "\n", get_option('sportspress_tax_classes' ) ) ) );
|
foreach ( SP()->text->event as $key => $value ):
|
||||||
|
$settings[] = array(
|
||||||
|
'title' => $value,
|
||||||
|
'id' => 'sportspress_event_' . $key . '_text',
|
||||||
|
'default' => '',
|
||||||
|
'placeholder' => $value,
|
||||||
|
'type' => 'text',
|
||||||
|
);
|
||||||
|
endforeach;
|
||||||
|
|
||||||
if ( $current_section == 'standard' || in_array( $current_section, array_map( 'sanitize_title', $tax_classes ) ) ) {
|
$settings[] = array( 'type' => 'sectionend', 'id' => 'text_options' );
|
||||||
$this->output_tax_rates();
|
|
||||||
} else {
|
|
||||||
$settings = $this->get_settings();
|
|
||||||
|
|
||||||
SP_Admin_Settings::output_fields( $settings );
|
return apply_filters( 'sportspress_event_settings', $settings ); // End event settings
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Save settings
|
* Save settings
|
||||||
*/
|
*/
|
||||||
public function save() {
|
public function save() {
|
||||||
global $current_section, $wpdb;
|
$settings = $this->get_settings();
|
||||||
|
SP_Admin_Settings::save_fields( $settings );
|
||||||
if ( ! $current_section ) {
|
|
||||||
|
if ( isset( $_POST['sportspress_event_teams_delimiter'] ) )
|
||||||
$settings = $this->get_settings();
|
update_option( 'sportspress_event_teams_delimiter', $_POST['sportspress_event_teams_delimiter'] );
|
||||||
SP_Admin_Settings::save_fields( $settings );
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
$this->save_tax_rates();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
$wpdb->query( "DELETE FROM `$wpdb->options` WHERE `option_name` LIKE ('_transient_sp_tax_rates_%') OR `option_name` LIKE ('_transient_timeout_sp_tax_rates_%')" );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Output tax rate tables
|
* Delimiter settings
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function output_tax_rates() {
|
public function delimiter_setting() {
|
||||||
global $sportspress, $current_section, $wpdb;
|
$selection = get_option( 'sportspress_event_teams_delimiter', 'vs' );
|
||||||
|
|
||||||
$page = ! empty( $_GET['p'] ) ? absint( $_GET['p'] ) : 1;
|
|
||||||
$limit = 100;
|
|
||||||
$tax_classes = array_filter( array_map( 'trim', explode( "\n", get_option('sportspress_tax_classes' ) ) ) );
|
|
||||||
$current_class = '';
|
|
||||||
|
|
||||||
foreach( $tax_classes as $class )
|
|
||||||
if ( sanitize_title( $class ) == $current_section )
|
|
||||||
$current_class = $class;
|
|
||||||
?>
|
?>
|
||||||
<h3><?php printf( __( 'Tax Rates for the "%s" Class', 'sportspress' ), $current_class ? esc_html( $current_class ) : __( 'Standard', 'sportspress' ) ); ?></h3>
|
<tr valign="top">
|
||||||
<p><?php printf( __( 'Define tax rates for countries and states below. <a href="%s">See here</a> for available alpha-2 country codes.', 'sportspress' ), 'http://en.wikipedia.org/wiki/ISO_3166-1#Current_codes' ); ?></p>
|
<th scope="row" class="titledesc">
|
||||||
<table class="sp_tax_rates sp_input_table sortable widefat">
|
<?php _e( 'Delimiter', 'sportspress' ); ?>
|
||||||
<thead>
|
</th>
|
||||||
<tr>
|
<td class="forminp">
|
||||||
<th class="sort"> </th>
|
<fieldset class="sp-custom-input-wrapper">
|
||||||
|
<legend class="screen-reader-text"><span><?php _e( 'Delimiter', 'sportspress' ); ?></span></legend>
|
||||||
<th width="8%"><?php _e( 'Country Code', 'sportspress' ); ?> <span class="tips" data-tip="<?php _e('A 2 digit country code, e.g. US. Leave blank to apply to all.', 'sportspress'); ?>">[?]</span></th>
|
<?php $delimiters = array( 'vs', 'v', '—', '/' ); ?>
|
||||||
|
<?php foreach ( $delimiters as $delimiter ): ?>
|
||||||
<th width="8%"><?php _e( 'State Code', 'sportspress' ); ?> <span class="tips" data-tip="<?php _e('A 2 digit state code, e.g. AL. Leave blank to apply to all.', 'sportspress'); ?>">[?]</span></th>
|
<label title="<?php echo $delimiter; ?>"><input type="radio" class="preset" name="sportspress_event_teams_delimiter_preset" value="<?php echo $delimiter; ?>" data-example="<?php _e( 'Team', 'sportspress' ); ?> <?php echo $delimiter; ?> <?php _e( 'Team', 'sportspress' ); ?>" <?php checked( $delimiter, $selection ); ?>> <span><?php _e( 'Team', 'sportspress' ); ?> <?php echo $delimiter; ?> <?php _e( 'Team', 'sportspress' ); ?></span></label><br>
|
||||||
|
<?php endforeach; ?>
|
||||||
<th><?php _e( 'ZIP/Postcode', 'sportspress' ); ?> <span class="tips" data-tip="<?php _e('Postcode for this rule. Semi-colon (;) separate multiple values. Leave blank to apply to all areas. Wildcards (*) can be used. Ranges for numeric postcodes (e.g. 12345-12350) will be expanded into individual postcodes.', 'sportspress'); ?>">[?]</span></th>
|
<label><input type="radio" class="preset" name="sportspress_event_teams_delimiter_preset" value="\c\u\s\t\o\m" <?php checked( false, in_array( $selection, $delimiters ) ); ?>> <?php _e( 'Custom:', 'sportspress' ); ?> </label><input type="text" class="small-text value" name="sportspress_event_teams_delimiter" value="<?php echo $selection; ?>" data-example-format="<?php _e( 'Team', 'sportspress' ); ?> __val__ <?php _e( 'Team', 'sportspress' ); ?>">
|
||||||
|
<span class="example"><?php _e( 'Team', 'sportspress' ); ?> <?php echo $selection; ?> <?php _e( 'Team', 'sportspress' ); ?></span>
|
||||||
<th><?php _e( 'City', 'sportspress' ); ?> <span class="tips" data-tip="<?php _e('Cities for this rule. Semi-colon (;) separate multiple values. Leave blank to apply to all cities.', 'sportspress'); ?>">[?]</span></th>
|
</fieldset>
|
||||||
|
</td>
|
||||||
<th width="8%"><?php _e( 'Rate %', 'sportspress' ); ?> <span class="tips" data-tip="<?php _e( 'Enter a tax rate (percentage) to 4 decimal places.', 'sportspress' ); ?>">[?]</span></th>
|
</tr>
|
||||||
|
|
||||||
<th width="8%"><?php _e( 'Tax Name', 'sportspress' ); ?> <span class="tips" data-tip="<?php _e('Enter a name for this tax rate.', 'sportspress'); ?>">[?]</span></th>
|
|
||||||
|
|
||||||
<th width="8%"><?php _e( 'Priority', 'sportspress' ); ?> <span class="tips" data-tip="<?php _e('Choose a priority for this tax rate. Only 1 matching rate per priority will be used. To define multiple tax rates for a single area you need to specify a different priority per rate.', 'sportspress'); ?>">[?]</span></th>
|
|
||||||
|
|
||||||
<th width="8%"><?php _e( 'Compound', 'sportspress' ); ?> <span class="tips" data-tip="<?php _e('Choose whether or not this is a compound rate. Compound tax rates are applied on top of other tax rates.', 'sportspress'); ?>">[?]</span></th>
|
|
||||||
|
|
||||||
<th width="8%"><?php _e( 'Shipping', 'sportspress' ); ?> <span class="tips" data-tip="<?php _e('Choose whether or not this tax rate also gets applied to shipping.', 'sportspress'); ?>">[?]</span></th>
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tfoot>
|
|
||||||
<tr>
|
|
||||||
<th colspan="10">
|
|
||||||
<a href="#" class="button plus insert"><?php _e( 'Insert row', 'sportspress' ); ?></a>
|
|
||||||
<a href="#" class="button minus remove_tax_rates"><?php _e( 'Remove selected row(s)', 'sportspress' ); ?></a>
|
|
||||||
|
|
||||||
<div class="pagination">
|
|
||||||
<?php
|
|
||||||
echo str_replace( 'page-numbers', 'page-numbers button', paginate_links( array(
|
|
||||||
'base' => add_query_arg( 'p', '%#%' ),
|
|
||||||
'type' => 'plain',
|
|
||||||
'prev_text' => '«',
|
|
||||||
'next_text' => '»',
|
|
||||||
'total' => ceil( absint( $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(tax_rate_id) FROM {$wpdb->prefix}sportspress_tax_rates WHERE tax_rate_class = %s;", sanitize_title( $current_class ) ) ) ) / $limit ),
|
|
||||||
'current' => $page
|
|
||||||
) ) );
|
|
||||||
?>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<a href="#" download="tax_rates.csv" class="button export"><?php _e( 'Export CSV', 'sportspress' ); ?></a>
|
|
||||||
<a href="<?php echo admin_url( 'admin.php?import=sportspress_tax_rate_csv' ); ?>" class="button import"><?php _e( 'Import CSV', 'sportspress' ); ?></a>
|
|
||||||
</th>
|
|
||||||
</tr>
|
|
||||||
</tfoot>
|
|
||||||
<tbody id="rates">
|
|
||||||
<?php
|
|
||||||
$rates = $wpdb->get_results( $wpdb->prepare(
|
|
||||||
"SELECT * FROM {$wpdb->prefix}sportspress_tax_rates
|
|
||||||
WHERE tax_rate_class = %s
|
|
||||||
ORDER BY tax_rate_order
|
|
||||||
LIMIT %d, %d
|
|
||||||
" ,
|
|
||||||
sanitize_title( $current_class ),
|
|
||||||
( $page - 1 ) * $limit,
|
|
||||||
$limit
|
|
||||||
) );
|
|
||||||
|
|
||||||
foreach ( $rates as $rate ) {
|
|
||||||
?>
|
|
||||||
<tr>
|
|
||||||
<td class="sort"><input type="hidden" class="remove_tax_rate" name="remove_tax_rate[<?php echo $rate->tax_rate_id ?>]" value="0" /></td>
|
|
||||||
|
|
||||||
<td class="country" width="8%">
|
|
||||||
<input type="text" value="<?php echo esc_attr( $rate->tax_rate_country ) ?>" placeholder="*" name="tax_rate_country[<?php echo $rate->tax_rate_id ?>]" />
|
|
||||||
</td>
|
|
||||||
|
|
||||||
<td class="state" width="8%">
|
|
||||||
<input type="text" value="<?php echo esc_attr( $rate->tax_rate_state ) ?>" placeholder="*" name="tax_rate_state[<?php echo $rate->tax_rate_id ?>]" />
|
|
||||||
</td>
|
|
||||||
|
|
||||||
<td class="postcode">
|
|
||||||
<input type="text" value="<?php
|
|
||||||
$locations = $wpdb->get_col( $wpdb->prepare( "SELECT location_code FROM {$wpdb->prefix}sportspress_tax_rate_locations WHERE location_type='postcode' AND tax_rate_id = %d ORDER BY location_code", $rate->tax_rate_id ) );
|
|
||||||
|
|
||||||
echo esc_attr( implode( '; ', $locations ) );
|
|
||||||
?>" placeholder="*" data-name="tax_rate_postcode[<?php echo $rate->tax_rate_id ?>]" />
|
|
||||||
</td>
|
|
||||||
|
|
||||||
<td class="city">
|
|
||||||
<input type="text" value="<?php
|
|
||||||
$locations = $wpdb->get_col( $wpdb->prepare( "SELECT location_code FROM {$wpdb->prefix}sportspress_tax_rate_locations WHERE location_type='city' AND tax_rate_id = %d ORDER BY location_code", $rate->tax_rate_id ) );
|
|
||||||
echo esc_attr( implode( '; ', $locations ) );
|
|
||||||
?>" placeholder="*" data-name="tax_rate_city[<?php echo $rate->tax_rate_id ?>]" />
|
|
||||||
</td>
|
|
||||||
|
|
||||||
<td class="rate" width="8%">
|
|
||||||
<input type="number" step="any" min="0" value="<?php echo esc_attr( $rate->tax_rate ) ?>" placeholder="0" name="tax_rate[<?php echo $rate->tax_rate_id ?>]" />
|
|
||||||
</td>
|
|
||||||
|
|
||||||
<td class="name" width="8%">
|
|
||||||
<input type="text" value="<?php echo esc_attr( $rate->tax_rate_name ) ?>" name="tax_rate_name[<?php echo $rate->tax_rate_id ?>]" />
|
|
||||||
</td>
|
|
||||||
|
|
||||||
<td class="priority" width="8%">
|
|
||||||
<input type="number" step="1" min="1" value="<?php echo esc_attr( $rate->tax_rate_priority ) ?>" name="tax_rate_priority[<?php echo $rate->tax_rate_id ?>]" />
|
|
||||||
</td>
|
|
||||||
|
|
||||||
<td class="compound" width="8%">
|
|
||||||
<input type="checkbox" class="checkbox" name="tax_rate_compound[<?php echo $rate->tax_rate_id ?>]" <?php checked( $rate->tax_rate_compound, '1' ); ?> />
|
|
||||||
</td>
|
|
||||||
|
|
||||||
<td class="apply_to_shipping" width="8%">
|
|
||||||
<input type="checkbox" class="checkbox" name="tax_rate_shipping[<?php echo $rate->tax_rate_id ?>]" <?php checked($rate->tax_rate_shipping, '1' ); ?> />
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
<script type="text/javascript">
|
|
||||||
jQuery( function() {
|
|
||||||
jQuery('.sp_tax_rates .remove_tax_rates').click(function() {
|
|
||||||
var $tbody = jQuery('.sp_tax_rates').find('tbody');
|
|
||||||
if ( $tbody.find('tr.current').size() > 0 ) {
|
|
||||||
$current = $tbody.find('tr.current');
|
|
||||||
$current.find('input').val('');
|
|
||||||
$current.find('input.remove_tax_rate').val('1');
|
|
||||||
|
|
||||||
$current.each(function(){
|
|
||||||
if ( jQuery(this).is('.new') )
|
|
||||||
jQuery(this).remove();
|
|
||||||
else
|
|
||||||
jQuery(this).hide();
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
alert('<?php echo esc_js( __( 'No row(s) selected', 'sportspress' ) ); ?>');
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
|
|
||||||
jQuery('.sp_tax_rates .export').click(function() {
|
|
||||||
|
|
||||||
var csv_data = "data:application/csv;charset=utf-8,<?php _e( 'Country Code', 'sportspress' ); ?>,<?php _e( 'State Code', 'sportspress' ); ?>,<?php _e( 'ZIP/Postcode', 'sportspress' ); ?>,<?php _e( 'City', 'sportspress' ); ?>,<?php _e( 'Rate %', 'sportspress' ); ?>,<?php _e( 'Tax Name', 'sportspress' ); ?>,<?php _e( 'Priority', 'sportspress' ); ?>,<?php _e( 'Compound', 'sportspress' ); ?>,<?php _e( 'Shipping', 'sportspress' ); ?>,<?php _e( 'Tax Class', 'sportspress' ); ?>\n";
|
|
||||||
|
|
||||||
jQuery('#rates tr:visible').each(function() {
|
|
||||||
var row = '';
|
|
||||||
jQuery(this).find('td:not(.sort) input').each(function() {
|
|
||||||
|
|
||||||
if ( jQuery(this).is('.checkbox') ) {
|
|
||||||
|
|
||||||
if ( jQuery(this).is(':checked') ) {
|
|
||||||
val = 1;
|
|
||||||
} else {
|
|
||||||
val = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
var val = jQuery(this).val();
|
|
||||||
|
|
||||||
if ( ! val )
|
|
||||||
val = jQuery(this).attr('placeholder');
|
|
||||||
}
|
|
||||||
|
|
||||||
row = row + val + ',';
|
|
||||||
});
|
|
||||||
row = row + '<?php echo $current_class; ?>';
|
|
||||||
//row.substring( 0, row.length - 1 );
|
|
||||||
csv_data = csv_data + row + "\n";
|
|
||||||
});
|
|
||||||
|
|
||||||
jQuery(this).attr( 'href', encodeURI( csv_data ) );
|
|
||||||
|
|
||||||
return true;
|
|
||||||
});
|
|
||||||
|
|
||||||
jQuery('.sp_tax_rates .insert').click(function() {
|
|
||||||
var $tbody = jQuery('.sp_tax_rates').find('tbody');
|
|
||||||
var size = $tbody.find('tr').size();
|
|
||||||
var code = '<tr class="new">\
|
|
||||||
<td class="sort"> </td>\
|
|
||||||
<td class="country" width="8%">\
|
|
||||||
<input type="text" placeholder="*" name="tax_rate_country[new][' + size + ']" />\
|
|
||||||
</td>\
|
|
||||||
<td class="state" width="8%">\
|
|
||||||
<input type="text" placeholder="*" name="tax_rate_state[new][' + size + ']" />\
|
|
||||||
</td>\
|
|
||||||
<td class="postcode">\
|
|
||||||
<input type="text" placeholder="*" name="tax_rate_postcode[new][' + size + ']" />\
|
|
||||||
</td>\
|
|
||||||
<td class="city">\
|
|
||||||
<input type="text" placeholder="*" name="tax_rate_city[new][' + size + ']" />\
|
|
||||||
</td>\
|
|
||||||
<td class="rate" width="8%">\
|
|
||||||
<input type="number" step="any" min="0" placeholder="0" name="tax_rate[new][' + size + ']" />\
|
|
||||||
</td>\
|
|
||||||
<td class="name" width="8%">\
|
|
||||||
<input type="text" name="tax_rate_name[new][' + size + ']" />\
|
|
||||||
</td>\
|
|
||||||
<td class="priority" width="8%">\
|
|
||||||
<input type="number" step="1" min="1" value="1" name="tax_rate_priority[new][' + size + ']" />\
|
|
||||||
</td>\
|
|
||||||
<td class="compound" width="8%">\
|
|
||||||
<input type="checkbox" class="checkbox" name="tax_rate_compound[new][' + size + ']" />\
|
|
||||||
</td>\
|
|
||||||
<td class="apply_to_shipping" width="8%">\
|
|
||||||
<input type="checkbox" class="checkbox" name="tax_rate_shipping[new][' + size + ']" checked="checked" />\
|
|
||||||
</td>\
|
|
||||||
</tr>';
|
|
||||||
|
|
||||||
if ( $tbody.find('tr.current').size() > 0 ) {
|
|
||||||
$tbody.find('tr.current').after( code );
|
|
||||||
} else {
|
|
||||||
$tbody.append( code );
|
|
||||||
}
|
|
||||||
|
|
||||||
jQuery( "td.country input" ).autocomplete({
|
|
||||||
source: availableCountries,
|
|
||||||
minLength: 3
|
|
||||||
});
|
|
||||||
|
|
||||||
jQuery( "td.state input" ).autocomplete({
|
|
||||||
source: availableStates,
|
|
||||||
minLength: 3
|
|
||||||
});
|
|
||||||
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
|
|
||||||
jQuery('.sp_tax_rates td.postcode, .sp_tax_rates td.city').find('input').change(function() {
|
|
||||||
jQuery(this).attr( 'name', jQuery(this).attr( 'data-name' ) );
|
|
||||||
});
|
|
||||||
|
|
||||||
var availableCountries = [<?php
|
|
||||||
$countries = array();
|
|
||||||
foreach ( SP()->countries->get_allowed_countries() as $value => $label )
|
|
||||||
$countries[] = '{ label: "' . $label . '", value: "' . $value . '" }';
|
|
||||||
echo implode( ', ', $countries );
|
|
||||||
?>];
|
|
||||||
|
|
||||||
var availableStates = [<?php
|
|
||||||
$countries = array();
|
|
||||||
foreach ( SP()->countries->get_allowed_country_states() as $value => $label )
|
|
||||||
foreach ( $label as $code => $state )
|
|
||||||
$countries[] = '{ label: "' . $state . '", value: "' . $code . '" }';
|
|
||||||
echo implode( ', ', $countries );
|
|
||||||
?>];
|
|
||||||
|
|
||||||
jQuery( "td.country input" ).autocomplete({
|
|
||||||
source: availableCountries,
|
|
||||||
minLength: 3
|
|
||||||
});
|
|
||||||
|
|
||||||
jQuery( "td.state input" ).autocomplete({
|
|
||||||
source: availableStates,
|
|
||||||
minLength: 3
|
|
||||||
});
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Save tax rates
|
|
||||||
*/
|
|
||||||
public function save_tax_rates() {
|
|
||||||
global $wpdb, $current_section;
|
|
||||||
|
|
||||||
// Get class
|
|
||||||
$tax_classes = array_filter( array_map( 'trim', explode( "\n", get_option('sportspress_tax_classes' ) ) ) );
|
|
||||||
$current_class = '';
|
|
||||||
|
|
||||||
foreach( $tax_classes as $class )
|
|
||||||
if ( sanitize_title( $class ) == $current_section )
|
|
||||||
$current_class = $class;
|
|
||||||
|
|
||||||
// Get POST data
|
|
||||||
$tax_rate_country = isset( $_POST['tax_rate_country'] ) ? $_POST['tax_rate_country'] : array();
|
|
||||||
$tax_rate_state = isset( $_POST['tax_rate_state'] ) ? $_POST['tax_rate_state'] : array();
|
|
||||||
$tax_rate_postcode = isset( $_POST['tax_rate_postcode'] ) ? $_POST['tax_rate_postcode'] : array();
|
|
||||||
$tax_rate_city = isset( $_POST['tax_rate_city'] ) ? $_POST['tax_rate_city'] : array();
|
|
||||||
$tax_rate = isset( $_POST['tax_rate'] ) ? $_POST['tax_rate'] : array();
|
|
||||||
$tax_rate_name = isset( $_POST['tax_rate_name'] ) ? $_POST['tax_rate_name'] : array();
|
|
||||||
$tax_rate_priority = isset( $_POST['tax_rate_priority'] ) ? $_POST['tax_rate_priority'] : array();
|
|
||||||
$tax_rate_compound = isset( $_POST['tax_rate_compound'] ) ? $_POST['tax_rate_compound'] : array();
|
|
||||||
$tax_rate_shipping = isset( $_POST['tax_rate_shipping'] ) ? $_POST['tax_rate_shipping'] : array();
|
|
||||||
|
|
||||||
$i = 0;
|
|
||||||
|
|
||||||
// Loop posted fields
|
|
||||||
foreach ( $tax_rate_country as $key => $value ) {
|
|
||||||
|
|
||||||
// new keys are inserted...
|
|
||||||
if ( $key == 'new' ) {
|
|
||||||
|
|
||||||
foreach ( $value as $new_key => $new_value ) {
|
|
||||||
|
|
||||||
// Sanitize + format
|
|
||||||
$country = strtoupper( sanitize_text_field( $tax_rate_country[ $key ][ $new_key ] ) );
|
|
||||||
$state = strtoupper( sanitize_text_field( $tax_rate_state[ $key ][ $new_key ] ) );
|
|
||||||
$postcode = sanitize_text_field( $tax_rate_postcode[ $key ][ $new_key ] );
|
|
||||||
$city = sanitize_text_field( $tax_rate_city[ $key ][ $new_key ] );
|
|
||||||
$rate = number_format( sanitize_text_field( $tax_rate[ $key ][ $new_key ] ), 4, '.', '' );
|
|
||||||
$name = sanitize_text_field( $tax_rate_name[ $key ][ $new_key ] );
|
|
||||||
$priority = absint( sanitize_text_field( $tax_rate_priority[ $key ][ $new_key ] ) );
|
|
||||||
$compound = isset( $tax_rate_compound[ $key ][ $new_key ] ) ? 1 : 0;
|
|
||||||
$shipping = isset( $tax_rate_shipping[ $key ][ $new_key ] ) ? 1 : 0;
|
|
||||||
|
|
||||||
if ( ! $name )
|
|
||||||
$name = __( 'Tax', 'sportspress' );
|
|
||||||
|
|
||||||
if ( $country == '*' )
|
|
||||||
$country = '';
|
|
||||||
|
|
||||||
if ( $state == '*' )
|
|
||||||
$state = '';
|
|
||||||
|
|
||||||
$wpdb->insert(
|
|
||||||
$wpdb->prefix . "sportspress_tax_rates",
|
|
||||||
array(
|
|
||||||
'tax_rate_country' => $country,
|
|
||||||
'tax_rate_state' => $state,
|
|
||||||
'tax_rate' => $rate,
|
|
||||||
'tax_rate_name' => $name,
|
|
||||||
'tax_rate_priority' => $priority,
|
|
||||||
'tax_rate_compound' => $compound,
|
|
||||||
'tax_rate_shipping' => $shipping,
|
|
||||||
'tax_rate_order' => $i,
|
|
||||||
'tax_rate_class' => sanitize_title( $current_class )
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
$tax_rate_id = $wpdb->insert_id;
|
|
||||||
|
|
||||||
if ( ! empty( $postcode ) ) {
|
|
||||||
$postcodes = explode( ';', $postcode );
|
|
||||||
$postcodes = array_map( 'strtoupper', array_map( 'sanitize_text_field', $postcodes ) );
|
|
||||||
|
|
||||||
$postcode_query = array();
|
|
||||||
|
|
||||||
foreach( $postcodes as $postcode )
|
|
||||||
if ( strstr( $postcode, '-' ) ) {
|
|
||||||
$postcode_parts = explode( '-', $postcode );
|
|
||||||
|
|
||||||
if ( is_numeric( $postcode_parts[0] ) && is_numeric( $postcode_parts[1] ) && $postcode_parts[1] > $postcode_parts[0] ) {
|
|
||||||
for ( $i = $postcode_parts[0]; $i <= $postcode_parts[1]; $i ++ ) {
|
|
||||||
if ( ! $i )
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if ( strlen( $i ) < strlen( $postcode_parts[0] ) )
|
|
||||||
$i = str_pad( $i, strlen( $postcode_parts[0] ), "0", STR_PAD_LEFT );
|
|
||||||
|
|
||||||
$postcode_query[] = "( '" . esc_sql( $i ) . "', $tax_rate_id, 'postcode' )";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if ( $postcode )
|
|
||||||
$postcode_query[] = "( '" . esc_sql( $postcode ) . "', $tax_rate_id, 'postcode' )";
|
|
||||||
}
|
|
||||||
|
|
||||||
$wpdb->query( "INSERT INTO {$wpdb->prefix}sportspress_tax_rate_locations ( location_code, tax_rate_id, location_type ) VALUES " . implode( ',', $postcode_query ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( ! empty( $city ) ) {
|
|
||||||
$cities = explode( ';', $city );
|
|
||||||
$cities = array_map( 'strtoupper', array_map( 'sanitize_text_field', $cities ) );
|
|
||||||
foreach( $cities as $city ) {
|
|
||||||
$wpdb->insert(
|
|
||||||
$wpdb->prefix . "sportspress_tax_rate_locations",
|
|
||||||
array(
|
|
||||||
'location_code' => $city,
|
|
||||||
'tax_rate_id' => $tax_rate_id,
|
|
||||||
'location_type' => 'city',
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$i++;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ...whereas the others are updated
|
|
||||||
} else {
|
|
||||||
|
|
||||||
$tax_rate_id = absint( $key );
|
|
||||||
|
|
||||||
if ( $_POST['remove_tax_rate'][ $key ] == 1 ) {
|
|
||||||
$wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}sportspress_tax_rate_locations WHERE tax_rate_id = %d;", $tax_rate_id ) );
|
|
||||||
$wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}sportspress_tax_rates WHERE tax_rate_id = %d;", $tax_rate_id ) );
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Sanitize + format
|
|
||||||
$country = strtoupper( sanitize_text_field( $tax_rate_country[ $key ] ) );
|
|
||||||
$state = strtoupper( sanitize_text_field( $tax_rate_state[ $key ] ) );
|
|
||||||
$rate = number_format( (double) sanitize_text_field( $tax_rate[ $key ] ), 4, '.', '' );
|
|
||||||
$name = sanitize_text_field( $tax_rate_name[ $key ] );
|
|
||||||
$priority = absint( sanitize_text_field( $tax_rate_priority[ $key ] ) );
|
|
||||||
$compound = isset( $tax_rate_compound[ $key ] ) ? 1 : 0;
|
|
||||||
$shipping = isset( $tax_rate_shipping[ $key ] ) ? 1 : 0;
|
|
||||||
|
|
||||||
if ( ! $name )
|
|
||||||
$name = __( 'Tax', 'sportspress' );
|
|
||||||
|
|
||||||
if ( $country == '*' )
|
|
||||||
$country = '';
|
|
||||||
|
|
||||||
if ( $state == '*' )
|
|
||||||
$state = '';
|
|
||||||
|
|
||||||
$wpdb->update(
|
|
||||||
$wpdb->prefix . "sportspress_tax_rates",
|
|
||||||
array(
|
|
||||||
'tax_rate_country' => $country,
|
|
||||||
'tax_rate_state' => $state,
|
|
||||||
'tax_rate' => $rate,
|
|
||||||
'tax_rate_name' => $name,
|
|
||||||
'tax_rate_priority' => $priority,
|
|
||||||
'tax_rate_compound' => $compound,
|
|
||||||
'tax_rate_shipping' => $shipping,
|
|
||||||
'tax_rate_order' => $i,
|
|
||||||
'tax_rate_class' => sanitize_title( $current_class )
|
|
||||||
),
|
|
||||||
array(
|
|
||||||
'tax_rate_id' => $tax_rate_id
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
if ( isset( $tax_rate_postcode[ $key ] ) ) {
|
|
||||||
// Delete old
|
|
||||||
$wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}sportspress_tax_rate_locations WHERE tax_rate_id = %d AND location_type = 'postcode';", $tax_rate_id ) );
|
|
||||||
|
|
||||||
// Add changed
|
|
||||||
$postcode = sanitize_text_field( $tax_rate_postcode[ $key ] );
|
|
||||||
$postcodes = explode( ';', $postcode );
|
|
||||||
$postcodes = array_map( 'strtoupper', array_map( 'sanitize_text_field', $postcodes ) );
|
|
||||||
|
|
||||||
$postcode_query = array();
|
|
||||||
|
|
||||||
foreach( $postcodes as $postcode )
|
|
||||||
if ( strstr( $postcode, '-' ) ) {
|
|
||||||
$postcode_parts = explode( '-', $postcode );
|
|
||||||
|
|
||||||
if ( is_numeric( $postcode_parts[0] ) && is_numeric( $postcode_parts[1] ) && $postcode_parts[1] > $postcode_parts[0] ) {
|
|
||||||
for ( $i = $postcode_parts[0]; $i <= $postcode_parts[1]; $i ++ ) {
|
|
||||||
if ( ! $i )
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if ( strlen( $i ) < strlen( $postcode_parts[0] ) )
|
|
||||||
$i = str_pad( $i, strlen( $postcode_parts[0] ), "0", STR_PAD_LEFT );
|
|
||||||
|
|
||||||
$postcode_query[] = "( '" . esc_sql( $i ) . "', $tax_rate_id, 'postcode' )";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if ( $postcode )
|
|
||||||
$postcode_query[] = "( '" . esc_sql( $postcode ) . "', $tax_rate_id, 'postcode' )";
|
|
||||||
}
|
|
||||||
|
|
||||||
$wpdb->query( "INSERT INTO {$wpdb->prefix}sportspress_tax_rate_locations ( location_code, tax_rate_id, location_type ) VALUES " . implode( ',', $postcode_query ) );
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( isset( $tax_rate_city[ $key ] ) ) {
|
|
||||||
// Delete old
|
|
||||||
$wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}sportspress_tax_rate_locations WHERE tax_rate_id = %d AND location_type = 'city';", $tax_rate_id ) );
|
|
||||||
|
|
||||||
// Add changed
|
|
||||||
$city = sanitize_text_field( $tax_rate_city[ $key ] );
|
|
||||||
$cities = explode( ';', $city );
|
|
||||||
$cities = array_map( 'strtoupper', array_map( 'sanitize_text_field', $cities ) );
|
|
||||||
foreach( $cities as $city ) {
|
|
||||||
if ( $city ) {
|
|
||||||
$wpdb->insert(
|
|
||||||
$wpdb->prefix . "sportspress_tax_rate_locations",
|
|
||||||
array(
|
|
||||||
'location_code' => $city,
|
|
||||||
'tax_rate_id' => $tax_rate_id,
|
|
||||||
'location_type' => 'city',
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$i++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
return new SP_Settings_Events();
|
return new SP_Settings_Events();
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ if ( ! class_exists( 'SP_Settings_General' ) ) :
|
|||||||
class SP_Settings_General extends SP_Settings_Page {
|
class SP_Settings_General extends SP_Settings_Page {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor
|
||||||
*/
|
*/
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
$this->id = 'general';
|
$this->id = 'general';
|
||||||
@@ -26,6 +26,8 @@ class SP_Settings_General extends SP_Settings_Page {
|
|||||||
|
|
||||||
add_filter( 'sportspress_settings_tabs_array', array( $this, 'add_settings_page' ), 20 );
|
add_filter( 'sportspress_settings_tabs_array', array( $this, 'add_settings_page' ), 20 );
|
||||||
add_action( 'sportspress_settings_' . $this->id, array( $this, 'output' ) );
|
add_action( 'sportspress_settings_' . $this->id, array( $this, 'output' ) );
|
||||||
|
add_action( 'sportspress_admin_field_country', array( $this, 'country_setting' ) );
|
||||||
|
add_action( 'sportspress_admin_field_frontend_styles', array( $this, 'frontend_styles_setting' ) );
|
||||||
add_action( 'sportspress_settings_save_' . $this->id, array( $this, 'save' ) );
|
add_action( 'sportspress_settings_save_' . $this->id, array( $this, 'save' ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -35,32 +37,186 @@ class SP_Settings_General extends SP_Settings_Page {
|
|||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function get_settings() {
|
public function get_settings() {
|
||||||
return apply_filters( 'sportspress_general_settings', array(
|
|
||||||
|
$settings = array(
|
||||||
|
|
||||||
array( 'title' => __( 'General Options', 'sportspress' ), 'type' => 'title', 'desc' => '', 'id' => 'general_options' ),
|
array( 'title' => __( 'General Options', 'sportspress' ), 'type' => 'title', 'desc' => '', 'id' => 'general_options' ),
|
||||||
|
|
||||||
array(
|
array( 'type' => 'country' ),
|
||||||
'title' => __( 'Tables', 'sportspress' ),
|
|
||||||
'desc' => __( 'Responsive', 'sportspress' ),
|
|
||||||
'id' => 'sportspress_tables_responsive',
|
|
||||||
'default' => 'yes',
|
|
||||||
'type' => 'checkbox',
|
|
||||||
'checkboxgroup' => 'start',
|
|
||||||
'autoload' => false
|
|
||||||
),
|
|
||||||
|
|
||||||
array(
|
|
||||||
'desc' => __( 'Sortable', 'sportspress' ),
|
|
||||||
'id' => 'sportspress_tables_sortable',
|
|
||||||
'default' => 'yes',
|
|
||||||
'type' => 'checkbox',
|
|
||||||
'checkboxgroup' => 'end',
|
|
||||||
'show_if_checked' => 'option',
|
|
||||||
),
|
|
||||||
|
|
||||||
array( 'type' => 'sectionend', 'id' => 'general_options' ),
|
array( 'type' => 'sectionend', 'id' => 'general_options' ),
|
||||||
|
|
||||||
)); // End general settings
|
array( 'title' => __( 'Styles and Scripts', 'sportspress' ), 'type' => 'title', 'desc' => '', 'id' => 'script_styling_options' ),
|
||||||
|
|
||||||
|
array( 'type' => 'frontend_styles' ),
|
||||||
|
|
||||||
|
array(
|
||||||
|
'title' => __( 'Custom CSS', 'woocommerce' ),
|
||||||
|
'id' => 'sportspress_custom_css',
|
||||||
|
'css' => 'width:100%; height: 130px;',
|
||||||
|
'type' => 'textarea',
|
||||||
|
),
|
||||||
|
|
||||||
|
array(
|
||||||
|
'title' => __( 'Scripts', 'sportspress' ),
|
||||||
|
'desc' => __( 'Responsive tables', 'sportspress' ),
|
||||||
|
'id' => 'sportspress_enable_responsive_tables',
|
||||||
|
'default' => 'yes',
|
||||||
|
'type' => 'checkbox',
|
||||||
|
'checkboxgroup' => 'start',
|
||||||
|
'desc_tip' => __( 'This will enable a script allowing the tables to be responsive.', 'sportspress' ),
|
||||||
|
),
|
||||||
|
|
||||||
|
array(
|
||||||
|
'desc' => __( 'Sortable tables', 'sportspress' ),
|
||||||
|
'id' => 'sportspress_enable_sortable_tables',
|
||||||
|
'default' => 'yes',
|
||||||
|
'type' => 'checkbox',
|
||||||
|
'checkboxgroup' => '',
|
||||||
|
'desc_tip' => __( 'This will enable a script allowing the tables to be sortable.', 'sportspress' ),
|
||||||
|
),
|
||||||
|
|
||||||
|
array(
|
||||||
|
'desc' => __( 'Live countdowns', 'sportspress' ),
|
||||||
|
'id' => 'sportspress_enable_live_countdowns',
|
||||||
|
'default' => 'yes',
|
||||||
|
'type' => 'checkbox',
|
||||||
|
'checkboxgroup' => 'end',
|
||||||
|
'desc_tip' => __( 'This will enable a script allowing the countdowns to be animated.', 'sportspress' ),
|
||||||
|
),
|
||||||
|
|
||||||
|
array( 'type' => 'sectionend', 'id' => 'script_styling_options' ),
|
||||||
|
|
||||||
|
array( 'title' => __( 'Text', 'sportspress' ), 'type' => 'title', 'desc' => __( 'The following options affect how words are displayed on the frontend.', 'sportspress' ), 'id' => 'text_options' ),
|
||||||
|
|
||||||
|
);
|
||||||
|
|
||||||
|
foreach ( SP()->text->general as $key => $value ):
|
||||||
|
$settings[] = array(
|
||||||
|
'title' => $value,
|
||||||
|
'id' => 'sportspress_' . $key . '_text',
|
||||||
|
'default' => '',
|
||||||
|
'placeholder' => $value,
|
||||||
|
'type' => 'text',
|
||||||
|
);
|
||||||
|
endforeach;
|
||||||
|
|
||||||
|
$settings[] = array( 'type' => 'sectionend', 'id' => 'text_options' );
|
||||||
|
|
||||||
|
return apply_filters( 'sportspress_general_settings', $settings ); // End general settings
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Save settings
|
||||||
|
*/
|
||||||
|
public function save() {
|
||||||
|
$settings = $this->get_settings();
|
||||||
|
SP_Admin_Settings::save_fields( $settings );
|
||||||
|
|
||||||
|
if ( isset( $_POST['sportspress_default_country'] ) )
|
||||||
|
update_option( 'sportspress_default_country', $_POST['sportspress_default_country'] );
|
||||||
|
|
||||||
|
update_option( 'sportspress_enable_frontend_css', isset( $_POST['sportspress_enable_frontend_css'] ) ? 'yes' : 'no' );
|
||||||
|
|
||||||
|
if ( isset( $_POST['sportspress_frontend_css_primary'] ) ) {
|
||||||
|
|
||||||
|
// Save settings
|
||||||
|
$primary = ( ! empty( $_POST['sportspress_frontend_css_primary'] ) ) ? sp_format_hex( $_POST['sportspress_frontend_css_primary'] ) : '';
|
||||||
|
$heading = ( ! empty( $_POST['sportspress_frontend_css_heading'] ) ) ? sp_format_hex( $_POST['sportspress_frontend_css_heading'] ) : '';
|
||||||
|
$text = ( ! empty( $_POST['sportspress_frontend_css_text'] ) ) ? sp_format_hex( $_POST['sportspress_frontend_css_text'] ) : '';
|
||||||
|
$background = ( ! empty( $_POST['sportspress_frontend_css_background'] ) ) ? sp_format_hex( $_POST['sportspress_frontend_css_background'] ) : '';
|
||||||
|
$alternate = ( ! empty( $_POST['sportspress_frontend_css_alternate'] ) ) ? sp_format_hex( $_POST['sportspress_frontend_css_alternate'] ) : '';
|
||||||
|
|
||||||
|
$colors = array(
|
||||||
|
'primary' => $primary,
|
||||||
|
'heading' => $heading,
|
||||||
|
'text' => $text,
|
||||||
|
'background' => $background,
|
||||||
|
'alternate' => $alternate
|
||||||
|
);
|
||||||
|
|
||||||
|
update_option( 'sportspress_frontend_css_colors', $colors );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Country settings
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function country_setting() {
|
||||||
|
$selected = (string) get_option( 'sportspress_default_country', 'AU' );
|
||||||
|
$continents = SP()->countries->continents;
|
||||||
|
?>
|
||||||
|
<tr valign="top">
|
||||||
|
<th scope="row" class="titledesc">
|
||||||
|
<label for="sportspress_default_country"><?php _e( 'Base Location', 'sportspress' ); ?></label>
|
||||||
|
</th>
|
||||||
|
<td class="forminp">
|
||||||
|
<legend class="screen-reader-text"><span><?php _e( 'Delimiter', 'sportspress' ); ?></span></legend>
|
||||||
|
<select name="sportspress_default_country" data-placeholder="<?php _e( 'Choose a country…', 'sportspress' ); ?>" title="Country" class="chosen-select<?php if ( is_rtl() ): ?> chosen-rtl<?php endif; ?>">
|
||||||
|
<?php SP()->countries->country_dropdown_options( $selected ); ?>
|
||||||
|
</select>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Output the frontend styles settings.
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function frontend_styles_setting() {
|
||||||
|
?><tr valign="top" class="sportspress_frontend_css_colors">
|
||||||
|
<th scope="row" class="titledesc">
|
||||||
|
<?php _e( 'Frontend Styles', 'sportspress' ); ?>
|
||||||
|
</th>
|
||||||
|
<td class="forminp"><?php
|
||||||
|
|
||||||
|
// Get settings
|
||||||
|
$colors = array_map( 'esc_attr', (array) get_option( 'sportspress_frontend_css_colors' ) );
|
||||||
|
|
||||||
|
// Defaults
|
||||||
|
if ( empty( $colors['primary'] ) ) $colors['primary'] = '#00a69c';
|
||||||
|
if ( empty( $colors['heading'] ) ) $colors['heading'] = '#ffffff';
|
||||||
|
if ( empty( $colors['text'] ) ) $colors['text'] = '#ffffff';
|
||||||
|
if ( empty( $colors['background'] ) ) $colors['background'] = '#3a3a3a';
|
||||||
|
if ( empty( $colors['alternate'] ) ) $colors['alternate'] = '#494949';
|
||||||
|
if ( empty( $colors['alternatea'] ) ) $colors['alternatea'] = '#494949';
|
||||||
|
|
||||||
|
// Show inputs
|
||||||
|
$this->color_picker( __( 'Primary', 'sportspress' ), 'sportspress_frontend_css_primary', $colors['primary'] );
|
||||||
|
$this->color_picker( __( 'Heading', 'sportspress' ), 'sportspress_frontend_css_heading', $colors['heading'] );
|
||||||
|
$this->color_picker( __( 'Text', 'sportspress' ), 'sportspress_frontend_css_text', $colors['text'] );
|
||||||
|
$this->color_picker( __( 'Background', 'sportspress' ), 'sportspress_frontend_css_background', $colors['background'] );
|
||||||
|
$this->color_picker( __( 'Alternate', 'sportspress' ), 'sportspress_frontend_css_alternate', $colors['alternate'] );
|
||||||
|
|
||||||
|
?><br>
|
||||||
|
<label for="sportspress_enable_frontend_css">
|
||||||
|
<input name="sportspress_enable_frontend_css" id="sportspress_enable_frontend_css" type="checkbox" value="1" <?php checked( get_option( 'sportspress_enable_frontend_css', 'yes' ), 'yes' ); ?>>
|
||||||
|
<?php _e( 'Enable', 'sportspress' ); ?>
|
||||||
|
</label>
|
||||||
|
</td>
|
||||||
|
</tr><?php
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Output a colour picker input box.
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @param mixed $name
|
||||||
|
* @param mixed $id
|
||||||
|
* @param mixed $value
|
||||||
|
* @param string $desc (default: '')
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
function color_picker( $name, $id, $value, $desc = '' ) {
|
||||||
|
echo '<div class="sp-color-box"><strong>' . esc_html( $name ) . '</strong>
|
||||||
|
<input name="' . esc_attr( $id ). '" id="' . esc_attr( $id ) . '" type="text" value="' . esc_attr( $value ) . '" class="colorpick" /> <div id="colorPickerDiv_' . esc_attr( $id ) . '" class="colorpickdiv"></div>
|
||||||
|
</div>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,74 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* SportsPress Integration Settings
|
|
||||||
*
|
|
||||||
* @author ThemeBoy
|
|
||||||
* @category Admin
|
|
||||||
* @package SportsPress/Admin
|
|
||||||
* @version 0.7
|
|
||||||
*/
|
|
||||||
|
|
||||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
|
||||||
|
|
||||||
if ( ! class_exists( 'SP_Settings_Integrations' ) ) :
|
|
||||||
|
|
||||||
/**
|
|
||||||
* SP_Settings_Integrations
|
|
||||||
*/
|
|
||||||
class SP_Settings_Integrations extends SP_Settings_Page {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor.
|
|
||||||
*/
|
|
||||||
public function __construct() {
|
|
||||||
$this->id = 'integration';
|
|
||||||
$this->label = __( 'Integration', 'sportspress' );
|
|
||||||
|
|
||||||
if ( isset( SP()->integrations ) && SP()->integrations->get_integrations() ) {
|
|
||||||
add_filter( 'sportspress_settings_tabs_array', array( $this, 'add_settings_page' ), 20 );
|
|
||||||
add_action( 'sportspress_sections_' . $this->id, array( $this, 'output_sections' ) );
|
|
||||||
add_action( 'sportspress_settings_' . $this->id, array( $this, 'output' ) );
|
|
||||||
add_action( 'sportspress_settings_save_' . $this->id, array( $this, 'save' ) );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get sections
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function get_sections() {
|
|
||||||
global $current_section;
|
|
||||||
|
|
||||||
$sections = array();
|
|
||||||
|
|
||||||
$integrations = SP()->integrations->get_integrations();
|
|
||||||
|
|
||||||
if ( ! $current_section )
|
|
||||||
$current_section = current( $integrations )->id;
|
|
||||||
|
|
||||||
foreach ( $integrations as $integration ) {
|
|
||||||
$title = empty( $integration->method_title ) ? ucfirst( $integration->id ) : $integration->method_title;
|
|
||||||
|
|
||||||
$sections[ strtolower( $integration->id ) ] = esc_html( $title );
|
|
||||||
}
|
|
||||||
|
|
||||||
return $sections;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Output the settings
|
|
||||||
*/
|
|
||||||
public function output() {
|
|
||||||
global $current_section;
|
|
||||||
|
|
||||||
$integrations = SP()->integrations->get_integrations();
|
|
||||||
|
|
||||||
if ( isset( $integrations[ $current_section ] ) )
|
|
||||||
$integrations[ $current_section ]->admin_options();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
endif;
|
|
||||||
|
|
||||||
return new SP_Settings_Integrations();
|
|
||||||
@@ -38,36 +38,6 @@ class SP_Settings_Page {
|
|||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get sections
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function get_sections() {
|
|
||||||
return array();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Output sections
|
|
||||||
*/
|
|
||||||
public function output_sections() {
|
|
||||||
global $current_section;
|
|
||||||
|
|
||||||
$sections = $this->get_sections();
|
|
||||||
|
|
||||||
if ( empty( $sections ) )
|
|
||||||
return;
|
|
||||||
|
|
||||||
echo '<ul class="subsubsub">';
|
|
||||||
|
|
||||||
$array_keys = array_keys( $sections );
|
|
||||||
|
|
||||||
foreach ( $sections as $id => $label )
|
|
||||||
echo '<li><a href="' . admin_url( 'admin.php?page=wc-settings&tab=' . $this->id . '§ion=' . sanitize_title( $id ) ) . '" class="' . ( $current_section == $id ? 'current' : '' ) . '">' . $label . '</a> ' . ( end( $array_keys ) == $id ? '' : '|' ) . ' </li>';
|
|
||||||
|
|
||||||
echo '</ul><br class="clear" />';
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Output the settings
|
* Output the settings
|
||||||
*/
|
*/
|
||||||
@@ -91,4 +61,4 @@ class SP_Settings_Page {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
endif;
|
endif;
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ if ( ! class_exists( 'SP_Settings_Players' ) ) :
|
|||||||
class SP_Settings_Players extends SP_Settings_Page {
|
class SP_Settings_Players extends SP_Settings_Page {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor
|
||||||
*/
|
*/
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
$this->id = 'players';
|
$this->id = 'players';
|
||||||
@@ -35,749 +35,49 @@ class SP_Settings_Players extends SP_Settings_Page {
|
|||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function get_settings() {
|
public function get_settings() {
|
||||||
$tax_classes = array_filter( array_map( 'trim', explode( "\n", get_option( 'sportspress_tax_classes' ) ) ) );
|
|
||||||
$classes_options = array();
|
|
||||||
if ( $tax_classes )
|
|
||||||
foreach ( $tax_classes as $class )
|
|
||||||
$classes_options[ sanitize_title( $class ) ] = esc_html( $class );
|
|
||||||
|
|
||||||
return apply_filters('sportspress_event_settings', array(
|
$settings = array(
|
||||||
|
|
||||||
array( 'title' => __( 'Player Options', 'sportspress' ), 'type' => 'title','desc' => '', 'id' => 'tax_options' ),
|
array( 'title' => __( 'Player Options', 'sportspress' ), 'type' => 'title','desc' => '', 'id' => 'player_options' ),
|
||||||
|
|
||||||
array(
|
array(
|
||||||
'title' => __( 'Enable Players', 'sportspress' ),
|
'title' => __( 'Nationality', 'sportspress' ),
|
||||||
'desc' => __( 'Enable taxes and tax calculations', 'sportspress' ),
|
'desc' => __( 'Display national flag', 'sportspress' ),
|
||||||
'id' => 'sportspress_calc_taxes',
|
'id' => 'sportspress_player_show_flag',
|
||||||
'default' => 'no',
|
'default' => 'yes',
|
||||||
'type' => 'checkbox'
|
|
||||||
),
|
|
||||||
|
|
||||||
array(
|
|
||||||
'title' => __( 'Prices Entered With Tax', 'sportspress' ),
|
|
||||||
'id' => 'sportspress_prices_include_tax',
|
|
||||||
'default' => 'no',
|
|
||||||
'type' => 'radio',
|
|
||||||
'options' => array(
|
|
||||||
'vs' => sprintf( '%s vs %s', __( 'Player', 'sportspress' ), __( 'Player', 'sportspress' ) ),
|
|
||||||
'v' => sprintf( '%s v %s', __( 'Player', 'sportspress' ), __( 'Player', 'sportspress' ) ),
|
|
||||||
'—' => sprintf( '%s — %s', __( 'Player', 'sportspress' ), __( 'Player', 'sportspress' ) ),
|
|
||||||
'/' => sprintf( '%s / %s', __( 'Player', 'sportspress' ), __( 'Player', 'sportspress' ) )
|
|
||||||
),
|
|
||||||
),
|
|
||||||
|
|
||||||
array(
|
|
||||||
'title' => __( 'Calculate Tax Based On:', 'sportspress' ),
|
|
||||||
'id' => 'sportspress_tax_based_on',
|
|
||||||
'desc_tip' => __( 'This option determines which address is used to calculate tax.', 'sportspress' ),
|
|
||||||
'default' => 'shipping',
|
|
||||||
'type' => 'select',
|
|
||||||
'options' => array(
|
|
||||||
'shipping' => __( 'Customer shipping address', 'sportspress' ),
|
|
||||||
'billing' => __( 'Customer billing address', 'sportspress' ),
|
|
||||||
'base' => __( 'Shop base address', 'sportspress' )
|
|
||||||
),
|
|
||||||
),
|
|
||||||
|
|
||||||
array(
|
|
||||||
'title' => __( 'Default Customer Address:', 'sportspress' ),
|
|
||||||
'id' => 'sportspress_default_customer_address',
|
|
||||||
'desc_tip' => __( 'This option determines the customers default address (before they input their own).', 'sportspress' ),
|
|
||||||
'default' => 'base',
|
|
||||||
'type' => 'select',
|
|
||||||
'options' => array(
|
|
||||||
'' => __( 'No address', 'sportspress' ),
|
|
||||||
'base' => __( 'Shop base address', 'sportspress' ),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
|
|
||||||
array(
|
|
||||||
'title' => __( 'Shipping Tax Class:', 'sportspress' ),
|
|
||||||
'desc' => __( 'Optionally control which tax class shipping gets, or leave it so shipping tax is based on the cart items themselves.', 'sportspress' ),
|
|
||||||
'id' => 'sportspress_shipping_tax_class',
|
|
||||||
'css' => 'min-width:150px;',
|
|
||||||
'default' => 'title',
|
|
||||||
'type' => 'select',
|
|
||||||
'options' => array( '' => __( 'Shipping tax class based on cart items', 'sportspress' ), 'standard' => __( 'Standard', 'sportspress' ) ) + $classes_options,
|
|
||||||
'desc_tip' => true,
|
|
||||||
),
|
|
||||||
|
|
||||||
array(
|
|
||||||
'title' => __( 'Rounding', 'sportspress' ),
|
|
||||||
'desc' => __( 'Round tax at subtotal level, instead of rounding per line', 'sportspress' ),
|
|
||||||
'id' => 'sportspress_tax_round_at_subtotal',
|
|
||||||
'default' => 'no',
|
|
||||||
'type' => 'checkbox',
|
'type' => 'checkbox',
|
||||||
),
|
),
|
||||||
|
|
||||||
array(
|
array(
|
||||||
'title' => __( 'Additional Tax Classes', 'sportspress' ),
|
'title' => __( 'Player Lists', 'sportspress' ),
|
||||||
'desc' => __( 'List additonal tax classes below (1 per line). This is in addition to the default <code>Standard Rate</code>. Tax classes can be assigned to products.', 'sportspress' ),
|
'desc' => __( 'Link players', 'sportspress' ),
|
||||||
'id' => 'sportspress_tax_classes',
|
'id' => 'sportspress_list_link_players',
|
||||||
'css' => 'width:100%; height: 65px;',
|
'default' => 'yes',
|
||||||
'type' => 'textarea',
|
'type' => 'checkbox',
|
||||||
'default' => sprintf( __( 'Reduced Rate%sZero Rate', 'sportspress' ), PHP_EOL )
|
|
||||||
),
|
),
|
||||||
|
|
||||||
array(
|
array( 'type' => 'sectionend', 'id' => 'player_options' ),
|
||||||
'title' => __( 'Display prices in the shop:', 'sportspress' ),
|
|
||||||
'id' => 'sportspress_tax_display_shop',
|
|
||||||
'default' => 'excl',
|
|
||||||
'type' => 'select',
|
|
||||||
'options' => array(
|
|
||||||
'incl' => __( 'Including tax', 'sportspress' ),
|
|
||||||
'excl' => __( 'Excluding tax', 'sportspress' ),
|
|
||||||
)
|
|
||||||
),
|
|
||||||
|
|
||||||
array(
|
array( 'title' => __( 'Text', 'sportspress' ), 'type' => 'title', 'desc' => __( 'The following options affect how words are displayed on the frontend.', 'sportspress' ), 'id' => 'text_options' ),
|
||||||
'title' => __( 'Price display suffix:', 'sportspress' ),
|
|
||||||
'id' => 'sportspress_price_display_suffix',
|
|
||||||
'default' => '',
|
|
||||||
'type' => 'text',
|
|
||||||
'desc' => __( 'Define text to show after your product prices. This could be, for example, "inc. Vat" to explain your pricing. You can also have prices substituted here using one of the following: <code>{price_including_tax}, {price_excluding_tax}</code>.', 'sportspress' ),
|
|
||||||
),
|
|
||||||
|
|
||||||
array(
|
|
||||||
'title' => __( 'Display prices during cart/checkout:', 'sportspress' ),
|
|
||||||
'id' => 'sportspress_tax_display_cart',
|
|
||||||
'default' => 'excl',
|
|
||||||
'type' => 'select',
|
|
||||||
'options' => array(
|
|
||||||
'incl' => __( 'Including tax', 'sportspress' ),
|
|
||||||
'excl' => __( 'Excluding tax', 'sportspress' ),
|
|
||||||
),
|
|
||||||
'autoload' => false
|
|
||||||
),
|
|
||||||
|
|
||||||
array(
|
|
||||||
'title' => __( 'Display tax totals:', 'sportspress' ),
|
|
||||||
'id' => 'sportspress_tax_total_display',
|
|
||||||
'default' => 'itemized',
|
|
||||||
'type' => 'select',
|
|
||||||
'options' => array(
|
|
||||||
'single' => __( 'As a single total', 'sportspress' ),
|
|
||||||
'itemized' => __( 'Itemized', 'sportspress' ),
|
|
||||||
),
|
|
||||||
'autoload' => false
|
|
||||||
),
|
|
||||||
|
|
||||||
array( 'type' => 'results' ),
|
|
||||||
|
|
||||||
array( 'type' => 'sectionend', 'id' => 'event_options' ),
|
|
||||||
|
|
||||||
)); // End event settings
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Output the settings
|
|
||||||
*/
|
|
||||||
public function output() {
|
|
||||||
global $current_section;
|
|
||||||
|
|
||||||
$tax_classes = array_filter( array_map( 'trim', explode( "\n", get_option('sportspress_tax_classes' ) ) ) );
|
|
||||||
|
|
||||||
if ( $current_section == 'standard' || in_array( $current_section, array_map( 'sanitize_title', $tax_classes ) ) ) {
|
|
||||||
$this->output_tax_rates();
|
|
||||||
} else {
|
|
||||||
$settings = $this->get_settings();
|
|
||||||
|
|
||||||
SP_Admin_Settings::output_fields( $settings );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Save settings
|
|
||||||
*/
|
|
||||||
public function save() {
|
|
||||||
global $current_section, $wpdb;
|
|
||||||
|
|
||||||
if ( ! $current_section ) {
|
|
||||||
|
|
||||||
$settings = $this->get_settings();
|
|
||||||
SP_Admin_Settings::save_fields( $settings );
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
$this->save_tax_rates();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
$wpdb->query( "DELETE FROM `$wpdb->options` WHERE `option_name` LIKE ('_transient_sp_tax_rates_%') OR `option_name` LIKE ('_transient_timeout_sp_tax_rates_%')" );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Output tax rate tables
|
|
||||||
*/
|
|
||||||
public function output_tax_rates() {
|
|
||||||
global $sportspress, $current_section, $wpdb;
|
|
||||||
|
|
||||||
$page = ! empty( $_GET['p'] ) ? absint( $_GET['p'] ) : 1;
|
|
||||||
$limit = 100;
|
|
||||||
$tax_classes = array_filter( array_map( 'trim', explode( "\n", get_option('sportspress_tax_classes' ) ) ) );
|
|
||||||
$current_class = '';
|
|
||||||
|
|
||||||
foreach( $tax_classes as $class )
|
|
||||||
if ( sanitize_title( $class ) == $current_section )
|
|
||||||
$current_class = $class;
|
|
||||||
?>
|
|
||||||
<h3><?php printf( __( 'Tax Rates for the "%s" Class', 'sportspress' ), $current_class ? esc_html( $current_class ) : __( 'Standard', 'sportspress' ) ); ?></h3>
|
|
||||||
<p><?php printf( __( 'Define tax rates for countries and states below. <a href="%s">See here</a> for available alpha-2 country codes.', 'sportspress' ), 'http://en.wikipedia.org/wiki/ISO_3166-1#Current_codes' ); ?></p>
|
|
||||||
<table class="sp_tax_rates sp_input_table sortable widefat">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th class="sort"> </th>
|
|
||||||
|
|
||||||
<th width="8%"><?php _e( 'Country Code', 'sportspress' ); ?> <span class="tips" data-tip="<?php _e('A 2 digit country code, e.g. US. Leave blank to apply to all.', 'sportspress'); ?>">[?]</span></th>
|
|
||||||
|
|
||||||
<th width="8%"><?php _e( 'State Code', 'sportspress' ); ?> <span class="tips" data-tip="<?php _e('A 2 digit state code, e.g. AL. Leave blank to apply to all.', 'sportspress'); ?>">[?]</span></th>
|
|
||||||
|
|
||||||
<th><?php _e( 'ZIP/Postcode', 'sportspress' ); ?> <span class="tips" data-tip="<?php _e('Postcode for this rule. Semi-colon (;) separate multiple values. Leave blank to apply to all areas. Wildcards (*) can be used. Ranges for numeric postcodes (e.g. 12345-12350) will be expanded into individual postcodes.', 'sportspress'); ?>">[?]</span></th>
|
|
||||||
|
|
||||||
<th><?php _e( 'City', 'sportspress' ); ?> <span class="tips" data-tip="<?php _e('Cities for this rule. Semi-colon (;) separate multiple values. Leave blank to apply to all cities.', 'sportspress'); ?>">[?]</span></th>
|
|
||||||
|
|
||||||
<th width="8%"><?php _e( 'Rate %', 'sportspress' ); ?> <span class="tips" data-tip="<?php _e( 'Enter a tax rate (percentage) to 4 decimal places.', 'sportspress' ); ?>">[?]</span></th>
|
|
||||||
|
|
||||||
<th width="8%"><?php _e( 'Tax Name', 'sportspress' ); ?> <span class="tips" data-tip="<?php _e('Enter a name for this tax rate.', 'sportspress'); ?>">[?]</span></th>
|
|
||||||
|
|
||||||
<th width="8%"><?php _e( 'Priority', 'sportspress' ); ?> <span class="tips" data-tip="<?php _e('Choose a priority for this tax rate. Only 1 matching rate per priority will be used. To define multiple tax rates for a single area you need to specify a different priority per rate.', 'sportspress'); ?>">[?]</span></th>
|
|
||||||
|
|
||||||
<th width="8%"><?php _e( 'Compound', 'sportspress' ); ?> <span class="tips" data-tip="<?php _e('Choose whether or not this is a compound rate. Compound tax rates are applied on top of other tax rates.', 'sportspress'); ?>">[?]</span></th>
|
|
||||||
|
|
||||||
<th width="8%"><?php _e( 'Shipping', 'sportspress' ); ?> <span class="tips" data-tip="<?php _e('Choose whether or not this tax rate also gets applied to shipping.', 'sportspress'); ?>">[?]</span></th>
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tfoot>
|
|
||||||
<tr>
|
|
||||||
<th colspan="10">
|
|
||||||
<a href="#" class="button plus insert"><?php _e( 'Insert row', 'sportspress' ); ?></a>
|
|
||||||
<a href="#" class="button minus remove_tax_rates"><?php _e( 'Remove selected row(s)', 'sportspress' ); ?></a>
|
|
||||||
|
|
||||||
<div class="pagination">
|
|
||||||
<?php
|
|
||||||
echo str_replace( 'page-numbers', 'page-numbers button', paginate_links( array(
|
|
||||||
'base' => add_query_arg( 'p', '%#%' ),
|
|
||||||
'type' => 'plain',
|
|
||||||
'prev_text' => '«',
|
|
||||||
'next_text' => '»',
|
|
||||||
'total' => ceil( absint( $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(tax_rate_id) FROM {$wpdb->prefix}sportspress_tax_rates WHERE tax_rate_class = %s;", sanitize_title( $current_class ) ) ) ) / $limit ),
|
|
||||||
'current' => $page
|
|
||||||
) ) );
|
|
||||||
?>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<a href="#" download="tax_rates.csv" class="button export"><?php _e( 'Export CSV', 'sportspress' ); ?></a>
|
|
||||||
<a href="<?php echo admin_url( 'admin.php?import=sportspress_tax_rate_csv' ); ?>" class="button import"><?php _e( 'Import CSV', 'sportspress' ); ?></a>
|
|
||||||
</th>
|
|
||||||
</tr>
|
|
||||||
</tfoot>
|
|
||||||
<tbody id="rates">
|
|
||||||
<?php
|
|
||||||
$rates = $wpdb->get_results( $wpdb->prepare(
|
|
||||||
"SELECT * FROM {$wpdb->prefix}sportspress_tax_rates
|
|
||||||
WHERE tax_rate_class = %s
|
|
||||||
ORDER BY tax_rate_order
|
|
||||||
LIMIT %d, %d
|
|
||||||
" ,
|
|
||||||
sanitize_title( $current_class ),
|
|
||||||
( $page - 1 ) * $limit,
|
|
||||||
$limit
|
|
||||||
) );
|
|
||||||
|
|
||||||
foreach ( $rates as $rate ) {
|
|
||||||
?>
|
|
||||||
<tr>
|
|
||||||
<td class="sort"><input type="hidden" class="remove_tax_rate" name="remove_tax_rate[<?php echo $rate->tax_rate_id ?>]" value="0" /></td>
|
|
||||||
|
|
||||||
<td class="country" width="8%">
|
|
||||||
<input type="text" value="<?php echo esc_attr( $rate->tax_rate_country ) ?>" placeholder="*" name="tax_rate_country[<?php echo $rate->tax_rate_id ?>]" />
|
|
||||||
</td>
|
|
||||||
|
|
||||||
<td class="state" width="8%">
|
|
||||||
<input type="text" value="<?php echo esc_attr( $rate->tax_rate_state ) ?>" placeholder="*" name="tax_rate_state[<?php echo $rate->tax_rate_id ?>]" />
|
|
||||||
</td>
|
|
||||||
|
|
||||||
<td class="postcode">
|
|
||||||
<input type="text" value="<?php
|
|
||||||
$locations = $wpdb->get_col( $wpdb->prepare( "SELECT location_code FROM {$wpdb->prefix}sportspress_tax_rate_locations WHERE location_type='postcode' AND tax_rate_id = %d ORDER BY location_code", $rate->tax_rate_id ) );
|
|
||||||
|
|
||||||
echo esc_attr( implode( '; ', $locations ) );
|
|
||||||
?>" placeholder="*" data-name="tax_rate_postcode[<?php echo $rate->tax_rate_id ?>]" />
|
|
||||||
</td>
|
|
||||||
|
|
||||||
<td class="city">
|
|
||||||
<input type="text" value="<?php
|
|
||||||
$locations = $wpdb->get_col( $wpdb->prepare( "SELECT location_code FROM {$wpdb->prefix}sportspress_tax_rate_locations WHERE location_type='city' AND tax_rate_id = %d ORDER BY location_code", $rate->tax_rate_id ) );
|
|
||||||
echo esc_attr( implode( '; ', $locations ) );
|
|
||||||
?>" placeholder="*" data-name="tax_rate_city[<?php echo $rate->tax_rate_id ?>]" />
|
|
||||||
</td>
|
|
||||||
|
|
||||||
<td class="rate" width="8%">
|
|
||||||
<input type="number" step="any" min="0" value="<?php echo esc_attr( $rate->tax_rate ) ?>" placeholder="0" name="tax_rate[<?php echo $rate->tax_rate_id ?>]" />
|
|
||||||
</td>
|
|
||||||
|
|
||||||
<td class="name" width="8%">
|
|
||||||
<input type="text" value="<?php echo esc_attr( $rate->tax_rate_name ) ?>" name="tax_rate_name[<?php echo $rate->tax_rate_id ?>]" />
|
|
||||||
</td>
|
|
||||||
|
|
||||||
<td class="priority" width="8%">
|
|
||||||
<input type="number" step="1" min="1" value="<?php echo esc_attr( $rate->tax_rate_priority ) ?>" name="tax_rate_priority[<?php echo $rate->tax_rate_id ?>]" />
|
|
||||||
</td>
|
|
||||||
|
|
||||||
<td class="compound" width="8%">
|
|
||||||
<input type="checkbox" class="checkbox" name="tax_rate_compound[<?php echo $rate->tax_rate_id ?>]" <?php checked( $rate->tax_rate_compound, '1' ); ?> />
|
|
||||||
</td>
|
|
||||||
|
|
||||||
<td class="apply_to_shipping" width="8%">
|
|
||||||
<input type="checkbox" class="checkbox" name="tax_rate_shipping[<?php echo $rate->tax_rate_id ?>]" <?php checked($rate->tax_rate_shipping, '1' ); ?> />
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
<script type="text/javascript">
|
|
||||||
jQuery( function() {
|
|
||||||
jQuery('.sp_tax_rates .remove_tax_rates').click(function() {
|
|
||||||
var $tbody = jQuery('.sp_tax_rates').find('tbody');
|
|
||||||
if ( $tbody.find('tr.current').size() > 0 ) {
|
|
||||||
$current = $tbody.find('tr.current');
|
|
||||||
$current.find('input').val('');
|
|
||||||
$current.find('input.remove_tax_rate').val('1');
|
|
||||||
|
|
||||||
$current.each(function(){
|
|
||||||
if ( jQuery(this).is('.new') )
|
|
||||||
jQuery(this).remove();
|
|
||||||
else
|
|
||||||
jQuery(this).hide();
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
alert('<?php echo esc_js( __( 'No row(s) selected', 'sportspress' ) ); ?>');
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
|
|
||||||
jQuery('.sp_tax_rates .export').click(function() {
|
|
||||||
|
|
||||||
var csv_data = "data:application/csv;charset=utf-8,<?php _e( 'Country Code', 'sportspress' ); ?>,<?php _e( 'State Code', 'sportspress' ); ?>,<?php _e( 'ZIP/Postcode', 'sportspress' ); ?>,<?php _e( 'City', 'sportspress' ); ?>,<?php _e( 'Rate %', 'sportspress' ); ?>,<?php _e( 'Tax Name', 'sportspress' ); ?>,<?php _e( 'Priority', 'sportspress' ); ?>,<?php _e( 'Compound', 'sportspress' ); ?>,<?php _e( 'Shipping', 'sportspress' ); ?>,<?php _e( 'Tax Class', 'sportspress' ); ?>\n";
|
|
||||||
|
|
||||||
jQuery('#rates tr:visible').each(function() {
|
|
||||||
var row = '';
|
|
||||||
jQuery(this).find('td:not(.sort) input').each(function() {
|
|
||||||
|
|
||||||
if ( jQuery(this).is('.checkbox') ) {
|
|
||||||
|
|
||||||
if ( jQuery(this).is(':checked') ) {
|
|
||||||
val = 1;
|
|
||||||
} else {
|
|
||||||
val = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
var val = jQuery(this).val();
|
|
||||||
|
|
||||||
if ( ! val )
|
|
||||||
val = jQuery(this).attr('placeholder');
|
|
||||||
}
|
|
||||||
|
|
||||||
row = row + val + ',';
|
|
||||||
});
|
|
||||||
row = row + '<?php echo $current_class; ?>';
|
|
||||||
//row.substring( 0, row.length - 1 );
|
|
||||||
csv_data = csv_data + row + "\n";
|
|
||||||
});
|
|
||||||
|
|
||||||
jQuery(this).attr( 'href', encodeURI( csv_data ) );
|
|
||||||
|
|
||||||
return true;
|
|
||||||
});
|
|
||||||
|
|
||||||
jQuery('.sp_tax_rates .insert').click(function() {
|
|
||||||
var $tbody = jQuery('.sp_tax_rates').find('tbody');
|
|
||||||
var size = $tbody.find('tr').size();
|
|
||||||
var code = '<tr class="new">\
|
|
||||||
<td class="sort"> </td>\
|
|
||||||
<td class="country" width="8%">\
|
|
||||||
<input type="text" placeholder="*" name="tax_rate_country[new][' + size + ']" />\
|
|
||||||
</td>\
|
|
||||||
<td class="state" width="8%">\
|
|
||||||
<input type="text" placeholder="*" name="tax_rate_state[new][' + size + ']" />\
|
|
||||||
</td>\
|
|
||||||
<td class="postcode">\
|
|
||||||
<input type="text" placeholder="*" name="tax_rate_postcode[new][' + size + ']" />\
|
|
||||||
</td>\
|
|
||||||
<td class="city">\
|
|
||||||
<input type="text" placeholder="*" name="tax_rate_city[new][' + size + ']" />\
|
|
||||||
</td>\
|
|
||||||
<td class="rate" width="8%">\
|
|
||||||
<input type="number" step="any" min="0" placeholder="0" name="tax_rate[new][' + size + ']" />\
|
|
||||||
</td>\
|
|
||||||
<td class="name" width="8%">\
|
|
||||||
<input type="text" name="tax_rate_name[new][' + size + ']" />\
|
|
||||||
</td>\
|
|
||||||
<td class="priority" width="8%">\
|
|
||||||
<input type="number" step="1" min="1" value="1" name="tax_rate_priority[new][' + size + ']" />\
|
|
||||||
</td>\
|
|
||||||
<td class="compound" width="8%">\
|
|
||||||
<input type="checkbox" class="checkbox" name="tax_rate_compound[new][' + size + ']" />\
|
|
||||||
</td>\
|
|
||||||
<td class="apply_to_shipping" width="8%">\
|
|
||||||
<input type="checkbox" class="checkbox" name="tax_rate_shipping[new][' + size + ']" checked="checked" />\
|
|
||||||
</td>\
|
|
||||||
</tr>';
|
|
||||||
|
|
||||||
if ( $tbody.find('tr.current').size() > 0 ) {
|
|
||||||
$tbody.find('tr.current').after( code );
|
|
||||||
} else {
|
|
||||||
$tbody.append( code );
|
|
||||||
}
|
|
||||||
|
|
||||||
jQuery( "td.country input" ).autocomplete({
|
|
||||||
source: availableCountries,
|
|
||||||
minLength: 3
|
|
||||||
});
|
|
||||||
|
|
||||||
jQuery( "td.state input" ).autocomplete({
|
|
||||||
source: availableStates,
|
|
||||||
minLength: 3
|
|
||||||
});
|
|
||||||
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
|
|
||||||
jQuery('.sp_tax_rates td.postcode, .sp_tax_rates td.city').find('input').change(function() {
|
|
||||||
jQuery(this).attr( 'name', jQuery(this).attr( 'data-name' ) );
|
|
||||||
});
|
|
||||||
|
|
||||||
var availableCountries = [<?php
|
|
||||||
$countries = array();
|
|
||||||
foreach ( SP()->countries->get_allowed_countries() as $value => $label )
|
|
||||||
$countries[] = '{ label: "' . $label . '", value: "' . $value . '" }';
|
|
||||||
echo implode( ', ', $countries );
|
|
||||||
?>];
|
|
||||||
|
|
||||||
var availableStates = [<?php
|
|
||||||
$countries = array();
|
|
||||||
foreach ( SP()->countries->get_allowed_country_states() as $value => $label )
|
|
||||||
foreach ( $label as $code => $state )
|
|
||||||
$countries[] = '{ label: "' . $state . '", value: "' . $code . '" }';
|
|
||||||
echo implode( ', ', $countries );
|
|
||||||
?>];
|
|
||||||
|
|
||||||
jQuery( "td.country input" ).autocomplete({
|
|
||||||
source: availableCountries,
|
|
||||||
minLength: 3
|
|
||||||
});
|
|
||||||
|
|
||||||
jQuery( "td.state input" ).autocomplete({
|
|
||||||
source: availableStates,
|
|
||||||
minLength: 3
|
|
||||||
});
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Save tax rates
|
|
||||||
*/
|
|
||||||
public function save_tax_rates() {
|
|
||||||
global $wpdb, $current_section;
|
|
||||||
|
|
||||||
// Get class
|
|
||||||
$tax_classes = array_filter( array_map( 'trim', explode( "\n", get_option('sportspress_tax_classes' ) ) ) );
|
|
||||||
$current_class = '';
|
|
||||||
|
|
||||||
foreach( $tax_classes as $class )
|
|
||||||
if ( sanitize_title( $class ) == $current_section )
|
|
||||||
$current_class = $class;
|
|
||||||
|
|
||||||
// Get POST data
|
|
||||||
$tax_rate_country = isset( $_POST['tax_rate_country'] ) ? $_POST['tax_rate_country'] : array();
|
|
||||||
$tax_rate_state = isset( $_POST['tax_rate_state'] ) ? $_POST['tax_rate_state'] : array();
|
|
||||||
$tax_rate_postcode = isset( $_POST['tax_rate_postcode'] ) ? $_POST['tax_rate_postcode'] : array();
|
|
||||||
$tax_rate_city = isset( $_POST['tax_rate_city'] ) ? $_POST['tax_rate_city'] : array();
|
|
||||||
$tax_rate = isset( $_POST['tax_rate'] ) ? $_POST['tax_rate'] : array();
|
|
||||||
$tax_rate_name = isset( $_POST['tax_rate_name'] ) ? $_POST['tax_rate_name'] : array();
|
|
||||||
$tax_rate_priority = isset( $_POST['tax_rate_priority'] ) ? $_POST['tax_rate_priority'] : array();
|
|
||||||
$tax_rate_compound = isset( $_POST['tax_rate_compound'] ) ? $_POST['tax_rate_compound'] : array();
|
|
||||||
$tax_rate_shipping = isset( $_POST['tax_rate_shipping'] ) ? $_POST['tax_rate_shipping'] : array();
|
|
||||||
|
|
||||||
$i = 0;
|
|
||||||
|
|
||||||
// Loop posted fields
|
|
||||||
foreach ( $tax_rate_country as $key => $value ) {
|
|
||||||
|
|
||||||
// new keys are inserted...
|
|
||||||
if ( $key == 'new' ) {
|
|
||||||
|
|
||||||
foreach ( $value as $new_key => $new_value ) {
|
|
||||||
|
|
||||||
// Sanitize + format
|
|
||||||
$country = strtoupper( sanitize_text_field( $tax_rate_country[ $key ][ $new_key ] ) );
|
|
||||||
$state = strtoupper( sanitize_text_field( $tax_rate_state[ $key ][ $new_key ] ) );
|
|
||||||
$postcode = sanitize_text_field( $tax_rate_postcode[ $key ][ $new_key ] );
|
|
||||||
$city = sanitize_text_field( $tax_rate_city[ $key ][ $new_key ] );
|
|
||||||
$rate = number_format( sanitize_text_field( $tax_rate[ $key ][ $new_key ] ), 4, '.', '' );
|
|
||||||
$name = sanitize_text_field( $tax_rate_name[ $key ][ $new_key ] );
|
|
||||||
$priority = absint( sanitize_text_field( $tax_rate_priority[ $key ][ $new_key ] ) );
|
|
||||||
$compound = isset( $tax_rate_compound[ $key ][ $new_key ] ) ? 1 : 0;
|
|
||||||
$shipping = isset( $tax_rate_shipping[ $key ][ $new_key ] ) ? 1 : 0;
|
|
||||||
|
|
||||||
if ( ! $name )
|
|
||||||
$name = __( 'Tax', 'sportspress' );
|
|
||||||
|
|
||||||
if ( $country == '*' )
|
|
||||||
$country = '';
|
|
||||||
|
|
||||||
if ( $state == '*' )
|
|
||||||
$state = '';
|
|
||||||
|
|
||||||
$wpdb->insert(
|
|
||||||
$wpdb->prefix . "sportspress_tax_rates",
|
|
||||||
array(
|
|
||||||
'tax_rate_country' => $country,
|
|
||||||
'tax_rate_state' => $state,
|
|
||||||
'tax_rate' => $rate,
|
|
||||||
'tax_rate_name' => $name,
|
|
||||||
'tax_rate_priority' => $priority,
|
|
||||||
'tax_rate_compound' => $compound,
|
|
||||||
'tax_rate_shipping' => $shipping,
|
|
||||||
'tax_rate_order' => $i,
|
|
||||||
'tax_rate_class' => sanitize_title( $current_class )
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
$tax_rate_id = $wpdb->insert_id;
|
|
||||||
|
|
||||||
if ( ! empty( $postcode ) ) {
|
|
||||||
$postcodes = explode( ';', $postcode );
|
|
||||||
$postcodes = array_map( 'strtoupper', array_map( 'sanitize_text_field', $postcodes ) );
|
|
||||||
|
|
||||||
$postcode_query = array();
|
|
||||||
|
|
||||||
foreach( $postcodes as $postcode )
|
|
||||||
if ( strstr( $postcode, '-' ) ) {
|
|
||||||
$postcode_parts = explode( '-', $postcode );
|
|
||||||
|
|
||||||
if ( is_numeric( $postcode_parts[0] ) && is_numeric( $postcode_parts[1] ) && $postcode_parts[1] > $postcode_parts[0] ) {
|
|
||||||
for ( $i = $postcode_parts[0]; $i <= $postcode_parts[1]; $i ++ ) {
|
|
||||||
if ( ! $i )
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if ( strlen( $i ) < strlen( $postcode_parts[0] ) )
|
|
||||||
$i = str_pad( $i, strlen( $postcode_parts[0] ), "0", STR_PAD_LEFT );
|
|
||||||
|
|
||||||
$postcode_query[] = "( '" . esc_sql( $i ) . "', $tax_rate_id, 'postcode' )";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if ( $postcode )
|
|
||||||
$postcode_query[] = "( '" . esc_sql( $postcode ) . "', $tax_rate_id, 'postcode' )";
|
|
||||||
}
|
|
||||||
|
|
||||||
$wpdb->query( "INSERT INTO {$wpdb->prefix}sportspress_tax_rate_locations ( location_code, tax_rate_id, location_type ) VALUES " . implode( ',', $postcode_query ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( ! empty( $city ) ) {
|
|
||||||
$cities = explode( ';', $city );
|
|
||||||
$cities = array_map( 'strtoupper', array_map( 'sanitize_text_field', $cities ) );
|
|
||||||
foreach( $cities as $city ) {
|
|
||||||
$wpdb->insert(
|
|
||||||
$wpdb->prefix . "sportspress_tax_rate_locations",
|
|
||||||
array(
|
|
||||||
'location_code' => $city,
|
|
||||||
'tax_rate_id' => $tax_rate_id,
|
|
||||||
'location_type' => 'city',
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$i++;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ...whereas the others are updated
|
|
||||||
} else {
|
|
||||||
|
|
||||||
$tax_rate_id = absint( $key );
|
|
||||||
|
|
||||||
if ( $_POST['remove_tax_rate'][ $key ] == 1 ) {
|
|
||||||
$wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}sportspress_tax_rate_locations WHERE tax_rate_id = %d;", $tax_rate_id ) );
|
|
||||||
$wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}sportspress_tax_rates WHERE tax_rate_id = %d;", $tax_rate_id ) );
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Sanitize + format
|
|
||||||
$country = strtoupper( sanitize_text_field( $tax_rate_country[ $key ] ) );
|
|
||||||
$state = strtoupper( sanitize_text_field( $tax_rate_state[ $key ] ) );
|
|
||||||
$rate = number_format( (double) sanitize_text_field( $tax_rate[ $key ] ), 4, '.', '' );
|
|
||||||
$name = sanitize_text_field( $tax_rate_name[ $key ] );
|
|
||||||
$priority = absint( sanitize_text_field( $tax_rate_priority[ $key ] ) );
|
|
||||||
$compound = isset( $tax_rate_compound[ $key ] ) ? 1 : 0;
|
|
||||||
$shipping = isset( $tax_rate_shipping[ $key ] ) ? 1 : 0;
|
|
||||||
|
|
||||||
if ( ! $name )
|
|
||||||
$name = __( 'Tax', 'sportspress' );
|
|
||||||
|
|
||||||
if ( $country == '*' )
|
|
||||||
$country = '';
|
|
||||||
|
|
||||||
if ( $state == '*' )
|
|
||||||
$state = '';
|
|
||||||
|
|
||||||
$wpdb->update(
|
|
||||||
$wpdb->prefix . "sportspress_tax_rates",
|
|
||||||
array(
|
|
||||||
'tax_rate_country' => $country,
|
|
||||||
'tax_rate_state' => $state,
|
|
||||||
'tax_rate' => $rate,
|
|
||||||
'tax_rate_name' => $name,
|
|
||||||
'tax_rate_priority' => $priority,
|
|
||||||
'tax_rate_compound' => $compound,
|
|
||||||
'tax_rate_shipping' => $shipping,
|
|
||||||
'tax_rate_order' => $i,
|
|
||||||
'tax_rate_class' => sanitize_title( $current_class )
|
|
||||||
),
|
|
||||||
array(
|
|
||||||
'tax_rate_id' => $tax_rate_id
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
if ( isset( $tax_rate_postcode[ $key ] ) ) {
|
|
||||||
// Delete old
|
|
||||||
$wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}sportspress_tax_rate_locations WHERE tax_rate_id = %d AND location_type = 'postcode';", $tax_rate_id ) );
|
|
||||||
|
|
||||||
// Add changed
|
|
||||||
$postcode = sanitize_text_field( $tax_rate_postcode[ $key ] );
|
|
||||||
$postcodes = explode( ';', $postcode );
|
|
||||||
$postcodes = array_map( 'strtoupper', array_map( 'sanitize_text_field', $postcodes ) );
|
|
||||||
|
|
||||||
$postcode_query = array();
|
|
||||||
|
|
||||||
foreach( $postcodes as $postcode )
|
|
||||||
if ( strstr( $postcode, '-' ) ) {
|
|
||||||
$postcode_parts = explode( '-', $postcode );
|
|
||||||
|
|
||||||
if ( is_numeric( $postcode_parts[0] ) && is_numeric( $postcode_parts[1] ) && $postcode_parts[1] > $postcode_parts[0] ) {
|
|
||||||
for ( $i = $postcode_parts[0]; $i <= $postcode_parts[1]; $i ++ ) {
|
|
||||||
if ( ! $i )
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if ( strlen( $i ) < strlen( $postcode_parts[0] ) )
|
|
||||||
$i = str_pad( $i, strlen( $postcode_parts[0] ), "0", STR_PAD_LEFT );
|
|
||||||
|
|
||||||
$postcode_query[] = "( '" . esc_sql( $i ) . "', $tax_rate_id, 'postcode' )";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if ( $postcode )
|
|
||||||
$postcode_query[] = "( '" . esc_sql( $postcode ) . "', $tax_rate_id, 'postcode' )";
|
|
||||||
}
|
|
||||||
|
|
||||||
$wpdb->query( "INSERT INTO {$wpdb->prefix}sportspress_tax_rate_locations ( location_code, tax_rate_id, location_type ) VALUES " . implode( ',', $postcode_query ) );
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( isset( $tax_rate_city[ $key ] ) ) {
|
|
||||||
// Delete old
|
|
||||||
$wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}sportspress_tax_rate_locations WHERE tax_rate_id = %d AND location_type = 'city';", $tax_rate_id ) );
|
|
||||||
|
|
||||||
// Add changed
|
|
||||||
$city = sanitize_text_field( $tax_rate_city[ $key ] );
|
|
||||||
$cities = explode( ';', $city );
|
|
||||||
$cities = array_map( 'strtoupper', array_map( 'sanitize_text_field', $cities ) );
|
|
||||||
foreach( $cities as $city ) {
|
|
||||||
if ( $city ) {
|
|
||||||
$wpdb->insert(
|
|
||||||
$wpdb->prefix . "sportspress_tax_rate_locations",
|
|
||||||
array(
|
|
||||||
'location_code' => $city,
|
|
||||||
'tax_rate_id' => $tax_rate_id,
|
|
||||||
'location_type' => 'city',
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$i++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Output results settings.
|
|
||||||
*
|
|
||||||
* @access public
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function results_setting() {
|
|
||||||
$main_result = get_option( 'sportspress_main_result', 0 );
|
|
||||||
|
|
||||||
$args = array(
|
|
||||||
'post_type' => 'sp_result',
|
|
||||||
'numberposts' => -1,
|
|
||||||
'posts_per_page' => -1,
|
|
||||||
'orderby' => 'menu_order',
|
|
||||||
'order' => 'ASC'
|
|
||||||
);
|
);
|
||||||
$data = get_posts( $args );
|
|
||||||
?>
|
|
||||||
<tr valign="top">
|
|
||||||
<th scope="row" class="titledesc"><?php _e( 'Results', 'sportspress' ) ?></th>
|
|
||||||
<td class="forminp">
|
|
||||||
<table class="widefat sp-admin-config-table">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th scope="col"><?php _e( 'Primary', 'sportspress' ); ?></th>
|
|
||||||
<th scope="col"><?php _e( 'Label', 'sportspress' ); ?></th>
|
|
||||||
<th scope="col"><?php _e( 'Key', 'sportspress' ); ?></th>
|
|
||||||
<th class="edit"></th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tfoot>
|
|
||||||
<tr>
|
|
||||||
<th class="radio"><input type="radio" id="sportspress_main_result_0" name="main_result" value="0" <?php checked( $main_result, 0 ); ?>></th>
|
|
||||||
<th colspan="3"><label for="main_result_0">
|
|
||||||
<?php
|
|
||||||
if ( sizeof( $data ) > 0 ):
|
|
||||||
$default = end( $data );
|
|
||||||
reset( $data );
|
|
||||||
printf( __( 'Default (%s)', 'sportspress' ), $default->post_title );
|
|
||||||
else:
|
|
||||||
_e( 'Default', 'sportspress' );
|
|
||||||
endif;
|
|
||||||
?>
|
|
||||||
</label></th>
|
|
||||||
</tr>
|
|
||||||
</tfoot>
|
|
||||||
<?php $i = 0; foreach ( $data as $row ): ?>
|
|
||||||
<tr<?php if ( $i % 2 == 0 ) echo ' class="alternate"'; ?>>
|
|
||||||
<td class="radio"><input type="radio" id="main_result_<?php echo $row->post_name; ?>" name="main_result" value="<?php echo $row->post_name; ?>" <?php checked( $main_result, $row->post_name ); ?>></td>
|
|
||||||
<td class="row-title"><label for="sportspress_main_result_<?php echo $row->post_name; ?>"><?php echo $row->post_title; ?></label></td>
|
|
||||||
<td><?php echo $row->post_name; ?>for / <?php echo $row->post_name; ?>against</td>
|
|
||||||
<td class="edit"><a class="button" href="<?php echo get_edit_post_link( $row->ID ); ?>"><?php _e( 'Edit', 'sportspress' ); ?></s></td>
|
|
||||||
</tr>
|
|
||||||
<?php $i++; endforeach; ?>
|
|
||||||
</table>
|
|
||||||
<div class="tablenav bottom">
|
|
||||||
<div class="alignleft actions">
|
|
||||||
<a class="button" id="doaction" href="<?php echo admin_url( 'edit.php?post_type=sp_result' ); ?>"><?php _e( 'View All', 'sportspress' ); ?></a>
|
|
||||||
<a class="button" id="doaction2" href="<?php echo admin_url( 'post-new.php?post_type=sp_result' ); ?>"><?php _e( 'Add New', 'sportspress' ); ?></a>
|
|
||||||
</div>
|
|
||||||
<br class="clear">
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
|
|
||||||
|
foreach ( SP()->text->player as $key => $value ):
|
||||||
|
$settings[] = array(
|
||||||
|
'title' => $value,
|
||||||
|
'id' => 'sportspress_player_' . $key . '_text',
|
||||||
|
'default' => '',
|
||||||
|
'placeholder' => $value,
|
||||||
|
'type' => 'text',
|
||||||
|
);
|
||||||
|
endforeach;
|
||||||
|
|
||||||
|
$settings[] = array( 'type' => 'sectionend', 'id' => 'text_options' );
|
||||||
|
|
||||||
|
return apply_filters( 'sportspress_event_settings', $settings ); // End player settings
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
return new SP_Settings_Players();
|
return new SP_Settings_Players();
|
||||||
|
|||||||
@@ -1,458 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* SportsPress Product Settings
|
|
||||||
*
|
|
||||||
* @author ThemeBoy
|
|
||||||
* @category Admin
|
|
||||||
* @package SportsPress/Admin
|
|
||||||
* @version 0.7
|
|
||||||
*/
|
|
||||||
|
|
||||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
|
||||||
|
|
||||||
if ( ! class_exists( 'SP_Settings_Products' ) ) :
|
|
||||||
|
|
||||||
/**
|
|
||||||
* SP_Settings_Products
|
|
||||||
*/
|
|
||||||
class SP_Settings_Products extends SP_Settings_Page {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor.
|
|
||||||
*/
|
|
||||||
public function __construct() {
|
|
||||||
$this->id = 'products';
|
|
||||||
$this->label = __( 'Products', 'sportspress' );
|
|
||||||
|
|
||||||
add_filter( 'sportspress_settings_tabs_array', array( $this, 'add_settings_page' ), 20 );
|
|
||||||
add_action( 'sportspress_settings_' . $this->id, array( $this, 'output' ) );
|
|
||||||
add_action( 'sportspress_settings_save_' . $this->id, array( $this, 'save' ) );
|
|
||||||
add_action( 'sportspress_sections_' . $this->id, array( $this, 'output_sections' ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get sections
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function get_sections() {
|
|
||||||
$sections = array(
|
|
||||||
'' => __( 'Product Options', 'sportspress' ),
|
|
||||||
'inventory' => __( 'Inventory', 'sportspress' )
|
|
||||||
);
|
|
||||||
|
|
||||||
return $sections;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Output the settings
|
|
||||||
*/
|
|
||||||
public function output() {
|
|
||||||
global $current_section;
|
|
||||||
|
|
||||||
$settings = $this->get_settings( $current_section );
|
|
||||||
|
|
||||||
SP_Admin_Settings::output_fields( $settings );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Save settings
|
|
||||||
*/
|
|
||||||
public function save() {
|
|
||||||
global $current_section;
|
|
||||||
|
|
||||||
$settings = $this->get_settings( $current_section );
|
|
||||||
SP_Admin_Settings::save_fields( $settings );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get settings array
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function get_settings( $current_section = '' ) {
|
|
||||||
|
|
||||||
if ( $current_section == 'inventory' ) {
|
|
||||||
|
|
||||||
return apply_filters('sportspress_inventory_settings', array(
|
|
||||||
|
|
||||||
array( 'title' => __( 'Inventory Options', 'sportspress' ), 'type' => 'title', 'desc' => '', 'id' => 'inventory_options' ),
|
|
||||||
|
|
||||||
array(
|
|
||||||
'title' => __( 'Manage Stock', 'sportspress' ),
|
|
||||||
'desc' => __( 'Enable stock management', 'sportspress' ),
|
|
||||||
'id' => 'sportspress_manage_stock',
|
|
||||||
'default' => 'yes',
|
|
||||||
'type' => 'checkbox'
|
|
||||||
),
|
|
||||||
|
|
||||||
array(
|
|
||||||
'title' => __( 'Hold Stock (minutes)', 'sportspress' ),
|
|
||||||
'desc' => __( 'Hold stock (for unpaid orders) for x minutes. When this limit is reached, the pending order will be cancelled. Leave blank to disable.', 'sportspress' ),
|
|
||||||
'id' => 'sportspress_hold_stock_minutes',
|
|
||||||
'type' => 'number',
|
|
||||||
'custom_attributes' => array(
|
|
||||||
'min' => 0,
|
|
||||||
'step' => 1
|
|
||||||
),
|
|
||||||
'css' => 'width:50px;',
|
|
||||||
'default' => '60',
|
|
||||||
'autoload' => false
|
|
||||||
),
|
|
||||||
|
|
||||||
array(
|
|
||||||
'title' => __( 'Notifications', 'sportspress' ),
|
|
||||||
'desc' => __( 'Enable low stock notifications', 'sportspress' ),
|
|
||||||
'id' => 'sportspress_notify_low_stock',
|
|
||||||
'default' => 'yes',
|
|
||||||
'type' => 'checkbox',
|
|
||||||
'checkboxgroup' => 'start',
|
|
||||||
'autoload' => false
|
|
||||||
),
|
|
||||||
|
|
||||||
array(
|
|
||||||
'desc' => __( 'Enable out of stock notifications', 'sportspress' ),
|
|
||||||
'id' => 'sportspress_notify_no_stock',
|
|
||||||
'default' => 'yes',
|
|
||||||
'type' => 'checkbox',
|
|
||||||
'checkboxgroup' => 'end',
|
|
||||||
'autoload' => false
|
|
||||||
),
|
|
||||||
|
|
||||||
array(
|
|
||||||
'title' => __( 'Notification Recipient', 'sportspress' ),
|
|
||||||
'desc' => '',
|
|
||||||
'id' => 'sportspress_stock_email_recipient',
|
|
||||||
'type' => 'email',
|
|
||||||
'default' => get_option( 'admin_email' ),
|
|
||||||
'autoload' => false
|
|
||||||
),
|
|
||||||
|
|
||||||
array(
|
|
||||||
'title' => __( 'Low Stock Threshold', 'sportspress' ),
|
|
||||||
'desc' => '',
|
|
||||||
'id' => 'sportspress_notify_low_stock_amount',
|
|
||||||
'css' => 'width:50px;',
|
|
||||||
'type' => 'number',
|
|
||||||
'custom_attributes' => array(
|
|
||||||
'min' => 0,
|
|
||||||
'step' => 1
|
|
||||||
),
|
|
||||||
'default' => '2',
|
|
||||||
'autoload' => false
|
|
||||||
),
|
|
||||||
|
|
||||||
array(
|
|
||||||
'title' => __( 'Out Of Stock Threshold', 'sportspress' ),
|
|
||||||
'desc' => '',
|
|
||||||
'id' => 'sportspress_notify_no_stock_amount',
|
|
||||||
'css' => 'width:50px;',
|
|
||||||
'type' => 'number',
|
|
||||||
'custom_attributes' => array(
|
|
||||||
'min' => 0,
|
|
||||||
'step' => 1
|
|
||||||
),
|
|
||||||
'default' => '0',
|
|
||||||
'autoload' => false
|
|
||||||
),
|
|
||||||
|
|
||||||
array(
|
|
||||||
'title' => __( 'Out Of Stock Visibility', 'sportspress' ),
|
|
||||||
'desc' => __( 'Hide out of stock items from the catalog', 'sportspress' ),
|
|
||||||
'id' => 'sportspress_hide_out_of_stock_items',
|
|
||||||
'default' => 'no',
|
|
||||||
'type' => 'checkbox'
|
|
||||||
),
|
|
||||||
|
|
||||||
array(
|
|
||||||
'title' => __( 'Stock Display Format', 'sportspress' ),
|
|
||||||
'desc' => __( 'This controls how stock is displayed on the frontend.', 'sportspress' ),
|
|
||||||
'id' => 'sportspress_stock_format',
|
|
||||||
'css' => 'min-width:150px;',
|
|
||||||
'default' => '',
|
|
||||||
'type' => 'select',
|
|
||||||
'options' => array(
|
|
||||||
'' => __( 'Always show stock e.g. "12 in stock"', 'sportspress' ),
|
|
||||||
'low_amount' => __( 'Only show stock when low e.g. "Only 2 left in stock" vs. "In Stock"', 'sportspress' ),
|
|
||||||
'no_amount' => __( 'Never show stock amount', 'sportspress' ),
|
|
||||||
),
|
|
||||||
'desc_tip' => true,
|
|
||||||
),
|
|
||||||
|
|
||||||
array( 'type' => 'sectionend', 'id' => 'inventory_options'),
|
|
||||||
|
|
||||||
));
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
// Get shop page
|
|
||||||
$shop_page_id = sp_get_page_id('shop');
|
|
||||||
|
|
||||||
$base_slug = ($shop_page_id > 0 && get_page( $shop_page_id )) ? get_page_uri( $shop_page_id ) : 'shop';
|
|
||||||
|
|
||||||
$sportspress_prepend_shop_page_to_products_warning = '';
|
|
||||||
|
|
||||||
if ( $shop_page_id > 0 && sizeof(get_pages("child_of=$shop_page_id")) > 0 )
|
|
||||||
$sportspress_prepend_shop_page_to_products_warning = ' <mark class="notice">' . __( 'Note: The shop page has children - child pages will not work if you enable this option.', 'sportspress' ) . '</mark>';
|
|
||||||
|
|
||||||
return apply_filters( 'sportspress_product_settings', array(
|
|
||||||
|
|
||||||
array( 'title' => __( 'Product Listings', 'sportspress' ), 'type' => 'title','desc' => '', 'id' => 'catalog_options' ),
|
|
||||||
|
|
||||||
array(
|
|
||||||
'title' => __( 'Product Archive / Shop Page', 'sportspress' ),
|
|
||||||
'desc' => '<br/>' . sprintf( __( 'The base page can also be used in your <a href="%s">product permalinks</a>.', 'sportspress' ), admin_url( 'options-permalink.php' ) ),
|
|
||||||
'id' => 'sportspress_shop_page_id',
|
|
||||||
'type' => 'single_select_page',
|
|
||||||
'default' => '',
|
|
||||||
'class' => 'chosen_select_nostd',
|
|
||||||
'css' => 'min-width:300px;',
|
|
||||||
'desc_tip' => __( 'This sets the base page of your shop - this is where your product archive will be.', 'sportspress' ),
|
|
||||||
),
|
|
||||||
|
|
||||||
array(
|
|
||||||
'title' => __( 'Shop Page Display', 'sportspress' ),
|
|
||||||
'desc' => __( 'This controls what is shown on the product archive.', 'sportspress' ),
|
|
||||||
'id' => 'sportspress_shop_page_display',
|
|
||||||
'class' => 'chosen_select',
|
|
||||||
'css' => 'min-width:300px;',
|
|
||||||
'default' => '',
|
|
||||||
'type' => 'select',
|
|
||||||
'options' => array(
|
|
||||||
'' => __( 'Show products', 'sportspress' ),
|
|
||||||
'subcategories' => __( 'Show subcategories', 'sportspress' ),
|
|
||||||
'both' => __( 'Show both', 'sportspress' ),
|
|
||||||
),
|
|
||||||
'desc_tip' => true,
|
|
||||||
),
|
|
||||||
|
|
||||||
array(
|
|
||||||
'title' => __( 'Default Category Display', 'sportspress' ),
|
|
||||||
'desc' => __( 'This controls what is shown on category archives.', 'sportspress' ),
|
|
||||||
'id' => 'sportspress_category_archive_display',
|
|
||||||
'class' => 'chosen_select',
|
|
||||||
'css' => 'min-width:300px;',
|
|
||||||
'default' => '',
|
|
||||||
'type' => 'select',
|
|
||||||
'options' => array(
|
|
||||||
'' => __( 'Show products', 'sportspress' ),
|
|
||||||
'subcategories' => __( 'Show subcategories', 'sportspress' ),
|
|
||||||
'both' => __( 'Show both', 'sportspress' ),
|
|
||||||
),
|
|
||||||
'desc_tip' => true,
|
|
||||||
),
|
|
||||||
|
|
||||||
array(
|
|
||||||
'title' => __( 'Default Product Sorting', 'sportspress' ),
|
|
||||||
'desc' => __( 'This controls the default sort order of the catalog.', 'sportspress' ),
|
|
||||||
'id' => 'sportspress_default_catalog_orderby',
|
|
||||||
'class' => 'chosen_select',
|
|
||||||
'css' => 'min-width:300px;',
|
|
||||||
'default' => 'title',
|
|
||||||
'type' => 'select',
|
|
||||||
'options' => apply_filters('sportspress_default_catalog_orderby_options', array(
|
|
||||||
'menu_order' => __( 'Default sorting (custom ordering + name)', 'sportspress' ),
|
|
||||||
'popularity' => __( 'Popularity (sales)', 'sportspress' ),
|
|
||||||
'rating' => __( 'Average Rating', 'sportspress' ),
|
|
||||||
'date' => __( 'Sort by most recent', 'sportspress' ),
|
|
||||||
'price' => __( 'Sort by price (asc)', 'sportspress' ),
|
|
||||||
'price-desc' => __( 'Sort by price (desc)', 'sportspress' ),
|
|
||||||
)),
|
|
||||||
'desc_tip' => true,
|
|
||||||
),
|
|
||||||
|
|
||||||
array(
|
|
||||||
'title' => __( 'Add to cart', 'sportspress' ),
|
|
||||||
'desc' => __( 'Redirect to the cart page after successful addition', 'sportspress' ),
|
|
||||||
'id' => 'sportspress_cart_redirect_after_add',
|
|
||||||
'default' => 'no',
|
|
||||||
'type' => 'checkbox',
|
|
||||||
'checkboxgroup' => 'start'
|
|
||||||
),
|
|
||||||
|
|
||||||
array(
|
|
||||||
'desc' => __( 'Enable AJAX add to cart buttons on archives', 'sportspress' ),
|
|
||||||
'id' => 'sportspress_enable_ajax_add_to_cart',
|
|
||||||
'default' => 'yes',
|
|
||||||
'type' => 'checkbox',
|
|
||||||
'checkboxgroup' => 'end'
|
|
||||||
),
|
|
||||||
|
|
||||||
array( 'type' => 'sectionend', 'id' => 'catalog_options' ),
|
|
||||||
|
|
||||||
array( 'title' => __( 'Product Data', 'sportspress' ), 'type' => 'title', 'id' => 'product_data_options' ),
|
|
||||||
|
|
||||||
array(
|
|
||||||
'title' => __( 'Weight Unit', 'sportspress' ),
|
|
||||||
'desc' => __( 'This controls what unit you will define weights in.', 'sportspress' ),
|
|
||||||
'id' => 'sportspress_weight_unit',
|
|
||||||
'class' => 'chosen_select',
|
|
||||||
'css' => 'min-width:300px;',
|
|
||||||
'default' => 'kg',
|
|
||||||
'type' => 'select',
|
|
||||||
'options' => array(
|
|
||||||
'kg' => __( 'kg', 'sportspress' ),
|
|
||||||
'g' => __( 'g', 'sportspress' ),
|
|
||||||
'lbs' => __( 'lbs', 'sportspress' ),
|
|
||||||
'oz' => __( 'oz', 'sportspress' ),
|
|
||||||
),
|
|
||||||
'desc_tip' => true,
|
|
||||||
),
|
|
||||||
|
|
||||||
array(
|
|
||||||
'title' => __( 'Dimensions Unit', 'sportspress' ),
|
|
||||||
'desc' => __( 'This controls what unit you will define lengths in.', 'sportspress' ),
|
|
||||||
'id' => 'sportspress_dimension_unit',
|
|
||||||
'class' => 'chosen_select',
|
|
||||||
'css' => 'min-width:300px;',
|
|
||||||
'default' => 'cm',
|
|
||||||
'type' => 'select',
|
|
||||||
'options' => array(
|
|
||||||
'm' => __( 'm', 'sportspress' ),
|
|
||||||
'cm' => __( 'cm', 'sportspress' ),
|
|
||||||
'mm' => __( 'mm', 'sportspress' ),
|
|
||||||
'in' => __( 'in', 'sportspress' ),
|
|
||||||
'yd' => __( 'yd', 'sportspress' ),
|
|
||||||
),
|
|
||||||
'desc_tip' => true,
|
|
||||||
),
|
|
||||||
|
|
||||||
array(
|
|
||||||
'title' => __( 'Product Ratings', 'sportspress' ),
|
|
||||||
'desc' => __( 'Enable ratings on reviews', 'sportspress' ),
|
|
||||||
'id' => 'sportspress_enable_review_rating',
|
|
||||||
'default' => 'yes',
|
|
||||||
'type' => 'checkbox',
|
|
||||||
'checkboxgroup' => 'start',
|
|
||||||
'show_if_checked' => 'option',
|
|
||||||
'autoload' => false
|
|
||||||
),
|
|
||||||
|
|
||||||
array(
|
|
||||||
'desc' => __( 'Ratings are required to leave a review', 'sportspress' ),
|
|
||||||
'id' => 'sportspress_review_rating_required',
|
|
||||||
'default' => 'yes',
|
|
||||||
'type' => 'checkbox',
|
|
||||||
'checkboxgroup' => '',
|
|
||||||
'show_if_checked' => 'yes',
|
|
||||||
'autoload' => false
|
|
||||||
),
|
|
||||||
|
|
||||||
array(
|
|
||||||
'desc' => __( 'Show "verified owner" label for customer reviews', 'sportspress' ),
|
|
||||||
'id' => 'sportspress_review_rating_verification_label',
|
|
||||||
'default' => 'yes',
|
|
||||||
'type' => 'checkbox',
|
|
||||||
'checkboxgroup' => '',
|
|
||||||
'show_if_checked' => 'yes',
|
|
||||||
'autoload' => false
|
|
||||||
),
|
|
||||||
|
|
||||||
array(
|
|
||||||
'desc' => __( 'Only allow reviews from "verified owners"', 'sportspress' ),
|
|
||||||
'id' => 'sportspress_review_rating_verification_required',
|
|
||||||
'default' => 'no',
|
|
||||||
'type' => 'checkbox',
|
|
||||||
'checkboxgroup' => 'end',
|
|
||||||
'show_if_checked' => 'yes',
|
|
||||||
'autoload' => false
|
|
||||||
),
|
|
||||||
|
|
||||||
array( 'type' => 'sectionend', 'id' => 'product_data_options' ),
|
|
||||||
|
|
||||||
array( 'title' => __( 'Product Image Sizes', 'sportspress' ), 'type' => 'title','desc' => sprintf(__( 'These settings affect the actual dimensions of images in your catalog - the display on the front-end will still be affected by CSS styles. After changing these settings you may need to <a href="%s">regenerate your thumbnails</a>.', 'sportspress' ), 'http://wordpress.org/extend/plugins/regenerate-thumbnails/'), 'id' => 'image_options' ),
|
|
||||||
|
|
||||||
array(
|
|
||||||
'title' => __( 'Catalog Images', 'sportspress' ),
|
|
||||||
'desc' => __( 'This size is usually used in product listings', 'sportspress' ),
|
|
||||||
'id' => 'shop_catalog_image_size',
|
|
||||||
'css' => '',
|
|
||||||
'type' => 'image_width',
|
|
||||||
'default' => array(
|
|
||||||
'width' => '150',
|
|
||||||
'height' => '150',
|
|
||||||
'crop' => true
|
|
||||||
),
|
|
||||||
'desc_tip' => true,
|
|
||||||
),
|
|
||||||
|
|
||||||
array(
|
|
||||||
'title' => __( 'Single Product Image', 'sportspress' ),
|
|
||||||
'desc' => __( 'This is the size used by the main image on the product page.', 'sportspress' ),
|
|
||||||
'id' => 'shop_single_image_size',
|
|
||||||
'css' => '',
|
|
||||||
'type' => 'image_width',
|
|
||||||
'default' => array(
|
|
||||||
'width' => '300',
|
|
||||||
'height' => '300',
|
|
||||||
'crop' => 1
|
|
||||||
),
|
|
||||||
'desc_tip' => true,
|
|
||||||
),
|
|
||||||
|
|
||||||
array(
|
|
||||||
'title' => __( 'Product Thumbnails', 'sportspress' ),
|
|
||||||
'desc' => __( 'This size is usually used for the gallery of images on the product page.', 'sportspress' ),
|
|
||||||
'id' => 'shop_thumbnail_image_size',
|
|
||||||
'css' => '',
|
|
||||||
'type' => 'image_width',
|
|
||||||
'default' => array(
|
|
||||||
'width' => '90',
|
|
||||||
'height' => '90',
|
|
||||||
'crop' => 1
|
|
||||||
),
|
|
||||||
'desc_tip' => true,
|
|
||||||
),
|
|
||||||
|
|
||||||
array( 'type' => 'sectionend', 'id' => 'image_options' ),
|
|
||||||
|
|
||||||
array( 'title' => __( 'Downloadable Products', 'sportspress' ), 'type' => 'title', 'id' => 'digital_download_options' ),
|
|
||||||
|
|
||||||
array(
|
|
||||||
'title' => __( 'File Download Method', 'sportspress' ),
|
|
||||||
'desc' => __( 'Forcing downloads will keep URLs hidden, but some servers may serve large files unreliably. If supported, <code>X-Accel-Redirect</code>/ <code>X-Sendfile</code> can be used to serve downloads instead (server requires <code>mod_xsendfile</code>).', 'sportspress' ),
|
|
||||||
'id' => 'sportspress_file_download_method',
|
|
||||||
'type' => 'select',
|
|
||||||
'class' => 'chosen_select',
|
|
||||||
'css' => 'min-width:300px;',
|
|
||||||
'default' => 'force',
|
|
||||||
'desc_tip' => true,
|
|
||||||
'options' => array(
|
|
||||||
'force' => __( 'Force Downloads', 'sportspress' ),
|
|
||||||
'xsendfile' => __( 'X-Accel-Redirect/X-Sendfile', 'sportspress' ),
|
|
||||||
'redirect' => __( 'Redirect only', 'sportspress' ),
|
|
||||||
),
|
|
||||||
'autoload' => false
|
|
||||||
),
|
|
||||||
|
|
||||||
array(
|
|
||||||
'title' => __( 'Access Restriction', 'sportspress' ),
|
|
||||||
'desc' => __( 'Downloads require login', 'sportspress' ),
|
|
||||||
'id' => 'sportspress_downloads_require_login',
|
|
||||||
'type' => 'checkbox',
|
|
||||||
'default' => 'no',
|
|
||||||
'desc_tip' => __( 'This setting does not apply to guest purchases.', 'sportspress' ),
|
|
||||||
'checkboxgroup' => 'start',
|
|
||||||
'autoload' => false
|
|
||||||
),
|
|
||||||
|
|
||||||
array(
|
|
||||||
'desc' => __( 'Grant access to downloadable products after payment', 'sportspress' ),
|
|
||||||
'id' => 'sportspress_downloads_grant_access_after_payment',
|
|
||||||
'type' => 'checkbox',
|
|
||||||
'default' => 'yes',
|
|
||||||
'desc_tip' => __( 'Enable this option to grant access to downloads when orders are "processing", rather than "completed".', 'sportspress' ),
|
|
||||||
'checkboxgroup' => 'end',
|
|
||||||
'autoload' => false
|
|
||||||
),
|
|
||||||
|
|
||||||
array( 'type' => 'sectionend', 'id' => 'digital_download_options' ),
|
|
||||||
|
|
||||||
));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
endif;
|
|
||||||
|
|
||||||
return new SP_Settings_Products();
|
|
||||||
@@ -1,281 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* SportsPress Shipping Settings
|
|
||||||
*
|
|
||||||
* @author ThemeBoy
|
|
||||||
* @category Admin
|
|
||||||
* @package SportsPress/Admin
|
|
||||||
* @version 0.7
|
|
||||||
*/
|
|
||||||
|
|
||||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
|
||||||
|
|
||||||
if ( ! class_exists( 'SP_Settings_Shipping' ) ) :
|
|
||||||
|
|
||||||
/**
|
|
||||||
* SP_Settings_Shipping
|
|
||||||
*/
|
|
||||||
class SP_Settings_Shipping extends SP_Settings_Page {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor.
|
|
||||||
*/
|
|
||||||
public function __construct() {
|
|
||||||
$this->id = 'shipping';
|
|
||||||
$this->label = __( 'Shipping', 'sportspress' );
|
|
||||||
|
|
||||||
add_filter( 'sportspress_settings_tabs_array', array( $this, 'add_settings_page' ), 20 );
|
|
||||||
add_action( 'sportspress_sections_' . $this->id, array( $this, 'output_sections' ) );
|
|
||||||
add_action( 'sportspress_settings_' . $this->id, array( $this, 'output' ) );
|
|
||||||
add_action( 'sportspress_admin_field_shipping_methods', array( $this, 'shipping_methods_setting' ) );
|
|
||||||
add_action( 'sportspress_settings_save_' . $this->id, array( $this, 'save' ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get sections
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function get_sections() {
|
|
||||||
$sections = array(
|
|
||||||
'' => __( 'Shipping Options', 'sportspress' )
|
|
||||||
);
|
|
||||||
|
|
||||||
// Load shipping methods so we can show any global options they may have
|
|
||||||
$shipping_methods = SP()->shipping->load_shipping_methods();
|
|
||||||
|
|
||||||
foreach ( $shipping_methods as $method ) {
|
|
||||||
|
|
||||||
if ( ! $method->has_settings() ) continue;
|
|
||||||
|
|
||||||
$title = empty( $method->method_title ) ? ucfirst( $method->id ) : $method->method_title;
|
|
||||||
|
|
||||||
$sections[ strtolower( get_class( $method ) ) ] = esc_html( $title );
|
|
||||||
}
|
|
||||||
|
|
||||||
return $sections;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get settings array
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function get_settings() {
|
|
||||||
return apply_filters('sportspress_shipping_settings', array(
|
|
||||||
|
|
||||||
array( 'title' => __( 'Shipping Options', 'sportspress' ), 'type' => 'title', 'id' => 'shipping_options' ),
|
|
||||||
|
|
||||||
array(
|
|
||||||
'title' => __( 'Shipping Calculations', 'sportspress' ),
|
|
||||||
'desc' => __( 'Enable shipping', 'sportspress' ),
|
|
||||||
'id' => 'sportspress_calc_shipping',
|
|
||||||
'default' => 'yes',
|
|
||||||
'type' => 'checkbox',
|
|
||||||
'checkboxgroup' => 'start'
|
|
||||||
),
|
|
||||||
|
|
||||||
array(
|
|
||||||
'desc' => __( 'Enable the shipping calculator on the cart page', 'sportspress' ),
|
|
||||||
'id' => 'sportspress_enable_shipping_calc',
|
|
||||||
'default' => 'yes',
|
|
||||||
'type' => 'checkbox',
|
|
||||||
'checkboxgroup' => '',
|
|
||||||
'autoload' => false
|
|
||||||
),
|
|
||||||
|
|
||||||
array(
|
|
||||||
'desc' => __( 'Hide shipping costs until an address is entered', 'sportspress' ),
|
|
||||||
'id' => 'sportspress_shipping_cost_requires_address',
|
|
||||||
'default' => 'no',
|
|
||||||
'type' => 'checkbox',
|
|
||||||
'checkboxgroup' => 'end',
|
|
||||||
'autoload' => false
|
|
||||||
),
|
|
||||||
|
|
||||||
array(
|
|
||||||
'title' => __( 'Shipping Display Mode', 'sportspress' ),
|
|
||||||
'desc' => __( 'This controls how multiple shipping methods are displayed on the frontend.', 'sportspress' ),
|
|
||||||
'id' => 'sportspress_shipping_method_format',
|
|
||||||
'default' => '',
|
|
||||||
'type' => 'radio',
|
|
||||||
'options' => array(
|
|
||||||
'' => __( 'Display shipping methods with "radio" buttons', 'sportspress' ),
|
|
||||||
'select' => __( 'Display shipping methods in a dropdown', 'sportspress' ),
|
|
||||||
),
|
|
||||||
'desc_tip' => true,
|
|
||||||
'autoload' => false
|
|
||||||
),
|
|
||||||
|
|
||||||
array(
|
|
||||||
'title' => __( 'Shipping Destination', 'sportspress' ),
|
|
||||||
'desc' => __( 'Ship to billing address by default', 'sportspress' ),
|
|
||||||
'id' => 'sportspress_ship_to_billing',
|
|
||||||
'default' => 'yes',
|
|
||||||
'type' => 'checkbox',
|
|
||||||
'checkboxgroup' => 'start',
|
|
||||||
'autoload' => false,
|
|
||||||
'show_if_checked' => 'option',
|
|
||||||
),
|
|
||||||
|
|
||||||
array(
|
|
||||||
'desc' => __( 'Only ship to the users billing address', 'sportspress' ),
|
|
||||||
'id' => 'sportspress_ship_to_billing_address_only',
|
|
||||||
'default' => 'no',
|
|
||||||
'type' => 'checkbox',
|
|
||||||
'checkboxgroup' => 'end',
|
|
||||||
'autoload' => false,
|
|
||||||
'show_if_checked' => 'yes',
|
|
||||||
),
|
|
||||||
|
|
||||||
array(
|
|
||||||
'title' => __( 'Restrict shipping to Location(s)', 'sportspress' ),
|
|
||||||
'desc' => sprintf( __( 'Choose which countries you want to ship to, or choose to ship to all <a href="%s">locations you sell to</a>.', 'sportspress' ), admin_url( 'admin.php?page=sp-settings&tab=general' ) ),
|
|
||||||
'id' => 'sportspress_ship_to_countries',
|
|
||||||
'default' => '',
|
|
||||||
'type' => 'select',
|
|
||||||
'class' => 'chosen_select',
|
|
||||||
'desc_tip' => false,
|
|
||||||
'options' => array(
|
|
||||||
'' => __( 'Ship to all countries you sell to', 'sportspress' ),
|
|
||||||
'all' => __( 'Ship to all countries', 'sportspress' ),
|
|
||||||
'specific' => __( 'Ship to specific countries only', 'sportspress' )
|
|
||||||
)
|
|
||||||
),
|
|
||||||
|
|
||||||
array(
|
|
||||||
'title' => __( 'Specific Countries', 'sportspress' ),
|
|
||||||
'desc' => '',
|
|
||||||
'id' => 'sportspress_specific_ship_to_countries',
|
|
||||||
'css' => '',
|
|
||||||
'default' => '',
|
|
||||||
'type' => 'multi_select_countries'
|
|
||||||
),
|
|
||||||
|
|
||||||
array(
|
|
||||||
'type' => 'shipping_methods',
|
|
||||||
),
|
|
||||||
|
|
||||||
array( 'type' => 'sectionend', 'id' => 'shipping_options' ),
|
|
||||||
|
|
||||||
)); // End shipping settings
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Output the settings
|
|
||||||
*/
|
|
||||||
public function output() {
|
|
||||||
global $current_section;
|
|
||||||
|
|
||||||
// Load shipping methods so we can show any global options they may have
|
|
||||||
$shipping_methods = SP()->shipping->load_shipping_methods();
|
|
||||||
|
|
||||||
if ( $current_section ) {
|
|
||||||
foreach ( $shipping_methods as $method ) {
|
|
||||||
if ( strtolower( get_class( $method ) ) == strtolower( $current_section ) && $method->has_settings() ) {
|
|
||||||
$method->admin_options();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$settings = $this->get_settings();
|
|
||||||
|
|
||||||
SP_Admin_Settings::output_fields( $settings );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Output shipping method settings.
|
|
||||||
*
|
|
||||||
* @access public
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function shipping_methods_setting() {
|
|
||||||
$default_shipping_method = esc_attr( get_option('sportspress_default_shipping_method') );
|
|
||||||
?>
|
|
||||||
<tr valign="top">
|
|
||||||
<th scope="row" class="titledesc"><?php _e( 'Shipping Methods', 'sportspress' ) ?></th>
|
|
||||||
<td class="forminp">
|
|
||||||
<table class="sp_shipping widefat" cellspacing="0">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th class="default"><?php _e( 'Default', 'sportspress' ); ?></th>
|
|
||||||
<th class="name"><?php _e( 'Name', 'sportspress' ); ?></th>
|
|
||||||
<th class="id"><?php _e( 'ID', 'sportspress' ); ?></th>
|
|
||||||
<th class="status"><?php _e( 'Status', 'sportspress' ); ?></th>
|
|
||||||
<th class="settings"> </th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tfoot>
|
|
||||||
<tr>
|
|
||||||
<th width="1%" class="default">
|
|
||||||
<input type="radio" name="default_shipping_method" value="" <?php checked( $default_shipping_method, '' ); ?> />
|
|
||||||
</th>
|
|
||||||
<th><?php _e( 'No default', 'sportspress' ); ?></th>
|
|
||||||
<th colspan="3"><span class="description"><?php _e( 'Drag and drop the above shipping methods to control their display order.', 'sportspress' ); ?></span></th>
|
|
||||||
</tr>
|
|
||||||
</tfoot>
|
|
||||||
<tbody>
|
|
||||||
<?php
|
|
||||||
foreach ( SP()->shipping->load_shipping_methods() as $key => $method ) {
|
|
||||||
echo '<tr>
|
|
||||||
<td width="1%" class="default">
|
|
||||||
<input type="radio" name="default_shipping_method" value="' . esc_attr( $method->id ) . '" ' . checked( $default_shipping_method, $method->id, false ) . ' />
|
|
||||||
<input type="hidden" name="method_order[]" value="' . esc_attr( $method->id ) . '" />
|
|
||||||
</td>
|
|
||||||
<td class="name">
|
|
||||||
' . $method->get_title() . '
|
|
||||||
</td>
|
|
||||||
<td class="id">
|
|
||||||
' . $method->id . '
|
|
||||||
</td>
|
|
||||||
<td class="status">';
|
|
||||||
|
|
||||||
if ( $method->enabled == 'yes' )
|
|
||||||
echo '<span class="status-enabled tips" data-tip="' . __ ( 'Enabled', 'sportspress' ) . '">' . __ ( 'Enabled', 'sportspress' ) . '</span>';
|
|
||||||
else
|
|
||||||
echo '-';
|
|
||||||
|
|
||||||
echo '</td>
|
|
||||||
<td class="settings">';
|
|
||||||
|
|
||||||
if ( $method->has_settings ) {
|
|
||||||
echo '<a class="button" href="' . admin_url( 'admin.php?page=sp-settings&tab=shipping§ion=' . strtolower( get_class( $method ) ) ) . '">' . __( 'Settings', 'sportspress' ) . '</a>';
|
|
||||||
}
|
|
||||||
|
|
||||||
echo '</td>
|
|
||||||
</tr>';
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Save settings
|
|
||||||
*/
|
|
||||||
public function save() {
|
|
||||||
global $current_section;
|
|
||||||
|
|
||||||
if ( ! $current_section ) {
|
|
||||||
|
|
||||||
$settings = $this->get_settings();
|
|
||||||
|
|
||||||
SP_Admin_Settings::save_fields( $settings );
|
|
||||||
SP()->shipping->process_admin_options();
|
|
||||||
|
|
||||||
} elseif ( class_exists( $current_section ) ) {
|
|
||||||
|
|
||||||
$current_section_class = new $current_section();
|
|
||||||
|
|
||||||
do_action( 'sportspress_update_options_' . $this->id . '_' . $current_section_class->id );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
endif;
|
|
||||||
|
|
||||||
return new SP_Settings_Shipping();
|
|
||||||
@@ -1,735 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* SportsPress Tax Settings
|
|
||||||
*
|
|
||||||
* @author ThemeBoy
|
|
||||||
* @category Admin
|
|
||||||
* @package SportsPress/Admin
|
|
||||||
* @version 0.7
|
|
||||||
*/
|
|
||||||
|
|
||||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
|
||||||
|
|
||||||
if ( ! class_exists( 'SP_Settings_Tax' ) ) :
|
|
||||||
|
|
||||||
/**
|
|
||||||
* SP_Settings_Tax
|
|
||||||
*/
|
|
||||||
class SP_Settings_Tax extends SP_Settings_Page {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor.
|
|
||||||
*/
|
|
||||||
public function __construct() {
|
|
||||||
$this->id = 'tax';
|
|
||||||
$this->label = __( 'Tax', 'sportspress' );
|
|
||||||
|
|
||||||
add_filter( 'sportspress_settings_tabs_array', array( $this, 'add_settings_page' ), 20 );
|
|
||||||
add_action( 'sportspress_sections_' . $this->id, array( $this, 'output_sections' ) );
|
|
||||||
add_action( 'sportspress_settings_' . $this->id, array( $this, 'output' ) );
|
|
||||||
add_action( 'sportspress_settings_save_' . $this->id, array( $this, 'save' ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get sections
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function get_sections() {
|
|
||||||
$sections = array(
|
|
||||||
'' => __( 'Tax Options', 'sportspress' ),
|
|
||||||
'standard' => __( 'Standard Rates', 'sportspress' )
|
|
||||||
);
|
|
||||||
|
|
||||||
// Get tax classes and display as links
|
|
||||||
$tax_classes = array_filter( array_map( 'trim', explode( "\n", get_option('sportspress_tax_classes' ) ) ) );
|
|
||||||
|
|
||||||
if ( $tax_classes )
|
|
||||||
foreach ( $tax_classes as $class )
|
|
||||||
$sections[ sanitize_title( $class ) ] = sprintf( __( '%s Rates', 'sportspress' ), $class );
|
|
||||||
|
|
||||||
return $sections;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get settings array
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function get_settings() {
|
|
||||||
$tax_classes = array_filter( array_map( 'trim', explode( "\n", get_option( 'sportspress_tax_classes' ) ) ) );
|
|
||||||
$classes_options = array();
|
|
||||||
if ( $tax_classes )
|
|
||||||
foreach ( $tax_classes as $class )
|
|
||||||
$classes_options[ sanitize_title( $class ) ] = esc_html( $class );
|
|
||||||
|
|
||||||
return apply_filters('sportspress_tax_settings', array(
|
|
||||||
|
|
||||||
array( 'title' => __( 'Tax Options', 'sportspress' ), 'type' => 'title','desc' => '', 'id' => 'tax_options' ),
|
|
||||||
|
|
||||||
array(
|
|
||||||
'title' => __( 'Enable Taxes', 'sportspress' ),
|
|
||||||
'desc' => __( 'Enable taxes and tax calculations', 'sportspress' ),
|
|
||||||
'id' => 'sportspress_calc_taxes',
|
|
||||||
'default' => 'no',
|
|
||||||
'type' => 'checkbox'
|
|
||||||
),
|
|
||||||
|
|
||||||
array(
|
|
||||||
'title' => __( 'Prices Entered With Tax', 'sportspress' ),
|
|
||||||
'id' => 'sportspress_prices_include_tax',
|
|
||||||
'default' => 'no',
|
|
||||||
'type' => 'radio',
|
|
||||||
'desc_tip' => __( 'This option is important as it will affect how you input prices. Changing it will not update existing products.', 'sportspress' ),
|
|
||||||
'options' => array(
|
|
||||||
'yes' => __( 'Yes, I will enter prices inclusive of tax', 'sportspress' ),
|
|
||||||
'no' => __( 'No, I will enter prices exclusive of tax', 'sportspress' )
|
|
||||||
),
|
|
||||||
),
|
|
||||||
|
|
||||||
array(
|
|
||||||
'title' => __( 'Calculate Tax Based On:', 'sportspress' ),
|
|
||||||
'id' => 'sportspress_tax_based_on',
|
|
||||||
'desc_tip' => __( 'This option determines which address is used to calculate tax.', 'sportspress' ),
|
|
||||||
'default' => 'shipping',
|
|
||||||
'type' => 'select',
|
|
||||||
'options' => array(
|
|
||||||
'shipping' => __( 'Customer shipping address', 'sportspress' ),
|
|
||||||
'billing' => __( 'Customer billing address', 'sportspress' ),
|
|
||||||
'base' => __( 'Shop base address', 'sportspress' )
|
|
||||||
),
|
|
||||||
),
|
|
||||||
|
|
||||||
array(
|
|
||||||
'title' => __( 'Default Customer Address:', 'sportspress' ),
|
|
||||||
'id' => 'sportspress_default_customer_address',
|
|
||||||
'desc_tip' => __( 'This option determines the customers default address (before they input their own).', 'sportspress' ),
|
|
||||||
'default' => 'base',
|
|
||||||
'type' => 'select',
|
|
||||||
'options' => array(
|
|
||||||
'' => __( 'No address', 'sportspress' ),
|
|
||||||
'base' => __( 'Shop base address', 'sportspress' ),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
|
|
||||||
array(
|
|
||||||
'title' => __( 'Shipping Tax Class:', 'sportspress' ),
|
|
||||||
'desc' => __( 'Optionally control which tax class shipping gets, or leave it so shipping tax is based on the cart items themselves.', 'sportspress' ),
|
|
||||||
'id' => 'sportspress_shipping_tax_class',
|
|
||||||
'css' => 'min-width:150px;',
|
|
||||||
'default' => 'title',
|
|
||||||
'type' => 'select',
|
|
||||||
'options' => array( '' => __( 'Shipping tax class based on cart items', 'sportspress' ), 'standard' => __( 'Standard', 'sportspress' ) ) + $classes_options,
|
|
||||||
'desc_tip' => true,
|
|
||||||
),
|
|
||||||
|
|
||||||
array(
|
|
||||||
'title' => __( 'Rounding', 'sportspress' ),
|
|
||||||
'desc' => __( 'Round tax at subtotal level, instead of rounding per line', 'sportspress' ),
|
|
||||||
'id' => 'sportspress_tax_round_at_subtotal',
|
|
||||||
'default' => 'no',
|
|
||||||
'type' => 'checkbox',
|
|
||||||
),
|
|
||||||
|
|
||||||
array(
|
|
||||||
'title' => __( 'Additional Tax Classes', 'sportspress' ),
|
|
||||||
'desc' => __( 'List additonal tax classes below (1 per line). This is in addition to the default <code>Standard Rate</code>. Tax classes can be assigned to products.', 'sportspress' ),
|
|
||||||
'id' => 'sportspress_tax_classes',
|
|
||||||
'css' => 'width:100%; height: 65px;',
|
|
||||||
'type' => 'textarea',
|
|
||||||
'default' => sprintf( __( 'Reduced Rate%sZero Rate', 'sportspress' ), PHP_EOL )
|
|
||||||
),
|
|
||||||
|
|
||||||
array(
|
|
||||||
'title' => __( 'Display prices in the shop:', 'sportspress' ),
|
|
||||||
'id' => 'sportspress_tax_display_shop',
|
|
||||||
'default' => 'excl',
|
|
||||||
'type' => 'select',
|
|
||||||
'options' => array(
|
|
||||||
'incl' => __( 'Including tax', 'sportspress' ),
|
|
||||||
'excl' => __( 'Excluding tax', 'sportspress' ),
|
|
||||||
)
|
|
||||||
),
|
|
||||||
|
|
||||||
array(
|
|
||||||
'title' => __( 'Price display suffix:', 'sportspress' ),
|
|
||||||
'id' => 'sportspress_price_display_suffix',
|
|
||||||
'default' => '',
|
|
||||||
'type' => 'text',
|
|
||||||
'desc' => __( 'Define text to show after your product prices. This could be, for example, "inc. Vat" to explain your pricing. You can also have prices substituted here using one of the following: <code>{price_including_tax}, {price_excluding_tax}</code>.', 'sportspress' ),
|
|
||||||
),
|
|
||||||
|
|
||||||
array(
|
|
||||||
'title' => __( 'Display prices during cart/checkout:', 'sportspress' ),
|
|
||||||
'id' => 'sportspress_tax_display_cart',
|
|
||||||
'default' => 'excl',
|
|
||||||
'type' => 'select',
|
|
||||||
'options' => array(
|
|
||||||
'incl' => __( 'Including tax', 'sportspress' ),
|
|
||||||
'excl' => __( 'Excluding tax', 'sportspress' ),
|
|
||||||
),
|
|
||||||
'autoload' => false
|
|
||||||
),
|
|
||||||
|
|
||||||
array(
|
|
||||||
'title' => __( 'Display tax totals:', 'sportspress' ),
|
|
||||||
'id' => 'sportspress_tax_total_display',
|
|
||||||
'default' => 'itemized',
|
|
||||||
'type' => 'select',
|
|
||||||
'options' => array(
|
|
||||||
'single' => __( 'As a single total', 'sportspress' ),
|
|
||||||
'itemized' => __( 'Itemized', 'sportspress' ),
|
|
||||||
),
|
|
||||||
'autoload' => false
|
|
||||||
),
|
|
||||||
|
|
||||||
array( 'type' => 'sectionend', 'id' => 'tax_options' ),
|
|
||||||
|
|
||||||
)); // End tax settings
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Output the settings
|
|
||||||
*/
|
|
||||||
public function output() {
|
|
||||||
global $current_section;
|
|
||||||
|
|
||||||
$tax_classes = array_filter( array_map( 'trim', explode( "\n", get_option('sportspress_tax_classes' ) ) ) );
|
|
||||||
|
|
||||||
if ( $current_section == 'standard' || in_array( $current_section, array_map( 'sanitize_title', $tax_classes ) ) ) {
|
|
||||||
$this->output_tax_rates();
|
|
||||||
} else {
|
|
||||||
$settings = $this->get_settings();
|
|
||||||
|
|
||||||
SP_Admin_Settings::output_fields( $settings );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Save settings
|
|
||||||
*/
|
|
||||||
public function save() {
|
|
||||||
global $current_section, $wpdb;
|
|
||||||
|
|
||||||
if ( ! $current_section ) {
|
|
||||||
|
|
||||||
$settings = $this->get_settings();
|
|
||||||
SP_Admin_Settings::save_fields( $settings );
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
$this->save_tax_rates();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
$wpdb->query( "DELETE FROM `$wpdb->options` WHERE `option_name` LIKE ('_transient_sp_tax_rates_%') OR `option_name` LIKE ('_transient_timeout_sp_tax_rates_%')" );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Output tax rate tables
|
|
||||||
*/
|
|
||||||
public function output_tax_rates() {
|
|
||||||
global $sportspress, $current_section, $wpdb;
|
|
||||||
|
|
||||||
$page = ! empty( $_GET['p'] ) ? absint( $_GET['p'] ) : 1;
|
|
||||||
$limit = 100;
|
|
||||||
$tax_classes = array_filter( array_map( 'trim', explode( "\n", get_option('sportspress_tax_classes' ) ) ) );
|
|
||||||
$current_class = '';
|
|
||||||
|
|
||||||
foreach( $tax_classes as $class )
|
|
||||||
if ( sanitize_title( $class ) == $current_section )
|
|
||||||
$current_class = $class;
|
|
||||||
?>
|
|
||||||
<h3><?php printf( __( 'Tax Rates for the "%s" Class', 'sportspress' ), $current_class ? esc_html( $current_class ) : __( 'Standard', 'sportspress' ) ); ?></h3>
|
|
||||||
<p><?php printf( __( 'Define tax rates for countries and states below. <a href="%s">See here</a> for available alpha-2 country codes.', 'sportspress' ), 'http://en.wikipedia.org/wiki/ISO_3166-1#Current_codes' ); ?></p>
|
|
||||||
<table class="sp_tax_rates sp_input_table sortable widefat">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th class="sort"> </th>
|
|
||||||
|
|
||||||
<th width="8%"><?php _e( 'Country Code', 'sportspress' ); ?> <span class="tips" data-tip="<?php _e('A 2 digit country code, e.g. US. Leave blank to apply to all.', 'sportspress'); ?>">[?]</span></th>
|
|
||||||
|
|
||||||
<th width="8%"><?php _e( 'State Code', 'sportspress' ); ?> <span class="tips" data-tip="<?php _e('A 2 digit state code, e.g. AL. Leave blank to apply to all.', 'sportspress'); ?>">[?]</span></th>
|
|
||||||
|
|
||||||
<th><?php _e( 'ZIP/Postcode', 'sportspress' ); ?> <span class="tips" data-tip="<?php _e('Postcode for this rule. Semi-colon (;) separate multiple values. Leave blank to apply to all areas. Wildcards (*) can be used. Ranges for numeric postcodes (e.g. 12345-12350) will be expanded into individual postcodes.', 'sportspress'); ?>">[?]</span></th>
|
|
||||||
|
|
||||||
<th><?php _e( 'City', 'sportspress' ); ?> <span class="tips" data-tip="<?php _e('Cities for this rule. Semi-colon (;) separate multiple values. Leave blank to apply to all cities.', 'sportspress'); ?>">[?]</span></th>
|
|
||||||
|
|
||||||
<th width="8%"><?php _e( 'Rate %', 'sportspress' ); ?> <span class="tips" data-tip="<?php _e( 'Enter a tax rate (percentage) to 4 decimal places.', 'sportspress' ); ?>">[?]</span></th>
|
|
||||||
|
|
||||||
<th width="8%"><?php _e( 'Tax Name', 'sportspress' ); ?> <span class="tips" data-tip="<?php _e('Enter a name for this tax rate.', 'sportspress'); ?>">[?]</span></th>
|
|
||||||
|
|
||||||
<th width="8%"><?php _e( 'Priority', 'sportspress' ); ?> <span class="tips" data-tip="<?php _e('Choose a priority for this tax rate. Only 1 matching rate per priority will be used. To define multiple tax rates for a single area you need to specify a different priority per rate.', 'sportspress'); ?>">[?]</span></th>
|
|
||||||
|
|
||||||
<th width="8%"><?php _e( 'Compound', 'sportspress' ); ?> <span class="tips" data-tip="<?php _e('Choose whether or not this is a compound rate. Compound tax rates are applied on top of other tax rates.', 'sportspress'); ?>">[?]</span></th>
|
|
||||||
|
|
||||||
<th width="8%"><?php _e( 'Shipping', 'sportspress' ); ?> <span class="tips" data-tip="<?php _e('Choose whether or not this tax rate also gets applied to shipping.', 'sportspress'); ?>">[?]</span></th>
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tfoot>
|
|
||||||
<tr>
|
|
||||||
<th colspan="10">
|
|
||||||
<a href="#" class="button plus insert"><?php _e( 'Insert row', 'sportspress' ); ?></a>
|
|
||||||
<a href="#" class="button minus remove_tax_rates"><?php _e( 'Remove selected row(s)', 'sportspress' ); ?></a>
|
|
||||||
|
|
||||||
<div class="pagination">
|
|
||||||
<?php
|
|
||||||
echo str_replace( 'page-numbers', 'page-numbers button', paginate_links( array(
|
|
||||||
'base' => add_query_arg( 'p', '%#%' ),
|
|
||||||
'type' => 'plain',
|
|
||||||
'prev_text' => '«',
|
|
||||||
'next_text' => '»',
|
|
||||||
'total' => ceil( absint( $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(tax_rate_id) FROM {$wpdb->prefix}sportspress_tax_rates WHERE tax_rate_class = %s;", sanitize_title( $current_class ) ) ) ) / $limit ),
|
|
||||||
'current' => $page
|
|
||||||
) ) );
|
|
||||||
?>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<a href="#" download="tax_rates.csv" class="button export"><?php _e( 'Export CSV', 'sportspress' ); ?></a>
|
|
||||||
<a href="<?php echo admin_url( 'admin.php?import=sportspress_tax_rate_csv' ); ?>" class="button import"><?php _e( 'Import CSV', 'sportspress' ); ?></a>
|
|
||||||
</th>
|
|
||||||
</tr>
|
|
||||||
</tfoot>
|
|
||||||
<tbody id="rates">
|
|
||||||
<?php
|
|
||||||
$rates = $wpdb->get_results( $wpdb->prepare(
|
|
||||||
"SELECT * FROM {$wpdb->prefix}sportspress_tax_rates
|
|
||||||
WHERE tax_rate_class = %s
|
|
||||||
ORDER BY tax_rate_order
|
|
||||||
LIMIT %d, %d
|
|
||||||
" ,
|
|
||||||
sanitize_title( $current_class ),
|
|
||||||
( $page - 1 ) * $limit,
|
|
||||||
$limit
|
|
||||||
) );
|
|
||||||
|
|
||||||
foreach ( $rates as $rate ) {
|
|
||||||
?>
|
|
||||||
<tr>
|
|
||||||
<td class="sort"><input type="hidden" class="remove_tax_rate" name="remove_tax_rate[<?php echo $rate->tax_rate_id ?>]" value="0" /></td>
|
|
||||||
|
|
||||||
<td class="country" width="8%">
|
|
||||||
<input type="text" value="<?php echo esc_attr( $rate->tax_rate_country ) ?>" placeholder="*" name="tax_rate_country[<?php echo $rate->tax_rate_id ?>]" />
|
|
||||||
</td>
|
|
||||||
|
|
||||||
<td class="state" width="8%">
|
|
||||||
<input type="text" value="<?php echo esc_attr( $rate->tax_rate_state ) ?>" placeholder="*" name="tax_rate_state[<?php echo $rate->tax_rate_id ?>]" />
|
|
||||||
</td>
|
|
||||||
|
|
||||||
<td class="postcode">
|
|
||||||
<input type="text" value="<?php
|
|
||||||
$locations = $wpdb->get_col( $wpdb->prepare( "SELECT location_code FROM {$wpdb->prefix}sportspress_tax_rate_locations WHERE location_type='postcode' AND tax_rate_id = %d ORDER BY location_code", $rate->tax_rate_id ) );
|
|
||||||
|
|
||||||
echo esc_attr( implode( '; ', $locations ) );
|
|
||||||
?>" placeholder="*" data-name="tax_rate_postcode[<?php echo $rate->tax_rate_id ?>]" />
|
|
||||||
</td>
|
|
||||||
|
|
||||||
<td class="city">
|
|
||||||
<input type="text" value="<?php
|
|
||||||
$locations = $wpdb->get_col( $wpdb->prepare( "SELECT location_code FROM {$wpdb->prefix}sportspress_tax_rate_locations WHERE location_type='city' AND tax_rate_id = %d ORDER BY location_code", $rate->tax_rate_id ) );
|
|
||||||
echo esc_attr( implode( '; ', $locations ) );
|
|
||||||
?>" placeholder="*" data-name="tax_rate_city[<?php echo $rate->tax_rate_id ?>]" />
|
|
||||||
</td>
|
|
||||||
|
|
||||||
<td class="rate" width="8%">
|
|
||||||
<input type="number" step="any" min="0" value="<?php echo esc_attr( $rate->tax_rate ) ?>" placeholder="0" name="tax_rate[<?php echo $rate->tax_rate_id ?>]" />
|
|
||||||
</td>
|
|
||||||
|
|
||||||
<td class="name" width="8%">
|
|
||||||
<input type="text" value="<?php echo esc_attr( $rate->tax_rate_name ) ?>" name="tax_rate_name[<?php echo $rate->tax_rate_id ?>]" />
|
|
||||||
</td>
|
|
||||||
|
|
||||||
<td class="priority" width="8%">
|
|
||||||
<input type="number" step="1" min="1" value="<?php echo esc_attr( $rate->tax_rate_priority ) ?>" name="tax_rate_priority[<?php echo $rate->tax_rate_id ?>]" />
|
|
||||||
</td>
|
|
||||||
|
|
||||||
<td class="compound" width="8%">
|
|
||||||
<input type="checkbox" class="checkbox" name="tax_rate_compound[<?php echo $rate->tax_rate_id ?>]" <?php checked( $rate->tax_rate_compound, '1' ); ?> />
|
|
||||||
</td>
|
|
||||||
|
|
||||||
<td class="apply_to_shipping" width="8%">
|
|
||||||
<input type="checkbox" class="checkbox" name="tax_rate_shipping[<?php echo $rate->tax_rate_id ?>]" <?php checked($rate->tax_rate_shipping, '1' ); ?> />
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
<script type="text/javascript">
|
|
||||||
jQuery( function() {
|
|
||||||
jQuery('.sp_tax_rates .remove_tax_rates').click(function() {
|
|
||||||
var $tbody = jQuery('.sp_tax_rates').find('tbody');
|
|
||||||
if ( $tbody.find('tr.current').size() > 0 ) {
|
|
||||||
$current = $tbody.find('tr.current');
|
|
||||||
$current.find('input').val('');
|
|
||||||
$current.find('input.remove_tax_rate').val('1');
|
|
||||||
|
|
||||||
$current.each(function(){
|
|
||||||
if ( jQuery(this).is('.new') )
|
|
||||||
jQuery(this).remove();
|
|
||||||
else
|
|
||||||
jQuery(this).hide();
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
alert('<?php echo esc_js( __( 'No row(s) selected', 'sportspress' ) ); ?>');
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
|
|
||||||
jQuery('.sp_tax_rates .export').click(function() {
|
|
||||||
|
|
||||||
var csv_data = "data:application/csv;charset=utf-8,<?php _e( 'Country Code', 'sportspress' ); ?>,<?php _e( 'State Code', 'sportspress' ); ?>,<?php _e( 'ZIP/Postcode', 'sportspress' ); ?>,<?php _e( 'City', 'sportspress' ); ?>,<?php _e( 'Rate %', 'sportspress' ); ?>,<?php _e( 'Tax Name', 'sportspress' ); ?>,<?php _e( 'Priority', 'sportspress' ); ?>,<?php _e( 'Compound', 'sportspress' ); ?>,<?php _e( 'Shipping', 'sportspress' ); ?>,<?php _e( 'Tax Class', 'sportspress' ); ?>\n";
|
|
||||||
|
|
||||||
jQuery('#rates tr:visible').each(function() {
|
|
||||||
var row = '';
|
|
||||||
jQuery(this).find('td:not(.sort) input').each(function() {
|
|
||||||
|
|
||||||
if ( jQuery(this).is('.checkbox') ) {
|
|
||||||
|
|
||||||
if ( jQuery(this).is(':checked') ) {
|
|
||||||
val = 1;
|
|
||||||
} else {
|
|
||||||
val = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
var val = jQuery(this).val();
|
|
||||||
|
|
||||||
if ( ! val )
|
|
||||||
val = jQuery(this).attr('placeholder');
|
|
||||||
}
|
|
||||||
|
|
||||||
row = row + val + ',';
|
|
||||||
});
|
|
||||||
row = row + '<?php echo $current_class; ?>';
|
|
||||||
//row.substring( 0, row.length - 1 );
|
|
||||||
csv_data = csv_data + row + "\n";
|
|
||||||
});
|
|
||||||
|
|
||||||
jQuery(this).attr( 'href', encodeURI( csv_data ) );
|
|
||||||
|
|
||||||
return true;
|
|
||||||
});
|
|
||||||
|
|
||||||
jQuery('.sp_tax_rates .insert').click(function() {
|
|
||||||
var $tbody = jQuery('.sp_tax_rates').find('tbody');
|
|
||||||
var size = $tbody.find('tr').size();
|
|
||||||
var code = '<tr class="new">\
|
|
||||||
<td class="sort"> </td>\
|
|
||||||
<td class="country" width="8%">\
|
|
||||||
<input type="text" placeholder="*" name="tax_rate_country[new][' + size + ']" />\
|
|
||||||
</td>\
|
|
||||||
<td class="state" width="8%">\
|
|
||||||
<input type="text" placeholder="*" name="tax_rate_state[new][' + size + ']" />\
|
|
||||||
</td>\
|
|
||||||
<td class="postcode">\
|
|
||||||
<input type="text" placeholder="*" name="tax_rate_postcode[new][' + size + ']" />\
|
|
||||||
</td>\
|
|
||||||
<td class="city">\
|
|
||||||
<input type="text" placeholder="*" name="tax_rate_city[new][' + size + ']" />\
|
|
||||||
</td>\
|
|
||||||
<td class="rate" width="8%">\
|
|
||||||
<input type="number" step="any" min="0" placeholder="0" name="tax_rate[new][' + size + ']" />\
|
|
||||||
</td>\
|
|
||||||
<td class="name" width="8%">\
|
|
||||||
<input type="text" name="tax_rate_name[new][' + size + ']" />\
|
|
||||||
</td>\
|
|
||||||
<td class="priority" width="8%">\
|
|
||||||
<input type="number" step="1" min="1" value="1" name="tax_rate_priority[new][' + size + ']" />\
|
|
||||||
</td>\
|
|
||||||
<td class="compound" width="8%">\
|
|
||||||
<input type="checkbox" class="checkbox" name="tax_rate_compound[new][' + size + ']" />\
|
|
||||||
</td>\
|
|
||||||
<td class="apply_to_shipping" width="8%">\
|
|
||||||
<input type="checkbox" class="checkbox" name="tax_rate_shipping[new][' + size + ']" checked="checked" />\
|
|
||||||
</td>\
|
|
||||||
</tr>';
|
|
||||||
|
|
||||||
if ( $tbody.find('tr.current').size() > 0 ) {
|
|
||||||
$tbody.find('tr.current').after( code );
|
|
||||||
} else {
|
|
||||||
$tbody.append( code );
|
|
||||||
}
|
|
||||||
|
|
||||||
jQuery( "td.country input" ).autocomplete({
|
|
||||||
source: availableCountries,
|
|
||||||
minLength: 3
|
|
||||||
});
|
|
||||||
|
|
||||||
jQuery( "td.state input" ).autocomplete({
|
|
||||||
source: availableStates,
|
|
||||||
minLength: 3
|
|
||||||
});
|
|
||||||
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
|
|
||||||
jQuery('.sp_tax_rates td.postcode, .sp_tax_rates td.city').find('input').change(function() {
|
|
||||||
jQuery(this).attr( 'name', jQuery(this).attr( 'data-name' ) );
|
|
||||||
});
|
|
||||||
|
|
||||||
var availableCountries = [<?php
|
|
||||||
$countries = array();
|
|
||||||
foreach ( SP()->countries->get_allowed_countries() as $value => $label )
|
|
||||||
$countries[] = '{ label: "' . $label . '", value: "' . $value . '" }';
|
|
||||||
echo implode( ', ', $countries );
|
|
||||||
?>];
|
|
||||||
|
|
||||||
var availableStates = [<?php
|
|
||||||
$countries = array();
|
|
||||||
foreach ( SP()->countries->get_allowed_country_states() as $value => $label )
|
|
||||||
foreach ( $label as $code => $state )
|
|
||||||
$countries[] = '{ label: "' . $state . '", value: "' . $code . '" }';
|
|
||||||
echo implode( ', ', $countries );
|
|
||||||
?>];
|
|
||||||
|
|
||||||
jQuery( "td.country input" ).autocomplete({
|
|
||||||
source: availableCountries,
|
|
||||||
minLength: 3
|
|
||||||
});
|
|
||||||
|
|
||||||
jQuery( "td.state input" ).autocomplete({
|
|
||||||
source: availableStates,
|
|
||||||
minLength: 3
|
|
||||||
});
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Save tax rates
|
|
||||||
*/
|
|
||||||
public function save_tax_rates() {
|
|
||||||
global $wpdb, $current_section;
|
|
||||||
|
|
||||||
// Get class
|
|
||||||
$tax_classes = array_filter( array_map( 'trim', explode( "\n", get_option('sportspress_tax_classes' ) ) ) );
|
|
||||||
$current_class = '';
|
|
||||||
|
|
||||||
foreach( $tax_classes as $class )
|
|
||||||
if ( sanitize_title( $class ) == $current_section )
|
|
||||||
$current_class = $class;
|
|
||||||
|
|
||||||
// Get POST data
|
|
||||||
$tax_rate_country = isset( $_POST['tax_rate_country'] ) ? $_POST['tax_rate_country'] : array();
|
|
||||||
$tax_rate_state = isset( $_POST['tax_rate_state'] ) ? $_POST['tax_rate_state'] : array();
|
|
||||||
$tax_rate_postcode = isset( $_POST['tax_rate_postcode'] ) ? $_POST['tax_rate_postcode'] : array();
|
|
||||||
$tax_rate_city = isset( $_POST['tax_rate_city'] ) ? $_POST['tax_rate_city'] : array();
|
|
||||||
$tax_rate = isset( $_POST['tax_rate'] ) ? $_POST['tax_rate'] : array();
|
|
||||||
$tax_rate_name = isset( $_POST['tax_rate_name'] ) ? $_POST['tax_rate_name'] : array();
|
|
||||||
$tax_rate_priority = isset( $_POST['tax_rate_priority'] ) ? $_POST['tax_rate_priority'] : array();
|
|
||||||
$tax_rate_compound = isset( $_POST['tax_rate_compound'] ) ? $_POST['tax_rate_compound'] : array();
|
|
||||||
$tax_rate_shipping = isset( $_POST['tax_rate_shipping'] ) ? $_POST['tax_rate_shipping'] : array();
|
|
||||||
|
|
||||||
$i = 0;
|
|
||||||
|
|
||||||
// Loop posted fields
|
|
||||||
foreach ( $tax_rate_country as $key => $value ) {
|
|
||||||
|
|
||||||
// new keys are inserted...
|
|
||||||
if ( $key == 'new' ) {
|
|
||||||
|
|
||||||
foreach ( $value as $new_key => $new_value ) {
|
|
||||||
|
|
||||||
// Sanitize + format
|
|
||||||
$country = strtoupper( sanitize_text_field( $tax_rate_country[ $key ][ $new_key ] ) );
|
|
||||||
$state = strtoupper( sanitize_text_field( $tax_rate_state[ $key ][ $new_key ] ) );
|
|
||||||
$postcode = sanitize_text_field( $tax_rate_postcode[ $key ][ $new_key ] );
|
|
||||||
$city = sanitize_text_field( $tax_rate_city[ $key ][ $new_key ] );
|
|
||||||
$rate = number_format( sanitize_text_field( $tax_rate[ $key ][ $new_key ] ), 4, '.', '' );
|
|
||||||
$name = sanitize_text_field( $tax_rate_name[ $key ][ $new_key ] );
|
|
||||||
$priority = absint( sanitize_text_field( $tax_rate_priority[ $key ][ $new_key ] ) );
|
|
||||||
$compound = isset( $tax_rate_compound[ $key ][ $new_key ] ) ? 1 : 0;
|
|
||||||
$shipping = isset( $tax_rate_shipping[ $key ][ $new_key ] ) ? 1 : 0;
|
|
||||||
|
|
||||||
if ( ! $name )
|
|
||||||
$name = __( 'Tax', 'sportspress' );
|
|
||||||
|
|
||||||
if ( $country == '*' )
|
|
||||||
$country = '';
|
|
||||||
|
|
||||||
if ( $state == '*' )
|
|
||||||
$state = '';
|
|
||||||
|
|
||||||
$wpdb->insert(
|
|
||||||
$wpdb->prefix . "sportspress_tax_rates",
|
|
||||||
array(
|
|
||||||
'tax_rate_country' => $country,
|
|
||||||
'tax_rate_state' => $state,
|
|
||||||
'tax_rate' => $rate,
|
|
||||||
'tax_rate_name' => $name,
|
|
||||||
'tax_rate_priority' => $priority,
|
|
||||||
'tax_rate_compound' => $compound,
|
|
||||||
'tax_rate_shipping' => $shipping,
|
|
||||||
'tax_rate_order' => $i,
|
|
||||||
'tax_rate_class' => sanitize_title( $current_class )
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
$tax_rate_id = $wpdb->insert_id;
|
|
||||||
|
|
||||||
if ( ! empty( $postcode ) ) {
|
|
||||||
$postcodes = explode( ';', $postcode );
|
|
||||||
$postcodes = array_map( 'strtoupper', array_map( 'sanitize_text_field', $postcodes ) );
|
|
||||||
|
|
||||||
$postcode_query = array();
|
|
||||||
|
|
||||||
foreach( $postcodes as $postcode )
|
|
||||||
if ( strstr( $postcode, '-' ) ) {
|
|
||||||
$postcode_parts = explode( '-', $postcode );
|
|
||||||
|
|
||||||
if ( is_numeric( $postcode_parts[0] ) && is_numeric( $postcode_parts[1] ) && $postcode_parts[1] > $postcode_parts[0] ) {
|
|
||||||
for ( $i = $postcode_parts[0]; $i <= $postcode_parts[1]; $i ++ ) {
|
|
||||||
if ( ! $i )
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if ( strlen( $i ) < strlen( $postcode_parts[0] ) )
|
|
||||||
$i = str_pad( $i, strlen( $postcode_parts[0] ), "0", STR_PAD_LEFT );
|
|
||||||
|
|
||||||
$postcode_query[] = "( '" . esc_sql( $i ) . "', $tax_rate_id, 'postcode' )";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if ( $postcode )
|
|
||||||
$postcode_query[] = "( '" . esc_sql( $postcode ) . "', $tax_rate_id, 'postcode' )";
|
|
||||||
}
|
|
||||||
|
|
||||||
$wpdb->query( "INSERT INTO {$wpdb->prefix}sportspress_tax_rate_locations ( location_code, tax_rate_id, location_type ) VALUES " . implode( ',', $postcode_query ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( ! empty( $city ) ) {
|
|
||||||
$cities = explode( ';', $city );
|
|
||||||
$cities = array_map( 'strtoupper', array_map( 'sanitize_text_field', $cities ) );
|
|
||||||
foreach( $cities as $city ) {
|
|
||||||
$wpdb->insert(
|
|
||||||
$wpdb->prefix . "sportspress_tax_rate_locations",
|
|
||||||
array(
|
|
||||||
'location_code' => $city,
|
|
||||||
'tax_rate_id' => $tax_rate_id,
|
|
||||||
'location_type' => 'city',
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$i++;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ...whereas the others are updated
|
|
||||||
} else {
|
|
||||||
|
|
||||||
$tax_rate_id = absint( $key );
|
|
||||||
|
|
||||||
if ( $_POST['remove_tax_rate'][ $key ] == 1 ) {
|
|
||||||
$wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}sportspress_tax_rate_locations WHERE tax_rate_id = %d;", $tax_rate_id ) );
|
|
||||||
$wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}sportspress_tax_rates WHERE tax_rate_id = %d;", $tax_rate_id ) );
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Sanitize + format
|
|
||||||
$country = strtoupper( sanitize_text_field( $tax_rate_country[ $key ] ) );
|
|
||||||
$state = strtoupper( sanitize_text_field( $tax_rate_state[ $key ] ) );
|
|
||||||
$rate = number_format( (double) sanitize_text_field( $tax_rate[ $key ] ), 4, '.', '' );
|
|
||||||
$name = sanitize_text_field( $tax_rate_name[ $key ] );
|
|
||||||
$priority = absint( sanitize_text_field( $tax_rate_priority[ $key ] ) );
|
|
||||||
$compound = isset( $tax_rate_compound[ $key ] ) ? 1 : 0;
|
|
||||||
$shipping = isset( $tax_rate_shipping[ $key ] ) ? 1 : 0;
|
|
||||||
|
|
||||||
if ( ! $name )
|
|
||||||
$name = __( 'Tax', 'sportspress' );
|
|
||||||
|
|
||||||
if ( $country == '*' )
|
|
||||||
$country = '';
|
|
||||||
|
|
||||||
if ( $state == '*' )
|
|
||||||
$state = '';
|
|
||||||
|
|
||||||
$wpdb->update(
|
|
||||||
$wpdb->prefix . "sportspress_tax_rates",
|
|
||||||
array(
|
|
||||||
'tax_rate_country' => $country,
|
|
||||||
'tax_rate_state' => $state,
|
|
||||||
'tax_rate' => $rate,
|
|
||||||
'tax_rate_name' => $name,
|
|
||||||
'tax_rate_priority' => $priority,
|
|
||||||
'tax_rate_compound' => $compound,
|
|
||||||
'tax_rate_shipping' => $shipping,
|
|
||||||
'tax_rate_order' => $i,
|
|
||||||
'tax_rate_class' => sanitize_title( $current_class )
|
|
||||||
),
|
|
||||||
array(
|
|
||||||
'tax_rate_id' => $tax_rate_id
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
if ( isset( $tax_rate_postcode[ $key ] ) ) {
|
|
||||||
// Delete old
|
|
||||||
$wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}sportspress_tax_rate_locations WHERE tax_rate_id = %d AND location_type = 'postcode';", $tax_rate_id ) );
|
|
||||||
|
|
||||||
// Add changed
|
|
||||||
$postcode = sanitize_text_field( $tax_rate_postcode[ $key ] );
|
|
||||||
$postcodes = explode( ';', $postcode );
|
|
||||||
$postcodes = array_map( 'strtoupper', array_map( 'sanitize_text_field', $postcodes ) );
|
|
||||||
|
|
||||||
$postcode_query = array();
|
|
||||||
|
|
||||||
foreach( $postcodes as $postcode )
|
|
||||||
if ( strstr( $postcode, '-' ) ) {
|
|
||||||
$postcode_parts = explode( '-', $postcode );
|
|
||||||
|
|
||||||
if ( is_numeric( $postcode_parts[0] ) && is_numeric( $postcode_parts[1] ) && $postcode_parts[1] > $postcode_parts[0] ) {
|
|
||||||
for ( $i = $postcode_parts[0]; $i <= $postcode_parts[1]; $i ++ ) {
|
|
||||||
if ( ! $i )
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if ( strlen( $i ) < strlen( $postcode_parts[0] ) )
|
|
||||||
$i = str_pad( $i, strlen( $postcode_parts[0] ), "0", STR_PAD_LEFT );
|
|
||||||
|
|
||||||
$postcode_query[] = "( '" . esc_sql( $i ) . "', $tax_rate_id, 'postcode' )";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if ( $postcode )
|
|
||||||
$postcode_query[] = "( '" . esc_sql( $postcode ) . "', $tax_rate_id, 'postcode' )";
|
|
||||||
}
|
|
||||||
|
|
||||||
$wpdb->query( "INSERT INTO {$wpdb->prefix}sportspress_tax_rate_locations ( location_code, tax_rate_id, location_type ) VALUES " . implode( ',', $postcode_query ) );
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( isset( $tax_rate_city[ $key ] ) ) {
|
|
||||||
// Delete old
|
|
||||||
$wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}sportspress_tax_rate_locations WHERE tax_rate_id = %d AND location_type = 'city';", $tax_rate_id ) );
|
|
||||||
|
|
||||||
// Add changed
|
|
||||||
$city = sanitize_text_field( $tax_rate_city[ $key ] );
|
|
||||||
$cities = explode( ';', $city );
|
|
||||||
$cities = array_map( 'strtoupper', array_map( 'sanitize_text_field', $cities ) );
|
|
||||||
foreach( $cities as $city ) {
|
|
||||||
if ( $city ) {
|
|
||||||
$wpdb->insert(
|
|
||||||
$wpdb->prefix . "sportspress_tax_rate_locations",
|
|
||||||
array(
|
|
||||||
'location_code' => $city,
|
|
||||||
'tax_rate_id' => $tax_rate_id,
|
|
||||||
'location_type' => 'city',
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$i++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
endif;
|
|
||||||
|
|
||||||
return new SP_Settings_Tax();
|
|
||||||
@@ -18,7 +18,7 @@ if ( ! class_exists( 'SP_Settings_Teams' ) ) :
|
|||||||
class SP_Settings_Teams extends SP_Settings_Page {
|
class SP_Settings_Teams extends SP_Settings_Page {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor
|
||||||
*/
|
*/
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
$this->id = 'teams';
|
$this->id = 'teams';
|
||||||
@@ -35,749 +35,50 @@ class SP_Settings_Teams extends SP_Settings_Page {
|
|||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function get_settings() {
|
public function get_settings() {
|
||||||
$tax_classes = array_filter( array_map( 'trim', explode( "\n", get_option( 'sportspress_tax_classes' ) ) ) );
|
|
||||||
$classes_options = array();
|
|
||||||
if ( $tax_classes )
|
|
||||||
foreach ( $tax_classes as $class )
|
|
||||||
$classes_options[ sanitize_title( $class ) ] = esc_html( $class );
|
|
||||||
|
|
||||||
return apply_filters('sportspress_event_settings', array(
|
$settings = array(
|
||||||
|
|
||||||
array( 'title' => __( 'Team Options', 'sportspress' ), 'type' => 'title','desc' => '', 'id' => 'tax_options' ),
|
|
||||||
|
|
||||||
|
array( 'title' => __( 'Team Options', 'sportspress' ), 'type' => 'title','desc' => '', 'id' => 'team_options' ),
|
||||||
|
|
||||||
array(
|
array(
|
||||||
'title' => __( 'Enable Teams', 'sportspress' ),
|
'title' => __( 'League Tables', 'sportspress' ),
|
||||||
'desc' => __( 'Enable taxes and tax calculations', 'sportspress' ),
|
'desc' => __( 'Display logos', 'sportspress' ),
|
||||||
'id' => 'sportspress_calc_taxes',
|
'id' => 'sportspress_table_show_logos',
|
||||||
'default' => 'no',
|
'default' => 'yes',
|
||||||
'type' => 'checkbox'
|
'type' => 'checkbox',
|
||||||
|
'checkboxgroup' => 'start',
|
||||||
),
|
),
|
||||||
|
|
||||||
array(
|
array(
|
||||||
'title' => __( 'Prices Entered With Tax', 'sportspress' ),
|
'desc' => __( 'Link teams', 'sportspress' ),
|
||||||
'id' => 'sportspress_prices_include_tax',
|
'id' => 'sportspress_table_link_teams',
|
||||||
'default' => 'no',
|
|
||||||
'type' => 'radio',
|
|
||||||
'options' => array(
|
|
||||||
'vs' => sprintf( '%s vs %s', __( 'Team', 'sportspress' ), __( 'Team', 'sportspress' ) ),
|
|
||||||
'v' => sprintf( '%s v %s', __( 'Team', 'sportspress' ), __( 'Team', 'sportspress' ) ),
|
|
||||||
'—' => sprintf( '%s — %s', __( 'Team', 'sportspress' ), __( 'Team', 'sportspress' ) ),
|
|
||||||
'/' => sprintf( '%s / %s', __( 'Team', 'sportspress' ), __( 'Team', 'sportspress' ) )
|
|
||||||
),
|
|
||||||
),
|
|
||||||
|
|
||||||
array(
|
|
||||||
'title' => __( 'Calculate Tax Based On:', 'sportspress' ),
|
|
||||||
'id' => 'sportspress_tax_based_on',
|
|
||||||
'desc_tip' => __( 'This option determines which address is used to calculate tax.', 'sportspress' ),
|
|
||||||
'default' => 'shipping',
|
|
||||||
'type' => 'select',
|
|
||||||
'options' => array(
|
|
||||||
'shipping' => __( 'Customer shipping address', 'sportspress' ),
|
|
||||||
'billing' => __( 'Customer billing address', 'sportspress' ),
|
|
||||||
'base' => __( 'Shop base address', 'sportspress' )
|
|
||||||
),
|
|
||||||
),
|
|
||||||
|
|
||||||
array(
|
|
||||||
'title' => __( 'Default Customer Address:', 'sportspress' ),
|
|
||||||
'id' => 'sportspress_default_customer_address',
|
|
||||||
'desc_tip' => __( 'This option determines the customers default address (before they input their own).', 'sportspress' ),
|
|
||||||
'default' => 'base',
|
|
||||||
'type' => 'select',
|
|
||||||
'options' => array(
|
|
||||||
'' => __( 'No address', 'sportspress' ),
|
|
||||||
'base' => __( 'Shop base address', 'sportspress' ),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
|
|
||||||
array(
|
|
||||||
'title' => __( 'Shipping Tax Class:', 'sportspress' ),
|
|
||||||
'desc' => __( 'Optionally control which tax class shipping gets, or leave it so shipping tax is based on the cart items themselves.', 'sportspress' ),
|
|
||||||
'id' => 'sportspress_shipping_tax_class',
|
|
||||||
'css' => 'min-width:150px;',
|
|
||||||
'default' => 'title',
|
|
||||||
'type' => 'select',
|
|
||||||
'options' => array( '' => __( 'Shipping tax class based on cart items', 'sportspress' ), 'standard' => __( 'Standard', 'sportspress' ) ) + $classes_options,
|
|
||||||
'desc_tip' => true,
|
|
||||||
),
|
|
||||||
|
|
||||||
array(
|
|
||||||
'title' => __( 'Rounding', 'sportspress' ),
|
|
||||||
'desc' => __( 'Round tax at subtotal level, instead of rounding per line', 'sportspress' ),
|
|
||||||
'id' => 'sportspress_tax_round_at_subtotal',
|
|
||||||
'default' => 'no',
|
'default' => 'no',
|
||||||
'type' => 'checkbox',
|
'type' => 'checkbox',
|
||||||
|
'checkboxgroup' => 'end',
|
||||||
),
|
),
|
||||||
|
|
||||||
array(
|
array( 'type' => 'sectionend', 'id' => 'team_options' ),
|
||||||
'title' => __( 'Additional Tax Classes', 'sportspress' ),
|
|
||||||
'desc' => __( 'List additonal tax classes below (1 per line). This is in addition to the default <code>Standard Rate</code>. Tax classes can be assigned to products.', 'sportspress' ),
|
|
||||||
'id' => 'sportspress_tax_classes',
|
|
||||||
'css' => 'width:100%; height: 65px;',
|
|
||||||
'type' => 'textarea',
|
|
||||||
'default' => sprintf( __( 'Reduced Rate%sZero Rate', 'sportspress' ), PHP_EOL )
|
|
||||||
),
|
|
||||||
|
|
||||||
array(
|
array( 'title' => __( 'Text', 'sportspress' ), 'type' => 'title', 'desc' => __( 'The following options affect how words are displayed on the frontend.', 'sportspress' ), 'id' => 'text_options' ),
|
||||||
'title' => __( 'Display prices in the shop:', 'sportspress' ),
|
|
||||||
'id' => 'sportspress_tax_display_shop',
|
|
||||||
'default' => 'excl',
|
|
||||||
'type' => 'select',
|
|
||||||
'options' => array(
|
|
||||||
'incl' => __( 'Including tax', 'sportspress' ),
|
|
||||||
'excl' => __( 'Excluding tax', 'sportspress' ),
|
|
||||||
)
|
|
||||||
),
|
|
||||||
|
|
||||||
array(
|
|
||||||
'title' => __( 'Price display suffix:', 'sportspress' ),
|
|
||||||
'id' => 'sportspress_price_display_suffix',
|
|
||||||
'default' => '',
|
|
||||||
'type' => 'text',
|
|
||||||
'desc' => __( 'Define text to show after your product prices. This could be, for example, "inc. Vat" to explain your pricing. You can also have prices substituted here using one of the following: <code>{price_including_tax}, {price_excluding_tax}</code>.', 'sportspress' ),
|
|
||||||
),
|
|
||||||
|
|
||||||
array(
|
|
||||||
'title' => __( 'Display prices during cart/checkout:', 'sportspress' ),
|
|
||||||
'id' => 'sportspress_tax_display_cart',
|
|
||||||
'default' => 'excl',
|
|
||||||
'type' => 'select',
|
|
||||||
'options' => array(
|
|
||||||
'incl' => __( 'Including tax', 'sportspress' ),
|
|
||||||
'excl' => __( 'Excluding tax', 'sportspress' ),
|
|
||||||
),
|
|
||||||
'autoload' => false
|
|
||||||
),
|
|
||||||
|
|
||||||
array(
|
|
||||||
'title' => __( 'Display tax totals:', 'sportspress' ),
|
|
||||||
'id' => 'sportspress_tax_total_display',
|
|
||||||
'default' => 'itemized',
|
|
||||||
'type' => 'select',
|
|
||||||
'options' => array(
|
|
||||||
'single' => __( 'As a single total', 'sportspress' ),
|
|
||||||
'itemized' => __( 'Itemized', 'sportspress' ),
|
|
||||||
),
|
|
||||||
'autoload' => false
|
|
||||||
),
|
|
||||||
|
|
||||||
array( 'type' => 'results' ),
|
|
||||||
|
|
||||||
array( 'type' => 'sectionend', 'id' => 'event_options' ),
|
|
||||||
|
|
||||||
)); // End event settings
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Output the settings
|
|
||||||
*/
|
|
||||||
public function output() {
|
|
||||||
global $current_section;
|
|
||||||
|
|
||||||
$tax_classes = array_filter( array_map( 'trim', explode( "\n", get_option('sportspress_tax_classes' ) ) ) );
|
|
||||||
|
|
||||||
if ( $current_section == 'standard' || in_array( $current_section, array_map( 'sanitize_title', $tax_classes ) ) ) {
|
|
||||||
$this->output_tax_rates();
|
|
||||||
} else {
|
|
||||||
$settings = $this->get_settings();
|
|
||||||
|
|
||||||
SP_Admin_Settings::output_fields( $settings );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Save settings
|
|
||||||
*/
|
|
||||||
public function save() {
|
|
||||||
global $current_section, $wpdb;
|
|
||||||
|
|
||||||
if ( ! $current_section ) {
|
|
||||||
|
|
||||||
$settings = $this->get_settings();
|
|
||||||
SP_Admin_Settings::save_fields( $settings );
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
$this->save_tax_rates();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
$wpdb->query( "DELETE FROM `$wpdb->options` WHERE `option_name` LIKE ('_transient_sp_tax_rates_%') OR `option_name` LIKE ('_transient_timeout_sp_tax_rates_%')" );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Output tax rate tables
|
|
||||||
*/
|
|
||||||
public function output_tax_rates() {
|
|
||||||
global $sportspress, $current_section, $wpdb;
|
|
||||||
|
|
||||||
$page = ! empty( $_GET['p'] ) ? absint( $_GET['p'] ) : 1;
|
|
||||||
$limit = 100;
|
|
||||||
$tax_classes = array_filter( array_map( 'trim', explode( "\n", get_option('sportspress_tax_classes' ) ) ) );
|
|
||||||
$current_class = '';
|
|
||||||
|
|
||||||
foreach( $tax_classes as $class )
|
|
||||||
if ( sanitize_title( $class ) == $current_section )
|
|
||||||
$current_class = $class;
|
|
||||||
?>
|
|
||||||
<h3><?php printf( __( 'Tax Rates for the "%s" Class', 'sportspress' ), $current_class ? esc_html( $current_class ) : __( 'Standard', 'sportspress' ) ); ?></h3>
|
|
||||||
<p><?php printf( __( 'Define tax rates for countries and states below. <a href="%s">See here</a> for available alpha-2 country codes.', 'sportspress' ), 'http://en.wikipedia.org/wiki/ISO_3166-1#Current_codes' ); ?></p>
|
|
||||||
<table class="sp_tax_rates sp_input_table sortable widefat">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th class="sort"> </th>
|
|
||||||
|
|
||||||
<th width="8%"><?php _e( 'Country Code', 'sportspress' ); ?> <span class="tips" data-tip="<?php _e('A 2 digit country code, e.g. US. Leave blank to apply to all.', 'sportspress'); ?>">[?]</span></th>
|
|
||||||
|
|
||||||
<th width="8%"><?php _e( 'State Code', 'sportspress' ); ?> <span class="tips" data-tip="<?php _e('A 2 digit state code, e.g. AL. Leave blank to apply to all.', 'sportspress'); ?>">[?]</span></th>
|
|
||||||
|
|
||||||
<th><?php _e( 'ZIP/Postcode', 'sportspress' ); ?> <span class="tips" data-tip="<?php _e('Postcode for this rule. Semi-colon (;) separate multiple values. Leave blank to apply to all areas. Wildcards (*) can be used. Ranges for numeric postcodes (e.g. 12345-12350) will be expanded into individual postcodes.', 'sportspress'); ?>">[?]</span></th>
|
|
||||||
|
|
||||||
<th><?php _e( 'City', 'sportspress' ); ?> <span class="tips" data-tip="<?php _e('Cities for this rule. Semi-colon (;) separate multiple values. Leave blank to apply to all cities.', 'sportspress'); ?>">[?]</span></th>
|
|
||||||
|
|
||||||
<th width="8%"><?php _e( 'Rate %', 'sportspress' ); ?> <span class="tips" data-tip="<?php _e( 'Enter a tax rate (percentage) to 4 decimal places.', 'sportspress' ); ?>">[?]</span></th>
|
|
||||||
|
|
||||||
<th width="8%"><?php _e( 'Tax Name', 'sportspress' ); ?> <span class="tips" data-tip="<?php _e('Enter a name for this tax rate.', 'sportspress'); ?>">[?]</span></th>
|
|
||||||
|
|
||||||
<th width="8%"><?php _e( 'Priority', 'sportspress' ); ?> <span class="tips" data-tip="<?php _e('Choose a priority for this tax rate. Only 1 matching rate per priority will be used. To define multiple tax rates for a single area you need to specify a different priority per rate.', 'sportspress'); ?>">[?]</span></th>
|
|
||||||
|
|
||||||
<th width="8%"><?php _e( 'Compound', 'sportspress' ); ?> <span class="tips" data-tip="<?php _e('Choose whether or not this is a compound rate. Compound tax rates are applied on top of other tax rates.', 'sportspress'); ?>">[?]</span></th>
|
|
||||||
|
|
||||||
<th width="8%"><?php _e( 'Shipping', 'sportspress' ); ?> <span class="tips" data-tip="<?php _e('Choose whether or not this tax rate also gets applied to shipping.', 'sportspress'); ?>">[?]</span></th>
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tfoot>
|
|
||||||
<tr>
|
|
||||||
<th colspan="10">
|
|
||||||
<a href="#" class="button plus insert"><?php _e( 'Insert row', 'sportspress' ); ?></a>
|
|
||||||
<a href="#" class="button minus remove_tax_rates"><?php _e( 'Remove selected row(s)', 'sportspress' ); ?></a>
|
|
||||||
|
|
||||||
<div class="pagination">
|
|
||||||
<?php
|
|
||||||
echo str_replace( 'page-numbers', 'page-numbers button', paginate_links( array(
|
|
||||||
'base' => add_query_arg( 'p', '%#%' ),
|
|
||||||
'type' => 'plain',
|
|
||||||
'prev_text' => '«',
|
|
||||||
'next_text' => '»',
|
|
||||||
'total' => ceil( absint( $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(tax_rate_id) FROM {$wpdb->prefix}sportspress_tax_rates WHERE tax_rate_class = %s;", sanitize_title( $current_class ) ) ) ) / $limit ),
|
|
||||||
'current' => $page
|
|
||||||
) ) );
|
|
||||||
?>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<a href="#" download="tax_rates.csv" class="button export"><?php _e( 'Export CSV', 'sportspress' ); ?></a>
|
|
||||||
<a href="<?php echo admin_url( 'admin.php?import=sportspress_tax_rate_csv' ); ?>" class="button import"><?php _e( 'Import CSV', 'sportspress' ); ?></a>
|
|
||||||
</th>
|
|
||||||
</tr>
|
|
||||||
</tfoot>
|
|
||||||
<tbody id="rates">
|
|
||||||
<?php
|
|
||||||
$rates = $wpdb->get_results( $wpdb->prepare(
|
|
||||||
"SELECT * FROM {$wpdb->prefix}sportspress_tax_rates
|
|
||||||
WHERE tax_rate_class = %s
|
|
||||||
ORDER BY tax_rate_order
|
|
||||||
LIMIT %d, %d
|
|
||||||
" ,
|
|
||||||
sanitize_title( $current_class ),
|
|
||||||
( $page - 1 ) * $limit,
|
|
||||||
$limit
|
|
||||||
) );
|
|
||||||
|
|
||||||
foreach ( $rates as $rate ) {
|
|
||||||
?>
|
|
||||||
<tr>
|
|
||||||
<td class="sort"><input type="hidden" class="remove_tax_rate" name="remove_tax_rate[<?php echo $rate->tax_rate_id ?>]" value="0" /></td>
|
|
||||||
|
|
||||||
<td class="country" width="8%">
|
|
||||||
<input type="text" value="<?php echo esc_attr( $rate->tax_rate_country ) ?>" placeholder="*" name="tax_rate_country[<?php echo $rate->tax_rate_id ?>]" />
|
|
||||||
</td>
|
|
||||||
|
|
||||||
<td class="state" width="8%">
|
|
||||||
<input type="text" value="<?php echo esc_attr( $rate->tax_rate_state ) ?>" placeholder="*" name="tax_rate_state[<?php echo $rate->tax_rate_id ?>]" />
|
|
||||||
</td>
|
|
||||||
|
|
||||||
<td class="postcode">
|
|
||||||
<input type="text" value="<?php
|
|
||||||
$locations = $wpdb->get_col( $wpdb->prepare( "SELECT location_code FROM {$wpdb->prefix}sportspress_tax_rate_locations WHERE location_type='postcode' AND tax_rate_id = %d ORDER BY location_code", $rate->tax_rate_id ) );
|
|
||||||
|
|
||||||
echo esc_attr( implode( '; ', $locations ) );
|
|
||||||
?>" placeholder="*" data-name="tax_rate_postcode[<?php echo $rate->tax_rate_id ?>]" />
|
|
||||||
</td>
|
|
||||||
|
|
||||||
<td class="city">
|
|
||||||
<input type="text" value="<?php
|
|
||||||
$locations = $wpdb->get_col( $wpdb->prepare( "SELECT location_code FROM {$wpdb->prefix}sportspress_tax_rate_locations WHERE location_type='city' AND tax_rate_id = %d ORDER BY location_code", $rate->tax_rate_id ) );
|
|
||||||
echo esc_attr( implode( '; ', $locations ) );
|
|
||||||
?>" placeholder="*" data-name="tax_rate_city[<?php echo $rate->tax_rate_id ?>]" />
|
|
||||||
</td>
|
|
||||||
|
|
||||||
<td class="rate" width="8%">
|
|
||||||
<input type="number" step="any" min="0" value="<?php echo esc_attr( $rate->tax_rate ) ?>" placeholder="0" name="tax_rate[<?php echo $rate->tax_rate_id ?>]" />
|
|
||||||
</td>
|
|
||||||
|
|
||||||
<td class="name" width="8%">
|
|
||||||
<input type="text" value="<?php echo esc_attr( $rate->tax_rate_name ) ?>" name="tax_rate_name[<?php echo $rate->tax_rate_id ?>]" />
|
|
||||||
</td>
|
|
||||||
|
|
||||||
<td class="priority" width="8%">
|
|
||||||
<input type="number" step="1" min="1" value="<?php echo esc_attr( $rate->tax_rate_priority ) ?>" name="tax_rate_priority[<?php echo $rate->tax_rate_id ?>]" />
|
|
||||||
</td>
|
|
||||||
|
|
||||||
<td class="compound" width="8%">
|
|
||||||
<input type="checkbox" class="checkbox" name="tax_rate_compound[<?php echo $rate->tax_rate_id ?>]" <?php checked( $rate->tax_rate_compound, '1' ); ?> />
|
|
||||||
</td>
|
|
||||||
|
|
||||||
<td class="apply_to_shipping" width="8%">
|
|
||||||
<input type="checkbox" class="checkbox" name="tax_rate_shipping[<?php echo $rate->tax_rate_id ?>]" <?php checked($rate->tax_rate_shipping, '1' ); ?> />
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
<script type="text/javascript">
|
|
||||||
jQuery( function() {
|
|
||||||
jQuery('.sp_tax_rates .remove_tax_rates').click(function() {
|
|
||||||
var $tbody = jQuery('.sp_tax_rates').find('tbody');
|
|
||||||
if ( $tbody.find('tr.current').size() > 0 ) {
|
|
||||||
$current = $tbody.find('tr.current');
|
|
||||||
$current.find('input').val('');
|
|
||||||
$current.find('input.remove_tax_rate').val('1');
|
|
||||||
|
|
||||||
$current.each(function(){
|
|
||||||
if ( jQuery(this).is('.new') )
|
|
||||||
jQuery(this).remove();
|
|
||||||
else
|
|
||||||
jQuery(this).hide();
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
alert('<?php echo esc_js( __( 'No row(s) selected', 'sportspress' ) ); ?>');
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
|
|
||||||
jQuery('.sp_tax_rates .export').click(function() {
|
|
||||||
|
|
||||||
var csv_data = "data:application/csv;charset=utf-8,<?php _e( 'Country Code', 'sportspress' ); ?>,<?php _e( 'State Code', 'sportspress' ); ?>,<?php _e( 'ZIP/Postcode', 'sportspress' ); ?>,<?php _e( 'City', 'sportspress' ); ?>,<?php _e( 'Rate %', 'sportspress' ); ?>,<?php _e( 'Tax Name', 'sportspress' ); ?>,<?php _e( 'Priority', 'sportspress' ); ?>,<?php _e( 'Compound', 'sportspress' ); ?>,<?php _e( 'Shipping', 'sportspress' ); ?>,<?php _e( 'Tax Class', 'sportspress' ); ?>\n";
|
|
||||||
|
|
||||||
jQuery('#rates tr:visible').each(function() {
|
|
||||||
var row = '';
|
|
||||||
jQuery(this).find('td:not(.sort) input').each(function() {
|
|
||||||
|
|
||||||
if ( jQuery(this).is('.checkbox') ) {
|
|
||||||
|
|
||||||
if ( jQuery(this).is(':checked') ) {
|
|
||||||
val = 1;
|
|
||||||
} else {
|
|
||||||
val = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
var val = jQuery(this).val();
|
|
||||||
|
|
||||||
if ( ! val )
|
|
||||||
val = jQuery(this).attr('placeholder');
|
|
||||||
}
|
|
||||||
|
|
||||||
row = row + val + ',';
|
|
||||||
});
|
|
||||||
row = row + '<?php echo $current_class; ?>';
|
|
||||||
//row.substring( 0, row.length - 1 );
|
|
||||||
csv_data = csv_data + row + "\n";
|
|
||||||
});
|
|
||||||
|
|
||||||
jQuery(this).attr( 'href', encodeURI( csv_data ) );
|
|
||||||
|
|
||||||
return true;
|
|
||||||
});
|
|
||||||
|
|
||||||
jQuery('.sp_tax_rates .insert').click(function() {
|
|
||||||
var $tbody = jQuery('.sp_tax_rates').find('tbody');
|
|
||||||
var size = $tbody.find('tr').size();
|
|
||||||
var code = '<tr class="new">\
|
|
||||||
<td class="sort"> </td>\
|
|
||||||
<td class="country" width="8%">\
|
|
||||||
<input type="text" placeholder="*" name="tax_rate_country[new][' + size + ']" />\
|
|
||||||
</td>\
|
|
||||||
<td class="state" width="8%">\
|
|
||||||
<input type="text" placeholder="*" name="tax_rate_state[new][' + size + ']" />\
|
|
||||||
</td>\
|
|
||||||
<td class="postcode">\
|
|
||||||
<input type="text" placeholder="*" name="tax_rate_postcode[new][' + size + ']" />\
|
|
||||||
</td>\
|
|
||||||
<td class="city">\
|
|
||||||
<input type="text" placeholder="*" name="tax_rate_city[new][' + size + ']" />\
|
|
||||||
</td>\
|
|
||||||
<td class="rate" width="8%">\
|
|
||||||
<input type="number" step="any" min="0" placeholder="0" name="tax_rate[new][' + size + ']" />\
|
|
||||||
</td>\
|
|
||||||
<td class="name" width="8%">\
|
|
||||||
<input type="text" name="tax_rate_name[new][' + size + ']" />\
|
|
||||||
</td>\
|
|
||||||
<td class="priority" width="8%">\
|
|
||||||
<input type="number" step="1" min="1" value="1" name="tax_rate_priority[new][' + size + ']" />\
|
|
||||||
</td>\
|
|
||||||
<td class="compound" width="8%">\
|
|
||||||
<input type="checkbox" class="checkbox" name="tax_rate_compound[new][' + size + ']" />\
|
|
||||||
</td>\
|
|
||||||
<td class="apply_to_shipping" width="8%">\
|
|
||||||
<input type="checkbox" class="checkbox" name="tax_rate_shipping[new][' + size + ']" checked="checked" />\
|
|
||||||
</td>\
|
|
||||||
</tr>';
|
|
||||||
|
|
||||||
if ( $tbody.find('tr.current').size() > 0 ) {
|
|
||||||
$tbody.find('tr.current').after( code );
|
|
||||||
} else {
|
|
||||||
$tbody.append( code );
|
|
||||||
}
|
|
||||||
|
|
||||||
jQuery( "td.country input" ).autocomplete({
|
|
||||||
source: availableCountries,
|
|
||||||
minLength: 3
|
|
||||||
});
|
|
||||||
|
|
||||||
jQuery( "td.state input" ).autocomplete({
|
|
||||||
source: availableStates,
|
|
||||||
minLength: 3
|
|
||||||
});
|
|
||||||
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
|
|
||||||
jQuery('.sp_tax_rates td.postcode, .sp_tax_rates td.city').find('input').change(function() {
|
|
||||||
jQuery(this).attr( 'name', jQuery(this).attr( 'data-name' ) );
|
|
||||||
});
|
|
||||||
|
|
||||||
var availableCountries = [<?php
|
|
||||||
$countries = array();
|
|
||||||
foreach ( SP()->countries->get_allowed_countries() as $value => $label )
|
|
||||||
$countries[] = '{ label: "' . $label . '", value: "' . $value . '" }';
|
|
||||||
echo implode( ', ', $countries );
|
|
||||||
?>];
|
|
||||||
|
|
||||||
var availableStates = [<?php
|
|
||||||
$countries = array();
|
|
||||||
foreach ( SP()->countries->get_allowed_country_states() as $value => $label )
|
|
||||||
foreach ( $label as $code => $state )
|
|
||||||
$countries[] = '{ label: "' . $state . '", value: "' . $code . '" }';
|
|
||||||
echo implode( ', ', $countries );
|
|
||||||
?>];
|
|
||||||
|
|
||||||
jQuery( "td.country input" ).autocomplete({
|
|
||||||
source: availableCountries,
|
|
||||||
minLength: 3
|
|
||||||
});
|
|
||||||
|
|
||||||
jQuery( "td.state input" ).autocomplete({
|
|
||||||
source: availableStates,
|
|
||||||
minLength: 3
|
|
||||||
});
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Save tax rates
|
|
||||||
*/
|
|
||||||
public function save_tax_rates() {
|
|
||||||
global $wpdb, $current_section;
|
|
||||||
|
|
||||||
// Get class
|
|
||||||
$tax_classes = array_filter( array_map( 'trim', explode( "\n", get_option('sportspress_tax_classes' ) ) ) );
|
|
||||||
$current_class = '';
|
|
||||||
|
|
||||||
foreach( $tax_classes as $class )
|
|
||||||
if ( sanitize_title( $class ) == $current_section )
|
|
||||||
$current_class = $class;
|
|
||||||
|
|
||||||
// Get POST data
|
|
||||||
$tax_rate_country = isset( $_POST['tax_rate_country'] ) ? $_POST['tax_rate_country'] : array();
|
|
||||||
$tax_rate_state = isset( $_POST['tax_rate_state'] ) ? $_POST['tax_rate_state'] : array();
|
|
||||||
$tax_rate_postcode = isset( $_POST['tax_rate_postcode'] ) ? $_POST['tax_rate_postcode'] : array();
|
|
||||||
$tax_rate_city = isset( $_POST['tax_rate_city'] ) ? $_POST['tax_rate_city'] : array();
|
|
||||||
$tax_rate = isset( $_POST['tax_rate'] ) ? $_POST['tax_rate'] : array();
|
|
||||||
$tax_rate_name = isset( $_POST['tax_rate_name'] ) ? $_POST['tax_rate_name'] : array();
|
|
||||||
$tax_rate_priority = isset( $_POST['tax_rate_priority'] ) ? $_POST['tax_rate_priority'] : array();
|
|
||||||
$tax_rate_compound = isset( $_POST['tax_rate_compound'] ) ? $_POST['tax_rate_compound'] : array();
|
|
||||||
$tax_rate_shipping = isset( $_POST['tax_rate_shipping'] ) ? $_POST['tax_rate_shipping'] : array();
|
|
||||||
|
|
||||||
$i = 0;
|
|
||||||
|
|
||||||
// Loop posted fields
|
|
||||||
foreach ( $tax_rate_country as $key => $value ) {
|
|
||||||
|
|
||||||
// new keys are inserted...
|
|
||||||
if ( $key == 'new' ) {
|
|
||||||
|
|
||||||
foreach ( $value as $new_key => $new_value ) {
|
|
||||||
|
|
||||||
// Sanitize + format
|
|
||||||
$country = strtoupper( sanitize_text_field( $tax_rate_country[ $key ][ $new_key ] ) );
|
|
||||||
$state = strtoupper( sanitize_text_field( $tax_rate_state[ $key ][ $new_key ] ) );
|
|
||||||
$postcode = sanitize_text_field( $tax_rate_postcode[ $key ][ $new_key ] );
|
|
||||||
$city = sanitize_text_field( $tax_rate_city[ $key ][ $new_key ] );
|
|
||||||
$rate = number_format( sanitize_text_field( $tax_rate[ $key ][ $new_key ] ), 4, '.', '' );
|
|
||||||
$name = sanitize_text_field( $tax_rate_name[ $key ][ $new_key ] );
|
|
||||||
$priority = absint( sanitize_text_field( $tax_rate_priority[ $key ][ $new_key ] ) );
|
|
||||||
$compound = isset( $tax_rate_compound[ $key ][ $new_key ] ) ? 1 : 0;
|
|
||||||
$shipping = isset( $tax_rate_shipping[ $key ][ $new_key ] ) ? 1 : 0;
|
|
||||||
|
|
||||||
if ( ! $name )
|
|
||||||
$name = __( 'Tax', 'sportspress' );
|
|
||||||
|
|
||||||
if ( $country == '*' )
|
|
||||||
$country = '';
|
|
||||||
|
|
||||||
if ( $state == '*' )
|
|
||||||
$state = '';
|
|
||||||
|
|
||||||
$wpdb->insert(
|
|
||||||
$wpdb->prefix . "sportspress_tax_rates",
|
|
||||||
array(
|
|
||||||
'tax_rate_country' => $country,
|
|
||||||
'tax_rate_state' => $state,
|
|
||||||
'tax_rate' => $rate,
|
|
||||||
'tax_rate_name' => $name,
|
|
||||||
'tax_rate_priority' => $priority,
|
|
||||||
'tax_rate_compound' => $compound,
|
|
||||||
'tax_rate_shipping' => $shipping,
|
|
||||||
'tax_rate_order' => $i,
|
|
||||||
'tax_rate_class' => sanitize_title( $current_class )
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
$tax_rate_id = $wpdb->insert_id;
|
|
||||||
|
|
||||||
if ( ! empty( $postcode ) ) {
|
|
||||||
$postcodes = explode( ';', $postcode );
|
|
||||||
$postcodes = array_map( 'strtoupper', array_map( 'sanitize_text_field', $postcodes ) );
|
|
||||||
|
|
||||||
$postcode_query = array();
|
|
||||||
|
|
||||||
foreach( $postcodes as $postcode )
|
|
||||||
if ( strstr( $postcode, '-' ) ) {
|
|
||||||
$postcode_parts = explode( '-', $postcode );
|
|
||||||
|
|
||||||
if ( is_numeric( $postcode_parts[0] ) && is_numeric( $postcode_parts[1] ) && $postcode_parts[1] > $postcode_parts[0] ) {
|
|
||||||
for ( $i = $postcode_parts[0]; $i <= $postcode_parts[1]; $i ++ ) {
|
|
||||||
if ( ! $i )
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if ( strlen( $i ) < strlen( $postcode_parts[0] ) )
|
|
||||||
$i = str_pad( $i, strlen( $postcode_parts[0] ), "0", STR_PAD_LEFT );
|
|
||||||
|
|
||||||
$postcode_query[] = "( '" . esc_sql( $i ) . "', $tax_rate_id, 'postcode' )";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if ( $postcode )
|
|
||||||
$postcode_query[] = "( '" . esc_sql( $postcode ) . "', $tax_rate_id, 'postcode' )";
|
|
||||||
}
|
|
||||||
|
|
||||||
$wpdb->query( "INSERT INTO {$wpdb->prefix}sportspress_tax_rate_locations ( location_code, tax_rate_id, location_type ) VALUES " . implode( ',', $postcode_query ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( ! empty( $city ) ) {
|
|
||||||
$cities = explode( ';', $city );
|
|
||||||
$cities = array_map( 'strtoupper', array_map( 'sanitize_text_field', $cities ) );
|
|
||||||
foreach( $cities as $city ) {
|
|
||||||
$wpdb->insert(
|
|
||||||
$wpdb->prefix . "sportspress_tax_rate_locations",
|
|
||||||
array(
|
|
||||||
'location_code' => $city,
|
|
||||||
'tax_rate_id' => $tax_rate_id,
|
|
||||||
'location_type' => 'city',
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$i++;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ...whereas the others are updated
|
|
||||||
} else {
|
|
||||||
|
|
||||||
$tax_rate_id = absint( $key );
|
|
||||||
|
|
||||||
if ( $_POST['remove_tax_rate'][ $key ] == 1 ) {
|
|
||||||
$wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}sportspress_tax_rate_locations WHERE tax_rate_id = %d;", $tax_rate_id ) );
|
|
||||||
$wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}sportspress_tax_rates WHERE tax_rate_id = %d;", $tax_rate_id ) );
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Sanitize + format
|
|
||||||
$country = strtoupper( sanitize_text_field( $tax_rate_country[ $key ] ) );
|
|
||||||
$state = strtoupper( sanitize_text_field( $tax_rate_state[ $key ] ) );
|
|
||||||
$rate = number_format( (double) sanitize_text_field( $tax_rate[ $key ] ), 4, '.', '' );
|
|
||||||
$name = sanitize_text_field( $tax_rate_name[ $key ] );
|
|
||||||
$priority = absint( sanitize_text_field( $tax_rate_priority[ $key ] ) );
|
|
||||||
$compound = isset( $tax_rate_compound[ $key ] ) ? 1 : 0;
|
|
||||||
$shipping = isset( $tax_rate_shipping[ $key ] ) ? 1 : 0;
|
|
||||||
|
|
||||||
if ( ! $name )
|
|
||||||
$name = __( 'Tax', 'sportspress' );
|
|
||||||
|
|
||||||
if ( $country == '*' )
|
|
||||||
$country = '';
|
|
||||||
|
|
||||||
if ( $state == '*' )
|
|
||||||
$state = '';
|
|
||||||
|
|
||||||
$wpdb->update(
|
|
||||||
$wpdb->prefix . "sportspress_tax_rates",
|
|
||||||
array(
|
|
||||||
'tax_rate_country' => $country,
|
|
||||||
'tax_rate_state' => $state,
|
|
||||||
'tax_rate' => $rate,
|
|
||||||
'tax_rate_name' => $name,
|
|
||||||
'tax_rate_priority' => $priority,
|
|
||||||
'tax_rate_compound' => $compound,
|
|
||||||
'tax_rate_shipping' => $shipping,
|
|
||||||
'tax_rate_order' => $i,
|
|
||||||
'tax_rate_class' => sanitize_title( $current_class )
|
|
||||||
),
|
|
||||||
array(
|
|
||||||
'tax_rate_id' => $tax_rate_id
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
if ( isset( $tax_rate_postcode[ $key ] ) ) {
|
|
||||||
// Delete old
|
|
||||||
$wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}sportspress_tax_rate_locations WHERE tax_rate_id = %d AND location_type = 'postcode';", $tax_rate_id ) );
|
|
||||||
|
|
||||||
// Add changed
|
|
||||||
$postcode = sanitize_text_field( $tax_rate_postcode[ $key ] );
|
|
||||||
$postcodes = explode( ';', $postcode );
|
|
||||||
$postcodes = array_map( 'strtoupper', array_map( 'sanitize_text_field', $postcodes ) );
|
|
||||||
|
|
||||||
$postcode_query = array();
|
|
||||||
|
|
||||||
foreach( $postcodes as $postcode )
|
|
||||||
if ( strstr( $postcode, '-' ) ) {
|
|
||||||
$postcode_parts = explode( '-', $postcode );
|
|
||||||
|
|
||||||
if ( is_numeric( $postcode_parts[0] ) && is_numeric( $postcode_parts[1] ) && $postcode_parts[1] > $postcode_parts[0] ) {
|
|
||||||
for ( $i = $postcode_parts[0]; $i <= $postcode_parts[1]; $i ++ ) {
|
|
||||||
if ( ! $i )
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if ( strlen( $i ) < strlen( $postcode_parts[0] ) )
|
|
||||||
$i = str_pad( $i, strlen( $postcode_parts[0] ), "0", STR_PAD_LEFT );
|
|
||||||
|
|
||||||
$postcode_query[] = "( '" . esc_sql( $i ) . "', $tax_rate_id, 'postcode' )";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if ( $postcode )
|
|
||||||
$postcode_query[] = "( '" . esc_sql( $postcode ) . "', $tax_rate_id, 'postcode' )";
|
|
||||||
}
|
|
||||||
|
|
||||||
$wpdb->query( "INSERT INTO {$wpdb->prefix}sportspress_tax_rate_locations ( location_code, tax_rate_id, location_type ) VALUES " . implode( ',', $postcode_query ) );
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( isset( $tax_rate_city[ $key ] ) ) {
|
|
||||||
// Delete old
|
|
||||||
$wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}sportspress_tax_rate_locations WHERE tax_rate_id = %d AND location_type = 'city';", $tax_rate_id ) );
|
|
||||||
|
|
||||||
// Add changed
|
|
||||||
$city = sanitize_text_field( $tax_rate_city[ $key ] );
|
|
||||||
$cities = explode( ';', $city );
|
|
||||||
$cities = array_map( 'strtoupper', array_map( 'sanitize_text_field', $cities ) );
|
|
||||||
foreach( $cities as $city ) {
|
|
||||||
if ( $city ) {
|
|
||||||
$wpdb->insert(
|
|
||||||
$wpdb->prefix . "sportspress_tax_rate_locations",
|
|
||||||
array(
|
|
||||||
'location_code' => $city,
|
|
||||||
'tax_rate_id' => $tax_rate_id,
|
|
||||||
'location_type' => 'city',
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$i++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Output results settings.
|
|
||||||
*
|
|
||||||
* @access public
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function results_setting() {
|
|
||||||
$main_result = get_option( 'sportspress_main_result', 0 );
|
|
||||||
|
|
||||||
$args = array(
|
|
||||||
'post_type' => 'sp_result',
|
|
||||||
'numberposts' => -1,
|
|
||||||
'posts_per_page' => -1,
|
|
||||||
'orderby' => 'menu_order',
|
|
||||||
'order' => 'ASC'
|
|
||||||
);
|
);
|
||||||
$data = get_posts( $args );
|
|
||||||
?>
|
|
||||||
<tr valign="top">
|
|
||||||
<th scope="row" class="titledesc"><?php _e( 'Results', 'sportspress' ) ?></th>
|
|
||||||
<td class="forminp">
|
|
||||||
<table class="widefat sp-admin-config-table">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th scope="col"><?php _e( 'Primary', 'sportspress' ); ?></th>
|
|
||||||
<th scope="col"><?php _e( 'Label', 'sportspress' ); ?></th>
|
|
||||||
<th scope="col"><?php _e( 'Key', 'sportspress' ); ?></th>
|
|
||||||
<th class="edit"></th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tfoot>
|
|
||||||
<tr>
|
|
||||||
<th class="radio"><input type="radio" id="sportspress_main_result_0" name="main_result" value="0" <?php checked( $main_result, 0 ); ?>></th>
|
|
||||||
<th colspan="3"><label for="main_result_0">
|
|
||||||
<?php
|
|
||||||
if ( sizeof( $data ) > 0 ):
|
|
||||||
$default = end( $data );
|
|
||||||
reset( $data );
|
|
||||||
printf( __( 'Default (%s)', 'sportspress' ), $default->post_title );
|
|
||||||
else:
|
|
||||||
_e( 'Default', 'sportspress' );
|
|
||||||
endif;
|
|
||||||
?>
|
|
||||||
</label></th>
|
|
||||||
</tr>
|
|
||||||
</tfoot>
|
|
||||||
<?php $i = 0; foreach ( $data as $row ): ?>
|
|
||||||
<tr<?php if ( $i % 2 == 0 ) echo ' class="alternate"'; ?>>
|
|
||||||
<td class="radio"><input type="radio" id="main_result_<?php echo $row->post_name; ?>" name="main_result" value="<?php echo $row->post_name; ?>" <?php checked( $main_result, $row->post_name ); ?>></td>
|
|
||||||
<td class="row-title"><label for="sportspress_main_result_<?php echo $row->post_name; ?>"><?php echo $row->post_title; ?></label></td>
|
|
||||||
<td><?php echo $row->post_name; ?>for / <?php echo $row->post_name; ?>against</td>
|
|
||||||
<td class="edit"><a class="button" href="<?php echo get_edit_post_link( $row->ID ); ?>"><?php _e( 'Edit', 'sportspress' ); ?></s></td>
|
|
||||||
</tr>
|
|
||||||
<?php $i++; endforeach; ?>
|
|
||||||
</table>
|
|
||||||
<div class="tablenav bottom">
|
|
||||||
<div class="alignleft actions">
|
|
||||||
<a class="button" id="doaction" href="<?php echo admin_url( 'edit.php?post_type=sp_result' ); ?>"><?php _e( 'View All', 'sportspress' ); ?></a>
|
|
||||||
<a class="button" id="doaction2" href="<?php echo admin_url( 'post-new.php?post_type=sp_result' ); ?>"><?php _e( 'Add New', 'sportspress' ); ?></a>
|
|
||||||
</div>
|
|
||||||
<br class="clear">
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
|
|
||||||
|
foreach ( SP()->text->team as $key => $value ):
|
||||||
|
$settings[] = array(
|
||||||
|
'title' => $value,
|
||||||
|
'id' => 'sportspress_team_' . $key . '_text',
|
||||||
|
'default' => '',
|
||||||
|
'placeholder' => $value,
|
||||||
|
'type' => 'text',
|
||||||
|
);
|
||||||
|
endforeach;
|
||||||
|
|
||||||
|
$settings[] = array( 'type' => 'sectionend', 'id' => 'text_options' );
|
||||||
|
|
||||||
|
return apply_filters( 'sportspress_event_settings', $settings ); // End team settings
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
return new SP_Settings_Teams();
|
return new SP_Settings_Teams();
|
||||||
|
|||||||
@@ -1,83 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* SportsPress Text Settings
|
|
||||||
*
|
|
||||||
* @author ThemeBoy
|
|
||||||
* @category Admin
|
|
||||||
* @package SportsPress/Admin
|
|
||||||
* @version 0.7
|
|
||||||
*/
|
|
||||||
|
|
||||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
|
||||||
|
|
||||||
if ( ! class_exists( 'SP_Settings_Text' ) ) :
|
|
||||||
|
|
||||||
/**
|
|
||||||
* SP_Settings_Text
|
|
||||||
*/
|
|
||||||
class SP_Settings_Text extends SP_Settings_Page {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor.
|
|
||||||
*/
|
|
||||||
public function __construct() {
|
|
||||||
$this->id = 'text';
|
|
||||||
$this->label = __( 'Text', 'sportspress' );
|
|
||||||
|
|
||||||
add_filter( 'sportspress_settings_tabs_array', array( $this, 'add_settings_page' ), 20 );
|
|
||||||
add_action( 'sportspress_settings_' . $this->id, array( $this, 'output' ) );
|
|
||||||
add_action( 'sportspress_settings_save_' . $this->id, array( $this, 'save' ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get settings array
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function get_settings() {
|
|
||||||
$tax_classes = array_filter( array_map( 'trim', explode( "\n", get_option( 'sportspress_tax_classes' ) ) ) );
|
|
||||||
$classes_options = array();
|
|
||||||
if ( $tax_classes )
|
|
||||||
foreach ( $tax_classes as $class )
|
|
||||||
$classes_options[ sanitize_title( $class ) ] = esc_html( $class );
|
|
||||||
|
|
||||||
$settings = array( array( 'title' => __( 'Text Options', 'sportspress' ), 'type' => 'title','desc' => '', 'id' => 'text_options' ) );
|
|
||||||
|
|
||||||
$this->strings =& SP()->text->strings;
|
|
||||||
foreach ( $this->strings as $string ):
|
|
||||||
$settings[] = array(
|
|
||||||
'title' => $string,
|
|
||||||
'id' => 'sportspress_text_' . sanitize_title( $string ),
|
|
||||||
'default' => '',
|
|
||||||
'placeholder' => $string,
|
|
||||||
'type' => 'text',
|
|
||||||
);
|
|
||||||
endforeach;
|
|
||||||
|
|
||||||
$settings[] = array( 'type' => 'sectionend', 'id' => 'text_options' );
|
|
||||||
|
|
||||||
return apply_filters( 'sportspress_event_settings', $settings ); // End text settings
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Output the settings
|
|
||||||
*/
|
|
||||||
public function output() {
|
|
||||||
global $current_section;
|
|
||||||
|
|
||||||
$tax_classes = array_filter( array_map( 'trim', explode( "\n", get_option('sportspress_tax_classes' ) ) ) );
|
|
||||||
|
|
||||||
if ( $current_section == 'standard' || in_array( $current_section, array_map( 'sanitize_title', $tax_classes ) ) ) {
|
|
||||||
$this->output_tax_rates();
|
|
||||||
} else {
|
|
||||||
$settings = $this->get_settings();
|
|
||||||
|
|
||||||
SP_Admin_Settings::output_fields( $settings );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
endif;
|
|
||||||
|
|
||||||
return new SP_Settings_Text();
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
<?php
|
|
||||||
function sportspress_define_globals() {
|
|
||||||
|
|
||||||
// Options
|
|
||||||
global $sportspress_options;
|
|
||||||
|
|
||||||
$sportspress_options = (array)get_option( 'sportspress', array() );
|
|
||||||
|
|
||||||
// Sports
|
|
||||||
global $sportspress_sports;
|
|
||||||
|
|
||||||
include_once dirname( SP_PLUGIN_FILE ) . '/presets/sports/soccer.php';
|
|
||||||
include_once dirname( SP_PLUGIN_FILE ) . '/presets/sports/football.php';
|
|
||||||
include_once dirname( SP_PLUGIN_FILE ) . '/presets/sports/footy.php';
|
|
||||||
include_once dirname( SP_PLUGIN_FILE ) . '/presets/sports/baseball.php';
|
|
||||||
include_once dirname( SP_PLUGIN_FILE ) . '/presets/sports/basketball.php';
|
|
||||||
include_once dirname( SP_PLUGIN_FILE ) . '/presets/sports/gaming.php';
|
|
||||||
include_once dirname( SP_PLUGIN_FILE ) . '/presets/sports/cricket.php';
|
|
||||||
include_once dirname( SP_PLUGIN_FILE ) . '/presets/sports/golf.php';
|
|
||||||
include_once dirname( SP_PLUGIN_FILE ) . '/presets/sports/handball.php';
|
|
||||||
include_once dirname( SP_PLUGIN_FILE ) . '/presets/sports/hockey.php';
|
|
||||||
include_once dirname( SP_PLUGIN_FILE ) . '/presets/sports/racing.php';
|
|
||||||
include_once dirname( SP_PLUGIN_FILE ) . '/presets/sports/rugby.php';
|
|
||||||
include_once dirname( SP_PLUGIN_FILE ) . '/presets/sports/swimming.php';
|
|
||||||
include_once dirname( SP_PLUGIN_FILE ) . '/presets/sports/tennis.php';
|
|
||||||
include_once dirname( SP_PLUGIN_FILE ) . '/presets/sports/volleyball.php';
|
|
||||||
|
|
||||||
uasort( $sportspress_sports, 'sportspress_sort_sports' );
|
|
||||||
}
|
|
||||||
add_action( 'init', 'sportspress_define_globals' );
|
|
||||||
@@ -1,194 +0,0 @@
|
|||||||
<?php
|
|
||||||
class SportsPressEventSettingsPage {
|
|
||||||
public function __construct() {
|
|
||||||
global $sportspress_options;
|
|
||||||
$this->options =& $sportspress_options;
|
|
||||||
add_action( 'admin_init', array( $this, 'page_init' ), 1 );
|
|
||||||
}
|
|
||||||
|
|
||||||
function page_init() {
|
|
||||||
register_setting(
|
|
||||||
'sportspress_events',
|
|
||||||
'sportspress',
|
|
||||||
'sportspress_options_validate'
|
|
||||||
);
|
|
||||||
|
|
||||||
add_settings_section(
|
|
||||||
'event',
|
|
||||||
__( 'Events', 'sportspress' ),
|
|
||||||
'',
|
|
||||||
'sportspress_events'
|
|
||||||
);
|
|
||||||
|
|
||||||
add_settings_field(
|
|
||||||
'delimiter',
|
|
||||||
__( 'Delimiter', 'sportspress' ),
|
|
||||||
array( $this, 'delimiter_callback' ),
|
|
||||||
'sportspress_events',
|
|
||||||
'event'
|
|
||||||
);
|
|
||||||
|
|
||||||
add_settings_field(
|
|
||||||
'performance',
|
|
||||||
__( 'Performance', 'sportspress' ),
|
|
||||||
array( $this, 'performance_callback' ),
|
|
||||||
'sportspress_events',
|
|
||||||
'event'
|
|
||||||
);
|
|
||||||
|
|
||||||
add_settings_field(
|
|
||||||
'results',
|
|
||||||
__( 'Results', 'sportspress' ),
|
|
||||||
array( $this, 'results_callback' ),
|
|
||||||
'sportspress_events',
|
|
||||||
'event'
|
|
||||||
);
|
|
||||||
|
|
||||||
add_settings_field(
|
|
||||||
'outcomes',
|
|
||||||
__( 'Outcomes', 'sportspress' ),
|
|
||||||
array( $this, 'outcomes_callback' ),
|
|
||||||
'sportspress_events',
|
|
||||||
'event'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function delimiter_callback() {
|
|
||||||
$teams_delimiter = sportspress_array_value( $this->options, 'event_teams_delimiter', __( 'vs', 'sportspress' ) );
|
|
||||||
?>
|
|
||||||
<fieldset class="sp-custom-input-wrapper">
|
|
||||||
<legend class="screen-reader-text"><span><?php _e( 'Delimiter', 'sportspress' ); ?></span></legend>
|
|
||||||
<?php $delimiters = array( 'vs', 'v', '—', '/' ); ?>
|
|
||||||
<?php foreach ( $delimiters as $delimiter ): ?>
|
|
||||||
<label title="<?php echo $delimiter; ?>"><input type="radio" class="preset" name="sportspress_event_teams_delimiter_preset" value="<?php echo $delimiter; ?>" data-example="<?php _e( 'Team', 'sportspress' ); ?> <?php echo $delimiter; ?> <?php _e( 'Team', 'sportspress' ); ?>" <?php checked( $delimiter, $teams_delimiter ); ?>> <span><?php _e( 'Team', 'sportspress' ); ?> <?php echo $delimiter; ?> <?php _e( 'Team', 'sportspress' ); ?></span></label><br>
|
|
||||||
<?php endforeach; ?>
|
|
||||||
<label><input type="radio" class="preset" name="sportspress_event_teams_delimiter_preset" value="\c\u\s\t\o\m" <?php checked( false, in_array( $teams_delimiter, $delimiters ) ); ?>> <?php _e( 'Custom:', 'sportspress' ); ?> </label><input type="text" class="small-text value" name="sportspress[event_teams_delimiter]" value="<?php echo $teams_delimiter; ?>" data-example-format="<?php _e( 'Team', 'sportspress' ); ?> __val__ <?php _e( 'Team', 'sportspress' ); ?>">
|
|
||||||
<span class="example"><?php _e( 'Team', 'sportspress' ); ?> <?php echo $teams_delimiter; ?> <?php _e( 'Team', 'sportspress' ); ?></span>
|
|
||||||
</fieldset>
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
|
|
||||||
function performance_callback() {
|
|
||||||
$responsive = sportspress_array_value( $this->options, 'event_performance_responsive', true );
|
|
||||||
$sortable = sportspress_array_value( $this->options, 'event_performance_sortable', true );
|
|
||||||
$link_posts = sportspress_array_value( $this->options, 'event_performance_link_posts', true );
|
|
||||||
?>
|
|
||||||
<fieldset>
|
|
||||||
<label for="sportspress_event_performance_responsive">
|
|
||||||
<input id="sportspress_event_performance_responsive_default" name="sportspress[event_performance_responsive]" type="hidden" value="0">
|
|
||||||
<input id="sportspress_event_performance_responsive" name="sportspress[event_performance_responsive]" type="checkbox" value="1" <?php checked( $responsive ); ?>>
|
|
||||||
<?php _e( 'Responsive', 'sportspress' ); ?>
|
|
||||||
</label>
|
|
||||||
</fieldset>
|
|
||||||
<fieldset>
|
|
||||||
<label for="sportspress_event_performance_sortable">
|
|
||||||
<input id="sportspress_event_performance_sortable_default" name="sportspress[event_performance_sortable]" type="hidden" value="0">
|
|
||||||
<input id="sportspress_event_performance_sortable" name="sportspress[event_performance_sortable]" type="checkbox" value="1" <?php checked( $sortable ); ?>>
|
|
||||||
<?php _e( 'Sortable', 'sportspress' ); ?>
|
|
||||||
</label>
|
|
||||||
</fieldset>
|
|
||||||
<fieldset>
|
|
||||||
<label for="sportspress_event_performance_link_posts">
|
|
||||||
<input id="sportspress_event_performance_link_posts_default" name="sportspress[event_performance_link_posts]" type="hidden" value="0">
|
|
||||||
<input id="sportspress_event_performance_link_posts" name="sportspress[event_performance_link_posts]" type="checkbox" value="1" <?php checked( $link_posts ); ?>>
|
|
||||||
<?php _e( 'Link players', 'sportspress' ); ?>
|
|
||||||
</label>
|
|
||||||
</fieldset>
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
|
|
||||||
function results_callback() {
|
|
||||||
$main_result = sportspress_array_value( $this->options, 'main_result', 0 );
|
|
||||||
|
|
||||||
$args = array(
|
|
||||||
'post_type' => 'sp_result',
|
|
||||||
'numberposts' => -1,
|
|
||||||
'posts_per_page' => -1,
|
|
||||||
'orderby' => 'menu_order',
|
|
||||||
'order' => 'ASC'
|
|
||||||
);
|
|
||||||
$data = get_posts( $args );
|
|
||||||
?>
|
|
||||||
<fieldset>
|
|
||||||
<table class="widefat sp-admin-config-table">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th scope="col"><?php _e( 'Primary', 'sportspress' ); ?></th>
|
|
||||||
<th scope="col"><?php _e( 'Label', 'sportspress' ); ?></th>
|
|
||||||
<th scope="col"><?php _e( 'Key', 'sportspress' ); ?></th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tfoot>
|
|
||||||
<tr>
|
|
||||||
<th class="radio"><input type="radio" id="sportspress_main_result_0" name="sportspress[main_result]" value="0" <?php checked( $main_result, 0 ); ?>></th>
|
|
||||||
<th colspan="2"><label for="sportspress_main_result_0">
|
|
||||||
<?php
|
|
||||||
if ( sizeof( $data ) > 0 ):
|
|
||||||
$default = end( $data );
|
|
||||||
reset( $data );
|
|
||||||
printf( __( 'Default (%s)', 'sportspress' ), $default->post_title );
|
|
||||||
else:
|
|
||||||
_e( 'Default', 'sportspress' );
|
|
||||||
endif;
|
|
||||||
?>
|
|
||||||
</label></th>
|
|
||||||
</tr>
|
|
||||||
</tfoot>
|
|
||||||
<?php $i = 0; foreach ( $data as $row ): ?>
|
|
||||||
<tr<?php if ( $i % 2 == 0 ) echo ' class="alternate"'; ?>>
|
|
||||||
<td class="radio"><input type="radio" id="sportspress_main_result_<?php echo $row->post_name; ?>" name="sportspress[main_result]" value="<?php echo $row->post_name; ?>" <?php checked( $main_result, $row->post_name ); ?>></td>
|
|
||||||
<td class="row-title"><label for="sportspress_main_result_<?php echo $row->post_name; ?>"><?php echo $row->post_title; ?></label></td>
|
|
||||||
<td><?php echo $row->post_name; ?>for / <?php echo $row->post_name; ?>against</td>
|
|
||||||
</tr>
|
|
||||||
<?php $i++; endforeach; ?>
|
|
||||||
</table>
|
|
||||||
<div class="tablenav bottom">
|
|
||||||
<div class="alignleft actions">
|
|
||||||
<a class="button" id="doaction" href="<?php echo admin_url( 'edit.php?post_type=sp_result' ); ?>"><?php _e( 'Edit', 'sportspress' ); ?></a>
|
|
||||||
<a class="button" id="doaction2" href="<?php echo admin_url( 'post-new.php?post_type=sp_result' ); ?>"><?php _e( 'Add New', 'sportspress' ); ?></a>
|
|
||||||
</div>
|
|
||||||
<br class="clear">
|
|
||||||
</div>
|
|
||||||
</fieldset>
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
|
|
||||||
function outcomes_callback() {
|
|
||||||
$args = array(
|
|
||||||
'post_type' => 'sp_outcome',
|
|
||||||
'numberposts' => -1,
|
|
||||||
'posts_per_page' => -1,
|
|
||||||
'orderby' => 'menu_order',
|
|
||||||
'order' => 'ASC'
|
|
||||||
);
|
|
||||||
$data = get_posts( $args );
|
|
||||||
?>
|
|
||||||
<fieldset>
|
|
||||||
<table class="widefat sp-admin-config-table">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th scope="col"><?php _e( 'Label', 'sportspress' ); ?></th>
|
|
||||||
<th scope="col"><?php _e( 'Key', 'sportspress' ); ?></th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<?php $i = 0; foreach ( $data as $row ): ?>
|
|
||||||
<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>
|
|
||||||
</tr>
|
|
||||||
<?php $i++; endforeach; ?>
|
|
||||||
</table>
|
|
||||||
<div class="tablenav bottom">
|
|
||||||
<div class="alignleft actions">
|
|
||||||
<a class="button" id="doaction" href="<?php echo admin_url( 'edit.php?post_type=sp_outcome' ); ?>"><?php _e( 'Edit', 'sportspress' ); ?></a>
|
|
||||||
<a class="button" id="doaction2" href="<?php echo admin_url( 'post-new.php?post_type=sp_outcome' ); ?>"><?php _e( 'Add New', 'sportspress' ); ?></a>
|
|
||||||
</div>
|
|
||||||
<br class="clear">
|
|
||||||
</div>
|
|
||||||
</fieldset>
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( is_admin() )
|
|
||||||
$sportspress_event_settings_page = new SportsPressEventSettingsPage();
|
|
||||||
@@ -1,53 +0,0 @@
|
|||||||
<?php
|
|
||||||
class SportsPressGeneralSettingsPage {
|
|
||||||
public function __construct() {
|
|
||||||
global $sportspress_options;
|
|
||||||
$this->options =& $sportspress_options;
|
|
||||||
add_action( 'admin_init', array( $this, 'page_init' ), 1 );
|
|
||||||
}
|
|
||||||
|
|
||||||
function page_init() {
|
|
||||||
register_setting(
|
|
||||||
'sportspress_general',
|
|
||||||
'sportspress',
|
|
||||||
'sportspress_options_validate'
|
|
||||||
);
|
|
||||||
|
|
||||||
add_settings_section(
|
|
||||||
'general',
|
|
||||||
__( 'General Options', 'sportspress' ),
|
|
||||||
'',
|
|
||||||
'sportspress_general'
|
|
||||||
);
|
|
||||||
|
|
||||||
add_settings_field(
|
|
||||||
'sport',
|
|
||||||
__( 'Sport', 'sportspress' ),
|
|
||||||
array( $this, 'sport_callback' ),
|
|
||||||
'sportspress_general',
|
|
||||||
'general'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function sport_callback() {
|
|
||||||
global $sportspress_options;
|
|
||||||
|
|
||||||
$selected = sportspress_array_value( $sportspress_options, 'sport', null );
|
|
||||||
$custom_sport_name = sportspress_array_value( $sportspress_options, 'custom_sport_name', null );
|
|
||||||
?>
|
|
||||||
<fieldset>
|
|
||||||
<select id="sportspress_sport" name="sportspress[sport]">
|
|
||||||
<option value><?php _e( '— Select —', 'sportspress' ); ?></option>
|
|
||||||
<?php foreach( SP()->sports->options as $slug => $sport ): ?>
|
|
||||||
<option value="<?php echo $slug; ?>" <?php selected( $selected, $slug ); ?>><?php echo $sport['name']; ?></option>
|
|
||||||
<?php endforeach; ?>
|
|
||||||
<option value="custom" <?php selected( $selected, 'custom' ); ?>><?php _e( 'Custom', 'sportspress' ); ?></option>
|
|
||||||
</select>
|
|
||||||
<input id="sportspress_custom_sport_name" name="sportspress[custom_sport_name]" type="text" placeholder="<?php _e( 'Sport', 'sportspress' ); ?>" value="<?php echo $custom_sport_name; ?>"<?php if ( $selected != 'custom' ): ?> class="hidden"<?php endif; ?>>
|
|
||||||
</fieldset>
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( is_admin() )
|
|
||||||
$sportspress_general_settings_page = new SportsPressGeneralSettingsPage();
|
|
||||||
@@ -1,204 +0,0 @@
|
|||||||
<?php
|
|
||||||
class SportsPressPlayerSettingsPage {
|
|
||||||
public function __construct() {
|
|
||||||
global $sportspress_options;
|
|
||||||
$this->options =& $sportspress_options;
|
|
||||||
add_action( 'admin_init', array( $this, 'page_init' ), 1 );
|
|
||||||
}
|
|
||||||
|
|
||||||
function page_init() {
|
|
||||||
register_setting(
|
|
||||||
'sportspress_players',
|
|
||||||
'sportspress',
|
|
||||||
'sportspress_options_validate'
|
|
||||||
);
|
|
||||||
|
|
||||||
add_settings_section(
|
|
||||||
'player',
|
|
||||||
__( 'Players', 'sportspress' ),
|
|
||||||
'',
|
|
||||||
'sportspress_players'
|
|
||||||
);
|
|
||||||
|
|
||||||
add_settings_section(
|
|
||||||
'list',
|
|
||||||
__( 'Player Lists', 'sportspress' ),
|
|
||||||
'',
|
|
||||||
'sportspress_players'
|
|
||||||
);
|
|
||||||
|
|
||||||
add_settings_field(
|
|
||||||
'nationality',
|
|
||||||
__( 'Nationality', 'sportspress' ),
|
|
||||||
array( $this, 'nationality_callback' ),
|
|
||||||
'sportspress_players',
|
|
||||||
'player'
|
|
||||||
);
|
|
||||||
|
|
||||||
add_settings_field(
|
|
||||||
'list',
|
|
||||||
__( 'List', 'sportspress' ),
|
|
||||||
array( $this, 'list_callback' ),
|
|
||||||
'sportspress_players',
|
|
||||||
'list'
|
|
||||||
);
|
|
||||||
|
|
||||||
add_settings_field(
|
|
||||||
'gallery',
|
|
||||||
__( 'Gallery', 'sportspress' ),
|
|
||||||
array( $this, 'gallery_callback' ),
|
|
||||||
'sportspress_players',
|
|
||||||
'list'
|
|
||||||
);
|
|
||||||
|
|
||||||
add_settings_field(
|
|
||||||
'metrics',
|
|
||||||
__( 'Metrics', 'sportspress' ),
|
|
||||||
array( $this, 'metrics_callback' ),
|
|
||||||
'sportspress_players',
|
|
||||||
'list'
|
|
||||||
);
|
|
||||||
|
|
||||||
add_settings_field(
|
|
||||||
'performance',
|
|
||||||
__( 'Performance', 'sportspress' ),
|
|
||||||
array( $this, 'performance_callback' ),
|
|
||||||
'sportspress_players',
|
|
||||||
'list'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function nationality_callback() {
|
|
||||||
$show_nationality_flag = sportspress_array_value( $this->options, 'player_show_nationality_flag', true );
|
|
||||||
?>
|
|
||||||
<fieldset>
|
|
||||||
<label for="sportspress_player_show_nationality_flag">
|
|
||||||
<input id="sportspress_player_show_nationality_flag_default" name="sportspress[player_show_nationality_flag]" type="hidden" value="0">
|
|
||||||
<input id="sportspress_player_show_nationality_flag" name="sportspress[player_show_nationality_flag]" type="checkbox" value="1" <?php checked( $show_nationality_flag ); ?>>
|
|
||||||
<?php _e( 'Display national flags', 'sportspress' ); ?>
|
|
||||||
</label>
|
|
||||||
</fieldset>
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
|
|
||||||
function list_callback() {
|
|
||||||
$responsive = sportspress_array_value( $this->options, 'player_list_responsive', true );
|
|
||||||
$sortable = sportspress_array_value( $this->options, 'player_list_sortable', true );
|
|
||||||
$link_posts = sportspress_array_value( $this->options, 'player_list_link_posts', true );
|
|
||||||
?>
|
|
||||||
<fieldset>
|
|
||||||
<label for="sportspress_player_list_responsive">
|
|
||||||
<input id="sportspress_player_list_responsive_default" name="sportspress[player_list_responsive]" type="hidden" value="0">
|
|
||||||
<input id="sportspress_player_list_responsive" name="sportspress[player_list_responsive]" type="checkbox" value="1" <?php checked( $responsive ); ?>>
|
|
||||||
<?php _e( 'Responsive', 'sportspress' ); ?>
|
|
||||||
</label>
|
|
||||||
</fieldset>
|
|
||||||
<fieldset>
|
|
||||||
<label for="sportspress_player_list_sortable">
|
|
||||||
<input id="sportspress_player_list_sortable_default" name="sportspress[player_list_sortable]" type="hidden" value="0">
|
|
||||||
<input id="sportspress_player_list_sortable" name="sportspress[player_list_sortable]" type="checkbox" value="1" <?php checked( $sortable ); ?>>
|
|
||||||
<?php _e( 'Sortable', 'sportspress' ); ?>
|
|
||||||
</label>
|
|
||||||
</fieldset>
|
|
||||||
<fieldset>
|
|
||||||
<label for="sportspress_player_list_link_posts">
|
|
||||||
<input id="sportspress_player_list_link_posts_default" name="sportspress[player_list_link_posts]" type="hidden" value="0">
|
|
||||||
<input id="sportspress_player_list_link_posts" name="sportspress[player_list_link_posts]" type="checkbox" value="1" <?php checked( $link_posts ); ?>>
|
|
||||||
<?php _e( 'Link players', 'sportspress' ); ?>
|
|
||||||
</label>
|
|
||||||
</fieldset>
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
|
|
||||||
function gallery_callback() {
|
|
||||||
$show_names_on_hover = sportspress_array_value( $this->options, 'player_gallery_show_names_on_hover', true );
|
|
||||||
?>
|
|
||||||
<fieldset>
|
|
||||||
<label for="sportspress_player_gallery_show_names_on_hover">
|
|
||||||
<input id="sportspress_player_gallery_show_names_on_hover_default" name="sportspress[player_gallery_show_names_on_hover]" type="hidden" value="0">
|
|
||||||
<input id="sportspress_player_gallery_show_names_on_hover" name="sportspress[player_gallery_show_names_on_hover]" type="checkbox" value="1" <?php checked( $show_names_on_hover ); ?>>
|
|
||||||
<?php _e( 'Display player names on hover', 'sportspress' ); ?>
|
|
||||||
</label>
|
|
||||||
</fieldset>
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
|
|
||||||
function metrics_callback() {
|
|
||||||
$args = array(
|
|
||||||
'post_type' => 'sp_metric',
|
|
||||||
'numberposts' => -1,
|
|
||||||
'posts_per_page' => -1,
|
|
||||||
'orderby' => 'menu_order',
|
|
||||||
'order' => 'ASC'
|
|
||||||
);
|
|
||||||
$data = get_posts( $args );
|
|
||||||
?>
|
|
||||||
<fieldset>
|
|
||||||
<table class="widefat sp-admin-config-table">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th scope="col"><?php _e( 'Label', 'sportspress' ); ?></th>
|
|
||||||
<th scope="col"><?php _e( 'Positions', 'sportspress' ); ?></th>
|
|
||||||
<th scope="col"> </th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<?php $i = 0; foreach ( $data as $row ): ?>
|
|
||||||
<tr<?php if ( $i % 2 == 0 ) echo ' class="alternate"'; ?>>
|
|
||||||
<td class="row-title"><?php echo $row->post_title; ?></td>
|
|
||||||
<td><?php echo get_the_terms ( $row->ID, 'sp_position' ) ? the_terms( $row->ID, 'sp_position' ) : '—'; ?></td>
|
|
||||||
<td> </td>
|
|
||||||
</tr>
|
|
||||||
<?php $i++; endforeach; ?>
|
|
||||||
</table>
|
|
||||||
<div class="tablenav bottom">
|
|
||||||
<div class="alignleft actions">
|
|
||||||
<a class="button" id="doaction" href="<?php echo admin_url( 'edit.php?post_type=sp_metric' ); ?>"><?php _e( 'Edit', 'sportspress' ); ?></a>
|
|
||||||
<a class="button" id="doaction2" href="<?php echo admin_url( 'post-new.php?post_type=sp_metric' ); ?>"><?php _e( 'Add New', 'sportspress' ); ?></a>
|
|
||||||
</div>
|
|
||||||
<br class="clear">
|
|
||||||
</div>
|
|
||||||
</fieldset>
|
|
||||||
<?
|
|
||||||
}
|
|
||||||
|
|
||||||
function performance_callback() {
|
|
||||||
$args = array(
|
|
||||||
'post_type' => 'sp_performance',
|
|
||||||
'numberposts' => -1,
|
|
||||||
'posts_per_page' => -1,
|
|
||||||
'orderby' => 'menu_order',
|
|
||||||
'order' => 'ASC'
|
|
||||||
);
|
|
||||||
$data = get_posts( $args );
|
|
||||||
?>
|
|
||||||
<fieldset>
|
|
||||||
<table class="widefat sp-admin-config-table">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th scope="col"><?php _e( 'Label', 'sportspress' ); ?></th>
|
|
||||||
<th scope="col"><?php _e( 'Positions', 'sportspress' ); ?></th>
|
|
||||||
<th scope="col"><?php _e( 'Calculate', 'sportspress' ); ?></th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<?php $i = 0; foreach ( $data as $row ): ?>
|
|
||||||
<tr<?php if ( $i % 2 == 0 ) echo ' class="alternate"'; ?>>
|
|
||||||
<td class="row-title"><?php echo $row->post_title; ?></td>
|
|
||||||
<td><?php echo get_the_terms ( $row->ID, 'sp_position' ) ? the_terms( $row->ID, 'sp_position' ) : '—'; ?></td>
|
|
||||||
<td><?php echo sportspress_get_post_calculate( $row->ID ); ?></td>
|
|
||||||
</tr>
|
|
||||||
<?php $i++; endforeach; ?>
|
|
||||||
</table>
|
|
||||||
<div class="tablenav bottom">
|
|
||||||
<div class="alignleft actions">
|
|
||||||
<a class="button" id="doaction" href="<?php echo admin_url( 'edit.php?post_type=sp_performance' ); ?>"><?php _e( 'Edit', 'sportspress' ); ?></a>
|
|
||||||
<a class="button" id="doaction2" href="<?php echo admin_url( 'post-new.php?post_type=sp_performance' ); ?>"><?php _e( 'Add New', 'sportspress' ); ?></a>
|
|
||||||
</div>
|
|
||||||
<br class="clear">
|
|
||||||
</div>
|
|
||||||
</fieldset>
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( is_admin() )
|
|
||||||
$sportspress_player_settings_page = new SportsPressPlayerSettingsPage();
|
|
||||||
@@ -1,121 +0,0 @@
|
|||||||
<?php
|
|
||||||
class SportsPressTeamSettingsPage {
|
|
||||||
public function __construct() {
|
|
||||||
global $sportspress_options;
|
|
||||||
$this->options =& $sportspress_options;
|
|
||||||
add_action( 'admin_init', array( $this, 'page_init' ), 1 );
|
|
||||||
}
|
|
||||||
|
|
||||||
function page_init() {
|
|
||||||
register_setting(
|
|
||||||
'sportspress_teams',
|
|
||||||
'sportspress',
|
|
||||||
'sportspress_options_validate'
|
|
||||||
);
|
|
||||||
|
|
||||||
add_settings_section(
|
|
||||||
'table',
|
|
||||||
__( 'League Tables', 'sportspress' ),
|
|
||||||
'',
|
|
||||||
'sportspress_teams'
|
|
||||||
);
|
|
||||||
|
|
||||||
add_settings_field(
|
|
||||||
'table',
|
|
||||||
__( 'Table', 'sportspress' ),
|
|
||||||
array( $this, 'table_callback' ),
|
|
||||||
'sportspress_teams',
|
|
||||||
'table'
|
|
||||||
);
|
|
||||||
|
|
||||||
add_settings_field(
|
|
||||||
'columns',
|
|
||||||
__( 'Columns', 'sportspress' ),
|
|
||||||
array( $this, 'columns_callback' ),
|
|
||||||
'sportspress_teams',
|
|
||||||
'table'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function table_callback() {
|
|
||||||
$responsive = sportspress_array_value( $this->options, 'league_table_responsive', true );
|
|
||||||
$sortable = sportspress_array_value( $this->options, 'league_table_sortable', true );
|
|
||||||
$show_team_logo = sportspress_array_value( $this->options, 'league_table_show_team_logo', false );
|
|
||||||
$link_posts = sportspress_array_value( $this->options, 'league_table_link_posts', false );
|
|
||||||
?>
|
|
||||||
<fieldset>
|
|
||||||
<label for="sportspress_league_table_responsive">
|
|
||||||
<input id="sportspress_league_table_responsive_default" name="sportspress[league_table_responsive]" type="hidden" value="0">
|
|
||||||
<input id="sportspress_league_table_responsive" name="sportspress[league_table_responsive]" type="checkbox" value="1" <?php checked( $responsive ); ?>>
|
|
||||||
<?php _e( 'Responsive', 'sportspress' ); ?>
|
|
||||||
</label>
|
|
||||||
</fieldset>
|
|
||||||
<fieldset>
|
|
||||||
<label for="sportspress_league_table_sortable">
|
|
||||||
<input id="sportspress_league_table_sortable_default" name="sportspress[league_table_sortable]" type="hidden" value="0">
|
|
||||||
<input id="sportspress_league_table_sortable" name="sportspress[league_table_sortable]" type="checkbox" value="1" <?php checked( $sortable ); ?>>
|
|
||||||
<?php _e( 'Sortable', 'sportspress' ); ?>
|
|
||||||
</label>
|
|
||||||
</fieldset>
|
|
||||||
<fieldset>
|
|
||||||
<label for="sportspress_league_table_show_team_logo">
|
|
||||||
<input id="sportspress_league_table_show_team_logo_default" name="sportspress[league_table_show_team_logo]" type="hidden" value="0">
|
|
||||||
<input id="sportspress_league_table_show_team_logo" name="sportspress[league_table_show_team_logo]" type="checkbox" value="1" <?php checked( $show_team_logo ); ?>>
|
|
||||||
<?php _e( 'Display logos', 'sportspress' ); ?>
|
|
||||||
</label>
|
|
||||||
</fieldset>
|
|
||||||
<fieldset>
|
|
||||||
<label for="sportspress_league_table_link_posts">
|
|
||||||
<input id="sportspress_league_table_link_posts_default" name="sportspress[league_table_link_posts]" type="hidden" value="0">
|
|
||||||
<input id="sportspress_league_table_link_posts" name="sportspress[league_table_link_posts]" type="checkbox" value="1" <?php checked( $link_posts ); ?>>
|
|
||||||
<?php _e( 'Link teams', 'sportspress' ); ?>
|
|
||||||
</label>
|
|
||||||
</fieldset>
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
|
|
||||||
function columns_callback() {
|
|
||||||
$args = array(
|
|
||||||
'post_type' => 'sp_column',
|
|
||||||
'numberposts' => -1,
|
|
||||||
'posts_per_page' => -1,
|
|
||||||
'orderby' => 'menu_order',
|
|
||||||
'order' => 'ASC'
|
|
||||||
);
|
|
||||||
$data = get_posts( $args );
|
|
||||||
?>
|
|
||||||
<fieldset>
|
|
||||||
<table class="widefat sp-admin-config-table">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th scope="col"><?php _e( 'Label', 'sportspress' ); ?></th>
|
|
||||||
<th scope="col"><?php _e( 'Key', 'sportspress' ); ?></th>
|
|
||||||
<th scope="col"><?php _e( 'Equation', 'sportspress' ); ?></th>
|
|
||||||
<th scope="col"><?php _e( 'Rounding', 'sportspress' ); ?></th>
|
|
||||||
<th scope="col"><?php _e( 'Sort Order', 'sportspress' ); ?></th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<?php $i = 0; foreach ( $data as $row ): ?>
|
|
||||||
<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 sportspress_get_post_equation( $row->ID, $row->post_name ); ?></td>
|
|
||||||
<td><?php echo sportspress_get_post_precision( $row->ID ); ?></td>
|
|
||||||
<td><?php echo sportspress_get_post_order( $row->ID ); ?></td>
|
|
||||||
</tr>
|
|
||||||
<?php $i++; endforeach; ?>
|
|
||||||
</table>
|
|
||||||
<div class="tablenav bottom">
|
|
||||||
<div class="alignleft actions">
|
|
||||||
<a class="button" id="doaction" href="<?php echo admin_url( 'edit.php?post_type=sp_column' ); ?>"><?php _e( 'Edit', 'sportspress' ); ?></a>
|
|
||||||
<a class="button" id="doaction2" href="<?php echo admin_url( 'post-new.php?post_type=sp_column' ); ?>"><?php _e( 'Add New', 'sportspress' ); ?></a>
|
|
||||||
</div>
|
|
||||||
<br class="clear">
|
|
||||||
</div>
|
|
||||||
</fieldset>
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( is_admin() )
|
|
||||||
$sportspress_team_settings_page = new SportsPressTeamSettingsPage();
|
|
||||||
@@ -1,46 +0,0 @@
|
|||||||
<?php
|
|
||||||
class SportsPressTextSettingsPage {
|
|
||||||
private $strings = null;
|
|
||||||
|
|
||||||
public function __construct() {
|
|
||||||
global $sportspress_options;
|
|
||||||
$this->options =& $sportspress_options;
|
|
||||||
add_action( 'admin_init', array( $this, 'page_init' ), 1 );
|
|
||||||
}
|
|
||||||
|
|
||||||
function page_init() {
|
|
||||||
register_setting(
|
|
||||||
'sportspress_text',
|
|
||||||
'sportspress',
|
|
||||||
'sportspress_options_validate'
|
|
||||||
);
|
|
||||||
|
|
||||||
add_settings_section(
|
|
||||||
'text',
|
|
||||||
__( 'Text', 'sportspress' ),
|
|
||||||
'',
|
|
||||||
'sportspress_text'
|
|
||||||
);
|
|
||||||
|
|
||||||
$this->strings =& SP()->text->strings;
|
|
||||||
foreach ( $this->strings as $string ):
|
|
||||||
add_settings_field(
|
|
||||||
sanitize_title( $string ),
|
|
||||||
$string,
|
|
||||||
array( $this, 'text_callback' ),
|
|
||||||
'sportspress_text',
|
|
||||||
'text'
|
|
||||||
);
|
|
||||||
endforeach;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function text_callback( $test ) {
|
|
||||||
$string = array_shift( $this->strings );
|
|
||||||
$key = sanitize_title( $string );
|
|
||||||
$text = sportspress_array_value( sportspress_array_value( $this->options, 'text', array() ), $string, null );
|
|
||||||
?><fieldset><input id="sportspress_text_<?php echo $key; ?>" name="sportspress[text][<?php echo $string; ?>]" type="text" class="regular-text" value="<?php echo $text; ?>" placeholder="<?php echo $string; ?>"></fieldset><?php
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( is_admin() )
|
|
||||||
$sportspress_text_settings_page = new SportsPressTextSettingsPage();
|
|
||||||
@@ -1,166 +0,0 @@
|
|||||||
<?php
|
|
||||||
function sportspress_options() {
|
|
||||||
|
|
||||||
$active_tab = isset( $_GET[ 'tab' ] ) ? $_GET[ 'tab' ] : 'general';
|
|
||||||
|
|
||||||
?>
|
|
||||||
<div class="wrap">
|
|
||||||
|
|
||||||
<h2 class="nav-tab-wrapper">
|
|
||||||
<a href="<?php echo remove_query_arg( 'tab' ); ?>" class="nav-tab<?php echo $active_tab == 'general' ? ' nav-tab-active' : ''; ?>"><?php _e( 'SportsPress', 'sportspress' ); ?></a>
|
|
||||||
<a href="<?php echo add_query_arg( 'tab', 'events' ); ?>" class="nav-tab<?php echo $active_tab == 'events' ? ' nav-tab-active' : ''; ?>"><?php _e( 'Schedule', 'sportspress' ); ?></a>
|
|
||||||
<a href="<?php echo add_query_arg( 'tab', 'teams' ); ?>" class="nav-tab<?php echo $active_tab == 'teams' ? ' nav-tab-active' : ''; ?>"><?php _e( 'Teams', 'sportspress' ); ?></a>
|
|
||||||
<a href="<?php echo add_query_arg( 'tab', 'players' ); ?>" class="nav-tab<?php echo $active_tab == 'players' ? ' nav-tab-active' : ''; ?>"><?php _e( 'Roster', 'sportspress' ); ?></a>
|
|
||||||
<a href="<?php echo add_query_arg( 'tab', 'text' ); ?>" class="nav-tab<?php echo $active_tab == 'text' ? ' nav-tab-active' : ''; ?>"><?php _e( 'Text', 'sportspress' ); ?></a>
|
|
||||||
</h2>
|
|
||||||
|
|
||||||
<form method="post" action="options.php">
|
|
||||||
<?php
|
|
||||||
switch ( $active_tab ):
|
|
||||||
case 'events':
|
|
||||||
settings_fields( 'sportspress_events' );
|
|
||||||
do_settings_sections( 'sportspress_events' );
|
|
||||||
submit_button();
|
|
||||||
break;
|
|
||||||
case 'teams':
|
|
||||||
settings_fields( 'sportspress_teams' );
|
|
||||||
do_settings_sections( 'sportspress_teams' );
|
|
||||||
submit_button();
|
|
||||||
break;
|
|
||||||
case 'players':
|
|
||||||
settings_fields( 'sportspress_players' );
|
|
||||||
do_settings_sections( 'sportspress_players' );
|
|
||||||
submit_button();
|
|
||||||
break;
|
|
||||||
case 'text':
|
|
||||||
settings_fields( 'sportspress_text' );
|
|
||||||
do_settings_sections( 'sportspress_text' );
|
|
||||||
submit_button();
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
settings_fields( 'sportspress_general' );
|
|
||||||
do_settings_sections( 'sportspress_general' );
|
|
||||||
submit_button();
|
|
||||||
break;
|
|
||||||
endswitch;
|
|
||||||
?>
|
|
||||||
</form>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
|
|
||||||
function sportspress_options_validate( $input ) {
|
|
||||||
|
|
||||||
$options = (array)get_option( 'sportspress', array() );
|
|
||||||
|
|
||||||
if ( isset( $input['sport'] ) && sportspress_array_value( $options, 'sport', null ) != sportspress_array_value( $input, 'sport', null ) ):
|
|
||||||
|
|
||||||
// Get sports presets
|
|
||||||
global $sportspress_sports;
|
|
||||||
|
|
||||||
// Get array of taxonomies to insert
|
|
||||||
$term_groups = sportspress_array_value( sportspress_array_value( $sportspress_sports, sportspress_array_value( $input, 'sport', null ), array() ), 'terms', array() );
|
|
||||||
|
|
||||||
foreach( $term_groups as $taxonomy => $terms ):
|
|
||||||
// Find empty terms and destroy
|
|
||||||
$allterms = get_terms( $taxonomy, 'hide_empty=0' );
|
|
||||||
|
|
||||||
foreach( $allterms as $term ):
|
|
||||||
if ( $term->count == 0 )
|
|
||||||
wp_delete_term( $term->term_id, $taxonomy );
|
|
||||||
endforeach;
|
|
||||||
|
|
||||||
// Insert terms
|
|
||||||
foreach( $terms as $term ):
|
|
||||||
wp_insert_term( $term['name'], $taxonomy, array( 'slug' => $term['slug'] ) );
|
|
||||||
endforeach;
|
|
||||||
endforeach;
|
|
||||||
|
|
||||||
// Get array of post types to insert
|
|
||||||
$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 ):
|
|
||||||
|
|
||||||
$args = array(
|
|
||||||
'post_type' => $post_type,
|
|
||||||
'numberposts' => -1,
|
|
||||||
'posts_per_page' => -1,
|
|
||||||
'meta_query' => array(
|
|
||||||
array(
|
|
||||||
'key' => '_sp_preset',
|
|
||||||
'value' => 1
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
// Delete posts
|
|
||||||
$old_posts = get_posts( $args );
|
|
||||||
|
|
||||||
foreach( $old_posts as $post ):
|
|
||||||
wp_delete_post( $post->ID, true);
|
|
||||||
endforeach;
|
|
||||||
|
|
||||||
// Add posts
|
|
||||||
foreach( $posts as $index => $post ):
|
|
||||||
|
|
||||||
// Make sure post doesn't overlap
|
|
||||||
if ( ! get_page_by_path( $post['post_name'], OBJECT, $post_type ) ):
|
|
||||||
|
|
||||||
// Translate post title
|
|
||||||
$post['post_title'] = __( $post['post_title'], 'sportspress' );
|
|
||||||
|
|
||||||
// Set post type
|
|
||||||
$post['post_type'] = $post_type;
|
|
||||||
|
|
||||||
// Increment menu order by 2 and publish post
|
|
||||||
$post['menu_order'] = $index * 2 + 2;
|
|
||||||
$post['post_status'] = 'publish';
|
|
||||||
$id = wp_insert_post( $post );
|
|
||||||
|
|
||||||
// Flag as preset
|
|
||||||
update_post_meta( $id, '_sp_preset', 1 );
|
|
||||||
|
|
||||||
// Update meta
|
|
||||||
if ( array_key_exists( 'meta', $post ) ):
|
|
||||||
|
|
||||||
foreach ( $post['meta'] as $key => $value ):
|
|
||||||
|
|
||||||
update_post_meta( $id, $key, $value );
|
|
||||||
|
|
||||||
endforeach;
|
|
||||||
|
|
||||||
endif;
|
|
||||||
|
|
||||||
// Update terms
|
|
||||||
if ( array_key_exists( 'tax_input', $post ) ):
|
|
||||||
|
|
||||||
foreach ( $post['tax_input'] as $taxonomy => $terms ):
|
|
||||||
|
|
||||||
wp_set_object_terms( $id, $terms, $taxonomy, false );
|
|
||||||
|
|
||||||
endforeach;
|
|
||||||
|
|
||||||
endif;
|
|
||||||
|
|
||||||
endif;
|
|
||||||
|
|
||||||
endforeach;
|
|
||||||
|
|
||||||
endforeach;
|
|
||||||
|
|
||||||
elseif ( isset( $input['text'] ) ):
|
|
||||||
$input['text'] = array_filter( $input['text'] );
|
|
||||||
endif;
|
|
||||||
|
|
||||||
if ( ! is_array( $input ) )
|
|
||||||
$input = array();
|
|
||||||
|
|
||||||
// Merge with existing options
|
|
||||||
return array_merge( $options, $input );
|
|
||||||
}
|
|
||||||
|
|
||||||
function sportspress_add_menu_page() {
|
|
||||||
}
|
|
||||||
add_action( 'admin_menu', 'sportspress_add_menu_page' );
|
|
||||||
@@ -245,4 +245,38 @@ class SP_Countries {
|
|||||||
|
|
||||||
$this->continents = apply_filters( 'sportspress_continents', $continents );
|
$this->continents = apply_filters( 'sportspress_continents', $continents );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the base country.
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function get_base_country() {
|
||||||
|
$default = esc_attr( get_option('sportspress_default_country') );
|
||||||
|
$country = ( ( $pos = strrpos( $default, ':' ) ) === false ) ? $default : substr( $default, 0, $pos );
|
||||||
|
|
||||||
|
return apply_filters( 'sportspress_countries_base_country', $country );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Outputs the list of continents and countries for use in dropdown boxes.
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @param string $selected_country (default: '')
|
||||||
|
* @param bool $escape (default: false)
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function country_dropdown_options( $selected_country = '', $escape = false ) {
|
||||||
|
if ( $this->continents ) foreach ( $this->continents as $continent => $countries ):
|
||||||
|
?>
|
||||||
|
<optgroup label="<?php echo $continent; ?>">
|
||||||
|
<?php foreach ( $countries as $code => $country ): ?>
|
||||||
|
<option value="<?php echo $code; ?>" <?php selected ( $selected_country, $code ); ?>><?php echo $country; ?></option>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</optgroup>
|
||||||
|
<?php
|
||||||
|
endforeach;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,35 +15,8 @@ class SP_Frontend_Scripts {
|
|||||||
*/
|
*/
|
||||||
public function __construct () {
|
public function __construct () {
|
||||||
add_action( 'wp_enqueue_scripts', array( $this, 'load_scripts' ) );
|
add_action( 'wp_enqueue_scripts', array( $this, 'load_scripts' ) );
|
||||||
add_action( 'wp_print_scripts', array( $this, 'check_jquery' ), 25 );
|
add_action( 'wp_print_scripts', array( $this, 'check_jquery' ), 25 );;
|
||||||
add_filter( 'sportspress_enqueue_styles', array( $this, 'backwards_compat' ) );
|
add_action( 'wp_print_scripts', array( $this, 'custom_css' ), 30 );;
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get styles for the frontend
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public static function get_styles() {
|
|
||||||
return apply_filters( 'sportspress_enqueue_styles', array(
|
|
||||||
'sportspress-layout' => array(
|
|
||||||
'src' => str_replace( array( 'http:', 'https:' ), '', SP()->plugin_url() ) . '/assets/css/sportspress-layout.css',
|
|
||||||
'deps' => '',
|
|
||||||
'version' => SP_VERSION,
|
|
||||||
'media' => 'all'
|
|
||||||
),
|
|
||||||
'sportspress-smallscreen' => array(
|
|
||||||
'src' => str_replace( array( 'http:', 'https:' ), '', SP()->plugin_url() ) . '/assets/css/sportspress-smallscreen.css',
|
|
||||||
'deps' => 'sportspress-layout',
|
|
||||||
'version' => SP_VERSION,
|
|
||||||
'media' => 'only screen and (max-width: ' . apply_filters( 'sportspress_style_smallscreen_breakpoint', $breakpoint = '768px' ) . ')'
|
|
||||||
),
|
|
||||||
'sportspress-general' => array(
|
|
||||||
'src' => str_replace( array( 'http:', 'https:' ), '', SP()->plugin_url() ) . '/assets/css/sportspress.css',
|
|
||||||
'deps' => '',
|
|
||||||
'version' => SP_VERSION,
|
|
||||||
'media' => 'all'
|
|
||||||
),
|
|
||||||
) );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -53,129 +26,18 @@ class SP_Frontend_Scripts {
|
|||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function load_scripts() {
|
public function load_scripts() {
|
||||||
global $post, $wp;
|
// Styles
|
||||||
|
wp_enqueue_style( 'sportspress', plugin_dir_url( SP_PLUGIN_FILE ) . 'assets/css/sportspress.css', array( 'dashicons' ), time() );
|
||||||
|
|
||||||
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
|
// Scripts
|
||||||
$lightbox_en = get_option( 'sportspress_enable_lightbox' ) == 'yes' ? true : false;
|
wp_enqueue_script( 'jquery' );
|
||||||
$ajax_cart_en = get_option( 'sportspress_enable_ajax_add_to_cart' ) == 'yes' ? true : false;
|
wp_enqueue_script( 'google-maps', 'https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false', array(), '3.exp', true );
|
||||||
$assets_path = str_replace( array( 'http:', 'https:' ), '', SP()->plugin_url() ) . '/assets/';
|
wp_enqueue_script( 'jquery-datatables', plugin_dir_url( SP_PLUGIN_FILE ) .'assets/js/jquery.dataTables.min.js', array( 'jquery' ), '1.9.4', true );
|
||||||
$frontend_script_path = $assets_path . 'js/frontend/';
|
wp_enqueue_script( 'jquery-countdown', plugin_dir_url( SP_PLUGIN_FILE ) .'assets/js/jquery.countdown.min.js', array( 'jquery' ), '2.0.2', true );
|
||||||
|
wp_enqueue_script( 'sportspress', plugin_dir_url( SP_PLUGIN_FILE ) .'assets/js/sportspress.js', array( 'jquery' ), time(), true );
|
||||||
|
|
||||||
// Register any scripts for later use, or used as dependencies
|
// Localize scripts.
|
||||||
wp_register_script( 'chosen', $assets_path . 'js/chosen/chosen.jquery' . $suffix . '.js', array( 'jquery' ), '1.0.0', true );
|
wp_localize_script( 'sportspress', 'localized_strings', array( 'days' => __( 'days', 'sportspress' ), 'hrs' => __( 'hrs', 'sportspress' ), 'mins' => __( 'mins', 'sportspress' ), 'secs' => __( 'secs', 'sportspress' ) ) );
|
||||||
wp_register_script( 'jquery-blockui', $assets_path . 'js/jquery-blockui/jquery.blockUI' . $suffix . '.js', array( 'jquery' ), '2.60', true );
|
|
||||||
wp_register_script( 'jquery-payment', $assets_path . 'js/jquery-payment/jquery.payment' . $suffix . '.js', array( 'jquery' ), '1.0.2', true );
|
|
||||||
wp_register_script( 'sp-credit-card-form', $assets_path . 'js/frontend/credit-card-form' . $suffix . '.js', array( 'jquery', 'jquery-payment' ), SP_VERSION, true );
|
|
||||||
|
|
||||||
wp_register_script( 'sp-add-to-cart-variation', $frontend_script_path . 'add-to-cart-variation' . $suffix . '.js', array( 'jquery' ), SP_VERSION, true );
|
|
||||||
wp_register_script( 'sp-single-product', $frontend_script_path . 'single-product' . $suffix . '.js', array( 'jquery' ), SP_VERSION, true );
|
|
||||||
wp_register_script( 'sp-country-select', $frontend_script_path . 'country-select' . $suffix . '.js', array( 'jquery' ), SP_VERSION, true );
|
|
||||||
wp_register_script( 'sp-address-i18n', $frontend_script_path . 'address-i18n' . $suffix . '.js', array( 'jquery' ), SP_VERSION, true );
|
|
||||||
wp_register_script( 'jquery-cookie', $assets_path . 'js/jquery-cookie/jquery.cookie' . $suffix . '.js', array( 'jquery' ), '1.3.1', true );
|
|
||||||
|
|
||||||
// Queue frontend scripts conditionally
|
|
||||||
if ( $ajax_cart_en )
|
|
||||||
wp_enqueue_script( 'sp-add-to-cart', $frontend_script_path . 'add-to-cart' . $suffix . '.js', array( 'jquery' ), SP_VERSION, true );
|
|
||||||
|
|
||||||
if ( is_cart() )
|
|
||||||
wp_enqueue_script( 'sp-cart', $frontend_script_path . 'cart' . $suffix . '.js', array( 'jquery', 'sp-country-select' ), SP_VERSION, true );
|
|
||||||
|
|
||||||
if ( is_checkout() ) {
|
|
||||||
|
|
||||||
if ( get_option( 'sportspress_enable_chosen' ) == 'yes' ) {
|
|
||||||
wp_enqueue_script( 'sp-chosen', $frontend_script_path . 'chosen-frontend' . $suffix . '.js', array( 'chosen' ), SP_VERSION, true );
|
|
||||||
wp_enqueue_style( 'sportspress_chosen_styles', $assets_path . 'css/chosen.css' );
|
|
||||||
}
|
|
||||||
|
|
||||||
wp_enqueue_script( 'sp-checkout', $frontend_script_path . 'checkout' . $suffix . '.js', array( 'jquery', 'sportspress', 'sp-country-select', 'sp-address-i18n' ), SP_VERSION, true );
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( is_page( get_option( 'sportspress_myaccount_page_id' ) ) ) {
|
|
||||||
if ( get_option( 'sportspress_enable_chosen' ) == 'yes' ) {
|
|
||||||
wp_enqueue_script( 'sp-chosen', $frontend_script_path . 'chosen-frontend' . $suffix . '.js', array( 'chosen' ), SP_VERSION, true );
|
|
||||||
wp_enqueue_style( 'sportspress_chosen_styles', $assets_path . 'css/chosen.css' );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( is_add_payment_method_page() )
|
|
||||||
wp_enqueue_script( 'sp-add-payment-method', $frontend_script_path . 'add-payment-method' . $suffix . '.js', array( 'jquery', 'sportspress' ), SP_VERSION, true );
|
|
||||||
|
|
||||||
if ( $lightbox_en && ( is_product() || ( ! empty( $post->post_content ) && strstr( $post->post_content, '[product_page' ) ) ) ) {
|
|
||||||
wp_enqueue_script( 'prettyPhoto', $assets_path . 'js/prettyPhoto/jquery.prettyPhoto' . $suffix . '.js', array( 'jquery' ), '3.1.5', true );
|
|
||||||
wp_enqueue_script( 'prettyPhoto-init', $assets_path . 'js/prettyPhoto/jquery.prettyPhoto.init' . $suffix . '.js', array( 'jquery' ), SP_VERSION, true );
|
|
||||||
wp_enqueue_style( 'sportspress_prettyPhoto_css', $assets_path . 'css/prettyPhoto.css' );
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( is_product() )
|
|
||||||
wp_enqueue_script( 'sp-single-product' );
|
|
||||||
|
|
||||||
// Global frontend scripts
|
|
||||||
wp_enqueue_script( 'sportspress', $frontend_script_path . 'sportspress' . $suffix . '.js', array( 'jquery', 'jquery-blockui' ), SP_VERSION, true );
|
|
||||||
wp_enqueue_script( 'sp-cart-fragments', $frontend_script_path . 'cart-fragments' . $suffix . '.js', array( 'jquery', 'jquery-cookie' ), SP_VERSION, true );
|
|
||||||
|
|
||||||
// Variables for JS scripts
|
|
||||||
wp_localize_script( 'sportspress', 'sportspress_params', apply_filters( 'sportspress_params', array(
|
|
||||||
'ajax_url' => SP()->ajax_url(),
|
|
||||||
'ajax_loader_url' => apply_filters( 'sportspress_ajax_loader_url', $assets_path . 'images/ajax-loader@2x.gif' ),
|
|
||||||
) ) );
|
|
||||||
|
|
||||||
wp_localize_script( 'sp-single-product', 'sp_single_product_params', apply_filters( 'sp_single_product_params', array(
|
|
||||||
'i18n_required_rating_text' => esc_attr__( 'Please select a rating', 'sportspress' ),
|
|
||||||
'review_rating_required' => get_option( 'sportspress_review_rating_required' ),
|
|
||||||
) ) );
|
|
||||||
|
|
||||||
wp_localize_script( 'sp-checkout', 'sp_checkout_params', apply_filters( 'sp_checkout_params', array(
|
|
||||||
'ajax_url' => SP()->ajax_url(),
|
|
||||||
'ajax_loader_url' => apply_filters( 'sportspress_ajax_loader_url', $assets_path . 'images/ajax-loader@2x.gif' ),
|
|
||||||
'update_order_review_nonce' => wp_create_nonce( "update-order-review" ),
|
|
||||||
'apply_coupon_nonce' => wp_create_nonce( "apply-coupon" ),
|
|
||||||
'option_guest_checkout' => get_option( 'sportspress_enable_guest_checkout' ),
|
|
||||||
'checkout_url' => add_query_arg( 'action', 'sportspress_checkout', SP()->ajax_url() ),
|
|
||||||
'is_checkout' => is_page( sp_get_page_id( 'checkout' ) ) && empty( $wp->query_vars['order-pay'] ) && ! isset( $wp->query_vars['order-received'] ) ? 1 : 0
|
|
||||||
) ) );
|
|
||||||
|
|
||||||
wp_localize_script( 'sp-address-i18n', 'sp_address_i18n_params', apply_filters( 'sp_address_i18n_params', array(
|
|
||||||
'locale' => json_encode( SP()->countries->get_country_locale() ),
|
|
||||||
'locale_fields' => json_encode( SP()->countries->get_country_locale_field_selectors() ),
|
|
||||||
'i18n_required_text' => esc_attr__( 'required', 'sportspress' ),
|
|
||||||
) ) );
|
|
||||||
|
|
||||||
wp_localize_script( 'sp-cart', 'sp_cart_params', apply_filters( 'sp_cart_params', array(
|
|
||||||
'ajax_url' => SP()->ajax_url(),
|
|
||||||
'ajax_loader_url' => apply_filters( 'sportspress_ajax_loader_url', $assets_path . 'images/ajax-loader@2x.gif' ),
|
|
||||||
'update_shipping_method_nonce' => wp_create_nonce( "update-shipping-method" ),
|
|
||||||
) ) );
|
|
||||||
|
|
||||||
wp_localize_script( 'sp-cart-fragments', 'sp_cart_fragments_params', apply_filters( 'sp_cart_fragments_params', array(
|
|
||||||
'ajax_url' => SP()->ajax_url(),
|
|
||||||
'fragment_name' => apply_filters( 'sportspress_cart_fragment_name', 'sp_fragments' )
|
|
||||||
) ) );
|
|
||||||
|
|
||||||
wp_localize_script( 'sp-add-to-cart', 'sp_add_to_cart_params', apply_filters( 'sp_add_to_cart_params', array(
|
|
||||||
'ajax_url' => SP()->ajax_url(),
|
|
||||||
'ajax_loader_url' => apply_filters( 'sportspress_ajax_loader_url', $assets_path . 'images/ajax-loader@2x.gif' ),
|
|
||||||
'i18n_view_cart' => esc_attr__( 'View Cart', 'sportspress' ),
|
|
||||||
'cart_url' => get_permalink( sp_get_page_id( 'cart' ) ),
|
|
||||||
'is_cart' => is_cart(),
|
|
||||||
'cart_redirect_after_add' => get_option( 'sportspress_cart_redirect_after_add' )
|
|
||||||
) ) );
|
|
||||||
|
|
||||||
wp_localize_script( 'sp-add-to-cart-variation', 'sp_add_to_cart_variation_params', apply_filters( 'sp_add_to_cart_variation_params', array(
|
|
||||||
'i18n_no_matching_variations_text' => esc_attr__( 'Sorry, no products matched your selection. Please choose a different combination.', 'sportspress' ),
|
|
||||||
'i18n_unavailable_text' => esc_attr__( 'Sorry, this product is unavailable. Please choose a different combination.', 'sportspress' ),
|
|
||||||
) ) );
|
|
||||||
|
|
||||||
wp_localize_script( 'sp-country-select', 'sp_country_select_params', apply_filters( 'sp_country_select_params', array(
|
|
||||||
'countries' => json_encode( array_merge( SP()->countries->get_allowed_country_states(), SP()->countries->get_shipping_country_states() ) ),
|
|
||||||
'i18n_select_state_text' => esc_attr__( 'Select an option…', 'sportspress' ),
|
|
||||||
) ) );
|
|
||||||
|
|
||||||
// CSS Styles
|
|
||||||
$enqueue_styles = $this->get_styles();
|
|
||||||
|
|
||||||
if ( $enqueue_styles )
|
|
||||||
foreach ( $enqueue_styles as $handle => $args )
|
|
||||||
wp_enqueue_style( $handle, $args['src'], $args['deps'], $args['version'], $args['media'] );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -198,21 +60,35 @@ class SP_Frontend_Scripts {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public function custom_css() {
|
||||||
* Provide backwards compat for old constant
|
$enabled = get_option( 'sportspress_enable_frontend_css', 'yes' );
|
||||||
* @param array $styles
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function backwards_compat( $styles ) {
|
|
||||||
if ( defined( 'WOOCOMMERCE_USE_CSS' ) ) {
|
|
||||||
|
|
||||||
_deprecated_function( 'WOOCOMMERCE_USE_CSS', '2.1', 'Styles should be removed using wp_deregister_style or the sportspress_enqueue_styles filter rather than the WOOCOMMERCE_USE_CSS constant.' );
|
if ( $enabled == 'yes' ) {
|
||||||
|
|
||||||
if ( ! WOOCOMMERCE_USE_CSS )
|
$colors = get_option( 'sportspress_frontend_css_colors' );
|
||||||
return false;
|
|
||||||
|
if ( sizeof( $colors ) > 0 ) {
|
||||||
|
|
||||||
|
echo '<style type="text/css">';
|
||||||
|
|
||||||
|
if ( isset( $colors['primary'] ) )
|
||||||
|
echo '.sp-data-table th,.sp-calendar th,.sp-data-table tfoot,.sp-calendar tfoot{background:' . $colors['primary'] . ' !important}.sp-data-table tbody a,.sp-calendar tbody a{color:' . $colors['primary'] . ' !important}';
|
||||||
|
|
||||||
|
if ( isset( $colors['heading'] ) )
|
||||||
|
echo '.sp-data-table th,.sp-data-table th a,.sp-data-table tfoot,.sp-data-table tfoot a,.sp-calendar th,.sp-calendar th a,.sp-calendar tfoot,.sp-calendar tfoot a{color: ' . $colors['heading'] . ' !important}';
|
||||||
|
|
||||||
|
if ( isset( $colors['text'] ) )
|
||||||
|
echo '.sp-data-table tbody,.sp-calendar tbody{color: ' . $colors['text'] . ' !important}';
|
||||||
|
|
||||||
|
if ( isset( $colors['background'] ) )
|
||||||
|
echo '.sp-data-table tbody,.sp-calendar tbody{background: ' . $colors['background'] . ' !important}';
|
||||||
|
|
||||||
|
if ( isset( $colors['alternatea'] ) )
|
||||||
|
echo '.sp-data-table tbody tr.odd,.sp-data-table tbody tr.alternate,.sp-calendar tbody td#today{background: ' . $colors['alternatea'] . ' !important}';
|
||||||
|
|
||||||
|
echo '</style>';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $styles;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
509
includes/class-sp-install.php
Normal file
509
includes/class-sp-install.php
Normal file
@@ -0,0 +1,509 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Installation related functions and actions.
|
||||||
|
*
|
||||||
|
* @author ThemeBoy
|
||||||
|
* @category Admin
|
||||||
|
* @package SportsPress/Classes
|
||||||
|
* @version 0.7
|
||||||
|
*/
|
||||||
|
|
||||||
|
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||||
|
|
||||||
|
if ( ! class_exists( 'SP_Install' ) ) :
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SP_Install Class
|
||||||
|
*/
|
||||||
|
class SP_Install {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hook in tabs.
|
||||||
|
*/
|
||||||
|
public function __construct() {
|
||||||
|
register_activation_hook( SP_PLUGIN_FILE, array( $this, 'install' ) );
|
||||||
|
|
||||||
|
add_action( 'admin_init', array( $this, 'install_actions' ) );
|
||||||
|
add_action( 'admin_init', array( $this, 'check_version' ), 5 );
|
||||||
|
add_action( 'in_plugin_update_message-sportspress/sportspress.php', array( $this, 'in_plugin_update_message' ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* check_version function.
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function check_version() {
|
||||||
|
if ( ! defined( 'IFRAME_REQUEST' ) && get_option( 'sportspress_version' ) != SP()->version ) {
|
||||||
|
$this->install();
|
||||||
|
|
||||||
|
do_action( 'sportspress_updated' );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Install actions such as installing pages when a button is clicked.
|
||||||
|
*/
|
||||||
|
public function install_actions() {
|
||||||
|
// Install - Add pages button
|
||||||
|
if ( ! empty( $_GET['install_sportspress_pages'] ) ) {
|
||||||
|
|
||||||
|
// We no longer need to install pages
|
||||||
|
delete_option( '_sp_needs_pages' );
|
||||||
|
delete_transient( '_sp_activation_redirect' );
|
||||||
|
|
||||||
|
// What's new redirect
|
||||||
|
wp_redirect( admin_url( 'index.php?page=sp-about&sp-installed=true' ) );
|
||||||
|
exit;
|
||||||
|
|
||||||
|
// Skip button
|
||||||
|
} elseif ( ! empty( $_GET['skip_install_sportspress_pages'] ) ) {
|
||||||
|
|
||||||
|
// We no longer need to install pages
|
||||||
|
delete_option( '_sp_needs_pages' );
|
||||||
|
delete_transient( '_sp_activation_redirect' );
|
||||||
|
|
||||||
|
// What's new redirect
|
||||||
|
wp_redirect( admin_url( 'index.php?page=sp-about' ) );
|
||||||
|
exit;
|
||||||
|
|
||||||
|
// Update button
|
||||||
|
} elseif ( ! empty( $_GET['do_update_sportspress'] ) ) {
|
||||||
|
|
||||||
|
$this->update();
|
||||||
|
|
||||||
|
// Update complete
|
||||||
|
delete_option( '_sp_needs_pages' );
|
||||||
|
delete_option( '_sp_needs_update' );
|
||||||
|
delete_transient( '_sp_activation_redirect' );
|
||||||
|
|
||||||
|
// What's new redirect
|
||||||
|
wp_redirect( admin_url( 'index.php?page=sp-about&sp-updated=true' ) );
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Install SP
|
||||||
|
*/
|
||||||
|
public function install() {
|
||||||
|
$this->create_options();
|
||||||
|
$this->create_roles();
|
||||||
|
|
||||||
|
// Register post types
|
||||||
|
include_once( 'class-sp-post-types.php' );
|
||||||
|
SP_Post_types::register_post_types();
|
||||||
|
SP_Post_types::register_taxonomies();
|
||||||
|
|
||||||
|
// Queue upgrades
|
||||||
|
$current_version = get_option( 'sportspress_version', null );
|
||||||
|
$current_db_version = get_option( 'sportspress_db_version', null );
|
||||||
|
|
||||||
|
if ( version_compare( $current_db_version, '2.1.0', '<' ) && null !== $current_db_version ) {
|
||||||
|
update_option( '_sp_needs_update', 1 );
|
||||||
|
} else {
|
||||||
|
update_option( 'sportspress_db_version', SP()->version );
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update version
|
||||||
|
update_option( 'sportspress_version', SP()->version );
|
||||||
|
|
||||||
|
// Flush rules after install
|
||||||
|
flush_rewrite_rules();
|
||||||
|
|
||||||
|
// Redirect to welcome screen
|
||||||
|
set_transient( '_sp_activation_redirect', 1, 60 * 60 );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle updates
|
||||||
|
*/
|
||||||
|
public function update() {
|
||||||
|
// Do updates
|
||||||
|
$current_db_version = get_option( 'sportspress_db_version' );
|
||||||
|
|
||||||
|
if ( version_compare( $current_db_version, '1.4', '<' ) ) {
|
||||||
|
include( 'updates/sportspress-update-1.4.php' );
|
||||||
|
update_option( 'sportspress_db_version', '1.4' );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( version_compare( $current_db_version, '1.5', '<' ) ) {
|
||||||
|
include( 'updates/sportspress-update-1.5.php' );
|
||||||
|
update_option( 'sportspress_db_version', '1.5' );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( version_compare( $current_db_version, '2.0', '<' ) ) {
|
||||||
|
include( 'updates/sportspress-update-2.0.php' );
|
||||||
|
update_option( 'sportspress_db_version', '2.0' );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( version_compare( $current_db_version, '2.0.9', '<' ) ) {
|
||||||
|
include( 'updates/sportspress-update-2.0.9.php' );
|
||||||
|
update_option( 'sportspress_db_version', '2.0.9' );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( version_compare( $current_db_version, '2.0.14', '<' ) ) {
|
||||||
|
if ( 'HU' == get_option( 'sportspress_default_country' ) ) {
|
||||||
|
update_option( 'sportspress_default_country', 'HU:BU' );
|
||||||
|
}
|
||||||
|
|
||||||
|
update_option( 'sportspress_db_version', '2.0.14' );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( version_compare( $current_db_version, '2.1.0', '<' ) || SP_VERSION == '2.1-bleeding' ) {
|
||||||
|
include( 'updates/sportspress-update-2.1.php' );
|
||||||
|
update_option( 'sportspress_db_version', '2.1.0' );
|
||||||
|
}
|
||||||
|
|
||||||
|
update_option( 'sportspress_db_version', SP()->version );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default options
|
||||||
|
*
|
||||||
|
* Sets up the default options used on the settings page
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
|
function create_options() {
|
||||||
|
// Include settings so that we can run through defaults
|
||||||
|
include_once( 'admin/class-sp-admin-settings.php' );
|
||||||
|
|
||||||
|
$settings = SP_Admin_Settings::get_settings_pages();
|
||||||
|
|
||||||
|
foreach ( $settings as $section ) {
|
||||||
|
foreach ( $section->get_settings() as $value ) {
|
||||||
|
if ( isset( $value['default'] ) && isset( $value['id'] ) ) {
|
||||||
|
$autoload = isset( $value['autoload'] ) ? (bool) $value['autoload'] : true;
|
||||||
|
add_option( $value['id'], $value['default'], '', ( $autoload ? 'yes' : 'no' ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create roles and capabilities
|
||||||
|
*/
|
||||||
|
public function create_roles() {
|
||||||
|
global $wp_roles;
|
||||||
|
|
||||||
|
if ( class_exists( 'WP_Roles' ) ) {
|
||||||
|
if ( ! isset( $wp_roles ) ) {
|
||||||
|
$wp_roles = new WP_Roles();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( is_object( $wp_roles ) ) {
|
||||||
|
|
||||||
|
add_role(
|
||||||
|
'sp_player',
|
||||||
|
__( 'Player', 'sportspress' ),
|
||||||
|
array(
|
||||||
|
'read' => true,
|
||||||
|
'edit_posts' => true,
|
||||||
|
'delete_posts' => true,
|
||||||
|
'upload_files' => true,
|
||||||
|
|
||||||
|
'edit_sp_player' => true,
|
||||||
|
'edit_sp_players' => true,
|
||||||
|
'read_sp_players' => true,
|
||||||
|
'delete_sp_players' => true,
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
add_role(
|
||||||
|
'sp_staff',
|
||||||
|
__( 'Staff', 'sportspress' ),
|
||||||
|
array(
|
||||||
|
'read' => true,
|
||||||
|
'edit_posts' => true,
|
||||||
|
'delete_posts' => true,
|
||||||
|
'upload_files' => true,
|
||||||
|
|
||||||
|
'edit_sp_staff' => true,
|
||||||
|
'edit_sp_staffs' => true,
|
||||||
|
'read_sp_staffs' => true,
|
||||||
|
'delete_sp_staffs' => true,
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
add_role(
|
||||||
|
'sp_team_manager',
|
||||||
|
__( 'Team Manager', 'sportspress' ),
|
||||||
|
array(
|
||||||
|
'read' => true,
|
||||||
|
'edit_posts' => true,
|
||||||
|
'delete_posts' => true,
|
||||||
|
'upload_files' => true,
|
||||||
|
|
||||||
|
'edit_sp_player' => true,
|
||||||
|
'edit_sp_players' => true,
|
||||||
|
'edit_private_sp_players' => true,
|
||||||
|
'edit_published_sp_players' => true,
|
||||||
|
'read_sp_players' => true,
|
||||||
|
'read_private_sp_players' => true,
|
||||||
|
'publish_sp_players' => true,
|
||||||
|
'delete_sp_players' => true,
|
||||||
|
'delete_private_sp_players' => true,
|
||||||
|
'delete_published_sp_players' => true,
|
||||||
|
|
||||||
|
'edit_sp_staff' => true,
|
||||||
|
'edit_sp_staffs' => true,
|
||||||
|
'edit_private_sp_staffs' => true,
|
||||||
|
'edit_published_sp_staffs' => true,
|
||||||
|
'read_sp_staffs' => true,
|
||||||
|
'read_private_sp_staffs' => true,
|
||||||
|
'publish_sp_staffs' => true,
|
||||||
|
'delete_sp_staffs' => true,
|
||||||
|
'delete_private_sp_staffs' => true,
|
||||||
|
'delete_published_sp_staffs' => true,
|
||||||
|
|
||||||
|
'edit_sp_team' => true,
|
||||||
|
'edit_sp_teams' => true,
|
||||||
|
'read_sp_teams' => true,
|
||||||
|
'delete_sp_teams' => true,
|
||||||
|
|
||||||
|
'edit_sp_list' => true,
|
||||||
|
'edit_sp_lists' => true,
|
||||||
|
'read_sp_lists' => true,
|
||||||
|
'delete_sp_lists' => true,
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
// League manager role
|
||||||
|
add_role( 'sp_league_manager', __( 'League Manager', 'sportspress' ), array(
|
||||||
|
'level_9' => true,
|
||||||
|
'level_8' => true,
|
||||||
|
'level_7' => true,
|
||||||
|
'level_6' => true,
|
||||||
|
'level_5' => true,
|
||||||
|
'level_4' => true,
|
||||||
|
'level_3' => true,
|
||||||
|
'level_2' => true,
|
||||||
|
'level_1' => true,
|
||||||
|
'level_0' => true,
|
||||||
|
'read' => true,
|
||||||
|
'read_private_pages' => true,
|
||||||
|
'read_private_posts' => true,
|
||||||
|
'edit_users' => true,
|
||||||
|
'edit_posts' => true,
|
||||||
|
'edit_pages' => true,
|
||||||
|
'edit_published_posts' => true,
|
||||||
|
'edit_published_pages' => true,
|
||||||
|
'edit_private_pages' => true,
|
||||||
|
'edit_private_posts' => true,
|
||||||
|
'edit_others_posts' => true,
|
||||||
|
'edit_others_pages' => true,
|
||||||
|
'publish_posts' => true,
|
||||||
|
'publish_pages' => true,
|
||||||
|
'delete_posts' => true,
|
||||||
|
'delete_pages' => true,
|
||||||
|
'delete_private_pages' => true,
|
||||||
|
'delete_private_posts' => true,
|
||||||
|
'delete_published_pages' => true,
|
||||||
|
'delete_published_posts' => true,
|
||||||
|
'delete_others_posts' => true,
|
||||||
|
'delete_others_pages' => true,
|
||||||
|
'manage_categories' => true,
|
||||||
|
'manage_links' => true,
|
||||||
|
'moderate_comments' => true,
|
||||||
|
'unfiltered_html' => true,
|
||||||
|
'upload_files' => true,
|
||||||
|
'export' => true,
|
||||||
|
'import' => true,
|
||||||
|
'list_users' => true
|
||||||
|
) );
|
||||||
|
|
||||||
|
$capabilities = $this->get_core_capabilities();
|
||||||
|
|
||||||
|
foreach ( $capabilities as $cap_group ) {
|
||||||
|
foreach ( $cap_group as $cap ) {
|
||||||
|
$wp_roles->add_cap( 'sp_league_manager', $cap );
|
||||||
|
$wp_roles->add_cap( 'administrator', $cap );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get capabilities for SportsPress - these are assigned to admin/shop manager during installation or reset
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function get_core_capabilities() {
|
||||||
|
$capabilities = array();
|
||||||
|
|
||||||
|
$capabilities['core'] = array(
|
||||||
|
'manage_sportspress',
|
||||||
|
'view_sportspress_reports'
|
||||||
|
);
|
||||||
|
|
||||||
|
$capability_types = array( 'sp_config', 'sp_event', 'sp_calendar', 'sp_team', 'sp_table', 'sp_player', 'sp_list', 'sp_staff' );
|
||||||
|
|
||||||
|
foreach ( $capability_types as $capability_type ) {
|
||||||
|
|
||||||
|
$capabilities[ $capability_type ] = array(
|
||||||
|
// Post type
|
||||||
|
"edit_{$capability_type}",
|
||||||
|
"read_{$capability_type}",
|
||||||
|
"delete_{$capability_type}",
|
||||||
|
"edit_{$capability_type}s",
|
||||||
|
"edit_others_{$capability_type}s",
|
||||||
|
"publish_{$capability_type}s",
|
||||||
|
"read_private_{$capability_type}s",
|
||||||
|
"delete_{$capability_type}s",
|
||||||
|
"delete_private_{$capability_type}s",
|
||||||
|
"delete_published_{$capability_type}s",
|
||||||
|
"delete_others_{$capability_type}s",
|
||||||
|
"edit_private_{$capability_type}s",
|
||||||
|
"edit_published_{$capability_type}s",
|
||||||
|
|
||||||
|
// Terms
|
||||||
|
"manage_{$capability_type}_terms",
|
||||||
|
"edit_{$capability_type}_terms",
|
||||||
|
"delete_{$capability_type}_terms",
|
||||||
|
"assign_{$capability_type}_terms"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $capabilities;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* sportspress_remove_roles function.
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function remove_roles() {
|
||||||
|
global $wp_roles;
|
||||||
|
|
||||||
|
if ( class_exists( 'WP_Roles' ) ) {
|
||||||
|
if ( ! isset( $wp_roles ) ) {
|
||||||
|
$wp_roles = new WP_Roles();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( is_object( $wp_roles ) ) {
|
||||||
|
|
||||||
|
$capabilities = $this->get_core_capabilities();
|
||||||
|
|
||||||
|
foreach ( $capabilities as $cap_group ) {
|
||||||
|
foreach ( $cap_group as $cap ) {
|
||||||
|
$wp_roles->remove_cap( 'sp_player', $cap );
|
||||||
|
$wp_roles->remove_cap( 'sp_staff', $cap );
|
||||||
|
$wp_roles->remove_cap( 'sp_team_manager', $cap );
|
||||||
|
$wp_roles->remove_cap( 'sp_league_manager', $cap );
|
||||||
|
$wp_roles->remove_cap( 'administrator', $cap );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
remove_role( 'sp_player' );
|
||||||
|
remove_role( 'sp_staff' );
|
||||||
|
remove_role( 'sp_team_manager' );
|
||||||
|
remove_role( 'sp_league_manager' );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Active plugins pre update option filter
|
||||||
|
*
|
||||||
|
* @param string $new_value
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function pre_update_option_active_plugins( $new_value ) {
|
||||||
|
$old_value = (array) get_option( 'active_plugins' );
|
||||||
|
|
||||||
|
if ( $new_value !== $old_value && in_array( W3TC_FILE, (array) $new_value ) && in_array( W3TC_FILE, (array) $old_value ) ) {
|
||||||
|
$this->_config->set( 'notes.plugins_updated', true );
|
||||||
|
try {
|
||||||
|
$this->_config->save();
|
||||||
|
} catch( Exception $ex ) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $new_value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show plugin changes. Code adapted from W3 Total Cache.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
function in_plugin_update_message() {
|
||||||
|
$response = wp_remote_get( 'https://plugins.svn.wordpress.org/sportspress/trunk/readme.txt' );
|
||||||
|
|
||||||
|
if ( ! is_wp_error( $response ) && ! empty( $response['body'] ) ) {
|
||||||
|
|
||||||
|
// Output Upgrade Notice
|
||||||
|
$matches = null;
|
||||||
|
$regexp = '~==\s*Upgrade Notice\s*==\s*=\s*(.*)\s*=(.*)(=\s*' . preg_quote( SP_VERSION ) . '\s*=|$)~Uis';
|
||||||
|
|
||||||
|
if ( preg_match( $regexp, $response['body'], $matches ) ) {
|
||||||
|
$version = trim( $matches[1] );
|
||||||
|
$notices = (array) preg_split('~[\r\n]+~', trim( $matches[2] ) );
|
||||||
|
|
||||||
|
if ( version_compare( SP_VERSION, $version, '<' ) ) {
|
||||||
|
|
||||||
|
echo '<div style="font-weight: normal; background: #cc99c2; color: #fff !important; border: 1px solid #b76ca9; padding: 9px; margin: 9px 0;">';
|
||||||
|
|
||||||
|
foreach ( $notices as $index => $line ) {
|
||||||
|
echo '<p style="margin: 0; font-size: 1.1em; color: #fff; text-shadow: 0 1px 1px #b574a8;">' . wp_kses_post( preg_replace( '~\[([^\]]*)\]\(([^\)]*)\)~', '<a href="${2}">${1}</a>', $line ) ) . '</p>';
|
||||||
|
}
|
||||||
|
|
||||||
|
echo '</div> ';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Output Changelog
|
||||||
|
$matches = null;
|
||||||
|
$regexp = '~==\s*Changelog\s*==\s*=\s*[0-9.]+\s*-(.*)=(.*)(=\s*' . preg_quote( SP_VERSION ) . '\s*-(.*)=|$)~Uis';
|
||||||
|
|
||||||
|
if ( preg_match( $regexp, $response['body'], $matches ) ) {
|
||||||
|
$changelog = (array) preg_split( '~[\r\n]+~', trim( $matches[2] ) );
|
||||||
|
|
||||||
|
echo __( 'What\'s new:', 'sportspress' ) . '<div style="font-weight: normal;">';
|
||||||
|
|
||||||
|
$ul = false;
|
||||||
|
|
||||||
|
foreach ( $changelog as $index => $line ) {
|
||||||
|
if ( preg_match('~^\s*\*\s*~', $line ) ) {
|
||||||
|
if ( ! $ul ) {
|
||||||
|
echo '<ul style="list-style: disc inside; margin: 9px 0 9px 20px; overflow:hidden; zoom: 1;">';
|
||||||
|
$ul = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
$line = preg_replace( '~^\s*\*\s*~', '', htmlspecialchars( $line ) );
|
||||||
|
|
||||||
|
echo '<li style="width: 50%; margin: 0; float: left; ' . ( $index % 2 == 0 ? 'clear: left;' : '' ) . '">' . esc_html( $line ) . '</li>';
|
||||||
|
} else {
|
||||||
|
|
||||||
|
$version = trim( current( explode( '-', str_replace( '=', '', $line ) ) ) );
|
||||||
|
|
||||||
|
if ( version_compare( SP_VERSION, $version, '>=' ) ) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( $ul ) {
|
||||||
|
echo '</ul>';
|
||||||
|
$ul = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
echo '<p style="margin: 9px 0;">' . esc_html( htmlspecialchars( $line ) ) . '</p>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( $ul ) {
|
||||||
|
echo '</ul>';
|
||||||
|
}
|
||||||
|
|
||||||
|
echo '</div>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
endif;
|
||||||
|
|
||||||
|
return new SP_Install();
|
||||||
@@ -13,7 +13,7 @@
|
|||||||
class SP_Text {
|
class SP_Text {
|
||||||
|
|
||||||
/** @var array Array of text */
|
/** @var array Array of text */
|
||||||
public $text;
|
public $data;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor for the text class - defines all editable strings.
|
* Constructor for the text class - defines all editable strings.
|
||||||
@@ -22,40 +22,68 @@ class SP_Text {
|
|||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
$strings = array(
|
$this->data = apply_filters( 'sportspress_text', array(
|
||||||
__( 'Article', 'sportspress' ),
|
'general' => array(
|
||||||
__( 'Current Team', 'sportspress' ),
|
'league' => __( 'League', 'sportspress' ),
|
||||||
__( 'Date', 'sportspress' ),
|
'season' => __( 'Season', 'sportspress' ),
|
||||||
__( 'Details', 'sportspress' ),
|
),
|
||||||
__( 'days', 'sportspress' ),
|
'event' => array(
|
||||||
__( 'Event', 'sportspress' ),
|
'event' => __( 'Event', 'sportspress' ),
|
||||||
__( 'Friendly', 'sportspress' ),
|
'date' => __( 'Date', 'sportspress' ),
|
||||||
__( 'hrs', 'sportspress' ),
|
'time' => __( 'Time', 'sportspress' ),
|
||||||
__( 'League', 'sportspress' ),
|
'results' => __( 'Results', 'sportspress' ),
|
||||||
__( 'mins', 'sportspress' ),
|
'team' => __( 'Team', 'sportspress' ),
|
||||||
__( 'Nationality', 'sportspress' ),
|
'teams' => __( 'Teams', 'sportspress' ),
|
||||||
__( 'Past Teams', 'sportspress' ),
|
'details' => __( 'Details', 'sportspress' ),
|
||||||
__( 'Player', 'sportspress' ),
|
'venue' => __( 'Venue', 'sportspress' ),
|
||||||
__( 'Position', 'sportspress' ),
|
'player' => __( 'Player', 'sportspress' ),
|
||||||
__( 'Pos', 'sportspress' ),
|
'substitutes' => __( 'Substitutes', 'sportspress' ),
|
||||||
__( 'Preview', 'sportspress' ),
|
'total' => __( 'Total', 'sportspress' ),
|
||||||
__( 'Rank', 'sportspress' ),
|
'article' => __( 'Article', 'sportspress' ),
|
||||||
__( 'Recap', 'sportspress' ),
|
'preview' => __( 'Preview', 'sportspress' ),
|
||||||
__( 'Results', 'sportspress' ),
|
'recap' => __( 'Recap', 'sportspress' ),
|
||||||
__( 'Season', 'sportspress' ),
|
'view_all_events' => __( 'View all events', 'sportspress' ),
|
||||||
__( 'secs', 'sportspress' ),
|
),
|
||||||
__( 'Staff', 'sportspress' ),
|
'team' => array(
|
||||||
__( 'Substitute', 'sportspress' ),
|
'team' => __( 'Team', 'sportspress' ),
|
||||||
__( 'Team', 'sportspress' ),
|
'teams' => __( 'Teams', 'sportspress' ),
|
||||||
__( 'Teams', 'sportspress' ),
|
'pos' => __( 'Pos', 'sportspress' ),
|
||||||
__( 'Time', 'sportspress' ),
|
'view_full_table' => __( 'View full table', 'sportspress' ),
|
||||||
__( 'Total', 'sportspress' ),
|
),
|
||||||
__( 'Venue', 'sportspress' ),
|
'player' => array(
|
||||||
__( 'View all players', 'sportspress' ),
|
'player' => __( 'Player', 'sportspress' ),
|
||||||
__( 'View all events', 'sportspress' ),
|
'position' => __( 'Position', 'sportspress' ),
|
||||||
__( 'View full table', 'sportspress' ),
|
'nationality' => __( 'Nationality', 'sportspress' ),
|
||||||
);
|
'current_team' => __( 'Current Team', 'sportspress' ),
|
||||||
sort( $strings );
|
'past_teams' => __( 'Past Teams', 'sportspress' ),
|
||||||
$this->strings = apply_filters( 'sportspress_text', $strings );
|
'rank' => __( 'Rank', 'sportspress' ),
|
||||||
|
'view_all_players' => __( 'View all players', 'sportspress' ),
|
||||||
|
),
|
||||||
|
'staff' => array(
|
||||||
|
'staff' => __( 'Staff', 'sportspress' ),
|
||||||
|
),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function __get( $key ) {
|
||||||
|
return ( array_key_exists( $key, $this->data ) ? $this->data[ $key ] : null );
|
||||||
|
}
|
||||||
|
|
||||||
|
public function __set( $key, $value ){
|
||||||
|
$this->data[ $key ] = $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function string( $key, $context = null ){
|
||||||
|
$key = str_replace( '-', '_', sanitize_title( $key ) );
|
||||||
|
|
||||||
|
if ( $context == null )
|
||||||
|
$context = 'general';
|
||||||
|
|
||||||
|
if ( array_key_exists( $context, $this->data ) && array_key_exists( $key, $this->data[ $context ] ) ):
|
||||||
|
$string = get_option( 'sportspress_' . ( $context == 'general' ? '' : $context . '_' ) . $key . '_text' );
|
||||||
|
return ( empty( $string ) ? $this->data[ $context ][ $key ] : $string );
|
||||||
|
else:
|
||||||
|
return $key;
|
||||||
|
endif;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
|||||||
|
|
||||||
// Include core functions
|
// Include core functions
|
||||||
include( 'sp-conditional-functions.php' );
|
include( 'sp-conditional-functions.php' );
|
||||||
|
include( 'sp-formatting-functions.php' );
|
||||||
include( 'sp-deprecated-functions.php' );
|
include( 'sp-deprecated-functions.php' );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -181,21 +182,9 @@ if( !function_exists( 'date_diff' ) ) {
|
|||||||
if ( !function_exists( 'sp_flush_rewrite_rules' ) ) {
|
if ( !function_exists( 'sp_flush_rewrite_rules' ) ) {
|
||||||
function sp_flush_rewrite_rules() {
|
function sp_flush_rewrite_rules() {
|
||||||
// Flush rewrite rules
|
// Flush rewrite rules
|
||||||
sportspress_result_post_init();
|
$post_types = new SP_Post_types();
|
||||||
sportspress_outcome_post_init();
|
$post_types->register_taxonomies();
|
||||||
sportspress_column_post_init();
|
$post_types->register_post_types();
|
||||||
sportspress_performance_post_init();
|
|
||||||
sportspress_event_post_init();
|
|
||||||
sportspress_calendar_post_init();
|
|
||||||
sportspress_team_post_init();
|
|
||||||
sportspress_table_post_init();
|
|
||||||
sportspress_player_post_init();
|
|
||||||
sportspress_list_post_init();
|
|
||||||
sportspress_staff_post_init();
|
|
||||||
sportspress_venue_term_init();
|
|
||||||
sportspress_league_term_init();
|
|
||||||
sportspress_season_term_init();
|
|
||||||
sportspress_position_term_init();
|
|
||||||
flush_rewrite_rules();
|
flush_rewrite_rules();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2195,7 +2184,7 @@ if ( !function_exists( 'sp_get_league_table_data' ) ) {
|
|||||||
unset( $columns[ $key ] );
|
unset( $columns[ $key ] );
|
||||||
endif;
|
endif;
|
||||||
endforeach;
|
endforeach;
|
||||||
$labels = array_merge( array( 'name' => __( 'Team', 'sportspress' ) ), $columns );
|
$labels = array_merge( array( 'name' => SP()->text->string('Team', 'team') ), $columns );
|
||||||
$merged[0] = $labels;
|
$merged[0] = $labels;
|
||||||
return $merged;
|
return $merged;
|
||||||
endif;
|
endif;
|
||||||
@@ -2388,7 +2377,7 @@ if ( !function_exists( 'sp_get_player_list_data' ) ) {
|
|||||||
);
|
);
|
||||||
$performances = get_posts( $args );
|
$performances = get_posts( $args );
|
||||||
|
|
||||||
$columns = array( 'eventsplayed' => __( 'Played', 'sportspress' ) );
|
$columns = array( 'eventsplayed' => SP()->text->string('Played', 'team') );
|
||||||
|
|
||||||
foreach ( $performances as $performance ):
|
foreach ( $performances as $performance ):
|
||||||
|
|
||||||
@@ -2491,7 +2480,7 @@ if ( !function_exists( 'sp_get_player_list_data' ) ) {
|
|||||||
unset( $columns[ $key ] );
|
unset( $columns[ $key ] );
|
||||||
endif;
|
endif;
|
||||||
endforeach;
|
endforeach;
|
||||||
$labels = array_merge( array( 'name' => __( 'Player', 'sportspress' ) ), $columns );
|
$labels = array_merge( array( 'name' => SP()->text->string('Player', 'player') ), $columns );
|
||||||
$merged[0] = $labels;
|
$merged[0] = $labels;
|
||||||
return $merged;
|
return $merged;
|
||||||
endif;
|
endif;
|
||||||
@@ -2654,7 +2643,7 @@ if ( !function_exists( 'sp_get_player_roster_data' ) ) {
|
|||||||
);
|
);
|
||||||
$performances = get_posts( $args );
|
$performances = get_posts( $args );
|
||||||
|
|
||||||
$columns = array( 'eventsplayed' => __( 'Played', 'sportspress' ) );
|
$columns = array( 'eventsplayed' => SP()->text->string('Played', 'player') );
|
||||||
|
|
||||||
foreach ( $performances as $performance ):
|
foreach ( $performances as $performance ):
|
||||||
|
|
||||||
@@ -2750,7 +2739,7 @@ if ( !function_exists( 'sp_get_player_roster_data' ) ) {
|
|||||||
if ( $admin ):
|
if ( $admin ):
|
||||||
return array( $columns, $data, $placeholders, $merged );
|
return array( $columns, $data, $placeholders, $merged );
|
||||||
else:
|
else:
|
||||||
$labels = array_merge( array( 'name' => __( 'Player', 'sportspress' ) ), $columns );
|
$labels = array_merge( array( 'name' => SP()->text->string('Player', 'player') ), $columns );
|
||||||
$merged[0] = $labels;
|
$merged[0] = $labels;
|
||||||
return $merged;
|
return $merged;
|
||||||
endif;
|
endif;
|
||||||
@@ -2856,7 +2845,7 @@ if ( !function_exists( 'sp_get_player_performance_data' ) ) {
|
|||||||
$performance_labels[ $performance->post_name ] = $performance->post_title;
|
$performance_labels[ $performance->post_name ] = $performance->post_title;
|
||||||
$equations[ $performance->post_name ] = get_post_meta( $performance->ID, 'sp_calculate', true );
|
$equations[ $performance->post_name ] = get_post_meta( $performance->ID, 'sp_calculate', true );
|
||||||
endforeach;
|
endforeach;
|
||||||
$columns = array_merge( array( 'eventsplayed' => __( 'Played', 'sportspress' ) ), $performance_labels );
|
$columns = array_merge( array( 'eventsplayed' => SP()->text->string('Played', 'player') ), $performance_labels );
|
||||||
|
|
||||||
// Generate array of all season ids and season names
|
// Generate array of all season ids and season names
|
||||||
$div_ids = array();
|
$div_ids = array();
|
||||||
@@ -2991,7 +2980,7 @@ if ( !function_exists( 'sp_get_player_performance_data' ) ) {
|
|||||||
if ( $admin ):
|
if ( $admin ):
|
||||||
return array( $columns, $tempdata, $placeholders, $merged, $seasons_teams );
|
return array( $columns, $tempdata, $placeholders, $merged, $seasons_teams );
|
||||||
else:
|
else:
|
||||||
$labels = array_merge( array( 'name' => __( 'Season', 'sportspress' ), 'team' => __( 'Team', 'sportspress' ), 'eventsplayed' => __( 'Played', 'sportspress' ) ), $columns );
|
$labels = array_merge( array( 'name' => SP()->text->string('Season'), 'team' => SP()->text->string('Team', 'player'), 'eventsplayed' => SP()->text->string('Played', 'player') ), $columns );
|
||||||
$merged[0] = $labels;
|
$merged[0] = $labels;
|
||||||
return $merged;
|
return $merged;
|
||||||
endif;
|
endif;
|
||||||
|
|||||||
211
includes/sp-formatting-functions.php
Normal file
211
includes/sp-formatting-functions.php
Normal file
@@ -0,0 +1,211 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* SportsPress Formatting
|
||||||
|
*
|
||||||
|
* Functions for formatting data.
|
||||||
|
*
|
||||||
|
* @author ThemeBoy
|
||||||
|
* @category Core
|
||||||
|
* @package SportsPress/Functions
|
||||||
|
* @version 0.7
|
||||||
|
*/
|
||||||
|
|
||||||
|
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sanitize taxonomy names. Slug format (no spaces, lowercase).
|
||||||
|
*
|
||||||
|
* Doesn't use sanitize_title as this destroys utf chars.
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @param mixed $taxonomy
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function sp_sanitize_taxonomy_name( $taxonomy ) {
|
||||||
|
$filtered = strtolower( remove_accents( stripslashes( strip_tags( $taxonomy ) ) ) );
|
||||||
|
$filtered = preg_replace( '/&.+?;/', '', $filtered ); // Kill entities
|
||||||
|
$filtered = str_replace( array( '.', '\'', '"' ), '', $filtered ); // Kill quotes and full stops.
|
||||||
|
$filtered = str_replace( array( ' ', '_' ), '-', $filtered ); // Replace spaces and underscores.
|
||||||
|
|
||||||
|
return apply_filters( 'sanitize_taxonomy_name', $filtered, $taxonomy );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clean variables
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @param string $var
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function sp_clean( $var ) {
|
||||||
|
return sanitize_text_field( $var );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Merge two arrays
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @param array $a1
|
||||||
|
* @param array $a2
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
function sp_array_overlay( $a1, $a2 ) {
|
||||||
|
foreach( $a1 as $k => $v ) {
|
||||||
|
if ( ! array_key_exists( $k, $a2 ) ) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if ( is_array( $v ) && is_array( $a2[ $k ] ) ) {
|
||||||
|
$a1[ $k ] = sp_array_overlay( $v, $a2[ $k ] );
|
||||||
|
} else {
|
||||||
|
$a1[ $k ] = $a2[ $k ];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $a1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SportsPress Date Format - Allows to change date format for everything SportsPress
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function sp_date_format() {
|
||||||
|
return apply_filters( 'sportspress_date_format', get_option( 'date_format' ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SportsPress Time Format - Allows to change time format for everything SportsPress
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function sp_time_format() {
|
||||||
|
return apply_filters( 'sportspress_time_format', get_option( 'time_format' ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( ! function_exists( 'sp_rgb_from_hex' ) ) {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hex darker/lighter/contrast functions for colours
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @param mixed $color
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function sp_rgb_from_hex( $color ) {
|
||||||
|
$color = str_replace( '#', '', $color );
|
||||||
|
// Convert shorthand colors to full format, e.g. "FFF" -> "FFFFFF"
|
||||||
|
$color = preg_replace( '~^(.)(.)(.)$~', '$1$1$2$2$3$3', $color );
|
||||||
|
|
||||||
|
$rgb['R'] = hexdec( $color{0}.$color{1} );
|
||||||
|
$rgb['G'] = hexdec( $color{2}.$color{3} );
|
||||||
|
$rgb['B'] = hexdec( $color{4}.$color{5} );
|
||||||
|
return $rgb;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( ! function_exists( 'sp_hex_darker' ) ) {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hex darker/lighter/contrast functions for colours
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @param mixed $color
|
||||||
|
* @param int $factor (default: 30)
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function sp_hex_darker( $color, $factor = 30 ) {
|
||||||
|
$base = sp_rgb_from_hex( $color );
|
||||||
|
$color = '#';
|
||||||
|
|
||||||
|
foreach ($base as $k => $v) :
|
||||||
|
$amount = $v / 100;
|
||||||
|
$amount = round($amount * $factor);
|
||||||
|
$new_decimal = $v - $amount;
|
||||||
|
|
||||||
|
$new_hex_component = dechex($new_decimal);
|
||||||
|
if(strlen($new_hex_component) < 2) :
|
||||||
|
$new_hex_component = "0".$new_hex_component;
|
||||||
|
endif;
|
||||||
|
$color .= $new_hex_component;
|
||||||
|
endforeach;
|
||||||
|
|
||||||
|
return $color;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( ! function_exists( 'sp_hex_lighter' ) ) {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hex darker/lighter/contrast functions for colours
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @param mixed $color
|
||||||
|
* @param int $factor (default: 30)
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function sp_hex_lighter( $color, $factor = 30 ) {
|
||||||
|
$base = sp_rgb_from_hex( $color );
|
||||||
|
$color = '#';
|
||||||
|
|
||||||
|
foreach ($base as $k => $v) :
|
||||||
|
$amount = 255 - $v;
|
||||||
|
$amount = $amount / 100;
|
||||||
|
$amount = round($amount * $factor);
|
||||||
|
$new_decimal = $v + $amount;
|
||||||
|
|
||||||
|
$new_hex_component = dechex($new_decimal);
|
||||||
|
if(strlen($new_hex_component) < 2) :
|
||||||
|
$new_hex_component = "0".$new_hex_component;
|
||||||
|
endif;
|
||||||
|
$color .= $new_hex_component;
|
||||||
|
endforeach;
|
||||||
|
|
||||||
|
return $color;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( ! function_exists( 'sp_light_or_dark' ) ) {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Detect if we should use a light or dark colour on a background colour
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @param mixed $color
|
||||||
|
* @param string $dark (default: '#000000')
|
||||||
|
* @param string $light (default: '#FFFFFF')
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function sp_light_or_dark( $color, $dark = '#000000', $light = '#FFFFFF' ) {
|
||||||
|
//return ( hexdec( $color ) > 0xffffff / 2 ) ? $dark : $light;
|
||||||
|
$hex = str_replace( '#', '', $color );
|
||||||
|
|
||||||
|
$c_r = hexdec( substr( $hex, 0, 2 ) );
|
||||||
|
$c_g = hexdec( substr( $hex, 2, 2 ) );
|
||||||
|
$c_b = hexdec( substr( $hex, 4, 2 ) );
|
||||||
|
$brightness = ( ( $c_r * 299 ) + ( $c_g * 587 ) + ( $c_b * 114 ) ) / 1000;
|
||||||
|
|
||||||
|
return $brightness > 155 ? $dark : $light;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( ! function_exists( 'sp_format_hex' ) ) {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Format string as hex
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @param string $hex
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function sp_format_hex( $hex ) {
|
||||||
|
|
||||||
|
$hex = trim( str_replace( '#', '', $hex ) );
|
||||||
|
|
||||||
|
if ( strlen( $hex ) == 3 ) {
|
||||||
|
$hex = $hex[0] . $hex[0] . $hex[1] . $hex[1] . $hex[2] . $hex[2];
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( $hex ) return '#' . $hex;
|
||||||
|
}
|
||||||
|
}
|
||||||
413
includes/sp-template-hooks.php
Normal file
413
includes/sp-template-hooks.php
Normal file
@@ -0,0 +1,413 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* SportsPress Template
|
||||||
|
*
|
||||||
|
* Functions for the templating system.
|
||||||
|
*
|
||||||
|
* @author ThemeBoy
|
||||||
|
* @category Core
|
||||||
|
* @package SportsPress/Functions
|
||||||
|
* @version 0.7
|
||||||
|
*/
|
||||||
|
|
||||||
|
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||||
|
|
||||||
|
function sportspress_plugins_loaded() {
|
||||||
|
|
||||||
|
// Load plugin textdomain
|
||||||
|
if ( function_exists( 'load_plugin_textdomain' ) ) {
|
||||||
|
load_plugin_textdomain ( 'sportspress', false, dirname( plugin_basename( SP_PLUGIN_FILE ) ) . '/languages/' );
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add image sizes
|
||||||
|
if ( function_exists( 'add_image_size' ) ) {
|
||||||
|
|
||||||
|
// Standard (3:2)
|
||||||
|
add_image_size( 'sportspress-standard', 637, 425, true );
|
||||||
|
add_image_size( 'sportspress-standard-thumbnail', 303, 202, true );
|
||||||
|
|
||||||
|
// Wide (16:9)
|
||||||
|
add_image_size( 'sportspress-wide-header', 1600, 900, true );
|
||||||
|
add_image_size( 'sportspress-wide', 637, 358, true );
|
||||||
|
add_image_size( 'sportspress-wide-thumbnail', 303, 170, true );
|
||||||
|
|
||||||
|
// Square (1:1)
|
||||||
|
add_image_size( 'sportspress-square', 637, 637, true );
|
||||||
|
add_image_size( 'sportspress-square-thumbnail', 303, 303, true );
|
||||||
|
|
||||||
|
// Fit (Proportional)
|
||||||
|
add_image_size( 'sportspress-fit', 637, 637, false );
|
||||||
|
add_image_size( 'sportspress-fit-thumbnail', 303, 303, false );
|
||||||
|
add_image_size( 'sportspress-fit-icon', 32, 32, false );
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
add_action( 'plugins_loaded', 'sportspress_plugins_loaded' );
|
||||||
|
|
||||||
|
function sportspress_default_venue_content( $query ) {
|
||||||
|
if ( ! is_tax( 'sp_venue' ) )
|
||||||
|
return;
|
||||||
|
|
||||||
|
$slug = sportspress_array_value( $query->query, 'sp_venue', null );
|
||||||
|
|
||||||
|
if ( ! $slug )
|
||||||
|
return;
|
||||||
|
|
||||||
|
$venue = get_term_by( 'slug', $slug, 'sp_venue' );
|
||||||
|
$t_id = $venue->term_id;
|
||||||
|
$venue_meta = get_option( "taxonomy_$t_id" );
|
||||||
|
$address = sportspress_array_value( $venue_meta, 'sp_address', null );
|
||||||
|
$latitude = sportspress_array_value( $venue_meta, 'sp_latitude', null );
|
||||||
|
$longitude = sportspress_array_value( $venue_meta, 'sp_longitude', null );
|
||||||
|
|
||||||
|
if ( $latitude != null && $longitude != null )
|
||||||
|
echo '<div class="sp-google-map" data-address="' . $address . '" data-latitude="' . $latitude . '" data-longitude="' . $longitude . '"></div>';
|
||||||
|
}
|
||||||
|
add_action( 'loop_start', 'sportspress_default_venue_content' );
|
||||||
|
|
||||||
|
function sportspress_the_title( $title, $id ) {
|
||||||
|
if ( is_singular( 'sp_player' ) && in_the_loop() && $id == get_the_ID() ):
|
||||||
|
$number = get_post_meta( $id, 'sp_number', true );
|
||||||
|
if ( $number != null ):
|
||||||
|
$title = '<strong>' . $number . '</strong> ' . $title;
|
||||||
|
endif;
|
||||||
|
endif;
|
||||||
|
return $title;
|
||||||
|
}
|
||||||
|
add_filter( 'the_title', 'sportspress_the_title', 10, 2 );
|
||||||
|
|
||||||
|
function sportspress_admin_notices_styles() {
|
||||||
|
$screen = get_current_screen();
|
||||||
|
|
||||||
|
if ( $screen->id != 'settings_page_sportspress' ):
|
||||||
|
if ( isset( $_REQUEST['sportspress_installed'] ) ):
|
||||||
|
update_option( 'sportspress_installed', $_REQUEST['sportspress_installed'] );
|
||||||
|
endif;
|
||||||
|
|
||||||
|
if ( ! get_option( 'sportspress_installed' ) ):
|
||||||
|
add_action( 'admin_notices', 'sportspress_admin_install_notices' );
|
||||||
|
endif;
|
||||||
|
endif;
|
||||||
|
|
||||||
|
$template = get_option( 'template' );
|
||||||
|
|
||||||
|
if ( ! current_theme_supports( 'sportspress' ) && ! in_array( $template, array( 'twentyfourteen', 'twentythirteen', 'twentyeleven', 'twentytwelve', 'twentyten' ) ) ):
|
||||||
|
if ( ! empty( $_GET['hide_sportspress_theme_support_check'] ) ):
|
||||||
|
update_option( 'sportspress_theme_support_check', $template );
|
||||||
|
return;
|
||||||
|
endif;
|
||||||
|
|
||||||
|
if ( get_option( 'sportspress_theme_support_check' ) !== $template ):
|
||||||
|
add_action( 'admin_notices', 'sportspress_theme_check_notice' );
|
||||||
|
endif;
|
||||||
|
endif;
|
||||||
|
}
|
||||||
|
add_action( 'admin_print_styles', 'sportspress_admin_notices_styles' );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* sportspress_admin_install_notices function.
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
function sportspress_admin_install_notices() {
|
||||||
|
// include( dirname( SP_PLUGIN_FILE ) . '/includes/admin/views/notice-install.php' );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* sportspress_theme_check_notice function.
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
function sportspress_theme_check_notice() {
|
||||||
|
// include( dirname( SP_PLUGIN_FILE ) . '/includes/admin/views/notice-theme-support.php' );
|
||||||
|
}
|
||||||
|
|
||||||
|
function sportspress_gettext( $translated_text, $untranslated_text, $domain ) {
|
||||||
|
if ( $domain != 'sportspress' )
|
||||||
|
return $translated_text;
|
||||||
|
|
||||||
|
global $typenow, $sportspress_options;
|
||||||
|
|
||||||
|
if ( is_admin() ):
|
||||||
|
if ( in_array( $typenow, array( 'sp_event', 'sp_team', 'sp_player', 'sp_staff' ) ) ):
|
||||||
|
switch ( $untranslated_text ):
|
||||||
|
case 'Author':
|
||||||
|
$translated_text = __( 'User', 'sportspress' );
|
||||||
|
break;
|
||||||
|
endswitch;
|
||||||
|
endif;
|
||||||
|
|
||||||
|
if ( in_array( $typenow, array( 'sp_event' ) ) ):
|
||||||
|
switch ( $untranslated_text ):
|
||||||
|
case 'Publish <b>immediately</b>':
|
||||||
|
$translated_text = __( 'Date/Time:', 'sportspress' ) . ' <b>' . __( 'Now', 'sportspress' ) . '</b>';
|
||||||
|
break;
|
||||||
|
endswitch;
|
||||||
|
endif;
|
||||||
|
else:
|
||||||
|
if ( $untranslated_text == 'Archives' && is_tax( 'sp_venue' ) ):
|
||||||
|
$slug = get_query_var( 'sp_venue' );
|
||||||
|
if ( $slug ):
|
||||||
|
$venue = get_term_by( 'slug', $slug, 'sp_venue' );
|
||||||
|
$translated_text = $venue->name;
|
||||||
|
endif;
|
||||||
|
endif;
|
||||||
|
if ( isset( $sportspress_options['text'] ) ):
|
||||||
|
foreach( $sportspress_options['text'] as $key => $value ):
|
||||||
|
if ( $translated_text == $key ):
|
||||||
|
$translated_text = $value;
|
||||||
|
endif;
|
||||||
|
endforeach;
|
||||||
|
endif;
|
||||||
|
endif;
|
||||||
|
|
||||||
|
return $translated_text;
|
||||||
|
}
|
||||||
|
add_filter( 'gettext', 'sportspress_gettext', 20, 3 );
|
||||||
|
|
||||||
|
function sportspress_pre_get_posts( $query ) {
|
||||||
|
|
||||||
|
if ( is_admin() ):
|
||||||
|
if ( isset( $query->query[ 'orderby' ] ) || isset( $query->query[ 'order' ] ) ):
|
||||||
|
return $query;
|
||||||
|
endif;
|
||||||
|
$post_type = $query->query['post_type'];
|
||||||
|
|
||||||
|
if ( in_array( $post_type, array( 'sp_result', 'sp_outcome', 'sp_column', 'sp_performance' ) ) ):
|
||||||
|
$query->set( 'orderby', 'menu_order' );
|
||||||
|
$query->set( 'order', 'ASC' );
|
||||||
|
elseif ( $post_type == 'sp_event' ):
|
||||||
|
$query->set( 'orderby', 'post_date' );
|
||||||
|
$query->set( 'order', 'ASC' );
|
||||||
|
endif;
|
||||||
|
else:
|
||||||
|
$post_type = $query->get( 'post_type' );
|
||||||
|
if ( $query->is_post_type_archive && $post_type == 'sp_event' ):
|
||||||
|
$query->set( 'order' , 'ASC' );
|
||||||
|
endif;
|
||||||
|
endif;
|
||||||
|
|
||||||
|
return $query;
|
||||||
|
}
|
||||||
|
add_filter('pre_get_posts', 'sportspress_pre_get_posts');
|
||||||
|
|
||||||
|
function sportspress_posts_where( $where, $that ) {
|
||||||
|
global $wpdb;
|
||||||
|
if( 'sp_event' == $that->query_vars['post_type'] && is_archive() )
|
||||||
|
$where = str_replace( "{$wpdb->posts}.post_status = 'publish'", "{$wpdb->posts}.post_status = 'publish' OR $wpdb->posts.post_status = 'future'", $where );
|
||||||
|
return $where;
|
||||||
|
}
|
||||||
|
add_filter( 'posts_where', 'sportspress_posts_where', 2, 10 );
|
||||||
|
|
||||||
|
function sportspress_sanitize_title( $title ) {
|
||||||
|
|
||||||
|
if ( isset( $_POST ) && array_key_exists( 'taxonomy', $_POST ) ):
|
||||||
|
|
||||||
|
return $title;
|
||||||
|
|
||||||
|
elseif ( isset( $_POST ) && array_key_exists( 'post_type', $_POST ) && in_array( $_POST['post_type'], array( 'sp_result', 'sp_outcome', 'sp_column', 'sp_performance', 'sp_metric' ) ) ):
|
||||||
|
|
||||||
|
$key = isset( $_POST['sp_key'] ) ? $_POST['sp_key'] : null;
|
||||||
|
|
||||||
|
if ( ! $key ) $key = $_POST['post_title'];
|
||||||
|
|
||||||
|
$id = sportspress_array_value( $_POST, 'post_ID', 'var' );
|
||||||
|
|
||||||
|
$title = sportspress_get_eos_safe_slug( $key, $id );
|
||||||
|
|
||||||
|
elseif ( isset( $_POST ) && array_key_exists( 'post_type', $_POST ) && $_POST['post_type'] == 'sp_event' ):
|
||||||
|
|
||||||
|
// Auto slug generation
|
||||||
|
if ( $_POST['post_title'] == '' && ( $_POST['post_name'] == '' || is_int( $_POST['post_name'] ) ) ):
|
||||||
|
|
||||||
|
$title = '';
|
||||||
|
|
||||||
|
endif;
|
||||||
|
|
||||||
|
endif;
|
||||||
|
|
||||||
|
return $title;
|
||||||
|
}
|
||||||
|
add_filter( 'sanitize_title', 'sportspress_sanitize_title' );
|
||||||
|
|
||||||
|
function sportspress_the_content( $content ) {
|
||||||
|
if ( is_single() || is_page() )
|
||||||
|
sportspress_set_post_views( get_the_ID() );
|
||||||
|
return $content;
|
||||||
|
}
|
||||||
|
add_filter( 'the_content', 'sportspress_the_content' );
|
||||||
|
add_filter( 'get_the_content', 'sportspress_the_content' );
|
||||||
|
|
||||||
|
function sportspress_default_event_content( $content ) {
|
||||||
|
if ( is_singular( 'sp_event' ) && in_the_loop() ):
|
||||||
|
$id = get_the_ID();
|
||||||
|
|
||||||
|
// Video
|
||||||
|
$video_url = get_post_meta( $id, 'sp_video', true );
|
||||||
|
if ( $video_url ):
|
||||||
|
global $wp_embed;
|
||||||
|
echo $wp_embed->autoembed( $video_url );
|
||||||
|
endif;
|
||||||
|
|
||||||
|
// Results
|
||||||
|
sp_get_template( 'event-results.php' );
|
||||||
|
|
||||||
|
// Details
|
||||||
|
sp_get_template( 'event-details.php' );
|
||||||
|
|
||||||
|
// Venue
|
||||||
|
sp_get_template( 'event-venue.php' );
|
||||||
|
|
||||||
|
// Performance
|
||||||
|
sp_get_template( 'event-performance.php' );
|
||||||
|
|
||||||
|
// Staff
|
||||||
|
sp_get_template( 'event-staff.php' );
|
||||||
|
endif;
|
||||||
|
|
||||||
|
return $content;
|
||||||
|
}
|
||||||
|
add_filter( 'the_content', 'sportspress_default_event_content', 7 );
|
||||||
|
|
||||||
|
function sportspress_default_calendar_content( $content ) {
|
||||||
|
if ( is_singular( 'sp_calendar' ) && in_the_loop() ):
|
||||||
|
$id = get_the_ID();
|
||||||
|
$format = get_post_meta( $id, 'sp_format', true );
|
||||||
|
switch ( $format ):
|
||||||
|
case 'list':
|
||||||
|
sp_get_template( 'event-list.php', array(
|
||||||
|
'id' => $id
|
||||||
|
) );
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
sp_get_template( 'event-calendar.php', array(
|
||||||
|
'id' => $id,
|
||||||
|
'initial' => false
|
||||||
|
) );
|
||||||
|
break;
|
||||||
|
endswitch;
|
||||||
|
endif;
|
||||||
|
return $content;
|
||||||
|
}
|
||||||
|
add_filter( 'the_content', 'sportspress_default_calendar_content' );
|
||||||
|
|
||||||
|
function sportspress_default_team_content( $content ) {
|
||||||
|
if ( is_singular( 'sp_team' ) && in_the_loop() ):
|
||||||
|
sp_get_template( 'team-columns.php' );
|
||||||
|
endif;
|
||||||
|
return $content;
|
||||||
|
}
|
||||||
|
add_filter( 'the_content', 'sportspress_default_team_content' );
|
||||||
|
|
||||||
|
function sportspress_default_table_content( $content ) {
|
||||||
|
if ( is_singular( 'sp_table' ) && in_the_loop() ):
|
||||||
|
$id = get_the_ID();
|
||||||
|
$leagues = get_the_terms( $id, 'sp_league' );
|
||||||
|
$seasons = get_the_terms( $id, 'sp_season' );
|
||||||
|
$terms = array();
|
||||||
|
if ( $leagues ):
|
||||||
|
$league = reset( $leagues );
|
||||||
|
$terms[] = $league->name;
|
||||||
|
endif;
|
||||||
|
if ( $seasons ):
|
||||||
|
$season = reset( $seasons );
|
||||||
|
$terms[] = $season->name;
|
||||||
|
endif;
|
||||||
|
$title = '';
|
||||||
|
if ( sizeof( $terms ) )
|
||||||
|
echo '<h4 class="sp-table-caption">' . implode( ' — ', $terms ) . '</h4>';
|
||||||
|
|
||||||
|
sp_get_template( 'league-table.php' );
|
||||||
|
$excerpt = has_excerpt() ? wpautop( get_the_excerpt() ) : '';
|
||||||
|
$content = $content . $excerpt;
|
||||||
|
endif;
|
||||||
|
return $content;
|
||||||
|
}
|
||||||
|
add_filter( 'the_content', 'sportspress_default_table_content' );
|
||||||
|
|
||||||
|
function sportspress_default_player_content( $content ) {
|
||||||
|
if ( is_singular( 'sp_player' ) && in_the_loop() ):
|
||||||
|
sp_get_template( 'player-metrics.php' );
|
||||||
|
sp_get_template( 'player-performance.php' );
|
||||||
|
endif;
|
||||||
|
return $content;
|
||||||
|
}
|
||||||
|
add_filter( 'the_content', 'sportspress_default_player_content' );
|
||||||
|
|
||||||
|
function sportspress_default_list_content( $content ) {
|
||||||
|
if ( is_singular( 'sp_list' ) && in_the_loop() ):
|
||||||
|
$id = get_the_ID();
|
||||||
|
$format = get_post_meta( $id, 'sp_format', true );
|
||||||
|
switch ( $format ):
|
||||||
|
case 'gallery':
|
||||||
|
sp_get_template( 'player-gallery.php' );
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
sp_get_template( 'player-list.php' );
|
||||||
|
break;
|
||||||
|
endswitch;
|
||||||
|
endif;
|
||||||
|
return $content;
|
||||||
|
}
|
||||||
|
add_filter( 'the_content', 'sportspress_default_list_content' );
|
||||||
|
|
||||||
|
function sportspress_widget_text( $content ) {
|
||||||
|
if ( ! preg_match( '/\[[\r\n\t ]*(countdown|league_table|event(s)_(calendar|list)|player_(list|gallery))?[\r\n\t ].*?\]/', $content ) )
|
||||||
|
return $content;
|
||||||
|
|
||||||
|
$content = do_shortcode( $content );
|
||||||
|
|
||||||
|
return $content;
|
||||||
|
}
|
||||||
|
add_filter( 'widget_text', 'sportspress_widget_text', 9 );
|
||||||
|
|
||||||
|
function sportspress_post_updated_messages( $messages ) {
|
||||||
|
|
||||||
|
global $typenow, $post;
|
||||||
|
|
||||||
|
if ( in_array( $typenow, array( 'sp_result', 'sp_outcome', 'sp_column', 'sp_metric', 'sp_performance' ) ) ):
|
||||||
|
$obj = get_post_type_object( $typenow );
|
||||||
|
|
||||||
|
for ( $i = 0; $i <= 10; $i++ ):
|
||||||
|
$messages['post'][ $i ] = __( 'Settings saved.', 'sportspress' ) .
|
||||||
|
' <a href="' . esc_url( admin_url( 'edit.php?post_type=' . $typenow ) ) . '">' .
|
||||||
|
__( 'View All', 'sportspress' ) . '</a>';
|
||||||
|
endfor;
|
||||||
|
|
||||||
|
elseif ( in_array( $typenow, array( 'sp_event', 'sp_team', 'sp_table', 'sp_player', 'sp_list', 'sp_staff' ) ) ):
|
||||||
|
$obj = get_post_type_object( $typenow );
|
||||||
|
|
||||||
|
$messages['post'][1] = __( 'Changes saved.', 'sportspress' ) .
|
||||||
|
' <a href="' . esc_url( get_permalink($post->ID) ) . '">' . $obj->labels->view_item . '</a>';
|
||||||
|
|
||||||
|
$messages['post'][4] = __( 'Changes saved.', 'sportspress' );
|
||||||
|
|
||||||
|
$messages['post'][6] = __( 'Success!', 'sportspress' ) .
|
||||||
|
' <a href="' . esc_url( get_permalink($post->ID) ) . '">' . $obj->labels->view_item . '</a>';
|
||||||
|
|
||||||
|
$messages['post'][7] = __( 'Changes saved.', 'sportspress' );
|
||||||
|
|
||||||
|
$messages['post'][8] = __( 'Success!', 'sportspress' ) .
|
||||||
|
' <a target="_blank" href="' . esc_url( add_query_arg( 'preview', 'true', get_permalink($post->ID) ) ) . '">' .
|
||||||
|
sprintf( __( 'Preview %s', 'sportspress' ), $obj->labels->singular_name ) . '</a>';
|
||||||
|
|
||||||
|
$messages['post'][9] = sprintf(
|
||||||
|
__( 'Scheduled for: <b>%1$s</b>.', 'sportspress' ),
|
||||||
|
date_i18n( __( 'M j, Y @ G:i', 'sportspress' ), strtotime( $post->post_date ) ), esc_url( get_permalink($post->ID) ) ) .
|
||||||
|
' <a target="_blank" href="' . esc_url( get_permalink($post->ID) ) . '">' .
|
||||||
|
sprintf( __( 'Preview %s', 'sportspress' ), $obj->labels->singular_name ) . '</a>';
|
||||||
|
|
||||||
|
$messages['post'][10] = __( 'Success!', 'sportspress' ) .
|
||||||
|
' <a target="_blank" href="' . esc_url( add_query_arg( 'preview', 'true', get_permalink($post->ID) ) ) . '">' .
|
||||||
|
sprintf( __( 'Preview %s', 'sportspress' ), $obj->labels->singular_name ) . '</a>';
|
||||||
|
|
||||||
|
endif;
|
||||||
|
|
||||||
|
return $messages;
|
||||||
|
}
|
||||||
|
|
||||||
|
add_filter('post_updated_messages', 'sportspress_post_updated_messages');
|
||||||
|
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
class SP_Widget_Event_List extends WP_Widget {
|
class SP_Widget_Event_List extends WP_Widget {
|
||||||
|
|
||||||
function __construct() {
|
function __construct() {
|
||||||
$widget_ops = array('classname' => 'widget_sp_event_list', 'description' => __( 'A list of events.', 'sportspress' ) );
|
$widget_ops = array('classname' => 'widget_calendar widget_sp_event_list', 'description' => __( 'A list of events.', 'sportspress' ) );
|
||||||
parent::__construct('sp_event_list', __( 'SportsPress Events List', 'sportspress' ), $widget_ops);
|
parent::__construct('sp_event_list', __( 'SportsPress Events List', 'sportspress' ), $widget_ops);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
class SP_Widget_League_Table extends WP_Widget {
|
class SP_Widget_League_Table extends WP_Widget {
|
||||||
|
|
||||||
function __construct() {
|
function __construct() {
|
||||||
$widget_ops = array('classname' => 'widget_league_table widget_sp_league_table', 'description' => __( 'Display a league table.', 'sportspress' ) );
|
$widget_ops = array('classname' => 'widget_calendar widget_league_table widget_sp_league_table', 'description' => __( 'Display a league table.', 'sportspress' ) );
|
||||||
parent::__construct('sp_league_table', __( 'SportsPress League Table', 'sportspress' ), $widget_ops);
|
parent::__construct('sp_league_table', __( 'SportsPress League Table', 'sportspress' ), $widget_ops);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
class SP_Widget_Player_list extends WP_Widget {
|
class SP_Widget_Player_list extends WP_Widget {
|
||||||
|
|
||||||
function __construct() {
|
function __construct() {
|
||||||
$widget_ops = array('classname' => 'widget_player_list widget_sp_player_list', 'description' => __( 'Display a list of players.', 'sportspress' ) );
|
$widget_ops = array('classname' => 'widget_calendar widget_player_list widget_sp_player_list', 'description' => __( 'Display a list of players.', 'sportspress' ) );
|
||||||
parent::__construct('sp_player_list', __( 'SportsPress Player List', 'sportspress' ), $widget_ops);
|
parent::__construct('sp_player_list', __( 'SportsPress Player List', 'sportspress' ), $widget_ops);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -201,21 +201,8 @@ final class SportsPress {
|
|||||||
* Include required core files used in admin and on the frontend.
|
* Include required core files used in admin and on the frontend.
|
||||||
*/
|
*/
|
||||||
private function includes() {
|
private function includes() {
|
||||||
|
|
||||||
// Functions
|
|
||||||
include_once( 'includes/sp-core-functions.php' );
|
include_once( 'includes/sp-core-functions.php' );
|
||||||
|
include_once( 'includes/class-sp-install.php' );
|
||||||
// Globals
|
|
||||||
//include_once( 'includes/admin/settings/globals.php' );
|
|
||||||
|
|
||||||
// Options
|
|
||||||
include_once( 'includes/admin/settings/settings.php' );
|
|
||||||
include_once( 'includes/admin/settings/options-general.php' );
|
|
||||||
include_once( 'includes/admin/settings/options-event.php' );
|
|
||||||
include_once( 'includes/admin/settings/options-team.php' );
|
|
||||||
include_once( 'includes/admin/settings/options-player.php' );
|
|
||||||
include_once( 'includes/admin/settings/options-text.php' );
|
|
||||||
include_once( 'includes/admin/settings/options-permalink.php' );
|
|
||||||
|
|
||||||
if ( is_admin() ) {
|
if ( is_admin() ) {
|
||||||
include_once( 'includes/admin/class-sp-admin.php' );
|
include_once( 'includes/admin/class-sp-admin.php' );
|
||||||
@@ -233,46 +220,15 @@ final class SportsPress {
|
|||||||
include_once( 'includes/class-sp-formats.php' ); // Defines custom post type formats
|
include_once( 'includes/class-sp-formats.php' ); // Defines custom post type formats
|
||||||
include_once( 'includes/class-sp-text.php' ); // Defines editable strings
|
include_once( 'includes/class-sp-text.php' ); // Defines editable strings
|
||||||
|
|
||||||
// Typical request actions (deprecating)
|
// Include template hooks in time for themes to remove/modify them
|
||||||
include_once( 'admin/hooks/plugins-loaded.php' );
|
include_once( 'includes/sp-template-hooks.php' );
|
||||||
include_once( 'admin/hooks/wp-enqueue-scripts.php' );
|
|
||||||
include_once( 'admin/hooks/loop-start.php' );
|
|
||||||
include_once( 'admin/hooks/the-title.php' );
|
|
||||||
|
|
||||||
// Admin request actions (deprecating)
|
|
||||||
include_once( 'admin/hooks/admin-init.php' );
|
|
||||||
//include_once( 'admin/hooks/admin-menu.php' );
|
|
||||||
//include_once( 'admin/hooks/admin-enqueue-scripts.php' );
|
|
||||||
include_once( 'admin/hooks/admin-print-styles.php' );
|
|
||||||
include_once( 'admin/hooks/admin-head.php' );
|
|
||||||
//include_once( 'admin/hooks/current-screen.php' );
|
|
||||||
|
|
||||||
// Administrative actions (deprecating)
|
|
||||||
//include_once( 'admin/hooks/manage-posts-columns.php' );
|
|
||||||
include_once( 'admin/hooks/post-thumbnail-html.php' );
|
|
||||||
//include_once( 'admin/hooks/restrict-manage-posts.php' );
|
|
||||||
//include_once( 'admin/hooks/parse-query.php' );
|
|
||||||
//include_once( 'admin/hooks/save-post.php' );
|
|
||||||
|
|
||||||
// Filters (deprecating)
|
|
||||||
include_once( 'admin/hooks/admin-post-thumbnail-html.php' );
|
|
||||||
include_once( 'admin/hooks/gettext.php' );
|
|
||||||
include_once( 'admin/hooks/pre-get-posts.php' );
|
|
||||||
include_once( 'admin/hooks/the-posts.php' );
|
|
||||||
include_once( 'admin/hooks/sanitize-title.php' );
|
|
||||||
include_once( 'admin/hooks/the-content.php' );
|
|
||||||
include_once( 'admin/hooks/widget-text.php' );
|
|
||||||
//include_once( 'admin/hooks/wp-insert-post-data.php' );
|
|
||||||
include_once( 'admin/hooks/post-updated-messages.php' );
|
|
||||||
|
|
||||||
// Register activation hook (deprecating)
|
|
||||||
include_once( 'admin/hooks/register-activation-hook.php' );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Include required frontend files.
|
* Include required frontend files.
|
||||||
*/
|
*/
|
||||||
public function frontend_includes() {
|
public function frontend_includes() {
|
||||||
|
include_once( 'includes/class-sp-frontend-scripts.php' ); // Frontend Scripts
|
||||||
include_once( 'includes/class-sp-shortcodes.php' ); // Shortcodes class
|
include_once( 'includes/class-sp-shortcodes.php' ); // Shortcodes class
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -287,7 +243,6 @@ final class SportsPress {
|
|||||||
* Include core widgets
|
* Include core widgets
|
||||||
*/
|
*/
|
||||||
public function include_widgets() {
|
public function include_widgets() {
|
||||||
//include_once( 'includes/abstracts/abstract-sp-widget.php' );
|
|
||||||
include_once( 'includes/widgets/class-sp-widget-countdown.php' );
|
include_once( 'includes/widgets/class-sp-widget-countdown.php' );
|
||||||
include_once( 'includes/widgets/class-sp-widget-event-calendar.php' );
|
include_once( 'includes/widgets/class-sp-widget-event-calendar.php' );
|
||||||
include_once( 'includes/widgets/class-sp-widget-event-list.php' );
|
include_once( 'includes/widgets/class-sp-widget-event-list.php' );
|
||||||
|
|||||||
@@ -195,6 +195,6 @@ if ( $pad != 0 && $pad != 7 )
|
|||||||
$calendar_output .= "\n\t</tr>\n\t</tbody>\n\t</table>\n\t</div>";
|
$calendar_output .= "\n\t</tr>\n\t</tbody>\n\t</table>\n\t</div>";
|
||||||
|
|
||||||
if ( $id && $show_all_events_link )
|
if ( $id && $show_all_events_link )
|
||||||
$calendar_output .= '<a class="sp-calendar-link" href="' . get_permalink( $id ) . '">' . __( 'View all events', 'sportspress' ) . '</a>';
|
$calendar_output .= '<a class="sp-calendar-link" href="' . get_permalink( $id ) . '">' . SP()->text->string('View all events', 'event') . '</a>';
|
||||||
|
|
||||||
echo apply_filters( 'sportspress_event_calendar', $calendar_output );
|
echo apply_filters( 'sportspress_event_calendar', $calendar_output );
|
||||||
|
|||||||
@@ -7,19 +7,19 @@ $time = get_the_time( get_option('time_format'), $id );
|
|||||||
$leagues = get_the_terms( $id, 'sp_league' );
|
$leagues = get_the_terms( $id, 'sp_league' );
|
||||||
$seasons = get_the_terms( $id, 'sp_season' );
|
$seasons = get_the_terms( $id, 'sp_season' );
|
||||||
|
|
||||||
$data = array( __( 'Date', 'sportspress' ) => $date, __( 'Time', 'sportspress' ) => $time );
|
$data = array( SP()->text->string('Date', 'event') => $date, SP()->text->string('Time', 'event') => $time );
|
||||||
|
|
||||||
if ( $leagues ):
|
if ( $leagues ):
|
||||||
$league = array_pop( $leagues );
|
$league = array_pop( $leagues );
|
||||||
$data[ __( 'League', 'sportspress' ) ] = $league->name;
|
$data[ SP()->text->string('League') ] = $league->name;
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
if ( $seasons ):
|
if ( $seasons ):
|
||||||
$season = array_pop( $seasons );
|
$season = array_pop( $seasons );
|
||||||
$data[ __( 'Season', 'sportspress' ) ] = $season->name;
|
$data[ SP()->text->string('Season') ] = $season->name;
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
$output = '<h3>' . __( 'Details', 'sportspress' ) . '</h3>';
|
$output = '<h3>' . SP()->text->string('Details', 'event') . '</h3>';
|
||||||
|
|
||||||
$output .= '<div class="sp-table-wrapper">' .
|
$output .= '<div class="sp-table-wrapper">' .
|
||||||
'<table class="sp-event-details sp-data-table"><tbody>';
|
'<table class="sp-event-details sp-data-table"><tbody>';
|
||||||
|
|||||||
@@ -16,19 +16,19 @@ list( $data, $usecolumns ) = sportspress_get_calendar_data( $id, true );
|
|||||||
if ( isset( $columns ) )
|
if ( isset( $columns ) )
|
||||||
$usecolumns = $columns;
|
$usecolumns = $columns;
|
||||||
|
|
||||||
$output .= '<th class="column-date">' . __( 'Date', 'sportspress' ). '</th>';
|
$output .= '<th class="data-date">' . SP()->text->string('Date', 'event') . '</th>';
|
||||||
|
|
||||||
if ( $usecolumns == null || in_array( 'event', $usecolumns ) )
|
if ( $usecolumns == null || in_array( 'event', $usecolumns ) )
|
||||||
$output .= '<th class="column-event">' . __( 'Event', 'sportspress' ). '</th>';
|
$output .= '<th class="data-event">' . SP()->text->string('Event', 'event') . '</th>';
|
||||||
|
|
||||||
if ( $usecolumns == null || in_array( 'teams', $usecolumns ) )
|
if ( $usecolumns == null || in_array( 'teams', $usecolumns ) )
|
||||||
$output .= '<th class="column-teams">' . __( 'Teams', 'sportspress' ). '</th>';
|
$output .= '<th class="data-teams">' . SP()->text->string('Teams', 'event') . '</th>';
|
||||||
|
|
||||||
if ( $usecolumns == null || in_array( 'time', $usecolumns ) )
|
if ( $usecolumns == null || in_array( 'time', $usecolumns ) )
|
||||||
$output .= '<th class="column-time">' . __( 'Time', 'sportspress' ). '</th>';
|
$output .= '<th class="data-time">' . SP()->text->string('Time', 'event') . '</th>';
|
||||||
|
|
||||||
if ( $usecolumns == null || in_array( 'article', $usecolumns ) )
|
if ( $usecolumns == null || in_array( 'article', $usecolumns ) )
|
||||||
$output .= '<th class="column-article">' . __( 'Article', 'sportspress' ). '</th>';
|
$output .= '<th class="data-article">' . SP()->text->string('Article', 'event') . '</th>';
|
||||||
|
|
||||||
$output .= '</tr>' . '</thead>' . '<tbody>';
|
$output .= '</tr>' . '</thead>' . '<tbody>';
|
||||||
|
|
||||||
@@ -40,13 +40,13 @@ foreach ( $data as $event ):
|
|||||||
|
|
||||||
$output .= '<tr class="sp-row sp-post' . ( $i % 2 == 0 ? ' alternate' : '' ) . '">';
|
$output .= '<tr class="sp-row sp-post' . ( $i % 2 == 0 ? ' alternate' : '' ) . '">';
|
||||||
|
|
||||||
$output .= '<td class="column-date">' . get_post_time( get_option( 'date_format' ), false, $event ) . '</td>';
|
$output .= '<td class="data-date">' . get_post_time( get_option( 'date_format' ), false, $event ) . '</td>';
|
||||||
|
|
||||||
if ( $usecolumns == null || in_array( 'event', $usecolumns ) )
|
if ( $usecolumns == null || in_array( 'event', $usecolumns ) )
|
||||||
$output .= '<td class="column-event">' . $event->post_title . '</td>';
|
$output .= '<td class="data-event">' . $event->post_title . '</td>';
|
||||||
|
|
||||||
if ( $usecolumns == null || in_array( 'teams', $usecolumns ) ):
|
if ( $usecolumns == null || in_array( 'teams', $usecolumns ) ):
|
||||||
$output .= '<td class="column-teams">';
|
$output .= '<td class="data-teams">';
|
||||||
|
|
||||||
$teams = get_post_meta( $event->ID, 'sp_team', false );
|
$teams = get_post_meta( $event->ID, 'sp_team', false );
|
||||||
if ( $teams ):
|
if ( $teams ):
|
||||||
@@ -83,11 +83,11 @@ foreach ( $data as $event ):
|
|||||||
endif;
|
endif;
|
||||||
|
|
||||||
if ( $usecolumns == null || in_array( 'time', $usecolumns ) )
|
if ( $usecolumns == null || in_array( 'time', $usecolumns ) )
|
||||||
$output .= '<td class="column-time">' . get_post_time( get_option( 'time_format' ), false, $event ) . '</td>';
|
$output .= '<td class="data-time">' . get_post_time( get_option( 'time_format' ), false, $event ) . '</td>';
|
||||||
|
|
||||||
if ( $usecolumns == null || in_array( 'article', $usecolumns ) ):
|
if ( $usecolumns == null || in_array( 'article', $usecolumns ) ):
|
||||||
$output .= '<td class="column-article">
|
$output .= '<td class="data-article">
|
||||||
<a href="' . get_permalink( $event->ID ) . '#sp_articlediv">';
|
<a href="' . get_permalink( $event->ID ) . '">';
|
||||||
|
|
||||||
if ( $video ):
|
if ( $video ):
|
||||||
$output .= '<div class="dashicons dashicons-video-alt"></div>';
|
$output .= '<div class="dashicons dashicons-video-alt"></div>';
|
||||||
@@ -96,9 +96,9 @@ foreach ( $data as $event ):
|
|||||||
endif;
|
endif;
|
||||||
if ( $event->post_content !== null ):
|
if ( $event->post_content !== null ):
|
||||||
if ( $event->post_status == 'publish' ):
|
if ( $event->post_status == 'publish' ):
|
||||||
$output .= __( 'Recap', 'sportspress' );
|
$output .= SP()->text->string('Recap', 'event');
|
||||||
else:
|
else:
|
||||||
$output .= __( 'Preview', 'sportspress' );
|
$output .= SP()->text->string('Preview', 'event');
|
||||||
endif;
|
endif;
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
@@ -114,7 +114,7 @@ endforeach;
|
|||||||
$output .= '</tbody>' . '</table>';
|
$output .= '</tbody>' . '</table>';
|
||||||
|
|
||||||
if ( $id && $show_all_events_link )
|
if ( $id && $show_all_events_link )
|
||||||
$output .= '<a class="sp-calendar-link" href="' . get_permalink( $id ) . '">' . __( 'View all events', 'sportspress' ) . '</a>';
|
$output .= '<a class="sp-calendar-link" href="' . get_permalink( $id ) . '">' . SP()->text->string('View all events', 'event') . '</a>';
|
||||||
|
|
||||||
$output .= '</div>';
|
$output .= '</div>';
|
||||||
|
|
||||||
|
|||||||
@@ -8,9 +8,9 @@ $teams = (array)get_post_meta( $id, 'sp_team', false );
|
|||||||
$staff = (array)get_post_meta( $id, 'sp_staff', false );
|
$staff = (array)get_post_meta( $id, 'sp_staff', false );
|
||||||
$stats = (array)get_post_meta( $id, 'sp_players', true );
|
$stats = (array)get_post_meta( $id, 'sp_players', true );
|
||||||
$performance_labels = sportspress_get_var_labels( 'sp_performance' );
|
$performance_labels = sportspress_get_var_labels( 'sp_performance' );
|
||||||
$link_posts = sportspress_array_value( $sportspress_options, 'event_performance_link_posts', true );
|
$link_posts = get_option( 'sportspress_event_link_players', 'yes' ) == 'yes' ? true : false;
|
||||||
$sortable = sportspress_array_value( $sportspress_options, 'event_performance_sortable', true );
|
$sortable = get_option( 'sportspress_enable_sortable_tables', 'yes' ) == 'yes' ? true : false;
|
||||||
$responsive = sportspress_array_value( $sportspress_options, 'event_performance_responsive', true );
|
$responsive = get_option( 'sportspress_enable_responsive_tables', 'yes' ) == 'yes' ? true : false;
|
||||||
|
|
||||||
$output = '';
|
$output = '';
|
||||||
|
|
||||||
@@ -29,7 +29,7 @@ foreach( $teams as $key => $team_id ):
|
|||||||
'<table class="sp-event-performance sp-data-table' . ( $responsive ? ' sp-responsive-table' : '' ) . ( $sortable ? ' sp-sortable-table' : '' ) . '">' . '<thead>' . '<tr>';
|
'<table class="sp-event-performance sp-data-table' . ( $responsive ? ' sp-responsive-table' : '' ) . ( $sortable ? ' sp-sortable-table' : '' ) . '">' . '<thead>' . '<tr>';
|
||||||
|
|
||||||
$output .= '<th class="data-number">#</th>';
|
$output .= '<th class="data-number">#</th>';
|
||||||
$output .= '<th class="data-number">' . __( 'Player', 'sportspress' ) . '</th>';
|
$output .= '<th class="data-name">' . SP()->text->string('Player', 'event') . '</th>';
|
||||||
|
|
||||||
foreach( $performance_labels as $key => $label ):
|
foreach( $performance_labels as $key => $label ):
|
||||||
$output .= '<th class="data-' . $key . '">' . $label . '</th>';
|
$output .= '<th class="data-' . $key . '">' . $label . '</th>';
|
||||||
@@ -94,7 +94,7 @@ foreach( $teams as $key => $team_id ):
|
|||||||
|
|
||||||
// Player number
|
// Player number
|
||||||
$output .= '<td class="data-number"> </td>';
|
$output .= '<td class="data-number"> </td>';
|
||||||
$output .= '<td class="data-name">' . __( 'Total', 'sportspress' ) . '</td>';
|
$output .= '<td class="data-name">' . SP()->text->string('Total', 'event') . '</td>';
|
||||||
|
|
||||||
$row = $data[0];
|
$row = $data[0];
|
||||||
|
|
||||||
|
|||||||
@@ -49,11 +49,11 @@ if ( empty( $table_rows ) ):
|
|||||||
|
|
||||||
else:
|
else:
|
||||||
|
|
||||||
$output .= '<h3>' . __( 'Results', 'sportspress' ) . '</h3>';
|
$output .= '<h3>' . SP()->text->string('Results', 'event') . '</h3>';
|
||||||
|
|
||||||
$output .= '<div class="sp-table-wrapper">' .
|
$output .= '<div class="sp-table-wrapper">' .
|
||||||
'<table class="sp-event-results sp-data-table sp-responsive-table"><thead>' .
|
'<table class="sp-event-results sp-data-table sp-responsive-table"><thead>' .
|
||||||
'<th class="data-name">' . __( 'Team', 'sportspress' ) . '</th>';
|
'<th class="data-name">' . SP()->text->string('Team', 'event') . '</th>';
|
||||||
foreach( $result_labels as $key => $label ):
|
foreach( $result_labels as $key => $label ):
|
||||||
$output .= '<th class="data-' . $key . '">' . $label . '</th>';
|
$output .= '<th class="data-' . $key . '">' . $label . '</th>';
|
||||||
endforeach;
|
endforeach;
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ foreach( $venues as $venue ):
|
|||||||
$latitude = sportspress_array_value( $term_meta, 'sp_latitude', 0 );
|
$latitude = sportspress_array_value( $term_meta, 'sp_latitude', 0 );
|
||||||
$longitude = sportspress_array_value( $term_meta, 'sp_longitude', 0 );
|
$longitude = sportspress_array_value( $term_meta, 'sp_longitude', 0 );
|
||||||
|
|
||||||
$output .= '<h3>' . __( 'Venue', 'sportspress' ) . '</h3>';
|
$output .= '<h3>' . SP()->text->string('Venue', 'event') . '</h3>';
|
||||||
$output .= '<p><a href="' . get_term_link( $t_id, 'sp_venue' ) . '">' . $venue->name . '</a><br><small>' . $address . '</small></p>';
|
$output .= '<p><a href="' . get_term_link( $t_id, 'sp_venue' ) . '">' . $venue->name . '</a><br><small>' . $address . '</small></p>';
|
||||||
if ( $latitude != null && $longitude != null )
|
if ( $latitude != null && $longitude != null )
|
||||||
$output .= '<div class="sp-google-map" data-address="' . $address . '" data-latitude="' . $latitude . '" data-longitude="' . $longitude . '"></div>';
|
$output .= '<div class="sp-google-map" data-address="' . $address . '" data-latitude="' . $latitude . '" data-longitude="' . $longitude . '"></div>';
|
||||||
|
|||||||
@@ -6,10 +6,10 @@ $defaults = array(
|
|||||||
'number' => -1,
|
'number' => -1,
|
||||||
'columns' => null,
|
'columns' => null,
|
||||||
'show_full_table_link' => false,
|
'show_full_table_link' => false,
|
||||||
'show_team_logo' => sportspress_array_value( $sportspress_options, 'league_table_show_team_logo', false ),
|
'show_team_logo' => get_option( 'sportspress_table_show_logos', 'yes' ) == 'yes' ? true : false,
|
||||||
'link_posts' => sportspress_array_value( $sportspress_options, 'league_table_link_posts', false ),
|
'link_posts' => get_option( 'sportspress_table_link_teams', 'no' ) == 'yes' ? true : false,
|
||||||
'sortable' => sportspress_array_value( $sportspress_options, 'league_table_sortable', true ),
|
'sortable' => get_option( 'sportspress_enable_sortable_tables', 'yes' ) == 'yes' ? true : false,
|
||||||
'responsive' => sportspress_array_value( $sportspress_options, 'league_table_responsive', true ),
|
'responsive' => get_option( 'sportspress_enable_responsive_tables', 'yes' ) == 'yes' ? true : false,
|
||||||
);
|
);
|
||||||
|
|
||||||
extract( $defaults, EXTR_SKIP );
|
extract( $defaults, EXTR_SKIP );
|
||||||
@@ -31,7 +31,7 @@ if ( ! $columns )
|
|||||||
if ( ! is_array( $columns ) )
|
if ( ! is_array( $columns ) )
|
||||||
$columns = explode( ',', $columns );
|
$columns = explode( ',', $columns );
|
||||||
|
|
||||||
$output .= '<th class="data-rank">' . __( 'Pos', 'sportspress' ) . '</th>';
|
$output .= '<th class="data-rank">' . SP()->text->string('Pos', 'team') . '</th>';
|
||||||
|
|
||||||
foreach( $labels as $key => $label ):
|
foreach( $labels as $key => $label ):
|
||||||
if ( ! is_array( $columns ) || $key == 'name' || in_array( $key, $columns ) )
|
if ( ! is_array( $columns ) || $key == 'name' || in_array( $key, $columns ) )
|
||||||
@@ -83,7 +83,7 @@ endforeach;
|
|||||||
$output .= '</tbody>' . '</table>';
|
$output .= '</tbody>' . '</table>';
|
||||||
|
|
||||||
if ( $show_full_table_link )
|
if ( $show_full_table_link )
|
||||||
$output .= '<a class="sp-league-table-link" href="' . get_permalink( $id ) . '">' . __( 'View full table', 'sportspress' ) . '</a>';
|
$output .= '<a class="sp-league-table-link" href="' . get_permalink( $id ) . '">' . SP()->text->string('View full table', 'team') . '</a>';
|
||||||
|
|
||||||
$output .= '</div>';
|
$output .= '</div>';
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ $defaults = array(
|
|||||||
'columns' => 3,
|
'columns' => 3,
|
||||||
'size' => 'thumbnail',
|
'size' => 'thumbnail',
|
||||||
'show_all_players_link' => false,
|
'show_all_players_link' => false,
|
||||||
'show_names_on_hover' => sportspress_array_value( $sportspress_options, 'player_gallery_show_names_on_hover', true ),
|
|
||||||
);
|
);
|
||||||
|
|
||||||
extract( $defaults, EXTR_SKIP );
|
extract( $defaults, EXTR_SKIP );
|
||||||
@@ -89,14 +88,10 @@ if ( is_int( $number ) && $number > 0 )
|
|||||||
|
|
||||||
foreach( $data as $player_id => $performance ):
|
foreach( $data as $player_id => $performance ):
|
||||||
|
|
||||||
if ( $show_names_on_hover ):
|
$caption = get_the_title( $player_id );
|
||||||
$caption = get_the_title( $player_id );
|
$player_number = get_post_meta( $player_id, 'sp_number', true );
|
||||||
$player_number = get_post_meta( $player_id, 'sp_number', true );
|
if ( $player_number ):
|
||||||
if ( $player_number ):
|
$caption = '<strong>' . $player_number . '</strong> ' . $caption;
|
||||||
$caption = '<strong>' . $player_number . '</strong> ' . $caption;
|
|
||||||
endif;
|
|
||||||
else:
|
|
||||||
$caption = null;
|
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
if ( isset( $limit ) && $i >= $limit )
|
if ( isset( $limit ) && $i >= $limit )
|
||||||
@@ -128,6 +123,6 @@ $output .= "
|
|||||||
</div>\n";
|
</div>\n";
|
||||||
|
|
||||||
if ( $show_all_players_link )
|
if ( $show_all_players_link )
|
||||||
$output .= '<a class="sp-player-list-link" href="' . get_permalink( $id ) . '">' . __( 'View all players', 'sportspress' ) . '</a>';
|
$output .= '<a class="sp-player-list-link" href="' . get_permalink( $id ) . '">' . SP()->text->string('View all players', 'player') . '</a>';
|
||||||
|
|
||||||
echo apply_filters( 'sportspress_player_gallery', $output );
|
echo apply_filters( 'sportspress_player_gallery', $output );
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ if ( ! isset( $league ) )
|
|||||||
if ( ! isset( $id ) )
|
if ( ! isset( $id ) )
|
||||||
$id = get_the_ID();
|
$id = get_the_ID();
|
||||||
|
|
||||||
|
$responsive = get_option( 'sportspress_enable_responsive_tables', 'yes' ) == 'yes' ? true : false;
|
||||||
|
|
||||||
$data = sportspress_get_player_performance_data( $id, $league->term_id );
|
$data = sportspress_get_player_performance_data( $id, $league->term_id );
|
||||||
|
|
||||||
// The first row should be column labels
|
// The first row should be column labels
|
||||||
@@ -19,7 +21,7 @@ if ( empty( $data ) )
|
|||||||
|
|
||||||
$output = '<h4 class="sp-table-caption">' . $league->name . '</h4>' .
|
$output = '<h4 class="sp-table-caption">' . $league->name . '</h4>' .
|
||||||
'<div class="sp-table-wrapper">' .
|
'<div class="sp-table-wrapper">' .
|
||||||
'<table class="sp-player-performance sp-data-table sp-responsive-table">' . '<thead>' . '<tr>';
|
'<table class="sp-player-performance sp-data-table' . ( $responsive ? ' sp-responsive-table' : '' ) . '">' . '<thead>' . '<tr>';
|
||||||
|
|
||||||
foreach( $labels as $key => $label ):
|
foreach( $labels as $key => $label ):
|
||||||
$output .= '<th class="data-' . $key . '">' . $label . '</th>';
|
$output .= '<th class="data-' . $key . '">' . $label . '</th>';
|
||||||
|
|||||||
@@ -8,9 +8,9 @@ $defaults = array(
|
|||||||
'orderby' => 'default',
|
'orderby' => 'default',
|
||||||
'order' => 'ASC',
|
'order' => 'ASC',
|
||||||
'show_all_players_link' => false,
|
'show_all_players_link' => false,
|
||||||
'link_posts' => sportspress_array_value( $sportspress_options, 'player_list_link_posts', true ),
|
'link_posts' => get_option( 'sportspress_list_link_players', 'yes' ) == 'yes' ? true : false,
|
||||||
'sortable' => sportspress_array_value( $sportspress_options, 'player_list_sortable', true ),
|
'sortable' => get_option( 'sportspress_enable_sortable_tables', 'yes' ) == 'yes' ? true : false,
|
||||||
'responsive' => sportspress_array_value( $sportspress_options, 'player_list_responsive', true ),
|
'responsive' => get_option( 'sportspress_enable_responsive_tables', 'yes' ) == 'yes' ? true : false,
|
||||||
);
|
);
|
||||||
|
|
||||||
extract( $defaults, EXTR_SKIP );
|
extract( $defaults, EXTR_SKIP );
|
||||||
@@ -43,7 +43,7 @@ endif;
|
|||||||
if ( in_array( $orderby, array( 'number', 'name' ) ) ):
|
if ( in_array( $orderby, array( 'number', 'name' ) ) ):
|
||||||
$output .= '<th class="data-number">#</th>';
|
$output .= '<th class="data-number">#</th>';
|
||||||
else:
|
else:
|
||||||
$output .= '<th class="data-rank">' . __( 'Rank', 'sportspress' ) . '</th>';
|
$output .= '<th class="data-rank">' . SP()->text->string('Rank', 'player') . '</th>';
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
foreach( $labels as $key => $label ):
|
foreach( $labels as $key => $label ):
|
||||||
@@ -97,6 +97,6 @@ endforeach;
|
|||||||
$output .= '</tbody>' . '</table>' . '</div>';
|
$output .= '</tbody>' . '</table>' . '</div>';
|
||||||
|
|
||||||
if ( $show_all_players_link )
|
if ( $show_all_players_link )
|
||||||
$output .= '<a class="sp-player-list-link" href="' . get_permalink( $id ) . '">' . __( 'View all players', 'sportspress' ) . '</a>';
|
$output .= '<a class="sp-player-list-link" href="' . get_permalink( $id ) . '">' . SP()->text->string('View all players', 'player') . '</a>';
|
||||||
|
|
||||||
echo apply_filters( 'sportspress_player_list', $output );
|
echo apply_filters( 'sportspress_player_list', $output );
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ if ( ! isset( $id ) )
|
|||||||
global $sportspress_options;
|
global $sportspress_options;
|
||||||
|
|
||||||
$defaults = array(
|
$defaults = array(
|
||||||
'show_nationality_flag' => sportspress_array_value( $sportspress_options, 'player_show_nationality_flag', true ),
|
'show_nationality_flag' => get_option( 'sportspress_player_show_flag', 'yes' ) == 'yes' ? true : false,
|
||||||
);
|
);
|
||||||
|
|
||||||
extract( $defaults, EXTR_SKIP );
|
extract( $defaults, EXTR_SKIP );
|
||||||
@@ -20,20 +20,20 @@ $metrics = sportspress_get_player_metrics_data( $id );
|
|||||||
$common = array();
|
$common = array();
|
||||||
if ( $nationality ):
|
if ( $nationality ):
|
||||||
$country_name = sportspress_array_value( $countries, $nationality, null );
|
$country_name = sportspress_array_value( $countries, $nationality, null );
|
||||||
$common[ __( 'Nationality', 'sportspress' ) ] = $country_name ? ( $show_nationality_flag ? '<img src="' . plugin_dir_url( SP_PLUGIN_FILE ) . '/assets/images/flags/' . strtolower( $nationality ) . '.png" alt="' . $nationality . '"> ' : '' ) . $country_name : '—';
|
$common[ SP()->text->string('Nationality', 'player') ] = $country_name ? ( $show_nationality_flag ? '<img src="' . plugin_dir_url( SP_PLUGIN_FILE ) . '/assets/images/flags/' . strtolower( $nationality ) . '.png" alt="' . $nationality . '"> ' : '' ) . $country_name : '—';
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
$data = array_merge( $common, $metrics );
|
$data = array_merge( $common, $metrics );
|
||||||
|
|
||||||
if ( $current_team )
|
if ( $current_team )
|
||||||
$data[ __( 'Current Team', 'sportspress' ) ] = '<a href="' . get_post_permalink( $current_team ) . '">' . get_the_title( $current_team ) . '</a>';
|
$data[ SP()->text->string('Current Team', 'player') ] = '<a href="' . get_post_permalink( $current_team ) . '">' . get_the_title( $current_team ) . '</a>';
|
||||||
|
|
||||||
if ( $past_teams ):
|
if ( $past_teams ):
|
||||||
$teams = array();
|
$teams = array();
|
||||||
foreach ( $past_teams as $team ):
|
foreach ( $past_teams as $team ):
|
||||||
$teams[] = '<a href="' . get_post_permalink( $team ) . '">' . get_the_title( $team ) . '</a>';
|
$teams[] = '<a href="' . get_post_permalink( $team ) . '">' . get_the_title( $team ) . '</a>';
|
||||||
endforeach;
|
endforeach;
|
||||||
$data[ __( 'Past Teams', 'sportspress' ) ] = implode( ', ', $teams );
|
$data[ SP()->text->string('Past Teams', 'player') ] = implode( ', ', $teams );
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
$output = '<div class="sp-list-wrapper">' .
|
$output = '<div class="sp-list-wrapper">' .
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ foreach ( $positions as $position ):
|
|||||||
if ( in_array( $r['orderby'], array( 'number', 'name' ) ) ):
|
if ( in_array( $r['orderby'], array( 'number', 'name' ) ) ):
|
||||||
$output .= '<th class="data-number">#</th>';
|
$output .= '<th class="data-number">#</th>';
|
||||||
else:
|
else:
|
||||||
$output .= '<th class="data-rank">' . __( 'Rank', 'sportspress' ) . '</th>';
|
$output .= '<th class="data-rank">' . SP()->text->string('Rank', 'player') . '</th>';
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
foreach( $labels as $key => $label ):
|
foreach( $labels as $key => $label ):
|
||||||
|
|||||||
24
uninstall.php
Normal file
24
uninstall.php
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* SportsPress Uninstall
|
||||||
|
*
|
||||||
|
* Uninstalling SportsPress deletes user roles and options.
|
||||||
|
*
|
||||||
|
* @author ThemeBoy
|
||||||
|
* @category Core
|
||||||
|
* @package SportsPress/Uninstaller
|
||||||
|
* @version 0.7
|
||||||
|
*/
|
||||||
|
if( ! defined( 'WP_UNINSTALL_PLUGIN' ) )
|
||||||
|
exit();
|
||||||
|
|
||||||
|
global $wpdb, $wp_roles;
|
||||||
|
|
||||||
|
$status_options = get_option( 'sportspress_status_options', array() );
|
||||||
|
|
||||||
|
// Roles + caps
|
||||||
|
$installer = include( 'includes/class-sp-install.php' );
|
||||||
|
$installer->remove_roles();
|
||||||
|
|
||||||
|
// Delete options
|
||||||
|
$wpdb->query("DELETE FROM $wpdb->options WHERE option_name LIKE 'sportspress_%';");
|
||||||
Reference in New Issue
Block a user