# Launchmind Blog Connector for WordPress

Display Launchmind SEO-optimized blog content on your WordPress website.

## Requirements

- WordPress 5.8 or higher
- PHP 7.4 or higher

## Installation

1. Download `wordpress-launchmind-blog.zip`
2. Go to WordPress Admin → Plugins → Add New
3. Click "Upload Plugin" and select the ZIP file
4. Click "Install Now" and then "Activate"

## Configuration

1. Go to Settings → Launchmind Blog
2. Enter your API credentials:
   - **API Base URL**: `https://launchmind.io/api` (default)
   - **API Key**: Your Launchmind API key
   - **Site ID**: Your Launchmind Site ID
3. Optionally adjust cache settings (default: 10 minutes)
4. Click "Test Connection" to verify your setup
5. Save Settings

## Usage

### Display Blog List

Add this shortcode to any page or post:

```
[launchmind_blog]
```

**Options:**

| Attribute | Default | Description |
|-----------|---------|-------------|
| `limit` | 10 | Number of posts to display |
| `columns` | 2 | Number of columns (1-4) |
| `lang` | auto | Language code (en, nl, de, fr, es, it, hi) |
| `show_excerpt` | true | Show post excerpts |
| `show_image` | true | Show cover images |
| `show_date` | true | Show publish date |
| `show_author` | true | Show author name |
| `show_tags` | false | Show tags |
| `class` | - | Additional CSS classes |
| `base_url` | - | Base URL for post links |

**Example:**

```
[launchmind_blog limit="6" columns="3" show_tags="true"]
```

### Display Single Post

Add this shortcode to display a specific post:

```
[launchmind_post slug="your-post-slug"]
```

**Options:**

| Attribute | Default | Description |
|-----------|---------|-------------|
| `slug` | required | Post slug from Launchmind |
| `lang` | auto | Language code |
| `show_title` | true | Show post title |
| `show_image` | true | Show cover image |
| `show_date` | true | Show publish date |
| `show_author` | true | Show author name |
| `show_tags` | true | Show tags |
| `class` | - | Additional CSS classes |

**Example:**

```
[launchmind_post slug="10-seo-tips-for-beginners" show_author="false"]
```

## Creating Blog Pages

### Option 1: Simple Setup

1. Create a new page called "Blog"
2. Add the shortcode `[launchmind_blog]`
3. Publish the page

### Option 2: Dynamic Single Posts

For dynamic single post pages, you'll need to create a custom template or use a page builder that can pass URL parameters to shortcodes.

**Using URL Rewriting (Advanced):**

Add to your theme's `functions.php`:

```php
add_action('init', function() {
    add_rewrite_rule(
        'blog/([^/]+)/?$',
        'index.php?pagename=blog-post&launchmind_slug=$matches[1]',
        'top'
    );
});

add_filter('query_vars', function($vars) {
    $vars[] = 'launchmind_slug';
    return $vars;
});
```

Then create a page template that uses:

```php
<?php
$slug = get_query_var('launchmind_slug');
if ($slug) {
    echo do_shortcode('[launchmind_post slug="' . esc_attr($slug) . '"]');
}
?>
```

## Styling

All elements use `.launchmind-` prefixed CSS classes for easy customization:

```css
/* Customize post cards */
.launchmind-post-card {
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* Customize read more link */
.launchmind-read-more {
    color: #your-brand-color;
}

/* Customize single post */
.launchmind-post-single .launchmind-post-title {
    font-family: 'Your Font', serif;
}
```

## Cache Management

The plugin caches API responses to improve performance:

- Default cache duration: 10 minutes
- Configurable from 60 seconds to 24 hours
- Clear cache manually from Settings → Launchmind Blog

## Security

- All API calls are server-side only
- API keys are never exposed to the browser
- All output is properly sanitized and escaped
- Uses WordPress nonces for AJAX requests

## Troubleshooting

### "API key not configured"
- Go to Settings → Launchmind Blog and enter your API key

### "Connection failed"
- Verify your API key is correct
- Check that your Site ID matches your Launchmind account
- Ensure your server can make outbound HTTPS requests

### Posts not updating
- Click "Clear Cache" in the settings page
- Reduce cache TTL for more frequent updates

### Styling conflicts
- The plugin uses minimal styles with `.launchmind-` prefix
- Add custom CSS to override default styles
- Use the `class` attribute to add wrapper classes

## Support

- Documentation: https://launchmind.io/docs/wordpress
- Email: support@launchmind.io

## Changelog

### 1.0.0
- Initial release
- Blog list shortcode
- Single post shortcode
- Admin settings page
- Transient-based caching
- Connection testing
- Cache management

