Created
October 26, 2022 07:50
-
-
Save abaicus/7495addaf1e9ae513360b01bfa927230 to your computer and use it in GitHub Desktop.
Get the theme mods for the starter content in PHP format
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import fs from 'fs'; | |
import fetch from 'node-fetch'; | |
const run = async () => { | |
const data = await fetch( | |
'https://demosites.io/web-agency-gb/wp-json/ti-demo-data/data' | |
); | |
const json = await data.json(); | |
fs.writeFile('theme_mods.json', JSON.stringify(json.theme_mods), function (err) { | |
if (err) throw err; | |
console.log('Saved!'); | |
}); | |
} | |
run(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "mods-demosite", | |
"version": "1.0.0", | |
"license": "MIT", | |
"type": "module", | |
"dependencies": { | |
"node-fetch": "^3.2.10" | |
}, | |
"scripts": { | |
"build": "node node.js && php run.php" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$json = file_get_contents('theme_mods.json'); | |
$data = json_decode($json, true); | |
file_put_contents('mods.php', var_export($data, true)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment