'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' ); ?> $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' ) . '


'; } add_action('save_post', 'pt_save_postdata', 1, 2); function pt_save_postdata($post_id, $post) { if ( !wp_verify_nonce( $_POST['pt_noncename'], plugin_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); } } function getPostViews($postID){ $count_key = 'post_views_count'; $count = get_post_meta($postID, $count_key, true); if($count==''){ delete_post_meta($postID, $count_key); add_post_meta($postID, $count_key, '0'); return "0"; } return $count.''; } function setPostViews($postID) { $count_key = 'post_views_count'; $count = get_post_meta($postID, $count_key, true); if($count==''){ $count = 0; delete_post_meta($postID, $count_key); add_post_meta($postID, $count_key, '0'); }else{ $count++; update_post_meta($postID, $count_key, $count); } } add_filter( 'avatar_defaults', 'new_default_avatar' ); function new_default_avatar ( $avatar_defaults ) { //Set the URL where the image file for your avatar is located $new_avatar_url = get_bloginfo( 'template_directory' ) . '/images/new_default_avatar.png'; //Set the text that will appear to the right of your avatar in Settings>>Discussion $avatar_defaults[$new_avatar_url] = 'Your New Default Avatar'; return $avatar_defaults; } function category_get_top_parent_id ($child = 0) { global $wpdb; if(is_numeric($child) && $child > 0){ $category_parent = $wpdb->get_var("SELECT category_parent FROM $wpdb->categories WHERE cat_ID =$child"); if($category_parent == 0){$result = $child;} else{ $result = category_get_top_parent_id($category_parent);} } else{ $result = 0; } return $result; } ?>