Advertisement
Guest User

Error

a guest
Dec 18th, 2013
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 13.98 KB | None | 0 0
  1. <?php
  2. include("includes/theme-options.php");
  3. // Uncomment this to test your localization, make sure to enter the right language code.
  4. // function test_localization( $locale ) {
  5. //  return "nl_NL";
  6. // }
  7. // add_filter('locale','test_localization');
  8. load_theme_textdomain('Designrshub', TEMPLATEPATH.'/languages/');
  9. if (function_exists('create_initial_post_types')) create_initial_post_types(); //fix for wp 3.0
  10. if (function_exists('add_custom_background')) add_custom_background();
  11. if (function_exists('add_post_type_support')) add_post_type_support( 'page', 'excerpt' );
  12. require_once(TEMPLATEPATH . '/includes/theme-widgets.php');
  13. require_once(TEMPLATEPATH . '/includes/column-shortcodes.php');
  14. /* MENUS */
  15. add_action( 'init', 'tj_register_my_menu' );
  16. function tj_register_my_menu() {
  17.    register_nav_menus(
  18.       array(
  19.          'header-cats' => __( 'Header Categories', 'Designrshub' )
  20.       )
  21.    );
  22. }
  23. /*
  24. * ------------------------------------------------- *
  25. *       Lines
  26. * ------------------------------------------------- *
  27. */
  28.  
  29. function rt_shortcode_lines( $atts, $content = null ) {
  30.     //[line toplink="top"]
  31.     if (isset($atts["toplink"]) && trim($atts["toplink"])){
  32.         $line='<div class="line margin"><a href="#" class="top">['.$atts["toplink"].']</a></div>';
  33.     }else{
  34.         $line = '<div class="line margin"></div>';
  35.     }
  36.    
  37.     return $line;
  38.    
  39. }
  40.  
  41. add_shortcode('line', 'rt_shortcode_lines');
  42. /*
  43. * ------------------------------------------------- *
  44. *       show shortcode :)
  45. * ------------------------------------------------- *
  46. */
  47.  
  48. function rt_shortcode_show_shortcode( $atts, $content = null ) {
  49.  
  50.    
  51.     return '<code>' . htmlspecialchars($content) . '</code>';
  52. }
  53.  
  54. add_shortcode('show_shortcode', 'rt_shortcode_show_shortcode');
  55.  
  56. /* MENUS END */
  57. // General Widgets
  58. if (function_exists('register_sidebar'))
  59. {
  60.     register_sidebar(array(
  61.         'name'          => 'Sidebar',
  62.         'before_widget' => '',
  63.         'after_widget'  => '<div class="clear"></div></div></div>',
  64.         'before_title'  => '<div class="widget"><h3>',
  65.         'after_title'   => '</h3><div class="widgetbox">',
  66.     ));
  67.     register_sidebar(array(
  68.         'name'          => 'Footer Widget #1',
  69.         'before_widget' => '',
  70.         'after_widget'  => '<div class="clear"></div></div></div>',
  71.         'before_title'  => '<div class="footerwidget"><h3>',
  72.         'after_title'   => '</h3><div class="widgetbox">',
  73.     ));
  74.     register_sidebar(array(
  75.         'name'          => 'Footer Widget #2',
  76.         'before_widget' => '',
  77.         'after_widget'  => '<div class="clear"></div></div></div>',
  78.         'before_title'  => '<div class="footerwidget"><h3>',
  79.         'after_title'   => '</h3><div class="widgetbox">',
  80.     ));
  81.     register_sidebar(array(
  82.         'name'          => 'Footer Widget #3',
  83.         'before_widget' => '',
  84.         'after_widget'  => '<div class="clear"></div></div></div>',
  85.         'before_title'  => '<div class="footerwidget"><h3>',
  86.         'after_title'   => '</h3><div class="widgetbox">',
  87.     ));
  88.     register_sidebar(array(
  89.         'name'          => 'Footer Widget #4',
  90.         'before_widget' => '',
  91.         'after_widget'  => '<div class="clear"></div></div></div>',
  92.         'before_title'  => '<div class="footerwidget"><h3>',
  93.         'after_title'   => '</h3><div class="widgetbox">',
  94.     ));
  95. }
  96. # Content Excerpts
  97. function tj_content_limit($max_char, $more_link_text = '', $stripteaser = 0, $more_file = '') {
  98.     $content = get_the_content($more_link_text, $stripteaser, $more_file);
  99.     $content = apply_filters('the_content', $content);
  100.     $content = str_replace(']]>', ']]&gt;', $content);
  101.     $content = strip_tags($content);
  102.    if (strlen($_GET['p']) > 0) {
  103.       echo "";
  104.       echo $content;
  105.       echo "...";
  106.    }
  107.    else if ((strlen($content)>$max_char) && ($espacio = strpos($content, " ", $max_char ))) {
  108.         $content = substr($content, 0, $espacio);
  109.         $content = $content;
  110.         echo "";
  111.         echo $content;
  112.         echo "...";
  113.    }
  114.    else {
  115.       echo "";
  116.       echo $content;
  117.    }
  118. }
  119. // Turn a category ID to a Name
  120. function cat_id_to_name($id) {
  121.     foreach((array)(get_categories()) as $category) {
  122.         if ($id == $category->cat_ID) { return $category->cat_name; break; }
  123.     }
  124. }
  125. // CALL TO ACTION BUTTONS - Download //
  126.  
  127. function action_button_shortcode( $atts ) {
  128.        extract( shortcode_atts(
  129.                array(
  130.                        'title' => 'Title',
  131.                        'url' => ''
  132.                ),
  133.                $atts
  134.        ));
  135.        return '<div style="text-align: center;"><span class="action-button blue-button"><a target="_blank" rel="nofollow" href="' . $url . '">' . $title . '</a></span></div>';
  136. }
  137.  
  138. add_shortcode( 'action-button', 'action_button_shortcode' );
  139.  
  140. // CALL TO ACTION BUTTONS - Feature //
  141.  
  142. function action_feature_shortcode( $atts ) {
  143.        extract( shortcode_atts(
  144.                array(
  145.                        'title' => 'Title',
  146.                        'url' => ''
  147.                ),
  148.                $atts
  149.        ));
  150.        return '<p style="background-color: #EEE; margin-bottom: 10px; border-left: 8px solid #BFCADA; padding: 8px 6px;">Recommended Post: <a target="_blank" href="' . $url . '">' . $title . '</a></p>';
  151. }
  152.  
  153. add_shortcode( 'action-feature', 'action_feature_shortcode' );
  154.  
  155. // DEALS //
  156. function action_deals_shortcode( $atts ) {
  157.        extract( shortcode_atts(
  158.                array(
  159.                        'title' => 'Title',
  160.                        'content' => '',
  161.                        'coupon' => 'ClickHere',
  162.                        'image' => '',
  163.                        'url' => ''
  164.                ),
  165.                $atts
  166.        ));
  167.        return '<div class="deals" style="opacity: 1; padding: 10px 0 0 0; position: static;"><div class="dealsthumb" style="opacity: 1; padding-right: 20px; position: static;"><a href="' . $url . '" title="' . $title . '" rel="nofollow" target="_blank"><img src="' . $image . '" alt="' . $title . '"></a></div><div class="dealsinfo" style="opacity: 1; padding: 10px 0 0 0; position: static;"><h2>' . $title . '</h2>' . $content . '<div class="couponcode" style=" opacity: 1; position: static; ">Coupon Code: <a rel="nofollow" class="copy" href="' . $url . '" title="' . $title . '" target="_blank">' . $coupon . '</a><span class="copysmall">(click to open site)</span></div></div></div>';
  168. }
  169.  
  170. add_shortcode( 'action-deals', 'action_deals_shortcode' );
  171.  
  172. // Default Content
  173. add_filter( 'default_content', 'my_editor_content' );
  174. function my_editor_content( $content ) {
  175.     $content = "[action-button title=View Source url=URLHERE]";
  176.     return $content;
  177. }
  178. // Related Posts with Thumbnail
  179. add_theme_support( 'post-thumbnails' );  
  180. set_post_thumbnail_size( 100, 100, true );  
  181.  
  182. //Delete Title Links
  183. add_filter('wp_list_categories', 'remove_category_link_prefix');
  184. function remove_category_link_prefix($output) {
  185.     return str_replace('View all posts filed under ', '', $output);
  186. }
  187.  
  188. // Contributors
  189. function contributors() {
  190. global $wpdb;
  191.  
  192. $authors = $wpdb->get_results("SELECT ID, user_nicename from $wpdb->users ORDER BY display_name");
  193.  
  194. foreach($authors as $author) {
  195. echo "<li>";
  196. echo "<a href=\"".get_bloginfo('url')."/?author=";
  197. echo $author->ID;
  198. echo "\">";
  199. echo get_avatar($author->ID);
  200. echo "</a>";
  201. echo "<div>";
  202. echo "<span>";
  203. the_author_meta('description', $author->ID);
  204. echo "</span>";
  205. echo "</div>";
  206. echo "</li>";
  207. }
  208. }
  209.  
  210. // Related Posts
  211. function related_posts_shortcode( $atts ) {
  212. extract(shortcode_atts(array(
  213. 'limit' => '5',
  214. ), $atts));
  215.  
  216. global $wpdb, $post, $table_prefix;
  217.  
  218. if ($post->ID) {
  219. $retval = '
  220. <ul>';
  221.  
  222. // Get tags
  223. $tags = wp_get_post_tags($post->ID);
  224. $tagsarray = array();
  225.  
  226. foreach ($tags as $tag) {
  227. $tagsarray[] = $tag->term_id;
  228. }
  229. $tagslist = implode(',', $tagsarray);
  230. // Do the query
  231. $q = "
  232. SELECT p.*, count(tr.object_id) as count
  233. FROM $wpdb->term_taxonomy AS tt, $wpdb->term_relationships AS tr, $wpdb->posts AS p
  234. WHERE tt.taxonomy ='post_tag'
  235. AND tt.term_taxonomy_id = tr.term_taxonomy_id
  236. AND tr.object_id = p.ID
  237. AND tt.term_id IN ($tagslist)
  238. AND p.ID != $post->ID
  239. AND p.post_status = 'publish'
  240. AND p.post_date_gmt < NOW()
  241. GROUP BY tr.object_id
  242. ORDER BY count DESC, p.post_date_gmt DESC
  243. LIMIT $limit;";
  244. $related = $wpdb->get_results($q);
  245.  
  246. if ( $related ) {
  247. foreach($related as $r) {
  248. $retval .= '
  249. <li><a target="_blank" href="'.get_permalink($r->ID).'">'.wptexturize($r->post_title).'</a></li>
  250. ';
  251. }
  252. } else {
  253. $retval .= '';
  254. }
  255. $retval .= '</ul>';
  256. return '<p>You might want to take a look at the following related articles: </p>' . $retval . '<p style="font-size: 12px; background: #E2E2E2; border: 1px solid silver; padding: 5px 5px; text-align: center; box-shadow: white 0px 0px 1px 1px inset;margin-bottom: 10px;"> Dont forget to <a href="http://feeds.feedburner.com/Designrshub" style="padding-left: 23px; background: url(http://graphicdesignjunction.com/images/rss.png) 2px -1px no-repeat; padding-bottom: 4px;" rel="nofollow" target="_blank">subscribe to our RSS-feed</a> and <a href="https://twitter.com/designrshub" rel="nofollow" target="_blank" style="padding-left: 23px; padding-bottom: 3px; padding-top: 0px; background: url(http://graphicdesignjunction.com/images/twitter.png) 2px -1px no-repeat;">follow us on Twitter</a> – for recent updates.</p><div style="padding:0px;overflow: hidden;width: 630px;height: 338px;"> <a href="http://themeforest.net/popular_item/by_category?category=wordpress&amp;ref=ManuelGarciaPH" target="_blank" title="Most Popular WordPress Themes on ThemeForest"><img alt="Most Popular WordPress Themes on ThemeForest" style="width: 630px;border: none;background: none;padding: 0;" src="http://theme.co/media/x_tf/x-marketing-intro.png"></a></div><div style="background: #34495e;width: 630px;height: 76px; margin: 0px 0px 20px 0px"> <div style="float:left;margin: 0 14px 0 15px;"> <span style="color: #00be9c; text-align: center; display: block; font-weight: bold; font-size: 29px; padding: 15px 0 6px 0; letter-spacing: -2px;">IMAGINE YOUR BRAND HERE</span> <span style="color: white; display: block; text-align: center;">Get it in front of thousands of highly targeted customers</span> </div> <div style="float: left; margin: 27px 0 0 13px;"> <a style="background: #00bc9b; padding: 10px 20px; color: white; border-radius: 6px;text-decoration: none;" href="http://designrshub.com/contact-us" target="_blank">Contact Us</a> </div> </div>';
  257. }
  258. return;
  259. }
  260. add_shortcode('related_posts', 'related_posts_shortcode');
  261.  
  262. function the_slug() {
  263.     $post_data = get_post($post->ID, ARRAY_A);
  264.     $slug = $post_data['post_name'];
  265.     return $slug;
  266. }
  267.  
  268. // Get Image Attachments
  269. function tj_get_image($postid=0, $size='full') {
  270.     if ($postid<1)
  271.     $postid = get_the_ID();
  272.     $thumb = get_post_meta($postid, "thumb", TRUE); // Declare the custom field for the image
  273.     if ($thumb != null or $thumb != '') {
  274.         echo get_image_path($thumb);
  275.     }
  276.     elseif ($images = get_children(array(
  277.         'post_parent' => $postid,
  278.         'post_type' => 'attachment',
  279.         'numberposts' => '1',
  280.         'post_mime_type' => 'image', )))
  281.         foreach($images as $image) {
  282.             $thumbnail=wp_get_attachment_image_src($image->ID, $size);
  283.             ?>
  284.     <?php echo get_image_path($thumbnail[0]); ?>
  285.     <?php }
  286.         else {
  287.         $theme_name = strtolower(get_current_theme());
  288.         echo get_image_path('wp-content/themes/'.$theme_name.'/images/image-pending.gif');
  289.     }
  290. }
  291. function get_image_path($thumbnail='') {
  292.     global $blog_id;
  293.     if (isset($blog_id) && $blog_id > 0) {
  294.         $imagePath = explode('/files/', $thumbnail);
  295.         if (isset($imagePath[1])) {
  296.             $thumbnail = '/blogs.dir/' . $blog_id . '/files/' . $imagePath[1];
  297.         }
  298.     }
  299.     return $thumbnail;
  300. }
  301.  
  302.  
  303. // Show Post Thumbnails
  304. function tj_show_thumb($width = 100, $height = 100) {
  305. ?>
  306. <a href="<?php the_permalink() ?>" rel="bookmark"><img class="thumb" src="<?php bloginfo('template_directory'); ?>/includes/timthumb.php?src=<?php tj_get_image(); ?>&amp;h=<?php echo get_theme_mod($height); ?>&amp;w=<?php echo get_theme_mod($width); ?>&amp;zc=1" alt="<?php the_title(); ?>" /></a>
  307. <?php
  308. }
  309. // Tabber: Get Most Popular Posts
  310. function tj_tabs_popular( $posts = 5, $size = 35 ) {
  311.     $popular = new WP_Query('orderby=comment_count&posts_per_page='.$posts);
  312.     while ($popular->have_posts()) : $popular->the_post();
  313. ?>
  314. <li>
  315.     <?php tj_show_thumb($size, $size); ?>
  316.     <div class="info">
  317.     <a title="<?php the_title(); ?>" href="<?php the_permalink() ?>"><?php the_title(); ?></a>
  318.     <span class="meta"><?php comments_popup_link('0 Comment', '1 Comment', '% Comments', 'comments-link', ''); ?></span>
  319.     </div> <!--end .info-->
  320.     <div class="clear"></div>
  321. </li>
  322. <?php endwhile;
  323. }
  324. function tj_tabs_latest( $posts = 5, $size = 35 ) {
  325.     $the_query = new WP_Query('showposts='. $posts .'&orderby=post_date&order=desc');  
  326.     while ($the_query->have_posts()) : $the_query->the_post();
  327. ?>
  328. <li>
  329.     <?php if ($size <> 0) ?>
  330.     <?php tj_show_thumb($size, $size);?>
  331.     <div class="info">
  332.     <a title="<?php the_title(); ?>" href="<?php the_permalink() ?>"><?php the_title(); ?></a>
  333.     <span class="meta"><?php the_time('F j, Y'); ?></span>
  334.     </div> <!--end .info-->
  335.     <div class="clear"></div>
  336. </li>
  337. <?php endwhile;
  338. }
  339.  
  340. // Tabber: Get Recent Comments
  341. function tj_tabs_comments( $posts = 5, $size = 35 ) {
  342.     global $wpdb;
  343.     $sql = "SELECT DISTINCT ID, post_title, post_password, comment_ID,
  344.     comment_post_ID, comment_author, comment_author_email, comment_date_gmt, comment_approved,
  345.     comment_type,comment_author_url,
  346.     SUBSTRING(comment_content,1,65) AS com_excerpt
  347.     FROM $wpdb->comments
  348.     LEFT OUTER JOIN $wpdb->posts ON ($wpdb->comments.comment_post_ID =
  349.     $wpdb->posts.ID)
  350.     WHERE comment_approved = '1' AND comment_type = '' AND
  351.     post_password = ''
  352.     ORDER BY comment_date_gmt DESC LIMIT ".$posts;
  353.     $comments = $wpdb->get_results($sql);
  354.     foreach ($comments as $comment) {
  355.     ?>
  356.     <li>
  357.         <?php echo get_avatar( $comment, $size ); ?>
  358.         <a href="<?php echo get_permalink($comment->ID); ?>#comment-<?php echo $comment->comment_ID; ?>" title="<?php _e('on ', 'Designrshub'); ?> <?php echo $comment->post_title; ?>">
  359.             <?php echo strip_tags($comment->comment_author); ?>: <?php echo strip_tags($comment->com_excerpt); ?>...
  360.         </a>
  361.         <div class="clear"></div>
  362.     </li>
  363.     <?php
  364.     }
  365. }
  366. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement