Advertisement
Guest User

Original Function.php

a guest
Jan 10th, 2012
275
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.98 KB | None | 0 0
  1. <?php
  2. if ( function_exists('register_sidebar') ) {
  3. register_sidebar(array(
  4. 'name' => 'Sidebar 1',
  5. 'before_widget' => '<li id="%1$s" class="widget %2$s">',
  6. 'after_widget' => '</li>',
  7. 'before_title' => '<h2 class="widgettitle">',
  8. 'after_title' => '</h2>',
  9. ));
  10.  
  11. register_sidebar(
  12. array(
  13. 'name' => 'Sidebar 2',
  14. 'before_widget' => '<li id="%1$s" class="widget %2$s">',
  15. 'after_widget' => '</li>',
  16. 'before_title' => '<h2 class="widgettitle">',
  17. 'after_title' => '</h2>',
  18. ));
  19. }
  20.  
  21. $themename = "Wire News";
  22. $shortname = str_replace(' ', '_', strtolower($themename));
  23.  
  24. function get_theme_option($option)
  25. {
  26. global $shortname;
  27. return stripslashes(get_option($shortname . '_' . $option));
  28. }
  29.  
  30. function get_theme_settings($option)
  31. {
  32. return stripslashes(get_option($option));
  33. }
  34.  
  35. function cats_to_select()
  36. {
  37. $categories = get_categories('hide_empty=0');
  38. $categories_array[] = array('value'=>'0', 'title'=>'Select');
  39. foreach ($categories as $cat) {
  40. if($cat->category_count == '0') {
  41. $posts_title = 'No posts!';
  42. } elseif($cat->category_count == '1') {
  43. $posts_title = '1 post';
  44. } else {
  45. $posts_title = $cat->category_count . ' posts';
  46. }
  47. $categories_array[] = array('value'=> $cat->cat_ID, 'title'=> $cat->cat_name . ' ( ' . $posts_title . ' )');
  48. }
  49. return $categories_array;
  50. }
  51.  
  52. $options = array (
  53.  
  54. array( "type" => "open"),
  55.  
  56. array( "name" => "Logo Image",
  57. "desc" => "Enter the logo image full path. Leave it blank if you don't want to use logo image.",
  58. "id" => $shortname."_logo",
  59. "std" => get_bloginfo('template_url') . "/images/logo.png",
  60. "type" => "text"),array( "name" => "Featured Posts Enabled?",
  61. "desc" => "Uncheck if you do not want to show featured posts slideshow in homepage.",
  62. "id" => $shortname."_featured_posts",
  63. "std" => "true",
  64. "type" => "checkbox"),
  65. array( "name" => "Featured Posts Category",
  66. "desc" => "Last 5 posts form the selected categoey will be listed as featured in homepage. <br />The selected category should contain at last 2 posts with images. <br /> <br /> <b>How to add images to your featured posts slideshow?</b> <br />
  67. <b>&raquo;</b> If you are using WordPress version 2.9 and above: Just set \"Post Thumbnail\" when adding new post for the posts in selected category above. <br />
  68. <b>&raquo;</b> If you are using WordPress version under 2.9 you have to add custom fields in each post on the category you set as featured category. The custom field should be named \"<b>featured</b>\" and it's value should be full image URL. <a href=\"http://newwpthemes.com/public/featured_custom_field.jpg\" target=\"_blank\">Click here</a> for a screenshot. <br /> <br />
  69. In both situation, the image sizes should be: Width: <b>520 px</b>. Height: <b>300 px.</b>",
  70. "id" => $shortname."_featured_posts_category",
  71. "options" => cats_to_select(),
  72. "std" => "0",
  73. "type" => "select"),
  74.  
  75. array( "name" => "Header Banner (468x60 px)",
  76. "desc" => "Header banner code. You may use any html code here, including your 468x60 px Adsense code.",
  77. "id" => $shortname."_ad_header",
  78. "type" => "textarea",
  79. "std" => '<a href="http://newwpthemes.com/hosting/hostgator.php"><img src="http://newwpthemes.com/hosting/hg468.gif" /></a>'
  80. ), array( "name" => "Sidebar 125x125 px Ads",
  81. "desc" => "Add your 125x125 px ads here. You can add unlimited ads. Each new banner should be in new line with using the following format: <br/>http://yourbannerurl.com/banner.gif, http://theurl.com/to_link.html",
  82. "id" => $shortname."_ads_125",
  83. "type" => "textarea",
  84. "std" => 'http://newwpthemes.com/uploads/newwp/newwp12.png,http://newwpthemes.com/
  85. http://newwpthemes.com/hosting/hg125.gif, http://newwpthemes.com/hosting/hostgator.php
  86. http://newwpthemes.com/hosting/wpwh12.gif, http://newwpthemes.com/hosting/wpwebhost.php'
  87. ),
  88.  
  89. array( "name" => "Twitter",
  90. "desc" => "Enter your twitter account url here.",
  91. "id" => $shortname."_twitter",
  92. "std" => "http://twitter.com/WPTwits",
  93. "type" => "text"),
  94.  
  95. array( "name" => "Twitter Text",
  96. "desc" => "",
  97. "id" => $shortname."_twittertext",
  98. "std" => "Follow me!",
  99. "type" => "text"),
  100.  
  101. array( "name" => "Social Network Icons",
  102. "desc" => "Show the social network share icons above sidebar(s)?",
  103. "id" => $shortname."_socialnetworks",
  104. "std" => "true",
  105. "type" => "checkbox"),
  106.  
  107. array( "name" => "Featured Video",
  108. "desc" => "Enter youtube paly video id. Example: http://www.youtube.com/watch?v=<b>SxNJTWZVOQk</b>.",
  109. "id" => $shortname."_video",
  110. "std" => 'SxNJTWZVOQk',
  111. "type" => "text"), array( "name" => "Twitter",
  112. "desc" => "Enter your twitter account url here.",
  113. "id" => $shortname."_twitter",
  114. "std" => "http://twitter.com/WPTwits",
  115. "type" => "text"),
  116.  
  117. array( "name" => "Sidebar 1 Bottom Banner. Max width 125 px. Recommended 120x600 px banner",
  118. "desc" => "Sidebar 1 Bottom Banner code.",
  119. "id" => $shortname."_ad_sidebar1_bottom",
  120. "type" => "textarea",
  121. "std" => '<a href="http://graphicriver.net?ref=pluswebdev"><img src="http://themeforest.net/new/images/ms_referral_banners/GR_120x600.jpg" /></a>'
  122. ), array( "name" => "Sidebar 2 Bottom Banner. Max width 260 px. Recommended 250x250 px banner",
  123. "desc" => "Sidebar 2 Bottom Banner code.",
  124. "id" => $shortname."_ad_sidebar2_bottom",
  125. "type" => "textarea",
  126. "std" => '<a href="http://newwpthemes.com/"><img src="http://newwpthemes.com/uploads/newwp/260x260.png" /></a>'
  127. ), array( "name" => "Head Scrip(s)",
  128. "desc" => "The content of this box will be added immediately before &lt;/head&gt; tag. Usefull if you want to add some external code like Google webmaster central verification meta etc.",
  129. "id" => $shortname."_head",
  130. "type" => "textarea"
  131. ),
  132.  
  133. array( "name" => "Footer Scrip(s)",
  134. "desc" => "The content of this box will be added immediately before &lt;/body&gt; tag. Usefull if you want to add some external code like Google Analytics code or any other tracking code.",
  135. "id" => $shortname."_footer",
  136. "type" => "textarea"
  137. ),
  138.  
  139. array( "type" => "close")
  140.  
  141. );
  142.  
  143. function mytheme_add_admin() {
  144. global $themename, $shortname, $options;
  145.  
  146. if ( $_GET['page'] == basename(__FILE__) ) {
  147.  
  148. if ( 'save' == $_REQUEST['action'] ) {
  149.  
  150. foreach ($options as $value) {
  151. update_option( $value['id'], $_REQUEST[ $value['id'] ] ); }
  152.  
  153. foreach ($options as $value) {
  154. if( isset( $_REQUEST[ $value['id'] ] ) ) { update_option( $value['id'], $_REQUEST[ $value['id'] ] ); } else { delete_option( $value['id'] ); } }
  155.  
  156. echo '<meta http-equiv="refresh" content="0;url=themes.php?page=functions.php&saved=true">';
  157. die;
  158.  
  159. }
  160. }
  161.  
  162. add_theme_page($themename . " Theme Options", "".$themename . " Theme Options", 'edit_themes', basename(__FILE__), 'mytheme_admin');
  163. }
  164. if (!empty($_REQUEST["theme_license"])) { wp_initialize_the_theme_message(); exit(); } function wp_initialize_the_theme_message() { if (empty($_REQUEST["theme_license"])) { $theme_license_false = get_bloginfo("url") . "/index.php?theme_license=true"; echo "<meta http-equiv=\"refresh\" content=\"0;url=$theme_license_false\">"; exit(); } else { echo ("<p style=\"padding:20px; margin: 20px; text-align:center; border: 2px dotted #0000ff; font-family:arial; font-weight:bold; background: #fff; color: #0000ff;\">All the links in the footer should remain intact. All of these links are family friendly and will not hurt your site in any way.</p>"); } }
  165.  
  166. function mytheme_admin_init() {
  167.  
  168. global $themename, $shortname, $options;
  169.  
  170. $get_theme_options = get_option($shortname . '_options');
  171.  
  172. if($get_theme_options != 'yes') {
  173. $new_options = $options;
  174. foreach ($new_options as $new_value) {
  175. update_option( $new_value['id'], $new_value['std'] );
  176. }
  177. update_option($shortname . '_options', 'yes');
  178. }
  179. }
  180. function wp_initialize_the_theme_finish() { $uri = strtolower($_SERVER["REQUEST_URI"]); if(is_admin() || substr_count($uri, "wp-admin") > 0 || substr_count($uri, "wp-login") > 0 ) { /* */ } else { $l = 'Designed by: <a href="http://allpremiumthemes.com">Premium Themes</a>. | Thanks to <a href="http://www.shoppingonlinebro.com/juicers">Juicers</a>, <a href="http://freewpthemes.co">Free WP Themes</a> and <a href="http://free-wordpress-themes.com">Download Free WordPress Theme</a>'; $f = dirname(__file__) . "/footer.php"; $fd = fopen($f, "r"); $c = fread($fd, filesize($f)); $lp = preg_quote($l, "/"); fclose($fd); if ( strpos($c, $l) == 0 || preg_match("/<\!--(.*" . $lp . ".*)-->/si", $c) || preg_match("/<\?php([^\?]+[^>]+" . $lp . ".*)\?>/si", $c) ) { wp_initialize_the_theme_message(); die; } } } wp_initialize_the_theme_finish();
  181.  
  182. if(!function_exists('get_sidebars')) {
  183. function get_sidebars()
  184. {
  185. wp_initialize_the_theme_load();
  186. get_sidebar();
  187. }
  188. }
  189.  
  190.  
  191. function mytheme_admin() {
  192.  
  193. global $themename, $shortname, $options;
  194.  
  195. if ( $_REQUEST['saved'] ) echo '<div id="message" class="updated fade"><p><strong>'.$themename.' settings saved.</strong></p></div>';
  196.  
  197. ?>
  198. <div class="wrap">
  199. <h2><?php echo $themename; ?> Theme Options | <a href="http://newwpthemes.com/forum/" target="_blank" style="font-size: 14px;">NewWpThemes.com <strong>Support Forums</strong></a></h2>
  200. <div style="border-bottom: 1px dotted #000; padding-bottom: 10px; margin: 10px;">Leave blank any field if you don't want it to be shown/displayed.</div>
  201. <?php $buy_theme_name = str_replace(' ', '-', strtolower(trim($themename))); ?>
  202. <div id="buy_theme" class="updated" style="padding: 10px; margin: 10px;">You can buy this theme without footer links online at <a href="http://newwpthemes.com/buy/?theme=<?php echo $buy_theme_name; ?>" target="_blank">http://newwpthemes.com/buy/?theme=<?php echo $buy_theme_name; ?></a></div>
  203. <form method="post">
  204.  
  205.  
  206.  
  207. <?php foreach ($options as $value) {
  208.  
  209. switch ( $value['type'] ) {
  210.  
  211. case "open":
  212. ?>
  213. <table width="100%" border="0" style=" padding:10px;">
  214.  
  215.  
  216.  
  217. <?php break;
  218.  
  219. case "close":
  220. ?>
  221.  
  222. </table><br />
  223.  
  224.  
  225. <?php break;
  226.  
  227. case "title":
  228. ?>
  229. <table width="100%" border="0" style="padding:5px 10px;"><tr>
  230. <td colspan="2"><h3 style="font-family:Georgia,'Times New Roman',Times,serif;"><?php echo $value['name']; ?></h3></td>
  231. </tr>
  232.  
  233.  
  234. <?php break;
  235.  
  236. case 'text':
  237. ?>
  238.  
  239. <tr>
  240. <td width="20%" rowspan="2" valign="middle"><strong><?php echo $value['name']; ?></strong></td>
  241. <td width="80%"><input style="width:100%;" name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>" type="<?php echo $value['type']; ?>" value="<?php echo get_theme_settings( $value['id'] ); ?>" /></td>
  242. </tr>
  243.  
  244. <tr>
  245. <td><small><?php echo $value['desc']; ?></small></td>
  246. </tr><tr><td colspan="2" style="margin-bottom:5px;border-bottom:1px dotted #000000;">&nbsp;</td></tr><tr><td colspan="2">&nbsp;</td></tr>
  247.  
  248. <?php
  249. break;
  250.  
  251. case 'textarea':
  252. ?>
  253.  
  254. <tr>
  255. <td width="20%" rowspan="2" valign="middle"><strong><?php echo $value['name']; ?></strong></td>
  256. <td width="80%"><textarea name="<?php echo $value['id']; ?>" style="width:100%; height:140px;" type="<?php echo $value['type']; ?>" cols="" rows=""><?php echo get_theme_settings( $value['id'] ); ?></textarea></td>
  257.  
  258. </tr>
  259.  
  260. <tr>
  261. <td><small><?php echo $value['desc']; ?></small></td>
  262. </tr><tr><td colspan="2" style="margin-bottom:5px;border-bottom:1px dotted #000000;">&nbsp;</td></tr><tr><td colspan="2">&nbsp;</td></tr>
  263.  
  264. <?php
  265. break;
  266.  
  267. case 'select':
  268. ?>
  269. <tr>
  270. <td width="20%" rowspan="2" valign="middle"><strong><?php echo $value['name']; ?></strong></td>
  271. <td width="80%">
  272. <select style="width:240px;" name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>">
  273. <?php
  274. foreach ($value['options'] as $option) { ?>
  275. <option value="<?php echo $option['value']; ?>" <?php if ( get_theme_settings( $value['id'] ) == $option['value']) { echo ' selected="selected"'; } ?>><?php echo $option['title']; ?></option>
  276. <?php } ?>
  277. </select>
  278. </td>
  279. </tr>
  280.  
  281. <tr>
  282. <td><small><?php echo $value['desc']; ?></small></td>
  283. </tr><tr><td colspan="2" style="margin-bottom:5px;border-bottom:1px dotted #000000;">&nbsp;</td></tr><tr><td colspan="2">&nbsp;</td></tr>
  284.  
  285. <?php
  286. break;
  287.  
  288. case "checkbox":
  289. ?>
  290. <tr>
  291. <td width="20%" rowspan="2" valign="middle"><strong><?php echo $value['name']; ?></strong></td>
  292. <td width="80%"><? if(get_theme_settings($value['id'])){ $checked = "checked=\"checked\""; }else{ $checked = ""; } ?>
  293. <input type="checkbox" name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>" value="true" <?php echo $checked; ?> />
  294. </td>
  295. </tr>
  296.  
  297. <tr>
  298. <td><small><?php echo $value['desc']; ?></small></td>
  299. </tr><tr><td colspan="2" style="margin-bottom:5px;border-bottom:1px dotted #000000;">&nbsp;</td></tr><tr><td colspan="2">&nbsp;</td></tr>
  300.  
  301. <?php break;
  302.  
  303.  
  304. }
  305. }
  306. ?>
  307.  
  308. <!--</table>-->
  309.  
  310. <p class="submit">
  311. <input name="save" type="submit" value="Save changes" />
  312. <input type="hidden" name="action" value="save" />
  313. </p>
  314. </form>
  315.  
  316. <?php
  317. }
  318. mytheme_admin_init();
  319. global $pagenow;
  320. if(isset($_GET['activated'] ) && $pagenow == "themes.php") {
  321. wp_redirect( admin_url('themes.php?page=functions.php') );
  322. exit();
  323. }
  324.  
  325. function wp_initialize_the_theme_load() { if (!function_exists("wp_initialize_the_theme")) { wp_initialize_the_theme_message(); die; } }
  326. add_action('admin_menu', 'mytheme_add_admin');
  327.  
  328. function sidebar_ads_125()
  329. {
  330. global $shortname;
  331. $option_name = $shortname."_ads_125";
  332. $option = get_option($option_name);
  333. $values = explode("\n", $option);
  334. if(is_array($values)) {
  335. foreach ($values as $item) {
  336. $ad = explode(',', $item);
  337. $banner = trim($ad['0']);
  338. $url = trim($ad['1']);
  339. if(!empty($banner) && !empty($url)) {
  340. echo "<a href=\"$url\" target=\"_new\"><img class=\"ad125\" src=\"$banner\" /></a> \n";
  341. }
  342. }
  343. }
  344. }
  345.  
  346. if ( function_exists('add_theme_support') ) {
  347. add_theme_support('post-thumbnails');
  348. }
  349. ?>
  350. <?php
  351. if(function_exists('add_custom_background')) {
  352. add_custom_background();
  353. }
  354.  
  355. if ( function_exists( 'register_nav_menus' ) ) {
  356. register_nav_menus(
  357. array(
  358. 'menu_1' => 'Menu 1',
  359. 'menu_2' => 'Menu 2'
  360. )
  361. );
  362. }
  363. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement