WE Custom Fields Block WP Registry grade B. Medium-severity findings · 1 findingWP RegistryMedium-severity findings · 1 findingOpen the reportB
Experimentel
Install
Upload it under Plugins → Add New Plugin → Upload Plugin, then activate.
Install straight from GitHub with WP-CLI:
wp plugin install https://github.com/gbyat/we-custom-fields-block/releases/download/v0.2.4/we-custom-fields-block.zipCustom Fields Block
A WordPress plugin that allows you to insert native WordPress custom fields as blocks with extensive typography and color options.
Features
- Dropdown Selection: Choose from all available custom fields of the current post
- Flexible Display: Display as heading or paragraph
- Typography Options: Font size, weight, line height, and letter spacing
- Color Options: Configurable text and background colors
- Spacing: Margin and padding for top and bottom
- Alignment: Left, centered, right, and wide alignment
- Responsive Design: Optimized for all screen sizes
Requirements
- WordPress 5.8 or higher
- PHP 7.4 or higher
- Node.js 14 or higher (for development)
- npm or yarn (for development)
Installation
Quick Start
- Download the plugin
- Extract it to the
/wp-content/plugins/we-custom-fields-block/folder - Activate the plugin in WordPress Admin → Plugins
Compile Assets (Development)
# Navigate to the plugin directory
cd wp-content/plugins/we-custom-fields-block
# Install dependencies
npm install
# Compile assets
npm run build
Development
Start Development Server
npm run start
This starts a development server that automatically compiles changes.
Format Code
npm run format
Linting
# JavaScript Linting
npm run lint:js
# CSS Linting
npm run lint:css
# JavaScript Linting with automatic fixes
npm run lint:js:fix
Update Dependencies
npm run packages-update
Usage
In the Block Editor
- Add a new block
- Search for "Custom Field" or "Custom Fields Block"
- Select the desired custom field from the dropdown
- Configure the display options:
- Display Type: Paragraph or heading
- Typography: Font size, weight, line height, letter spacing
- Colors: Text and background color
- Spacing: Margin and padding
- Alignment: Left, centered, right, wide
Creating Custom Fields
The plugin works with all native WordPress custom fields. You can create them via:
Manually via WordPress Admin
- Edit a post
- Scroll down to "Custom Fields"
- Add new fields
Programmatically
// Add custom field to a post
add_post_meta($post_id, 'my_field', 'My Value');
// Multiple values for a field
add_post_meta($post_id, 'my_field', 'Value 1');
add_post_meta($post_id, 'my_field', 'Value 2');
Technical Details
Supported Custom Fields
The plugin automatically detects all custom fields that:
- Do not start with an underscore (internal WordPress fields are ignored)
- Are assigned to the current post
Block Attributes
{
"fieldKey": "string",
"displayType": "paragraph|heading",
"typography": {
"fontSize": "number",
"fontWeight": "string",
"lineHeight": "number",
"letterSpacing": "number"
},
"colors": {
"textColor": "string",
"backgroundColor": "string"
},
"spacing": {
"marginTop": "number",
"marginBottom": "number",
"paddingTop": "number",
"paddingBottom": "number"
},
"alignment": "left|center|right|wide"
}
CSS Classes
The plugin automatically adds CSS classes:
.cfb-block- Main container.has-text-align-{alignment}- Alignment.has-text-color- Text color set.has-background- Background color set
Customization
Custom CSS
You can customize the styling via your theme:
/* Example: Custom styling for all custom field blocks */
.cfb-block {
font-family: "Your Custom Font", sans-serif;
}
/* Example: Specific styling for headings */
.cfb-block h1,
.cfb-block h2,
.cfb-block h3 {
border-bottom: 2px solid #007cba;
padding-bottom: 0.5rem;
}
Hooks and Filters
The plugin provides various hooks for developers:
// Filter custom fields
add_filter('cfb_custom_fields', function($fields, $post_id) {
// Your logic here
return $fields;
}, 10, 2);
// Customize block output
add_filter('cfb_block_output', function($output, $attributes, $field_value) {
// Your logic here
return $output;
}, 10, 3);
Browser Support
- Chrome 60+
- Firefox 55+
- Safari 12+
- Edge 79+
WordPress Version
- WordPress 5.8 or higher
- PHP 7.4 or higher
License
GPL v2 or later
Troubleshooting
Plugin Not Displaying
- Check if the plugin is activated
- Make sure assets are compiled (
npm run build) - Check the browser console for JavaScript errors
Custom Fields Not Displaying
- Make sure custom fields exist
- Check that fields do not start with an underscore
- Make sure you are on the correct post
Styling Issues
- Check if CSS files are loaded
- Make sure your theme supports block styles
- Add custom CSS via your theme
Performance Issues
- Make sure assets are minified
- Check the number of custom fields
- Use caching plugins
Updates
Updating the Plugin
- Download the latest version
- Replace the old files
- Run
npm installandnpm run build - Test functionality
Security
- The plugin uses WordPress nonces for security
- All outputs are properly escaped
- Custom fields are validated
- No direct database queries without sanitization
Performance Tips
- Use caching for custom fields
- Minimize the number of block instances
- Use lazy loading for large datasets
- Optimize CSS files
Support
For questions or issues:
- Check WordPress debug logs
- Test the plugin in a clean WordPress installation
- Create an issue in the GitHub Repository
Changelog
The complete changelog can be found in the CHANGELOG.md file.
Releases
9 releases. Each count is every asset in that release; expand a row for the breakdown.