Monthly Archives: April 2015

Website Speed Checker

http://gtmetrix.com/

http://tools.pingdom.com/fpt/

serve scaled images by htaccess

.htaccess


<FilesMatch "\.(ico|jpg|jpeg|png|gif|js|css|swf|svg|pdf|flv|mp3)$">
<IfModule mod_expires.c>
ExpiresActive on
ExpiresDefault "access plus 1 month 2 days 3 hours"
</IfModule>
</FilesMatch>

defer parsing of javascript

functions.php


/*defer parsing of javascript */
function defer_parsing_of_js ( $url ) {
if ( FALSE === strpos( $url, '.js' ) ) return $url;
if ( strpos( $url, 'jquery.js' ) ) return $url;
return "$url' defer ";
}
add_filter( 'clean_url', 'defer_parsing_of_js', 11, 1 );

add expires headers by htaccess

.htaccess


<IfModule mod_expires.c>
ExpiresActive on
ExpiresByType text/css "access plus 60 days"
ExpiresByType text/javascript "access plus 60 days"
ExpiresByType image/ico "access plus 60 days"
ExpiresByType image/jpg "access plus 60 days"
ExpiresByType image/jpeg "access plus 60 days"
ExpiresByType image/gif "access plus 60 days"
ExpiresByType image/png "access plus 60 days"
ExpiresByType text/css "access plus 60 days"
ExpiresByType text/html "access plus 60 days"
</IfModule>

Add expires headers from htaccess

.htaccess


<IfModule mod_expires.c>
ExpiresActive On
ExpiresDefault A300
ExpiresByType application/x-javascript A3600
ExpiresByType text/css A3600
ExpiresByType image/gif A3600
ExpiresByType image/png A3600
ExpiresByType image/jpeg A3600
ExpiresByType text/plain A300
ExpiresByType application/x-shockwave-flash A3600
ExpiresByType video/x-flv A3600
ExpiresByType application/pdf A3600
ExpiresByType text/html A300
</IfModule>
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

Different widget in sidebar for different post and page

Add required widget in sidebar

Create Sidebar


register_sidebar(array(
'name' => __('Contact Attorny', 'legal'),
'id' => 'contact-attorny',
'description' => __('Contact Attorny sidebar that appears on the right.', 'legal'),
'before_widget' => '<aside id="%1$s" class="sidebar-widget widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<div class="sidebar-widget"><h3>',
'after_title' => '</h3></div>',
));

register_sidebar(array(
'name' => __('Twitter', 'legal'),
'id' => 'twitterfids',
'description' => __('Twitter that appears on the right.', 'legal'),
'before_widget' => '<aside id="%1$s" class="sidebar-widget widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<div class="sidebar-widget"><h3>',
'after_title' => '</h3></div>',
));

register_sidebar(array(
'name' => __('Blog Category', 'legal'),
'id' => 'bcats',
'description' => __('Blog Category that appears on the right.', 'legal'),
'before_widget' => '<aside id="%1$s" class="sidebar-widget widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<div class="sidebar-widget"><h3>',
'after_title' => '</h3></div>',
));
register_sidebar(array(
'name' => __('Practice Area', 'legal'),
'id' => 'practicearea',
'description' => __('Practice Area that appears on the right.', 'legal'),
'before_widget' => '<aside id="%1$s" class="sidebar-widget widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<div class="sidebar-widget"><h3>',
'after_title' => '</h3></div>',
));

Sidebar.php


<?php
$legal_options = get_option('legal_theme_options');
?>
<?php if ( is_singular('practice-areas') ) { ?>
<div class="sidebar-box">
<?php if (is_active_sidebar('contact-attorny')) {
dynamic_sidebar('contact-attorny'); }?>
</div>
<div class="sidebar-box">
<?php if (is_active_sidebar('twitterfids')) {
dynamic_sidebar('twitterfids'); }?>
</div>
<div class="sidebar-box">
<?php if (is_active_sidebar('practicearea')) {
dynamic_sidebar('practicearea'); }?>
</div>
<?php } ?>

