Skip to content

Instantly share code, notes, and snippets.

@abaicus
Created October 26, 2022 07:50
Show Gist options
  • Save abaicus/7495addaf1e9ae513360b01bfa927230 to your computer and use it in GitHub Desktop.
Save abaicus/7495addaf1e9ae513360b01bfa927230 to your computer and use it in GitHub Desktop.
Get the theme mods for the starter content in PHP format
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();
{
"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"
}
}
<?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