Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow specifing a JSON file path with options for wp core install command #278

Open
vadimkantorov opened this issue Dec 20, 2024 · 4 comments

Comments

@vadimkantorov
Copy link

vadimkantorov commented Dec 20, 2024

Could be a convenience for specifying directly a JSON file with exported options to the wp core install command. Related to:

I suggest that this would initialize the wp_options table from the values in the JSON file. The JSON file format should be the same as used in wp option list --format=json command output. This would simplify usage of WordPress as a SSG engine (experimented with at https://github.com/vadimkantorov/wpssg)

@mrsdizzie
Copy link
Member

If you want a way to copy options from one site to another now:

wp db export --tables=wp_options --no-create-info=true --replace=true options.sql

wp db import options.sql

Which will give you a sql dump file that you can import to another site to replace any existing options with the previous ones.

@vadimkantorov
Copy link
Author

vadimkantorov commented Dec 20, 2024

In my SSG hack I am trying to keep the WP content in common human-editable files (like markdown for posts and JSON for options. I also wonder if the block editor in WP comes with its own markup language spec?).

SQL format for options files also would work, but for more convenience JSON would be preferrable (as it's also the most basic format implemented in de/serialization in all programming languages and easy for working both manually and with any automation).

So the feature could be specifying an options file (as JSON and/or SQL?) at the core install command invocation time for the wp_options table init from this specified file...

@mrsdizzie
Copy link
Member

Thats going to be outside the scope of wp cli I think (just to set expectations and that nobody is waiting on this to be implemented).

The current JSON output from wp cli commands is there for easier parsing of output and isn't intended as a way to save data and pass it back and forth from WordPress installs since WordPress core has no support for that. SQL should be used for this purpose unless you want to write your own importer to handle JSON.

@vadimkantorov
Copy link
Author

vadimkantorov commented Dec 20, 2024

wp option update --format=json has some support for importing JSON values but I failed to surmount the string escaping problems in

when I tried to make it work and feed in it the values from wp option list --format=json...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants