Understanding the nuts and bolts of WordPress Theme development standards

November 17th, 2014 Blog

Ever since WordPress came into existence, there have been continuous discussions regarding WordPress theme development and the varied options available to developers for building eye-catchy and fully-functional WordPress themes. Well, there’s actually no “one-size-fits-all answer” for the best methods that can be employed to build an outstanding WordPress theme. Through this post, I’ll be allowing you to gather an in-depth insight into the basic understanding of WordPress theme development standards that are being followed by both novice as well as proficient WordPress designers. Hope by the end of this post, you’d be all geared up for designing your all-exclusive WordPress theme that would fit the varied needs of your client.

What’s the need for designing WordPress themes?

Although, WordPress.org serves as a brilliant hub for fine-quality themes that can suit a wide range of websites, designers often opt for designing a unique theme. Well, there are a number of reasons backing the development of new WordPress themes. While some WordPress experts do it for showcasing their creativity, other release it to the public so as to play their individual role in contributing to the widespread WordPress community. There are other WordPress designers who build new themes in the wake of learning more about the popular web technologies including HTML, CSS and PHP.

And now, let me take you on a journey of exploring WordPress Theme Development Standards

1. Picking up a suitable theme development option is vital
Prior to proceeding ahead with the development of a WordPress theme, it is crucial to pick up a suitable option/approach for the same. You can opt for any one of the following WordPress theme development approaches:

  • Building a WP theme from scratch
  • Editing/hacking an existing WordPress theme
  • Using a child theme for making changes to an existing WP theme
  • Create a new parent theme and related child themes
  • Using a WordPress theme development framework
  • Using a theme customizer for moderating an existing WP theme

2. Use of well-structured, error-free PHP and HTML can’t be ignored
One of the most crucial parameters in ensuring flawless WordPress theme development is the use of bug-free PHP and a valid HTML. As a WordPress theme developer, you need to follow all the coding standards that have been defined by the WordPress community. Doing this would allow you to avoid common coding issues, simplify code modification and enhance the readability of code. All in all, following coding standards will ensure that your project files appear as if they have been worked by a single person.

3. Use of clean, valid CSS is unavoidable
Although CSS style-sheets tend to contain certain inconsistencies, it is important to address to the same on an immediate basis. You need to ensure that the CSS code is readable, meaningful and consistent. It’s also beneficial to fill in all the loopholes and commits that have interfered with the originality of the code.

4. Pay attention to proper commending of code
For making other developers understand how you build your theme, it is important to make the theme’s code clear and readable. This can be achieved by commenting the code in an appropriate way. If you’re working with PHP, then I recommend you using PHPDoc- a phpDocumentor that offers a clean, bug-free documentation style for the PHP Code. While on the other hand, if you’re working with CSS, then do visit the WordPress CSS standards page which will offer you brilliant insights on using CSS code the same way as you do it for PHP using the PHPDoc.

5. Don’t forget the localization and internationalization of your WordPress theme
Making your WordPress theme translation-ready is something that can fetch you several applauds from the WordPress community. The WordPress Codex comprises of an elaborate introduction about the coding that needs to be performed for the localization and internationalization of WordPress themes. You can visit the Files and Tools page available in the Core Contributor Handbook for gathering handy tips and tricks on developing a multilingual WordPress theme.

6. Adherence to WordPress theme design guidelines is beneficial

If you want your WordPress theme to stand out from the crowd, its necessary for you to follow all the design guidelines that have been laid down by the WordPress community. Whether its about adding a navigation menu, developing a color scheme, formatting data and time, designing headlines, wrapping text around images, dynamic menu highlighting or playing with fonts; you must be well acquainted with everything that needs to be done on the theme’s designing part.

7. Testing the theme is something you can’t afford to miss
Before releasing your WordPress theme for the public, its important to test the same for any kind of un-attented bugs. You can visit the WordPress Theme Review Guidelines page where you can find the best practices of testing WordPress themes for high performance.

Wrapping Up

WordPress Theme Development isn’t that complicated as it seems to be. With a proper understanding of all the ins and outs regarding WordPress theme design and development, you can definitely come up with a theme that’s both eye-catchy as well as loaded with user-friendly functionality.

Author Bio

Ben Wilson is a WordPress developer and senior editor at WordPrax Ltd., PSD to WordPress conversion service company. He has shared many articles on WordPress related things.

