Skills.MD
# ActivityPub Integrations
This skill provides guidance on integrating the ActivityPub plugin with other WordPress plugins.
## Quick Reference
### Integration Location
All integrations live in the `integration/` directory.
**File naming:** `class-{plugin-name}.php` (following [PHP conventions](../activitypub-php-conventions/SKILL.md))
### Available Integrations
- BuddyPress
- bbPress
- WooCommerce
- Jetpack
- The Events Calendar
- WP User Avatars
- And 13+ more
For complete directory structure and naming conventions, see [PHP Class Structure](../../../docs/php-class-structure.md).
## Creating New Integration
### Basic Integration Class
```php
<?php
namespace Activitypub\Integration;
class Plugin_Name {
public static function init() {
\add_filter( 'activitypub_transformer', array( self::class, 'custom_transformer' ), 10, 2 );
\add_filter( 'activitypub_post_types', array( self::class, 'add_post_types' ) );
}
public static function custom_transformer( $transformer, $object ) {
// Return custom transformer if needed.
return $transformer;
}
public static function add_post_types( $post_types ) {
// Add plugin's post types.
$post_types[] = 'plugin_post_type';
return $post_types;
}
}
```
## Integration Patterns
### Adding Post Type Support
```php
public static function add_post_types( $post_types ) {
$post_types[] = 'event';
$post_types[] = 'product';
return $post_types;
}
```
### Custom Transformers
```php
public static function transformer( $transformer, $object ) {
if ( 'custom_type' === get_post_type( $object ) ) {
require_once __DIR__ . '/transformer/class-custom.php';
return new Transformer\Custom( $object );
}
return $transformer;
}
```
### Modifying Activities
```php
\add_filter( 'activitypub_activity_object', function( $object, $post ) {
if ( 'product' === get_post_type( $post ) ) {
$object['type'] = 'Product';
$object['price'] = get_post_meta( $post->ID, 'price', true );
}
return $object;
}, 10, 2 );
```
## Testing Integrations
### Verify Integration Loading
```php
// Check if integration is active.
if ( class_exists( '\Activitypub\Integration\Plugin_Name' ) ) {
// Integration loaded.
}
```
### Test Compatibility
1. Install target plugin
2. Activate ActivityPub
3. Check for conflicts
4. Verify custom post types work
5. Test federation of plugin content
## Common Integration Issues
### Plugin Detection
```php
// Multiple detection methods.
if ( defined( 'PLUGIN_VERSION' ) ) { }
if ( function_exists( 'plugin_function' ) ) { }
if ( class_exists( 'Plugin_Class' ) ) { }
```
### Hook Priority
```php
// Use appropriate priority.
add_filter( 'hook', 'callback', 20 ); // After plugin's filter.
```
### Namespace Conflicts
```php
// Use fully qualified names.
$object = new \Plugin\Namespace\Class();
```
## Existing Integrations
### BuddyPress
- Adds BuddyPress activity support
- Custom member transformers
- Group activity federation
### WooCommerce
- Product post type support
- Order activity notifications
- Customer review federation
### bbPress
- Forum topic federation
- Reply activities
- User forum profiles
## Best Practices
1. **Always check if plugin is active** before adding hooks
2. **Use late priority** for filters to override plugin defaults
3. **Test with multiple plugin versions**
4. **Document compatibility requirements**
5. **Handle plugin deactivation gracefully**
评论 0
还没有评论,来抢沙发。
相关内容
同类或同场景的收录内容
building-with-kafka-strimzi
在 Kubernetes 上构建基于 Apache Kafka 的事件驱动系统,支持高可靠的消息传递、事务性处理与精确一次语义,结合 Strimzi 运营商实现集群自动化管理,利用 Schema Registry 保障事件模式演进,适用于微服务间解耦通信与实时数据流处理场景。
站外数据与分析
609 0.0
personal-tool-builder
专注于从个人真实痛点出发快速构建实用工具,涵盖命令行程序、本地优先应用和自动化脚本的开发与演进,强调先满足自身需求再逐步扩展,通过持续自用打磨功能,避免过度设计,确保工具简洁有效且长期可维护。
站外商业与营销
196 0.0
threejs-lighting
实现三维场景中的光照与阴影控制,支持多种光源类型及环境光照明,提供从基础布光到高级阴影优化的完整方案,适用于需要真实感渲染或性能平衡的可视化项目。
站外效率工具
442 0.0
aggregation-helper
提供数据聚合场景的自动化辅助能力,涵盖 SQL 查询编写、统计分析建模、可视化方案设计及商业智能配置,支持从需求理解到生产级代码生成的全流程指导。
站外效率工具数据与分析
217 0.0
举报「activitypub-integrations」
举报信息仅审核团队可见,同一资产 24 小时内仅可举报一次