webdevstudios/cpt-core 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

webdevstudios/cpt-core

最新稳定版本:v1.0.3

Composer 安装命令:

composer require webdevstudios/cpt-core

包简介

WordPress Custom Post Type OO wrapper

README 文档

README

A tool to make custom post type registration just a bit simpler. Automatically registers post type labels and messages, and provides helpful methods.

Also see Taxonomy_Core.

WebDevStudios. WordPress for big brands.

The simple way:

<?php

/**
 * Load CPT_Core.
 */
require_once 'CPT_Core/CPT_Core.php';

/**
 * Will register a 'Q & A' CPT
 */
register_via_cpt_core( array(
	__( 'Q & A', 'your-text-domain' ), // Singular
	__( 'Q & As', 'your-text-domain' ), // Plural
	'q-and-a-items' // Registered name/slug
) );

The object-oriented way!

<?php

/**
 * Load CPT_Core.
 */
require_once 'CPT_Core/CPT_Core.php';

/**
 * Creating a custom class allows you to override core methods, like CPT_Core::columns, and CPT_Core::columns_display
 */
class Actress_CPT extends CPT_Core {

	/**
	 * Register Custom Post Types. See documentation in CPT_Core, and in wp-includes/post.php
	 */
	public function __construct() {

		// Register this cpt
		// First parameter should be an array with Singular, Plural, and Registered name
		parent::__construct(
			array( 
				__( 'Actress', 'your-text-domain' ),
				__( 'Actresses', 'your-text-domain' ),
				'film-actress'
			),
			array( 
				'supports' => array( 'title', 'editor', 'excerpt', 'thumbnail' ), 
			)
		);

	}

	/**
	 * Registers admin columns to display. Hooked in via CPT_Core.
	 * @since  0.1.0
	 * @param  array  $columns Array of registered column names/labels
	 * @return array           Modified array
	 */
	public function columns( $columns ) {
		$new_column = array(
			'headshot' => sprintf( __( '%s Headshot', 'your-text-domain' ), $this->post_type( 'singular' ) ),
		);
		return array_merge( $new_column, $columns );
	}

	/**
	 * Handles admin column display. Hooked in via CPT_Core.
	 * @since  0.1.0
	 * @param  array  $column Array of registered column names
	 */
	public function columns_display( $column, $post_id ) {
		switch ( $column ) {
			case 'headshot':
				the_post_thumbnail();
				break;
		}
	}

}
new Actress_CPT();

统计信息

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

GitHub 信息

  • Stars: 78
  • Watchers: 61
  • Forks: 12
  • 开发语言: PHP

其他信息

  • 授权协议: GPLv2
  • 更新时间: 2015-02-27

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固