Share This | Read on | 1 Comment


Theme Update: iPin Pro v2.0

October 27th, 2014 Blog

iPin Pro has been given a major revamp aesthetically. Version 2.0 now has a modern flat design and better responsive support for mobile devices.

New features for iPin Pro: WordPress Pinterest Clone Theme

  • Bootstrap 3.2
  • Fontawesome 4.2
  • User profile cover
  • Popup notifications
  • Bookmarklet can fetch background-image

Guide for Upgraders

There are some important changes to note in v2.0. Current users should read through the following before upgrading.

  1. Download the latest version at here.
  2. Backup your files and database.
  3. Upload all theme files (overwrite any existing files). If you have modified any files, you will need to re-apply the changes to the new files later.
  4. If using the WordPress Social Login plugin, update to latest version (v2.2.2 as of this writing). After updating, go to WP-Admin > Settings > WP Social Login > Widget tab > simply click “Save Settings”.
  5. Frontpage image size: is now 235px by 4096px (previously 200px by 4096px). Go to WP-Admin > Settings > Media > set “Medium size” to 235 x 4096. If you want to retain your current frontpage image size, skip this step and in style.css, replace 235px with your current frontpage image size e.g 200px.
  6. Single post image size: is now 700px by 4096px (previously 520px by 4096px). Go to WP-Admin > Settings > Media > set “Large size” to 700 x 4096.
  7. Regenerate the images with Ajax Thumbnail Rebuild plugin (select medium, large & Only rebuild featured images) (Or select large & Only rebuild featured images if you skip step 5).
  8. Logo height is now 50px tall (previously 40px). If you are using a logo, go to WP-Admin > Appearance > Theme Options > upload a new logo for “Header Logo Image”.
  9. Dropdown from top menu is now single column by default. If you need to set double columns, see this guide.
  10. Single posts now only have a right sidebar. If need to, rearrange your widgets for the sidebar at WP-Admin > Appearance > Widgets.
  11. Register page’s permalink is now /signup/ (previously /register/). Theme will auto update the permalink but double-check that the signup page is accessible.
  12. Add Pin page’s permalink is now /itm-settings/ (previously /pins-settings/). Again theme will auto update the permalink but double-check that the add pin page is accessible. To retain your current Add Pin page permalink, go to WP-Admin > Pages > select “Item Settings”. Change permalink to your current Add Pin page permalink e.g pins-settings. Then replace all instances of itm-settings with pins-settings in header.php, index-masonry-inc.php, page_cp_pins.php, single-pin.php, ipin.custom.js and ipinit.js.
  13. Add Board page’s permalink is now /grp-settings/ (previously /boards-settings/). Again theme will auto update the permalink but double-check that the add board page is accessible. To retain your current Add Board page permalink, go to WP-Admin > Pages > select “Group Settings”. Change permalink to your current Add Board page permalink e.g boards-settings. Then replace all instances of grp-settings with boards-settings in author.php, header.php, search.php, sidebar-right.php, single-pin.php and taxonomy-boards.php.
  14. Clear any Cache/Minify/CDN plugins you may have installed. Also clear the browser cache.
Share This | Read on | 1 Comment


Theme Update: iPin Pro v1.8

May 27th, 2014 Blog

New features for iPin Pro: WordPress Pinterest Clone Theme

  • Fontawesome 4.1
  • Masonry 3.1.5
  • SoundCloud support
  • Top users page and badges
  • Advanced search by categories, max price, min price and sort options
  • Popup login form when visitors click on repin/like/comment button
  • Microdata support
  • Display ‘pending review’ pins to contributors
  • Can reassign posts to another user when deleting user in WP-Admin backend
  • Option: show/hide repins on front, categories and tags page

Notes for upgraders

  • Download the latest version at here
  • To upgrade, upload all files (and overwrite existing files). If you have modified any files, you will need to re-apply the changes to the new files. Then go to WP-Admin > Appearance > Theme Options > click Save Options (even if you didn’t change any options). Do backup your files/database and after upgrade, clear your browser/wordpress cache.
Share This | Read on | 7 Comments


Another Elegant Themes Giveaway – 3 Lifetime Access Accounts Worth $249 Each!

May 22nd, 2014 Blog

[Update 28/5] Congrats to the winners. Mitch from ElegantThemes will be in touch with you on claiming the giveaway. Also a thank you to all for participating!

divi-tools

ElegantThemes has followed up with a major v2 realease of the Divi WordPress theme. In celebration of the new Divi theme v2, ElegantThemes is giving away 3 Lifetime Access accounts which are valued at $249 each. With a Lifetime Access account, you get access to all their themes and plugins with updates and support forever!

How to Participate

divi-giveaway-wide

To enter the contest, all you need to do is Tweet using the raffle widget below. The contest ends next Wednesday (28/5), and you can re-tweet each day to enter another ticket into the raffle.

All 3 winners will be selected randomly at the end of the giveaway. Good luck!

a Rafflecopter giveaway

Share This | Read on | No Comments


Theme Update: iPin Pro v1.7

February 8th, 2014 Blog

Changelog for iPin Pro: WordPress Pinterest Clone Script

  • Notification center
  • Allow login using email
  • Autocomplete tags
  • Search by tags
  • Popular page category filter
  • Facebook Share button
  • Fetch avatar with WP Social Login (Facebook & Twitter only)
  • Option: Facebook comments
  • Option: reCaptcha in login/register form
  • Option: user can delete own account
  • Option: header/footer scripts

Download the latest version at http://ericulous.com/product-download-for-verified-buyers/

Notes for upgraders

  • To upgrade, upload all files (and overwrite existing files).
    If you have modified any files, you will need to re-apply the changes to the new files.
    Then go to WP-Admin > Appearance > Theme Options > click Save Options (even if you didn’t change any options)
    Do backup your files/database and after upgrade, clear your browser/wordpress cache.
Share This | Read on | No Comments


iPin Pro: Compatibility with WordPress 3.8

December 16th, 2013 Blog

[Update] Bug fixed in WordPress 3.8.1

iPin Pro v1.6.1 is mostly compatible with WordPress v3.8.
However a bug in WP 3.8 causes the sideblog to not display any posts.
WP Bug #26627:
Regression: get_queried_object no longer working with pre_get_posts and pretty permalinks

To patch the bug, edit the WordPress core file /wp-includes/query.php, replacing

				
				$term = get_term( $this->get( 'cat' ), 'category' );

with

				if ( $this->get( 'cat' ) ) {
					$term = get_term( $this->get( 'cat' ), 'category' );
				} elseif ( $this->get( 'category_name' ) ) {
					$term = get_term_by( 'slug', $this->get( 'category_name' ), 'category' );
				}

The bug has been marked as consideration for WP 3.8.1 so it will likely be patched in the next release.

Share This | Read on | No Comments


Elegant Themes Giveaway – 3 Lifetime Access Accounts Worth $249 Each!

December 12th, 2013 Blog

[Update 17/12] Congrats to the winners. Mitch from ElegantThemes will be in touch with you on claiming the giveaway. Also a thank you to all for participating!

elegant_themes_giveaway

ElegantThemes have just released the highly anticipated Divi WordPress theme. In celebration of the new Divi theme, ElegantThemes is giving away 3 Lifetime Access accounts which are valued at $249 each. With a Lifetime Access account, you get access to all their themes and plugins with updates and support forever!

How to Participate

To enter the contest, all you need to do is Tweet using the raffle widget below. The contest ends next Tuesday (17/12), and you can re-tweet each day to enter another ticket into the raffle.

All 3 winners will be selected randomly at the end of the giveaway. Good luck!

a Rafflecopter giveaway

Share This | Read on | 4 Comments


How to Use Your Own Images for Social Media Sharing Buttons

December 4th, 2013 Blog

For Facebook Share button
« click to try

<a href="" onclick="window.open('https://www.facebook.com/sharer/sharer.php?u=' + encodeURIComponent('<?php the_permalink(); ?>'), 'facebook-share-dialog', 'width=626,height=500'); return false;"><img src="http://your-domain.com/fb-share.png" /></a>

For Twitter Tweet button
« click to try

<a href="" onclick="window.open('http://twitter.com/share?url=<?php the_permalink(); ?>&text=<?php the_title_attribute(); ?>', 'twitter-share-dialog', 'width=626,height=500'); return false;"><img src="http://your-domain.com/tweet.png" /></a>

For Google Plus +1 button
« click to try

<a href="" onclick="window.open('https://plus.google.com/share?url=<?php the_permalink(); ?>', 'gplus-share-dialog', 'width=626,height=500'); return false;"><img src="http://your-domain.com/googleplus.png" /></a>

For Pinterest Pin It button
« click to try

<a href="" onclick="window.open('http://pinterest.com/pin/create/button/?url=<?php echo rawurlencode(get_permalink()); ?>&media=<?php echo rawurlencode(wp_get_attachment_url(get_post_thumbnail_id($post->ID))); ?>&description=<?php the_title_attribute(); ?>', 'pinterest-share-dialog', 'width=626,height=500'); return false;"><img src="http://your-domain.com/googleplus.png" /></a>

For Reddit Submit button
« click to try

<a href="" onclick="window.open('http://www.reddit.com/submit?url=' + encodeURIComponent('<?php the_permalink(); ?>') + '&title=<?php the_title_attribute(); ?>', 'reddit-share-dialog', 'width=880,height=500'scrollbars=1); return false;"><img src="http://your-domain.com/reddit.png" /></a>

Notes
1. Remember to replace the text in bold with your own image url
2. Credit: icons from Social Media Circles Icon

Share This | Read on | No Comments


Theme Update: iPin Pro v1.6.1

October 25th, 2013 Blog

A minor update for iPin Pro theme to be compatible with the newly released WordPress v3.7, which mainly broke the register, lost password page. Download the latest version at http://ericulous.com/product-download-for-verified-buyers/

Notes for upgraders

  • Changed files from v1.6 to v1.6.1
    – style.css (only the version number 1.6 to 1.6.1)
    – page_cp_register.php
    – page_cp_login_lpw.php
    – page_cp_settings.php
  • To update, upgrade to WordPress v3.7 first. Them upload the theme files (and overwrite existing files). If you have modified any files, you will need to re-apply the changes to the new files.
  • iPin Pro v1.6.1 is not backward compatible with WordPress v3.6.1 and below.
Share This | Read on | 14 Comments


Videos: Bookmarklets for iPin Pro WordPress Theme Pinterest Clone

October 22nd, 2013 Blog

These videos demonstrates how to install and use the pinterest clone wordpress theme bookmarklet in various browsers to grab images from websites or videos from Youtube or Vimeo.

For Google Chrome

For Firefox

For Microsoft Internet Explorer

For Apple Safari

Share This | Read on | No Comments


Browser Addons/Extensions Pack for iPin Pro

September 18th, 2013 Blog

ipinpro-browser-addon-no-chrome

Complementary to the iPin Pro pinterest clone theme, the Browser Addons/Extensions Pack allows your users to install a “Pin It” extension to their browsers.

Support major browsers on both Windows and Mac:

  • Firefox
  • Internet Explorer
  • Apple Safari
  • Demo

    You will be given a widget code which displays the button as below. When a user click the button, it will auto detect what browser the user is using and install the appropriate extension.

    Give it a try. Clicking the button will install the Pin It button, which allows you to pin images to the iPin Pro demo at http://ipinprotheme.com

    Purchase/Download

    Add to Cart – $15

    Only available to verified buyers. After purchase, open a ticket at http://ericulous.com/support/ with the following info:

    1. Site title e.g iPin Pro
    2. Mouseover text when hover over button e.g Pin to iPin Pro [screenshot]
    3. Full theme directory url e.g http://ipinprotheme.com/wp-content/themes/ipinpro/
    4. Button image (128 x 128px): if image is not provided, the default image will be used.

    After submission, you will receive the widget code within 72 hours.

    Faqs

    Do I need this to run iPin Pro theme?
    No, this is an addon pack and the theme runs just fine without it. In fact the theme has a built-in “Pin It” bookmarklet which offers similar functionality. This addon pack offers an alternative for your users, who may prefer using a browser extenstion to pin images. It may also help with your branding as the extension can display an icon whereas the bookmarklet can’t.

    Will the source code be provided?
    No. The source code for the addons/extensions will not be provided.

    What if I change my theme directory or domain name?
    Please open a ticket with the new details as the addons/extensions needs to be recompiled.

Share This | Read on | No Comments


How to Upgrade from iPin Free Version to iPin Pro

September 16th, 2013 Blog

Ready to upgrade and add more Pinterest functionality with iPin Pro?
The steps may also work for other themes.

Steps

  1. Backup your database just in case
  2. Activate iPin Pro theme and go through the installation instructions
  3. Skip this step if you have set Featured Images for your posts in previous theme. Otherwise automatically set the Featured Images using the free Auto Post Thumbnail plugin.
  4. Download the upgrade script (requires login) and upload to the ipinpro theme directory (/wp-content/themes/ipinpro/)
  5. Run the script at http://yourdomain.com/wp-content/themes/ipinpro/script-upgrade-ipin-to-ipin-pro.php.

Special Notes

  • WordPress Multisite mode must be disabled
  • Post with multiple categories: in iPin Pro, a post is assigned to a board, and the board is in turn assigned to a single category, like what Pinterest.com does. So the upgrade script will use the first category name to create the board. The other categories are dropped. For example, if a post has 3 categories: Humour/Kid/Video, a Humour board will be created and the post will be assgined to the Humour board. The Kid and Video categories are dropped.
Share This | Read on | 8 Comments


Themefuse Giveaway: 3 Free Themes Worth $49-99 Each

July 24th, 2013 Blog

[Updated: 30/7] Congrats to the winners. Olga from Themefuse will be in touch with you guys. Thanks everyone for participating.

Themefuse Giveaway (wide)

If you own a blog or website and are in need of a great new theme, you’ve come to the right place. ThemeFuse has decided to give away 3 WordPress themes free design templates this week!

If you use WordPress, this contest is perfect for you! The winners will get one of three free themes from ThemeFuse to use however they would like. If you want a chance to win, keep reading.

Here is how you can qualify:

1. Simply comment on this post and say what you would do if you won the free theme.

2. Get social and spread the news on Twitter: Win a free copy of @ThemeFuse #WordPress Theme from @[your Twitter] (RT to Enter)

3. Like us on Facebook.

It’s so easy, so go ahead and enter today! In only one week we will be announcing the winners, so don’t waste another second!

Want to know a little bit more?

Well, when looking for great themes and designs, ThemeFuse is the place to go. With all sorts of WordPress templates, it is easy to find just what you need with very little effort. Besides, their themes are not only outstanding to look at but also very simple to use. The features and everything else are crafted with a lot of care when it comes to the source codes and whatnot.

On top of that, their website has a very convenient Support Forum and the FAQ section to help answer any additional questions you might have.

Wondering what kinds of themes are available? Well, here are a few great samples of WordPress templates created by ThemeFuse.

HomeQuest – Real Estate WordPress Theme

Real estate brokers and more, this is your theme for sure. This template is classy and bold for that perfect “SOLD” look.
Real Estate WordPress Theme

NewsSetter – News WordPress Theme

With a very sleek and professional look to it, this template will fit all your needs if you run a technology review site or a news release blog. News WordPress Theme

The Muse – Inspiration WordPress Theme

A minimalist inspiration WordPress theme for anyone that wants to start his own blog and believes that content is king.

Inspiration WordPress Theme

Just Married – Wedding WordPress Theme

For those adorable lovebirds, this super sweet wedding theme is just right.
Wedding WordPress Theme

Welcome Inn – Hotel WordPress Theme

If you are in the hotel business, take a look at this awesome template. There are also other variations to fit your needs.
Hotel WordPress Theme

And by the way ThemeFuse has a cool new product launched in partnership with a trusted hosting company. They offer hosting that comes with a free domain and on top of that they do all the set up and handle all the installs for you for free. You’ll get your website in a matter of minutes. Find out more about this amazing product.

You have just spent more time reading this than it would take to actually qualify for the contest. So, what are you waiting for? Enter to win a free ThemeFuse theme today! You’ll be glad you did!

Share This | Read on | 2 Comments


Elegant Themes Giveaway – 3 Developer Accounts Worth $89 Each!

May 15th, 2013 Blog

[Updated: 22/5] Congrats to the 3 winners. Mitch from ElegantThemes will be in touch with you guys. Thanks everyone for participating.

Header

ElegantThemes is giving away 3 Developer Accounts which are valued at $89 each! With a Developer Account, you get access to all their themes and plugins with updates and support for a full year.

How to Participate

To enter the contest, all you need to do is like our page on Facebook or follow us on Twitter via the widget below. You can also comment or tweet what is your favorite Portfolio WordPress Themes? The contest ends next Wednesday (22/5), and you can re-tweet each day to enter another ticket into the raffle by revisiting this post and using the widget below!

All 3 winners will be selected randomly at the end of the giveaway. Good luck!

a Rafflecopter giveaway

Share This | Read on | 17 Comments


Upload Multiple Photos for iPin Pro Theme

February 19th, 2013 Blog

Multiple Upload Plugin for iPin Pro theme

For every photo uploaded thru WordPress media uploader, the original Automatic Featured Image Posts plugin creates a new post and set the featured image. I’ve modified the plugin so that it will also assign a board to the newly created post for iPin Pro theme. Useful for uploading multiple photos from your computer.

Note that this only work for the admin with user ID 1. And you must deactivate this plugin when done batch uploading. Otherwise there will be double posting when adding pins (only user ID 1, other users are not affected). Tested on WP3.5.1.

Download

Download Plugin (Free for iPin Pro theme users. Requires login.)

Faqs

How can I allow other users to upload multiple photos?
Unfortunately there’s no easy way as this plugin has a site wide effect of double posting for other users. If you need to temporarily allow another user to do multiple uploading, you can modify the plugin. In automatic-featured-image-posts.php, replace the user id in

if (current_user_can('administrator') || $current_user->ID == 1)

and

if ($current_user->ID != 1)

and

$parent_board_id = get_user_meta(1, '_Board Parent ID', true);

amd

echo '- Only works for User ID: 1<br />';

Then you and the other user will need to coordinate with each other

  1. You go to WP-Admin > Users > All Users > Change the Role for the other user to Editor (if other user is not already an editor)
  2. Other user go to WP-Admin > Settings > Auto Image Posts > Select the Default Board
  3. Other user go to WP-Admin > Media > Add New > Upload his photos
  4. When other user is done, ask him not to upload any photo until you deactivate the plugin
  5. You deactivate the plugin and change back his role in step 1 if necessary
Share This | Read on | 2 Comments


OneNews Premium Theme: Auto Generate Daily Archives

November 29th, 2012 Blog

The OneNews Premium Theme already allows you to create multiple pages of feeds. With this hack you can create daily snapshots for each onenews feeds page. In a year you will have 365 pages for each page. Automagically. View live demo at http://ericulous.com/onenews/archives/. The idea is to copy the index.html files generated by WP Supercache and archive them in an “Archives” directory daily.

1. First you need to install and activate the WP Supercache plugin.

2. In themes/onenewspremium/functions.php, add the following just before the last line “?>”

function dailyarchives() {
	global $wpdb;
	$siteurl = trailingslashit(strtolower(str_replace('http://', '', site_url())));
	$filedir = WP_CONTENT_DIR . '/cache/supercache/' . $siteurl;
	
	//remove if don't want to display homepage archives
	//archive homepage
	if (!is_dir(ABSPATH . 'archives/')) {
		mkdir(ABSPATH . 'archives/');
		mkdir(ABSPATH . 'archives/homepage/');
	}

	$oldfile = $filedir . 'index.html';
	if (file_exists($oldfile)) {
		$newfile = ABSPATH . 'archives/homepage/homepage_' . strtolower(date('Y_m_d')) . '.html';
		copy($oldfile, $newfile) or die("Unable to copy $old to $new.");
	}
	//end archive homepage
	
	//archive onenews subpages
	$onenewspages_query = 'SELECT ' . $wpdb->prefix . 'posts.post_name
		FROM ' . $wpdb->prefix . 'posts,' . $wpdb->prefix . 'postmeta
		WHERE ' . $wpdb->prefix . 'posts.post_type = "page"
		AND ' . $wpdb->prefix . 'postmeta.meta_key = "_wp_page_template"
		AND ' . $wpdb->prefix . 'postmeta.meta_value = "page_onenews.php"
		AND ' . $wpdb->prefix . 'postmeta.post_id = ' . $wpdb->prefix . 'posts.ID
		ORDER BY ' . $wpdb->prefix . 'posts.ID ASC
		';

	$onenewspages = $wpdb->get_results($onenewspages_query);

	if ($onenewspages) {
		foreach ($onenewspages as $onenewspage) {
			$oldfile = $filedir . $onenewspage->post_name . '/index.html';
		
			if (file_exists($oldfile)) {
				if (!is_dir(ABSPATH . 'archives/' . $onenewspage->post_name . '/')) {
					mkdir(ABSPATH . 'archives/' . $onenewspage->post_name . '/');
				}
			
				$newfile = ABSPATH . 'archives/' . $onenewspage->post_name . '/' . $onenewspage->post_name . '_' . strtolower(date('Y_m_d')) . '.html';
				copy($oldfile, $newfile) or die("Unable to copy $old to $new.");
			}
		}
	}
	//end archive onenews subpages
}
add_action('dailyarchives_hook', 'dailyarchives');

if (!wp_next_scheduled('dailyarchives_hook')) {
	wp_schedule_event(time(), 'daily', 'dailyarchives_hook');
}

3. In themes/onenewspremium/ direcotry, create a new file named “page_archives.php” and paste the following code (skip this step if you have OneNews v3.2)

<?php
/*
Template Name: OneNews Archives
*/
?>

<?php get_header(); ?>
<div id="postbody">
	<div id="postwrapper">
	<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    
		<div <?php post_class() ?> id="post-<?php the_ID(); ?>">
          	<div class="postcontent">
				<h2 class="posttitle"><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php printf( esc_attr__( 'Permalink to %s', 'onenews' ), the_title_attribute( 'echo=0' ) ); ?>"><?php the_title(); ?></a></h2>
				<hr />
				<?php
				if ($_GET['i']) {
					$dir = ABSPATH . 'archives/' . $_GET['i'];
					
					if (is_dir($dir)) {
						$files = scandir($dir, 1);
						
						if($files) {
							foreach ($files as $file) {
								if ($file != '.' && $file != '..') {
									$linktitle = str_replace('.html', '', $file);
									$linktitle = str_replace('_', ' ', $linktitle);
									$linktitle = str_replace('- ','-',ucwords(str_replace('-','- ',$linktitle)));
									echo '<p>&raquo; <a href="' . network_home_url('/') . 'archives/' . esc_attr($_GET['i']) . '/' . $file . '">' . $linktitle . '</a></p>';
								}
							}
						}
					} else {
						_e('No archives found.', 'onenews');
					}
				} else {
					?>
					<!-- remove if don't want to display homepage archives -->
					<p>&raquo; <a href="<?php echo get_permalink() . '?i=homepage'; ?>">Homepage</a></p>
					<!-- display homepage archives -->

					<?php
					$onenewspages_query = 'SELECT ' . $wpdb->prefix . 'posts.post_title, ' . $wpdb->prefix . 'posts.post_name
						FROM ' . $wpdb->prefix . 'posts,' . $wpdb->prefix . 'postmeta
						WHERE ' . $wpdb->prefix . 'posts.post_type = "page"
						AND ' . $wpdb->prefix . 'postmeta.meta_key = "_wp_page_template"
						AND ' . $wpdb->prefix . 'postmeta.meta_value = "page_onenews.php"
						AND ' . $wpdb->prefix . 'postmeta.post_id = ' . $wpdb->prefix . 'posts.ID
						ORDER BY ' . $wpdb->prefix . 'posts.post_title ASC
						';
				
					$onenewspages = $wpdb->get_results($onenewspages_query);

					if ($onenewspages) {
						foreach ($onenewspages as $onenewspage) {
						?>
						<p>&raquo; <a href="<?php echo get_permalink() . '?i=' . $onenewspage->post_name; ?>"><?php echo esc_attr($onenewspage->post_title); ?></a></p>
						<?php
						}
					}
				}
				?>
			</div>
		</div>
        
        <div class="clearer"></div>
		
		<?php endwhile; endif; ?>
	</div><!-- END POSTWRAPPER -->
    
	<?php get_sidebar(); ?>
	
	<div style="clear:both"></div>
</div> <!-- END POSTBODY -->
<?php get_footer(); ?>

