Complete refactoring and add style settings
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user