Skip to content

wp core config to handle updates as well #2501

@borekb

Description

@borekb

I'd like to see the core config command handle updates as well. For example, for updating WP_DEBUG, I'd run something like this:

wp core config WP_DEBUG true

(similarly to git config user.name Name).

A couple of quick notes:

  • I understand that wp-config.php can contain arbitrary PHP and implementing the proposed functionality can be a bit tricky. My approach would be to strictly specify how the core config command works, for example, only supporting simple constants and putting them right before require_once(ABSPATH . 'wp-settings.php'); or something like that. If the file structure doesn't conform to what core config expects, it would do nothing and only print an error message.
  • Was thinking whether there should be a separate (sub)command for this but I think that the core config could be used for this seamlessly.
  • Data types would need some attention. For example, the example given above (updating WP_DEBUG) would need to correctly put a boolean into wp-config.php while in other cases, strings or numbers could be required. I think that most cases could be handled automatically but there could also be switches like --bool or --int, similarly to what git config supports.

What do you think? I'd be willing to contribute the code but wanted to discuss it first.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions