wordpress plugin #3

68
WordPress Plugin #3 May 21st, 2015 changwoo

Upload: giwoolee

Post on 14-Aug-2015

34 views

Category:

Internet


0 download

TRANSCRIPT

Page 1: WordPress plugin #3

WordPress Plugin 3May 21st 2015

changwoo

Recap

Hooks in Nutshell Hook is an event Plugin is hook-driven Task separation

o Changing cores workflow actiono Modifying contents filtero In fact action and filter are the same

Recap

Hooks in Nutshell Callback function utility You can define your own hooks There are many predefined hooks

Recap

Datbase Nutshell Parent-meta strategy

o Flexiblilityo Extendibleo But can experience some defects

Meta key meta valueo Hash-like storage

Recap

Database Nutshell Term taxonomy

o Term a wordo Taxonomy a classification of words

There are some pre-defined terms and taxonomieso category (hierarchical) post_tag (flat)

Recap

Todays Topics

1Entry Points in Plugina Menub Shortcodesc Admin Postd Ajaxe Redirectf activation deactivation uninstall

2Managing Your Own Contentsa All About Custom Posts

Entry Points in Plugin

Entry Points

Plugins run on the server sideServer only responds when it is requested

Requested moment rarr entry point

Entry Points

Q When the server is requestedA It is when client access via a URL

Q Why a URL is usedA To define a resource output to clientA To receive data input from client

Entry Points

Q Output FormA Whatever

Images audio video html documents

Q Input formA Generally submitting forms

via GETPOST method

Entry Points

There are some special entry points left for plugins

Menu items Shortcodes Admin post AJAX Redirecting Activation deactivation uninstall

Menu Items

Callback from admin menu clicking

add_menu_page()add_submenu_page()

remove_menu_page()remove_submenu_page()

Where is default menu

wp-adminmenu-headerphp

ltul id=adminmenugtltphp_wp_menu_output( $menu $submenu )

function _wp_menu_output( $menu $submenu $submenu_as_parent = true )

here menus are printed in html

Where is default menu

wp-adminmenuphp (adminphp includes it)wp-amdinincludesmenuphp

builds administrative menus

global $menu $submenu stores menu information

Our custom menus

wp-adminincludesmenuphp

do_action( admin_menu )

Menu API are defined in wp-adminincludespluginphp

add_menu_page

function add_menu_page( $page_title $menu_title $capability $menu_slug $function = $icon_url = $position = null )

$new_menu = array( $menu_title $capability $menu_slug $page_title menu-top $icon_class $hookname $hookname $icon_url )

if ( null === $position ) $menu[] = $new_menuelse $menu[$position] = $new_menu

add_submenu_page

function add_submenu_page( $parent_slug $page_title $menu_title $capability $menu_slug $function = ) $submenu[$parent_slug][] = array ( $menu_title $capability $menu_slug $page_title )

derivatives

add_dashboard_page() add_posts_page() add_media_page() add_pages_page() add_comments_page() add_theme_page() add_plugins_page() add_users_page() add_management_page() add_options_page()

Shortcodes

What is shortcodeA magic word in post content that is replaced by some process defined in plugin or themes in runtime

Good for displaying complex dynamic contents

Shortcodes

Sample[gallery id=123 size=medium][gallery]

or

[caption]My Caption[caption] enclosed form

Shortcodes

add_shortcode()

$shortcode_tags = array()function add_shortcode($tag $func) global $shortcode_tags

if ( is_callable($func) ) $shortcode_tags[$tag] = $func

Shortcodes

function do_shortcode($content) global $shortcode_tags

if ( false === strpos( $content [ ) ) return $content

if (empty($shortcode_tags) || is_array($shortcode_tags)) return $content

$pattern = get_shortcode_regex() return preg_replace_callback( $patterns do_shortcode_tag $content )

Shortcodes

function do_shortcode_tag( $m )

if ( isset( $m[5] ) ) enclosing tag - extra parameter return $m[1] call_user_func( $shortcode_tags[$tag] $attr $m[5] $tag ) $m[6] else self-closing tag return $m[1] call_user_func( $shortcode_tags[$tag] $attr null $tag ) $m[6]

Shortcodes

callback params $attrs attributes $content enclosed tags text $tag shortcode tag itself

Admin-post

Data from clientsProcessing requests

You can just process requests in your own page because $_REQUEST $_GET $_POST is global

Admin-post

But in your own handlerYou cannot use WP core functionsYou cannot authenticate

Do not reinvent the wheelSo there is admin-postphp

Admin-post

wp-adminadmin-postphpdefine amp include minimal settingsand do_action

$action = empty( $_REQUEST[action] ) $_REQUEST[action]

admin_post_nopriv admin_post_nopriv_$actionadmin_post admin_post_$action

finish using die() in callback function

AJAX

Very similar to admin-post but DOING_AJAX is defineddefine( DOING_AJAX true )

also use die() in callback function

if ( is_user_logged_in() ) do_action( wp_ajax_ $_REQUEST[action] ) else do_action( wp_ajax_nopriv_ $_REQUEST[action] ) Default statusdie( 0 )

Redirect

You can generate custom page in plugin by using template_redirect action

function my_page_template_redirect() if( is_page( goodies ) ampamp is_user_logged_in() )

wp_redirect( home_url( signup ) ) exit()

add_action( template_redirect my_page_template_redirect )

Redirect

You can generate web pages on-the-fly by utilizing these 3 hooks rewrite rule query parsing redirect

Detailed instructions later

(de)activation uninstall

register_activation_hook($file $cb)register_deactivation_hook($file $cb)register_uninstall_hook($file $cb)

$file full path of plugin file$cb callback function

callbacks should be SILENT No echo please

Summary

menu items shortcodes admin post ajax template redirects and (de)activation- uninstall hooks are good initial entry pointso It is a good strategy to find these

hooks in plugins first and dissect their codes from those points

I know you want to do something

You understand hook conceptYou know database detail

Now you know entry points

Definitely you wanna make something

Visit http[ip]practice and download entry-pointsphp

소스코드 http[ip]source-codes1 어드민 화면에 메뉴 추가2 쇼트코드 추가3 메뉴에서 admin post 전송4 메뉴에서 ajax 전송5redirect 테스트

ltauthorgt 부분은 자신의 이름으로 일괄변경하고 적절히 콜백 함수를 정의해 주세요

Source code explained

10 minutes break

Managing Your Own Contents

Wow there are too many things about posts

For today just focuse oncustom post type

Arguments are too complex

Just use Types or Pods pluginThats all problem solved

Yeah

of course you might not want this I was just kidding

Custom Post

You want to manage your own contentsThats why custom post is

Music collections Online store Event calendar Book data Photo portfolio

Custom Post Motivation

Well with just one type post and you may define many categories and use them to organize all contents

JUST ONE TYPE POSTMANY CATEGORIES

portfolio calendar music db

Custom Post Motivation

But you might feel that some post types should be hidden from some users even might be excluded from search may be only for private use may have very complex taxonomies

so that it should have its own territory

can be accessible from their own URL rules

Custom Post Motivation

Why re-invent wheel again

By extending built-in post type systemyou can REUSE whole facilities related to posts easily

UI and all thing about managing

Built-in Custom Post Types

wp-includespostphp (included in wp-settingsphp)function create_initial_post_types()

register_post_type( post array( register_post_type( page array( register_post_type( attachment array( register_post_type( revision array( register_post_type( nav_menu_item array( register_post_status( publish array(

register_post_type

ltphp register_post_type( $post_type $args ) gt

$arg is very complex

But I think it should be explained in detail Actually you cannot avoid it because eventuall all post type plugins will use that function too

Those plugins also have diffcult UIs too

register_post_type

Lets take a look how Types and Pods create their custom posts

They have easy (really) UI and provide better functionaliy but you can see horribly many options there

register_post_type $post_type

Up to 20 characters Only lowercase and numbers

register_post_type $args

publicvisible to authors

true impliesexclude_from_search falsepublicly_queryable show_in_nav_manues show_ui

false impliesexclude_from_search true publicly_queryable falseshow_in_nav_manues false show_ui false

register_post_type $args

labelplural descriptive name

egMusic CollectionsMostly localized text

register_post_type $args

labels more specific text labelsnamesigular_namemenu_namename_admin_barall_itemsadd_newadd_new_itemedit_itemview_itemsearch_items

search_itemsnot_foundnot_found in trashparent_item_colon

register_post_type $args

descriptionsummary of this post type

register_post_type $args

exclude_from_searchdo not search this post typetry S=beatbles

register_post_type $args

publicly_queryablecan use query

eg) post_type=music_collection

register_post_type $args

show_uidisplay default UI

register_post_type $args

show_in_nav_menusshow in navigation menus

be careful publicly_queryablemust be true

register_post_type $args

show_in_menushow admin_menu show_ui must be trueJust showing menutrue false else some strings

(toolsphp editphp)

altough it is falseyou can access URLS likewp-admineditphppost_type=music_collection(show_ui must be true)

register_post_type $args

show_in_admin_baravailable in admin bar

menu_postiondefault below comments

menu_iconsee dashicons

register_post_type $args

capability_typestring or array to build capabilites

in our exampeedit_music_collectionsedit_others_music_collections

publish_music_collectionsread_private_music_collections

register_post_type $args

capabilitiesto give specific names to each capability

map_meta_capif true default meta capability will be added

and then your role or account need capabilities

register_post_type $args

hierarchicalpost type can be hierarchicalthis is for page-styles

register_post_type $args

query_varto query posts query_var=slug

rewriteto use pretty permalinks

has_archiveEnables post type archive

register_post_type $args

permalink_epmaskrewrite endpoint bitmask

can_exporttrue makes the post can be exported

Too exhaustive but worth it

Practice Custom Post

Create custom-plugin-ltauthorgtphpCreate a simple custom post

Display admin menuHide admin_barWrite your post Any content is OK Include at least one meta field

Next Week

Customizing Visual Components List Table Screen Widgets

WordPress System Undercover Constants and Globals WPDB

  • WordPress Plugin 3
  • Recap
  • Recap (2)
  • Recap (3)
  • Recap (4)
  • Recap (5)
  • Todays Topics
  • Entry Points in Plugin
  • Entry Points
  • Entry Points (2)
  • Entry Points (3)
  • Entry Points (4)
  • Menu Items
  • Where is default menu
  • Where is default menu (2)
  • Our custom menus
  • add_menu_page
  • add_submenu_page
  • derivatives
  • Shortcodes
  • Shortcodes (2)
  • Shortcodes (3)
  • Shortcodes (4)
  • Shortcodes (5)
  • Shortcodes (6)
  • Admin-post
  • Admin-post (2)
  • Admin-post (3)
  • AJAX
  • Redirect
  • Redirect (2)
  • (de)activation uninstall
  • Summary
  • I know you want to do something
  • Slide 35
  • Source code explained
  • 10 minutes break
  • Managing Your Own Contents
  • Wow there are too many things about posts
  • For today just focuse on custom post type
  • Arguments are too complex
  • of course you might not want this I was just kidding
  • Custom Post
  • Custom Post Motivation
  • Custom Post Motivation (2)
  • Custom Post Motivation (3)
  • Built-in Custom Post Types
  • register_post_type
  • register_post_type (2)
  • register_post_type $post_type
  • register_post_type $args
  • register_post_type $args (2)
  • register_post_type $args (3)
  • register_post_type $args (4)
  • register_post_type $args (5)
  • register_post_type $args (6)
  • register_post_type $args (7)
  • register_post_type $args (8)
  • register_post_type $args (9)
  • register_post_type $args (10)
  • register_post_type $args (11)
  • register_post_type $args (12)
  • register_post_type $args (13)
  • register_post_type $args (14)
  • register_post_type $args (15)
  • Too exhaustive but worth it
  • Practice Custom Post
  • Next Week
Page 2: WordPress plugin #3

Recap

Hooks in Nutshell Hook is an event Plugin is hook-driven Task separation

o Changing cores workflow actiono Modifying contents filtero In fact action and filter are the same

Recap

Hooks in Nutshell Callback function utility You can define your own hooks There are many predefined hooks

Recap

Datbase Nutshell Parent-meta strategy

o Flexiblilityo Extendibleo But can experience some defects

Meta key meta valueo Hash-like storage

Recap

Database Nutshell Term taxonomy

o Term a wordo Taxonomy a classification of words

There are some pre-defined terms and taxonomieso category (hierarchical) post_tag (flat)

Recap

Todays Topics

1Entry Points in Plugina Menub Shortcodesc Admin Postd Ajaxe Redirectf activation deactivation uninstall

2Managing Your Own Contentsa All About Custom Posts

Entry Points in Plugin

Entry Points

Plugins run on the server sideServer only responds when it is requested

Requested moment rarr entry point

Entry Points

Q When the server is requestedA It is when client access via a URL

Q Why a URL is usedA To define a resource output to clientA To receive data input from client

Entry Points

Q Output FormA Whatever

Images audio video html documents

Q Input formA Generally submitting forms

via GETPOST method

Entry Points

There are some special entry points left for plugins

Menu items Shortcodes Admin post AJAX Redirecting Activation deactivation uninstall

Menu Items

Callback from admin menu clicking

add_menu_page()add_submenu_page()

remove_menu_page()remove_submenu_page()

Where is default menu

wp-adminmenu-headerphp

ltul id=adminmenugtltphp_wp_menu_output( $menu $submenu )

function _wp_menu_output( $menu $submenu $submenu_as_parent = true )

here menus are printed in html

Where is default menu

wp-adminmenuphp (adminphp includes it)wp-amdinincludesmenuphp

builds administrative menus

global $menu $submenu stores menu information

Our custom menus

wp-adminincludesmenuphp

do_action( admin_menu )

Menu API are defined in wp-adminincludespluginphp

add_menu_page

function add_menu_page( $page_title $menu_title $capability $menu_slug $function = $icon_url = $position = null )

$new_menu = array( $menu_title $capability $menu_slug $page_title menu-top $icon_class $hookname $hookname $icon_url )

if ( null === $position ) $menu[] = $new_menuelse $menu[$position] = $new_menu

add_submenu_page

function add_submenu_page( $parent_slug $page_title $menu_title $capability $menu_slug $function = ) $submenu[$parent_slug][] = array ( $menu_title $capability $menu_slug $page_title )

derivatives

add_dashboard_page() add_posts_page() add_media_page() add_pages_page() add_comments_page() add_theme_page() add_plugins_page() add_users_page() add_management_page() add_options_page()

Shortcodes

What is shortcodeA magic word in post content that is replaced by some process defined in plugin or themes in runtime

Good for displaying complex dynamic contents

Shortcodes

Sample[gallery id=123 size=medium][gallery]

or

[caption]My Caption[caption] enclosed form

Shortcodes

add_shortcode()

$shortcode_tags = array()function add_shortcode($tag $func) global $shortcode_tags

if ( is_callable($func) ) $shortcode_tags[$tag] = $func

Shortcodes

function do_shortcode($content) global $shortcode_tags

if ( false === strpos( $content [ ) ) return $content

if (empty($shortcode_tags) || is_array($shortcode_tags)) return $content

$pattern = get_shortcode_regex() return preg_replace_callback( $patterns do_shortcode_tag $content )

Shortcodes

function do_shortcode_tag( $m )

if ( isset( $m[5] ) ) enclosing tag - extra parameter return $m[1] call_user_func( $shortcode_tags[$tag] $attr $m[5] $tag ) $m[6] else self-closing tag return $m[1] call_user_func( $shortcode_tags[$tag] $attr null $tag ) $m[6]

Shortcodes

callback params $attrs attributes $content enclosed tags text $tag shortcode tag itself

Admin-post

Data from clientsProcessing requests

You can just process requests in your own page because $_REQUEST $_GET $_POST is global

Admin-post

But in your own handlerYou cannot use WP core functionsYou cannot authenticate

Do not reinvent the wheelSo there is admin-postphp

Admin-post

wp-adminadmin-postphpdefine amp include minimal settingsand do_action

$action = empty( $_REQUEST[action] ) $_REQUEST[action]

admin_post_nopriv admin_post_nopriv_$actionadmin_post admin_post_$action

finish using die() in callback function

AJAX

Very similar to admin-post but DOING_AJAX is defineddefine( DOING_AJAX true )

also use die() in callback function

if ( is_user_logged_in() ) do_action( wp_ajax_ $_REQUEST[action] ) else do_action( wp_ajax_nopriv_ $_REQUEST[action] ) Default statusdie( 0 )

Redirect

You can generate custom page in plugin by using template_redirect action

function my_page_template_redirect() if( is_page( goodies ) ampamp is_user_logged_in() )

wp_redirect( home_url( signup ) ) exit()

add_action( template_redirect my_page_template_redirect )

Redirect

You can generate web pages on-the-fly by utilizing these 3 hooks rewrite rule query parsing redirect

Detailed instructions later

(de)activation uninstall

register_activation_hook($file $cb)register_deactivation_hook($file $cb)register_uninstall_hook($file $cb)

$file full path of plugin file$cb callback function

callbacks should be SILENT No echo please

Summary

menu items shortcodes admin post ajax template redirects and (de)activation- uninstall hooks are good initial entry pointso It is a good strategy to find these

hooks in plugins first and dissect their codes from those points

I know you want to do something

You understand hook conceptYou know database detail

Now you know entry points

Definitely you wanna make something

Visit http[ip]practice and download entry-pointsphp

소스코드 http[ip]source-codes1 어드민 화면에 메뉴 추가2 쇼트코드 추가3 메뉴에서 admin post 전송4 메뉴에서 ajax 전송5redirect 테스트

ltauthorgt 부분은 자신의 이름으로 일괄변경하고 적절히 콜백 함수를 정의해 주세요

Source code explained

10 minutes break

Managing Your Own Contents

Wow there are too many things about posts

For today just focuse oncustom post type

Arguments are too complex

Just use Types or Pods pluginThats all problem solved

Yeah

of course you might not want this I was just kidding

Custom Post

You want to manage your own contentsThats why custom post is

Music collections Online store Event calendar Book data Photo portfolio

Custom Post Motivation

Well with just one type post and you may define many categories and use them to organize all contents

JUST ONE TYPE POSTMANY CATEGORIES

portfolio calendar music db

Custom Post Motivation

But you might feel that some post types should be hidden from some users even might be excluded from search may be only for private use may have very complex taxonomies

so that it should have its own territory

can be accessible from their own URL rules

Custom Post Motivation

Why re-invent wheel again

By extending built-in post type systemyou can REUSE whole facilities related to posts easily

UI and all thing about managing

Built-in Custom Post Types

wp-includespostphp (included in wp-settingsphp)function create_initial_post_types()

register_post_type( post array( register_post_type( page array( register_post_type( attachment array( register_post_type( revision array( register_post_type( nav_menu_item array( register_post_status( publish array(

register_post_type

ltphp register_post_type( $post_type $args ) gt

$arg is very complex

But I think it should be explained in detail Actually you cannot avoid it because eventuall all post type plugins will use that function too

Those plugins also have diffcult UIs too

register_post_type

Lets take a look how Types and Pods create their custom posts

They have easy (really) UI and provide better functionaliy but you can see horribly many options there

register_post_type $post_type

Up to 20 characters Only lowercase and numbers

register_post_type $args

publicvisible to authors

true impliesexclude_from_search falsepublicly_queryable show_in_nav_manues show_ui

false impliesexclude_from_search true publicly_queryable falseshow_in_nav_manues false show_ui false

register_post_type $args

labelplural descriptive name

egMusic CollectionsMostly localized text

register_post_type $args

labels more specific text labelsnamesigular_namemenu_namename_admin_barall_itemsadd_newadd_new_itemedit_itemview_itemsearch_items

search_itemsnot_foundnot_found in trashparent_item_colon

register_post_type $args

descriptionsummary of this post type

register_post_type $args

exclude_from_searchdo not search this post typetry S=beatbles

register_post_type $args

publicly_queryablecan use query

eg) post_type=music_collection

register_post_type $args

show_uidisplay default UI

register_post_type $args

show_in_nav_menusshow in navigation menus

be careful publicly_queryablemust be true

register_post_type $args

show_in_menushow admin_menu show_ui must be trueJust showing menutrue false else some strings

(toolsphp editphp)

altough it is falseyou can access URLS likewp-admineditphppost_type=music_collection(show_ui must be true)

register_post_type $args

show_in_admin_baravailable in admin bar

menu_postiondefault below comments

menu_iconsee dashicons

register_post_type $args

capability_typestring or array to build capabilites

in our exampeedit_music_collectionsedit_others_music_collections

publish_music_collectionsread_private_music_collections

register_post_type $args

capabilitiesto give specific names to each capability

map_meta_capif true default meta capability will be added

and then your role or account need capabilities

register_post_type $args

hierarchicalpost type can be hierarchicalthis is for page-styles

register_post_type $args

query_varto query posts query_var=slug

rewriteto use pretty permalinks

has_archiveEnables post type archive

register_post_type $args

permalink_epmaskrewrite endpoint bitmask

can_exporttrue makes the post can be exported

Too exhaustive but worth it

Practice Custom Post

Create custom-plugin-ltauthorgtphpCreate a simple custom post

Display admin menuHide admin_barWrite your post Any content is OK Include at least one meta field

Next Week

Customizing Visual Components List Table Screen Widgets

WordPress System Undercover Constants and Globals WPDB

  • WordPress Plugin 3
  • Recap
  • Recap (2)
  • Recap (3)
  • Recap (4)
  • Recap (5)
  • Todays Topics
  • Entry Points in Plugin
  • Entry Points
  • Entry Points (2)
  • Entry Points (3)
  • Entry Points (4)
  • Menu Items
  • Where is default menu
  • Where is default menu (2)
  • Our custom menus
  • add_menu_page
  • add_submenu_page
  • derivatives
  • Shortcodes
  • Shortcodes (2)
  • Shortcodes (3)
  • Shortcodes (4)
  • Shortcodes (5)
  • Shortcodes (6)
  • Admin-post
  • Admin-post (2)
  • Admin-post (3)
  • AJAX
  • Redirect
  • Redirect (2)
  • (de)activation uninstall
  • Summary
  • I know you want to do something
  • Slide 35
  • Source code explained
  • 10 minutes break
  • Managing Your Own Contents
  • Wow there are too many things about posts
  • For today just focuse on custom post type
  • Arguments are too complex
  • of course you might not want this I was just kidding
  • Custom Post
  • Custom Post Motivation
  • Custom Post Motivation (2)
  • Custom Post Motivation (3)
  • Built-in Custom Post Types
  • register_post_type
  • register_post_type (2)
  • register_post_type $post_type
  • register_post_type $args
  • register_post_type $args (2)
  • register_post_type $args (3)
  • register_post_type $args (4)
  • register_post_type $args (5)
  • register_post_type $args (6)
  • register_post_type $args (7)
  • register_post_type $args (8)
  • register_post_type $args (9)
  • register_post_type $args (10)
  • register_post_type $args (11)
  • register_post_type $args (12)
  • register_post_type $args (13)
  • register_post_type $args (14)
  • register_post_type $args (15)
  • Too exhaustive but worth it
  • Practice Custom Post
  • Next Week
Page 3: WordPress plugin #3

Recap

Hooks in Nutshell Callback function utility You can define your own hooks There are many predefined hooks

Recap

Datbase Nutshell Parent-meta strategy

o Flexiblilityo Extendibleo But can experience some defects

Meta key meta valueo Hash-like storage

Recap

Database Nutshell Term taxonomy

o Term a wordo Taxonomy a classification of words

There are some pre-defined terms and taxonomieso category (hierarchical) post_tag (flat)

Recap

Todays Topics

1Entry Points in Plugina Menub Shortcodesc Admin Postd Ajaxe Redirectf activation deactivation uninstall

2Managing Your Own Contentsa All About Custom Posts

Entry Points in Plugin

Entry Points

Plugins run on the server sideServer only responds when it is requested

Requested moment rarr entry point

Entry Points

Q When the server is requestedA It is when client access via a URL

Q Why a URL is usedA To define a resource output to clientA To receive data input from client

Entry Points

Q Output FormA Whatever

Images audio video html documents

Q Input formA Generally submitting forms

via GETPOST method

Entry Points

There are some special entry points left for plugins

Menu items Shortcodes Admin post AJAX Redirecting Activation deactivation uninstall

Menu Items

Callback from admin menu clicking

add_menu_page()add_submenu_page()

remove_menu_page()remove_submenu_page()

Where is default menu

wp-adminmenu-headerphp

ltul id=adminmenugtltphp_wp_menu_output( $menu $submenu )

function _wp_menu_output( $menu $submenu $submenu_as_parent = true )

here menus are printed in html

Where is default menu

wp-adminmenuphp (adminphp includes it)wp-amdinincludesmenuphp

builds administrative menus

global $menu $submenu stores menu information

Our custom menus

wp-adminincludesmenuphp

do_action( admin_menu )

Menu API are defined in wp-adminincludespluginphp

add_menu_page

function add_menu_page( $page_title $menu_title $capability $menu_slug $function = $icon_url = $position = null )

$new_menu = array( $menu_title $capability $menu_slug $page_title menu-top $icon_class $hookname $hookname $icon_url )

if ( null === $position ) $menu[] = $new_menuelse $menu[$position] = $new_menu

add_submenu_page

function add_submenu_page( $parent_slug $page_title $menu_title $capability $menu_slug $function = ) $submenu[$parent_slug][] = array ( $menu_title $capability $menu_slug $page_title )

derivatives

add_dashboard_page() add_posts_page() add_media_page() add_pages_page() add_comments_page() add_theme_page() add_plugins_page() add_users_page() add_management_page() add_options_page()

Shortcodes

What is shortcodeA magic word in post content that is replaced by some process defined in plugin or themes in runtime

Good for displaying complex dynamic contents

Shortcodes

Sample[gallery id=123 size=medium][gallery]

or

[caption]My Caption[caption] enclosed form

Shortcodes

add_shortcode()

$shortcode_tags = array()function add_shortcode($tag $func) global $shortcode_tags

if ( is_callable($func) ) $shortcode_tags[$tag] = $func

Shortcodes

function do_shortcode($content) global $shortcode_tags

if ( false === strpos( $content [ ) ) return $content

if (empty($shortcode_tags) || is_array($shortcode_tags)) return $content

$pattern = get_shortcode_regex() return preg_replace_callback( $patterns do_shortcode_tag $content )

Shortcodes

function do_shortcode_tag( $m )

if ( isset( $m[5] ) ) enclosing tag - extra parameter return $m[1] call_user_func( $shortcode_tags[$tag] $attr $m[5] $tag ) $m[6] else self-closing tag return $m[1] call_user_func( $shortcode_tags[$tag] $attr null $tag ) $m[6]

Shortcodes

callback params $attrs attributes $content enclosed tags text $tag shortcode tag itself

Admin-post

Data from clientsProcessing requests

You can just process requests in your own page because $_REQUEST $_GET $_POST is global

Admin-post

But in your own handlerYou cannot use WP core functionsYou cannot authenticate

Do not reinvent the wheelSo there is admin-postphp

Admin-post

wp-adminadmin-postphpdefine amp include minimal settingsand do_action

$action = empty( $_REQUEST[action] ) $_REQUEST[action]

admin_post_nopriv admin_post_nopriv_$actionadmin_post admin_post_$action

finish using die() in callback function

AJAX

Very similar to admin-post but DOING_AJAX is defineddefine( DOING_AJAX true )

also use die() in callback function

if ( is_user_logged_in() ) do_action( wp_ajax_ $_REQUEST[action] ) else do_action( wp_ajax_nopriv_ $_REQUEST[action] ) Default statusdie( 0 )

Redirect

You can generate custom page in plugin by using template_redirect action

function my_page_template_redirect() if( is_page( goodies ) ampamp is_user_logged_in() )

wp_redirect( home_url( signup ) ) exit()

add_action( template_redirect my_page_template_redirect )

Redirect

You can generate web pages on-the-fly by utilizing these 3 hooks rewrite rule query parsing redirect

Detailed instructions later

(de)activation uninstall

register_activation_hook($file $cb)register_deactivation_hook($file $cb)register_uninstall_hook($file $cb)

$file full path of plugin file$cb callback function

callbacks should be SILENT No echo please

Summary

menu items shortcodes admin post ajax template redirects and (de)activation- uninstall hooks are good initial entry pointso It is a good strategy to find these

hooks in plugins first and dissect their codes from those points

I know you want to do something

You understand hook conceptYou know database detail

Now you know entry points

Definitely you wanna make something

Visit http[ip]practice and download entry-pointsphp

소스코드 http[ip]source-codes1 어드민 화면에 메뉴 추가2 쇼트코드 추가3 메뉴에서 admin post 전송4 메뉴에서 ajax 전송5redirect 테스트

ltauthorgt 부분은 자신의 이름으로 일괄변경하고 적절히 콜백 함수를 정의해 주세요

Source code explained

10 minutes break

Managing Your Own Contents

Wow there are too many things about posts

For today just focuse oncustom post type

Arguments are too complex

Just use Types or Pods pluginThats all problem solved

Yeah

of course you might not want this I was just kidding

Custom Post

You want to manage your own contentsThats why custom post is

Music collections Online store Event calendar Book data Photo portfolio

Custom Post Motivation

Well with just one type post and you may define many categories and use them to organize all contents

JUST ONE TYPE POSTMANY CATEGORIES

portfolio calendar music db

Custom Post Motivation

But you might feel that some post types should be hidden from some users even might be excluded from search may be only for private use may have very complex taxonomies

so that it should have its own territory

can be accessible from their own URL rules

Custom Post Motivation

Why re-invent wheel again

By extending built-in post type systemyou can REUSE whole facilities related to posts easily

UI and all thing about managing

Built-in Custom Post Types

wp-includespostphp (included in wp-settingsphp)function create_initial_post_types()

register_post_type( post array( register_post_type( page array( register_post_type( attachment array( register_post_type( revision array( register_post_type( nav_menu_item array( register_post_status( publish array(

register_post_type

ltphp register_post_type( $post_type $args ) gt

$arg is very complex

But I think it should be explained in detail Actually you cannot avoid it because eventuall all post type plugins will use that function too

Those plugins also have diffcult UIs too

register_post_type

Lets take a look how Types and Pods create their custom posts

They have easy (really) UI and provide better functionaliy but you can see horribly many options there

register_post_type $post_type

Up to 20 characters Only lowercase and numbers

register_post_type $args

publicvisible to authors

true impliesexclude_from_search falsepublicly_queryable show_in_nav_manues show_ui

false impliesexclude_from_search true publicly_queryable falseshow_in_nav_manues false show_ui false

register_post_type $args

labelplural descriptive name

egMusic CollectionsMostly localized text

register_post_type $args

labels more specific text labelsnamesigular_namemenu_namename_admin_barall_itemsadd_newadd_new_itemedit_itemview_itemsearch_items

search_itemsnot_foundnot_found in trashparent_item_colon

register_post_type $args

descriptionsummary of this post type

register_post_type $args

exclude_from_searchdo not search this post typetry S=beatbles

register_post_type $args

publicly_queryablecan use query

eg) post_type=music_collection

register_post_type $args

show_uidisplay default UI

register_post_type $args

show_in_nav_menusshow in navigation menus

be careful publicly_queryablemust be true

register_post_type $args

show_in_menushow admin_menu show_ui must be trueJust showing menutrue false else some strings

(toolsphp editphp)

altough it is falseyou can access URLS likewp-admineditphppost_type=music_collection(show_ui must be true)

register_post_type $args

show_in_admin_baravailable in admin bar

menu_postiondefault below comments

menu_iconsee dashicons

register_post_type $args

capability_typestring or array to build capabilites

in our exampeedit_music_collectionsedit_others_music_collections

publish_music_collectionsread_private_music_collections

register_post_type $args

capabilitiesto give specific names to each capability

map_meta_capif true default meta capability will be added

and then your role or account need capabilities

register_post_type $args

hierarchicalpost type can be hierarchicalthis is for page-styles

register_post_type $args

query_varto query posts query_var=slug

rewriteto use pretty permalinks

has_archiveEnables post type archive

register_post_type $args

permalink_epmaskrewrite endpoint bitmask

can_exporttrue makes the post can be exported

Too exhaustive but worth it

Practice Custom Post

Create custom-plugin-ltauthorgtphpCreate a simple custom post

Display admin menuHide admin_barWrite your post Any content is OK Include at least one meta field

Next Week

Customizing Visual Components List Table Screen Widgets

WordPress System Undercover Constants and Globals WPDB

  • WordPress Plugin 3
  • Recap
  • Recap (2)
  • Recap (3)
  • Recap (4)
  • Recap (5)
  • Todays Topics
  • Entry Points in Plugin
  • Entry Points
  • Entry Points (2)
  • Entry Points (3)
  • Entry Points (4)
  • Menu Items
  • Where is default menu
  • Where is default menu (2)
  • Our custom menus
  • add_menu_page
  • add_submenu_page
  • derivatives
  • Shortcodes
  • Shortcodes (2)
  • Shortcodes (3)
  • Shortcodes (4)
  • Shortcodes (5)
  • Shortcodes (6)
  • Admin-post
  • Admin-post (2)
  • Admin-post (3)
  • AJAX
  • Redirect
  • Redirect (2)
  • (de)activation uninstall
  • Summary
  • I know you want to do something
  • Slide 35
  • Source code explained
  • 10 minutes break
  • Managing Your Own Contents
  • Wow there are too many things about posts
  • For today just focuse on custom post type
  • Arguments are too complex
  • of course you might not want this I was just kidding
  • Custom Post
  • Custom Post Motivation
  • Custom Post Motivation (2)
  • Custom Post Motivation (3)
  • Built-in Custom Post Types
  • register_post_type
  • register_post_type (2)
  • register_post_type $post_type
  • register_post_type $args
  • register_post_type $args (2)
  • register_post_type $args (3)
  • register_post_type $args (4)
  • register_post_type $args (5)
  • register_post_type $args (6)
  • register_post_type $args (7)
  • register_post_type $args (8)
  • register_post_type $args (9)
  • register_post_type $args (10)
  • register_post_type $args (11)
  • register_post_type $args (12)
  • register_post_type $args (13)
  • register_post_type $args (14)
  • register_post_type $args (15)
  • Too exhaustive but worth it
  • Practice Custom Post
  • Next Week
Page 4: WordPress plugin #3

Recap

Datbase Nutshell Parent-meta strategy

o Flexiblilityo Extendibleo But can experience some defects

Meta key meta valueo Hash-like storage

Recap

Database Nutshell Term taxonomy

o Term a wordo Taxonomy a classification of words

There are some pre-defined terms and taxonomieso category (hierarchical) post_tag (flat)

Recap

Todays Topics

1Entry Points in Plugina Menub Shortcodesc Admin Postd Ajaxe Redirectf activation deactivation uninstall

2Managing Your Own Contentsa All About Custom Posts

Entry Points in Plugin

Entry Points

Plugins run on the server sideServer only responds when it is requested

Requested moment rarr entry point

Entry Points

Q When the server is requestedA It is when client access via a URL

Q Why a URL is usedA To define a resource output to clientA To receive data input from client

Entry Points

Q Output FormA Whatever

Images audio video html documents

Q Input formA Generally submitting forms

via GETPOST method

Entry Points

There are some special entry points left for plugins

Menu items Shortcodes Admin post AJAX Redirecting Activation deactivation uninstall

Menu Items

Callback from admin menu clicking

add_menu_page()add_submenu_page()

remove_menu_page()remove_submenu_page()

Where is default menu

wp-adminmenu-headerphp

ltul id=adminmenugtltphp_wp_menu_output( $menu $submenu )

function _wp_menu_output( $menu $submenu $submenu_as_parent = true )

here menus are printed in html

Where is default menu

wp-adminmenuphp (adminphp includes it)wp-amdinincludesmenuphp

builds administrative menus

global $menu $submenu stores menu information

Our custom menus

wp-adminincludesmenuphp

do_action( admin_menu )

Menu API are defined in wp-adminincludespluginphp

add_menu_page

function add_menu_page( $page_title $menu_title $capability $menu_slug $function = $icon_url = $position = null )

$new_menu = array( $menu_title $capability $menu_slug $page_title menu-top $icon_class $hookname $hookname $icon_url )

if ( null === $position ) $menu[] = $new_menuelse $menu[$position] = $new_menu

add_submenu_page

function add_submenu_page( $parent_slug $page_title $menu_title $capability $menu_slug $function = ) $submenu[$parent_slug][] = array ( $menu_title $capability $menu_slug $page_title )

derivatives

add_dashboard_page() add_posts_page() add_media_page() add_pages_page() add_comments_page() add_theme_page() add_plugins_page() add_users_page() add_management_page() add_options_page()

Shortcodes

What is shortcodeA magic word in post content that is replaced by some process defined in plugin or themes in runtime

Good for displaying complex dynamic contents

Shortcodes

Sample[gallery id=123 size=medium][gallery]

or

[caption]My Caption[caption] enclosed form

Shortcodes

add_shortcode()

$shortcode_tags = array()function add_shortcode($tag $func) global $shortcode_tags

if ( is_callable($func) ) $shortcode_tags[$tag] = $func

Shortcodes

function do_shortcode($content) global $shortcode_tags

if ( false === strpos( $content [ ) ) return $content

if (empty($shortcode_tags) || is_array($shortcode_tags)) return $content

$pattern = get_shortcode_regex() return preg_replace_callback( $patterns do_shortcode_tag $content )

Shortcodes

function do_shortcode_tag( $m )

if ( isset( $m[5] ) ) enclosing tag - extra parameter return $m[1] call_user_func( $shortcode_tags[$tag] $attr $m[5] $tag ) $m[6] else self-closing tag return $m[1] call_user_func( $shortcode_tags[$tag] $attr null $tag ) $m[6]

Shortcodes

callback params $attrs attributes $content enclosed tags text $tag shortcode tag itself

Admin-post

Data from clientsProcessing requests

You can just process requests in your own page because $_REQUEST $_GET $_POST is global

Admin-post

But in your own handlerYou cannot use WP core functionsYou cannot authenticate

Do not reinvent the wheelSo there is admin-postphp

Admin-post

wp-adminadmin-postphpdefine amp include minimal settingsand do_action

$action = empty( $_REQUEST[action] ) $_REQUEST[action]

admin_post_nopriv admin_post_nopriv_$actionadmin_post admin_post_$action

finish using die() in callback function

AJAX

Very similar to admin-post but DOING_AJAX is defineddefine( DOING_AJAX true )

also use die() in callback function

if ( is_user_logged_in() ) do_action( wp_ajax_ $_REQUEST[action] ) else do_action( wp_ajax_nopriv_ $_REQUEST[action] ) Default statusdie( 0 )

Redirect

You can generate custom page in plugin by using template_redirect action

function my_page_template_redirect() if( is_page( goodies ) ampamp is_user_logged_in() )

wp_redirect( home_url( signup ) ) exit()

add_action( template_redirect my_page_template_redirect )

Redirect

You can generate web pages on-the-fly by utilizing these 3 hooks rewrite rule query parsing redirect

Detailed instructions later

(de)activation uninstall

register_activation_hook($file $cb)register_deactivation_hook($file $cb)register_uninstall_hook($file $cb)

$file full path of plugin file$cb callback function

callbacks should be SILENT No echo please

Summary

menu items shortcodes admin post ajax template redirects and (de)activation- uninstall hooks are good initial entry pointso It is a good strategy to find these

hooks in plugins first and dissect their codes from those points

I know you want to do something

You understand hook conceptYou know database detail

Now you know entry points

Definitely you wanna make something

Visit http[ip]practice and download entry-pointsphp

소스코드 http[ip]source-codes1 어드민 화면에 메뉴 추가2 쇼트코드 추가3 메뉴에서 admin post 전송4 메뉴에서 ajax 전송5redirect 테스트

ltauthorgt 부분은 자신의 이름으로 일괄변경하고 적절히 콜백 함수를 정의해 주세요

Source code explained

10 minutes break

Managing Your Own Contents

Wow there are too many things about posts

For today just focuse oncustom post type

Arguments are too complex

Just use Types or Pods pluginThats all problem solved

Yeah

of course you might not want this I was just kidding

Custom Post

You want to manage your own contentsThats why custom post is

Music collections Online store Event calendar Book data Photo portfolio

Custom Post Motivation

Well with just one type post and you may define many categories and use them to organize all contents

JUST ONE TYPE POSTMANY CATEGORIES

portfolio calendar music db

Custom Post Motivation

But you might feel that some post types should be hidden from some users even might be excluded from search may be only for private use may have very complex taxonomies

so that it should have its own territory

can be accessible from their own URL rules

Custom Post Motivation

Why re-invent wheel again

By extending built-in post type systemyou can REUSE whole facilities related to posts easily

UI and all thing about managing

Built-in Custom Post Types

wp-includespostphp (included in wp-settingsphp)function create_initial_post_types()

register_post_type( post array( register_post_type( page array( register_post_type( attachment array( register_post_type( revision array( register_post_type( nav_menu_item array( register_post_status( publish array(

register_post_type

ltphp register_post_type( $post_type $args ) gt

$arg is very complex

But I think it should be explained in detail Actually you cannot avoid it because eventuall all post type plugins will use that function too

Those plugins also have diffcult UIs too

register_post_type

Lets take a look how Types and Pods create their custom posts

They have easy (really) UI and provide better functionaliy but you can see horribly many options there

register_post_type $post_type

Up to 20 characters Only lowercase and numbers

register_post_type $args

publicvisible to authors

true impliesexclude_from_search falsepublicly_queryable show_in_nav_manues show_ui

false impliesexclude_from_search true publicly_queryable falseshow_in_nav_manues false show_ui false

register_post_type $args

labelplural descriptive name

egMusic CollectionsMostly localized text

register_post_type $args

labels more specific text labelsnamesigular_namemenu_namename_admin_barall_itemsadd_newadd_new_itemedit_itemview_itemsearch_items

search_itemsnot_foundnot_found in trashparent_item_colon

register_post_type $args

descriptionsummary of this post type

register_post_type $args

exclude_from_searchdo not search this post typetry S=beatbles

register_post_type $args

publicly_queryablecan use query

eg) post_type=music_collection

register_post_type $args

show_uidisplay default UI

register_post_type $args

show_in_nav_menusshow in navigation menus

be careful publicly_queryablemust be true

register_post_type $args

show_in_menushow admin_menu show_ui must be trueJust showing menutrue false else some strings

(toolsphp editphp)

altough it is falseyou can access URLS likewp-admineditphppost_type=music_collection(show_ui must be true)

register_post_type $args

show_in_admin_baravailable in admin bar

menu_postiondefault below comments

menu_iconsee dashicons

register_post_type $args

capability_typestring or array to build capabilites

in our exampeedit_music_collectionsedit_others_music_collections

publish_music_collectionsread_private_music_collections

register_post_type $args

capabilitiesto give specific names to each capability

map_meta_capif true default meta capability will be added

and then your role or account need capabilities

register_post_type $args

hierarchicalpost type can be hierarchicalthis is for page-styles

register_post_type $args

query_varto query posts query_var=slug

rewriteto use pretty permalinks

has_archiveEnables post type archive

register_post_type $args

permalink_epmaskrewrite endpoint bitmask

can_exporttrue makes the post can be exported

Too exhaustive but worth it

Practice Custom Post

Create custom-plugin-ltauthorgtphpCreate a simple custom post

Display admin menuHide admin_barWrite your post Any content is OK Include at least one meta field

Next Week

Customizing Visual Components List Table Screen Widgets

WordPress System Undercover Constants and Globals WPDB

  • WordPress Plugin 3
  • Recap
  • Recap (2)
  • Recap (3)
  • Recap (4)
  • Recap (5)
  • Todays Topics
  • Entry Points in Plugin
  • Entry Points
  • Entry Points (2)
  • Entry Points (3)
  • Entry Points (4)
  • Menu Items
  • Where is default menu
  • Where is default menu (2)
  • Our custom menus
  • add_menu_page
  • add_submenu_page
  • derivatives
  • Shortcodes
  • Shortcodes (2)
  • Shortcodes (3)
  • Shortcodes (4)
  • Shortcodes (5)
  • Shortcodes (6)
  • Admin-post
  • Admin-post (2)
  • Admin-post (3)
  • AJAX
  • Redirect
  • Redirect (2)
  • (de)activation uninstall
  • Summary
  • I know you want to do something
  • Slide 35
  • Source code explained
  • 10 minutes break
  • Managing Your Own Contents
  • Wow there are too many things about posts
  • For today just focuse on custom post type
  • Arguments are too complex
  • of course you might not want this I was just kidding
  • Custom Post
  • Custom Post Motivation
  • Custom Post Motivation (2)
  • Custom Post Motivation (3)
  • Built-in Custom Post Types
  • register_post_type
  • register_post_type (2)
  • register_post_type $post_type
  • register_post_type $args
  • register_post_type $args (2)
  • register_post_type $args (3)
  • register_post_type $args (4)
  • register_post_type $args (5)
  • register_post_type $args (6)
  • register_post_type $args (7)
  • register_post_type $args (8)
  • register_post_type $args (9)
  • register_post_type $args (10)
  • register_post_type $args (11)
  • register_post_type $args (12)
  • register_post_type $args (13)
  • register_post_type $args (14)
  • register_post_type $args (15)
  • Too exhaustive but worth it
  • Practice Custom Post
  • Next Week
Page 5: WordPress plugin #3

Recap

Database Nutshell Term taxonomy

o Term a wordo Taxonomy a classification of words

There are some pre-defined terms and taxonomieso category (hierarchical) post_tag (flat)

Recap

Todays Topics

1Entry Points in Plugina Menub Shortcodesc Admin Postd Ajaxe Redirectf activation deactivation uninstall

2Managing Your Own Contentsa All About Custom Posts

Entry Points in Plugin

Entry Points

Plugins run on the server sideServer only responds when it is requested

Requested moment rarr entry point

Entry Points

Q When the server is requestedA It is when client access via a URL

Q Why a URL is usedA To define a resource output to clientA To receive data input from client

Entry Points

Q Output FormA Whatever

Images audio video html documents

Q Input formA Generally submitting forms

via GETPOST method

Entry Points

There are some special entry points left for plugins

Menu items Shortcodes Admin post AJAX Redirecting Activation deactivation uninstall

Menu Items

Callback from admin menu clicking

add_menu_page()add_submenu_page()

remove_menu_page()remove_submenu_page()

Where is default menu

wp-adminmenu-headerphp

ltul id=adminmenugtltphp_wp_menu_output( $menu $submenu )

function _wp_menu_output( $menu $submenu $submenu_as_parent = true )

here menus are printed in html

Where is default menu

wp-adminmenuphp (adminphp includes it)wp-amdinincludesmenuphp

builds administrative menus

global $menu $submenu stores menu information

Our custom menus

wp-adminincludesmenuphp

do_action( admin_menu )

Menu API are defined in wp-adminincludespluginphp

add_menu_page

function add_menu_page( $page_title $menu_title $capability $menu_slug $function = $icon_url = $position = null )

$new_menu = array( $menu_title $capability $menu_slug $page_title menu-top $icon_class $hookname $hookname $icon_url )

if ( null === $position ) $menu[] = $new_menuelse $menu[$position] = $new_menu

add_submenu_page

function add_submenu_page( $parent_slug $page_title $menu_title $capability $menu_slug $function = ) $submenu[$parent_slug][] = array ( $menu_title $capability $menu_slug $page_title )

derivatives

add_dashboard_page() add_posts_page() add_media_page() add_pages_page() add_comments_page() add_theme_page() add_plugins_page() add_users_page() add_management_page() add_options_page()

Shortcodes

What is shortcodeA magic word in post content that is replaced by some process defined in plugin or themes in runtime

Good for displaying complex dynamic contents

Shortcodes

Sample[gallery id=123 size=medium][gallery]

or

[caption]My Caption[caption] enclosed form

Shortcodes

add_shortcode()

$shortcode_tags = array()function add_shortcode($tag $func) global $shortcode_tags

if ( is_callable($func) ) $shortcode_tags[$tag] = $func

Shortcodes

function do_shortcode($content) global $shortcode_tags

if ( false === strpos( $content [ ) ) return $content

if (empty($shortcode_tags) || is_array($shortcode_tags)) return $content

$pattern = get_shortcode_regex() return preg_replace_callback( $patterns do_shortcode_tag $content )

Shortcodes

function do_shortcode_tag( $m )

if ( isset( $m[5] ) ) enclosing tag - extra parameter return $m[1] call_user_func( $shortcode_tags[$tag] $attr $m[5] $tag ) $m[6] else self-closing tag return $m[1] call_user_func( $shortcode_tags[$tag] $attr null $tag ) $m[6]

Shortcodes

callback params $attrs attributes $content enclosed tags text $tag shortcode tag itself

Admin-post

Data from clientsProcessing requests

You can just process requests in your own page because $_REQUEST $_GET $_POST is global

Admin-post

But in your own handlerYou cannot use WP core functionsYou cannot authenticate

Do not reinvent the wheelSo there is admin-postphp

Admin-post

wp-adminadmin-postphpdefine amp include minimal settingsand do_action

$action = empty( $_REQUEST[action] ) $_REQUEST[action]

admin_post_nopriv admin_post_nopriv_$actionadmin_post admin_post_$action

finish using die() in callback function

AJAX

Very similar to admin-post but DOING_AJAX is defineddefine( DOING_AJAX true )

also use die() in callback function

if ( is_user_logged_in() ) do_action( wp_ajax_ $_REQUEST[action] ) else do_action( wp_ajax_nopriv_ $_REQUEST[action] ) Default statusdie( 0 )

Redirect

You can generate custom page in plugin by using template_redirect action

function my_page_template_redirect() if( is_page( goodies ) ampamp is_user_logged_in() )

wp_redirect( home_url( signup ) ) exit()

add_action( template_redirect my_page_template_redirect )

Redirect

You can generate web pages on-the-fly by utilizing these 3 hooks rewrite rule query parsing redirect

Detailed instructions later

(de)activation uninstall

register_activation_hook($file $cb)register_deactivation_hook($file $cb)register_uninstall_hook($file $cb)

$file full path of plugin file$cb callback function

callbacks should be SILENT No echo please

Summary

menu items shortcodes admin post ajax template redirects and (de)activation- uninstall hooks are good initial entry pointso It is a good strategy to find these

hooks in plugins first and dissect their codes from those points

I know you want to do something

You understand hook conceptYou know database detail

Now you know entry points

Definitely you wanna make something

Visit http[ip]practice and download entry-pointsphp

소스코드 http[ip]source-codes1 어드민 화면에 메뉴 추가2 쇼트코드 추가3 메뉴에서 admin post 전송4 메뉴에서 ajax 전송5redirect 테스트

ltauthorgt 부분은 자신의 이름으로 일괄변경하고 적절히 콜백 함수를 정의해 주세요

Source code explained

10 minutes break

Managing Your Own Contents

Wow there are too many things about posts

For today just focuse oncustom post type

Arguments are too complex

Just use Types or Pods pluginThats all problem solved

Yeah

of course you might not want this I was just kidding

Custom Post

You want to manage your own contentsThats why custom post is

Music collections Online store Event calendar Book data Photo portfolio

Custom Post Motivation

Well with just one type post and you may define many categories and use them to organize all contents

JUST ONE TYPE POSTMANY CATEGORIES

portfolio calendar music db

Custom Post Motivation

But you might feel that some post types should be hidden from some users even might be excluded from search may be only for private use may have very complex taxonomies

so that it should have its own territory

can be accessible from their own URL rules

Custom Post Motivation

Why re-invent wheel again

By extending built-in post type systemyou can REUSE whole facilities related to posts easily

UI and all thing about managing

Built-in Custom Post Types

wp-includespostphp (included in wp-settingsphp)function create_initial_post_types()

register_post_type( post array( register_post_type( page array( register_post_type( attachment array( register_post_type( revision array( register_post_type( nav_menu_item array( register_post_status( publish array(

register_post_type

ltphp register_post_type( $post_type $args ) gt

$arg is very complex

But I think it should be explained in detail Actually you cannot avoid it because eventuall all post type plugins will use that function too

Those plugins also have diffcult UIs too

register_post_type

Lets take a look how Types and Pods create their custom posts

They have easy (really) UI and provide better functionaliy but you can see horribly many options there

register_post_type $post_type

Up to 20 characters Only lowercase and numbers

register_post_type $args

publicvisible to authors

true impliesexclude_from_search falsepublicly_queryable show_in_nav_manues show_ui

false impliesexclude_from_search true publicly_queryable falseshow_in_nav_manues false show_ui false

register_post_type $args

labelplural descriptive name

egMusic CollectionsMostly localized text

register_post_type $args

labels more specific text labelsnamesigular_namemenu_namename_admin_barall_itemsadd_newadd_new_itemedit_itemview_itemsearch_items

search_itemsnot_foundnot_found in trashparent_item_colon

register_post_type $args

descriptionsummary of this post type

register_post_type $args

exclude_from_searchdo not search this post typetry S=beatbles

register_post_type $args

publicly_queryablecan use query

eg) post_type=music_collection

register_post_type $args

show_uidisplay default UI

register_post_type $args

show_in_nav_menusshow in navigation menus

be careful publicly_queryablemust be true

register_post_type $args

show_in_menushow admin_menu show_ui must be trueJust showing menutrue false else some strings

(toolsphp editphp)

altough it is falseyou can access URLS likewp-admineditphppost_type=music_collection(show_ui must be true)

register_post_type $args

show_in_admin_baravailable in admin bar

menu_postiondefault below comments

menu_iconsee dashicons

register_post_type $args

capability_typestring or array to build capabilites

in our exampeedit_music_collectionsedit_others_music_collections

publish_music_collectionsread_private_music_collections

register_post_type $args

capabilitiesto give specific names to each capability

map_meta_capif true default meta capability will be added

and then your role or account need capabilities

register_post_type $args

hierarchicalpost type can be hierarchicalthis is for page-styles

register_post_type $args

query_varto query posts query_var=slug

rewriteto use pretty permalinks

has_archiveEnables post type archive

register_post_type $args

permalink_epmaskrewrite endpoint bitmask

can_exporttrue makes the post can be exported

Too exhaustive but worth it

Practice Custom Post

Create custom-plugin-ltauthorgtphpCreate a simple custom post

Display admin menuHide admin_barWrite your post Any content is OK Include at least one meta field

Next Week

Customizing Visual Components List Table Screen Widgets

WordPress System Undercover Constants and Globals WPDB

  • WordPress Plugin 3
  • Recap
  • Recap (2)
  • Recap (3)
  • Recap (4)
  • Recap (5)
  • Todays Topics
  • Entry Points in Plugin
  • Entry Points
  • Entry Points (2)
  • Entry Points (3)
  • Entry Points (4)
  • Menu Items
  • Where is default menu
  • Where is default menu (2)
  • Our custom menus
  • add_menu_page
  • add_submenu_page
  • derivatives
  • Shortcodes
  • Shortcodes (2)
  • Shortcodes (3)
  • Shortcodes (4)
  • Shortcodes (5)
  • Shortcodes (6)
  • Admin-post
  • Admin-post (2)
  • Admin-post (3)
  • AJAX
  • Redirect
  • Redirect (2)
  • (de)activation uninstall
  • Summary
  • I know you want to do something
  • Slide 35
  • Source code explained
  • 10 minutes break
  • Managing Your Own Contents
  • Wow there are too many things about posts
  • For today just focuse on custom post type
  • Arguments are too complex
  • of course you might not want this I was just kidding
  • Custom Post
  • Custom Post Motivation
  • Custom Post Motivation (2)
  • Custom Post Motivation (3)
  • Built-in Custom Post Types
  • register_post_type
  • register_post_type (2)
  • register_post_type $post_type
  • register_post_type $args
  • register_post_type $args (2)
  • register_post_type $args (3)
  • register_post_type $args (4)
  • register_post_type $args (5)
  • register_post_type $args (6)
  • register_post_type $args (7)
  • register_post_type $args (8)
  • register_post_type $args (9)
  • register_post_type $args (10)
  • register_post_type $args (11)
  • register_post_type $args (12)
  • register_post_type $args (13)
  • register_post_type $args (14)
  • register_post_type $args (15)
  • Too exhaustive but worth it
  • Practice Custom Post
  • Next Week
Page 6: WordPress plugin #3

Recap

Todays Topics

1Entry Points in Plugina Menub Shortcodesc Admin Postd Ajaxe Redirectf activation deactivation uninstall

2Managing Your Own Contentsa All About Custom Posts

Entry Points in Plugin

Entry Points

Plugins run on the server sideServer only responds when it is requested

Requested moment rarr entry point

Entry Points

Q When the server is requestedA It is when client access via a URL

Q Why a URL is usedA To define a resource output to clientA To receive data input from client

Entry Points

Q Output FormA Whatever

Images audio video html documents

Q Input formA Generally submitting forms

via GETPOST method

Entry Points

There are some special entry points left for plugins

Menu items Shortcodes Admin post AJAX Redirecting Activation deactivation uninstall

Menu Items

Callback from admin menu clicking

add_menu_page()add_submenu_page()

remove_menu_page()remove_submenu_page()

Where is default menu

wp-adminmenu-headerphp

ltul id=adminmenugtltphp_wp_menu_output( $menu $submenu )

function _wp_menu_output( $menu $submenu $submenu_as_parent = true )

here menus are printed in html

Where is default menu

wp-adminmenuphp (adminphp includes it)wp-amdinincludesmenuphp

builds administrative menus

global $menu $submenu stores menu information

Our custom menus

wp-adminincludesmenuphp

do_action( admin_menu )

Menu API are defined in wp-adminincludespluginphp

add_menu_page

function add_menu_page( $page_title $menu_title $capability $menu_slug $function = $icon_url = $position = null )

$new_menu = array( $menu_title $capability $menu_slug $page_title menu-top $icon_class $hookname $hookname $icon_url )

if ( null === $position ) $menu[] = $new_menuelse $menu[$position] = $new_menu

add_submenu_page

function add_submenu_page( $parent_slug $page_title $menu_title $capability $menu_slug $function = ) $submenu[$parent_slug][] = array ( $menu_title $capability $menu_slug $page_title )

derivatives

add_dashboard_page() add_posts_page() add_media_page() add_pages_page() add_comments_page() add_theme_page() add_plugins_page() add_users_page() add_management_page() add_options_page()

Shortcodes

What is shortcodeA magic word in post content that is replaced by some process defined in plugin or themes in runtime

Good for displaying complex dynamic contents

Shortcodes

Sample[gallery id=123 size=medium][gallery]

or

[caption]My Caption[caption] enclosed form

Shortcodes

add_shortcode()

$shortcode_tags = array()function add_shortcode($tag $func) global $shortcode_tags

if ( is_callable($func) ) $shortcode_tags[$tag] = $func

Shortcodes

function do_shortcode($content) global $shortcode_tags

if ( false === strpos( $content [ ) ) return $content

if (empty($shortcode_tags) || is_array($shortcode_tags)) return $content

$pattern = get_shortcode_regex() return preg_replace_callback( $patterns do_shortcode_tag $content )

Shortcodes

function do_shortcode_tag( $m )

if ( isset( $m[5] ) ) enclosing tag - extra parameter return $m[1] call_user_func( $shortcode_tags[$tag] $attr $m[5] $tag ) $m[6] else self-closing tag return $m[1] call_user_func( $shortcode_tags[$tag] $attr null $tag ) $m[6]

Shortcodes

callback params $attrs attributes $content enclosed tags text $tag shortcode tag itself

Admin-post

Data from clientsProcessing requests

You can just process requests in your own page because $_REQUEST $_GET $_POST is global

Admin-post

But in your own handlerYou cannot use WP core functionsYou cannot authenticate

Do not reinvent the wheelSo there is admin-postphp

Admin-post

wp-adminadmin-postphpdefine amp include minimal settingsand do_action

$action = empty( $_REQUEST[action] ) $_REQUEST[action]

admin_post_nopriv admin_post_nopriv_$actionadmin_post admin_post_$action

finish using die() in callback function

AJAX

Very similar to admin-post but DOING_AJAX is defineddefine( DOING_AJAX true )

also use die() in callback function

if ( is_user_logged_in() ) do_action( wp_ajax_ $_REQUEST[action] ) else do_action( wp_ajax_nopriv_ $_REQUEST[action] ) Default statusdie( 0 )

Redirect

You can generate custom page in plugin by using template_redirect action

function my_page_template_redirect() if( is_page( goodies ) ampamp is_user_logged_in() )

wp_redirect( home_url( signup ) ) exit()

add_action( template_redirect my_page_template_redirect )

Redirect

You can generate web pages on-the-fly by utilizing these 3 hooks rewrite rule query parsing redirect

Detailed instructions later

(de)activation uninstall

register_activation_hook($file $cb)register_deactivation_hook($file $cb)register_uninstall_hook($file $cb)

$file full path of plugin file$cb callback function

callbacks should be SILENT No echo please

Summary

menu items shortcodes admin post ajax template redirects and (de)activation- uninstall hooks are good initial entry pointso It is a good strategy to find these

hooks in plugins first and dissect their codes from those points

I know you want to do something

You understand hook conceptYou know database detail

Now you know entry points

Definitely you wanna make something

Visit http[ip]practice and download entry-pointsphp

소스코드 http[ip]source-codes1 어드민 화면에 메뉴 추가2 쇼트코드 추가3 메뉴에서 admin post 전송4 메뉴에서 ajax 전송5redirect 테스트

ltauthorgt 부분은 자신의 이름으로 일괄변경하고 적절히 콜백 함수를 정의해 주세요

Source code explained

10 minutes break

Managing Your Own Contents

Wow there are too many things about posts

For today just focuse oncustom post type

Arguments are too complex

Just use Types or Pods pluginThats all problem solved

Yeah

of course you might not want this I was just kidding

Custom Post

You want to manage your own contentsThats why custom post is

Music collections Online store Event calendar Book data Photo portfolio

Custom Post Motivation

Well with just one type post and you may define many categories and use them to organize all contents

JUST ONE TYPE POSTMANY CATEGORIES

portfolio calendar music db

Custom Post Motivation

But you might feel that some post types should be hidden from some users even might be excluded from search may be only for private use may have very complex taxonomies

so that it should have its own territory

can be accessible from their own URL rules

Custom Post Motivation

Why re-invent wheel again

By extending built-in post type systemyou can REUSE whole facilities related to posts easily

UI and all thing about managing

Built-in Custom Post Types

wp-includespostphp (included in wp-settingsphp)function create_initial_post_types()

register_post_type( post array( register_post_type( page array( register_post_type( attachment array( register_post_type( revision array( register_post_type( nav_menu_item array( register_post_status( publish array(

register_post_type

ltphp register_post_type( $post_type $args ) gt

$arg is very complex

But I think it should be explained in detail Actually you cannot avoid it because eventuall all post type plugins will use that function too

Those plugins also have diffcult UIs too

register_post_type

Lets take a look how Types and Pods create their custom posts

They have easy (really) UI and provide better functionaliy but you can see horribly many options there

register_post_type $post_type

Up to 20 characters Only lowercase and numbers

register_post_type $args

publicvisible to authors

true impliesexclude_from_search falsepublicly_queryable show_in_nav_manues show_ui

false impliesexclude_from_search true publicly_queryable falseshow_in_nav_manues false show_ui false

register_post_type $args

labelplural descriptive name

egMusic CollectionsMostly localized text

register_post_type $args

labels more specific text labelsnamesigular_namemenu_namename_admin_barall_itemsadd_newadd_new_itemedit_itemview_itemsearch_items

search_itemsnot_foundnot_found in trashparent_item_colon

register_post_type $args

descriptionsummary of this post type

register_post_type $args

exclude_from_searchdo not search this post typetry S=beatbles

register_post_type $args

publicly_queryablecan use query

eg) post_type=music_collection

register_post_type $args

show_uidisplay default UI

register_post_type $args

show_in_nav_menusshow in navigation menus

be careful publicly_queryablemust be true

register_post_type $args

show_in_menushow admin_menu show_ui must be trueJust showing menutrue false else some strings

(toolsphp editphp)

altough it is falseyou can access URLS likewp-admineditphppost_type=music_collection(show_ui must be true)

register_post_type $args

show_in_admin_baravailable in admin bar

menu_postiondefault below comments

menu_iconsee dashicons

register_post_type $args

capability_typestring or array to build capabilites

in our exampeedit_music_collectionsedit_others_music_collections

publish_music_collectionsread_private_music_collections

register_post_type $args

capabilitiesto give specific names to each capability

map_meta_capif true default meta capability will be added

and then your role or account need capabilities

register_post_type $args

hierarchicalpost type can be hierarchicalthis is for page-styles

register_post_type $args

query_varto query posts query_var=slug

rewriteto use pretty permalinks

has_archiveEnables post type archive

register_post_type $args

permalink_epmaskrewrite endpoint bitmask

can_exporttrue makes the post can be exported

Too exhaustive but worth it

Practice Custom Post

Create custom-plugin-ltauthorgtphpCreate a simple custom post

Display admin menuHide admin_barWrite your post Any content is OK Include at least one meta field

Next Week

Customizing Visual Components List Table Screen Widgets

WordPress System Undercover Constants and Globals WPDB

  • WordPress Plugin 3
  • Recap
  • Recap (2)
  • Recap (3)
  • Recap (4)
  • Recap (5)
  • Todays Topics
  • Entry Points in Plugin
  • Entry Points
  • Entry Points (2)
  • Entry Points (3)
  • Entry Points (4)
  • Menu Items
  • Where is default menu
  • Where is default menu (2)
  • Our custom menus
  • add_menu_page
  • add_submenu_page
  • derivatives
  • Shortcodes
  • Shortcodes (2)
  • Shortcodes (3)
  • Shortcodes (4)
  • Shortcodes (5)
  • Shortcodes (6)
  • Admin-post
  • Admin-post (2)
  • Admin-post (3)
  • AJAX
  • Redirect
  • Redirect (2)
  • (de)activation uninstall
  • Summary
  • I know you want to do something
  • Slide 35
  • Source code explained
  • 10 minutes break
  • Managing Your Own Contents
  • Wow there are too many things about posts
  • For today just focuse on custom post type
  • Arguments are too complex
  • of course you might not want this I was just kidding
  • Custom Post
  • Custom Post Motivation
  • Custom Post Motivation (2)
  • Custom Post Motivation (3)
  • Built-in Custom Post Types
  • register_post_type
  • register_post_type (2)
  • register_post_type $post_type
  • register_post_type $args
  • register_post_type $args (2)
  • register_post_type $args (3)
  • register_post_type $args (4)
  • register_post_type $args (5)
  • register_post_type $args (6)
  • register_post_type $args (7)
  • register_post_type $args (8)
  • register_post_type $args (9)
  • register_post_type $args (10)
  • register_post_type $args (11)
  • register_post_type $args (12)
  • register_post_type $args (13)
  • register_post_type $args (14)
  • register_post_type $args (15)
  • Too exhaustive but worth it
  • Practice Custom Post
  • Next Week
Page 7: WordPress plugin #3

Todays Topics

1Entry Points in Plugina Menub Shortcodesc Admin Postd Ajaxe Redirectf activation deactivation uninstall

2Managing Your Own Contentsa All About Custom Posts

Entry Points in Plugin

Entry Points

Plugins run on the server sideServer only responds when it is requested

Requested moment rarr entry point

Entry Points

Q When the server is requestedA It is when client access via a URL

Q Why a URL is usedA To define a resource output to clientA To receive data input from client

Entry Points

Q Output FormA Whatever

Images audio video html documents

Q Input formA Generally submitting forms

via GETPOST method

Entry Points

There are some special entry points left for plugins

Menu items Shortcodes Admin post AJAX Redirecting Activation deactivation uninstall

Menu Items

Callback from admin menu clicking

add_menu_page()add_submenu_page()

remove_menu_page()remove_submenu_page()

Where is default menu

wp-adminmenu-headerphp

ltul id=adminmenugtltphp_wp_menu_output( $menu $submenu )

function _wp_menu_output( $menu $submenu $submenu_as_parent = true )

here menus are printed in html

Where is default menu

wp-adminmenuphp (adminphp includes it)wp-amdinincludesmenuphp

builds administrative menus

global $menu $submenu stores menu information

Our custom menus

wp-adminincludesmenuphp

do_action( admin_menu )

Menu API are defined in wp-adminincludespluginphp

add_menu_page

function add_menu_page( $page_title $menu_title $capability $menu_slug $function = $icon_url = $position = null )

$new_menu = array( $menu_title $capability $menu_slug $page_title menu-top $icon_class $hookname $hookname $icon_url )

if ( null === $position ) $menu[] = $new_menuelse $menu[$position] = $new_menu

add_submenu_page

function add_submenu_page( $parent_slug $page_title $menu_title $capability $menu_slug $function = ) $submenu[$parent_slug][] = array ( $menu_title $capability $menu_slug $page_title )

derivatives

add_dashboard_page() add_posts_page() add_media_page() add_pages_page() add_comments_page() add_theme_page() add_plugins_page() add_users_page() add_management_page() add_options_page()

Shortcodes

What is shortcodeA magic word in post content that is replaced by some process defined in plugin or themes in runtime

Good for displaying complex dynamic contents

Shortcodes

Sample[gallery id=123 size=medium][gallery]

or

[caption]My Caption[caption] enclosed form

Shortcodes

add_shortcode()

$shortcode_tags = array()function add_shortcode($tag $func) global $shortcode_tags

if ( is_callable($func) ) $shortcode_tags[$tag] = $func

Shortcodes

function do_shortcode($content) global $shortcode_tags

if ( false === strpos( $content [ ) ) return $content

if (empty($shortcode_tags) || is_array($shortcode_tags)) return $content

$pattern = get_shortcode_regex() return preg_replace_callback( $patterns do_shortcode_tag $content )

Shortcodes

function do_shortcode_tag( $m )

if ( isset( $m[5] ) ) enclosing tag - extra parameter return $m[1] call_user_func( $shortcode_tags[$tag] $attr $m[5] $tag ) $m[6] else self-closing tag return $m[1] call_user_func( $shortcode_tags[$tag] $attr null $tag ) $m[6]

Shortcodes

callback params $attrs attributes $content enclosed tags text $tag shortcode tag itself

Admin-post

Data from clientsProcessing requests

You can just process requests in your own page because $_REQUEST $_GET $_POST is global

Admin-post

But in your own handlerYou cannot use WP core functionsYou cannot authenticate

Do not reinvent the wheelSo there is admin-postphp

Admin-post

wp-adminadmin-postphpdefine amp include minimal settingsand do_action

$action = empty( $_REQUEST[action] ) $_REQUEST[action]

admin_post_nopriv admin_post_nopriv_$actionadmin_post admin_post_$action

finish using die() in callback function

AJAX

Very similar to admin-post but DOING_AJAX is defineddefine( DOING_AJAX true )

also use die() in callback function

if ( is_user_logged_in() ) do_action( wp_ajax_ $_REQUEST[action] ) else do_action( wp_ajax_nopriv_ $_REQUEST[action] ) Default statusdie( 0 )

Redirect

You can generate custom page in plugin by using template_redirect action

function my_page_template_redirect() if( is_page( goodies ) ampamp is_user_logged_in() )

wp_redirect( home_url( signup ) ) exit()

add_action( template_redirect my_page_template_redirect )

Redirect

You can generate web pages on-the-fly by utilizing these 3 hooks rewrite rule query parsing redirect

Detailed instructions later

(de)activation uninstall

register_activation_hook($file $cb)register_deactivation_hook($file $cb)register_uninstall_hook($file $cb)

$file full path of plugin file$cb callback function

callbacks should be SILENT No echo please

Summary

menu items shortcodes admin post ajax template redirects and (de)activation- uninstall hooks are good initial entry pointso It is a good strategy to find these

hooks in plugins first and dissect their codes from those points

I know you want to do something

You understand hook conceptYou know database detail

Now you know entry points

Definitely you wanna make something

Visit http[ip]practice and download entry-pointsphp

소스코드 http[ip]source-codes1 어드민 화면에 메뉴 추가2 쇼트코드 추가3 메뉴에서 admin post 전송4 메뉴에서 ajax 전송5redirect 테스트

ltauthorgt 부분은 자신의 이름으로 일괄변경하고 적절히 콜백 함수를 정의해 주세요

Source code explained

10 minutes break

Managing Your Own Contents

Wow there are too many things about posts

For today just focuse oncustom post type

Arguments are too complex

Just use Types or Pods pluginThats all problem solved

Yeah

of course you might not want this I was just kidding

Custom Post

You want to manage your own contentsThats why custom post is

Music collections Online store Event calendar Book data Photo portfolio

Custom Post Motivation

Well with just one type post and you may define many categories and use them to organize all contents

JUST ONE TYPE POSTMANY CATEGORIES

portfolio calendar music db

Custom Post Motivation

But you might feel that some post types should be hidden from some users even might be excluded from search may be only for private use may have very complex taxonomies

so that it should have its own territory

can be accessible from their own URL rules

Custom Post Motivation

Why re-invent wheel again

By extending built-in post type systemyou can REUSE whole facilities related to posts easily

UI and all thing about managing

Built-in Custom Post Types

wp-includespostphp (included in wp-settingsphp)function create_initial_post_types()

register_post_type( post array( register_post_type( page array( register_post_type( attachment array( register_post_type( revision array( register_post_type( nav_menu_item array( register_post_status( publish array(

register_post_type

ltphp register_post_type( $post_type $args ) gt

$arg is very complex

But I think it should be explained in detail Actually you cannot avoid it because eventuall all post type plugins will use that function too

Those plugins also have diffcult UIs too

register_post_type

Lets take a look how Types and Pods create their custom posts

They have easy (really) UI and provide better functionaliy but you can see horribly many options there

register_post_type $post_type

Up to 20 characters Only lowercase and numbers

register_post_type $args

publicvisible to authors

true impliesexclude_from_search falsepublicly_queryable show_in_nav_manues show_ui

false impliesexclude_from_search true publicly_queryable falseshow_in_nav_manues false show_ui false

register_post_type $args

labelplural descriptive name

egMusic CollectionsMostly localized text

register_post_type $args

labels more specific text labelsnamesigular_namemenu_namename_admin_barall_itemsadd_newadd_new_itemedit_itemview_itemsearch_items

search_itemsnot_foundnot_found in trashparent_item_colon

register_post_type $args

descriptionsummary of this post type

register_post_type $args

exclude_from_searchdo not search this post typetry S=beatbles

register_post_type $args

publicly_queryablecan use query

eg) post_type=music_collection

register_post_type $args

show_uidisplay default UI

register_post_type $args

show_in_nav_menusshow in navigation menus

be careful publicly_queryablemust be true

register_post_type $args

show_in_menushow admin_menu show_ui must be trueJust showing menutrue false else some strings

(toolsphp editphp)

altough it is falseyou can access URLS likewp-admineditphppost_type=music_collection(show_ui must be true)

register_post_type $args

show_in_admin_baravailable in admin bar

menu_postiondefault below comments

menu_iconsee dashicons

register_post_type $args

capability_typestring or array to build capabilites

in our exampeedit_music_collectionsedit_others_music_collections

publish_music_collectionsread_private_music_collections

register_post_type $args

capabilitiesto give specific names to each capability

map_meta_capif true default meta capability will be added

and then your role or account need capabilities

register_post_type $args

hierarchicalpost type can be hierarchicalthis is for page-styles

register_post_type $args

query_varto query posts query_var=slug

rewriteto use pretty permalinks

has_archiveEnables post type archive

register_post_type $args

permalink_epmaskrewrite endpoint bitmask

can_exporttrue makes the post can be exported

Too exhaustive but worth it

Practice Custom Post

Create custom-plugin-ltauthorgtphpCreate a simple custom post

Display admin menuHide admin_barWrite your post Any content is OK Include at least one meta field

Next Week

Customizing Visual Components List Table Screen Widgets

WordPress System Undercover Constants and Globals WPDB

  • WordPress Plugin 3
  • Recap
  • Recap (2)
  • Recap (3)
  • Recap (4)
  • Recap (5)
  • Todays Topics
  • Entry Points in Plugin
  • Entry Points
  • Entry Points (2)
  • Entry Points (3)
  • Entry Points (4)
  • Menu Items
  • Where is default menu
  • Where is default menu (2)
  • Our custom menus
  • add_menu_page
  • add_submenu_page
  • derivatives
  • Shortcodes
  • Shortcodes (2)
  • Shortcodes (3)
  • Shortcodes (4)
  • Shortcodes (5)
  • Shortcodes (6)
  • Admin-post
  • Admin-post (2)
  • Admin-post (3)
  • AJAX
  • Redirect
  • Redirect (2)
  • (de)activation uninstall
  • Summary
  • I know you want to do something
  • Slide 35
  • Source code explained
  • 10 minutes break
  • Managing Your Own Contents
  • Wow there are too many things about posts
  • For today just focuse on custom post type
  • Arguments are too complex
  • of course you might not want this I was just kidding
  • Custom Post
  • Custom Post Motivation
  • Custom Post Motivation (2)
  • Custom Post Motivation (3)
  • Built-in Custom Post Types
  • register_post_type
  • register_post_type (2)
  • register_post_type $post_type
  • register_post_type $args
  • register_post_type $args (2)
  • register_post_type $args (3)
  • register_post_type $args (4)
  • register_post_type $args (5)
  • register_post_type $args (6)
  • register_post_type $args (7)
  • register_post_type $args (8)
  • register_post_type $args (9)
  • register_post_type $args (10)
  • register_post_type $args (11)
  • register_post_type $args (12)
  • register_post_type $args (13)
  • register_post_type $args (14)
  • register_post_type $args (15)
  • Too exhaustive but worth it
  • Practice Custom Post
  • Next Week
Page 8: WordPress plugin #3

Entry Points in Plugin

Entry Points

Plugins run on the server sideServer only responds when it is requested

Requested moment rarr entry point

Entry Points

Q When the server is requestedA It is when client access via a URL

Q Why a URL is usedA To define a resource output to clientA To receive data input from client

Entry Points

Q Output FormA Whatever

Images audio video html documents

Q Input formA Generally submitting forms

via GETPOST method

Entry Points

There are some special entry points left for plugins

Menu items Shortcodes Admin post AJAX Redirecting Activation deactivation uninstall

Menu Items

Callback from admin menu clicking

add_menu_page()add_submenu_page()

remove_menu_page()remove_submenu_page()

Where is default menu

wp-adminmenu-headerphp

ltul id=adminmenugtltphp_wp_menu_output( $menu $submenu )

function _wp_menu_output( $menu $submenu $submenu_as_parent = true )

here menus are printed in html

Where is default menu

wp-adminmenuphp (adminphp includes it)wp-amdinincludesmenuphp

builds administrative menus

global $menu $submenu stores menu information

Our custom menus

wp-adminincludesmenuphp

do_action( admin_menu )

Menu API are defined in wp-adminincludespluginphp

add_menu_page

function add_menu_page( $page_title $menu_title $capability $menu_slug $function = $icon_url = $position = null )

$new_menu = array( $menu_title $capability $menu_slug $page_title menu-top $icon_class $hookname $hookname $icon_url )

if ( null === $position ) $menu[] = $new_menuelse $menu[$position] = $new_menu

add_submenu_page

function add_submenu_page( $parent_slug $page_title $menu_title $capability $menu_slug $function = ) $submenu[$parent_slug][] = array ( $menu_title $capability $menu_slug $page_title )

derivatives

add_dashboard_page() add_posts_page() add_media_page() add_pages_page() add_comments_page() add_theme_page() add_plugins_page() add_users_page() add_management_page() add_options_page()

Shortcodes

What is shortcodeA magic word in post content that is replaced by some process defined in plugin or themes in runtime

Good for displaying complex dynamic contents

Shortcodes

Sample[gallery id=123 size=medium][gallery]

or

[caption]My Caption[caption] enclosed form

Shortcodes

add_shortcode()

$shortcode_tags = array()function add_shortcode($tag $func) global $shortcode_tags

if ( is_callable($func) ) $shortcode_tags[$tag] = $func

Shortcodes

function do_shortcode($content) global $shortcode_tags

if ( false === strpos( $content [ ) ) return $content

if (empty($shortcode_tags) || is_array($shortcode_tags)) return $content

$pattern = get_shortcode_regex() return preg_replace_callback( $patterns do_shortcode_tag $content )

Shortcodes

function do_shortcode_tag( $m )

if ( isset( $m[5] ) ) enclosing tag - extra parameter return $m[1] call_user_func( $shortcode_tags[$tag] $attr $m[5] $tag ) $m[6] else self-closing tag return $m[1] call_user_func( $shortcode_tags[$tag] $attr null $tag ) $m[6]

Shortcodes

callback params $attrs attributes $content enclosed tags text $tag shortcode tag itself

Admin-post

Data from clientsProcessing requests

You can just process requests in your own page because $_REQUEST $_GET $_POST is global

Admin-post

But in your own handlerYou cannot use WP core functionsYou cannot authenticate

Do not reinvent the wheelSo there is admin-postphp

Admin-post

wp-adminadmin-postphpdefine amp include minimal settingsand do_action

$action = empty( $_REQUEST[action] ) $_REQUEST[action]

admin_post_nopriv admin_post_nopriv_$actionadmin_post admin_post_$action

finish using die() in callback function

AJAX

Very similar to admin-post but DOING_AJAX is defineddefine( DOING_AJAX true )

also use die() in callback function

if ( is_user_logged_in() ) do_action( wp_ajax_ $_REQUEST[action] ) else do_action( wp_ajax_nopriv_ $_REQUEST[action] ) Default statusdie( 0 )

Redirect

You can generate custom page in plugin by using template_redirect action

function my_page_template_redirect() if( is_page( goodies ) ampamp is_user_logged_in() )

wp_redirect( home_url( signup ) ) exit()

add_action( template_redirect my_page_template_redirect )

Redirect

You can generate web pages on-the-fly by utilizing these 3 hooks rewrite rule query parsing redirect

Detailed instructions later

(de)activation uninstall

register_activation_hook($file $cb)register_deactivation_hook($file $cb)register_uninstall_hook($file $cb)

$file full path of plugin file$cb callback function

callbacks should be SILENT No echo please

Summary

menu items shortcodes admin post ajax template redirects and (de)activation- uninstall hooks are good initial entry pointso It is a good strategy to find these

hooks in plugins first and dissect their codes from those points

I know you want to do something

You understand hook conceptYou know database detail

Now you know entry points

Definitely you wanna make something

Visit http[ip]practice and download entry-pointsphp

소스코드 http[ip]source-codes1 어드민 화면에 메뉴 추가2 쇼트코드 추가3 메뉴에서 admin post 전송4 메뉴에서 ajax 전송5redirect 테스트

ltauthorgt 부분은 자신의 이름으로 일괄변경하고 적절히 콜백 함수를 정의해 주세요

Source code explained

10 minutes break

Managing Your Own Contents

Wow there are too many things about posts

For today just focuse oncustom post type

Arguments are too complex

Just use Types or Pods pluginThats all problem solved

Yeah

of course you might not want this I was just kidding

Custom Post

You want to manage your own contentsThats why custom post is

Music collections Online store Event calendar Book data Photo portfolio

Custom Post Motivation

Well with just one type post and you may define many categories and use them to organize all contents

JUST ONE TYPE POSTMANY CATEGORIES

portfolio calendar music db

Custom Post Motivation

But you might feel that some post types should be hidden from some users even might be excluded from search may be only for private use may have very complex taxonomies

so that it should have its own territory

can be accessible from their own URL rules

Custom Post Motivation

Why re-invent wheel again

By extending built-in post type systemyou can REUSE whole facilities related to posts easily

UI and all thing about managing

Built-in Custom Post Types

wp-includespostphp (included in wp-settingsphp)function create_initial_post_types()

register_post_type( post array( register_post_type( page array( register_post_type( attachment array( register_post_type( revision array( register_post_type( nav_menu_item array( register_post_status( publish array(

register_post_type

ltphp register_post_type( $post_type $args ) gt

$arg is very complex

But I think it should be explained in detail Actually you cannot avoid it because eventuall all post type plugins will use that function too

Those plugins also have diffcult UIs too

register_post_type

Lets take a look how Types and Pods create their custom posts

They have easy (really) UI and provide better functionaliy but you can see horribly many options there

register_post_type $post_type

Up to 20 characters Only lowercase and numbers

register_post_type $args

publicvisible to authors

true impliesexclude_from_search falsepublicly_queryable show_in_nav_manues show_ui

false impliesexclude_from_search true publicly_queryable falseshow_in_nav_manues false show_ui false

register_post_type $args

labelplural descriptive name

egMusic CollectionsMostly localized text

register_post_type $args

labels more specific text labelsnamesigular_namemenu_namename_admin_barall_itemsadd_newadd_new_itemedit_itemview_itemsearch_items

search_itemsnot_foundnot_found in trashparent_item_colon

register_post_type $args

descriptionsummary of this post type

register_post_type $args

exclude_from_searchdo not search this post typetry S=beatbles

register_post_type $args

publicly_queryablecan use query

eg) post_type=music_collection

register_post_type $args

show_uidisplay default UI

register_post_type $args

show_in_nav_menusshow in navigation menus

be careful publicly_queryablemust be true

register_post_type $args

show_in_menushow admin_menu show_ui must be trueJust showing menutrue false else some strings

(toolsphp editphp)

altough it is falseyou can access URLS likewp-admineditphppost_type=music_collection(show_ui must be true)

register_post_type $args

show_in_admin_baravailable in admin bar

menu_postiondefault below comments

menu_iconsee dashicons

register_post_type $args

capability_typestring or array to build capabilites

in our exampeedit_music_collectionsedit_others_music_collections

publish_music_collectionsread_private_music_collections

register_post_type $args

capabilitiesto give specific names to each capability

map_meta_capif true default meta capability will be added

and then your role or account need capabilities

register_post_type $args

hierarchicalpost type can be hierarchicalthis is for page-styles

register_post_type $args

query_varto query posts query_var=slug

rewriteto use pretty permalinks

has_archiveEnables post type archive

register_post_type $args

permalink_epmaskrewrite endpoint bitmask

can_exporttrue makes the post can be exported

Too exhaustive but worth it

Practice Custom Post

Create custom-plugin-ltauthorgtphpCreate a simple custom post

Display admin menuHide admin_barWrite your post Any content is OK Include at least one meta field

Next Week

Customizing Visual Components List Table Screen Widgets

WordPress System Undercover Constants and Globals WPDB

  • WordPress Plugin 3
  • Recap
  • Recap (2)
  • Recap (3)
  • Recap (4)
  • Recap (5)
  • Todays Topics
  • Entry Points in Plugin
  • Entry Points
  • Entry Points (2)
  • Entry Points (3)
  • Entry Points (4)
  • Menu Items
  • Where is default menu
  • Where is default menu (2)
  • Our custom menus
  • add_menu_page
  • add_submenu_page
  • derivatives
  • Shortcodes
  • Shortcodes (2)
  • Shortcodes (3)
  • Shortcodes (4)
  • Shortcodes (5)
  • Shortcodes (6)
  • Admin-post
  • Admin-post (2)
  • Admin-post (3)
  • AJAX
  • Redirect
  • Redirect (2)
  • (de)activation uninstall
  • Summary
  • I know you want to do something
  • Slide 35
  • Source code explained
  • 10 minutes break
  • Managing Your Own Contents
  • Wow there are too many things about posts
  • For today just focuse on custom post type
  • Arguments are too complex
  • of course you might not want this I was just kidding
  • Custom Post
  • Custom Post Motivation
  • Custom Post Motivation (2)
  • Custom Post Motivation (3)
  • Built-in Custom Post Types
  • register_post_type
  • register_post_type (2)
  • register_post_type $post_type
  • register_post_type $args
  • register_post_type $args (2)
  • register_post_type $args (3)
  • register_post_type $args (4)
  • register_post_type $args (5)
  • register_post_type $args (6)
  • register_post_type $args (7)
  • register_post_type $args (8)
  • register_post_type $args (9)
  • register_post_type $args (10)
  • register_post_type $args (11)
  • register_post_type $args (12)
  • register_post_type $args (13)
  • register_post_type $args (14)
  • register_post_type $args (15)
  • Too exhaustive but worth it
  • Practice Custom Post
  • Next Week
Page 9: WordPress plugin #3

Entry Points

Plugins run on the server sideServer only responds when it is requested

Requested moment rarr entry point

Entry Points

Q When the server is requestedA It is when client access via a URL

Q Why a URL is usedA To define a resource output to clientA To receive data input from client

Entry Points

Q Output FormA Whatever

Images audio video html documents

Q Input formA Generally submitting forms

via GETPOST method

Entry Points

There are some special entry points left for plugins

Menu items Shortcodes Admin post AJAX Redirecting Activation deactivation uninstall

Menu Items

Callback from admin menu clicking

add_menu_page()add_submenu_page()

remove_menu_page()remove_submenu_page()

Where is default menu

wp-adminmenu-headerphp

ltul id=adminmenugtltphp_wp_menu_output( $menu $submenu )

function _wp_menu_output( $menu $submenu $submenu_as_parent = true )

here menus are printed in html

Where is default menu

wp-adminmenuphp (adminphp includes it)wp-amdinincludesmenuphp

builds administrative menus

global $menu $submenu stores menu information

Our custom menus

wp-adminincludesmenuphp

do_action( admin_menu )

Menu API are defined in wp-adminincludespluginphp

add_menu_page

function add_menu_page( $page_title $menu_title $capability $menu_slug $function = $icon_url = $position = null )

$new_menu = array( $menu_title $capability $menu_slug $page_title menu-top $icon_class $hookname $hookname $icon_url )

if ( null === $position ) $menu[] = $new_menuelse $menu[$position] = $new_menu

add_submenu_page

function add_submenu_page( $parent_slug $page_title $menu_title $capability $menu_slug $function = ) $submenu[$parent_slug][] = array ( $menu_title $capability $menu_slug $page_title )

derivatives

add_dashboard_page() add_posts_page() add_media_page() add_pages_page() add_comments_page() add_theme_page() add_plugins_page() add_users_page() add_management_page() add_options_page()

Shortcodes

What is shortcodeA magic word in post content that is replaced by some process defined in plugin or themes in runtime

Good for displaying complex dynamic contents

Shortcodes

Sample[gallery id=123 size=medium][gallery]

or

[caption]My Caption[caption] enclosed form

Shortcodes

add_shortcode()

$shortcode_tags = array()function add_shortcode($tag $func) global $shortcode_tags

if ( is_callable($func) ) $shortcode_tags[$tag] = $func

Shortcodes

function do_shortcode($content) global $shortcode_tags

if ( false === strpos( $content [ ) ) return $content

if (empty($shortcode_tags) || is_array($shortcode_tags)) return $content

$pattern = get_shortcode_regex() return preg_replace_callback( $patterns do_shortcode_tag $content )

Shortcodes

function do_shortcode_tag( $m )

if ( isset( $m[5] ) ) enclosing tag - extra parameter return $m[1] call_user_func( $shortcode_tags[$tag] $attr $m[5] $tag ) $m[6] else self-closing tag return $m[1] call_user_func( $shortcode_tags[$tag] $attr null $tag ) $m[6]

Shortcodes

callback params $attrs attributes $content enclosed tags text $tag shortcode tag itself

Admin-post

Data from clientsProcessing requests

You can just process requests in your own page because $_REQUEST $_GET $_POST is global

Admin-post

But in your own handlerYou cannot use WP core functionsYou cannot authenticate

Do not reinvent the wheelSo there is admin-postphp

Admin-post

wp-adminadmin-postphpdefine amp include minimal settingsand do_action

$action = empty( $_REQUEST[action] ) $_REQUEST[action]

admin_post_nopriv admin_post_nopriv_$actionadmin_post admin_post_$action

finish using die() in callback function

AJAX

Very similar to admin-post but DOING_AJAX is defineddefine( DOING_AJAX true )

also use die() in callback function

if ( is_user_logged_in() ) do_action( wp_ajax_ $_REQUEST[action] ) else do_action( wp_ajax_nopriv_ $_REQUEST[action] ) Default statusdie( 0 )

Redirect

You can generate custom page in plugin by using template_redirect action

function my_page_template_redirect() if( is_page( goodies ) ampamp is_user_logged_in() )

wp_redirect( home_url( signup ) ) exit()

add_action( template_redirect my_page_template_redirect )

Redirect

You can generate web pages on-the-fly by utilizing these 3 hooks rewrite rule query parsing redirect

Detailed instructions later

(de)activation uninstall

register_activation_hook($file $cb)register_deactivation_hook($file $cb)register_uninstall_hook($file $cb)

$file full path of plugin file$cb callback function

callbacks should be SILENT No echo please

Summary

menu items shortcodes admin post ajax template redirects and (de)activation- uninstall hooks are good initial entry pointso It is a good strategy to find these

hooks in plugins first and dissect their codes from those points

I know you want to do something

You understand hook conceptYou know database detail

Now you know entry points

Definitely you wanna make something

Visit http[ip]practice and download entry-pointsphp

소스코드 http[ip]source-codes1 어드민 화면에 메뉴 추가2 쇼트코드 추가3 메뉴에서 admin post 전송4 메뉴에서 ajax 전송5redirect 테스트

ltauthorgt 부분은 자신의 이름으로 일괄변경하고 적절히 콜백 함수를 정의해 주세요

Source code explained

10 minutes break

Managing Your Own Contents

Wow there are too many things about posts

For today just focuse oncustom post type

Arguments are too complex

Just use Types or Pods pluginThats all problem solved

Yeah

of course you might not want this I was just kidding

Custom Post

You want to manage your own contentsThats why custom post is

Music collections Online store Event calendar Book data Photo portfolio

Custom Post Motivation

Well with just one type post and you may define many categories and use them to organize all contents

JUST ONE TYPE POSTMANY CATEGORIES

portfolio calendar music db

Custom Post Motivation

But you might feel that some post types should be hidden from some users even might be excluded from search may be only for private use may have very complex taxonomies

so that it should have its own territory

can be accessible from their own URL rules

Custom Post Motivation

Why re-invent wheel again

By extending built-in post type systemyou can REUSE whole facilities related to posts easily

UI and all thing about managing

Built-in Custom Post Types

wp-includespostphp (included in wp-settingsphp)function create_initial_post_types()

register_post_type( post array( register_post_type( page array( register_post_type( attachment array( register_post_type( revision array( register_post_type( nav_menu_item array( register_post_status( publish array(

register_post_type

ltphp register_post_type( $post_type $args ) gt

$arg is very complex

But I think it should be explained in detail Actually you cannot avoid it because eventuall all post type plugins will use that function too

Those plugins also have diffcult UIs too

register_post_type

Lets take a look how Types and Pods create their custom posts

They have easy (really) UI and provide better functionaliy but you can see horribly many options there

register_post_type $post_type

Up to 20 characters Only lowercase and numbers

register_post_type $args

publicvisible to authors

true impliesexclude_from_search falsepublicly_queryable show_in_nav_manues show_ui

false impliesexclude_from_search true publicly_queryable falseshow_in_nav_manues false show_ui false

register_post_type $args

labelplural descriptive name

egMusic CollectionsMostly localized text

register_post_type $args

labels more specific text labelsnamesigular_namemenu_namename_admin_barall_itemsadd_newadd_new_itemedit_itemview_itemsearch_items

search_itemsnot_foundnot_found in trashparent_item_colon

register_post_type $args

descriptionsummary of this post type

register_post_type $args

exclude_from_searchdo not search this post typetry S=beatbles

register_post_type $args

publicly_queryablecan use query

eg) post_type=music_collection

register_post_type $args

show_uidisplay default UI

register_post_type $args

show_in_nav_menusshow in navigation menus

be careful publicly_queryablemust be true

register_post_type $args

show_in_menushow admin_menu show_ui must be trueJust showing menutrue false else some strings

(toolsphp editphp)

altough it is falseyou can access URLS likewp-admineditphppost_type=music_collection(show_ui must be true)

register_post_type $args

show_in_admin_baravailable in admin bar

menu_postiondefault below comments

menu_iconsee dashicons

register_post_type $args

capability_typestring or array to build capabilites

in our exampeedit_music_collectionsedit_others_music_collections

publish_music_collectionsread_private_music_collections

register_post_type $args

capabilitiesto give specific names to each capability

map_meta_capif true default meta capability will be added

and then your role or account need capabilities

register_post_type $args

hierarchicalpost type can be hierarchicalthis is for page-styles

register_post_type $args

query_varto query posts query_var=slug

rewriteto use pretty permalinks

has_archiveEnables post type archive

register_post_type $args

permalink_epmaskrewrite endpoint bitmask

can_exporttrue makes the post can be exported

Too exhaustive but worth it

Practice Custom Post

Create custom-plugin-ltauthorgtphpCreate a simple custom post

Display admin menuHide admin_barWrite your post Any content is OK Include at least one meta field

Next Week

Customizing Visual Components List Table Screen Widgets

WordPress System Undercover Constants and Globals WPDB

  • WordPress Plugin 3
  • Recap
  • Recap (2)
  • Recap (3)
  • Recap (4)
  • Recap (5)
  • Todays Topics
  • Entry Points in Plugin
  • Entry Points
  • Entry Points (2)
  • Entry Points (3)
  • Entry Points (4)
  • Menu Items
  • Where is default menu
  • Where is default menu (2)
  • Our custom menus
  • add_menu_page
  • add_submenu_page
  • derivatives
  • Shortcodes
  • Shortcodes (2)
  • Shortcodes (3)
  • Shortcodes (4)
  • Shortcodes (5)
  • Shortcodes (6)
  • Admin-post
  • Admin-post (2)
  • Admin-post (3)
  • AJAX
  • Redirect
  • Redirect (2)
  • (de)activation uninstall
  • Summary
  • I know you want to do something
  • Slide 35
  • Source code explained
  • 10 minutes break
  • Managing Your Own Contents
  • Wow there are too many things about posts
  • For today just focuse on custom post type
  • Arguments are too complex
  • of course you might not want this I was just kidding
  • Custom Post
  • Custom Post Motivation
  • Custom Post Motivation (2)
  • Custom Post Motivation (3)
  • Built-in Custom Post Types
  • register_post_type
  • register_post_type (2)
  • register_post_type $post_type
  • register_post_type $args
  • register_post_type $args (2)
  • register_post_type $args (3)
  • register_post_type $args (4)
  • register_post_type $args (5)
  • register_post_type $args (6)
  • register_post_type $args (7)
  • register_post_type $args (8)
  • register_post_type $args (9)
  • register_post_type $args (10)
  • register_post_type $args (11)
  • register_post_type $args (12)
  • register_post_type $args (13)
  • register_post_type $args (14)
  • register_post_type $args (15)
  • Too exhaustive but worth it
  • Practice Custom Post
  • Next Week
Page 10: WordPress plugin #3

Entry Points

Q When the server is requestedA It is when client access via a URL

Q Why a URL is usedA To define a resource output to clientA To receive data input from client

Entry Points

Q Output FormA Whatever

Images audio video html documents

Q Input formA Generally submitting forms

via GETPOST method

Entry Points

There are some special entry points left for plugins

Menu items Shortcodes Admin post AJAX Redirecting Activation deactivation uninstall

Menu Items

Callback from admin menu clicking

add_menu_page()add_submenu_page()

remove_menu_page()remove_submenu_page()

Where is default menu

wp-adminmenu-headerphp

ltul id=adminmenugtltphp_wp_menu_output( $menu $submenu )

function _wp_menu_output( $menu $submenu $submenu_as_parent = true )

here menus are printed in html

Where is default menu

wp-adminmenuphp (adminphp includes it)wp-amdinincludesmenuphp

builds administrative menus

global $menu $submenu stores menu information

Our custom menus

wp-adminincludesmenuphp

do_action( admin_menu )

Menu API are defined in wp-adminincludespluginphp

add_menu_page

function add_menu_page( $page_title $menu_title $capability $menu_slug $function = $icon_url = $position = null )

$new_menu = array( $menu_title $capability $menu_slug $page_title menu-top $icon_class $hookname $hookname $icon_url )

if ( null === $position ) $menu[] = $new_menuelse $menu[$position] = $new_menu

add_submenu_page

function add_submenu_page( $parent_slug $page_title $menu_title $capability $menu_slug $function = ) $submenu[$parent_slug][] = array ( $menu_title $capability $menu_slug $page_title )

derivatives

add_dashboard_page() add_posts_page() add_media_page() add_pages_page() add_comments_page() add_theme_page() add_plugins_page() add_users_page() add_management_page() add_options_page()

Shortcodes

What is shortcodeA magic word in post content that is replaced by some process defined in plugin or themes in runtime

Good for displaying complex dynamic contents

Shortcodes

Sample[gallery id=123 size=medium][gallery]

or

[caption]My Caption[caption] enclosed form

Shortcodes

add_shortcode()

$shortcode_tags = array()function add_shortcode($tag $func) global $shortcode_tags

if ( is_callable($func) ) $shortcode_tags[$tag] = $func

Shortcodes

function do_shortcode($content) global $shortcode_tags

if ( false === strpos( $content [ ) ) return $content

if (empty($shortcode_tags) || is_array($shortcode_tags)) return $content

$pattern = get_shortcode_regex() return preg_replace_callback( $patterns do_shortcode_tag $content )

Shortcodes

function do_shortcode_tag( $m )

if ( isset( $m[5] ) ) enclosing tag - extra parameter return $m[1] call_user_func( $shortcode_tags[$tag] $attr $m[5] $tag ) $m[6] else self-closing tag return $m[1] call_user_func( $shortcode_tags[$tag] $attr null $tag ) $m[6]

Shortcodes

callback params $attrs attributes $content enclosed tags text $tag shortcode tag itself

Admin-post

Data from clientsProcessing requests

You can just process requests in your own page because $_REQUEST $_GET $_POST is global

Admin-post

But in your own handlerYou cannot use WP core functionsYou cannot authenticate

Do not reinvent the wheelSo there is admin-postphp

Admin-post

wp-adminadmin-postphpdefine amp include minimal settingsand do_action

$action = empty( $_REQUEST[action] ) $_REQUEST[action]

admin_post_nopriv admin_post_nopriv_$actionadmin_post admin_post_$action

finish using die() in callback function

AJAX

Very similar to admin-post but DOING_AJAX is defineddefine( DOING_AJAX true )

also use die() in callback function

if ( is_user_logged_in() ) do_action( wp_ajax_ $_REQUEST[action] ) else do_action( wp_ajax_nopriv_ $_REQUEST[action] ) Default statusdie( 0 )

Redirect

You can generate custom page in plugin by using template_redirect action

function my_page_template_redirect() if( is_page( goodies ) ampamp is_user_logged_in() )

wp_redirect( home_url( signup ) ) exit()

add_action( template_redirect my_page_template_redirect )

Redirect

You can generate web pages on-the-fly by utilizing these 3 hooks rewrite rule query parsing redirect

Detailed instructions later

(de)activation uninstall

register_activation_hook($file $cb)register_deactivation_hook($file $cb)register_uninstall_hook($file $cb)

$file full path of plugin file$cb callback function

callbacks should be SILENT No echo please

Summary

menu items shortcodes admin post ajax template redirects and (de)activation- uninstall hooks are good initial entry pointso It is a good strategy to find these

hooks in plugins first and dissect their codes from those points

I know you want to do something

You understand hook conceptYou know database detail

Now you know entry points

Definitely you wanna make something

Visit http[ip]practice and download entry-pointsphp

소스코드 http[ip]source-codes1 어드민 화면에 메뉴 추가2 쇼트코드 추가3 메뉴에서 admin post 전송4 메뉴에서 ajax 전송5redirect 테스트

ltauthorgt 부분은 자신의 이름으로 일괄변경하고 적절히 콜백 함수를 정의해 주세요

Source code explained

10 minutes break

Managing Your Own Contents

Wow there are too many things about posts

For today just focuse oncustom post type

Arguments are too complex

Just use Types or Pods pluginThats all problem solved

Yeah

of course you might not want this I was just kidding

Custom Post

You want to manage your own contentsThats why custom post is

Music collections Online store Event calendar Book data Photo portfolio

Custom Post Motivation

Well with just one type post and you may define many categories and use them to organize all contents

JUST ONE TYPE POSTMANY CATEGORIES

portfolio calendar music db

Custom Post Motivation

But you might feel that some post types should be hidden from some users even might be excluded from search may be only for private use may have very complex taxonomies

so that it should have its own territory

can be accessible from their own URL rules

Custom Post Motivation

Why re-invent wheel again

By extending built-in post type systemyou can REUSE whole facilities related to posts easily

UI and all thing about managing

Built-in Custom Post Types

wp-includespostphp (included in wp-settingsphp)function create_initial_post_types()

register_post_type( post array( register_post_type( page array( register_post_type( attachment array( register_post_type( revision array( register_post_type( nav_menu_item array( register_post_status( publish array(

register_post_type

ltphp register_post_type( $post_type $args ) gt

$arg is very complex

But I think it should be explained in detail Actually you cannot avoid it because eventuall all post type plugins will use that function too

Those plugins also have diffcult UIs too

register_post_type

Lets take a look how Types and Pods create their custom posts

They have easy (really) UI and provide better functionaliy but you can see horribly many options there

register_post_type $post_type

Up to 20 characters Only lowercase and numbers

register_post_type $args

publicvisible to authors

true impliesexclude_from_search falsepublicly_queryable show_in_nav_manues show_ui

false impliesexclude_from_search true publicly_queryable falseshow_in_nav_manues false show_ui false

register_post_type $args

labelplural descriptive name

egMusic CollectionsMostly localized text

register_post_type $args

labels more specific text labelsnamesigular_namemenu_namename_admin_barall_itemsadd_newadd_new_itemedit_itemview_itemsearch_items

search_itemsnot_foundnot_found in trashparent_item_colon

register_post_type $args

descriptionsummary of this post type

register_post_type $args

exclude_from_searchdo not search this post typetry S=beatbles

register_post_type $args

publicly_queryablecan use query

eg) post_type=music_collection

register_post_type $args

show_uidisplay default UI

register_post_type $args

show_in_nav_menusshow in navigation menus

be careful publicly_queryablemust be true

register_post_type $args

show_in_menushow admin_menu show_ui must be trueJust showing menutrue false else some strings

(toolsphp editphp)

altough it is falseyou can access URLS likewp-admineditphppost_type=music_collection(show_ui must be true)

register_post_type $args

show_in_admin_baravailable in admin bar

menu_postiondefault below comments

menu_iconsee dashicons

register_post_type $args

capability_typestring or array to build capabilites

in our exampeedit_music_collectionsedit_others_music_collections

publish_music_collectionsread_private_music_collections

register_post_type $args

capabilitiesto give specific names to each capability

map_meta_capif true default meta capability will be added

and then your role or account need capabilities

register_post_type $args

hierarchicalpost type can be hierarchicalthis is for page-styles

register_post_type $args

query_varto query posts query_var=slug

rewriteto use pretty permalinks

has_archiveEnables post type archive

register_post_type $args

permalink_epmaskrewrite endpoint bitmask

can_exporttrue makes the post can be exported

Too exhaustive but worth it

Practice Custom Post

Create custom-plugin-ltauthorgtphpCreate a simple custom post

Display admin menuHide admin_barWrite your post Any content is OK Include at least one meta field

Next Week

Customizing Visual Components List Table Screen Widgets

WordPress System Undercover Constants and Globals WPDB

  • WordPress Plugin 3
  • Recap
  • Recap (2)
  • Recap (3)
  • Recap (4)
  • Recap (5)
  • Todays Topics
  • Entry Points in Plugin
  • Entry Points
  • Entry Points (2)
  • Entry Points (3)
  • Entry Points (4)
  • Menu Items
  • Where is default menu
  • Where is default menu (2)
  • Our custom menus
  • add_menu_page
  • add_submenu_page
  • derivatives
  • Shortcodes
  • Shortcodes (2)
  • Shortcodes (3)
  • Shortcodes (4)
  • Shortcodes (5)
  • Shortcodes (6)
  • Admin-post
  • Admin-post (2)
  • Admin-post (3)
  • AJAX
  • Redirect
  • Redirect (2)
  • (de)activation uninstall
  • Summary
  • I know you want to do something
  • Slide 35
  • Source code explained
  • 10 minutes break
  • Managing Your Own Contents
  • Wow there are too many things about posts
  • For today just focuse on custom post type
  • Arguments are too complex
  • of course you might not want this I was just kidding
  • Custom Post
  • Custom Post Motivation
  • Custom Post Motivation (2)
  • Custom Post Motivation (3)
  • Built-in Custom Post Types
  • register_post_type
  • register_post_type (2)
  • register_post_type $post_type
  • register_post_type $args
  • register_post_type $args (2)
  • register_post_type $args (3)
  • register_post_type $args (4)
  • register_post_type $args (5)
  • register_post_type $args (6)
  • register_post_type $args (7)
  • register_post_type $args (8)
  • register_post_type $args (9)
  • register_post_type $args (10)
  • register_post_type $args (11)
  • register_post_type $args (12)
  • register_post_type $args (13)
  • register_post_type $args (14)
  • register_post_type $args (15)
  • Too exhaustive but worth it
  • Practice Custom Post
  • Next Week
Page 11: WordPress plugin #3

Entry Points

Q Output FormA Whatever

Images audio video html documents

Q Input formA Generally submitting forms

via GETPOST method

Entry Points

There are some special entry points left for plugins

Menu items Shortcodes Admin post AJAX Redirecting Activation deactivation uninstall

Menu Items

Callback from admin menu clicking

add_menu_page()add_submenu_page()

remove_menu_page()remove_submenu_page()

Where is default menu

wp-adminmenu-headerphp

ltul id=adminmenugtltphp_wp_menu_output( $menu $submenu )

function _wp_menu_output( $menu $submenu $submenu_as_parent = true )

here menus are printed in html

Where is default menu

wp-adminmenuphp (adminphp includes it)wp-amdinincludesmenuphp

builds administrative menus

global $menu $submenu stores menu information

Our custom menus

wp-adminincludesmenuphp

do_action( admin_menu )

Menu API are defined in wp-adminincludespluginphp

add_menu_page

function add_menu_page( $page_title $menu_title $capability $menu_slug $function = $icon_url = $position = null )

$new_menu = array( $menu_title $capability $menu_slug $page_title menu-top $icon_class $hookname $hookname $icon_url )

if ( null === $position ) $menu[] = $new_menuelse $menu[$position] = $new_menu

add_submenu_page

function add_submenu_page( $parent_slug $page_title $menu_title $capability $menu_slug $function = ) $submenu[$parent_slug][] = array ( $menu_title $capability $menu_slug $page_title )

derivatives

add_dashboard_page() add_posts_page() add_media_page() add_pages_page() add_comments_page() add_theme_page() add_plugins_page() add_users_page() add_management_page() add_options_page()

Shortcodes

What is shortcodeA magic word in post content that is replaced by some process defined in plugin or themes in runtime

Good for displaying complex dynamic contents

Shortcodes

Sample[gallery id=123 size=medium][gallery]

or

[caption]My Caption[caption] enclosed form

Shortcodes

add_shortcode()

$shortcode_tags = array()function add_shortcode($tag $func) global $shortcode_tags

if ( is_callable($func) ) $shortcode_tags[$tag] = $func

Shortcodes

function do_shortcode($content) global $shortcode_tags

if ( false === strpos( $content [ ) ) return $content

if (empty($shortcode_tags) || is_array($shortcode_tags)) return $content

$pattern = get_shortcode_regex() return preg_replace_callback( $patterns do_shortcode_tag $content )

Shortcodes

function do_shortcode_tag( $m )

if ( isset( $m[5] ) ) enclosing tag - extra parameter return $m[1] call_user_func( $shortcode_tags[$tag] $attr $m[5] $tag ) $m[6] else self-closing tag return $m[1] call_user_func( $shortcode_tags[$tag] $attr null $tag ) $m[6]

Shortcodes

callback params $attrs attributes $content enclosed tags text $tag shortcode tag itself

Admin-post

Data from clientsProcessing requests

You can just process requests in your own page because $_REQUEST $_GET $_POST is global

Admin-post

But in your own handlerYou cannot use WP core functionsYou cannot authenticate

Do not reinvent the wheelSo there is admin-postphp

Admin-post

wp-adminadmin-postphpdefine amp include minimal settingsand do_action

$action = empty( $_REQUEST[action] ) $_REQUEST[action]

admin_post_nopriv admin_post_nopriv_$actionadmin_post admin_post_$action

finish using die() in callback function

AJAX

Very similar to admin-post but DOING_AJAX is defineddefine( DOING_AJAX true )

also use die() in callback function

if ( is_user_logged_in() ) do_action( wp_ajax_ $_REQUEST[action] ) else do_action( wp_ajax_nopriv_ $_REQUEST[action] ) Default statusdie( 0 )

Redirect

You can generate custom page in plugin by using template_redirect action

function my_page_template_redirect() if( is_page( goodies ) ampamp is_user_logged_in() )

wp_redirect( home_url( signup ) ) exit()

add_action( template_redirect my_page_template_redirect )

Redirect

You can generate web pages on-the-fly by utilizing these 3 hooks rewrite rule query parsing redirect

Detailed instructions later

(de)activation uninstall

register_activation_hook($file $cb)register_deactivation_hook($file $cb)register_uninstall_hook($file $cb)

$file full path of plugin file$cb callback function

callbacks should be SILENT No echo please

Summary

menu items shortcodes admin post ajax template redirects and (de)activation- uninstall hooks are good initial entry pointso It is a good strategy to find these

hooks in plugins first and dissect their codes from those points

I know you want to do something

You understand hook conceptYou know database detail

Now you know entry points

Definitely you wanna make something

Visit http[ip]practice and download entry-pointsphp

소스코드 http[ip]source-codes1 어드민 화면에 메뉴 추가2 쇼트코드 추가3 메뉴에서 admin post 전송4 메뉴에서 ajax 전송5redirect 테스트

ltauthorgt 부분은 자신의 이름으로 일괄변경하고 적절히 콜백 함수를 정의해 주세요

Source code explained

10 minutes break

Managing Your Own Contents

Wow there are too many things about posts

For today just focuse oncustom post type

Arguments are too complex

Just use Types or Pods pluginThats all problem solved

Yeah

of course you might not want this I was just kidding

Custom Post

You want to manage your own contentsThats why custom post is

Music collections Online store Event calendar Book data Photo portfolio

Custom Post Motivation

Well with just one type post and you may define many categories and use them to organize all contents

JUST ONE TYPE POSTMANY CATEGORIES

portfolio calendar music db

Custom Post Motivation

But you might feel that some post types should be hidden from some users even might be excluded from search may be only for private use may have very complex taxonomies

so that it should have its own territory

can be accessible from their own URL rules

Custom Post Motivation

Why re-invent wheel again

By extending built-in post type systemyou can REUSE whole facilities related to posts easily

UI and all thing about managing

Built-in Custom Post Types

wp-includespostphp (included in wp-settingsphp)function create_initial_post_types()

register_post_type( post array( register_post_type( page array( register_post_type( attachment array( register_post_type( revision array( register_post_type( nav_menu_item array( register_post_status( publish array(

register_post_type

ltphp register_post_type( $post_type $args ) gt

$arg is very complex

But I think it should be explained in detail Actually you cannot avoid it because eventuall all post type plugins will use that function too

Those plugins also have diffcult UIs too

register_post_type

Lets take a look how Types and Pods create their custom posts

They have easy (really) UI and provide better functionaliy but you can see horribly many options there

register_post_type $post_type

Up to 20 characters Only lowercase and numbers

register_post_type $args

publicvisible to authors

true impliesexclude_from_search falsepublicly_queryable show_in_nav_manues show_ui

false impliesexclude_from_search true publicly_queryable falseshow_in_nav_manues false show_ui false

register_post_type $args

labelplural descriptive name

egMusic CollectionsMostly localized text

register_post_type $args

labels more specific text labelsnamesigular_namemenu_namename_admin_barall_itemsadd_newadd_new_itemedit_itemview_itemsearch_items

search_itemsnot_foundnot_found in trashparent_item_colon

register_post_type $args

descriptionsummary of this post type

register_post_type $args

exclude_from_searchdo not search this post typetry S=beatbles

register_post_type $args

publicly_queryablecan use query

eg) post_type=music_collection

register_post_type $args

show_uidisplay default UI

register_post_type $args

show_in_nav_menusshow in navigation menus

be careful publicly_queryablemust be true

register_post_type $args

show_in_menushow admin_menu show_ui must be trueJust showing menutrue false else some strings

(toolsphp editphp)

altough it is falseyou can access URLS likewp-admineditphppost_type=music_collection(show_ui must be true)

register_post_type $args

show_in_admin_baravailable in admin bar

menu_postiondefault below comments

menu_iconsee dashicons

register_post_type $args

capability_typestring or array to build capabilites

in our exampeedit_music_collectionsedit_others_music_collections

publish_music_collectionsread_private_music_collections

register_post_type $args

capabilitiesto give specific names to each capability

map_meta_capif true default meta capability will be added

and then your role or account need capabilities

register_post_type $args

hierarchicalpost type can be hierarchicalthis is for page-styles

register_post_type $args

query_varto query posts query_var=slug

rewriteto use pretty permalinks

has_archiveEnables post type archive

register_post_type $args

permalink_epmaskrewrite endpoint bitmask

can_exporttrue makes the post can be exported

Too exhaustive but worth it

Practice Custom Post

Create custom-plugin-ltauthorgtphpCreate a simple custom post

Display admin menuHide admin_barWrite your post Any content is OK Include at least one meta field

Next Week

Customizing Visual Components List Table Screen Widgets

WordPress System Undercover Constants and Globals WPDB

  • WordPress Plugin 3
  • Recap
  • Recap (2)
  • Recap (3)
  • Recap (4)
  • Recap (5)
  • Todays Topics
  • Entry Points in Plugin
  • Entry Points
  • Entry Points (2)
  • Entry Points (3)
  • Entry Points (4)
  • Menu Items
  • Where is default menu
  • Where is default menu (2)
  • Our custom menus
  • add_menu_page
  • add_submenu_page
  • derivatives
  • Shortcodes
  • Shortcodes (2)
  • Shortcodes (3)
  • Shortcodes (4)
  • Shortcodes (5)
  • Shortcodes (6)
  • Admin-post
  • Admin-post (2)
  • Admin-post (3)
  • AJAX
  • Redirect
  • Redirect (2)
  • (de)activation uninstall
  • Summary
  • I know you want to do something
  • Slide 35
  • Source code explained
  • 10 minutes break
  • Managing Your Own Contents
  • Wow there are too many things about posts
  • For today just focuse on custom post type
  • Arguments are too complex
  • of course you might not want this I was just kidding
  • Custom Post
  • Custom Post Motivation
  • Custom Post Motivation (2)
  • Custom Post Motivation (3)
  • Built-in Custom Post Types
  • register_post_type
  • register_post_type (2)
  • register_post_type $post_type
  • register_post_type $args
  • register_post_type $args (2)
  • register_post_type $args (3)
  • register_post_type $args (4)
  • register_post_type $args (5)
  • register_post_type $args (6)
  • register_post_type $args (7)
  • register_post_type $args (8)
  • register_post_type $args (9)
  • register_post_type $args (10)
  • register_post_type $args (11)
  • register_post_type $args (12)
  • register_post_type $args (13)
  • register_post_type $args (14)
  • register_post_type $args (15)
  • Too exhaustive but worth it
  • Practice Custom Post
  • Next Week
Page 12: WordPress plugin #3

Entry Points

There are some special entry points left for plugins

Menu items Shortcodes Admin post AJAX Redirecting Activation deactivation uninstall

Menu Items

Callback from admin menu clicking

add_menu_page()add_submenu_page()

remove_menu_page()remove_submenu_page()

Where is default menu

wp-adminmenu-headerphp

ltul id=adminmenugtltphp_wp_menu_output( $menu $submenu )

function _wp_menu_output( $menu $submenu $submenu_as_parent = true )

here menus are printed in html

Where is default menu

wp-adminmenuphp (adminphp includes it)wp-amdinincludesmenuphp

builds administrative menus

global $menu $submenu stores menu information

Our custom menus

wp-adminincludesmenuphp

do_action( admin_menu )

Menu API are defined in wp-adminincludespluginphp

add_menu_page

function add_menu_page( $page_title $menu_title $capability $menu_slug $function = $icon_url = $position = null )

$new_menu = array( $menu_title $capability $menu_slug $page_title menu-top $icon_class $hookname $hookname $icon_url )

if ( null === $position ) $menu[] = $new_menuelse $menu[$position] = $new_menu

add_submenu_page

function add_submenu_page( $parent_slug $page_title $menu_title $capability $menu_slug $function = ) $submenu[$parent_slug][] = array ( $menu_title $capability $menu_slug $page_title )

derivatives

add_dashboard_page() add_posts_page() add_media_page() add_pages_page() add_comments_page() add_theme_page() add_plugins_page() add_users_page() add_management_page() add_options_page()

Shortcodes

What is shortcodeA magic word in post content that is replaced by some process defined in plugin or themes in runtime

Good for displaying complex dynamic contents

Shortcodes

Sample[gallery id=123 size=medium][gallery]

or

[caption]My Caption[caption] enclosed form

Shortcodes

add_shortcode()

$shortcode_tags = array()function add_shortcode($tag $func) global $shortcode_tags

if ( is_callable($func) ) $shortcode_tags[$tag] = $func

Shortcodes

function do_shortcode($content) global $shortcode_tags

if ( false === strpos( $content [ ) ) return $content

if (empty($shortcode_tags) || is_array($shortcode_tags)) return $content

$pattern = get_shortcode_regex() return preg_replace_callback( $patterns do_shortcode_tag $content )

Shortcodes

function do_shortcode_tag( $m )

if ( isset( $m[5] ) ) enclosing tag - extra parameter return $m[1] call_user_func( $shortcode_tags[$tag] $attr $m[5] $tag ) $m[6] else self-closing tag return $m[1] call_user_func( $shortcode_tags[$tag] $attr null $tag ) $m[6]

Shortcodes

callback params $attrs attributes $content enclosed tags text $tag shortcode tag itself

Admin-post

Data from clientsProcessing requests

You can just process requests in your own page because $_REQUEST $_GET $_POST is global

Admin-post

But in your own handlerYou cannot use WP core functionsYou cannot authenticate

Do not reinvent the wheelSo there is admin-postphp

Admin-post

wp-adminadmin-postphpdefine amp include minimal settingsand do_action

$action = empty( $_REQUEST[action] ) $_REQUEST[action]

admin_post_nopriv admin_post_nopriv_$actionadmin_post admin_post_$action

finish using die() in callback function

AJAX

Very similar to admin-post but DOING_AJAX is defineddefine( DOING_AJAX true )

also use die() in callback function

if ( is_user_logged_in() ) do_action( wp_ajax_ $_REQUEST[action] ) else do_action( wp_ajax_nopriv_ $_REQUEST[action] ) Default statusdie( 0 )

Redirect

You can generate custom page in plugin by using template_redirect action

function my_page_template_redirect() if( is_page( goodies ) ampamp is_user_logged_in() )

wp_redirect( home_url( signup ) ) exit()

add_action( template_redirect my_page_template_redirect )

Redirect

You can generate web pages on-the-fly by utilizing these 3 hooks rewrite rule query parsing redirect

Detailed instructions later

(de)activation uninstall

register_activation_hook($file $cb)register_deactivation_hook($file $cb)register_uninstall_hook($file $cb)

$file full path of plugin file$cb callback function

callbacks should be SILENT No echo please

Summary

menu items shortcodes admin post ajax template redirects and (de)activation- uninstall hooks are good initial entry pointso It is a good strategy to find these

hooks in plugins first and dissect their codes from those points

I know you want to do something

You understand hook conceptYou know database detail

Now you know entry points

Definitely you wanna make something

Visit http[ip]practice and download entry-pointsphp

소스코드 http[ip]source-codes1 어드민 화면에 메뉴 추가2 쇼트코드 추가3 메뉴에서 admin post 전송4 메뉴에서 ajax 전송5redirect 테스트

ltauthorgt 부분은 자신의 이름으로 일괄변경하고 적절히 콜백 함수를 정의해 주세요

Source code explained

10 minutes break

Managing Your Own Contents

Wow there are too many things about posts

For today just focuse oncustom post type

Arguments are too complex

Just use Types or Pods pluginThats all problem solved

Yeah

of course you might not want this I was just kidding

Custom Post

You want to manage your own contentsThats why custom post is

Music collections Online store Event calendar Book data Photo portfolio

Custom Post Motivation

Well with just one type post and you may define many categories and use them to organize all contents

JUST ONE TYPE POSTMANY CATEGORIES

portfolio calendar music db

Custom Post Motivation

But you might feel that some post types should be hidden from some users even might be excluded from search may be only for private use may have very complex taxonomies

so that it should have its own territory

can be accessible from their own URL rules

Custom Post Motivation

Why re-invent wheel again

By extending built-in post type systemyou can REUSE whole facilities related to posts easily

UI and all thing about managing

Built-in Custom Post Types

wp-includespostphp (included in wp-settingsphp)function create_initial_post_types()

register_post_type( post array( register_post_type( page array( register_post_type( attachment array( register_post_type( revision array( register_post_type( nav_menu_item array( register_post_status( publish array(

register_post_type

ltphp register_post_type( $post_type $args ) gt

$arg is very complex

But I think it should be explained in detail Actually you cannot avoid it because eventuall all post type plugins will use that function too

Those plugins also have diffcult UIs too

register_post_type

Lets take a look how Types and Pods create their custom posts

They have easy (really) UI and provide better functionaliy but you can see horribly many options there

register_post_type $post_type

Up to 20 characters Only lowercase and numbers

register_post_type $args

publicvisible to authors

true impliesexclude_from_search falsepublicly_queryable show_in_nav_manues show_ui

false impliesexclude_from_search true publicly_queryable falseshow_in_nav_manues false show_ui false

register_post_type $args

labelplural descriptive name

egMusic CollectionsMostly localized text

register_post_type $args

labels more specific text labelsnamesigular_namemenu_namename_admin_barall_itemsadd_newadd_new_itemedit_itemview_itemsearch_items

search_itemsnot_foundnot_found in trashparent_item_colon

register_post_type $args

descriptionsummary of this post type

register_post_type $args

exclude_from_searchdo not search this post typetry S=beatbles

register_post_type $args

publicly_queryablecan use query

eg) post_type=music_collection

register_post_type $args

show_uidisplay default UI

register_post_type $args

show_in_nav_menusshow in navigation menus

be careful publicly_queryablemust be true

register_post_type $args

show_in_menushow admin_menu show_ui must be trueJust showing menutrue false else some strings

(toolsphp editphp)

altough it is falseyou can access URLS likewp-admineditphppost_type=music_collection(show_ui must be true)

register_post_type $args

show_in_admin_baravailable in admin bar

menu_postiondefault below comments

menu_iconsee dashicons

register_post_type $args

capability_typestring or array to build capabilites

in our exampeedit_music_collectionsedit_others_music_collections

publish_music_collectionsread_private_music_collections

register_post_type $args

capabilitiesto give specific names to each capability

map_meta_capif true default meta capability will be added

and then your role or account need capabilities

register_post_type $args

hierarchicalpost type can be hierarchicalthis is for page-styles

register_post_type $args

query_varto query posts query_var=slug

rewriteto use pretty permalinks

has_archiveEnables post type archive

register_post_type $args

permalink_epmaskrewrite endpoint bitmask

can_exporttrue makes the post can be exported

Too exhaustive but worth it

Practice Custom Post

Create custom-plugin-ltauthorgtphpCreate a simple custom post

Display admin menuHide admin_barWrite your post Any content is OK Include at least one meta field

Next Week

Customizing Visual Components List Table Screen Widgets

WordPress System Undercover Constants and Globals WPDB

  • WordPress Plugin 3
  • Recap
  • Recap (2)
  • Recap (3)
  • Recap (4)
  • Recap (5)
  • Todays Topics
  • Entry Points in Plugin
  • Entry Points
  • Entry Points (2)
  • Entry Points (3)
  • Entry Points (4)
  • Menu Items
  • Where is default menu
  • Where is default menu (2)
  • Our custom menus
  • add_menu_page
  • add_submenu_page
  • derivatives
  • Shortcodes
  • Shortcodes (2)
  • Shortcodes (3)
  • Shortcodes (4)
  • Shortcodes (5)
  • Shortcodes (6)
  • Admin-post
  • Admin-post (2)
  • Admin-post (3)
  • AJAX
  • Redirect
  • Redirect (2)
  • (de)activation uninstall
  • Summary
  • I know you want to do something
  • Slide 35
  • Source code explained
  • 10 minutes break
  • Managing Your Own Contents
  • Wow there are too many things about posts
  • For today just focuse on custom post type
  • Arguments are too complex
  • of course you might not want this I was just kidding
  • Custom Post
  • Custom Post Motivation
  • Custom Post Motivation (2)
  • Custom Post Motivation (3)
  • Built-in Custom Post Types
  • register_post_type
  • register_post_type (2)
  • register_post_type $post_type
  • register_post_type $args
  • register_post_type $args (2)
  • register_post_type $args (3)
  • register_post_type $args (4)
  • register_post_type $args (5)
  • register_post_type $args (6)
  • register_post_type $args (7)
  • register_post_type $args (8)
  • register_post_type $args (9)
  • register_post_type $args (10)
  • register_post_type $args (11)
  • register_post_type $args (12)
  • register_post_type $args (13)
  • register_post_type $args (14)
  • register_post_type $args (15)
  • Too exhaustive but worth it
  • Practice Custom Post
  • Next Week
Page 13: WordPress plugin #3

Menu Items

Callback from admin menu clicking

add_menu_page()add_submenu_page()

remove_menu_page()remove_submenu_page()

Where is default menu

wp-adminmenu-headerphp

ltul id=adminmenugtltphp_wp_menu_output( $menu $submenu )

function _wp_menu_output( $menu $submenu $submenu_as_parent = true )

here menus are printed in html

Where is default menu

wp-adminmenuphp (adminphp includes it)wp-amdinincludesmenuphp

builds administrative menus

global $menu $submenu stores menu information

Our custom menus

wp-adminincludesmenuphp

do_action( admin_menu )

Menu API are defined in wp-adminincludespluginphp

add_menu_page

function add_menu_page( $page_title $menu_title $capability $menu_slug $function = $icon_url = $position = null )

$new_menu = array( $menu_title $capability $menu_slug $page_title menu-top $icon_class $hookname $hookname $icon_url )

if ( null === $position ) $menu[] = $new_menuelse $menu[$position] = $new_menu

add_submenu_page

function add_submenu_page( $parent_slug $page_title $menu_title $capability $menu_slug $function = ) $submenu[$parent_slug][] = array ( $menu_title $capability $menu_slug $page_title )

derivatives

add_dashboard_page() add_posts_page() add_media_page() add_pages_page() add_comments_page() add_theme_page() add_plugins_page() add_users_page() add_management_page() add_options_page()

Shortcodes

What is shortcodeA magic word in post content that is replaced by some process defined in plugin or themes in runtime

Good for displaying complex dynamic contents

Shortcodes

Sample[gallery id=123 size=medium][gallery]

or

[caption]My Caption[caption] enclosed form

Shortcodes

add_shortcode()

$shortcode_tags = array()function add_shortcode($tag $func) global $shortcode_tags

if ( is_callable($func) ) $shortcode_tags[$tag] = $func

Shortcodes

function do_shortcode($content) global $shortcode_tags

if ( false === strpos( $content [ ) ) return $content

if (empty($shortcode_tags) || is_array($shortcode_tags)) return $content

$pattern = get_shortcode_regex() return preg_replace_callback( $patterns do_shortcode_tag $content )

Shortcodes

function do_shortcode_tag( $m )

if ( isset( $m[5] ) ) enclosing tag - extra parameter return $m[1] call_user_func( $shortcode_tags[$tag] $attr $m[5] $tag ) $m[6] else self-closing tag return $m[1] call_user_func( $shortcode_tags[$tag] $attr null $tag ) $m[6]

Shortcodes

callback params $attrs attributes $content enclosed tags text $tag shortcode tag itself

Admin-post

Data from clientsProcessing requests

You can just process requests in your own page because $_REQUEST $_GET $_POST is global

Admin-post

But in your own handlerYou cannot use WP core functionsYou cannot authenticate

Do not reinvent the wheelSo there is admin-postphp

Admin-post

wp-adminadmin-postphpdefine amp include minimal settingsand do_action

$action = empty( $_REQUEST[action] ) $_REQUEST[action]

admin_post_nopriv admin_post_nopriv_$actionadmin_post admin_post_$action

finish using die() in callback function

AJAX

Very similar to admin-post but DOING_AJAX is defineddefine( DOING_AJAX true )

also use die() in callback function

if ( is_user_logged_in() ) do_action( wp_ajax_ $_REQUEST[action] ) else do_action( wp_ajax_nopriv_ $_REQUEST[action] ) Default statusdie( 0 )

Redirect

You can generate custom page in plugin by using template_redirect action

function my_page_template_redirect() if( is_page( goodies ) ampamp is_user_logged_in() )

wp_redirect( home_url( signup ) ) exit()

add_action( template_redirect my_page_template_redirect )

Redirect

You can generate web pages on-the-fly by utilizing these 3 hooks rewrite rule query parsing redirect

Detailed instructions later

(de)activation uninstall

register_activation_hook($file $cb)register_deactivation_hook($file $cb)register_uninstall_hook($file $cb)

$file full path of plugin file$cb callback function

callbacks should be SILENT No echo please

Summary

menu items shortcodes admin post ajax template redirects and (de)activation- uninstall hooks are good initial entry pointso It is a good strategy to find these

hooks in plugins first and dissect their codes from those points

I know you want to do something

You understand hook conceptYou know database detail

Now you know entry points

Definitely you wanna make something

Visit http[ip]practice and download entry-pointsphp

소스코드 http[ip]source-codes1 어드민 화면에 메뉴 추가2 쇼트코드 추가3 메뉴에서 admin post 전송4 메뉴에서 ajax 전송5redirect 테스트

ltauthorgt 부분은 자신의 이름으로 일괄변경하고 적절히 콜백 함수를 정의해 주세요

Source code explained

10 minutes break

Managing Your Own Contents

Wow there are too many things about posts

For today just focuse oncustom post type

Arguments are too complex

Just use Types or Pods pluginThats all problem solved

Yeah

of course you might not want this I was just kidding

Custom Post

You want to manage your own contentsThats why custom post is

Music collections Online store Event calendar Book data Photo portfolio

Custom Post Motivation

Well with just one type post and you may define many categories and use them to organize all contents

JUST ONE TYPE POSTMANY CATEGORIES

portfolio calendar music db

Custom Post Motivation

But you might feel that some post types should be hidden from some users even might be excluded from search may be only for private use may have very complex taxonomies

so that it should have its own territory

can be accessible from their own URL rules

Custom Post Motivation

Why re-invent wheel again

By extending built-in post type systemyou can REUSE whole facilities related to posts easily

UI and all thing about managing

Built-in Custom Post Types

wp-includespostphp (included in wp-settingsphp)function create_initial_post_types()

register_post_type( post array( register_post_type( page array( register_post_type( attachment array( register_post_type( revision array( register_post_type( nav_menu_item array( register_post_status( publish array(

register_post_type

ltphp register_post_type( $post_type $args ) gt

$arg is very complex

But I think it should be explained in detail Actually you cannot avoid it because eventuall all post type plugins will use that function too

Those plugins also have diffcult UIs too

register_post_type

Lets take a look how Types and Pods create their custom posts

They have easy (really) UI and provide better functionaliy but you can see horribly many options there

register_post_type $post_type

Up to 20 characters Only lowercase and numbers

register_post_type $args

publicvisible to authors

true impliesexclude_from_search falsepublicly_queryable show_in_nav_manues show_ui

false impliesexclude_from_search true publicly_queryable falseshow_in_nav_manues false show_ui false

register_post_type $args

labelplural descriptive name

egMusic CollectionsMostly localized text

register_post_type $args

labels more specific text labelsnamesigular_namemenu_namename_admin_barall_itemsadd_newadd_new_itemedit_itemview_itemsearch_items

search_itemsnot_foundnot_found in trashparent_item_colon

register_post_type $args

descriptionsummary of this post type

register_post_type $args

exclude_from_searchdo not search this post typetry S=beatbles

register_post_type $args

publicly_queryablecan use query

eg) post_type=music_collection

register_post_type $args

show_uidisplay default UI

register_post_type $args

show_in_nav_menusshow in navigation menus

be careful publicly_queryablemust be true

register_post_type $args

show_in_menushow admin_menu show_ui must be trueJust showing menutrue false else some strings

(toolsphp editphp)

altough it is falseyou can access URLS likewp-admineditphppost_type=music_collection(show_ui must be true)

register_post_type $args

show_in_admin_baravailable in admin bar

menu_postiondefault below comments

menu_iconsee dashicons

register_post_type $args

capability_typestring or array to build capabilites

in our exampeedit_music_collectionsedit_others_music_collections

publish_music_collectionsread_private_music_collections

register_post_type $args

capabilitiesto give specific names to each capability

map_meta_capif true default meta capability will be added

and then your role or account need capabilities

register_post_type $args

hierarchicalpost type can be hierarchicalthis is for page-styles

register_post_type $args

query_varto query posts query_var=slug

rewriteto use pretty permalinks

has_archiveEnables post type archive

register_post_type $args

permalink_epmaskrewrite endpoint bitmask

can_exporttrue makes the post can be exported

Too exhaustive but worth it

Practice Custom Post

Create custom-plugin-ltauthorgtphpCreate a simple custom post

Display admin menuHide admin_barWrite your post Any content is OK Include at least one meta field

Next Week

Customizing Visual Components List Table Screen Widgets

WordPress System Undercover Constants and Globals WPDB

  • WordPress Plugin 3
  • Recap
  • Recap (2)
  • Recap (3)
  • Recap (4)
  • Recap (5)
  • Todays Topics
  • Entry Points in Plugin
  • Entry Points
  • Entry Points (2)
  • Entry Points (3)
  • Entry Points (4)
  • Menu Items
  • Where is default menu
  • Where is default menu (2)
  • Our custom menus
  • add_menu_page
  • add_submenu_page
  • derivatives
  • Shortcodes
  • Shortcodes (2)
  • Shortcodes (3)
  • Shortcodes (4)
  • Shortcodes (5)
  • Shortcodes (6)
  • Admin-post
  • Admin-post (2)
  • Admin-post (3)
  • AJAX
  • Redirect
  • Redirect (2)
  • (de)activation uninstall
  • Summary
  • I know you want to do something
  • Slide 35
  • Source code explained
  • 10 minutes break
  • Managing Your Own Contents
  • Wow there are too many things about posts
  • For today just focuse on custom post type
  • Arguments are too complex
  • of course you might not want this I was just kidding
  • Custom Post
  • Custom Post Motivation
  • Custom Post Motivation (2)
  • Custom Post Motivation (3)
  • Built-in Custom Post Types
  • register_post_type
  • register_post_type (2)
  • register_post_type $post_type
  • register_post_type $args
  • register_post_type $args (2)
  • register_post_type $args (3)
  • register_post_type $args (4)
  • register_post_type $args (5)
  • register_post_type $args (6)
  • register_post_type $args (7)
  • register_post_type $args (8)
  • register_post_type $args (9)
  • register_post_type $args (10)
  • register_post_type $args (11)
  • register_post_type $args (12)
  • register_post_type $args (13)
  • register_post_type $args (14)
  • register_post_type $args (15)
  • Too exhaustive but worth it
  • Practice Custom Post
  • Next Week
Page 14: WordPress plugin #3

Where is default menu

wp-adminmenu-headerphp

ltul id=adminmenugtltphp_wp_menu_output( $menu $submenu )

function _wp_menu_output( $menu $submenu $submenu_as_parent = true )

here menus are printed in html

Where is default menu

wp-adminmenuphp (adminphp includes it)wp-amdinincludesmenuphp

builds administrative menus

global $menu $submenu stores menu information

Our custom menus

wp-adminincludesmenuphp

do_action( admin_menu )

Menu API are defined in wp-adminincludespluginphp

add_menu_page

function add_menu_page( $page_title $menu_title $capability $menu_slug $function = $icon_url = $position = null )

$new_menu = array( $menu_title $capability $menu_slug $page_title menu-top $icon_class $hookname $hookname $icon_url )

if ( null === $position ) $menu[] = $new_menuelse $menu[$position] = $new_menu

add_submenu_page

function add_submenu_page( $parent_slug $page_title $menu_title $capability $menu_slug $function = ) $submenu[$parent_slug][] = array ( $menu_title $capability $menu_slug $page_title )

derivatives

add_dashboard_page() add_posts_page() add_media_page() add_pages_page() add_comments_page() add_theme_page() add_plugins_page() add_users_page() add_management_page() add_options_page()

Shortcodes

What is shortcodeA magic word in post content that is replaced by some process defined in plugin or themes in runtime

Good for displaying complex dynamic contents

Shortcodes

Sample[gallery id=123 size=medium][gallery]

or

[caption]My Caption[caption] enclosed form

Shortcodes

add_shortcode()

$shortcode_tags = array()function add_shortcode($tag $func) global $shortcode_tags

if ( is_callable($func) ) $shortcode_tags[$tag] = $func

Shortcodes

function do_shortcode($content) global $shortcode_tags

if ( false === strpos( $content [ ) ) return $content

if (empty($shortcode_tags) || is_array($shortcode_tags)) return $content

$pattern = get_shortcode_regex() return preg_replace_callback( $patterns do_shortcode_tag $content )

Shortcodes

function do_shortcode_tag( $m )

if ( isset( $m[5] ) ) enclosing tag - extra parameter return $m[1] call_user_func( $shortcode_tags[$tag] $attr $m[5] $tag ) $m[6] else self-closing tag return $m[1] call_user_func( $shortcode_tags[$tag] $attr null $tag ) $m[6]

Shortcodes

callback params $attrs attributes $content enclosed tags text $tag shortcode tag itself

Admin-post

Data from clientsProcessing requests

You can just process requests in your own page because $_REQUEST $_GET $_POST is global

Admin-post

But in your own handlerYou cannot use WP core functionsYou cannot authenticate

Do not reinvent the wheelSo there is admin-postphp

Admin-post

wp-adminadmin-postphpdefine amp include minimal settingsand do_action

$action = empty( $_REQUEST[action] ) $_REQUEST[action]

admin_post_nopriv admin_post_nopriv_$actionadmin_post admin_post_$action

finish using die() in callback function

AJAX

Very similar to admin-post but DOING_AJAX is defineddefine( DOING_AJAX true )

also use die() in callback function

if ( is_user_logged_in() ) do_action( wp_ajax_ $_REQUEST[action] ) else do_action( wp_ajax_nopriv_ $_REQUEST[action] ) Default statusdie( 0 )

Redirect

You can generate custom page in plugin by using template_redirect action

function my_page_template_redirect() if( is_page( goodies ) ampamp is_user_logged_in() )

wp_redirect( home_url( signup ) ) exit()

add_action( template_redirect my_page_template_redirect )

Redirect

You can generate web pages on-the-fly by utilizing these 3 hooks rewrite rule query parsing redirect

Detailed instructions later

(de)activation uninstall

register_activation_hook($file $cb)register_deactivation_hook($file $cb)register_uninstall_hook($file $cb)

$file full path of plugin file$cb callback function

callbacks should be SILENT No echo please

Summary

menu items shortcodes admin post ajax template redirects and (de)activation- uninstall hooks are good initial entry pointso It is a good strategy to find these

hooks in plugins first and dissect their codes from those points

I know you want to do something

You understand hook conceptYou know database detail

Now you know entry points

Definitely you wanna make something

Visit http[ip]practice and download entry-pointsphp

소스코드 http[ip]source-codes1 어드민 화면에 메뉴 추가2 쇼트코드 추가3 메뉴에서 admin post 전송4 메뉴에서 ajax 전송5redirect 테스트

ltauthorgt 부분은 자신의 이름으로 일괄변경하고 적절히 콜백 함수를 정의해 주세요

Source code explained

10 minutes break

Managing Your Own Contents

Wow there are too many things about posts

For today just focuse oncustom post type

Arguments are too complex

Just use Types or Pods pluginThats all problem solved

Yeah

of course you might not want this I was just kidding

Custom Post

You want to manage your own contentsThats why custom post is

Music collections Online store Event calendar Book data Photo portfolio

Custom Post Motivation

Well with just one type post and you may define many categories and use them to organize all contents

JUST ONE TYPE POSTMANY CATEGORIES

portfolio calendar music db

Custom Post Motivation

But you might feel that some post types should be hidden from some users even might be excluded from search may be only for private use may have very complex taxonomies

so that it should have its own territory

can be accessible from their own URL rules

Custom Post Motivation

Why re-invent wheel again

By extending built-in post type systemyou can REUSE whole facilities related to posts easily

UI and all thing about managing

Built-in Custom Post Types

wp-includespostphp (included in wp-settingsphp)function create_initial_post_types()

register_post_type( post array( register_post_type( page array( register_post_type( attachment array( register_post_type( revision array( register_post_type( nav_menu_item array( register_post_status( publish array(

register_post_type

ltphp register_post_type( $post_type $args ) gt

$arg is very complex

But I think it should be explained in detail Actually you cannot avoid it because eventuall all post type plugins will use that function too

Those plugins also have diffcult UIs too

register_post_type

Lets take a look how Types and Pods create their custom posts

They have easy (really) UI and provide better functionaliy but you can see horribly many options there

register_post_type $post_type

Up to 20 characters Only lowercase and numbers

register_post_type $args

publicvisible to authors

true impliesexclude_from_search falsepublicly_queryable show_in_nav_manues show_ui

false impliesexclude_from_search true publicly_queryable falseshow_in_nav_manues false show_ui false

register_post_type $args

labelplural descriptive name

egMusic CollectionsMostly localized text

register_post_type $args

labels more specific text labelsnamesigular_namemenu_namename_admin_barall_itemsadd_newadd_new_itemedit_itemview_itemsearch_items

search_itemsnot_foundnot_found in trashparent_item_colon

register_post_type $args

descriptionsummary of this post type

register_post_type $args

exclude_from_searchdo not search this post typetry S=beatbles

register_post_type $args

publicly_queryablecan use query

eg) post_type=music_collection

register_post_type $args

show_uidisplay default UI

register_post_type $args

show_in_nav_menusshow in navigation menus

be careful publicly_queryablemust be true

register_post_type $args

show_in_menushow admin_menu show_ui must be trueJust showing menutrue false else some strings

(toolsphp editphp)

altough it is falseyou can access URLS likewp-admineditphppost_type=music_collection(show_ui must be true)

register_post_type $args

show_in_admin_baravailable in admin bar

menu_postiondefault below comments

menu_iconsee dashicons

register_post_type $args

capability_typestring or array to build capabilites

in our exampeedit_music_collectionsedit_others_music_collections

publish_music_collectionsread_private_music_collections

register_post_type $args

capabilitiesto give specific names to each capability

map_meta_capif true default meta capability will be added

and then your role or account need capabilities

register_post_type $args

hierarchicalpost type can be hierarchicalthis is for page-styles

register_post_type $args

query_varto query posts query_var=slug

rewriteto use pretty permalinks

has_archiveEnables post type archive

register_post_type $args

permalink_epmaskrewrite endpoint bitmask

can_exporttrue makes the post can be exported

Too exhaustive but worth it

Practice Custom Post

Create custom-plugin-ltauthorgtphpCreate a simple custom post

Display admin menuHide admin_barWrite your post Any content is OK Include at least one meta field

Next Week

Customizing Visual Components List Table Screen Widgets

WordPress System Undercover Constants and Globals WPDB

  • WordPress Plugin 3
  • Recap
  • Recap (2)
  • Recap (3)
  • Recap (4)
  • Recap (5)
  • Todays Topics
  • Entry Points in Plugin
  • Entry Points
  • Entry Points (2)
  • Entry Points (3)
  • Entry Points (4)
  • Menu Items
  • Where is default menu
  • Where is default menu (2)
  • Our custom menus
  • add_menu_page
  • add_submenu_page
  • derivatives
  • Shortcodes
  • Shortcodes (2)
  • Shortcodes (3)
  • Shortcodes (4)
  • Shortcodes (5)
  • Shortcodes (6)
  • Admin-post
  • Admin-post (2)
  • Admin-post (3)
  • AJAX
  • Redirect
  • Redirect (2)
  • (de)activation uninstall
  • Summary
  • I know you want to do something
  • Slide 35
  • Source code explained
  • 10 minutes break
  • Managing Your Own Contents
  • Wow there are too many things about posts
  • For today just focuse on custom post type
  • Arguments are too complex
  • of course you might not want this I was just kidding
  • Custom Post
  • Custom Post Motivation
  • Custom Post Motivation (2)
  • Custom Post Motivation (3)
  • Built-in Custom Post Types
  • register_post_type
  • register_post_type (2)
  • register_post_type $post_type
  • register_post_type $args
  • register_post_type $args (2)
  • register_post_type $args (3)
  • register_post_type $args (4)
  • register_post_type $args (5)
  • register_post_type $args (6)
  • register_post_type $args (7)
  • register_post_type $args (8)
  • register_post_type $args (9)
  • register_post_type $args (10)
  • register_post_type $args (11)
  • register_post_type $args (12)
  • register_post_type $args (13)
  • register_post_type $args (14)
  • register_post_type $args (15)
  • Too exhaustive but worth it
  • Practice Custom Post
  • Next Week
Page 15: WordPress plugin #3

Where is default menu

wp-adminmenuphp (adminphp includes it)wp-amdinincludesmenuphp

builds administrative menus

global $menu $submenu stores menu information

Our custom menus

wp-adminincludesmenuphp

do_action( admin_menu )

Menu API are defined in wp-adminincludespluginphp

add_menu_page

function add_menu_page( $page_title $menu_title $capability $menu_slug $function = $icon_url = $position = null )

$new_menu = array( $menu_title $capability $menu_slug $page_title menu-top $icon_class $hookname $hookname $icon_url )

if ( null === $position ) $menu[] = $new_menuelse $menu[$position] = $new_menu

add_submenu_page

function add_submenu_page( $parent_slug $page_title $menu_title $capability $menu_slug $function = ) $submenu[$parent_slug][] = array ( $menu_title $capability $menu_slug $page_title )

derivatives

add_dashboard_page() add_posts_page() add_media_page() add_pages_page() add_comments_page() add_theme_page() add_plugins_page() add_users_page() add_management_page() add_options_page()

Shortcodes

What is shortcodeA magic word in post content that is replaced by some process defined in plugin or themes in runtime

Good for displaying complex dynamic contents

Shortcodes

Sample[gallery id=123 size=medium][gallery]

or

[caption]My Caption[caption] enclosed form

Shortcodes

add_shortcode()

$shortcode_tags = array()function add_shortcode($tag $func) global $shortcode_tags

if ( is_callable($func) ) $shortcode_tags[$tag] = $func

Shortcodes

function do_shortcode($content) global $shortcode_tags

if ( false === strpos( $content [ ) ) return $content

if (empty($shortcode_tags) || is_array($shortcode_tags)) return $content

$pattern = get_shortcode_regex() return preg_replace_callback( $patterns do_shortcode_tag $content )

Shortcodes

function do_shortcode_tag( $m )

if ( isset( $m[5] ) ) enclosing tag - extra parameter return $m[1] call_user_func( $shortcode_tags[$tag] $attr $m[5] $tag ) $m[6] else self-closing tag return $m[1] call_user_func( $shortcode_tags[$tag] $attr null $tag ) $m[6]

Shortcodes

callback params $attrs attributes $content enclosed tags text $tag shortcode tag itself

Admin-post

Data from clientsProcessing requests

You can just process requests in your own page because $_REQUEST $_GET $_POST is global

Admin-post

But in your own handlerYou cannot use WP core functionsYou cannot authenticate

Do not reinvent the wheelSo there is admin-postphp

Admin-post

wp-adminadmin-postphpdefine amp include minimal settingsand do_action

$action = empty( $_REQUEST[action] ) $_REQUEST[action]

admin_post_nopriv admin_post_nopriv_$actionadmin_post admin_post_$action

finish using die() in callback function

AJAX

Very similar to admin-post but DOING_AJAX is defineddefine( DOING_AJAX true )

also use die() in callback function

if ( is_user_logged_in() ) do_action( wp_ajax_ $_REQUEST[action] ) else do_action( wp_ajax_nopriv_ $_REQUEST[action] ) Default statusdie( 0 )

Redirect

You can generate custom page in plugin by using template_redirect action

function my_page_template_redirect() if( is_page( goodies ) ampamp is_user_logged_in() )

wp_redirect( home_url( signup ) ) exit()

add_action( template_redirect my_page_template_redirect )

Redirect

You can generate web pages on-the-fly by utilizing these 3 hooks rewrite rule query parsing redirect

Detailed instructions later

(de)activation uninstall

register_activation_hook($file $cb)register_deactivation_hook($file $cb)register_uninstall_hook($file $cb)

$file full path of plugin file$cb callback function

callbacks should be SILENT No echo please

Summary

menu items shortcodes admin post ajax template redirects and (de)activation- uninstall hooks are good initial entry pointso It is a good strategy to find these

hooks in plugins first and dissect their codes from those points

I know you want to do something

You understand hook conceptYou know database detail

Now you know entry points

Definitely you wanna make something

Visit http[ip]practice and download entry-pointsphp

소스코드 http[ip]source-codes1 어드민 화면에 메뉴 추가2 쇼트코드 추가3 메뉴에서 admin post 전송4 메뉴에서 ajax 전송5redirect 테스트

ltauthorgt 부분은 자신의 이름으로 일괄변경하고 적절히 콜백 함수를 정의해 주세요

Source code explained

10 minutes break

Managing Your Own Contents

Wow there are too many things about posts

For today just focuse oncustom post type

Arguments are too complex

Just use Types or Pods pluginThats all problem solved

Yeah

of course you might not want this I was just kidding

Custom Post

You want to manage your own contentsThats why custom post is

Music collections Online store Event calendar Book data Photo portfolio

Custom Post Motivation

Well with just one type post and you may define many categories and use them to organize all contents

JUST ONE TYPE POSTMANY CATEGORIES

portfolio calendar music db

Custom Post Motivation

But you might feel that some post types should be hidden from some users even might be excluded from search may be only for private use may have very complex taxonomies

so that it should have its own territory

can be accessible from their own URL rules

Custom Post Motivation

Why re-invent wheel again

By extending built-in post type systemyou can REUSE whole facilities related to posts easily

UI and all thing about managing

Built-in Custom Post Types

wp-includespostphp (included in wp-settingsphp)function create_initial_post_types()

register_post_type( post array( register_post_type( page array( register_post_type( attachment array( register_post_type( revision array( register_post_type( nav_menu_item array( register_post_status( publish array(

register_post_type

ltphp register_post_type( $post_type $args ) gt

$arg is very complex

But I think it should be explained in detail Actually you cannot avoid it because eventuall all post type plugins will use that function too

Those plugins also have diffcult UIs too

register_post_type

Lets take a look how Types and Pods create their custom posts

They have easy (really) UI and provide better functionaliy but you can see horribly many options there

register_post_type $post_type

Up to 20 characters Only lowercase and numbers

register_post_type $args

publicvisible to authors

true impliesexclude_from_search falsepublicly_queryable show_in_nav_manues show_ui

false impliesexclude_from_search true publicly_queryable falseshow_in_nav_manues false show_ui false

register_post_type $args

labelplural descriptive name

egMusic CollectionsMostly localized text

register_post_type $args

labels more specific text labelsnamesigular_namemenu_namename_admin_barall_itemsadd_newadd_new_itemedit_itemview_itemsearch_items

search_itemsnot_foundnot_found in trashparent_item_colon

register_post_type $args

descriptionsummary of this post type

register_post_type $args

exclude_from_searchdo not search this post typetry S=beatbles

register_post_type $args

publicly_queryablecan use query

eg) post_type=music_collection

register_post_type $args

show_uidisplay default UI

register_post_type $args

show_in_nav_menusshow in navigation menus

be careful publicly_queryablemust be true

register_post_type $args

show_in_menushow admin_menu show_ui must be trueJust showing menutrue false else some strings

(toolsphp editphp)

altough it is falseyou can access URLS likewp-admineditphppost_type=music_collection(show_ui must be true)

register_post_type $args

show_in_admin_baravailable in admin bar

menu_postiondefault below comments

menu_iconsee dashicons

register_post_type $args

capability_typestring or array to build capabilites

in our exampeedit_music_collectionsedit_others_music_collections

publish_music_collectionsread_private_music_collections

register_post_type $args

capabilitiesto give specific names to each capability

map_meta_capif true default meta capability will be added

and then your role or account need capabilities

register_post_type $args

hierarchicalpost type can be hierarchicalthis is for page-styles

register_post_type $args

query_varto query posts query_var=slug

rewriteto use pretty permalinks

has_archiveEnables post type archive

register_post_type $args

permalink_epmaskrewrite endpoint bitmask

can_exporttrue makes the post can be exported

Too exhaustive but worth it

Practice Custom Post

Create custom-plugin-ltauthorgtphpCreate a simple custom post

Display admin menuHide admin_barWrite your post Any content is OK Include at least one meta field

Next Week

Customizing Visual Components List Table Screen Widgets

WordPress System Undercover Constants and Globals WPDB

  • WordPress Plugin 3
  • Recap
  • Recap (2)
  • Recap (3)
  • Recap (4)
  • Recap (5)
  • Todays Topics
  • Entry Points in Plugin
  • Entry Points
  • Entry Points (2)
  • Entry Points (3)
  • Entry Points (4)
  • Menu Items
  • Where is default menu
  • Where is default menu (2)
  • Our custom menus
  • add_menu_page
  • add_submenu_page
  • derivatives
  • Shortcodes
  • Shortcodes (2)
  • Shortcodes (3)
  • Shortcodes (4)
  • Shortcodes (5)
  • Shortcodes (6)
  • Admin-post
  • Admin-post (2)
  • Admin-post (3)
  • AJAX
  • Redirect
  • Redirect (2)
  • (de)activation uninstall
  • Summary
  • I know you want to do something
  • Slide 35
  • Source code explained
  • 10 minutes break
  • Managing Your Own Contents
  • Wow there are too many things about posts
  • For today just focuse on custom post type
  • Arguments are too complex
  • of course you might not want this I was just kidding
  • Custom Post
  • Custom Post Motivation
  • Custom Post Motivation (2)
  • Custom Post Motivation (3)
  • Built-in Custom Post Types
  • register_post_type
  • register_post_type (2)
  • register_post_type $post_type
  • register_post_type $args
  • register_post_type $args (2)
  • register_post_type $args (3)
  • register_post_type $args (4)
  • register_post_type $args (5)
  • register_post_type $args (6)
  • register_post_type $args (7)
  • register_post_type $args (8)
  • register_post_type $args (9)
  • register_post_type $args (10)
  • register_post_type $args (11)
  • register_post_type $args (12)
  • register_post_type $args (13)
  • register_post_type $args (14)
  • register_post_type $args (15)
  • Too exhaustive but worth it
  • Practice Custom Post
  • Next Week
Page 16: WordPress plugin #3

Our custom menus

wp-adminincludesmenuphp

do_action( admin_menu )

Menu API are defined in wp-adminincludespluginphp

add_menu_page

function add_menu_page( $page_title $menu_title $capability $menu_slug $function = $icon_url = $position = null )

$new_menu = array( $menu_title $capability $menu_slug $page_title menu-top $icon_class $hookname $hookname $icon_url )

if ( null === $position ) $menu[] = $new_menuelse $menu[$position] = $new_menu

add_submenu_page

function add_submenu_page( $parent_slug $page_title $menu_title $capability $menu_slug $function = ) $submenu[$parent_slug][] = array ( $menu_title $capability $menu_slug $page_title )

derivatives

add_dashboard_page() add_posts_page() add_media_page() add_pages_page() add_comments_page() add_theme_page() add_plugins_page() add_users_page() add_management_page() add_options_page()

Shortcodes

What is shortcodeA magic word in post content that is replaced by some process defined in plugin or themes in runtime

Good for displaying complex dynamic contents

Shortcodes

Sample[gallery id=123 size=medium][gallery]

or

[caption]My Caption[caption] enclosed form

Shortcodes

add_shortcode()

$shortcode_tags = array()function add_shortcode($tag $func) global $shortcode_tags

if ( is_callable($func) ) $shortcode_tags[$tag] = $func

Shortcodes

function do_shortcode($content) global $shortcode_tags

if ( false === strpos( $content [ ) ) return $content

if (empty($shortcode_tags) || is_array($shortcode_tags)) return $content

$pattern = get_shortcode_regex() return preg_replace_callback( $patterns do_shortcode_tag $content )

Shortcodes

function do_shortcode_tag( $m )

if ( isset( $m[5] ) ) enclosing tag - extra parameter return $m[1] call_user_func( $shortcode_tags[$tag] $attr $m[5] $tag ) $m[6] else self-closing tag return $m[1] call_user_func( $shortcode_tags[$tag] $attr null $tag ) $m[6]

Shortcodes

callback params $attrs attributes $content enclosed tags text $tag shortcode tag itself

Admin-post

Data from clientsProcessing requests

You can just process requests in your own page because $_REQUEST $_GET $_POST is global

Admin-post

But in your own handlerYou cannot use WP core functionsYou cannot authenticate

Do not reinvent the wheelSo there is admin-postphp

Admin-post

wp-adminadmin-postphpdefine amp include minimal settingsand do_action

$action = empty( $_REQUEST[action] ) $_REQUEST[action]

admin_post_nopriv admin_post_nopriv_$actionadmin_post admin_post_$action

finish using die() in callback function

AJAX

Very similar to admin-post but DOING_AJAX is defineddefine( DOING_AJAX true )

also use die() in callback function

if ( is_user_logged_in() ) do_action( wp_ajax_ $_REQUEST[action] ) else do_action( wp_ajax_nopriv_ $_REQUEST[action] ) Default statusdie( 0 )

Redirect

You can generate custom page in plugin by using template_redirect action

function my_page_template_redirect() if( is_page( goodies ) ampamp is_user_logged_in() )

wp_redirect( home_url( signup ) ) exit()

add_action( template_redirect my_page_template_redirect )

Redirect

You can generate web pages on-the-fly by utilizing these 3 hooks rewrite rule query parsing redirect

Detailed instructions later

(de)activation uninstall

register_activation_hook($file $cb)register_deactivation_hook($file $cb)register_uninstall_hook($file $cb)

$file full path of plugin file$cb callback function

callbacks should be SILENT No echo please

Summary

menu items shortcodes admin post ajax template redirects and (de)activation- uninstall hooks are good initial entry pointso It is a good strategy to find these

hooks in plugins first and dissect their codes from those points

I know you want to do something

You understand hook conceptYou know database detail

Now you know entry points

Definitely you wanna make something

Visit http[ip]practice and download entry-pointsphp

소스코드 http[ip]source-codes1 어드민 화면에 메뉴 추가2 쇼트코드 추가3 메뉴에서 admin post 전송4 메뉴에서 ajax 전송5redirect 테스트

ltauthorgt 부분은 자신의 이름으로 일괄변경하고 적절히 콜백 함수를 정의해 주세요

Source code explained

10 minutes break

Managing Your Own Contents

Wow there are too many things about posts

For today just focuse oncustom post type

Arguments are too complex

Just use Types or Pods pluginThats all problem solved

Yeah

of course you might not want this I was just kidding

Custom Post

You want to manage your own contentsThats why custom post is

Music collections Online store Event calendar Book data Photo portfolio

Custom Post Motivation

Well with just one type post and you may define many categories and use them to organize all contents

JUST ONE TYPE POSTMANY CATEGORIES

portfolio calendar music db

Custom Post Motivation

But you might feel that some post types should be hidden from some users even might be excluded from search may be only for private use may have very complex taxonomies

so that it should have its own territory

can be accessible from their own URL rules

Custom Post Motivation

Why re-invent wheel again

By extending built-in post type systemyou can REUSE whole facilities related to posts easily

UI and all thing about managing

Built-in Custom Post Types

wp-includespostphp (included in wp-settingsphp)function create_initial_post_types()

register_post_type( post array( register_post_type( page array( register_post_type( attachment array( register_post_type( revision array( register_post_type( nav_menu_item array( register_post_status( publish array(

register_post_type

ltphp register_post_type( $post_type $args ) gt

$arg is very complex

But I think it should be explained in detail Actually you cannot avoid it because eventuall all post type plugins will use that function too

Those plugins also have diffcult UIs too

register_post_type

Lets take a look how Types and Pods create their custom posts

They have easy (really) UI and provide better functionaliy but you can see horribly many options there

register_post_type $post_type

Up to 20 characters Only lowercase and numbers

register_post_type $args

publicvisible to authors

true impliesexclude_from_search falsepublicly_queryable show_in_nav_manues show_ui

false impliesexclude_from_search true publicly_queryable falseshow_in_nav_manues false show_ui false

register_post_type $args

labelplural descriptive name

egMusic CollectionsMostly localized text

register_post_type $args

labels more specific text labelsnamesigular_namemenu_namename_admin_barall_itemsadd_newadd_new_itemedit_itemview_itemsearch_items

search_itemsnot_foundnot_found in trashparent_item_colon

register_post_type $args

descriptionsummary of this post type

register_post_type $args

exclude_from_searchdo not search this post typetry S=beatbles

register_post_type $args

publicly_queryablecan use query

eg) post_type=music_collection

register_post_type $args

show_uidisplay default UI

register_post_type $args

show_in_nav_menusshow in navigation menus

be careful publicly_queryablemust be true

register_post_type $args

show_in_menushow admin_menu show_ui must be trueJust showing menutrue false else some strings

(toolsphp editphp)

altough it is falseyou can access URLS likewp-admineditphppost_type=music_collection(show_ui must be true)

register_post_type $args

show_in_admin_baravailable in admin bar

menu_postiondefault below comments

menu_iconsee dashicons

register_post_type $args

capability_typestring or array to build capabilites

in our exampeedit_music_collectionsedit_others_music_collections

publish_music_collectionsread_private_music_collections

register_post_type $args

capabilitiesto give specific names to each capability

map_meta_capif true default meta capability will be added

and then your role or account need capabilities

register_post_type $args

hierarchicalpost type can be hierarchicalthis is for page-styles

register_post_type $args

query_varto query posts query_var=slug

rewriteto use pretty permalinks

has_archiveEnables post type archive

register_post_type $args

permalink_epmaskrewrite endpoint bitmask

can_exporttrue makes the post can be exported

Too exhaustive but worth it

Practice Custom Post

Create custom-plugin-ltauthorgtphpCreate a simple custom post

Display admin menuHide admin_barWrite your post Any content is OK Include at least one meta field

Next Week

Customizing Visual Components List Table Screen Widgets

WordPress System Undercover Constants and Globals WPDB

  • WordPress Plugin 3
  • Recap
  • Recap (2)
  • Recap (3)
  • Recap (4)
  • Recap (5)
  • Todays Topics
  • Entry Points in Plugin
  • Entry Points
  • Entry Points (2)
  • Entry Points (3)
  • Entry Points (4)
  • Menu Items
  • Where is default menu
  • Where is default menu (2)
  • Our custom menus
  • add_menu_page
  • add_submenu_page
  • derivatives
  • Shortcodes
  • Shortcodes (2)
  • Shortcodes (3)
  • Shortcodes (4)
  • Shortcodes (5)
  • Shortcodes (6)
  • Admin-post
  • Admin-post (2)
  • Admin-post (3)
  • AJAX
  • Redirect
  • Redirect (2)
  • (de)activation uninstall
  • Summary
  • I know you want to do something
  • Slide 35
  • Source code explained
  • 10 minutes break
  • Managing Your Own Contents
  • Wow there are too many things about posts
  • For today just focuse on custom post type
  • Arguments are too complex
  • of course you might not want this I was just kidding
  • Custom Post
  • Custom Post Motivation
  • Custom Post Motivation (2)
  • Custom Post Motivation (3)
  • Built-in Custom Post Types
  • register_post_type
  • register_post_type (2)
  • register_post_type $post_type
  • register_post_type $args
  • register_post_type $args (2)
  • register_post_type $args (3)
  • register_post_type $args (4)
  • register_post_type $args (5)
  • register_post_type $args (6)
  • register_post_type $args (7)
  • register_post_type $args (8)
  • register_post_type $args (9)
  • register_post_type $args (10)
  • register_post_type $args (11)
  • register_post_type $args (12)
  • register_post_type $args (13)
  • register_post_type $args (14)
  • register_post_type $args (15)
  • Too exhaustive but worth it
  • Practice Custom Post
  • Next Week
Page 17: WordPress plugin #3

add_menu_page

function add_menu_page( $page_title $menu_title $capability $menu_slug $function = $icon_url = $position = null )

$new_menu = array( $menu_title $capability $menu_slug $page_title menu-top $icon_class $hookname $hookname $icon_url )

if ( null === $position ) $menu[] = $new_menuelse $menu[$position] = $new_menu

add_submenu_page

function add_submenu_page( $parent_slug $page_title $menu_title $capability $menu_slug $function = ) $submenu[$parent_slug][] = array ( $menu_title $capability $menu_slug $page_title )

derivatives

add_dashboard_page() add_posts_page() add_media_page() add_pages_page() add_comments_page() add_theme_page() add_plugins_page() add_users_page() add_management_page() add_options_page()

Shortcodes

What is shortcodeA magic word in post content that is replaced by some process defined in plugin or themes in runtime

Good for displaying complex dynamic contents

Shortcodes

Sample[gallery id=123 size=medium][gallery]

or

[caption]My Caption[caption] enclosed form

Shortcodes

add_shortcode()

$shortcode_tags = array()function add_shortcode($tag $func) global $shortcode_tags

if ( is_callable($func) ) $shortcode_tags[$tag] = $func

Shortcodes

function do_shortcode($content) global $shortcode_tags

if ( false === strpos( $content [ ) ) return $content

if (empty($shortcode_tags) || is_array($shortcode_tags)) return $content

$pattern = get_shortcode_regex() return preg_replace_callback( $patterns do_shortcode_tag $content )

Shortcodes

function do_shortcode_tag( $m )

if ( isset( $m[5] ) ) enclosing tag - extra parameter return $m[1] call_user_func( $shortcode_tags[$tag] $attr $m[5] $tag ) $m[6] else self-closing tag return $m[1] call_user_func( $shortcode_tags[$tag] $attr null $tag ) $m[6]

Shortcodes

callback params $attrs attributes $content enclosed tags text $tag shortcode tag itself

Admin-post

Data from clientsProcessing requests

You can just process requests in your own page because $_REQUEST $_GET $_POST is global

Admin-post

But in your own handlerYou cannot use WP core functionsYou cannot authenticate

Do not reinvent the wheelSo there is admin-postphp

Admin-post

wp-adminadmin-postphpdefine amp include minimal settingsand do_action

$action = empty( $_REQUEST[action] ) $_REQUEST[action]

admin_post_nopriv admin_post_nopriv_$actionadmin_post admin_post_$action

finish using die() in callback function

AJAX

Very similar to admin-post but DOING_AJAX is defineddefine( DOING_AJAX true )

also use die() in callback function

if ( is_user_logged_in() ) do_action( wp_ajax_ $_REQUEST[action] ) else do_action( wp_ajax_nopriv_ $_REQUEST[action] ) Default statusdie( 0 )

Redirect

You can generate custom page in plugin by using template_redirect action

function my_page_template_redirect() if( is_page( goodies ) ampamp is_user_logged_in() )

wp_redirect( home_url( signup ) ) exit()

add_action( template_redirect my_page_template_redirect )

Redirect

You can generate web pages on-the-fly by utilizing these 3 hooks rewrite rule query parsing redirect

Detailed instructions later

(de)activation uninstall

register_activation_hook($file $cb)register_deactivation_hook($file $cb)register_uninstall_hook($file $cb)

$file full path of plugin file$cb callback function

callbacks should be SILENT No echo please

Summary

menu items shortcodes admin post ajax template redirects and (de)activation- uninstall hooks are good initial entry pointso It is a good strategy to find these

hooks in plugins first and dissect their codes from those points

I know you want to do something

You understand hook conceptYou know database detail

Now you know entry points

Definitely you wanna make something

Visit http[ip]practice and download entry-pointsphp

소스코드 http[ip]source-codes1 어드민 화면에 메뉴 추가2 쇼트코드 추가3 메뉴에서 admin post 전송4 메뉴에서 ajax 전송5redirect 테스트

ltauthorgt 부분은 자신의 이름으로 일괄변경하고 적절히 콜백 함수를 정의해 주세요

Source code explained

10 minutes break

Managing Your Own Contents

Wow there are too many things about posts

For today just focuse oncustom post type

Arguments are too complex

Just use Types or Pods pluginThats all problem solved

Yeah

of course you might not want this I was just kidding

Custom Post

You want to manage your own contentsThats why custom post is

Music collections Online store Event calendar Book data Photo portfolio

Custom Post Motivation

Well with just one type post and you may define many categories and use them to organize all contents

JUST ONE TYPE POSTMANY CATEGORIES

portfolio calendar music db

Custom Post Motivation

But you might feel that some post types should be hidden from some users even might be excluded from search may be only for private use may have very complex taxonomies

so that it should have its own territory

can be accessible from their own URL rules

Custom Post Motivation

Why re-invent wheel again

By extending built-in post type systemyou can REUSE whole facilities related to posts easily

UI and all thing about managing

Built-in Custom Post Types

wp-includespostphp (included in wp-settingsphp)function create_initial_post_types()

register_post_type( post array( register_post_type( page array( register_post_type( attachment array( register_post_type( revision array( register_post_type( nav_menu_item array( register_post_status( publish array(

register_post_type

ltphp register_post_type( $post_type $args ) gt

$arg is very complex

But I think it should be explained in detail Actually you cannot avoid it because eventuall all post type plugins will use that function too

Those plugins also have diffcult UIs too

register_post_type

Lets take a look how Types and Pods create their custom posts

They have easy (really) UI and provide better functionaliy but you can see horribly many options there

register_post_type $post_type

Up to 20 characters Only lowercase and numbers

register_post_type $args

publicvisible to authors

true impliesexclude_from_search falsepublicly_queryable show_in_nav_manues show_ui

false impliesexclude_from_search true publicly_queryable falseshow_in_nav_manues false show_ui false

register_post_type $args

labelplural descriptive name

egMusic CollectionsMostly localized text

register_post_type $args

labels more specific text labelsnamesigular_namemenu_namename_admin_barall_itemsadd_newadd_new_itemedit_itemview_itemsearch_items

search_itemsnot_foundnot_found in trashparent_item_colon

register_post_type $args

descriptionsummary of this post type

register_post_type $args

exclude_from_searchdo not search this post typetry S=beatbles

register_post_type $args

publicly_queryablecan use query

eg) post_type=music_collection

register_post_type $args

show_uidisplay default UI

register_post_type $args

show_in_nav_menusshow in navigation menus

be careful publicly_queryablemust be true

register_post_type $args

show_in_menushow admin_menu show_ui must be trueJust showing menutrue false else some strings

(toolsphp editphp)

altough it is falseyou can access URLS likewp-admineditphppost_type=music_collection(show_ui must be true)

register_post_type $args

show_in_admin_baravailable in admin bar

menu_postiondefault below comments

menu_iconsee dashicons

register_post_type $args

capability_typestring or array to build capabilites

in our exampeedit_music_collectionsedit_others_music_collections

publish_music_collectionsread_private_music_collections

register_post_type $args

capabilitiesto give specific names to each capability

map_meta_capif true default meta capability will be added

and then your role or account need capabilities

register_post_type $args

hierarchicalpost type can be hierarchicalthis is for page-styles

register_post_type $args

query_varto query posts query_var=slug

rewriteto use pretty permalinks

has_archiveEnables post type archive

register_post_type $args

permalink_epmaskrewrite endpoint bitmask

can_exporttrue makes the post can be exported

Too exhaustive but worth it

Practice Custom Post

Create custom-plugin-ltauthorgtphpCreate a simple custom post

Display admin menuHide admin_barWrite your post Any content is OK Include at least one meta field

Next Week

Customizing Visual Components List Table Screen Widgets

WordPress System Undercover Constants and Globals WPDB

  • WordPress Plugin 3
  • Recap
  • Recap (2)
  • Recap (3)
  • Recap (4)
  • Recap (5)
  • Todays Topics
  • Entry Points in Plugin
  • Entry Points
  • Entry Points (2)
  • Entry Points (3)
  • Entry Points (4)
  • Menu Items
  • Where is default menu
  • Where is default menu (2)
  • Our custom menus
  • add_menu_page
  • add_submenu_page
  • derivatives
  • Shortcodes
  • Shortcodes (2)
  • Shortcodes (3)
  • Shortcodes (4)
  • Shortcodes (5)
  • Shortcodes (6)
  • Admin-post
  • Admin-post (2)
  • Admin-post (3)
  • AJAX
  • Redirect
  • Redirect (2)
  • (de)activation uninstall
  • Summary
  • I know you want to do something
  • Slide 35
  • Source code explained
  • 10 minutes break
  • Managing Your Own Contents
  • Wow there are too many things about posts
  • For today just focuse on custom post type
  • Arguments are too complex
  • of course you might not want this I was just kidding
  • Custom Post
  • Custom Post Motivation
  • Custom Post Motivation (2)
  • Custom Post Motivation (3)
  • Built-in Custom Post Types
  • register_post_type
  • register_post_type (2)
  • register_post_type $post_type
  • register_post_type $args
  • register_post_type $args (2)
  • register_post_type $args (3)
  • register_post_type $args (4)
  • register_post_type $args (5)
  • register_post_type $args (6)
  • register_post_type $args (7)
  • register_post_type $args (8)
  • register_post_type $args (9)
  • register_post_type $args (10)
  • register_post_type $args (11)
  • register_post_type $args (12)
  • register_post_type $args (13)
  • register_post_type $args (14)
  • register_post_type $args (15)
  • Too exhaustive but worth it
  • Practice Custom Post
  • Next Week
Page 18: WordPress plugin #3

add_submenu_page

function add_submenu_page( $parent_slug $page_title $menu_title $capability $menu_slug $function = ) $submenu[$parent_slug][] = array ( $menu_title $capability $menu_slug $page_title )

derivatives

add_dashboard_page() add_posts_page() add_media_page() add_pages_page() add_comments_page() add_theme_page() add_plugins_page() add_users_page() add_management_page() add_options_page()

Shortcodes

What is shortcodeA magic word in post content that is replaced by some process defined in plugin or themes in runtime

Good for displaying complex dynamic contents

Shortcodes

Sample[gallery id=123 size=medium][gallery]

or

[caption]My Caption[caption] enclosed form

Shortcodes

add_shortcode()

$shortcode_tags = array()function add_shortcode($tag $func) global $shortcode_tags

if ( is_callable($func) ) $shortcode_tags[$tag] = $func

Shortcodes

function do_shortcode($content) global $shortcode_tags

if ( false === strpos( $content [ ) ) return $content

if (empty($shortcode_tags) || is_array($shortcode_tags)) return $content

$pattern = get_shortcode_regex() return preg_replace_callback( $patterns do_shortcode_tag $content )

Shortcodes

function do_shortcode_tag( $m )

if ( isset( $m[5] ) ) enclosing tag - extra parameter return $m[1] call_user_func( $shortcode_tags[$tag] $attr $m[5] $tag ) $m[6] else self-closing tag return $m[1] call_user_func( $shortcode_tags[$tag] $attr null $tag ) $m[6]

Shortcodes

callback params $attrs attributes $content enclosed tags text $tag shortcode tag itself

Admin-post

Data from clientsProcessing requests

You can just process requests in your own page because $_REQUEST $_GET $_POST is global

Admin-post

But in your own handlerYou cannot use WP core functionsYou cannot authenticate

Do not reinvent the wheelSo there is admin-postphp

Admin-post

wp-adminadmin-postphpdefine amp include minimal settingsand do_action

$action = empty( $_REQUEST[action] ) $_REQUEST[action]

admin_post_nopriv admin_post_nopriv_$actionadmin_post admin_post_$action

finish using die() in callback function

AJAX

Very similar to admin-post but DOING_AJAX is defineddefine( DOING_AJAX true )

also use die() in callback function

if ( is_user_logged_in() ) do_action( wp_ajax_ $_REQUEST[action] ) else do_action( wp_ajax_nopriv_ $_REQUEST[action] ) Default statusdie( 0 )

Redirect

You can generate custom page in plugin by using template_redirect action

function my_page_template_redirect() if( is_page( goodies ) ampamp is_user_logged_in() )

wp_redirect( home_url( signup ) ) exit()

add_action( template_redirect my_page_template_redirect )

Redirect

You can generate web pages on-the-fly by utilizing these 3 hooks rewrite rule query parsing redirect

Detailed instructions later

(de)activation uninstall

register_activation_hook($file $cb)register_deactivation_hook($file $cb)register_uninstall_hook($file $cb)

$file full path of plugin file$cb callback function

callbacks should be SILENT No echo please

Summary

menu items shortcodes admin post ajax template redirects and (de)activation- uninstall hooks are good initial entry pointso It is a good strategy to find these

hooks in plugins first and dissect their codes from those points

I know you want to do something

You understand hook conceptYou know database detail

Now you know entry points

Definitely you wanna make something

Visit http[ip]practice and download entry-pointsphp

소스코드 http[ip]source-codes1 어드민 화면에 메뉴 추가2 쇼트코드 추가3 메뉴에서 admin post 전송4 메뉴에서 ajax 전송5redirect 테스트

ltauthorgt 부분은 자신의 이름으로 일괄변경하고 적절히 콜백 함수를 정의해 주세요

Source code explained

10 minutes break

Managing Your Own Contents

Wow there are too many things about posts

For today just focuse oncustom post type

Arguments are too complex

Just use Types or Pods pluginThats all problem solved

Yeah

of course you might not want this I was just kidding

Custom Post

You want to manage your own contentsThats why custom post is

Music collections Online store Event calendar Book data Photo portfolio

Custom Post Motivation

Well with just one type post and you may define many categories and use them to organize all contents

JUST ONE TYPE POSTMANY CATEGORIES

portfolio calendar music db

Custom Post Motivation

But you might feel that some post types should be hidden from some users even might be excluded from search may be only for private use may have very complex taxonomies

so that it should have its own territory

can be accessible from their own URL rules

Custom Post Motivation

Why re-invent wheel again

By extending built-in post type systemyou can REUSE whole facilities related to posts easily

UI and all thing about managing

Built-in Custom Post Types

wp-includespostphp (included in wp-settingsphp)function create_initial_post_types()

register_post_type( post array( register_post_type( page array( register_post_type( attachment array( register_post_type( revision array( register_post_type( nav_menu_item array( register_post_status( publish array(

register_post_type

ltphp register_post_type( $post_type $args ) gt

$arg is very complex

But I think it should be explained in detail Actually you cannot avoid it because eventuall all post type plugins will use that function too

Those plugins also have diffcult UIs too

register_post_type

Lets take a look how Types and Pods create their custom posts

They have easy (really) UI and provide better functionaliy but you can see horribly many options there

register_post_type $post_type

Up to 20 characters Only lowercase and numbers

register_post_type $args

publicvisible to authors

true impliesexclude_from_search falsepublicly_queryable show_in_nav_manues show_ui

false impliesexclude_from_search true publicly_queryable falseshow_in_nav_manues false show_ui false

register_post_type $args

labelplural descriptive name

egMusic CollectionsMostly localized text

register_post_type $args

labels more specific text labelsnamesigular_namemenu_namename_admin_barall_itemsadd_newadd_new_itemedit_itemview_itemsearch_items

search_itemsnot_foundnot_found in trashparent_item_colon

register_post_type $args

descriptionsummary of this post type

register_post_type $args

exclude_from_searchdo not search this post typetry S=beatbles

register_post_type $args

publicly_queryablecan use query

eg) post_type=music_collection

register_post_type $args

show_uidisplay default UI

register_post_type $args

show_in_nav_menusshow in navigation menus

be careful publicly_queryablemust be true

register_post_type $args

show_in_menushow admin_menu show_ui must be trueJust showing menutrue false else some strings

(toolsphp editphp)

altough it is falseyou can access URLS likewp-admineditphppost_type=music_collection(show_ui must be true)

register_post_type $args

show_in_admin_baravailable in admin bar

menu_postiondefault below comments

menu_iconsee dashicons

register_post_type $args

capability_typestring or array to build capabilites

in our exampeedit_music_collectionsedit_others_music_collections

publish_music_collectionsread_private_music_collections

register_post_type $args

capabilitiesto give specific names to each capability

map_meta_capif true default meta capability will be added

and then your role or account need capabilities

register_post_type $args

hierarchicalpost type can be hierarchicalthis is for page-styles

register_post_type $args

query_varto query posts query_var=slug

rewriteto use pretty permalinks

has_archiveEnables post type archive

register_post_type $args

permalink_epmaskrewrite endpoint bitmask

can_exporttrue makes the post can be exported

Too exhaustive but worth it

Practice Custom Post

Create custom-plugin-ltauthorgtphpCreate a simple custom post

Display admin menuHide admin_barWrite your post Any content is OK Include at least one meta field

Next Week

Customizing Visual Components List Table Screen Widgets

WordPress System Undercover Constants and Globals WPDB

  • WordPress Plugin 3
  • Recap
  • Recap (2)
  • Recap (3)
  • Recap (4)
  • Recap (5)
  • Todays Topics
  • Entry Points in Plugin
  • Entry Points
  • Entry Points (2)
  • Entry Points (3)
  • Entry Points (4)
  • Menu Items
  • Where is default menu
  • Where is default menu (2)
  • Our custom menus
  • add_menu_page
  • add_submenu_page
  • derivatives
  • Shortcodes
  • Shortcodes (2)
  • Shortcodes (3)
  • Shortcodes (4)
  • Shortcodes (5)
  • Shortcodes (6)
  • Admin-post
  • Admin-post (2)
  • Admin-post (3)
  • AJAX
  • Redirect
  • Redirect (2)
  • (de)activation uninstall
  • Summary
  • I know you want to do something
  • Slide 35
  • Source code explained
  • 10 minutes break
  • Managing Your Own Contents
  • Wow there are too many things about posts
  • For today just focuse on custom post type
  • Arguments are too complex
  • of course you might not want this I was just kidding
  • Custom Post
  • Custom Post Motivation
  • Custom Post Motivation (2)
  • Custom Post Motivation (3)
  • Built-in Custom Post Types
  • register_post_type
  • register_post_type (2)
  • register_post_type $post_type
  • register_post_type $args
  • register_post_type $args (2)
  • register_post_type $args (3)
  • register_post_type $args (4)
  • register_post_type $args (5)
  • register_post_type $args (6)
  • register_post_type $args (7)
  • register_post_type $args (8)
  • register_post_type $args (9)
  • register_post_type $args (10)
  • register_post_type $args (11)
  • register_post_type $args (12)
  • register_post_type $args (13)
  • register_post_type $args (14)
  • register_post_type $args (15)
  • Too exhaustive but worth it
  • Practice Custom Post
  • Next Week
Page 19: WordPress plugin #3

derivatives

add_dashboard_page() add_posts_page() add_media_page() add_pages_page() add_comments_page() add_theme_page() add_plugins_page() add_users_page() add_management_page() add_options_page()

Shortcodes

What is shortcodeA magic word in post content that is replaced by some process defined in plugin or themes in runtime

Good for displaying complex dynamic contents

Shortcodes

Sample[gallery id=123 size=medium][gallery]

or

[caption]My Caption[caption] enclosed form

Shortcodes

add_shortcode()

$shortcode_tags = array()function add_shortcode($tag $func) global $shortcode_tags

if ( is_callable($func) ) $shortcode_tags[$tag] = $func

Shortcodes

function do_shortcode($content) global $shortcode_tags

if ( false === strpos( $content [ ) ) return $content

if (empty($shortcode_tags) || is_array($shortcode_tags)) return $content

$pattern = get_shortcode_regex() return preg_replace_callback( $patterns do_shortcode_tag $content )

Shortcodes

function do_shortcode_tag( $m )

if ( isset( $m[5] ) ) enclosing tag - extra parameter return $m[1] call_user_func( $shortcode_tags[$tag] $attr $m[5] $tag ) $m[6] else self-closing tag return $m[1] call_user_func( $shortcode_tags[$tag] $attr null $tag ) $m[6]

Shortcodes

callback params $attrs attributes $content enclosed tags text $tag shortcode tag itself

Admin-post

Data from clientsProcessing requests

You can just process requests in your own page because $_REQUEST $_GET $_POST is global

Admin-post

But in your own handlerYou cannot use WP core functionsYou cannot authenticate

Do not reinvent the wheelSo there is admin-postphp

Admin-post

wp-adminadmin-postphpdefine amp include minimal settingsand do_action

$action = empty( $_REQUEST[action] ) $_REQUEST[action]

admin_post_nopriv admin_post_nopriv_$actionadmin_post admin_post_$action

finish using die() in callback function

AJAX

Very similar to admin-post but DOING_AJAX is defineddefine( DOING_AJAX true )

also use die() in callback function

if ( is_user_logged_in() ) do_action( wp_ajax_ $_REQUEST[action] ) else do_action( wp_ajax_nopriv_ $_REQUEST[action] ) Default statusdie( 0 )

Redirect

You can generate custom page in plugin by using template_redirect action

function my_page_template_redirect() if( is_page( goodies ) ampamp is_user_logged_in() )

wp_redirect( home_url( signup ) ) exit()

add_action( template_redirect my_page_template_redirect )

Redirect

You can generate web pages on-the-fly by utilizing these 3 hooks rewrite rule query parsing redirect

Detailed instructions later

(de)activation uninstall

register_activation_hook($file $cb)register_deactivation_hook($file $cb)register_uninstall_hook($file $cb)

$file full path of plugin file$cb callback function

callbacks should be SILENT No echo please

Summary

menu items shortcodes admin post ajax template redirects and (de)activation- uninstall hooks are good initial entry pointso It is a good strategy to find these

hooks in plugins first and dissect their codes from those points

I know you want to do something

You understand hook conceptYou know database detail

Now you know entry points

Definitely you wanna make something

Visit http[ip]practice and download entry-pointsphp

소스코드 http[ip]source-codes1 어드민 화면에 메뉴 추가2 쇼트코드 추가3 메뉴에서 admin post 전송4 메뉴에서 ajax 전송5redirect 테스트

ltauthorgt 부분은 자신의 이름으로 일괄변경하고 적절히 콜백 함수를 정의해 주세요

Source code explained

10 minutes break

Managing Your Own Contents

Wow there are too many things about posts

For today just focuse oncustom post type

Arguments are too complex

Just use Types or Pods pluginThats all problem solved

Yeah

of course you might not want this I was just kidding

Custom Post

You want to manage your own contentsThats why custom post is

Music collections Online store Event calendar Book data Photo portfolio

Custom Post Motivation

Well with just one type post and you may define many categories and use them to organize all contents

JUST ONE TYPE POSTMANY CATEGORIES

portfolio calendar music db

Custom Post Motivation

But you might feel that some post types should be hidden from some users even might be excluded from search may be only for private use may have very complex taxonomies

so that it should have its own territory

can be accessible from their own URL rules

Custom Post Motivation

Why re-invent wheel again

By extending built-in post type systemyou can REUSE whole facilities related to posts easily

UI and all thing about managing

Built-in Custom Post Types

wp-includespostphp (included in wp-settingsphp)function create_initial_post_types()

register_post_type( post array( register_post_type( page array( register_post_type( attachment array( register_post_type( revision array( register_post_type( nav_menu_item array( register_post_status( publish array(

register_post_type

ltphp register_post_type( $post_type $args ) gt

$arg is very complex

But I think it should be explained in detail Actually you cannot avoid it because eventuall all post type plugins will use that function too

Those plugins also have diffcult UIs too

register_post_type

Lets take a look how Types and Pods create their custom posts

They have easy (really) UI and provide better functionaliy but you can see horribly many options there

register_post_type $post_type

Up to 20 characters Only lowercase and numbers

register_post_type $args

publicvisible to authors

true impliesexclude_from_search falsepublicly_queryable show_in_nav_manues show_ui

false impliesexclude_from_search true publicly_queryable falseshow_in_nav_manues false show_ui false

register_post_type $args

labelplural descriptive name

egMusic CollectionsMostly localized text

register_post_type $args

labels more specific text labelsnamesigular_namemenu_namename_admin_barall_itemsadd_newadd_new_itemedit_itemview_itemsearch_items

search_itemsnot_foundnot_found in trashparent_item_colon

register_post_type $args

descriptionsummary of this post type

register_post_type $args

exclude_from_searchdo not search this post typetry S=beatbles

register_post_type $args

publicly_queryablecan use query

eg) post_type=music_collection

register_post_type $args

show_uidisplay default UI

register_post_type $args

show_in_nav_menusshow in navigation menus

be careful publicly_queryablemust be true

register_post_type $args

show_in_menushow admin_menu show_ui must be trueJust showing menutrue false else some strings

(toolsphp editphp)

altough it is falseyou can access URLS likewp-admineditphppost_type=music_collection(show_ui must be true)

register_post_type $args

show_in_admin_baravailable in admin bar

menu_postiondefault below comments

menu_iconsee dashicons

register_post_type $args

capability_typestring or array to build capabilites

in our exampeedit_music_collectionsedit_others_music_collections

publish_music_collectionsread_private_music_collections

register_post_type $args

capabilitiesto give specific names to each capability

map_meta_capif true default meta capability will be added

and then your role or account need capabilities

register_post_type $args

hierarchicalpost type can be hierarchicalthis is for page-styles

register_post_type $args

query_varto query posts query_var=slug

rewriteto use pretty permalinks

has_archiveEnables post type archive

register_post_type $args

permalink_epmaskrewrite endpoint bitmask

can_exporttrue makes the post can be exported

Too exhaustive but worth it

Practice Custom Post

Create custom-plugin-ltauthorgtphpCreate a simple custom post

Display admin menuHide admin_barWrite your post Any content is OK Include at least one meta field

Next Week

Customizing Visual Components List Table Screen Widgets

WordPress System Undercover Constants and Globals WPDB

  • WordPress Plugin 3
  • Recap
  • Recap (2)
  • Recap (3)
  • Recap (4)
  • Recap (5)
  • Todays Topics
  • Entry Points in Plugin
  • Entry Points
  • Entry Points (2)
  • Entry Points (3)
  • Entry Points (4)
  • Menu Items
  • Where is default menu
  • Where is default menu (2)
  • Our custom menus
  • add_menu_page
  • add_submenu_page
  • derivatives
  • Shortcodes
  • Shortcodes (2)
  • Shortcodes (3)
  • Shortcodes (4)
  • Shortcodes (5)
  • Shortcodes (6)
  • Admin-post
  • Admin-post (2)
  • Admin-post (3)
  • AJAX
  • Redirect
  • Redirect (2)
  • (de)activation uninstall
  • Summary
  • I know you want to do something
  • Slide 35
  • Source code explained
  • 10 minutes break
  • Managing Your Own Contents
  • Wow there are too many things about posts
  • For today just focuse on custom post type
  • Arguments are too complex
  • of course you might not want this I was just kidding
  • Custom Post
  • Custom Post Motivation
  • Custom Post Motivation (2)
  • Custom Post Motivation (3)
  • Built-in Custom Post Types
  • register_post_type
  • register_post_type (2)
  • register_post_type $post_type
  • register_post_type $args
  • register_post_type $args (2)
  • register_post_type $args (3)
  • register_post_type $args (4)
  • register_post_type $args (5)
  • register_post_type $args (6)
  • register_post_type $args (7)
  • register_post_type $args (8)
  • register_post_type $args (9)
  • register_post_type $args (10)
  • register_post_type $args (11)
  • register_post_type $args (12)
  • register_post_type $args (13)
  • register_post_type $args (14)
  • register_post_type $args (15)
  • Too exhaustive but worth it
  • Practice Custom Post
  • Next Week
Page 20: WordPress plugin #3

Shortcodes

What is shortcodeA magic word in post content that is replaced by some process defined in plugin or themes in runtime

Good for displaying complex dynamic contents

Shortcodes

Sample[gallery id=123 size=medium][gallery]

or

[caption]My Caption[caption] enclosed form

Shortcodes

add_shortcode()

$shortcode_tags = array()function add_shortcode($tag $func) global $shortcode_tags

if ( is_callable($func) ) $shortcode_tags[$tag] = $func

Shortcodes

function do_shortcode($content) global $shortcode_tags

if ( false === strpos( $content [ ) ) return $content

if (empty($shortcode_tags) || is_array($shortcode_tags)) return $content

$pattern = get_shortcode_regex() return preg_replace_callback( $patterns do_shortcode_tag $content )

Shortcodes

function do_shortcode_tag( $m )

if ( isset( $m[5] ) ) enclosing tag - extra parameter return $m[1] call_user_func( $shortcode_tags[$tag] $attr $m[5] $tag ) $m[6] else self-closing tag return $m[1] call_user_func( $shortcode_tags[$tag] $attr null $tag ) $m[6]

Shortcodes

callback params $attrs attributes $content enclosed tags text $tag shortcode tag itself

Admin-post

Data from clientsProcessing requests

You can just process requests in your own page because $_REQUEST $_GET $_POST is global

Admin-post

But in your own handlerYou cannot use WP core functionsYou cannot authenticate

Do not reinvent the wheelSo there is admin-postphp

Admin-post

wp-adminadmin-postphpdefine amp include minimal settingsand do_action

$action = empty( $_REQUEST[action] ) $_REQUEST[action]

admin_post_nopriv admin_post_nopriv_$actionadmin_post admin_post_$action

finish using die() in callback function

AJAX

Very similar to admin-post but DOING_AJAX is defineddefine( DOING_AJAX true )

also use die() in callback function

if ( is_user_logged_in() ) do_action( wp_ajax_ $_REQUEST[action] ) else do_action( wp_ajax_nopriv_ $_REQUEST[action] ) Default statusdie( 0 )

Redirect

You can generate custom page in plugin by using template_redirect action

function my_page_template_redirect() if( is_page( goodies ) ampamp is_user_logged_in() )

wp_redirect( home_url( signup ) ) exit()

add_action( template_redirect my_page_template_redirect )

Redirect

You can generate web pages on-the-fly by utilizing these 3 hooks rewrite rule query parsing redirect

Detailed instructions later

(de)activation uninstall

register_activation_hook($file $cb)register_deactivation_hook($file $cb)register_uninstall_hook($file $cb)

$file full path of plugin file$cb callback function

callbacks should be SILENT No echo please

Summary

menu items shortcodes admin post ajax template redirects and (de)activation- uninstall hooks are good initial entry pointso It is a good strategy to find these

hooks in plugins first and dissect their codes from those points

I know you want to do something

You understand hook conceptYou know database detail

Now you know entry points

Definitely you wanna make something

Visit http[ip]practice and download entry-pointsphp

소스코드 http[ip]source-codes1 어드민 화면에 메뉴 추가2 쇼트코드 추가3 메뉴에서 admin post 전송4 메뉴에서 ajax 전송5redirect 테스트

ltauthorgt 부분은 자신의 이름으로 일괄변경하고 적절히 콜백 함수를 정의해 주세요

Source code explained

10 minutes break

Managing Your Own Contents

Wow there are too many things about posts

For today just focuse oncustom post type

Arguments are too complex

Just use Types or Pods pluginThats all problem solved

Yeah

of course you might not want this I was just kidding

Custom Post

You want to manage your own contentsThats why custom post is

Music collections Online store Event calendar Book data Photo portfolio

Custom Post Motivation

Well with just one type post and you may define many categories and use them to organize all contents

JUST ONE TYPE POSTMANY CATEGORIES

portfolio calendar music db

Custom Post Motivation

But you might feel that some post types should be hidden from some users even might be excluded from search may be only for private use may have very complex taxonomies

so that it should have its own territory

can be accessible from their own URL rules

Custom Post Motivation

Why re-invent wheel again

By extending built-in post type systemyou can REUSE whole facilities related to posts easily

UI and all thing about managing

Built-in Custom Post Types

wp-includespostphp (included in wp-settingsphp)function create_initial_post_types()

register_post_type( post array( register_post_type( page array( register_post_type( attachment array( register_post_type( revision array( register_post_type( nav_menu_item array( register_post_status( publish array(

register_post_type

ltphp register_post_type( $post_type $args ) gt

$arg is very complex

But I think it should be explained in detail Actually you cannot avoid it because eventuall all post type plugins will use that function too

Those plugins also have diffcult UIs too

register_post_type

Lets take a look how Types and Pods create their custom posts

They have easy (really) UI and provide better functionaliy but you can see horribly many options there

register_post_type $post_type

Up to 20 characters Only lowercase and numbers

register_post_type $args

publicvisible to authors

true impliesexclude_from_search falsepublicly_queryable show_in_nav_manues show_ui

false impliesexclude_from_search true publicly_queryable falseshow_in_nav_manues false show_ui false

register_post_type $args

labelplural descriptive name

egMusic CollectionsMostly localized text

register_post_type $args

labels more specific text labelsnamesigular_namemenu_namename_admin_barall_itemsadd_newadd_new_itemedit_itemview_itemsearch_items

search_itemsnot_foundnot_found in trashparent_item_colon

register_post_type $args

descriptionsummary of this post type

register_post_type $args

exclude_from_searchdo not search this post typetry S=beatbles

register_post_type $args

publicly_queryablecan use query

eg) post_type=music_collection

register_post_type $args

show_uidisplay default UI

register_post_type $args

show_in_nav_menusshow in navigation menus

be careful publicly_queryablemust be true

register_post_type $args

show_in_menushow admin_menu show_ui must be trueJust showing menutrue false else some strings

(toolsphp editphp)

altough it is falseyou can access URLS likewp-admineditphppost_type=music_collection(show_ui must be true)

register_post_type $args

show_in_admin_baravailable in admin bar

menu_postiondefault below comments

menu_iconsee dashicons

register_post_type $args

capability_typestring or array to build capabilites

in our exampeedit_music_collectionsedit_others_music_collections

publish_music_collectionsread_private_music_collections

register_post_type $args

capabilitiesto give specific names to each capability

map_meta_capif true default meta capability will be added

and then your role or account need capabilities

register_post_type $args

hierarchicalpost type can be hierarchicalthis is for page-styles

register_post_type $args

query_varto query posts query_var=slug

rewriteto use pretty permalinks

has_archiveEnables post type archive

register_post_type $args

permalink_epmaskrewrite endpoint bitmask

can_exporttrue makes the post can be exported

Too exhaustive but worth it

Practice Custom Post

Create custom-plugin-ltauthorgtphpCreate a simple custom post

Display admin menuHide admin_barWrite your post Any content is OK Include at least one meta field

Next Week

Customizing Visual Components List Table Screen Widgets

WordPress System Undercover Constants and Globals WPDB

  • WordPress Plugin 3
  • Recap
  • Recap (2)
  • Recap (3)
  • Recap (4)
  • Recap (5)
  • Todays Topics
  • Entry Points in Plugin
  • Entry Points
  • Entry Points (2)
  • Entry Points (3)
  • Entry Points (4)
  • Menu Items
  • Where is default menu
  • Where is default menu (2)
  • Our custom menus
  • add_menu_page
  • add_submenu_page
  • derivatives
  • Shortcodes
  • Shortcodes (2)
  • Shortcodes (3)
  • Shortcodes (4)
  • Shortcodes (5)
  • Shortcodes (6)
  • Admin-post
  • Admin-post (2)
  • Admin-post (3)
  • AJAX
  • Redirect
  • Redirect (2)
  • (de)activation uninstall
  • Summary
  • I know you want to do something
  • Slide 35
  • Source code explained
  • 10 minutes break
  • Managing Your Own Contents
  • Wow there are too many things about posts
  • For today just focuse on custom post type
  • Arguments are too complex
  • of course you might not want this I was just kidding
  • Custom Post
  • Custom Post Motivation
  • Custom Post Motivation (2)
  • Custom Post Motivation (3)
  • Built-in Custom Post Types
  • register_post_type
  • register_post_type (2)
  • register_post_type $post_type
  • register_post_type $args
  • register_post_type $args (2)
  • register_post_type $args (3)
  • register_post_type $args (4)
  • register_post_type $args (5)
  • register_post_type $args (6)
  • register_post_type $args (7)
  • register_post_type $args (8)
  • register_post_type $args (9)
  • register_post_type $args (10)
  • register_post_type $args (11)
  • register_post_type $args (12)
  • register_post_type $args (13)
  • register_post_type $args (14)
  • register_post_type $args (15)
  • Too exhaustive but worth it
  • Practice Custom Post
  • Next Week
Page 21: WordPress plugin #3

Shortcodes

Sample[gallery id=123 size=medium][gallery]

or

[caption]My Caption[caption] enclosed form

Shortcodes

add_shortcode()

$shortcode_tags = array()function add_shortcode($tag $func) global $shortcode_tags

if ( is_callable($func) ) $shortcode_tags[$tag] = $func

Shortcodes

function do_shortcode($content) global $shortcode_tags

if ( false === strpos( $content [ ) ) return $content

if (empty($shortcode_tags) || is_array($shortcode_tags)) return $content

$pattern = get_shortcode_regex() return preg_replace_callback( $patterns do_shortcode_tag $content )

Shortcodes

function do_shortcode_tag( $m )

if ( isset( $m[5] ) ) enclosing tag - extra parameter return $m[1] call_user_func( $shortcode_tags[$tag] $attr $m[5] $tag ) $m[6] else self-closing tag return $m[1] call_user_func( $shortcode_tags[$tag] $attr null $tag ) $m[6]

Shortcodes

callback params $attrs attributes $content enclosed tags text $tag shortcode tag itself

Admin-post

Data from clientsProcessing requests

You can just process requests in your own page because $_REQUEST $_GET $_POST is global

Admin-post

But in your own handlerYou cannot use WP core functionsYou cannot authenticate

Do not reinvent the wheelSo there is admin-postphp

Admin-post

wp-adminadmin-postphpdefine amp include minimal settingsand do_action

$action = empty( $_REQUEST[action] ) $_REQUEST[action]

admin_post_nopriv admin_post_nopriv_$actionadmin_post admin_post_$action

finish using die() in callback function

AJAX

Very similar to admin-post but DOING_AJAX is defineddefine( DOING_AJAX true )

also use die() in callback function

if ( is_user_logged_in() ) do_action( wp_ajax_ $_REQUEST[action] ) else do_action( wp_ajax_nopriv_ $_REQUEST[action] ) Default statusdie( 0 )

Redirect

You can generate custom page in plugin by using template_redirect action

function my_page_template_redirect() if( is_page( goodies ) ampamp is_user_logged_in() )

wp_redirect( home_url( signup ) ) exit()

add_action( template_redirect my_page_template_redirect )

Redirect

You can generate web pages on-the-fly by utilizing these 3 hooks rewrite rule query parsing redirect

Detailed instructions later

(de)activation uninstall

register_activation_hook($file $cb)register_deactivation_hook($file $cb)register_uninstall_hook($file $cb)

$file full path of plugin file$cb callback function

callbacks should be SILENT No echo please

Summary

menu items shortcodes admin post ajax template redirects and (de)activation- uninstall hooks are good initial entry pointso It is a good strategy to find these

hooks in plugins first and dissect their codes from those points

I know you want to do something

You understand hook conceptYou know database detail

Now you know entry points

Definitely you wanna make something

Visit http[ip]practice and download entry-pointsphp

소스코드 http[ip]source-codes1 어드민 화면에 메뉴 추가2 쇼트코드 추가3 메뉴에서 admin post 전송4 메뉴에서 ajax 전송5redirect 테스트

ltauthorgt 부분은 자신의 이름으로 일괄변경하고 적절히 콜백 함수를 정의해 주세요

Source code explained

10 minutes break

Managing Your Own Contents

Wow there are too many things about posts

For today just focuse oncustom post type

Arguments are too complex

Just use Types or Pods pluginThats all problem solved

Yeah

of course you might not want this I was just kidding

Custom Post

You want to manage your own contentsThats why custom post is

Music collections Online store Event calendar Book data Photo portfolio

Custom Post Motivation

Well with just one type post and you may define many categories and use them to organize all contents

JUST ONE TYPE POSTMANY CATEGORIES

portfolio calendar music db

Custom Post Motivation

But you might feel that some post types should be hidden from some users even might be excluded from search may be only for private use may have very complex taxonomies

so that it should have its own territory

can be accessible from their own URL rules

Custom Post Motivation

Why re-invent wheel again

By extending built-in post type systemyou can REUSE whole facilities related to posts easily

UI and all thing about managing

Built-in Custom Post Types

wp-includespostphp (included in wp-settingsphp)function create_initial_post_types()

register_post_type( post array( register_post_type( page array( register_post_type( attachment array( register_post_type( revision array( register_post_type( nav_menu_item array( register_post_status( publish array(

register_post_type

ltphp register_post_type( $post_type $args ) gt

$arg is very complex

But I think it should be explained in detail Actually you cannot avoid it because eventuall all post type plugins will use that function too

Those plugins also have diffcult UIs too

register_post_type

Lets take a look how Types and Pods create their custom posts

They have easy (really) UI and provide better functionaliy but you can see horribly many options there

register_post_type $post_type

Up to 20 characters Only lowercase and numbers

register_post_type $args

publicvisible to authors

true impliesexclude_from_search falsepublicly_queryable show_in_nav_manues show_ui

false impliesexclude_from_search true publicly_queryable falseshow_in_nav_manues false show_ui false

register_post_type $args

labelplural descriptive name

egMusic CollectionsMostly localized text

register_post_type $args

labels more specific text labelsnamesigular_namemenu_namename_admin_barall_itemsadd_newadd_new_itemedit_itemview_itemsearch_items

search_itemsnot_foundnot_found in trashparent_item_colon

register_post_type $args

descriptionsummary of this post type

register_post_type $args

exclude_from_searchdo not search this post typetry S=beatbles

register_post_type $args

publicly_queryablecan use query

eg) post_type=music_collection

register_post_type $args

show_uidisplay default UI

register_post_type $args

show_in_nav_menusshow in navigation menus

be careful publicly_queryablemust be true

register_post_type $args

show_in_menushow admin_menu show_ui must be trueJust showing menutrue false else some strings

(toolsphp editphp)

altough it is falseyou can access URLS likewp-admineditphppost_type=music_collection(show_ui must be true)

register_post_type $args

show_in_admin_baravailable in admin bar

menu_postiondefault below comments

menu_iconsee dashicons

register_post_type $args

capability_typestring or array to build capabilites

in our exampeedit_music_collectionsedit_others_music_collections

publish_music_collectionsread_private_music_collections

register_post_type $args

capabilitiesto give specific names to each capability

map_meta_capif true default meta capability will be added

and then your role or account need capabilities

register_post_type $args

hierarchicalpost type can be hierarchicalthis is for page-styles

register_post_type $args

query_varto query posts query_var=slug

rewriteto use pretty permalinks

has_archiveEnables post type archive

register_post_type $args

permalink_epmaskrewrite endpoint bitmask

can_exporttrue makes the post can be exported

Too exhaustive but worth it

Practice Custom Post

Create custom-plugin-ltauthorgtphpCreate a simple custom post

Display admin menuHide admin_barWrite your post Any content is OK Include at least one meta field

Next Week

Customizing Visual Components List Table Screen Widgets

WordPress System Undercover Constants and Globals WPDB

  • WordPress Plugin 3
  • Recap
  • Recap (2)
  • Recap (3)
  • Recap (4)
  • Recap (5)
  • Todays Topics
  • Entry Points in Plugin
  • Entry Points
  • Entry Points (2)
  • Entry Points (3)
  • Entry Points (4)
  • Menu Items
  • Where is default menu
  • Where is default menu (2)
  • Our custom menus
  • add_menu_page
  • add_submenu_page
  • derivatives
  • Shortcodes
  • Shortcodes (2)
  • Shortcodes (3)
  • Shortcodes (4)
  • Shortcodes (5)
  • Shortcodes (6)
  • Admin-post
  • Admin-post (2)
  • Admin-post (3)
  • AJAX
  • Redirect
  • Redirect (2)
  • (de)activation uninstall
  • Summary
  • I know you want to do something
  • Slide 35
  • Source code explained
  • 10 minutes break
  • Managing Your Own Contents
  • Wow there are too many things about posts
  • For today just focuse on custom post type
  • Arguments are too complex
  • of course you might not want this I was just kidding
  • Custom Post
  • Custom Post Motivation
  • Custom Post Motivation (2)
  • Custom Post Motivation (3)
  • Built-in Custom Post Types
  • register_post_type
  • register_post_type (2)
  • register_post_type $post_type
  • register_post_type $args
  • register_post_type $args (2)
  • register_post_type $args (3)
  • register_post_type $args (4)
  • register_post_type $args (5)
  • register_post_type $args (6)
  • register_post_type $args (7)
  • register_post_type $args (8)
  • register_post_type $args (9)
  • register_post_type $args (10)
  • register_post_type $args (11)
  • register_post_type $args (12)
  • register_post_type $args (13)
  • register_post_type $args (14)
  • register_post_type $args (15)
  • Too exhaustive but worth it
  • Practice Custom Post
  • Next Week
Page 22: WordPress plugin #3

Shortcodes

add_shortcode()

$shortcode_tags = array()function add_shortcode($tag $func) global $shortcode_tags

if ( is_callable($func) ) $shortcode_tags[$tag] = $func

Shortcodes

function do_shortcode($content) global $shortcode_tags

if ( false === strpos( $content [ ) ) return $content

if (empty($shortcode_tags) || is_array($shortcode_tags)) return $content

$pattern = get_shortcode_regex() return preg_replace_callback( $patterns do_shortcode_tag $content )

Shortcodes

function do_shortcode_tag( $m )

if ( isset( $m[5] ) ) enclosing tag - extra parameter return $m[1] call_user_func( $shortcode_tags[$tag] $attr $m[5] $tag ) $m[6] else self-closing tag return $m[1] call_user_func( $shortcode_tags[$tag] $attr null $tag ) $m[6]

Shortcodes

callback params $attrs attributes $content enclosed tags text $tag shortcode tag itself

Admin-post

Data from clientsProcessing requests

You can just process requests in your own page because $_REQUEST $_GET $_POST is global

Admin-post

But in your own handlerYou cannot use WP core functionsYou cannot authenticate

Do not reinvent the wheelSo there is admin-postphp

Admin-post

wp-adminadmin-postphpdefine amp include minimal settingsand do_action

$action = empty( $_REQUEST[action] ) $_REQUEST[action]

admin_post_nopriv admin_post_nopriv_$actionadmin_post admin_post_$action

finish using die() in callback function

AJAX

Very similar to admin-post but DOING_AJAX is defineddefine( DOING_AJAX true )

also use die() in callback function

if ( is_user_logged_in() ) do_action( wp_ajax_ $_REQUEST[action] ) else do_action( wp_ajax_nopriv_ $_REQUEST[action] ) Default statusdie( 0 )

Redirect

You can generate custom page in plugin by using template_redirect action

function my_page_template_redirect() if( is_page( goodies ) ampamp is_user_logged_in() )

wp_redirect( home_url( signup ) ) exit()

add_action( template_redirect my_page_template_redirect )

Redirect

You can generate web pages on-the-fly by utilizing these 3 hooks rewrite rule query parsing redirect

Detailed instructions later

(de)activation uninstall

register_activation_hook($file $cb)register_deactivation_hook($file $cb)register_uninstall_hook($file $cb)

$file full path of plugin file$cb callback function

callbacks should be SILENT No echo please

Summary

menu items shortcodes admin post ajax template redirects and (de)activation- uninstall hooks are good initial entry pointso It is a good strategy to find these

hooks in plugins first and dissect their codes from those points

I know you want to do something

You understand hook conceptYou know database detail

Now you know entry points

Definitely you wanna make something

Visit http[ip]practice and download entry-pointsphp

소스코드 http[ip]source-codes1 어드민 화면에 메뉴 추가2 쇼트코드 추가3 메뉴에서 admin post 전송4 메뉴에서 ajax 전송5redirect 테스트

ltauthorgt 부분은 자신의 이름으로 일괄변경하고 적절히 콜백 함수를 정의해 주세요

Source code explained

10 minutes break

Managing Your Own Contents

Wow there are too many things about posts

For today just focuse oncustom post type

Arguments are too complex

Just use Types or Pods pluginThats all problem solved

Yeah

of course you might not want this I was just kidding

Custom Post

You want to manage your own contentsThats why custom post is

Music collections Online store Event calendar Book data Photo portfolio

Custom Post Motivation

Well with just one type post and you may define many categories and use them to organize all contents

JUST ONE TYPE POSTMANY CATEGORIES

portfolio calendar music db

Custom Post Motivation

But you might feel that some post types should be hidden from some users even might be excluded from search may be only for private use may have very complex taxonomies

so that it should have its own territory

can be accessible from their own URL rules

Custom Post Motivation

Why re-invent wheel again

By extending built-in post type systemyou can REUSE whole facilities related to posts easily

UI and all thing about managing

Built-in Custom Post Types

wp-includespostphp (included in wp-settingsphp)function create_initial_post_types()

register_post_type( post array( register_post_type( page array( register_post_type( attachment array( register_post_type( revision array( register_post_type( nav_menu_item array( register_post_status( publish array(

register_post_type

ltphp register_post_type( $post_type $args ) gt

$arg is very complex

But I think it should be explained in detail Actually you cannot avoid it because eventuall all post type plugins will use that function too

Those plugins also have diffcult UIs too

register_post_type

Lets take a look how Types and Pods create their custom posts

They have easy (really) UI and provide better functionaliy but you can see horribly many options there

register_post_type $post_type

Up to 20 characters Only lowercase and numbers

register_post_type $args

publicvisible to authors

true impliesexclude_from_search falsepublicly_queryable show_in_nav_manues show_ui

false impliesexclude_from_search true publicly_queryable falseshow_in_nav_manues false show_ui false

register_post_type $args

labelplural descriptive name

egMusic CollectionsMostly localized text

register_post_type $args

labels more specific text labelsnamesigular_namemenu_namename_admin_barall_itemsadd_newadd_new_itemedit_itemview_itemsearch_items

search_itemsnot_foundnot_found in trashparent_item_colon

register_post_type $args

descriptionsummary of this post type

register_post_type $args

exclude_from_searchdo not search this post typetry S=beatbles

register_post_type $args

publicly_queryablecan use query

eg) post_type=music_collection

register_post_type $args

show_uidisplay default UI

register_post_type $args

show_in_nav_menusshow in navigation menus

be careful publicly_queryablemust be true

register_post_type $args

show_in_menushow admin_menu show_ui must be trueJust showing menutrue false else some strings

(toolsphp editphp)

altough it is falseyou can access URLS likewp-admineditphppost_type=music_collection(show_ui must be true)

register_post_type $args

show_in_admin_baravailable in admin bar

menu_postiondefault below comments

menu_iconsee dashicons

register_post_type $args

capability_typestring or array to build capabilites

in our exampeedit_music_collectionsedit_others_music_collections

publish_music_collectionsread_private_music_collections

register_post_type $args

capabilitiesto give specific names to each capability

map_meta_capif true default meta capability will be added

and then your role or account need capabilities

register_post_type $args

hierarchicalpost type can be hierarchicalthis is for page-styles

register_post_type $args

query_varto query posts query_var=slug

rewriteto use pretty permalinks

has_archiveEnables post type archive

register_post_type $args

permalink_epmaskrewrite endpoint bitmask

can_exporttrue makes the post can be exported

Too exhaustive but worth it

Practice Custom Post

Create custom-plugin-ltauthorgtphpCreate a simple custom post

Display admin menuHide admin_barWrite your post Any content is OK Include at least one meta field

Next Week

Customizing Visual Components List Table Screen Widgets

WordPress System Undercover Constants and Globals WPDB

  • WordPress Plugin 3
  • Recap
  • Recap (2)
  • Recap (3)
  • Recap (4)
  • Recap (5)
  • Todays Topics
  • Entry Points in Plugin
  • Entry Points
  • Entry Points (2)
  • Entry Points (3)
  • Entry Points (4)
  • Menu Items
  • Where is default menu
  • Where is default menu (2)
  • Our custom menus
  • add_menu_page
  • add_submenu_page
  • derivatives
  • Shortcodes
  • Shortcodes (2)
  • Shortcodes (3)
  • Shortcodes (4)
  • Shortcodes (5)
  • Shortcodes (6)
  • Admin-post
  • Admin-post (2)
  • Admin-post (3)
  • AJAX
  • Redirect
  • Redirect (2)
  • (de)activation uninstall
  • Summary
  • I know you want to do something
  • Slide 35
  • Source code explained
  • 10 minutes break
  • Managing Your Own Contents
  • Wow there are too many things about posts
  • For today just focuse on custom post type
  • Arguments are too complex
  • of course you might not want this I was just kidding
  • Custom Post
  • Custom Post Motivation
  • Custom Post Motivation (2)
  • Custom Post Motivation (3)
  • Built-in Custom Post Types
  • register_post_type
  • register_post_type (2)
  • register_post_type $post_type
  • register_post_type $args
  • register_post_type $args (2)
  • register_post_type $args (3)
  • register_post_type $args (4)
  • register_post_type $args (5)
  • register_post_type $args (6)
  • register_post_type $args (7)
  • register_post_type $args (8)
  • register_post_type $args (9)
  • register_post_type $args (10)
  • register_post_type $args (11)
  • register_post_type $args (12)
  • register_post_type $args (13)
  • register_post_type $args (14)
  • register_post_type $args (15)
  • Too exhaustive but worth it
  • Practice Custom Post
  • Next Week
Page 23: WordPress plugin #3

Shortcodes

function do_shortcode($content) global $shortcode_tags

if ( false === strpos( $content [ ) ) return $content

if (empty($shortcode_tags) || is_array($shortcode_tags)) return $content

$pattern = get_shortcode_regex() return preg_replace_callback( $patterns do_shortcode_tag $content )

Shortcodes

function do_shortcode_tag( $m )

if ( isset( $m[5] ) ) enclosing tag - extra parameter return $m[1] call_user_func( $shortcode_tags[$tag] $attr $m[5] $tag ) $m[6] else self-closing tag return $m[1] call_user_func( $shortcode_tags[$tag] $attr null $tag ) $m[6]

Shortcodes

callback params $attrs attributes $content enclosed tags text $tag shortcode tag itself

Admin-post

Data from clientsProcessing requests

You can just process requests in your own page because $_REQUEST $_GET $_POST is global

Admin-post

But in your own handlerYou cannot use WP core functionsYou cannot authenticate

Do not reinvent the wheelSo there is admin-postphp

Admin-post

wp-adminadmin-postphpdefine amp include minimal settingsand do_action

$action = empty( $_REQUEST[action] ) $_REQUEST[action]

admin_post_nopriv admin_post_nopriv_$actionadmin_post admin_post_$action

finish using die() in callback function

AJAX

Very similar to admin-post but DOING_AJAX is defineddefine( DOING_AJAX true )

also use die() in callback function

if ( is_user_logged_in() ) do_action( wp_ajax_ $_REQUEST[action] ) else do_action( wp_ajax_nopriv_ $_REQUEST[action] ) Default statusdie( 0 )

Redirect

You can generate custom page in plugin by using template_redirect action

function my_page_template_redirect() if( is_page( goodies ) ampamp is_user_logged_in() )

wp_redirect( home_url( signup ) ) exit()

add_action( template_redirect my_page_template_redirect )

Redirect

You can generate web pages on-the-fly by utilizing these 3 hooks rewrite rule query parsing redirect

Detailed instructions later

(de)activation uninstall

register_activation_hook($file $cb)register_deactivation_hook($file $cb)register_uninstall_hook($file $cb)

$file full path of plugin file$cb callback function

callbacks should be SILENT No echo please

Summary

menu items shortcodes admin post ajax template redirects and (de)activation- uninstall hooks are good initial entry pointso It is a good strategy to find these

hooks in plugins first and dissect their codes from those points

I know you want to do something

You understand hook conceptYou know database detail

Now you know entry points

Definitely you wanna make something

Visit http[ip]practice and download entry-pointsphp

소스코드 http[ip]source-codes1 어드민 화면에 메뉴 추가2 쇼트코드 추가3 메뉴에서 admin post 전송4 메뉴에서 ajax 전송5redirect 테스트

ltauthorgt 부분은 자신의 이름으로 일괄변경하고 적절히 콜백 함수를 정의해 주세요

Source code explained

10 minutes break

Managing Your Own Contents

Wow there are too many things about posts

For today just focuse oncustom post type

Arguments are too complex

Just use Types or Pods pluginThats all problem solved

Yeah

of course you might not want this I was just kidding

Custom Post

You want to manage your own contentsThats why custom post is

Music collections Online store Event calendar Book data Photo portfolio

Custom Post Motivation

Well with just one type post and you may define many categories and use them to organize all contents

JUST ONE TYPE POSTMANY CATEGORIES

portfolio calendar music db

Custom Post Motivation

But you might feel that some post types should be hidden from some users even might be excluded from search may be only for private use may have very complex taxonomies

so that it should have its own territory

can be accessible from their own URL rules

Custom Post Motivation

Why re-invent wheel again

By extending built-in post type systemyou can REUSE whole facilities related to posts easily

UI and all thing about managing

Built-in Custom Post Types

wp-includespostphp (included in wp-settingsphp)function create_initial_post_types()

register_post_type( post array( register_post_type( page array( register_post_type( attachment array( register_post_type( revision array( register_post_type( nav_menu_item array( register_post_status( publish array(

register_post_type

ltphp register_post_type( $post_type $args ) gt

$arg is very complex

But I think it should be explained in detail Actually you cannot avoid it because eventuall all post type plugins will use that function too

Those plugins also have diffcult UIs too

register_post_type

Lets take a look how Types and Pods create their custom posts

They have easy (really) UI and provide better functionaliy but you can see horribly many options there

register_post_type $post_type

Up to 20 characters Only lowercase and numbers

register_post_type $args

publicvisible to authors

true impliesexclude_from_search falsepublicly_queryable show_in_nav_manues show_ui

false impliesexclude_from_search true publicly_queryable falseshow_in_nav_manues false show_ui false

register_post_type $args

labelplural descriptive name

egMusic CollectionsMostly localized text

register_post_type $args

labels more specific text labelsnamesigular_namemenu_namename_admin_barall_itemsadd_newadd_new_itemedit_itemview_itemsearch_items

search_itemsnot_foundnot_found in trashparent_item_colon

register_post_type $args

descriptionsummary of this post type

register_post_type $args

exclude_from_searchdo not search this post typetry S=beatbles

register_post_type $args

publicly_queryablecan use query

eg) post_type=music_collection

register_post_type $args

show_uidisplay default UI

register_post_type $args

show_in_nav_menusshow in navigation menus

be careful publicly_queryablemust be true

register_post_type $args

show_in_menushow admin_menu show_ui must be trueJust showing menutrue false else some strings

(toolsphp editphp)

altough it is falseyou can access URLS likewp-admineditphppost_type=music_collection(show_ui must be true)

register_post_type $args

show_in_admin_baravailable in admin bar

menu_postiondefault below comments

menu_iconsee dashicons

register_post_type $args

capability_typestring or array to build capabilites

in our exampeedit_music_collectionsedit_others_music_collections

publish_music_collectionsread_private_music_collections

register_post_type $args

capabilitiesto give specific names to each capability

map_meta_capif true default meta capability will be added

and then your role or account need capabilities

register_post_type $args

hierarchicalpost type can be hierarchicalthis is for page-styles

register_post_type $args

query_varto query posts query_var=slug

rewriteto use pretty permalinks

has_archiveEnables post type archive

register_post_type $args

permalink_epmaskrewrite endpoint bitmask

can_exporttrue makes the post can be exported

Too exhaustive but worth it

Practice Custom Post

Create custom-plugin-ltauthorgtphpCreate a simple custom post

Display admin menuHide admin_barWrite your post Any content is OK Include at least one meta field

Next Week

Customizing Visual Components List Table Screen Widgets

WordPress System Undercover Constants and Globals WPDB

  • WordPress Plugin 3
  • Recap
  • Recap (2)
  • Recap (3)
  • Recap (4)
  • Recap (5)
  • Todays Topics
  • Entry Points in Plugin
  • Entry Points
  • Entry Points (2)
  • Entry Points (3)
  • Entry Points (4)
  • Menu Items
  • Where is default menu
  • Where is default menu (2)
  • Our custom menus
  • add_menu_page
  • add_submenu_page
  • derivatives
  • Shortcodes
  • Shortcodes (2)
  • Shortcodes (3)
  • Shortcodes (4)
  • Shortcodes (5)
  • Shortcodes (6)
  • Admin-post
  • Admin-post (2)
  • Admin-post (3)
  • AJAX
  • Redirect
  • Redirect (2)
  • (de)activation uninstall
  • Summary
  • I know you want to do something
  • Slide 35
  • Source code explained
  • 10 minutes break
  • Managing Your Own Contents
  • Wow there are too many things about posts
  • For today just focuse on custom post type
  • Arguments are too complex
  • of course you might not want this I was just kidding
  • Custom Post
  • Custom Post Motivation
  • Custom Post Motivation (2)
  • Custom Post Motivation (3)
  • Built-in Custom Post Types
  • register_post_type
  • register_post_type (2)
  • register_post_type $post_type
  • register_post_type $args
  • register_post_type $args (2)
  • register_post_type $args (3)
  • register_post_type $args (4)
  • register_post_type $args (5)
  • register_post_type $args (6)
  • register_post_type $args (7)
  • register_post_type $args (8)
  • register_post_type $args (9)
  • register_post_type $args (10)
  • register_post_type $args (11)
  • register_post_type $args (12)
  • register_post_type $args (13)
  • register_post_type $args (14)
  • register_post_type $args (15)
  • Too exhaustive but worth it
  • Practice Custom Post
  • Next Week
Page 24: WordPress plugin #3

Shortcodes

function do_shortcode_tag( $m )

if ( isset( $m[5] ) ) enclosing tag - extra parameter return $m[1] call_user_func( $shortcode_tags[$tag] $attr $m[5] $tag ) $m[6] else self-closing tag return $m[1] call_user_func( $shortcode_tags[$tag] $attr null $tag ) $m[6]

Shortcodes

callback params $attrs attributes $content enclosed tags text $tag shortcode tag itself

Admin-post

Data from clientsProcessing requests

You can just process requests in your own page because $_REQUEST $_GET $_POST is global

Admin-post

But in your own handlerYou cannot use WP core functionsYou cannot authenticate

Do not reinvent the wheelSo there is admin-postphp

Admin-post

wp-adminadmin-postphpdefine amp include minimal settingsand do_action

$action = empty( $_REQUEST[action] ) $_REQUEST[action]

admin_post_nopriv admin_post_nopriv_$actionadmin_post admin_post_$action

finish using die() in callback function

AJAX

Very similar to admin-post but DOING_AJAX is defineddefine( DOING_AJAX true )

also use die() in callback function

if ( is_user_logged_in() ) do_action( wp_ajax_ $_REQUEST[action] ) else do_action( wp_ajax_nopriv_ $_REQUEST[action] ) Default statusdie( 0 )

Redirect

You can generate custom page in plugin by using template_redirect action

function my_page_template_redirect() if( is_page( goodies ) ampamp is_user_logged_in() )

wp_redirect( home_url( signup ) ) exit()

add_action( template_redirect my_page_template_redirect )

Redirect

You can generate web pages on-the-fly by utilizing these 3 hooks rewrite rule query parsing redirect

Detailed instructions later

(de)activation uninstall

register_activation_hook($file $cb)register_deactivation_hook($file $cb)register_uninstall_hook($file $cb)

$file full path of plugin file$cb callback function

callbacks should be SILENT No echo please

Summary

menu items shortcodes admin post ajax template redirects and (de)activation- uninstall hooks are good initial entry pointso It is a good strategy to find these

hooks in plugins first and dissect their codes from those points

I know you want to do something

You understand hook conceptYou know database detail

Now you know entry points

Definitely you wanna make something

Visit http[ip]practice and download entry-pointsphp

소스코드 http[ip]source-codes1 어드민 화면에 메뉴 추가2 쇼트코드 추가3 메뉴에서 admin post 전송4 메뉴에서 ajax 전송5redirect 테스트

ltauthorgt 부분은 자신의 이름으로 일괄변경하고 적절히 콜백 함수를 정의해 주세요

Source code explained

10 minutes break

Managing Your Own Contents

Wow there are too many things about posts

For today just focuse oncustom post type

Arguments are too complex

Just use Types or Pods pluginThats all problem solved

Yeah

of course you might not want this I was just kidding

Custom Post

You want to manage your own contentsThats why custom post is

Music collections Online store Event calendar Book data Photo portfolio

Custom Post Motivation

Well with just one type post and you may define many categories and use them to organize all contents

JUST ONE TYPE POSTMANY CATEGORIES

portfolio calendar music db

Custom Post Motivation

But you might feel that some post types should be hidden from some users even might be excluded from search may be only for private use may have very complex taxonomies

so that it should have its own territory

can be accessible from their own URL rules

Custom Post Motivation

Why re-invent wheel again

By extending built-in post type systemyou can REUSE whole facilities related to posts easily

UI and all thing about managing

Built-in Custom Post Types

wp-includespostphp (included in wp-settingsphp)function create_initial_post_types()

register_post_type( post array( register_post_type( page array( register_post_type( attachment array( register_post_type( revision array( register_post_type( nav_menu_item array( register_post_status( publish array(

register_post_type

ltphp register_post_type( $post_type $args ) gt

$arg is very complex

But I think it should be explained in detail Actually you cannot avoid it because eventuall all post type plugins will use that function too

Those plugins also have diffcult UIs too

register_post_type

Lets take a look how Types and Pods create their custom posts

They have easy (really) UI and provide better functionaliy but you can see horribly many options there

register_post_type $post_type

Up to 20 characters Only lowercase and numbers

register_post_type $args

publicvisible to authors

true impliesexclude_from_search falsepublicly_queryable show_in_nav_manues show_ui

false impliesexclude_from_search true publicly_queryable falseshow_in_nav_manues false show_ui false

register_post_type $args

labelplural descriptive name

egMusic CollectionsMostly localized text

register_post_type $args

labels more specific text labelsnamesigular_namemenu_namename_admin_barall_itemsadd_newadd_new_itemedit_itemview_itemsearch_items

search_itemsnot_foundnot_found in trashparent_item_colon

register_post_type $args

descriptionsummary of this post type

register_post_type $args

exclude_from_searchdo not search this post typetry S=beatbles

register_post_type $args

publicly_queryablecan use query

eg) post_type=music_collection

register_post_type $args

show_uidisplay default UI

register_post_type $args

show_in_nav_menusshow in navigation menus

be careful publicly_queryablemust be true

register_post_type $args

show_in_menushow admin_menu show_ui must be trueJust showing menutrue false else some strings

(toolsphp editphp)

altough it is falseyou can access URLS likewp-admineditphppost_type=music_collection(show_ui must be true)

register_post_type $args

show_in_admin_baravailable in admin bar

menu_postiondefault below comments

menu_iconsee dashicons

register_post_type $args

capability_typestring or array to build capabilites

in our exampeedit_music_collectionsedit_others_music_collections

publish_music_collectionsread_private_music_collections

register_post_type $args

capabilitiesto give specific names to each capability

map_meta_capif true default meta capability will be added

and then your role or account need capabilities

register_post_type $args

hierarchicalpost type can be hierarchicalthis is for page-styles

register_post_type $args

query_varto query posts query_var=slug

rewriteto use pretty permalinks

has_archiveEnables post type archive

register_post_type $args

permalink_epmaskrewrite endpoint bitmask

can_exporttrue makes the post can be exported

Too exhaustive but worth it

Practice Custom Post

Create custom-plugin-ltauthorgtphpCreate a simple custom post

Display admin menuHide admin_barWrite your post Any content is OK Include at least one meta field

Next Week

Customizing Visual Components List Table Screen Widgets

WordPress System Undercover Constants and Globals WPDB

  • WordPress Plugin 3
  • Recap
  • Recap (2)
  • Recap (3)
  • Recap (4)
  • Recap (5)
  • Todays Topics
  • Entry Points in Plugin
  • Entry Points
  • Entry Points (2)
  • Entry Points (3)
  • Entry Points (4)
  • Menu Items
  • Where is default menu
  • Where is default menu (2)
  • Our custom menus
  • add_menu_page
  • add_submenu_page
  • derivatives
  • Shortcodes
  • Shortcodes (2)
  • Shortcodes (3)
  • Shortcodes (4)
  • Shortcodes (5)
  • Shortcodes (6)
  • Admin-post
  • Admin-post (2)
  • Admin-post (3)
  • AJAX
  • Redirect
  • Redirect (2)
  • (de)activation uninstall
  • Summary
  • I know you want to do something
  • Slide 35
  • Source code explained
  • 10 minutes break
  • Managing Your Own Contents
  • Wow there are too many things about posts
  • For today just focuse on custom post type
  • Arguments are too complex
  • of course you might not want this I was just kidding
  • Custom Post
  • Custom Post Motivation
  • Custom Post Motivation (2)
  • Custom Post Motivation (3)
  • Built-in Custom Post Types
  • register_post_type
  • register_post_type (2)
  • register_post_type $post_type
  • register_post_type $args
  • register_post_type $args (2)
  • register_post_type $args (3)
  • register_post_type $args (4)
  • register_post_type $args (5)
  • register_post_type $args (6)
  • register_post_type $args (7)
  • register_post_type $args (8)
  • register_post_type $args (9)
  • register_post_type $args (10)
  • register_post_type $args (11)
  • register_post_type $args (12)
  • register_post_type $args (13)
  • register_post_type $args (14)
  • register_post_type $args (15)
  • Too exhaustive but worth it
  • Practice Custom Post
  • Next Week
Page 25: WordPress plugin #3

Shortcodes

callback params $attrs attributes $content enclosed tags text $tag shortcode tag itself

Admin-post

Data from clientsProcessing requests

You can just process requests in your own page because $_REQUEST $_GET $_POST is global

Admin-post

But in your own handlerYou cannot use WP core functionsYou cannot authenticate

Do not reinvent the wheelSo there is admin-postphp

Admin-post

wp-adminadmin-postphpdefine amp include minimal settingsand do_action

$action = empty( $_REQUEST[action] ) $_REQUEST[action]

admin_post_nopriv admin_post_nopriv_$actionadmin_post admin_post_$action

finish using die() in callback function

AJAX

Very similar to admin-post but DOING_AJAX is defineddefine( DOING_AJAX true )

also use die() in callback function

if ( is_user_logged_in() ) do_action( wp_ajax_ $_REQUEST[action] ) else do_action( wp_ajax_nopriv_ $_REQUEST[action] ) Default statusdie( 0 )

Redirect

You can generate custom page in plugin by using template_redirect action

function my_page_template_redirect() if( is_page( goodies ) ampamp is_user_logged_in() )

wp_redirect( home_url( signup ) ) exit()

add_action( template_redirect my_page_template_redirect )

Redirect

You can generate web pages on-the-fly by utilizing these 3 hooks rewrite rule query parsing redirect

Detailed instructions later

(de)activation uninstall

register_activation_hook($file $cb)register_deactivation_hook($file $cb)register_uninstall_hook($file $cb)

$file full path of plugin file$cb callback function

callbacks should be SILENT No echo please

Summary

menu items shortcodes admin post ajax template redirects and (de)activation- uninstall hooks are good initial entry pointso It is a good strategy to find these

hooks in plugins first and dissect their codes from those points

I know you want to do something

You understand hook conceptYou know database detail

Now you know entry points

Definitely you wanna make something

Visit http[ip]practice and download entry-pointsphp

소스코드 http[ip]source-codes1 어드민 화면에 메뉴 추가2 쇼트코드 추가3 메뉴에서 admin post 전송4 메뉴에서 ajax 전송5redirect 테스트

ltauthorgt 부분은 자신의 이름으로 일괄변경하고 적절히 콜백 함수를 정의해 주세요

Source code explained

10 minutes break

Managing Your Own Contents

Wow there are too many things about posts

For today just focuse oncustom post type

Arguments are too complex

Just use Types or Pods pluginThats all problem solved

Yeah

of course you might not want this I was just kidding

Custom Post

You want to manage your own contentsThats why custom post is

Music collections Online store Event calendar Book data Photo portfolio

Custom Post Motivation

Well with just one type post and you may define many categories and use them to organize all contents

JUST ONE TYPE POSTMANY CATEGORIES

portfolio calendar music db

Custom Post Motivation

But you might feel that some post types should be hidden from some users even might be excluded from search may be only for private use may have very complex taxonomies

so that it should have its own territory

can be accessible from their own URL rules

Custom Post Motivation

Why re-invent wheel again

By extending built-in post type systemyou can REUSE whole facilities related to posts easily

UI and all thing about managing

Built-in Custom Post Types

wp-includespostphp (included in wp-settingsphp)function create_initial_post_types()

register_post_type( post array( register_post_type( page array( register_post_type( attachment array( register_post_type( revision array( register_post_type( nav_menu_item array( register_post_status( publish array(

register_post_type

ltphp register_post_type( $post_type $args ) gt

$arg is very complex

But I think it should be explained in detail Actually you cannot avoid it because eventuall all post type plugins will use that function too

Those plugins also have diffcult UIs too

register_post_type

Lets take a look how Types and Pods create their custom posts

They have easy (really) UI and provide better functionaliy but you can see horribly many options there

register_post_type $post_type

Up to 20 characters Only lowercase and numbers

register_post_type $args

publicvisible to authors

true impliesexclude_from_search falsepublicly_queryable show_in_nav_manues show_ui

false impliesexclude_from_search true publicly_queryable falseshow_in_nav_manues false show_ui false

register_post_type $args

labelplural descriptive name

egMusic CollectionsMostly localized text

register_post_type $args

labels more specific text labelsnamesigular_namemenu_namename_admin_barall_itemsadd_newadd_new_itemedit_itemview_itemsearch_items

search_itemsnot_foundnot_found in trashparent_item_colon

register_post_type $args

descriptionsummary of this post type

register_post_type $args

exclude_from_searchdo not search this post typetry S=beatbles

register_post_type $args

publicly_queryablecan use query

eg) post_type=music_collection

register_post_type $args

show_uidisplay default UI

register_post_type $args

show_in_nav_menusshow in navigation menus

be careful publicly_queryablemust be true

register_post_type $args

show_in_menushow admin_menu show_ui must be trueJust showing menutrue false else some strings

(toolsphp editphp)

altough it is falseyou can access URLS likewp-admineditphppost_type=music_collection(show_ui must be true)

register_post_type $args

show_in_admin_baravailable in admin bar

menu_postiondefault below comments

menu_iconsee dashicons

register_post_type $args

capability_typestring or array to build capabilites

in our exampeedit_music_collectionsedit_others_music_collections

publish_music_collectionsread_private_music_collections

register_post_type $args

capabilitiesto give specific names to each capability

map_meta_capif true default meta capability will be added

and then your role or account need capabilities

register_post_type $args

hierarchicalpost type can be hierarchicalthis is for page-styles

register_post_type $args

query_varto query posts query_var=slug

rewriteto use pretty permalinks

has_archiveEnables post type archive

register_post_type $args

permalink_epmaskrewrite endpoint bitmask

can_exporttrue makes the post can be exported

Too exhaustive but worth it

Practice Custom Post

Create custom-plugin-ltauthorgtphpCreate a simple custom post

Display admin menuHide admin_barWrite your post Any content is OK Include at least one meta field

Next Week

Customizing Visual Components List Table Screen Widgets

WordPress System Undercover Constants and Globals WPDB

  • WordPress Plugin 3
  • Recap
  • Recap (2)
  • Recap (3)
  • Recap (4)
  • Recap (5)
  • Todays Topics
  • Entry Points in Plugin
  • Entry Points
  • Entry Points (2)
  • Entry Points (3)
  • Entry Points (4)
  • Menu Items
  • Where is default menu
  • Where is default menu (2)
  • Our custom menus
  • add_menu_page
  • add_submenu_page
  • derivatives
  • Shortcodes
  • Shortcodes (2)
  • Shortcodes (3)
  • Shortcodes (4)
  • Shortcodes (5)
  • Shortcodes (6)
  • Admin-post
  • Admin-post (2)
  • Admin-post (3)
  • AJAX
  • Redirect
  • Redirect (2)
  • (de)activation uninstall
  • Summary
  • I know you want to do something
  • Slide 35
  • Source code explained
  • 10 minutes break
  • Managing Your Own Contents
  • Wow there are too many things about posts
  • For today just focuse on custom post type
  • Arguments are too complex
  • of course you might not want this I was just kidding
  • Custom Post
  • Custom Post Motivation
  • Custom Post Motivation (2)
  • Custom Post Motivation (3)
  • Built-in Custom Post Types
  • register_post_type
  • register_post_type (2)
  • register_post_type $post_type
  • register_post_type $args
  • register_post_type $args (2)
  • register_post_type $args (3)
  • register_post_type $args (4)
  • register_post_type $args (5)
  • register_post_type $args (6)
  • register_post_type $args (7)
  • register_post_type $args (8)
  • register_post_type $args (9)
  • register_post_type $args (10)
  • register_post_type $args (11)
  • register_post_type $args (12)
  • register_post_type $args (13)
  • register_post_type $args (14)
  • register_post_type $args (15)
  • Too exhaustive but worth it
  • Practice Custom Post
  • Next Week
Page 26: WordPress plugin #3

Admin-post

Data from clientsProcessing requests

You can just process requests in your own page because $_REQUEST $_GET $_POST is global

Admin-post

But in your own handlerYou cannot use WP core functionsYou cannot authenticate

Do not reinvent the wheelSo there is admin-postphp

Admin-post

wp-adminadmin-postphpdefine amp include minimal settingsand do_action

$action = empty( $_REQUEST[action] ) $_REQUEST[action]

admin_post_nopriv admin_post_nopriv_$actionadmin_post admin_post_$action

finish using die() in callback function

AJAX

Very similar to admin-post but DOING_AJAX is defineddefine( DOING_AJAX true )

also use die() in callback function

if ( is_user_logged_in() ) do_action( wp_ajax_ $_REQUEST[action] ) else do_action( wp_ajax_nopriv_ $_REQUEST[action] ) Default statusdie( 0 )

Redirect

You can generate custom page in plugin by using template_redirect action

function my_page_template_redirect() if( is_page( goodies ) ampamp is_user_logged_in() )

wp_redirect( home_url( signup ) ) exit()

add_action( template_redirect my_page_template_redirect )

Redirect

You can generate web pages on-the-fly by utilizing these 3 hooks rewrite rule query parsing redirect

Detailed instructions later

(de)activation uninstall

register_activation_hook($file $cb)register_deactivation_hook($file $cb)register_uninstall_hook($file $cb)

$file full path of plugin file$cb callback function

callbacks should be SILENT No echo please

Summary

menu items shortcodes admin post ajax template redirects and (de)activation- uninstall hooks are good initial entry pointso It is a good strategy to find these

hooks in plugins first and dissect their codes from those points

I know you want to do something

You understand hook conceptYou know database detail

Now you know entry points

Definitely you wanna make something

Visit http[ip]practice and download entry-pointsphp

소스코드 http[ip]source-codes1 어드민 화면에 메뉴 추가2 쇼트코드 추가3 메뉴에서 admin post 전송4 메뉴에서 ajax 전송5redirect 테스트

ltauthorgt 부분은 자신의 이름으로 일괄변경하고 적절히 콜백 함수를 정의해 주세요

Source code explained

10 minutes break

Managing Your Own Contents

Wow there are too many things about posts

For today just focuse oncustom post type

Arguments are too complex

Just use Types or Pods pluginThats all problem solved

Yeah

of course you might not want this I was just kidding

Custom Post

You want to manage your own contentsThats why custom post is

Music collections Online store Event calendar Book data Photo portfolio

Custom Post Motivation

Well with just one type post and you may define many categories and use them to organize all contents

JUST ONE TYPE POSTMANY CATEGORIES

portfolio calendar music db

Custom Post Motivation

But you might feel that some post types should be hidden from some users even might be excluded from search may be only for private use may have very complex taxonomies

so that it should have its own territory

can be accessible from their own URL rules

Custom Post Motivation

Why re-invent wheel again

By extending built-in post type systemyou can REUSE whole facilities related to posts easily

UI and all thing about managing

Built-in Custom Post Types

wp-includespostphp (included in wp-settingsphp)function create_initial_post_types()

register_post_type( post array( register_post_type( page array( register_post_type( attachment array( register_post_type( revision array( register_post_type( nav_menu_item array( register_post_status( publish array(

register_post_type

ltphp register_post_type( $post_type $args ) gt

$arg is very complex

But I think it should be explained in detail Actually you cannot avoid it because eventuall all post type plugins will use that function too

Those plugins also have diffcult UIs too

register_post_type

Lets take a look how Types and Pods create their custom posts

They have easy (really) UI and provide better functionaliy but you can see horribly many options there

register_post_type $post_type

Up to 20 characters Only lowercase and numbers

register_post_type $args

publicvisible to authors

true impliesexclude_from_search falsepublicly_queryable show_in_nav_manues show_ui

false impliesexclude_from_search true publicly_queryable falseshow_in_nav_manues false show_ui false

register_post_type $args

labelplural descriptive name

egMusic CollectionsMostly localized text

register_post_type $args

labels more specific text labelsnamesigular_namemenu_namename_admin_barall_itemsadd_newadd_new_itemedit_itemview_itemsearch_items

search_itemsnot_foundnot_found in trashparent_item_colon

register_post_type $args

descriptionsummary of this post type

register_post_type $args

exclude_from_searchdo not search this post typetry S=beatbles

register_post_type $args

publicly_queryablecan use query

eg) post_type=music_collection

register_post_type $args

show_uidisplay default UI

register_post_type $args

show_in_nav_menusshow in navigation menus

be careful publicly_queryablemust be true

register_post_type $args

show_in_menushow admin_menu show_ui must be trueJust showing menutrue false else some strings

(toolsphp editphp)

altough it is falseyou can access URLS likewp-admineditphppost_type=music_collection(show_ui must be true)

register_post_type $args

show_in_admin_baravailable in admin bar

menu_postiondefault below comments

menu_iconsee dashicons

register_post_type $args

capability_typestring or array to build capabilites

in our exampeedit_music_collectionsedit_others_music_collections

publish_music_collectionsread_private_music_collections

register_post_type $args

capabilitiesto give specific names to each capability

map_meta_capif true default meta capability will be added

and then your role or account need capabilities

register_post_type $args

hierarchicalpost type can be hierarchicalthis is for page-styles

register_post_type $args

query_varto query posts query_var=slug

rewriteto use pretty permalinks

has_archiveEnables post type archive

register_post_type $args

permalink_epmaskrewrite endpoint bitmask

can_exporttrue makes the post can be exported

Too exhaustive but worth it

Practice Custom Post

Create custom-plugin-ltauthorgtphpCreate a simple custom post

Display admin menuHide admin_barWrite your post Any content is OK Include at least one meta field

Next Week

Customizing Visual Components List Table Screen Widgets

WordPress System Undercover Constants and Globals WPDB

  • WordPress Plugin 3
  • Recap
  • Recap (2)
  • Recap (3)
  • Recap (4)
  • Recap (5)
  • Todays Topics
  • Entry Points in Plugin
  • Entry Points
  • Entry Points (2)
  • Entry Points (3)
  • Entry Points (4)
  • Menu Items
  • Where is default menu
  • Where is default menu (2)
  • Our custom menus
  • add_menu_page
  • add_submenu_page
  • derivatives
  • Shortcodes
  • Shortcodes (2)
  • Shortcodes (3)
  • Shortcodes (4)
  • Shortcodes (5)
  • Shortcodes (6)
  • Admin-post
  • Admin-post (2)
  • Admin-post (3)
  • AJAX
  • Redirect
  • Redirect (2)
  • (de)activation uninstall
  • Summary
  • I know you want to do something
  • Slide 35
  • Source code explained
  • 10 minutes break
  • Managing Your Own Contents
  • Wow there are too many things about posts
  • For today just focuse on custom post type
  • Arguments are too complex
  • of course you might not want this I was just kidding
  • Custom Post
  • Custom Post Motivation
  • Custom Post Motivation (2)
  • Custom Post Motivation (3)
  • Built-in Custom Post Types
  • register_post_type
  • register_post_type (2)
  • register_post_type $post_type
  • register_post_type $args
  • register_post_type $args (2)
  • register_post_type $args (3)
  • register_post_type $args (4)
  • register_post_type $args (5)
  • register_post_type $args (6)
  • register_post_type $args (7)
  • register_post_type $args (8)
  • register_post_type $args (9)
  • register_post_type $args (10)
  • register_post_type $args (11)
  • register_post_type $args (12)
  • register_post_type $args (13)
  • register_post_type $args (14)
  • register_post_type $args (15)
  • Too exhaustive but worth it
  • Practice Custom Post
  • Next Week
Page 27: WordPress plugin #3

Admin-post

But in your own handlerYou cannot use WP core functionsYou cannot authenticate

Do not reinvent the wheelSo there is admin-postphp

Admin-post

wp-adminadmin-postphpdefine amp include minimal settingsand do_action

$action = empty( $_REQUEST[action] ) $_REQUEST[action]

admin_post_nopriv admin_post_nopriv_$actionadmin_post admin_post_$action

finish using die() in callback function

AJAX

Very similar to admin-post but DOING_AJAX is defineddefine( DOING_AJAX true )

also use die() in callback function

if ( is_user_logged_in() ) do_action( wp_ajax_ $_REQUEST[action] ) else do_action( wp_ajax_nopriv_ $_REQUEST[action] ) Default statusdie( 0 )

Redirect

You can generate custom page in plugin by using template_redirect action

function my_page_template_redirect() if( is_page( goodies ) ampamp is_user_logged_in() )

wp_redirect( home_url( signup ) ) exit()

add_action( template_redirect my_page_template_redirect )

Redirect

You can generate web pages on-the-fly by utilizing these 3 hooks rewrite rule query parsing redirect

Detailed instructions later

(de)activation uninstall

register_activation_hook($file $cb)register_deactivation_hook($file $cb)register_uninstall_hook($file $cb)

$file full path of plugin file$cb callback function

callbacks should be SILENT No echo please

Summary

menu items shortcodes admin post ajax template redirects and (de)activation- uninstall hooks are good initial entry pointso It is a good strategy to find these

hooks in plugins first and dissect their codes from those points

I know you want to do something

You understand hook conceptYou know database detail

Now you know entry points

Definitely you wanna make something

Visit http[ip]practice and download entry-pointsphp

소스코드 http[ip]source-codes1 어드민 화면에 메뉴 추가2 쇼트코드 추가3 메뉴에서 admin post 전송4 메뉴에서 ajax 전송5redirect 테스트

ltauthorgt 부분은 자신의 이름으로 일괄변경하고 적절히 콜백 함수를 정의해 주세요

Source code explained

10 minutes break

Managing Your Own Contents

Wow there are too many things about posts

For today just focuse oncustom post type

Arguments are too complex

Just use Types or Pods pluginThats all problem solved

Yeah

of course you might not want this I was just kidding

Custom Post

You want to manage your own contentsThats why custom post is

Music collections Online store Event calendar Book data Photo portfolio

Custom Post Motivation

Well with just one type post and you may define many categories and use them to organize all contents

JUST ONE TYPE POSTMANY CATEGORIES

portfolio calendar music db

Custom Post Motivation

But you might feel that some post types should be hidden from some users even might be excluded from search may be only for private use may have very complex taxonomies

so that it should have its own territory

can be accessible from their own URL rules

Custom Post Motivation

Why re-invent wheel again

By extending built-in post type systemyou can REUSE whole facilities related to posts easily

UI and all thing about managing

Built-in Custom Post Types

wp-includespostphp (included in wp-settingsphp)function create_initial_post_types()

register_post_type( post array( register_post_type( page array( register_post_type( attachment array( register_post_type( revision array( register_post_type( nav_menu_item array( register_post_status( publish array(

register_post_type

ltphp register_post_type( $post_type $args ) gt

$arg is very complex

But I think it should be explained in detail Actually you cannot avoid it because eventuall all post type plugins will use that function too

Those plugins also have diffcult UIs too

register_post_type

Lets take a look how Types and Pods create their custom posts

They have easy (really) UI and provide better functionaliy but you can see horribly many options there

register_post_type $post_type

Up to 20 characters Only lowercase and numbers

register_post_type $args

publicvisible to authors

true impliesexclude_from_search falsepublicly_queryable show_in_nav_manues show_ui

false impliesexclude_from_search true publicly_queryable falseshow_in_nav_manues false show_ui false

register_post_type $args

labelplural descriptive name

egMusic CollectionsMostly localized text

register_post_type $args

labels more specific text labelsnamesigular_namemenu_namename_admin_barall_itemsadd_newadd_new_itemedit_itemview_itemsearch_items

search_itemsnot_foundnot_found in trashparent_item_colon

register_post_type $args

descriptionsummary of this post type

register_post_type $args

exclude_from_searchdo not search this post typetry S=beatbles

register_post_type $args

publicly_queryablecan use query

eg) post_type=music_collection

register_post_type $args

show_uidisplay default UI

register_post_type $args

show_in_nav_menusshow in navigation menus

be careful publicly_queryablemust be true

register_post_type $args

show_in_menushow admin_menu show_ui must be trueJust showing menutrue false else some strings

(toolsphp editphp)

altough it is falseyou can access URLS likewp-admineditphppost_type=music_collection(show_ui must be true)

register_post_type $args

show_in_admin_baravailable in admin bar

menu_postiondefault below comments

menu_iconsee dashicons

register_post_type $args

capability_typestring or array to build capabilites

in our exampeedit_music_collectionsedit_others_music_collections

publish_music_collectionsread_private_music_collections

register_post_type $args

capabilitiesto give specific names to each capability

map_meta_capif true default meta capability will be added

and then your role or account need capabilities

register_post_type $args

hierarchicalpost type can be hierarchicalthis is for page-styles

register_post_type $args

query_varto query posts query_var=slug

rewriteto use pretty permalinks

has_archiveEnables post type archive

register_post_type $args

permalink_epmaskrewrite endpoint bitmask

can_exporttrue makes the post can be exported

Too exhaustive but worth it

Practice Custom Post

Create custom-plugin-ltauthorgtphpCreate a simple custom post

Display admin menuHide admin_barWrite your post Any content is OK Include at least one meta field

Next Week

Customizing Visual Components List Table Screen Widgets

WordPress System Undercover Constants and Globals WPDB

  • WordPress Plugin 3
  • Recap
  • Recap (2)
  • Recap (3)
  • Recap (4)
  • Recap (5)
  • Todays Topics
  • Entry Points in Plugin
  • Entry Points
  • Entry Points (2)
  • Entry Points (3)
  • Entry Points (4)
  • Menu Items
  • Where is default menu
  • Where is default menu (2)
  • Our custom menus
  • add_menu_page
  • add_submenu_page
  • derivatives
  • Shortcodes
  • Shortcodes (2)
  • Shortcodes (3)
  • Shortcodes (4)
  • Shortcodes (5)
  • Shortcodes (6)
  • Admin-post
  • Admin-post (2)
  • Admin-post (3)
  • AJAX
  • Redirect
  • Redirect (2)
  • (de)activation uninstall
  • Summary
  • I know you want to do something
  • Slide 35
  • Source code explained
  • 10 minutes break
  • Managing Your Own Contents
  • Wow there are too many things about posts
  • For today just focuse on custom post type
  • Arguments are too complex
  • of course you might not want this I was just kidding
  • Custom Post
  • Custom Post Motivation
  • Custom Post Motivation (2)
  • Custom Post Motivation (3)
  • Built-in Custom Post Types
  • register_post_type
  • register_post_type (2)
  • register_post_type $post_type
  • register_post_type $args
  • register_post_type $args (2)
  • register_post_type $args (3)
  • register_post_type $args (4)
  • register_post_type $args (5)
  • register_post_type $args (6)
  • register_post_type $args (7)
  • register_post_type $args (8)
  • register_post_type $args (9)
  • register_post_type $args (10)
  • register_post_type $args (11)
  • register_post_type $args (12)
  • register_post_type $args (13)
  • register_post_type $args (14)
  • register_post_type $args (15)
  • Too exhaustive but worth it
  • Practice Custom Post
  • Next Week
Page 28: WordPress plugin #3

Admin-post

wp-adminadmin-postphpdefine amp include minimal settingsand do_action

$action = empty( $_REQUEST[action] ) $_REQUEST[action]

admin_post_nopriv admin_post_nopriv_$actionadmin_post admin_post_$action

finish using die() in callback function

AJAX

Very similar to admin-post but DOING_AJAX is defineddefine( DOING_AJAX true )

also use die() in callback function

if ( is_user_logged_in() ) do_action( wp_ajax_ $_REQUEST[action] ) else do_action( wp_ajax_nopriv_ $_REQUEST[action] ) Default statusdie( 0 )

Redirect

You can generate custom page in plugin by using template_redirect action

function my_page_template_redirect() if( is_page( goodies ) ampamp is_user_logged_in() )

wp_redirect( home_url( signup ) ) exit()

add_action( template_redirect my_page_template_redirect )

Redirect

You can generate web pages on-the-fly by utilizing these 3 hooks rewrite rule query parsing redirect

Detailed instructions later

(de)activation uninstall

register_activation_hook($file $cb)register_deactivation_hook($file $cb)register_uninstall_hook($file $cb)

$file full path of plugin file$cb callback function

callbacks should be SILENT No echo please

Summary

menu items shortcodes admin post ajax template redirects and (de)activation- uninstall hooks are good initial entry pointso It is a good strategy to find these

hooks in plugins first and dissect their codes from those points

I know you want to do something

You understand hook conceptYou know database detail

Now you know entry points

Definitely you wanna make something

Visit http[ip]practice and download entry-pointsphp

소스코드 http[ip]source-codes1 어드민 화면에 메뉴 추가2 쇼트코드 추가3 메뉴에서 admin post 전송4 메뉴에서 ajax 전송5redirect 테스트

ltauthorgt 부분은 자신의 이름으로 일괄변경하고 적절히 콜백 함수를 정의해 주세요

Source code explained

10 minutes break

Managing Your Own Contents

Wow there are too many things about posts

For today just focuse oncustom post type

Arguments are too complex

Just use Types or Pods pluginThats all problem solved

Yeah

of course you might not want this I was just kidding

Custom Post

You want to manage your own contentsThats why custom post is

Music collections Online store Event calendar Book data Photo portfolio

Custom Post Motivation

Well with just one type post and you may define many categories and use them to organize all contents

JUST ONE TYPE POSTMANY CATEGORIES

portfolio calendar music db

Custom Post Motivation

But you might feel that some post types should be hidden from some users even might be excluded from search may be only for private use may have very complex taxonomies

so that it should have its own territory

can be accessible from their own URL rules

Custom Post Motivation

Why re-invent wheel again

By extending built-in post type systemyou can REUSE whole facilities related to posts easily

UI and all thing about managing

Built-in Custom Post Types

wp-includespostphp (included in wp-settingsphp)function create_initial_post_types()

register_post_type( post array( register_post_type( page array( register_post_type( attachment array( register_post_type( revision array( register_post_type( nav_menu_item array( register_post_status( publish array(

register_post_type

ltphp register_post_type( $post_type $args ) gt

$arg is very complex

But I think it should be explained in detail Actually you cannot avoid it because eventuall all post type plugins will use that function too

Those plugins also have diffcult UIs too

register_post_type

Lets take a look how Types and Pods create their custom posts

They have easy (really) UI and provide better functionaliy but you can see horribly many options there

register_post_type $post_type

Up to 20 characters Only lowercase and numbers

register_post_type $args

publicvisible to authors

true impliesexclude_from_search falsepublicly_queryable show_in_nav_manues show_ui

false impliesexclude_from_search true publicly_queryable falseshow_in_nav_manues false show_ui false

register_post_type $args

labelplural descriptive name

egMusic CollectionsMostly localized text

register_post_type $args

labels more specific text labelsnamesigular_namemenu_namename_admin_barall_itemsadd_newadd_new_itemedit_itemview_itemsearch_items

search_itemsnot_foundnot_found in trashparent_item_colon

register_post_type $args

descriptionsummary of this post type

register_post_type $args

exclude_from_searchdo not search this post typetry S=beatbles

register_post_type $args

publicly_queryablecan use query

eg) post_type=music_collection

register_post_type $args

show_uidisplay default UI

register_post_type $args

show_in_nav_menusshow in navigation menus

be careful publicly_queryablemust be true

register_post_type $args

show_in_menushow admin_menu show_ui must be trueJust showing menutrue false else some strings

(toolsphp editphp)

altough it is falseyou can access URLS likewp-admineditphppost_type=music_collection(show_ui must be true)

register_post_type $args

show_in_admin_baravailable in admin bar

menu_postiondefault below comments

menu_iconsee dashicons

register_post_type $args

capability_typestring or array to build capabilites

in our exampeedit_music_collectionsedit_others_music_collections

publish_music_collectionsread_private_music_collections

register_post_type $args

capabilitiesto give specific names to each capability

map_meta_capif true default meta capability will be added

and then your role or account need capabilities

register_post_type $args

hierarchicalpost type can be hierarchicalthis is for page-styles

register_post_type $args

query_varto query posts query_var=slug

rewriteto use pretty permalinks

has_archiveEnables post type archive

register_post_type $args

permalink_epmaskrewrite endpoint bitmask

can_exporttrue makes the post can be exported

Too exhaustive but worth it

Practice Custom Post

Create custom-plugin-ltauthorgtphpCreate a simple custom post

Display admin menuHide admin_barWrite your post Any content is OK Include at least one meta field

Next Week

Customizing Visual Components List Table Screen Widgets

WordPress System Undercover Constants and Globals WPDB

  • WordPress Plugin 3
  • Recap
  • Recap (2)
  • Recap (3)
  • Recap (4)
  • Recap (5)
  • Todays Topics
  • Entry Points in Plugin
  • Entry Points
  • Entry Points (2)
  • Entry Points (3)
  • Entry Points (4)
  • Menu Items
  • Where is default menu
  • Where is default menu (2)
  • Our custom menus
  • add_menu_page
  • add_submenu_page
  • derivatives
  • Shortcodes
  • Shortcodes (2)
  • Shortcodes (3)
  • Shortcodes (4)
  • Shortcodes (5)
  • Shortcodes (6)
  • Admin-post
  • Admin-post (2)
  • Admin-post (3)
  • AJAX
  • Redirect
  • Redirect (2)
  • (de)activation uninstall
  • Summary
  • I know you want to do something
  • Slide 35
  • Source code explained
  • 10 minutes break
  • Managing Your Own Contents
  • Wow there are too many things about posts
  • For today just focuse on custom post type
  • Arguments are too complex
  • of course you might not want this I was just kidding
  • Custom Post
  • Custom Post Motivation
  • Custom Post Motivation (2)
  • Custom Post Motivation (3)
  • Built-in Custom Post Types
  • register_post_type
  • register_post_type (2)
  • register_post_type $post_type
  • register_post_type $args
  • register_post_type $args (2)
  • register_post_type $args (3)
  • register_post_type $args (4)
  • register_post_type $args (5)
  • register_post_type $args (6)
  • register_post_type $args (7)
  • register_post_type $args (8)
  • register_post_type $args (9)
  • register_post_type $args (10)
  • register_post_type $args (11)
  • register_post_type $args (12)
  • register_post_type $args (13)
  • register_post_type $args (14)
  • register_post_type $args (15)
  • Too exhaustive but worth it
  • Practice Custom Post
  • Next Week
Page 29: WordPress plugin #3

AJAX

Very similar to admin-post but DOING_AJAX is defineddefine( DOING_AJAX true )

also use die() in callback function

if ( is_user_logged_in() ) do_action( wp_ajax_ $_REQUEST[action] ) else do_action( wp_ajax_nopriv_ $_REQUEST[action] ) Default statusdie( 0 )

Redirect

You can generate custom page in plugin by using template_redirect action

function my_page_template_redirect() if( is_page( goodies ) ampamp is_user_logged_in() )

wp_redirect( home_url( signup ) ) exit()

add_action( template_redirect my_page_template_redirect )

Redirect

You can generate web pages on-the-fly by utilizing these 3 hooks rewrite rule query parsing redirect

Detailed instructions later

(de)activation uninstall

register_activation_hook($file $cb)register_deactivation_hook($file $cb)register_uninstall_hook($file $cb)

$file full path of plugin file$cb callback function

callbacks should be SILENT No echo please

Summary

menu items shortcodes admin post ajax template redirects and (de)activation- uninstall hooks are good initial entry pointso It is a good strategy to find these

hooks in plugins first and dissect their codes from those points

I know you want to do something

You understand hook conceptYou know database detail

Now you know entry points

Definitely you wanna make something

Visit http[ip]practice and download entry-pointsphp

소스코드 http[ip]source-codes1 어드민 화면에 메뉴 추가2 쇼트코드 추가3 메뉴에서 admin post 전송4 메뉴에서 ajax 전송5redirect 테스트

ltauthorgt 부분은 자신의 이름으로 일괄변경하고 적절히 콜백 함수를 정의해 주세요

Source code explained

10 minutes break

Managing Your Own Contents

Wow there are too many things about posts

For today just focuse oncustom post type

Arguments are too complex

Just use Types or Pods pluginThats all problem solved

Yeah

of course you might not want this I was just kidding

Custom Post

You want to manage your own contentsThats why custom post is

Music collections Online store Event calendar Book data Photo portfolio

Custom Post Motivation

Well with just one type post and you may define many categories and use them to organize all contents

JUST ONE TYPE POSTMANY CATEGORIES

portfolio calendar music db

Custom Post Motivation

But you might feel that some post types should be hidden from some users even might be excluded from search may be only for private use may have very complex taxonomies

so that it should have its own territory

can be accessible from their own URL rules

Custom Post Motivation

Why re-invent wheel again

By extending built-in post type systemyou can REUSE whole facilities related to posts easily

UI and all thing about managing

Built-in Custom Post Types

wp-includespostphp (included in wp-settingsphp)function create_initial_post_types()

register_post_type( post array( register_post_type( page array( register_post_type( attachment array( register_post_type( revision array( register_post_type( nav_menu_item array( register_post_status( publish array(

register_post_type

ltphp register_post_type( $post_type $args ) gt

$arg is very complex

But I think it should be explained in detail Actually you cannot avoid it because eventuall all post type plugins will use that function too

Those plugins also have diffcult UIs too

register_post_type

Lets take a look how Types and Pods create their custom posts

They have easy (really) UI and provide better functionaliy but you can see horribly many options there

register_post_type $post_type

Up to 20 characters Only lowercase and numbers

register_post_type $args

publicvisible to authors

true impliesexclude_from_search falsepublicly_queryable show_in_nav_manues show_ui

false impliesexclude_from_search true publicly_queryable falseshow_in_nav_manues false show_ui false

register_post_type $args

labelplural descriptive name

egMusic CollectionsMostly localized text

register_post_type $args

labels more specific text labelsnamesigular_namemenu_namename_admin_barall_itemsadd_newadd_new_itemedit_itemview_itemsearch_items

search_itemsnot_foundnot_found in trashparent_item_colon

register_post_type $args

descriptionsummary of this post type

register_post_type $args

exclude_from_searchdo not search this post typetry S=beatbles

register_post_type $args

publicly_queryablecan use query

eg) post_type=music_collection

register_post_type $args

show_uidisplay default UI

register_post_type $args

show_in_nav_menusshow in navigation menus

be careful publicly_queryablemust be true

register_post_type $args

show_in_menushow admin_menu show_ui must be trueJust showing menutrue false else some strings

(toolsphp editphp)

altough it is falseyou can access URLS likewp-admineditphppost_type=music_collection(show_ui must be true)

register_post_type $args

show_in_admin_baravailable in admin bar

menu_postiondefault below comments

menu_iconsee dashicons

register_post_type $args

capability_typestring or array to build capabilites

in our exampeedit_music_collectionsedit_others_music_collections

publish_music_collectionsread_private_music_collections

register_post_type $args

capabilitiesto give specific names to each capability

map_meta_capif true default meta capability will be added

and then your role or account need capabilities

register_post_type $args

hierarchicalpost type can be hierarchicalthis is for page-styles

register_post_type $args

query_varto query posts query_var=slug

rewriteto use pretty permalinks

has_archiveEnables post type archive

register_post_type $args

permalink_epmaskrewrite endpoint bitmask

can_exporttrue makes the post can be exported

Too exhaustive but worth it

Practice Custom Post

Create custom-plugin-ltauthorgtphpCreate a simple custom post

Display admin menuHide admin_barWrite your post Any content is OK Include at least one meta field

Next Week

Customizing Visual Components List Table Screen Widgets

WordPress System Undercover Constants and Globals WPDB

  • WordPress Plugin 3
  • Recap
  • Recap (2)
  • Recap (3)
  • Recap (4)
  • Recap (5)
  • Todays Topics
  • Entry Points in Plugin
  • Entry Points
  • Entry Points (2)
  • Entry Points (3)
  • Entry Points (4)
  • Menu Items
  • Where is default menu
  • Where is default menu (2)
  • Our custom menus
  • add_menu_page
  • add_submenu_page
  • derivatives
  • Shortcodes
  • Shortcodes (2)
  • Shortcodes (3)
  • Shortcodes (4)
  • Shortcodes (5)
  • Shortcodes (6)
  • Admin-post
  • Admin-post (2)
  • Admin-post (3)
  • AJAX
  • Redirect
  • Redirect (2)
  • (de)activation uninstall
  • Summary
  • I know you want to do something
  • Slide 35
  • Source code explained
  • 10 minutes break
  • Managing Your Own Contents
  • Wow there are too many things about posts
  • For today just focuse on custom post type
  • Arguments are too complex
  • of course you might not want this I was just kidding
  • Custom Post
  • Custom Post Motivation
  • Custom Post Motivation (2)
  • Custom Post Motivation (3)
  • Built-in Custom Post Types
  • register_post_type
  • register_post_type (2)
  • register_post_type $post_type
  • register_post_type $args
  • register_post_type $args (2)
  • register_post_type $args (3)
  • register_post_type $args (4)
  • register_post_type $args (5)
  • register_post_type $args (6)
  • register_post_type $args (7)
  • register_post_type $args (8)
  • register_post_type $args (9)
  • register_post_type $args (10)
  • register_post_type $args (11)
  • register_post_type $args (12)
  • register_post_type $args (13)
  • register_post_type $args (14)
  • register_post_type $args (15)
  • Too exhaustive but worth it
  • Practice Custom Post
  • Next Week
Page 30: WordPress plugin #3

Redirect

You can generate custom page in plugin by using template_redirect action

function my_page_template_redirect() if( is_page( goodies ) ampamp is_user_logged_in() )

wp_redirect( home_url( signup ) ) exit()

add_action( template_redirect my_page_template_redirect )

Redirect

You can generate web pages on-the-fly by utilizing these 3 hooks rewrite rule query parsing redirect

Detailed instructions later

(de)activation uninstall

register_activation_hook($file $cb)register_deactivation_hook($file $cb)register_uninstall_hook($file $cb)

$file full path of plugin file$cb callback function

callbacks should be SILENT No echo please

Summary

menu items shortcodes admin post ajax template redirects and (de)activation- uninstall hooks are good initial entry pointso It is a good strategy to find these

hooks in plugins first and dissect their codes from those points

I know you want to do something

You understand hook conceptYou know database detail

Now you know entry points

Definitely you wanna make something

Visit http[ip]practice and download entry-pointsphp

소스코드 http[ip]source-codes1 어드민 화면에 메뉴 추가2 쇼트코드 추가3 메뉴에서 admin post 전송4 메뉴에서 ajax 전송5redirect 테스트

ltauthorgt 부분은 자신의 이름으로 일괄변경하고 적절히 콜백 함수를 정의해 주세요

Source code explained

10 minutes break

Managing Your Own Contents

Wow there are too many things about posts

For today just focuse oncustom post type

Arguments are too complex

Just use Types or Pods pluginThats all problem solved

Yeah

of course you might not want this I was just kidding

Custom Post

You want to manage your own contentsThats why custom post is

Music collections Online store Event calendar Book data Photo portfolio

Custom Post Motivation

Well with just one type post and you may define many categories and use them to organize all contents

JUST ONE TYPE POSTMANY CATEGORIES

portfolio calendar music db

Custom Post Motivation

But you might feel that some post types should be hidden from some users even might be excluded from search may be only for private use may have very complex taxonomies

so that it should have its own territory

can be accessible from their own URL rules

Custom Post Motivation

Why re-invent wheel again

By extending built-in post type systemyou can REUSE whole facilities related to posts easily

UI and all thing about managing

Built-in Custom Post Types

wp-includespostphp (included in wp-settingsphp)function create_initial_post_types()

register_post_type( post array( register_post_type( page array( register_post_type( attachment array( register_post_type( revision array( register_post_type( nav_menu_item array( register_post_status( publish array(

register_post_type

ltphp register_post_type( $post_type $args ) gt

$arg is very complex

But I think it should be explained in detail Actually you cannot avoid it because eventuall all post type plugins will use that function too

Those plugins also have diffcult UIs too

register_post_type

Lets take a look how Types and Pods create their custom posts

They have easy (really) UI and provide better functionaliy but you can see horribly many options there

register_post_type $post_type

Up to 20 characters Only lowercase and numbers

register_post_type $args

publicvisible to authors

true impliesexclude_from_search falsepublicly_queryable show_in_nav_manues show_ui

false impliesexclude_from_search true publicly_queryable falseshow_in_nav_manues false show_ui false

register_post_type $args

labelplural descriptive name

egMusic CollectionsMostly localized text

register_post_type $args

labels more specific text labelsnamesigular_namemenu_namename_admin_barall_itemsadd_newadd_new_itemedit_itemview_itemsearch_items

search_itemsnot_foundnot_found in trashparent_item_colon

register_post_type $args

descriptionsummary of this post type

register_post_type $args

exclude_from_searchdo not search this post typetry S=beatbles

register_post_type $args

publicly_queryablecan use query

eg) post_type=music_collection

register_post_type $args

show_uidisplay default UI

register_post_type $args

show_in_nav_menusshow in navigation menus

be careful publicly_queryablemust be true

register_post_type $args

show_in_menushow admin_menu show_ui must be trueJust showing menutrue false else some strings

(toolsphp editphp)

altough it is falseyou can access URLS likewp-admineditphppost_type=music_collection(show_ui must be true)

register_post_type $args

show_in_admin_baravailable in admin bar

menu_postiondefault below comments

menu_iconsee dashicons

register_post_type $args

capability_typestring or array to build capabilites

in our exampeedit_music_collectionsedit_others_music_collections

publish_music_collectionsread_private_music_collections

register_post_type $args

capabilitiesto give specific names to each capability

map_meta_capif true default meta capability will be added

and then your role or account need capabilities

register_post_type $args

hierarchicalpost type can be hierarchicalthis is for page-styles

register_post_type $args

query_varto query posts query_var=slug

rewriteto use pretty permalinks

has_archiveEnables post type archive

register_post_type $args

permalink_epmaskrewrite endpoint bitmask

can_exporttrue makes the post can be exported

Too exhaustive but worth it

Practice Custom Post

Create custom-plugin-ltauthorgtphpCreate a simple custom post

Display admin menuHide admin_barWrite your post Any content is OK Include at least one meta field

Next Week

Customizing Visual Components List Table Screen Widgets

WordPress System Undercover Constants and Globals WPDB

  • WordPress Plugin 3
  • Recap
  • Recap (2)
  • Recap (3)
  • Recap (4)
  • Recap (5)
  • Todays Topics
  • Entry Points in Plugin
  • Entry Points
  • Entry Points (2)
  • Entry Points (3)
  • Entry Points (4)
  • Menu Items
  • Where is default menu
  • Where is default menu (2)
  • Our custom menus
  • add_menu_page
  • add_submenu_page
  • derivatives
  • Shortcodes
  • Shortcodes (2)
  • Shortcodes (3)
  • Shortcodes (4)
  • Shortcodes (5)
  • Shortcodes (6)
  • Admin-post
  • Admin-post (2)
  • Admin-post (3)
  • AJAX
  • Redirect
  • Redirect (2)
  • (de)activation uninstall
  • Summary
  • I know you want to do something
  • Slide 35
  • Source code explained
  • 10 minutes break
  • Managing Your Own Contents
  • Wow there are too many things about posts
  • For today just focuse on custom post type
  • Arguments are too complex
  • of course you might not want this I was just kidding
  • Custom Post
  • Custom Post Motivation
  • Custom Post Motivation (2)
  • Custom Post Motivation (3)
  • Built-in Custom Post Types
  • register_post_type
  • register_post_type (2)
  • register_post_type $post_type
  • register_post_type $args
  • register_post_type $args (2)
  • register_post_type $args (3)
  • register_post_type $args (4)
  • register_post_type $args (5)
  • register_post_type $args (6)
  • register_post_type $args (7)
  • register_post_type $args (8)
  • register_post_type $args (9)
  • register_post_type $args (10)
  • register_post_type $args (11)
  • register_post_type $args (12)
  • register_post_type $args (13)
  • register_post_type $args (14)
  • register_post_type $args (15)
  • Too exhaustive but worth it
  • Practice Custom Post
  • Next Week
Page 31: WordPress plugin #3

Redirect

You can generate web pages on-the-fly by utilizing these 3 hooks rewrite rule query parsing redirect

Detailed instructions later

(de)activation uninstall

register_activation_hook($file $cb)register_deactivation_hook($file $cb)register_uninstall_hook($file $cb)

$file full path of plugin file$cb callback function

callbacks should be SILENT No echo please

Summary

menu items shortcodes admin post ajax template redirects and (de)activation- uninstall hooks are good initial entry pointso It is a good strategy to find these

hooks in plugins first and dissect their codes from those points

I know you want to do something

You understand hook conceptYou know database detail

Now you know entry points

Definitely you wanna make something

Visit http[ip]practice and download entry-pointsphp

소스코드 http[ip]source-codes1 어드민 화면에 메뉴 추가2 쇼트코드 추가3 메뉴에서 admin post 전송4 메뉴에서 ajax 전송5redirect 테스트

ltauthorgt 부분은 자신의 이름으로 일괄변경하고 적절히 콜백 함수를 정의해 주세요

Source code explained

10 minutes break

Managing Your Own Contents

Wow there are too many things about posts

For today just focuse oncustom post type

Arguments are too complex

Just use Types or Pods pluginThats all problem solved

Yeah

of course you might not want this I was just kidding

Custom Post

You want to manage your own contentsThats why custom post is

Music collections Online store Event calendar Book data Photo portfolio

Custom Post Motivation

Well with just one type post and you may define many categories and use them to organize all contents

JUST ONE TYPE POSTMANY CATEGORIES

portfolio calendar music db

Custom Post Motivation

But you might feel that some post types should be hidden from some users even might be excluded from search may be only for private use may have very complex taxonomies

so that it should have its own territory

can be accessible from their own URL rules

Custom Post Motivation

Why re-invent wheel again

By extending built-in post type systemyou can REUSE whole facilities related to posts easily

UI and all thing about managing

Built-in Custom Post Types

wp-includespostphp (included in wp-settingsphp)function create_initial_post_types()

register_post_type( post array( register_post_type( page array( register_post_type( attachment array( register_post_type( revision array( register_post_type( nav_menu_item array( register_post_status( publish array(

register_post_type

ltphp register_post_type( $post_type $args ) gt

$arg is very complex

But I think it should be explained in detail Actually you cannot avoid it because eventuall all post type plugins will use that function too

Those plugins also have diffcult UIs too

register_post_type

Lets take a look how Types and Pods create their custom posts

They have easy (really) UI and provide better functionaliy but you can see horribly many options there

register_post_type $post_type

Up to 20 characters Only lowercase and numbers

register_post_type $args

publicvisible to authors

true impliesexclude_from_search falsepublicly_queryable show_in_nav_manues show_ui

false impliesexclude_from_search true publicly_queryable falseshow_in_nav_manues false show_ui false

register_post_type $args

labelplural descriptive name

egMusic CollectionsMostly localized text

register_post_type $args

labels more specific text labelsnamesigular_namemenu_namename_admin_barall_itemsadd_newadd_new_itemedit_itemview_itemsearch_items

search_itemsnot_foundnot_found in trashparent_item_colon

register_post_type $args

descriptionsummary of this post type

register_post_type $args

exclude_from_searchdo not search this post typetry S=beatbles

register_post_type $args

publicly_queryablecan use query

eg) post_type=music_collection

register_post_type $args

show_uidisplay default UI

register_post_type $args

show_in_nav_menusshow in navigation menus

be careful publicly_queryablemust be true

register_post_type $args

show_in_menushow admin_menu show_ui must be trueJust showing menutrue false else some strings

(toolsphp editphp)

altough it is falseyou can access URLS likewp-admineditphppost_type=music_collection(show_ui must be true)

register_post_type $args

show_in_admin_baravailable in admin bar

menu_postiondefault below comments

menu_iconsee dashicons

register_post_type $args

capability_typestring or array to build capabilites

in our exampeedit_music_collectionsedit_others_music_collections

publish_music_collectionsread_private_music_collections

register_post_type $args

capabilitiesto give specific names to each capability

map_meta_capif true default meta capability will be added

and then your role or account need capabilities

register_post_type $args

hierarchicalpost type can be hierarchicalthis is for page-styles

register_post_type $args

query_varto query posts query_var=slug

rewriteto use pretty permalinks

has_archiveEnables post type archive

register_post_type $args

permalink_epmaskrewrite endpoint bitmask

can_exporttrue makes the post can be exported

Too exhaustive but worth it

Practice Custom Post

Create custom-plugin-ltauthorgtphpCreate a simple custom post

Display admin menuHide admin_barWrite your post Any content is OK Include at least one meta field

Next Week

Customizing Visual Components List Table Screen Widgets

WordPress System Undercover Constants and Globals WPDB

  • WordPress Plugin 3
  • Recap
  • Recap (2)
  • Recap (3)
  • Recap (4)
  • Recap (5)
  • Todays Topics
  • Entry Points in Plugin
  • Entry Points
  • Entry Points (2)
  • Entry Points (3)
  • Entry Points (4)
  • Menu Items
  • Where is default menu
  • Where is default menu (2)
  • Our custom menus
  • add_menu_page
  • add_submenu_page
  • derivatives
  • Shortcodes
  • Shortcodes (2)
  • Shortcodes (3)
  • Shortcodes (4)
  • Shortcodes (5)
  • Shortcodes (6)
  • Admin-post
  • Admin-post (2)
  • Admin-post (3)
  • AJAX
  • Redirect
  • Redirect (2)
  • (de)activation uninstall
  • Summary
  • I know you want to do something
  • Slide 35
  • Source code explained
  • 10 minutes break
  • Managing Your Own Contents
  • Wow there are too many things about posts
  • For today just focuse on custom post type
  • Arguments are too complex
  • of course you might not want this I was just kidding
  • Custom Post
  • Custom Post Motivation
  • Custom Post Motivation (2)
  • Custom Post Motivation (3)
  • Built-in Custom Post Types
  • register_post_type
  • register_post_type (2)
  • register_post_type $post_type
  • register_post_type $args
  • register_post_type $args (2)
  • register_post_type $args (3)
  • register_post_type $args (4)
  • register_post_type $args (5)
  • register_post_type $args (6)
  • register_post_type $args (7)
  • register_post_type $args (8)
  • register_post_type $args (9)
  • register_post_type $args (10)
  • register_post_type $args (11)
  • register_post_type $args (12)
  • register_post_type $args (13)
  • register_post_type $args (14)
  • register_post_type $args (15)
  • Too exhaustive but worth it
  • Practice Custom Post
  • Next Week
Page 32: WordPress plugin #3

(de)activation uninstall

register_activation_hook($file $cb)register_deactivation_hook($file $cb)register_uninstall_hook($file $cb)

$file full path of plugin file$cb callback function

callbacks should be SILENT No echo please

Summary

menu items shortcodes admin post ajax template redirects and (de)activation- uninstall hooks are good initial entry pointso It is a good strategy to find these

hooks in plugins first and dissect their codes from those points

I know you want to do something

You understand hook conceptYou know database detail

Now you know entry points

Definitely you wanna make something

Visit http[ip]practice and download entry-pointsphp

소스코드 http[ip]source-codes1 어드민 화면에 메뉴 추가2 쇼트코드 추가3 메뉴에서 admin post 전송4 메뉴에서 ajax 전송5redirect 테스트

ltauthorgt 부분은 자신의 이름으로 일괄변경하고 적절히 콜백 함수를 정의해 주세요

Source code explained

10 minutes break

Managing Your Own Contents

Wow there are too many things about posts

For today just focuse oncustom post type

Arguments are too complex

Just use Types or Pods pluginThats all problem solved

Yeah

of course you might not want this I was just kidding

Custom Post

You want to manage your own contentsThats why custom post is

Music collections Online store Event calendar Book data Photo portfolio

Custom Post Motivation

Well with just one type post and you may define many categories and use them to organize all contents

JUST ONE TYPE POSTMANY CATEGORIES

portfolio calendar music db

Custom Post Motivation

But you might feel that some post types should be hidden from some users even might be excluded from search may be only for private use may have very complex taxonomies

so that it should have its own territory

can be accessible from their own URL rules

Custom Post Motivation

Why re-invent wheel again

By extending built-in post type systemyou can REUSE whole facilities related to posts easily

UI and all thing about managing

Built-in Custom Post Types

wp-includespostphp (included in wp-settingsphp)function create_initial_post_types()

register_post_type( post array( register_post_type( page array( register_post_type( attachment array( register_post_type( revision array( register_post_type( nav_menu_item array( register_post_status( publish array(

register_post_type

ltphp register_post_type( $post_type $args ) gt

$arg is very complex

But I think it should be explained in detail Actually you cannot avoid it because eventuall all post type plugins will use that function too

Those plugins also have diffcult UIs too

register_post_type

Lets take a look how Types and Pods create their custom posts

They have easy (really) UI and provide better functionaliy but you can see horribly many options there

register_post_type $post_type

Up to 20 characters Only lowercase and numbers

register_post_type $args

publicvisible to authors

true impliesexclude_from_search falsepublicly_queryable show_in_nav_manues show_ui

false impliesexclude_from_search true publicly_queryable falseshow_in_nav_manues false show_ui false

register_post_type $args

labelplural descriptive name

egMusic CollectionsMostly localized text

register_post_type $args

labels more specific text labelsnamesigular_namemenu_namename_admin_barall_itemsadd_newadd_new_itemedit_itemview_itemsearch_items

search_itemsnot_foundnot_found in trashparent_item_colon

register_post_type $args

descriptionsummary of this post type

register_post_type $args

exclude_from_searchdo not search this post typetry S=beatbles

register_post_type $args

publicly_queryablecan use query

eg) post_type=music_collection

register_post_type $args

show_uidisplay default UI

register_post_type $args

show_in_nav_menusshow in navigation menus

be careful publicly_queryablemust be true

register_post_type $args

show_in_menushow admin_menu show_ui must be trueJust showing menutrue false else some strings

(toolsphp editphp)

altough it is falseyou can access URLS likewp-admineditphppost_type=music_collection(show_ui must be true)

register_post_type $args

show_in_admin_baravailable in admin bar

menu_postiondefault below comments

menu_iconsee dashicons

register_post_type $args

capability_typestring or array to build capabilites

in our exampeedit_music_collectionsedit_others_music_collections

publish_music_collectionsread_private_music_collections

register_post_type $args

capabilitiesto give specific names to each capability

map_meta_capif true default meta capability will be added

and then your role or account need capabilities

register_post_type $args

hierarchicalpost type can be hierarchicalthis is for page-styles

register_post_type $args

query_varto query posts query_var=slug

rewriteto use pretty permalinks

has_archiveEnables post type archive

register_post_type $args

permalink_epmaskrewrite endpoint bitmask

can_exporttrue makes the post can be exported

Too exhaustive but worth it

Practice Custom Post

Create custom-plugin-ltauthorgtphpCreate a simple custom post

Display admin menuHide admin_barWrite your post Any content is OK Include at least one meta field

Next Week

Customizing Visual Components List Table Screen Widgets

WordPress System Undercover Constants and Globals WPDB

  • WordPress Plugin 3
  • Recap
  • Recap (2)
  • Recap (3)
  • Recap (4)
  • Recap (5)
  • Todays Topics
  • Entry Points in Plugin
  • Entry Points
  • Entry Points (2)
  • Entry Points (3)
  • Entry Points (4)
  • Menu Items
  • Where is default menu
  • Where is default menu (2)
  • Our custom menus
  • add_menu_page
  • add_submenu_page
  • derivatives
  • Shortcodes
  • Shortcodes (2)
  • Shortcodes (3)
  • Shortcodes (4)
  • Shortcodes (5)
  • Shortcodes (6)
  • Admin-post
  • Admin-post (2)
  • Admin-post (3)
  • AJAX
  • Redirect
  • Redirect (2)
  • (de)activation uninstall
  • Summary
  • I know you want to do something
  • Slide 35
  • Source code explained
  • 10 minutes break
  • Managing Your Own Contents
  • Wow there are too many things about posts
  • For today just focuse on custom post type
  • Arguments are too complex
  • of course you might not want this I was just kidding
  • Custom Post
  • Custom Post Motivation
  • Custom Post Motivation (2)
  • Custom Post Motivation (3)
  • Built-in Custom Post Types
  • register_post_type
  • register_post_type (2)
  • register_post_type $post_type
  • register_post_type $args
  • register_post_type $args (2)
  • register_post_type $args (3)
  • register_post_type $args (4)
  • register_post_type $args (5)
  • register_post_type $args (6)
  • register_post_type $args (7)
  • register_post_type $args (8)
  • register_post_type $args (9)
  • register_post_type $args (10)
  • register_post_type $args (11)
  • register_post_type $args (12)
  • register_post_type $args (13)
  • register_post_type $args (14)
  • register_post_type $args (15)
  • Too exhaustive but worth it
  • Practice Custom Post
  • Next Week
Page 33: WordPress plugin #3

Summary

menu items shortcodes admin post ajax template redirects and (de)activation- uninstall hooks are good initial entry pointso It is a good strategy to find these

hooks in plugins first and dissect their codes from those points

I know you want to do something

You understand hook conceptYou know database detail

Now you know entry points

Definitely you wanna make something

Visit http[ip]practice and download entry-pointsphp

소스코드 http[ip]source-codes1 어드민 화면에 메뉴 추가2 쇼트코드 추가3 메뉴에서 admin post 전송4 메뉴에서 ajax 전송5redirect 테스트

ltauthorgt 부분은 자신의 이름으로 일괄변경하고 적절히 콜백 함수를 정의해 주세요

Source code explained

10 minutes break

Managing Your Own Contents

Wow there are too many things about posts

For today just focuse oncustom post type

Arguments are too complex

Just use Types or Pods pluginThats all problem solved

Yeah

of course you might not want this I was just kidding

Custom Post

You want to manage your own contentsThats why custom post is

Music collections Online store Event calendar Book data Photo portfolio

Custom Post Motivation

Well with just one type post and you may define many categories and use them to organize all contents

JUST ONE TYPE POSTMANY CATEGORIES

portfolio calendar music db

Custom Post Motivation

But you might feel that some post types should be hidden from some users even might be excluded from search may be only for private use may have very complex taxonomies

so that it should have its own territory

can be accessible from their own URL rules

Custom Post Motivation

Why re-invent wheel again

By extending built-in post type systemyou can REUSE whole facilities related to posts easily

UI and all thing about managing

Built-in Custom Post Types

wp-includespostphp (included in wp-settingsphp)function create_initial_post_types()

register_post_type( post array( register_post_type( page array( register_post_type( attachment array( register_post_type( revision array( register_post_type( nav_menu_item array( register_post_status( publish array(

register_post_type

ltphp register_post_type( $post_type $args ) gt

$arg is very complex

But I think it should be explained in detail Actually you cannot avoid it because eventuall all post type plugins will use that function too

Those plugins also have diffcult UIs too

register_post_type

Lets take a look how Types and Pods create their custom posts

They have easy (really) UI and provide better functionaliy but you can see horribly many options there

register_post_type $post_type

Up to 20 characters Only lowercase and numbers

register_post_type $args

publicvisible to authors

true impliesexclude_from_search falsepublicly_queryable show_in_nav_manues show_ui

false impliesexclude_from_search true publicly_queryable falseshow_in_nav_manues false show_ui false

register_post_type $args

labelplural descriptive name

egMusic CollectionsMostly localized text

register_post_type $args

labels more specific text labelsnamesigular_namemenu_namename_admin_barall_itemsadd_newadd_new_itemedit_itemview_itemsearch_items

search_itemsnot_foundnot_found in trashparent_item_colon

register_post_type $args

descriptionsummary of this post type

register_post_type $args

exclude_from_searchdo not search this post typetry S=beatbles

register_post_type $args

publicly_queryablecan use query

eg) post_type=music_collection

register_post_type $args

show_uidisplay default UI

register_post_type $args

show_in_nav_menusshow in navigation menus

be careful publicly_queryablemust be true

register_post_type $args

show_in_menushow admin_menu show_ui must be trueJust showing menutrue false else some strings

(toolsphp editphp)

altough it is falseyou can access URLS likewp-admineditphppost_type=music_collection(show_ui must be true)

register_post_type $args

show_in_admin_baravailable in admin bar

menu_postiondefault below comments

menu_iconsee dashicons

register_post_type $args

capability_typestring or array to build capabilites

in our exampeedit_music_collectionsedit_others_music_collections

publish_music_collectionsread_private_music_collections

register_post_type $args

capabilitiesto give specific names to each capability

map_meta_capif true default meta capability will be added

and then your role or account need capabilities

register_post_type $args

hierarchicalpost type can be hierarchicalthis is for page-styles

register_post_type $args

query_varto query posts query_var=slug

rewriteto use pretty permalinks

has_archiveEnables post type archive

register_post_type $args

permalink_epmaskrewrite endpoint bitmask

can_exporttrue makes the post can be exported

Too exhaustive but worth it

Practice Custom Post

Create custom-plugin-ltauthorgtphpCreate a simple custom post

Display admin menuHide admin_barWrite your post Any content is OK Include at least one meta field

Next Week

Customizing Visual Components List Table Screen Widgets

WordPress System Undercover Constants and Globals WPDB

  • WordPress Plugin 3
  • Recap
  • Recap (2)
  • Recap (3)
  • Recap (4)
  • Recap (5)
  • Todays Topics
  • Entry Points in Plugin
  • Entry Points
  • Entry Points (2)
  • Entry Points (3)
  • Entry Points (4)
  • Menu Items
  • Where is default menu
  • Where is default menu (2)
  • Our custom menus
  • add_menu_page
  • add_submenu_page
  • derivatives
  • Shortcodes
  • Shortcodes (2)
  • Shortcodes (3)
  • Shortcodes (4)
  • Shortcodes (5)
  • Shortcodes (6)
  • Admin-post
  • Admin-post (2)
  • Admin-post (3)
  • AJAX
  • Redirect
  • Redirect (2)
  • (de)activation uninstall
  • Summary
  • I know you want to do something
  • Slide 35
  • Source code explained
  • 10 minutes break
  • Managing Your Own Contents
  • Wow there are too many things about posts
  • For today just focuse on custom post type
  • Arguments are too complex
  • of course you might not want this I was just kidding
  • Custom Post
  • Custom Post Motivation
  • Custom Post Motivation (2)
  • Custom Post Motivation (3)
  • Built-in Custom Post Types
  • register_post_type
  • register_post_type (2)
  • register_post_type $post_type
  • register_post_type $args
  • register_post_type $args (2)
  • register_post_type $args (3)
  • register_post_type $args (4)
  • register_post_type $args (5)
  • register_post_type $args (6)
  • register_post_type $args (7)
  • register_post_type $args (8)
  • register_post_type $args (9)
  • register_post_type $args (10)
  • register_post_type $args (11)
  • register_post_type $args (12)
  • register_post_type $args (13)
  • register_post_type $args (14)
  • register_post_type $args (15)
  • Too exhaustive but worth it
  • Practice Custom Post
  • Next Week
Page 34: WordPress plugin #3

I know you want to do something

You understand hook conceptYou know database detail

Now you know entry points

Definitely you wanna make something

Visit http[ip]practice and download entry-pointsphp

소스코드 http[ip]source-codes1 어드민 화면에 메뉴 추가2 쇼트코드 추가3 메뉴에서 admin post 전송4 메뉴에서 ajax 전송5redirect 테스트

ltauthorgt 부분은 자신의 이름으로 일괄변경하고 적절히 콜백 함수를 정의해 주세요

Source code explained

10 minutes break

Managing Your Own Contents

Wow there are too many things about posts

For today just focuse oncustom post type

Arguments are too complex

Just use Types or Pods pluginThats all problem solved

Yeah

of course you might not want this I was just kidding

Custom Post

You want to manage your own contentsThats why custom post is

Music collections Online store Event calendar Book data Photo portfolio

Custom Post Motivation

Well with just one type post and you may define many categories and use them to organize all contents

JUST ONE TYPE POSTMANY CATEGORIES

portfolio calendar music db

Custom Post Motivation

But you might feel that some post types should be hidden from some users even might be excluded from search may be only for private use may have very complex taxonomies

so that it should have its own territory

can be accessible from their own URL rules

Custom Post Motivation

Why re-invent wheel again

By extending built-in post type systemyou can REUSE whole facilities related to posts easily

UI and all thing about managing

Built-in Custom Post Types

wp-includespostphp (included in wp-settingsphp)function create_initial_post_types()

register_post_type( post array( register_post_type( page array( register_post_type( attachment array( register_post_type( revision array( register_post_type( nav_menu_item array( register_post_status( publish array(

register_post_type

ltphp register_post_type( $post_type $args ) gt

$arg is very complex

But I think it should be explained in detail Actually you cannot avoid it because eventuall all post type plugins will use that function too

Those plugins also have diffcult UIs too

register_post_type

Lets take a look how Types and Pods create their custom posts

They have easy (really) UI and provide better functionaliy but you can see horribly many options there

register_post_type $post_type

Up to 20 characters Only lowercase and numbers

register_post_type $args

publicvisible to authors

true impliesexclude_from_search falsepublicly_queryable show_in_nav_manues show_ui

false impliesexclude_from_search true publicly_queryable falseshow_in_nav_manues false show_ui false

register_post_type $args

labelplural descriptive name

egMusic CollectionsMostly localized text

register_post_type $args

labels more specific text labelsnamesigular_namemenu_namename_admin_barall_itemsadd_newadd_new_itemedit_itemview_itemsearch_items

search_itemsnot_foundnot_found in trashparent_item_colon

register_post_type $args

descriptionsummary of this post type

register_post_type $args

exclude_from_searchdo not search this post typetry S=beatbles

register_post_type $args

publicly_queryablecan use query

eg) post_type=music_collection

register_post_type $args

show_uidisplay default UI

register_post_type $args

show_in_nav_menusshow in navigation menus

be careful publicly_queryablemust be true

register_post_type $args

show_in_menushow admin_menu show_ui must be trueJust showing menutrue false else some strings

(toolsphp editphp)

altough it is falseyou can access URLS likewp-admineditphppost_type=music_collection(show_ui must be true)

register_post_type $args

show_in_admin_baravailable in admin bar

menu_postiondefault below comments

menu_iconsee dashicons

register_post_type $args

capability_typestring or array to build capabilites

in our exampeedit_music_collectionsedit_others_music_collections

publish_music_collectionsread_private_music_collections

register_post_type $args

capabilitiesto give specific names to each capability

map_meta_capif true default meta capability will be added

and then your role or account need capabilities

register_post_type $args

hierarchicalpost type can be hierarchicalthis is for page-styles

register_post_type $args

query_varto query posts query_var=slug

rewriteto use pretty permalinks

has_archiveEnables post type archive

register_post_type $args

permalink_epmaskrewrite endpoint bitmask

can_exporttrue makes the post can be exported

Too exhaustive but worth it

Practice Custom Post

Create custom-plugin-ltauthorgtphpCreate a simple custom post

Display admin menuHide admin_barWrite your post Any content is OK Include at least one meta field

Next Week

Customizing Visual Components List Table Screen Widgets

WordPress System Undercover Constants and Globals WPDB

  • WordPress Plugin 3
  • Recap
  • Recap (2)
  • Recap (3)
  • Recap (4)
  • Recap (5)
  • Todays Topics
  • Entry Points in Plugin
  • Entry Points
  • Entry Points (2)
  • Entry Points (3)
  • Entry Points (4)
  • Menu Items
  • Where is default menu
  • Where is default menu (2)
  • Our custom menus
  • add_menu_page
  • add_submenu_page
  • derivatives
  • Shortcodes
  • Shortcodes (2)
  • Shortcodes (3)
  • Shortcodes (4)
  • Shortcodes (5)
  • Shortcodes (6)
  • Admin-post
  • Admin-post (2)
  • Admin-post (3)
  • AJAX
  • Redirect
  • Redirect (2)
  • (de)activation uninstall
  • Summary
  • I know you want to do something
  • Slide 35
  • Source code explained
  • 10 minutes break
  • Managing Your Own Contents
  • Wow there are too many things about posts
  • For today just focuse on custom post type
  • Arguments are too complex
  • of course you might not want this I was just kidding
  • Custom Post
  • Custom Post Motivation
  • Custom Post Motivation (2)
  • Custom Post Motivation (3)
  • Built-in Custom Post Types
  • register_post_type
  • register_post_type (2)
  • register_post_type $post_type
  • register_post_type $args
  • register_post_type $args (2)
  • register_post_type $args (3)
  • register_post_type $args (4)
  • register_post_type $args (5)
  • register_post_type $args (6)
  • register_post_type $args (7)
  • register_post_type $args (8)
  • register_post_type $args (9)
  • register_post_type $args (10)
  • register_post_type $args (11)
  • register_post_type $args (12)
  • register_post_type $args (13)
  • register_post_type $args (14)
  • register_post_type $args (15)
  • Too exhaustive but worth it
  • Practice Custom Post
  • Next Week
Page 35: WordPress plugin #3

Visit http[ip]practice and download entry-pointsphp

소스코드 http[ip]source-codes1 어드민 화면에 메뉴 추가2 쇼트코드 추가3 메뉴에서 admin post 전송4 메뉴에서 ajax 전송5redirect 테스트

ltauthorgt 부분은 자신의 이름으로 일괄변경하고 적절히 콜백 함수를 정의해 주세요

Source code explained

10 minutes break

Managing Your Own Contents

Wow there are too many things about posts

For today just focuse oncustom post type

Arguments are too complex

Just use Types or Pods pluginThats all problem solved

Yeah

of course you might not want this I was just kidding

Custom Post

You want to manage your own contentsThats why custom post is

Music collections Online store Event calendar Book data Photo portfolio

Custom Post Motivation

Well with just one type post and you may define many categories and use them to organize all contents

JUST ONE TYPE POSTMANY CATEGORIES

portfolio calendar music db

Custom Post Motivation

But you might feel that some post types should be hidden from some users even might be excluded from search may be only for private use may have very complex taxonomies

so that it should have its own territory

can be accessible from their own URL rules

Custom Post Motivation

Why re-invent wheel again

By extending built-in post type systemyou can REUSE whole facilities related to posts easily

UI and all thing about managing

Built-in Custom Post Types

wp-includespostphp (included in wp-settingsphp)function create_initial_post_types()

register_post_type( post array( register_post_type( page array( register_post_type( attachment array( register_post_type( revision array( register_post_type( nav_menu_item array( register_post_status( publish array(

register_post_type

ltphp register_post_type( $post_type $args ) gt

$arg is very complex

But I think it should be explained in detail Actually you cannot avoid it because eventuall all post type plugins will use that function too

Those plugins also have diffcult UIs too

register_post_type

Lets take a look how Types and Pods create their custom posts

They have easy (really) UI and provide better functionaliy but you can see horribly many options there

register_post_type $post_type

Up to 20 characters Only lowercase and numbers

register_post_type $args

publicvisible to authors

true impliesexclude_from_search falsepublicly_queryable show_in_nav_manues show_ui

false impliesexclude_from_search true publicly_queryable falseshow_in_nav_manues false show_ui false

register_post_type $args

labelplural descriptive name

egMusic CollectionsMostly localized text

register_post_type $args

labels more specific text labelsnamesigular_namemenu_namename_admin_barall_itemsadd_newadd_new_itemedit_itemview_itemsearch_items

search_itemsnot_foundnot_found in trashparent_item_colon

register_post_type $args

descriptionsummary of this post type

register_post_type $args

exclude_from_searchdo not search this post typetry S=beatbles

register_post_type $args

publicly_queryablecan use query

eg) post_type=music_collection

register_post_type $args

show_uidisplay default UI

register_post_type $args

show_in_nav_menusshow in navigation menus

be careful publicly_queryablemust be true

register_post_type $args

show_in_menushow admin_menu show_ui must be trueJust showing menutrue false else some strings

(toolsphp editphp)

altough it is falseyou can access URLS likewp-admineditphppost_type=music_collection(show_ui must be true)

register_post_type $args

show_in_admin_baravailable in admin bar

menu_postiondefault below comments

menu_iconsee dashicons

register_post_type $args

capability_typestring or array to build capabilites

in our exampeedit_music_collectionsedit_others_music_collections

publish_music_collectionsread_private_music_collections

register_post_type $args

capabilitiesto give specific names to each capability

map_meta_capif true default meta capability will be added

and then your role or account need capabilities

register_post_type $args

hierarchicalpost type can be hierarchicalthis is for page-styles

register_post_type $args

query_varto query posts query_var=slug

rewriteto use pretty permalinks

has_archiveEnables post type archive

register_post_type $args

permalink_epmaskrewrite endpoint bitmask

can_exporttrue makes the post can be exported

Too exhaustive but worth it

Practice Custom Post

Create custom-plugin-ltauthorgtphpCreate a simple custom post

Display admin menuHide admin_barWrite your post Any content is OK Include at least one meta field

Next Week

Customizing Visual Components List Table Screen Widgets

WordPress System Undercover Constants and Globals WPDB

  • WordPress Plugin 3
  • Recap
  • Recap (2)
  • Recap (3)
  • Recap (4)
  • Recap (5)
  • Todays Topics
  • Entry Points in Plugin
  • Entry Points
  • Entry Points (2)
  • Entry Points (3)
  • Entry Points (4)
  • Menu Items
  • Where is default menu
  • Where is default menu (2)
  • Our custom menus
  • add_menu_page
  • add_submenu_page
  • derivatives
  • Shortcodes
  • Shortcodes (2)
  • Shortcodes (3)
  • Shortcodes (4)
  • Shortcodes (5)
  • Shortcodes (6)
  • Admin-post
  • Admin-post (2)
  • Admin-post (3)
  • AJAX
  • Redirect
  • Redirect (2)
  • (de)activation uninstall
  • Summary
  • I know you want to do something
  • Slide 35
  • Source code explained
  • 10 minutes break
  • Managing Your Own Contents
  • Wow there are too many things about posts
  • For today just focuse on custom post type
  • Arguments are too complex
  • of course you might not want this I was just kidding
  • Custom Post
  • Custom Post Motivation
  • Custom Post Motivation (2)
  • Custom Post Motivation (3)
  • Built-in Custom Post Types
  • register_post_type
  • register_post_type (2)
  • register_post_type $post_type
  • register_post_type $args
  • register_post_type $args (2)
  • register_post_type $args (3)
  • register_post_type $args (4)
  • register_post_type $args (5)
  • register_post_type $args (6)
  • register_post_type $args (7)
  • register_post_type $args (8)
  • register_post_type $args (9)
  • register_post_type $args (10)
  • register_post_type $args (11)
  • register_post_type $args (12)
  • register_post_type $args (13)
  • register_post_type $args (14)
  • register_post_type $args (15)
  • Too exhaustive but worth it
  • Practice Custom Post
  • Next Week
Page 36: WordPress plugin #3

소스코드 http[ip]source-codes1 어드민 화면에 메뉴 추가2 쇼트코드 추가3 메뉴에서 admin post 전송4 메뉴에서 ajax 전송5redirect 테스트

ltauthorgt 부분은 자신의 이름으로 일괄변경하고 적절히 콜백 함수를 정의해 주세요

Source code explained

10 minutes break

Managing Your Own Contents

Wow there are too many things about posts

For today just focuse oncustom post type

Arguments are too complex

Just use Types or Pods pluginThats all problem solved

Yeah

of course you might not want this I was just kidding

Custom Post

You want to manage your own contentsThats why custom post is

Music collections Online store Event calendar Book data Photo portfolio

Custom Post Motivation

Well with just one type post and you may define many categories and use them to organize all contents

JUST ONE TYPE POSTMANY CATEGORIES

portfolio calendar music db

Custom Post Motivation

But you might feel that some post types should be hidden from some users even might be excluded from search may be only for private use may have very complex taxonomies

so that it should have its own territory

can be accessible from their own URL rules

Custom Post Motivation

Why re-invent wheel again

By extending built-in post type systemyou can REUSE whole facilities related to posts easily

UI and all thing about managing

Built-in Custom Post Types

wp-includespostphp (included in wp-settingsphp)function create_initial_post_types()

register_post_type( post array( register_post_type( page array( register_post_type( attachment array( register_post_type( revision array( register_post_type( nav_menu_item array( register_post_status( publish array(

register_post_type

ltphp register_post_type( $post_type $args ) gt

$arg is very complex

But I think it should be explained in detail Actually you cannot avoid it because eventuall all post type plugins will use that function too

Those plugins also have diffcult UIs too

register_post_type

Lets take a look how Types and Pods create their custom posts

They have easy (really) UI and provide better functionaliy but you can see horribly many options there

register_post_type $post_type

Up to 20 characters Only lowercase and numbers

register_post_type $args

publicvisible to authors

true impliesexclude_from_search falsepublicly_queryable show_in_nav_manues show_ui

false impliesexclude_from_search true publicly_queryable falseshow_in_nav_manues false show_ui false

register_post_type $args

labelplural descriptive name

egMusic CollectionsMostly localized text

register_post_type $args

labels more specific text labelsnamesigular_namemenu_namename_admin_barall_itemsadd_newadd_new_itemedit_itemview_itemsearch_items

search_itemsnot_foundnot_found in trashparent_item_colon

register_post_type $args

descriptionsummary of this post type

register_post_type $args

exclude_from_searchdo not search this post typetry S=beatbles

register_post_type $args

publicly_queryablecan use query

eg) post_type=music_collection

register_post_type $args

show_uidisplay default UI

register_post_type $args

show_in_nav_menusshow in navigation menus

be careful publicly_queryablemust be true

register_post_type $args

show_in_menushow admin_menu show_ui must be trueJust showing menutrue false else some strings

(toolsphp editphp)

altough it is falseyou can access URLS likewp-admineditphppost_type=music_collection(show_ui must be true)

register_post_type $args

show_in_admin_baravailable in admin bar

menu_postiondefault below comments

menu_iconsee dashicons

register_post_type $args

capability_typestring or array to build capabilites

in our exampeedit_music_collectionsedit_others_music_collections

publish_music_collectionsread_private_music_collections

register_post_type $args

capabilitiesto give specific names to each capability

map_meta_capif true default meta capability will be added

and then your role or account need capabilities

register_post_type $args

hierarchicalpost type can be hierarchicalthis is for page-styles

register_post_type $args

query_varto query posts query_var=slug

rewriteto use pretty permalinks

has_archiveEnables post type archive

register_post_type $args

permalink_epmaskrewrite endpoint bitmask

can_exporttrue makes the post can be exported

Too exhaustive but worth it

Practice Custom Post

Create custom-plugin-ltauthorgtphpCreate a simple custom post

Display admin menuHide admin_barWrite your post Any content is OK Include at least one meta field

Next Week

Customizing Visual Components List Table Screen Widgets

WordPress System Undercover Constants and Globals WPDB

  • WordPress Plugin 3
  • Recap
  • Recap (2)
  • Recap (3)
  • Recap (4)
  • Recap (5)
  • Todays Topics
  • Entry Points in Plugin
  • Entry Points
  • Entry Points (2)
  • Entry Points (3)
  • Entry Points (4)
  • Menu Items
  • Where is default menu
  • Where is default menu (2)
  • Our custom menus
  • add_menu_page
  • add_submenu_page
  • derivatives
  • Shortcodes
  • Shortcodes (2)
  • Shortcodes (3)
  • Shortcodes (4)
  • Shortcodes (5)
  • Shortcodes (6)
  • Admin-post
  • Admin-post (2)
  • Admin-post (3)
  • AJAX
  • Redirect
  • Redirect (2)
  • (de)activation uninstall
  • Summary
  • I know you want to do something
  • Slide 35
  • Source code explained
  • 10 minutes break
  • Managing Your Own Contents
  • Wow there are too many things about posts
  • For today just focuse on custom post type
  • Arguments are too complex
  • of course you might not want this I was just kidding
  • Custom Post
  • Custom Post Motivation
  • Custom Post Motivation (2)
  • Custom Post Motivation (3)
  • Built-in Custom Post Types
  • register_post_type
  • register_post_type (2)
  • register_post_type $post_type
  • register_post_type $args
  • register_post_type $args (2)
  • register_post_type $args (3)
  • register_post_type $args (4)
  • register_post_type $args (5)
  • register_post_type $args (6)
  • register_post_type $args (7)
  • register_post_type $args (8)
  • register_post_type $args (9)
  • register_post_type $args (10)
  • register_post_type $args (11)
  • register_post_type $args (12)
  • register_post_type $args (13)
  • register_post_type $args (14)
  • register_post_type $args (15)
  • Too exhaustive but worth it
  • Practice Custom Post
  • Next Week
Page 37: WordPress plugin #3

10 minutes break

Managing Your Own Contents

Wow there are too many things about posts

For today just focuse oncustom post type

Arguments are too complex

Just use Types or Pods pluginThats all problem solved

Yeah

of course you might not want this I was just kidding

Custom Post

You want to manage your own contentsThats why custom post is

Music collections Online store Event calendar Book data Photo portfolio

Custom Post Motivation

Well with just one type post and you may define many categories and use them to organize all contents

JUST ONE TYPE POSTMANY CATEGORIES

portfolio calendar music db

Custom Post Motivation

But you might feel that some post types should be hidden from some users even might be excluded from search may be only for private use may have very complex taxonomies

so that it should have its own territory

can be accessible from their own URL rules

Custom Post Motivation

Why re-invent wheel again

By extending built-in post type systemyou can REUSE whole facilities related to posts easily

UI and all thing about managing

Built-in Custom Post Types

wp-includespostphp (included in wp-settingsphp)function create_initial_post_types()

register_post_type( post array( register_post_type( page array( register_post_type( attachment array( register_post_type( revision array( register_post_type( nav_menu_item array( register_post_status( publish array(

register_post_type

ltphp register_post_type( $post_type $args ) gt

$arg is very complex

But I think it should be explained in detail Actually you cannot avoid it because eventuall all post type plugins will use that function too

Those plugins also have diffcult UIs too

register_post_type

Lets take a look how Types and Pods create their custom posts

They have easy (really) UI and provide better functionaliy but you can see horribly many options there

register_post_type $post_type

Up to 20 characters Only lowercase and numbers

register_post_type $args

publicvisible to authors

true impliesexclude_from_search falsepublicly_queryable show_in_nav_manues show_ui

false impliesexclude_from_search true publicly_queryable falseshow_in_nav_manues false show_ui false

register_post_type $args

labelplural descriptive name

egMusic CollectionsMostly localized text

register_post_type $args

labels more specific text labelsnamesigular_namemenu_namename_admin_barall_itemsadd_newadd_new_itemedit_itemview_itemsearch_items

search_itemsnot_foundnot_found in trashparent_item_colon

register_post_type $args

descriptionsummary of this post type

register_post_type $args

exclude_from_searchdo not search this post typetry S=beatbles

register_post_type $args

publicly_queryablecan use query

eg) post_type=music_collection

register_post_type $args

show_uidisplay default UI

register_post_type $args

show_in_nav_menusshow in navigation menus

be careful publicly_queryablemust be true

register_post_type $args

show_in_menushow admin_menu show_ui must be trueJust showing menutrue false else some strings

(toolsphp editphp)

altough it is falseyou can access URLS likewp-admineditphppost_type=music_collection(show_ui must be true)

register_post_type $args

show_in_admin_baravailable in admin bar

menu_postiondefault below comments

menu_iconsee dashicons

register_post_type $args

capability_typestring or array to build capabilites

in our exampeedit_music_collectionsedit_others_music_collections

publish_music_collectionsread_private_music_collections

register_post_type $args

capabilitiesto give specific names to each capability

map_meta_capif true default meta capability will be added

and then your role or account need capabilities

register_post_type $args

hierarchicalpost type can be hierarchicalthis is for page-styles

register_post_type $args

query_varto query posts query_var=slug

rewriteto use pretty permalinks

has_archiveEnables post type archive

register_post_type $args

permalink_epmaskrewrite endpoint bitmask

can_exporttrue makes the post can be exported

Too exhaustive but worth it

Practice Custom Post

Create custom-plugin-ltauthorgtphpCreate a simple custom post

Display admin menuHide admin_barWrite your post Any content is OK Include at least one meta field

Next Week

Customizing Visual Components List Table Screen Widgets

WordPress System Undercover Constants and Globals WPDB

  • WordPress Plugin 3
  • Recap
  • Recap (2)
  • Recap (3)
  • Recap (4)
  • Recap (5)
  • Todays Topics
  • Entry Points in Plugin
  • Entry Points
  • Entry Points (2)
  • Entry Points (3)
  • Entry Points (4)
  • Menu Items
  • Where is default menu
  • Where is default menu (2)
  • Our custom menus
  • add_menu_page
  • add_submenu_page
  • derivatives
  • Shortcodes
  • Shortcodes (2)
  • Shortcodes (3)
  • Shortcodes (4)
  • Shortcodes (5)
  • Shortcodes (6)
  • Admin-post
  • Admin-post (2)
  • Admin-post (3)
  • AJAX
  • Redirect
  • Redirect (2)
  • (de)activation uninstall
  • Summary
  • I know you want to do something
  • Slide 35
  • Source code explained
  • 10 minutes break
  • Managing Your Own Contents
  • Wow there are too many things about posts
  • For today just focuse on custom post type
  • Arguments are too complex
  • of course you might not want this I was just kidding
  • Custom Post
  • Custom Post Motivation
  • Custom Post Motivation (2)
  • Custom Post Motivation (3)
  • Built-in Custom Post Types
  • register_post_type
  • register_post_type (2)
  • register_post_type $post_type
  • register_post_type $args
  • register_post_type $args (2)
  • register_post_type $args (3)
  • register_post_type $args (4)
  • register_post_type $args (5)
  • register_post_type $args (6)
  • register_post_type $args (7)
  • register_post_type $args (8)
  • register_post_type $args (9)
  • register_post_type $args (10)
  • register_post_type $args (11)
  • register_post_type $args (12)
  • register_post_type $args (13)
  • register_post_type $args (14)
  • register_post_type $args (15)
  • Too exhaustive but worth it
  • Practice Custom Post
  • Next Week
Page 38: WordPress plugin #3

Managing Your Own Contents

Wow there are too many things about posts

For today just focuse oncustom post type

Arguments are too complex

Just use Types or Pods pluginThats all problem solved

Yeah

of course you might not want this I was just kidding

Custom Post

You want to manage your own contentsThats why custom post is

Music collections Online store Event calendar Book data Photo portfolio

Custom Post Motivation

Well with just one type post and you may define many categories and use them to organize all contents

JUST ONE TYPE POSTMANY CATEGORIES

portfolio calendar music db

Custom Post Motivation

But you might feel that some post types should be hidden from some users even might be excluded from search may be only for private use may have very complex taxonomies

so that it should have its own territory

can be accessible from their own URL rules

Custom Post Motivation

Why re-invent wheel again

By extending built-in post type systemyou can REUSE whole facilities related to posts easily

UI and all thing about managing

Built-in Custom Post Types

wp-includespostphp (included in wp-settingsphp)function create_initial_post_types()

register_post_type( post array( register_post_type( page array( register_post_type( attachment array( register_post_type( revision array( register_post_type( nav_menu_item array( register_post_status( publish array(

register_post_type

ltphp register_post_type( $post_type $args ) gt

$arg is very complex

But I think it should be explained in detail Actually you cannot avoid it because eventuall all post type plugins will use that function too

Those plugins also have diffcult UIs too

register_post_type

Lets take a look how Types and Pods create their custom posts

They have easy (really) UI and provide better functionaliy but you can see horribly many options there

register_post_type $post_type

Up to 20 characters Only lowercase and numbers

register_post_type $args

publicvisible to authors

true impliesexclude_from_search falsepublicly_queryable show_in_nav_manues show_ui

false impliesexclude_from_search true publicly_queryable falseshow_in_nav_manues false show_ui false

register_post_type $args

labelplural descriptive name

egMusic CollectionsMostly localized text

register_post_type $args

labels more specific text labelsnamesigular_namemenu_namename_admin_barall_itemsadd_newadd_new_itemedit_itemview_itemsearch_items

search_itemsnot_foundnot_found in trashparent_item_colon

register_post_type $args

descriptionsummary of this post type

register_post_type $args

exclude_from_searchdo not search this post typetry S=beatbles

register_post_type $args

publicly_queryablecan use query

eg) post_type=music_collection

register_post_type $args

show_uidisplay default UI

register_post_type $args

show_in_nav_menusshow in navigation menus

be careful publicly_queryablemust be true

register_post_type $args

show_in_menushow admin_menu show_ui must be trueJust showing menutrue false else some strings

(toolsphp editphp)

altough it is falseyou can access URLS likewp-admineditphppost_type=music_collection(show_ui must be true)

register_post_type $args

show_in_admin_baravailable in admin bar

menu_postiondefault below comments

menu_iconsee dashicons

register_post_type $args

capability_typestring or array to build capabilites

in our exampeedit_music_collectionsedit_others_music_collections

publish_music_collectionsread_private_music_collections

register_post_type $args

capabilitiesto give specific names to each capability

map_meta_capif true default meta capability will be added

and then your role or account need capabilities

register_post_type $args

hierarchicalpost type can be hierarchicalthis is for page-styles

register_post_type $args

query_varto query posts query_var=slug

rewriteto use pretty permalinks

has_archiveEnables post type archive

register_post_type $args

permalink_epmaskrewrite endpoint bitmask

can_exporttrue makes the post can be exported

Too exhaustive but worth it

Practice Custom Post

Create custom-plugin-ltauthorgtphpCreate a simple custom post

Display admin menuHide admin_barWrite your post Any content is OK Include at least one meta field

Next Week

Customizing Visual Components List Table Screen Widgets

WordPress System Undercover Constants and Globals WPDB

  • WordPress Plugin 3
  • Recap
  • Recap (2)
  • Recap (3)
  • Recap (4)
  • Recap (5)
  • Todays Topics
  • Entry Points in Plugin
  • Entry Points
  • Entry Points (2)
  • Entry Points (3)
  • Entry Points (4)
  • Menu Items
  • Where is default menu
  • Where is default menu (2)
  • Our custom menus
  • add_menu_page
  • add_submenu_page
  • derivatives
  • Shortcodes
  • Shortcodes (2)
  • Shortcodes (3)
  • Shortcodes (4)
  • Shortcodes (5)
  • Shortcodes (6)
  • Admin-post
  • Admin-post (2)
  • Admin-post (3)
  • AJAX
  • Redirect
  • Redirect (2)
  • (de)activation uninstall
  • Summary
  • I know you want to do something
  • Slide 35
  • Source code explained
  • 10 minutes break
  • Managing Your Own Contents
  • Wow there are too many things about posts
  • For today just focuse on custom post type
  • Arguments are too complex
  • of course you might not want this I was just kidding
  • Custom Post
  • Custom Post Motivation
  • Custom Post Motivation (2)
  • Custom Post Motivation (3)
  • Built-in Custom Post Types
  • register_post_type
  • register_post_type (2)
  • register_post_type $post_type
  • register_post_type $args
  • register_post_type $args (2)
  • register_post_type $args (3)
  • register_post_type $args (4)
  • register_post_type $args (5)
  • register_post_type $args (6)
  • register_post_type $args (7)
  • register_post_type $args (8)
  • register_post_type $args (9)
  • register_post_type $args (10)
  • register_post_type $args (11)
  • register_post_type $args (12)
  • register_post_type $args (13)
  • register_post_type $args (14)
  • register_post_type $args (15)
  • Too exhaustive but worth it
  • Practice Custom Post
  • Next Week
Page 39: WordPress plugin #3

Wow there are too many things about posts

For today just focuse oncustom post type

Arguments are too complex

Just use Types or Pods pluginThats all problem solved

Yeah

of course you might not want this I was just kidding

Custom Post

You want to manage your own contentsThats why custom post is

Music collections Online store Event calendar Book data Photo portfolio

Custom Post Motivation

Well with just one type post and you may define many categories and use them to organize all contents

JUST ONE TYPE POSTMANY CATEGORIES

portfolio calendar music db

Custom Post Motivation

But you might feel that some post types should be hidden from some users even might be excluded from search may be only for private use may have very complex taxonomies

so that it should have its own territory

can be accessible from their own URL rules

Custom Post Motivation

Why re-invent wheel again

By extending built-in post type systemyou can REUSE whole facilities related to posts easily

UI and all thing about managing

Built-in Custom Post Types

wp-includespostphp (included in wp-settingsphp)function create_initial_post_types()

register_post_type( post array( register_post_type( page array( register_post_type( attachment array( register_post_type( revision array( register_post_type( nav_menu_item array( register_post_status( publish array(

register_post_type

ltphp register_post_type( $post_type $args ) gt

$arg is very complex

But I think it should be explained in detail Actually you cannot avoid it because eventuall all post type plugins will use that function too

Those plugins also have diffcult UIs too

register_post_type

Lets take a look how Types and Pods create their custom posts

They have easy (really) UI and provide better functionaliy but you can see horribly many options there

register_post_type $post_type

Up to 20 characters Only lowercase and numbers

register_post_type $args

publicvisible to authors

true impliesexclude_from_search falsepublicly_queryable show_in_nav_manues show_ui

false impliesexclude_from_search true publicly_queryable falseshow_in_nav_manues false show_ui false

register_post_type $args

labelplural descriptive name

egMusic CollectionsMostly localized text

register_post_type $args

labels more specific text labelsnamesigular_namemenu_namename_admin_barall_itemsadd_newadd_new_itemedit_itemview_itemsearch_items

search_itemsnot_foundnot_found in trashparent_item_colon

register_post_type $args

descriptionsummary of this post type

register_post_type $args

exclude_from_searchdo not search this post typetry S=beatbles

register_post_type $args

publicly_queryablecan use query

eg) post_type=music_collection

register_post_type $args

show_uidisplay default UI

register_post_type $args

show_in_nav_menusshow in navigation menus

be careful publicly_queryablemust be true

register_post_type $args

show_in_menushow admin_menu show_ui must be trueJust showing menutrue false else some strings

(toolsphp editphp)

altough it is falseyou can access URLS likewp-admineditphppost_type=music_collection(show_ui must be true)

register_post_type $args

show_in_admin_baravailable in admin bar

menu_postiondefault below comments

menu_iconsee dashicons

register_post_type $args

capability_typestring or array to build capabilites

in our exampeedit_music_collectionsedit_others_music_collections

publish_music_collectionsread_private_music_collections

register_post_type $args

capabilitiesto give specific names to each capability

map_meta_capif true default meta capability will be added

and then your role or account need capabilities

register_post_type $args

hierarchicalpost type can be hierarchicalthis is for page-styles

register_post_type $args

query_varto query posts query_var=slug

rewriteto use pretty permalinks

has_archiveEnables post type archive

register_post_type $args

permalink_epmaskrewrite endpoint bitmask

can_exporttrue makes the post can be exported

Too exhaustive but worth it

Practice Custom Post

Create custom-plugin-ltauthorgtphpCreate a simple custom post

Display admin menuHide admin_barWrite your post Any content is OK Include at least one meta field

Next Week

Customizing Visual Components List Table Screen Widgets

WordPress System Undercover Constants and Globals WPDB

  • WordPress Plugin 3
  • Recap
  • Recap (2)
  • Recap (3)
  • Recap (4)
  • Recap (5)
  • Todays Topics
  • Entry Points in Plugin
  • Entry Points
  • Entry Points (2)
  • Entry Points (3)
  • Entry Points (4)
  • Menu Items
  • Where is default menu
  • Where is default menu (2)
  • Our custom menus
  • add_menu_page
  • add_submenu_page
  • derivatives
  • Shortcodes
  • Shortcodes (2)
  • Shortcodes (3)
  • Shortcodes (4)
  • Shortcodes (5)
  • Shortcodes (6)
  • Admin-post
  • Admin-post (2)
  • Admin-post (3)
  • AJAX
  • Redirect
  • Redirect (2)
  • (de)activation uninstall
  • Summary
  • I know you want to do something
  • Slide 35
  • Source code explained
  • 10 minutes break
  • Managing Your Own Contents
  • Wow there are too many things about posts
  • For today just focuse on custom post type
  • Arguments are too complex
  • of course you might not want this I was just kidding
  • Custom Post
  • Custom Post Motivation
  • Custom Post Motivation (2)
  • Custom Post Motivation (3)
  • Built-in Custom Post Types
  • register_post_type
  • register_post_type (2)
  • register_post_type $post_type
  • register_post_type $args
  • register_post_type $args (2)
  • register_post_type $args (3)
  • register_post_type $args (4)
  • register_post_type $args (5)
  • register_post_type $args (6)
  • register_post_type $args (7)
  • register_post_type $args (8)
  • register_post_type $args (9)
  • register_post_type $args (10)
  • register_post_type $args (11)
  • register_post_type $args (12)
  • register_post_type $args (13)
  • register_post_type $args (14)
  • register_post_type $args (15)
  • Too exhaustive but worth it
  • Practice Custom Post
  • Next Week
Page 40: WordPress plugin #3

For today just focuse oncustom post type

Arguments are too complex

Just use Types or Pods pluginThats all problem solved

Yeah

of course you might not want this I was just kidding

Custom Post

You want to manage your own contentsThats why custom post is

Music collections Online store Event calendar Book data Photo portfolio

Custom Post Motivation

Well with just one type post and you may define many categories and use them to organize all contents

JUST ONE TYPE POSTMANY CATEGORIES

portfolio calendar music db

Custom Post Motivation

But you might feel that some post types should be hidden from some users even might be excluded from search may be only for private use may have very complex taxonomies

so that it should have its own territory

can be accessible from their own URL rules

Custom Post Motivation

Why re-invent wheel again

By extending built-in post type systemyou can REUSE whole facilities related to posts easily

UI and all thing about managing

Built-in Custom Post Types

wp-includespostphp (included in wp-settingsphp)function create_initial_post_types()

register_post_type( post array( register_post_type( page array( register_post_type( attachment array( register_post_type( revision array( register_post_type( nav_menu_item array( register_post_status( publish array(

register_post_type

ltphp register_post_type( $post_type $args ) gt

$arg is very complex

But I think it should be explained in detail Actually you cannot avoid it because eventuall all post type plugins will use that function too

Those plugins also have diffcult UIs too

register_post_type

Lets take a look how Types and Pods create their custom posts

They have easy (really) UI and provide better functionaliy but you can see horribly many options there

register_post_type $post_type

Up to 20 characters Only lowercase and numbers

register_post_type $args

publicvisible to authors

true impliesexclude_from_search falsepublicly_queryable show_in_nav_manues show_ui

false impliesexclude_from_search true publicly_queryable falseshow_in_nav_manues false show_ui false

register_post_type $args

labelplural descriptive name

egMusic CollectionsMostly localized text

register_post_type $args

labels more specific text labelsnamesigular_namemenu_namename_admin_barall_itemsadd_newadd_new_itemedit_itemview_itemsearch_items

search_itemsnot_foundnot_found in trashparent_item_colon

register_post_type $args

descriptionsummary of this post type

register_post_type $args

exclude_from_searchdo not search this post typetry S=beatbles

register_post_type $args

publicly_queryablecan use query

eg) post_type=music_collection

register_post_type $args

show_uidisplay default UI

register_post_type $args

show_in_nav_menusshow in navigation menus

be careful publicly_queryablemust be true

register_post_type $args

show_in_menushow admin_menu show_ui must be trueJust showing menutrue false else some strings

(toolsphp editphp)

altough it is falseyou can access URLS likewp-admineditphppost_type=music_collection(show_ui must be true)

register_post_type $args

show_in_admin_baravailable in admin bar

menu_postiondefault below comments

menu_iconsee dashicons

register_post_type $args

capability_typestring or array to build capabilites

in our exampeedit_music_collectionsedit_others_music_collections

publish_music_collectionsread_private_music_collections

register_post_type $args

capabilitiesto give specific names to each capability

map_meta_capif true default meta capability will be added

and then your role or account need capabilities

register_post_type $args

hierarchicalpost type can be hierarchicalthis is for page-styles

register_post_type $args

query_varto query posts query_var=slug

rewriteto use pretty permalinks

has_archiveEnables post type archive

register_post_type $args

permalink_epmaskrewrite endpoint bitmask

can_exporttrue makes the post can be exported

Too exhaustive but worth it

Practice Custom Post

Create custom-plugin-ltauthorgtphpCreate a simple custom post

Display admin menuHide admin_barWrite your post Any content is OK Include at least one meta field

Next Week

Customizing Visual Components List Table Screen Widgets

WordPress System Undercover Constants and Globals WPDB

  • WordPress Plugin 3
  • Recap
  • Recap (2)
  • Recap (3)
  • Recap (4)
  • Recap (5)
  • Todays Topics
  • Entry Points in Plugin
  • Entry Points
  • Entry Points (2)
  • Entry Points (3)
  • Entry Points (4)
  • Menu Items
  • Where is default menu
  • Where is default menu (2)
  • Our custom menus
  • add_menu_page
  • add_submenu_page
  • derivatives
  • Shortcodes
  • Shortcodes (2)
  • Shortcodes (3)
  • Shortcodes (4)
  • Shortcodes (5)
  • Shortcodes (6)
  • Admin-post
  • Admin-post (2)
  • Admin-post (3)
  • AJAX
  • Redirect
  • Redirect (2)
  • (de)activation uninstall
  • Summary
  • I know you want to do something
  • Slide 35
  • Source code explained
  • 10 minutes break
  • Managing Your Own Contents
  • Wow there are too many things about posts
  • For today just focuse on custom post type
  • Arguments are too complex
  • of course you might not want this I was just kidding
  • Custom Post
  • Custom Post Motivation
  • Custom Post Motivation (2)
  • Custom Post Motivation (3)
  • Built-in Custom Post Types
  • register_post_type
  • register_post_type (2)
  • register_post_type $post_type
  • register_post_type $args
  • register_post_type $args (2)
  • register_post_type $args (3)
  • register_post_type $args (4)
  • register_post_type $args (5)
  • register_post_type $args (6)
  • register_post_type $args (7)
  • register_post_type $args (8)
  • register_post_type $args (9)
  • register_post_type $args (10)
  • register_post_type $args (11)
  • register_post_type $args (12)
  • register_post_type $args (13)
  • register_post_type $args (14)
  • register_post_type $args (15)
  • Too exhaustive but worth it
  • Practice Custom Post
  • Next Week
Page 41: WordPress plugin #3

Arguments are too complex

Just use Types or Pods pluginThats all problem solved

Yeah

of course you might not want this I was just kidding

Custom Post

You want to manage your own contentsThats why custom post is

Music collections Online store Event calendar Book data Photo portfolio

Custom Post Motivation

Well with just one type post and you may define many categories and use them to organize all contents

JUST ONE TYPE POSTMANY CATEGORIES

portfolio calendar music db

Custom Post Motivation

But you might feel that some post types should be hidden from some users even might be excluded from search may be only for private use may have very complex taxonomies

so that it should have its own territory

can be accessible from their own URL rules

Custom Post Motivation

Why re-invent wheel again

By extending built-in post type systemyou can REUSE whole facilities related to posts easily

UI and all thing about managing

Built-in Custom Post Types

wp-includespostphp (included in wp-settingsphp)function create_initial_post_types()

register_post_type( post array( register_post_type( page array( register_post_type( attachment array( register_post_type( revision array( register_post_type( nav_menu_item array( register_post_status( publish array(

register_post_type

ltphp register_post_type( $post_type $args ) gt

$arg is very complex

But I think it should be explained in detail Actually you cannot avoid it because eventuall all post type plugins will use that function too

Those plugins also have diffcult UIs too

register_post_type

Lets take a look how Types and Pods create their custom posts

They have easy (really) UI and provide better functionaliy but you can see horribly many options there

register_post_type $post_type

Up to 20 characters Only lowercase and numbers

register_post_type $args

publicvisible to authors

true impliesexclude_from_search falsepublicly_queryable show_in_nav_manues show_ui

false impliesexclude_from_search true publicly_queryable falseshow_in_nav_manues false show_ui false

register_post_type $args

labelplural descriptive name

egMusic CollectionsMostly localized text

register_post_type $args

labels more specific text labelsnamesigular_namemenu_namename_admin_barall_itemsadd_newadd_new_itemedit_itemview_itemsearch_items

search_itemsnot_foundnot_found in trashparent_item_colon

register_post_type $args

descriptionsummary of this post type

register_post_type $args

exclude_from_searchdo not search this post typetry S=beatbles

register_post_type $args

publicly_queryablecan use query

eg) post_type=music_collection

register_post_type $args

show_uidisplay default UI

register_post_type $args

show_in_nav_menusshow in navigation menus

be careful publicly_queryablemust be true

register_post_type $args

show_in_menushow admin_menu show_ui must be trueJust showing menutrue false else some strings

(toolsphp editphp)

altough it is falseyou can access URLS likewp-admineditphppost_type=music_collection(show_ui must be true)

register_post_type $args

show_in_admin_baravailable in admin bar

menu_postiondefault below comments

menu_iconsee dashicons

register_post_type $args

capability_typestring or array to build capabilites

in our exampeedit_music_collectionsedit_others_music_collections

publish_music_collectionsread_private_music_collections

register_post_type $args

capabilitiesto give specific names to each capability

map_meta_capif true default meta capability will be added

and then your role or account need capabilities

register_post_type $args

hierarchicalpost type can be hierarchicalthis is for page-styles

register_post_type $args

query_varto query posts query_var=slug

rewriteto use pretty permalinks

has_archiveEnables post type archive

register_post_type $args

permalink_epmaskrewrite endpoint bitmask

can_exporttrue makes the post can be exported

Too exhaustive but worth it

Practice Custom Post

Create custom-plugin-ltauthorgtphpCreate a simple custom post

Display admin menuHide admin_barWrite your post Any content is OK Include at least one meta field

Next Week

Customizing Visual Components List Table Screen Widgets

WordPress System Undercover Constants and Globals WPDB

  • WordPress Plugin 3
  • Recap
  • Recap (2)
  • Recap (3)
  • Recap (4)
  • Recap (5)
  • Todays Topics
  • Entry Points in Plugin
  • Entry Points
  • Entry Points (2)
  • Entry Points (3)
  • Entry Points (4)
  • Menu Items
  • Where is default menu
  • Where is default menu (2)
  • Our custom menus
  • add_menu_page
  • add_submenu_page
  • derivatives
  • Shortcodes
  • Shortcodes (2)
  • Shortcodes (3)
  • Shortcodes (4)
  • Shortcodes (5)
  • Shortcodes (6)
  • Admin-post
  • Admin-post (2)
  • Admin-post (3)
  • AJAX
  • Redirect
  • Redirect (2)
  • (de)activation uninstall
  • Summary
  • I know you want to do something
  • Slide 35
  • Source code explained
  • 10 minutes break
  • Managing Your Own Contents
  • Wow there are too many things about posts
  • For today just focuse on custom post type
  • Arguments are too complex
  • of course you might not want this I was just kidding
  • Custom Post
  • Custom Post Motivation
  • Custom Post Motivation (2)
  • Custom Post Motivation (3)
  • Built-in Custom Post Types
  • register_post_type
  • register_post_type (2)
  • register_post_type $post_type
  • register_post_type $args
  • register_post_type $args (2)
  • register_post_type $args (3)
  • register_post_type $args (4)
  • register_post_type $args (5)
  • register_post_type $args (6)
  • register_post_type $args (7)
  • register_post_type $args (8)
  • register_post_type $args (9)
  • register_post_type $args (10)
  • register_post_type $args (11)
  • register_post_type $args (12)
  • register_post_type $args (13)
  • register_post_type $args (14)
  • register_post_type $args (15)
  • Too exhaustive but worth it
  • Practice Custom Post
  • Next Week
Page 42: WordPress plugin #3

of course you might not want this I was just kidding

Custom Post

You want to manage your own contentsThats why custom post is

Music collections Online store Event calendar Book data Photo portfolio

Custom Post Motivation

Well with just one type post and you may define many categories and use them to organize all contents

JUST ONE TYPE POSTMANY CATEGORIES

portfolio calendar music db

Custom Post Motivation

But you might feel that some post types should be hidden from some users even might be excluded from search may be only for private use may have very complex taxonomies

so that it should have its own territory

can be accessible from their own URL rules

Custom Post Motivation

Why re-invent wheel again

By extending built-in post type systemyou can REUSE whole facilities related to posts easily

UI and all thing about managing

Built-in Custom Post Types

wp-includespostphp (included in wp-settingsphp)function create_initial_post_types()

register_post_type( post array( register_post_type( page array( register_post_type( attachment array( register_post_type( revision array( register_post_type( nav_menu_item array( register_post_status( publish array(

register_post_type

ltphp register_post_type( $post_type $args ) gt

$arg is very complex

But I think it should be explained in detail Actually you cannot avoid it because eventuall all post type plugins will use that function too

Those plugins also have diffcult UIs too

register_post_type

Lets take a look how Types and Pods create their custom posts

They have easy (really) UI and provide better functionaliy but you can see horribly many options there

register_post_type $post_type

Up to 20 characters Only lowercase and numbers

register_post_type $args

publicvisible to authors

true impliesexclude_from_search falsepublicly_queryable show_in_nav_manues show_ui

false impliesexclude_from_search true publicly_queryable falseshow_in_nav_manues false show_ui false

register_post_type $args

labelplural descriptive name

egMusic CollectionsMostly localized text

register_post_type $args

labels more specific text labelsnamesigular_namemenu_namename_admin_barall_itemsadd_newadd_new_itemedit_itemview_itemsearch_items

search_itemsnot_foundnot_found in trashparent_item_colon

register_post_type $args

descriptionsummary of this post type

register_post_type $args

exclude_from_searchdo not search this post typetry S=beatbles

register_post_type $args

publicly_queryablecan use query

eg) post_type=music_collection

register_post_type $args

show_uidisplay default UI

register_post_type $args

show_in_nav_menusshow in navigation menus

be careful publicly_queryablemust be true

register_post_type $args

show_in_menushow admin_menu show_ui must be trueJust showing menutrue false else some strings

(toolsphp editphp)

altough it is falseyou can access URLS likewp-admineditphppost_type=music_collection(show_ui must be true)

register_post_type $args

show_in_admin_baravailable in admin bar

menu_postiondefault below comments

menu_iconsee dashicons

register_post_type $args

capability_typestring or array to build capabilites

in our exampeedit_music_collectionsedit_others_music_collections

publish_music_collectionsread_private_music_collections

register_post_type $args

capabilitiesto give specific names to each capability

map_meta_capif true default meta capability will be added

and then your role or account need capabilities

register_post_type $args

hierarchicalpost type can be hierarchicalthis is for page-styles

register_post_type $args

query_varto query posts query_var=slug

rewriteto use pretty permalinks

has_archiveEnables post type archive

register_post_type $args

permalink_epmaskrewrite endpoint bitmask

can_exporttrue makes the post can be exported

Too exhaustive but worth it

Practice Custom Post

Create custom-plugin-ltauthorgtphpCreate a simple custom post

Display admin menuHide admin_barWrite your post Any content is OK Include at least one meta field

Next Week

Customizing Visual Components List Table Screen Widgets

WordPress System Undercover Constants and Globals WPDB

  • WordPress Plugin 3
  • Recap
  • Recap (2)
  • Recap (3)
  • Recap (4)
  • Recap (5)
  • Todays Topics
  • Entry Points in Plugin
  • Entry Points
  • Entry Points (2)
  • Entry Points (3)
  • Entry Points (4)
  • Menu Items
  • Where is default menu
  • Where is default menu (2)
  • Our custom menus
  • add_menu_page
  • add_submenu_page
  • derivatives
  • Shortcodes
  • Shortcodes (2)
  • Shortcodes (3)
  • Shortcodes (4)
  • Shortcodes (5)
  • Shortcodes (6)
  • Admin-post
  • Admin-post (2)
  • Admin-post (3)
  • AJAX
  • Redirect
  • Redirect (2)
  • (de)activation uninstall
  • Summary
  • I know you want to do something
  • Slide 35
  • Source code explained
  • 10 minutes break
  • Managing Your Own Contents
  • Wow there are too many things about posts
  • For today just focuse on custom post type
  • Arguments are too complex
  • of course you might not want this I was just kidding
  • Custom Post
  • Custom Post Motivation
  • Custom Post Motivation (2)
  • Custom Post Motivation (3)
  • Built-in Custom Post Types
  • register_post_type
  • register_post_type (2)
  • register_post_type $post_type
  • register_post_type $args
  • register_post_type $args (2)
  • register_post_type $args (3)
  • register_post_type $args (4)
  • register_post_type $args (5)
  • register_post_type $args (6)
  • register_post_type $args (7)
  • register_post_type $args (8)
  • register_post_type $args (9)
  • register_post_type $args (10)
  • register_post_type $args (11)
  • register_post_type $args (12)
  • register_post_type $args (13)
  • register_post_type $args (14)
  • register_post_type $args (15)
  • Too exhaustive but worth it
  • Practice Custom Post
  • Next Week
Page 43: WordPress plugin #3

Custom Post

You want to manage your own contentsThats why custom post is

Music collections Online store Event calendar Book data Photo portfolio

Custom Post Motivation

Well with just one type post and you may define many categories and use them to organize all contents

JUST ONE TYPE POSTMANY CATEGORIES

portfolio calendar music db

Custom Post Motivation

But you might feel that some post types should be hidden from some users even might be excluded from search may be only for private use may have very complex taxonomies

so that it should have its own territory

can be accessible from their own URL rules

Custom Post Motivation

Why re-invent wheel again

By extending built-in post type systemyou can REUSE whole facilities related to posts easily

UI and all thing about managing

Built-in Custom Post Types

wp-includespostphp (included in wp-settingsphp)function create_initial_post_types()

register_post_type( post array( register_post_type( page array( register_post_type( attachment array( register_post_type( revision array( register_post_type( nav_menu_item array( register_post_status( publish array(

register_post_type

ltphp register_post_type( $post_type $args ) gt

$arg is very complex

But I think it should be explained in detail Actually you cannot avoid it because eventuall all post type plugins will use that function too

Those plugins also have diffcult UIs too

register_post_type

Lets take a look how Types and Pods create their custom posts

They have easy (really) UI and provide better functionaliy but you can see horribly many options there

register_post_type $post_type

Up to 20 characters Only lowercase and numbers

register_post_type $args

publicvisible to authors

true impliesexclude_from_search falsepublicly_queryable show_in_nav_manues show_ui

false impliesexclude_from_search true publicly_queryable falseshow_in_nav_manues false show_ui false

register_post_type $args

labelplural descriptive name

egMusic CollectionsMostly localized text

register_post_type $args

labels more specific text labelsnamesigular_namemenu_namename_admin_barall_itemsadd_newadd_new_itemedit_itemview_itemsearch_items

search_itemsnot_foundnot_found in trashparent_item_colon

register_post_type $args

descriptionsummary of this post type

register_post_type $args

exclude_from_searchdo not search this post typetry S=beatbles

register_post_type $args

publicly_queryablecan use query

eg) post_type=music_collection

register_post_type $args

show_uidisplay default UI

register_post_type $args

show_in_nav_menusshow in navigation menus

be careful publicly_queryablemust be true

register_post_type $args

show_in_menushow admin_menu show_ui must be trueJust showing menutrue false else some strings

(toolsphp editphp)

altough it is falseyou can access URLS likewp-admineditphppost_type=music_collection(show_ui must be true)

register_post_type $args

show_in_admin_baravailable in admin bar

menu_postiondefault below comments

menu_iconsee dashicons

register_post_type $args

capability_typestring or array to build capabilites

in our exampeedit_music_collectionsedit_others_music_collections

publish_music_collectionsread_private_music_collections

register_post_type $args

capabilitiesto give specific names to each capability

map_meta_capif true default meta capability will be added

and then your role or account need capabilities

register_post_type $args

hierarchicalpost type can be hierarchicalthis is for page-styles

register_post_type $args

query_varto query posts query_var=slug

rewriteto use pretty permalinks

has_archiveEnables post type archive

register_post_type $args

permalink_epmaskrewrite endpoint bitmask

can_exporttrue makes the post can be exported

Too exhaustive but worth it

Practice Custom Post

Create custom-plugin-ltauthorgtphpCreate a simple custom post

Display admin menuHide admin_barWrite your post Any content is OK Include at least one meta field

Next Week

Customizing Visual Components List Table Screen Widgets

WordPress System Undercover Constants and Globals WPDB

  • WordPress Plugin 3
  • Recap
  • Recap (2)
  • Recap (3)
  • Recap (4)
  • Recap (5)
  • Todays Topics
  • Entry Points in Plugin
  • Entry Points
  • Entry Points (2)
  • Entry Points (3)
  • Entry Points (4)
  • Menu Items
  • Where is default menu
  • Where is default menu (2)
  • Our custom menus
  • add_menu_page
  • add_submenu_page
  • derivatives
  • Shortcodes
  • Shortcodes (2)
  • Shortcodes (3)
  • Shortcodes (4)
  • Shortcodes (5)
  • Shortcodes (6)
  • Admin-post
  • Admin-post (2)
  • Admin-post (3)
  • AJAX
  • Redirect
  • Redirect (2)
  • (de)activation uninstall
  • Summary
  • I know you want to do something
  • Slide 35
  • Source code explained
  • 10 minutes break
  • Managing Your Own Contents
  • Wow there are too many things about posts
  • For today just focuse on custom post type
  • Arguments are too complex
  • of course you might not want this I was just kidding
  • Custom Post
  • Custom Post Motivation
  • Custom Post Motivation (2)
  • Custom Post Motivation (3)
  • Built-in Custom Post Types
  • register_post_type
  • register_post_type (2)
  • register_post_type $post_type
  • register_post_type $args
  • register_post_type $args (2)
  • register_post_type $args (3)
  • register_post_type $args (4)
  • register_post_type $args (5)
  • register_post_type $args (6)
  • register_post_type $args (7)
  • register_post_type $args (8)
  • register_post_type $args (9)
  • register_post_type $args (10)
  • register_post_type $args (11)
  • register_post_type $args (12)
  • register_post_type $args (13)
  • register_post_type $args (14)
  • register_post_type $args (15)
  • Too exhaustive but worth it
  • Practice Custom Post
  • Next Week
Page 44: WordPress plugin #3

Custom Post Motivation

Well with just one type post and you may define many categories and use them to organize all contents

JUST ONE TYPE POSTMANY CATEGORIES

portfolio calendar music db

Custom Post Motivation

But you might feel that some post types should be hidden from some users even might be excluded from search may be only for private use may have very complex taxonomies

so that it should have its own territory

can be accessible from their own URL rules

Custom Post Motivation

Why re-invent wheel again

By extending built-in post type systemyou can REUSE whole facilities related to posts easily

UI and all thing about managing

Built-in Custom Post Types

wp-includespostphp (included in wp-settingsphp)function create_initial_post_types()

register_post_type( post array( register_post_type( page array( register_post_type( attachment array( register_post_type( revision array( register_post_type( nav_menu_item array( register_post_status( publish array(

register_post_type

ltphp register_post_type( $post_type $args ) gt

$arg is very complex

But I think it should be explained in detail Actually you cannot avoid it because eventuall all post type plugins will use that function too

Those plugins also have diffcult UIs too

register_post_type

Lets take a look how Types and Pods create their custom posts

They have easy (really) UI and provide better functionaliy but you can see horribly many options there

register_post_type $post_type

Up to 20 characters Only lowercase and numbers

register_post_type $args

publicvisible to authors

true impliesexclude_from_search falsepublicly_queryable show_in_nav_manues show_ui

false impliesexclude_from_search true publicly_queryable falseshow_in_nav_manues false show_ui false

register_post_type $args

labelplural descriptive name

egMusic CollectionsMostly localized text

register_post_type $args

labels more specific text labelsnamesigular_namemenu_namename_admin_barall_itemsadd_newadd_new_itemedit_itemview_itemsearch_items

search_itemsnot_foundnot_found in trashparent_item_colon

register_post_type $args

descriptionsummary of this post type

register_post_type $args

exclude_from_searchdo not search this post typetry S=beatbles

register_post_type $args

publicly_queryablecan use query

eg) post_type=music_collection

register_post_type $args

show_uidisplay default UI

register_post_type $args

show_in_nav_menusshow in navigation menus

be careful publicly_queryablemust be true

register_post_type $args

show_in_menushow admin_menu show_ui must be trueJust showing menutrue false else some strings

(toolsphp editphp)

altough it is falseyou can access URLS likewp-admineditphppost_type=music_collection(show_ui must be true)

register_post_type $args

show_in_admin_baravailable in admin bar

menu_postiondefault below comments

menu_iconsee dashicons

register_post_type $args

capability_typestring or array to build capabilites

in our exampeedit_music_collectionsedit_others_music_collections

publish_music_collectionsread_private_music_collections

register_post_type $args

capabilitiesto give specific names to each capability

map_meta_capif true default meta capability will be added

and then your role or account need capabilities

register_post_type $args

hierarchicalpost type can be hierarchicalthis is for page-styles

register_post_type $args

query_varto query posts query_var=slug

rewriteto use pretty permalinks

has_archiveEnables post type archive

register_post_type $args

permalink_epmaskrewrite endpoint bitmask

can_exporttrue makes the post can be exported

Too exhaustive but worth it

Practice Custom Post

Create custom-plugin-ltauthorgtphpCreate a simple custom post

Display admin menuHide admin_barWrite your post Any content is OK Include at least one meta field

Next Week

Customizing Visual Components List Table Screen Widgets

WordPress System Undercover Constants and Globals WPDB

  • WordPress Plugin 3
  • Recap
  • Recap (2)
  • Recap (3)
  • Recap (4)
  • Recap (5)
  • Todays Topics
  • Entry Points in Plugin
  • Entry Points
  • Entry Points (2)
  • Entry Points (3)
  • Entry Points (4)
  • Menu Items
  • Where is default menu
  • Where is default menu (2)
  • Our custom menus
  • add_menu_page
  • add_submenu_page
  • derivatives
  • Shortcodes
  • Shortcodes (2)
  • Shortcodes (3)
  • Shortcodes (4)
  • Shortcodes (5)
  • Shortcodes (6)
  • Admin-post
  • Admin-post (2)
  • Admin-post (3)
  • AJAX
  • Redirect
  • Redirect (2)
  • (de)activation uninstall
  • Summary
  • I know you want to do something
  • Slide 35
  • Source code explained
  • 10 minutes break
  • Managing Your Own Contents
  • Wow there are too many things about posts
  • For today just focuse on custom post type
  • Arguments are too complex
  • of course you might not want this I was just kidding
  • Custom Post
  • Custom Post Motivation
  • Custom Post Motivation (2)
  • Custom Post Motivation (3)
  • Built-in Custom Post Types
  • register_post_type
  • register_post_type (2)
  • register_post_type $post_type
  • register_post_type $args
  • register_post_type $args (2)
  • register_post_type $args (3)
  • register_post_type $args (4)
  • register_post_type $args (5)
  • register_post_type $args (6)
  • register_post_type $args (7)
  • register_post_type $args (8)
  • register_post_type $args (9)
  • register_post_type $args (10)
  • register_post_type $args (11)
  • register_post_type $args (12)
  • register_post_type $args (13)
  • register_post_type $args (14)
  • register_post_type $args (15)
  • Too exhaustive but worth it
  • Practice Custom Post
  • Next Week
Page 45: WordPress plugin #3

Custom Post Motivation

But you might feel that some post types should be hidden from some users even might be excluded from search may be only for private use may have very complex taxonomies

so that it should have its own territory

can be accessible from their own URL rules

Custom Post Motivation

Why re-invent wheel again

By extending built-in post type systemyou can REUSE whole facilities related to posts easily

UI and all thing about managing

Built-in Custom Post Types

wp-includespostphp (included in wp-settingsphp)function create_initial_post_types()

register_post_type( post array( register_post_type( page array( register_post_type( attachment array( register_post_type( revision array( register_post_type( nav_menu_item array( register_post_status( publish array(

register_post_type

ltphp register_post_type( $post_type $args ) gt

$arg is very complex

But I think it should be explained in detail Actually you cannot avoid it because eventuall all post type plugins will use that function too

Those plugins also have diffcult UIs too

register_post_type

Lets take a look how Types and Pods create their custom posts

They have easy (really) UI and provide better functionaliy but you can see horribly many options there

register_post_type $post_type

Up to 20 characters Only lowercase and numbers

register_post_type $args

publicvisible to authors

true impliesexclude_from_search falsepublicly_queryable show_in_nav_manues show_ui

false impliesexclude_from_search true publicly_queryable falseshow_in_nav_manues false show_ui false

register_post_type $args

labelplural descriptive name

egMusic CollectionsMostly localized text

register_post_type $args

labels more specific text labelsnamesigular_namemenu_namename_admin_barall_itemsadd_newadd_new_itemedit_itemview_itemsearch_items

search_itemsnot_foundnot_found in trashparent_item_colon

register_post_type $args

descriptionsummary of this post type

register_post_type $args

exclude_from_searchdo not search this post typetry S=beatbles

register_post_type $args

publicly_queryablecan use query

eg) post_type=music_collection

register_post_type $args

show_uidisplay default UI

register_post_type $args

show_in_nav_menusshow in navigation menus

be careful publicly_queryablemust be true

register_post_type $args

show_in_menushow admin_menu show_ui must be trueJust showing menutrue false else some strings

(toolsphp editphp)

altough it is falseyou can access URLS likewp-admineditphppost_type=music_collection(show_ui must be true)

register_post_type $args

show_in_admin_baravailable in admin bar

menu_postiondefault below comments

menu_iconsee dashicons

register_post_type $args

capability_typestring or array to build capabilites

in our exampeedit_music_collectionsedit_others_music_collections

publish_music_collectionsread_private_music_collections

register_post_type $args

capabilitiesto give specific names to each capability

map_meta_capif true default meta capability will be added

and then your role or account need capabilities

register_post_type $args

hierarchicalpost type can be hierarchicalthis is for page-styles

register_post_type $args

query_varto query posts query_var=slug

rewriteto use pretty permalinks

has_archiveEnables post type archive

register_post_type $args

permalink_epmaskrewrite endpoint bitmask

can_exporttrue makes the post can be exported

Too exhaustive but worth it

Practice Custom Post

Create custom-plugin-ltauthorgtphpCreate a simple custom post

Display admin menuHide admin_barWrite your post Any content is OK Include at least one meta field

Next Week

Customizing Visual Components List Table Screen Widgets

WordPress System Undercover Constants and Globals WPDB

  • WordPress Plugin 3
  • Recap
  • Recap (2)
  • Recap (3)
  • Recap (4)
  • Recap (5)
  • Todays Topics
  • Entry Points in Plugin
  • Entry Points
  • Entry Points (2)
  • Entry Points (3)
  • Entry Points (4)
  • Menu Items
  • Where is default menu
  • Where is default menu (2)
  • Our custom menus
  • add_menu_page
  • add_submenu_page
  • derivatives
  • Shortcodes
  • Shortcodes (2)
  • Shortcodes (3)
  • Shortcodes (4)
  • Shortcodes (5)
  • Shortcodes (6)
  • Admin-post
  • Admin-post (2)
  • Admin-post (3)
  • AJAX
  • Redirect
  • Redirect (2)
  • (de)activation uninstall
  • Summary
  • I know you want to do something
  • Slide 35
  • Source code explained
  • 10 minutes break
  • Managing Your Own Contents
  • Wow there are too many things about posts
  • For today just focuse on custom post type
  • Arguments are too complex
  • of course you might not want this I was just kidding
  • Custom Post
  • Custom Post Motivation
  • Custom Post Motivation (2)
  • Custom Post Motivation (3)
  • Built-in Custom Post Types
  • register_post_type
  • register_post_type (2)
  • register_post_type $post_type
  • register_post_type $args
  • register_post_type $args (2)
  • register_post_type $args (3)
  • register_post_type $args (4)
  • register_post_type $args (5)
  • register_post_type $args (6)
  • register_post_type $args (7)
  • register_post_type $args (8)
  • register_post_type $args (9)
  • register_post_type $args (10)
  • register_post_type $args (11)
  • register_post_type $args (12)
  • register_post_type $args (13)
  • register_post_type $args (14)
  • register_post_type $args (15)
  • Too exhaustive but worth it
  • Practice Custom Post
  • Next Week
Page 46: WordPress plugin #3

Custom Post Motivation

Why re-invent wheel again

By extending built-in post type systemyou can REUSE whole facilities related to posts easily

UI and all thing about managing

Built-in Custom Post Types

wp-includespostphp (included in wp-settingsphp)function create_initial_post_types()

register_post_type( post array( register_post_type( page array( register_post_type( attachment array( register_post_type( revision array( register_post_type( nav_menu_item array( register_post_status( publish array(

register_post_type

ltphp register_post_type( $post_type $args ) gt

$arg is very complex

But I think it should be explained in detail Actually you cannot avoid it because eventuall all post type plugins will use that function too

Those plugins also have diffcult UIs too

register_post_type

Lets take a look how Types and Pods create their custom posts

They have easy (really) UI and provide better functionaliy but you can see horribly many options there

register_post_type $post_type

Up to 20 characters Only lowercase and numbers

register_post_type $args

publicvisible to authors

true impliesexclude_from_search falsepublicly_queryable show_in_nav_manues show_ui

false impliesexclude_from_search true publicly_queryable falseshow_in_nav_manues false show_ui false

register_post_type $args

labelplural descriptive name

egMusic CollectionsMostly localized text

register_post_type $args

labels more specific text labelsnamesigular_namemenu_namename_admin_barall_itemsadd_newadd_new_itemedit_itemview_itemsearch_items

search_itemsnot_foundnot_found in trashparent_item_colon

register_post_type $args

descriptionsummary of this post type

register_post_type $args

exclude_from_searchdo not search this post typetry S=beatbles

register_post_type $args

publicly_queryablecan use query

eg) post_type=music_collection

register_post_type $args

show_uidisplay default UI

register_post_type $args

show_in_nav_menusshow in navigation menus

be careful publicly_queryablemust be true

register_post_type $args

show_in_menushow admin_menu show_ui must be trueJust showing menutrue false else some strings

(toolsphp editphp)

altough it is falseyou can access URLS likewp-admineditphppost_type=music_collection(show_ui must be true)

register_post_type $args

show_in_admin_baravailable in admin bar

menu_postiondefault below comments

menu_iconsee dashicons

register_post_type $args

capability_typestring or array to build capabilites

in our exampeedit_music_collectionsedit_others_music_collections

publish_music_collectionsread_private_music_collections

register_post_type $args

capabilitiesto give specific names to each capability

map_meta_capif true default meta capability will be added

and then your role or account need capabilities

register_post_type $args

hierarchicalpost type can be hierarchicalthis is for page-styles

register_post_type $args

query_varto query posts query_var=slug

rewriteto use pretty permalinks

has_archiveEnables post type archive

register_post_type $args

permalink_epmaskrewrite endpoint bitmask

can_exporttrue makes the post can be exported

Too exhaustive but worth it

Practice Custom Post

Create custom-plugin-ltauthorgtphpCreate a simple custom post

Display admin menuHide admin_barWrite your post Any content is OK Include at least one meta field

Next Week

Customizing Visual Components List Table Screen Widgets

WordPress System Undercover Constants and Globals WPDB

  • WordPress Plugin 3
  • Recap
  • Recap (2)
  • Recap (3)
  • Recap (4)
  • Recap (5)
  • Todays Topics
  • Entry Points in Plugin
  • Entry Points
  • Entry Points (2)
  • Entry Points (3)
  • Entry Points (4)
  • Menu Items
  • Where is default menu
  • Where is default menu (2)
  • Our custom menus
  • add_menu_page
  • add_submenu_page
  • derivatives
  • Shortcodes
  • Shortcodes (2)
  • Shortcodes (3)
  • Shortcodes (4)
  • Shortcodes (5)
  • Shortcodes (6)
  • Admin-post
  • Admin-post (2)
  • Admin-post (3)
  • AJAX
  • Redirect
  • Redirect (2)
  • (de)activation uninstall
  • Summary
  • I know you want to do something
  • Slide 35
  • Source code explained
  • 10 minutes break
  • Managing Your Own Contents
  • Wow there are too many things about posts
  • For today just focuse on custom post type
  • Arguments are too complex
  • of course you might not want this I was just kidding
  • Custom Post
  • Custom Post Motivation
  • Custom Post Motivation (2)
  • Custom Post Motivation (3)
  • Built-in Custom Post Types
  • register_post_type
  • register_post_type (2)
  • register_post_type $post_type
  • register_post_type $args
  • register_post_type $args (2)
  • register_post_type $args (3)
  • register_post_type $args (4)
  • register_post_type $args (5)
  • register_post_type $args (6)
  • register_post_type $args (7)
  • register_post_type $args (8)
  • register_post_type $args (9)
  • register_post_type $args (10)
  • register_post_type $args (11)
  • register_post_type $args (12)
  • register_post_type $args (13)
  • register_post_type $args (14)
  • register_post_type $args (15)
  • Too exhaustive but worth it
  • Practice Custom Post
  • Next Week
Page 47: WordPress plugin #3

Built-in Custom Post Types

wp-includespostphp (included in wp-settingsphp)function create_initial_post_types()

register_post_type( post array( register_post_type( page array( register_post_type( attachment array( register_post_type( revision array( register_post_type( nav_menu_item array( register_post_status( publish array(

register_post_type

ltphp register_post_type( $post_type $args ) gt

$arg is very complex

But I think it should be explained in detail Actually you cannot avoid it because eventuall all post type plugins will use that function too

Those plugins also have diffcult UIs too

register_post_type

Lets take a look how Types and Pods create their custom posts

They have easy (really) UI and provide better functionaliy but you can see horribly many options there

register_post_type $post_type

Up to 20 characters Only lowercase and numbers

register_post_type $args

publicvisible to authors

true impliesexclude_from_search falsepublicly_queryable show_in_nav_manues show_ui

false impliesexclude_from_search true publicly_queryable falseshow_in_nav_manues false show_ui false

register_post_type $args

labelplural descriptive name

egMusic CollectionsMostly localized text

register_post_type $args

labels more specific text labelsnamesigular_namemenu_namename_admin_barall_itemsadd_newadd_new_itemedit_itemview_itemsearch_items

search_itemsnot_foundnot_found in trashparent_item_colon

register_post_type $args

descriptionsummary of this post type

register_post_type $args

exclude_from_searchdo not search this post typetry S=beatbles

register_post_type $args

publicly_queryablecan use query

eg) post_type=music_collection

register_post_type $args

show_uidisplay default UI

register_post_type $args

show_in_nav_menusshow in navigation menus

be careful publicly_queryablemust be true

register_post_type $args

show_in_menushow admin_menu show_ui must be trueJust showing menutrue false else some strings

(toolsphp editphp)

altough it is falseyou can access URLS likewp-admineditphppost_type=music_collection(show_ui must be true)

register_post_type $args

show_in_admin_baravailable in admin bar

menu_postiondefault below comments

menu_iconsee dashicons

register_post_type $args

capability_typestring or array to build capabilites

in our exampeedit_music_collectionsedit_others_music_collections

publish_music_collectionsread_private_music_collections

register_post_type $args

capabilitiesto give specific names to each capability

map_meta_capif true default meta capability will be added

and then your role or account need capabilities

register_post_type $args

hierarchicalpost type can be hierarchicalthis is for page-styles

register_post_type $args

query_varto query posts query_var=slug

rewriteto use pretty permalinks

has_archiveEnables post type archive

register_post_type $args

permalink_epmaskrewrite endpoint bitmask

can_exporttrue makes the post can be exported

Too exhaustive but worth it

Practice Custom Post

Create custom-plugin-ltauthorgtphpCreate a simple custom post

Display admin menuHide admin_barWrite your post Any content is OK Include at least one meta field

Next Week

Customizing Visual Components List Table Screen Widgets

WordPress System Undercover Constants and Globals WPDB

  • WordPress Plugin 3
  • Recap
  • Recap (2)
  • Recap (3)
  • Recap (4)
  • Recap (5)
  • Todays Topics
  • Entry Points in Plugin
  • Entry Points
  • Entry Points (2)
  • Entry Points (3)
  • Entry Points (4)
  • Menu Items
  • Where is default menu
  • Where is default menu (2)
  • Our custom menus
  • add_menu_page
  • add_submenu_page
  • derivatives
  • Shortcodes
  • Shortcodes (2)
  • Shortcodes (3)
  • Shortcodes (4)
  • Shortcodes (5)
  • Shortcodes (6)
  • Admin-post
  • Admin-post (2)
  • Admin-post (3)
  • AJAX
  • Redirect
  • Redirect (2)
  • (de)activation uninstall
  • Summary
  • I know you want to do something
  • Slide 35
  • Source code explained
  • 10 minutes break
  • Managing Your Own Contents
  • Wow there are too many things about posts
  • For today just focuse on custom post type
  • Arguments are too complex
  • of course you might not want this I was just kidding
  • Custom Post
  • Custom Post Motivation
  • Custom Post Motivation (2)
  • Custom Post Motivation (3)
  • Built-in Custom Post Types
  • register_post_type
  • register_post_type (2)
  • register_post_type $post_type
  • register_post_type $args
  • register_post_type $args (2)
  • register_post_type $args (3)
  • register_post_type $args (4)
  • register_post_type $args (5)
  • register_post_type $args (6)
  • register_post_type $args (7)
  • register_post_type $args (8)
  • register_post_type $args (9)
  • register_post_type $args (10)
  • register_post_type $args (11)
  • register_post_type $args (12)
  • register_post_type $args (13)
  • register_post_type $args (14)
  • register_post_type $args (15)
  • Too exhaustive but worth it
  • Practice Custom Post
  • Next Week
Page 48: WordPress plugin #3

register_post_type

ltphp register_post_type( $post_type $args ) gt

$arg is very complex

But I think it should be explained in detail Actually you cannot avoid it because eventuall all post type plugins will use that function too

Those plugins also have diffcult UIs too

register_post_type

Lets take a look how Types and Pods create their custom posts

They have easy (really) UI and provide better functionaliy but you can see horribly many options there

register_post_type $post_type

Up to 20 characters Only lowercase and numbers

register_post_type $args

publicvisible to authors

true impliesexclude_from_search falsepublicly_queryable show_in_nav_manues show_ui

false impliesexclude_from_search true publicly_queryable falseshow_in_nav_manues false show_ui false

register_post_type $args

labelplural descriptive name

egMusic CollectionsMostly localized text

register_post_type $args

labels more specific text labelsnamesigular_namemenu_namename_admin_barall_itemsadd_newadd_new_itemedit_itemview_itemsearch_items

search_itemsnot_foundnot_found in trashparent_item_colon

register_post_type $args

descriptionsummary of this post type

register_post_type $args

exclude_from_searchdo not search this post typetry S=beatbles

register_post_type $args

publicly_queryablecan use query

eg) post_type=music_collection

register_post_type $args

show_uidisplay default UI

register_post_type $args

show_in_nav_menusshow in navigation menus

be careful publicly_queryablemust be true

register_post_type $args

show_in_menushow admin_menu show_ui must be trueJust showing menutrue false else some strings

(toolsphp editphp)

altough it is falseyou can access URLS likewp-admineditphppost_type=music_collection(show_ui must be true)

register_post_type $args

show_in_admin_baravailable in admin bar

menu_postiondefault below comments

menu_iconsee dashicons

register_post_type $args

capability_typestring or array to build capabilites

in our exampeedit_music_collectionsedit_others_music_collections

publish_music_collectionsread_private_music_collections

register_post_type $args

capabilitiesto give specific names to each capability

map_meta_capif true default meta capability will be added

and then your role or account need capabilities

register_post_type $args

hierarchicalpost type can be hierarchicalthis is for page-styles

register_post_type $args

query_varto query posts query_var=slug

rewriteto use pretty permalinks

has_archiveEnables post type archive

register_post_type $args

permalink_epmaskrewrite endpoint bitmask

can_exporttrue makes the post can be exported

Too exhaustive but worth it

Practice Custom Post

Create custom-plugin-ltauthorgtphpCreate a simple custom post

Display admin menuHide admin_barWrite your post Any content is OK Include at least one meta field

Next Week

Customizing Visual Components List Table Screen Widgets

WordPress System Undercover Constants and Globals WPDB

  • WordPress Plugin 3
  • Recap
  • Recap (2)
  • Recap (3)
  • Recap (4)
  • Recap (5)
  • Todays Topics
  • Entry Points in Plugin
  • Entry Points
  • Entry Points (2)
  • Entry Points (3)
  • Entry Points (4)
  • Menu Items
  • Where is default menu
  • Where is default menu (2)
  • Our custom menus
  • add_menu_page
  • add_submenu_page
  • derivatives
  • Shortcodes
  • Shortcodes (2)
  • Shortcodes (3)
  • Shortcodes (4)
  • Shortcodes (5)
  • Shortcodes (6)
  • Admin-post
  • Admin-post (2)
  • Admin-post (3)
  • AJAX
  • Redirect
  • Redirect (2)
  • (de)activation uninstall
  • Summary
  • I know you want to do something
  • Slide 35
  • Source code explained
  • 10 minutes break
  • Managing Your Own Contents
  • Wow there are too many things about posts
  • For today just focuse on custom post type
  • Arguments are too complex
  • of course you might not want this I was just kidding
  • Custom Post
  • Custom Post Motivation
  • Custom Post Motivation (2)
  • Custom Post Motivation (3)
  • Built-in Custom Post Types
  • register_post_type
  • register_post_type (2)
  • register_post_type $post_type
  • register_post_type $args
  • register_post_type $args (2)
  • register_post_type $args (3)
  • register_post_type $args (4)
  • register_post_type $args (5)
  • register_post_type $args (6)
  • register_post_type $args (7)
  • register_post_type $args (8)
  • register_post_type $args (9)
  • register_post_type $args (10)
  • register_post_type $args (11)
  • register_post_type $args (12)
  • register_post_type $args (13)
  • register_post_type $args (14)
  • register_post_type $args (15)
  • Too exhaustive but worth it
  • Practice Custom Post
  • Next Week
Page 49: WordPress plugin #3

register_post_type

Lets take a look how Types and Pods create their custom posts

They have easy (really) UI and provide better functionaliy but you can see horribly many options there

register_post_type $post_type

Up to 20 characters Only lowercase and numbers

register_post_type $args

publicvisible to authors

true impliesexclude_from_search falsepublicly_queryable show_in_nav_manues show_ui

false impliesexclude_from_search true publicly_queryable falseshow_in_nav_manues false show_ui false

register_post_type $args

labelplural descriptive name

egMusic CollectionsMostly localized text

register_post_type $args

labels more specific text labelsnamesigular_namemenu_namename_admin_barall_itemsadd_newadd_new_itemedit_itemview_itemsearch_items

search_itemsnot_foundnot_found in trashparent_item_colon

register_post_type $args

descriptionsummary of this post type

register_post_type $args

exclude_from_searchdo not search this post typetry S=beatbles

register_post_type $args

publicly_queryablecan use query

eg) post_type=music_collection

register_post_type $args

show_uidisplay default UI

register_post_type $args

show_in_nav_menusshow in navigation menus

be careful publicly_queryablemust be true

register_post_type $args

show_in_menushow admin_menu show_ui must be trueJust showing menutrue false else some strings

(toolsphp editphp)

altough it is falseyou can access URLS likewp-admineditphppost_type=music_collection(show_ui must be true)

register_post_type $args

show_in_admin_baravailable in admin bar

menu_postiondefault below comments

menu_iconsee dashicons

register_post_type $args

capability_typestring or array to build capabilites

in our exampeedit_music_collectionsedit_others_music_collections

publish_music_collectionsread_private_music_collections

register_post_type $args

capabilitiesto give specific names to each capability

map_meta_capif true default meta capability will be added

and then your role or account need capabilities

register_post_type $args

hierarchicalpost type can be hierarchicalthis is for page-styles

register_post_type $args

query_varto query posts query_var=slug

rewriteto use pretty permalinks

has_archiveEnables post type archive

register_post_type $args

permalink_epmaskrewrite endpoint bitmask

can_exporttrue makes the post can be exported

Too exhaustive but worth it

Practice Custom Post

Create custom-plugin-ltauthorgtphpCreate a simple custom post

Display admin menuHide admin_barWrite your post Any content is OK Include at least one meta field

Next Week

Customizing Visual Components List Table Screen Widgets

WordPress System Undercover Constants and Globals WPDB

  • WordPress Plugin 3
  • Recap
  • Recap (2)
  • Recap (3)
  • Recap (4)
  • Recap (5)
  • Todays Topics
  • Entry Points in Plugin
  • Entry Points
  • Entry Points (2)
  • Entry Points (3)
  • Entry Points (4)
  • Menu Items
  • Where is default menu
  • Where is default menu (2)
  • Our custom menus
  • add_menu_page
  • add_submenu_page
  • derivatives
  • Shortcodes
  • Shortcodes (2)
  • Shortcodes (3)
  • Shortcodes (4)
  • Shortcodes (5)
  • Shortcodes (6)
  • Admin-post
  • Admin-post (2)
  • Admin-post (3)
  • AJAX
  • Redirect
  • Redirect (2)
  • (de)activation uninstall
  • Summary
  • I know you want to do something
  • Slide 35
  • Source code explained
  • 10 minutes break
  • Managing Your Own Contents
  • Wow there are too many things about posts
  • For today just focuse on custom post type
  • Arguments are too complex
  • of course you might not want this I was just kidding
  • Custom Post
  • Custom Post Motivation
  • Custom Post Motivation (2)
  • Custom Post Motivation (3)
  • Built-in Custom Post Types
  • register_post_type
  • register_post_type (2)
  • register_post_type $post_type
  • register_post_type $args
  • register_post_type $args (2)
  • register_post_type $args (3)
  • register_post_type $args (4)
  • register_post_type $args (5)
  • register_post_type $args (6)
  • register_post_type $args (7)
  • register_post_type $args (8)
  • register_post_type $args (9)
  • register_post_type $args (10)
  • register_post_type $args (11)
  • register_post_type $args (12)
  • register_post_type $args (13)
  • register_post_type $args (14)
  • register_post_type $args (15)
  • Too exhaustive but worth it
  • Practice Custom Post
  • Next Week
Page 50: WordPress plugin #3

register_post_type $post_type

Up to 20 characters Only lowercase and numbers

register_post_type $args

publicvisible to authors

true impliesexclude_from_search falsepublicly_queryable show_in_nav_manues show_ui

false impliesexclude_from_search true publicly_queryable falseshow_in_nav_manues false show_ui false

register_post_type $args

labelplural descriptive name

egMusic CollectionsMostly localized text

register_post_type $args

labels more specific text labelsnamesigular_namemenu_namename_admin_barall_itemsadd_newadd_new_itemedit_itemview_itemsearch_items

search_itemsnot_foundnot_found in trashparent_item_colon

register_post_type $args

descriptionsummary of this post type

register_post_type $args

exclude_from_searchdo not search this post typetry S=beatbles

register_post_type $args

publicly_queryablecan use query

eg) post_type=music_collection

register_post_type $args

show_uidisplay default UI

register_post_type $args

show_in_nav_menusshow in navigation menus

be careful publicly_queryablemust be true

register_post_type $args

show_in_menushow admin_menu show_ui must be trueJust showing menutrue false else some strings

(toolsphp editphp)

altough it is falseyou can access URLS likewp-admineditphppost_type=music_collection(show_ui must be true)

register_post_type $args

show_in_admin_baravailable in admin bar

menu_postiondefault below comments

menu_iconsee dashicons

register_post_type $args

capability_typestring or array to build capabilites

in our exampeedit_music_collectionsedit_others_music_collections

publish_music_collectionsread_private_music_collections

register_post_type $args

capabilitiesto give specific names to each capability

map_meta_capif true default meta capability will be added

and then your role or account need capabilities

register_post_type $args

hierarchicalpost type can be hierarchicalthis is for page-styles

register_post_type $args

query_varto query posts query_var=slug

rewriteto use pretty permalinks

has_archiveEnables post type archive

register_post_type $args

permalink_epmaskrewrite endpoint bitmask

can_exporttrue makes the post can be exported

Too exhaustive but worth it

Practice Custom Post

Create custom-plugin-ltauthorgtphpCreate a simple custom post

Display admin menuHide admin_barWrite your post Any content is OK Include at least one meta field

Next Week

Customizing Visual Components List Table Screen Widgets

WordPress System Undercover Constants and Globals WPDB

  • WordPress Plugin 3
  • Recap
  • Recap (2)
  • Recap (3)
  • Recap (4)
  • Recap (5)
  • Todays Topics
  • Entry Points in Plugin
  • Entry Points
  • Entry Points (2)
  • Entry Points (3)
  • Entry Points (4)
  • Menu Items
  • Where is default menu
  • Where is default menu (2)
  • Our custom menus
  • add_menu_page
  • add_submenu_page
  • derivatives
  • Shortcodes
  • Shortcodes (2)
  • Shortcodes (3)
  • Shortcodes (4)
  • Shortcodes (5)
  • Shortcodes (6)
  • Admin-post
  • Admin-post (2)
  • Admin-post (3)
  • AJAX
  • Redirect
  • Redirect (2)
  • (de)activation uninstall
  • Summary
  • I know you want to do something
  • Slide 35
  • Source code explained
  • 10 minutes break
  • Managing Your Own Contents
  • Wow there are too many things about posts
  • For today just focuse on custom post type
  • Arguments are too complex
  • of course you might not want this I was just kidding
  • Custom Post
  • Custom Post Motivation
  • Custom Post Motivation (2)
  • Custom Post Motivation (3)
  • Built-in Custom Post Types
  • register_post_type
  • register_post_type (2)
  • register_post_type $post_type
  • register_post_type $args
  • register_post_type $args (2)
  • register_post_type $args (3)
  • register_post_type $args (4)
  • register_post_type $args (5)
  • register_post_type $args (6)
  • register_post_type $args (7)
  • register_post_type $args (8)
  • register_post_type $args (9)
  • register_post_type $args (10)
  • register_post_type $args (11)
  • register_post_type $args (12)
  • register_post_type $args (13)
  • register_post_type $args (14)
  • register_post_type $args (15)
  • Too exhaustive but worth it
  • Practice Custom Post
  • Next Week
Page 51: WordPress plugin #3

register_post_type $args

publicvisible to authors

true impliesexclude_from_search falsepublicly_queryable show_in_nav_manues show_ui

false impliesexclude_from_search true publicly_queryable falseshow_in_nav_manues false show_ui false

register_post_type $args

labelplural descriptive name

egMusic CollectionsMostly localized text

register_post_type $args

labels more specific text labelsnamesigular_namemenu_namename_admin_barall_itemsadd_newadd_new_itemedit_itemview_itemsearch_items

search_itemsnot_foundnot_found in trashparent_item_colon

register_post_type $args

descriptionsummary of this post type

register_post_type $args

exclude_from_searchdo not search this post typetry S=beatbles

register_post_type $args

publicly_queryablecan use query

eg) post_type=music_collection

register_post_type $args

show_uidisplay default UI

register_post_type $args

show_in_nav_menusshow in navigation menus

be careful publicly_queryablemust be true

register_post_type $args

show_in_menushow admin_menu show_ui must be trueJust showing menutrue false else some strings

(toolsphp editphp)

altough it is falseyou can access URLS likewp-admineditphppost_type=music_collection(show_ui must be true)

register_post_type $args

show_in_admin_baravailable in admin bar

menu_postiondefault below comments

menu_iconsee dashicons

register_post_type $args

capability_typestring or array to build capabilites

in our exampeedit_music_collectionsedit_others_music_collections

publish_music_collectionsread_private_music_collections

register_post_type $args

capabilitiesto give specific names to each capability

map_meta_capif true default meta capability will be added

and then your role or account need capabilities

register_post_type $args

hierarchicalpost type can be hierarchicalthis is for page-styles

register_post_type $args

query_varto query posts query_var=slug

rewriteto use pretty permalinks

has_archiveEnables post type archive

register_post_type $args

permalink_epmaskrewrite endpoint bitmask

can_exporttrue makes the post can be exported

Too exhaustive but worth it

Practice Custom Post

Create custom-plugin-ltauthorgtphpCreate a simple custom post

Display admin menuHide admin_barWrite your post Any content is OK Include at least one meta field

Next Week

Customizing Visual Components List Table Screen Widgets

WordPress System Undercover Constants and Globals WPDB

  • WordPress Plugin 3
  • Recap
  • Recap (2)
  • Recap (3)
  • Recap (4)
  • Recap (5)
  • Todays Topics
  • Entry Points in Plugin
  • Entry Points
  • Entry Points (2)
  • Entry Points (3)
  • Entry Points (4)
  • Menu Items
  • Where is default menu
  • Where is default menu (2)
  • Our custom menus
  • add_menu_page
  • add_submenu_page
  • derivatives
  • Shortcodes
  • Shortcodes (2)
  • Shortcodes (3)
  • Shortcodes (4)
  • Shortcodes (5)
  • Shortcodes (6)
  • Admin-post
  • Admin-post (2)
  • Admin-post (3)
  • AJAX
  • Redirect
  • Redirect (2)
  • (de)activation uninstall
  • Summary
  • I know you want to do something
  • Slide 35
  • Source code explained
  • 10 minutes break
  • Managing Your Own Contents
  • Wow there are too many things about posts
  • For today just focuse on custom post type
  • Arguments are too complex
  • of course you might not want this I was just kidding
  • Custom Post
  • Custom Post Motivation
  • Custom Post Motivation (2)
  • Custom Post Motivation (3)
  • Built-in Custom Post Types
  • register_post_type
  • register_post_type (2)
  • register_post_type $post_type
  • register_post_type $args
  • register_post_type $args (2)
  • register_post_type $args (3)
  • register_post_type $args (4)
  • register_post_type $args (5)
  • register_post_type $args (6)
  • register_post_type $args (7)
  • register_post_type $args (8)
  • register_post_type $args (9)
  • register_post_type $args (10)
  • register_post_type $args (11)
  • register_post_type $args (12)
  • register_post_type $args (13)
  • register_post_type $args (14)
  • register_post_type $args (15)
  • Too exhaustive but worth it
  • Practice Custom Post
  • Next Week
Page 52: WordPress plugin #3

register_post_type $args

labelplural descriptive name

egMusic CollectionsMostly localized text

register_post_type $args

labels more specific text labelsnamesigular_namemenu_namename_admin_barall_itemsadd_newadd_new_itemedit_itemview_itemsearch_items

search_itemsnot_foundnot_found in trashparent_item_colon

register_post_type $args

descriptionsummary of this post type

register_post_type $args

exclude_from_searchdo not search this post typetry S=beatbles

register_post_type $args

publicly_queryablecan use query

eg) post_type=music_collection

register_post_type $args

show_uidisplay default UI

register_post_type $args

show_in_nav_menusshow in navigation menus

be careful publicly_queryablemust be true

register_post_type $args

show_in_menushow admin_menu show_ui must be trueJust showing menutrue false else some strings

(toolsphp editphp)

altough it is falseyou can access URLS likewp-admineditphppost_type=music_collection(show_ui must be true)

register_post_type $args

show_in_admin_baravailable in admin bar

menu_postiondefault below comments

menu_iconsee dashicons

register_post_type $args

capability_typestring or array to build capabilites

in our exampeedit_music_collectionsedit_others_music_collections

publish_music_collectionsread_private_music_collections

register_post_type $args

capabilitiesto give specific names to each capability

map_meta_capif true default meta capability will be added

and then your role or account need capabilities

register_post_type $args

hierarchicalpost type can be hierarchicalthis is for page-styles

register_post_type $args

query_varto query posts query_var=slug

rewriteto use pretty permalinks

has_archiveEnables post type archive

register_post_type $args

permalink_epmaskrewrite endpoint bitmask

can_exporttrue makes the post can be exported

Too exhaustive but worth it

Practice Custom Post

Create custom-plugin-ltauthorgtphpCreate a simple custom post

Display admin menuHide admin_barWrite your post Any content is OK Include at least one meta field

Next Week

Customizing Visual Components List Table Screen Widgets

WordPress System Undercover Constants and Globals WPDB

  • WordPress Plugin 3
  • Recap
  • Recap (2)
  • Recap (3)
  • Recap (4)
  • Recap (5)
  • Todays Topics
  • Entry Points in Plugin
  • Entry Points
  • Entry Points (2)
  • Entry Points (3)
  • Entry Points (4)
  • Menu Items
  • Where is default menu
  • Where is default menu (2)
  • Our custom menus
  • add_menu_page
  • add_submenu_page
  • derivatives
  • Shortcodes
  • Shortcodes (2)
  • Shortcodes (3)
  • Shortcodes (4)
  • Shortcodes (5)
  • Shortcodes (6)
  • Admin-post
  • Admin-post (2)
  • Admin-post (3)
  • AJAX
  • Redirect
  • Redirect (2)
  • (de)activation uninstall
  • Summary
  • I know you want to do something
  • Slide 35
  • Source code explained
  • 10 minutes break
  • Managing Your Own Contents
  • Wow there are too many things about posts
  • For today just focuse on custom post type
  • Arguments are too complex
  • of course you might not want this I was just kidding
  • Custom Post
  • Custom Post Motivation
  • Custom Post Motivation (2)
  • Custom Post Motivation (3)
  • Built-in Custom Post Types
  • register_post_type
  • register_post_type (2)
  • register_post_type $post_type
  • register_post_type $args
  • register_post_type $args (2)
  • register_post_type $args (3)
  • register_post_type $args (4)
  • register_post_type $args (5)
  • register_post_type $args (6)
  • register_post_type $args (7)
  • register_post_type $args (8)
  • register_post_type $args (9)
  • register_post_type $args (10)
  • register_post_type $args (11)
  • register_post_type $args (12)
  • register_post_type $args (13)
  • register_post_type $args (14)
  • register_post_type $args (15)
  • Too exhaustive but worth it
  • Practice Custom Post
  • Next Week
Page 53: WordPress plugin #3

register_post_type $args

labels more specific text labelsnamesigular_namemenu_namename_admin_barall_itemsadd_newadd_new_itemedit_itemview_itemsearch_items

search_itemsnot_foundnot_found in trashparent_item_colon

register_post_type $args

descriptionsummary of this post type

register_post_type $args

exclude_from_searchdo not search this post typetry S=beatbles

register_post_type $args

publicly_queryablecan use query

eg) post_type=music_collection

register_post_type $args

show_uidisplay default UI

register_post_type $args

show_in_nav_menusshow in navigation menus

be careful publicly_queryablemust be true

register_post_type $args

show_in_menushow admin_menu show_ui must be trueJust showing menutrue false else some strings

(toolsphp editphp)

altough it is falseyou can access URLS likewp-admineditphppost_type=music_collection(show_ui must be true)

register_post_type $args

show_in_admin_baravailable in admin bar

menu_postiondefault below comments

menu_iconsee dashicons

register_post_type $args

capability_typestring or array to build capabilites

in our exampeedit_music_collectionsedit_others_music_collections

publish_music_collectionsread_private_music_collections

register_post_type $args

capabilitiesto give specific names to each capability

map_meta_capif true default meta capability will be added

and then your role or account need capabilities

register_post_type $args

hierarchicalpost type can be hierarchicalthis is for page-styles

register_post_type $args

query_varto query posts query_var=slug

rewriteto use pretty permalinks

has_archiveEnables post type archive

register_post_type $args

permalink_epmaskrewrite endpoint bitmask

can_exporttrue makes the post can be exported

Too exhaustive but worth it

Practice Custom Post

Create custom-plugin-ltauthorgtphpCreate a simple custom post

Display admin menuHide admin_barWrite your post Any content is OK Include at least one meta field

Next Week

Customizing Visual Components List Table Screen Widgets

WordPress System Undercover Constants and Globals WPDB

  • WordPress Plugin 3
  • Recap
  • Recap (2)
  • Recap (3)
  • Recap (4)
  • Recap (5)
  • Todays Topics
  • Entry Points in Plugin
  • Entry Points
  • Entry Points (2)
  • Entry Points (3)
  • Entry Points (4)
  • Menu Items
  • Where is default menu
  • Where is default menu (2)
  • Our custom menus
  • add_menu_page
  • add_submenu_page
  • derivatives
  • Shortcodes
  • Shortcodes (2)
  • Shortcodes (3)
  • Shortcodes (4)
  • Shortcodes (5)
  • Shortcodes (6)
  • Admin-post
  • Admin-post (2)
  • Admin-post (3)
  • AJAX
  • Redirect
  • Redirect (2)
  • (de)activation uninstall
  • Summary
  • I know you want to do something
  • Slide 35
  • Source code explained
  • 10 minutes break
  • Managing Your Own Contents
  • Wow there are too many things about posts
  • For today just focuse on custom post type
  • Arguments are too complex
  • of course you might not want this I was just kidding
  • Custom Post
  • Custom Post Motivation
  • Custom Post Motivation (2)
  • Custom Post Motivation (3)
  • Built-in Custom Post Types
  • register_post_type
  • register_post_type (2)
  • register_post_type $post_type
  • register_post_type $args
  • register_post_type $args (2)
  • register_post_type $args (3)
  • register_post_type $args (4)
  • register_post_type $args (5)
  • register_post_type $args (6)
  • register_post_type $args (7)
  • register_post_type $args (8)
  • register_post_type $args (9)
  • register_post_type $args (10)
  • register_post_type $args (11)
  • register_post_type $args (12)
  • register_post_type $args (13)
  • register_post_type $args (14)
  • register_post_type $args (15)
  • Too exhaustive but worth it
  • Practice Custom Post
  • Next Week
Page 54: WordPress plugin #3

register_post_type $args

descriptionsummary of this post type

register_post_type $args

exclude_from_searchdo not search this post typetry S=beatbles

register_post_type $args

publicly_queryablecan use query

eg) post_type=music_collection

register_post_type $args

show_uidisplay default UI

register_post_type $args

show_in_nav_menusshow in navigation menus

be careful publicly_queryablemust be true

register_post_type $args

show_in_menushow admin_menu show_ui must be trueJust showing menutrue false else some strings

(toolsphp editphp)

altough it is falseyou can access URLS likewp-admineditphppost_type=music_collection(show_ui must be true)

register_post_type $args

show_in_admin_baravailable in admin bar

menu_postiondefault below comments

menu_iconsee dashicons

register_post_type $args

capability_typestring or array to build capabilites

in our exampeedit_music_collectionsedit_others_music_collections

publish_music_collectionsread_private_music_collections

register_post_type $args

capabilitiesto give specific names to each capability

map_meta_capif true default meta capability will be added

and then your role or account need capabilities

register_post_type $args

hierarchicalpost type can be hierarchicalthis is for page-styles

register_post_type $args

query_varto query posts query_var=slug

rewriteto use pretty permalinks

has_archiveEnables post type archive

register_post_type $args

permalink_epmaskrewrite endpoint bitmask

can_exporttrue makes the post can be exported

Too exhaustive but worth it

Practice Custom Post

Create custom-plugin-ltauthorgtphpCreate a simple custom post

Display admin menuHide admin_barWrite your post Any content is OK Include at least one meta field

Next Week

Customizing Visual Components List Table Screen Widgets

WordPress System Undercover Constants and Globals WPDB

  • WordPress Plugin 3
  • Recap
  • Recap (2)
  • Recap (3)
  • Recap (4)
  • Recap (5)
  • Todays Topics
  • Entry Points in Plugin
  • Entry Points
  • Entry Points (2)
  • Entry Points (3)
  • Entry Points (4)
  • Menu Items
  • Where is default menu
  • Where is default menu (2)
  • Our custom menus
  • add_menu_page
  • add_submenu_page
  • derivatives
  • Shortcodes
  • Shortcodes (2)
  • Shortcodes (3)
  • Shortcodes (4)
  • Shortcodes (5)
  • Shortcodes (6)
  • Admin-post
  • Admin-post (2)
  • Admin-post (3)
  • AJAX
  • Redirect
  • Redirect (2)
  • (de)activation uninstall
  • Summary
  • I know you want to do something
  • Slide 35
  • Source code explained
  • 10 minutes break
  • Managing Your Own Contents
  • Wow there are too many things about posts
  • For today just focuse on custom post type
  • Arguments are too complex
  • of course you might not want this I was just kidding
  • Custom Post
  • Custom Post Motivation
  • Custom Post Motivation (2)
  • Custom Post Motivation (3)
  • Built-in Custom Post Types
  • register_post_type
  • register_post_type (2)
  • register_post_type $post_type
  • register_post_type $args
  • register_post_type $args (2)
  • register_post_type $args (3)
  • register_post_type $args (4)
  • register_post_type $args (5)
  • register_post_type $args (6)
  • register_post_type $args (7)
  • register_post_type $args (8)
  • register_post_type $args (9)
  • register_post_type $args (10)
  • register_post_type $args (11)
  • register_post_type $args (12)
  • register_post_type $args (13)
  • register_post_type $args (14)
  • register_post_type $args (15)
  • Too exhaustive but worth it
  • Practice Custom Post
  • Next Week
Page 55: WordPress plugin #3

register_post_type $args

exclude_from_searchdo not search this post typetry S=beatbles

register_post_type $args

publicly_queryablecan use query

eg) post_type=music_collection

register_post_type $args

show_uidisplay default UI

register_post_type $args

show_in_nav_menusshow in navigation menus

be careful publicly_queryablemust be true

register_post_type $args

show_in_menushow admin_menu show_ui must be trueJust showing menutrue false else some strings

(toolsphp editphp)

altough it is falseyou can access URLS likewp-admineditphppost_type=music_collection(show_ui must be true)

register_post_type $args

show_in_admin_baravailable in admin bar

menu_postiondefault below comments

menu_iconsee dashicons

register_post_type $args

capability_typestring or array to build capabilites

in our exampeedit_music_collectionsedit_others_music_collections

publish_music_collectionsread_private_music_collections

register_post_type $args

capabilitiesto give specific names to each capability

map_meta_capif true default meta capability will be added

and then your role or account need capabilities

register_post_type $args

hierarchicalpost type can be hierarchicalthis is for page-styles

register_post_type $args

query_varto query posts query_var=slug

rewriteto use pretty permalinks

has_archiveEnables post type archive

register_post_type $args

permalink_epmaskrewrite endpoint bitmask

can_exporttrue makes the post can be exported

Too exhaustive but worth it

Practice Custom Post

Create custom-plugin-ltauthorgtphpCreate a simple custom post

Display admin menuHide admin_barWrite your post Any content is OK Include at least one meta field

Next Week

Customizing Visual Components List Table Screen Widgets

WordPress System Undercover Constants and Globals WPDB

  • WordPress Plugin 3
  • Recap
  • Recap (2)
  • Recap (3)
  • Recap (4)
  • Recap (5)
  • Todays Topics
  • Entry Points in Plugin
  • Entry Points
  • Entry Points (2)
  • Entry Points (3)
  • Entry Points (4)
  • Menu Items
  • Where is default menu
  • Where is default menu (2)
  • Our custom menus
  • add_menu_page
  • add_submenu_page
  • derivatives
  • Shortcodes
  • Shortcodes (2)
  • Shortcodes (3)
  • Shortcodes (4)
  • Shortcodes (5)
  • Shortcodes (6)
  • Admin-post
  • Admin-post (2)
  • Admin-post (3)
  • AJAX
  • Redirect
  • Redirect (2)
  • (de)activation uninstall
  • Summary
  • I know you want to do something
  • Slide 35
  • Source code explained
  • 10 minutes break
  • Managing Your Own Contents
  • Wow there are too many things about posts
  • For today just focuse on custom post type
  • Arguments are too complex
  • of course you might not want this I was just kidding
  • Custom Post
  • Custom Post Motivation
  • Custom Post Motivation (2)
  • Custom Post Motivation (3)
  • Built-in Custom Post Types
  • register_post_type
  • register_post_type (2)
  • register_post_type $post_type
  • register_post_type $args
  • register_post_type $args (2)
  • register_post_type $args (3)
  • register_post_type $args (4)
  • register_post_type $args (5)
  • register_post_type $args (6)
  • register_post_type $args (7)
  • register_post_type $args (8)
  • register_post_type $args (9)
  • register_post_type $args (10)
  • register_post_type $args (11)
  • register_post_type $args (12)
  • register_post_type $args (13)
  • register_post_type $args (14)
  • register_post_type $args (15)
  • Too exhaustive but worth it
  • Practice Custom Post
  • Next Week
Page 56: WordPress plugin #3

register_post_type $args

publicly_queryablecan use query

eg) post_type=music_collection

register_post_type $args

show_uidisplay default UI

register_post_type $args

show_in_nav_menusshow in navigation menus

be careful publicly_queryablemust be true

register_post_type $args

show_in_menushow admin_menu show_ui must be trueJust showing menutrue false else some strings

(toolsphp editphp)

altough it is falseyou can access URLS likewp-admineditphppost_type=music_collection(show_ui must be true)

register_post_type $args

show_in_admin_baravailable in admin bar

menu_postiondefault below comments

menu_iconsee dashicons

register_post_type $args

capability_typestring or array to build capabilites

in our exampeedit_music_collectionsedit_others_music_collections

publish_music_collectionsread_private_music_collections

register_post_type $args

capabilitiesto give specific names to each capability

map_meta_capif true default meta capability will be added

and then your role or account need capabilities

register_post_type $args

hierarchicalpost type can be hierarchicalthis is for page-styles

register_post_type $args

query_varto query posts query_var=slug

rewriteto use pretty permalinks

has_archiveEnables post type archive

register_post_type $args

permalink_epmaskrewrite endpoint bitmask

can_exporttrue makes the post can be exported

Too exhaustive but worth it

Practice Custom Post

Create custom-plugin-ltauthorgtphpCreate a simple custom post

Display admin menuHide admin_barWrite your post Any content is OK Include at least one meta field

Next Week

Customizing Visual Components List Table Screen Widgets

WordPress System Undercover Constants and Globals WPDB

  • WordPress Plugin 3
  • Recap
  • Recap (2)
  • Recap (3)
  • Recap (4)
  • Recap (5)
  • Todays Topics
  • Entry Points in Plugin
  • Entry Points
  • Entry Points (2)
  • Entry Points (3)
  • Entry Points (4)
  • Menu Items
  • Where is default menu
  • Where is default menu (2)
  • Our custom menus
  • add_menu_page
  • add_submenu_page
  • derivatives
  • Shortcodes
  • Shortcodes (2)
  • Shortcodes (3)
  • Shortcodes (4)
  • Shortcodes (5)
  • Shortcodes (6)
  • Admin-post
  • Admin-post (2)
  • Admin-post (3)
  • AJAX
  • Redirect
  • Redirect (2)
  • (de)activation uninstall
  • Summary
  • I know you want to do something
  • Slide 35
  • Source code explained
  • 10 minutes break
  • Managing Your Own Contents
  • Wow there are too many things about posts
  • For today just focuse on custom post type
  • Arguments are too complex
  • of course you might not want this I was just kidding
  • Custom Post
  • Custom Post Motivation
  • Custom Post Motivation (2)
  • Custom Post Motivation (3)
  • Built-in Custom Post Types
  • register_post_type
  • register_post_type (2)
  • register_post_type $post_type
  • register_post_type $args
  • register_post_type $args (2)
  • register_post_type $args (3)
  • register_post_type $args (4)
  • register_post_type $args (5)
  • register_post_type $args (6)
  • register_post_type $args (7)
  • register_post_type $args (8)
  • register_post_type $args (9)
  • register_post_type $args (10)
  • register_post_type $args (11)
  • register_post_type $args (12)
  • register_post_type $args (13)
  • register_post_type $args (14)
  • register_post_type $args (15)
  • Too exhaustive but worth it
  • Practice Custom Post
  • Next Week
Page 57: WordPress plugin #3

register_post_type $args

show_uidisplay default UI

register_post_type $args

show_in_nav_menusshow in navigation menus

be careful publicly_queryablemust be true

register_post_type $args

show_in_menushow admin_menu show_ui must be trueJust showing menutrue false else some strings

(toolsphp editphp)

altough it is falseyou can access URLS likewp-admineditphppost_type=music_collection(show_ui must be true)

register_post_type $args

show_in_admin_baravailable in admin bar

menu_postiondefault below comments

menu_iconsee dashicons

register_post_type $args

capability_typestring or array to build capabilites

in our exampeedit_music_collectionsedit_others_music_collections

publish_music_collectionsread_private_music_collections

register_post_type $args

capabilitiesto give specific names to each capability

map_meta_capif true default meta capability will be added

and then your role or account need capabilities

register_post_type $args

hierarchicalpost type can be hierarchicalthis is for page-styles

register_post_type $args

query_varto query posts query_var=slug

rewriteto use pretty permalinks

has_archiveEnables post type archive

register_post_type $args

permalink_epmaskrewrite endpoint bitmask

can_exporttrue makes the post can be exported

Too exhaustive but worth it

Practice Custom Post

Create custom-plugin-ltauthorgtphpCreate a simple custom post

Display admin menuHide admin_barWrite your post Any content is OK Include at least one meta field

Next Week

Customizing Visual Components List Table Screen Widgets

WordPress System Undercover Constants and Globals WPDB

  • WordPress Plugin 3
  • Recap
  • Recap (2)
  • Recap (3)
  • Recap (4)
  • Recap (5)
  • Todays Topics
  • Entry Points in Plugin
  • Entry Points
  • Entry Points (2)
  • Entry Points (3)
  • Entry Points (4)
  • Menu Items
  • Where is default menu
  • Where is default menu (2)
  • Our custom menus
  • add_menu_page
  • add_submenu_page
  • derivatives
  • Shortcodes
  • Shortcodes (2)
  • Shortcodes (3)
  • Shortcodes (4)
  • Shortcodes (5)
  • Shortcodes (6)
  • Admin-post
  • Admin-post (2)
  • Admin-post (3)
  • AJAX
  • Redirect
  • Redirect (2)
  • (de)activation uninstall
  • Summary
  • I know you want to do something
  • Slide 35
  • Source code explained
  • 10 minutes break
  • Managing Your Own Contents
  • Wow there are too many things about posts
  • For today just focuse on custom post type
  • Arguments are too complex
  • of course you might not want this I was just kidding
  • Custom Post
  • Custom Post Motivation
  • Custom Post Motivation (2)
  • Custom Post Motivation (3)
  • Built-in Custom Post Types
  • register_post_type
  • register_post_type (2)
  • register_post_type $post_type
  • register_post_type $args
  • register_post_type $args (2)
  • register_post_type $args (3)
  • register_post_type $args (4)
  • register_post_type $args (5)
  • register_post_type $args (6)
  • register_post_type $args (7)
  • register_post_type $args (8)
  • register_post_type $args (9)
  • register_post_type $args (10)
  • register_post_type $args (11)
  • register_post_type $args (12)
  • register_post_type $args (13)
  • register_post_type $args (14)
  • register_post_type $args (15)
  • Too exhaustive but worth it
  • Practice Custom Post
  • Next Week
Page 58: WordPress plugin #3

register_post_type $args

show_in_nav_menusshow in navigation menus

be careful publicly_queryablemust be true

register_post_type $args

show_in_menushow admin_menu show_ui must be trueJust showing menutrue false else some strings

(toolsphp editphp)

altough it is falseyou can access URLS likewp-admineditphppost_type=music_collection(show_ui must be true)

register_post_type $args

show_in_admin_baravailable in admin bar

menu_postiondefault below comments

menu_iconsee dashicons

register_post_type $args

capability_typestring or array to build capabilites

in our exampeedit_music_collectionsedit_others_music_collections

publish_music_collectionsread_private_music_collections

register_post_type $args

capabilitiesto give specific names to each capability

map_meta_capif true default meta capability will be added

and then your role or account need capabilities

register_post_type $args

hierarchicalpost type can be hierarchicalthis is for page-styles

register_post_type $args

query_varto query posts query_var=slug

rewriteto use pretty permalinks

has_archiveEnables post type archive

register_post_type $args

permalink_epmaskrewrite endpoint bitmask

can_exporttrue makes the post can be exported

Too exhaustive but worth it

Practice Custom Post

Create custom-plugin-ltauthorgtphpCreate a simple custom post

Display admin menuHide admin_barWrite your post Any content is OK Include at least one meta field

Next Week

Customizing Visual Components List Table Screen Widgets

WordPress System Undercover Constants and Globals WPDB

  • WordPress Plugin 3
  • Recap
  • Recap (2)
  • Recap (3)
  • Recap (4)
  • Recap (5)
  • Todays Topics
  • Entry Points in Plugin
  • Entry Points
  • Entry Points (2)
  • Entry Points (3)
  • Entry Points (4)
  • Menu Items
  • Where is default menu
  • Where is default menu (2)
  • Our custom menus
  • add_menu_page
  • add_submenu_page
  • derivatives
  • Shortcodes
  • Shortcodes (2)
  • Shortcodes (3)
  • Shortcodes (4)
  • Shortcodes (5)
  • Shortcodes (6)
  • Admin-post
  • Admin-post (2)
  • Admin-post (3)
  • AJAX
  • Redirect
  • Redirect (2)
  • (de)activation uninstall
  • Summary
  • I know you want to do something
  • Slide 35
  • Source code explained
  • 10 minutes break
  • Managing Your Own Contents
  • Wow there are too many things about posts
  • For today just focuse on custom post type
  • Arguments are too complex
  • of course you might not want this I was just kidding
  • Custom Post
  • Custom Post Motivation
  • Custom Post Motivation (2)
  • Custom Post Motivation (3)
  • Built-in Custom Post Types
  • register_post_type
  • register_post_type (2)
  • register_post_type $post_type
  • register_post_type $args
  • register_post_type $args (2)
  • register_post_type $args (3)
  • register_post_type $args (4)
  • register_post_type $args (5)
  • register_post_type $args (6)
  • register_post_type $args (7)
  • register_post_type $args (8)
  • register_post_type $args (9)
  • register_post_type $args (10)
  • register_post_type $args (11)
  • register_post_type $args (12)
  • register_post_type $args (13)
  • register_post_type $args (14)
  • register_post_type $args (15)
  • Too exhaustive but worth it
  • Practice Custom Post
  • Next Week
Page 59: WordPress plugin #3

register_post_type $args

show_in_menushow admin_menu show_ui must be trueJust showing menutrue false else some strings

(toolsphp editphp)

altough it is falseyou can access URLS likewp-admineditphppost_type=music_collection(show_ui must be true)

register_post_type $args

show_in_admin_baravailable in admin bar

menu_postiondefault below comments

menu_iconsee dashicons

register_post_type $args

capability_typestring or array to build capabilites

in our exampeedit_music_collectionsedit_others_music_collections

publish_music_collectionsread_private_music_collections

register_post_type $args

capabilitiesto give specific names to each capability

map_meta_capif true default meta capability will be added

and then your role or account need capabilities

register_post_type $args

hierarchicalpost type can be hierarchicalthis is for page-styles

register_post_type $args

query_varto query posts query_var=slug

rewriteto use pretty permalinks

has_archiveEnables post type archive

register_post_type $args

permalink_epmaskrewrite endpoint bitmask

can_exporttrue makes the post can be exported

Too exhaustive but worth it

Practice Custom Post

Create custom-plugin-ltauthorgtphpCreate a simple custom post

Display admin menuHide admin_barWrite your post Any content is OK Include at least one meta field

Next Week

Customizing Visual Components List Table Screen Widgets

WordPress System Undercover Constants and Globals WPDB

  • WordPress Plugin 3
  • Recap
  • Recap (2)
  • Recap (3)
  • Recap (4)
  • Recap (5)
  • Todays Topics
  • Entry Points in Plugin
  • Entry Points
  • Entry Points (2)
  • Entry Points (3)
  • Entry Points (4)
  • Menu Items
  • Where is default menu
  • Where is default menu (2)
  • Our custom menus
  • add_menu_page
  • add_submenu_page
  • derivatives
  • Shortcodes
  • Shortcodes (2)
  • Shortcodes (3)
  • Shortcodes (4)
  • Shortcodes (5)
  • Shortcodes (6)
  • Admin-post
  • Admin-post (2)
  • Admin-post (3)
  • AJAX
  • Redirect
  • Redirect (2)
  • (de)activation uninstall
  • Summary
  • I know you want to do something
  • Slide 35
  • Source code explained
  • 10 minutes break
  • Managing Your Own Contents
  • Wow there are too many things about posts
  • For today just focuse on custom post type
  • Arguments are too complex
  • of course you might not want this I was just kidding
  • Custom Post
  • Custom Post Motivation
  • Custom Post Motivation (2)
  • Custom Post Motivation (3)
  • Built-in Custom Post Types
  • register_post_type
  • register_post_type (2)
  • register_post_type $post_type
  • register_post_type $args
  • register_post_type $args (2)
  • register_post_type $args (3)
  • register_post_type $args (4)
  • register_post_type $args (5)
  • register_post_type $args (6)
  • register_post_type $args (7)
  • register_post_type $args (8)
  • register_post_type $args (9)
  • register_post_type $args (10)
  • register_post_type $args (11)
  • register_post_type $args (12)
  • register_post_type $args (13)
  • register_post_type $args (14)
  • register_post_type $args (15)
  • Too exhaustive but worth it
  • Practice Custom Post
  • Next Week
Page 60: WordPress plugin #3

register_post_type $args

show_in_admin_baravailable in admin bar

menu_postiondefault below comments

menu_iconsee dashicons

register_post_type $args

capability_typestring or array to build capabilites

in our exampeedit_music_collectionsedit_others_music_collections

publish_music_collectionsread_private_music_collections

register_post_type $args

capabilitiesto give specific names to each capability

map_meta_capif true default meta capability will be added

and then your role or account need capabilities

register_post_type $args

hierarchicalpost type can be hierarchicalthis is for page-styles

register_post_type $args

query_varto query posts query_var=slug

rewriteto use pretty permalinks

has_archiveEnables post type archive

register_post_type $args

permalink_epmaskrewrite endpoint bitmask

can_exporttrue makes the post can be exported

Too exhaustive but worth it

Practice Custom Post

Create custom-plugin-ltauthorgtphpCreate a simple custom post

Display admin menuHide admin_barWrite your post Any content is OK Include at least one meta field

Next Week

Customizing Visual Components List Table Screen Widgets

WordPress System Undercover Constants and Globals WPDB

  • WordPress Plugin 3
  • Recap
  • Recap (2)
  • Recap (3)
  • Recap (4)
  • Recap (5)
  • Todays Topics
  • Entry Points in Plugin
  • Entry Points
  • Entry Points (2)
  • Entry Points (3)
  • Entry Points (4)
  • Menu Items
  • Where is default menu
  • Where is default menu (2)
  • Our custom menus
  • add_menu_page
  • add_submenu_page
  • derivatives
  • Shortcodes
  • Shortcodes (2)
  • Shortcodes (3)
  • Shortcodes (4)
  • Shortcodes (5)
  • Shortcodes (6)
  • Admin-post
  • Admin-post (2)
  • Admin-post (3)
  • AJAX
  • Redirect
  • Redirect (2)
  • (de)activation uninstall
  • Summary
  • I know you want to do something
  • Slide 35
  • Source code explained
  • 10 minutes break
  • Managing Your Own Contents
  • Wow there are too many things about posts
  • For today just focuse on custom post type
  • Arguments are too complex
  • of course you might not want this I was just kidding
  • Custom Post
  • Custom Post Motivation
  • Custom Post Motivation (2)
  • Custom Post Motivation (3)
  • Built-in Custom Post Types
  • register_post_type
  • register_post_type (2)
  • register_post_type $post_type
  • register_post_type $args
  • register_post_type $args (2)
  • register_post_type $args (3)
  • register_post_type $args (4)
  • register_post_type $args (5)
  • register_post_type $args (6)
  • register_post_type $args (7)
  • register_post_type $args (8)
  • register_post_type $args (9)
  • register_post_type $args (10)
  • register_post_type $args (11)
  • register_post_type $args (12)
  • register_post_type $args (13)
  • register_post_type $args (14)
  • register_post_type $args (15)
  • Too exhaustive but worth it
  • Practice Custom Post
  • Next Week
Page 61: WordPress plugin #3

register_post_type $args

capability_typestring or array to build capabilites

in our exampeedit_music_collectionsedit_others_music_collections

publish_music_collectionsread_private_music_collections

register_post_type $args

capabilitiesto give specific names to each capability

map_meta_capif true default meta capability will be added

and then your role or account need capabilities

register_post_type $args

hierarchicalpost type can be hierarchicalthis is for page-styles

register_post_type $args

query_varto query posts query_var=slug

rewriteto use pretty permalinks

has_archiveEnables post type archive

register_post_type $args

permalink_epmaskrewrite endpoint bitmask

can_exporttrue makes the post can be exported

Too exhaustive but worth it

Practice Custom Post

Create custom-plugin-ltauthorgtphpCreate a simple custom post

Display admin menuHide admin_barWrite your post Any content is OK Include at least one meta field

Next Week

Customizing Visual Components List Table Screen Widgets

WordPress System Undercover Constants and Globals WPDB

  • WordPress Plugin 3
  • Recap
  • Recap (2)
  • Recap (3)
  • Recap (4)
  • Recap (5)
  • Todays Topics
  • Entry Points in Plugin
  • Entry Points
  • Entry Points (2)
  • Entry Points (3)
  • Entry Points (4)
  • Menu Items
  • Where is default menu
  • Where is default menu (2)
  • Our custom menus
  • add_menu_page
  • add_submenu_page
  • derivatives
  • Shortcodes
  • Shortcodes (2)
  • Shortcodes (3)
  • Shortcodes (4)
  • Shortcodes (5)
  • Shortcodes (6)
  • Admin-post
  • Admin-post (2)
  • Admin-post (3)
  • AJAX
  • Redirect
  • Redirect (2)
  • (de)activation uninstall
  • Summary
  • I know you want to do something
  • Slide 35
  • Source code explained
  • 10 minutes break
  • Managing Your Own Contents
  • Wow there are too many things about posts
  • For today just focuse on custom post type
  • Arguments are too complex
  • of course you might not want this I was just kidding
  • Custom Post
  • Custom Post Motivation
  • Custom Post Motivation (2)
  • Custom Post Motivation (3)
  • Built-in Custom Post Types
  • register_post_type
  • register_post_type (2)
  • register_post_type $post_type
  • register_post_type $args
  • register_post_type $args (2)
  • register_post_type $args (3)
  • register_post_type $args (4)
  • register_post_type $args (5)
  • register_post_type $args (6)
  • register_post_type $args (7)
  • register_post_type $args (8)
  • register_post_type $args (9)
  • register_post_type $args (10)
  • register_post_type $args (11)
  • register_post_type $args (12)
  • register_post_type $args (13)
  • register_post_type $args (14)
  • register_post_type $args (15)
  • Too exhaustive but worth it
  • Practice Custom Post
  • Next Week
Page 62: WordPress plugin #3

register_post_type $args

capabilitiesto give specific names to each capability

map_meta_capif true default meta capability will be added

and then your role or account need capabilities

register_post_type $args

hierarchicalpost type can be hierarchicalthis is for page-styles

register_post_type $args

query_varto query posts query_var=slug

rewriteto use pretty permalinks

has_archiveEnables post type archive

register_post_type $args

permalink_epmaskrewrite endpoint bitmask

can_exporttrue makes the post can be exported

Too exhaustive but worth it

Practice Custom Post

Create custom-plugin-ltauthorgtphpCreate a simple custom post

Display admin menuHide admin_barWrite your post Any content is OK Include at least one meta field

Next Week

Customizing Visual Components List Table Screen Widgets

WordPress System Undercover Constants and Globals WPDB

  • WordPress Plugin 3
  • Recap
  • Recap (2)
  • Recap (3)
  • Recap (4)
  • Recap (5)
  • Todays Topics
  • Entry Points in Plugin
  • Entry Points
  • Entry Points (2)
  • Entry Points (3)
  • Entry Points (4)
  • Menu Items
  • Where is default menu
  • Where is default menu (2)
  • Our custom menus
  • add_menu_page
  • add_submenu_page
  • derivatives
  • Shortcodes
  • Shortcodes (2)
  • Shortcodes (3)
  • Shortcodes (4)
  • Shortcodes (5)
  • Shortcodes (6)
  • Admin-post
  • Admin-post (2)
  • Admin-post (3)
  • AJAX
  • Redirect
  • Redirect (2)
  • (de)activation uninstall
  • Summary
  • I know you want to do something
  • Slide 35
  • Source code explained
  • 10 minutes break
  • Managing Your Own Contents
  • Wow there are too many things about posts
  • For today just focuse on custom post type
  • Arguments are too complex
  • of course you might not want this I was just kidding
  • Custom Post
  • Custom Post Motivation
  • Custom Post Motivation (2)
  • Custom Post Motivation (3)
  • Built-in Custom Post Types
  • register_post_type
  • register_post_type (2)
  • register_post_type $post_type
  • register_post_type $args
  • register_post_type $args (2)
  • register_post_type $args (3)
  • register_post_type $args (4)
  • register_post_type $args (5)
  • register_post_type $args (6)
  • register_post_type $args (7)
  • register_post_type $args (8)
  • register_post_type $args (9)
  • register_post_type $args (10)
  • register_post_type $args (11)
  • register_post_type $args (12)
  • register_post_type $args (13)
  • register_post_type $args (14)
  • register_post_type $args (15)
  • Too exhaustive but worth it
  • Practice Custom Post
  • Next Week
Page 63: WordPress plugin #3

register_post_type $args

hierarchicalpost type can be hierarchicalthis is for page-styles

register_post_type $args

query_varto query posts query_var=slug

rewriteto use pretty permalinks

has_archiveEnables post type archive

register_post_type $args

permalink_epmaskrewrite endpoint bitmask

can_exporttrue makes the post can be exported

Too exhaustive but worth it

Practice Custom Post

Create custom-plugin-ltauthorgtphpCreate a simple custom post

Display admin menuHide admin_barWrite your post Any content is OK Include at least one meta field

Next Week

Customizing Visual Components List Table Screen Widgets

WordPress System Undercover Constants and Globals WPDB

  • WordPress Plugin 3
  • Recap
  • Recap (2)
  • Recap (3)
  • Recap (4)
  • Recap (5)
  • Todays Topics
  • Entry Points in Plugin
  • Entry Points
  • Entry Points (2)
  • Entry Points (3)
  • Entry Points (4)
  • Menu Items
  • Where is default menu
  • Where is default menu (2)
  • Our custom menus
  • add_menu_page
  • add_submenu_page
  • derivatives
  • Shortcodes
  • Shortcodes (2)
  • Shortcodes (3)
  • Shortcodes (4)
  • Shortcodes (5)
  • Shortcodes (6)
  • Admin-post
  • Admin-post (2)
  • Admin-post (3)
  • AJAX
  • Redirect
  • Redirect (2)
  • (de)activation uninstall
  • Summary
  • I know you want to do something
  • Slide 35
  • Source code explained
  • 10 minutes break
  • Managing Your Own Contents
  • Wow there are too many things about posts
  • For today just focuse on custom post type
  • Arguments are too complex
  • of course you might not want this I was just kidding
  • Custom Post
  • Custom Post Motivation
  • Custom Post Motivation (2)
  • Custom Post Motivation (3)
  • Built-in Custom Post Types
  • register_post_type
  • register_post_type (2)
  • register_post_type $post_type
  • register_post_type $args
  • register_post_type $args (2)
  • register_post_type $args (3)
  • register_post_type $args (4)
  • register_post_type $args (5)
  • register_post_type $args (6)
  • register_post_type $args (7)
  • register_post_type $args (8)
  • register_post_type $args (9)
  • register_post_type $args (10)
  • register_post_type $args (11)
  • register_post_type $args (12)
  • register_post_type $args (13)
  • register_post_type $args (14)
  • register_post_type $args (15)
  • Too exhaustive but worth it
  • Practice Custom Post
  • Next Week
Page 64: WordPress plugin #3

register_post_type $args

query_varto query posts query_var=slug

rewriteto use pretty permalinks

has_archiveEnables post type archive

register_post_type $args

permalink_epmaskrewrite endpoint bitmask

can_exporttrue makes the post can be exported

Too exhaustive but worth it

Practice Custom Post

Create custom-plugin-ltauthorgtphpCreate a simple custom post

Display admin menuHide admin_barWrite your post Any content is OK Include at least one meta field

Next Week

Customizing Visual Components List Table Screen Widgets

WordPress System Undercover Constants and Globals WPDB

  • WordPress Plugin 3
  • Recap
  • Recap (2)
  • Recap (3)
  • Recap (4)
  • Recap (5)
  • Todays Topics
  • Entry Points in Plugin
  • Entry Points
  • Entry Points (2)
  • Entry Points (3)
  • Entry Points (4)
  • Menu Items
  • Where is default menu
  • Where is default menu (2)
  • Our custom menus
  • add_menu_page
  • add_submenu_page
  • derivatives
  • Shortcodes
  • Shortcodes (2)
  • Shortcodes (3)
  • Shortcodes (4)
  • Shortcodes (5)
  • Shortcodes (6)
  • Admin-post
  • Admin-post (2)
  • Admin-post (3)
  • AJAX
  • Redirect
  • Redirect (2)
  • (de)activation uninstall
  • Summary
  • I know you want to do something
  • Slide 35
  • Source code explained
  • 10 minutes break
  • Managing Your Own Contents
  • Wow there are too many things about posts
  • For today just focuse on custom post type
  • Arguments are too complex
  • of course you might not want this I was just kidding
  • Custom Post
  • Custom Post Motivation
  • Custom Post Motivation (2)
  • Custom Post Motivation (3)
  • Built-in Custom Post Types
  • register_post_type
  • register_post_type (2)
  • register_post_type $post_type
  • register_post_type $args
  • register_post_type $args (2)
  • register_post_type $args (3)
  • register_post_type $args (4)
  • register_post_type $args (5)
  • register_post_type $args (6)
  • register_post_type $args (7)
  • register_post_type $args (8)
  • register_post_type $args (9)
  • register_post_type $args (10)
  • register_post_type $args (11)
  • register_post_type $args (12)
  • register_post_type $args (13)
  • register_post_type $args (14)
  • register_post_type $args (15)
  • Too exhaustive but worth it
  • Practice Custom Post
  • Next Week
Page 65: WordPress plugin #3

register_post_type $args

permalink_epmaskrewrite endpoint bitmask

can_exporttrue makes the post can be exported

Too exhaustive but worth it

Practice Custom Post

Create custom-plugin-ltauthorgtphpCreate a simple custom post

Display admin menuHide admin_barWrite your post Any content is OK Include at least one meta field

Next Week

Customizing Visual Components List Table Screen Widgets

WordPress System Undercover Constants and Globals WPDB

  • WordPress Plugin 3
  • Recap
  • Recap (2)
  • Recap (3)
  • Recap (4)
  • Recap (5)
  • Todays Topics
  • Entry Points in Plugin
  • Entry Points
  • Entry Points (2)
  • Entry Points (3)
  • Entry Points (4)
  • Menu Items
  • Where is default menu
  • Where is default menu (2)
  • Our custom menus
  • add_menu_page
  • add_submenu_page
  • derivatives
  • Shortcodes
  • Shortcodes (2)
  • Shortcodes (3)
  • Shortcodes (4)
  • Shortcodes (5)
  • Shortcodes (6)
  • Admin-post
  • Admin-post (2)
  • Admin-post (3)
  • AJAX
  • Redirect
  • Redirect (2)
  • (de)activation uninstall
  • Summary
  • I know you want to do something
  • Slide 35
  • Source code explained
  • 10 minutes break
  • Managing Your Own Contents
  • Wow there are too many things about posts
  • For today just focuse on custom post type
  • Arguments are too complex
  • of course you might not want this I was just kidding
  • Custom Post
  • Custom Post Motivation
  • Custom Post Motivation (2)
  • Custom Post Motivation (3)
  • Built-in Custom Post Types
  • register_post_type
  • register_post_type (2)
  • register_post_type $post_type
  • register_post_type $args
  • register_post_type $args (2)
  • register_post_type $args (3)
  • register_post_type $args (4)
  • register_post_type $args (5)
  • register_post_type $args (6)
  • register_post_type $args (7)
  • register_post_type $args (8)
  • register_post_type $args (9)
  • register_post_type $args (10)
  • register_post_type $args (11)
  • register_post_type $args (12)
  • register_post_type $args (13)
  • register_post_type $args (14)
  • register_post_type $args (15)
  • Too exhaustive but worth it
  • Practice Custom Post
  • Next Week
Page 66: WordPress plugin #3

Too exhaustive but worth it

Practice Custom Post

Create custom-plugin-ltauthorgtphpCreate a simple custom post

Display admin menuHide admin_barWrite your post Any content is OK Include at least one meta field

Next Week

Customizing Visual Components List Table Screen Widgets

WordPress System Undercover Constants and Globals WPDB

  • WordPress Plugin 3
  • Recap
  • Recap (2)
  • Recap (3)
  • Recap (4)
  • Recap (5)
  • Todays Topics
  • Entry Points in Plugin
  • Entry Points
  • Entry Points (2)
  • Entry Points (3)
  • Entry Points (4)
  • Menu Items
  • Where is default menu
  • Where is default menu (2)
  • Our custom menus
  • add_menu_page
  • add_submenu_page
  • derivatives
  • Shortcodes
  • Shortcodes (2)
  • Shortcodes (3)
  • Shortcodes (4)
  • Shortcodes (5)
  • Shortcodes (6)
  • Admin-post
  • Admin-post (2)
  • Admin-post (3)
  • AJAX
  • Redirect
  • Redirect (2)
  • (de)activation uninstall
  • Summary
  • I know you want to do something
  • Slide 35
  • Source code explained
  • 10 minutes break
  • Managing Your Own Contents
  • Wow there are too many things about posts
  • For today just focuse on custom post type
  • Arguments are too complex
  • of course you might not want this I was just kidding
  • Custom Post
  • Custom Post Motivation
  • Custom Post Motivation (2)
  • Custom Post Motivation (3)
  • Built-in Custom Post Types
  • register_post_type
  • register_post_type (2)
  • register_post_type $post_type
  • register_post_type $args
  • register_post_type $args (2)
  • register_post_type $args (3)
  • register_post_type $args (4)
  • register_post_type $args (5)
  • register_post_type $args (6)
  • register_post_type $args (7)
  • register_post_type $args (8)
  • register_post_type $args (9)
  • register_post_type $args (10)
  • register_post_type $args (11)
  • register_post_type $args (12)
  • register_post_type $args (13)
  • register_post_type $args (14)
  • register_post_type $args (15)
  • Too exhaustive but worth it
  • Practice Custom Post
  • Next Week
Page 67: WordPress plugin #3

Practice Custom Post

Create custom-plugin-ltauthorgtphpCreate a simple custom post

Display admin menuHide admin_barWrite your post Any content is OK Include at least one meta field

Next Week

Customizing Visual Components List Table Screen Widgets

WordPress System Undercover Constants and Globals WPDB

  • WordPress Plugin 3
  • Recap
  • Recap (2)
  • Recap (3)
  • Recap (4)
  • Recap (5)
  • Todays Topics
  • Entry Points in Plugin
  • Entry Points
  • Entry Points (2)
  • Entry Points (3)
  • Entry Points (4)
  • Menu Items
  • Where is default menu
  • Where is default menu (2)
  • Our custom menus
  • add_menu_page
  • add_submenu_page
  • derivatives
  • Shortcodes
  • Shortcodes (2)
  • Shortcodes (3)
  • Shortcodes (4)
  • Shortcodes (5)
  • Shortcodes (6)
  • Admin-post
  • Admin-post (2)
  • Admin-post (3)
  • AJAX
  • Redirect
  • Redirect (2)
  • (de)activation uninstall
  • Summary
  • I know you want to do something
  • Slide 35
  • Source code explained
  • 10 minutes break
  • Managing Your Own Contents
  • Wow there are too many things about posts
  • For today just focuse on custom post type
  • Arguments are too complex
  • of course you might not want this I was just kidding
  • Custom Post
  • Custom Post Motivation
  • Custom Post Motivation (2)
  • Custom Post Motivation (3)
  • Built-in Custom Post Types
  • register_post_type
  • register_post_type (2)
  • register_post_type $post_type
  • register_post_type $args
  • register_post_type $args (2)
  • register_post_type $args (3)
  • register_post_type $args (4)
  • register_post_type $args (5)
  • register_post_type $args (6)
  • register_post_type $args (7)
  • register_post_type $args (8)
  • register_post_type $args (9)
  • register_post_type $args (10)
  • register_post_type $args (11)
  • register_post_type $args (12)
  • register_post_type $args (13)
  • register_post_type $args (14)
  • register_post_type $args (15)
  • Too exhaustive but worth it
  • Practice Custom Post
  • Next Week
Page 68: WordPress plugin #3

Next Week

Customizing Visual Components List Table Screen Widgets

WordPress System Undercover Constants and Globals WPDB

  • WordPress Plugin 3
  • Recap
  • Recap (2)
  • Recap (3)
  • Recap (4)
  • Recap (5)
  • Todays Topics
  • Entry Points in Plugin
  • Entry Points
  • Entry Points (2)
  • Entry Points (3)
  • Entry Points (4)
  • Menu Items
  • Where is default menu
  • Where is default menu (2)
  • Our custom menus
  • add_menu_page
  • add_submenu_page
  • derivatives
  • Shortcodes
  • Shortcodes (2)
  • Shortcodes (3)
  • Shortcodes (4)
  • Shortcodes (5)
  • Shortcodes (6)
  • Admin-post
  • Admin-post (2)
  • Admin-post (3)
  • AJAX
  • Redirect
  • Redirect (2)
  • (de)activation uninstall
  • Summary
  • I know you want to do something
  • Slide 35
  • Source code explained
  • 10 minutes break
  • Managing Your Own Contents
  • Wow there are too many things about posts
  • For today just focuse on custom post type
  • Arguments are too complex
  • of course you might not want this I was just kidding
  • Custom Post
  • Custom Post Motivation
  • Custom Post Motivation (2)
  • Custom Post Motivation (3)
  • Built-in Custom Post Types
  • register_post_type
  • register_post_type (2)
  • register_post_type $post_type
  • register_post_type $args
  • register_post_type $args (2)
  • register_post_type $args (3)
  • register_post_type $args (4)
  • register_post_type $args (5)
  • register_post_type $args (6)
  • register_post_type $args (7)
  • register_post_type $args (8)
  • register_post_type $args (9)
  • register_post_type $args (10)
  • register_post_type $args (11)
  • register_post_type $args (12)
  • register_post_type $args (13)
  • register_post_type $args (14)
  • register_post_type $args (15)
  • Too exhaustive but worth it
  • Practice Custom Post
  • Next Week