4. Go to WP-Admin > Pages > Add New (Enter “Archives” for Title and select “OneNews Archives” in the Template dropdown menu. If you get a “Forbidden Error” viewing the Archives page, change the slug to “archive” (see pic).

5. Go to WP-Admin > Appearance > Menus (Add the newly created Archives page to your top menu)

Notes: For this hack to work properly, WP Supercache must have the super cached index.html files generated for copying. When your site is new and not many visitors yet, WP Supercache may not have the files ready. Try turning on the Preload Mode to automatically generate the super cached files. May have to wait a day or two for the archives to start showing.

Share This | Read on | 16 Comments


OneNews Premium Theme – Recommended Settings for WP Super Cache

November 19th, 2012 Blog

These settings works well for me. Feel free to tweak and adapt for your own OnewNews site.

Under Advanced Tab

Select the following options:
– Cache hits to this website for quick access.
– Use mod_rewrite to serve cache files.
– Don’t cache pages for known users.
– Cache rebuild. Serve a supercache file to anonymous users while a new file is being generated.
– Extra homepage checks. (Very occasionally stops homepage caching)

Expiry Time & Garbage Collection
– Cache Timeout: 1800
– Scheduler: Timer: 600

Under Preload Tab

– Refresh preloaded cache files every 30 minutes
– Preload all posts
– Select Preload mode (garbage collection only on legacy cache files.)

Extra

WP Super Cache Preload strangely does not “preload” the homepage. Only the single posts and pages are preloaded. So we have to setup cPanel cron to hit our homepage manually. Why 0,1 & 30,31? It seems to take 2 hits for supercache to properly preload and clear garbage.

  1. Login to your webhost cPanel at http://your-domain.com/cpanel
  2. Select the “Cron jobs” icon
  3. For the first job, enter
    • Minute: 0,1,30,31
    • The rest: *
    • Command: wget -q -O – http://your-website.com/wp-cron.php?doing_wp_cron
  4. For the second job, enter
    • Minute: 2,32
    • The rest: *
    • Command: wget -q -O – http://your-website.com/

Note 1: Some webhost disables the wget command. Check with your webhost.
Note 2: WP Super Cache only serves the preloaded supercached pages to unknown users, meaning you need to logout of WordPress to see them.

Share This | Read on | 16 Comments


Giveaway Contest: Free ElegantThemes Membership!

May 21st, 2012 Blog

[Update 26/5]
Thank you all for participating. Congratulation to the winners for the Elegant Themes Membership.
I will be sending the winners’ email to Nick and he will in be touch with the winners shortly.
Thanks again to Elegant WordPress Themes for the wonderful prizes!

The Winners:
Dimitar Tsonev: favorite theme – AskIt
James: favorite theme – TheStyle

Nick from ElegantThemes is giving away 2 ElegantThemes memberships to Ericulous readers! Get free access to all current 76 Premium WordPress Themes (with more coming).

The Prize

2 x Memberships worth $39/year each

How to Participate

Simply browse through the ElegantThemes Gallery on Ericulous. Then leave a comment to this post about your favorite theme e.g “My favorite theme is the Chameleon.”

2 winners will be selected by random.org on 26 May 2012 and notified via email. Good luck and comment away!

Share This | Read on | 13 Comments


Redirect Gallery Image Links in RSS Feed to Parent Post

January 4th, 2012 Blog

rss-gallery

When using the [ gallery ] shortcode, the individual photos are linked to the photo attachment page in the rss feed e.g when your visitors click on the above first photo in Google Reader, they are brought to the thumbnail attachment page (http://ericulous.com/demo/2007/07/19/full-of-images/attachment/01/). Which may be confusing to your visitors if your theme does not have a nicely formatted attachment.php file.

The [ gallery link=file ], which should open the full image directly, also doesn’t work. Not ideal either as I prefer my visitors to view my post rather than simply view all the images from Google Reader. In this case, I would rather they be redirected to the parent post (http://ericulous.com/demo/2007/07/19/full-of-images/).

So I created a new file – attachment.php in my theme directory and insert the following code. If your theme directory already have a attachment.php, you can insert the code in the very first line.

<?php
header( 'location:' . get_permalink( $post->post_parent ) );
?>

Share This | Read on | 1 Comment


Themes affected by TimThumb Zero Day Vulnerability

August 5th, 2011 Blog

You probably heard of the TimThumb Zero Day Vulnerability by now and unfortunately (or fortunately) only 2 of my themes (HackerWP and Celebrity Gossip) uses the TimThumb script for generating thumbnails. The fix is pretty easy.

1. Go to your theme cache directory (e.g /wp-content/themes/hackerwp/cache) and delete all files except index.htm
2. Download the latest version of timthumb.php and replace the file on your server at /wp-content/themes/hackerwp/timthumb.php
3. Optional: If you wish to grab image files from all external sites. Open timthumb.php, look for

$allowedSites = array (
'flickr.com',
'picasa.com',
'img.youtube.com',
);

and replace with

$allowedSites = array (
'*',
);

Share This | Read on | 4 Comments


Scroll
to Top