Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions .claude/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"permissions": {
"allow": [
"Bash(npx grunt:*)",
"Bash(npm install)",
"Bash(composer install)",
"Bash(./vendor/bin/phpcs:*)",
"Bash(git status)",
"Bash(git diff:*)",
"Bash(git log:*)",
"Bash(git branch:*)",
"Bash(git checkout:*)",
"Bash(git add:*)",
"Bash(git commit:*)",
"Bash(git push:*)",
"Bash(git remote:*)",
"Bash(ls:*)",
"Bash(find:*)",
"Bash(cat:*)",
"Bash(wc:*)"
],
"deny": [
"Bash(rm -rf:*)",
"Bash(git push --force:*)",
"Bash(git reset --hard:*)"
]
}
}
4 changes: 4 additions & 0 deletions .distignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,7 @@ node_modules
package-lock.json
.wordpress-org
.github

.claude
CLAUDE.md
internal-docs
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,5 @@ vendor/
borders-for-default-menu.json
defaults.json
no-toggle-border-fix.json

.claude/settings.local.json
55 changes: 55 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Astra Widgets

## Project Overview

Astra Widgets is a WordPress plugin by Brainstorm Force. Add address, social profiles, and list icon widgets to WordPress.

- **Version:** 1.2.17
- **Text Domain:** astra-widgets
- **Main File:** astra-widgets.php
- **Requires:** WordPress, PHP 5.6+

## Tech Stack

- **Language:** PHP
- **Platform:** WordPress
- **Build:** Grunt (i18n, readme conversion)
- **Coding Standards:** PHPCS with WordPress standards

## Commands

```bash
# Install dependencies
npm install
composer install

# Build (i18n + readme)
npx grunt

# Generate translations
npx grunt i18n

# Convert readme.txt to README.md
npx grunt readme

# Run PHPCS
./vendor/bin/phpcs .
```

## Architecture

This is a WordPress plugin following standard WordPress patterns:
- Entry point: `astra-widgets.php`
- Constants defined for version, file path, base, dir, and URI
- Classes loaded via `after_setup_theme` or `plugins_loaded` hook
- Follows WordPress Coding Standards (WPCS)

## Conventions

- Use WordPress hooks (`add_action`, `add_filter`) for extensibility
- Prefix all functions and classes to avoid conflicts
- Use `astra-widgets` text domain for all translatable strings
- Escape all output (`esc_html`, `esc_attr`, `esc_url`, `wp_kses`)
- Sanitize all input (`sanitize_text_field`, `absint`, etc.)
- Use nonces for form submissions and AJAX requests
- Follow WordPress PHP coding standards
3 changes: 3 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,9 @@ module.exports = function( grunt ) {
'!composer.lock',
'!package-lock.json',
'!phpcs.xml.dist',
'!CLAUDE.md',
'!.claude/**',
'!internal-docs/**',
],
dest: 'astra-widgets/'
}
Expand Down
25 changes: 25 additions & 0 deletions internal-docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Astra Widgets — Internal Documentation

> Auto-generated documentation for developer onboarding and AI agent understanding.

## Quick Facts

| Key | Value |
|-----|-------|
| **Plugin Name** | Astra Widgets |
| **Version** | 1.2.17 |
| **Text Domain** | astra-widgets |
| **Main File** | `astra-widgets.php` |
| **PHP Files** | 12 |
| **Build Tool** | Grunt |
| **Stack** | WordPress Plugin (PHP) |

## Description

Add address, social profiles, and list icon widgets to WordPress.

## Index

- [Architecture](architecture.md) — High-level architecture and data flow
- [Codebase Map](codebase-map.md) — Directory structure and key files
- [AI Agent Guide](ai-agent-guide.md) — Key patterns and locations for AI-assisted development
40 changes: 40 additions & 0 deletions internal-docs/ai-agent-guide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# AI Agent Guide — Astra Widgets

## Quick Start for AI Agents

