diff --git a/includes/admin/settings/class-sp-settings-text.php b/includes/admin/settings/class-sp-settings-text.php
index 78a22016..ceb1d2b3 100644
--- a/includes/admin/settings/class-sp-settings-text.php
+++ b/includes/admin/settings/class-sp-settings-text.php
@@ -43,14 +43,16 @@ class SP_Settings_Text extends SP_Settings_Page {
);
$strings = sp_get_text_options();
+ $options = get_option( 'sportspress_text' );
- foreach ( $strings as $key => $value ):
+ foreach ( $strings as $string ):
$settings[] = array(
- 'title' => $value,
- 'id' => 'sportspress_' . $key . '_text',
- 'default' => '',
- 'placeholder' => $value,
- 'type' => 'text',
+ 'title' => $string,
+ 'id' => 'sportspress_text[' . $string . ']',
+ 'default' => '',
+ 'placeholder' => $string,
+ 'value' => sp_array_value( $options, $string, null ),
+ 'type' => 'text',
);
endforeach;
@@ -58,6 +60,14 @@ class SP_Settings_Text extends SP_Settings_Page {
return apply_filters( 'sportspress_text_settings', $settings ); // End event settings
}
+
+ /**
+ * Save settings
+ */
+ public function save() {
+ if ( isset( $_POST['sportspress_text'] ) )
+ update_option( 'sportspress_text', $_POST['sportspress_text'] );
+ }
}
endif;
diff --git a/includes/class-sp-league-table.php b/includes/class-sp-league-table.php
index 15cafcf4..ff0c7beb 100644
--- a/includes/class-sp-league-table.php
+++ b/includes/class-sp-league-table.php
@@ -316,7 +316,7 @@ class SP_League_Table extends SP_Custom_Post{
unset( $columns[ $key ] );
endif;
endforeach;
- $labels = array_merge( array( 'name' => SP()->text->string('Team') ), $columns );
+ $labels = array_merge( array( 'name' => __( 'Team', 'sportspress' ) ), $columns );
$merged[0] = $labels;
return $merged;
endif;
diff --git a/includes/class-sp-player-list.php b/includes/class-sp-player-list.php
index fe92d7ca..b69c94dd 100644
--- a/includes/class-sp-player-list.php
+++ b/includes/class-sp-player-list.php
@@ -358,7 +358,7 @@ class SP_Player_List extends SP_Custom_Post {
endif;
endforeach;
- $labels = array( 'name' => SP()->text->string('Player') );
+ $labels = array( 'name' => __( 'Player', 'sportspress' ) );
if ( in_array( 'team', $this->columns ) )
$labels['team'] = __( 'Team', 'sportspress' );
diff --git a/includes/class-sp-player.php b/includes/class-sp-player.php
index 74861d24..61e6e57b 100644
--- a/includes/class-sp-player.php
+++ b/includes/class-sp-player.php
@@ -316,7 +316,7 @@ class SP_Player extends SP_Custom_Post {
unset( $columns[ $key ] );
endif;
endforeach;
- $labels = array_merge( array( 'name' => SP()->text->string('Season'), 'team' => SP()->text->string('Team') ), $columns );
+ $labels = array_merge( array( 'name' => __( 'Season', 'sportspress' ), 'team' => __( 'Team', 'sportspress' ) ), $columns );
$merged[0] = $labels;
return $merged;
endif;
diff --git a/includes/class-sp-team.php b/includes/class-sp-team.php
index 2ebd96c4..7a665047 100644
--- a/includes/class-sp-team.php
+++ b/includes/class-sp-team.php
@@ -252,7 +252,7 @@ class SP_Team extends SP_Custom_Post {
if ( $admin ):
return array( $columns, $data, $placeholders, $merged, $leagues_seasons );
else:
- $labels = array_merge( array( 'name' => SP()->text->string('Season') ), $columns );
+ $labels = array_merge( array( 'name' => __( 'Season', 'sportspress' ) ), $columns );
$merged[0] = $labels;
return $merged;
endif;
diff --git a/includes/class-sp-text.php b/includes/class-sp-text.php
deleted file mode 100644
index a03039da..00000000
--- a/includes/class-sp-text.php
+++ /dev/null
@@ -1,49 +0,0 @@
-data = sp_get_text_options();
- }
-
- 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( $string ){
- if ( is_admin() )
- return $string;
-
- $key = str_replace( '-', '_', sanitize_title( $string ) );
-
- if ( array_key_exists( $key, $this->data ) ):
- $string = get_option( 'sportspress_' . $key . '_text' );
- return ( empty( $string ) ? $this->data[ $key ] : $string );
- else:
- return $string;
- endif;
- }
-}
diff --git a/includes/sp-core-functions.php b/includes/sp-core-functions.php
index 059f4871..b921f125 100644
--- a/includes/sp-core-functions.php
+++ b/includes/sp-core-functions.php
@@ -2387,35 +2387,35 @@ function sp_get_sport_presets() {
*/
function sp_get_text_options() {
$strings = apply_filters( 'sportspress_text', array(
- 'article' => __( 'Article', 'sportspress' ),
- 'current_team' => __( 'Current Team', 'sportspress' ),
- 'date' => __( 'Date', 'sportspress' ),
- 'details' => __( 'Details', 'sportspress' ),
- 'event' => __( 'Event', 'sportspress' ),
- 'league' => __( 'League', 'sportspress' ),
- 'nationality' => __( 'Nationality', 'sportspress' ),
- 'outcome' => __( 'Outcome', 'sportspress' ),
- 'past_teams' => __( 'Past Teams', 'sportspress' ),
- 'played' => __( 'Played', 'sportspress' ),
- 'player' => __( 'Player', 'sportspress' ),
- 'pos' => __( 'Pos', 'sportspress' ),
- 'position' => __( 'Position', 'sportspress' ),
- 'preview' => __( 'Preview', 'sportspress' ),
- 'rank' => __( 'Rank', 'sportspress' ),
- 'recap' => __( 'Recap', 'sportspress' ),
- 'team_results' => __( 'Team Results', 'sportspress' ),
- 'season' => __( 'Season', 'sportspress' ),
- 'staff' => __( 'Staff', 'sportspress' ),
- 'substitutes' => __( 'Substitutes', 'sportspress' ),
- 'team' => __( 'Team', 'sportspress' ),
- 'teams' => __( 'Teams', 'sportspress' ),
- 'time' => __( 'Time', 'sportspress' ),
- 'timeresults' => __( 'Time/Results', 'sportspress' ),
- 'total' => __( 'Total', 'sportspress' ),
- 'venue' => __( 'Venue', 'sportspress' ),
- 'view_all_events' => __( 'View all events', 'sportspress' ),
- 'view_all_players' => __( 'View all players', 'sportspress' ),
- 'view_full_table' => __( 'View full table', 'sportspress' ),
+ __( 'Article', 'sportspress' ),
+ __( 'Current Team', 'sportspress' ),
+ __( 'Date', 'sportspress' ),
+ __( 'Details', 'sportspress' ),
+ __( 'Event', 'sportspress' ),
+ __( 'League', 'sportspress' ),
+ __( 'Nationality', 'sportspress' ),
+ __( 'Outcome', 'sportspress' ),
+ __( 'Past Teams', 'sportspress' ),
+ __( 'Played', 'sportspress' ),
+ __( 'Player', 'sportspress' ),
+ __( 'Pos', 'sportspress' ),
+ __( 'Position', 'sportspress' ),
+ __( 'Preview', 'sportspress' ),
+ __( 'Rank', 'sportspress' ),
+ __( 'Recap', 'sportspress' ),
+ __( 'Team Results', 'sportspress' ),
+ __( 'Season', 'sportspress' ),
+ __( 'Staff', 'sportspress' ),
+ __( 'Substitutes', 'sportspress' ),
+ __( 'Team', 'sportspress' ),
+ __( 'Teams', 'sportspress' ),
+ __( 'Time', 'sportspress' ),
+ __( 'Time/Results', 'sportspress' ),
+ __( 'Total', 'sportspress' ),
+ __( 'Venue', 'sportspress' ),
+ __( 'View all events', 'sportspress' ),
+ __( 'View all players', 'sportspress' ),
+ __( 'View full table', 'sportspress' ),
));
asort( $strings );
return $strings;
diff --git a/includes/sp-template-hooks.php b/includes/sp-template-hooks.php
index de6ff053..a70e373e 100644
--- a/includes/sp-template-hooks.php
+++ b/includes/sp-template-hooks.php
@@ -190,7 +190,11 @@ function sportspress_gettext( $translated_text, $untranslated_text, $domain ) {
endswitch;
endif;
else:
- if ( ! current_theme_supports( 'sportspress' ) && $untranslated_text == 'Archives' && is_tax( 'sp_venue' ) ):
+ if ( $domain == 'sportspress' ):
+ if ( ! empty( SP()->text[ $untranslated_text ] ) ):
+ $translated_text = SP()->text[ $untranslated_text ];
+ endif;
+ elseif ( ! current_theme_supports( 'sportspress' ) && $untranslated_text == 'Archives' && is_tax( 'sp_venue' ) ):
$slug = get_query_var( 'sp_venue' );
if ( $slug ):
$venue = get_term_by( 'slug', $slug, 'sp_venue' );
diff --git a/sportspress.php b/sportspress.php
index 443703b5..49427c23 100644
--- a/sportspress.php
+++ b/sportspress.php
@@ -52,9 +52,9 @@ final class SportsPress {
public $formats = null;
/**
- * @var SP_Text $text
+ * @var array
*/
- public $text = null;
+ public $text = array();
/**
* Main SportsPress Instance
@@ -211,7 +211,6 @@ final class SportsPress {
// Classes (used on all pages)
include_once( 'includes/class-sp-countries.php' ); // Defines continents and countries
include_once( 'includes/class-sp-formats.php' ); // Defines custom post type formats
- include_once( 'includes/class-sp-text.php' ); // Defines editable strings
// Include template hooks in time for themes to remove/modify them
include_once( 'includes/sp-template-hooks.php' );
@@ -261,7 +260,9 @@ final class SportsPress {
// Load class instances
$this->countries = new SP_Countries(); // Countries class
$this->formats = new SP_Formats(); // Formats class
- $this->text = new SP_Text(); // Text class
+
+ // Load string options
+ $this->text = get_option( 'sportspress_text', array() );
// Init action
do_action( 'sportspress_init' );
diff --git a/templates/event-blocks.php b/templates/event-blocks.php
index e23cb968..4ab5c63a 100644
--- a/templates/event-blocks.php
+++ b/templates/event-blocks.php
@@ -102,5 +102,5 @@ if ( isset( $columns ) )
' . SP()->text->string('View all events') . '';
+ echo '' . __( 'View all events', 'sportspress' ) . '';
?>
\ No newline at end of file
diff --git a/templates/event-calendar.php b/templates/event-calendar.php
index 6331cda9..4952ee23 100644
--- a/templates/event-calendar.php
+++ b/templates/event-calendar.php
@@ -209,6 +209,6 @@ if ( $pad != 0 && $pad != 7 )
$calendar_output .= "\n\t\n\t\n\t\n\t";
if ( $id && $show_all_events_link )
- $calendar_output .= '' . SP()->text->string('View all events') . '';
+ $calendar_output .= '' . __( 'View all events', 'sportspress' ) . '';
echo apply_filters( 'sportspress_event_calendar', $calendar_output );
diff --git a/templates/event-details.php b/templates/event-details.php
index 7519deb9..3efe4783 100644
--- a/templates/event-details.php
+++ b/templates/event-details.php
@@ -17,19 +17,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( SP()->text->string('Date') => $date, SP()->text->string('Time') => $time );
+$data = array( __( 'Date', 'sportspress' ) => $date, __( 'Time', 'sportspress' ) => $time );
if ( $leagues ):
$league = array_pop( $leagues );
- $data[ SP()->text->string('League') ] = $league->name;
+ $data[ __( 'League', 'sportspress' ) ] = $league->name;
endif;
if ( $seasons ):
$season = array_pop( $seasons );
- $data[ SP()->text->string('Season') ] = $season->name;
+ $data[ __( 'Season', 'sportspress' ) ] = $season->name;
endif;
?>
-
text->string('Details'); ?>
+