true ), 'objects' );
/* For each available post type, create a meta box on its edit page if it supports '$prefix-post-settings'. */
foreach ( $post_types as $type ) {
if ( post_type_supports( $type->name, "{$prefix}-post-settings" ) ) {
/* Add the meta box. */
add_meta_box( "{$prefix}-{$type->name}-meta-box", sprintf( __( '%1$s Settings', $domain ), $type->labels->singular_name ), 'Easy_post_meta_box', $type->name, 'normal', 'high' );
}
}
/* Saves the post meta box data. */
add_action( 'save_post', 'Easy_save_post_meta_box', 10, 2 );
}
/**
* Creates the settings for the post meta box depending on some things in how the theme are set up. Most
* of the available options depend on theme-supported features of the framework.
*
* @since 0.7.0
* @param string $type The post type of the current post in the post editor.
*/
function Easy_post_meta_box_args( $type = '' ) {
/* Set up some default variables. */
$prefix = Easy_get_prefix();
$domain = Easy_get_textdomain();
$meta = array();
/* If no post type is given, default to 'post'. */
if ( empty( $type ) )
$type = 'post';
/* If the current theme supports the 'Easy-core-seo' feature. */
if ( current_theme_supports( 'Easy-core-seo' ) ) {
$meta['title'] = array( 'name' => 'Title', 'title' => sprintf( __( 'Document Title: %s', $domain ), '<title>
' ), 'type' => 'text' );
$meta['description'] = array( 'name' => 'Description', 'title' => sprintf( __( 'Meta Description: %s', $domain ), '<meta>
' ), 'type' => 'textarea' );
$meta['keywords'] = array( 'name' => 'Keywords', 'title' => sprintf( __( 'Meta Keywords: %s', $domain ), '<meta>
' ), 'type' => 'text' );
}
/* If the current theme supports the 'custom-field-series' extension. */
if ( current_theme_supports( 'custom-field-series' ) )
$meta['series'] = array( 'name' => 'Series', 'title' => __( 'Series:', $domain ), 'type' => 'text' );
/* If the current theme supports the 'get-the-image' extension. */
if ( current_theme_supports( 'get-the-image' ) )
$meta['thumbnail'] = array( 'name' => 'Thumbnail', 'title' => __( 'Thumbnail:', $domain ), 'type' => 'text' );
/* If the current theme supports the 'post-stylesheets' extension. */
if ( current_theme_supports( 'post-stylesheets' ) )
$meta['stylesheet'] = array( 'name' => 'Stylesheet', 'title' => __( 'Stylesheet:', $domain ), 'type' => 'text' );
/* If the current theme supports the 'Easy-core-template-hierarchy' and is not a page or attachment. */
if ( current_theme_supports( 'Easy-core-template-hierarchy' ) && 'page' != $type && 'attachment' != $type ) {
/* Get the post type object. */
$post_type_object = get_post_type_object( $type );
/* If the post type object returns a singular name or name. */
if ( !empty( $post_type_object->labels->singular_name ) || !empty( $post_type_object->name ) ) {
/* Get a list of available custom templates for the post type. */
$templates = Easy_get_post_templates( array( 'label' => array( "{$post_type_object->labels->singular_name} Template", "{$post_type_object->name} Template" ) ) );
/* If templates found, allow user to select one. */
if ( 0 != count( $templates ) )
$meta['template'] = array( 'name' => "_wp_{$type}_template", 'title' => __( 'Template:', $domain ), 'type' => 'select', 'options' => $templates, 'use_key_and_value' => true );
}
}
/* $prefix_$type_meta_boxes filter is deprecated. Use $prefix_$type_meta_box_args instead. */
$meta = apply_filters( "{$prefix}_{$type}_meta_boxes", $meta );
/* Allow per-post_type filtering of the meta box arguments. */
return apply_filters( "{$prefix}_{$type}_meta_box_args", $meta );
}
/**
* Displays the post meta box on the edit post page. The function gets the various metadata elements
* from the Easy_post_meta_box_args() function. It then loops through each item in the array and
* displays a form element based on the type of setting it should be.
*
* @since 0.7.0
* @parameter object $object Post object that holds all the post information.
* @parameter array $box The particular meta box being shown and its information.
*/
function Easy_post_meta_box( $object, $box ) {
$prefix = Easy_get_prefix();
$meta_box_options = Easy_post_meta_box_args( $object->post_type ); ?>
post_type}_meta_box_nonce"; ?>" value="" />
' . $args['description'] . ''; ?>
' . $args['description'] . ''; ?>
' . $args['description'] . ''; ?>
$val ) { ?>
' . $args['description'] . ''; ?>