We have been working hard on getting things ready for version 1.0.4 and it is finally almost here. This version is our first release candidate and we wanted to share it with the community to get some feedback. Now things have changed quite a bit underneath the hood so we don’t suggest testing this out on a live site since most likely your child themes will need a little adjusting.
A New Loop
The major changes in 1.0.4 are with the post loop in the actions.php file. The old loop was hard to customize so we decided to rewrite it from the ground up and separate it into some sections. First comes the header:
[porto_content_box border_top_color=”transparent” align=”left”]/* * Post header */ function pw_post_header() { echo pw_function_handle(__FUNCTION__); ?> <header> <hgroup> <h1 class="posttitle"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', "presswork" ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h1> <?php if(!is_page()) { ?> <h2 class="meta"> <?php _e("by", "presswork"); echo " "; the_author_posts_link(); echo ' • '; the_time(get_option('date_format')); if(!is_home()) { echo ' • '; the_category(', '); } if(comments_open()) { echo ' • '; comments_popup_link(__('0 Comments', "presswork"),__('1 Comment', "presswork"),__('% Comments', "presswork")); } ?> </h2> <?php } ?> </hgroup> </header> <?php } add_action('pw_archive_post_middle', 'pw_post_header', 10); add_action('pw_author_post_middle', 'pw_post_header', 10); add_action('pw_category_post_middle', 'pw_post_header', 10); add_action('pw_search_post_middle', 'pw_post_header', 10); add_action('pw_index_post_middle', 'pw_post_header', 10); add_action('pw_single_post_middle', 'pw_post_header', 10); add_action('pw_page_post_middle', 'pw_post_header', 10);[/porto_content_box]
Next comes the actual post content function:
[porto_content_box border_top_color=”transparent” border_top_width=”1px” align=”left”]/* * Post content */ function pw_post_content($ignore_image = false, $excerpt_length = 55, $hide_readmore = false, $display_excerpt = false) { echo pw_function_handle(__FUNCTION__); ?> <div class="storycontent"> <?php if(function_exists('has_post_format') && !is_singular()) { $format = get_post_format(); if(empty($format) || has_post_format('image')) { if(has_post_format('image')) $size = 'full'; elseif(empty($ignore_image)) $size = 'small'; else $size = 'thumbnail'; if(function_exists('has_post_thumbnail') && has_post_thumbnail()) { if(empty($ignore_image)) { echo '<a href="'.get_permalink().'" class="image-anchor">'; the_post_thumbnail($size, array( 'class' => 'alignleft' )); echo '</a>'; } } else { if(has_post_format('image')) the_content(); } if(empty($format)) { pw_excerpt($excerpt_length); if(empty($hide_readmore)) echo '<a href="'.get_permalink().'" class="more-link">'.__('Read more →', "presswork").'</a>'; } } elseif(has_post_format('gallery')) { // new gallery post format global $post; $images = get_children( array( 'post_parent' => $post->ID, 'post_type' => 'attachment', 'post_mime_type' => 'image', 'orderby' => 'menu_order', 'order' => 'ASC', 'numberposts' => 999 ) ); if ( $images ) : $total_images = count( $images ); $image = array_shift( $images ); $image_img_tag = wp_get_attachment_image( $image->ID, 'full' ); ?> <a class="gallery-thumb img-shadow alignnone" href="<?php the_permalink(); ?>"><?php echo $image_img_tag; ?></a> <p class="gallery-text clearfix fl"><em><?php printf( _n( 'This gallery contains <a %1$s>%2$s photo →</a>', 'This gallery contains <a %1$s>%2$s photos →</a>', $total_images, "presswork" ), 'href="' . get_permalink() . '" title="' . sprintf( esc_attr__( 'Permalink to %s', "presswork" ), the_title_attribute( 'echo=0' ) ) . '" rel="bookmark"', number_format_i18n( $total_images ) ); ?></em> </p> <?php endif; ?> <?php } else { // new aside || link || audio || video || image post format echo '<div class="pformat clearfix">'; the_content(''); echo '</div>'; } } else { if(!empty($display_excerpt)) pw_excerpt($excerpt_length); else the_content( __( 'Read more →', "presswork" ) ); } ?> </div> <?php } add_action('pw_archive_post_middle', 'pw_post_content', 11); add_action('pw_author_post_middle', 'pw_post_content', 11); add_action('pw_category_post_middle', 'pw_post_content', 11); add_action('pw_search_post_middle', 'pw_post_content', 11); add_action('pw_index_post_middle', 'pw_post_content', 11); add_action('pw_single_post_middle', 'pw_post_content', 11); add_action('pw_page_post_middle', 'pw_post_content', 11);[/porto_content_box]
And finally the footer:
[porto_content_box border_top_color=”transparent” border_top_width=”1px” align=”left”]/* * Post footer */ function pw_post_footer() { ?> <footer class="clearfix fl"> <?php the_tags('<p class="tags"><small>'.__('Tags', "presswork").': ', ', ', '</small></p>'); wp_link_pages(array('before' => '<p><strong>'.__('Pages', "presswork").':</strong> ', 'after' => '</p>', 'next_or_number' => 'number')); edit_post_link(__('(edit)', "presswork"), '<p class="clearfix">', '</p>'); ?> </footer> <?php } add_action('pw_single_post_middle', 'pw_post_footer', 12); add_action('pw_page_post_middle', 'pw_post_footer', 12);[/porto_content_box]
With this type of structure, you can easily customize elements without having to rewrite the entire function.
Font Preview
You will notice a new font preview in the PressWork Toolbox that makes it easier to see what fonts are available and how your site will look using each one. Thanks to Michal Bluma for contributing the code.
Bug fixes galore
When WordPress 3.3 was released, things got a little funky here and there with PressWork. We went through all of the code, rewriting things to improve efficiency and to debug common issue. Thanks to Michael Riethmuller for his multiple fixes on the toolbox.
Release Candidate 01
Please download PressWork v1.0.4 Release Candidate and test it out. If you encounter any issues, please report them on GitHub so we can do our best to get things perfect for the official release.