定制 tfrommen/external-content 二次开发

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

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

tfrommen/external-content

Composer 安装命令:

composer require tfrommen/external-content

包简介

This plugin registers a custom post type to handle external content like any other post. The post permalink is replaced by a custom post meta that holds an external URL.

README 文档

README

Latest Stable Version Project Status Build Status License

Have you ever wanted to integrate external content such as a specific post of an external website into your WordPress website? But treat it like any other post? That is, have it appear as teaser or part of a specific (pseudo) archive?

This is exactly when External Content kicks in.

Installation

  1. Download ZIP.
  2. Upload contents to the /wp-content/plugins directory on your web server.
  3. Activate the plugin through the Plugins menu in WordPress.
  4. Find the new External Content menu in your WordPress backend.

Screenshots

Meta box
Meta box - Enter an external URL to have the post's permalink be replaced with it.

Usage

External Content registers a custom post type that, by default, supports title, content, excerpt and thumbnail. This can be customized, though. Managing your posts in your backend is no different from any other post type. Create a new post, give it a title, write some text, define an individual excerpt, and set a post thumbnail, if you wish. Then assign each post an individual external URL by means of the according meta box. This external URL will be used as the post's permalink.

Filters

In order to customize certain aspects of the plugin, it provides you with several filters. For each of these, a short description as well as a code example on how to alter the default behavior is given below. Just put the according code snippet in your theme's functions.php file or your customization plugin, or to some other appropriate place.

external_content_args

If you want to alter a specific post type argument but you can't find a fitting filter, there's external_content_args, which provides you with the complete args array.

/**
 * Filter the post type args.
 *
 * @param array $args Post type args.
 */
add_filter( 'external_content_args', function( $args ) {

	// Use hierarchical external content
	$args[ 'hierarchical' ] = TRUE;
	
	return $args;
} );

external_content_description

The post type description can be customized by using the external_content_description filter.

/**
 * Filter the post type description.
 *
 * @param string $description Post type description.
 */
add_filter( 'external_content_description', function() {

	// Provide a description
	return 'Simple post type for handling external content like any other post.';
} );

external_content_labels

In case you don't like the labels, easily adapt them to your liking.

/**
 * Filter the post type labels.
 *
 * @param array $labels Post type labels.
 */
add_filter( 'external_content_labels', function( $labels ) {
	
	// A little more horror, please...
	$labels[ 'not_found' ] = 'ZOMG, no external content found!!1!!1!!oneone!!!1!eleven!1!';
	
	return $labels;
} );

external_content_meta_key

If you want to alter the meta key for the external URL, feel free to do it via this filter.

/**
 * Filter the meta key.
 *
 * @param string $meta_key Meta key.
 */
add_filter( 'external_content_meta_key', function() {

	// Let's Shrekify the meta key
	return 'far_far_away';
} );

external_content_post_type

Yes, you can also alter the post type (slug).

/**
 * Filter the post type.
 *
 * @param string $post_type Post type.
 */
add_filter( 'external_content_post_type', function() {
	
	return 'exotic_stuff';
} );

external_content_supports

This filter provides you with the the post type supports.

/**
 * Filter the post type supports.
 *
 * @param array $supports Post type supports.
 */
add_filter( 'external_content_supports', function( $supports ) {

	// If your theme uses the excerpt for teasers, just remove the editor to prevent confusion
	foreach ( $supports as $key => $value ) {
		if ( 'editor' === $value ) {
			unset( $supports[ $key ] );
		}
	}
	
	return $supports;
} );

external_content_use_external_url

The permalink of external content is, by default, replaced with the post's according external URL (i.e., post meta). To disable this behavior, just do the following:

/**
 * Filter the usage of the external URL as permalink.
 *
 * @param bool $use_external_url Use the external URL as permalink?
 */
add_filter( 'external_content_use_external_url', '__return_false' );

Contribution

If you have a feature request, or if you have developed the feature already, please feel free to use the Issues and/or Pull Requests section.

Of course, you can also provide me with translations if you would like to use the plugin in another not yet included language.

Changelog

Changelog

tfrommen/external-content 适用场景与选型建议

tfrommen/external-content 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 8 次下载、GitHub Stars 达 1, 最近一次更新时间为 2015 年 09 月 19 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

围绕 tfrommen/external-content 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: GPL-3.0
  • 更新时间: 2015-09-19