Advertisement
STATEDLIGHT

Admin-Functions

Jan 21st, 2013
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.85 KB | None | 0 0
  1. <?php
  2.  
  3. /*-----------------------------------------------------------------------------------*/
  4. /* Add default options after activation */
  5. /*-----------------------------------------------------------------------------------*/
  6. if (is_admin() && isset($_GET['activated'] ) && $pagenow == "themes.php?page=siteoptions" ) {
  7. //Call action that sets
  8. add_action('admin_head','tt_option_setup');
  9. }
  10.  
  11. function tt_option_setup(){
  12.  
  13. //Update EMPTY options
  14. $tt_array = array();
  15. add_option('tt_options',$tt_array);
  16.  
  17. $template = get_option('tt_template');
  18. $saved_options = get_option('tt_options');
  19.  
  20. foreach($template as $option) {
  21. if($option['type'] != 'heading'){
  22. $id = $option['id'];
  23. $std = $option['std'];
  24. $db_option = get_option($id);
  25. if(empty($db_option)){
  26. if(is_array($option['type'])) {
  27. foreach($option['type'] as $child){
  28. $c_id = $child['id'];
  29. $c_std = $child['std'];
  30. update_option($c_id,$c_std);
  31. $tt_array[$c_id] = $c_std;
  32. }
  33. } else {
  34. update_option($id,$std);
  35. $tt_array[$id] = $std;
  36. }
  37. }
  38. else { //So just store the old values over again.
  39. $tt_array[$id] = $db_option;
  40. }
  41. }
  42. }
  43. update_option('tt_options',$tt_array);
  44. }
  45.  
  46.  
  47.  
  48.  
  49.  
  50. /*-----------------------------------------------------------------------------------*/
  51. /* Admin Backend */
  52. /*-----------------------------------------------------------------------------------*/
  53. function siteoptions_admin_head() { ?>
  54.  
  55. <script type="text/javascript">
  56. jQuery(function(){
  57. var message = '<p><strong>Activation Successful!</strong> This theme\'s settings are located under <a href="<?php echo admin_url('admin.php?page=siteoptions'); ?>">Appearance > Site Options</a>.</p>';
  58. jQuery('.themes-php #message2').html(message);
  59. });
  60. </script>
  61.  
  62.  
  63. <?php }
  64.  
  65. add_action('admin_head', 'siteoptions_admin_head');
  66. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement