Advertisement
johnburn

Untitled

Apr 30th, 2011
317
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 7.99 KB | None | 0 0
  1. <?php
  2. function the_trend_categories($echo = true) {
  3.     $post_cat = get_the_category();
  4.     if (is_array($post_cat)):
  5.         foreach($post_cat as $npc):
  6.             $list_tc[] = $npc->cat_name;
  7.         endforeach;
  8.     endif;
  9.     if ($echo):
  10.         echo $list_tc[0];
  11.     else:
  12.         return $list_tc[0];
  13.     endif;
  14. }
  15. function blogname() {
  16.     $blogname = get_bloginfo("name");
  17.     $exp = explode(" ", $blogname);
  18.     $tot = count($exp);
  19.     $lastword = end($exp);
  20.     $left = implode(" ", array_slice($exp, 0, count($exp) - 1));
  21.     echo $left . " <span>" . $lastword . "</span>";
  22. }
  23. function remove_more_link($content) {
  24.     global $post;
  25.     $match = preg_match('/<a href="(.+)" class="more-link">(.+)/i', $content, $matches);
  26.     if ($match) {
  27.         $ret_data = str_replace($matches[0], '</p>', $content);
  28.         if (show_post_image()):
  29.             return $ret_data . '<a href="' . $matches[1] . '" class="more-links" id="readmore-post-' . $post->ID . '" title="Read More">Read More</a>';
  30.         else:
  31.             return $ret_data;
  32.         endif;
  33.     }
  34.     return $content;
  35. }
  36. add_filter('the_content', 'remove_more_link');
  37. function show_post_image() {
  38.     global $post;
  39.     $showImage = get_post_meta($post->ID, "show-image", true);
  40.     if ($showImage == "false") return false;
  41.     return true;
  42. }
  43. function the_tab_image($w = 82, $h = 57, $def = "No Image Found", $key = 'image') {
  44.     global $post;
  45.     $image = get_post_meta($post->ID, $key, true);
  46.     $g = blogdir . "thumb.php?src=" . $image . "&amp;h=$h&amp;w=$w&amp;zc=1&amp;q=100&amp;nmT=" . $def;
  47.     echo $g;
  48. }
  49. function the_short_title($limit = 26, $echo = 1, $title = '') {
  50.     if (empty($title)) {
  51.         $title = strip_tags(the_title('', '', false));
  52.     }
  53.     if (strlen($title) <= $limit) {
  54.     } else {
  55.         $title = strip_tags(substr_replace(the_title('', '', false), ' ...', $limit));
  56.     }
  57.     if ($echo == 1) {
  58.         echo $title;
  59.     } else {
  60.         return $title;
  61.     }
  62. }
  63. function substr_ellipse($str, $len) {
  64.     if (strlen($str) > $len) {
  65.         $str = substr($str, 0, $len - 3) . "...";
  66.     }
  67.     return $str;
  68. }
  69. function the_new_excerpt($limit = 100) {
  70.     echo substr_ellipse(get_the_excerpt(), $limit);
  71. }
  72. function wp_list_pages_tweak($actions = 'title_li=&echo=0') {
  73.     $pages = wp_list_pages($actions);
  74.     $pages_array = preg_split('/\n/', $pages);
  75.     $count = count($pages_array);
  76.     $i = 0;
  77.     while ($i < $count) {
  78.         $eo.= preg_replace('/<li (.+)>(.+)/i', '<li $1>', $category_array[$i]) . "\n";
  79.         $i++;
  80.     }
  81.     echo '<!--Pages Tweak-->' . $eo . '<!--/Pages Tweak-->';
  82. }
  83. function the_list_categories_tweak($categories) {
  84.     $category_array = preg_split('/\n/', $categories);
  85.     $count = count($category_array);
  86.     $i = 0;
  87.     while ($i < $count) {
  88.         if (preg_match('/<ul class=(\'|")children(\'|")/i', $category_array[$i + 1])) {
  89.             $eo.= preg_replace('/<li class=(\'|")(.+)(\'|")>/i', '<li class=$1has-child $2$3>', $category_array[$i]) . "\n";
  90.         } else {
  91.             $eo.= $category_array[$i] . "\n";
  92.         }
  93.         $i++;
  94.     }
  95.     return '<!--Categories Tweak-->' . $eo . '<!--/Categories Tweak-->';
  96. }
  97. add_action('wp_list_categories', 'the_list_categories_tweak');
  98. add_action('wp_footer', 'wp_footer_tweak');
  99. function wp_footer_tweak() { ?>
  100.                         <div class="clear"></div>
  101.                     </div>
  102.                 </div>
  103.             </div>
  104.         </div>
  105.          
  106.         <div class="footAdsense"></div>
  107.         <div class="copyright">&copy; Copyright <?php echo date("Y"); ?> <a href="<?php echo get_option('home'); ?>/"  title="<?php bloginfo('name'); ?>"><?php bloginfo('name'); ?></a>. All Rights Reserved | Designed by <a href="http://themes.rock-kitty.net/" title="FREE Wordpress Themes" target="_blank">FREE Wordpress Themes</a> and <a href="http://www.jennings-ford.co.uk/usedsales/summary/fordfocus.aspx" title="Ford Focus for Sale" target="_blank">Ford Focus for Sale</a></div>
  108.     </div>
  109.  
  110. </div>
  111.  
  112. <script type="text/javascript" src="<?php echo blogdir; ?>js/functions.js"></script>
  113. <script type="text/javascript" src="<?php echo blogdir; ?>js/HandelGothicEF.js"></script>
  114. <script type="text/javascript" src="<?php echo blogdir; ?>js/football.js"></script>
  115. <?php
  116. }
  117. $rpt = array(2, 4, 6, 8, 10);
  118. function blog_setting_warning() {
  119.     $theme_settings = get_option("blogsetings");
  120.     if (is_admin() && !is_array($theme_settings)) {
  121.         echo "    <div id='theme-warning' class='updated fade'><p><strong>" . __('Theme is not configured yet.') . "</strong> " . sprintf(__('You must <a href="%1$s">configure this theme</a> for it to work.'), "themes.php?page=blog-options") . "</p></div>    ";
  122.     }
  123. }
  124. add_action('admin_notices', 'blog_setting_warning');
  125. add_action('admin_init', 'register_theme_settings');
  126. function register_theme_settings() {
  127.     $theme_settings = $_REQUEST['blogsetings'];
  128.     $page = $_GET['page'];
  129.     $action = $_REQUEST['action'];
  130.     if ($page == "blog-options") {
  131.         if ('Save Settings' == $action) {
  132.             update_option("blogsetings", $theme_settings);
  133.             header("Location: themes.php?page=blog-options&saved=true");
  134.             die();
  135.         } elseif ('Reset Settings' == $action) {
  136.             delete_option("blogsetings");
  137.             header("Location: admin.php?page=blog-options&reset=true");
  138.             die();
  139.         }
  140.     }
  141. }
  142. function theme_options_css_js() { ?>
  143. <style type="text/css">
  144.     .metabox-holder {  
  145.         width: 350px; float: left;
  146.         margin: 0px; padding: 0px 10px 0px 0px;
  147.     }
  148.     .metabox-holder .postbox .inside {
  149.         padding: 0px 10px 0px 10px;
  150.     }
  151.     .catOptions { width:100%; height:184px!important; }
  152.     .catOption { width:100%; height:132px!important; }
  153. </style>
  154. <?php
  155. }
  156. function sp_add_custom_box() {
  157.     if (function_exists('add_meta_box')) {
  158.         add_meta_box('sp_custom_box_sp', "Post Settings", 'sp_inner_custom_box_spanish', 'post', 'normal', 'high');
  159.     }
  160. }
  161. function sp_inner_custom_box_spanish() {
  162.     global $post;
  163.     echo '<script language="javascript">jQuery("form#post").attr("enctype","multipart/form-data");</script>';
  164.     echo '<input type="hidden" name="sp_noncename" id="sp_noncename" value="' . wp_create_nonce(plugin_basename(__FILE__)) . '" />';
  165.     echo '<p><label for="_nov"><strong>No of Visits: </strong></label></p>';
  166.     echo '<textarea style="width: 95%;height: 25px;" id="_nov" name="_post-counter">' . get_post_meta($post->ID, 'post-counter', true) . '</textarea><br /><br />';
  167.     echo '<p><label for="_featured_title"><strong>Show Image?<br /></strong></label></p>';
  168.     echo '<select style="width: 95%;height: 25px;" name="_show-image">';
  169.     echo '<option value="true"';
  170.     echo get_post_meta($post->ID, 'show-image', true) == "true" ? " selected=\"selected\"" : "";
  171.     echo '>Yes</option>';
  172.     echo '<option value="false"';
  173.     echo get_post_meta($post->ID, 'show-image', true) == "false" ? " selected=\"selected\"" : "";
  174.     echo '>No</option>';
  175.     echo '</select><br /><br />';
  176. }
  177. function sp_save_postdata($post_id, $post) {
  178.     if (!wp_verify_nonce($_POST['sp_noncename'], plugin_basename(__FILE__))) {
  179.         return $post->ID;
  180.     }
  181.     if ('page' == $_POST['post_type']) {
  182.         if (!current_user_can('edit_page', $post->ID)) return $post->ID;
  183.     } else {
  184.         if (!current_user_can('edit_post', $post->ID)) return $post->ID;
  185.     }
  186.     $mydata['post-counter'] = $_POST['_post-counter'];
  187.     $mydata['show-image'] = $_POST['_show-image'];
  188.     foreach($mydata as $key => $value) {
  189.         if ($post->post_type == 'revision') return;
  190.         $value = implode(',', (array)$value);
  191.         if (get_post_meta($post->ID, $key, FALSE)) {
  192.             update_post_meta($post->ID, $key, $value);
  193.         } else {
  194.             add_post_meta($post->ID, $key, $value);
  195.         }
  196.         if (!$value) delete_post_meta($post->ID, $key);
  197.     }
  198. }
  199. add_action('admin_menu', 'sp_add_custom_box');
  200. add_action('save_post', 'sp_save_postdata', 1, 2); ?><?
  201. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement