arraypress / wp-mdash
A collection of WordPress functions for handling empty values consistently using mdash and other semantic formatting patterns
Installs: 1
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/arraypress/wp-mdash
Requires
- php: >=7.4
Suggests
- wordpress/wordpress: These functions are designed to work with WordPress
This package is auto-updated.
Last update: 2025-10-03 22:17:20 UTC
README
A minimal WordPress polyfill providing mdash functions for consistent empty value handling.
Description
This package provides two simple utility functions for WordPress development that handle empty values using the HTML em dash entity (—
). Since WordPress doesn't include built-in mdash functions, this fills that gap with a minimal, focused implementation.
Installation
Install via Composer:
composer require arraypress/wp-mdash
Usage
Basic Functions
Return em dash for empty values echo mdash( $value ); Returns '—' if empty, otherwise the value echo mdash( '' ); Returns '—' echo mdash( null ); Returns '—' echo mdash( false ); Returns '—' echo mdash( 0 ); Returns '—' echo mdash( 'Hello' ); Returns 'Hello' Direct output mdash_e( $value ); Echoes '—' if empty, otherwise echoes the value
Common Use Cases
In admin tables echo '<td>' . mdash( $user->last_login ) . '</td>'; In reports echo 'Total Sales: ' . mdash( $sales_count ); In user profiles echo 'Bio: ' . mdash( $user_bio ); Direct output in templates <div class="price"><?php mdash_e( $product->sale_price ); ?></div>
Why This Exists
WordPress has many display functions but lacks a simple way to handle empty values with em dashes—a common pattern in professional interfaces. This polyfill provides that missing functionality with just two functions, following WordPress coding standards and conventions.
Requirements
- PHP 7.4 or higher
- WordPress 5.0 or higher
License
GPL-2.0-or-later
Support
For support, please use the GitHub issue tracker