Install
This is the repository archive. It installs, but the folder name will carry the branch suffix and updates will not flow.
Install straight from GitHub with WP-CLI:
wp plugin install https://github.com/estoericull3nea/bvelaw-legal-updates/archive/refs/heads/main.zipBVE Law Legal Updates - WordPress Plugin
A simple, secure WordPress plugin for managing and displaying legal updates with category-based tabbed navigation.
Features
- Admin CRUD Interface: Complete Create, Read, Update, Delete functionality for legal updates
- Custom Database Table: Uses a dedicated table (not custom post types)
- Category System: 5 fixed categories for organizing updates
- Tabbed Frontend Display: AJAX-powered tabs for smooth category switching
- Security First: Nonces, capability checks, and proper sanitization throughout
- Responsive Design: Mobile-friendly layout
Fixed Categories
- Commercial & Taxation
- Litigation & Alternative Dispute Resolution
- Employment
- Intellectual Property
- Immigration and Citizenship
Installation
- Download the
bve-law-legal-updatesfolder - Upload to
/wp-content/plugins/directory - Activate the plugin through the 'Plugins' menu in WordPress
- The custom database table will be created automatically on activation
Database Schema
The plugin creates a custom table: {wp_prefix}legal_updates
CREATE TABLE wp_legal_updates (
id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
heading VARCHAR(255) NOT NULL,
content LONGTEXT NOT NULL,
category VARCHAR(100) NOT NULL,
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (id),
KEY category (category),
KEY created_at (created_at)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
Admin Usage
Accessing the Admin Panel
- Navigate to Legal Updates in the WordPress admin menu
- Only users with
manage_optionscapability (Administrators) can access
Adding a New Legal Update
- Click Legal Updates > Add New
- Select a Category from the dropdown
- Enter a Heading (title for the update)
- Add Content using the WYSIWYG editor
- Click Save Legal Update
Editing a Legal Update
- Go to Legal Updates list page
- Click Edit next to the update you want to modify
- Make your changes
- Click Update Legal Update
Deleting a Legal Update
- Go to Legal Updates list page
- Click Delete next to the update
- Confirm the deletion in the popup
Frontend Usage
Shortcode
Display legal updates on any page or post using the shortcode:
[bve_legal_updates]
Example Usage
- Create a new page: Legal Updates
- Add the shortcode:
[bve_legal_updates] - Publish the page
- The page will display tabs for each category
- Users can click tabs to view updates in each category
Frontend Features
- Default Tab: "Commercial & Taxation" loads by default
- AJAX Loading: Updates load without page refresh
- Responsive: Works on desktop, tablet, and mobile devices
- Clean Design: Professional styling that matches most themes
File Structure
bve-law-legal-updates/
├── bve-law-legal-updates.php # Main plugin file
├── assets/
│ ├── legal-updates.js # Frontend JavaScript
│ └── legal-updates.css # Frontend styles
└── README.md # Documentation
Security Features
Capability Checks
- All admin functions require
manage_optionscapability - Unauthorized users are blocked from accessing CRUD operations
Nonces
- Add/Edit forms use nonces:
bve_lu_save - Delete actions use unique nonces:
bve_lu_delete_{id} - AJAX requests use nonces:
bve_lu_ajax
Data Sanitization
- Heading:
sanitize_text_field() - Content:
wp_kses_post()(allows safe HTML) - Category: Validated against allowed list
Data Escaping
- Admin Output:
esc_html(),esc_attr() - Frontend Output:
esc_html(),esc_attr(),wp_kses_post()
SQL Security
- All database queries use
$wpdb->prepare()for safe parameter binding
Technical Details
Database Functions
Insert New Update:
$wpdb->insert(
$table_name,
array(
'heading' => $heading,
'content' => $content,
'category' => $category
),
array('%s', '%s', '%s')
);
Update Existing:
$wpdb->update(
$table_name,
$data,
array('id' => $id),
array('%s', '%s', '%s'),
array('%d')
);
Delete:
$wpdb->delete(
$table_name,
array('id' => $id),
array('%d')
);
AJAX Handler
The plugin includes an AJAX handler for loading updates by category:
Action Hook: bve_lu_get_updates
Registered for: Logged-in and non-logged-in users
Request Format:
{
action: 'bve_lu_get_updates',
category: 'commercial-taxation',
nonce: '...'
}
Response Format:
{
success: true,
data: '<div class="bve-lu-update-item">...</div>'
}
Asset Enqueuing
Frontend assets are conditionally loaded only when the shortcode is present:
if (has_shortcode($post->post_content, 'bve_legal_updates')) {
wp_enqueue_style('bve-legal-updates', ...);
wp_enqueue_script('bve-legal-updates', ...);
}
Customization
Modifying Styles
Edit /assets/legal-updates.css to customize:
- Tab colors and fonts
- Update item styling
- Responsive breakpoints
- Spacing and padding
Changing Categories
To modify categories, edit the bve_lu_get_categories() function in the main plugin file:
function bve_lu_get_categories() {
return array(
'category-slug' => 'Category Display Name',
// Add more categories
);
}
Note: Changing categories after data exists may require migration.
Browser Compatibility
- Chrome (latest)
- Firefox (latest)
- Safari (latest)
- Edge (latest)
- Mobile browsers (iOS Safari, Chrome Mobile)
Requirements
- WordPress 5.0 or higher
- PHP 7.0 or higher
- MySQL 5.6 or higher
Support
For issues or questions:
- Check the WordPress debug log
- Verify database table was created
- Ensure user has
manage_optionscapability - Clear browser cache after updates
Version History
1.0.0 (Initial Release)
- Complete CRUD functionality
- Custom database table
- Frontend tabbed display with AJAX
- Security hardening
- Responsive design
License
This plugin is provided as-is for BVE Law's internal use.
Credits
Developed for BVE Law