'FFF', 'default-image' => get_template_directory_uri() . '/images/body-bg.jpg' )); // Register Menus register_nav_menus( array( 'main-menu' => __('Main Menu', 'corpo'), // Main Navigation 'footer-menu' => __('Footer Menu', 'corpo') // Footer Navigation )); // Enables post and comment RSS feed links to head add_theme_support('automatic-feed-links'); // Localisation Support load_theme_textdomain('corpo', get_template_directory() . '/languages'); $locale = get_locale(); $locale_file = get_template_directory() . "/languages/$locale.php"; if ( is_readable( $locale_file ) ) require_once( $locale_file ); } /*-----------------------------------------------------------------------------------*/ /* Functions /*-----------------------------------------------------------------------------------*/ // Load scripts function corpo_enqueue_scripts() { if (!is_admin()) { wp_enqueue_script('jquery'); wp_register_script('jquery_tools', get_template_directory_uri() . '/js/jquery.tools.min.js'); wp_enqueue_script('jquery_tools'); wp_register_script('modernizr', get_template_directory_uri() . '/js/modernizr.min.js', array(), '2.6.2'); wp_enqueue_script('modernizr'); wp_register_script('tinynav', get_template_directory_uri() . '/js/tinynav.min.js'); wp_enqueue_script('tinynav'); wp_register_script('custom-scripts', get_template_directory_uri() . '/js/scripts.js', array(), '1.0.0'); wp_enqueue_script('custom-scripts'); } } add_action('init', 'corpo_enqueue_scripts'); // Add Custom Scripts to wp_head // Load conditional scripts function corpo_conditional_scripts() { if ( is_front_page() || ( 'corpo_portfolio' == get_post_type() && is_singular() ) ) : wp_register_script('flexslider', get_template_directory_uri() . '/js/jquery.flexslider-min.js',array(),'',true); // Load in footer wp_enqueue_script('flexslider'); endif; } add_action('wp_print_scripts', 'corpo_conditional_scripts'); // Load CSS styles function corpo_enqueue_css() { $subsets = 'latin,latin-ext'; $protocol = is_ssl() ? 'https' : 'http'; $query_args = array( 'family' => 'Open+Sans:400italic,400,600,700', 'subset' => $subsets, ); $color_scheme = of_get_option('corpo_color_scheme','red'); wp_enqueue_style( 'corpo-fonts', add_query_arg( $query_args, "$protocol://fonts.googleapis.com/css" ), array(), null ); wp_register_style('font_awsome-css', get_template_directory_uri() . '/css/font-awesome.min.css', array(), null); wp_enqueue_style('font_awsome-css'); wp_register_style('corpo-css', get_template_directory_uri() . '/style.css'); wp_enqueue_style('corpo-css'); wp_register_style('color_scheme', get_template_directory_uri() . '/css/color_scheme/'.$color_scheme.'.css'); wp_enqueue_style('color_scheme'); } add_action('wp_enqueue_scripts', 'corpo_enqueue_css'); // Add Theme Stylesheet // Remove invalid rel attribute values in the categorylist function corpo_remove_category_rel_from_category_list($thelist) { return str_replace('rel="category tag"', 'rel="tag"', $thelist); } add_filter('the_category', 'corpo_remove_category_rel_from_category_list'); // Add page slug to body class, Credit: Starkers Wordpress Theme function corpo_add_slug_to_body_class($classes) { global $post; if (is_home()) { $key = array_search('blog', $classes); if ($key > -1) { unset($classes[$key]); } } elseif (is_page()) { $classes[] = sanitize_html_class($post->post_name); } elseif (is_singular()) { $classes[] = sanitize_html_class($post->post_name); } return $classes; } add_filter('body_class', 'corpo_add_slug_to_body_class'); // Add slug to body class (Starkers build) // Remove wp_head() injected Recent Comment styles function corpo_remove_recent_comments_style() { global $wp_widget_factory; remove_action('wp_head', array( $wp_widget_factory->widgets['WP_Widget_Recent_Comments'], 'recent_comments_style' )); } add_action('widgets_init', 'corpo_remove_recent_comments_style'); // Remove inline Recent Comment Styles from wp_head() /*-----------------------------------------------------------------------------------*/ /* Display tag /*-----------------------------------------------------------------------------------*/ // Filter function for wp_title function corpo_filter_wp_title( $old_title, $sep, $sep_location ){ // add padding to the sep $ssep = ' ' . $sep . ' '; // find the type of index page this is if( is_category() ) $insert = $ssep . __('Category','corpo'); elseif( is_tag() ) $insert = $ssep . __('Tag','corpo'); elseif( is_author() ) $insert = $ssep . __('Author','corpo'); elseif( is_year() || is_month() || is_day() ) $insert = $ssep . __('Archives','corpo'); elseif( is_home() ) $insert = $ssep . get_bloginfo('description'); else $insert = NULL; // get the page number we're on (index) if( get_query_var( 'paged' ) ) $num = $ssep . __('Page ','corpo') . get_query_var( 'paged' ); // get the page number we're on (multipage post) elseif( get_query_var( 'page' ) ) $num = $ssep . __('Page ','corpo') . get_query_var( 'page' ); // else else $num = NULL; // concoct and return new title return get_bloginfo( 'name' ) . $insert . $old_title . $num; } add_filter( 'wp_title', 'corpo_filter_wp_title', 10, 3 ); function corpo_rss_title($title) { /* need to fix our add a | blog name to wp_title */ $ft = str_replace(' | ','',$title); return str_replace(get_bloginfo('name'),'',$ft); } add_filter('get_wp_title_rss', 'corpo_rss_title',10,1); /*-----------------------------------------------------------------------------------*/ /* Sidebar & Widgets /*-----------------------------------------------------------------------------------*/ if (function_exists('register_sidebar')) { // Define Home Page Widget Area register_sidebar(array( 'name' => __('Home Page Services', 'corpo'), 'description' => __('This widget area is designed to display up to 4 services widgets.', 'corpo'), 'id' => 'homepage-sidebar', 'before_widget' => '<div id="%1$s" class=" widget %2$s">', 'after_widget' => '</div>', 'before_title' => '<h3>', 'after_title' => '</h3>' )); // Define Sidebar Widget Area register_sidebar(array( 'name' => __('Main Sidebar', 'corpo'), 'description' => __('Main widget area displayed on blog posts & archives', 'corpo'), 'id' => 'main-sidebar', 'before_widget' => '<div id="%1$s" class="widget %2$s">', 'after_widget' => '</div>', 'before_title' => '<h4>', 'after_title' => '</h4>' )); // Define Prefooter Widget Area register_sidebar(array( 'name' => __('Prefooter', 'corpo'), 'description' => __('Prefooter widget area displayed above the footer (max 4 widgets)', 'corpo'), 'id' => 'prefooter-sidebar', 'before_widget' => '<div id="%1$s" class=" widget %2$s">', 'after_widget' => '</div>', 'before_title' => '<h4 class="widget-title">', 'after_title' => '</h4>' )); } include(get_template_directory() . "/functions/widgets/recent-posts-widget.php"); include(get_template_directory() . "/functions/widgets/popular-posts-widget.php"); include(get_template_directory() . "/functions/widgets/twitter-widget.php"); include(get_template_directory() . "/functions/widgets/contact-widget.php"); include(get_template_directory() . "/functions/widgets/services-widget.php"); function corpo_bottom_sidebar_params($params) { global $my_widget_num; // Global a counter array $sidebar_id = $params[0]['id']; $width = array ( '1' => '', '2' => 'half', '3' => 'third', '4' => 'fourth' ); if ( $sidebar_id == 'homepage-sidebar' || $sidebar_id == 'prefooter-sidebar' ) { $registered_widgets = wp_get_sidebars_widgets(); if(!isset($registered_widgets[$sidebar_id]) || !is_array($registered_widgets[$sidebar_id])) { // Check if the current sidebar has no widgets return $params; // No widgets in this sidebar... bail early. } $number_of_widgets = count($registered_widgets[$sidebar_id]); if(!$my_widget_num) {// If the counter array doesn't exist, create it $my_widget_num = array(); } if(isset($my_widget_num[$sidebar_id])) { // See if the counter array has an entry for this sidebar $my_widget_num[$sidebar_id] ++; } else { // If not, create it starting with 1 $my_widget_num[$sidebar_id] = 1; } $classes = 'one-' . $width[$number_of_widgets]; if($my_widget_num[$sidebar_id] == 1) { // If this is the first widget $classes .= ' first '; } elseif($my_widget_num[$sidebar_id] == count($registered_widgets[$sidebar_id])) { // If this is the last widget $classes .= ' last '; } $params[0]['before_widget'] = preg_replace('/class=\"/', 'class="' . $classes . ' ', $params[0]['before_widget'], 1); } return $params; } add_filter('dynamic_sidebar_params','corpo_bottom_sidebar_params'); // Get Post Views - for Popular Posts widget function corpo_getPostViews($postID){ $count_key = 'post_views_count'; $count = get_post_meta($postID, $count_key, true); if($count==''){ delete_post_meta($postID, $count_key); add_post_meta($postID, $count_key, '0'); return "0 View"; } return $count.' Views'; } function corpo_setPostViews($postID) { $count_key = 'post_views_count'; $count = get_post_meta($postID, $count_key, true); if($count==''){ $count = 0; delete_post_meta($postID, $count_key); add_post_meta($postID, $count_key, '0'); }else{ $count++; update_post_meta($postID, $count_key, $count); } } if(!function_exists('corpo_portfolio_loop')) : function corpo_portfolio_loop ( $title, $query ){ $query = new WP_Query($query); $GLOBALS['corpo_loop'] = compact('title', 'query'); get_template_part('projects', 'loop'); } endif; /*-----------------------------------------------------------------------------------*/ /* Excerpt config /*-----------------------------------------------------------------------------------*/ function corpo_excerptlength_teaser($length) { return 20; } // Custom 'Read more' link to Post function corpo_excerpt_more($more) { global $post; return '... <a class="more" href="' . get_permalink($post->ID) . '">' . __('Continue reading →', 'corpo') . '</a>'; } add_filter('excerpt_more', 'corpo_excerpt_more'); // Create the Custom Excerpts callback function corpo_excerpt($length_callback = '', $more_callback = '') { global $post; if(function_exists($length_callback)){ add_filter('excerpt_length', $length_callback); } if(function_exists($more_callback)){ add_filter('excerpt_more', $more_callback); } $output = get_the_excerpt(); $output = apply_filters('wptexturize', $output); $output = apply_filters('convert_chars', $output); $output = '<p>'.$output.'</p>'; echo $output; } /*-----------------------------------------------------------------------------------*/ /* Append post meta & pagination after post content /*-----------------------------------------------------------------------------------*/ function corpo_post_meta($content) { if ( is_single() ) { $categories = get_the_category_list(__( ', ', 'corpo' )); $tags = get_the_category_list(__( ', ', 'corpo' )); $content .= corpo_custom_wp_link_pages(); //Pagination $content .= '<div class="post-meta">'; if( !empty( $categories ) ) : $content .= '<i>'. __( 'Posted in ', 'corpo' ) . $categories .'</i>'; endif; if( !empty( $tags ) ) : $content .= '<i> | '. __( 'Tagged ', 'corpo' ) . $tags .'</i>'; endif; $content .= '</div>'; } return $content; } add_filter('the_content','corpo_post_meta', 10); /*-----------------------------------------------------------------------------------*/ /* Comments /*-----------------------------------------------------------------------------------*/ function corpo_threaded_comments() { if (!is_admin()) { if (is_singular() AND comments_open() AND (get_option('thread_comments') == 1)) { wp_enqueue_script('comment-reply'); } } } add_action('get_header', 'corpo_threaded_comments'); // Custom Comments Callback function corpo_comments($comment, $args, $depth) { $GLOBALS['comment'] = $comment; ?> <li <?php comment_class(); ?> id="li-comment-<?php comment_ID(); ?>"> <article id="comment-<?php comment_ID(); ?>" class="the-comment"> <?php echo get_avatar( $comment, 60 ); ?> <?php if ( $comment->comment_approved == '0' ) : ?> <em><?php _e( 'Your comment is awaiting moderation.', 'corpo' ); ?></em> <br /> <?php endif; ?> <div class="comment-box"> <?php echo get_comment_author_link() ?> <span class="comment-meta"> <small> <?php comment_time( 'F j, Y g:i a' ); ?></small> <small> <?php comment_reply_link( array_merge( $args, array( 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?> </small> </span> <div class="comment-text"><p><?php comment_text(); ?></p></div> </div> </article> <?php } /*-----------------------------------------------------------------------------------*/ /* Actions & Filters /*-----------------------------------------------------------------------------------*/ // Clean up the <head> remove_action('wp_head', 'feed_links_extra', 3); // Display the links to the extra feeds such as category feeds remove_action('wp_head', 'feed_links', 2); // Display the links to the general feeds: Post and Comment Feed remove_action('wp_head', 'rsd_link'); // Display the link to the Really Simple Discovery service endpoint, EditURI link remove_action('wp_head', 'wlwmanifest_link'); // Display the link to the Windows Live Writer manifest file. remove_action('wp_head', 'index_rel_link'); // Index link remove_action('wp_head', 'parent_post_rel_link', 10, 0); // Prev link remove_action('wp_head', 'start_post_rel_link', 10, 0); // Start link remove_action('wp_head', 'adjacent_posts_rel_link', 10, 0); // Display relational links for the posts adjacent to the current post. remove_action('wp_head', 'wp_generator'); // Display the XHTML generator that is generated on the wp_head hook, WP version remove_action('wp_head', 'start_post_rel_link', 10, 0); remove_action('wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0); remove_action('wp_head', 'rel_canonical'); remove_action('wp_head', 'wp_shortlink_wp_head', 10, 0); // Add Filters add_filter('widget_text', 'do_shortcode'); // Allow shortcodes in Dynamic Sidebar add_filter('widget_text', 'shortcode_unautop'); // Remove <p> tags in Dynamic Sidebars (better!) add_filter('the_excerpt', 'shortcode_unautop'); // Remove auto <p> tags in Excerpt (Manual Excerpts only) add_filter('the_excerpt', 'do_shortcode'); // Allows Shortcodes to be executed in Excerpt (Manual Excerpts only) add_filter('use_default_gallery_style', '__return_false' ); // Remove inline style of WordPress Gallery Shortcode // Remove Filters remove_filter('the_excerpt', 'wpautop'); // Remove <p> tags from Excerpt altogether /*-----------------------------------------------------------------------------------*/ /* Custom Post Types /*-----------------------------------------------------------------------------------*/ include get_template_directory() . '/functions/custom_post_types.php'; include get_template_directory() . '/functions/custom_functions.php'; /*-----------------------------------------------------------------------------------*/ /* Shortcodes /*-----------------------------------------------------------------------------------*/ // Button add_shortcode('button', 'corpo_shortcode_button'); function corpo_shortcode_button($atts, $content = null) { $atts = shortcode_atts( array( 'color' => 'red', 'url' => '#', 'size' => '', ), $atts); if($atts['size'] == 'medium'){ $atts['size'] = ''; } return '<a class="button ' . $atts['color'] .' '. $atts['size'] .'" href="' . $atts['url'] . '" >' .do_shortcode($content). '</a>'; } /*-----------------------------------------------------------------------------------*/ /* Meta-boxes setup /*-----------------------------------------------------------------------------------*/ // Re-define meta box path and URL define( 'RWMB_DIR', trailingslashit( get_template_directory() . '/functions/meta-box' ) ); define( 'RWMB_URL', trailingslashit( get_template_directory_uri() . '/functions/meta-box' ) ); // Include the meta box script require_once RWMB_DIR . 'meta-box.php'; // Include the meta box definition (the file where you define meta boxes, see `demo/demo.php`) include 'functions/meta-box/metabox-def.php'; /*-----------------------------------------------------------------------------------*/ /* Options framework /*-----------------------------------------------------------------------------------*/ if ( !function_exists( 'optionsframework_init' ) ) { define( 'OPTIONS_FRAMEWORK_DIRECTORY', get_template_directory_uri() . '/functions/admin/options-framework/' ); require_once dirname( __FILE__ ) . '/functions/admin/options-framework/options-framework.php'; } add_action('optionsframework_custom_scripts', 'optionsframework_custom_scripts'); function optionsframework_custom_scripts() { ?> <script type="text/javascript"> jQuery(document).ready(function() { jQuery('#example_showhidden').click(function() { jQuery('#section-example_text_hidden').fadeToggle(400); }); if (jQuery('#example_showhidden:checked').val() !== undefined) { jQuery('#section-example_text_hidden').show(); } }); </script> <?php } // Theme Options sidebar add_action( 'optionsframework_after','corpo_options_display_sidebar' ); function corpo_options_display_sidebar() { ?> <div id="optionsframework-sidebar"> <div class="metabox-holder"> <div class="postbox"> <h3><?php _e('Support','corpo') ?></h3> <div class="inside"> <p><b><a href="http://webtuts.pl/documentation/corpo"><?php _e('Corpo Documentation','corpo'); ?></a></b></p> <p><?php _e('The best way to contact me with <b>support questions</b> and <b>bug reports</b> is via the','corpo') ?> <a href="http://wordpress.org/support/"><?php _e('WordPress support forums','corpo') ?></a>.</p> <p><?php _e('If you like this theme, I\'d appreciate any of the following:','corpo') ?></p> <ul> <li><a href="http://wordpress.org/extend/themes/corpo"><?php _e('Rate Corpo at WordPress.org','corpo') ?></a></li> <li><a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=8LRJAUNAPKJ9S"><?php _e('Donate a token of your appreciation','corpo') ?></a></li> </ul> </div> </div> </div> </div> <?php }