定制 arraypress/wp-mdash 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

arraypress/wp-mdash

Composer 安装命令:

composer require arraypress/wp-mdash

包简介

Minimal WordPress polyfill for handling empty values with mdash

README 文档

README

Minimal WordPress polyfill for handling empty values with em dashes.

Installation

composer require arraypress/wp-mdash

Functions

mdash( $value ): string

Return an em dash if value is empty, otherwise return the value.

mdash( '' );         // '—'
mdash( null );       // '—'
mdash( false );      // '—'
mdash( 0 );          // '—'
mdash( 'Hello' );    // 'Hello'
mdash( 42 );         // '42'

mdash_esc( $value ): string

Return an em dash if value is empty, otherwise return the escaped value.

mdash_esc( '' );                    // '—'
mdash_esc( 'Hello' );               // 'Hello'
mdash_esc( '<script>alert()</script>' );  // '&lt;script&gt;alert()&lt;/script&gt;'

Usage

Admin Tables

<table class="wp-list-table">
    <tr>
        <td><?php echo mdash_esc( $user->display_name ); ?></td>
        <td><?php echo mdash_esc( $user->last_login ); ?></td>
        <td><?php echo mdash( $user->post_count ); ?></td>
    </tr>
</table>

Settings Pages

<tr>
    <th>API Key</th>
    <td><?php echo mdash_esc( get_option( 'api_key' ) ); ?></td>
</tr>
<tr>
    <th>Last Sync</th>
    <td><?php echo mdash( $last_sync_date ); ?></td>
</tr>

Reports

echo 'Total Sales: ' . mdash( $sales_count );
echo 'Average Rating: ' . mdash( $avg_rating );
echo 'Customer Notes: ' . mdash_esc( $customer_notes );

When to Use Each

Function Use When
mdash() Value is already safe (numbers, dates, pre-escaped)
mdash_esc() Value contains user input or untrusted data

Requirements

  • PHP 7.4+
  • WordPress 5.0+

License

GPL-2.0-or-later

统计信息

  • 总下载量: 7
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-2.0-or-later
  • 更新时间: 2025-01-13

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固