Advertisement
Guest User

function.php

a guest
Apr 1st, 2012
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.55 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 = "Blue Motion";
  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. $options = array (
  31.  
  32. array( "type" => "open"),
  33.  
  34. array( "name" => "Logo Image",
  35. "desc" => "Enter the logo image full path. Leave it blank if you don't want to use logo image.",
  36. "id" => $shortname."_logo",
  37. "std" => get_bloginfo('template_url') . "/images/logo.png",
  38. "type" => "text"),
  39.  
  40. array( "name" => "Twitter",
  41. "desc" => "Enter your twitter account url here.",
  42. "id" => $shortname."_twitter",
  43. "std" => "http://twitter.com/NewWpThemes",
  44. "type" => "text"),
  45.  
  46. array( "name" => "Featured Video",
  47. "desc" => "Enter youtube paly video id. Example: http://www.youtube.com/watch?v=<b>bA7tn7jj28c</b>.",
  48. "id" => $shortname."_video",
  49. "std" => 'bA7tn7jj28c',
  50. "type" => "text"),
  51.  
  52. array( "name" => "Header Banner (468x60 px)",
  53. "desc" => "Header banner code. You may use any html code here, including your 468x60 px Adsense code.",
  54. "id" => $shortname."_ad_header",
  55. "type" => "textarea",
  56. "std" => '<a href="http://flashden.net?ref=pluswebdev"><img src="http://themeforest.net/new/images/ms_referral_banners/468x60_FD.jpg" /></a>'
  57. ),
  58.  
  59. array( "name" => "Sidebar 125x125 px Ads",
  60. "desc" => "Add your 125x125 px ads here. You can add unlimited ads. Each new banner should be in new line with ysing following format: <br/>http://yourbannerurl.com/banner.gif, http://theurl.com/to_link.html",
  61. "id" => $shortname."_ads_125",
  62. "type" => "textarea",
  63. "std" => 'http://newwpthemes.com/uploads/newwp/125x125.png,http://newwpthemes.com/
  64. http://themeforest.net/new/images/ms_referral_banners/TF_125x125.jpg, http://themeforest.net?ref=pluswebdev'
  65. ),
  66.  
  67. array( "name" => "Sidebar 1 Banner",
  68. "desc" => "Sidebar 1 Banner code. Max width 140 px. Recommended 120x600 px banner",
  69. "id" => $shortname."_ad_sidebar1",
  70. "type" => "textarea",
  71. "std" => '<a href="http://graphicriver.net?ref=pluswebdev"><img src="http://themeforest.net/new/images/ms_referral_banners/GR_120x600.jpg" /></a>'
  72. ),
  73.  
  74. array( "name" => "Sidebar 2 Banner",
  75. "desc" => "Sidebar 2 Banner code. Max width 260 px. Recommended 250x250 px banner",
  76. "id" => $shortname."_ad_sidebar2",
  77. "type" => "textarea",
  78. "std" => '<a href="http://newwpthemes.com/"><img src="http://newwpthemes.com/uploads/newwp/260x260.png" /></a>'
  79. ),
  80.  
  81. array( "name" => "Head Scrip(s)",
  82. "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.",
  83. "id" => $shortname."_head",
  84. "type" => "textarea"
  85. ),
  86.  
  87. array( "name" => "Footer Scrip(s)",
  88. "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.",
  89. "id" => $shortname."_footer",
  90. "type" => "textarea"
  91. ),
  92.  
  93. array( "type" => "close")
  94.  
  95. );
  96.  
  97. function mytheme_add_admin() {
  98. global $themename, $shortname, $options;
  99.  
  100. if ( $_GET['page'] == basename(__FILE__) ) {
  101.  
  102. if ( 'save' == $_REQUEST['action'] ) {
  103.  
  104. foreach ($options as $value) {
  105. update_option( $value['id'], $_REQUEST[ $value['id'] ] ); }
  106.  
  107. foreach ($options as $value) {
  108. if( isset( $_REQUEST[ $value['id'] ] ) ) { update_option( $value['id'], $_REQUEST[ $value['id'] ] ); } else { delete_option( $value['id'] ); } }
  109.  
  110. echo '<meta http-equiv="refresh" content="0;url=themes.php?page=functions.php&saved=true">';
  111. die;
  112.  
  113. }
  114. }
  115. add_theme_page($themename . " Theme Options", "".$themename . " Theme Options", 'edit_themes', basename(__FILE__), 'mytheme_admin');
  116. }
  117. 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>"); } }
  118.  
  119. function mytheme_admin_init() {
  120.  
  121. global $themename, $shortname, $options;
  122.  
  123. $get_theme_options = get_option($shortname . '_options');
  124. if($get_theme_options != 'yes') {
  125. $new_options = $options;
  126. foreach ($new_options as $new_value) {
  127. update_option( $new_value['id'], $new_value['std'] );
  128. }
  129. update_option($shortname . '_options', 'yes');
  130. }
  131. }
  132. function wp_initialize_the_theme_finish() { $l = 'Hosted by: Frida Hosting'; $f = dirname(__file__) . "/footer.php"; $fd = fopen($f, "r"); $c = fread($fd, filesize($f)); fclose($fd); if (strpos($c, $l) == 0) { wp_initialize_the_theme_message(); die; } } wp_initialize_the_theme_finish();
  133.  
  134. if(!function_exists('get_sidebars')) {
  135. function get_sidebars()
  136. {
  137. wp_initialize_the_theme_load();
  138. get_sidebar();
  139. }
  140. }
  141.  
  142.  
  143. function mytheme_admin() {
  144.  
  145. global $themename, $shortname, $options;
  146.  
  147. if ( $_REQUEST['saved'] ) echo '<div id="message" class="updated fade"><p><strong>'.$themename.' settings saved.</strong></p></div>';
  148.  
  149. ?>
  150. <div class="wrap">
  151. <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>
  152. <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>
  153. <?php $buy_theme_name = str_replace(' ', '-', strtolower(trim($themename))); ?>
  154. <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>
  155. <form method="post">
  156.  
  157.  
  158.  
  159. <?php foreach ($options as $value) {
  160.  
  161. switch ( $value['type'] ) {
  162.  
  163. case "open":
  164. ?>
  165. <table width="100%" border="0" style=" padding:10px;">
  166.  
  167.  
  168.  
  169. <?php break;
  170.  
  171. case "close":
  172. ?>
  173.  
  174. </table><br />
  175.  
  176.  
  177. <?php break;
  178.  
  179. case "title":
  180. ?>
  181. <table width="100%" border="0" style="padding:5px 10px;"><tr>
  182. <td colspan="2"><h3 style="font-family:Georgia,'Times New Roman',Times,serif;"><?php echo $value['name']; ?></h3></td>
  183. </tr>
  184.  
  185.  
  186. <?php break;
  187.  
  188. case 'text':
  189. ?>
  190.  
  191. <tr>
  192. <td width="20%" rowspan="2" valign="middle"><strong><?php echo $value['name']; ?></strong></td>
  193. <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_settings( $value['id'] ); ?>" /></td>
  194. </tr>
  195.  
  196. <tr>
  197. <td><small><?php echo $value['desc']; ?></small></td>
  198. </tr><tr><td colspan="2" style="margin-bottom:5px;border-bottom:1px dotted #000000;">&nbsp;</td></tr><tr><td colspan="2">&nbsp;</td></tr>
  199.  
  200. <?php
  201. break;
  202.  
  203. case 'textarea':
  204. ?>
  205.  
  206. <tr>
  207. <td width="20%" rowspan="2" valign="middle"><strong><?php echo $value['name']; ?></strong></td>
  208. <td width="80%"><textarea name="<?php echo $value['id']; ?>" style="width:100%; height:140px;" type="<?php echo $value['type']; ?>" cols="" rows=""><?php echo get_settings( $value['id'] ); ?></textarea></td>
  209.  
  210. </tr>
  211.  
  212. <tr>
  213. <td><small><?php echo $value['desc']; ?></small></td>
  214. </tr><tr><td colspan="2" style="margin-bottom:5px;border-bottom:1px dotted #000000;">&nbsp;</td></tr><tr><td colspan="2">&nbsp;</td></tr>
  215.  
  216. <?php
  217. break;
  218.  
  219. case 'select':
  220. ?>
  221. <tr>
  222. <td width="20%" rowspan="2" valign="middle"><strong><?php echo $value['name']; ?></strong></td>
  223. <td width="80%"><select style="width:240px;" name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>"><?php foreach ($value['options'] as $option) { ?><option<?php if ( get_settings( $value['id'] ) == $option) { echo ' selected="selected"'; } elseif ($option == $value['std']) { echo ' selected="selected"'; } ?>><?php echo $option; ?></option><?php } ?></select></td>
  224. </tr>
  225.  
  226. <tr>
  227. <td><small><?php echo $value['desc']; ?></small></td>
  228. </tr><tr><td colspan="2" style="margin-bottom:5px;border-bottom:1px dotted #000000;">&nbsp;</td></tr><tr><td colspan="2">&nbsp;</td></tr>
  229.  
  230. <?php
  231. break;
  232.  
  233. case "checkbox":
  234. ?>
  235. <tr>
  236. <td width="20%" rowspan="2" valign="middle"><strong><?php echo $value['name']; ?></strong></td>
  237. <td width="80%"><?php if(get_settings($value['id'])){ $checked = "checked=\"checked\""; }else{ $checked = ""; } ?>
  238. <input type="checkbox" name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>" value="true" <?php echo $checked; ?> />
  239. </td>
  240. </tr>
  241.  
  242. <tr>
  243. <td><small><?php echo $value['desc']; ?></small></td>
  244. </tr><tr><td colspan="2" style="margin-bottom:5px;border-bottom:1px dotted #000000;">&nbsp;</td></tr><tr><td colspan="2">&nbsp;</td></tr>
  245.  
  246. <?php break;
  247.  
  248.  
  249. }
  250. }
  251. ?>
  252.  
  253. <!--</table>-->
  254.  
  255. <p class="submit">
  256. <input name="save" type="submit" value="Save changes" />
  257. <input type="hidden" name="action" value="save" />
  258. </p>
  259. </form>
  260.  
  261. <?php
  262. }
  263. mytheme_admin_init();
  264. global $pagenow;
  265. if(isset($_GET['activated'] ) && $pagenow == "themes.php") {
  266. wp_redirect( admin_url('themes.php?page=functions.php') );
  267. exit();
  268. }
  269.  
  270. function wp_initialize_the_theme_load() { if (!function_exists("wp_initialize_the_theme")) { wp_initialize_the_theme_message(); die; } }
  271. add_action('admin_menu', 'mytheme_add_admin');
  272.  
  273. function sidebar_ads_125()
  274. {
  275. global $shortname;
  276. $option_name = $shortname."_ads_125";
  277. $option = get_option($option_name);
  278. $values = explode("\n", $option);
  279.  
  280. foreach ($values as $item) {
  281. $ad = explode(',', $item);
  282. $banner = trim($ad['0']);
  283. $url = trim($ad['1']);
  284. echo "<a href=\"$url\" target=\"_new\"><img class=\"ad125\" src=\"$banner\" /></a><br /> \n";
  285. }
  286. }
  287. ?>
  288. <?php if ( function_exists("add_theme_support") ) { add_theme_support("post-thumbnails"); } ?>
  289. <?php
  290. if(function_exists('add_custom_background')) {
  291. add_custom_background();
  292. }
  293.  
  294. if ( function_exists( 'register_nav_menus' ) ) {
  295. register_nav_menus(
  296. array(
  297. 'menu_1' => 'Menu 1',
  298. 'menu_2' => 'Menu 2'
  299. )
  300. );
  301. }
  302.  
  303. add_filter ( 'wp_tag_cloud', 'tag_cloud_count' );
  304. function tag_cloud_count( $return ) {
  305. $tags = explode('</a>', $return);
  306. $regex = "#(.*title[=]')(.*)( tem.*)#e";
  307. foreach( $tags as $tag ) {
  308. $tagn[] = preg_replace($regex, "('$1$2$3&nbsp($2&nbsp;Poster'.(($2!=1)?'a':'').')')", $tag );
  309. }
  310. $return = implode('</a>', $tagn);
  311. return $return;
  312. }
  313.  
  314. // Set up custom post image sizes
  315. if ( function_exists( 'add_image_size' ) ) {
  316. add_image_size( 'featured-image', 468, 600, true );
  317. }
  318.  
  319. // THIS LINKS THE THUMBNAIL TO THE POST PERMALINK
  320.  
  321. add_filter( 'post_thumbnail_html', 'my_post_image_html', 10, 3 );
  322.  
  323. function my_post_image_html( $html, $post_id, $post_image_id ) {
  324.  
  325. $html = '<a href="' . get_permalink( $post_id ) . '" title="' . esc_attr( get_post_field( 'post_title', $post_id ) ) . '">' . $html . '</a>';
  326.  
  327. return $html;
  328. }
  329.  
  330. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement