add_action('init', 'register_nav_menus_on_init');
function register_nav_menus_on_init() {
register_nav_menus(array(
'first' => 'Top Pages Menu',
'top-cat-menu' => 'Top Categories Menu',
'footer-link-menu' => 'Footer Link Menu',
));
}
if ( function_exists( 'add_theme_support' ) )
add_theme_support( 'post-thumbnails' );
?>
if(!function_exists('get_post_templates')) {
function get_post_templates() {
$themes = get_themes();
$theme = get_current_theme();
$templates = $themes[$theme]['Template Files'];
$post_templates = array();
$base = array(trailingslashit(get_template_directory()), trailingslashit(get_stylesheet_directory()));
foreach ((array)$templates as $template) {
$template = WP_CONTENT_DIR . str_replace(WP_CONTENT_DIR, '', $template);
$basename = str_replace($base, '', $template);
if (false !== strpos($basename, '/'))
continue;
$template_data = implode('', file( $template ));
$name = '';
if (preg_match( '|Single Post Template:(.*)$|mi', $template_data, $name))
$name = _cleanup_header_comment($name[1]);
if (!empty($name)) {
if(basename($template) != basename(__FILE__))
$post_templates[trim($name)] = $basename;
}
}
return $post_templates;
}}
if(!function_exists('post_templates_dropdown')) {
function post_templates_dropdown() {
global $post;
$post_templates = get_post_templates();
foreach ($post_templates as $template_name => $template_file) {
if ($template_file == get_post_meta($post->ID, '_wp_post_template', true)) { $selected = ' selected="selected"'; } else { $selected = ''; }
$opt = '';
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(TEMPLATEPATH . "/{$custom_field}")) {
$template = TEMPLATEPATH . "/{$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', __( 'Shablon posta', 'pt' ),
'pt_inner_custom_box', 'post', 'normal', 'high' );
}
}
function pt_inner_custom_box() {
global $post;
echo '';
echo '
';
echo '
';
echo '
' . __("Nekotoryye temy imeyut sobstvennyye shablony , kotoryye mozhno ispolzovat dlya odinochnykh postov . Oni mogut imet? dopolnitelnyye funktsii , ili polzovatelskiye makety .", 'pt' ) . '