承接 tmf/wp-metabox-helper 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

tmf/wp-metabox-helper

Composer 安装命令:

composer require tmf/wp-metabox-helper

包简介

A Pimple service that facilitates the creation of WordPress metaboxes

README 文档

README

Build Status

A Pimple service based on the Hookable Service Provider that facilitates the creation of metaboxes for post meta fields. The items in a metabox representing post meta fields are compatible with WordPress revisions and autosaves. This service can be registered in a pimple container and be used in WordPress themes or plugins.

This metabox helper service comes with the following types of items out of the box:

  • Text inputs
  • Dropdown fields (implemented with selectize)
  • Textareas
  • TinyMCE Editors

Usage

This service is installable via Composer and relies on it's class autoloading mechanism. You can package the vendor directory with you theme or plugin, with your WordPress installation or with a setup of your choosing.

  1. Create a composer project for your plugin or theme:

    cd your-plugin-directory
    # install composer phar
    curl -sS https://getcomposer.org/installer | php
    # create a basic composer.json
    ./composer.phar init
  2. Add the metabox helper service as a dependency in your composer.json

    ./composer.phar require tmf/wp-metabox-helper ~0.1
  3. Create a pimple container and register the metabox helper service

    // load the vendors via composer autoload
    if (file_exists( __DIR__ . '/vendor/autoload.php')) {
        require_once __DIR__ . '/vendor/autoload.php';
    }
    
    use Tmf\Wordpress\Service\Metabox\MetaboxServiceProvider,
        Tmf\Wordpress\Service\Metabox\Metabox,
        Tmf\Wordpress\Service\Metabox\Item\InputItem,
        Tmf\Wordpress\Service\Metabox\Item\DropdownItem,
        Tmf\Wordpress\Service\Metabox\Item\EditorItem;
    
    // create the service container
    $services = new Pimple\Container();
    
    // register the metabox helper with this service provider. the service is registered with the 'metaboxes' key
    $services->register(new MetaboxServiceProvider());
  4. Add a metabox and some metabox items representing post meta values

    add_action('admin_init', function () use ($services) {
        // create a metabox for 'post' post types
        $services['metaboxes']['foo'] = new Metabox('Foo', ['post'], 'normal', 'high');
        
        // add item: the key is the post meta key
        $services['metaboxes']['foo']['text'] = new InputItem(['label' => 'Metatext', 'description' => 'Some description']);
        $services['metaboxes']['foo']['dropdown'] = new DropdownItem([['label' => 'Foo', 'value'=>'foo'], ['label' => 'Bar', 'value'=>'bar']]);
        $services['metaboxes']['foo']['editor'] = new EditorItem();
    });

Extend

If you want to use your own metabox items, your item must implement the Tmf\Wordpress\Service\Metabox\Item\MetaboxItemInterface interface. You can, however, extend any of the available items or the Tmf\Wordpress\Service\Metabox\Item\TwigTemplateItemRenderer. If you want to define your own Twig templates for the item rendering, add a Twig loader to the Twig Chain:

add_action('add_meta_boxes', function() use ($services) {
    $this->getContainer()->extend('metaboxes.twig.loader', function($loader, $services){
        /** @var Twig_Loader_Chain $loader */
        $loader->addLoader(new Twig_Loader_Filesystem(get_stylesheet_directory() . '/templates/items'));
        return $loader;
    });
}, 95); // additional twig loaders should be registered between priority 90 and 100

tmf/wp-metabox-helper 适用场景与选型建议

tmf/wp-metabox-helper 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 40 次下载、GitHub Stars 达 2, 最近一次更新时间为 2014 年 11 月 26 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 tmf/wp-metabox-helper 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 tmf/wp-metabox-helper 我们能提供哪些服务?
定制开发 / 二次开发

基于 tmf/wp-metabox-helper 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2014-11-26