'Clear Line Top Navigation Menu')); } $clear_line_options =null; include ('functions-core.php'); include ('options/options.php'); //delete_option('clear_line_options'); /* Выдает строку с путем до поста (все родительские категории) */ function get_post_path($post_id,$delimiter, $links=true) { $out =''; $categories = &get_the_category($post_id); if (!$categories) return ''; //TODO: проверять на is_attachment и выводить путь до поста. if (is_array($categories)) { foreach ($categories as $category) { if ($out) $out .= ', '; $out .= (($links)?'':'').$category->name.(($links)?'':''); //echo "out=";var_dump($out); echo "
"; } $category_list = get_category_parents($categories[0]->cat_ID, $links, $delimiter); if (is_string($category_list)) { //var_dump($category_list); $category_list =substr($category_list,0, strrpos($category_list,$delimiter)); $category_list =substr($category_list,0, strrpos($category_list,$delimiter)); if ($category_list) $out = $category_list . $delimiter . $out; } } return $out; } /* @param $post_id int @param $category int определяет, находится ли пост в заданной корневой категории */ function in_root_category($post_id, $root_category_id='') { $categories = &get_the_category($post_id); if (is_array($categories)) { foreach ($categories as $category) { if ($root_category_id == get_root_category($category->cat_ID)) return true; } } return false; } /* returns category IDs of the post separated by comma */ function get_post_categories_list($post_id) { $categories = &get_the_category($post_id); $out=''; foreach ($categories as $category) { if ($out) $out .= ', '; $out .= $category->cat_ID; } return $out; } function get_post_category_names_list($post_id) { $categories = &get_the_category($post_id); $out=''; foreach ($categories as $category) { if ($out) $out .= ', '; $out .= $category->name; } return $out; } function get_post_root_category($post_id) { $categories = &get_the_category($post_id); if (is_array($categories)) { foreach ($categories as $category_id) { return get_root_category($category_id); } } return false; } function get_root_category($category_id='') { $category = &get_category( $category_id ); if ($category->parent) { $parent_id = get_root_category($category->parent); //echo "+"; print_r($parent); return $parent_id; } else return $category_id; } function post_has_immage($post) { return (bool)preg_match('//i', $post->post_content); } // не проверялась! function catch_that_image() { global $post; $first_img = ''; $output = preg_match_all('//i', $post->post_content, $matches); $first_img = $matches [1] [0]; if(empty($first_img)){ //определяем картинку по умолчанию $first_img = "/images/default.jpg"; } return $first_img; } // custom comments function clearline_comment($comment, $args, $depth) { $GLOBALS['comment'] = $comment; $options = & ClearLineOptions::getOptions(); $shortname = & ClearLineOptions::cfg('shortname'); //print_r($comment); ?>
  • id="comment-">
    comment_approved == '0') : ?>
    $depth, 'max_depth' => $args['max_depth']))) ?>
    var m=' . $js_email .';' . 'document.write(\'\'+' . (($text)?'\''.$text.'\'':'m') . '+\'\');'; return $js; } function get_tags_for_post($post_id, $type='post_tag') { $tags = get_the_terms($post_id,$type); $tag_list=''; if (is_array($tags)) foreach ($tags as $tag) $tag_list .= ' '.$tag->name; return $tag_list; } function fix_caption_width($x=null, $attr, $content) { $xs= 8; //add 8px to image width extract(shortcode_atts(array( 'id' => '', 'align' => 'alignnone', 'width' => '', 'caption' => '' ), $attr)); if ( 1 > (int) $width || empty($caption) ) { return $content; } if ( $id ) $id = 'id="' . $id . '" '; return '
    ' . $content . '

    ' . $caption . '

    '; } // #######################################################################################3 function draw_image_thumb($args) { global $post; $defaults = array( 'max_width' => 700, 'max_height' => 700, 'caption' => false, 'align'=>'alignnone', 'link_to' => 'post', 'thumb_only'=>false, 'fit_entire_size'=>true, 'img'=>null, 'margin'=>false, 'aclass'=>'agallery wp-caption', 'padding'=>4, ); $r = wp_parse_args( $args, $defaults ); $awidth = $r['max_width']; $aheight = $r['max_height']; if ($r['caption']) $aheight +=22; $pad=$r['padding']; //padding; if ($r['img']) $img =$r['img']; else { $args = array( 'post_parent' => $post->ID, 'post_type' => 'attachment', 'post_mime_type' => image, 'order' => 'ASC', 'orderby' => 'menu_order ID' ); $images =& get_children( $args ); if (($images)) { $found_thumb=false; foreach ( $images as $attachment_id => $attachment ) { if (preg_match('/thumb/i',$attachment->post_name)) { $found_thumb=true; $img = wp_get_attachment_image_src( $attachment_id,'full'); break; } } if (!$found_thumb && !$thumb_only) { foreach ( $images as $attachment_id => $attachment ) { $img = wp_get_attachment_image_src( $attachment_id,'full'); break; } } } else return; } $h = round(min($img[2]*$r['max_width']/$img[1],$r['max_height'])); $w = round(min($img[1]*$h/$img[2],$r['max_width'])); //echo "h=$h, w=$w "; $img_url = substr($img[0], 7); $img_url = substr($img_url, strpos($img_url,'/')); //echo $img_url; ?> ID . ']"':'')?> class=" " title="" style="width: px; height:px; ">

    post_excerpt?>

    \n"; } function addThemeStyles() { $time = ClearLineOptions::getOptions('last_update_time'); if (strpos($_SERVER["SERVER_NAME"], 'wp-themes.com') !== false) wp_enqueue_style('vtm-theme-css', get_bloginfo('stylesheet_directory').'/sample.css'); else wp_enqueue_style('vtm-theme-css', get_option('home').'/index.php?vtm-theme=css&lud='.$time.'&layout='.ClearLineOptions::getLayoutCSS()); } function echoPostInfo($column = false) { $options = & ClearLineOptions::getOptions(); $shortname = & ClearLineOptions::cfg('shortname'); ?> post->ID; $url = get_post_meta($postid, '_short_url', true); if (!$url) { $url = wp_remote_retrieve_body( wp_remote_get( 'http://api.bit.ly/api?url=' . $long_url ) ); } if (!$url) { return sprintf('%s?p=%s', get_bloginfo('url'),$postid); } add_post_meta( $postid, '_short_url', $url); return $url; } else { $r = wp_remote_get('http://api.bit.ly/api?url=' . urlencode($long_url) ); $url = wp_remote_retrieve_body($r); if ( is_wp_error($url) ) { $error_string = $url->get_error_message(); echo '

    ' . $error_string . '

    '; } if (!$url) { return $long_url; } //return $long_url; return $url; } } function get_seo_meta() { global $wp_query; $options = & ClearLineOptions::getOptions(); $shortname = & ClearLineOptions::cfg('shortname'); if (is_home () ) { $title=$options[$shortname . '_seo_home_title']; if (!$title) $title = get_bloginfo('name') . ' - ' . get_bloginfo('description'); $description=$options[$shortname . '_seo_home_description']; $keywords=$options[$shortname . '_seo_home_keywords']; } elseif ( is_category() ) { $title_format=$options[$shortname . '_seo_category_title_format']; $title = str_replace( array('%blog_title%', '%blog_description%', '%category%', '%category_description%'), array(get_bloginfo('name'), get_bloginfo('description'), single_cat_title('',false), category_description()), $title_format ); $description = category_description(); $keywords = $description; } elseif (is_single() ) { $post_id = $wp_query->post->ID; $categories = get_post_path($post_id,'―', false); $title_format=$options[$shortname . '_seo_post_title_format']; $title = str_replace( array('%blog_title%', '%blog_description%', '%category%', '%post_title%'), array(get_bloginfo('name'), get_bloginfo('description'), $categories, single_post_title('',false)), $title_format ); $description = get_the_excerpt(); $keywords = $description . ', '. $categories; } elseif (is_page() ) { $title_format=$options[$shortname . '_seo_page_title_format']; $title = str_replace( array('%blog_title%', '%blog_description%', '%page_title%'), array(get_bloginfo('name'), get_bloginfo('description'), single_post_title('',false)), $title_format ); $description = ''; $keywords = single_post_title('',false) . ' ' . get_bloginfo('name') . ' ' . get_bloginfo('description'); } elseif(is_tag()) { $title_format=$options[$shortname . '_seo_tag_title_format']; $title = str_replace( array('%blog_title%', '%blog_description%', '%tag%'), array(get_bloginfo('name'), get_bloginfo('description'), single_cat_title('',false)), $title_format ); $description = ''; } else { $title = wp_title(' - ',false,'right') . ' '. get_bloginfo('description') ; $description = get_bloginfo('description'); $keywords = $title; } return (array( 'title' => str_replace('"','',strip_tags($title)), 'description' => str_replace('"','',strip_tags($description)), 'keywords' => str_replace('"','',strip_tags($keywords)) ) ); } function echo_share_this($show = null) { $options = & ClearLineOptions::getOptions(); $shortname = & ClearLineOptions::cfg('shortname'); $social_theme = $options[$shortname . '_social_buttons_theme']; if (!$show) { $show = array('rss'=>1,'delicious'=>1,'digg'=>1, 'facebook'=>1, 'stumbleupon'=>1,'reddit'=>1,'twitter'=>1); } if (!is_array($show)) { $options = & ClearLineOptions::getOptions(); $shortname = & ClearLineOptions::cfg('shortname'); $option_name = $shortname . $show; if ($options[$option_name . '_show'] != 'yes') return; $show = array( 'delicious'=> ($options[$option_name . '_services_'. 'delicious']=='on'), 'digg'=> ($options[$option_name . '_services_'. 'digg']=='on'), 'facebook'=> ($options[$option_name . '_services_'. 'facebook']=='on'), 'stumbleupon'=> ($options[$option_name . '_services_'. 'stumbleupon']=='on'), 'reddit'=> ($options[$option_name . '_services_'. 'reddit']=='on'), 'twitter'=> ($options[$option_name . '_services_'. 'twitter']=='on') ); } $template_url = get_bloginfo('template_url'); ?>
    '.$options[$shortname . '_excerpt_more_link_text'] .''; return $text; } function echo_regular_post() { $options = & ClearLineOptions::getOptions(); $shortname = & ClearLineOptions::cfg('shortname'); $has_excerpt = has_excerpt(); ?>
    >

    have_posts()) { while ($wpq->have_posts()) : $wpq->the_post(); $id=get_the_ID(); if (!isset($displayed_ids[$id])) { $count++; $ids[$id] = $id; echo_regular_post(); } endwhile; } return array('count'=>$count, 'ids'=>$ids); } function display_column_posts($wpq = null, $rows = -1) // wpq - WP_Query object // rows = 0 - get from the theme options // rows = -1 - show all posts in column // returns displayed post ids and number of displayed posts { global $wp_query; if (!$wpq) $wpq = & $wp_query; $options = & ClearLineOptions::getOptions(); $shortname = & ClearLineOptions::cfg('shortname'); $ids = array(); $count=0; $col = 0; if ($rows == 0) $row = $options[$shortname.'_post_list_column_rows']; elseif ($rows == -1) $row = 999999; else $row = $rows; if ($wpq->have_posts()) { while ($wpq->have_posts() && $row > 0) : $wpq->the_post(); $count++; $id=get_the_ID(); $ids[$id] = $id; if ($col == 0) $col = $options[$shortname.'_post_list_column_count']; if ($col>=1 ) { echo_column_post(); $col--; } if ($col == 0) { echo '
    '; $row--; } endwhile; } return array('count'=>$count, 'ids'=>$ids); } function header_style() { $options = & ClearLineOptions::getOptions(); $shortname = & ClearLineOptions::cfg('shortname'); ?>'; } function vtm_remove_version() { return ''; } if (is_admin()) { wp_enqueue_script('vtm-colorpicker', get_bloginfo('stylesheet_directory').'/options/js/colorpicker.js'); wp_enqueue_style ('vtm-colorpicker1', get_bloginfo('stylesheet_directory').'/options/js/css/colorpicker.css'); //wp_enqueue_script('colorpicker'); } if (!is_admin()) { /** * Parse request * * @param unknown_type $wp */ function vtm_theme_parse_request() { $param = get_query_var('vtm-theme'); switch ($param) { case 'css': //require_once 'options/css.php'; get_template_part( 'options/css'); die(); // die after return data } } add_action('template_redirect', 'vtm_theme_parse_request'); //add_action('wp', 'vtm_theme_parse_request'); function vtm_register_query_vars($vars) { $vars[] = 'vtm-theme'; $vars[] = 'lud'; //last updated date $vars[] = 'layout'; return $vars; } add_filter('query_vars', 'vtm_register_query_vars'); } add_filter('excerpt_length', 'vtm_excerpt_length'); // add a favicon to your add_action('wp_head', 'blog_favicon'); add_filter('the_generator', 'vtm_remove_version'); if (function_exists('add_theme_support')) add_theme_support( 'post-thumbnails' ); if (function_exists('set_post_thumbnail_size')) set_post_thumbnail_size( $options[$shortname . '_normal_thumbnail_size_x'], $options[$shortname . '_normal_thumbnail_size_y']); if (function_exists('add_image_size')) add_image_size( 'column-thumbnail', $options[$shortname . '_column_thumbnail_size_x'], $options[$shortname . '_column_thumbnail_size_y'],true ); // Permalink thumbnail size //var_dump ($shortname . '_column_thumbnail_size_x'); //var_dump ($options[$shortname . '_column_thumbnail_size_y']); add_filter('img_caption_shortcode', 'fix_caption_width', 10, 3); //add_filter( 'comments_template', 'legacy_comments' ); add_action ('init', 'theme_init'); add_action('admin_menu', array('ClearLineOptions', 'adminMenu')); add_action('admin_head', 'admin_register_head'); if (function_exists('add_theme_support')) add_theme_support('automatic-feed-links'); if (function_exists('add_custom_background')) add_custom_background(); define('HEADER_TEXTCOLOR', ''); //define('HEADER_IMAGE', '%s/img/header/tree-small.jpg'); // %s is the template dir uri define('HEADER_IMAGE_WIDTH', $options[$shortname . '_header_image_size_x']); // use width and height appropriate for your theme define('HEADER_IMAGE_HEIGHT', $options[$shortname . '_header_image_size_y']); define('NO_HEADER_TEXT', true ); add_custom_image_header('header_style', 'admin_header_style'); add_action('wp_head', 'addThemeStyles', 1); add_filter('get_the_excerpt', 'trim_excerpt'); if( function_exists('register_sidebar') ) { register_sidebar(array( 'name' => 'Blue Sidebar', 'before_widget' => '
    ', 'after_widget' => '
    ', 'before_title' => '
    ', 'after_title' => '
    ' )); register_sidebar(array( 'name' => 'Cyan Sidebar', 'before_widget' => '
    ', 'after_widget' => '
    ', 'before_title' => '
    ', 'after_title' => '
    ' )); register_sidebar(array( 'name' => 'Green Sidebar', 'before_widget' => '
    ', 'after_widget' => '
    ', 'before_title' => '
    ', 'after_title' => '
    ' )); register_sidebar(array( 'name' => 'Orange Sidebar', 'before_widget' => '
    ', 'after_widget' => '
    ', 'before_title' => '
    ', 'after_title' => '
    ' )); register_sidebar(array( 'name' => 'Red Sidebar', 'before_widget' => '
    ', 'after_widget' => '
    ', 'before_title' => '
    ', 'after_title' => '
    ' )); register_sidebar(array( 'name' => 'Blue Footer', 'before_widget' => '
    ', 'after_widget' => '
    ', 'before_title' => '
    ', 'after_title' => '
    ' )); register_sidebar(array( 'name' => 'Green Footer', 'before_widget' => '
    ', 'after_widget' => '
    ', 'before_title' => '
    ', 'after_title' => '
    ' )); register_sidebar(array( 'name' => 'Orange Footer', 'before_widget' => '
    ', 'after_widget' => '
    ', 'before_title' => '
    ', 'after_title' => '
    ' )); register_sidebar(array( 'name' => 'Red Footer', 'before_widget' => '
    ', 'after_widget' => '
    ', 'before_title' => '
    ', 'after_title' => '
    ' )); register_sidebar(array( 'name' => 'Before Columns on Index Page', 'before_widget' => '
    ', 'after_widget' => '
    ', 'before_title' => '
    ', 'after_title' => '
    ' )); register_sidebar(array( 'name' => 'Footer Counters', 'before_widget' => '
    ', 'after_widget' => '
    ', 'before_title' => '', 'after_title' => '' )); if ( ! isset( $content_width ) ) $content_width = 640; }