diff --git a/admin/hooks/admin-head.php b/admin/hooks/admin-head.php deleted file mode 100644 index 7c908c76..00000000 --- a/admin/hooks/admin-head.php +++ /dev/null @@ -1,17 +0,0 @@ -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' ); diff --git a/admin/hooks/admin-menu.php b/admin/hooks/admin-menu.php deleted file mode 100644 index 9a0fc1d3..00000000 --- a/admin/hooks/admin-menu.php +++ /dev/null @@ -1,66 +0,0 @@ - $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' ); - } -} diff --git a/admin/hooks/admin-post-thumbnail-html.php b/admin/hooks/admin-post-thumbnail-html.php deleted file mode 100644 index 0d25f9a3..00000000 --- a/admin/hooks/admin-post-thumbnail-html.php +++ /dev/null @@ -1,26 +0,0 @@ - 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 ); diff --git a/admin/hooks/admin-print-styles.php b/admin/hooks/admin-print-styles.php deleted file mode 100644 index 4e698831..00000000 --- a/admin/hooks/admin-print-styles.php +++ /dev/null @@ -1,48 +0,0 @@ -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' ); -} diff --git a/admin/hooks/gettext.php b/admin/hooks/gettext.php deleted file mode 100644 index 472cae37..00000000 --- a/admin/hooks/gettext.php +++ /dev/null @@ -1,84 +0,0 @@ -immediately': - $translated_text = __( 'Date/Time:', 'sportspress' ) . ' ' . __( 'Now', 'sportspress' ) . ''; - 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 ); diff --git a/admin/hooks/loop-start.php b/admin/hooks/loop-start.php deleted file mode 100644 index 86c3b131..00000000 --- a/admin/hooks/loop-start.php +++ /dev/null @@ -1,21 +0,0 @@ -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 '
'; -} -add_action( 'loop_start', 'sportspress_default_venue_content' ); diff --git a/admin/hooks/manage-posts-columns.php b/admin/hooks/manage-posts-columns.php deleted file mode 100644 index 58f56456..00000000 --- a/admin/hooks/manage-posts-columns.php +++ /dev/null @@ -1,143 +0,0 @@ -'; - break; - case 'friendly': - echo ''; - 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 '' . $number . ''; - 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 '' . $team_result . ' '; - endif; - - echo $team->post_title; - - echo '
'; - 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 ''; - endif; - echo '
'; - 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 . '
'; - 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 ); diff --git a/admin/hooks/parse-query.php b/admin/hooks/parse-query.php deleted file mode 100644 index d02c5a00..00000000 --- a/admin/hooks/parse-query.php +++ /dev/null @@ -1,13 +0,0 @@ -query_vars['meta_key'] = 'sp_team'; - $query->query_vars['meta_value'] = $_GET['team']; - endif; - endif; -} -add_filter('parse_query', 'sportspress_parse_query'); diff --git a/admin/hooks/plugins-loaded.php b/admin/hooks/plugins-loaded.php deleted file mode 100644 index 75d6cd4c..00000000 --- a/admin/hooks/plugins-loaded.php +++ /dev/null @@ -1,33 +0,0 @@ -' . - __( 'View All', 'sportspress' ) . ''; - 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' ) . - ' ' . $obj->labels->view_item . ''; - - $messages['post'][4] = __( 'Changes saved.', 'sportspress' ); - - $messages['post'][6] = __( 'Success!', 'sportspress' ) . - ' ' . $obj->labels->view_item . ''; - - $messages['post'][7] = __( 'Changes saved.', 'sportspress' ); - - $messages['post'][8] = __( 'Success!', 'sportspress' ) . - ' ' . - sprintf( __( 'Preview %s', 'sportspress' ), $obj->labels->singular_name ) . ''; - - $messages['post'][9] = sprintf( - __( 'Scheduled for: %1$s.', 'sportspress' ), - date_i18n( __( 'M j, Y @ G:i', 'sportspress' ), strtotime( $post->post_date ) ), esc_url( get_permalink($post->ID) ) ) . - ' ' . - sprintf( __( 'Preview %s', 'sportspress' ), $obj->labels->singular_name ) . ''; - - $messages['post'][10] = __( 'Success!', 'sportspress' ) . - ' ' . - sprintf( __( 'Preview %s', 'sportspress' ), $obj->labels->singular_name ) . ''; - - endif; - - return $messages; -} - -add_filter('post_updated_messages', 'sportspress_post_updated_messages'); -?> \ No newline at end of file diff --git a/admin/hooks/pre-get-posts.php b/admin/hooks/pre-get-posts.php deleted file mode 100644 index 0ce481f6..00000000 --- a/admin/hooks/pre-get-posts.php +++ /dev/null @@ -1,26 +0,0 @@ -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'); diff --git a/admin/hooks/register-activation-hook.php b/admin/hooks/register-activation-hook.php deleted file mode 100644 index 3916c483..00000000 --- a/admin/hooks/register-activation-hook.php +++ /dev/null @@ -1,165 +0,0 @@ - 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' ); diff --git a/admin/hooks/restrict-manage-posts.php b/admin/hooks/restrict-manage-posts.php deleted file mode 100644 index 89bb7ccd..00000000 --- a/admin/hooks/restrict-manage-posts.php +++ /dev/null @@ -1,47 +0,0 @@ - __( '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' ); diff --git a/admin/hooks/sanitize-title.php b/admin/hooks/sanitize-title.php deleted file mode 100644 index f18538e9..00000000 --- a/admin/hooks/sanitize-title.php +++ /dev/null @@ -1,31 +0,0 @@ -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 '

' . implode( ' — ', $terms ) . '

'; - - 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' ); diff --git a/admin/hooks/the-posts.php b/admin/hooks/the-posts.php deleted file mode 100644 index 0924ebd1..00000000 --- a/admin/hooks/the-posts.php +++ /dev/null @@ -1,8 +0,0 @@ -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 ); diff --git a/admin/hooks/the-title.php b/admin/hooks/the-title.php deleted file mode 100644 index b39f1488..00000000 --- a/admin/hooks/the-title.php +++ /dev/null @@ -1,11 +0,0 @@ -' . $number . ' ' . $title; - endif; - endif; - return $title; -} -add_filter( 'the_title', 'sportspress_the_title', 10, 2 ); diff --git a/admin/hooks/widget-text.php b/admin/hooks/widget-text.php deleted file mode 100644 index fe37153f..00000000 --- a/admin/hooks/widget-text.php +++ /dev/null @@ -1,10 +0,0 @@ - __( 'days', 'sportspress' ), 'hrs' => __( 'hrs', 'sportspress' ), 'mins' => __( 'mins', 'sportspress' ), 'secs' => __( 'secs', 'sportspress' ) ) ); -} -add_action( 'wp_enqueue_scripts', 'sportspress_enqueue_scripts' ); \ No newline at end of file diff --git a/assets/css/admin.css b/assets/css/admin.css index 3772907d..d3a7f407 100644 --- a/assets/css/admin.css +++ b/assets/css/admin.css @@ -68,9 +68,58 @@ .sportspress table.form-table, .sportspress table.form-table .forminp-radio ul { 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 { 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 */ .sportspress-message { diff --git a/assets/css/sportspress.css b/assets/css/sportspress.css index 89ac8789..2ddde8d4 100644 --- a/assets/css/sportspress.css +++ b/assets/css/sportspress.css @@ -109,6 +109,7 @@ .sp-responsive-table .data-number, .sp-responsive-table .data-name, .sp-responsive-table .data-rank, + .sp-responsive-table .data-date, .sp-responsive-.sp-pinned-table td { display: none; } diff --git a/assets/js/admin/dashboard.js b/assets/js/admin/dashboard.js new file mode 100644 index 00000000..7ab9f30c --- /dev/null +++ b/assets/js/admin/dashboard.js @@ -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")); + }); + }); + +}); \ No newline at end of file diff --git a/assets/js/admin-locationpicker.js b/assets/js/admin/locationpicker.js similarity index 100% rename from assets/js/admin-locationpicker.js rename to assets/js/admin/locationpicker.js diff --git a/assets/js/admin/settings.js b/assets/js/admin/settings.js new file mode 100644 index 00000000..ebea452e --- /dev/null +++ b/assets/js/admin/settings.js @@ -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); + }); + +}); \ No newline at end of file diff --git a/assets/js/admin.js b/assets/js/admin/sportspress-admin.js similarity index 100% rename from assets/js/admin.js rename to assets/js/admin/sportspress-admin.js diff --git a/assets/js/sportspress.js b/assets/js/sportspress.js index 5ecf36cf..62d5157b 100644 --- a/assets/js/sportspress.js +++ b/assets/js/sportspress.js @@ -83,7 +83,7 @@ function viewport() { original.wrap("
"); 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"); original.closest(".sp-responsive-table-wrapper").append(copy); diff --git a/includes/admin/class-sp-admin-assets.php b/includes/admin/class-sp-admin-assets.php index 7d9007c0..5a22164d 100644 --- a/includes/admin/class-sp-admin-assets.php +++ b/includes/admin/class-sp-admin-assets.php @@ -60,7 +60,7 @@ class SP_Admin_Assets { $screen = get_current_screen(); // 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 ); @@ -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( '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 if ( in_array( $screen->id, sp_get_screen_ids() ) ) { wp_enqueue_script( 'jquery' ); - wp_enqueue_script( 'jquery-chosen' ); + wp_enqueue_script( 'chosen' ); wp_enqueue_script( 'jquery-tiptip' ); wp_enqueue_script( 'jquery-caret' ); wp_enqueue_script( 'jquery-countdown' ); @@ -99,6 +99,10 @@ class SP_Admin_Assets { wp_localize_script( 'sportspress-admin', 'localized_strings', $params ); } + if ( in_array( $screen->id, array( 'dashboard' ) ) ) { + //wp_enqueue_style( 'sportspress-admin-dashboard' ); + } + // Edit venue pages if ( in_array( $screen->id, array( 'edit-sp_venue' ) ) ) { diff --git a/includes/admin/settings/options-permalink.php b/includes/admin/class-sp-admin-permalink-settings.php similarity index 65% rename from includes/admin/settings/options-permalink.php rename to includes/admin/class-sp-admin-permalink-settings.php index e08c6efa..da622123 100644 --- a/includes/admin/settings/options-permalink.php +++ b/includes/admin/class-sp-admin-permalink-settings.php @@ -1,5 +1,25 @@ slugs = array( array( 'events', __( 'Events', 'sportspress' ) ), @@ -19,36 +39,45 @@ class SportsPressPermalinkSettingsSection { add_action( 'admin_init', array( $this, 'settings_save' ) ); } - function settings_init() { - add_settings_section( - 'sportspress', - __( 'SportsPress', 'sportspress' ), - array( $this, 'settings' ), - 'permalink' - ); + /** + * Init our settings + */ + public function settings_init() { + // Add a section to the permalinks page + add_settings_section( 'sportspress-permalink', __( 'SportsPress', 'sportspress' ), array( $this, 'settings' ), 'permalink' ); + // Add our settings foreach ( $this->slugs as $slug ): add_settings_field( - $slug[0], - $slug[1], - array( $this, 'slug_callback' ), - 'permalink', - 'sportspress' + $slug[0], // id + $slug[1], // setting title + array( $this, 'slug_input' ), // display callback + 'permalink', // settings page + 'sportspress-permalink' // settings section ); endforeach; } - public function settings() { - echo wpautop( __( 'These settings control the permalinks used for SportsPress. These settings only apply when not using "default" permalinks above.', 'sportspress' ) ); - } - - public function slug_callback( $test ) { + /** + * Show a slug input box. + */ + public function slug_input() { $slug = array_shift( $this->slugs ); $key = $slug[0]; $text = get_option( 'sportspress_' . $key . '_slug', null ); ?>
not using "default" permalinks above.', 'sportspress' ) ); + } + + /** + * Save the settings + */ public function settings_save() { if ( ! is_admin() ) return; @@ -67,5 +96,6 @@ class SportsPressPermalinkSettingsSection { } } -if ( is_admin() ) - $sportspress_permalink_settings_section = new SportsPressPermalinkSettingsSection(); +endif; + +return new SP_Admin_Permalink_Settings(); \ No newline at end of file diff --git a/includes/admin/class-sp-admin-settings.php b/includes/admin/class-sp-admin-settings.php index e6b9870b..f71818e2 100644 --- a/includes/admin/class-sp-admin-settings.php +++ b/includes/admin/class-sp-admin-settings.php @@ -34,7 +34,6 @@ class SP_Admin_Settings { $settings[] = include( 'settings/class-sp-settings-events.php' ); $settings[] = include( 'settings/class-sp-settings-teams.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' ); self::$settings = apply_filters( 'sportspress_get_settings_pages', $settings ); @@ -103,10 +102,10 @@ class SP_Admin_Settings { 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( - 'i18n_nav_warning' => __( 'The changes you made will be lost if you navigate away from this page.', 'sportspress' ) + wp_localize_script( 'sportspress_settings', 'localized_strings', array( + 'none' => __( 'None', 'sportspress' ) ) ); // Include settings pages @@ -464,102 +463,6 @@ class SP_Admin_Settings { } 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 ); - - ?> - - - - × px - - - - - $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 ); - - ?> - - - - - countries->countries; - - if ( strstr( $country_setting, ':' ) ) { - $country_setting = explode( ':', $country_setting ); - $country = current( $country_setting ); - $state = end( $country_setting ); - } else { - $country = $country_setting; - $state = '*'; - } - ?> - - - - - - - countries->countries; - - asort( $countries ); - ?> - - - - - -
- - - + diff --git a/includes/admin/post-types/class-sp-admin-meta-boxes.php b/includes/admin/post-types/class-sp-admin-meta-boxes.php index bf0dd711..c92f5f24 100644 --- a/includes/admin/post-types/class-sp-admin-meta-boxes.php +++ b/includes/admin/post-types/class-sp-admin-meta-boxes.php @@ -98,7 +98,7 @@ class SP_Admin_Meta_Boxes { // Calendars 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_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' ); @@ -119,10 +119,10 @@ class SP_Admin_Meta_Boxes { // Lists 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_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' ); } /** diff --git a/includes/admin/post-types/meta-boxes/class-sp-meta-box-calendar-format.php b/includes/admin/post-types/meta-boxes/class-sp-meta-box-calendar-layout.php similarity index 100% rename from includes/admin/post-types/meta-boxes/class-sp-meta-box-calendar-format.php rename to includes/admin/post-types/meta-boxes/class-sp-meta-box-calendar-layout.php diff --git a/includes/admin/post-types/meta-boxes/class-sp-meta-box-list-description.php b/includes/admin/post-types/meta-boxes/class-sp-meta-box-list-description.php new file mode 100644 index 00000000..c2d5c895 --- /dev/null +++ b/includes/admin/post-types/meta-boxes/class-sp-meta-box-list-description.php @@ -0,0 +1,24 @@ +post_content, 'content' ); + } +} \ No newline at end of file diff --git a/includes/admin/post-types/meta-boxes/class-sp-meta-box-list-shortcode.php b/includes/admin/post-types/meta-boxes/class-sp-meta-box-list-shortcode.php new file mode 100644 index 00000000..b7a689d8 --- /dev/null +++ b/includes/admin/post-types/meta-boxes/class-sp-meta-box-list-shortcode.php @@ -0,0 +1,30 @@ +ID, 'sp_format', true ); + ?> +

+ +

+

+ 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(); \ No newline at end of file diff --git a/includes/admin/settings/class-sp-settings-checkout.php b/includes/admin/settings/class-sp-settings-checkout.php deleted file mode 100644 index f2d8c438..00000000 --- a/includes/admin/settings/class-sp-settings-checkout.php +++ /dev/null @@ -1,322 +0,0 @@ -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() { - ?> - - - - - - - __( 'Default', 'sportspress' ), - 'name' => __( 'Gateway', 'sportspress' ), - 'id' => __( 'Gateway ID', 'sportspress' ), - 'status' => __( 'Status', 'sportspress' ), - 'settings' => '' - ) ); - - foreach ( $columns as $key => $column ) { - echo ''; - } - ?> - - - - payment_gateways->payment_gateways() as $gateway ) { - - echo ''; - - foreach ( $columns as $key => $column ) { - switch ( $key ) { - case 'default' : - echo ''; - break; - case 'name' : - echo ''; - break; - case 'id' : - echo ''; - break; - case 'status' : - echo ''; - break; - case 'settings' : - echo ''; - break; - default : - do_action( 'sportspress_payment_gateways_setting_column_' . $key, $gateway ); - break; - } - } - - echo ''; - } - ?> - -
' . esc_html( $column ) . '
- id ), false ) . ' /> - - - ' . $gateway->get_title() . ' - - ' . esc_html( $gateway->id ) . ' - '; - - if ( $gateway->enabled == 'yes' ) - echo '' . __ ( 'Enabled', 'sportspress' ) . ''; - else - echo '-'; - - echo ' - ' . __( 'Settings', 'sportspress' ) . ' -
- - - 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(); \ No newline at end of file diff --git a/includes/admin/settings/class-sp-settings-config.php b/includes/admin/settings/class-sp-settings-config.php index 03b26cc1..2ccf4641 100644 --- a/includes/admin/settings/class-sp-settings-config.php +++ b/includes/admin/settings/class-sp-settings-config.php @@ -51,9 +51,9 @@ class SP_Settings_Config extends SP_Settings_Page { 'type' => 'select', 'options' => SP()->sports->options, ), - + array( 'type' => 'results' ), - + array( 'type' => 'outcomes' ), array( 'type' => 'columns' ), @@ -69,51 +69,110 @@ class SP_Settings_Config extends SP_Settings_Page { )); // 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; + $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(); - SP_Admin_Settings::save_fields( $settings ); + $sport = SP()->sports->$_POST['sportspress_sport']; - } 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 * @return void */ public function results_setting() { - $main_result = get_option( 'sportspress_main_result', 0 ); + $selection = get_option( 'sportspress_primary_result', 0 ); $args = array( 'post_type' => 'sp_result', @@ -127,54 +186,57 @@ class SP_Settings_Config extends SP_Settings_Page { - - - - - - - - - - - - - - - - - > - - - - - - -
>
post_name ); ?>>post_name; ?>for / post_name; ?>against
-
-
- - +
+ + + + + + + + + + + + + + + + + + > + + + + + + +
>
post_name ); ?>>post_name; ?>for / post_name; ?>against
+
+
+ + +
+
-
-
+ 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. Click here to preview your email template. For more advanced control copy sportspress/templates/emails/ to yourtheme/sportspress/emails/.', '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 media uploader.', '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 #557da1.', '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 #f5f5f5.', '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 #fdfdfd.', '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 #505050.', '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(); \ No newline at end of file diff --git a/includes/admin/settings/class-sp-settings-events.php b/includes/admin/settings/class-sp-settings-events.php index 0076ae38..4bd1974b 100644 --- a/includes/admin/settings/class-sp-settings-events.php +++ b/includes/admin/settings/class-sp-settings-events.php @@ -18,7 +18,7 @@ if ( ! class_exists( 'SP_Settings_Events' ) ) : class SP_Settings_Events extends SP_Settings_Page { /** - * Constructor. + * Constructor */ public function __construct() { $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_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' ) ); } @@ -35,674 +36,112 @@ class SP_Settings_Events extends SP_Settings_Page { * @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_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( - 'title' => __( 'Delimiter', 'sportspress' ), - 'id' => 'sportspress_event_teams_delimiter', - 'default' => 'vs', - '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' ) ) - ), + 'title' => __( 'Number of Teams', 'sportspress' ), + 'id' => 'sportspress_event_num_teams', + 'css' => 'width:50px;', + 'default' => '2', + 'type' => 'number', + 'custom_attributes' => array( + 'min' => 0, + 'step' => 1 + ) + ), + + array( 'type' => 'delimiter' ), + + array( + 'title' => __( 'Venue', 'sportspress' ), + 'desc' => __( 'Display maps', 'sportspress' ), + 'id' => 'sportspress_event_show_map', + 'default' => 'yes', + 'type' => 'checkbox', + 'checkboxgroup' => 'start', ), 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', + 'desc' => __( 'Link venues', 'sportspress' ), + 'id' => 'sportspress_event_link_venues', 'default' => 'no', '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 Standard Rate. 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: {price_including_tax}, {price_excluding_tax}.', '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 - } + 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 ) ) ) { - $this->output_tax_rates(); - } else { - $settings = $this->get_settings(); + $settings[] = array( 'type' => 'sectionend', 'id' => 'text_options' ); - SP_Admin_Settings::output_fields( $settings ); - } + return apply_filters( 'sportspress_event_settings', $settings ); // End event 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_%')" ); + $settings = $this->get_settings(); + SP_Admin_Settings::save_fields( $settings ); + + if ( isset( $_POST['sportspress_event_teams_delimiter'] ) ) + update_option( 'sportspress_event_teams_delimiter', $_POST['sportspress_event_teams_delimiter'] ); } /** - * Output tax rate tables + * Delimiter settings + * + * @access public + * @return void */ - public function output_tax_rates() { - global $sportspress, $current_section, $wpdb; + public function delimiter_setting() { + $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; ?> -

