PageRenderTime 50ms CodeModel.GetById 31ms RepoModel.GetById 1ms app.codeStats 0ms

/wp-content/themes/arras/library/admin/options.php

https://github.com/digitalstrategyworks/Reese-WordPress
PHP | 608 lines | 520 code | 81 blank | 7 comment | 0 complexity | eab7038ab156a4fb967fb17adcaed4c2 MD5 | raw file
  1. <?php
  2. class ArrasOptions {
  3. var $defaults;
  4. // General Settings
  5. var $version, $donate, $feed_url, $comments_feed_url, $twitter_username, $facebook_profile, $footer_title, $footer_message;
  6. // Navigation
  7. var $topnav_home, $topnav_display, $topnav_linkcat;
  8. // Home
  9. var $hide_duplicates;
  10. var $enable_slideshow, $slideshow_cat, $slideshow_count;
  11. var $enable_featured1, $featured1_title, $featured1_cat, $featured1_display, $featured1_count;
  12. var $enable_featured2, $featured2_title, $featured2_cat, $featured2_display, $featured2_count;
  13. var $enable_news, $news_title, $news_cat, $news_display, $index_count;
  14. // Layout
  15. var $archive_display;
  16. var $display_author, $single_custom_fields, $single_custom_taxonomies;
  17. var $excerpt_limit;
  18. var $post_author, $post_date, $post_cats, $post_tags, $postbar_footer, $single_thumbs;
  19. // Thumbnail Sizes
  20. var $auto_thumbs, $custom_thumbs;
  21. // Design
  22. var $layout, $style, $logo, $footer_sidebars;
  23. // Custom Post Types & Taxonomies
  24. var $slideshow_posttype, $featured1_posttype, $featured2_posttype, $news_posttype;
  25. var $slideshow_tax, $featured1_tax, $featured2_tax, $news_tax;
  26. function __construct() {
  27. $this->default_options();
  28. }
  29. function ArrasOptions() {
  30. return $this->__construct();
  31. }
  32. function default_options() {
  33. $this->defaults = array(
  34. 'version' => ARRAS_VERSION,
  35. 'donate' => false,
  36. 'feed_url' => get_bloginfo('rss2_url'),
  37. 'comments_feed_url' => get_bloginfo('comments_rss2_url'),
  38. 'footer_sidebars' => 1,
  39. 'footer_title' => __('Copyright', 'arras'),
  40. 'footer_message' => '<p>' . sprintf( __('Copyright %s. All Rights Reserved.', 'arras'), get_bloginfo('name') ) . '</p>',
  41. 'topnav_home' => __('Home', 'arras'),
  42. 'topnav_display' => 'categories',
  43. 'topnav_linkcat' => 0,
  44. 'hide_duplicates' => false,
  45. 'enable_slideshow' => true,
  46. 'slideshow_cat' => 0,
  47. 'slideshow_count' => 4,
  48. 'enable_featured1' => true,
  49. 'featured1_title' => __('Featured Stories', 'arras'),
  50. 'featured1_cat' => 0,
  51. 'featured1_display' => 'default',
  52. 'featured1_count' => 3,
  53. 'enable_featured2' => true,
  54. 'featured2_title' => __("Editors' Picks", 'arras'),
  55. 'featured2_cat' => 0,
  56. 'featured2_display' => 'quick',
  57. 'featured2_count' => 3,
  58. 'enable_news' => true,
  59. 'news_title' => __('Latest Headlines', 'arras'),
  60. 'news_cat' => 0,
  61. 'news_display' => 'line',
  62. 'index_count' => get_option('posts_per_page'),
  63. 'archive_display' => 'quick',
  64. 'display_author' => true,
  65. 'post_author' => true,
  66. 'post_date' => true,
  67. 'post_cats' => true,
  68. 'post_tags' => true,
  69. 'single_thumbs' => false,
  70. 'single_custom_fields' => 'Score:score,Pros:pros,Cons:cons',
  71. 'excerpt_limit' => 30,
  72. 'layout' => '2c-r-fixed',
  73. 'style' => 'default',
  74. 'auto_thumbs' => true,
  75. 'slideshow_posttype' => 'post',
  76. 'featured1_posttype' => 'post',
  77. 'featured2_posttype' => 'post',
  78. 'news_posttype' => 'post',
  79. 'slideshow_tax' => 'category',
  80. 'featured1_tax' => 'category',
  81. 'featured2_tax' => 'category',
  82. 'news_tax' => 'category'
  83. );
  84. foreach ($this->defaults as $key => $value)
  85. if (!isset($this->$key)) $this->$key = $value;
  86. do_action('arras_options_defaults');
  87. }
  88. function save_options() {
  89. $this->version = ARRAS_VERSION;
  90. $this->donate = !isset($_POST['arras-credits']);
  91. $this->feed_url = (string)$_POST['arras-rss-feed-url'];
  92. $this->comments_feed_url = (string)$_POST['arras-rss-comments-url'];
  93. $this->twitter_username = (string)$_POST['arras-twitter'];
  94. $this->facebook_profile = (string)$_POST['arras-facebook'];
  95. $this->footer_sidebars = (int)$_POST['arras-footer-sidebars'];
  96. $this->footer_title = (string)stripslashes($_POST['arras-footer-title']);
  97. $this->footer_message = (string)($_POST['arras-footer-message']);
  98. if ( !function_exists('wp_nav_menu') ) {
  99. $this->topnav_home = (string)$_POST['arras-nav-home'];
  100. $this->topnav_display = (string)$_POST['arras-nav-display'];
  101. $this->topnav_linkcat = (int)$_POST['arras-nav-linkcat'];
  102. }
  103. $this->hide_duplicates = isset($_POST['arras-hide-duplicates']);
  104. $this->enable_slideshow = isset($_POST['arras-enable-slideshow']);
  105. if (isset($_POST['arras-cat-slideshow'])) {
  106. $this->slideshow_cat = $_POST['arras-cat-slideshow'];
  107. } else {
  108. $this->slideshow_cat = null;
  109. }
  110. $this->slideshow_count = (int)stripslashes($_POST['arras-layout-slideshow-count']);
  111. $this->enable_featured1 = isset($_POST['arras-enable-featured1']);
  112. $this->featured1_title = (string)(stripslashes($_POST['arras-layout-featured1-title']));
  113. if (isset($_POST['arras-cat-featured1'])) {
  114. $this->featured1_cat = $_POST['arras-cat-featured1'];
  115. } else {
  116. $this->featured1_cat = null;
  117. }
  118. $this->featured1_display = (string)$_POST['arras-layout-featured1-display'];
  119. $this->featured1_count = (int)stripslashes($_POST['arras-layout-featured1-count']);
  120. $this->enable_featured2 = isset($_POST['arras-enable-featured2']);
  121. $this->featured2_title = (string)(stripslashes($_POST['arras-layout-featured2-title']));
  122. if (isset($_POST['arras-cat-featured2'])) {
  123. $this->featured2_cat = $_POST['arras-cat-featured2'];
  124. } else {
  125. $this->featured2_cat = null;
  126. }
  127. $this->featured2_display = (string)$_POST['arras-layout-featured2-display'];
  128. $this->featured2_count = (int)stripslashes($_POST['arras-layout-featured2-count']);
  129. $this->enable_news = isset($_POST['arras-enable-news']);
  130. $this->news_title = (string)(stripslashes($_POST['arras-layout-news-title']));
  131. if (isset($_POST['arras-cat-news'])) {
  132. $this->news_cat = $_POST['arras-cat-news'];
  133. } else {
  134. $this->news_cat = null;
  135. }
  136. $this->news_display = (string)$_POST['arras-layout-index-newsdisplay'];
  137. $this->index_count = (int)stripslashes($_POST['arras-layout-index-count']);
  138. $this->excerpt_limit = (int)$_POST['arras-layout-limit-words'];
  139. $this->archive_display = (string)$_POST['arras-layout-archive-newsdisplay'];
  140. $this->display_author = isset($_POST['arras-layout-single-author']);
  141. $this->post_author = isset($_POST['arras-layout-post-author']);
  142. $this->post_date = isset($_POST['arras-layout-post-date']);
  143. $this->post_cats = isset($_POST['arras-layout-post-cats']);
  144. $this->post_tags = isset($_POST['arras-layout-post-tags']);
  145. $this->single_thumbs = isset($_POST['arras-layout-single-thumbs']);
  146. $this->single_custom_taxonomies = (string)$_POST['arras-single-custom-taxonomies'];
  147. if ( defined('ARRAS_CUSTOM_FIELDS') && ARRAS_CUSTOM_FIELDS == true) {
  148. $this->single_custom_fields = (string)$_POST['arras-single-custom-fields'];
  149. }
  150. if ( !defined('ARRAS_INHERIT_LAYOUT') || ARRAS_INHERIT_LAYOUT == true ) {
  151. $this->layout = (string)$_POST['arras-layout-col'];
  152. }
  153. if ( !defined('ARRAS_INHERIT_STYLES') || ARRAS_INHERIT_STYLES == true ) {
  154. $this->style = (string)$_POST['arras-style'];
  155. }
  156. $this->auto_thumbs = isset($_POST['arras-thumbs-auto']);
  157. }
  158. function save_posttypes() {
  159. $this->_chain_update_posttypes( $this->slideshow_posttype, (string)$_POST['arras-posttype-slideshow'], $this->slideshow_tax, $this->slideshow_cat );
  160. $this->_chain_update_posttypes( $this->featured1_posttype, (string)$_POST['arras-posttype-featured1'], $this->featured1_tax, $this->featured1_cat );
  161. $this->_chain_update_posttypes( $this->featured2_posttype, (string)$_POST['arras-posttype-featured2'], $this->featured2_tax, $this->featured2_cat );
  162. $this->_chain_update_posttypes( $this->news_posttype, (string)$_POST['arras-posttype-news'], $this->news_tax, $this->news_cat );
  163. }
  164. function _chain_update_posttypes(&$posttype, $new_posttype, &$taxonomy, &$category = null) {
  165. if ( $posttype != $new_posttype ) {
  166. $posttype = $new_posttype;
  167. $taxonomies = get_object_taxonomies($posttype, 'names');
  168. if(count($taxonomies) > 0) $taxonomy = $taxonomies[0];
  169. else $taxonomy = 0;
  170. $category = null;
  171. }
  172. }
  173. function save_taxonomies() {
  174. if ( $this->slideshow_tax != (string)$_POST['arras-taxonomy-slideshow'] ) {
  175. $this->slideshow_tax = (string)$_POST['arras-taxonomy-slideshow'];
  176. $this->slideshow_cat = null;
  177. }
  178. if ( $this->featured1_tax != (string)$_POST['arras-taxonomy-featured1'] ) {
  179. $this->featured1_tax = (string)$_POST['arras-taxonomy-featured1'];
  180. $this->featured1_cat = null;
  181. }
  182. if ( $this->featured2_tax != (string)$_POST['arras-taxonomy-featured2'] ) {
  183. $this->featured2_tax = (string)$_POST['arras-taxonomy-featured2'];
  184. $this->featured2_cat = null;
  185. }
  186. if ( $this->news_tax != (string)$_POST['arras-taxonomy-news'] ) {
  187. $this->news_tax = (string)$_POST['arras-taxonomy-news'];
  188. $this->news_cat = null;
  189. }
  190. }
  191. }
  192. function arras_flush_options() {
  193. global $arras_options;
  194. $opts = get_option('arras_options');
  195. if (is_a($opts, 'ArrasOptions')) {
  196. $arras_options = $opts;
  197. } else {
  198. $arras_options = new ArrasOptions();
  199. foreach ($arras_options->defaults as $key => $value) {
  200. if (isset($opts->$key)) {
  201. $arras_options->$key = $opts->key;
  202. }
  203. }
  204. }
  205. return $arras_options;
  206. }
  207. function arras_update_options() {
  208. global $arras_options;
  209. update_option('arras_options', $arras_options);
  210. }
  211. function arras_upgrade_options() {
  212. global $arras_options, $arras_custom_bg_options;
  213. $custom_thumbs = $arras_options->custom_thumbs;
  214. if (isset($arras_options->featured_thumb_w)) $custom_thumbs['node-based-thumb']['w'] = $arras_options->featured_thumb_w;
  215. if (isset($arras_options->featured_thumb_h)) $custom_thumbs['node-based-thumb']['h'] = $arras_options->featured_thumb_h;
  216. if (isset($arras_options->news_thumb_w)) $custom_thumbs['quick-preview-thumb']['w'] = $arras_options->news_thumb_w;
  217. if (isset($arras_options->news_thumb_h)) $custom_thumbs['quick-preview-thumb']['h'] = $arras_options->news_thumb_h;
  218. $arras_options->custom_thumbs = $custom_thumbs;
  219. $arras_options->version = ARRAS_VERSION;
  220. arras_update_options();
  221. }
  222. function arras_get_option($name) {
  223. global $arras_options;
  224. if (!is_object($arras_options) )
  225. arras_flush_options();
  226. if (isset($arras_options->$name)) {
  227. return $arras_options->$name;
  228. } elseif (isset($arras_options->defaults[$name])) {
  229. return $arras_options->defaults[$name];
  230. }
  231. }
  232. /* End of file options.php */
  233. /* Location: ./admin/options.php */