Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- Author: Eddie Machado
- URL: htp://themble.com/bones/
- This is where you can drop your custom functions or
- just edit things like thumbnail sizes, header images,
- sidebars, comments, ect.
- */
- /************* INCLUDE NEEDED FILES ***************/
- /*
- 1. library/bones.php
- - head cleanup (remove rsd, uri links, junk css, ect)
- - enqueueing scripts & styles
- - theme support functions
- - custom menu output & fallbacks
- - related post function
- - page-navi function
- - removing <p> from around images
- - customizing the post excerpt
- - custom google+ integration
- - adding custom fields to user profiles
- */
- require_once('library/bones.php'); // if you remove this, bones will break
- /*
- 2. library/custom-post-type.php
- - an example custom post type
- - example custom taxonomy (like categories)
- - example custom taxonomy (like tags)
- */
- require_once('library/metaboxes/category-metabox-functions.php');
- require_once('library/metaboxes/metabox-functions.php');
- /*
- 3. library/admin.php
- - removing some default WordPress dashboard widgets
- - an example custom dashboard widget
- - adding custom login css
- - changing text in footer of admin
- */
- require_once('library/admin.php'); // this comes turned off by default
- /*
- 4. library/translation/translation.php
- - adding support for other languages
- */
- // require_once('library/translation/translation.php'); // this comes turned off by default
- /************* THUMBNAIL SIZE OPTIONS *************/
- // Thumbnail sizes
- add_image_size( 'single-post-image', 270, 270, true );
- add_image_size( 'prod-cat-image', 980, 155, true );
- /*
- to add more sizes, simply copy a line from above
- and change the dimensions & name. As long as you
- upload a "featured image" as large as the biggest
- set width or height, all the other sizes will be
- auto-cropped.
- To call a different size, simply change the text
- inside the thumbnail function.
- For example, to call the 300 x 300 sized image,
- we would use the function:
- <?php the_post_thumbnail( 'bones-thumb-300' ); ?>
- for the 600 x 100 image:
- <?php the_post_thumbnail( 'bones-thumb-600' ); ?>
- You can change the names and dimensions to whatever
- you like. Enjoy!
- */
- /************* ACTIVE SIDEBARS ********************/
- // Sidebars & Widgetizes Areas
- function bones_register_sidebars() {
- register_sidebar(array(
- 'id' => 'sidebar1',
- 'name' => __('Sidebar 1', 'bonestheme'),
- 'description' => __('The homepage sidebar (below buy online dropdowns).', 'bonestheme'),
- 'before_widget' => '<div id="%1$s" class="widget %2$s"><div class="widget-top"> </div><div class="widget-body">',
- 'after_widget' => '</div><div class="widget-bottom"> </div></div>',
- 'before_title' => '<h4 class="widgettitle">',
- 'after_title' => '</h4>',
- ));
- register_sidebar(array(
- 'id' => 'sidebar2',
- 'name' => __('Sidebar 2', 'bonestheme'),
- 'description' => __('The general sidebar (appears top on all pages except homepage).', 'bonestheme'),
- 'before_widget' => '<div id="%1$s" class="widget %2$s"><div class="widget-top"> </div><div class="widget-body">',
- 'after_widget' => '</div><div class="widget-bottom"> </div></div>',
- 'before_title' => '<h4 class="widgettitle">',
- 'after_title' => '</h4>',
- ));
- register_sidebar(array(
- 'id' => 'sidebar3',
- 'name' => __('Sidebar 3', 'bonestheme'),
- 'description' => __('The sidebar that appears at the top on the homepage.', 'bonestheme'),
- 'before_widget' => '<div id="%1$s" class="widget %2$s"><div class="widget-top"> </div><div class="widget-body">',
- 'after_widget' => '</div><div class="widget-bottom"> </div></div>',
- 'before_title' => '<h4 class="widgettitle">',
- 'after_title' => '</h4>',
- ));
- register_sidebar(array(
- 'id' => 'sidebar4',
- 'name' => __('Sidebar 4', 'bonestheme'),
- 'description' => __('The sidebar that appears below other widgets on general pages.', 'bonestheme'),
- 'before_widget' => '<div id="%1$s" class="widget %2$s"><div class="widget-top"> </div><div class="widget-body">',
- 'after_widget' => '</div><div class="widget-bottom"> </div></div>',
- 'before_title' => '<h4 class="widgettitle">',
- 'after_title' => '</h4>',
- ));
- /*
- to add more sidebars or widgetized areas, just copy
- and edit the above sidebar code. In order to call
- your new sidebar just use the following code:
- Just change the name to whatever your new
- sidebar's id is, for example:
- register_sidebar(array(
- 'id' => 'sidebar2',
- 'name' => __('Sidebar 2', 'bonestheme'),
- 'description' => __('The second (secondary) sidebar.', 'bonestheme'),
- 'before_widget' => '<div id="%1$s" class="widget %2$s">',
- 'after_widget' => '</div>',
- 'before_title' => '<h4 class="widgettitle">',
- 'after_title' => '</h4>',
- ));
- To call the sidebar in your template, you can just copy
- the sidebar.php file and rename it to your sidebar's name.
- So using the above example, it would be:
- sidebar-sidebar2.php
- */
- } // don't remove this bracket!
- /************* COMMENT LAYOUT *********************/
- // Comment Layout
- function bones_comments($comment, $args, $depth) {
- $GLOBALS['comment'] = $comment; ?>
- <li <?php comment_class(); ?>>
- <article id="comment-<?php comment_ID(); ?>" class="clearfix">
- <header class="comment-author vcard">
- <?php
- /*
- this is the new responsive optimized comment image. It used the new HTML5 data-attribute to display comment gravatars on larger screens only. What this means is that on larger posts, mobile sites don't have a ton of requests for comment images. This makes load time incredibly fast! If you'd like to change it back, just replace it with the regular wordpress gravatar call:
- echo get_avatar($comment,$size='32',$default='<path_to_url>' );
- */
- ?>
- <!-- custom gravatar call -->
- <?php
- // create variable
- $bgauthemail = get_comment_author_email();
- ?>
- <img data-gravatar="http://www.gravatar.com/avatar/<?php echo md5($bgauthemail); ?>?s=32" class="load-gravatar avatar avatar-48 photo" height="32" width="32" src="<?php echo get_template_directory_uri(); ?>/library/images/nothing.gif" />
- <!-- end custom gravatar call -->
- <?php printf(__('<cite class="fn">%s</cite>', 'bonestheme'), get_comment_author_link()) ?>
- <time datetime="<?php echo comment_time('Y-m-j'); ?>"><a href="<?php echo htmlspecialchars( get_comment_link( $comment->comment_ID ) ) ?>"><?php comment_time(__('F jS, Y', 'bonestheme')); ?> </a></time>
- <?php edit_comment_link(__('(Edit)', 'bonestheme'),' ','') ?>
- </header>
- <?php if ($comment->comment_approved == '0') : ?>
- <div class="alert info">
- <p><?php _e('Your comment is awaiting moderation.', 'bonestheme') ?></p>
- </div>
- <?php endif; ?>
- <section class="comment_content clearfix">
- <?php comment_text() ?>
- </section>
- <?php comment_reply_link(array_merge( $args, array('depth' => $depth, 'max_depth' => $args['max_depth']))) ?>
- </article>
- <!-- </li> is added by WordPress automatically -->
- <?php
- } // don't remove this bracket!
- /************* SEARCH FORM LAYOUT *****************/
- // Search Form
- function bones_wpsearch($form) {
- $form = '<form role="search" method="get" id="searchform" action="' . home_url( '/' ) . '" >
- <label class="screen-reader-text" for="s">' . __('Search for:', 'bonestheme') . '</label>
- <input type="text" value="' . get_search_query() . '" name="s" id="s" placeholder="'.esc_attr__('Search the Site...','bonestheme').'" />
- <input type="submit" id="searchsubmit" value="'. esc_attr__('Search') .'" />
- </form>';
- return $form;
- } // don't remove this bracket!
- //Lists Children of $postp if there are any.
- function childposts($postp){
- $children = wp_list_pages("title_li=&child_of=".$postp."&echo=0");
- if ($children) { ?>
- <ul>
- <?php echo $children; ?>
- </ul>
- <?php }} ?>
- <?php
- function site_information_widget(){
- echo "<p>". bloginfo('description') ."</p><hr />";
- $num_page = wp_count_posts( 'page' );
- $pagenum = number_format_i18n( $num_page->publish );
- $num_posts = wp_count_posts( 'post' );
- $postnum = number_format_i18n( $num_posts->publish );
- echo "<p>This site has <a href='edit.php?post_type=page'>".$pagenum." Pages</a> and <a href='edit.php?post_type=post'>".$postnum." Posts</a>.</p>";
- $post_types = get_post_types( array( '_builtin' => false ), 'objects' );
- foreach ( $post_types as $post_type ) {
- if($post_type->name !== 'wp-types-group' && $post_type->name !== 'wpcf7_contact_form'){
- $num_posts = wp_count_posts( $post_type->name );
- $num = number_format_i18n( $num_posts->publish );
- $text = _n( $post_type->labels->singular_name, $post_type->labels->name, $num_posts->publish );
- if ( current_user_can( 'edit_posts' ) ) {
- $num = '<p>There are <a href="edit.php?post_type=' . $post_type->name . '">' . $num . '</a> ';
- $text = '<a href="edit.php?post_type=' . $post_type->name . '">' . $text . '</a> on the site';
- }
- echo '<td class="first b b-' . $post_type->name . 's">' . $num . '</td>';
- echo '<td class="t ' . $post_type->name . 's">' . $text . '</td>';
- echo '</tr>';
- if ( $num_posts->pending > 0 ) {
- $num = number_format_i18n( $num_posts->pending );
- $text = _n( $post_type->labels->singular_name . ' pending', $post_type->labels->name . ' pending', $num_posts->pending );
- if ( current_user_can( 'edit_posts' ) ) {
- $num = ', <a href="edit.php?post_status=pending&post_type=' . $post_type->name . '">' . $num . '</a> ';
- $text = '<a href="edit.php?post_status=pending&post_type=' . $post_type->name . '">' . $text . '</a> review.</p>';
- }
- echo '<td class="first b b-' . $post_type->name . 's">' . $num . '</td>';
- echo '<td class="t ' . $post_type->name . 's">' . $text . '</td>';
- echo '</tr>';
- } else { echo ".</p>"; }
- }}
- }
- //truncate title
- function customTitle($limit) {
- $title = get_the_title($post->ID);
- if(strlen($title) > $limit) {
- $title = substr($title, 0, $limit) . '...';
- }
- echo $title;
- }
- // Jigoshop
- function mytheme_open_jigoshop_content_wrappers()
- {
- echo '<div id="page-banner">
- <div id="page-banner-border" class="wrap clearfix">
- <div class="wrap clearfix">';
- include('library/banner.php');
- echo '</div>';
- echo '<div id="content">
- <div id="inner-content" class="wrap clearfix">
- <div id="main" class="ninecol first clearfix" role="main">';
- }
- function mytheme_close_jigoshop_content_wrappers()
- {
- echo '</div>';
- }
- function mytheme_prepare_jigoshop_wrappers()
- {
- remove_action( 'jigoshop_before_main_content', 'jigoshop_output_content_wrapper', 10 );
- remove_action( 'jigoshop_after_main_content', 'jigoshop_output_content_wrapper_end', 10);
- add_action( 'jigoshop_before_main_content', 'mytheme_open_jigoshop_content_wrappers', 10 );
- add_action( 'jigoshop_after_main_content', 'mytheme_close_jigoshop_content_wrappers', 10 );
- }
- add_action( 'wp_head', 'mytheme_prepare_jigoshop_wrappers' );
- function schoolwear_product_dropdown_categories( $show_counts = false, $hierarchal = false ) {
- global $wp_query;
- $r = array();
- $r['pad_counts'] = 1;
- $r['hierarchal'] = $hierarchal;
- $r['hide_empty'] = 1;
- $r['show_count'] = 0;
- $r['selected'] = isset( $wp_query->query['product_cat'] ) ? $wp_query->query['product_cat'] : '';
- $r['menu_order'] = false; // This is to enable the following order args
- $r['orderby'] = 'id';
- $r['order'] = 'ASC';
- $r['parent'] = 25;
- $terms = get_terms( 'product_cat', $r );
- if ( ! $terms ) return;
- $output = "<select name='product_cat' id='school_cat'>";
- $output .= '<option value="" ' . selected( isset( $_GET['product_cat'] ) ? esc_attr( $_GET['product_cat'] ) : '', '', false ) . '>'.__('Select...', 'jigoshop').'</option>';
- $output .= jigoshop_walk_category_dropdown_tree( $terms, 0, $r );
- $output .="</select>";
- echo $output;
- }
- function ranges_categories( $show_counts = false, $hierarchal = false ) {
- global $wp_query;
- $r = array();
- $r['pad_counts'] = 1;
- $r['hierarchal'] = $hierarchal;
- $r['hide_empty'] = 0;
- $r['show_count'] = 0;
- $r['selected'] = isset( $wp_query->query['product_cat'] ) ? $wp_query->query['product_cat'] : '';
- $r['menu_order'] = false; // This is to enable the following order args
- $r['orderby'] = 'id';
- $r['order'] = 'ASC';
- $r['parent'] = 0;
- $r['exclude'] = 25;
- $terms = get_terms( 'product_cat', $r );
- if ( ! $terms ) return;
- $output = "<select name='product_cat' id='ranges_cat'>";
- $output .= '<option value="" ' . selected( isset( $_GET['product_cat'] ) ? esc_attr( $_GET['product_cat'] ) : '', '', false ) . '>'.__('Choose a category', 'jigoshop').'</option>';
- $output .= jigoshop_walk_category_dropdown_tree( $terms, 0, $r );
- $output .="</select>";
- echo $output;
- }
- //options
- // KEYWORDS from content
- function get_keywords($text, $letterlimit, $wordlimit)
- {
- $string = '';
- $text=strip_tags($text); // not neccssary for none HTML
- //$text=strip_shortcodes($text); // uncomment only inside wordpress system
- $text = trim(preg_replace("/\s+/"," ",$text));
- $text=str_replace(",","",$text);
- $text=str_replace(".","",$text);
- $word_array = explode(" ", $text);
- $words =0;
- foreach ($word_array as $key=>$word)
- {
- if ($words < $wordlimit){
- if (strlen($word) > $letterlimit)
- {
- $string[$key] = $word ;
- ++$words;
- }
- }
- }
- if ($string != ""){
- $text = implode(", ", $string); }
- else {$text = implode(", ", $word_array);}
- return $text;
- }
- // Custom Description
- function custom_description($text = '') {
- $text = do_shortcode( $text );
- $text = apply_filters('the_content', $text);
- $text = str_replace(']]>', ']]>', $text);
- $excerpt_length = 42;
- $text = wp_trim_words( $text, $excerpt_length, $more = '...' );
- return $text;
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment