Skip to content

Commit

Permalink
Allowed template locations now a class-static variable
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterUpfold committed Oct 29, 2014
1 parent c8665e3 commit 38b5ff5
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 20 deletions.
2 changes: 1 addition & 1 deletion admin/slide-groups.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@
// determine which template location this template is from
$t = new Total_Slider_Template_Iterator();

foreach( $allowed_template_locations as $l )
foreach( Total_Slider::$allowed_template_locations as $l )
{

if ($tpl_location || $tpl_slug) {
Expand Down
2 changes: 1 addition & 1 deletion admin/slides.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
// determine which template location this template is from
$t = new Total_Slider_Template_Iterator();

foreach( $allowed_template_locations as $l ) {
foreach( Total_Slider::allowed_template_locations as $l ) {

if ( $tpl_location || $tpl_slug ) {
break;
Expand Down
10 changes: 1 addition & 9 deletions includes/class.total-slide-group.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,6 @@
die( '<h1>Forbidden</h1>' );
}

static $allowed_template_locations = array(
'builtin',
'theme',
'downloaded',
'legacy'
);

/* data structure
a serialized array stored as a wp_option
Expand Down Expand Up @@ -168,7 +161,6 @@ public function sanitize_slug( $slug ) {
*/
public function load() {

global $allowed_template_locations;

if ( ! get_option( 'total_slider_slide_groups' ) ) {
return false;
Expand Down Expand Up @@ -197,7 +189,7 @@ public function load() {

if (
property_exists( $current_groups[$the_index], 'templateLocation' ) &&
in_array( $current_groups[$the_index]->templateLocation, $allowed_template_locations )
in_array( $current_groups[$the_index]->templateLocation, Total_Slider::$allowed_template_locations )
) {
$this->templateLocation = $current_groups[$the_index]->templateLocation;
}
Expand Down
11 changes: 4 additions & 7 deletions includes/class.total-slider-template.php
Original file line number Diff line number Diff line change
Expand Up @@ -242,17 +242,15 @@ class Total_Slider_Template {
*/
public function __construct( $slug, $location ) {

global $allowed_template_locations;

if ( ! is_array($allowed_template_locations ) ) {
if ( ! is_array(Total_Slider::$allowed_template_locations ) ) {
throw new UnexpectedValueException( __( 'The allowed template locations are not available. This file must not be loaded without class.total-slide-group.php', 'total_slider' ), 103 );
return;
}

// get some key things ready
$this->slug = $this->sanitize_slug( $slug );

if ( in_array( $location, $allowed_template_locations ) ) {
if ( in_array( $location, Total_Slider::$allowed_template_locations ) ) {
$this->location = $location;
}
else {
Expand Down Expand Up @@ -1482,15 +1480,14 @@ class Total_Slider_Template_Iterator {
* @return array
*/
public function discover_templates($location, $should_parse_name = true) {
global $allowed_template_locations;

if ( ! is_array( $allowed_template_locations ) ) {
if ( ! is_array( Total_Slider::$allowed_template_locations ) ) {
throw new UnexpectedValueException( __( 'The allowed template locations are not available. This file must not be loaded without class.total-slide-group.php', 'total_slider' ), 103 );
return false;
}

// check the location given is valid
if ( ! in_array( $location, $allowed_template_locations ) ) {
if ( ! in_array( $location, Total_Slider::$allowed_template_locations ) ) {
throw new UnexpectedValueException( __( 'The supplied template location is not one of the allowed template locations', 'total_slider' ), 101 );
return false;
}
Expand Down
14 changes: 12 additions & 2 deletions total-slider.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,17 @@ class Total_Slider {
*/
public $tpl_error = false;


/**
* The list of allowed template locations -- 'builtin','theme','downloaded','legacy'
*
* @var array
*/
public static $allowed_template_locations = array(
'builtin',
'theme',
'downloaded',
'legacy'
);


/* data structure
Expand Down Expand Up @@ -813,7 +823,7 @@ public function register_tinymce_button ( $buttons ) {
*/
public function print_slide_groups_page() {

global $allowed_template_locations, $TS_Total_Slider;
global $TS_Total_Slider;

require( dirname( __FILE__ ) . '/admin/slide-groups.php' );

Expand Down

0 comments on commit 38b5ff5

Please sign in to comment.