定制 dxw/wordpress-setup 二次开发

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

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

dxw/wordpress-setup

最新稳定版本:v0.1.1

Composer 安装命令:

composer require dxw/wordpress-setup

包简介

Helpers for automating your WordPress setup

README 文档

README

A package to help with getting WordPress configured and populated with content, so that it's a known testable or dev-able state.

How to use

Install with Composer:

composer require-dev dxw/wordpress-setup

Call the Factory to get a new Setup instance, e.g.:

$setup = Dxw\WordPressSetup\Factory::create();

Then call specific modules as properties of setup, e.g to create a post:

$setup->post->create();

Or to create a menu and assign it to a menu location in your theme:

$setup->menu->createAndAssignLocation('menu-name', 'menu-location');

Modules and their available methods are documented in detail below.

Modules

Media

upload

Upload a file to the media library, and create the appropriate attachment metadata.

Takes either a path to the file, or a URL:

$setup->media->upload(string $pathOrUrlToFile);

Returns the ID of the created attachment.

Menu

addCustomLink

Add a custom link item to a menu, where the first argument is the ID of the menu to assign it to:

$setup->menu->addCustomLink(int $menuId, string $menuItemTitle, string $menuItemUrl);

Can also be passed the ID of the menu item this should be a child of as the final argument:

$setup->menu->addCustomLink(int $menuId, string $menuItemTitle, string $menuItemUrl, int $parentMenuItemId);

Returns the ID of the menu item that has been created.

addTaxonomyLink

Add a taxonomy archive link to a menu.

$setup->menu->addTaxonomyLink(int $menuId, int $termid, int $taxonomyName)

Can also optionally be passed the ID of the menu item this should be a child of:

$setup->menu->addTaxonomyLink(int $menuId, int $termid, int $taxonomyName, int $parentMenuItemId)

Returns the ID of the menu item that has been created.

createAndAssignLocation

Create a new menu and assign it to a theme location by name:

$setup->menu->createAndAssignLocation(string $menuName, string $menuLocation);

Returns the ID of the new menu.

Plugin

activate

Activate a plugin by its slug:

$setup->plugin->activate(string $pluginSlug)

Post

create

Create a new post:

$setup->post->create();

By default, Faker will be used to generate dummy title and content, the post type will be post and the post status will be publish.

You can override any of these defaults (or add additional parameters) using the same array of args you would pass to wp_insert_post.

Returns the ID of the new post.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-07-22