Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include("includes/theme-options.php");
- // Uncomment this to test your localization, make sure to enter the right language code.
- // function test_localization( $locale ) {
- // return "nl_NL";
- // }
- // add_filter('locale','test_localization');
- load_theme_textdomain('Designrshub', TEMPLATEPATH.'/languages/');
- if (function_exists('create_initial_post_types')) create_initial_post_types(); //fix for wp 3.0
- if (function_exists('add_custom_background')) add_custom_background();
- if (function_exists('add_post_type_support')) add_post_type_support( 'page', 'excerpt' );
- require_once(TEMPLATEPATH . '/includes/theme-widgets.php');
- require_once(TEMPLATEPATH . '/includes/column-shortcodes.php');
- /* MENUS */
- add_action( 'init', 'tj_register_my_menu' );
- function tj_register_my_menu() {
- register_nav_menus(
- array(
- 'header-cats' => __( 'Header Categories', 'Designrshub' )
- )
- );
- }
- /*
- * ------------------------------------------------- *
- * Lines
- * ------------------------------------------------- *
- */
- function rt_shortcode_lines( $atts, $content = null ) {
- //[line toplink="top"]
- if (isset($atts["toplink"]) && trim($atts["toplink"])){
- $line='<div class="line margin"><a href="#" class="top">['.$atts["toplink"].']</a></div>';
- }else{
- $line = '<div class="line margin"></div>';
- }
- return $line;
- }
- add_shortcode('line', 'rt_shortcode_lines');
- /*
- * ------------------------------------------------- *
- * show shortcode :)
- * ------------------------------------------------- *
- */
- function rt_shortcode_show_shortcode( $atts, $content = null ) {
- return '<code>' . htmlspecialchars($content) . '</code>';
- }
- add_shortcode('show_shortcode', 'rt_shortcode_show_shortcode');
- /* MENUS END */
- // General Widgets
- if (function_exists('register_sidebar'))
- {
- register_sidebar(array(
- 'name' => 'Sidebar',
- 'before_widget' => '',
- 'after_widget' => '<div class="clear"></div></div></div>',
- 'before_title' => '<div class="widget"><h3>',
- 'after_title' => '</h3><div class="widgetbox">',
- ));
- register_sidebar(array(
- 'name' => 'Footer Widget #1',
- 'before_widget' => '',
- 'after_widget' => '<div class="clear"></div></div></div>',
- 'before_title' => '<div class="footerwidget"><h3>',
- 'after_title' => '</h3><div class="widgetbox">',
- ));
- register_sidebar(array(
- 'name' => 'Footer Widget #2',
- 'before_widget' => '',
- 'after_widget' => '<div class="clear"></div></div></div>',
- 'before_title' => '<div class="footerwidget"><h3>',
- 'after_title' => '</h3><div class="widgetbox">',
- ));
- register_sidebar(array(
- 'name' => 'Footer Widget #3',
- 'before_widget' => '',
- 'after_widget' => '<div class="clear"></div></div></div>',
- 'before_title' => '<div class="footerwidget"><h3>',
- 'after_title' => '</h3><div class="widgetbox">',
- ));
- register_sidebar(array(
- 'name' => 'Footer Widget #4',
- 'before_widget' => '',
- 'after_widget' => '<div class="clear"></div></div></div>',
- 'before_title' => '<div class="footerwidget"><h3>',
- 'after_title' => '</h3><div class="widgetbox">',
- ));
- }
- # Content Excerpts
- function tj_content_limit($max_char, $more_link_text = '', $stripteaser = 0, $more_file = '') {
- $content = get_the_content($more_link_text, $stripteaser, $more_file);
- $content = apply_filters('the_content', $content);
- $content = str_replace(']]>', ']]>', $content);
- $content = strip_tags($content);
- if (strlen($_GET['p']) > 0) {
- echo "";
- echo $content;
- echo "...";
- }
- else if ((strlen($content)>$max_char) && ($espacio = strpos($content, " ", $max_char ))) {
- $content = substr($content, 0, $espacio);
- $content = $content;
- echo "";
- echo $content;
- echo "...";
- }
- else {
- echo "";
- echo $content;
- }
- }
- // Turn a category ID to a Name
- function cat_id_to_name($id) {
- foreach((array)(get_categories()) as $category) {
- if ($id == $category->cat_ID) { return $category->cat_name; break; }
- }
- }
- // CALL TO ACTION BUTTONS - Download //
- function action_button_shortcode( $atts ) {
- extract( shortcode_atts(
- array(
- 'title' => 'Title',
- 'url' => ''
- ),
- $atts
- ));
- return '<div style="text-align: center;"><span class="action-button blue-button"><a target="_blank" rel="nofollow" href="' . $url . '">' . $title . '</a></span></div>';
- }
- add_shortcode( 'action-button', 'action_button_shortcode' );
- // CALL TO ACTION BUTTONS - Feature //
- function action_feature_shortcode( $atts ) {
- extract( shortcode_atts(
- array(
- 'title' => 'Title',
- 'url' => ''
- ),
- $atts
- ));
- 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>';
- }
- add_shortcode( 'action-feature', 'action_feature_shortcode' );
- // DEALS //
- function action_deals_shortcode( $atts ) {
- extract( shortcode_atts(
- array(
- 'title' => 'Title',
- 'content' => '',
- 'coupon' => 'ClickHere',
- 'image' => '',
- 'url' => ''
- ),
- $atts
- ));
- 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>';
- }
- add_shortcode( 'action-deals', 'action_deals_shortcode' );
- // Default Content
- add_filter( 'default_content', 'my_editor_content' );
- function my_editor_content( $content ) {
- $content = "[action-button title=View Source url=URLHERE]";
- return $content;
- }
- // Related Posts with Thumbnail
- add_theme_support( 'post-thumbnails' );
- set_post_thumbnail_size( 100, 100, true );
- //Delete Title Links
- add_filter('wp_list_categories', 'remove_category_link_prefix');
- function remove_category_link_prefix($output) {
- return str_replace('View all posts filed under ', '', $output);
- }
- // Contributors
- function contributors() {
- global $wpdb;
- $authors = $wpdb->get_results("SELECT ID, user_nicename from $wpdb->users ORDER BY display_name");
- foreach($authors as $author) {
- echo "<li>";
- echo "<a href=\"".get_bloginfo('url')."/?author=";
- echo $author->ID;
- echo "\">";
- echo get_avatar($author->ID);
- echo "</a>";
- echo "<div>";
- echo "<span>";
- the_author_meta('description', $author->ID);
- echo "</span>";
- echo "</div>";
- echo "</li>";
- }
- }
- // Related Posts
- function related_posts_shortcode( $atts ) {
- extract(shortcode_atts(array(
- 'limit' => '5',
- ), $atts));
- global $wpdb, $post, $table_prefix;
- if ($post->ID) {
- $retval = '
- <ul>';
- // Get tags
- $tags = wp_get_post_tags($post->ID);
- $tagsarray = array();
- foreach ($tags as $tag) {
- $tagsarray[] = $tag->term_id;
- }
- $tagslist = implode(',', $tagsarray);
- // Do the query
- $q = "
- SELECT p.*, count(tr.object_id) as count
- FROM $wpdb->term_taxonomy AS tt, $wpdb->term_relationships AS tr, $wpdb->posts AS p
- WHERE tt.taxonomy ='post_tag'
- AND tt.term_taxonomy_id = tr.term_taxonomy_id
- AND tr.object_id = p.ID
- AND tt.term_id IN ($tagslist)
- AND p.ID != $post->ID
- AND p.post_status = 'publish'
- AND p.post_date_gmt < NOW()
- GROUP BY tr.object_id
- ORDER BY count DESC, p.post_date_gmt DESC
- LIMIT $limit;";
- $related = $wpdb->get_results($q);
- if ( $related ) {
- foreach($related as $r) {
- $retval .= '
- <li><a target="_blank" href="'.get_permalink($r->ID).'">'.wptexturize($r->post_title).'</a></li>
- ';
- }
- } else {
- $retval .= '';
- }
- $retval .= '</ul>';
- 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&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>';
- }
- return;
- }
- add_shortcode('related_posts', 'related_posts_shortcode');
- function the_slug() {
- $post_data = get_post($post->ID, ARRAY_A);
- $slug = $post_data['post_name'];
- return $slug;
- }
- // Get Image Attachments
- function tj_get_image($postid=0, $size='full') {
- if ($postid<1)
- $postid = get_the_ID();
- $thumb = get_post_meta($postid, "thumb", TRUE); // Declare the custom field for the image
- if ($thumb != null or $thumb != '') {
- echo get_image_path($thumb);
- }
- elseif ($images = get_children(array(
- 'post_parent' => $postid,
- 'post_type' => 'attachment',
- 'numberposts' => '1',
- 'post_mime_type' => 'image', )))
- foreach($images as $image) {
- $thumbnail=wp_get_attachment_image_src($image->ID, $size);
- ?>
- <?php echo get_image_path($thumbnail[0]); ?>
- <?php }
- else {
- $theme_name = strtolower(get_current_theme());
- echo get_image_path('wp-content/themes/'.$theme_name.'/images/image-pending.gif');
- }
- }
- function get_image_path($thumbnail='') {
- global $blog_id;
- if (isset($blog_id) && $blog_id > 0) {
- $imagePath = explode('/files/', $thumbnail);
- if (isset($imagePath[1])) {
- $thumbnail = '/blogs.dir/' . $blog_id . '/files/' . $imagePath[1];
- }
- }
- return $thumbnail;
- }
- // Show Post Thumbnails
- function tj_show_thumb($width = 100, $height = 100) {
- ?>
- <a href="<?php the_permalink() ?>" rel="bookmark"><img class="thumb" src="<?php bloginfo('template_directory'); ?>/includes/timthumb.php?src=<?php tj_get_image(); ?>&h=<?php echo get_theme_mod($height); ?>&w=<?php echo get_theme_mod($width); ?>&zc=1" alt="<?php the_title(); ?>" /></a>
- <?php
- }
- // Tabber: Get Most Popular Posts
- function tj_tabs_popular( $posts = 5, $size = 35 ) {
- $popular = new WP_Query('orderby=comment_count&posts_per_page='.$posts);
- while ($popular->have_posts()) : $popular->the_post();
- ?>
- <li>
- <?php tj_show_thumb($size, $size); ?>
- <div class="info">
- <a title="<?php the_title(); ?>" href="<?php the_permalink() ?>"><?php the_title(); ?></a>
- <span class="meta"><?php comments_popup_link('0 Comment', '1 Comment', '% Comments', 'comments-link', ''); ?></span>
- </div> <!--end .info-->
- <div class="clear"></div>
- </li>
- <?php endwhile;
- }
- function tj_tabs_latest( $posts = 5, $size = 35 ) {
- $the_query = new WP_Query('showposts='. $posts .'&orderby=post_date&order=desc');
- while ($the_query->have_posts()) : $the_query->the_post();
- ?>
- <li>
- <?php if ($size <> 0) ?>
- <?php tj_show_thumb($size, $size);?>
- <div class="info">
- <a title="<?php the_title(); ?>" href="<?php the_permalink() ?>"><?php the_title(); ?></a>
- <span class="meta"><?php the_time('F j, Y'); ?></span>
- </div> <!--end .info-->
- <div class="clear"></div>
- </li>
- <?php endwhile;
- }
- // Tabber: Get Recent Comments
- function tj_tabs_comments( $posts = 5, $size = 35 ) {
- global $wpdb;
- $sql = "SELECT DISTINCT ID, post_title, post_password, comment_ID,
- comment_post_ID, comment_author, comment_author_email, comment_date_gmt, comment_approved,
- comment_type,comment_author_url,
- SUBSTRING(comment_content,1,65) AS com_excerpt
- FROM $wpdb->comments
- LEFT OUTER JOIN $wpdb->posts ON ($wpdb->comments.comment_post_ID =
- $wpdb->posts.ID)
- WHERE comment_approved = '1' AND comment_type = '' AND
- post_password = ''
- ORDER BY comment_date_gmt DESC LIMIT ".$posts;
- $comments = $wpdb->get_results($sql);
- foreach ($comments as $comment) {
- ?>
- <li>
- <?php echo get_avatar( $comment, $size ); ?>
- <a href="<?php echo get_permalink($comment->ID); ?>#comment-<?php echo $comment->comment_ID; ?>" title="<?php _e('on ', 'Designrshub'); ?> <?php echo $comment->post_title; ?>">
- <?php echo strip_tags($comment->comment_author); ?>: <?php echo strip_tags($comment->com_excerpt); ?>...
- </a>
- <div class="clear"></div>
- </li>
- <?php
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement