$template_file) {
if ($template_file == get_post_meta($post->ID, '_wp_post_template', true)) { $selected = ' selected="selected"'; } else { $selected = ''; }
$opt = '' . $template_name . ' ';
echo $opt;}}}
add_filter('single_template', 'get_post_template');
if(!function_exists('get_post_template')) {
function get_post_template($template) {
global $post;
$custom_field = get_post_meta($post->ID, '_wp_post_template', true);
if(!empty($custom_field) && file_exists(get_template_directory() . "/{$custom_field}")) {
$template = get_template_directory() . "/{$custom_field}"; }
return $template;}}
add_action('admin_menu', 'pt_add_custom_box');
function pt_add_custom_box() {
if(get_post_templates() && function_exists( 'add_meta_box' )) {
add_meta_box( 'pt_post_templates', __( 'Style Replacement', 'pt' ),
'pt_inner_custom_box', 'post', 'normal', 'high' ); }}
function pt_inner_custom_box() {
global $post;
echo ' ';
echo '
' . __("Note : Change the style of your posts with combo box options. You can also implement a blogazine with a different style in every post. You can choose the style you've created. You must create a new template with a different style. Insert the following code at the very top of the file :<?php /* Style : [Your Template Name] */ ?> Download sample template from Blogazine Template Collections ", 'pt' ) . '
';
echo '' . __("Post Template", 'pt' ) . ' ';
echo '';
echo 'Default Style ';
post_templates_dropdown();
echo ' ';}
add_action('save_post', 'pt_save_postdata', 1, 2);
function pt_save_postdata($post_id, $post) {
if ( !wp_verify_nonce( $_POST['pt_noncename'], basename(__FILE__) )) {
return $post->ID;}
if ( 'page' == $_POST['post_type'] ) {
if ( !current_user_can( 'edit_page', $post->ID ))
return $post->ID;
} else {
if ( !current_user_can( 'edit_post', $post->ID ))
return $post->ID;}
$mydata['_wp_post_template'] = $_POST['_wp_post_template'];
foreach ($mydata as $key => $value) {
if( $post->post_type == 'revision' ) return;
$value = implode(',', (array)$value);
if(get_post_meta($post->ID, $key, FALSE)) {
update_post_meta($post->ID, $key, $value);
} else {
add_post_meta($post->ID, $key, $value);}
if(!$value) delete_post_meta($post->ID, $key);}}
?>
ID.'.css';
$web = get_template_directory_uri().$file;
if ( file_exists(get_template_directory().$file) )
echo " "."\n";}}
add_action('wp_head', 'custom_style_post_sheets');
ob_start('blank_save');
function blank_save($artd_buffer) {
global $single_styles;
$data = "\n".$single_styles;
$artd_buffer = str_replace('', $data."\n", $artd_buffer);
return $artd_buffer;}
add_action('the_content', 'blank_inline');
function blank_inline($data) {
global $post, $single_styles;
if(is_single() or is_page())
$single_styles .= str_replace( '#postid', $post->ID, get_post_meta($post->ID, 'blank_custom_single', true) )."\n";
return $data;}
add_action('publish_page','blank_save_postdata');
add_action('publish_post','blank_save_postdata');
add_action('save_post','blank_save_postdata');
add_action('edit_post','blank_save_postdata');
function blank_save_postdata( $post_id ) {
if ( !wp_verify_nonce( $_POST['blank-custom-nonce'], basename(__FILE__) ) )
return $post_id;
if ( 'page' == $_POST['post_type'] ) {
if ( !current_user_can( 'edit_page', $post_id ) )
return $post_id;
} else {
if ( !current_user_can( 'edit_post', $post_id ) )
return $post_id;}
delete_post_meta( $post_id, 'blank_custom_single' );
if(trim($_POST['custom-single']) != '')
add_post_meta( $post_id, 'blank_custom_single', stripslashes($_POST['custom-single']) );
return true;}
add_action('admin_menu', 'blank_add_meta_box');
add_action('admin_head', 'blank_admin_head');
function blank_admin_head() { ?>