承接 flexpress/component-post-type 相关项目开发

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

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

flexpress/component-post-type

Composer 安装命令:

composer require flexpress/component-post-type

包简介

Post type helper for WordPress

README 文档

README

Install with Pimple

The PostType component uses two classes:

  • AbstractPostType, which you extend to create a PostType.
  • PostTypeHelper, which hooks into everything for you and registers the post types.

Lets create a pimple config for both of these

$pimple["documentPostType"] = function () {
  return new Document();
};

$pimple['PostTypeHelper'] = function ($c) {
    return new PostTypeHelper($c['objectStorage'], array(
        $c["documentPostType"]
    ));
};
  • Note the dependency $c['objectStorage'] is a SPLObjectStorage

Creating a concreate PostType class

Create a concreate class that implements the AbstractPostType class and implements the getName() method.

class DocumentType extends AbstractPostType {

    public function getName()
    {
      return "document";
    }
    
}

This above example is the bare minimum you must implement, the example that follows is the other extreme implementing all available methods.

class Document extends AbstractPostType {

  public function getSingularName()
  {
    return "Doc";
  }
  
  public function getPluralName()
  {
    return "Docs";
  }
  
  public function getArgs()
  {
    $args = parent::getArgs();
    $args['supports'] = array("title", "editor");
    return $args;
  }
  
  protected function getLabels()
  {
    $labels = parent::getLabels();
    $labels['menu_name'] = 'Docs';
    return $labels;
  }
    
  public function getName()
  {
    return "document";
  }

}

Public Methods

  • getSingularName() - returns the singular name of the post type.
  • getPluralName() - returns the plural name of the post type.
  • getArgs() - returns the array of args.
  • getLabels() - Returns the array of labels.
  • getName() - Returns post type name.

PostTypeHelper usage

Once you have setup the pimple config you are use the PostTypeHelper like this

$helper = $pimple['postTypeHelper'];
$helper->registerPostTypes();

That's it, the helper will then add all the needed hooks and register all the post types you have provided it.

Public methods

  • registerPostTypes() - Registers the post types provided.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: Unknown
  • 更新时间: 2014-08-13

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固