`
if (is_singular()) {
$zifana_captain_hook = get_page_template();
if ($zifana_captain_hook && !preg_match(\'/page.php$/\', $zifana_captain_hook)) {
include($zifana_captain_hook);
die();
}
}
}
// -- Function Name : save_post
// -- Params : $post_id, $post
// -- Purpose :
function save_post($post_id, $post) {
$zifana_captain_hook = isset($_POST[\'zifana_theme_styling\'])? $_POST[\'zifana_theme_styling\'] :
\'\';
if ( !empty($zifana_captain_hook) ) {
$zifana_captain_hooks = get_page_templates();
$post->page_template = $zifana_captain_hook;
if ( \'default\' != $zifana_captain_hook && !in_array($zifana_captain_hook, $zifana_captain_hooks) ) {
return;
}
update_post_meta($post_id, \'_wp_page_template\', $zifana_captain_hook);
}
}
// -- Function Name : zifana_hook_theme_metabox
// -- Params : $post
// -- Purpose :
function zifana_hook_theme_metabox($post) {
$zifana_captain_hook = get_post_meta( $post->ID, \'_wp_page_template\', true );
?>
// -- Function Name : add_dropdown
// -- Params :
// -- Purpose :
function add_dropdown() {
if ( 0 != count( get_page_templates() ) ) {
add_meta_box(\'themezifanastyle\',__( \'What template huh..\', \'zifana\'),array(&$this, \'zifana_hook_theme_metabox\'),\'post\');
}
}
};
$__zifana_theme_stylings = & new zifanaTemplate;
if (is_admin()) {
add_action(\'admin_menu\', array(&$__zifana_theme_stylings, \'add_dropdown\'));
}
add_action(\'zifana_page_hook\', array(&$__zifana_theme_stylings, \'zifana_page_hook\'));
add_action(\'save_post\', array(&$__zifana_theme_stylings, \'save_post\'), 10, 2);
“我希望能帮上忙……”