[WPSNIPP]Track post and page views by user ID, date and time

From: wpsnipp.com
By: Kevin Chard

After an interesting conversation with a fan of wpsnipp, I come up with something to track unique post views for registered users. However this neat little snippet does a little more than that. First add wps_trackViewDates(); within the loop of your single.php template file. Once this has been added, the snippet will track the ID of the user that viewed an individual post along with the date and time it was viewed.

link: Track post and page views by user ID, date and time


Track post and page views by user ID, date and time is a post from: wpsnipp.com - WordPress Snippets, Code, Hacks, 615+ for your wordpress theme or blog.

[WordPress Canada]The History of WordPress and More By Kinsta

If you were ever curious about the history of WordPress, Mark Gavalda, CEO of Kinsta Performance WordPress Hosting, has published an incredible piece on the humble beginnings of the platform we all know and love. Not only that, the article also takes an in-depth look at both the vast ecosystem and community that has sprung up around WordPress covering everything from theme shops to popular plugins to core contributors to community news sites and everything in-between.

It’s a long read but well worth it. So if you have an hour or so to spare, put on some coffee, relax in your favourite chair and give it a go.

The post The History of WordPress and More By Kinsta appeared first on WPCanada.

[WordPress Canada]Plugin Review: AddQuicktag

There is no shortage of plugins out there to customize WordPress and make it your own. One of my all time favourites is AddQuicktag by Frank Bültge.

This handy tool lets you add or remove whatever buttons you want to and from the post toolbar via a simple GUI without having to alter core files (which is something you shouldn’t do).

Once activated, the plugin adds a new menu item located at Settings > AddQuicktag where you can configure your options. So let’s take a look at the plugin’s configuration screen.

The configuration screen is divided into several areas:

Add or delete Quicktag buttons (click image to enlarge)

add buttons

On the screen shown above you can add the button label, title attribute, start and close tag as well as choose where you want to add the button ie: the visual editor, on pages, on posts etc. For instance, I sometimes include subheadings in some of my posts and pages so I added the <h3></h3> and <h4></h4> tags. I want to use them on both posts and pages so I checked the appropriate boxes. I left the visual editor unchecked as I never use it.

This is what my configuration screen looks like … (click image to enlarge)

my add button screen

Remove Core Quicktag buttons

This section appears below the previous one. On this screen we can remove any core WordPress buttons we don’t use from the toolbar. (click image to enlarge)

remove buttons

In my case I have removed the del, ins, more and fullscreen buttons as I never use them.

Enhanced Code Quicktag buttons

This is the next section and it is my personal favourite. If you write a lot of tutorials containing code snippets you’re going to love it too. (click image to enlarge)

enhanced code

Here you have the option of adding a pre button which adds a <pre> tag to the toolbar. Handy for preformatted text (think blocks of code) as well as a HTML Entities button. The HTML Entities button is great for times when you want to display code in a post. Normally you would have to run off to another website somewhere to convert your characters such as < or > so that they display rather then execute. The HTML Entities button it does it for you – just highlight the characters you want to convert then click the button. Done.

But wait, there’s more. It also enhances the code button as shown below. (click image to enlarge)

add class to code button

Before clicking the code button, choose an option from the drop down menu such as html, javascript, php etc then highlight your text. This will add a class to the code tag which you can then style via css. For example, select javascript, highlight your text, click the code button and you’ll get this …

<code class="language-javascript">some random text</code>

Now you can target that class in your css as such …

code.language-javascript {
	
}

Export / Import

In the last two sections you can export your settings to your desktop in the form of a JSON file then import it in to another site if you want. (click image to enlarge)

export and import your settings

The plugin also comes with the ability to use hooks and filters for more advanced use which I won’t cover here. Take a look at the plugin’s documentation for details.

All in all I find AddQuicktag easy to use and a huge time saver.

The post Plugin Review: AddQuicktag appeared first on WPCanada.

[WordPress Canada]Plugin Review: Dashboard Maintenance Mode

For several years my favourite maintenance mode plugin was one aptly called Maintenance Mode by Michael Wöhrer. It was a wonderful little plugin that not only applied a 503 HTTP header but also included the ability to use a custom HTML page.

So naturally I was disappointed to discover the plugin was no longer in the WordPress Plugin Directory.

My search for a replacement turned up many results and after testing about a half dozen or so I found one I like – Dashboard Maintenance Mode by Mirte Becker.

The other plugins I tested came with oodles of options but I was after something lightweight and simple and Dashboard Maintenance Mode fits the bill. Like Maintenance Mode, Dashboard Maintenance Mode applies a 503 HTTP header when active and also includes the ability to use a custom HTML page.

Here’s how to set it up with your own custom HTML page.

Once installed and activated it will add a widget to your Dashboard. Navigate to your Dashboard, locate the widget and click Activate. (see image below)

activate Dashboard Maintenance Mode

When activated the plugin adds a file named maintenance.php to your /wp-content directory. This is the file we can edit to get the look we want.

This is the content of the default maintenance.php file.

<?php
$protocol = $_SERVER["SERVER_PROTOCOL"];
if ( 'HTTP/1.1' != $protocol && 'HTTP/1.0' != $protocol )
        $protocol = 'HTTP/1.0';
header( "$protocol 503 Service Unavailable", true, 503 );
header( 'Content-Type: text/html; charset=utf-8' );
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Your Website | Maintenance Mode</title>
    
    <style>
    body {
    	background-color: #F0F0F0;
    	font-family: "Trebuchet MS", sans-serif;
    	color: #4A4A4A;
    }
    
    section {
    	background-color: #fff;
    	width: 600px;
    	margin: 0 auto;
    	margin-top: 100px;
    	padding: 45px 25px;
    	border: 10px solid #b2b2b2;
    	text-align: center;
    }
    
    h1 {
    	font-size: 1em;
    }
    </style>
    
</head>
<body>

	<section>
    	<h1>Briefly unavailable for scheduled maintenance.</h1>
	</section>
	
</body>
</html>
<?php die(); ?>

And this is the default splash page that file generates. (see image below)

default maintenance page

It’s a simple page which does the job but we can dress it up a bit. Notice the following line from the file above?

<h1>Briefly unavailable for scheduled maintenance.</h1>

You can change that to whatever you want. You can also add additional text. Want to change the styling? No problem. Note this bit from the file above.

<style>
    body {
    	background-color: #F0F0F0;
    	font-family: "Trebuchet MS", sans-serif;
    	color: #4A4A4A;
    }
    
    section {
    	background-color: #fff;
    	width: 600px;
    	margin: 0 auto;
    	margin-top: 100px;
    	padding: 45px 25px;
    	border: 10px solid #b2b2b2;
    	text-align: center;
    }
    
    h1 {
    	font-size: 1em;
    }
    </style>

That bit above is the money ticket. You can modify that in any way you want. If you don’t want to have the CSS and HTML in the same document you can even delete the <style> </style> tags and everything in between and link to a custom style sheet.

This is my customized maintenance.php file.

<?php
$protocol = $_SERVER["SERVER_PROTOCOL"];
if ( 'HTTP/1.1' != $protocol && 'HTTP/1.0' != $protocol )
        $protocol = 'HTTP/1.0';
header( "$protocol 503 Service Unavailable", true, 503 );
header( 'Content-Type: text/html; charset=utf-8' );
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>WPCanada | Maintenance Mode</title>
<link rel="stylesheet" href="http://wpcanada.ca/wp-content/themes/gigawatt/maintenance.css" type="text/css" />
<link rel="Shortcut Icon" href="http://wpcanada.ca/wp-content/themes/gigawatt/images/favicon.ico" type="image/x-icon" />
<link href='http://fonts.googleapis.com/css?family=Roboto:400,700' rel='stylesheet' type='text/css'>

</head>
<body>

	<section>
    	<h1>Closed for Maintenance</h1>
<p>We're sorry but WPCanada is currently undergoing scheduled maintenance. As a result, all areas of this web site have been temporarily turned off. Once all maintenance activities are complete, access to this site will be restored.</p>
<p>If you came here looking for our free Genesis child themes here are some useful links:</p>
<ul>
<li><a href="http://demo.wpcanada.ca/" title="Theme demos">Theme demos</a></li>
<li><a href="http://docs.wpcanada.ca/" title="Theme docs">Theme docs</a></li>
<li><a href="https://github.com/lenkutchma" title="Theme downloads">Theme downloads</a></li>
</ul>
<p class="right">// Shameless Twitter plug &raquo; <a href="https://twitter.com/wpcanada">@wpcanada</a></p>
	</section>
	
</body>
</html>
<?php die(); ?>

First off all you can see that I changed the heading text between the <h1> </h1> tags and added additional text wrapped in paragraph tags. I also added an unordered list. Additionally, I deleted the CSS and linked to a separate CSS file. I simply created a new CSS file, named it something descriptive like maintenance.css, dropped it in my theme’s folder and linked to it from the head of the document like so …

<link rel="stylesheet" href="http://wpcanada.ca/wp-content/themes/gigawatt/maintenance.css" type="text/css" />

Simple, yes?

As you can see I also linked to Google Fonts to include the Roboto font (to match my theme’s typeface) and included my site’s favicon.

And here is the content of the maintenance.css file I created …

body {
	background-color: #f5f5f5;
}

section {
	background-color: #fff;
	border: 1px solid #ddd;
	border-radius: 5px;
	color: #666;
	font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
	font-size: 16px;
	margin: 40px auto;
	max-width: 960px;
	padding: 20px 40px;
	-webkit-border-radius: 5px;
}

a {
	color: #a90000;
	text-decoration: none;
}

a:hover {
	color: #999;
}

h1 {
	border-bottom: 1px solid #ddd;
	clear: both;
	color: #333;
	font-family: 'Roboto', sans-serif;
	font-size: 36px;
	font-weight: 400;
	line-height: 1.2;
	margin: 20px 0 20px;
	text-align: center;
}

p {
	margin: 0 0 28px;
	padding: 0;
	font-size: 16px;
	line-height: 1.625;
}

p.right {
	text-align: right;
}

ol,
ul {
	margin-bottom: 28px;
	margin-left: 0;
}

ol > li {
	list-style-type: decimal;
}

ul > li {
	list-style-type: disc;
}

li {
	margin-bottom: 6px;
	padding-bottom: 6px;
}

p:last-child,
ul > li:last-child {
	margin-bottom: 0;
}

ol ol,
ul ul {
	margin-bottom: 0;
}

@media only screen and (max-width: 960px) {

	body {
		background-color: #fff;
	}

	section {
		border: none;
		margin: 0 auto;
	}

	h1 {
		border-bottom: 0;
	}

	p.right {
		text-align: center;
	}

}

If you want to see what my maintenance page looks like when the plugin is active click here. Everything you see on that page was accomplished by the code above.

When you are ready to turn the plugin off, navigate to your Dashboard, locate the widget and click Deactivate. (see image below)

deactivate Dashboard Maintenance Mode

One more thing. If for whatever reason you find your site stuck in permanent maintenance mode (stuff happens) simply delete the maintenance.php file from your wp-content directory. The next time you activate the plugin it will generate a new one. Of course that means you’ll have to re-add any customizations you made so it’s a good idea to have a backup of that file handy. Actually, you should be backing up your entire site on a regular basis – but that’s another post for another time. :)

The post Plugin Review: Dashboard Maintenance Mode appeared first on WPCanada.

[WordPress Canada]Megawatt Retired

The Megawatt child theme has been retired and will no longer be maintained. I realize that it was released just a few weeks ago but here is the story; I was working on a major overhaul of what was supposed to be Megawatt v2.0 but that theme became its own entity and was released separately as Gigawatt.

Since Gigawatt is far superior to Megawatt in every way (it even looks like it) there is no point in keeping it around. If you had plans on installing Megawatt my advice is go with Gigawatt instead. It’s a much better theme.

The download, demo site and documentation will remain online for a short time but will eventually be removed. Download, demo site and documentation have been removed.

The post Megawatt Retired appeared first on WPCanada.

[WordPress Canada]Gigawatt Updated v1.1.1

The Gigawatt child theme has been updated to version 1.1.1. This is a minor maintenance release that addresses the way in which the Before Header widget area is called.

If we go to Gigawatt’s functions.php file Line 75, this is the way that widget area was being called,

//* Add before header widget area to home page
add_action( 'genesis_before', 'gigawatt_before_header' ); 
function gigawatt_before_header() {

	if ( ! is_home() )
    	return;

	genesis_widget_area( 'before-header', array(
		'before' => '<div class="before-header widget-area"><div class="wrap">',
		'after'  => '</div></div>',
    ) );

}

The culprit is this line if ( ! is_home() )

While the widget area was displaying on the front page as intended, the problem occurs when you set a static page for your front page under Settings > Reading. By doing so the widget area will no longer appear. This is not what I had in mind. The fix is easy,

if ( ! is_home() )

has been changed to

if ( ! is_front_page() )

Now, if you go to Settings > Reading and set a static page for your front page the widget area will appear.

As usual further info including demo and download links can be found on the official theme page.

Reference: http://codex.wordpress.org/Template_Hierarchy

The post Gigawatt Updated v1.1.1 appeared first on WPCanada.

[WP First Aid]Multisite Wildcard DNS Doesn’t Work?

So you just tried to set up a new Multisite WordPress (sub-domain) installation and the sub-sites are not resolving … what went wrong?!

Following all of the common articles (including one I wrote some time ago) I ran into this problem. Why could I not get any of the sub-sites I created to resolve?

I re-read several articles and my web hosting service’s documentation, everything appeared to be set up correctly. The key to all of this being to ensure “Wildcard DNS” is enabled on the site. There are many tutorials on this you can easily find with your preferred search engine but they all essentially say the same thing: you want to add the * sub-domain to your top level domain ( TLD ), such as, *.example.com

This is where I’m going to get a bit specific (as this may not apply to all web hosting services but it did work in the case of mine, HostGator). I followed their documentation to create the Wildcard DNS sub-domain and it appeared to work correctly. This created a DNS Zone file “A” record pointing sub-domains to the domain’s IP address, but this did not allow the sub-sites to resolve correctly for the Multisite installation.

Wildcard-DNS-A-Record

Looking at the other DNS Zone file records I noted several similar “CNAME” records that were being used for common sub-domains such as “mail”, “www”, and “ftp” … and this became the key to unlocking the problem I was having.

I simply edited the “A” record for the Wildcard DNS and changed it to a “CNAME” record using the same domain as the other records (instead of the IP address) and now everything seems to be working just fine … well, the sub-site domains are resolving. Since this Multisite installation will be used exclusively for testing I suspect many other things will be broken.

Wildcard-DNS-CNAME-Record

This worked for my installation and I suspect it will work for most instances that are similar.
Let me know if it helped you out … or not, in the comments below; or, if you have another working solution, by all means, please share it below, too.

Enjoy!

[WPSNIPP]Create page on theme activation

From: wpsnipp.com
By: Kevin Chard

If you are creating a new theme either for sale of for a client you may want to have it create a custom page or pages when the theme is activated. Adding this snippet to the functions.php of your theme will do just that.

link: Create page on theme activation


Create page on theme activation is a post from: wpsnipp.com - WordPress Snippets, Code, Hacks, 615+ for your wordpress theme or blog.

[WordPress Canada]Gigawatt Updated v1.1.0

The Gigawatt child theme has been updated to version 1.1.0. This is the sixth of our child themes to receive an update since the release of Genesis 2.1.0.

The changes in this update are:

  • As of Genesis 2.1, the Primary Navigation Extras options have been removed for new installs while upgrades of current installs to 2.1 have retained the option. This is actually a good thing. Under the old method you were limited to adding a Twitter or RSS link only. The new method is to add a custom link to the menu then add a CSS Class of right. Of course this means you can now add any link you want, you aren’t limited to just Twitter or your RSS feed. I have replaced Dashicons with Genericons for primary nav custom links. The reason for that is Genericons offer a much larger selection of social icon fonts. Dashicon support remains in other areas of the theme. Refer to the theme docs for details.
  • Genesis 2.1 now includes built-in support for adding a widget area after a post on single post pages by adding just one line of code … add_theme_support( 'genesis-after-entry-widget-area' ); Therefore, I have removed the existing method of adding that particular widget area in favour of the new method.
  • I have renamed the Before Post widget area Before Entry for consistency.
  • Added new Gold colour scheme.
  • Misc style tweaks.

As usual further info including demo and download links can be found on the official theme page.

The post Gigawatt Updated v1.1.0 appeared first on WPCanada.

[WordPress Canada]Marcus Updated v1.2.0

The Marcus child theme has been updated to version 1.2.0. This is the fifth of our child themes to receive an update since the release of Genesis 2.1.0.

The changes in this update are nearly identical to the changes to Malcolm which was updated just hours ago with the exception of a few css adjustments.

As usual further info including demo and download links can be found on the official theme page.

The post Marcus Updated v1.2.0 appeared first on WPCanada.

Planet WordPress Canada theme by WPDesigner, syndication by Pipes, FeedWordPress, and Feedburner, powered by ?