Advertisement
alchymyth

Untitled

Mar 25th, 2011
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 18.29 KB | None | 0 0
  1. <?php
  2.  
  3. $artThemeSettings = array(
  4. 'menu.showSubmenus' => true,
  5. 'menu.homeCaption' => "Home",
  6. 'menu.showHome' => true,
  7. 'menu.topItemBegin' => "<span class=\"l\"></span><span class=\"r\"></span><span class=\"t\">",
  8. 'menu.topItemEnd' => "</span>"
  9. );
  10.  
  11. load_theme_textdomain('kubrick');
  12.  
  13. $themename = "animeseven2";
  14. $shortname = "artisteer";
  15. $default_footer_content = "<a href='#'>Contact Us</a> | <a href='#'>Terms of Use</a> | <a href='#'>Trademarks</a> | <a href='#'>Privacy Statement</a><br />Copyright &copy; 2009 ".get_bloginfo('name').". All Rights Reserved.";
  16. $options = array (
  17. array( "name" => "HTML",
  18. "desc" => sprintf(__('<strong>XHTML:</strong> You can use these tags: <code>%s</code>', 'kubrick'), 'a, abbr, acronym, em, b, i, strike, strong, span'),
  19. "id" => "art_footer_content",
  20. "std" => $default_footer_content,
  21. "type" => "textarea")
  22. );
  23.  
  24.  
  25. function art_update_option($key, $value){
  26. update_option($key, (get_magic_quotes_gpc()) ? stripslashes($value) : $value);
  27. }
  28.  
  29. function art_add_admin() {
  30.  
  31.  
  32.  
  33. global $themename, $shortname, $options;
  34.  
  35. if ( $_GET['page'] == basename(__FILE__) ) {
  36.  
  37. if ('save' == $_REQUEST['action'] ) {
  38.  
  39. foreach ($options as $value) {
  40. if($value['type'] != 'multicheck'){
  41. art_update_option( $value['id'], $_REQUEST[ $value['id'] ] );
  42. }else{
  43. foreach($value['options'] as $mc_key => $mc_value){
  44. $up_opt = $value['id'].'_'.$mc_key;
  45. art_update_option($up_opt, $_REQUEST[$up_opt] );
  46. }
  47. }
  48. }
  49. foreach ($options as $value) {
  50. if($value['type'] != 'multicheck'){
  51. if( isset( $_REQUEST[ $value['id'] ] ) ) { art_update_option( $value['id'], $_REQUEST[ $value['id'] ] ); } else { delete_option( $value['id'] ); }
  52. }else{
  53. foreach($value['options'] as $mc_key => $mc_value){
  54. $up_opt = $value['id'].'_'.$mc_key;
  55. if( isset( $_REQUEST[ $up_opt ] ) ) { art_update_option( $up_opt, $_REQUEST[ $up_opt ] ); } else { delete_option( $up_opt ); }
  56. }
  57. }
  58. }
  59. header("Location: themes.php?page=functions.php&saved=true");
  60. die;
  61. }
  62. }
  63.  
  64. add_theme_page("Footer", "Footer", 'edit_themes', basename(__FILE__), 'art_admin');
  65.  
  66. }
  67.  
  68. function art_admin() {
  69. global $themename, $shortname, $options;
  70. if ( $_REQUEST['saved'] ) echo '<div id="message" class="updated fade"><p><strong>'.$themename.' settings saved.</strong></p></div>';
  71. ?>
  72. <div class="wrap">
  73. <h2>Footer</h2>
  74.  
  75. <form method="post">
  76.  
  77. <table class="optiontable" style="width:100%;">
  78.  
  79. <?php foreach ($options as $value) {
  80.  
  81. switch ( $value['type'] ) {
  82. case 'text':
  83. option_wrapper_header($value);
  84. ?>
  85. <input style="width:100%;" name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>" type="<?php echo $value['type']; ?>" value="<?php if ( get_settings( $value['id'] ) != "") { echo get_settings( $value['id'] ); } else { echo $value['std']; } ?>" />
  86. <?php
  87. option_wrapper_footer($value);
  88. break;
  89.  
  90. case 'select':
  91. option_wrapper_header($value);
  92. ?>
  93. <select style="width:70%;" name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>">
  94. <?php foreach ($value['options'] as $option) { ?>
  95. <option<?php if ( get_settings( $value['id'] ) == $option) { echo ' selected="selected"'; } elseif ($option == $value['std']) { echo ' selected="selected"'; } ?>><?php echo $option; ?></option>
  96. <?php } ?>
  97. </select>
  98. <?php
  99. option_wrapper_footer($value);
  100. break;
  101.  
  102. case 'textarea':
  103. $ta_options = $value['options'];
  104. option_wrapper_header($value);
  105. ?>
  106. <textarea name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>" style="width:100%;height:100px;"><?php
  107. if( get_settings($value['id']) !== false) {
  108. echo get_settings($value['id']);
  109. }else{
  110. echo $value['std'];
  111. }?></textarea>
  112. <?php
  113. option_wrapper_footer($value);
  114. break;
  115.  
  116. case "radio":
  117. option_wrapper_header($value);
  118.  
  119. foreach ($value['options'] as $key=>$option) {
  120. $radio_setting = get_settings($value['id']);
  121. if($radio_setting != ''){
  122. if ($key == get_settings($value['id']) ) {
  123. $checked = "checked=\"checked\"";
  124. } else {
  125. $checked = "";
  126. }
  127. }else{
  128. if($key == $value['std']){
  129. $checked = "checked=\"checked\"";
  130. }else{
  131. $checked = "";
  132. }
  133. }?>
  134. <input type="radio" name="<?php echo $value['id']; ?>" value="<?php echo $key; ?>" <?php echo $checked; ?> /><?php echo $option; ?><br />
  135. <?php
  136. }
  137.  
  138. option_wrapper_footer($value);
  139. break;
  140.  
  141. case "checkbox":
  142. option_wrapper_header($value);
  143. if(get_settings($value['id'])){
  144. $checked = "checked=\"checked\"";
  145. }else{
  146. $checked = "";
  147. }
  148. ?>
  149. <input type="checkbox" name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>" value="true" <?php echo $checked; ?> />
  150. <?php
  151. option_wrapper_footer($value);
  152. break;
  153.  
  154. case "multicheck":
  155. option_wrapper_header($value);
  156.  
  157. foreach ($value['options'] as $key=>$option) {
  158. $pn_key = $value['id'] . '_' . $key;
  159. $checkbox_setting = get_settings($pn_key);
  160. if($checkbox_setting != ''){
  161. if (get_settings($pn_key) ) {
  162. $checked = "checked=\"checked\"";
  163. } else {
  164. $checked = "";
  165. }
  166. }else{
  167. if($key == $value['std']){
  168. $checked = "checked=\"checked\"";
  169. }else{
  170. $checked = "";
  171. }
  172. }?>
  173. <input type="checkbox" name="<?php echo $pn_key; ?>" id="<?php echo $pn_key; ?>" value="true" <?php echo $checked; ?> /><label for="<?php echo $pn_key; ?>"><?php echo $option; ?></label><br />
  174. <?php
  175. }
  176.  
  177. option_wrapper_footer($value);
  178. break;
  179.  
  180. case "heading":
  181. ?>
  182. <tr valign="top">
  183. <td colspan="2" style="text-align: center;"><h3><?php echo $value['name']; ?></h3></td>
  184. </tr>
  185. <?php
  186. break;
  187.  
  188. default:
  189.  
  190. break;
  191. }
  192. }
  193. ?>
  194.  
  195. </table>
  196.  
  197. <p class="submit">
  198. <input name="save" type="submit" value="Save changes" />
  199. <input type="hidden" name="action" value="save" />
  200. </p>
  201. </form>
  202. </div>
  203. <?php
  204. }
  205.  
  206. function option_wrapper_header($values){
  207. ?>
  208. <tr valign="top">
  209. <th scope="row" style="width:1%;white-space: nowrap;"><?php echo $values['name']; ?>:</th>
  210. <td>
  211. <?php
  212. }
  213.  
  214. function option_wrapper_footer($values){
  215. ?>
  216. </td>
  217. </tr>
  218. <tr valign="top">
  219. <td>&nbsp;</td><td><small><?php echo $values['desc']; ?></small></td>
  220. </tr>
  221. <?php
  222. }
  223.  
  224.  
  225. add_action('admin_menu', 'art_add_admin');
  226.  
  227. if (!function_exists('get_search_form')) {
  228. function get_search_form()
  229. {
  230. include (TEMPLATEPATH . "/searchform.php");
  231. }
  232. }
  233.  
  234. if (!function_exists('get_previous_posts_link')) {
  235. function get_previous_posts_link($label)
  236. {
  237. ob_start();
  238. previous_posts_link($label);
  239. return ob_get_clean();
  240. }
  241. }
  242.  
  243. if (!function_exists('get_next_posts_link')) {
  244. function get_next_posts_link($label)
  245. {
  246. ob_start();
  247. next_posts_link($label);
  248. return ob_get_clean();
  249. }
  250. }
  251.  
  252. if (!function_exists('get_previous_post_link')) {
  253. function get_previous_post_link($label1, $label2, $label3)
  254. {
  255. ob_start();
  256. previous_post_link($label1, $label2, $label3);
  257. return ob_get_clean();
  258. }
  259. }
  260.  
  261. if (!function_exists('get_next_post_link')) {
  262. function get_next_post_link($label1, $label2, $label3)
  263. {
  264. ob_start();
  265. next_post_link($label1, $label2, $label3);
  266. return ob_get_clean();
  267. }
  268. }
  269.  
  270. function art_comment($comment, $args, $depth)
  271. {
  272. $GLOBALS['comment'] = $comment; ?>
  273. <li <?php comment_class(); ?> id="li-comment-<?php comment_ID() ?>">
  274. <div id="comment-<?php comment_ID(); ?>">
  275. <div class="art-Post">
  276. <div class="art-Post-body">
  277. <div class="art-Post-inner art-article">
  278.  
  279. <div class="art-PostContent">
  280.  
  281. <div class="comment-author vcard">
  282. <?php echo get_avatar($comment,$size='48',$default='<path_to_url>' ); ?>
  283. <cite class="fn"><?php comment_author_link(); ?>:</cite>
  284. </div>
  285. <?php if ($comment->comment_approved == '0') : ?>
  286. <em><?php _e('Your comment is awaiting moderation.') ?></em>
  287. <br />
  288. <?php endif; ?>
  289.  
  290. <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', 'kubrick').')',' ','') ?></div>
  291.  
  292. <?php comment_text() ?>
  293.  
  294. <div class="reply">
  295. <?php comment_reply_link(array_merge( $args, array('depth' => $depth, 'max_depth' => $args['max_depth']))) ?>
  296. </div>
  297.  
  298. </div>
  299. <div class="cleared"></div>
  300.  
  301.  
  302. </div>
  303.  
  304. <div class="cleared"></div>
  305. </div>
  306. </div>
  307.  
  308. </div>
  309. <?php
  310. }
  311.  
  312.  
  313. if (function_exists('register_sidebars')) {
  314. register_sidebars(2, array(
  315. 'before_widget' => '<div id="%1$s" class="widget %2$s">'.'<!--- BEGIN Widget --->',
  316. 'before_title' => '<!--- BEGIN WidgetTitle --->',
  317. 'after_title' => '<!--- END WidgetTitle --->',
  318. 'after_widget' => '<!--- END Widget --->'.'</div>'
  319. ));
  320. }
  321.  
  322. function art_normalize_widget_style_tokens($content) {
  323. $bw = '<!--- BEGIN Widget --->';
  324. $bwt = '<!--- BEGIN WidgetTitle --->';
  325. $ewt = '<!--- END WidgetTitle --->';
  326. $bwc = '<!--- BEGIN WidgetContent --->';
  327. $ewc = '<!--- END WidgetContent --->';
  328. $ew = '<!--- END Widget --->';
  329. $result = '';
  330. $startBlock = 0;
  331. $endBlock = 0;
  332. while (true) {
  333. $startBlock = strpos($content, $bw, $endBlock);
  334. if (false === $startBlock) {
  335. $result .= substr($content, $endBlock);
  336. break;
  337. }
  338. $result .= substr($content, $endBlock, $startBlock - $endBlock);
  339. $endBlock = strpos($content, $ew, $startBlock);
  340. if (false === $endBlock) {
  341. $result .= substr($content, $endBlock);
  342. break;
  343. }
  344. $endBlock += strlen($ew);
  345. $widgetContent = substr($content, $startBlock, $endBlock - $startBlock);
  346. $beginTitlePos = strpos($widgetContent, $bwt);
  347. $endTitlePos = strpos($widgetContent, $ewt);
  348. if ((false == $beginTitlePos) xor (false == $endTitlePos)) {
  349. $widgetContent = str_replace($bwt, '', $widgetContent);
  350. $widgetContent = str_replace($ewt, '', $widgetContent);
  351. } else {
  352. $beginTitleText = $beginTitlePos + strlen($bwt);
  353. $titleContent = substr($widgetContent, $beginTitleText, $endTitlePos - $beginTitleText);
  354. if ('&nbsp;' == $titleContent) {
  355. $widgetContent = substr($widgetContent, 0, $beginTitlePos)
  356. . substr($widgetContent, $endTitlePos + strlen($ewt));
  357. }
  358. }
  359. if (false === strpos($widgetContent, $bwt)) {
  360. $widgetContent = str_replace($bw, $bw . $bwc, $widgetContent);
  361. } else {
  362. $widgetContent = str_replace($ewt, $ewt . $bwc, $widgetContent);
  363. }
  364. $result .= str_replace($ew, $ewc . $ew, $widgetContent);
  365. }
  366. return $result;
  367. }
  368.  
  369. function art_sidebar($index = 1)
  370. {
  371. if (!function_exists('dynamic_sidebar')) return false;
  372. ob_start();
  373. $success = dynamic_sidebar($index);
  374. $content = ob_get_clean();
  375. if (!$success) return false;
  376. $content = art_normalize_widget_style_tokens($content);
  377. $replaces = array(
  378. '<!--- BEGIN Widget --->' => "<div class=\"art-Block\">\r\n <div class=\"art-Block-body\">\r\n",
  379. '<!--- BEGIN WidgetTitle --->' => "<div class=\"art-BlockHeader\">\r\n <div class=\"l\"></div>\r\n <div class=\"r\"></div>\r\n <div class=\"art-header-tag-icon\">\r\n <div class=\"t\">",
  380. '<!--- END WidgetTitle --->' => "</div>\r\n </div>\r\n</div>",
  381. '<!--- BEGIN WidgetContent --->' => "<div class=\"art-BlockContent\">\r\n <div class=\"art-BlockContent-tl\"></div>\r\n <div class=\"art-BlockContent-tr\"></div>\r\n <div class=\"art-BlockContent-bl\"></div>\r\n <div class=\"art-BlockContent-br\"></div>\r\n <div class=\"art-BlockContent-tc\"></div>\r\n <div class=\"art-BlockContent-bc\"></div>\r\n <div class=\"art-BlockContent-cl\"></div>\r\n <div class=\"art-BlockContent-cr\"></div>\r\n <div class=\"art-BlockContent-cc\"></div>\r\n <div class=\"art-BlockContent-body\">\r\n",
  382. '<!--- END WidgetContent --->' => "\r\n <div class=\"cleared\"></div>\r\n </div>\r\n</div>\r\n",
  383. '<!--- END Widget --->' => "\r\n <div class=\"cleared\"></div>\r\n </div>\r\n</div>\r\n"
  384. );
  385. $bwt = '<!--- BEGIN WidgetTitle --->';
  386. $ewt = '<!--- END WidgetTitle --->';
  387. if ('' == $replaces[$bwt] && '' == $replaces[$ewt]) {
  388. $startTitle = 0;
  389. $endTitle = 0;
  390. $result = '';
  391. while (true) {
  392. $startTitle = strpos($content, $bwt, $endTitle);
  393. if (false == $startTitle) {
  394. $result .= substr($content, $endTitle);
  395. break;
  396. }
  397. $result .= substr($content, $endTitle, $startTitle - $endTitle);
  398. $endTitle = strpos($content, $ewt, $startTitle);
  399. if (false == $endTitle) {
  400. $result .= substr($content, $startTitle);
  401. break;
  402. }
  403. $endTitle += strlen($ewt);
  404. }
  405. $content = $result;
  406. }
  407. $content = str_replace(array_keys($replaces), array_values($replaces), $content);
  408. echo $content;
  409. return true;
  410. }
  411.  
  412. function art_activeID($pages){
  413. $result = null;
  414. foreach ($pages as $index => $page){
  415. if (is_page($page->ID)) {
  416. $result = $page;
  417. break;
  418. }
  419. }
  420. while($result && $result->post_parent) {
  421. foreach ($pages as $parent){
  422. if ($parent->ID == $result->post_parent) {
  423. $result = $parent;
  424. breack;
  425. }
  426. }
  427. }
  428. return ($result ? $result->ID : null);
  429. }
  430.  
  431. function art_blogID($pages){
  432. $result = null;
  433. if(!'page' == get_option('show_on_front')) return $result;
  434. $blogID = get_option('page_for_posts');
  435. if (!$blogID) return $result;
  436. foreach ($pages as $index => $page){
  437. if ($page->ID == $blogID) {
  438. $result = $page;
  439. break;
  440. }
  441. }
  442. while($result && $result->post_parent) {
  443. foreach ($pages as $parent){
  444. if ($parent->ID == $result->post_parent) {
  445. $result = $parent;
  446. breack;
  447. }
  448. }
  449. }
  450. return ($result ? $result->ID : null);
  451. }
  452.  
  453. function art_process_front(&$pages){
  454. if ('page' != get_option('show_on_front')) return;
  455. $frontID = get_option('page_on_front');
  456. if (!$frontID) return;
  457. foreach ($pages as $index => $page)
  458. if($page->ID == $frontID) {
  459. unset($pages[$index]);
  460. $page->post_parent = '0';
  461. $page->menu_order = '0';
  462. array_unshift($pages, $page);
  463. break;
  464. }
  465. }
  466.  
  467. function art_topIDs($pages){
  468. $result = array();
  469. foreach ($pages as $index => $page)
  470. if (!$page->post_parent) $result[]=$page->ID;
  471. return $result;
  472. }
  473.  
  474. function art_remove_subitems(&$pages){
  475. foreach ($pages as $index => $page)
  476. if ($page->post_parent) unset($pages[$index]);
  477. }
  478.  
  479. function art_header_page_list_filter($pages)
  480. {
  481. global $artThemeSettings;
  482. art_process_front($pages);
  483. $artThemeSettings['menu.topItemIDs'] = art_topIDs($pages);
  484. $artThemeSettings['menu.activeID'] = art_activeID($pages);
  485. $artThemeSettings['menu.blogID'] = art_blogID($pages);
  486. if (!$artThemeSettings['menu.showSubmenus']) art_remove_subitems($pages);
  487. return $pages;
  488. }
  489.  
  490. function art_list_pages_filter($output)
  491. {
  492. global $artThemeSettings;
  493. $pref ='page-item-';
  494. if($artThemeSettings['menu.topItemIDs'])
  495. foreach($artThemeSettings['menu.topItemIDs'] as $id){
  496. $output = preg_replace('~<li class="([^"]*)\b(' . $pref . $id . ')\b([^"]*)"><a ([^>]+)>([^<]*)</a>~',
  497. '<li class="$1$2$3"><a $4>' . $artThemeSettings['menu.topItemBegin']
  498. . '$5' . $artThemeSettings['menu.topItemEnd'] . '</a>', $output, 1);
  499. }
  500.  
  501. $frontID = null;
  502. $blogID = null;
  503. if('page' == get_option('show_on_front')) {
  504. $frontID = get_option('page_on_front');
  505. $blogID = $artThemeSettings['menu.blogID'];
  506. }
  507. if ($frontID)
  508. $output = preg_replace('~<li class="([^"]*)\b(' . $pref . $frontID . ')\b([^"]*)"><a href="([^"]*)" ~',
  509. '<li class="$1$2$3"><a href="'. get_option('home') .'" ', $output, 1);
  510.  
  511. if ((is_home() && $blogID) || $artThemeSettings['menu.activeID'])
  512. $output = preg_replace('~<li class="([^"]*)\b(' . $pref . (is_home() ? $blogID : $artThemeSettings['menu.activeID']) . ')\b([^"]*)"><a ~',
  513. '<li class="$1$2$3"><a class="active" ', $output, 1);
  514. return $output;
  515. }
  516.  
  517. function art_menu_items()
  518. {
  519. global $artThemeSettings;
  520. if (true === $artThemeSettings['menu.showHome'] && 'page' != get_option('show_on_front'))
  521. echo '<li><a' . (is_home() ? ' class="active"' : '') . ' href="' . get_option('home') . '">'.$artThemeSettings['menu.topItemBegin']
  522. . $artThemeSettings['menu.homeCaption'] . $artThemeSettings['menu.topItemEnd'] . '</a></li>';
  523. add_action('get_pages', 'art_header_page_list_filter');
  524. add_action('wp_list_pages', 'art_list_pages_filter');
  525. wp_list_pages('title_li=');
  526. remove_action('wp_list_pages', 'art_list_pages_filter');
  527. remove_action('get_pages', 'art_header_page_list_filter');
  528. }
  529.  
  530. add_filter('comments_template', 'legacy_comments');
  531. function legacy_comments($file) {
  532. if(!function_exists('wp_list_comments')) : // WP 2.7-only check
  533. $file = TEMPLATEPATH.'/legacy.comments.php';
  534. endif;
  535. return $file;
  536. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement