Przeglądaj źródła

cleaning up the functions file

removing alot of stuff to make it even easier and simpler to read.
adding the launch bones into functions to make it easier to use.
removing search function
adding a google font thing, just to make things pretty (easy to remove)
Eddie Machado 12 lat temu
rodzic
commit
ec4b010afb
2 zmienionych plików z 124 dodań i 109 usunięć
  1. 102 77
      functions.php
  2. 22 32
      taxonomy-custom_cat.php

+ 102 - 77
functions.php

@@ -8,42 +8,62 @@ just edit things like thumbnail sizes, header images,
 sidebars, comments, ect.
 sidebars, comments, ect.
 */
 */
 
 
-/************* INCLUDE NEEDED FILES ***************/
+// LOAD BONES CORE (if you remove this, the theme will break)
+require_once( 'library/bones.php' );
 
 
-/*
-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/custom-post-type.php' ); // you can disable this if you like
-/*
-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
+// USE THIS TEMPLATE TO CREATE CUSTOM POST TYPES EASILY
+require_once( 'library/custom-post-type.php' );
+
+// CUSTOMIZE THE WORDPRESS ADMIN (off by default)
+// require_once get_template_directory() . 'library/admin.php';
+
+/*********************
+LAUNCH BONES
+Let's get everything up and running.
+*********************/
+
+function bones_ahoy() {
+
+  // let's get language support going, if you need it
+  load_theme_textdomain( 'bonestheme', get_template_directory() . '/library/translation' );
+
+  // launching operation cleanup
+  add_action( 'init', 'bones_head_cleanup' );
+  // remove WP version from RSS
+  add_filter( 'the_generator', 'bones_rss_version' );
+  // remove pesky injected css for recent comments widget
+  add_filter( 'wp_head', 'bones_remove_wp_widget_recent_comments_style', 1 );
+  // clean up comment styles in the head
+  add_action( 'wp_head', 'bones_remove_recent_comments_style', 1 );
+  // clean up gallery output in wp
+  add_filter( 'gallery_style', 'bones_gallery_style' );
+
+  // enqueue base scripts and styles
+  add_action( 'wp_enqueue_scripts', 'bones_scripts_and_styles', 999 );
+  // ie conditional wrapper
+
+  // launching this stuff after theme setup
+  bones_theme_support();
+
+  // adding sidebars to Wordpress (these are created in functions.php)
+  add_action( 'widgets_init', 'bones_register_sidebars' );
+
+  // cleaning up random code around images
+  add_filter( 'the_content', 'bones_filter_ptags_on_images' );
+  // cleaning up excerpt
+  add_filter( 'excerpt_more', 'bones_excerpt_more' );
+
+} /* end bones ahoy */
+
+// let's get this party started
+add_action( 'after_setup_theme', 'bones_ahoy' );
+
+
+/************* OEMBED SIZE OPTIONS *************/
+
+if ( ! isset( $content_width ) ) {
+	$content_width = 640;
+}
 
 
 /************* THUMBNAIL SIZE OPTIONS *************/
 /************* THUMBNAIL SIZE OPTIONS *************/
 
 
@@ -110,56 +130,61 @@ function bones_register_sidebars() {
 	*/
 	*/
 } // don't remove this bracket!
 } // don't remove this bracket!
 
 
+
 /************* COMMENT LAYOUT *********************/
 /************* COMMENT LAYOUT *********************/
 
 
 // Comment Layout
 // Comment Layout
 function bones_comments( $comment, $args, $depth ) {
 function bones_comments( $comment, $args, $depth ) {
    $GLOBALS['comment'] = $comment; ?>
    $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 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 -->
+  <div id="comment-<?php comment_ID(); ?>" <?php comment_class('cf'); ?>>
+    <article  class="cf">
+      <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>' );
+        */
+        ?>
+        <?php // custom gravatar call ?>
+        <?php
+          // create variable
+          $bgauthemail = get_comment_author_email();
+        ?>
+        <img data-gravatar="http://www.gravatar.com/avatar/<?php echo md5( $bgauthemail ); ?>?s=40" class="load-gravatar avatar avatar-48 photo" height="40" width="40" src="<?php echo get_template_directory_uri(); ?>/library/images/nothing.gif" />
+        <?php // end custom gravatar call ?>
+        <?php printf(__( '<cite class="fn">%1$s</cite> %2$s', 'bonestheme' ), get_comment_author_link(), edit_comment_link(__( '(Edit)', 'bonestheme' ),'  ','') ) ?>
+        <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>
+
+      </header>
+      <?php if ($comment->comment_approved == '0') : ?>
+        <div class="alert alert-info">
+          <p><?php _e( 'Your comment is awaiting moderation.', 'bonestheme' ) ?></p>
+        </div>
+      <?php endif; ?>
+      <section class="comment_content cf">
+        <?php comment_text() ?>
+      </section>
+      <?php comment_reply_link(array_merge( $args, array('depth' => $depth, 'max_depth' => $args['max_depth']))) ?>
+    </article>
+  <?php // </li> is added by WordPress automatically ?>
 <?php
 <?php
 } // don't remove this bracket!
 } // 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!
+/*
+This is a modification of a function found in the
+twentythirteen theme where we can declare some
+external fonts. If you're using Google Fonts, you
+can replace these fonts, change it in your scss files
+and be up and running in seconds.
+*/
+function bones_fonts() {
+  wp_register_style('googleFonts', 'http://fonts.googleapis.com/css?family=Lato:400,700,400italic,700italic');
+  wp_enqueue_style( 'googleFonts');
+}
+
+add_action('wp_print_styles', 'bones_fonts');
+
 
 
 
 
-?>
+/* DON'T DELETE THIS CLOSING TAG */ ?>

+ 22 - 32
taxonomy-custom_cat.php

@@ -1,15 +1,14 @@
 <?php
 <?php
 /*
 /*
-This is the custom post type taxonomy template.
-If you edit the custom taxonomy name, you've got
-to change the name of this template to
-reflect that name change.
-
-i.e. if your custom taxonomy is called
-register_taxonomy( 'shoes',
-then your single template should be
-taxonomy-shoes.php
-
+ * CUSTOM POST TYPE TAXONOMY TEMPLATE
+ *
+ * This is the custom post type taxonomy template. If you edit the custom taxonomy name,
+ * you've got to change the name of this template to reflect that name change.
+ *
+ * For Example, if your custom taxonomy is called "register_taxonomy('shoes')",
+ * then your template name should be taxonomy-shoes.php
+ *
+ * For more info: http://codex.wordpress.org/Post_Type_Templates#Displaying_Custom_Taxonomies
 */
 */
 ?>
 ?>
 
 
@@ -17,52 +16,43 @@ taxonomy-shoes.php
 
 
 			<div id="content">
 			<div id="content">
 
 
-				<div id="inner-content" class="wrap clearfix">
+				<div id="inner-content" class="wrap cf">
 
 
-						<div id="main" class="eightcol first clearfix" role="main">
+						<div id="main" class="m-all t-2of3 d-5of7 cf" role="main">
 
 
 							<h1 class="archive-title h2"><span><?php _e( 'Posts Categorized:', 'bonestheme' ); ?></span> <?php single_cat_title(); ?></h1>
 							<h1 class="archive-title h2"><span><?php _e( 'Posts Categorized:', 'bonestheme' ); ?></span> <?php single_cat_title(); ?></h1>
 
 
 							<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
 							<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
 
 
-							<article id="post-<?php the_ID(); ?>" <?php post_class( 'clearfix' ); ?> role="article">
+							<article id="post-<?php the_ID(); ?>" <?php post_class( 'cf' ); ?> role="article">
 
 
 								<header class="article-header">
 								<header class="article-header">
 
 
 									<h3 class="h2"><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></h3>
 									<h3 class="h2"><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></h3>
 									<p class="byline vcard"><?php
 									<p class="byline vcard"><?php
-										printf( __( 'Posted <time class="updated" datetime="%1$s" pubdate>%2$s</time> by <span class="author">%3$s</span> <span class="amp">&</span> filed under %4$s.', 'bonestheme' ), get_the_time( 'Y-m-j' ), get_the_time( __( 'F jS, Y', 'bonestheme' )), bones_get_the_author_posts_link(), get_the_term_list( get_the_ID(), 'custom_cat', "" ) );
+										printf( __( 'Posted <time class="updated" datetime="%1$s" pubdate>%2$s</time> by <span class="author">%3$s</span> <span class="amp">&</span> filed under %4$s.', 'bonestheme' ), get_the_time( 'Y-m-j' ), get_the_time( __( 'F jS, Y', 'bonestheme' )), get_author_posts_url( get_the_author_meta( 'ID' ) ), get_the_term_list( get_the_ID(), 'custom_cat', "" ) );
 									?></p>
 									?></p>
 
 
-								</header> <!-- end article header -->
+								</header> <?php // end article header ?>
 
 
 								<section class="entry-content">
 								<section class="entry-content">
 									<?php the_excerpt( '<span class="read-more">' . __( 'Read More &raquo;', 'bonestheme' ) . '</span>' ); ?>
 									<?php the_excerpt( '<span class="read-more">' . __( 'Read More &raquo;', 'bonestheme' ) . '</span>' ); ?>
 
 
-								</section> <!-- end article section -->
+								</section> <?php // end article section ?>
 
 
 								<footer class="article-footer">
 								<footer class="article-footer">
 
 
-								</footer> <!-- end article footer -->
+								</footer> <?php // end article footer ?>
 
 
-							</article> <!-- end article -->
+							</article> <?php // end article ?>
 
 
 							<?php endwhile; ?>
 							<?php endwhile; ?>
 
 
-									<?php if ( function_exists( 'bones_page_navi' ) ) { ?>
-											<?php bones_page_navi(); ?>
-									<?php } else { ?>
-											<nav class="wp-prev-next">
-													<ul class="clearfix">
-														<li class="prev-link"><?php next_posts_link( __( '&laquo; Older Entries', 'bonestheme' )) ?></li>
-														<li class="next-link"><?php previous_posts_link( __( 'Newer Entries &raquo;', 'bonestheme' )) ?></li>
-													</ul>
-											</nav>
-									<?php } ?>
+									<?php bones_page_navi(); ?>
 
 
 							<?php else : ?>
 							<?php else : ?>
 
 
-									<article id="post-not-found" class="hentry clearfix">
+									<article id="post-not-found" class="hentry cf">
 										<header class="article-header">
 										<header class="article-header">
 											<h1><?php _e( 'Oops, Post Not Found!', 'bonestheme' ); ?></h1>
 											<h1><?php _e( 'Oops, Post Not Found!', 'bonestheme' ); ?></h1>
 										</header>
 										</header>
@@ -76,12 +66,12 @@ taxonomy-shoes.php
 
 
 							<?php endif; ?>
 							<?php endif; ?>
 
 
-						</div> <!-- end #main -->
+						</div> <?php // end #main ?>
 
 
 						<?php get_sidebar(); ?>
 						<?php get_sidebar(); ?>
 
 
-				</div> <!-- end #inner-content -->
+				</div> <?php // end #inner-content ?>
 
 
-			</div> <!-- end #content -->
+			</div> <?php // end #content ?>
 
 
 <?php get_footer(); ?>
 <?php get_footer(); ?>