arraypress/wp-mdash
Composer 安装命令:
composer require arraypress/wp-mdash
包简介
A collection of WordPress functions for handling empty values consistently using mdash and other semantic formatting patterns
关键字:
README 文档
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
统计信息
- 总下载量: 3
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: GPL-2.0-or-later
- 更新时间: 2025-01-13