1. **Entry point:** Start at `astra-widgets.php` to understand plugin initialization
2. **Constants:** Look for `define()` calls in the main file for paths and versions
3. **Hook registration:** Search for `add_action` and `add_filter` to find where functionality is attached
4. **Text domain:** Use `astra-widgets` for all translatable strings

## Common Tasks

### Adding a new feature
1. Create a new class file in the appropriate directory
2. Register it via `require_once` in the loader or main class
3. Use `add_action`/`add_filter` to hook into WordPress
4. Follow existing class patterns for consistency

### Modifying existing behavior
1. Find the relevant class by searching for the hook or function name
2. Check for filters that allow modification without editing core files
3. If editing, maintain the existing code style and patterns

### Adding translatable strings
1. Wrap strings in `__( 'text', 'astra-widgets' )` or `esc_html__( 'text', 'astra-widgets' )`
2. Run `npx grunt i18n` to update the POT file

## WordPress Checklist

- [ ] All output is escaped (`esc_html`, `esc_attr`, `esc_url`, `wp_kses`)
- [ ] All input is sanitized (`sanitize_text_field`, `absint`, etc.)
- [ ] Nonces used for forms and AJAX (`wp_nonce_field`, `check_ajax_referer`)
- [ ] Capability checks before privileged operations (`current_user_can`)
- [ ] Text domain `astra-widgets` used for all user-facing strings
- [ ] No direct file access (files start with `defined( 'ABSPATH' )` check or silence)

## Pitfalls

- Plugin may depend on Astra theme being active — check for theme dependency logic
- Constants are defined only once — don't redefine them
- Follow WordPress coding standards (spaces not tabs for alignment, tabs for indentation)
32 changes: 32 additions & 0 deletions internal-docs/architecture.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Architecture — Astra Widgets

## Overview

Astra Widgets is a WordPress plugin that follows standard WordPress plugin architecture patterns.

## Entry Point

The plugin entry point is `astra-widgets.php`, which:
1. Defines plugin constants (version, file path, base name, directory, URI)
2. Loads the main plugin class via a WordPress hook (`after_setup_theme` or `plugins_loaded`)

## Request Lifecycle

1. WordPress loads the plugin via `astra-widgets.php`
2. Constants are defined for use throughout the plugin
3. Main class is instantiated/loaded on the appropriate hook
4. Classes register their own hooks and filters
5. Frontend/admin output is rendered when WordPress fires the relevant hooks

## Key Patterns

- **Hook-based architecture:** All functionality is attached via `add_action()` and `add_filter()`
- **Class autoloading:** Classes are loaded via `require_once` in the main plugin file or loader class
- **Separation of concerns:** Admin and frontend code are separated into different classes/directories
- **WordPress Customizer integration:** Settings are registered via the Customizer API where applicable

## Dependencies

- WordPress core (required)
- Astra theme (recommended/required for full functionality)
- No external PHP dependencies beyond WordPress
25 changes: 25 additions & 0 deletions internal-docs/codebase-map.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Codebase Map — Astra Widgets

## Directory Structure

```
astra-widgets/
├── astra-widgets.php # Plugin entry point
├── admin/bsf-analytics/class-bsf-analytics-loader.php
├── admin/bsf-analytics/class-bsf-analytics-stats.php
├── admin/bsf-analytics/class-bsf-analytics.php
├── astra-widgets.php
├── classes/class-astra-widgets-helper.php
├── classes/class-astra-widgets-loader.php
├── classes/class-astra-widgets.php
├── classes/widgets/class-astra-widget-address.php
├── classes/widgets/class-astra-widget-list-icons.php
├── classes/widgets/class-astra-widget-social-profiles.php
├── lib/astra-notices/class-astra-notices.php
├── .distignore # WordPress.org distribution exclusions
├── .gitignore # Git exclusions
├── Gruntfile.js # Grunt build configuration
├── package.json # Node.js dependencies
├── CLAUDE.md # Claude Code project context
└── .claude/settings.json # Claude Code tool permissions
```
Loading