PRESSWORK WordPressTheme-Removing the Offensive Tweet Widgets

Tweet or Not, It’s Otherwise a Great Theme

Recently I downloaded the PRESSWORK theme which is available in the WordPress repository.  What I loved about this theme is that it is simple, elegant and can be made to look like it was built with something other than WordPress. WordPress themes are usually easy to spot and have a WordPress look that I can identify without looking at the source code.

When I came across this theme I was very excited.  I finally found a theme which I could use to transform my site which has been called “cartoonish” to something that is very professional looking.

I spent about four hours customizing the CSS files and menus to look simple, plain and understated.

What a transformation! My site no longer had an, “I am trying to sell you something look”.

Instead it had an elegance and simplicity written on it that I could be proud of!

 

The “Tweet Problem

But wait, what’s that on my front page? HMM, oh no it’s on EVERY PAGE!

[embedplusvideo height=”365″ width=”600″ standard=”http://www.youtube.com/v/HDFbopKD634?fs=1″ vars=”ytid=HDFbopKD634&width=600&height=365&start=&stop=&rs=w&hd=0&autoplay=0&react=1&chapters=&notes=” id=”ep1998″ /]

A tweet bar on the bottom over every page! I did not put it there! Oh good lord, it shows a tweet about someone hating their bitch and when I refresh the page it’s even worse, it’s talking about someone’s mother!

Time to change the tweet channel I thought. So I configured it to use my credentials for my tweet account, problem solved!

 

The Tweets Just Keep on Rollin!

But wait, “No, that didn’t fix the tweet problem!”

Hmm,  I must not have saved the tweet settings the first time. So naturally I entered them again, and again, and again.

It keeps going back to the same crappy tweet messages!

PRESSWORK WordPress Offensive Tweet
PRESSWORK WordPress Theme — Offensive Tweets Appear

 

I then did a search and found out that a social media plugin might be the culprit. Apparently, the social media widget has some rogue programmers that have built spam into their plugin.

I checked, sure enough four days ago I had installed that plugin. Okay, that’s an easy fix I thought. Because I have a virtualized WordPress site, a rollback of four days is a cinch. (I take a SAN snapshot every day as well as a complete backup as described in my “How to Setup a Secure, Virtualized WordPress Site” series.)

I was up and running after two minutes. The only difficulty was that I had to re-integrate the PRESSWORK theme back into the site.

“Ah well!”, I thought, “Well worth the effort!”, after all it’s a great theme!

Two hours later, the theme was switched. “What a beautiful page!”, I thought, but wait, to my horror, I could almost hear the poltergeist actress say, “It’s back!”.

There it was on the bottom over every page, new and changing with each page refresh, an obscene tweet appearing there below on an otherwise professional looking site.

It successfully changed my rated G topic to a rated R!

I spent the next two hours trying to get rid of the tweet. I realized it was in fact the PRESSWORK theme that had placed it there.  I could find no way to successfully change the tweet account (It kept reverting back to their default account) so I took the time to bury myself in the theme code searching for the “LATEST TWEET” section.

Two hours later, “EUREKA!!!”

I had found the offending code.

It was contained mainly in a “widget-twitter.php” file but was called by the “actions.php” file.

I realized, a search for the word “twitter” with a ” find / -iname twitter “ might have found it in a few minutes, but I felt my limits in imagination, was only partially responsible for the lost time, after all, why couldn’t I just disable this TWEET widget?

 

The Tweet Code!

Here is the original widget-twitter.php code which was responsible for my woes. I replaced areas in orange with the empty php header and closure remainder which is shown beneath in green.

<?php

/**

 * Functionality for Twitter widget

 *

 * @since PressWork 1.0

 */

class PW_Twitter_Widget extends WP_Widget {

     function PW_Twitter_Widget() {

           $widget_ops = array(‘classname’ => ‘pw_twitter_feed’, ‘description’ => __(‘Displays your tweets’, “presswork”) );

           $this->WP_Widget(‘pw_twitter_feed’, __(‘PW – Twitter Feed’, “presswork”), $widget_ops);    

     }

 

     function widget($args, $instance) {

           extract($args, EXTR_SKIP);

           $title = empty($instance[‘title’]) ? ” : apply_filters(‘widget_title’, $instance[‘title’]);

           $username = $instance[‘username’];

           $limit = $instance[‘number’];

           $link = $instance[‘link’];

          

           echo $before_widget;

         if(!empty($title)) { echo $before_title . $title . $after_title; };

          

           $feed = “http://search.twitter.com/search.atom?q=from:” . $username . “&rpp=” . $limit;

          

           $twitterFeed = wp_remote_fopen($feed);

           $this->pw_parse_feed($twitterFeed);

           ?>

         <p class=”clear”><a href=”http://twitter.com/<?php echo $username; ?>”><?php echo $link; ?></a></p>

          <?php 

          

           echo $after_widget;

     }

    

     function pw_parse_feed($feed) {

           $feed = str_replace(“&lt;”, “<“, $feed);

           $feed = str_replace(“&gt;”, “>”, $feed);

           $feed = str_replace(“&quot;”, ‘”‘, $feed);

           $clean = explode(“<content type=\”html\”>”, $feed);

          

           $amount = count($clean) – 1;

          

           echo “<ul class=’mytweets’>”;

          

           for ($i = 1; $i <= $amount; $i++) {

           $cleaner = explode(“</content>”, $clean[$i]);

          echo “<li>”;

           echo str_replace(“&amp;”, “&”, $cleaner[0]);

           echo “</li>”;

           }

          

           echo “</ul>”;

     }

 

     function form($instance) {

           $instance = wp_parse_args( (array) $instance, array( ‘title’ => ‘Latest Tweets’, ‘username’ => ‘pressworkwp’, ‘link’ => ‘Follow Us’, ‘number’ => ‘3’ ) );

           $title = strip_tags($instance[‘title’]);

           $username = strip_tags($instance[‘username’]);

           $number = strip_tags($instance[‘number’]);

           $link = strip_tags($instance[‘link’]);

           ?>

           <p><label for=”<?php echo $this->get_field_id(‘title’); ?>”><?php _e(‘Title’, “presswork”); ?>: <input id=”<?php echo $this->get_field_id(‘title’); ?>” name=”<?php echo $this->get_field_name(‘title’); ?>” type=”text” value=”<?php echo esc_attr($title); ?>” /></label></p>

           <p><label for=”<?php echo $this->get_field_id(‘username’); ?>”><?php _e(‘Username’, “presswork”); ?>: <input id=”<?php echo $this->get_field_id(‘username’); ?>” name=”<?php echo $this->get_field_name(‘username’); ?>” type=”text” value=”<?php echo esc_attr($username); ?>” /></label></p>

           <p><label for=”<?php echo $this->get_field_id(‘number’); ?>”><?php _e(‘Number of Tweets’, “presswork”); ?>: <input id=”<?php echo $this->get_field_id(‘number’); ?>” name=”<?php echo $this->get_field_name(‘number’); ?>” type=”text” value=”<?php echo esc_attr($number); ?>” /></label></p>

           <p><label for=”<?php echo $this->get_field_id(‘link’); ?>”><?php _e(‘Text Link’, “presswork”); ?>: <input id=”<?php echo $this->get_field_id(‘link’); ?>” name=”<?php echo $this->get_field_name(‘link’); ?>” type=”text” value=”<?php echo esc_attr($link); ?>” /></label></p>

           <?php

 

     }

 

     function update($new_instance, $old_instance) {

           $instance = $old_instance;

          $instance[‘title’] = strip_tags($new_instance[‘title’]);

           $instance[‘username’] = strip_tags($new_instance[‘username’]);

           $instance[‘link’] = strip_tags($new_instance[‘link’]);

           $instance[‘number’] = strip_tags($new_instance[‘number’]);

           return $instance;

     }

}

register_widget(‘PW_Twitter_Widget’);

 

And my Anti-Spam version of the widget-twitter.php  file content shown here in green:

(untar this file and replace the original found in the PRESSWORK Theme)

 

<?php ?>

 

The Tweet PIG!

Ah, much simpler, more to my liking simple and elegant, not unlike our iphone & Android specialty case we are going to start selling next month, or E=MC2.

Well, Ok it isn’t actually the code of a computer wizard, but in the words of farmer in the 1995 hit, Babe (James Cromwell):

PRESSWORK WordPress theme OFFENSIVE TWEET Babe 1995 Film with James Cromwell
PRESSWORK WordPress theme OFFENSIVE TWEET

That’ll do Pig, that’ll do!

 

Oops! That caused my site to crash!

 

Some more less elegant hacking was necessary on the actions.php file.

Here is the original actions.php file content with my totally hacked fix for the calling of the widget-twitter.php (Area’s that are in orange I simply commented out with a # (pound sign) inside the original file while areas in green I left alone. ) Here is the edited version in tar format for download: actions.php. I think I could have avoided the downtime if I had edited the actions.php file first.

<?php

/**

 * The action hooks. This is where functions are hooked into certain

 * action calls.

 *

 * @since PressWork 1.0

 */

 

/*

 * The Header

 */

function pw_header_content() {

     echo pw_function_handle(__FUNCTION__);

     ?>

    <ul id=”headerbanner”>

           <?php

         $layout = pw_theme_option(‘header_option’);

         $layout = explode(“,”, $layout);

         foreach($layout as $elem) {

         pw_get_element($elem);

         }

         ?>

    </ul> <!– end headerbanner –>

     <?php

}

add_action(‘pw_header_middle’, ‘pw_header_content’);

 

/*

 * Social Icons

 */

function pw_social_content() {

     $twitter = pw_theme_option(‘twitter’);

     $facebook = pw_theme_option(‘facebook’);

     $flickr = pw_theme_option(‘flickr’);

     $linkedin = pw_theme_option(‘linkedin’);

     $googleplus = pw_theme_option(‘googleplus’);

     $stumbleupon = pw_theme_option(‘stumbleupon’);

    

     echo ‘<div id=”social-icons”>’;

     if(!empty($twitter))

           echo ‘<a href=”http://twitter.com/’.$twitter.'” class=”twitter-icon”></a>’;

     if(!empty($facebook))

           echo ‘<a href=”http://facebook.com/’.$facebook.'” class=”facebook-icon”></a>’;

     if(!empty($flickr))

           echo ‘<a href=”http://www.flickr.com/photos/’.$flickr.'” class=”flickr-icon”></a>’;        

     if(!empty($googleplus))

           echo ‘<a href=”https://plus.google.com/’.$googleplus.'” class=”googleplus-icon”></a>’; 

     if(!empty($linkedin))

           echo ‘<a href=”http://www.linkedin.com/in/’.$linkedin.'” class=”linkedin-icon”></a>’;   

     if(!empty($stumbleupon))

           echo ‘<a href=”http://www.stumbleupon.com/stumbler/’.$stumbleupon.'” class=”stumbleupon-icon”></a>’;

     echo ‘</div>’;

}

add_action(‘pw_header_middle’, ‘pw_social_content’);

 

/*

 * The Footer

 */

function pw_footer_content() {

     echo pw_function_handle(__FUNCTION__);

     ?>

    <ul id=”footer” class=”clearfix”>

           <?php

         $layout = pw_theme_option(‘footer_option’);

         $layout = explode(“,”, $layout);

         foreach($layout as $elem) {

         pw_get_element($elem);

         }

         ?>

    </ul> <!– end #footer –>

     <?php

}

add_action(‘pw_footer_middle’, ‘pw_footer_content’);

 

/*

 * The first sidebar

 */

function pw_sidebar() {

#    echo pw_function_handle(__FUNCTION__);

#    if(!dynamic_sidebar(“first-sidebar”)) :   

#          echo ‘<aside>’;

#          get_search_form();

#          echo ‘</aside>’;

#

#          $args = array(

#               ‘before_widget’ => ‘<aside class=”side-widget pw_featured_posts”>’,

#               ‘after_widget’ => “</aside>”,

#               ‘before_title’ => ‘<header><h3>’,

##              ‘after_title’ => ‘</h3></header>’,

#          );

#

#          $featured = new PW_Featured_Posts_Widget;

#          $instance = array( ‘title’ => ‘Featured Posts’, ‘category’ => ‘0’, ‘number’ => ‘2’ );

#          $featured->widget($args, $instance);

 

#          $args[‘before_widget’] = ‘<aside>’;

#          $tweet = new PW_Twitter_Widget;

#          $instance =

##array( ‘title’ => ‘Latest Tweets’, ‘username’ => ”, ‘link’ => ‘Follow Us’, ‘number’ => ‘3’ );

#          $tweet->widget($args, $instance);

 

#          if(current_user_can(‘edit_theme_options’)) {

#               echo ‘<aside><p>’;

#               printf(__(“Add your own widgets to the First Sidebar %shere%s”, “presswork”), ‘<a href=”‘.admin_url(‘widgets.php’).'”>’, ‘</a>’);

#               echo ‘</p></aside>’;

           }

#    endif;

}

#add_action(‘pw_sidebar_middle’, ‘pw_sidebar’);

 

/*

 * The second sidebar

 */

function pw_second_sidebar() {

#    echo pw_function_handle(__FUNCTION__);

#    if(!dynamic_sidebar(“second-sidebar” ) && current_user_can(‘edit_theme_options’)) :

#          echo ‘<aside><p>’;

#          printf(__(“Add widgets to the Second Sidebar %shere%s”, “presswork”), ‘<a href=”‘.admin_url(‘widgets.php’).'”>’, ‘</a>’);

#          echo ‘</p></aside>’;    endif;

}

add_action(‘pw_second_sidebar_middle’, ‘pw_second_sidebar’);

 

/*

 * Top Content Widgetized Area

 */

function pw_top_content_widgetized_area() {

     global $paged;

     if($paged < 2) {

           echo pw_function_handle(__FUNCTION__);

           dynamic_sidebar(“top-index-area” );

     }

}

add_action(‘pw_index_top’, ‘pw_top_content_widgetized_area’);

 

/*

 * Basic Loop

 */

function pw_loop() {

     get_template_part( ‘loop’);

}

add_action(‘pw_index_middle’,’pw_loop’);

add_action(‘pw_single_middle’, ‘pw_loop’);

add_action(‘pw_page_middle’, ‘pw_loop’);

add_action(‘pw_archive_middle’, ‘pw_loop’);

add_action(‘pw_category_middle’, ‘pw_loop’);

add_action(‘pw_author_middle’, ‘pw_loop’);

add_action(‘pw_search_middle’, ‘pw_loop’);

 

/*

 * Pagination

 */

function pw_pagination() {

     echo pw_function_handle(__FUNCTION__);

     pw_paginate();

}

add_action(‘pw_index_bottom’, ‘pw_pagination’);

add_action(‘pw_archive_bottom’, ‘pw_pagination’);

add_action(‘pw_author_bottom’, ‘pw_pagination’);

add_action(‘pw_category_bottom’, ‘pw_pagination’);

add_action(‘pw_search_bottom’, ‘pw_pagination’);

 

/*

 * This is the 404 page

 */

function pw_404() {

     echo pw_function_handle(__FUNCTION__);

     ?>

     <article id=”post-0″>

    <header>

         <h1 class=”posttitle”><?php _e(“Not found”, “presswork”); ?></h1>

        </header>

        <div class=”entry”>

            <p><?php _e(“No results were found for your request.”, “presswork”); ?></p>

        </div>

    </article>

     <?php

}

add_action(‘pw_404_middle’, ‘pw_404’);

 

/*

 * Archive header

 */

function pw_archive_title() {

     echo pw_function_handle(__FUNCTION__);

     if (have_posts()) {

           ?>

           <header>

         <h1 class=”catheader”>

             <?php

             if( is_tag() ) { ?>

                 <?php printf(__(“Posts Tagged &#8216;%s&#8217;”, “presswork”), single_tag_title(”,false)); ?>

                <?php

                } elseif (is_day()) { ?>

                 <?php _e(“Archive for”, “presswork”); echo ” “; the_time(‘F jS, Y’); ?>

                <?php

                } elseif (is_month()) { ?>

                 <?php _e(“Archive for”, “presswork”); echo ” “; the_time(‘F, Y’); ?>

                <?php

                } elseif (is_year()) { ?>

                 <?php _e(“Archive for”, “presswork”); echo ” “; the_time(‘Y’); ?>

                <?php

                } elseif (isset($_GET[‘paged’]) && !empty($_GET[‘paged’])) { ?>

                 <?php _e(“Blog Archives”, “presswork”); ?>

             <?php

                }

                ?>

             </h1>

        </header>

        <?php

     } else {

           echo “<header><h1 class=’posttitle’>”.__(“No posts found.”, “presswork”).”</h1></header>”;

     }

}

add_action(‘pw_archive_top’, ‘pw_archive_title’);

 

/*

 * Category header

 */

function pw_category_title() {

     echo pw_function_handle(__FUNCTION__);

     if(have_posts()) { ?>

        <header>

        <h1 class=”catheader”><?php single_cat_title(); ?></h1>

        <?php $catdesc = category_description(); if(stristr($catdesc,'<p>’)) echo ‘<div>’.$catdesc.'</div>’; ?>

        </header>

        <?php

     } else {

           echo “<header><h1 class=’posttitle’>”.__(“No posts found.”, “presswork”).”</h1></header>”;

     }         

}

add_action(‘pw_category_top’, ‘pw_category_title’);

 

/*

 * Author header

 */

function pw_author_title() {

     echo pw_function_handle(__FUNCTION__);

     if (have_posts()) {

        pw_authorbox();       

     } else {

           echo “<header><h1 class=’posttitle’>”.__(“No posts found.”, “presswork”).”</h1></header>”;

     }         

}

add_action(‘pw_author_top’, ‘pw_author_title’);

 

/*

 * Top of comments section

 */

function pw_comment_section_title() {

     echo pw_function_handle(__FUNCTION__);

     echo ‘<h3 id=”comments-title”>’;

     printf( _n( ‘One Response to %2$s’, ‘%1$s Responses to %2$s’, get_comments_number(), “presswork” ), number_format_i18n( get_comments_number() ), ‘<em>’ . get_the_title() . ‘</em>’ );

     echo ‘</h3>’;

}

add_action(‘pw_comments_top’, ‘pw_comment_section_title’);

 

/*

 * Comment middle section

 */

function pw_comment_section() {

     echo pw_function_handle(__FUNCTION__);

     ?>

    <ol class=”commentlist”>

           <?php wp_list_comments( array( ‘callback’ => ‘pw_comment_template’, ‘reply_text’ => __(‘Reply’, “presswork”) ) ); ?>

    </ol>

    <?php

}

add_action(‘pw_comments_middle’, ‘pw_comment_section’);

 

/*

 * Comment navigation

 */

function pw_comment_navigation() {

     echo pw_function_handle(__FUNCTION__);

    if ( get_comment_pages_count() > 1 ) { ?>

        <nav class=”navigation”>

                <h1 class=”assistive-text”><?php _e( ‘Comment navigation’, ‘presswork’ ); ?></h1>

                <div><?php previous_comments_link( __( ‘&larr; Older Comments’, “presswork” ) ); ?></div>

            <div class=”nav-next”><?php next_comments_link( __( ‘Newer Comments &rarr;’, “presswork” ) ); ?></div>

        </nav>

    <?php

     }

}

add_action(‘pw_comments_nav_top’, ‘pw_comment_navigation’);

add_action(‘pw_comments_nav_bottom’, ‘pw_comment_navigation’);

 

/*

 * Comment reply section

 */

function pw_comment_section_reply() {

     echo pw_function_handle(__FUNCTION__);

     $args = array(

           ‘comment_notes_after’ => ”,

           ‘comment_field’ => ‘<p><textarea id=”comment” name=”comment” required cols=”45″ rows=”8″ placeholder=”‘.__(“Your comment”, “presswork”).’ *” aria-required=”true”></textarea></p>’

     );

     comment_form($args);

}

add_action(‘pw_comments_reply’, ‘pw_comment_section_reply’);

 

/*

 * Search page title

 */

function pw_search_title() {

     echo pw_function_handle(__FUNCTION__);

     global $wp_query;

     $total_results = $wp_query->found_posts;

    echo ‘<h1 class=”catheader”>’.$total_results.’ ‘.__(‘search results for’, “presswork”).’ “‘; the_search_query(); echo ‘”</h1>’;

 

}

add_action(‘pw_search_top’, ‘pw_search_title’);

 

/*

 * Home page featured query

 *

 * @since PressWork 1.0.3

 */

function pw_home_page_featured_query() {

     global $post, $notin, $paged, $pw;

     $pw = 1;

     $sticky = get_option( ‘sticky_posts’ );

     $notin = pw_notin();

     if(!empty($sticky)) {

           if(!empty($notin)) $notin = array_merge($notin, $sticky); else $notin = $sticky;

           if($paged < 2) {

                $args = array(

                     ‘post__in’  => $sticky,

                     ‘ignore_sticky_posts’ => 1

                );

                $the_query = new WP_Query( $args );

                while ( $the_query->have_posts() ) : $the_query->the_post();

                ?>

                <article id=”post-<?php the_ID(); ?>” <?php post_class(“pw pw”.$pw); ?>>

                     <?php pw_actionBlock(‘pw_index_sticky_post’); ?>

                </article>

                <?php

                $pw++;    

                endwhile;

                wp_reset_query();

           }

     } else {

           $args = array(

                ‘post__not_in’  => $notin,

                ‘posts_per_page’ => 2

           );

           $the_query = new WP_Query( $args );

           while ( $the_query->have_posts() ) : $the_query->the_post();

           if($paged < 2) {

                $notin[] = $post->ID;

                ?>

                <article id=”post-<?php the_ID(); ?>” <?php post_class(“pw pw”.$pw); ?>>

                     <?php pw_actionBlock(‘pw_index_featured_post’); ?>

                </article>

                <?php

                $pw++;    

           } else {

                $notin[] = $post->ID;

           }

           endwhile;

           wp_reset_query();

     }

     query_posts( array( ‘post__not_in’ => $notin, “paged” => $paged  ) );

}

add_action(‘pw_home_page’, ‘pw_home_page_featured_query’);

 

/*

 * Featured posts

 */

function pw_posts_featured() {

     echo pw_function_handle(__FUNCTION__);

     global $pw;

     $rightcon = ”;

     $bool = true;

     if(function_exists(‘has_post_thumbnail’) && has_post_thumbnail() && (function_exists(‘has_post_format’) && !has_post_format(‘gallery’) && !has_post_format(‘video’) && !has_post_format(‘image’))) {

           echo ‘<a href=”‘.get_permalink().'”>’;

           if($pw==1) { $thumb = ‘sticky’; $class = ‘alignnone’; } else { $thumb = ‘thumbnail’; $class = ‘alignleft’; }

           the_post_thumbnail($thumb, array(‘class’=>$class));

           echo ‘</a>’;

           $rightcon = ‘ class=”content-col”‘;

     } else {

           if(has_post_format(“image”)) $bool = false;

     }

     ?>

    <div<?php echo $rightcon; ?>>

           <?php pw_post_header(); ?>

           <?php pw_post_content($bool); ?>

     </div>

<?php

}

add_action(‘pw_index_sticky_post_middle’, ‘pw_posts_featured’);

add_action(‘pw_index_featured_post_middle’, ‘pw_posts_featured’);

 

/*

 * 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 ‘&nbsp;&bull;&nbsp;’;

                     the_time(get_option(‘date_format’));

                     if(!is_home()) {

                           echo ‘&nbsp;&bull;&nbsp;’;

                           the_category(‘, ‘);

                     }

                     if(comments_open()) { echo ‘&nbsp;&bull;&nbsp;’; 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);

 

/*

 * 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) || has_post_format(‘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 &rarr;’, “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 &rarr;</a>’, ‘This gallery contains <a %1$s>%2$s photos &rarr;</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>’;

                     the_content(”);

                     echo ‘</div>’;

                }

           } else {

                if(!empty($display_excerpt))

                     pw_excerpt($excerpt_length);

                else

                     the_content( __( ‘Read more &rarr;’, “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);

 

/*

 * Post footer

 */

function pw_post_footer() {

     ?>

     <footer>

         <?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>’, ‘</p>’);

           ?>

     </footer>

     <?php

}

add_action(‘pw_single_post_middle’, ‘pw_post_footer’, 12);

add_action(‘pw_page_post_middle’, ‘pw_post_footer’, 12);

 

/*

 * Author box

 */

function pw_authorbox() {

     echo pw_function_handle(__FUNCTION__);

     global $author;

     ?>

    <div id=”authorbox” class=”clearfix fl”>

        <?php if (function_exists(‘get_avatar’)) { echo get_avatar( get_the_author_meta(’email’, $author), ’80’ ); }?>

        <div>

           <header>

                     <h4><?php _e(‘About’, “presswork”); ?> <?php if(is_author()) the_author_meta(‘display_name’, $author); else the_author_posts_link(); ?></h4>

           </header>

           <p><?php the_author_meta(‘description’, $author); ?></p>

           <p><a href=”<?php the_author_meta(‘url’, $author); ?>”><?php the_author_meta(‘url’, $author); ?></a></p>

        </div>

    </div>

<?php

}

add_action(‘pw_single_bottom’, ‘pw_authorbox’);

 

/*

 * Columns top

 */

function pw_columns_post_title($r) {

     if(function_exists(‘has_post_format’) && (has_post_format(‘aside’) || has_post_format(‘link’))) { // new aside || link post format

           // do nothing

     } else {

           ?>

     <header>

           <hgroup>

                <h1 class=”posttitle”><a href=”<?php the_permalink() ?>” title=”<?php printf(__(“Permanent Link to %s”, “presswork”), the_title_attribute(‘echo=0’)); ?>”><?php the_title(); ?></a></h1>

             <h2>

                <?php

                if(!empty($r[‘authors’])) { _e(“by”, “presswork”); echo ” “; the_author_posts_link(); }

                 if(!empty($r[‘dates’])) { echo ‘&nbsp;&bull;&nbsp;’; the_time(get_option(‘date_format’)); }

                 if(!empty($r[‘comments’]) && comments_open()) { echo ‘&nbsp;&bull;&nbsp;’; comments_popup_link(__(‘0 Comments’, “presswork”),__(‘1 Comment’, “presswork”),__(‘% Comments’, “presswork”)); }

                ?>

             </h2>

        </hgroup>

    </header>

        <?php

     }

}

add_action(‘pw_columns_top’, ‘pw_columns_post_title’, 1, 1);

 

function pw_columns_post_content($r) {

     ?>

    <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’; else $size = array($r[‘img_w’], $r[‘img_h’]);

                     if(function_exists(‘has_post_thumbnail’) && has_post_thumbnail() && $r[‘images’]==1) {

                           echo ‘<a href=”‘.get_permalink().'” class=”image-anchor”>’;

                           the_post_thumbnail($size, array( ‘class’ => $r[‘img_float’] ));

                           echo ‘</a>’;

                     } else {

                           if(has_post_format(‘image’))

                                the_content();

                     }

                     if(empty($format)) {

                           if($r[‘text’]==”content”) {

                                if($r[‘readmore’]==1) {

                                     the_content( __( ‘Read more &rarr;’, “presswork” ) );

                                } else {

                                     the_content(”);

                                }         

                           } else {

                                pw_excerpt($r[‘excerpt_length’]);

                                if($r[‘readmore’]==1) echo ‘<a href=”‘.get_permalink().'” class=”more-link”>’.__(‘Read more &rarr;’, “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 &rarr;</a>’, ‘This gallery contains <a %1$s>%2$s photos &rarr;</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>’;

                     if($r[‘readmore’]==1) {

                           the_content( __( ‘Read more &rarr;’, “presswork” ) );

                     } else {

                           the_content(”);

                     }

                     echo ‘</div>’;

                }

           }

        ?>

    </div>

     <?php

}

add_action(‘pw_columns_middle’, ‘pw_columns_post_content’, 1, 1);

 

/*

 * The Media Queries

 */

function pw_add_media_queries() {

     global $pw_content_width, $pw_first_sidebar, $pw_second_sidebar, $pw_site;

     $ipad = 720 / $pw_site;

     ?>

@media only screen and (max-device-width: 768px), only screen and (max-width: 768px) {

           #body-wrapper { width: 720px !important; padding: 0 10px; }

           body.fullwidth #maincontent, #headerbanner, #footer { width: 720px !important; }

           #header_image { background-size: 720px !important; height: <?php echo 720/$pw_site*HEADER_IMAGE_HEIGHT; ?>px !important; }

           #maincontent { width: <?php echo ($pw_content_width * $ipad) – 10; ?>px !important; }

           #firstsidebar { width: <?php echo $pw_first_sidebar * $ipad; ?>px !important; }

           #secondsidebar { width: <?php echo ($pw_second_sidebar * $ipad) – 15; ?>px !important; }

     }

     @media only screen and (max-width: 480px), only screen and (max-device-width: 480px) {

           #body-wrapper { width: 420px !important; padding: 0 10px; }

           body.fullwidth #maincontent, #headerbanner, #footer { width: 420px !important; }

           #maincontent { width: 420px !important; }

           #header_image { background-size: 420px !important; height: <?php echo 420/$pw_site*HEADER_IMAGE_HEIGHT; ?>px !important; }

           .home article { width: 100%; }

           #firstsidebar, #secondsidebar { float: none; width: 100% !important; }

           #main-wrapper > li { margin: 0 !important; }

           #extendedfooter .bottom-widget { width: 100%; margin: 0 0 20px; }

     }<?php    

}

add_action(‘pw_media_queries’, ‘pw_add_media_queries’);

 

// Including child theme action file

if(!defined(‘CHILD_ACTION_FILE’))

     define(‘CHILD_ACTION_FILE’, STYLESHEETPATH.’/actions.php’);

if(file_exists(CHILD_ACTION_FILE))

     include(CHILD_ACTION_FILE);

?>

PRESSWORK OFFENSIVE TWEETS in Widget that won't go away! Babe 1995
PRESSWORK OFFENSIVE TWEETS in Widget that won’t go away!

 

Tweet, the Final Words!

Finally, ten minutes of down time later, my site was up and running, without the twitter vulgarity. I hope that someone else finds this article useful! Please enjoy the articles on our site about world energy solutions, and our other training videos. (See the top menu! Lots of good content)

 

Also be sure to come back and see our iPhone & Android specialty phone case when it becomes available on our KickStarter project next month! IT DOES SOMETHING NO OTHER CASE DOES!