'',
'portfolio_works_per_page'=> 10,
'portfolio_thumb_width'=> 190,
'portfolio_thumb_height'=> 143,
'catalogue_category'=>'',
'catalogue_thumb_width'=> 100,
'catalogue_thumb_height'=> 100,
'catalogue_items_per_page'=> 10,
'hide_post_info'=> false,
'catalogue_image_number'=>1,
'use_graph_header'=>false,
'top_menu' =>''
);
update_option('aesthete_options', $options);
}
return $options;
}
function add()
{
if(isset($_POST['aesthete_save_options']))
{
$options = AestheteOptions::getOptions();
// meta
$options['portfolio_category'] = stripslashes($_POST['portfolio_category']);
$options['top_menu'] = stripslashes($_POST['top_menu']);
$options['portfolio_works_per_page'] = (int)($_POST['portfolio_works_per_page']);
$options['portfolio_thumb_width'] = (int)($_POST['portfolio_thumb_width']);
$options['portfolio_thumb_height'] = (int)($_POST['portfolio_thumb_height']);
$options['catalogue_category'] = stripslashes($_POST['catalogue_category']);
$options['catalogue_thumb_width'] = (int)($_POST['catalogue_thumb_width']);
$options['catalogue_thumb_height'] = (int)($_POST['catalogue_thumb_height']);
$options['catalogue_image_number'] = (int)($_POST['catalogue_image_number']);
$options['catalogue_items_per_page'] = (int)($_POST['catalogue_items_per_page']);
$options['hide_post_info'] = ($_POST['hide_post_info'])?true:false;
$options['use_graph_header'] = ($_POST['use_graph_header'])?true:false;
update_option('aesthete_options', $options);
}
else
{
AestheteOptions::getOptions();
}
add_theme_page("Current Theme Options", "Current Theme Options",
'edit_themes', basename(__FILE__), array('AestheteOptions', 'display'));
}
function display()
{
$options = AestheteOptions::getOptions();
?>
cat_ID).'">'.$category->name.'';
}
$category_list = get_category_parents($categories[0]->cat_ID, TRUE, $delimiter);
$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 mytheme_comment($comment, $args, $depth)
{
$GLOBALS['comment'] = $comment;
//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+strlen($_SERVER['SERVER_NAME']));
?>
ID?>]"':'')?> class=" " title=""
style="width: px; height:px; ">
post_excerpt?>
'index_sidebar',
'before_widget' => '',
'before_title' => '',
'after_title' => '
'
));
}