control-ships.sh

Controls the import and update of ships data from an external API into a WordPress site, including post creation and translation handling.

Usage

./control-ships.sh

Description

  • Sets the script path and sources the functions.sh file.
  • Removes the existing ships.xml file.
  • Calls the control-tables.sh script to prepare the database table.
  • Constructs and sends an XML request to get ships data from the external API.
  • Renames XML attributes for consistency.
  • Loads XML data into the MySQL database table.
  • Updates the database table with post IDs from WordPress.
  • Removes locked ships from updates.
  • Selects ships without post IDs and creates new WordPress posts for them.
  • If WPML is active, creates translations for new posts.
  • Calls the update-ship.sh script to update new posts.

Dependencies

  • functions.sh: Utility functions.
  • mysql: MySQL commands.
  • wp: WP-CLI for WordPress operations.
  • curl, xmlstarlet: Shell utilities.

Notes

  • Ensure all required environment variables and plugins are set before running.
  • Intended for use by developers or system administrators familiar with WordPress and server scripting.

For further details, refer to the comments in the script or contact the development team.