Permalink
Browse files

* Updated page slug sanitisation method

* Updated save/reset logic, added Something went wrong message
  • Loading branch information...
1 parent 894c2cd commit 40a2206e88e67096c7c1fedc54f34b07f1ae33b1 @gndev committed Apr 12, 2015
Showing with 11 additions and 6 deletions.
  1. +11 −6 sunrise.php
View
@@ -147,7 +147,7 @@ public function render() {
// Prepare page options
$options = $this->get_page_options();
// Get current page slug
- $page = sanitize_title_with_dashes( $_GET['page'], 'save' );
+ $page = sanitize_key( $_GET['page'] );
// Hook before page output
do_action( 'sunrise/page/before' );
do_action( 'sunrise/page/' . $page . '/before' );
@@ -234,17 +234,15 @@ public function submit() {
if ( !$this->is_sunrise() ) return;
// Prepare page slug
$page = sanitize_key( $_GET['page'] );
- // Prepare message var (Something went wrong)
- $message = 3;
// Submit hooks
do_action( 'sunrise/submit', $this );
do_action( 'sunrise/submit/' . $page, $this );
// Parse incoming data
$action = sanitize_key( $_REQUEST['sunrise_action'] );
$request = ( isset( $_REQUEST['sunrise'] ) ) ? (array) $_REQUEST['sunrise'] : array();
// Run actions
- switch ( $action ) {
- case 'save': // Save options
+ // Save options
+ if ( $action === 'save' ) {
// Loop through current page options
foreach ( (array) $this->get_page_options() as $option ) {
// Option must have an ID
@@ -259,7 +257,9 @@ public function submit() {
do_action( 'sunrise/save/' . $page, $this );
// Set message
$message = 1;
- case 'reset': // Reset options
+ }
+ // Reset options
+ elseif ( $action === 'reset' ) {
// Loop through current page options
foreach ( (array) $this->get_page_options() as $option ) {
// Option must have an ID
@@ -282,6 +282,11 @@ public function submit() {
// Set message
$message = 2;
}
+ // Other actions
+ else {
+ // Set message var to "Something went wrong..."
+ $message = 3;
+ }
// Go to page with specified message
wp_redirect( $this->get_page_url() . '&message=' . $message );
exit;

0 comments on commit 40a2206

Please sign in to comment.