update-ship-thumbnail.sh Script Documentation
This document describes the functionality and usage of the update-ship-thumbnail.sh script found in the cruiseappy/scripts folder.
Purpose
Updates the featured thumbnail image for a ship post in WordPress by fetching image data from an external API, processing it, and updating the database and media library.
Usage
./update-ship-thumbnail.sh <post_id>
Arguments
post_id: The WordPress post ID for the ship whose thumbnail image is to be updated.
Description
- Determines the script and WordPress installation paths.
- Sources the
functions.shscript for utility functions. - Retrieves the ship ID from the database for the given post ID.
- Creates a temporary table for ship images.
- Fetches ship image data from the API if not already cached as XML.
- Parses the XML to extract image data and updates the database.
- Identifies the featured image and imports it into WordPress using WP-CLI.
- Regenerates image sizes for the featured image.
- Updates the
_thumbnail_idmeta key for the post in the database. - Cleans up temporary tables.
- Logs operations to the appropriate log files.
Environment Variables
ca_db_name: WordPress database name.ca_db_table_prefix: WordPress table prefix.ca_tt_username: API username.ca_tt_password: API password.ca_tt_language: Language code for API/WPML.ca_tt_endpoint: API endpoint URL.wordpress_path: Path to the WordPress installation.
Dependencies
mysql: For database operations.curl: For fetching XML data from the API.xmlstarlet: For parsing XML files.wp: WP-CLI for media import and image regeneration.sed,echo,while,if,do,done: Standard shell utilities.
Notes
- Ensure all required environment variables are set before running the script.
- Requires pre-configured MySQL login path for authentication.
- 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.