-

See here for available alpha-2 country codes.', 'sportspress' ), 'http://en.wikipedia.org/wiki/ISO_3166-1#Current_codes' ); ?>

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 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 ) { - ?> - - - - - - - - - - - - - - - - - - - - - - - -
  [?] [?] [?] [?] [?] [?] [?] [?] [?]
- - - - - - - -
- - - - - 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[tax_rate_id ?>]" /> - - 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[tax_rate_id ?>]" /> - - - - - - - - tax_rate_compound, '1' ); ?> /> - - tax_rate_shipping, '1' ); ?> /> -
- + + + + + +
+ + + +
+ + + +
+ + $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_Events(); \ No newline at end of file +return new SP_Settings_Events(); diff --git a/includes/admin/settings/class-sp-settings-general.php b/includes/admin/settings/class-sp-settings-general.php index ddaec88b..2f7e8dc2 100644 --- a/includes/admin/settings/class-sp-settings-general.php +++ b/includes/admin/settings/class-sp-settings-general.php @@ -18,7 +18,7 @@ if ( ! class_exists( 'SP_Settings_General' ) ) : class SP_Settings_General extends SP_Settings_Page { /** - * Constructor. + * Constructor */ public function __construct() { $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_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' ) ); } @@ -35,32 +37,186 @@ class SP_Settings_General extends SP_Settings_Page { * @return array */ 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' => __( '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' => 'country' ), 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; + ?> + + + + + + + + + + + + + + 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'] ); + + ?>
+ + + ' . esc_html( $name ) . ' +
+
'; } } diff --git a/includes/admin/settings/class-sp-settings-integrations.php b/includes/admin/settings/class-sp-settings-integrations.php deleted file mode 100644 index d9807670..00000000 --- a/includes/admin/settings/class-sp-settings-integrations.php +++ /dev/null @@ -1,74 +0,0 @@ -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(); \ No newline at end of file diff --git a/includes/admin/settings/class-sp-settings-page.php b/includes/admin/settings/class-sp-settings-page.php index 8c08b09c..3e155a0e 100644 --- a/includes/admin/settings/class-sp-settings-page.php +++ b/includes/admin/settings/class-sp-settings-page.php @@ -38,36 +38,6 @@ class SP_Settings_Page { 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 '
'; - } - /** * Output the settings */ @@ -91,4 +61,4 @@ class SP_Settings_Page { } } -endif; \ No newline at end of file +endif; diff --git a/includes/admin/settings/class-sp-settings-players.php b/includes/admin/settings/class-sp-settings-players.php index 612f8fa5..f45668a0 100644 --- a/includes/admin/settings/class-sp-settings-players.php +++ b/includes/admin/settings/class-sp-settings-players.php @@ -18,7 +18,7 @@ if ( ! class_exists( 'SP_Settings_Players' ) ) : class SP_Settings_Players extends SP_Settings_Page { /** - * Constructor. + * Constructor */ public function __construct() { $this->id = 'players'; @@ -35,749 +35,49 @@ class SP_Settings_Players extends SP_Settings_Page { * @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_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( - 'title' => __( 'Enable Players', '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', - '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', + 'title' => __( 'Nationality', 'sportspress' ), + 'desc' => __( 'Display national flag', 'sportspress' ), + 'id' => 'sportspress_player_show_flag', + '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 Standard Rate. 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 ) + 'title' => __( 'Player Lists', 'sportspress' ), + 'desc' => __( 'Link players', 'sportspress' ), + 'id' => 'sportspress_list_link_players', + 'default' => 'yes', + 'type' => 'checkbox', ), - 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( 'type' => 'sectionend', 'id' => 'player_options' ), - 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: {price_including_tax}, {price_excluding_tax}.', 'sportspress' ), - ), + array( 'title' => __( 'Text', 'sportspress' ), 'type' => 'title', 'desc' => __( 'The following options affect how words are displayed on the frontend.', 'sportspress' ), 'id' => 'text_options' ), - 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; - ?> -

-

See here for available alpha-2 country codes.', 'sportspress' ), 'http://en.wikipedia.org/wiki/ISO_3166-1#Current_codes' ); ?>

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 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 ) { - ?> - - - - - - - - - - - - - - - - - - - - - - - -
  [?] [?] [?] [?] [?] [?] [?] [?] [?]
- - - - - - - -
- - - - - 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[tax_rate_id ?>]" /> - - 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[tax_rate_id ?>]" /> - - - - - - - - tax_rate_compound, '1' ); ?> /> - - tax_rate_shipping, '1' ); ?> /> -
- - $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 ); - ?> - - - - - - - - - - - - - - - - - - - - > - - - - - - -
>
post_name ); ?>>post_name; ?>for / post_name; ?>against
-
-
- - -
-
-
- - - 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; -return new SP_Settings_Players(); \ No newline at end of file +return new SP_Settings_Players(); diff --git a/includes/admin/settings/class-sp-settings-products.php b/includes/admin/settings/class-sp-settings-products.php deleted file mode 100644 index 4d78fbc2..00000000 --- a/includes/admin/settings/class-sp-settings-products.php +++ /dev/null @@ -1,458 +0,0 @@ -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 = ' ' . __( 'Note: The shop page has children - child pages will not work if you enable this option.', 'sportspress' ) . ''; - - 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' => '
' . sprintf( __( 'The base page can also be used in your product permalinks.', '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 regenerate your thumbnails.', '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, X-Accel-Redirect/ X-Sendfile can be used to serve downloads instead (server requires mod_xsendfile).', '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(); \ No newline at end of file diff --git a/includes/admin/settings/class-sp-settings-shipping.php b/includes/admin/settings/class-sp-settings-shipping.php deleted file mode 100644 index e4ad3101..00000000 --- a/includes/admin/settings/class-sp-settings-shipping.php +++ /dev/null @@ -1,281 +0,0 @@ -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 locations you sell to.', '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') ); - ?> - - - - - - - - - - - - - - - - - - - - - - shipping->load_shipping_methods() as $key => $method ) { - echo ' - - - - - - '; - } - ?> - -
 
- /> -
- id, false ) . ' /> - - - ' . $method->get_title() . ' - - ' . $method->id . ' - '; - - if ( $method->enabled == 'yes' ) - echo '' . __ ( 'Enabled', 'sportspress' ) . ''; - else - echo '-'; - - echo ''; - - if ( $method->has_settings ) { - echo '' . __( 'Settings', 'sportspress' ) . ''; - } - - echo '
- - - 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(); diff --git a/includes/admin/settings/class-sp-settings-tax.php b/includes/admin/settings/class-sp-settings-tax.php deleted file mode 100644 index fd50c87d..00000000 --- a/includes/admin/settings/class-sp-settings-tax.php +++ /dev/null @@ -1,735 +0,0 @@ -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 Standard Rate. 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: {price_including_tax}, {price_excluding_tax}.', '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; - ?> -

-

See here for available alpha-2 country codes.', 'sportspress' ), 'http://en.wikipedia.org/wiki/ISO_3166-1#Current_codes' ); ?>

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 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 ) { - ?> - - - - - - - - - - - - - - - - - - - - - - - -
  [?] [?] [?] [?] [?] [?] [?] [?] [?]
- - - - - - - -
- - - - - 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[tax_rate_id ?>]" /> - - 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[tax_rate_id ?>]" /> - - - - - - - - tax_rate_compound, '1' ); ?> /> - - tax_rate_shipping, '1' ); ?> /> -
- - $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(); \ No newline at end of file diff --git a/includes/admin/settings/class-sp-settings-teams.php b/includes/admin/settings/class-sp-settings-teams.php index ad1a1d08..544ea3c3 100644 --- a/includes/admin/settings/class-sp-settings-teams.php +++ b/includes/admin/settings/class-sp-settings-teams.php @@ -18,7 +18,7 @@ if ( ! class_exists( 'SP_Settings_Teams' ) ) : class SP_Settings_Teams extends SP_Settings_Page { /** - * Constructor. + * Constructor */ public function __construct() { $this->id = 'teams'; @@ -35,749 +35,50 @@ class SP_Settings_Teams extends SP_Settings_Page { * @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_event_settings', array( - - array( 'title' => __( 'Team Options', 'sportspress' ), 'type' => 'title','desc' => '', 'id' => 'tax_options' ), + $settings = array( + array( 'title' => __( 'Team Options', 'sportspress' ), 'type' => 'title','desc' => '', 'id' => 'team_options' ), + array( - 'title' => __( 'Enable Teams', 'sportspress' ), - 'desc' => __( 'Enable taxes and tax calculations', 'sportspress' ), - 'id' => 'sportspress_calc_taxes', - 'default' => 'no', - 'type' => 'checkbox' + 'title' => __( 'League Tables', 'sportspress' ), + 'desc' => __( 'Display logos', 'sportspress' ), + 'id' => 'sportspress_table_show_logos', + 'default' => 'yes', + 'type' => 'checkbox', + 'checkboxgroup' => 'start', ), array( - 'title' => __( 'Prices Entered With Tax', 'sportspress' ), - 'id' => 'sportspress_prices_include_tax', - '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', + 'desc' => __( 'Link teams', 'sportspress' ), + 'id' => 'sportspress_table_link_teams', 'default' => 'no', 'type' => 'checkbox', + 'checkboxgroup' => 'end', ), - array( - 'title' => __( 'Additional Tax Classes', 'sportspress' ), - 'desc' => __( 'List additonal tax classes below (1 per line). This is in addition to the default Standard Rate. 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( 'type' => 'sectionend', 'id' => 'team_options' ), - 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' => __( 'Text', 'sportspress' ), 'type' => 'title', 'desc' => __( 'The following options affect how words are displayed on the frontend.', 'sportspress' ), 'id' => 'text_options' ), - 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: {price_including_tax}, {price_excluding_tax}.', '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; - ?> -

-

See here for available alpha-2 country codes.', 'sportspress' ), 'http://en.wikipedia.org/wiki/ISO_3166-1#Current_codes' ); ?>

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 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 ) { - ?> - - - - - - - - - - - - - - - - - - - - - - - -
  [?] [?] [?] [?] [?] [?] [?] [?] [?]
- - - - - - - -
- - - - - 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[tax_rate_id ?>]" /> - - 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[tax_rate_id ?>]" /> - - - - - - - - tax_rate_compound, '1' ); ?> /> - - tax_rate_shipping, '1' ); ?> /> -
- - $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 ); - ?> - - - - - - - - - - - - - - - - - - - - > - - - - - - -
>
post_name ); ?>>post_name; ?>for / post_name; ?>against
-
-
- - -
-
-
- - - 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; -return new SP_Settings_Teams(); \ No newline at end of file +return new SP_Settings_Teams(); diff --git a/includes/admin/settings/class-sp-settings-text.php b/includes/admin/settings/class-sp-settings-text.php deleted file mode 100644 index 10cfd49a..00000000 --- a/includes/admin/settings/class-sp-settings-text.php +++ /dev/null @@ -1,83 +0,0 @@ -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(); \ No newline at end of file diff --git a/includes/admin/settings/globals.php b/includes/admin/settings/globals.php deleted file mode 100644 index 26bd5655..00000000 --- a/includes/admin/settings/globals.php +++ /dev/null @@ -1,30 +0,0 @@ -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' ) ); - ?> -
- - - -
- - - -
- 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 ); - ?> -
- -
-
- -
-
- -
- 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 ); - ?> -
- - - - - - - - - - - - - - - - > - - - - - -
>
post_name ); ?>>post_name; ?>for / post_name; ?>against
-
-
- - -
-
-
-
- 'sp_outcome', - 'numberposts' => -1, - 'posts_per_page' => -1, - 'orderby' => 'menu_order', - 'order' => 'ASC' - ); - $data = get_posts( $args ); - ?> -
- - - - - - - - - > - - - - -
post_title; ?>post_name; ?>
-
-
- - -
-
-
-
- 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 ); - ?> -
- - class="hidden"> -
- 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 ); - ?> -
- -
- 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 ); - ?> -
- -
-
- -
-
- -
- options, 'player_gallery_show_names_on_hover', true ); - ?> -
- -
- 'sp_metric', - 'numberposts' => -1, - 'posts_per_page' => -1, - 'orderby' => 'menu_order', - 'order' => 'ASC' - ); - $data = get_posts( $args ); - ?> -
- - - - - - - - - - > - - - - - -
 
post_title; ?>ID, 'sp_position' ) ? the_terms( $row->ID, 'sp_position' ) : '—'; ?> 
-
-
- - -
-
-
-
- 'sp_performance', - 'numberposts' => -1, - 'posts_per_page' => -1, - 'orderby' => 'menu_order', - 'order' => 'ASC' - ); - $data = get_posts( $args ); - ?> -
- - - - - - - - - - > - - - - - -
post_title; ?>ID, 'sp_position' ) ? the_terms( $row->ID, 'sp_position' ) : '—'; ?>ID ); ?>
-
-
- - -
-
-
-
- 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 ); - ?> -
- -
-
- -
-
- -
-
- -
- 'sp_column', - 'numberposts' => -1, - 'posts_per_page' => -1, - 'orderby' => 'menu_order', - 'order' => 'ASC' - ); - $data = get_posts( $args ); - ?> -
- - - - - - - - - - - - > - - - - - - - -
post_title; ?>post_name; ?>ID, $row->post_name ); ?>ID ); ?>ID ); ?>
-
-
- - -
-
-
-
- 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 ); - ?>
-
- - - -
- -
- -
- $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' ); diff --git a/includes/class-sp-countries.php b/includes/class-sp-countries.php index 7bad13ee..d858d7ed 100644 --- a/includes/class-sp-countries.php +++ b/includes/class-sp-countries.php @@ -245,4 +245,38 @@ class SP_Countries { $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 ): + ?> + + $country ): ?> + + + + 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' - ), - ) ); + add_action( 'wp_print_scripts', array( $this, 'check_jquery' ), 25 );; + add_action( 'wp_print_scripts', array( $this, 'custom_css' ), 30 );; } /** @@ -53,129 +26,18 @@ class SP_Frontend_Scripts { * @return void */ 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'; - $lightbox_en = get_option( 'sportspress_enable_lightbox' ) == 'yes' ? true : false; - $ajax_cart_en = get_option( 'sportspress_enable_ajax_add_to_cart' ) == 'yes' ? true : false; - $assets_path = str_replace( array( 'http:', 'https:' ), '', SP()->plugin_url() ) . '/assets/'; - $frontend_script_path = $assets_path . 'js/frontend/'; + // 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 ); - // Register any scripts for later use, or used as dependencies - wp_register_script( 'chosen', $assets_path . 'js/chosen/chosen.jquery' . $suffix . '.js', array( 'jquery' ), '1.0.0', true ); - 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'] ); + // Localize scripts. + wp_localize_script( 'sportspress', 'localized_strings', array( 'days' => __( 'days', 'sportspress' ), 'hrs' => __( 'hrs', 'sportspress' ), 'mins' => __( 'mins', 'sportspress' ), 'secs' => __( 'secs', 'sportspress' ) ) ); } /** @@ -198,21 +60,35 @@ class SP_Frontend_Scripts { } } - /** - * Provide backwards compat for old constant - * @param array $styles - * @return array - */ - public function backwards_compat( $styles ) { - if ( defined( 'WOOCOMMERCE_USE_CSS' ) ) { + public function custom_css() { + $enabled = get_option( 'sportspress_enable_frontend_css', 'yes' ); - _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 ) - return false; + $colors = get_option( 'sportspress_frontend_css_colors' ); + + if ( sizeof( $colors ) > 0 ) { + + echo ''; + } } - - return $styles; } } diff --git a/includes/class-sp-install.php b/includes/class-sp-install.php new file mode 100644 index 00000000..1277846c --- /dev/null +++ b/includes/class-sp-install.php @@ -0,0 +1,509 @@ +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 '
'; + + foreach ( $notices as $index => $line ) { + echo '

' . wp_kses_post( preg_replace( '~\[([^\]]*)\]\(([^\)]*)\)~', '${1}', $line ) ) . '

'; + } + + echo '
'; + } + } + + // 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' ) . '
'; + + $ul = false; + + foreach ( $changelog as $index => $line ) { + if ( preg_match('~^\s*\*\s*~', $line ) ) { + if ( ! $ul ) { + echo ''; + $ul = false; + } + + echo '

' . esc_html( htmlspecialchars( $line ) ) . '

'; + } + } + + if ( $ul ) { + echo ''; + } + + echo '
'; + } + } + } +} + +endif; + +return new SP_Install(); diff --git a/includes/class-sp-text.php b/includes/class-sp-text.php index 2ece5adb..07897d46 100644 --- a/includes/class-sp-text.php +++ b/includes/class-sp-text.php @@ -13,7 +13,7 @@ class SP_Text { /** @var array Array of text */ - public $text; + public $data; /** * Constructor for the text class - defines all editable strings. @@ -22,40 +22,68 @@ class SP_Text { * @return void */ public function __construct() { - $strings = array( - __( 'Article', 'sportspress' ), - __( 'Current Team', 'sportspress' ), - __( 'Date', 'sportspress' ), - __( 'Details', 'sportspress' ), - __( 'days', 'sportspress' ), - __( 'Event', 'sportspress' ), - __( 'Friendly', 'sportspress' ), - __( 'hrs', 'sportspress' ), - __( 'League', 'sportspress' ), - __( 'mins', 'sportspress' ), - __( 'Nationality', 'sportspress' ), - __( 'Past Teams', 'sportspress' ), - __( 'Player', 'sportspress' ), - __( 'Position', 'sportspress' ), - __( 'Pos', 'sportspress' ), - __( 'Preview', 'sportspress' ), - __( 'Rank', 'sportspress' ), - __( 'Recap', 'sportspress' ), - __( 'Results', 'sportspress' ), - __( 'Season', 'sportspress' ), - __( 'secs', 'sportspress' ), - __( 'Staff', 'sportspress' ), - __( 'Substitute', 'sportspress' ), - __( 'Team', 'sportspress' ), - __( 'Teams', 'sportspress' ), - __( 'Time', 'sportspress' ), - __( 'Total', 'sportspress' ), - __( 'Venue', 'sportspress' ), - __( 'View all players', 'sportspress' ), - __( 'View all events', 'sportspress' ), - __( 'View full table', 'sportspress' ), - ); - sort( $strings ); - $this->strings = apply_filters( 'sportspress_text', $strings ); + $this->data = apply_filters( 'sportspress_text', array( + 'general' => array( + 'league' => __( 'League', 'sportspress' ), + 'season' => __( 'Season', 'sportspress' ), + ), + 'event' => array( + 'event' => __( 'Event', 'sportspress' ), + 'date' => __( 'Date', 'sportspress' ), + 'time' => __( 'Time', 'sportspress' ), + 'results' => __( 'Results', 'sportspress' ), + 'team' => __( 'Team', 'sportspress' ), + 'teams' => __( 'Teams', 'sportspress' ), + 'details' => __( 'Details', 'sportspress' ), + 'venue' => __( 'Venue', 'sportspress' ), + 'player' => __( 'Player', 'sportspress' ), + 'substitutes' => __( 'Substitutes', 'sportspress' ), + 'total' => __( 'Total', 'sportspress' ), + 'article' => __( 'Article', 'sportspress' ), + 'preview' => __( 'Preview', 'sportspress' ), + 'recap' => __( 'Recap', 'sportspress' ), + 'view_all_events' => __( 'View all events', 'sportspress' ), + ), + 'team' => array( + 'team' => __( 'Team', 'sportspress' ), + 'teams' => __( 'Teams', 'sportspress' ), + 'pos' => __( 'Pos', 'sportspress' ), + 'view_full_table' => __( 'View full table', 'sportspress' ), + ), + 'player' => array( + 'player' => __( 'Player', 'sportspress' ), + 'position' => __( 'Position', 'sportspress' ), + 'nationality' => __( 'Nationality', 'sportspress' ), + 'current_team' => __( 'Current Team', 'sportspress' ), + 'past_teams' => __( 'Past Teams', 'sportspress' ), + '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; } } diff --git a/includes/sp-core-functions.php b/includes/sp-core-functions.php index ea46b18a..dc0394a6 100644 --- a/includes/sp-core-functions.php +++ b/includes/sp-core-functions.php @@ -14,6 +14,7 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly // Include core functions include( 'sp-conditional-functions.php' ); +include( 'sp-formatting-functions.php' ); include( 'sp-deprecated-functions.php' ); /** @@ -181,21 +182,9 @@ if( !function_exists( 'date_diff' ) ) { if ( !function_exists( 'sp_flush_rewrite_rules' ) ) { function sp_flush_rewrite_rules() { // Flush rewrite rules - sportspress_result_post_init(); - sportspress_outcome_post_init(); - sportspress_column_post_init(); - 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(); + $post_types = new SP_Post_types(); + $post_types->register_taxonomies(); + $post_types->register_post_types(); flush_rewrite_rules(); } } @@ -2195,7 +2184,7 @@ if ( !function_exists( 'sp_get_league_table_data' ) ) { unset( $columns[ $key ] ); endif; endforeach; - $labels = array_merge( array( 'name' => __( 'Team', 'sportspress' ) ), $columns ); + $labels = array_merge( array( 'name' => SP()->text->string('Team', 'team') ), $columns ); $merged[0] = $labels; return $merged; endif; @@ -2388,7 +2377,7 @@ if ( !function_exists( 'sp_get_player_list_data' ) ) { ); $performances = get_posts( $args ); - $columns = array( 'eventsplayed' => __( 'Played', 'sportspress' ) ); + $columns = array( 'eventsplayed' => SP()->text->string('Played', 'team') ); foreach ( $performances as $performance ): @@ -2491,7 +2480,7 @@ if ( !function_exists( 'sp_get_player_list_data' ) ) { unset( $columns[ $key ] ); endif; endforeach; - $labels = array_merge( array( 'name' => __( 'Player', 'sportspress' ) ), $columns ); + $labels = array_merge( array( 'name' => SP()->text->string('Player', 'player') ), $columns ); $merged[0] = $labels; return $merged; endif; @@ -2654,7 +2643,7 @@ if ( !function_exists( 'sp_get_player_roster_data' ) ) { ); $performances = get_posts( $args ); - $columns = array( 'eventsplayed' => __( 'Played', 'sportspress' ) ); + $columns = array( 'eventsplayed' => SP()->text->string('Played', 'player') ); foreach ( $performances as $performance ): @@ -2750,7 +2739,7 @@ if ( !function_exists( 'sp_get_player_roster_data' ) ) { if ( $admin ): return array( $columns, $data, $placeholders, $merged ); else: - $labels = array_merge( array( 'name' => __( 'Player', 'sportspress' ) ), $columns ); + $labels = array_merge( array( 'name' => SP()->text->string('Player', 'player') ), $columns ); $merged[0] = $labels; return $merged; endif; @@ -2856,7 +2845,7 @@ if ( !function_exists( 'sp_get_player_performance_data' ) ) { $performance_labels[ $performance->post_name ] = $performance->post_title; $equations[ $performance->post_name ] = get_post_meta( $performance->ID, 'sp_calculate', true ); 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 $div_ids = array(); @@ -2991,7 +2980,7 @@ if ( !function_exists( 'sp_get_player_performance_data' ) ) { if ( $admin ): return array( $columns, $tempdata, $placeholders, $merged, $seasons_teams ); 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; return $merged; endif; diff --git a/includes/sp-formatting-functions.php b/includes/sp-formatting-functions.php new file mode 100644 index 00000000..94083045 --- /dev/null +++ b/includes/sp-formatting-functions.php @@ -0,0 +1,211 @@ + $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; + } +} diff --git a/includes/sp-template-hooks.php b/includes/sp-template-hooks.php new file mode 100644 index 00000000..7df38d78 --- /dev/null +++ b/includes/sp-template-hooks.php @@ -0,0 +1,413 @@ +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 '
'; +} +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 = '' . $number . ' ' . $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 immediately': + $translated_text = __( 'Date/Time:', 'sportspress' ) . ' ' . __( 'Now', '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 ); + +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 '

' . implode( ' — ', $terms ) . '

'; + + 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' ) . + ' ' . + __( 'View All', 'sportspress' ) . ''; + 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' ) . + ' ' . $obj->labels->view_item . ''; + + $messages['post'][4] = __( 'Changes saved.', 'sportspress' ); + + $messages['post'][6] = __( 'Success!', 'sportspress' ) . + ' ' . $obj->labels->view_item . ''; + + $messages['post'][7] = __( 'Changes saved.', 'sportspress' ); + + $messages['post'][8] = __( 'Success!', 'sportspress' ) . + ' ' . + sprintf( __( 'Preview %s', 'sportspress' ), $obj->labels->singular_name ) . ''; + + $messages['post'][9] = sprintf( + __( 'Scheduled for: %1$s.', 'sportspress' ), + date_i18n( __( 'M j, Y @ G:i', 'sportspress' ), strtotime( $post->post_date ) ), esc_url( get_permalink($post->ID) ) ) . + ' ' . + sprintf( __( 'Preview %s', 'sportspress' ), $obj->labels->singular_name ) . ''; + + $messages['post'][10] = __( 'Success!', 'sportspress' ) . + ' ' . + sprintf( __( 'Preview %s', 'sportspress' ), $obj->labels->singular_name ) . ''; + + endif; + + return $messages; +} + +add_filter('post_updated_messages', 'sportspress_post_updated_messages'); + diff --git a/includes/widgets/class-sp-widget-event-list.php b/includes/widgets/class-sp-widget-event-list.php index 7024d8aa..9a40d796 100644 --- a/includes/widgets/class-sp-widget-event-list.php +++ b/includes/widgets/class-sp-widget-event-list.php @@ -2,7 +2,7 @@ class SP_Widget_Event_List extends WP_Widget { 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); } diff --git a/includes/widgets/class-sp-widget-league-table.php b/includes/widgets/class-sp-widget-league-table.php index 92e16552..11f87741 100644 --- a/includes/widgets/class-sp-widget-league-table.php +++ b/includes/widgets/class-sp-widget-league-table.php @@ -2,7 +2,7 @@ class SP_Widget_League_Table extends WP_Widget { 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); } diff --git a/includes/widgets/class-sp-widget-player-list.php b/includes/widgets/class-sp-widget-player-list.php index c920e0fc..4b560a56 100644 --- a/includes/widgets/class-sp-widget-player-list.php +++ b/includes/widgets/class-sp-widget-player-list.php @@ -2,7 +2,7 @@ class SP_Widget_Player_list extends WP_Widget { 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); } diff --git a/sportspress.php b/sportspress.php index 694475eb..2cf6a878 100644 --- a/sportspress.php +++ b/sportspress.php @@ -201,21 +201,8 @@ final class SportsPress { * Include required core files used in admin and on the frontend. */ private function includes() { - - // Functions include_once( 'includes/sp-core-functions.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' ); + include_once( 'includes/class-sp-install.php' ); if ( is_admin() ) { 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-text.php' ); // Defines editable strings - // Typical request actions (deprecating) - include_once( 'admin/hooks/plugins-loaded.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 template hooks in time for themes to remove/modify them + include_once( 'includes/sp-template-hooks.php' ); } /** * Include required frontend files. */ public function frontend_includes() { + include_once( 'includes/class-sp-frontend-scripts.php' ); // Frontend Scripts include_once( 'includes/class-sp-shortcodes.php' ); // Shortcodes class } @@ -287,7 +243,6 @@ final class SportsPress { * Include core 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-event-calendar.php' ); include_once( 'includes/widgets/class-sp-widget-event-list.php' ); diff --git a/templates/event-calendar.php b/templates/event-calendar.php index 93472ec2..43da1088 100644 --- a/templates/event-calendar.php +++ b/templates/event-calendar.php @@ -195,6 +195,6 @@ if ( $pad != 0 && $pad != 7 ) $calendar_output .= "\n\t\n\t\n\t\n\t
"; if ( $id && $show_all_events_link ) - $calendar_output .= '' . __( 'View all events', 'sportspress' ) . ''; + $calendar_output .= '' . SP()->text->string('View all events', 'event') . ''; echo apply_filters( 'sportspress_event_calendar', $calendar_output ); diff --git a/templates/event-details.php b/templates/event-details.php index 3070d922..d802d1b0 100644 --- a/templates/event-details.php +++ b/templates/event-details.php @@ -7,19 +7,19 @@ $time = get_the_time( get_option('time_format'), $id ); $leagues = get_the_terms( $id, 'sp_league' ); $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 ): $league = array_pop( $leagues ); - $data[ __( 'League', 'sportspress' ) ] = $league->name; + $data[ SP()->text->string('League') ] = $league->name; endif; if ( $seasons ): $season = array_pop( $seasons ); - $data[ __( 'Season', 'sportspress' ) ] = $season->name; + $data[ SP()->text->string('Season') ] = $season->name; endif; -$output = '

' . __( 'Details', 'sportspress' ) . '

'; +$output = '

' . SP()->text->string('Details', 'event') . '

'; $output .= '
' . ''; diff --git a/templates/event-list.php b/templates/event-list.php index af4b26cc..12f0d662 100644 --- a/templates/event-list.php +++ b/templates/event-list.php @@ -16,19 +16,19 @@ list( $data, $usecolumns ) = sportspress_get_calendar_data( $id, true ); if ( isset( $columns ) ) $usecolumns = $columns; -$output .= ''; +$output .= ''; if ( $usecolumns == null || in_array( 'event', $usecolumns ) ) - $output .= ''; + $output .= ''; if ( $usecolumns == null || in_array( 'teams', $usecolumns ) ) - $output .= ''; + $output .= ''; if ( $usecolumns == null || in_array( 'time', $usecolumns ) ) - $output .= ''; + $output .= ''; if ( $usecolumns == null || in_array( 'article', $usecolumns ) ) - $output .= ''; + $output .= ''; $output .= '' . '' . ''; @@ -40,13 +40,13 @@ foreach ( $data as $event ): $output .= ''; - $output .= ''; + $output .= ''; if ( $usecolumns == null || in_array( 'event', $usecolumns ) ) - $output .= ''; + $output .= ''; if ( $usecolumns == null || in_array( 'teams', $usecolumns ) ): - $output .= ''; + $output .= ''; if ( $usecolumns == null || in_array( 'article', $usecolumns ) ): - $output .= '' . '
' . __( 'Date', 'sportspress' ). '' . SP()->text->string('Date', 'event') . '' . __( 'Event', 'sportspress' ). '' . SP()->text->string('Event', 'event') . '' . __( 'Teams', 'sportspress' ). '' . SP()->text->string('Teams', 'event') . '' . __( 'Time', 'sportspress' ). '' . SP()->text->string('Time', 'event') . '' . __( 'Article', 'sportspress' ). '' . SP()->text->string('Article', 'event') . '
' . get_post_time( get_option( 'date_format' ), false, $event ) . '' . get_post_time( get_option( 'date_format' ), false, $event ) . '' . $event->post_title . '' . $event->post_title . ''; + $output .= ''; $teams = get_post_meta( $event->ID, 'sp_team', false ); if ( $teams ): @@ -83,11 +83,11 @@ foreach ( $data as $event ): endif; if ( $usecolumns == null || in_array( 'time', $usecolumns ) ) - $output .= '' . get_post_time( get_option( 'time_format' ), false, $event ) . '' . get_post_time( get_option( 'time_format' ), false, $event ) . ' - '; + $output .= ' + '; if ( $video ): $output .= '
'; @@ -96,9 +96,9 @@ foreach ( $data as $event ): endif; if ( $event->post_content !== null ): if ( $event->post_status == 'publish' ): - $output .= __( 'Recap', 'sportspress' ); + $output .= SP()->text->string('Recap', 'event'); else: - $output .= __( 'Preview', 'sportspress' ); + $output .= SP()->text->string('Preview', 'event'); endif; endif; @@ -114,7 +114,7 @@ endforeach; $output .= '
'; if ( $id && $show_all_events_link ) - $output .= '' . __( 'View all events', 'sportspress' ) . ''; + $output .= '' . SP()->text->string('View all events', 'event') . ''; $output .= '
'; diff --git a/templates/event-performance.php b/templates/event-performance.php index c7f939e9..8350af50 100644 --- a/templates/event-performance.php +++ b/templates/event-performance.php @@ -8,9 +8,9 @@ $teams = (array)get_post_meta( $id, 'sp_team', false ); $staff = (array)get_post_meta( $id, 'sp_staff', false ); $stats = (array)get_post_meta( $id, 'sp_players', true ); $performance_labels = sportspress_get_var_labels( 'sp_performance' ); -$link_posts = sportspress_array_value( $sportspress_options, 'event_performance_link_posts', true ); -$sortable = sportspress_array_value( $sportspress_options, 'event_performance_sortable', true ); -$responsive = sportspress_array_value( $sportspress_options, 'event_performance_responsive', true ); +$link_posts = get_option( 'sportspress_event_link_players', 'yes' ) == 'yes' ? true : false; +$sortable = get_option( 'sportspress_enable_sortable_tables', 'yes' ) == 'yes' ? true : false; +$responsive = get_option( 'sportspress_enable_responsive_tables', 'yes' ) == 'yes' ? true : false; $output = ''; @@ -29,7 +29,7 @@ foreach( $teams as $key => $team_id ): '' . '' . ''; $output .= ''; - $output .= ''; + $output .= ''; foreach( $performance_labels as $key => $label ): $output .= ''; @@ -94,7 +94,7 @@ foreach( $teams as $key => $team_id ): // Player number $output .= ''; - $output .= ''; + $output .= ''; $row = $data[0]; diff --git a/templates/event-results.php b/templates/event-results.php index 713b67c1..108d65c0 100644 --- a/templates/event-results.php +++ b/templates/event-results.php @@ -49,11 +49,11 @@ if ( empty( $table_rows ) ): else: - $output .= '

' . __( 'Results', 'sportspress' ) . '

'; + $output .= '

' . SP()->text->string('Results', 'event') . '

'; $output .= '
' . '
#' . __( 'Player', 'sportspress' ) . '' . SP()->text->string('Player', 'event') . '' . $label . ' ' . __( 'Total', 'sportspress' ) . '' . SP()->text->string('Total', 'event') . '
' . - ''; + ''; foreach( $result_labels as $key => $label ): $output .= ''; endforeach; diff --git a/templates/event-venue.php b/templates/event-venue.php index e7687c80..71f9127b 100644 --- a/templates/event-venue.php +++ b/templates/event-venue.php @@ -18,7 +18,7 @@ foreach( $venues as $venue ): $latitude = sportspress_array_value( $term_meta, 'sp_latitude', 0 ); $longitude = sportspress_array_value( $term_meta, 'sp_longitude', 0 ); - $output .= '

' . __( 'Venue', 'sportspress' ) . '

'; + $output .= '

' . SP()->text->string('Venue', 'event') . '

'; $output .= '

' . $venue->name . '
' . $address . '

'; if ( $latitude != null && $longitude != null ) $output .= '
'; diff --git a/templates/league-table.php b/templates/league-table.php index c126b87a..eefc412e 100644 --- a/templates/league-table.php +++ b/templates/league-table.php @@ -6,10 +6,10 @@ $defaults = array( 'number' => -1, 'columns' => null, 'show_full_table_link' => false, - 'show_team_logo' => sportspress_array_value( $sportspress_options, 'league_table_show_team_logo', false ), - 'link_posts' => sportspress_array_value( $sportspress_options, 'league_table_link_posts', false ), - 'sortable' => sportspress_array_value( $sportspress_options, 'league_table_sortable', true ), - 'responsive' => sportspress_array_value( $sportspress_options, 'league_table_responsive', true ), + 'show_team_logo' => get_option( 'sportspress_table_show_logos', 'yes' ) == 'yes' ? true : false, + 'link_posts' => get_option( 'sportspress_table_link_teams', 'no' ) == 'yes' ? true : false, + 'sortable' => get_option( 'sportspress_enable_sortable_tables', 'yes' ) == 'yes' ? true : false, + 'responsive' => get_option( 'sportspress_enable_responsive_tables', 'yes' ) == 'yes' ? true : false, ); extract( $defaults, EXTR_SKIP ); @@ -31,7 +31,7 @@ if ( ! $columns ) if ( ! is_array( $columns ) ) $columns = explode( ',', $columns ); -$output .= ''; +$output .= ''; foreach( $labels as $key => $label ): if ( ! is_array( $columns ) || $key == 'name' || in_array( $key, $columns ) ) @@ -83,7 +83,7 @@ endforeach; $output .= '' . '
' . __( 'Team', 'sportspress' ) . '' . SP()->text->string('Team', 'event') . '' . $label . '' . __( 'Pos', 'sportspress' ) . '' . SP()->text->string('Pos', 'team') . '
'; if ( $show_full_table_link ) - $output .= '' . __( 'View full table', 'sportspress' ) . ''; + $output .= '' . SP()->text->string('View full table', 'team') . ''; $output .= ''; diff --git a/templates/player-gallery.php b/templates/player-gallery.php index fbddcf44..691206cf 100644 --- a/templates/player-gallery.php +++ b/templates/player-gallery.php @@ -12,7 +12,6 @@ $defaults = array( 'columns' => 3, 'size' => 'thumbnail', '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 ); @@ -89,14 +88,10 @@ if ( is_int( $number ) && $number > 0 ) foreach( $data as $player_id => $performance ): - if ( $show_names_on_hover ): - $caption = get_the_title( $player_id ); - $player_number = get_post_meta( $player_id, 'sp_number', true ); - if ( $player_number ): - $caption = '' . $player_number . ' ' . $caption; - endif; - else: - $caption = null; + $caption = get_the_title( $player_id ); + $player_number = get_post_meta( $player_id, 'sp_number', true ); + if ( $player_number ): + $caption = '' . $player_number . ' ' . $caption; endif; if ( isset( $limit ) && $i >= $limit ) @@ -128,6 +123,6 @@ $output .= " \n"; if ( $show_all_players_link ) - $output .= '' . __( 'View all players', 'sportspress' ) . ''; + $output .= '' . SP()->text->string('View all players', 'player') . ''; echo apply_filters( 'sportspress_player_gallery', $output ); diff --git a/templates/player-league-performance.php b/templates/player-league-performance.php index 628f39c9..48aaf33e 100644 --- a/templates/player-league-performance.php +++ b/templates/player-league-performance.php @@ -5,6 +5,8 @@ if ( ! isset( $league ) ) if ( ! isset( $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 ); // The first row should be column labels @@ -19,7 +21,7 @@ if ( empty( $data ) ) $output = '

' . $league->name . '

' . '
' . - '' . '' . ''; + '
' . '' . ''; foreach( $labels as $key => $label ): $output .= ''; diff --git a/templates/player-list.php b/templates/player-list.php index f6061e5e..bcc09504 100644 --- a/templates/player-list.php +++ b/templates/player-list.php @@ -8,9 +8,9 @@ $defaults = array( 'orderby' => 'default', 'order' => 'ASC', 'show_all_players_link' => false, - 'link_posts' => sportspress_array_value( $sportspress_options, 'player_list_link_posts', true ), - 'sortable' => sportspress_array_value( $sportspress_options, 'player_list_sortable', true ), - 'responsive' => sportspress_array_value( $sportspress_options, 'player_list_responsive', true ), + 'link_posts' => get_option( 'sportspress_list_link_players', 'yes' ) == 'yes' ? true : false, + 'sortable' => get_option( 'sportspress_enable_sortable_tables', 'yes' ) == 'yes' ? true : false, + 'responsive' => get_option( 'sportspress_enable_responsive_tables', 'yes' ) == 'yes' ? true : false, ); extract( $defaults, EXTR_SKIP ); @@ -43,7 +43,7 @@ endif; if ( in_array( $orderby, array( 'number', 'name' ) ) ): $output .= ''; else: - $output .= ''; + $output .= ''; endif; foreach( $labels as $key => $label ): @@ -97,6 +97,6 @@ endforeach; $output .= '' . '
' . $label . '#' . __( 'Rank', 'sportspress' ) . '' . SP()->text->string('Rank', 'player') . '
' . '
'; if ( $show_all_players_link ) - $output .= '' . __( 'View all players', 'sportspress' ) . ''; + $output .= '' . SP()->text->string('View all players', 'player') . ''; echo apply_filters( 'sportspress_player_list', $output ); diff --git a/templates/player-metrics.php b/templates/player-metrics.php index d67e3b28..6630db52 100644 --- a/templates/player-metrics.php +++ b/templates/player-metrics.php @@ -5,7 +5,7 @@ if ( ! isset( $id ) ) global $sportspress_options; $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 ); @@ -20,20 +20,20 @@ $metrics = sportspress_get_player_metrics_data( $id ); $common = array(); if ( $nationality ): $country_name = sportspress_array_value( $countries, $nationality, null ); - $common[ __( 'Nationality', 'sportspress' ) ] = $country_name ? ( $show_nationality_flag ? '' . $nationality . ' ' : '' ) . $country_name : '—'; + $common[ SP()->text->string('Nationality', 'player') ] = $country_name ? ( $show_nationality_flag ? '' . $nationality . ' ' : '' ) . $country_name : '—'; endif; $data = array_merge( $common, $metrics ); if ( $current_team ) - $data[ __( 'Current Team', 'sportspress' ) ] = '' . get_the_title( $current_team ) . ''; + $data[ SP()->text->string('Current Team', 'player') ] = '' . get_the_title( $current_team ) . ''; if ( $past_teams ): $teams = array(); foreach ( $past_teams as $team ): $teams[] = '' . get_the_title( $team ) . ''; endforeach; - $data[ __( 'Past Teams', 'sportspress' ) ] = implode( ', ', $teams ); + $data[ SP()->text->string('Past Teams', 'player') ] = implode( ', ', $teams ); endif; $output = '
' . diff --git a/templates/player-roster.php b/templates/player-roster.php index 4abe05c6..120e6a8a 100644 --- a/templates/player-roster.php +++ b/templates/player-roster.php @@ -82,7 +82,7 @@ foreach ( $positions as $position ): if ( in_array( $r['orderby'], array( 'number', 'name' ) ) ): $output .= '#'; else: - $output .= '' . __( 'Rank', 'sportspress' ) . ''; + $output .= '' . SP()->text->string('Rank', 'player') . ''; endif; foreach( $labels as $key => $label ): diff --git a/uninstall.php b/uninstall.php new file mode 100644 index 00000000..5a047400 --- /dev/null +++ b/uninstall.php @@ -0,0 +1,24 @@ +remove_roles(); + +// Delete options +$wpdb->query("DELETE FROM $wpdb->options WHERE option_name LIKE 'sportspress_%';");