diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3650cae --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +wp-serverless-api.tgz +wp-serverless-api.zip diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..806bcf7 --- /dev/null +++ b/Makefile @@ -0,0 +1,7 @@ +.PHONY: archive clean + +archive: clean + zip -r wp-serverless-api.zip *.php *.md + +clean: + rm -f wp-serverless-api.zip diff --git a/README.md b/README.md index 3582705..0e1eabb 100644 --- a/README.md +++ b/README.md @@ -5,4 +5,10 @@ Explore WordPress data via the WP REST API as a JSON file for static WordPress H 1. Install as a WordPress Plugin 2. Activate and save or create a new post or page 3. Create a new static Artifact on Shifter -4. Visit your new WP Serverless API endpoint at `example.com/wp-content/uploads/wp-sls-api/db.json` +4. Visit your new WP Serverless API endpoint at `example.com/wp-content/wp-sls-api/db.json` + +## CHANGELOG + +### 0.2.0 + +- [BREAKING CHANGE] Change save path from `/wp-content/uploads/wp-sls-api/db.json` to `/wp-content/wp-sls-api/db.json` diff --git a/wp-serverless-api.php b/wp-serverless-api.php index 107d1a0..999754c 100644 --- a/wp-serverless-api.php +++ b/wp-serverless-api.php @@ -2,9 +2,11 @@ /* Plugin Name: WP Serverless API -Author: Daniel Olson -Author URI: https://github.com/emaildano/wp-serverless-api +Plugin URI: https://github.com/getshifter/wp-serverless-api Description: WordPress REST API to JSON File +Version: 0.2.0 +Author: Shifter +Author URI: https://getshifter.io */ function enable_permalinks_notice() { @@ -51,10 +53,9 @@ function save_db( $db, $file_name = 'db.json' ) { - $upload_dir = wp_get_upload_dir(); - $save_path = $upload_dir['basedir'] . '/wp-sls-api/' . $file_name; + $save_path = WP_CONTENT_DIR . '/wp-sls-api/' . $file_name; $dirname = dirname($save_path); - + if (!is_dir($dirname)) { mkdir($dirname, 0755, true); @@ -74,4 +75,4 @@ function build_db() /** * Build on Post Save */ -add_action( 'save_post', 'build_db' ); \ No newline at end of file +add_action( 'save_post', 'build_db' );