barbashin-andrey/shortcode 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

barbashin-andrey/shortcode

最新稳定版本:v1.0.0

Composer 安装命令:

composer require barbashin-andrey/shortcode

包简介

PHP shortcodes handler

README 文档

README

Based on Wordpress sources for my personal purposes

Example

require_once __DIR__.'/vendor/autoload.php';

function sampleFunc($params) {
    $atts = $params["atts"];
    $args = $params["args"];

    $name = $atts["name"];
    $age = $args["age"];
    
    return "<p>Name: $name</p><p>Age: $age</p>";
}

$content = '
    <p>Some other elements</p>
    [sample name="Alex"]
    <p>Some other elements</p>
';

$handler = new ShortcodeHandler();
$handler->addShortcode('sample', 'sampleFunc', ['age' => 18]);

$content = $handler->handle($content);
print_r($content);

Result:

<p>Some other elements</p>
<p>Name: Alex</p><p>Age: 18</p>
<p>Some other elements</p>

Installation

Via composer:

composer require barbashin-andrey/shortcode

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: https
  • 更新时间: 2024-04-22