* @copyright Copyright (c) 2008 - 2015, Justin Tadlock * @link http://themehybrid.com/hybrid-core * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html */ # Add the post stylesheets meta box on the 'add_meta_boxes' hook. add_action( 'add_meta_boxes', 'hybrid_add_post_style_meta_box', 10, 2 ); # Saves the post meta box data. add_action( 'save_post', 'hybrid_save_post_style', 10, 2 ); add_action( 'add_attachment', 'hybrid_save_post_style' ); add_action( 'edit_attachment', 'hybrid_save_post_style' ); /** * Adds the style meta box. * * @since 3.0.0 * @access public * @param string $post_type * @param object $post * @return void */ function hybrid_add_post_style_meta_box( $post_type, $post ) { $styles = hybrid_get_post_styles( $post_type ); if ( ! empty( $styles ) && current_user_can( 'edit_theme_options' ) ) add_meta_box( 'hybrid-post-style', esc_html__( 'Style', 'hybrid-core' ), 'hybrid_post_style_meta_box', $post_type, 'side', 'default' ); } /** * Callback function for displaying the style meta box. * * @since 3.0.0 * @access public * @param object $object * @param array $box * @return void */ function hybrid_post_style_meta_box( $post, $box ) { $styles = hybrid_get_post_styles( $post->post_type ); $post_style = hybrid_get_post_style( $post->ID ); wp_nonce_field( basename( __FILE__ ), 'hybrid-post-style-nonce' ); ?>