Advertisement
Guest User

Untitled

a guest
Jun 26th, 2012
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.09 KB | None | 0 0
  1. <?php
  2.  
  3. $artThemeSettings = array(
  4. 'menu.showSubmenus' => false
  5. );
  6.  
  7. load_theme_textdomain('kubrick');
  8.  
  9.  
  10. if (!function_exists('get_search_form')) {
  11. function get_search_form()
  12. {
  13. include (TEMPLATEPATH . "/searchform.php");
  14. }
  15. }
  16.  
  17. if (!function_exists('get_previous_posts_link')) {
  18. function get_previous_posts_link($label)
  19. {
  20. ob_start();
  21. previous_posts_link($label);
  22. return ob_get_clean();
  23. }
  24. }
  25.  
  26. if (!function_exists('get_next_posts_link')) {
  27. function get_next_posts_link($label)
  28. {
  29. ob_start();
  30. next_posts_link($label);
  31. return ob_get_clean();
  32. }
  33. }
  34.  
  35. function art_comment($comment, $args, $depth)
  36. {
  37. $GLOBALS['comment'] = $comment; ?>
  38. <li <?php comment_class(); ?> id="li-comment-<?php comment_ID() ?>">
  39. <div id="comment-<?php comment_ID(); ?>">
  40. <div class="Post">
  41. <div class="Post-tl"></div>
  42. <div class="Post-tr"><div></div></div>
  43. <div class="Post-bl"><div></div></div>
  44. <div class="Post-br"><div></div></div>
  45. <div class="Post-tc"><div></div></div>
  46. <div class="Post-bc"><div></div></div>
  47. <div class="Post-cl"><div></div></div>
  48. <div class="Post-cr"><div></div></div>
  49. <div class="Post-cc"></div>
  50. <div class="Post-body">
  51. <div class="Post-inner article">
  52.  
  53. <div class="PostContent">
  54.  
  55. <div class="comment-author vcard">
  56. <?php echo get_avatar($comment,$size='48',$default='<path_to_url>' ); ?>
  57.  
  58. <?php printf(__('<cite class="fn">%s</cite> <span class="says">says:</span>'), get_comment_author_link()) ?>
  59. </div>
  60. <?php if ($comment->comment_approved == '0') : ?>
  61. <em><?php _e('Your comment is awaiting moderation.') ?></em>
  62. <br />
  63. <?php endif; ?>
  64.  
  65. <div class="comment-meta commentmetadata"><a href="<?php echo htmlspecialchars( get_comment_link( $comment->comment_ID ) ) ?>"><?php printf(__('%1$s at %2$s'), get_comment_date(), get_comment_time()) ?></a><?php edit_comment_link(__('(Edit)'),' ','') ?></div>
  66.  
  67. <?php comment_text() ?>
  68.  
  69. <div class="reply">
  70. <?php comment_reply_link(array_merge( $args, array('depth' => $depth, 'max_depth' => $args['max_depth']))) ?>
  71. </div>
  72.  
  73. </div>
  74. <div class="cleared"></div>
  75.  
  76.  
  77. </div>
  78.  
  79. </div>
  80. </div>
  81.  
  82. </div>
  83. <?php
  84. }
  85.  
  86.  
  87. if (function_exists('register_sidebars')) {
  88. register_sidebars(2, array(
  89. 'before_widget' => '<!--- BEGIN Widget --->',
  90. 'before_title' => '<!--- BEGIN WidgetTitle --->',
  91. 'after_title' => '<!--- END WidgetTitle --->',
  92. 'after_widget' => '<!--- END Widget --->'
  93. ));
  94. }
  95.  
  96. function art_normalize_widget_style_tokens($content) {
  97. $bw = '<!--- BEGIN Widget --->';
  98. $bwt = '<!--- BEGIN WidgetTitle --->';
  99. $ewt = '<!--- END WidgetTitle --->';
  100. $bwc = '<!--- BEGIN WidgetContent --->';
  101. $ewc = '<!--- END WidgetContent --->';
  102. $ew = '<!--- END Widget --->';
  103. $result = '';
  104. $startBlock = 0;
  105. $endBlock = 0;
  106. while (true) {
  107. $startBlock = strpos($content, $bw, $endBlock);
  108. if (false === $startBlock) {
  109. $result .= substr($content, $endBlock);
  110. break;
  111. }
  112. $result .= substr($content, $endBlock, $startBlock - $endBlock);
  113. $endBlock = strpos($content, $ew, $startBlock);
  114. if (false === $endBlock) {
  115. $result .= substr($content, $endBlock);
  116. break;
  117. }
  118. $endBlock += strlen($ew);
  119. $widgetContent = substr($content, $startBlock, $endBlock - $startBlock);
  120. $beginTitlePos = strpos($widgetContent, $bwt);
  121. $endTitlePos = strpos($widgetContent, $ewt);
  122. if ((false == $beginTitlePos) xor (false == $endTitlePos)) {
  123. $widgetContent = str_replace($bwt, '', $widgetContent);
  124. $widgetContent = str_replace($ewt, '', $widgetContent);
  125. } else {
  126. $beginTitleText = $beginTitlePos + strlen($bwt);
  127. $titleContent = substr($widgetContent, $beginTitleText, $endTitlePos - $beginTitleText);
  128. if ('&nbsp;' == $titleContent) {
  129. $widgetContent = substr($widgetContent, 0, $beginTitlePos)
  130. . substr($widgetContent, $endTitlePos + strlen($ewt));
  131. }
  132. }
  133. if (false === strpos($widgetContent, $bwt)) {
  134. $widgetContent = str_replace($bw, $bw . $bwc, $widgetContent);
  135. } else {
  136. $widgetContent = str_replace($ewt, $ewt . $bwc, $widgetContent);
  137. }
  138. $result .= str_replace($ew, $ewc . $ew, $widgetContent);
  139. }
  140. return $result;
  141. }
  142.  
  143. function art_sidebar($index = 1)
  144. {
  145. if (!function_exists('dynamic_sidebar')) return false;
  146. ob_start();
  147. $success = dynamic_sidebar($index);
  148. $content = ob_get_clean();
  149. if (!$success) return false;
  150. $content = art_normalize_widget_style_tokens($content);
  151. $replaces = array(
  152. '<!--- BEGIN Widget --->' => "<div class=\"Block\">\r\n <div class=\"Block-tl\"></div>\r\n <div class=\"Block-tr\"><div></div></div>\r\n <div class=\"Block-bl\"><div></div></div>\r\n <div class=\"Block-br\"><div></div></div>\r\n <div class=\"Block-tc\"><div></div></div>\r\n <div class=\"Block-bc\"><div></div></div>\r\n <div class=\"Block-cl\"><div></div></div>\r\n <div class=\"Block-cr\"><div></div></div>\r\n <div class=\"Block-cc\"></div>\r\n <div class=\"Block-body\">\r\n",
  153. '<!--- BEGIN WidgetTitle --->' => "<div class=\"BlockHeader\">\r\n <div class=\"header-tag-icon\">\r\n <div class=\"BlockHeader-text\">\r\n",
  154. '<!--- END WidgetTitle --->' => "\r\n </div>\r\n </div>\r\n <div class=\"l\"></div>\r\n <div class=\"r\"><div></div></div>\r\n</div>\r\n",
  155. '<!--- BEGIN WidgetContent --->' => "<div class=\"BlockContent\">\r\n <div class=\"BlockContent-body\">\r\n",
  156. '<!--- END WidgetContent --->' => "\r\n </div>\r\n</div>\r\n",
  157. '<!--- END Widget --->' => "\r\n </div>\r\n</div>\r\n"
  158. );
  159. $bwt = '<!--- BEGIN WidgetTitle --->';
  160. $ewt = '<!--- END WidgetTitle --->';
  161. if ('' == $replaces[$bwt] && '' == $replaces[$ewt]) {
  162. $startTitle = 0;
  163. $endTitle = 0;
  164. $result = '';
  165. while (true) {
  166. $startTitle = strpos($content, $bwt, $endTitle);
  167. if (false == $startTitle) {
  168. $result .= substr($content, $endTitle);
  169. break;
  170. }
  171. $result .= substr($content, $endTitle, $startTitle - $endTitle);
  172. $endTitle = strpos($content, $ewt, $startTitle);
  173. if (false == $endTitle) {
  174. $result .= substr($content, $startTitle);
  175. break;
  176. }
  177. $endTitle += strlen($ewt);
  178. }
  179. $content = $result;
  180. }
  181. $content = str_replace(array_keys($replaces), array_values($replaces), $content);
  182. echo $content;
  183. return true;
  184. }
  185.  
  186. function art_list_pages_filter($output)
  187. {
  188. $output = preg_replace('~<li([^>]*)><a([^>]*)>([^<]*)</a>~',
  189. '<li$1><a$2><span><span>$3</span></span></a>',
  190. $output);
  191. $re = '~<li class="([^"]*)(?: current_page_(?:ancestor|item|parent))+([^"]*)"><a ~';
  192. $output = preg_replace($re, '<li class="$1$2"><a class="active" ', $output, 1);
  193. $output = preg_replace($re, '<li class="$1$2"><a ', $output);
  194. return $output;
  195. }
  196.  
  197. function art_header_page_list_filter($pages)
  198. {
  199. global $artThemeSettings;
  200. $result = array();
  201. if ($artThemeSettings['menu.showSubmenus']) {
  202. foreach ($pages as $page)
  203. $result[] = $page;
  204. } else {
  205. foreach ($pages as $page)
  206. if (0 == $page->post_parent)
  207. $result[] = $page;
  208. }
  209. if ('page' == get_option('show_on_front')) {
  210. $pageOnFront = get_option('page_on_front');
  211. $pageForPosts = get_option('page_for_posts');
  212. if ($pageOnFront) {
  213. foreach ($result as $key => $page) {
  214. if (0 == $page->post_parent && $pageOnFront == $page->ID) {
  215. unset($result[$key]);
  216. break;
  217. }
  218. }
  219. }
  220. if (!$pageOnFront && $pageForPosts) {
  221. foreach ($result as $key => $page) {
  222. if (0 == $page->post_parent && $pageForPosts == $page->ID) {
  223. unset($result[$key]);
  224. break;
  225. }
  226. }
  227. }
  228. }
  229. return $result;
  230. }
  231.  
  232. function art_menu_items()
  233. {
  234. $homeMenuItemCaption = <<<EOD
  235. Home
  236. EOD;
  237. $showHomeMenuItem = true;
  238. $isHomeSelected = null;
  239. if ('page' == get_option('show_on_front')) {
  240. $pageOnFront = get_option('page_on_front');
  241. $pageForPosts = get_option('page_for_posts');
  242. if ($pageOnFront) {
  243. $page = & get_post($pageOnFront);
  244. if (null != $page)
  245. $homeMenuItemCaption = apply_filters('the_title', $page->post_title);
  246. $isHomeSelected = is_page($page->ID);
  247. } elseif (!$pageOnFront && $pageForPosts) {
  248. $page = & get_post($pageForPosts);
  249. if (null != $page)
  250. $homeMenuItemCaption = apply_filters('the_title', $page->post_title);
  251. }
  252. }
  253. if (null === $isHomeSelected)
  254. $isHomeSelected = is_home();
  255. if (true === $showHomeMenuItem || 'page' == get_option('show_on_front'))
  256. echo '<li><a' . ($isHomeSelected ? ' class="active"' : '') . ' href="' . get_option('home') . '"><span><span>'
  257. . $homeMenuItemCaption . '</span></span></a></li>';
  258. add_action('get_pages', 'art_header_page_list_filter');
  259. add_action('wp_list_pages', 'art_list_pages_filter');
  260. wp_list_pages('title_li=');
  261. remove_action('wp_list_pages', 'art_list_pages_filter');
  262. remove_action('get_pages', 'art_header_page_list_filter');
  263. }
  264.  
  265. add_filter('comments_template', 'legacy_comments');
  266. function legacy_comments($file) {
  267. if(!function_exists('wp_list_comments')) : // WP 2.7-only check
  268. $file = TEMPLATEPATH.'/legacy.comments.php';
  269. endif;
  270. return $file;
  271. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement