Advertisement
Guest User

Cannot modify header information

a guest
Jul 14th, 2010
563
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 14.92 KB | None | 0 0
  1. <?php
  2. $themename = "Angelia";
  3. $shortname ="ang";
  4. $ang_categories_obj = get_categories('hide_empty=0');
  5. $ang_categories = array();
  6. foreach ($ang_categories_obj as $ang_cat) {
  7.     $ang_categories[$ang_cat->cat_ID] = $ang_cat->category_nicename;
  8. }
  9. $categories_tmp = array_unshift($ang_categories, "Select a category:");
  10. $number_entries = array("Select a Number:","1","2","3","4","5","6","7","8","9","10" );
  11. $options = array(
  12. array (
  13. "type" => "open",
  14. "id" => $shortname."_temp",
  15. "std" => ""
  16. ),
  17.  
  18. array(
  19. "name" => "Styles",
  20. "desc" => "Switch Style",
  21. "id" => $shortname."_style",
  22. "type" => "select",
  23. "options" => array("Style1","Style2","Style3","Style4","Style5","Style6","Style7","Style8","Style9","Style10"),
  24. "std" => "Style1",
  25. ),
  26.  
  27. array(
  28. "name" => "BreadCrumbs",
  29. "desc" => "Hide Breadcrumbs?",
  30. "id" => $shortname."_breadcrumbs",
  31. "type" => "checkbox",
  32. "std" => "false"
  33. ),
  34.  
  35.  
  36. array(
  37. "name" => "Slider Category",
  38. "desc" => "Select  the category for slider",
  39. "id" => $shortname."_slider_cat",
  40. "type" => "select",
  41. "std" => "Select a category",
  42. "options" => $ang_categories),
  43.  
  44. array(
  45. "name" => "Slider Posts Count",
  46. "desc" => "How many posts you want to show in slider?",
  47. "id" => $shortname."_slider_count",
  48. "type" => "select",
  49. "std" => "3",
  50. "options" => $number_entries),
  51.  
  52. array(
  53. "name" => "Featured Posts Category",
  54. "desc" => "Select the category of featured posts",
  55. "id" =>$shortname."_featured_cat",
  56. "type" => "select",
  57. "std" => "Select a category",
  58. "options" => $ang_categories),
  59.  
  60. array(
  61. "name" => "Featured Posts count",
  62. "desc" => "How many Featured posts you want to show on homepage?",
  63. "id" => $shortname."_featured_count",
  64. "type" => "select",
  65. "std" => "3",
  66. "options" => $number_entries),
  67.  
  68. array(
  69. "name" => "Hide all the Social Icons",
  70. "id" => $shortname."_hide_social",
  71. "type" => "checkbox",
  72. "std" => "false"),
  73.  
  74. array(
  75. "name" => "Twitter Icon",
  76. "desc" => "Check to hide Twitter icon. If not type your twitter url below:",
  77. "id" => $shortname."_hide_tw",
  78. "type" => "checkbox",
  79. "std" => ""),
  80.  
  81. array(
  82. "id" => $shortname."_tw_url",
  83. "type" => "text2",
  84. "desc" => "Type Your Twitter URL",
  85. "std" => ""
  86. ),
  87.  
  88. array(
  89. "name" => "Facebook Icon",
  90. "desc" => "Check to hide Facebook icon. If not type your Facebook url below:",
  91. "id" => $shortname."_hide_fb",
  92. "type" => "checkbox",
  93. "std" => ""),
  94.  
  95. array(
  96. "id" => $shortname."_fb_url",
  97. "type" => "text2",
  98. "desc" => "Type Your Facebook URL",
  99. "std" => ""
  100. ),
  101.  
  102. array(
  103. "name" => "Myspace Icon",
  104. "desc" => "Check to hide Myspace icon. If not type your Myspace url below:",
  105. "id" => $shortname."_hide_ms",
  106. "type" => "checkbox",
  107. "std" => ""),
  108.  
  109. array(
  110. "id" => $shortname."_ms_url",
  111. "type" => "text2",
  112. "desc" => "Type Your Myspace URL",
  113. "std" => ""
  114. ),
  115.  
  116. array(
  117. "name" => "RSS Feed Icon",
  118. "desc" => "Check to hide Feedburner icon. If not type your Feedburner url below:",
  119. "id" => $shortname."_hide_rss",
  120. "type" => "checkbox",
  121. "std" => ""),
  122.  
  123. array(
  124. "id" => $shortname."_rss_url",
  125. "type" => "text2",
  126. "desc" => "Type Your Feedburner URL",
  127. "std" => ""
  128. ),
  129.  
  130. array(
  131. "name" => "Footer Text",
  132. "desc" => "Type your own footer text",
  133. "id" => $shortname."_text",
  134. "type" => "textarea",
  135. "std" => "&#169;Angelia 2010")
  136. );
  137. array( "type" => "close"
  138.  
  139. );
  140.  
  141. function mytheme_add_admin() {
  142. global $themename, $shortname, $options;
  143.         $optionvar = array();
  144.     if ( isset($_GET['page']) && $_GET['page'] == basename(__FILE__) )  {
  145.         if ( isset($_REQUEST['action']) && 'save' == $_REQUEST['action'] ) {
  146.                 foreach ($options as $value) {
  147.                     update_option( $value['id'], $_REQUEST[ $value['id'] ] ); }
  148.                 foreach ($options as $value) {
  149.                         if( isset( $_REQUEST[ $value['id'] ] ) ) {
  150.                             $optionvar[$value['id']] = $_REQUEST[ $value['id']];
  151.                         } else {
  152.                             $optionvar[$value['id']] = null;
  153.                         }
  154.                     }
  155.                 update_option( $shortname."_options", $optionvar  );
  156.                 header("Location: themes.php?page=functions.php&saved=true");
  157.                 die;
  158.  
  159.         } else if( isset($_REQUEST['action']) && 'reset' == $_REQUEST['action'] ) {
  160.  
  161.             foreach ($options as $value) {
  162.                 delete_option( $value['id'] ); }
  163.  
  164.             header("Location: themes.php?page=functions.php&reset=true");
  165.             die;
  166.  
  167.         }
  168.     }
  169.  
  170.     add_theme_page($themename." Options", "".$themename." Options", 'edit_themes', basename(__FILE__), 'mytheme_admin');
  171.  
  172. }
  173.  
  174. function mytheme_admin() {
  175.     global $themename, $shortname, $options, $option_values;
  176.     if ( isset($_REQUEST['saved']) &&  $_REQUEST['saved'] ) echo '<div id="message" class="updated fade"><p><strong>'.$themename.' settings saved.</strong></p></div>';
  177.     if ( isset($_REQUEST['reset']) &&  $_REQUEST['reset'] ) echo '<div id="message" class="updated fade"><p><strong>'.$themename.' settings reset.</strong></p></div>';
  178. ?>
  179. <div class="wrap" style="margin:0px 20px; padding:20px 0px 0px;">
  180.  
  181. <form method="post">
  182.  
  183. <?php foreach ($options as $value) {
  184. switch ( $value['type'] ) {
  185.  
  186. case "open":
  187. ?>
  188. <div style="width:808px; background:#eee; border:1px solid #ddd; padding:20px; overflow:hidden; display: block; margin: 0px 0px 30px;">
  189.  
  190. <?php break;
  191.  
  192. case "close":
  193. ?>
  194.  
  195. </div>
  196.  
  197. <?php break;
  198.  
  199. case "misc":
  200. ?>
  201. <div style="width:808px; background:#fffde2; border:1px solid #ddd; padding:20px; overflow:hidden; display: block; margin: 0px 0px 30px;">
  202.     <?php echo $value['name']; ?>
  203. </div>
  204. <?php break;
  205.  
  206. case "title":
  207. ?>
  208.  
  209. <div style="width:810px; height:22px; background:#555; padding:9px 20px; overflow:hidden; margin:0px; font-family:Verdana, sans-serif; font-size:18px; font-weight:normal; color:#EEE;">
  210.     <?php echo $value['name']; ?>
  211. </div>
  212.  
  213. <?php break;
  214.  
  215. case "heading":
  216. ?>
  217.  
  218. <div style="width:800px; height:22px; color:#555; padding:9px 0px; overflow:hidden; margin:0px; font-family:Verdana, sans-serif; font-size:21px; font-weight:bold; font-style:normal; border-bottom:solid 2px #666; margin-bottom:15px;">
  219.     <?php echo $value['name']; ?>
  220. </div>
  221.  
  222. <?php break;
  223.  
  224. case 'text':
  225. ?>
  226.  
  227. <div style="width:800px; padding:0px 0px 10px; margin:0px 0px 10px; border-bottom:1px solid #ddd; overflow:hidden;">
  228.     <span style="font-family:Arial, sans-serif; font-size:16px; font-weight:bold; color:#444; display:block; padding:5px 0px; width:350px; float:left;">
  229.         <?php echo $value['name']; ?>
  230.     </span>
  231.  
  232.     <input style="width:200px;" name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>" type="<?php echo $value['type']; ?>" value="<?php if ( get_option( $value['id'] ) != "") { echo stripslashes(get_option( $value['id'] )); } else { echo stripslashes($value['std']); } ?>" />
  233.     <br/>
  234.     <span style="font-family:Arial, sans-serif; font-size:11px; font-weight:bold; color:#444; display:block; padding:5px 0px; width:350px; float:left;">
  235.         <?php echo $value['desc']; ?>
  236.     </span>
  237. </div>
  238.  
  239.  
  240. <?php
  241. break;
  242.  
  243.  
  244. case 'text2':
  245. ?>
  246.  
  247. <div style="width:460px; padding:0px 0px 10px; margin:0px 0px 10px; border-bottom:1px solid #ddd; overflow:hidden; float:right;">
  248.     <span style="font-family:Arial, sans-serif; font-size:16px; font-weight:bold; color:#444; display:block; padding:5px 0px; width:auto; float:left;">
  249.     </span>
  250.     <input style="width:200px;" name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>" type="<?php echo $value['type']; ?>" value="<?php if ( get_option( $value['id'] ) != "") { echo stripslashes(get_option( $value['id'] )); } else { echo stripslashes($value['std']); } ?>" />
  251.     <br/>
  252.     <span style="font-family:Arial, sans-serif; font-size:11px; font-weight:bold; color:#444; display:block; padding:5px 0px; width:350px; float:left;">
  253.         <?php echo $value['desc']; ?>
  254.     </span>
  255. </div>
  256.  
  257.  
  258. <?php
  259. break;
  260.  
  261. case 'textarea':
  262. ?>
  263.  
  264. <div style="width:808px; padding:0px 0px 10px; margin:0px 0px 10px; border-bottom:1px solid #ddd; overflow:hidden;">
  265.     <span style="font-family:Arial, sans-serif; font-size:16px; font-weight:bold; color:#444; display:block; padding:5px 0px; width:350px; float:left;">
  266.         <?php echo $value['name']; ?>
  267.     </span>
  268.     <textarea name="<?php echo $value['id']; ?>" style="width:600px; height:120px;" type="<?php echo $value['type']; ?>" cols="" rows=""><?php if ( get_option( $value['id'] ) != "") { echo stripslashes(get_option( $value['id'] )); } else { echo stripslashes($value['std']); } ?></textarea>
  269.     <br/>
  270.     <span style="font-family:Arial, sans-serif; font-size:11px; font-weight:bold; color:#444; display:block; padding:5px 0px; width:350px; float:left;">
  271.         <?php echo $value['desc']; ?>
  272.     </span>
  273. </div>
  274.  
  275. <?php
  276. break;
  277. /*Ralph Damiano*/
  278. case 'select':
  279. ?>
  280.  
  281. <div style="width:600px; padding:0px 0px 10px; margin:0px 0px 10px; border-bottom:1px solid #ddd; overflow:hidden;">
  282.     <span style="font-family:Arial, sans-serif; font-size:16px; font-weight:bold; color:#444; display:block; padding:5px 0px; width:350px; float:left;">
  283.         <?php echo $value['name']; ?>
  284.     </span>
  285.     <select style="width:240px;" name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>"><?php foreach ($value['options'] as $option) { ?><option<?php if ( get_option( $value['id'] ) == $option) { echo ' selected="selected"'; } elseif ($option == $value['std']) { echo ' selected="selected"'; } ?>><?php echo $option; ?></option><?php } ?></select>
  286.     <br/>
  287.     <span style="font-family:Arial, sans-serif; font-size:11px; font-weight:bold; color:#444; display:block; padding:5px 0px; width:350px; float:left;">
  288.         <?php echo $value['desc']; ?>
  289.     </span>
  290. </div>
  291.  
  292. <?php
  293. break;
  294.  
  295. case "checkbox":
  296. ?>
  297.  
  298. <div style="width:600px; padding:0px 0px 0px; margin:0px 0px 0px; overflow:hidden; float:left;">
  299.     <span style="font-family:Arial, sans-serif; font-size:16px; font-weight:bold; color:#444; display:block; padding:5px 0px; width:350px; float:left;">
  300.         <?php echo $value['name']; ?>
  301.     </span>
  302.     <?php if(get_option($value['id'])){ $checked = "checked=\"checked\""; }else{ $checked = "";} ?>
  303.     <input type="checkbox" name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>" value="true" <?php echo $checked; ?> />
  304.     <br/>
  305.     <span style="font-family:Arial, sans-serif; font-size:11px; font-weight:bold; color:#444; display:block; padding:5px 0px; width:200px; float:left;">
  306.     </span>
  307. </div>
  308.  
  309.  
  310. <?php break;
  311.  
  312. }
  313. }
  314. ?>
  315. <p class="submit">
  316. <input name="save" type="submit" value="Save changes" />
  317. <input type="hidden" name="action" value="save" />
  318. </p>
  319. </form>
  320. <form method="post">
  321. <p class="submit">
  322. <input name="reset" type="submit" value="Reset" />
  323. <input type="hidden" name="action" value="reset" />
  324. </p>
  325. </form>
  326.  
  327. <?php
  328. }
  329. add_action('admin_menu', 'mytheme_add_admin');?>
  330. <?php
  331. if ( function_exists('register_sidebar') )
  332. register_sidebar(array(
  333. 'name' => 'Sidebar'
  334. ));
  335.  
  336. if ( function_exists('register_sidebar') )
  337. register_sidebar(array(
  338. 'name' => 'Footer'
  339. ));
  340.  
  341.  
  342. function new_excerpt_length($length) {
  343.     return 15;
  344. }
  345. add_filter('excerpt_length', 'new_excerpt_length');
  346.  
  347.  
  348. function getImage($num) {
  349. global $more;
  350. $more = 1;
  351. $content = get_the_content();
  352. $count = substr_count($content, '<img');
  353. $start = 0;
  354. for($i=1;$i<=$count;$i++) {
  355. $imgBeg = strpos($content, '<img', $start);
  356. $post = substr($content, $imgBeg);
  357. $imgEnd = strpos($post, '>');
  358. $postOutput = substr($post, 0, $imgEnd+1);
  359. $postOutput = preg_replace('/width="([0-9]*)" height="([0-9]*)"/', '',$postOutput);;
  360. $image[$i] = $postOutput;
  361. $start=$imgEnd+1;
  362. }
  363. if(stristr($image[$num],'<img')) { echo '<a href="'.$link.'">'.$image[$num]."</a>"; }
  364. $more = 0;
  365. }
  366.  
  367.  
  368. function the_thumb($size = "medium", $add = "") {
  369. global $wpdb, $post;
  370. $thumb = $wpdb->get_row("SELECT ID, post_title FROM {$wpdb->posts} WHERE post_parent = {$post->ID} AND post_mime_type LIKE 'image%' ORDER BY menu_order");
  371. if(!empty($thumb)) {
  372. $image = image_downsize($thumb->ID, $size);
  373. print "<img src='{$image[0]}' alt='{$thumb->post_title}' {$add} />";
  374. }
  375. }
  376.  
  377. function dimox_breadcrumbs() {
  378.  
  379.   $delimiter = '&raquo;';
  380.   $name = 'Home'; //text for the 'Home' link
  381.   $currentBefore = '<span class="current">';
  382.   $currentAfter = '</span>';
  383.  
  384.   if ( !is_home() && !is_front_page() || is_paged() ) {
  385.  
  386.     echo '<div id="crumbs">';
  387.  
  388.     global $post;
  389.     $home = get_bloginfo('url');
  390.     echo '<a href="' . $home . '">' . $name . '</a> ' . $delimiter . ' ';
  391.  
  392.     if ( is_category() ) {
  393.       global $wp_query;
  394.       $cat_obj = $wp_query->get_queried_object();
  395.       $thisCat = $cat_obj->term_id;
  396.       $thisCat = get_category($thisCat);
  397.       $parentCat = get_category($thisCat->parent);
  398.       if ($thisCat->parent != 0) echo(get_category_parents($parentCat, TRUE, ' ' . $delimiter . ' '));
  399.       single_cat_title();
  400.  
  401.  
  402.     } elseif ( is_day() ) {
  403.       echo '<a href="' . get_year_link(get_the_time('Y')) . '">' . get_the_time('Y') . '</a> ' . $delimiter . ' ';
  404.       echo '<a href="' . get_month_link(get_the_time('Y'),get_the_time('m')) . '">' . get_the_time('F') . '</a> ' . $delimiter . ' ';
  405.       echo $currentBefore . get_the_time('d') . $currentAfter;
  406.  
  407.     } elseif ( is_month() ) {
  408.       echo '<a href="' . get_year_link(get_the_time('Y')) . '">' . get_the_time('Y') . '</a> ' . $delimiter . ' ';
  409.       echo $currentBefore . get_the_time('F') . $currentAfter;
  410.  
  411.     } elseif ( is_year() ) {
  412.       echo $currentBefore . get_the_time('Y') . $currentAfter;
  413.  
  414.     } elseif ( is_single() ) {
  415.       $cat = get_the_category(); $cat = $cat[0];
  416.       echo get_category_parents($cat, TRUE, ' ' . $delimiter . ' ');
  417.       echo $currentBefore;
  418.       the_title();
  419.       echo $currentAfter;
  420.  
  421.     } elseif ( is_page() && !$post->post_parent ) {
  422.       echo $currentBefore;
  423.       the_title();
  424.       echo $currentAfter;
  425.  
  426.     } elseif ( is_page() && $post->post_parent ) {
  427.       $parent_id  = $post->post_parent;
  428.       $breadcrumbs = array();
  429.       while ($parent_id) {
  430.         $page = get_page($parent_id);
  431.         $breadcrumbs[] = '<a href="' . get_permalink($page->ID) . '">' . get_the_title($page->ID) . '</a>';
  432.         $parent_id  = $page->post_parent;
  433.       }
  434.       $breadcrumbs = array_reverse($breadcrumbs);
  435.       foreach ($breadcrumbs as $crumb) echo $crumb . ' ' . $delimiter . ' ';
  436.       echo $currentBefore;
  437.       the_title();
  438.       echo $currentAfter;
  439.  
  440.     } elseif ( is_search() ) {
  441.       echo $currentBefore . 'Search results for &#39;' . get_search_query() . '&#39;' . $currentAfter;
  442.  
  443.     } elseif ( is_tag() ) {
  444.       echo $currentBefore . 'Posts tagged &#39;';
  445.       single_tag_title();
  446.       echo '&#39;' . $currentAfter;
  447.  
  448.     } elseif ( is_author() ) {
  449.        global $author;
  450.       $userdata = get_userdata($author);
  451.       echo $currentBefore . 'Articles posted by ' . $userdata->display_name . $currentAfter;
  452.  
  453.     } elseif ( is_404() ) {
  454.       echo $currentBefore . 'Error 404' . $currentAfter;
  455.     }
  456.  
  457.     if ( get_query_var('paged') ) {
  458.       if ( is_category() || is_day() || is_month() || is_year() || is_search() || is_tag() || is_author() ) echo ' (';
  459.       echo __('Page') . ' ' . get_query_var('paged');
  460.       if ( is_category() || is_day() || is_month() || is_year() || is_search() || is_tag() || is_author() ) echo ')';
  461.     }
  462.  
  463.     echo '</div>';
  464.  
  465.   }
  466. }
  467. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement