Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/Config/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function registerSettingsPage()
public function settingsPage()
{
$tab = ( isset($_GET['tab']) ) ? sanitize_text_field($_GET['tab']) : 'general';
include( Helpers::view('settings/settings') );
include( Helpers::view('settings') );
}

/**
Expand All @@ -77,4 +77,4 @@ public function registerSettings()
register_setting( 'simple-favorites-users', 'simplefavorites_users' );
register_setting( 'simple-favorites-display', 'simplefavorites_display' );
}
}
}
14 changes: 11 additions & 3 deletions app/Helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,17 @@ public static function plugin_url()
/**
* Views
*/
public static function view($file)
public static function view($file, $folder = 'settings')
{
return dirname(__FILE__) . '/Views/' . $file . '.php';
// Sanitaze file name.
$file = sanitize_file_name($file);
$file = preg_replace('/[^a-zA-Z0-9\-_]/', '', $file);

// Sanitaze folder name.
$folder = sanitize_file_name($folder);
$folder = preg_replace('/[^a-zA-Z0-9\-_]/', '', $folder);

return dirname(__FILE__) . '/Views/' . $folder . '/' . $file . '.php';
}

/**
Expand Down Expand Up @@ -117,4 +125,4 @@ public static function pluckGroupFavorites($group_id, $site_id = 1, $all_favorit
}
return array();
}
}
}
4 changes: 2 additions & 2 deletions app/Views/settings/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
</h2>

<form method="post" enctype="multipart/form-data" action="options.php">
<?php include(Favorites\Helpers::view('settings/settings-' . $tab)); ?>
<?php include(Favorites\Helpers::view('settings-' . $tab)); ?>
<?php submit_button(); ?>
</form>
</div><!-- .wrap -->
</div><!-- .wrap -->