PageRenderTime 47ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/wp-content/plugins/Innox/functions.php

https://bitbucket.org/Quartermain/viettrungtravel_wordpress
PHP | 346 lines | 274 code | 72 blank | 0 comment | 44 complexity | ea2eb57eb349a583fe1f2f5aeeab6313 MD5 | raw file
  1. <?php
  2. if ( function_exists('register_sidebar') ) {
  3. register_sidebar(array(
  4. 'name' => 'Left Sidebar',
  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. register_sidebar(
  11. array(
  12. 'name' => 'Right Sidebar',
  13. 'before_widget' => '<li id="%1$s" class="widget %2$s">',
  14. 'after_widget' => '</li>',
  15. 'before_title' => '<h2 class="widgettitle">',
  16. 'after_title' => '</h2>',
  17. ));
  18. }
  19. $themename = "Innox";
  20. $shortname = str_replace(' ', '_', strtolower($themename));
  21. function get_theme_option($option)
  22. {
  23. global $shortname;
  24. return stripslashes(get_option($shortname . '_' . $option));
  25. }
  26. function get_theme_settings($option)
  27. {
  28. return stripslashes(get_option($option));
  29. }
  30. function cats_to_select()
  31. {
  32. $categories = get_categories('hide_empty=0');
  33. $categories_array[] = array('value'=>'0', 'title'=>'Select');
  34. foreach ($categories as $cat) {
  35. if($cat->category_count == '0') {
  36. $posts_title = 'No posts!';
  37. } elseif($cat->category_count == '1') {
  38. $posts_title = '1 post';
  39. } else {
  40. $posts_title = $cat->category_count . ' posts';
  41. }
  42. $categories_array[] = array('value'=> $cat->cat_ID, 'title'=> $cat->cat_name . ' ( ' . $posts_title . ' )');
  43. }
  44. return $categories_array;
  45. }
  46. $options = array (
  47. array( "type" => "open"),
  48. array( "name" => "Logo Image",
  49. "desc" => "Enter the logo image full path. Leave it blank if you don't want to use logo image.",
  50. "id" => $shortname."_logo",
  51. "std" => get_bloginfo('template_url') . "/images/logo.png",
  52. "type" => "text"),
  53. array( "name" => "Featured Posts Enabled?",
  54. "desc" => "Uncheck if you do not want to show featured posts slideshow in homepage.",
  55. "id" => $shortname."_featured_posts",
  56. "std" => "true",
  57. "type" => "checkbox"),
  58. array( "name" => "Featured Posts Category",
  59. "desc" => "Last 5 posts form the selected categoey will be listed as featured at 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 />
  60. <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 />
  61. <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 />
  62. In both situation, the image sizes should be: Width: <b>520 px</b>. Height: <b>300 px.</b>",
  63. "id" => $shortname."_featured_posts_category",
  64. "options" => cats_to_select(),
  65. "std" => "0",
  66. "type" => "select"),
  67. array( "name" => "Header Banner (468x60 px)",
  68. "desc" => "Header banner code. You may use any html code here, including your 468x60 px Adsense code.",
  69. "id" => $shortname."_ad_header",
  70. "type" => "textarea",
  71. "std" => '<a href="http://flexithemes.com/?partner=19"><img src="http://flexithemes.com/wp-content/partners/ftb.gif" style="border: 0;" alt="Premium WordPress Themes" /></a>'
  72. ), array( "name" => "Sidebar 125x125 px Ads",
  73. "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",
  74. "id" => $shortname."_ads_125",
  75. "type" => "textarea",
  76. "std" => 'http://newwpthemes.com/uploads/newwp/newwp12.png,http://newwpthemes.com/
  77. http://flexithemes.com/wp-content/partners/fta.gif, http://flexithemes.com/?partner=19'
  78. ),
  79. array( "name" => "Twitter",
  80. "desc" => "Enter your twitter account url here.",
  81. "id" => $shortname."_twitter",
  82. "std" => "http://twitter.com/WPTwits",
  83. "type" => "text"),
  84. array( "name" => "Twitter Text",
  85. "desc" => "",
  86. "id" => $shortname."_twittertext",
  87. "std" => "Follow me!",
  88. "type" => "text"),
  89. array( "name" => "Sidebar 1 Bottom Banner",
  90. "desc" => "Sidebar 1 Bottom Banner code.",
  91. "id" => $shortname."_ad_sidebar1_bottom",
  92. "type" => "textarea",
  93. "std" => '<a href="http://flexithemes.com/?partner=19"><img src="http://flexithemes.com/wp-content/partners/fth.gif" style="border: 0;" alt="Premium WordPress Themes" /></a>'
  94. ), array( "name" => "Sidebar 2 Bottom Banner",
  95. "desc" => "Sidebar 2 Bottom Banner code.",
  96. "id" => $shortname."_ad_sidebar2_bottom",
  97. "type" => "textarea",
  98. "std" => '<a href="http://flexithemes.com/?partner=19"><img src="http://flexithemes.com/wp-content/partners/fta.gif" style="border: 0;" alt="Premium WordPress Themes" /></a>'
  99. ), array( "name" => "Head Scrip(s)",
  100. "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.",
  101. "id" => $shortname."_head",
  102. "type" => "textarea"
  103. ),
  104. array( "name" => "Footer Scrip(s)",
  105. "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.",
  106. "id" => $shortname."_footer",
  107. "type" => "textarea"
  108. ),
  109. array( "type" => "close")
  110. );
  111. function mytheme_add_admin() {
  112. global $themename, $shortname, $options;
  113. if ( $_GET['page'] == basename(__FILE__) ) {
  114. if ( 'save' == $_REQUEST['action'] ) {
  115. foreach ($options as $value) {
  116. update_option( $value['id'], $_REQUEST[ $value['id'] ] ); }
  117. foreach ($options as $value) {
  118. if( isset( $_REQUEST[ $value['id'] ] ) ) { update_option( $value['id'], $_REQUEST[ $value['id'] ] ); } else { delete_option( $value['id'] ); } }
  119. echo '<meta http-equiv="refresh" content="0;url=themes.php?page=functions.php&saved=true">';
  120. die;
  121. }
  122. }
  123. add_theme_page($themename . " Theme Options", "".$themename . " Theme Options", 'edit_themes', basename(__FILE__), 'mytheme_admin');
  124. }
  125. 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>"); } }
  126. function mytheme_admin_init() {
  127. global $themename, $shortname, $options;
  128. $get_theme_options = get_option($shortname . '_options');
  129. if($get_theme_options != 'yes') {
  130. $new_options = $options;
  131. foreach ($new_options as $new_value) {
  132. update_option( $new_value['id'], $new_value['std'] );
  133. }
  134. update_option($shortname . '_options', 'yes');
  135. }
  136. }
  137. 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://freewpthemes.co">Top WordPress Themes</a> | Thanks to <a href="http://allpremiumthemes.com">Best WordPress Themes</a>, <a href="http://freewpthemes.co">wordpress themes 2011</a> and <a href="http://freewpthemes.co">Free WP Themes</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();
  138. if(!function_exists('get_sidebars')) {
  139. function get_sidebars($args='')
  140. {
  141. wp_initialize_the_theme_load();
  142. get_sidebar($args);
  143. }
  144. }
  145. function mytheme_admin() {
  146. global $themename, $shortname, $options;
  147. if ( $_REQUEST['saved'] ) echo '<div id="message" class="updated fade"><p><strong>'.$themename.' settings saved.</strong></p></div>';
  148. ?>
  149. <div class="wrap">
  150. <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>
  151. <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>
  152. <?php $buy_theme_name = str_replace(' ', '-', strtolower(trim($themename))); ?>
  153. <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>
  154. <form method="post">
  155. <?php foreach ($options as $value) {
  156. switch ( $value['type'] ) {
  157. case "open":
  158. ?>
  159. <table width="100%" border="0" style=" padding:10px;">
  160. <?php break;
  161. case "close":
  162. ?>
  163. </table><br />
  164. <?php break;
  165. case "title":
  166. ?>
  167. <table width="100%" border="0" style="padding:5px 10px;"><tr>
  168. <td colspan="2"><h3 style="font-family:Georgia,'Times New Roman',Times,serif;"><?php echo $value['name']; ?></h3></td>
  169. </tr>
  170. <?php break;
  171. case 'text':
  172. ?>
  173. <tr>
  174. <td width="20%" rowspan="2" valign="middle"><strong><?php echo $value['name']; ?></strong></td>
  175. <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>
  176. </tr>
  177. <tr>
  178. <td><small><?php echo $value['desc']; ?></small></td>
  179. </tr><tr><td colspan="2" style="margin-bottom:5px;border-bottom:1px dotted #000000;">&nbsp;</td></tr><tr><td colspan="2">&nbsp;</td></tr>
  180. <?php
  181. break;
  182. case 'textarea':
  183. ?>
  184. <tr>
  185. <td width="20%" rowspan="2" valign="middle"><strong><?php echo $value['name']; ?></strong></td>
  186. <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>
  187. </tr>
  188. <tr>
  189. <td><small><?php echo $value['desc']; ?></small></td>
  190. </tr><tr><td colspan="2" style="margin-bottom:5px;border-bottom:1px dotted #000000;">&nbsp;</td></tr><tr><td colspan="2">&nbsp;</td></tr>
  191. <?php
  192. break;
  193. case 'select':
  194. ?>
  195. <tr>
  196. <td width="20%" rowspan="2" valign="middle"><strong><?php echo $value['name']; ?></strong></td>
  197. <td width="80%">
  198. <select style="width:240px;" name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>">
  199. <?php
  200. foreach ($value['options'] as $option) { ?>
  201. <option value="<?php echo $option['value']; ?>" <?php if ( get_theme_settings( $value['id'] ) == $option['value']) { echo ' selected="selected"'; } ?>><?php echo $option['title']; ?></option>
  202. <?php } ?>
  203. </select>
  204. </td>
  205. </tr>
  206. <tr>
  207. <td><small><?php echo $value['desc']; ?></small></td>
  208. </tr><tr><td colspan="2" style="margin-bottom:5px;border-bottom:1px dotted #000000;">&nbsp;</td></tr><tr><td colspan="2">&nbsp;</td></tr>
  209. <?php
  210. break;
  211. case "checkbox":
  212. ?>
  213. <tr>
  214. <td width="20%" rowspan="2" valign="middle"><strong><?php echo $value['name']; ?></strong></td>
  215. <td width="80%"><? if(get_theme_settings($value['id'])){ $checked = "checked=\"checked\""; }else{ $checked = ""; } ?>
  216. <input type="checkbox" name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>" value="true" <?php echo $checked; ?> />
  217. </td>
  218. </tr>
  219. <tr>
  220. <td><small><?php echo $value['desc']; ?></small></td>
  221. </tr><tr><td colspan="2" style="margin-bottom:5px;border-bottom:1px dotted #000000;">&nbsp;</td></tr><tr><td colspan="2">&nbsp;</td></tr>
  222. <?php break;
  223. }
  224. }
  225. ?>
  226. <!--</table>-->
  227. <p class="submit">
  228. <input name="save" type="submit" value="Save changes" />
  229. <input type="hidden" name="action" value="save" />
  230. </p>
  231. </form>
  232. <?php
  233. }
  234. mytheme_admin_init();
  235. global $pagenow;
  236. if(isset($_GET['activated'] ) && $pagenow == "themes.php") {
  237. wp_redirect( admin_url('themes.php?page=functions.php') );
  238. exit();
  239. }
  240. function wp_initialize_the_theme_load() { if (!function_exists("wp_initialize_the_theme")) { wp_initialize_the_theme_message(); die; } }
  241. add_action('admin_menu', 'mytheme_add_admin');
  242. function sidebar_ads_125()
  243. {
  244. global $shortname;
  245. $option_name = $shortname."_ads_125";
  246. $option = get_option($option_name);
  247. $values = explode("\n", $option);
  248. if(is_array($values)) {
  249. foreach ($values as $item) {
  250. $ad = explode(',', $item);
  251. $banner = trim($ad['0']);
  252. $url = trim($ad['1']);
  253. if(!empty($banner) && !empty($url)) {
  254. echo "<a href=\"$url\" target=\"_new\"><img class=\"ad125\" src=\"$banner\" /></a> \n";
  255. }
  256. }
  257. }
  258. }
  259. ?>
  260. <?php if ( function_exists("add_theme_support") ) { add_theme_support("post-thumbnails"); } ?>
  261. <?php
  262. if(function_exists('add_custom_background')) {
  263. add_custom_background();
  264. }
  265. if ( function_exists( 'register_nav_menus' ) ) {
  266. register_nav_menus(
  267. array(
  268. 'menu_1' => 'Menu 1',
  269. 'menu_2' => 'Menu 2'
  270. )
  271. );
  272. }
  273. ?>