承接 moehrenzahn/wp-toolkit 相关项目开发

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

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

moehrenzahn/wp-toolkit

Composer 安装命令:

composer require moehrenzahn/wp-toolkit

包简介

An object-oriented framework around common WordPress functionality to jumpstart theme and plugin development.

关键字:

README 文档

README

Work with common WordPress Plugin and Theme APIs in a modern, object-oriented way.

By Max Melzer

The WordPress Toolkit is a Composer module that offers easy access to common WordPress functionality, inspired by modern PHP frameworks like Symfony.

It's aim is to provide consistent, object-oriented methods for WordPress plugin and theme development.

Installation

To use the toolkit, add it to your theme or plugin via Composer.

cd wp-content/themes/your-awesome-theme
composer init
composer require moehrenzahn/wp-toolkit

Then, you can initialize the Client class in your PHP script. This is the entry point to all functionality of the toolkit.

<?php
$client = new \Moehrenzahn\Toolkit\Api\Client();

Requirements

  • Composer
  • PHP >= 7.1
  • WordPress >= 5.0 (older versions may work but are untested)

Features

  • convenient API around Wordpress action and filter management
  • object manager with simple, automatic dependency injection
  • template rendering with Model-View-Controller architecture
  • add and manage
    • JavaScript files
    • CSS files
    • image sizes
    • shortcodes
    • virtual user accounts
    • Transients
    • Post Types
    • Post Terms and Meta
    • Post Meta boxes
    • Post filters
    • comment Meta
    • comment Meta boxes
    • settings pages
    • admin pages
    • admin notices
    • AJAX actions
    • POST actions

Usage example

Add a CSS file to your theme:

<?php
// Entry point for all actions is the Client object
$client = new \Moehrenzahn\Toolkit\Api\Client();
$stylesheets = $client->getStylesheetManager();
$stylesheets->add('eule-stylesheet', 'src/css/style.css', '1.0.0');

Add a shortcode with a custom template:

<?php
$client = new \Moehrenzahn\Toolkit\Api\Client();
$shortcodes = $client->getShortcodeManager();
$shortcodes->add(
    'my-shortcode',
    $client->getViewFactory()->create('shortcode-template.phtml')
);

Create a custom settings page with pre-built input type templates.

<?php
$client = new \Moehrenzahn\Toolkit\Api\Client();
$client->getAdminPageManager()->addSettingsPage(
    'Sample settings page',
    'sample-settings-page',
    getSections($client)
);

/**
 * @param \Moehrenzahn\Toolkit\Api\Client $client
 * @return Moehrenzahn\Toolkit\View\Settings\Section[]
 */
function getSections(\Moehrenzahn\Toolkit\Api\Client $client): array
{
    $sectionBuilder = $client->getSettingsSectionBuilder();
    $sectionBuilder->addSetting(
        'my-sample-setting',
        'A sample setting title',
        \Moehrenzahn\Toolkit\AdminPage\SettingsSectionBuilder::SETTING_TYPE_BOOLEAN,
        'A sample setting description.'
    );

    $sectionBuilder->addSetting(
        'my-sample-select',
        'Select your thing',
        \Moehrenzahn\Toolkit\AdminPage\SettingsSectionBuilder::SETTING_TYPE_SELECT,
        'You can also do select inputs!',
       [
           'sample-option-value' => 'Sample option label',
           'another-option-value' => 'Another option!',
       ]
    );
    
    return [$sectionBuilder->create('sample-section', 'A sample settings section')];
}

Use the built-in View class to render your templates and get access to features like lazy-loading images and partials:

<?php /** @var \Moehrenzahn\Toolkit\View $view */ ?>
<h2>Here comes a lazy-loaded partial that is only loaded when it's scrolled into view:</h2>
<?php $view->renderLazyPartial(
    'your-template-to-load.phtml',
    'your-static-placeholder-template.phtml'
) ?>

Use the object manager to initalize objects with automatic dependency resolution.

<?php 
$client = new \Moehrenzahn\Toolkit\Api\Client();
$objectManager = $client->getObjectManager();
/**
 * The object manager will try to automatically and recursively
 * resolve all dependencies of the given class.
 * Don't use this for very large projects since it can impact performance.
 */
$customObject = $objectManager->getSingleton(YourCustomClass::class);

Release History

  • 1.0.0
    • Initial release

Meta

Max Melzer – @_maxmelzerhi@moehrenzahn.de

Distributed under the GNU General Public License. See LICENSE.md for more information.

https://github.com/moehrenzahn

Contributing

  1. Fork it (https://github.com/moehrenzahn/wp-toolkit/fork)
  2. Create your feature branch (git checkout -b feature/fooBar)
  3. Commit your changes (git commit -am 'Add some fooBar')
  4. Push to the branch (git push origin feature/fooBar)
  5. Create a new Pull Request

moehrenzahn/wp-toolkit 适用场景与选型建议

moehrenzahn/wp-toolkit 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 78 次下载、GitHub Stars 达 6, 最近一次更新时间为 2019 年 05 月 18 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「wordpress」 「OOP」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-05-18