PageRenderTime 28ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/wp-content/themes/inove/functions.php

https://github.com/benbruscella/dynamicbodytherapy.com
PHP | 429 lines | 378 code | 36 blank | 15 comment | 57 complexity | ebf5ec5fbf670c1fe9a2ff569b4a75a3 MD5 | raw file
  1. <?php
  2. /** inove options */
  3. class iNoveOptions {
  4. function getOptions() {
  5. $options = get_option('inove_options');
  6. if (!is_array($options)) {
  7. $options['description'] = '';
  8. $options['keywords'] = '';
  9. $options['google_cse'] = false;
  10. $options['google_cse_cx'] = '';
  11. $options['menu_type'] = 'pages';
  12. $options['notice'] = false;
  13. $options['notice_content'] = '';
  14. $options['showcase_registered'] = false;
  15. $options['showcase_commentator'] = false;
  16. $options['showcase_visitor'] = false;
  17. $options['showcase_caption'] = false;
  18. $options['showcase_title'] = '';
  19. $options['showcase_content'] = '';
  20. $options['author'] = true;
  21. $options['categories'] = true;
  22. $options['tags'] = true;
  23. $options['feed'] = false;
  24. $options['feed_url'] = '';
  25. $options['feed_email'] = false;
  26. $options['feed_url_email'] = '';
  27. update_option('inove_options', $options);
  28. }
  29. return $options;
  30. }
  31. function add() {
  32. if(isset($_POST['inove_save'])) {
  33. $options = iNoveOptions::getOptions();
  34. // meta
  35. $options['description'] = stripslashes($_POST['description']);
  36. $options['keywords'] = stripslashes($_POST['keywords']);
  37. // google custom search engine
  38. if ($_POST['google_cse']) {
  39. $options['google_cse'] = (bool)true;
  40. } else {
  41. $options['google_cse'] = (bool)false;
  42. }
  43. $options['google_cse_cx'] = stripslashes($_POST['google_cse_cx']);
  44. // menu
  45. $options['menu_type'] = stripslashes($_POST['menu_type']);
  46. // notice
  47. if ($_POST['notice']) {
  48. $options['notice'] = (bool)true;
  49. } else {
  50. $options['notice'] = (bool)false;
  51. }
  52. $options['notice_content'] = stripslashes($_POST['notice_content']);
  53. // showcase
  54. if (!$_POST['showcase_registered']) {
  55. $options['showcase_registered'] = (bool)false;
  56. } else {
  57. $options['showcase_registered'] = (bool)true;
  58. }
  59. if (!$_POST['showcase_commentator']) {
  60. $options['showcase_commentator'] = (bool)false;
  61. } else {
  62. $options['showcase_commentator'] = (bool)true;
  63. }
  64. if (!$_POST['showcase_visitor']) {
  65. $options['showcase_visitor'] = (bool)false;
  66. } else {
  67. $options['showcase_visitor'] = (bool)true;
  68. }
  69. if ($_POST['showcase_caption']) {
  70. $options['showcase_caption'] = (bool)true;
  71. } else {
  72. $options['showcase_caption'] = (bool)false;
  73. }
  74. $options['showcase_title'] = stripslashes($_POST['showcase_title']);
  75. $options['showcase_content'] = stripslashes($_POST['showcase_content']);
  76. // author & categories & tags
  77. if ($_POST['author']) {
  78. $options['author'] = (bool)true;
  79. } else {
  80. $options['author'] = (bool)false;
  81. }
  82. if ($_POST['categories']) {
  83. $options['categories'] = (bool)true;
  84. } else {
  85. $options['categories'] = (bool)false;
  86. }
  87. if (!$_POST['tags']) {
  88. $options['tags'] = (bool)false;
  89. } else {
  90. $options['tags'] = (bool)true;
  91. }
  92. // feed
  93. if ($_POST['feed']) {
  94. $options['feed'] = (bool)true;
  95. } else {
  96. $options['feed'] = (bool)false;
  97. }
  98. // feed
  99. if ($_POST['feed']) {
  100. $options['feed'] = (bool)true;
  101. } else {
  102. $options['feed'] = (bool)false;
  103. }
  104. $options['feed_url'] = stripslashes($_POST['feed_url']);
  105. if ($_POST['feed_email']) {
  106. $options['feed_email'] = (bool)true;
  107. } else {
  108. $options['feed_email'] = (bool)false;
  109. }
  110. $options['feed_url_email'] = stripslashes($_POST['feed_url_email']);
  111. update_option('inove_options', $options);
  112. } else {
  113. iNoveOptions::getOptions();
  114. }
  115. add_theme_page(__('Current Theme Options', 'inove'), __('Current Theme Options', 'inove'), 'edit_themes', basename(__FILE__), array('iNoveOptions', 'display'));
  116. }
  117. function display() {
  118. $options = iNoveOptions::getOptions();
  119. ?>
  120. <form action="#" method="post" enctype="multipart/form-data" name="inove_form" id="inove_form">
  121. <div class="wrap">
  122. <h2><?php _e('Current Theme Options', 'inove'); ?></h2>
  123. <table class="form-table">
  124. <tbody>
  125. <tr valign="top">
  126. <th scope="row"><?php _e('Meta', 'inove'); ?></th>
  127. <td>
  128. <?php _e('Description:', 'inove'); ?>
  129. <br/>
  130. <input type="text" name="description" id="description" class="code" style="width:98%;" value="<?php echo($options['description']); ?>">
  131. <br/>
  132. <?php _e('Keywords:', 'inove'); ?> <small><?php _e('( Separate keywords with commas )', 'inove'); ?></small>
  133. <br/>
  134. <input type="text" name="keywords" id="keywords" class="code" style="width:98%;" value="<?php echo($options['keywords']); ?>">
  135. </td>
  136. </tr>
  137. </tbody>
  138. </table>
  139. <table class="form-table">
  140. <tbody>
  141. <tr valign="top">
  142. <th scope="row"><?php _e('Search', 'inove'); ?></th>
  143. <td>
  144. <label>
  145. <input name="google_cse" type="checkbox" value="checkbox" <?php if($options['google_cse']) echo "checked='checked'"; ?> />
  146. <?php _e('Using google custom search engine.', 'inove'); ?>
  147. </label>
  148. <br/>
  149. <?php _e('CX:', 'inove'); ?>
  150. <input type="text" name="google_cse_cx" id="google_cse_cx" class="code" size="40" value="<?php echo($options['google_cse_cx']); ?>">
  151. <br/>
  152. <?php _e('Find <code>name="cx"</code> in the <strong>Search box code</strong> of <a href="http://www.google.com/coop/cse/">Google Custom Search Engine</a>, and type the <code>value</code> here.<br/>For example: <code>014782006753236413342:1ltfrybsbz4</code>', 'inove'); ?>
  153. </td>
  154. </tr>
  155. </tbody>
  156. </table>
  157. <table class="form-table">
  158. <tbody>
  159. <tr valign="top">
  160. <th scope="row"><?php _e('Menubar', 'inove'); ?></th>
  161. <td>
  162. <label style="margin-right:20px;">
  163. <input name="menu_type" type="radio" value="pages" <?php if($options['menu_type'] != 'categories') echo "checked='checked'"; ?> />
  164. <?php _e('Show pages as menu.', 'inove'); ?>
  165. </label>
  166. <label>
  167. <input name="menu_type" type="radio" value="categories" <?php if($options['menu_type'] == 'categories') echo "checked='checked'"; ?> />
  168. <?php _e('Show categories as menu.', 'inove'); ?>
  169. </label>
  170. </td>
  171. </tr>
  172. </tbody>
  173. </table>
  174. <table class="form-table">
  175. <tbody>
  176. <tr valign="top">
  177. <th scope="row">
  178. <?php _e('Notice', 'inove'); ?>
  179. <br/>
  180. <small style="font-weight:normal;"><?php _e('HTML enabled', 'inove'); ?></small>
  181. </th>
  182. <td>
  183. <!-- notice START -->
  184. <label>
  185. <input name="notice" type="checkbox" value="checkbox" <?php if($options['notice']) echo "checked='checked'"; ?> />
  186. <?php _e('This notice bar will display at the top of posts on homepage.', 'inove'); ?>
  187. </label>
  188. <br />
  189. <label>
  190. <textarea name="notice_content" id="notice_content" cols="50" rows="10" style="width:98%;font-size:12px;" class="code"><?php echo($options['notice_content']); ?></textarea>
  191. </label>
  192. <!-- notice END -->
  193. </td>
  194. </tr>
  195. </tbody>
  196. </table>
  197. <table class="form-table">
  198. <tbody>
  199. <tr valign="top">
  200. <th scope="row">
  201. <?php _e('Showcase', 'inove'); ?>
  202. <br/>
  203. <small style="font-weight:normal;"><?php _e('HTML enabled', 'inove'); ?></small>
  204. </th>
  205. <td>
  206. <!-- showcase START -->
  207. <label><?php _e('This showcase will display at the top of sidebar.', 'inove'); ?></label>
  208. <br/>
  209. <label><?php _e('Who can see?', 'inove'); ?></label>
  210. <label style="margin-left:10px;">
  211. <input name="showcase_registered" type="checkbox" value="checkbox" <?php if($options['showcase_registered']) echo "checked='checked'"; ?> />
  212. <?php _e('Registered Users', 'inove'); ?>
  213. </label>
  214. <label style="margin-left:10px;">
  215. <input name="showcase_commentator" type="checkbox" value="checkbox" <?php if($options['showcase_commentator']) echo "checked='checked'"; ?> />
  216. <?php _e('Commentator', 'inove'); ?>
  217. </label>
  218. <label style="margin-left:10px;">
  219. <input name="showcase_visitor" type="checkbox" value="checkbox" <?php if($options['showcase_visitor']) echo "checked='checked'"; ?> />
  220. <?php _e('Visitors', 'inove'); ?>
  221. </label>
  222. <br/>
  223. <label>
  224. <input name="showcase_caption" type="checkbox" value="checkbox" <?php if($options['showcase_caption']) echo "checked='checked'"; ?> />
  225. <?php _e('Title:', 'inove'); ?>
  226. </label>
  227. <input type="text" name="showcase_title" id="showcase_title" class="code" size="40" value="<?php echo($options['showcase_title']); ?>">
  228. <br/>
  229. <label>
  230. <textarea name="showcase_content" id="showcase_content" cols="50" rows="10" style="width:98%;font-size:12px;" class="code"><?php echo($options['showcase_content']); ?></textarea>
  231. </label>
  232. <!-- showcase END -->
  233. </td>
  234. </tr>
  235. </tbody>
  236. </table>
  237. <table class="form-table">
  238. <tbody>
  239. <tr valign="top">
  240. <th scope="row"><?php _e('Posts'); ?></th>
  241. <td>
  242. <label style="margin-right:20px;">
  243. <input name="author" type="checkbox" value="checkbox" <?php if($options['author']) echo "checked='checked'"; ?> />
  244. <?php _e('Show author on posts.', 'inove'); ?>
  245. </label>
  246. <label style="margin-right:20px;">
  247. <input name="categories" type="checkbox" value="checkbox" <?php if($options['categories']) echo "checked='checked'"; ?> />
  248. <?php _e('Show categories on posts.', 'inove'); ?>
  249. </label>
  250. <label>
  251. <input name="tags" type="checkbox" value="checkbox" <?php if($options['tags']) echo "checked='checked'"; ?> />
  252. <?php _e('Show tags on posts.', 'inove'); ?>
  253. </label>
  254. </td>
  255. </tr>
  256. </tbody>
  257. </table>
  258. <table class="form-table">
  259. <tbody>
  260. <tr valign="top">
  261. <th scope="row"><?php _e('Feed', 'inove'); ?></th>
  262. <td>
  263. <label>
  264. <input name="feed" type="checkbox" value="checkbox" <?php if($options['feed']) echo "checked='checked'"; ?> />
  265. <?php _e('Custom feed.', 'inove'); ?>
  266. </label>
  267. <br/>
  268. <?php _e('URL:', 'inove'); ?> <input type="text" name="feed_url" id="feed_url" class="code" size="60" value="<?php echo($options['feed_url']); ?>">
  269. <br/>
  270. <label>
  271. <input name="feed_email" type="checkbox" value="checkbox" <?php if($options['feed_email']) echo "checked='checked'"; ?> />
  272. <?php _e('Email feed.', 'inove'); ?>
  273. </label>
  274. <br/>
  275. <?php _e('URL:', 'inove'); ?> <input type="text" name="feed_url_email" id="feed_url_email" class="code" size="60" value="<?php echo($options['feed_url_email']); ?>">
  276. </td>
  277. </tr>
  278. </tbody>
  279. </table>
  280. <p class="submit">
  281. <input class="button-primary" type="submit" name="inove_save" value="<?php _e('Save Changes', 'inove'); ?>" />
  282. </p>
  283. </div>
  284. </form>
  285. <?php
  286. }
  287. }
  288. // register functions
  289. add_action('admin_menu', array('iNoveOptions', 'add'));
  290. /** l10n */
  291. function theme_init(){
  292. load_theme_textdomain('inove', get_template_directory() . '/languages');
  293. }
  294. add_action ('init', 'theme_init');
  295. /** widgets */
  296. if( function_exists('register_sidebar') ) {
  297. register_sidebar(array(
  298. 'name' => 'north_sidebar',
  299. 'before_widget' => '<div id="%1$s" class="widget %2$s">',
  300. 'after_widget' => '</div>',
  301. 'before_title' => '<h3>',
  302. 'after_title' => '</h3>'
  303. ));
  304. register_sidebar(array(
  305. 'name' => 'south_sidebar',
  306. 'before_widget' => '<div id="%1$s" class="widget %2$s">',
  307. 'after_widget' => '</div>',
  308. 'before_title' => '<h3>',
  309. 'after_title' => '</h3>'
  310. ));
  311. register_sidebar(array(
  312. 'name' => 'west_sidebar',
  313. 'before_widget' => '<div id="%1$s" class="widget %2$s">',
  314. 'after_widget' => '</div>',
  315. 'before_title' => '<h3>',
  316. 'after_title' => '</h3>'
  317. ));
  318. register_sidebar(array(
  319. 'name' => 'east_sidebar',
  320. 'before_widget' => '<div id="%1$s" class="widget %2$s">',
  321. 'after_widget' => '</div>',
  322. 'before_title' => '<h3>',
  323. 'after_title' => '</h3>'
  324. ));
  325. }
  326. /** Comments */
  327. if (function_exists('wp_list_comments')) {
  328. // comment count
  329. add_filter('get_comments_number', 'comment_count', 0);
  330. function comment_count( $commentcount ) {
  331. global $id;
  332. $_commnets = get_comments('post_id=' . $id);
  333. $comments_by_type = &separate_comments($_commnets);
  334. return count($comments_by_type['comment']);
  335. }
  336. }
  337. // custom comments
  338. function custom_comments($comment, $args, $depth) {
  339. $GLOBALS['comment'] = $comment;
  340. global $commentcount;
  341. if(!$commentcount) {
  342. $commentcount = 0;
  343. }
  344. ?>
  345. <li class="comment <?php if($comment->comment_author_email == get_the_author_email()) {echo 'admincomment';} else {echo 'regularcomment';} ?>" id="comment-<?php comment_ID() ?>">
  346. <div class="author">
  347. <div class="pic">
  348. <?php if (function_exists('get_avatar') && get_option('show_avatars')) { echo get_avatar($comment, 32); } ?>
  349. </div>
  350. <div class="name">
  351. <?php if (get_comment_author_url()) : ?>
  352. <a id="commentauthor-<?php comment_ID() ?>" class="url" href="<?php comment_author_url() ?>" rel="external nofollow">
  353. <?php else : ?>
  354. <span id="commentauthor-<?php comment_ID() ?>">
  355. <?php endif; ?>
  356. <?php comment_author(); ?>
  357. <?php if(get_comment_author_url()) : ?>
  358. </a>
  359. <?php else : ?>
  360. </span>
  361. <?php endif; ?>
  362. </div>
  363. </div>
  364. <div class="info">
  365. <div class="date">
  366. <? printf( __('%1$s at %2$s', 'inove'), get_comment_time(__('F jS, Y', 'inove')), get_comment_time(__('H:i', 'inove')) ); ?>
  367. | <a href="#comment-<?php comment_ID() ?>"><?php printf('#%1$s', ++$commentcount); ?></a>
  368. </div>
  369. <div class="act">
  370. <a href="javascript:void(0);" onclick="MGJS_CMT.reply('commentauthor-<?php comment_ID() ?>', 'comment-<?php comment_ID() ?>', 'comment');"><?php _e('Reply', 'inove'); ?></a> |
  371. <a href="javascript:void(0);" onclick="MGJS_CMT.quote('commentauthor-<?php comment_ID() ?>', 'comment-<?php comment_ID() ?>', 'commentbody-<?php comment_ID() ?>', 'comment');"><?php _e('Quote', 'inove'); ?></a>
  372. <?php
  373. if (function_exists("qc_comment_edit_link")) {
  374. qc_comment_edit_link('', ' | ', '', __('Edit', 'inove'));
  375. }
  376. edit_comment_link(__('Advanced edit', 'inove'), ' | ', '');
  377. ?>
  378. </div>
  379. <div class="fixed"></div>
  380. <div class="content">
  381. <?php if ($comment->comment_approved == '0') : ?>
  382. <p><small><?php _e('Your comment is awaiting moderation.', 'inove'); ?></small></p>
  383. <?php endif; ?>
  384. <div id="commentbody-<?php comment_ID() ?>">
  385. <?php comment_text(); ?>
  386. </div>
  387. </div>
  388. </div>
  389. <div class="fixed"></div>
  390. </li>
  391. <?php
  392. }
  393. ?>