- Jul 25, 2018
- 12,059
- 22,063
- 120
please wait.
Code:
public function import() {
if ( ! isset( $_POST['ID'] ) || ! wp_verify_nonce( $_POST['verify'], 'aux-import-demo-' . $_POST['ID'] ) ) {
// This nonce is not valid.
wp_send_json_error( array( 'message' => __( 'Invalid Inputs.', 'auxin-elements' ) ) );
}
// Put demo ID in a variable
$demo_ID = $_POST['ID'];
$demo_path = ABSPATH . '/wp-content/plugins/auxin-elements/demos/' . $demo_ID . '.json';
if ( file_exists( $demo_path ) ) {
$data = file_get_contents( $demo_path );
file_put_contents( ABSPATH . '/wp-content/uploads/phlox-pro/demo.json', $data );
} else {
$data = json_decode( $this->parse( 'https://demo.phlox.pro/api/v2/data/' . $demo_ID, 'insert', 'post' ), true );
}
already so.