Advertisement
Guest User

Cannot modify header information

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