/** * Displays the post template meta box. * * @since 1.2.0 * @access public * @param object $object * @param array $box * @return void */ function hybrid_meta_box_post_display_template($post, $box) { $templates = hybrid_get_post_templates($post->post_type); $post_template = hybrid_get_post_template($post->ID); wp_nonce_field(basename(__FILE__), 'hybrid-post-template-nonce'); ?> <p> <select name="hybrid-post-template" class="widefat"> <option value=""></option> <?php foreach ($templates as $label => $template) { ?> <option value="<?php echo esc_attr($template); ?> " <?php selected($post_template, $template); ?> ><?php echo esc_html($label); ?> </option> <?php } ?> </select> </p> <?php }
/** * Displays the post template meta box. * * @since 1.2.0 */ function hybrid_meta_box_post_display_template($object, $box) { /* Get the post type object. */ $post_type_object = get_post_type_object($object->post_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 = hybrid_get_post_templates(array('label' => array("{$post_type_object->labels->singular_name} Template", "{$post_type_object->name} Template"))); } ?> <input type="hidden" name="hybrid-core-post-meta-box-template" value="<?php echo wp_create_nonce(basename(__FILE__)); ?> " /> <p> <?php if (0 != count($templates)) { ?> <select name="hybrid-post-template" id="hybrid-post-template" class="widefat"> <option value=""></option> <?php foreach ($templates as $label => $template) { ?> <option value="<?php echo esc_attr($template); ?> " <?php selected(esc_attr(get_post_meta($object->ID, "_wp_{$post_type_object->name}_template", true)), esc_attr($template)); ?> ><?php echo esc_html($label); ?> </option> <?php } ?> </select> <?php } else { ?> <?php _e('No templates exist for this post type.', hybrid_get_textdomain()); ?> <?php } ?> </p> <?php }
/** * Creates the settings for the post meta box depending on some things in how the theme is * set up. * * @since 0.7 * @param string $type The post_type of the current post in the post editor. */ function hybrid_post_meta_box_args( $type = '' ) { /* Get theme information. */ $prefix = hybrid_get_prefix(); $domain = hybrid_get_textdomain(); /* If no post type is given, default to 'post'. */ if ( empty( $type ) ) $type = 'post'; /* If the disable SEO plugin setting is not selected, allow the input of custom meta. */ if ( !hybrid_get_setting( 'seo_plugin' ) ) { $meta['title'] = array( 'name' => 'Title', 'title' => __( 'Title:', $domain ), 'type' => 'text' ); $meta['description'] = array( 'name' => 'Description', 'title' => __( 'Description:', $domain ), 'type' => 'textarea' ); $meta['keywords'] = array( 'name' => 'Keywords', 'title' => __( 'Keywords:', $domain ), 'type' => 'text' ); } /* Integrates with the custom field series extension. */ if ( function_exists( 'custom_field_series' ) ) $meta['series'] = array( 'name' => 'Series', 'title' => __( 'Series:', $domain ), 'type' => 'text' ); /* Input box for a custom thumbnail. */ $meta['thumbnail'] = array( 'name' => 'Thumbnail', 'title' => __( 'Thumbnail:', $domain ), 'type' => 'text' ); /* If there are any custom post templates, allow the user to select one. */ if ( 'page' != $type && 'attachment' != $type ) { $post_type_object = get_post_type_object( $type ); if ( $post_type_object->singular_label || $post_type_object->name ) { $templates = hybrid_get_post_templates( array( 'label' => array( "{$post_type_object->labels->singular_name} Template", "{$post_type_object->name} Template" ) ) ); if ( 0 != count( $templates ) ) $meta['template'] = array( 'name' => "_wp_{$type}_template", 'title' => __( 'Template:', $domain ), 'type' => 'select', 'options' => $templates, 'use_key_and_value' => true ); } } /* Add post layouts option if current theme supports them. */ if ( current_theme_supports( 'post-layouts' ) ) $meta['post_layout'] = array( 'name' => 'Layout', 'title' => __( 'Layout:', $domain ), 'type' => 'select', 'options' => array( '1c', '2c-l', '2c-r', '3c-l', '3c-r', '3c-c' ) ); /* $prefix_$type_meta_boxes filter is deprecated. Use $prefix_$type_meta_box_args instead. */ $meta = apply_filters( "{$prefix}_{$type}_meta_boxes", $meta ); return apply_filters( "{$prefix}_{$type}_meta_box_args", $meta ); }
/** * Displays the post template meta box. * * @since 1.2.0 * @return void */ function hybrid_meta_box_post_display_template($object, $box) { /* Get the post type object. */ $post_type_object = get_post_type_object($object->post_type); /* Get a list of available custom templates for the post type. */ $templates = hybrid_get_post_templates($object->post_type); wp_nonce_field(basename(__FILE__), 'hybrid-core-post-meta-box-template'); ?> <p> <?php if (0 != count($templates)) { ?> <select name="hybrid-post-template" id="hybrid-post-template" class="widefat"> <option value=""></option> <?php foreach ($templates as $label => $template) { ?> <option value="<?php echo esc_attr($template); ?> " <?php selected(esc_attr(get_post_meta($object->ID, "_wp_{$post_type_object->name}_template", true)), esc_attr($template)); ?> ><?php echo esc_html($label); ?> </option> <?php } ?> </select> <?php } else { ?> <?php _e('No templates exist for this post type.', 'hybrid-core'); ?> <?php } ?> </p> <?php }
/** * 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 hybrid_post_meta_box_args( $type = '' ) { /* Set up some default variables. */ $prefix = hybrid_get_prefix(); $domain = hybrid_get_textdomain(); $meta = array(); /* If no post type is given, default to 'post'. */ if ( empty( $type ) ) $type = 'post'; /* If the current theme supports the 'hybrid-core-seo' feature. */ if ( current_theme_supports( 'hybrid-core-seo' ) ) { $meta['title'] = array( 'name' => 'Title', 'title' => sprintf( __( 'Document Title: %s', $domain ), '<code><title></code>' ), 'type' => 'text' ); $meta['description'] = array( 'name' => 'Description', 'title' => sprintf( __( 'Meta Description: %s', $domain ), '<code><meta></code>' ), 'type' => 'textarea' ); $meta['keywords'] = array( 'name' => 'Keywords', 'title' => sprintf( __( 'Meta Keywords: %s', $domain ), '<code><meta></code>' ), '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 'hybrid-core-template-hierarchy' and is not a page or attachment. */ if ( current_theme_supports( 'hybrid-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 = hybrid_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 ); }