Advertisement
Guest User

Untitled

a guest
Aug 1st, 2011
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.77 KB | None | 0 0
  1. <!--Help sections-->
  2.  
  3. <?php
  4. add_action('admin_menu', 'help_menu');
  5. add_action('admin_init', 'help_menu_add_init');
  6.  
  7. function help_menu() {
  8. add_options_page('Help Menu Options', 'Help Section', 'manage_options', 'my-unique-identifier', 'help_menu_options');
  9. }
  10.  
  11. function help_menu_options() {
  12. if (!current_user_can('manage_options')) {
  13. wp_die( __('You do not have sufficient permissions to access this page.') );
  14. }
  15.  
  16. include ($TEMPLATEPATH . 'functions/help.php');
  17. }
  18. function help_menu_add_init() {
  19.  
  20. $file_dir=get_bloginfo('template_directory');
  21. wp_enqueue_style("functions", $file_dir."/functions/functions.css", false, "1.0", "all");
  22. wp_enqueue_script("help", $file_dir."/functions/help.js", false, "1.0");
  23.  
  24. }
  25.  
  26. ?>
  27.  
  28. <!--Theme Custom Menu-->
  29.  
  30. <?php
  31.  
  32. $themename = "Site Options";
  33. $shortname = "nt";
  34.  
  35. $categories = get_categories('hide_empty=0&orderby=name');
  36. $wp_cats = array();
  37. foreach ($categories as $category_list ) {
  38. $wp_cats[$category_list->cat_ID] = $category_list->cat_name;
  39. }
  40. array_unshift($wp_cats, "Choose a category");
  41.  
  42. $options = array (
  43.  
  44. array( "name" => $themename." Options",
  45. "type" => "title"),
  46.  
  47. array( "name" => "Customization",
  48. "type" => "section"),
  49. array( "type" => "open"),
  50.  
  51. array( "name" => "Header Contact Name",
  52. "desc" => "Enter a name for the Header Contact info",
  53. "id" => $shortname."_head_name",
  54. "type" => "text",
  55. "std" => ""),
  56.  
  57. array( "name" => "Header Contact Info",
  58. "desc" => "Enter a number or email for the Header Contact info",
  59. "id" => $shortname."_head_contact",
  60. "type" => "text",
  61. "std" => ""),
  62.  
  63. array( "name" => "Header Logo",
  64. "desc" => "Enter the URL for the Header Logo",
  65. "id" => $shortname."_header_logo",
  66. "type" => "text",
  67. "std" => ""),
  68.  
  69. array( "name" => "Picture 1",
  70. "desc" => "Enter a URL for a picture for the 1st spot",
  71. "id" => $shortname."_picture_1",
  72. "type" => "text",
  73. "std" => ""),
  74.  
  75. array( "name" => "Name Above Picture 1 Description",
  76. "desc" => "Enter a name to be displayed above the first picture description",
  77. "id" => $shortname."_footer_name_1",
  78. "type" => "text",
  79. "std" => ""),
  80.  
  81. array( "name" => "Picture 1 Description",
  82. "desc" => "Enter some text to display below the first picture",
  83. "id" => $shortname."_footer_text_1",
  84. "type" => "text",
  85. "std" => ""),
  86.  
  87. array( "name" => "Picture 2",
  88. "desc" => "Enter a URL for a picture for the 2nd spot",
  89. "id" => $shortname."_picture_2",
  90. "type" => "text",
  91. "std" => ""),
  92.  
  93. array( "name" => "Name Above Picture 2 Description",
  94. "desc" => "Enter a name to be displayed above the second picture description",
  95. "id" => $shortname."_footer_name_2",
  96. "type" => "text",
  97. "std" => ""),
  98.  
  99.  
  100. array( "name" => "Picture 2 Description",
  101. "desc" => "Enter some text to display below the second picture",
  102. "id" => $shortname."_footer_text_2",
  103. "type" => "text",
  104. "std" => ""),
  105.  
  106. array( "name" => "Picture 3",
  107. "desc" => "Enter a URL for a picture for the 3rd spot",
  108. "id" => $shortname."_picture_3",
  109. "type" => "text",
  110. "std" => ""),
  111.  
  112. array( "name" => "Name Above Picture 3 Description",
  113. "desc" => "Enter a name to be displayed above the third picture description",
  114. "id" => $shortname."_footer_name_3",
  115. "type" => "text",
  116. "std" => ""),
  117.  
  118. array( "name" => "Picture 3 Description",
  119. "desc" => "Enter some text to display below the third picture",
  120. "id" => $shortname."_footer_text_3",
  121. "type" => "text",
  122. "std" => ""),
  123.  
  124. array( "name" => "Picture 4",
  125. "desc" => "Enter a URL for a picture for the 4th spot",
  126. "id" => $shortname."_picture_4",
  127. "type" => "text",
  128. "std" => ""),
  129.  
  130. array( "name" => "Name Above Picture 4 Description",
  131. "desc" => "Enter a name to be displayed above the fourth picture description",
  132. "id" => $shortname."_footer_name_4",
  133. "type" => "text",
  134. "std" => ""),
  135.  
  136.  
  137. array( "name" => "Picture 4 Description",
  138. "desc" => "Enter some text to display below the fourth picture",
  139. "id" => $shortname."_footer_text_4",
  140. "type" => "text",
  141. "std" => ""),
  142.  
  143.  
  144. array( "name" => "Name Above Email",
  145. "desc" => "Enter a name to be displayed above the email",
  146. "id" => $shortname."_footer_name",
  147. "type" => "text",
  148. "std" => ""),
  149.  
  150. array( "name" => "Address",
  151. "desc" => "Enter your address if you would like to display it",
  152. "id" => $shortname."_display_address",
  153. "std" => "",
  154. "type" => "text"),
  155.  
  156. array( "name" => "Phone",
  157. "desc" => "Enter your phone number if you would like to display it",
  158. "id" => $shortname."_display_phone",
  159. "std" => "",
  160. "type" => "text"),
  161.  
  162. array( "name" => "Fax",
  163. "desc" => "Enter your number if you would like to display it",
  164. "id" => $shortname."_display_fax",
  165. "std" => "",
  166. "type" => "text"),
  167.  
  168. array( "name" => "Email",
  169. "desc" => "Enter your email address if you would like to display it",
  170. "id" => $shortname."_display_email",
  171. "std" => "",
  172. "type" => "text"),
  173.  
  174. array( "name" => "Google Analytics Code",
  175. "desc" => "You can paste your Google Analytics or other tracking code in this box. This will be automatically added to the footer.",
  176. "id" => $shortname."_ga_code",
  177. "type" => "textarea",
  178. "std" => ""),
  179.  
  180. array( "type" => "close")
  181.  
  182. );
  183.  
  184.  
  185. function mytheme_add_admin() {
  186.  
  187. global $themename, $shortname, $options;
  188.  
  189. if ( $_GET['page'] == basename(__FILE__) ) {
  190.  
  191. if ( 'save' == $_REQUEST['action'] ) {
  192.  
  193. foreach ($options as $value) {
  194. update_option( $value['id'], $_REQUEST[ $value['id'] ] ); }
  195.  
  196. foreach ($options as $value) {
  197. if( isset( $_REQUEST[ $value['id'] ] ) ) { update_option( $value['id'], $_REQUEST[ $value['id'] ] ); } else { delete_option( $value['id'] ); } }
  198.  
  199. header("Location: themes.php?page=functions.php&saved=true");
  200. die;
  201.  
  202. }
  203. else if( 'reset' == $_REQUEST['action'] ) {
  204.  
  205. foreach ($options as $value) {
  206. delete_option( $value['id'] ); }
  207.  
  208. header("Location: themes.php?page=functions.php&reset=true");
  209. die;
  210.  
  211. }
  212. }
  213.  
  214. add_menu_page($themename, $themename, 'administrator', basename(__FILE__), 'mytheme_admin');
  215. }
  216.  
  217. function mytheme_add_init() {
  218.  
  219. $file_dir=get_bloginfo('template_directory');
  220. wp_enqueue_style("functions", $file_dir."/functions/functions.css", false, "1.0", "all");
  221. wp_enqueue_script("rm_script", $file_dir."/functions/rm_script.js", false, "1.0");
  222.  
  223. }
  224. function mytheme_admin() {
  225.  
  226. global $themename, $shortname, $options;
  227. $i=0;
  228.  
  229. if ( $_REQUEST['saved'] ) echo '<div id="message" class="updated fade"><p><strong>'.$themename.' settings saved.</strong></p></div>';
  230. if ( $_REQUEST['reset'] ) echo '<div id="message" class="updated fade"><p><strong>'.$themename.' settings reset.</strong></p></div>';
  231.  
  232. ?>
  233. <div class="wrap rm_wrap">
  234. <h2><?php echo $themename; ?> Settings</h2>
  235.  
  236. <div class="rm_opts">
  237. <form method="post">
  238. <?php foreach ($options as $value) {
  239. switch ( $value['type'] ) {
  240.  
  241. case "open":
  242. ?>
  243.  
  244. <?php break;
  245.  
  246. case "close":
  247. ?>
  248.  
  249. </div>
  250. </div>
  251. <br />
  252.  
  253.  
  254. <?php break;
  255.  
  256. case "title":
  257. ?>
  258. <p>To easily use the <?php echo $themename;?> theme, you can use the menu below.</p>
  259.  
  260.  
  261. <?php break;
  262.  
  263. case 'text':
  264. ?>
  265.  
  266. <div class="rm_input rm_text">
  267. <label for="<?php echo $value['id']; ?>"><?php echo $value['name']; ?></label>
  268. <input name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>" type="<?php echo $value['type']; ?>" value="<?php if ( get_settings( $value['id'] ) != "") { echo stripslashes(get_settings( $value['id']) ); } else { echo $value['std']; } ?>" />
  269. <small><?php echo $value['desc']; ?></small><div class="clearfix"></div>
  270.  
  271. </div>
  272. <?php
  273. break;
  274.  
  275. case 'textarea':
  276. ?>
  277.  
  278. <div class="rm_input rm_textarea">
  279. <label for="<?php echo $value['id']; ?>"><?php echo $value['name']; ?></label>
  280. <textarea name="<?php echo $value['id']; ?>" type="<?php echo $value['type']; ?>" cols="" rows=""><?php if ( get_settings( $value['id'] ) != "") { echo stripslashes(get_settings( $value['id']) ); } else { echo $value['std']; } ?></textarea>
  281. <small><?php echo $value['desc']; ?></small><div class="clearfix"></div>
  282.  
  283. </div>
  284.  
  285. <?php
  286. break;
  287.  
  288. case 'select':
  289. ?>
  290.  
  291. <div class="rm_input rm_select">
  292. <label for="<?php echo $value['id']; ?>"><?php echo $value['name']; ?></label>
  293.  
  294. <select name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>">
  295. <?php foreach ($value['options'] as $option) { ?>
  296. <option <?php if (get_settings( $value['id'] ) == $option) { echo 'selected="selected"'; } ?>><?php echo $option; ?></option><?php } ?>
  297. </select>
  298.  
  299. <small><?php echo $value['desc']; ?></small><div class="clearfix"></div>
  300. </div>
  301. <?php
  302. break;
  303.  
  304. case "checkbox":
  305. ?>
  306.  
  307. <div class="rm_input rm_checkbox">
  308. <label for="<?php echo $value['id']; ?>"><?php echo $value['name']; ?></label>
  309.  
  310. <?php if(get_option($value['id'])){ $checked = "checked=\"checked\""; }else{ $checked = "";} ?>
  311. <input type="checkbox" name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>" value="true" <?php echo $checked; ?> />
  312.  
  313.  
  314. <small><?php echo $value['desc']; ?></small><div class="clearfix"></div>
  315. </div>
  316. <?php break;
  317. case "section":
  318.  
  319. $i++;
  320.  
  321. ?>
  322.  
  323. <div class="rm_section">
  324. <div class="rm_title"><h3><img src="<?php bloginfo('template_directory')?>/functions/images/trans.png" class="inactive" alt="""><?php echo $value['name']; ?></h3><span class="submit"><input name="save<?php echo $i; ?>" type="submit" value="Save changes" />
  325. </span><div class="clearfix"></div></div>
  326. <div class="rm_options">
  327.  
  328.  
  329. <?php break;
  330.  
  331. }
  332. }
  333. ?>
  334.  
  335. <input type="hidden" name="action" value="save" />
  336. </form>
  337. <form method="post">
  338. <p class="submit">
  339. <input name="reset" type="submit" value="Reset" />
  340. <input type="hidden" name="action" value="reset" />
  341. </p>
  342. </form>
  343. <div style="font-size:9px; margin-bottom:10px;">Icons: <a href="http://www.woothemes.com/2009/09/woofunction/">WooFunction</a></div>
  344. </div>
  345.  
  346.  
  347. <?php
  348. }
  349. ?>
  350.  
  351. <!--Theme Custom Menu-->
  352.  
  353.  
  354. <?php
  355. add_action('admin_init', 'mytheme_add_init');
  356. add_action('admin_menu', 'mytheme_add_admin');
  357. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement