Use the HTML Entity ‘Identical To’ For Your Responsive Menu

A lot of websites become responsive to mobile devices these days, and there are a lot of different implementations. One I’ve seen is with the use of the Hamburger Menu, that symbolizes a folded menu. Some websites use special made fonts, like genericons, and others use a simple image.

But there’s another option: the HTML Entity IDENTICAL TO (≡ or ≡ in decimal). It’s almost the same and you can tweak the size with font-size.

Weg met Social Network knoppen

Al eerder heb ik een poging ondernomen door de sociale netwerkknoppen weg te halen op mijn blog over fotografie. Het heeft namelijk weinig nut dat die knoppen er staan, want de bezoekers delen de berichten niet.

Daarnaast kost het extra tijd om de knoppen volledig te laden, en veel sociale netwerken kijken met je mee tijdens het laden van de knop. Zo kunnen ze hele profielen van jou maken zonder dat je daar weet van hebt.

De keuze is gebaseerd op het volgende artikel: Sweep the Sleaze.

Europese Unie en hun WordPress blogs

De Europese Unie is blijkbaar niet erg up to date.. Ze gebruiken voor hun blogs een verouderde versie van WordPress, namelijk versie 2.9.1, terwijl op dit moment (van schrijven) versie 3.5.2 de nieuwste versie is.

Blijkbaar is up to date zijn niet zo belangrijk..

OldWordPressVersionEuropa

Protect wp-login.php with nginx for botnet that scans WordPress websites

With the recent news of a big botnet that attacks WordPress websites via wp-login.php was it time to prepare myself for the attack. wp.login.php is an uncached page that uses PHP resources which can slow down your website or cause errors.

My resolution: restrict access to wp-login.php with nginx. I’m only allowing the IP addresses that I can trust and anyone else will receive a 403 Forbidden error!

location ~* /wp-login.php$ {
allow INSERTYOURIPADDRESSHERE;
deny all;
# These lines are here to make sure that the page is loaded correctly after your IP has been verified. Change them to your own settings.
fastcgi_keep_conn on;
include fastcgi_params;
try_files $uri =404;
fastcgi_split_path_info ^(.+.php)(/.+)$;
fastcgi_intercept_errors on;
# By all means use a different server for the fcgi processes if you need to
proxy_set_header Proxy-Connection "";
fastcgi_pass php5-fpm;
}

How to change WordPress default Email From Name and From Address

WordPress sends by default an email from wordpress@domainname.com with WordPress as sender name.

This can be adjusted easily via a filter.

Change the From Address

The filter will change the From address from wordpress@ to the value you specify.

function new_mail_from( $from_email ) {
$from_email = 'myownemail@domainname.com';
return $from_email;
}
add_filter( 'wp_mail_from', 'new_mail_from' );

Change the From Name

To change the From name:

function new_mail_from_name( $from_name) {
$from_name = 'my own sender name';
return $from_name;
}
add_filter( 'wp_mail_from_name', 'new_mail_from_name' );

You can put this code inside your functions.php file.

WordPress MP6 registers Google fonts apart from my theme

My theme (customized theme Esplanade on www.maartenvandekamp.nl) uses Google fonts. These fonts are registered and enqueued the right way in functions.php.

The new (secret!) plugin MP6 also uses Google fonts, but does not check if a user is logged in, so these fonts are always enqueued when a post of page is viewed, even when I’m logged out. In my case, a visitor downloads the same font twice, taking extra bandwidth and loading time.

You can recognize the MP6 stylesheet by the next line:

<link rel='stylesheet' id='open-sans-css' href='//fonts.googleapis.com/css?family=Open+Sans%3A300italic%2C400italic%2C600italic%2C300%2C400%2C600&#038;subset=latin-ext%2Clatin&#038;ver=0.1' type='text/css' media='all' />

This bug (for me) is easy to fix.

Fix

Open WordPress Admin and navigate to the plugin editor ( Plugins > Editor ), select the MP6 plugin (mp6/mp6.php) and scroll down until you reach the following function:

function mp6_load_open_sans()

Add the following line – if ( is_user_logged_in() ) - above the line:

wp_register_style( 'open-sans', '//fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,300,400,600&subset=latin-ext,latin', false, 0.1 );

The new code will be:


// load Open Sans
add_action( 'init', 'mp6_load_open_sans' );
function mp6_load_open_sans() {
if ( is_user_logged_in() ) 
    wp_register_style( 'open-sans', '//fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,300,400,600&subset=latin-ext,latin', false, 0.1 );
    wp_enqueue_style( 'open-sans' );
}

The MP6 plugin will work as expected when a user / admin is logged in and when this is not the case, the Google fonts won’t be enqueued and no extra bandwidth will be wasted

Improved code – Show related posts in WordPress without a plugin

A while ago I posted an article about showing related posts in WordPress without the use of a plugin. Recently I have found better code for this and I would like to share it with you

<?php
$tag_ids = wp_get_post_tags( $post->ID, array( 'fields' => 'ids' ) );
$args = array(
'tag__in' => $tag_ids,
'post__not_in' => array($post->ID),
'posts_per_page'=> 5,
'no_found_rows' => true,
'update_post_meta_cache' => false,
'update_post_term_cache' => false
);
$tag_query = new WP_Query($args);
if( $tag_query->have_posts() ) : ?>
<h3 class="widget-title">You might also like:</h3>
<ul>
<?php while ($tag_query->have_posts()) : $tag_query->the_post(); ?>
<li><a href="<?php the_permalink() ?>" rel="bookmark" title="Open <?php the_title_attribute(); ?>"><?php the_title(); ?></a></li>
<?php
endwhile;
wp_reset_postdata();
?>
</ul>
<?php endif; ?>

The difference with the previous code is that this code only retrieves the ID’s from the related tags, where the previous code retrieved all the information from the tags, to use only the ID from the array.

The code is cleaner and does not use any if anymore

Verhuizing website IhavetheKnowledge.nl

Zojuist heb ik de laatste grote website verhuisd naar mijn VPS. De verhuizing komt de snelheid van de website zeer ten goede. Hiervoor was de VPS een reverse caching proxy, wat inhoudt dat de VPS een week een gecachde versie van de website vasthield.

Het nadeel hiervan was dat de server na een week alle pagina’s opnieuw moest ophalen wat voor lange laadtijden zorgde. Nu is dat probleem opgelost.

Statistieken Maart 2013

Vorige maand kende een enorme groei in pageviews en ik wist dat deze groei niet constant zou blijven. In Maart is het inderdaad iets teruggelopen en dat vind ik helemaal niet erg. Het aantal bezoekers is wel goed gestegen en dat betekent dat de website een steeds breder publiek gaat aantrekken. Dat is ook groei!

Maand Bezoeken Pageviews Percentage bezoeken Percentage pageviews
Oktober 2012 2626 6734
November 2012 3268 8170 + 24.45% + 21.32%
December 2012 3864 10 332 + 17.5% + 26%
Januari 2013 4946 13 640 + 28% + 32%
Februari 2013 4962 16 139 + 0.14% + 18%
Maart 2013 5745 15 037 + 14.08% – 7.2%

Ik ben erg benieuwd wat April gaat brengen, of er op beide vlakken weer groei is, of dat de cijfers zich stabiliseren en een kleinere groei laten zien.