承接 wefabric/wp-video-indexer 相关项目开发

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

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

wefabric/wp-video-indexer

Composer 安装命令:

composer require wefabric/wp-video-indexer

包简介

Indexes platform videos in WordPress post content as VideoObject schema markup.

README 文档

README

Indexes YouTube and Vimeo videos found in WordPress post content and ACF fields as VideoObject schema markup (JSON-LD).

How it works

  1. On save_post, the package scans post_content and all ACF fields for YouTube and Vimeo URLs (including iframe embed URLs).
  2. For each unique video found, it fetches metadata via the platform's oEmbed API and builds a VideoObject schema.
  3. The schemas are cached in post meta, keyed by URL. On subsequent saves, already-cached videos are reused without a new HTTP request.
  4. On wp_head (singular pages only), the cached schemas are output as <script type="application/ld+json"> tags.

Installation

The package is available on Packagist.

composer require wefabric/wp-video-indexer:^1.0
php artisan package:discover

Requirements

  • PHP >= 7.4
  • WordPress
  • Themosis framework (for hook registration and service container)
  • wefabric/wp-support (for WPSupport::addHooks)

Supported URL formats

YouTube

Format Example
Watch URL https://youtube.com/watch?v=ID
Short URL https://youtu.be/ID
Embed iframe https://youtube.com/embed/ID
Legacy embed https://youtube.com/v/ID

Vimeo

Format Example
Standard URL https://vimeo.com/ID
URL with query params https://vimeo.com/ID?fl=pl&fe=vl
Embed iframe https://player.vimeo.com/video/ID
Channel URL https://vimeo.com/channels/name/ID

Structure

src/
├── Hooks/
│   └── VideoIndexerHook.php            Registers save_post + wp_head, delegates to services
├── Providers/
│   └── ServiceProvider.php             Laravel service provider (auto-discovered)
└── Services/
    ├── VideoSchemaServiceInterface.php  Contract for all platform services
    ├── VideoSchemaCacheService.php      Scans content, fetches/reuses schemas, saves to post meta
    ├── VideoSchemaOutputService.php     Reads post meta and outputs JSON-LD script tags
    ├── YouTubeSchemaService.php         YouTube oEmbed fetching and schema generation
    └── VimeoSchemaService.php           Vimeo oEmbed fetching and schema generation

Adding a new platform

Each platform is a service class implementing VideoSchemaServiceInterface:

interface VideoSchemaServiceInterface
{
    public function matches(string $url): bool;
    public function extractId(string $url): ?string;
    public function fetchSchema(string $url): array;
}
  1. Create a new service class implementing the interface:
class DailymotionSchemaService implements VideoSchemaServiceInterface
{
    public function matches(string $url): bool
    {
        return strpos($url, 'dailymotion.com') !== false;
    }

    public function extractId(string $url): ?string
    {
        // extract ID from URL
    }

    public function fetchSchema(string $url): array
    {
        // fetch oEmbed data and return a VideoObject schema array
    }
}
  1. Register it in VideoIndexerHook::$services:
protected array $services = [
    YouTubeSchemaService::class,
    VimeoSchemaService::class,
    DailymotionSchemaService::class, // add here
];

No other changes are needed.

Testing

composer install
./vendor/bin/phpunit

Tests cover matches(), extractId(), and fetchSchema() (including fallback behaviour) for each platform service. WordPress functions are mocked using Brain Monkey.

Post meta

Key Type Description
_cached_video_schemas array Schemas keyed by URL: [ $url => $schema, ... ]

Schemas are re-cached each time a post is saved. Already-cached URLs are reused without a new API call. To force a full refresh, delete the _cached_video_schemas post meta and re-save the post.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: proprietary
  • 更新时间: 2026-03-26

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固