Advertisement
Guest User

theme-options.php

a guest
Jun 30th, 2013
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 30.79 KB | None | 0 0
  1. <?php
  2.  
  3. add_action( 'admin_init', 'theme_options_init' );
  4. add_action( 'admin_menu', 'theme_options_add_page' );
  5.  
  6. /**
  7. * Init plugin options to white list our options
  8. */
  9. function theme_options_init(){
  10. register_setting( 'critter_options', 'critter_theme_options', 'theme_options_validate' );
  11. }
  12.  
  13. /**
  14. * Load up the menu page
  15. */
  16. function theme_options_add_page() {
  17. add_theme_page( __( 'Theme Options', 'crittertheme' ), __( 'Theme Options', 'crittertheme' ), 'edit_theme_options', 'theme_options', 'theme_options_do_page' );
  18. }
  19.  
  20. /**
  21. * Create arrays for our select and radio options
  22. */
  23. $select_options = array(
  24. 'lightblue.css' => array(
  25. 'value' => 'lightblue.css',
  26. 'label' => __( 'Light Blue', 'crittertheme' )
  27. ),
  28. 'darkblue.css' => array(
  29. 'value' => 'darkblue.css',
  30. 'label' => __( 'Dark Blue', 'crittertheme' )
  31. ),
  32. 'purple.css' => array(
  33. 'value' => 'purple.css',
  34. 'label' => __( 'Purple', 'crittertheme' )
  35. ),
  36. 'red.css' => array(
  37. 'value' => 'red.css',
  38. 'label' => __( 'Red', 'crittertheme' )
  39. ),
  40. 'orange.css' => array(
  41. 'value' => 'orange.css',
  42. 'label' => __( 'Orange', 'crittertheme' )
  43. ),
  44. 'yellow.css' => array(
  45. 'value' => 'yellow.css',
  46. 'label' => __( 'Yellow', 'crittertheme' )
  47. ),
  48. 'green.css' => array(
  49. 'value' => 'green.css',
  50. 'label' => __( 'Green', 'crittertheme' )
  51. )
  52. );
  53.  
  54. $radio_options = array(
  55. 'yes' => array(
  56. 'value' => 'yes',
  57. 'label' => __( 'Yes', 'crittertheme' )
  58. ),
  59. 'no' => array(
  60. 'value' => 'no',
  61. 'label' => __( 'No', 'crittertheme' )
  62. ),
  63. 'maybe' => array(
  64. 'value' => 'maybe',
  65. 'label' => __( 'Maybe', 'crittertheme' )
  66. )
  67. );
  68.  
  69. $arg = array(
  70. 'echo' => 1,
  71. 'selected' => $the_link,
  72. 'name' => 'theme_option[the_link]');
  73.  
  74. $max_id = esc_attr($_POST["element-max-id"]);
  75. for ($i = 0; $i < $max_id; $i ++) {
  76. $field_name = "element-page-id-" . $i;
  77. if (isset($_POST[$field_name])) {
  78. $front_page_elements[] = esc_attr($_POST[$field_name]);
  79. }
  80. }
  81.  
  82.  
  83. /**
  84. * Create the options page
  85. */
  86. function theme_options_do_page() {
  87. global $select_options, $radio_options;
  88.  
  89. if ( ! isset( $_REQUEST['settings-updated'] ) )
  90. $_REQUEST['settings-updated'] = false;
  91.  
  92. ?>
  93. <div class="wrap">
  94. <?php screen_icon(); echo "<h2>" . get_current_theme() . __( ' Theme Options', 'crittertheme' ) . "</h2>"; ?>
  95.  
  96. <?php if ( false !== $_REQUEST['settings-updated'] ) : ?>
  97. <div class="updated fade"><p><strong><?php _e( 'Options saved', 'crittertheme' ); ?></strong></p></div>
  98. <?php endif; ?>
  99.  
  100. <form method="post" action="options.php">
  101. <?php settings_fields( 'critter_options' ); ?>
  102. <?php $options = get_option( 'critter_theme_options' ); ?>
  103.  
  104. <table class="form-table">
  105. <tr><td><h3>Layout Options</h3></td></tr>
  106. <tr valign="top"><th scope="row"><?php _e( 'Main Colour Scheme', 'crittertheme' ); ?></th>
  107. <td>
  108. <select name="critter_theme_options[colour]">
  109. <?php
  110. $selected = $options['colour'];
  111. $p = '';
  112. $r = '';
  113.  
  114. foreach ( $select_options as $option ) {
  115. $label = $option['label'];
  116. if ( $selected == $option['value'] ) // Make default first in list
  117. $p = "\n\t<option style=\"padding-right: 10px;\" selected='selected' value='" . esc_attr( $option['value'] ) . "'>$label</option>";
  118. else
  119. $r .= "\n\t<option style=\"padding-right: 10px;\" value='" . esc_attr( $option['value'] ) . "'>$label</option>";
  120. }
  121. echo $p . $r;
  122. ?>
  123. </select>
  124. <label class="description" for="critter_theme_options[colour]"><?php _e( '', 'crittertheme' ); ?></label>
  125. </td>
  126. </tr>
  127. <tr valign="top"><th scope="row"><?php _e( 'Show Slider on Homepage', 'crittertheme' ); ?></th>
  128. <td>
  129. <input id="critter_theme_options[slider]" name="critter_theme_options[slider]" type="checkbox" value="1" <?php checked( '1', $options['slider'] ); ?> />
  130. <label class="description" for="critter_theme_options[slider]"><?php _e( 'Yes please', 'crittertheme' ); ?></label>
  131. </td>
  132. </tr>
  133. <tr valign="top"><th scope="row"><?php _e( 'Show Recent Posts on Homepage', 'crittertheme' ); ?></th>
  134. <td>
  135. <input id="critter_theme_options[showposts1]" name="critter_theme_options[showposts1]" type="checkbox" value="1" <?php checked( '1', $options['showposts1'] ); ?> />
  136. <label class="description" for="critter_theme_options[showposts1]"><?php _e( 'Yes please', 'crittertheme' ); ?></label>
  137. </td>
  138. </tr>
  139. <tr><td><h3>Homepage Calls to Action</h3></td></tr>
  140. <tr valign="top"><th scope="row"><?php _e( 'Show Calls to Action on Homepage', 'crittertheme' ); ?></th>
  141. <td>
  142. <input id="critter_theme_options[showctas]" name="critter_theme_options[showctas]" type="checkbox" value="1" <?php checked( '1', $options['showctas'] ); ?> />
  143. <label class="description" for="critter_theme_options[showctas]"><?php _e( 'Yes please', 'crittertheme' ); ?></label>
  144. </td>
  145. </tr>
  146. <tr>
  147. <td>
  148. <h4>Doctors/Staff Call to Action</h4>
  149. <label class="description" for="critter_theme_options[doctors_title]"><?php _e( 'Call to Action Title', 'crittertheme' ); ?></label>
  150. <input id="critter_theme_options[doctors_title]" class="regular-text" type="text" name="critter_theme_options[doctors_title]" value="<?php esc_attr_e( $options['doctors_title'] ); ?>" /><br />
  151. <label class="description" for="critter_theme_options[doctors_text]"><?php _e( 'Call to Action Text', 'crittertheme' ); ?></label>
  152. <textarea rows="4" cols="30" id="critter_theme_options[doctors_text]" class="regular-text" type="text" name="critter_theme_options[doctors_text]" value="Doctors/staff call to action content goes here"><?php esc_attr_e( $options['doctors_text'] ); ?></textarea><br />
  153. <label class="description" for="critter_theme_options[doctors_link_text]"><?php _e( 'Call to Action Link', 'crittertheme' ); ?></label>
  154. <input id="critter_theme_options[doctors_link_text]" class="regular-text" type="text" name="critter_theme_options[doctors_button_text]" value="<?php esc_attr_e( $options['doctors_button_text'] ); ?>" />
  155. <label class="description" for="critter_theme_options[doctors_button_text]"><?php _e( 'Call to Action Button Text', 'crittertheme' ); ?></label>
  156. <input id="critter_theme_options[doctors_link_text]" class="regular-text" type="text" name="critter_theme_options[doctors_link_text]" value="<?php esc_attr_e( $options['doctors_link_text'] ); ?>" />
  157.  
  158. <?php wp_dropdown_pages($arg); ?>
  159. </td>
  160. <td>
  161. <h4>Services Call to Action</h4>
  162. <label class="description" for="critter_theme_options[services_title]"><?php _e( 'Call to Action Title', 'crittertheme' ); ?></label>
  163. <input id="critter_theme_options[services_title]" class="regular-text" type="text" name="critter_theme_options[services_title]" value="<?php esc_attr_e( $options['services_title'] ); ?>" /><br />
  164. <label class="description" for="critter_theme_options[services_text]"><?php _e( 'Call to Action Text', 'crittertheme' ); ?></label>
  165. <textarea rows="4" cols="30" id="critter_theme_options[services_text]" class="regular-text" type="text" name="critter_theme_options[services_text]" value="Services call to action content goes here"><?php esc_attr_e( $options['services_text'] ); ?></textarea><br />
  166. <label class="description" for="critter_theme_options[services_link_text]"><?php _e( 'Call to Action Link', 'crittertheme' ); ?></label>
  167. <input id="critter_theme_options[services_button_text]" class="regular-text" type="text" name="critter_theme_options[services_button_text]" value="<?php esc_attr_e( $options['services_button_text'] ); ?>" />
  168. <label class="description" for="critter_theme_options[services_button_text]"><?php _e( 'Call to Action Button Text', 'crittertheme' ); ?></label>
  169. <input id="critter_theme_options[services_link_text]" class="regular-text" type="text" name="critter_theme_options[services_link_text]" value="<?php esc_attr_e( $options['services_link_text'] ); ?>" />
  170. <select name="critter_service_link">
  171. <option value="">Nowhere</option>
  172. <?php foreach(get_pages() as $page){ ?>
  173. <option value="<?php echo $page->ID;?>"<?php esc_attr_e($options['services_link'] == $page->ID) ? ' selected':'';?>><?php echo $page->post_title;?></option>
  174. <?php } ?>
  175. </select>
  176. </td>
  177. <td>
  178. <h4>Testimonials Call to Action</h4>
  179. <label class="description" for="critter_theme_options[testimonial_title]"><?php _e( 'Call to Action Title', 'crittertheme' ); ?></label>
  180. <input id="critter_theme_options[testimonial_title]" class="regular-text" type="text" name="critter_theme_options[testimonial_title]" value="<?php esc_attr_e( $options['testimonial_title'] ); ?>" /><br />
  181. <label class="description" for="critter_theme_options[testimonial_text]"><?php _e( 'Call to Action Text', 'crittertheme' ); ?></label>
  182. <textarea rows="4" cols="30" id="critter_theme_options[testimonial_text]" class="regular-text" type="text" name="critter_theme_options[testimonial_text]" value="Services call to action content goes here"><?php esc_attr_e( $options['testimonial_text'] ); ?></textarea><br />
  183. <label class="description" for="critter_theme_options[testimonial_link_text]"><?php _e( 'Call to Action Link', 'crittertheme' ); ?></label>
  184. <input id="critter_theme_options[testimonial_button_text]" class="regular-text" type="text" name="critter_theme_options[testimonial_button_text]" value="<?php esc_attr_e( $options['testimonial_button_text'] ); ?>" />
  185. <label class="description" for="critter_theme_options[testimonial_button_text]"><?php _e( 'Call to Action Button Text', 'crittertheme' ); ?></label>
  186. <input id="critter_theme_options[testimonial_link_text]" class="regular-text" type="text" name="critter_theme_options[testimonial_link_text]" value="<?php esc_attr_e( $options['testimonial_link_text'] ); ?>" />
  187. <select name="critter_service_link">
  188. <option value="">Nowhere</option>
  189. <?php foreach(get_pages() as $page){ ?>
  190. <option value="<?php echo $page->ID;?>"<?php esc_attr_e($options['testimonial_link'] == $page->ID) ? ' selected':'';?>><?php echo $page->post_title;?></option>
  191. <?php } ?>
  192. </select>
  193. </td>
  194. </tr>
  195. <?php
  196. /**
  197. * The Contact Information
  198. */
  199. ?>
  200. <tr><td><h3>Footer Calls to Action</h3></td></tr>
  201. <td>
  202. <h4>Footer Doctors/Staff Call to Action</h4>
  203. <label class="description" for="critter_theme_options[footer_doctors_title]"><?php _e( 'Call to Action Title', 'crittertheme' ); ?></label>
  204. <input id="critter_theme_options[footer_doctors_title]" class="regular-text" type="text" name="critter_theme_options[footer_doctors_title]" value="<?php esc_attr_e( $options['footer_doctors_title'] ); ?>" /><br />
  205. <label class="description" for="critter_theme_options[footer_doctors_text]"><?php _e( 'Call to Action Text', 'crittertheme' ); ?></label>
  206. <textarea rows="4" cols="30" id="critter_theme_options[footer_doctors_text]" class="regular-text" type="text" name="critter_theme_options[footer_doctors_text]" value="Doctors/staff call to action content goes here"><?php esc_attr_e( $options['footer_doctors_text'] ); ?></textarea><br />
  207. <label class="description" for="critter_theme_options[footer_doctors_link_text]"><?php _e( 'Call to Action Link', 'crittertheme' ); ?></label>
  208. <input id="critter_theme_options[footer_doctors_link_text]" class="regular-text" type="text" name="critter_theme_options[footer_doctors_link_text]" value="<?php esc_attr_e( $options['doctors_link_text'] ); ?>" />
  209. <label class="description" for="critter_theme_options[footer_doctors_button_text]"><?php _e( 'Call to Action Button Text', 'crittertheme' ); ?></label>
  210. <input id="critter_theme_options[footer_doctors_button_text]" class="regular-text" type="text" name="critter_theme_options[footer_doctors_button_text]" value="<?php esc_attr_e( $options['footer_doctors_button_text'] ); ?>" />
  211. <select name="critter_service_link">
  212. <option value="">Nowhere</option>
  213. <?php foreach(get_pages() as $page){ ?>
  214. <option value="<?php echo $page->ID;?>"<?php esc_attr_e($options['footer_doctors_link'] == $page->ID) ? ' selected':'';?>><?php echo $page->post_title;?></option>
  215. <?php } ?>
  216. </select>
  217. </td>
  218. <td>
  219. <h4>Footer Services Call to Action</h4>
  220. <label class="description" for="critter_theme_options[footer_services_title]"><?php _e( 'Call to Action Title', 'crittertheme' ); ?></label>
  221. <input id="critter_theme_options[footer_services_title]" class="regular-text" type="text" name="critter_theme_options[footer_services_title]" value="<?php esc_attr_e( $options['footer_services_title'] ); ?>" /><br />
  222. <label class="description" for="critter_theme_options[footer_services_text]"><?php _e( 'Call to Action Text', 'crittertheme' ); ?></label>
  223. <textarea rows="4" cols="30" id="critter_theme_options[footer_services_text]" class="regular-text" type="text" name="critter_theme_options[footer_services_text]" value="Services call to action content goes here"><?php esc_attr_e( $options['footer_services_text'] ); ?></textarea><br />
  224. <label class="description" for="critter_theme_options[footer_services_link_text]"><?php _e( 'Call to Action Link', 'crittertheme' ); ?></label>
  225. <input id="critter_theme_options[footer_services_link_text]" class="regular-text" type="text" name="critter_theme_options[footer_services_link_text]" value="<?php esc_attr_e( $options['services_link_text'] ); ?>" />
  226. <label class="description" for="critter_theme_options[footer_services_button_text]"><?php _e( 'Call to Action Button Text', 'crittertheme' ); ?></label>
  227. <input id="critter_theme_options[footer_services_button_text]" class="regular-text" type="text" name="critter_theme_options[footer_services_button_text]" value="<?php esc_attr_e( $options['footer_services_button_text'] ); ?>" />
  228. <select name="critter_service_link">
  229. <option value="">Nowhere</option>
  230. <?php foreach(get_pages() as $page){ ?>
  231. <option value="<?php echo $page->ID;?>"<?php esc_attr_e($options['footer_services_link'] == $page->ID) ? ' selected':'';?>><?php echo $page->post_title;?></option>
  232. <?php } ?>
  233. </select>
  234. </td>
  235. <td>
  236. <h4>Footer Testimonials Call to Action</h4>
  237. <label class="description" for="critter_theme_options[footer_testimonial_title]"><?php _e( 'Call to Action Title', 'crittertheme' ); ?></label>
  238. <input id="critter_theme_options[footer_testimonial_title]" class="regular-text" type="text" name="critter_theme_options[footer_testimonial_title]" value="<?php esc_attr_e( $options['footer_testimonial_title'] ); ?>" /><br />
  239. <label class="description" for="critter_theme_options[footer_testimonial_text]"><?php _e( 'Call to Action Text', 'crittertheme' ); ?></label>
  240. <textarea rows="4" cols="30" id="critter_theme_options[footer_testimonial_text]" class="regular-text" type="text" name="critter_theme_options[footer_testimonial_text]" value="Services call to action content goes here"><?php esc_attr_e( $options['footer_testimonial_text'] ); ?></textarea><br />
  241. <label class="description" for="critter_theme_options[footer_testimonial_link_text]"><?php _e( 'Call to Action Link', 'crittertheme' ); ?></label>
  242. <input id="critter_theme_options[footer_testimonial_link_text]" class="regular-text" type="text" name="critter_theme_options[footer_testimonial_link_text]" value="<?php esc_attr_e( $options['footer_testimonial_link_text'] ); ?>" />
  243. <label class="description" for="critter_theme_options[footer_testimonial_button_text]"><?php _e( 'Call to Action Button Text', 'crittertheme' ); ?></label>
  244. <input id="critter_theme_options[footer_testimonial_button_text]" class="regular-text" type="text" name="critter_theme_options[footer_testimonial_button_text]" value="<?php esc_attr_e( $options['footer_testimonial_button_text'] ); ?>" />
  245. <select name="critter_service_link">
  246. <option value="">Nowhere</option>
  247. <?php foreach(get_pages() as $page){ ?>
  248. <option value="<?php echo $page->ID;?>"<?php esc_attr_e($options['footer_testimonial_link'] == $page->ID) ? ' selected':'';?>><?php echo $page->post_title;?></option>
  249. <?php } ?>
  250. </select>
  251. </td>
  252. <tr><td><h3>Contact Information</h3></td></tr>
  253. <tr valign="top"><th scope="row"><?php _e( 'Phone Number', 'crittertheme' ); ?></th>
  254. <td>
  255. <input id="critter_theme_options[phonenumber]" class="regular-text" type="text" name="critter_theme_options[phonenumber]" value="<?php esc_attr_e( $options['phonenumber'] ); ?>" />
  256. <label class="description" for="critter_theme_options[phonenumber]"><?php _e( '', 'crittertheme' ); ?></label>
  257. </td>
  258. </tr>
  259. <tr valign="top"><th scope="row"><?php _e( 'Fax Number', 'crittertheme' ); ?></th>
  260. <td>
  261. <input id="critter_theme_options[faxnumber]" class="regular-text" type="text" name="critter_theme_options[faxnumber]" value="<?php esc_attr_e( $options['faxnumber'] ); ?>" />
  262. <label class="description" for="critter_theme_options[faxnumber]"><?php _e( '', 'crittertheme' ); ?></label>
  263. </td>
  264. </tr>
  265. <tr valign="top"><th scope="row"><?php _e( 'Emergency Number', 'crittertheme' ); ?></th>
  266. <td>
  267. <input id="critter_theme_options[emergencynumber]" class="regular-text" type="text" name="critter_theme_options[emergencynumber]" value="<?php esc_attr_e( $options['emergencynumber'] ); ?>" />
  268. <label class="description" for="critter_theme_options[emergencynumber]"><?php _e( '', 'crittertheme' ); ?></label>
  269. </td>
  270. </tr>
  271. <tr valign="top"><th scope="row"><?php _e( 'Google Maps Friendly Address', 'crittertheme' ); ?></th>
  272. <td>
  273. <input id="critter_theme_options[googlemaps]" class="regular-text" type="text" name="critter_theme_options[googlemaps]" value="<?php esc_attr_e( $options['googlemaps'] ); ?>" />
  274. <label class="description" for="critter_theme_options[googlemaps]"><?php _e( '', 'crittertheme' ); ?></label>
  275. </td>
  276. </tr>
  277. <?php
  278. /**
  279. * Social Media Profiles
  280. */
  281. ?>
  282. <tr><td><h3>Social Media Profile Links</h3></td></tr>
  283. <tr valign="top"><th scope="row"><?php _e( 'Facebook Page', 'crittertheme' ); ?></th>
  284. <td>
  285. <input id="critter_theme_options[facebook]" class="regular-text" type="text" name="critter_theme_options[facebook]" value="<?php esc_attr_e( $options['facebook'] ); ?>" />
  286. <label class="description" for="critter_theme_options[facebook]"><?php _e( '', 'crittertheme' ); ?></label>
  287. </td>
  288. </tr>
  289. <tr valign="top"><th scope="row"><?php _e( 'Twitter Account', 'crittertheme' ); ?></th>
  290. <td>
  291. <input id="critter_theme_options[twitter]" class="regular-text" type="text" name="critter_theme_options[twitter]" value="<?php esc_attr_e( $options['twitter'] ); ?>" />
  292. <label class="description" for="critter_theme_options[twitter]"><?php _e( '', 'crittertheme' ); ?></label>
  293. </td>
  294. </tr>
  295. <tr valign="top"><th scope="row"><?php _e( 'LinkedIn Profile', 'crittertheme' ); ?></th>
  296. <td>
  297. <input id="critter_theme_options[linkedin]" class="regular-text" type="text" name="critter_theme_options[linkedin]" value="<?php esc_attr_e( $options['linkedin'] ); ?>" />
  298. <label class="description" for="critter_theme_options[linkedin]"><?php _e( '', 'crittertheme' ); ?></label>
  299. </td>
  300. </tr>
  301. <tr valign="top"><th scope="row"><?php _e( 'YouTube Account', 'crittertheme' ); ?></th>
  302. <td>
  303. <input id="critter_theme_options[youtube]" class="regular-text" type="text" name="critter_theme_options[youtube]" value="<?php esc_attr_e( $options['youtube'] ); ?>" />
  304. <label class="description" for="critter_theme_options[youtube]"><?php _e( '', 'crittertheme' ); ?></label>
  305. </td>
  306. </tr>
  307. <tr valign="top"><th scope="row"><?php _e( 'Google+ Profile', 'crittertheme' ); ?></th>
  308. <td>
  309. <input id="critter_theme_options[googleplus]" class="regular-text" type="text" name="critter_theme_options[googleplus]" value="<?php esc_attr_e( $options['googleplus'] ); ?>" />
  310. <label class="description" for="critter_theme_options[googleplus]"><?php _e( '', 'crittertheme' ); ?></label>
  311. </td>
  312. </tr>
  313. <?php
  314. /**
  315. * Hours of Operation
  316. */
  317. ?>
  318. <tr>
  319. <td><h3>Hours of Operation</h3></td>
  320. <td><p>If closed, just fill in 'Closed' in the first field for that day.</p></td>
  321. </tr>
  322. <tr valign="top"><th scope="row"><?php _e( 'Display Hours of Operation', 'crittertheme' ); ?></th>
  323. <td>
  324. <input id="critter_theme_options[hours]" name="critter_theme_options[hours]" type="checkbox" value="1" <?php checked( '1', $options['hours'] ); ?> />
  325. <label class="description" for="critter_theme_options[hours]"><?php _e( 'Yes please', 'crittertheme' ); ?></label>
  326. </td>
  327. </tr>
  328. <tr valign="top"><th scope="row"><?php _e( 'Monday', 'crittertheme' ); ?></th>
  329. <td>
  330. <input id="critter_theme_options[monday1]" class="regular-text" type="text" name="critter_theme_options[monday1]" value="<?php esc_attr_e( $options['monday1'] ); ?>" />
  331. <label class="description" for="critter_theme_options[monday1]"><?php _e( ' - ', 'crittertheme' ); ?></label>
  332. <input id="critter_theme_options[monday2]" class="regular-text" type="text" name="critter_theme_options[monday2]" value="<?php esc_attr_e( $options['monday2'] ); ?>" />
  333. </td>
  334. </tr>
  335. <tr valign="top"><th scope="row"><?php _e( 'Tuesday', 'crittertheme' ); ?></th>
  336. <td>
  337. <input id="critter_theme_options[tuesday1]" class="regular-text" type="text" name="critter_theme_options[tuesday1]" value="<?php esc_attr_e( $options['tuesday1'] ); ?>" />
  338. <label class="description" for="critter_theme_options[tuesday1]"><?php _e( ' - ', 'crittertheme' ); ?></label>
  339. <input id="critter_theme_options[tuesday2]" class="regular-text" type="text" name="critter_theme_options[tuesday2]" value="<?php esc_attr_e( $options['tuesday2'] ); ?>" />
  340. </td>
  341. </tr>
  342. <tr valign="top"><th scope="row"><?php _e( 'Wednesday', 'crittertheme' ); ?></th>
  343. <td>
  344. <input id="critter_theme_options[wednesday1]" class="regular-text" type="text" name="critter_theme_options[wednesday1]" value="<?php esc_attr_e( $options['wednesday1'] ); ?>" />
  345. <label class="description" for="critter_theme_options[wednesday1]"><?php _e( ' - ', 'crittertheme' ); ?></label>
  346. <input id="critter_theme_options[wednesday2]" class="regular-text" type="text" name="critter_theme_options[wednesday2]" value="<?php esc_attr_e( $options['wednesday2'] ); ?>" />
  347. </td>
  348. </tr>
  349. <tr valign="top"><th scope="row"><?php _e( 'Thursday', 'crittertheme' ); ?></th>
  350. <td>
  351. <input id="critter_theme_options[thursday1]" class="regular-text" type="text" name="critter_theme_options[thursday1]" value="<?php esc_attr_e( $options['thursday1'] ); ?>" />
  352. <label class="description" for="critter_theme_options[thursday1]"><?php _e( ' - ', 'crittertheme' ); ?></label>
  353. <input id="critter_theme_options[thursday2]" class="regular-text" type="text" name="critter_theme_options[thursday2]" value="<?php esc_attr_e( $options['thursday2'] ); ?>" />
  354. </td>
  355. </tr>
  356. <tr valign="top"><th scope="row"><?php _e( 'Friday', 'crittertheme' ); ?></th>
  357. <td>
  358. <input id="critter_theme_options[friday1]" class="regular-text" type="text" name="critter_theme_options[friday1]" value="<?php esc_attr_e( $options['friday1'] ); ?>" />
  359. <label class="description" for="critter_theme_options[friday1]"><?php _e( ' - ', 'crittertheme' ); ?></label>
  360. <input id="critter_theme_options[friday2]" class="regular-text" type="text" name="critter_theme_options[friday2]" value="<?php esc_attr_e( $options['friday2'] ); ?>" />
  361. </td>
  362. </tr>
  363. <tr valign="top"><th scope="row"><?php _e( 'Saturday', 'crittertheme' ); ?></th>
  364. <td>
  365. <input id="critter_theme_options[saturday1]" class="regular-text" type="text" name="critter_theme_options[saturday1]" value="<?php esc_attr_e( $options['saturday1'] ); ?>" />
  366. <label class="description" for="critter_theme_options[saturday1]"><?php _e( ' - ', 'crittertheme' ); ?></label>
  367. <input id="critter_theme_options[saturday2]" class="regular-text" type="text" name="critter_theme_options[saturday2]" value="<?php esc_attr_e( $options['saturday2'] ); ?>" />
  368. </td>
  369. </tr>
  370. <tr valign="top"><th scope="row"><?php _e( 'Sunday', 'crittertheme' ); ?></th>
  371. <td>
  372. <input id="critter_theme_options[sunday1]" class="regular-text" type="text" name="critter_theme_options[sunday1]" value="<?php esc_attr_e( $options['sunday1'] ); ?>" />
  373. <label class="description" for="critter_theme_options[sunday1]"><?php _e( ' - ', 'crittertheme' ); ?></label>
  374. <input id="critter_theme_options[sunday2]" class="regular-text" type="text" name="critter_theme_options[sunday2]" value="<?php esc_attr_e( $options['sunday2'] ); ?>" />
  375. </td>
  376. </tr>
  377. </table>
  378.  
  379. <p class="submit">
  380. <input type="submit" class="button-primary" value="<?php _e( 'Save Options', 'crittertheme' ); ?>" />
  381. </p>
  382. </form>
  383. </div>
  384. <?php
  385. }
  386.  
  387. /**
  388. * Sanitize and validate input. Accepts an array, return a sanitized array.
  389. */
  390. function theme_options_validate( $input ) {
  391. global $select_options, $radio_options;
  392.  
  393. // Our checkbox value is either 0 or 1
  394. if ( ! isset( $input['slider'] ) )
  395. $input['slider'] = null;
  396. $input['slider'] = ( $input['slider'] == 1 ? 1 : 0 );
  397.  
  398. if ( ! isset( $input['showposts1'] ) )
  399. $input['showposts1'] = null;
  400. $input['showposts1'] = ( $input['showposts1'] == 1 ? 1 : 0 );
  401.  
  402. if ( ! isset( $input['showctas'] ) )
  403. $input['showctas'] = null;
  404. $input['showctas'] = ( $input['showctas'] == 1 ? 1 : 0 );
  405.  
  406. if ( ! isset( $input['hours'] ) )
  407. $input['hours'] = null;
  408. $input['hours'] = ( $input['hours'] == 1 ? 1 : 0 );
  409.  
  410. // Say our text option must be safe text with no HTML tags
  411. $input['doctors_title'] = wp_filter_nohtml_kses( $input['doctors_title'] );
  412. $input['doctors_text'] = wp_filter_nohtml_kses( $input['doctors_text'] );
  413. $input['doctors_link_text'] = wp_filter_nohtml_kses( $input['doctors_link_text'] );
  414. $input['doctors_button_text'] = wp_filter_nohtml_kses( $input['doctors_button_text'] );
  415. $input['doctors_link'] = wp_filter_nohtml_kses( $input['doctors_link'] );
  416. $input['services_title'] = wp_filter_nohtml_kses( $input['services_title'] );
  417. $input['services_text'] = wp_filter_nohtml_kses( $input['services_text'] );
  418. $input['services_button_text'] = wp_filter_nohtml_kses( $input['services_button_text'] );
  419. $input['services_link_text'] = wp_filter_nohtml_kses( $input['services_link_text'] );
  420. $input['services_link'] = wp_filter_nohtml_kses( $input['services_link'] );
  421. $input['testimonial_title'] = wp_filter_nohtml_kses( $input['testimonial_title'] );
  422. $input['testimonial_text'] = wp_filter_nohtml_kses( $input['testimonial_text'] );
  423. $input['testimonial_button_text'] = wp_filter_nohtml_kses( $input['testimonial_button_text'] );
  424. $input['testimonial_link_text'] = wp_filter_nohtml_kses( $input['testimonial_link_text'] );
  425. $input['testimonial_link'] = wp_filter_nohtml_kses( $input['testimonial_link'] );
  426.  
  427. $input['footer_doctors_title'] = wp_filter_nohtml_kses( $input['footer_doctors_title'] );
  428. $input['footer_doctors_text'] = wp_filter_nohtml_kses( $input['footer_doctors_text'] );
  429. $input['footer_doctors_link_text'] = wp_filter_nohtml_kses( $input['footer_doctors_link_text'] );
  430. $input['footer_doctors_button_text'] = wp_filter_nohtml_kses( $input['footer_doctors_button_text'] );
  431. $input['footer_doctors_link'] = wp_filter_nohtml_kses( $input['footer_doctors_link'] );
  432. $input['footer_services_title'] = wp_filter_nohtml_kses( $input['footer_services_title'] );
  433. $input['footer_services_text'] = wp_filter_nohtml_kses( $input['footer_services_text'] );
  434. $input['footer_services_link_text'] = wp_filter_nohtml_kses( $input['footer_services_link_text'] );
  435. $input['footer_services_button_text'] = wp_filter_nohtml_kses( $input['footer_services_button_text'] );
  436. $input['footer_services_link'] = wp_filter_nohtml_kses( $input['footer_services_link'] );
  437. $input['footer_testimonial_title'] = wp_filter_nohtml_kses( $input['footer_testimonial_title'] );
  438. $input['footer_testimonial_text'] = wp_filter_nohtml_kses( $input['footer_testimonial_text'] );
  439. $input['footer_testimonial_link_text'] = wp_filter_nohtml_kses( $input['footer_testimonial_link_text'] );
  440. $input['footer_testimonial_button_text'] = wp_filter_nohtml_kses( $input['footer_testimonial_button_text'] );
  441. $input['footer_testimonial_link'] = wp_filter_nohtml_kses( $input['footer_testimonial_link'] );
  442.  
  443. $input['phonenumber'] = wp_filter_nohtml_kses( $input['phonenumber'] );
  444. $input['emergencynumber'] = wp_filter_nohtml_kses( $input['emergencynumber'] );
  445. $input['faxnumber'] = wp_filter_nohtml_kses( $input['faxnumber'] );
  446. $input['googlemaps'] = wp_filter_nohtml_kses( $input['googlemaps'] );
  447.  
  448. $input['facebook'] = wp_filter_nohtml_kses( $input['facebook'] );
  449. $input['twitter'] = wp_filter_nohtml_kses( $input['twitter'] );
  450. $input['linkedin'] = wp_filter_nohtml_kses( $input['linkedin'] );
  451. $input['youtube'] = wp_filter_nohtml_kses( $input['youtube'] );
  452. $input['googlemaps'] = wp_filter_nohtml_kses( $input['googlemaps'] );
  453.  
  454. $input['monday1'] = wp_filter_nohtml_kses( $input['monday1'] );
  455. $input['monday2'] = wp_filter_nohtml_kses( $input['monday2'] );
  456. $input['tuesday1'] = wp_filter_nohtml_kses( $input['tuesday1'] );
  457. $input['tuesday2'] = wp_filter_nohtml_kses( $input['tuesday2'] );
  458. $input['wednesday1'] = wp_filter_nohtml_kses( $input['wednesday1'] );
  459. $input['wednesday2'] = wp_filter_nohtml_kses( $input['wednesday2'] );
  460. $input['thursday1'] = wp_filter_nohtml_kses( $input['thursday1'] );
  461. $input['thursday2'] = wp_filter_nohtml_kses( $input['thursday2'] );
  462. $input['friday1'] = wp_filter_nohtml_kses( $input['friday1'] );
  463. $input['friday2'] = wp_filter_nohtml_kses( $input['friday2'] );
  464. $input['saturday1'] = wp_filter_nohtml_kses( $input['saturday1'] );
  465. $input['saturday2'] = wp_filter_nohtml_kses( $input['saturday2'] );
  466. $input['sunday1'] = wp_filter_nohtml_kses( $input['sunday1'] );
  467. $input['sunday2'] = wp_filter_nohtml_kses( $input['sunday2'] );
  468.  
  469. // Our select option must actually be in our array of select options
  470. if ( ! array_key_exists( $input['selectinput'], $select_options ) )
  471. $input['selectinput'] = null;
  472.  
  473. $input['the_link'] = get_option('the_link');
  474.  
  475. // Our radio option must actually be in our array of radio options
  476. if ( ! isset( $input['radioinput'] ) )
  477. $input['radioinput'] = null;
  478. if ( ! array_key_exists( $input['radioinput'], $radio_options ) )
  479. $input['radioinput'] = null;
  480.  
  481. // Say our textarea option must be safe text with the allowed tags for posts
  482. $input['sometextarea'] = wp_filter_post_kses( $input['sometextarea'] );
  483.  
  484. return $input;
  485. }
  486.  
  487. // adapted from http://planetozh.com/blog/2009/05/handling-plugins-options-in-wordpress-28-with-register_setting/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement