Move globals to classes
This commit is contained in:
@@ -6,59 +6,6 @@ function sportspress_define_globals() {
|
|||||||
|
|
||||||
$sportspress_options = (array)get_option( 'sportspress', array() );
|
$sportspress_options = (array)get_option( 'sportspress', array() );
|
||||||
|
|
||||||
// Text
|
|
||||||
global $sportspress_text_options;
|
|
||||||
|
|
||||||
$sportspress_text_options = 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( $sportspress_text_options );
|
|
||||||
|
|
||||||
// Formats
|
|
||||||
global $sportspress_formats;
|
|
||||||
|
|
||||||
$sportspress_formats = array( 'event' => array(), 'list' => array() );
|
|
||||||
|
|
||||||
$sportspress_formats['event']['league'] = __( 'League', 'sportspress' );
|
|
||||||
$sportspress_formats['event']['friendly'] = __( 'Friendly', 'sportspress' );
|
|
||||||
|
|
||||||
$sportspress_formats['calendar']['calendar'] = __( 'Calendar', 'sportspress' );
|
|
||||||
$sportspress_formats['calendar']['list'] = __( 'List', 'sportspress' );
|
|
||||||
|
|
||||||
$sportspress_formats['list']['list'] = __( 'List', 'sportspress' );
|
|
||||||
$sportspress_formats['list']['gallery'] = __( 'Gallery', 'sportspress' );
|
|
||||||
|
|
||||||
// Sports
|
// Sports
|
||||||
global $sportspress_sports;
|
global $sportspress_sports;
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
class SportsPressTextSettingsPage {
|
class SportsPressTextSettingsPage {
|
||||||
|
private $strings = null;
|
||||||
|
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
global $sportspress_options, $sportspress_text_options;
|
global $sportspress_options;
|
||||||
$this->options =& $sportspress_options;
|
$this->options =& $sportspress_options;
|
||||||
$this->strings =& $sportspress_text_options;
|
|
||||||
add_action( 'admin_init', array( $this, 'page_init' ), 1 );
|
add_action( 'admin_init', array( $this, 'page_init' ), 1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -21,6 +22,7 @@ class SportsPressTextSettingsPage {
|
|||||||
'sportspress_text'
|
'sportspress_text'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$this->strings =& SP()->text->strings;
|
||||||
foreach ( $this->strings as $string ):
|
foreach ( $this->strings as $string ):
|
||||||
add_settings_field(
|
add_settings_field(
|
||||||
sanitize_title( $string ),
|
sanitize_title( $string ),
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ class SP_Countries {
|
|||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
|
|
||||||
$continents = array(
|
$continents = array(
|
||||||
__( 'Africa', 'sportspress' ) => array('AO','BF','BI','BJ','BW','CD','CF','CG','CI','CM','CV','DJ','DZ','EG','EH','ER','ET','GA','GH','GM','GN','GQ','GW','KE','KM','LR','LS','LY','MA','MG','ML','MR','MU','MZ','NA','NE','NG','RW','SC','SD','SL','SN','SO','ST','SZ','TD','TG','TN','TZ','UG','ZA','ZM','ZW'),
|
__( 'Africa', 'sportspress' ) => array('AO','BF','BI','BJ','BW','CD','CF','CG','CI','CM','CV','DJ','DZ','EG','EH','ER','ET','GA','GH','GM','GN','GQ','GW','KE','KM','LR','LS','LY','MA','MG','ML','MR','MU','MZ','NA','NE','NG','RW','SC','SD','SL','SN','SO','ST','SZ','TD','TG','TN','TZ','UG','ZA','ZM','ZW'),
|
||||||
__( 'Asia', 'sportspress' ) => array('AE','AF','AM','AZ','BD','BH','BN','BT','CN','CY','GE','HK','IL','IN','IQ','IR','JO','JP','KG','KH','KP','KR','KW','KZ','LA','LB','LK','MM','MN','MO','MV','MY','NP','OM','PH','PK','QA','SA','SG','TH','TJ','TM','TW','UZ','VN','YE'),
|
__( 'Asia', 'sportspress' ) => array('AE','AF','AM','AZ','BD','BH','BN','BT','CN','CY','GE','HK','IL','IN','IQ','IR','JO','JP','KG','KH','KP','KR','KW','KZ','LA','LB','LK','MM','MN','MO','MV','MY','NP','OM','PH','PK','QA','SA','SG','TH','TJ','TM','TW','UZ','VN','YE'),
|
||||||
|
|||||||
40
includes/class-sp-formats.php
Normal file
40
includes/class-sp-formats.php
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* SportsPress formats
|
||||||
|
*
|
||||||
|
* The SportsPress formats class stores preset sport data.
|
||||||
|
*
|
||||||
|
* @class SP_Formats
|
||||||
|
* @version 0.7
|
||||||
|
* @package SportsPress/Classes
|
||||||
|
* @category Class
|
||||||
|
* @author ThemeBoy
|
||||||
|
*/
|
||||||
|
class SP_Formats {
|
||||||
|
|
||||||
|
/** @var array Array of formats */
|
||||||
|
public $formats;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor for the formats class - defines all preset formats.
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct() {
|
||||||
|
$this->formats = apply_filters( 'sportspress_formats', array(
|
||||||
|
'event' => array(
|
||||||
|
'league' => __( 'League', 'sportspress' ),
|
||||||
|
'friendly' => __( 'Friendly', 'sportspress' ),
|
||||||
|
),
|
||||||
|
'calendar' => array(
|
||||||
|
'calendar' => __( 'Calendar', 'sportspress' ),
|
||||||
|
'list' => __( 'List', 'sportspress' ),
|
||||||
|
),
|
||||||
|
'list' => array(
|
||||||
|
'list' => __( 'List', 'sportspress' ),
|
||||||
|
'gallery' => __( 'Gallery', 'sportspress' ),
|
||||||
|
),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
28
includes/class-sp-sports.php
Normal file
28
includes/class-sp-sports.php
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* SportsPress sports
|
||||||
|
*
|
||||||
|
* The SportsPress sports class stores preset sport data.
|
||||||
|
*
|
||||||
|
* @class SP_Sports
|
||||||
|
* @version 0.7
|
||||||
|
* @package SportsPress/Classes
|
||||||
|
* @category Class
|
||||||
|
* @author ThemeBoy
|
||||||
|
*/
|
||||||
|
class SP_Sports {
|
||||||
|
|
||||||
|
/** @var array Array of sports */
|
||||||
|
public $sports;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor for the sports class - defines all preset sports.
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct() {
|
||||||
|
$this->sports = apply_filters( 'sportspress_sports', array(
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
61
includes/class-sp-text.php
Normal file
61
includes/class-sp-text.php
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* SportsPress text
|
||||||
|
*
|
||||||
|
* The SportsPress text class stores editable strings.
|
||||||
|
*
|
||||||
|
* @class SP_Text
|
||||||
|
* @version 0.7
|
||||||
|
* @package SportsPress/Classes
|
||||||
|
* @category Class
|
||||||
|
* @author ThemeBoy
|
||||||
|
*/
|
||||||
|
class SP_Text {
|
||||||
|
|
||||||
|
/** @var array Array of text */
|
||||||
|
public $text;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor for the text class - defines all editable strings.
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @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 );
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -46,6 +46,11 @@ final class SportsPress {
|
|||||||
*/
|
*/
|
||||||
public $countries = null;
|
public $countries = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var SP_Text $text
|
||||||
|
*/
|
||||||
|
public $text = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Main SportsPress Instance
|
* Main SportsPress Instance
|
||||||
*
|
*
|
||||||
@@ -238,6 +243,7 @@ final class SportsPress {
|
|||||||
|
|
||||||
// Classes (used on all pages)
|
// Classes (used on all pages)
|
||||||
include_once( 'includes/class-sp-countries.php' ); // Defines continents and countries
|
include_once( 'includes/class-sp-countries.php' ); // Defines continents and countries
|
||||||
|
include_once( 'includes/class-sp-text.php' ); // Defines editable strings
|
||||||
|
|
||||||
// Terms
|
// Terms
|
||||||
include_once( 'admin/terms/venue.php' );
|
include_once( 'admin/terms/venue.php' );
|
||||||
@@ -318,6 +324,9 @@ final class SportsPress {
|
|||||||
// Load class instances
|
// Load class instances
|
||||||
$this->countries = new SP_Countries(); // Countries class
|
$this->countries = new SP_Countries(); // Countries class
|
||||||
|
|
||||||
|
// Load class instances
|
||||||
|
$this->text = new SP_Text(); // Text class
|
||||||
|
|
||||||
// Init action
|
// Init action
|
||||||
do_action( 'sportspress_init' );
|
do_action( 'sportspress_init' );
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user