PHP 클래스 RW_Meta_Box

저자: Rilwis
저자: Co-Authors @see https://github.com/rilwis/meta-box
파일 보기 프로젝트 열기: rilwis/meta-box 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
$fields Fields information
$meta_box Meta box information
$saved Used to prevent duplicated calls like revisions, manual hook to wp_insert_post, etc.

공개 메소드들

메소드 설명
__construct ( array $meta_box ) Create meta box based on given data
add_meta_boxes ( ) Add meta box for multiple post types
enqueue ( ) Enqueue common scripts and styles.
hide ( array $hidden, object $screen ) : array Hide meta box if it's set 'default_hidden'
is_edit_screen ( WP_Screen $screen = null ) : boolean Check if we're on the right edit screen.
is_saved ( ) : boolean Check if meta box is saved before.
normalize ( array $meta_box ) : array Normalize parameters for meta box
normalize_fields ( array $fields ) : array Normalize an array of fields
save_post ( integer $post_id ) Save data from meta box
show ( ) Callback function to show fields in meta box

보호된 메소드들

메소드 설명
global_hooks ( ) Add global hooks.
is_shown ( ) : boolean Conditional check for whether initializing meta box.
object_hooks ( ) Specific hooks for meta box object. Default is 'post'.
validate ( ) : boolean Validate form when submit. Check: - If this function is called to prevent duplicated calls like revisions, manual hook to wp_insert_post, etc.

메소드 상세

__construct() 공개 메소드

Create meta box based on given data
public __construct ( array $meta_box )
$meta_box array Meta box definition

add_meta_boxes() 공개 메소드

Add meta box for multiple post types
public add_meta_boxes ( )

enqueue() 공개 메소드

Enqueue common scripts and styles.
public enqueue ( )

global_hooks() 보호된 메소드

Add global hooks.
protected global_hooks ( )

hide() 공개 메소드

Hide meta box if it's set 'default_hidden'
public hide ( array $hidden, object $screen ) : array
$hidden array Array of default hidden meta boxes
$screen object Current screen information
리턴 array

is_edit_screen() 공개 메소드

Check if we're on the right edit screen.
public is_edit_screen ( WP_Screen $screen = null ) : boolean
$screen WP_Screen Screen object. Optional. Use current screen object by default.
리턴 boolean

is_saved() 공개 메소드

This helps saving empty value in meta fields (text, check box, etc.) and set the correct default values.
public is_saved ( ) : boolean
리턴 boolean

is_shown() 보호된 메소드

- 1st filter applies to all meta boxes - 2nd filter applies to only current meta box
protected is_shown ( ) : boolean
리턴 boolean

normalize() 공개 정적인 메소드

Normalize parameters for meta box
public static normalize ( array $meta_box ) : array
$meta_box array Meta box definition
리턴 array $meta_box Normalized meta box

normalize_fields() 공개 정적인 메소드

Normalize an array of fields
public static normalize_fields ( array $fields ) : array
$fields array Array of fields
리턴 array $fields Normalized fields

object_hooks() 보호된 메소드

This should be extended in sub-classes to support meta fields for terms, user, settings pages, etc.
protected object_hooks ( )

save_post() 공개 메소드

Save data from meta box
public save_post ( integer $post_id )
$post_id integer Post ID

show() 공개 메소드

Callback function to show fields in meta box
public show ( )

validate() 보호된 메소드

- Autosave - If form is submitted properly
protected validate ( ) : boolean
리턴 boolean

프로퍼티 상세

$fields 공개적으로 프로퍼티

Fields information
public $fields

$meta_box 공개적으로 프로퍼티

Meta box information
public $meta_box

$saved 공개적으로 프로퍼티

Used to prevent duplicated calls like revisions, manual hook to wp_insert_post, etc.
public $saved