<?php if ( is_singular('post') ) { ?>
<div class="sidebar-box">
<?php if (is_active_sidebar('contact-attorny')) {
dynamic_sidebar('contact-attorny'); }?>
</div>
<div class="sidebar-box">
<?php if (is_active_sidebar('twitterfids')) {
dynamic_sidebar('twitterfids'); }?>
</div>
<div class="sidebar-box">
<?php if (is_active_sidebar('bcats')) {
dynamic_sidebar('bcats'); }?>
</div>
<?php } ?>

<?php if(is_home()) { ?>
<div class="sidebar-box">
<?php if (is_active_sidebar('contact-attorny')) {
dynamic_sidebar('contact-attorny'); }?>
</div>
<div class="sidebar-box">
<?php if (is_active_sidebar('twitterfids')) {
dynamic_sidebar('twitterfids'); }?>
</div>
<div class="sidebar-box">
<?php if (is_active_sidebar('bcats')) {
dynamic_sidebar('bcats'); }?>
</div>
<?php } ?>

<?php if (is_page_template('page-template/testimonials.php')) { ?>
<div class="sidebar-box">
<?php if (is_active_sidebar('contact-attorny')) {
dynamic_sidebar('contact-attorny'); }?>
</div>
<div class="sidebar-box">
<?php if (is_active_sidebar('twitterfids')) {
dynamic_sidebar('twitterfids'); }?>
</div>
<div class="sidebar-box">
<?php if (is_active_sidebar('practicearea')) {
dynamic_sidebar('practicearea'); }?>
</div>
<?php } ?>

<?php if (is_page_template('page-template/case-results.php')) { ?>
<div class="sidebar-box">
<?php if (is_active_sidebar('practicearea')) {
dynamic_sidebar('practicearea'); }?>
</div>
<div class="sidebar-box">
<?php if (is_active_sidebar('twitterfids')) {
dynamic_sidebar('twitterfids'); }?>
</div>
<?php } ?>

<?php if (is_page(204)) { ?>
<div class="sidebar-box">
<?php if (is_active_sidebar('contact-attorny')) {
dynamic_sidebar('contact-attorny'); }?>
</div>
<div class="sidebar-box">
<?php if (is_active_sidebar('twitterfids')) {
dynamic_sidebar('twitterfids'); }?>
</div>
<?php } ?>

<?php if (is_page(269)) { ?>
<div class="sidebar-box">
<?php if (is_active_sidebar('contact-attorny')) {
dynamic_sidebar('contact-attorny'); }?>
</div>
<div class="sidebar-box">
<?php if (is_active_sidebar('twitterfids')) {
dynamic_sidebar('twitterfids'); }?>
</div>
<div class="sidebar-box">
<?php if (is_active_sidebar('bcats')) {
dynamic_sidebar('bcats'); }?>
</div>
<?php } ?>

<?php if (is_page(206)) { ?>
<div class="sidebar-box">
<?php if (is_active_sidebar('contact-attorny')) {
dynamic_sidebar('contact-attorny'); }?>
</div>
<div class="sidebar-box">
<?php if (is_active_sidebar('twitterfids')) {
dynamic_sidebar('twitterfids'); }?>
</div>
<div class="sidebar-box">
<div class="address_info">
<h4> <?php echo esc_attr($legal_options['contacttitles']); ?> </h4>
<div class="textwidget">
<ul>
<li>
<?php echo esc_attr($legal_options['contactaddresses']); ?><br>
Phone: <?php  echo esc_url($legal_options['pnumbers']); ?><br>
Fax: <?php  echo esc_attr($legal_options['faxnumbs']); ?><br>
E-mail: <a href="mailto:<?php echo sanitize_email($legal_options['cemails']); ?>"><?php echo sanitize_email($legal_options['cemails']); ?></a><br>
Website: <a href="<?php echo esc_url($legal_options['cweb']); ?>"><?php echo esc_url($legal_options['cweb']); ?></a> </li>
</ul>
</div>
</div>
</div>

<?php } ?>

%d bloggers like this: