2008-05-08 19:25:07 +02:00
< ? php
2008-08-16 09:27:34 +02:00
/**
* Post advanced form for inclusion in the administration panels .
*
* @ package WordPress
* @ subpackage Administration
*/
2008-05-08 19:25:07 +02:00
2009-08-03 02:04:45 +02:00
// don't load directly
if ( ! defined ( 'ABSPATH' ) )
die ( '-1' );
2015-05-28 23:41:30 +02:00
/**
* @ global string $post_type
* @ global object $post_type_object
* @ global WP_Post $post
*/
2015-01-10 06:29:22 +01:00
global $post_type , $post_type_object , $post ;
2010-04-16 16:03:48 +02:00
wp_enqueue_script ( 'post' );
2014-11-26 03:50:24 +01:00
$_wp_editor_expand = $_content_editor_dfw = false ;
2014-07-10 21:36:15 +02:00
2014-08-29 04:38:16 +02:00
/**
* Filter whether to enable the 'expand' functionality in the post editor .
*
* @ since 4.0 . 0
2014-11-30 10:51:23 +01:00
* @ since 4.1 . 0 Added the `$post_type` parameter .
2014-08-29 04:38:16 +02:00
*
2014-11-30 10:51:23 +01:00
* @ param bool $expand Whether to enable the 'expand' functionality . Default true .
2014-11-30 07:37:21 +01:00
* @ param string $post_type Post type .
2014-08-29 04:38:16 +02:00
*/
2014-07-16 00:37:14 +02:00
if ( post_type_supports ( $post_type , 'editor' ) && ! wp_is_mobile () &&
2014-08-29 04:28:18 +02:00
! ( $is_IE && preg_match ( '/MSIE [5678]/' , $_SERVER [ 'HTTP_USER_AGENT' ] ) ) &&
2014-11-30 07:37:21 +01:00
apply_filters ( 'wp_editor_expand' , true , $post_type ) ) {
2014-07-16 00:37:14 +02:00
2014-07-10 21:36:15 +02:00
wp_enqueue_script ( 'editor-expand' );
2014-11-26 03:50:24 +01:00
$_content_editor_dfw = true ;
2014-08-29 04:28:18 +02:00
$_wp_editor_expand = ( get_user_setting ( 'editor_expand' , 'on' ) === 'on' );
2014-07-10 21:36:15 +02:00
}
2010-04-16 16:03:48 +02:00
2012-04-11 04:20:51 +02:00
if ( wp_is_mobile () )
wp_enqueue_script ( 'jquery-touch-punch' );
2008-08-16 09:27:34 +02:00
/**
* Post ID global
* @ name $post_ID
* @ var int
*/
2009-02-02 04:41:19 +01:00
$post_ID = isset ( $post_ID ) ? ( int ) $post_ID : 0 ;
2010-01-11 22:42:45 +01:00
$user_ID = isset ( $user_ID ) ? ( int ) $user_ID : 0 ;
2008-05-08 19:25:07 +02:00
$action = isset ( $action ) ? $action : '' ;
2009-10-11 02:37:26 +02:00
2015-02-26 03:47:25 +01:00
if ( $post_ID == get_option ( 'page_for_posts' ) && empty ( $post -> post_content ) ) {
add_action ( 'edit_form_after_title' , '_wp_posts_page_notice' );
remove_post_type_support ( $post_type , 'editor' );
}
2014-04-08 19:40:28 +02:00
$thumbnail_support = current_theme_supports ( 'post-thumbnails' , $post_type ) && post_type_supports ( $post_type , 'thumbnail' );
if ( ! $thumbnail_support && 'attachment' === $post_type && $post -> post_mime_type ) {
2015-03-06 21:26:26 +01:00
if ( wp_attachment_is ( 'audio' , $post ) ) {
2014-04-08 19:40:28 +02:00
$thumbnail_support = post_type_supports ( 'attachment:audio' , 'thumbnail' ) || current_theme_supports ( 'post-thumbnails' , 'attachment:audio' );
2015-03-06 21:26:26 +01:00
} elseif ( wp_attachment_is ( 'video' , $post ) ) {
2014-04-08 19:40:28 +02:00
$thumbnail_support = post_type_supports ( 'attachment:video' , 'thumbnail' ) || current_theme_supports ( 'post-thumbnails' , 'attachment:video' );
}
}
2014-02-20 18:50:13 +01:00
2014-04-08 19:40:28 +02:00
if ( $thumbnail_support ) {
2012-11-21 00:22:03 +01:00
add_thickbox ();
2012-11-21 10:35:23 +01:00
wp_enqueue_media ( array ( 'post' => $post_ID ) );
2012-11-21 00:22:03 +01:00
}
2013-07-22 07:09:49 +02:00
// Add the local autosave notice HTML
add_action ( 'admin_footer' , '_local_storage_notice' );
2013-10-17 00:59:09 +02:00
/*
* @ todo Document the $messages array ( s ) .
*/
2015-01-10 22:21:22 +01:00
$permalink = get_permalink ( $post_ID );
if ( ! $permalink ) {
$permalink = '' ;
}
2010-01-11 22:42:45 +01:00
$messages = array ();
2015-06-19 23:49:25 +02:00
2015-09-24 05:28:24 +02:00
$preview_post_link_html = $scheduled_post_link_html = $view_post_link_html = '' ;
$preview_page_link_html = $scheduled_page_link_html = $view_page_link_html = '' ;
$preview_url = get_preview_post_link ( $post );
Custom Post Types:
* Introduce `is_post_type_viewable( $post_type_object )`
* Separate the HTML bits from the translatable bits in the `post` messages array in `edit-form-advanced.php`
* Don't show certain UI pieces when a post is not viewable on the front end
When a custom post type item is not viewable on the front end, we don't want to show links to View it (on the front end) all over the admin. We also want to hide the Preview link, et al. We also want our admin messages to not contain said links.
Custom post types with `public_queryable` set to `false` are not viewable on the front end.
`'page'` is viewable on the front end, but `'page'` is a `_builtin` type, and `public_queryable` is set to `false` when it is registered - see `WP::parse_request()` for when `public_queryable` gets used.
This is confusing, but also somewhat straightforward: to determine if a post type is viewable on the front end, we can check one way for `_builtin => true` and another way for `_builtin => false`:
`$post_type->publicly_queryable || ( $post_type->_builtin && $post_type->public )`
If a post type is `publicly_queryable`, it's viewable. If that value is `false`, it is viewable if it's a `_builtin` type that is also `public`.
I am in search of edge cases, so this shall land.
Props wonderboymusic, DrewAPicture.
See #17609.
Built from https://develop.svn.wordpress.org/trunk@33666
git-svn-id: http://core.svn.wordpress.org/trunk@33633 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-08-20 21:40:25 +02:00
$viewable = is_post_type_viewable ( $post_type_object );
if ( $viewable ) {
2015-09-24 05:28:24 +02:00
// Preview post link.
$preview_post_link_html = sprintf ( ' <a target="_blank" href="%1$s">%2$s</a>' ,
esc_url ( $preview_url ),
Custom Post Types:
* Introduce `is_post_type_viewable( $post_type_object )`
* Separate the HTML bits from the translatable bits in the `post` messages array in `edit-form-advanced.php`
* Don't show certain UI pieces when a post is not viewable on the front end
When a custom post type item is not viewable on the front end, we don't want to show links to View it (on the front end) all over the admin. We also want to hide the Preview link, et al. We also want our admin messages to not contain said links.
Custom post types with `public_queryable` set to `false` are not viewable on the front end.
`'page'` is viewable on the front end, but `'page'` is a `_builtin` type, and `public_queryable` is set to `false` when it is registered - see `WP::parse_request()` for when `public_queryable` gets used.
This is confusing, but also somewhat straightforward: to determine if a post type is viewable on the front end, we can check one way for `_builtin => true` and another way for `_builtin => false`:
`$post_type->publicly_queryable || ( $post_type->_builtin && $post_type->public )`
If a post type is `publicly_queryable`, it's viewable. If that value is `false`, it is viewable if it's a `_builtin` type that is also `public`.
I am in search of edge cases, so this shall land.
Props wonderboymusic, DrewAPicture.
See #17609.
Built from https://develop.svn.wordpress.org/trunk@33666
git-svn-id: http://core.svn.wordpress.org/trunk@33633 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-08-20 21:40:25 +02:00
__ ( 'Preview post' )
);
2015-09-24 05:28:24 +02:00
// Scheduled post preview link.
$scheduled_post_link_html = sprintf ( ' <a target="_blank" href="%1$s">%2$s</a>' ,
Custom Post Types:
* Introduce `is_post_type_viewable( $post_type_object )`
* Separate the HTML bits from the translatable bits in the `post` messages array in `edit-form-advanced.php`
* Don't show certain UI pieces when a post is not viewable on the front end
When a custom post type item is not viewable on the front end, we don't want to show links to View it (on the front end) all over the admin. We also want to hide the Preview link, et al. We also want our admin messages to not contain said links.
Custom post types with `public_queryable` set to `false` are not viewable on the front end.
`'page'` is viewable on the front end, but `'page'` is a `_builtin` type, and `public_queryable` is set to `false` when it is registered - see `WP::parse_request()` for when `public_queryable` gets used.
This is confusing, but also somewhat straightforward: to determine if a post type is viewable on the front end, we can check one way for `_builtin => true` and another way for `_builtin => false`:
`$post_type->publicly_queryable || ( $post_type->_builtin && $post_type->public )`
If a post type is `publicly_queryable`, it's viewable. If that value is `false`, it is viewable if it's a `_builtin` type that is also `public`.
I am in search of edge cases, so this shall land.
Props wonderboymusic, DrewAPicture.
See #17609.
Built from https://develop.svn.wordpress.org/trunk@33666
git-svn-id: http://core.svn.wordpress.org/trunk@33633 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-08-20 21:40:25 +02:00
esc_url ( $permalink ),
__ ( 'Preview post' )
);
// View post link.
2015-09-24 05:28:24 +02:00
$view_post_link_html = sprintf ( ' <a href="%1$s">%2$s</a>' ,
Custom Post Types:
* Introduce `is_post_type_viewable( $post_type_object )`
* Separate the HTML bits from the translatable bits in the `post` messages array in `edit-form-advanced.php`
* Don't show certain UI pieces when a post is not viewable on the front end
When a custom post type item is not viewable on the front end, we don't want to show links to View it (on the front end) all over the admin. We also want to hide the Preview link, et al. We also want our admin messages to not contain said links.
Custom post types with `public_queryable` set to `false` are not viewable on the front end.
`'page'` is viewable on the front end, but `'page'` is a `_builtin` type, and `public_queryable` is set to `false` when it is registered - see `WP::parse_request()` for when `public_queryable` gets used.
This is confusing, but also somewhat straightforward: to determine if a post type is viewable on the front end, we can check one way for `_builtin => true` and another way for `_builtin => false`:
`$post_type->publicly_queryable || ( $post_type->_builtin && $post_type->public )`
If a post type is `publicly_queryable`, it's viewable. If that value is `false`, it is viewable if it's a `_builtin` type that is also `public`.
I am in search of edge cases, so this shall land.
Props wonderboymusic, DrewAPicture.
See #17609.
Built from https://develop.svn.wordpress.org/trunk@33666
git-svn-id: http://core.svn.wordpress.org/trunk@33633 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-08-20 21:40:25 +02:00
esc_url ( $permalink ),
__ ( 'View post' )
);
2015-09-24 05:28:24 +02:00
// Preview page link.
$preview_page_link_html = sprintf ( ' <a target="_blank" href="%1$s">%2$s</a>' ,
esc_url ( $preview_url ),
__ ( 'Preview page' )
);
// Scheduled page preview link.
$scheduled_page_link_html = sprintf ( ' <a target="_blank" href="%1$s">%2$s</a>' ,
esc_url ( $permalink ),
__ ( 'Preview page' )
);
// View page link.
$view_page_link_html = sprintf ( ' <a href="%1$s">%2$s</a>' ,
esc_url ( $permalink ),
__ ( 'View page' )
);
Custom Post Types:
* Introduce `is_post_type_viewable( $post_type_object )`
* Separate the HTML bits from the translatable bits in the `post` messages array in `edit-form-advanced.php`
* Don't show certain UI pieces when a post is not viewable on the front end
When a custom post type item is not viewable on the front end, we don't want to show links to View it (on the front end) all over the admin. We also want to hide the Preview link, et al. We also want our admin messages to not contain said links.
Custom post types with `public_queryable` set to `false` are not viewable on the front end.
`'page'` is viewable on the front end, but `'page'` is a `_builtin` type, and `public_queryable` is set to `false` when it is registered - see `WP::parse_request()` for when `public_queryable` gets used.
This is confusing, but also somewhat straightforward: to determine if a post type is viewable on the front end, we can check one way for `_builtin => true` and another way for `_builtin => false`:
`$post_type->publicly_queryable || ( $post_type->_builtin && $post_type->public )`
If a post type is `publicly_queryable`, it's viewable. If that value is `false`, it is viewable if it's a `_builtin` type that is also `public`.
I am in search of edge cases, so this shall land.
Props wonderboymusic, DrewAPicture.
See #17609.
Built from https://develop.svn.wordpress.org/trunk@33666
git-svn-id: http://core.svn.wordpress.org/trunk@33633 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-08-20 21:40:25 +02:00
}
/* translators: Publish box date format, see http://php.net/date */
$scheduled_date = date_i18n ( __ ( 'M j, Y @ H:i' ), strtotime ( $post -> post_date ) );
2015-09-24 05:28:24 +02:00
2010-01-11 22:42:45 +01:00
$messages [ 'post' ] = array (
2010-05-22 07:40:29 +02:00
0 => '' , // Unused. Messages start at index 1.
2015-09-24 05:28:24 +02:00
1 => __ ( 'Post updated.' ) . $view_post_link_html ,
2 => __ ( 'Custom field updated.' ),
3 => __ ( 'Custom field deleted.' ),
4 => __ ( 'Post updated.' ),
2010-01-21 22:37:43 +01:00
/* translators: %s: date and time of the revision */
2015-09-24 10:54:26 +02:00
5 => isset ( $_GET [ 'revision' ]) ? sprintf ( __ ( 'Post restored to revision from %s.' ), wp_post_revision_title ( ( int ) $_GET [ 'revision' ], false ) ) : false ,
2015-09-24 05:28:24 +02:00
6 => __ ( 'Post published.' ) . $view_post_link_html ,
7 => __ ( 'Post saved.' ),
8 => __ ( 'Post submitted.' ) . $preview_post_link_html ,
9 => sprintf ( __ ( 'Post scheduled for: %s.' ), '<strong>' . $scheduled_date . '</strong>' ) . $scheduled_post_link_html ,
10 => __ ( 'Post draft updated.' ) . $preview_post_link_html ,
2010-01-11 22:42:45 +01:00
);
$messages [ 'page' ] = array (
2010-05-22 07:40:29 +02:00
0 => '' , // Unused. Messages start at index 1.
2015-09-24 05:28:24 +02:00
1 => __ ( 'Page updated.' ) . $view_page_link_html ,
2 => __ ( 'Custom field updated.' ),
3 => __ ( 'Custom field deleted.' ),
4 => __ ( 'Page updated.' ),
/* translators: %s: date and time of the revision */
2015-09-24 10:54:26 +02:00
5 => isset ( $_GET [ 'revision' ]) ? sprintf ( __ ( 'Page restored to revision from %s.' ), wp_post_revision_title ( ( int ) $_GET [ 'revision' ], false ) ) : false ,
2015-09-24 05:28:24 +02:00
6 => __ ( 'Page published.' ) . $view_page_link_html ,
7 => __ ( 'Page saved.' ),
8 => __ ( 'Page submitted.' ) . $preview_page_link_html ,
9 => sprintf ( __ ( 'Page scheduled for: %s.' ), '<strong>' . $scheduled_date . '</strong>' ) . $scheduled_page_link_html ,
10 => __ ( 'Page draft updated.' ) . $preview_page_link_html ,
2010-01-11 22:42:45 +01:00
);
2016-03-08 18:43:25 +01:00
$messages [ 'attachment' ] = array_fill ( 1 , 10 , __ ( 'Media file updated.' ) ); // Hack, for now.
2010-01-11 22:42:45 +01:00
2013-10-17 00:59:09 +02:00
/**
* Filter the post updated messages .
*
* @ since 3.0 . 0
*
* @ param array $messages Post updated messages . For defaults @ see $messages declarations above .
*/
2010-05-22 07:40:29 +02:00
$messages = apply_filters ( 'post_updated_messages' , $messages );
2009-10-11 02:37:26 +02:00
$message = false ;
if ( isset ( $_GET [ 'message' ]) ) {
2008-03-21 04:31:12 +01:00
$_GET [ 'message' ] = absint ( $_GET [ 'message' ] );
2010-01-11 22:42:45 +01:00
if ( isset ( $messages [ $post_type ][ $_GET [ 'message' ]]) )
$message = $messages [ $post_type ][ $_GET [ 'message' ]];
elseif ( ! isset ( $messages [ $post_type ]) && isset ( $messages [ 'post' ][ $_GET [ 'message' ]]) )
$message = $messages [ 'post' ][ $_GET [ 'message' ]];
2009-10-11 02:37:26 +02:00
}
2008-05-08 19:25:07 +02:00
2009-10-11 02:37:26 +02:00
$notice = false ;
2010-02-06 11:07:57 +01:00
$form_extra = '' ;
2012-12-02 00:12:30 +01:00
if ( 'auto-draft' == $post -> post_status ) {
2010-02-06 11:07:57 +01:00
if ( 'edit' == $action )
$post -> post_title = '' ;
2008-05-08 19:25:07 +02:00
$autosave = false ;
2010-02-06 11:07:57 +01:00
$form_extra .= " <input type='hidden' id='auto_draft' name='auto_draft' value='1' /> " ;
2008-05-08 19:25:07 +02:00
} else {
2008-08-25 23:50:11 +02:00
$autosave = wp_get_post_autosave ( $post_ID );
2010-02-06 11:07:57 +01:00
}
$form_action = 'editpost' ;
2012-08-14 20:39:15 +02:00
$nonce_action = 'update-post_' . $post_ID ;
2010-02-06 11:07:57 +01:00
$form_extra .= " <input type='hidden' id='post_ID' name='post_ID' value=' " . esc_attr ( $post_ID ) . " ' /> " ;
2008-06-24 00:25:27 +02:00
2010-02-06 11:07:57 +01:00
// Detect if there exists an autosave newer than the post and if that autosave is different than the post
if ( $autosave && mysql2date ( 'U' , $autosave -> post_modified_gmt , false ) > mysql2date ( 'U' , $post -> post_modified_gmt , false ) ) {
2016-02-24 01:44:59 +01:00
foreach ( _wp_post_revision_fields ( $post ) as $autosave_field => $_autosave_field ) {
2010-02-06 11:07:57 +01:00
if ( normalize_whitespace ( $autosave -> $autosave_field ) != normalize_whitespace ( $post -> $autosave_field ) ) {
2011-12-14 00:45:31 +01:00
$notice = sprintf ( __ ( 'There is an autosave of this post that is more recent than the version below. <a href="%s">View the autosave</a>' ), get_edit_post_link ( $autosave -> ID ) );
2010-02-06 11:07:57 +01:00
break ;
2008-06-24 00:25:27 +02:00
}
}
2013-07-24 07:37:53 +02:00
// If this autosave isn't different from the current post, begone.
if ( ! $notice )
wp_delete_post_revision ( $autosave -> ID );
2010-02-06 11:07:57 +01:00
unset ( $autosave_field , $_autosave_field );
2008-05-08 19:25:07 +02:00
}
2010-01-11 22:42:45 +01:00
$post_type_object = get_post_type_object ( $post_type );
2008-08-20 23:42:31 +02:00
// All meta boxes should be defined and added before the first do_meta_boxes() call (or potentially during the do_meta_boxes action).
2013-09-25 02:18:11 +02:00
require_once ( ABSPATH . 'wp-admin/includes/meta-boxes.php' );
2008-10-10 20:21:16 +02:00
2013-07-24 08:08:14 +02:00
$publish_callback_args = null ;
if ( post_type_supports ( $post_type , 'revisions' ) && 'auto-draft' != $post -> post_status ) {
$revisions = wp_get_post_revisions ( $post_ID );
// We should aim to show the revisions metabox only when there are revisions.
if ( count ( $revisions ) > 1 ) {
reset ( $revisions ); // Reset pointer for key()
$publish_callback_args = array ( 'revisions_count' => count ( $revisions ), 'revision_id' => key ( $revisions ) );
2013-08-01 19:06:38 +02:00
add_meta_box ( 'revisionsdiv' , __ ( 'Revisions' ), 'post_revisions_meta_box' , null , 'normal' , 'core' );
2013-07-24 08:08:14 +02:00
}
}
2012-09-22 00:52:54 +02:00
if ( 'attachment' == $post_type ) {
wp_enqueue_script ( 'image-edit' );
wp_enqueue_style ( 'imgareaselect' );
add_meta_box ( 'submitdiv' , __ ( 'Save' ), 'attachment_submit_meta_box' , null , 'side' , 'core' );
add_action ( 'edit_form_after_title' , 'edit_form_image_editor' );
2014-03-30 21:28:16 +02:00
2015-03-06 21:26:26 +01:00
if ( wp_attachment_is ( 'audio' , $post ) ) {
2014-03-30 21:28:16 +02:00
add_meta_box ( 'attachment-id3' , __ ( 'Metadata' ), 'attachment_id3_data_meta_box' , null , 'normal' , 'core' );
}
2012-09-22 00:52:54 +02:00
} else {
2013-07-24 08:08:14 +02:00
add_meta_box ( 'submitdiv' , __ ( 'Publish' ), 'post_submit_meta_box' , null , 'side' , 'core' , $publish_callback_args );
2012-09-22 00:52:54 +02:00
}
2008-02-22 04:45:19 +01:00
2013-05-30 23:33:46 +02:00
if ( current_theme_supports ( 'post-formats' ) && post_type_supports ( $post_type , 'post-formats' ) )
add_meta_box ( 'formatdiv' , _x ( 'Format' , 'post format' ), 'post_format_meta_box' , null , 'side' , 'core' );
2010-04-02 03:23:58 +02:00
// all taxonomies
2012-09-22 00:52:54 +02:00
foreach ( get_object_taxonomies ( $post ) as $tax_name ) {
2013-09-23 19:12:10 +02:00
$taxonomy = get_taxonomy ( $tax_name );
2013-10-27 21:36:09 +01:00
if ( ! $taxonomy -> show_ui || false === $taxonomy -> meta_box_cb )
2010-04-02 03:23:58 +02:00
continue ;
2010-05-14 02:34:04 +02:00
$label = $taxonomy -> labels -> name ;
2008-12-18 20:12:26 +01:00
2013-09-23 19:12:10 +02:00
if ( ! is_taxonomy_hierarchical ( $tax_name ) )
$tax_meta_box_id = 'tagsdiv-' . $tax_name ;
2010-01-22 20:30:05 +01:00
else
2013-09-23 19:12:10 +02:00
$tax_meta_box_id = $tax_name . 'div' ;
2013-10-27 21:36:09 +01:00
add_meta_box ( $tax_meta_box_id , $label , $taxonomy -> meta_box_cb , null , 'side' , 'core' , array ( 'taxonomy' => $tax_name ) );
2009-03-18 03:43:45 +01:00
}
2008-01-14 02:14:57 +01:00
2010-01-11 22:42:45 +01:00
if ( post_type_supports ( $post_type , 'page-attributes' ) )
2011-10-19 23:43:02 +02:00
add_meta_box ( 'pageparentdiv' , 'page' == $post_type ? __ ( 'Page Attributes' ) : __ ( 'Attributes' ), 'page_attributes_meta_box' , null , 'side' , 'core' );
2010-01-11 22:42:45 +01:00
2014-08-06 19:17:16 +02:00
if ( $thumbnail_support && current_user_can ( 'upload_files' ) )
2015-05-31 18:54:27 +02:00
add_meta_box ( 'postimagediv' , esc_html ( $post_type_object -> labels -> featured_image ), 'post_thumbnail_meta_box' , null , 'side' , 'low' );
2010-01-11 22:42:45 +01:00
2010-03-15 22:16:41 +01:00
if ( post_type_supports ( $post_type , 'excerpt' ) )
2011-10-19 23:43:02 +02:00
add_meta_box ( 'postexcerpt' , __ ( 'Excerpt' ), 'post_excerpt_meta_box' , null , 'normal' , 'core' );
2010-01-11 22:42:45 +01:00
2010-01-10 02:23:14 +01:00
if ( post_type_supports ( $post_type , 'trackbacks' ) )
2011-10-19 23:43:02 +02:00
add_meta_box ( 'trackbacksdiv' , __ ( 'Send Trackbacks' ), 'post_trackback_meta_box' , null , 'normal' , 'core' );
2010-01-11 22:42:45 +01:00
2010-01-10 02:23:14 +01:00
if ( post_type_supports ( $post_type , 'custom-fields' ) )
2011-10-19 23:43:02 +02:00
add_meta_box ( 'postcustom' , __ ( 'Custom Fields' ), 'post_custom_meta_box' , null , 'normal' , 'core' );
2010-01-11 22:42:45 +01:00
2013-10-17 00:59:09 +02:00
/**
* Fires in the middle of built - in meta box registration .
*
* @ since 2.1 . 0
* @ deprecated 3.7 . 0 Use 'add_meta_boxes' instead .
*
* @ param WP_Post $post Post object .
*/
do_action ( 'dbx_post_advanced' , $post );
2015-09-23 21:49:26 +02:00
// Allow the Discussion meta box to show up if the post type supports comments,
// or if comments or pings are open.
if ( comments_open ( $post ) || pings_open ( $post ) || post_type_supports ( $post_type , 'comments' ) ) {
add_meta_box ( 'commentstatusdiv' , __ ( 'Discussion' ), 'post_comment_status_meta_box' , null , 'normal' , 'core' );
}
2009-02-02 04:41:19 +01:00
2015-09-24 22:02:24 +02:00
$stati = get_post_stati ( array ( 'public' => true ) );
if ( empty ( $stati ) ) {
$stati = array ( 'publish' );
}
$stati [] = 'private' ;
if ( in_array ( get_post_status ( $post ), $stati ) ) {
2015-09-23 21:49:26 +02:00
// If the post type support comments, or the post has comments, allow the
// Comments meta box.
if ( comments_open ( $post ) || pings_open ( $post ) || $post -> comment_count > 0 || post_type_supports ( $post_type , 'comments' ) ) {
add_meta_box ( 'commentsdiv' , __ ( 'Comments' ), 'post_comment_meta_box' , null , 'normal' , 'core' );
}
}
2008-01-03 09:03:29 +01:00
2012-09-22 00:52:54 +02:00
if ( ! ( 'pending' == get_post_status ( $post ) && ! current_user_can ( $post_type_object -> cap -> publish_posts ) ) )
2011-10-19 23:43:02 +02:00
add_meta_box ( 'slugdiv' , __ ( 'Slug' ), 'post_slug_meta_box' , null , 'normal' , 'core' );
2008-05-14 10:22:01 +02:00
2010-03-15 22:16:41 +01:00
if ( post_type_supports ( $post_type , 'author' ) ) {
2010-08-27 03:07:21 +02:00
if ( is_super_admin () || current_user_can ( $post_type_object -> cap -> edit_others_posts ) )
2011-10-19 23:43:02 +02:00
add_meta_box ( 'authordiv' , __ ( 'Author' ), 'post_author_meta_box' , null , 'normal' , 'core' );
2010-03-15 22:16:41 +01:00
}
2008-01-03 09:03:29 +01:00
2013-10-17 00:59:09 +02:00
/**
* Fires after all built - in meta boxes have been added .
*
* @ since 3.0 . 0
*
* @ param string $post_type Post type .
* @ param WP_Post $post Post object .
*/
do_action ( 'add_meta_boxes' , $post_type , $post );
2010-02-03 19:54:42 +01:00
2013-10-17 00:59:09 +02:00
/**
* Fires after all built - in meta boxes have been added , contextually for the given post type .
*
2014-11-30 12:42:24 +01:00
* The dynamic portion of the hook , `$post_type` , refers to the post type of the post .
2013-10-17 00:59:09 +02:00
*
* @ since 3.0 . 0
*
* @ param WP_Post $post Post object .
*/
do_action ( 'add_meta_boxes_' . $post_type , $post );
/**
* Fires after meta boxes have been added .
*
* Fires once for each of the default meta box contexts : normal , advanced , and side .
*
* @ since 3.0 . 0
*
* @ param string $post_type Post type of the post .
* @ param string $context string Meta box context .
* @ param WP_Post $post Post object .
*/
do_action ( 'do_meta_boxes' , $post_type , 'normal' , $post );
2013-10-25 00:59:20 +02:00
/** This action is documented in wp-admin/edit-form-advanced.php */
2013-10-17 00:59:09 +02:00
do_action ( 'do_meta_boxes' , $post_type , 'advanced' , $post );
2013-10-25 00:59:20 +02:00
/** This action is documented in wp-admin/edit-form-advanced.php */
2013-10-17 00:59:09 +02:00
do_action ( 'do_meta_boxes' , $post_type , 'side' , $post );
2008-11-11 23:40:16 +01:00
2011-10-07 06:57:12 +02:00
add_screen_option ( 'layout_columns' , array ( 'max' => 2 , 'default' => 2 ) );
2011-10-02 08:59:36 +02:00
2010-05-26 05:36:04 +02:00
if ( 'post' == $post_type ) {
2012-11-22 10:00:39 +01:00
$customize_display = '<p>' . __ ( 'The title field and the big Post Editing Area are fixed in place, but you can reposition all the other boxes using drag and drop. You can also minimize or expand them by clicking the title bar of each box. Use the Screen Options tab to unhide more boxes (Excerpt, Send Trackbacks, Custom Fields, Discussion, Slug, Author) or to choose a 1- or 2-column layout for this screen.' ) . '</p>' ;
2011-09-26 23:03:38 +02:00
2011-11-02 03:38:37 +01:00
get_current_screen () -> add_help_tab ( array (
2011-10-01 02:24:44 +02:00
'id' => 'customize-display' ,
'title' => __ ( 'Customizing This Display' ),
2011-10-07 06:57:12 +02:00
'content' => $customize_display ,
2011-10-01 02:24:44 +02:00
) );
2011-09-26 23:03:38 +02:00
2015-08-19 06:53:25 +02:00
$title_and_editor = '<p>' . __ ( '<strong>Title</strong> — Enter a title for your post. After you enter a title, you’ll see the permalink below, which you can edit.' ) . '</p>' ;
$title_and_editor .= '<p>' . __ ( '<strong>Post editor</strong> — Enter the text for your post. There are two modes of editing: Visual and Text. Choose the mode by clicking on the appropriate tab.' ) . '</p>' ;
2014-12-02 06:15:23 +01:00
$title_and_editor .= '<p>' . __ ( 'Visual mode gives you a WYSIWYG editor. Click the last icon in the row to get a second row of controls. ' ) . '</p>' ;
$title_and_editor .= '<p>' . __ ( 'The Text mode allows you to enter HTML along with your post text. Line breaks will be converted to paragraphs automatically.' ) . '</p>' ;
$title_and_editor .= '<p>' . __ ( 'You can insert media files by clicking the icons above the post editor and following the directions. You can align or edit images using the inline formatting toolbar available in Visual mode.' ) . '</p>' ;
2014-12-16 11:07:23 +01:00
$title_and_editor .= '<p>' . __ ( 'You can enable distraction-free writing mode using the icon to the right. This feature is not available for old browsers or devices with small screens, and requires that the full-height editor be enabled in Screen Options.' ) . '</p>' ;
2014-04-08 03:39:14 +02:00
$title_and_editor .= '<p>' . __ ( 'Keyboard users: When you’re working in the visual editor, you can use <kbd>Alt + F10</kbd> to access the toolbar.' ) . '</p>' ;
2011-09-26 23:03:38 +02:00
2011-11-02 03:38:37 +01:00
get_current_screen () -> add_help_tab ( array (
2011-10-01 02:24:44 +02:00
'id' => 'title-post-editor' ,
'title' => __ ( 'Title and Post Editor' ),
'content' => $title_and_editor ,
) );
2011-09-26 23:03:38 +02:00
2011-11-02 21:14:10 +01:00
get_current_screen () -> set_help_sidebar (
2015-07-29 10:44:25 +02:00
'<p>' . sprintf ( __ ( 'You can also create posts with the <a href="%s">Press This bookmarklet</a>.' ), 'tools.php' ) . '</p>' .
2011-09-26 23:03:38 +02:00
'<p><strong>' . __ ( 'For more information:' ) . '</strong></p>' .
2015-04-12 23:29:32 +02:00
'<p>' . __ ( '<a href="https://codex.wordpress.org/Posts_Add_New_Screen" target="_blank">Documentation on Writing and Editing Posts</a>' ) . '</p>' .
2014-03-08 05:14:15 +01:00
'<p>' . __ ( '<a href="https://wordpress.org/support/" target="_blank">Support Forums</a>' ) . '</p>'
2010-05-26 05:36:04 +02:00
);
} elseif ( 'page' == $post_type ) {
2015-05-09 22:07:26 +02:00
$about_pages = '<p>' . __ ( 'Pages are similar to posts in that they have a title, body text, and associated metadata, but they are different in that they are not part of the chronological blog stream, kind of like permanent posts. Pages are not categorized or tagged, but can have a hierarchy. You can nest pages under other pages by making one the “Parent” of the other, creating a group of pages.' ) . '</p>' .
2015-09-26 15:44:26 +02:00
'<p>' . __ ( 'Creating a Page is very similar to creating a Post, and the screens can be customized in the same way using drag and drop, the Screen Options tab, and expanding/collapsing boxes as you choose. This screen also has the distraction-free writing space, available in both the Visual and Text modes via the Fullscreen buttons. The Page editor mostly works the same as the Post editor, but there are some Page-specific features in the Page Attributes box.' ) . '</p>' ;
2011-10-24 21:13:23 +02:00
2011-11-02 03:38:37 +01:00
get_current_screen () -> add_help_tab ( array (
2011-10-11 21:29:09 +02:00
'id' => 'about-pages' ,
'title' => __ ( 'About Pages' ),
'content' => $about_pages ,
) );
2011-10-24 21:13:23 +02:00
2011-11-02 21:14:10 +01:00
get_current_screen () -> set_help_sidebar (
2011-09-26 23:03:38 +02:00
'<p><strong>' . __ ( 'For more information:' ) . '</strong></p>' .
2015-04-12 23:29:32 +02:00
'<p>' . __ ( '<a href="https://codex.wordpress.org/Pages_Add_New_Screen" target="_blank">Documentation on Adding New Pages</a>' ) . '</p>' .
'<p>' . __ ( '<a href="https://codex.wordpress.org/Pages_Screen#Editing_Individual_Pages" target="_blank">Documentation on Editing Pages</a>' ) . '</p>' .
2014-03-08 05:14:15 +01:00
'<p>' . __ ( '<a href="https://wordpress.org/support/" target="_blank">Support Forums</a>' ) . '</p>'
2010-05-26 05:36:04 +02:00
);
2012-09-24 15:13:09 +02:00
} elseif ( 'attachment' == $post_type ) {
get_current_screen () -> add_help_tab ( array (
'id' => 'overview' ,
'title' => __ ( 'Overview' ),
'content' =>
'<p>' . __ ( 'This screen allows you to edit four fields for metadata in a file within the media library.' ) . '</p>' .
'<p>' . __ ( 'For images only, you can click on Edit Image under the thumbnail to expand out an inline image editor with icons for cropping, rotating, or flipping the image as well as for undoing and redoing. The boxes on the right give you more options for scaling the image, for cropping it, and for cropping the thumbnail in a different way than you crop the original image. You can click on Help in those boxes to get more information.' ) . '</p>' .
'<p>' . __ ( 'Note that you crop the image by clicking on it (the Crop icon is already selected) and dragging the cropping frame to select the desired part. Then click Save to retain the cropping.' ) . '</p>' .
'<p>' . __ ( 'Remember to click Update Media to save metadata entered or changed.' ) . '</p>'
) );
get_current_screen () -> set_help_sidebar (
'<p><strong>' . __ ( 'For more information:' ) . '</strong></p>' .
2015-04-12 23:29:32 +02:00
'<p>' . __ ( '<a href="https://codex.wordpress.org/Media_Add_New_Screen#Edit_Media" target="_blank">Documentation on Edit Media</a>' ) . '</p>' .
2014-03-08 05:14:15 +01:00
'<p>' . __ ( '<a href="https://wordpress.org/support/" target="_blank">Support Forums</a>' ) . '</p>'
2012-09-24 15:13:09 +02:00
);
2010-05-26 05:36:04 +02:00
}
2010-01-15 17:58:36 +01:00
2012-11-22 10:00:39 +01:00
if ( 'post' == $post_type || 'page' == $post_type ) {
2012-11-29 18:51:54 +01:00
$inserting_media = '<p>' . __ ( 'You can upload and insert media (images, audio, documents, etc.) by clicking the Add Media button. You can select from the images and files already uploaded to the Media Library, or upload new media to add to your page or post. To create an image gallery, select the images to add and click the “Create a new gallery” button.' ) . '</p>' ;
2015-04-12 23:29:32 +02:00
$inserting_media .= '<p>' . __ ( 'You can also embed media from many popular websites including Twitter, YouTube, Flickr and others by pasting the media URL on its own line into the content of your post/page. Please refer to the Codex to <a href="https://codex.wordpress.org/Embeds">learn more about embeds</a>.' ) . '</p>' ;
2012-11-22 10:00:39 +01:00
get_current_screen () -> add_help_tab ( array (
'id' => 'inserting-media' ,
'title' => __ ( 'Inserting Media' ),
'content' => $inserting_media ,
) );
}
if ( 'post' == $post_type ) {
$publish_box = '<p>' . __ ( 'Several boxes on this screen contain settings for how your content will be published, including:' ) . '</p>' ;
2015-09-10 23:00:24 +02:00
$publish_box .= '<ul><li>' .
2015-12-12 02:56:29 +01:00
__ ( '<strong>Publish</strong> — You can set the terms of publishing your post in the Publish box. For Status, Visibility, and Publish (immediately), click on the Edit link to reveal more options. Visibility includes options for password-protecting a post or making it stay at the top of your blog indefinitely (sticky). The Password protected option allows you to set an arbitrary password for each post. The Private option hides the post from everyone except editors and administrators. Publish (immediately) allows you to set a future or past date and time, so you can schedule a post to be published in the future or backdate a post.' ) .
2015-09-10 19:36:24 +02:00
'</li>' ;
2012-11-22 10:00:39 +01:00
if ( current_theme_supports ( 'post-formats' ) && post_type_supports ( 'post' , 'post-formats' ) ) {
2015-08-19 06:53:25 +02:00
$publish_box .= '<li>' . __ ( '<strong>Format</strong> — Post Formats designate how your theme will display a specific post. For example, you could have a <em>standard</em> blog post with a title and paragraphs, or a short <em>aside</em> that omits the title and contains a short text blurb. Please refer to the Codex for <a href="https://codex.wordpress.org/Post_Formats#Supported_Formats">descriptions of each post format</a>. Your theme could enable all or some of 10 possible formats.' ) . '</li>' ;
2012-11-22 10:00:39 +01:00
}
if ( current_theme_supports ( 'post-thumbnails' ) && post_type_supports ( 'post' , 'thumbnail' ) ) {
2015-05-31 18:54:27 +02:00
/* translators: %s: Featured Image */
2015-08-19 06:53:25 +02:00
$publish_box .= '<li>' . sprintf ( __ ( '<strong>%s</strong> — This allows you to associate an image with your post without inserting it. This is usually useful only if your theme makes use of the image as a post thumbnail on the home page, a custom header, etc.' ), esc_html ( $post_type_object -> labels -> featured_image ) ) . '</li>' ;
2012-11-22 10:00:39 +01:00
}
$publish_box .= '</ul>' ;
get_current_screen () -> add_help_tab ( array (
'id' => 'publish-box' ,
'title' => __ ( 'Publish Settings' ),
'content' => $publish_box ,
) );
2015-08-19 06:53:25 +02:00
$discussion_settings = '<p>' . __ ( '<strong>Send Trackbacks</strong> — Trackbacks are a way to notify legacy blog systems that you’ve linked to them. Enter the URL(s) you want to send trackbacks. If you link to other WordPress sites they’ll be notified automatically using pingbacks, and this field is unnecessary.' ) . '</p>' ;
$discussion_settings .= '<p>' . __ ( '<strong>Discussion</strong> — You can turn comments and pings on or off, and if there are comments on the post, you can see them here and moderate them.' ) . '</p>' ;
2012-11-22 10:00:39 +01:00
get_current_screen () -> add_help_tab ( array (
'id' => 'discussion-settings' ,
'title' => __ ( 'Discussion Settings' ),
'content' => $discussion_settings ,
) );
} elseif ( 'page' == $post_type ) {
2015-08-19 06:53:25 +02:00
$page_attributes = '<p>' . __ ( '<strong>Parent</strong> — You can arrange your pages in hierarchies. For example, you could have an “About” page that has “Life Story” and “My Dog” pages under it. There are no limits to how many levels you can nest pages.' ) . '</p>' .
'<p>' . __ ( '<strong>Template</strong> — Some themes have custom templates you can use for certain pages that might have additional features or custom layouts. If so, you’ll see them in this dropdown menu.' ) . '</p>' .
'<p>' . __ ( '<strong>Order</strong> — Pages are usually ordered alphabetically, but you can choose your own order by entering a number (1 for first, etc.) in this field.' ) . '</p>' ;
2012-11-22 10:00:39 +01:00
get_current_screen () -> add_help_tab ( array (
'id' => 'page-attributes' ,
'title' => __ ( 'Page Attributes' ),
'content' => $page_attributes ,
) );
}
2013-09-25 02:18:11 +02:00
require_once ( ABSPATH . 'wp-admin/admin-header.php' );
2008-08-20 23:42:31 +02:00
?>
2008-09-28 06:11:27 +02:00
2013-04-26 14:36:12 +02:00
< div class = " wrap " >
2015-06-27 17:41:25 +02:00
< h1 >< ? php
2012-10-25 00:15:43 +02:00
echo esc_html ( $title );
if ( isset ( $post_new_file ) && current_user_can ( $post_type_object -> cap -> create_posts ) )
2015-07-03 18:42:24 +02:00
echo ' <a href="' . esc_url ( admin_url ( $post_new_file ) ) . '" class="page-title-action">' . esc_html ( $post_type_object -> labels -> add_new ) . '</a>' ;
2015-06-27 17:41:25 +02:00
?> </h1>
2008-11-05 20:17:22 +01:00
< ? php if ( $notice ) : ?>
2014-11-21 17:41:25 +01:00
< div id = " notice " class = " notice notice-warning " >< p id = " has-newer-autosave " >< ? php echo $notice ?> </p></div>
2008-11-05 20:17:22 +01:00
< ? php endif ; ?>
2009-10-11 02:37:26 +02:00
< ? php if ( $message ) : ?>
2015-04-02 00:06:28 +02:00
< div id = " message " class = " updated notice notice-success is-dismissible " >< p >< ? php echo $message ; ?> </p></div>
2008-11-05 20:17:22 +01:00
< ? php endif ; ?>
2013-04-03 00:51:09 +02:00
< div id = " lost-connection-notice " class = " error hidden " >
2013-07-18 23:33:59 +02:00
< p >< span class = " spinner " ></ span > < ? php _e ( '<strong>Connection lost.</strong> Saving has been disabled until you’re reconnected.' ); ?>
< span class = " hide-if-no-sessionstorage " >< ? php _e ( 'We’re backing up this post in your browser, just in case.' ); ?> </span>
</ p >
2013-04-03 00:51:09 +02:00
</ div >
2014-11-24 06:22:23 +01:00
< form name = " post " action = " post.php " method = " post " id = " post " < ? php
2013-10-17 00:59:09 +02:00
/**
2014-11-24 06:22:23 +01:00
* Fires inside the post editor form tag .
2013-10-17 00:59:09 +02:00
*
* @ since 3.0 . 0
*
* @ param WP_Post $post Post object .
*/
2014-11-24 06:22:23 +01:00
do_action ( 'post_edit_form_tag' , $post );
2015-03-09 03:11:28 +01:00
$referer = wp_get_referer ();
2014-11-24 06:22:23 +01:00
?> >
2010-01-11 22:42:45 +01:00
< ? php wp_nonce_field ( $nonce_action ); ?>
2008-08-20 23:42:31 +02:00
< input type = " hidden " id = " user-id " name = " user_ID " value = " <?php echo (int) $user_ID ?> " />
2010-12-01 19:50:24 +01:00
< input type = " hidden " id = " hiddenaction " name = " action " value = " <?php echo esc_attr( $form_action ) ?> " />
< input type = " hidden " id = " originalaction " name = " originalaction " value = " <?php echo esc_attr( $form_action ) ?> " />
2009-05-05 21:43:53 +02:00
< input type = " hidden " id = " post_author " name = " post_author " value = " <?php echo esc_attr( $post->post_author ); ?> " />
2010-12-01 19:50:24 +01:00
< input type = " hidden " id = " post_type " name = " post_type " value = " <?php echo esc_attr( $post_type ) ?> " />
< input type = " hidden " id = " original_post_status " name = " original_post_status " value = " <?php echo esc_attr( $post->post_status ) ?> " />
2015-03-09 03:11:28 +01:00
< input type = " hidden " id = " referredby " name = " referredby " value = " <?php echo $referer ? esc_url( $referer ) : ''; ?> " />
2011-09-27 22:52:07 +02:00
< ? php if ( ! empty ( $active_post_lock ) ) { ?>
< input type = " hidden " id = " active_post_lock " value = " <?php echo esc_attr( implode( ':', $active_post_lock ) ); ?> " />
2009-05-05 04:14:25 +02:00
< ? php
2011-09-27 22:52:07 +02:00
}
2012-09-22 00:52:54 +02:00
if ( 'draft' != get_post_status ( $post ) )
2009-05-05 04:14:25 +02:00
wp_original_referer_field ( true , 'previous' );
2008-08-20 23:42:31 +02:00
2010-04-18 11:23:03 +02:00
echo $form_extra ;
wp_nonce_field ( 'meta-box-order' , 'meta-box-order-nonce' , false );
wp_nonce_field ( 'closedpostboxes' , 'closedpostboxesnonce' , false );
?>
2008-08-20 23:42:31 +02:00
2013-10-17 00:59:09 +02:00
< ? php
/**
* Fires at the beginning of the edit form .
*
* At this point , the required hidden fields and nonces have already been output .
*
* @ since 3.7 . 0
*
* @ param WP_Post $post Post object .
*/
do_action ( 'edit_form_top' , $post ); ?>
2013-07-29 00:29:36 +02:00
2012-03-23 22:41:00 +01:00
< div id = " poststuff " >
2012-04-24 22:46:04 +02:00
< div id = " post-body " class = " metabox-holder columns-<?php echo 1 == get_current_screen()->get_columns() ? '1' : '2'; ?> " >
2013-05-30 23:33:46 +02:00
< div id = " post-body-content " >
2010-03-15 22:16:41 +01:00
< ? php if ( post_type_supports ( $post_type , 'title' ) ) { ?>
2008-08-20 23:42:31 +02:00
< div id = " titlediv " >
< div id = " titlewrap " >
2013-10-17 00:59:09 +02:00
< ? php
/**
* Filter the title field placeholder text .
*
* @ since 3.1 . 0
*
* @ param string $text Placeholder text . Default 'Enter title here' .
* @ param WP_Post $post Post object .
*/
2014-12-06 22:32:24 +01:00
$title_placeholder = apply_filters ( 'enter_title_here' , __ ( 'Enter title here' ), $post );
2013-10-17 00:59:09 +02:00
?>
2014-12-06 22:32:24 +01:00
< label class = " screen-reader-text " id = " title-prompt-text " for = " title " >< ? php echo $title_placeholder ; ?> </label>
2015-07-14 19:56:26 +02:00
< input type = " text " name = " post_title " size = " 30 " value = " <?php echo esc_attr( $post->post_title ); ?> " id = " title " spellcheck = " true " autocomplete = " off " />
2008-08-20 23:42:31 +02:00
</ div >
2014-10-26 22:49:18 +01:00
< ? php
/**
2014-11-28 09:52:23 +01:00
* Fires before the permalink field in the edit form .
2014-10-26 22:49:18 +01:00
*
* @ since 4.1 . 0
*
* @ param WP_Post $post Post object .
*/
do_action ( 'edit_form_before_permalink' , $post );
?>
2008-08-20 23:42:31 +02:00
< div class = " inside " >
2009-05-05 04:14:25 +02:00
< ? php
Custom Post Types:
* Introduce `is_post_type_viewable( $post_type_object )`
* Separate the HTML bits from the translatable bits in the `post` messages array in `edit-form-advanced.php`
* Don't show certain UI pieces when a post is not viewable on the front end
When a custom post type item is not viewable on the front end, we don't want to show links to View it (on the front end) all over the admin. We also want to hide the Preview link, et al. We also want our admin messages to not contain said links.
Custom post types with `public_queryable` set to `false` are not viewable on the front end.
`'page'` is viewable on the front end, but `'page'` is a `_builtin` type, and `public_queryable` is set to `false` when it is registered - see `WP::parse_request()` for when `public_queryable` gets used.
This is confusing, but also somewhat straightforward: to determine if a post type is viewable on the front end, we can check one way for `_builtin => true` and another way for `_builtin => false`:
`$post_type->publicly_queryable || ( $post_type->_builtin && $post_type->public )`
If a post type is `publicly_queryable`, it's viewable. If that value is `false`, it is viewable if it's a `_builtin` type that is also `public`.
I am in search of edge cases, so this shall land.
Props wonderboymusic, DrewAPicture.
See #17609.
Built from https://develop.svn.wordpress.org/trunk@33666
git-svn-id: http://core.svn.wordpress.org/trunk@33633 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-08-20 21:40:25 +02:00
if ( $viewable ) :
2011-06-10 19:02:03 +02:00
$sample_permalink_html = $post_type_object -> public ? get_sample_permalink_html ( $post -> ID ) : '' ;
2015-01-10 22:21:22 +01:00
2015-09-25 21:54:25 +02:00
// As of 4.4, the Get Shortlink button is hidden by default.
if ( has_filter ( 'pre_get_shortlink' ) || has_filter ( 'get_shortlink' ) ) {
$shortlink = wp_get_shortlink ( $post -> ID , 'post' );
if ( ! empty ( $shortlink ) && $shortlink !== $permalink && $permalink !== home_url ( '?page_id=' . $post -> ID ) ) {
$sample_permalink_html .= '<input id="shortlink" type="hidden" value="' . esc_attr ( $shortlink ) . '" /><a href="#" class="button button-small" onclick="prompt('URL:', jQuery(\'#shortlink\').val()); return false;">' . __ ( 'Get Shortlink' ) . '</a>' ;
}
}
2010-03-09 20:36:38 +01:00
2013-03-29 04:35:41 +01:00
if ( $post_type_object -> public && ! ( 'pending' == get_post_status ( $post ) && ! current_user_can ( $post_type_object -> cap -> publish_posts ) ) ) {
$has_sample_permalink = $sample_permalink_html && 'auto-draft' != $post -> post_status ;
?>
2013-04-17 06:08:46 +02:00
< div id = " edit-slug-box " class = " hide-if-no-js " >
2010-03-15 22:16:41 +01:00
< ? php
2013-03-29 04:35:41 +01:00
if ( $has_sample_permalink )
2010-03-15 22:16:41 +01:00
echo $sample_permalink_html ;
?>
2008-08-20 23:42:31 +02:00
</ div >
2009-05-05 04:14:25 +02:00
< ? php
2010-03-15 22:16:41 +01:00
}
Custom Post Types:
* Introduce `is_post_type_viewable( $post_type_object )`
* Separate the HTML bits from the translatable bits in the `post` messages array in `edit-form-advanced.php`
* Don't show certain UI pieces when a post is not viewable on the front end
When a custom post type item is not viewable on the front end, we don't want to show links to View it (on the front end) all over the admin. We also want to hide the Preview link, et al. We also want our admin messages to not contain said links.
Custom post types with `public_queryable` set to `false` are not viewable on the front end.
`'page'` is viewable on the front end, but `'page'` is a `_builtin` type, and `public_queryable` is set to `false` when it is registered - see `WP::parse_request()` for when `public_queryable` gets used.
This is confusing, but also somewhat straightforward: to determine if a post type is viewable on the front end, we can check one way for `_builtin => true` and another way for `_builtin => false`:
`$post_type->publicly_queryable || ( $post_type->_builtin && $post_type->public )`
If a post type is `publicly_queryable`, it's viewable. If that value is `false`, it is viewable if it's a `_builtin` type that is also `public`.
I am in search of edge cases, so this shall land.
Props wonderboymusic, DrewAPicture.
See #17609.
Built from https://develop.svn.wordpress.org/trunk@33666
git-svn-id: http://core.svn.wordpress.org/trunk@33633 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-08-20 21:40:25 +02:00
endif ;
2010-03-15 22:16:41 +01:00
?>
2008-08-20 23:42:31 +02:00
</ div >
2010-04-18 11:23:03 +02:00
< ? php
wp_nonce_field ( 'samplepermalink' , 'samplepermalinknonce' , false );
?>
2012-09-22 00:52:54 +02:00
</ div ><!-- / titlediv -->
< ? php
}
2013-10-17 00:59:09 +02:00
/**
* Fires after the title field .
*
* @ since 3.5 . 0
*
* @ param WP_Post $post Post object .
*/
2013-07-08 17:45:53 +02:00
do_action ( 'edit_form_after_title' , $post );
2008-08-20 23:42:31 +02:00
2012-09-22 00:52:54 +02:00
if ( post_type_supports ( $post_type , 'editor' ) ) {
?>
2014-08-29 04:28:18 +02:00
< div id = " postdivrich " class = " postarea<?php if ( $_wp_editor_expand ) { echo ' wp-editor-expand'; } ?> " >
2008-08-20 23:42:31 +02:00
2013-04-25 06:06:06 +02:00
< ? php wp_editor ( $post -> post_content , 'content' , array (
2014-11-26 03:50:24 +01:00
'_content_editor_dfw' => $_content_editor_dfw ,
2014-04-02 04:42:16 +02:00
'drag_drop_upload' => true ,
2014-10-24 03:21:18 +02:00
'tabfocus_elements' => 'content-html,save-post' ,
2014-08-26 20:39:17 +02:00
'editor_height' => 300 ,
TinyMCE 4.0.12, first run.
- Removes wp-tinymce-schema.js and mark-loaded.js, no longer needed.
- Removes the inlinepopups and most of the wpdialogs plugins; wpdialog.js is moved to wp-includes/js.
- Adds charmap, compat3x, image, link and textcolor plugins, previously contained in /themes/advanced.
- Updates the wordpress, wpeditimage, wpfullscreen, wpgallery and wplink plugins.
- Updates DFW, wp-admin/js/wp-fullscreen.js.
See #24067.
Built from https://develop.svn.wordpress.org/trunk@26876
git-svn-id: http://core.svn.wordpress.org/trunk@26759 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-29 00:53:15 +01:00
'tinymce' => array (
'resize' => false ,
2014-08-29 04:28:18 +02:00
'wp_autoresize_on' => $_wp_editor_expand ,
2014-01-17 21:35:12 +01:00
'add_unload_trigger' => false ,
TinyMCE 4.0.12, first run.
- Removes wp-tinymce-schema.js and mark-loaded.js, no longer needed.
- Removes the inlinepopups and most of the wpdialogs plugins; wpdialog.js is moved to wp-includes/js.
- Adds charmap, compat3x, image, link and textcolor plugins, previously contained in /themes/advanced.
- Updates the wordpress, wpeditimage, wpfullscreen, wpgallery and wplink plugins.
- Updates DFW, wp-admin/js/wp-fullscreen.js.
See #24067.
Built from https://develop.svn.wordpress.org/trunk@26876
git-svn-id: http://core.svn.wordpress.org/trunk@26759 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-29 00:53:15 +01:00
),
2013-04-25 06:06:06 +02:00
) ); ?>
2014-01-26 21:28:12 +01:00
< table id = " post-status-info " >< tbody >< tr >
2015-09-18 04:32:26 +02:00
< td id = " wp-word-count " class = " hide-if-no-js " >< ? php printf ( __ ( 'Word count: %s' ), '<span class="word-count">0</span>' ); ?> </td>
2009-03-25 15:29:22 +01:00
< td class = " autosave-info " >
2011-05-30 21:53:18 +02:00
< span class = " autosave-message " >& nbsp ; </ span >
2008-08-20 23:42:31 +02:00
< ? php
2012-12-02 00:12:30 +01:00
if ( 'auto-draft' != $post -> post_status ) {
2008-08-20 23:42:31 +02:00
echo '<span id="last-edit">' ;
2013-07-28 22:35:51 +02:00
if ( $last_user = get_userdata ( get_post_meta ( $post_ID , '_edit_last' , true ) ) ) {
2015-12-07 05:26:27 +01:00
printf ( __ ( 'Last edited by %1$s on %2$s at %3$s' ), esc_html ( $last_user -> display_name ), mysql2date ( __ ( 'F j, Y' ), $post -> post_modified ), mysql2date ( __ ( 'g:i a' ), $post -> post_modified ) );
2008-08-20 23:42:31 +02:00
} else {
2015-12-07 05:26:27 +01:00
printf ( __ ( 'Last edited on %1$s at %2$s' ), mysql2date ( __ ( 'F j, Y' ), $post -> post_modified ), mysql2date ( __ ( 'g:i a' ), $post -> post_modified ) );
2008-08-20 23:42:31 +02:00
}
echo '</span>' ;
2009-05-05 04:14:25 +02:00
} ?>
2009-03-25 15:29:22 +01:00
</ td >
TinyMCE 4.0.12, first run.
- Removes wp-tinymce-schema.js and mark-loaded.js, no longer needed.
- Removes the inlinepopups and most of the wpdialogs plugins; wpdialog.js is moved to wp-includes/js.
- Adds charmap, compat3x, image, link and textcolor plugins, previously contained in /themes/advanced.
- Updates the wordpress, wpeditimage, wpfullscreen, wpgallery and wplink plugins.
- Updates DFW, wp-admin/js/wp-fullscreen.js.
See #24067.
Built from https://develop.svn.wordpress.org/trunk@26876
git-svn-id: http://core.svn.wordpress.org/trunk@26759 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-29 00:53:15 +01:00
< td id = " content-resize-handle " class = " hide-if-no-js " >< br /></ td >
2009-03-25 15:29:22 +01:00
</ tr ></ tbody ></ table >
2008-08-20 23:42:31 +02:00
</ div >
2013-03-05 00:22:17 +01:00
< ? php }
2013-10-17 00:59:09 +02:00
/**
* Fires after the content editor .
*
* @ since 3.5 . 0
*
* @ param WP_Post $post Post object .
*/
2013-07-08 17:45:53 +02:00
do_action ( 'edit_form_after_editor' , $post );
2013-03-05 00:22:17 +01:00
?>
2012-03-23 22:41:00 +01:00
</ div ><!-- / post - body - content -->
2008-08-20 23:42:31 +02:00
2012-03-23 22:41:00 +01:00
< div id = " postbox-container-1 " class = " postbox-container " >
< ? php
2013-10-17 00:59:09 +02:00
if ( 'page' == $post_type ) {
/**
* Fires before meta boxes with 'side' context are output for the 'page' post type .
*
* The submitpage box is a meta box with 'side' context , so this hook fires just before it is output .
*
* @ since 2.5 . 0
*
* @ param WP_Post $post Post object .
*/
do_action ( 'submitpage_box' , $post );
}
else {
/**
* Fires before meta boxes with 'side' context are output for all post types other than 'page' .
*
* The submitpost box is a meta box with 'side' context , so this hook fires just before it is output .
*
* @ since 2.5 . 0
*
* @ param WP_Post $post Post object .
*/
do_action ( 'submitpost_box' , $post );
}
2012-03-23 22:41:00 +01:00
do_meta_boxes ( $post_type , 'side' , $post );
?>
</ div >
< div id = " postbox-container-2 " class = " postbox-container " >
< ? php
2011-09-21 08:16:24 +02:00
2011-10-19 23:43:02 +02:00
do_meta_boxes ( null , 'normal' , $post );
2008-08-20 23:42:31 +02:00
2013-10-17 00:59:09 +02:00
if ( 'page' == $post_type ) {
/**
* Fires after 'normal' context meta boxes have been output for the 'page' post type .
*
2013-10-30 15:39:10 +01:00
* @ since 1.5 . 0
2013-10-17 00:59:09 +02:00
*
* @ param WP_Post $post Post object .
*/
do_action ( 'edit_page_form' , $post );
}
else {
/**
* Fires after 'normal' context meta boxes have been output for all post types other than 'page' .
*
2013-10-30 15:39:10 +01:00
* @ since 1.5 . 0
2013-10-17 00:59:09 +02:00
*
* @ param WP_Post $post Post object .
*/
do_action ( 'edit_form_advanced' , $post );
}
2008-08-20 23:42:31 +02:00
2011-10-19 23:43:02 +02:00
do_meta_boxes ( null , 'advanced' , $post );
2008-02-08 19:51:37 +01:00
2012-03-23 22:41:00 +01:00
?>
2005-06-14 09:31:36 +02:00
</ div >
2012-03-23 22:41:00 +01:00
< ? php
2013-10-17 00:59:09 +02:00
/**
* Fires after all meta box sections have been output , before the closing #post-body div.
*
* @ since 2.1 . 0
*
* @ param WP_Post $post Post object .
*/
do_action ( 'dbx_post_sidebar' , $post );
2012-03-23 22:41:00 +01:00
?>
</ div ><!-- / post - body -->
2008-10-23 00:08:58 +02:00
< br class = " clear " />
2008-08-20 23:42:31 +02:00
</ div ><!-- / poststuff -->
2005-09-27 01:55:36 +02:00
</ form >
2008-09-28 06:11:27 +02:00
</ div >
2008-03-15 23:57:47 +01:00
2011-11-05 06:41:25 +01:00
< ? php
if ( post_type_supports ( $post_type , 'comments' ) )
wp_comment_reply ();
?>
2008-08-24 08:56:22 +02:00
2014-12-13 23:08:23 +01:00
< ? php if ( ! wp_is_mobile () && post_type_supports ( $post_type , 'title' ) && '' === $post -> post_title ) : ?>
2008-03-15 23:57:47 +01:00
< script type = " text/javascript " >
try { document . post . title . focus ();} catch ( e ){}
</ script >
< ? php endif ; ?>