tfrommen/外部内容

此插件注册了一个自定义文章类型来处理外部内容,就像任何其他文章一样。文章的永久链接被替换为自定义文章元数据,该元数据包含一个外部URL。

安装: 7

依赖项: 0

建议者: 0

安全: 0

星星: 1

关注者: 2

分支: 1

开放问题: 0

类型:wordpress-plugin

v1.4.2 2016-01-03 17:45 UTC

This package is auto-updated.

Last update: 2024-09-15 15:59:43 UTC


README

Latest Stable Version Project Status Build Status License

你是否曾想将外部内容(如外部网站的特定文章)集成到你的WordPress网站中?但将其视为任何其他文章?也就是说,让它以预告或特定(伪)存档的一部分的形式出现?

这正是外部内容发挥作用的时候。

安装

  1. 下载ZIP.
  2. 将内容上传到你的Web服务器的/wp-content/plugins目录。
  3. 通过WordPress中的插件菜单激活插件。
  4. 在WordPress后端找到新的外部内容菜单。

屏幕截图

Meta box
元数据框 - 输入一个外部URL,以便将文章的永久链接替换为它。

用法

外部内容注册了一个自定义文章类型,默认情况下支持标题、内容、摘要和缩略图。虽然可以自定义,但在后端管理文章与任何其他文章类型没有区别。创建一篇新文章,给它一个标题,写一些文本,定义一个单独的摘要,如果你愿意,还可以设置文章缩略图。然后通过相应的元数据框为每个文章分配一个单独的外部URL。这个外部URL将被用作文章的永久链接。

过滤器

为了自定义插件的一些方面,它为你提供了几个过滤器。下面为每个过滤器提供了一个简短的描述以及如何更改默认行为的代码示例。只需将相应的代码片段放入你的主题的functions.php文件或你的定制插件,或者放入其他适当的位置。

external_content_args

如果你想要更改特定的文章类型参数但找不到合适的过滤器,那么有external_content_args,它为你提供了完整的参数数组。

/**
 * 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

可以使用external_content_description过滤器自定义文章类型描述。

/**
 * 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

如果你不喜欢标签,可以轻松地按照你的喜好进行修改。

/**
 * 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

如果你想要更改外部URL的元数据键,可以通过此过滤器自由地进行。

/**
 * 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

是的,你也可以更改文章类型(缩略名)。

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

external_content_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

默认情况下,外部内容的永久链接会被替换为相应的文章外部URL(即,文章元数据)。要禁用此行为,请执行以下操作

/**
 * 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' );

贡献

如果你有一个功能请求,或者如果你已经开发了该功能,请自由使用问题和/或拉取请求部分。

当然,如果你希望在其他尚未包括的语言中使用此插件,你也可以提供翻译。

更新日志

更新日志