Skip to content

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

Closed as not planned

Description

@vadimkantorov

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)

Activity

  1. mrsdizzie commented on Dec 20, 2024

    @mrsdizzie
    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.

  2. vadimkantorov commented on Dec 20, 2024

    @vadimkantorov
    Author

    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...

  3. mrsdizzie commented on Dec 20, 2024

    @mrsdizzie
    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.

  4. vadimkantorov commented on Dec 20, 2024

    @vadimkantorov
    Author

    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...

  5. swissspidy commented on Feb 18, 2025

    @swissspidy
    Member

    Closing in favor of wp-cli/entity-command#512 since import/export functionaltiy is out of scope for wp core install. That command is there solely for running the install process, nothing more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions