diff --git a/includes/boilerplate-classes/enqueue.php b/includes/boilerplate-classes/enqueue.php index 1044c52..1651250 100644 --- a/includes/boilerplate-classes/enqueue.php +++ b/includes/boilerplate-classes/enqueue.php @@ -90,11 +90,11 @@ function enqueue_js( $name ) { $data = str_replace( '-', '_', $name . '_data' ); $this->$data = apply_filters( 'localize_script', $this->$data, $name ); - - if ( empty( $this->$data ) ) + + if ( empty( $this->data ) ) return; - wp_localize_script( $this->parent->slug, $this->parent->slug_, $this->$data ); + wp_localize_script( $this->parent->slug, $this->parent->slug_, $this->data ); } diff --git a/templates/resume-json.php b/templates/resume-json.php index 6677137..4786013 100644 --- a/templates/resume-json.php +++ b/templates/resume-json.php @@ -85,8 +85,16 @@ $output = apply_filters( 'json_resume', $output ); +//check for callback and sanitize +//http://stackoverflow.com/a/10900911/1082542 +$callback = ( isset( $_GET['callback'] ) ) ? $_GET['callback'] : false; + +if ( preg_match( '/[^0-9a-zA-Z\$_]|^(abstract|boolean|break|byte|case|catch|char|class|const|continue|debugger|default|delete|do|double|else|enum|export|extends|false|final|finally|float|for|function|goto|if|implements|import|in|instanceof|int|interface|long|native|new|null|package|private|protected|public|return|short|static|super|switch|synchronized|this|throw|throws|transient|true|try|typeof|var|volatile|void|while|with|NaN|Infinity|undefined)$/', $callback) ) + $callback = false; + //push json output to browser -echo json_encode($output); +$json = json_encode($output); +echo ( $callback ) ? "{$callback}($json)" : $json; //reset WP query wp_reset_query();