定制 nyco/wp-open-data-transients 二次开发

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

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

nyco/wp-open-data-transients

Composer 安装命令:

composer require nyco/wp-open-data-transients

包简介

Interface for saving Open Data endpoints as WordPress Transients.

README 文档

README

This WordPress Plugin will provide an interface in the WP Admin to save saving external Open Data as WordPress transients and a developer API to interact with them. You can read more about the WordPress Transients API in the Codex.

Features

  • Admin Interface (Settings > Open Data Transients) for adding new transients and adding an Open Data token.
  • Transients can be updated manually in the Admin, but they are set to expire weekly (using the WordPress constant WEEK_IN_SECONDS).
  • Developer API for getting the transient data, and updating it automatically if it is expired.

Usage

Installation

It uses composer/installers to install it to the plugin directly using Composer. Just run:

composer require nyco/wp-open-data-transients

You can also download the package and add it manually to your plugin directory.

App Token

A token will be sent in the header (X-App-Token) to the Open Data endpoint to authenticate your application for for saving data. This can be set in the same admin or as an environment variable $_ENV['OPEN_DATA_APP_TOKEN']. The NYCO WP Config plugin can be used to manage environment variables.

Saved Transients

Transients can be saved by adding a valid name (letters and underscores only) and valid url. Clicking "Save Transient" will save the transient and cache the request. Once it is saved, the developer API can be used to get the data. The developer API also exposes the save and set methods used by the admin interface.

Typing the name of an already saved transient and clicking "Save Transient" will update the transient data cache.

Developer API

Once the plugin is installed, you can reference the name space to use it;

use NYCO\Transients as Transients;

Save

The transient needs to be saved with a valid name (letters and underscores only) and valid url before it can be exposed to the set or get methods.

Transients::save('your_transient_name', 'https://opendata.com/endpoint');

Set

Uses WordPress' wp_remote_get and set_transient methods to retrieve the saved endpoint and save the response body. It will expect a JSON response and will be saved as a PHP Object.

Transients::set('your_transient_name');

Get

Returns a saved transient. If the transient is empty (expired) it will use the set method to re-cache it.

Transients::get('your_transient_name');

Potential Improvements

This plugin only provides a small interface for saving external Open Data as WordPress Transients and external data and is not a fully fledged transient manager.

  • Method to delete saved transients.
  • Option to set the expiration of transients.

About NYCO

NYC Opportunity is the New York City Mayor's Office for Economic Opportunity. We are committed to sharing open source software that we use in our products. Feel free to ask questions and share feedback. Follow @nycopportunity on Github, Twitter, Facebook, and Instagram.

nyco/wp-open-data-transients 适用场景与选型建议

nyco/wp-open-data-transients 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 127 次下载、GitHub Stars 达 1, 最近一次更新时间为 2018 年 10 月 03 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

围绕 nyco/wp-open-data-transients 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: GPL-3.0
  • 更新时间: 2018-10-03