<p align="center">
  <a href="https://roots.io/bedrock/">
    <img alt="Bedrock" src="https://cdn.roots.io/app/uploads/logo-bedrock.svg" height="100">
  </a>
</p>

<p align="center">
  <a href="https://packagist.org/packages/roots/bedrock"><img alt="Packagist Installs" src="https://img.shields.io/packagist/dt/roots/bedrock?label=projects%20created&colorB=2b3072&colorA=525ddc&style=flat-square"></a>
  <a href="https://packagist.org/packages/roots/wordpress"><img alt="roots/wordpress Packagist Downloads" src="https://img.shields.io/packagist/dt/roots/wordpress?label=roots%2Fwordpress%20downloads&logo=roots&logoColor=white&colorB=2b3072&colorA=525ddc&style=flat-square"></a>
  <img src="https://img.shields.io/badge/dynamic/json.svg?url=https://raw.githubusercontent.com/roots/bedrock/master/composer.json&label=wordpress&logo=roots&logoColor=white&query=$.require[%22roots/wordpress%22]&colorB=2b3072&colorA=525ddc&style=flat-square">
  <a href="https://github.com/roots/bedrock/actions/workflows/ci.yml"><img alt="Build Status" src="https://img.shields.io/github/actions/workflow/status/roots/bedrock/ci.yml?branch=master&logo=github&label=CI&style=flat-square"></a>
  <a href="https://twitter.com/rootswp"><img alt="Follow Roots" src="https://img.shields.io/badge/follow%20@rootswp-1da1f2?logo=twitter&logoColor=ffffff&message=&style=flat-square"></a>
  <a href="https://github.com/sponsors/roots"><img src="https://img.shields.io/badge/sponsor%20roots-525ddc?logo=github&style=flat-square&logoColor=ffffff&message=" alt="Sponsor Roots"></a>
</p>

<p align="center">WordPress boilerplate with Composer, easier configuration, and an improved folder structure</p>

<p align="center">
  <a href="https://roots.io/bedrock/">Website</a> &nbsp;&nbsp; <a href="https://roots.io/bedrock/docs/installation/">Documentation</a> &nbsp;&nbsp; <a href="https://github.com/roots/bedrock/releases">Releases</a> &nbsp;&nbsp; <a href="https://discourse.roots.io/">Community</a>
</p>

## Support us

We're dedicated to pushing modern WordPress development forward through our open source projects, and we need your support to keep building. You can support our work by purchasing [Radicle](https://roots.io/radicle/), our recommended WordPress stack, or by [sponsoring us on GitHub](https://github.com/sponsors/roots). Every contribution directly helps us create better tools for the WordPress ecosystem.

### Sponsors

<a href="https://carrot.com/"><img src="https://cdn.roots.io/app/uploads/carrot.svg" alt="Carrot" width="120" height="90"></a> <a href="https://wordpress.com/"><img src="https://cdn.roots.io/app/uploads/wordpress.svg" alt="WordPress.com" width="120" height="90"></a> <a href="https://www.itineris.co.uk/"><img src="https://cdn.roots.io/app/uploads/itineris.svg" alt="Itineris" width="120" height="90"></a> <a href="https://kinsta.com/?kaid=OFDHAJIXUDIV"><img src="https://cdn.roots.io/app/uploads/kinsta.svg" alt="Kinsta" width="120" height="90"></a>

## Overview

Bedrock is a WordPress boilerplate for developers that want to manage their projects with Git and Composer. Much of the philosophy behind Bedrock is inspired by the [Twelve-Factor App](http://12factor.net/) methodology, including the [WordPress specific version](https://roots.io/twelve-factor-wordpress/).

- Better folder structure
- Dependency management with [Composer](https://getcomposer.org)
- Easy WordPress configuration with environment specific files
- Environment variables with [Dotenv](https://github.com/vlucas/phpdotenv)
- Autoloader for mu-plugins (use regular plugins as mu-plugins)

## Getting Started

See the [Bedrock installation documentation](https://roots.io/bedrock/docs/installation/).

## Mulholand Projects

### Timeline Player Plugin

The `timeline-player` plugin integrates with the media-processor API to display live camera footage timelines and generate timelapse videos.

#### Setup

1. **Configure API Credentials in `.env`**:
   ```bash
   MEDIA_API_URL=https://xxxxx.execute-api.eu-west-1.amazonaws.com/prod
   MEDIA_API_KEY=your-api-key-here
   ```

   To retrieve these values after deploying the media-processor stack:
   ```bash
   # Get API endpoint
   aws cloudformation describe-stacks \
     --stack-name mulholand-media-processor \
     --query 'Stacks[0].Outputs[?OutputKey==`ApiEndpoint`].OutputValue' \
     --output text

   # Get API key ID
   API_KEY_ID=$(aws cloudformation describe-stacks \
     --stack-name mulholand-media-processor \
     --query 'Stacks[0].Outputs[?OutputKey==`ApiKeyId`].OutputValue' \
     --output text)

   # Get actual API key value
   aws apigateway get-api-key --api-key "$API_KEY_ID" --include-value --query 'value' --output text
   ```

2. **How It Works**:
   - The plugin reads camera data from the media-processor API's `/cameras` endpoint (requires API key)
   - Fetches timestamped images from the `/images` endpoint with presigned S3 URLs
   - All API calls happen server-side in PHP using `wp_remote_get()`
   - The API key is never exposed to the browser or included in the React bundle
   - Data is cached server-side using WordPress transients (6 hours for images, 15 minutes for camera list)

3. **Available Endpoints**:
   - **GET `/cameras`** - Lists all cameras with image counts and date ranges
   - **GET `/images`** - Queries images by camera and date range (supports pagination)
   - **POST `/videos`** - Generates timelapse videos (synchronous, up to 15 minutes)
   - **GET `/videos/{key}/download`** - Generates presigned download URLs for videos

4. **Rate Limiting**:
   - 1000 requests per day quota
   - 10 requests per second burst limit
   - Configured via API Gateway usage plan

5. **Editing Construction Sites**:
   - Go to WordPress admin → Construction Sites
   - Edit a post and add cameras via the "Cameras" meta box
   - Cameras are sourced from the live `/cameras` API call
   - If the API is unreachable at edit time, the meta box falls back to manual text entry
   - Camera codes must exactly match what's returned by `/cameras`

#### For Developers

See [`web/app/plugins/timeline-player/README.md`](web/app/plugins/timeline-player/README.md) for detailed plugin documentation, including:
- Current status and known limitations
- Architecture and component overview
- Development setup with Vite
- Local testing procedures

#### Troubleshooting

- **"No images found" in frontend**: Verify camera code in the post's meta box exactly matches a code from `/cameras` endpoint
- **API authentication fails**: Check `.env` file has valid `MEDIA_API_URL` and `MEDIA_API_KEY`
- **Slow page loads**: Cache is working correctly; first load hits API, subsequent loads within 6 hours use cached data
- **Images not updating**: WordPress transient cache persists for 6 hours; clear with `wp transient delete --all` for immediate refresh

## Stay Connected

- Join us on Discord by [sponsoring us on GitHub](https://github.com/sponsors/roots)
- Participate on [Roots Discourse](https://discourse.roots.io/)
- Follow [@rootswp on Twitter](https://twitter.com/rootswp)
- Read the [Roots Blog](https://roots.io/blog/)
- Subscribe to the [Roots Newsletter](https://roots.io/newsletter/)
