JavaBeat

  • Home
  • Java
    • Java 7
    • Java 8
    • Java EE
    • Servlets
  • Spring Framework
    • Spring Tutorials
    • Spring 4 Tutorials
    • Spring Boot
  • JSF Tutorials
  • Most Popular
    • Binary Search Tree Traversal
    • Spring Batch Tutorial
    • AngularJS + Spring MVC
    • Spring Data JPA Tutorial
    • Packaging and Deploying Node.js
  • About Us
    • Join Us (JBC)
  • Privacy
  • Contact Us

5 Plugins to Post JavaScript Code Snippets on your WordPress Site

October 16, 2016 by Krishna Srinivasan Leave a Comment

Are you a Java developer that runs a tutorial site or writes the occasional tut? If you are, you might be on the lookout for some easy ways to post formatted code snippets into your WordPress posts. Take a look at any of these plugins to learn more about how to easily add JavaScript code (or HTML, CSS, etc) to your posts and tutorials.

1. Code Markup

Code Markup makes it easy to include code snippets in your pages. The plugin can intuitively tell which tags and characters should be displayed as part of the code snippet and which should be rendered as HTML/JavaScript, etc.

2. CodeColorer

CodeColorer is a code snippet plugin that inserts code that is formatted with the appropriate syntax and highlighting depending on the language.

3. Developer Formatter

Developer Formatter uses a highlight system and includes support for over 110 languages, which makes it a one-size-fits-all plugin and reduces the number of plugins you might need for your site if you include tutorials for many different languages.

4. Google Syntax Highlighter

This plugin will highlight your code snippets according to Alex Gorbatchev’s syntax highlighting and supports over 10 languages, including JavaScript, Java, and VB.

5. File Inliner

File Inliner will display the whole content of a file in a WordPress post — perfect to use if your code snippets are particularly long, or if you want to include many elements (<head>, <body>, <scripts>, etc).

Filed Under: CSS, HTML, jQuery, Wordpress Tagged With: Code Markup, CodeColorer, Developer Formatter, File Inliner, Google Syntax Highlighter

WordPress Error: Database Update Required

July 31, 2015 by Krishna Srinivasan Leave a Comment

If you are using WordPress as the blogging platform for your website, it is certain that you will have lot of database related issues periodically. One of the frequent wordpress error is “WordPress has been updated! Before we send you on your way, we have to update your database to the newest version”. Most of the cases this error would occur when you try to access the wordpress admin page. The main site would work without any issues.

The screen would look like below:

Wordpress Error

Immediately you will come to a conclusion that you have to update the database version by clicking on the “Update WordPress Database” button. When you click on the “Update WordPress Database” button, you will get either time out error or blank page. The real issue is that there is a mismatch between two entries which used for specifying the database version number.

How to Fix this error?

It is very simple to fix this error. You just have to update a value in the wp-includes/version.php. Please follow the following steps to correct this error:

  1. Go to /wp-include/ folder and open the version.phpfile.
  2. Find the value for $wp_db_version, and note it down for the comparison.
  3. Now, open your database, check in the table called wp_options
  4. Find the db_version value by executing the below query in the query browser:SELECT option_value FROM wp_options WHERE option_name = 'db_version';
  5. Those two values must be the same.
  6. If the both values are not same, change it in the version.php file, not the database table value.

Now you access your WP-ADMIN page, it should show wonderful screen for you :). Have fun and come back here for more tips on internet technologies.

 

Filed Under: Wordpress Tagged With: Wordpress Tips

W3 Total Cache Configurations

September 16, 2013 by Krishna Srinivasan Leave a Comment

This article is about wordpress plug-in used for improving the performance of this blog. This blog has serious issues on response time. Several readers has reported that, it takes while for loading the site. One of the main challenging issue with using the wordpress platform is tons of plug-in which would drastically impact the performance of website loading time. When I have used the plain website with HTML pages, the response time was very good. But, managing the content is not easy without wordpress like Content Management Systems (CMS). There are few great plug-ins available to improve the performance, but it needs little learning curve to understand the complete configurations to super charge your blog.

W3 Total Cache is one of the greatest plug-in available and it is rated as the best caching plug-in out in the market. It helped me to improve the website loading time drastically and I would like to share some of the configurations used for improving the efficiency. If you have any suggestions, please write it in the comments section. I would explain only few important items which will enhance the performance.

wordpress-logo

1. Install W3 Total Cache

It is very simple to install W3 Total Cache plugin to your wordpress blog. In the plug-in area, search for the “W3 Total Cache” plug-in and you will find this plugin as the first one.

Install W3 Total Cache

Just click on the “Insiall” link and it will install and activate the plug-in. Once the plug-in is installed, list of configurations items will be displayed on the left navigation bar as shown below.

w3 total cache options

2. General Settings

In the general settings tab, all the configurations options would be displayed. This is the page where you have to enable or disable a particular configuration item. It is a summary of all the configurations items. Each configuration items listed on this page has separate tab for the details configurations. In the next sections, I would explains some of the few important configuration sections.

w3-total-cache-general-settings

3. Minify

This is most important section to make the changes. Minify is simply reduces the size of the resources and also compress with the less number of files. Take an example, if you have 10 CSS files to be loaded on one page, requires 10 http requests to download that files which is repeated round trip to the server. Multiple http request would slow down the page loading time. Also learn about the pipelining.

To overcome the above problems, Minify option could effectively reduces the number of files to be downloaded. The following screenshots are the settings for each section under minify.

w3-total-cache-general

w3-total-cache--minify-html

w3-total-cache-css

w3-total-cache-js

3. Browser Cache

This is another place where you can optimize your site for the local cached files. It is reported that, more number of sites loading time is impacted on loading the repeated files. This would have been improved by caching it in the browser. The following are the preferred settings for the each sections. Enable the below options under each section.

General:

  • Set Last-Modified header
  • Set expires header
  • Set cache control header
  • Set W3 Total Cache header
  • Enable HTTP (gzip) compression

CSS & JS:

  • Set Last-Modified header
  • Set expires header (Expires header lifetime : 31536000)
  • Set cache control header (Cache Control policy: Cache with max age)
  • Set W3 Total Cache header
  • Enable HTTP (gzip) compression

HTML & XML:

  • Set Last-Modified header
  • Set expires header (Expires header lifetime : 7200)
  • Set cache control header (Cache Control policy: Cache with max age)
  • Set W3 Total Cache header
  • Enable HTTP (gzip) compression

Media and Other Files:

  • Set Last-Modified header
  • Set expires header (Expires header lifetime : 31536000)
  • Set cache control header  (Cache Control policy: Cache with max age)
  • Set W3 Total Cache header
  • Enable HTTP (gzip) compression

4. Other Configurations

There are many other configurations which can be configured to optimize the performance. But, it is not applicable for all the sites, I am not covering those details here. The above configurations are the only solution for the shared hosting servers. If your website is running on dedicated server, then you have the multiple caching techniques to improve the speed. One of the solution is using the Content Delivery Network (CDN).

I have used several websites to understand these techniques. This may not be the complete guide for configuring this plug-in, if you drop a comment, I would help you in optimizing this plug-in. Or please refer this website inspire2rise.

Once you have made the changes, run the speed test using google speed test. This site is a great tool to see what is the loading time for your site. This also provides suggestion to improve the performance.

Filed Under: Wordpress Tagged With: Wordpress

WordPress for Business Bloggers

October 28, 2009 by Krishna Srinivasan Leave a Comment

WordPress for Business Bloggers

WordPress for Business Bloggers provides advanced strategies and techniques to take
your WordPress business blog from average to extraordinary. Whether you already have
a blog, or are still in the planning stages, this book will show you how to use WordPress
to create a highly successful blog for your business.

The release of version 2.6 has confirmed the status of WordPress as the leading blogging
platform. This book has been written for and tested on WordPress 2.6, so all the
screenshots and tutorials are accurate for users of that version of the software.

This is a practical, hands-on book based around a fictitious case-study blog, which you
will build using a development server on your own computer. The vast majority of
tutorials and examples will be applied to the case study blog. The case study grows
chapter by chapter, from installing your local development server, right up to the finished
blog. You will be installing and configuring a selection of WordPress plugins to improve
the functionality of the case-study blog.

You are provided with clear instructions and detailed screenshots, so you can see exactly
what to do at each step of the build. When you have completed the case study, you will
have the knowledge and confidence to apply all the techniques you have learned to your
own WordPress business blog.

The author assumes you have basic experience with WordPress, already know how to set
up a self-hosted WordPress blog, and are familiar with the basics: creating posts and
pages, configuring blog settings, and so on. By the time you have finished the book you
will have moved forward from WordPress novice to an advanced user of the software in a
business context.

What This Book Covers

In Chapter 1 you will examine many different types of business blogs. You will be
shown a selection of great business blogs and see what you can learn from them.

In Chapter 2 you will be introduced to the case study blog, and taken through the process
of developing strategic goals and your blog plan. You will learn that the planning process
is important, even if your blog is already up and running.

In Chapter 3 you will learn the basics of blog design. You will work through a brief
introduction to HTML and CSS, and see how easy it is to create your own custom design
using the Sandbox theme.

In Chapter 4 you will learn some advanced image and video handling techniques,
including setting up an image gallery and using video from third-party sources, such as
YouTube and Google Video.

Chapter 5 focuses on different techniques and methods required for creating the best
possible content for your business blog.

Chapter 6 covers some of the most important SEO strategies and how to apply them, as
well as how to submit your blog to the search engines.

In Chapter 7 you will learn some advanced blog promotion techniques, including:
advanced RSS with FeedBurner; using Internet Explorer 8 Web Slices; submitting to the
blog search engines, like Technorati; using social networks, such as Facebook and
Twitter; and using social bookmarks, such as Digg and del.icio.us.

In Chapter 8 you will learn the importance of connecting with other bloggers and playing
an active role in the blogosphere to promote your business blog.

In Chapter 9 you will learn how to analyze your blog’s performance using tools such as
Google Analytics and WordPress.com Stats.

In Chapter 10 you will be introduced to a variety of strategies to help you generate
revenue from your blog, like using advertising and affiliate programs.

In Chapter 11 you will learn how to manage the growth of your blog by optimizing it for
high traffic and introducing multiple authors by using WordPress MU.

Content Is King

The title may seem like rather an old cliché now, but it still rings true—content is
king. In this chapter, we will look at issues surrounding content creation, and discuss
some techniques and methods to help you produce the best content you can. We’ve
already looked at visual content, in the form of images and videos, but still for many
web users, blogging is all about text—that’s what we’ll be focusing on here.

We will begin with some general writing tips for bloggers. Although you may be
familiar with some of these already, it’s as well to re-focus your attention on them
and ensure that you are applying them as part of your blogging routine. We then
look at ways of organizing your content in a user-friendly way by using categories
and tags. We will examine the apparently subtle differences between the two and
ensure that you’re using them correctly. We move on to apply categories and tags to
the ChilliGuru case study.

Next, we will look at one of the most important pieces of ‘static’ content on your
blog—the ‘About’ page. It’s vital to get this right as it is so often the first port of call
for new visitors to your blog. We will add an ‘About’ page to ChilliGuru. Finally, we
underline the importance of protecting your precious content by carrying out regular
backups. You will learn how to back up both your WordPress site files and the
all-important MySQL database, which drives your blog.

Blog Writing Tips

The first thing to look at regarding content is the quality of your writing itself. Good
writing takes practice. The best way to learn is to study the work of other good
writers and bloggers, and by doing so, develop an ear for a good sentence. However,
there are guidelines to bear in mind that apply specifically to blogs, and we’ll look at
some of these here.

Killer Headlines

Ask any newspaper sub-editor and he or she will tell you that writing good
headlines is an art to be mastered. This is equally true for blogs. Your headlines are
the post titles and it’s very important to get them right.

Your headlines should be concise and to the point. You should try to convey the
essence of the post in its title. Remember that blogs are often consumed quickly, and
readers will use your post titles to decide if they want to carry on reading. People
tend to scan through blogs, so the titles play a big part in helping them pick which
posts they might be interested in.

Your post titles also have a part to play in search engine optimization (SEO will be
covered in detail in the next chapter). Many search engines will use them to index
your posts.

As more and more people are using RSS feeds to subscribe to blogs it becomes even
more important to make your post titles as descriptive and informative as possible.
Many RSS readers and aggregators only display the post title, so it’s essential that
you convey as much information as possible whilst keeping it short and snappy. For
example, The World’s Best Salsa Recipe is a better post title than, A new recipe.

Length of Posts

Try to keep your posts manageable in terms of their word count. It’s difficult to be
prescriptive about post lengths. There’s no one size fits all rule in blogging. You need
to gauge the length of your posts based on your subject matter and target audience.
There may be an element of experimentation to see how posts of different lengths
are received by your readership. As with headlines, bear in mind that most people
tend to read blogs fairly quickly and they may be put off by an overly long post.
WordPress 2.6 includes a useful word count feature:

An important factor in controlling the length of your posts is your writing skills.
You will find that as you improve as a writer, you will be able to get your points
across using fewer words. Good writing is all about making your point as quickly
and concisely as possible. Inexperienced writers often feel the urge to embellish their
sentences and use long, complicated phrases. This is usually unnecessary and when
you read back that long sentence, you might see a few words that can be cut.

Editing your posts is an important process. At the very least you should always
proofread them before clicking the Publish button. Better still; try to get into the
habit of actively editing everything you write. If you know someone who is willing
to act as an editor for you, that’s great. It’s always useful to get some feedback on
your writing.


	If, after re-reading and editing your post, it still seems very long, it might
	be an idea to split the post in two and publish the second installment a
	few days later.

Post Frequency

Again, there are no rules set in stone about how frequently you should post. You
will probably know from your own experience of other blogs that this varies
tremendously from blogger to blogger. Some bloggers post several times a day and
others just once a week or less.

Figuring out the correct frequency of your posts is likely to take some trial and error.
It will depend on your subject matter and how much you have to say about it. The
length of your posts may also have a bearing on this. If you like to write short posts
that make just one main point, you may find yourself posting quite regularly. Or,
your may prefer to save up your thoughts and get them down in one longer post.

As a general rule of thumb, try to post at least once per week. Any less than this
and there is a danger your readers will lose interest in your blog. However, it’s
extremely important not to post just for the sake of it. This is likely to annoy readers
and they may very well delete your feed from their news reader. As with many
issues in blogging, post frequency is a personal thing. You should aim to strike a
balance between posting once in a blue moon and subjecting your readers to
‘verbal diarrhea’.

Almost as important as getting the post frequency right is fine-tuning the timing of
your posts, that is, the time you publish them. Once again, you can achieve this by
knowing your target audience. Who are they, and when are they most likely to sit
down in front of their computers and read your blog? If most of your readers are
office workers, then it makes sense to have your new posts ready for them when
they switch on their workstations in the morning. Maybe your blog is aimed at
stay-at-home moms, in which case a good time to post might be mid-morning when
the kids have been dropped off at school, the supermarket run is over, and the first
round of chores are done. If you blog about gigs, bars, and nightclubs in your local
area, the readers may well include twenty-something professionals who access your
blog on their iPhones whilst riding the subway home—a good time to post for them
might be late afternoon.

Links to Other Blogs

We’ll examine this in more detail in Chapter 8, but it’s worth fl agging up here, also.
Links to other bloggers and websites are an important part of your content. Not only
are they great for your blog’s search engine findability, they also help to establish
your place in the blogosphere. Blogging is all about linking to others and the
resulting ‘conversations’.

Try to avoid over-using popular links that appear all over the Web, and instead
introduce your readers to new websites and blogs that they may not have heard
of. Admittedly, this is difficult nowadays with so many bloggers linking to each
other’s posts, but the more original you can be, the better. This may take quite a bit
of research and trawling through the lower-ranked pages on search engines and
indices, but it could be time well spent if your readers come to appreciate you as a
source of new content beyond your own blog. Try to focus on finding blogs in your
niche or key topic areas.

Establishing Your Tone and Voice

Tone and voice are two concepts that professional writers are constantly aware of
and are attempting to improve. An in-depth discussion isn’t necessary here, but it’s
worth being aware of them. The concept of ‘tone’ can seem rather esoteric to the nonprofessional
writer but as you write more and more, it’s something you will become
increasingly aware of.

For our purposes, we could say the ‘tone’ of a blog post is all about the way it feels
or the way the blogger has pitched it. Some posts may seem very informal; others
may be straight-laced, or appear overly complex and technical. Some may seem
quite simplistic, while others come across as advanced material. These are all
matters of tone. It can be quite subtle, but as far as most bloggers are concerned,
it’s usually a matter of formal or informal. How you pitch your writing boils down
to understanding your target audience. Will they appreciate informal, first-person
prose or should you keep it strictly third person, with no slang or casual language?
On blogs, a conversational tone is often the most appropriate.

With regards to ‘voice’, this is what makes your writing distinctly yours. Writers who
develop a distinct voice become instantly recognizable to readers who know them. It
takes a lot of practice to develop and is not something you can consciously aim for; it
just happens as you gain more experience. The only thing you can do to help it along
is step back from your writing and ask yourself if any of your habits stand in the way
of clarity.

While you read back your blog posts imagine yourself as one of your target readers
and consider whether they would appreciate the language and style you’ve used.
Employing tone and voice well is all about getting inside their heads and producing
content they can relate to.


	Developing a distinctive voice can also be an important aspect of your
	company's brand identity. Your marketing department may already have
	brand guidelines, which allude to the tone and voice that should be used
	while producing written communications. Or you may wish to develop
	guidelines (such as this) yourself as a way of focusing your use of tone
	and voice.

The Structure of a Post

This may not apply to very short posts that don’t go further than a couple of brief
paragraphs, but for anything longer, it’s worth thinking about a structure. The classic
form is ‘beginning, middle, and end’. Consider what your main point or argument is,
and get it down in the first paragraph. In the middle section expand on it and back
it up with secondary arguments. At the end reinforce it, and leave no doubt in the
reader’s mind what it is you’ve been trying to say.

As we’ve already mentioned, blogs are often read quickly or even just scanned
through. Using this kind of structure, which most people are sub-consciously aware
of, can help them extract your main points quickly and easily.

End with a Question

You may have already applied the ‘beginning, middle, and end’ structure, but that’s
not necessarily the best place to end a post. Many bloggers finish with a question.
This is a great way of soliciting comments. If it’s an interesting or provocative
question, it may persuade those readers who only scanned quickly through your
post to go back and digest it in more detail, so that they can give an answer to your
question and join the debate.

Pages: 1 2

Filed Under: Wordpress

WordPress Plugin Development

October 10, 2009 by Krishna Srinivasan Leave a Comment

WordPress Plugin Development

If you can write WordPress plugins, you can make WordPress do just about anything.
From making the site easier to administer, to adding the odd tweak or new feature, to
completely changing the way your blog works; plugins are the method WordPress offers
to customize and extend its functionality. This book will show you how to build all sorts
of WordPress plugins: admin plugins, Widgets, plugins that alter your post output,
present custom “views” of your blog, and more.

This book focuses on teaching you all aspects of modern WordPress development and
usage. The book uses real and published WordPress plugins and follows their creation
from the idea to the finishing touches, in a series of carefully picked, easy-to-follow
tutorials. You will discover how to use the WordPress API in all typical situations, from
displaying output on the site in the beginning to turning WordPress into a CMS in the last
chapter. In Chapters 2 to 7, you will develop six concrete plugins and conquer all aspects
of WordPress plugin development.

Each new chapter and each new plugin introduces different features of WordPress and
how to put them to good use, allowing you to gradually advance your knowledge. This
book is written as a guide to take your WordPress skills from the very beginning to the
level where you are able to completely understand how WordPress works and how you
can use it to your advantage.

This is a Packt Beginners Guide, which means it focuses on practical examples and has a
fast-paced but friendly approach, with the opportunity to learn by experimentation and
play. Each chapter builds a practical plugin from the ground up using step-by-step
instructions. Individual sections show you how to code some functionality into your
plugin and follow up with a discussion of concepts.

What This Book Covers

Chapter 1 teaches the advantages of WordPress development, and what WordPress has to
offer to plugin authors.

Chapter 2 creates a working, useful, and attractive WordPress plugin from scratch. It
shows how to extract information using the WordPress API and how to use CSS to
improve the look of our plugin.

Chapter 3 explores more cool things we can do with WordPress by livening up the
default WordPress blogroll. The purpose of the plugin is to display the most recent posts
from the sites listed in the blogroll using a nice pop-up window.

Chapter 4 uses the mixed approach, by taking advantage of creative WordPress and
JavaScript techniques, in order to create an Ajax powered ‘Wall’ for your blog’s sidebar.
It introduces quite a few interesting techniques such as Widgets, interacting with the
WordPress Database, and Ajax form submission.

Chapter 5 covers the creation of a very sleek and stylish looking WordPress
enhancement. The purpose of the Snazzy Archives plugin will be to present your site
archives in a unique visual way. It shows how to manipulate the layout of the template
using shortcodes and custom templates.

Chapter 6 is all about digging a little deeper into WordPress and hacking the Write Post
screen. It shows how to create custom panels in the various sections of the Write Post
screen. It teaches how to access the current WordPress rich text editor, tinyMCE, and
create a button on its toolbar.

Chapter 7 explores the possibilities of turning WordPress into a Content Management
System (CMS), using methods provided to us by WordPress. It shows how to modify the
Manage Posts panel to display the information we want. It also covers managing who can
use your plugin by looking at the logged in user capabilities.

Chapter 8 covers the additional steps involved in localizing, documenting, publishing,
and promoting your plugin. It also covers useful tips and ideas to improve your general
WordPress knowledge further.

Social Bookmarking

I hope the first chapter got you warmed up and prepared for WordPress plugin development,
and that you are as eager to start as I am.

In this chapter, we will create our first functional WordPress plugin and learn how to interact
with the WordPress API (this is the WordPress interface to PHP) on the way. The knowledge
you will gain in this chapter alone will allow you to write a lot of similar plugins.

Let’s get moving! In this chapter, you will learn:

  • Creating a new plugin and having it displayed in the plugins admin panel
  • Checking the WordPress version and control activation of the plugin
  • Accessing API features—for example the title and permalink URL of each post
  • Using WordPress hooks to execute your plugin code when it’s needed
  • Using conditional tags to control the fl ow of your plugins

You will learn these by:

  • Creating a ‘social bookmarking’ type of plugin that adds a Digg button to each post
    on your blog
  • As you probably know, Digg is a very popular service for promoting interesting content on
    the Internet. The purpose of a Digg butt on on your blog is to make it easier for Digg users to
    vote for your article and also to bring in more visitors to your blog.

    The plugin we’ll create in this chapter will automatically insert the necessary code to each of
    your posts. So let’s get started with WordPress plugin development!

    Plugging in your first plugin

    Usually, the first step in plugin creation is coming up with a plugin name. We usually want to
    use a name that is associated with what the plugin does, so we will call this plugin, WP Digg
    This
    . WP is a common prefix used to name WordPress plugins.

    To introduce the plugin to WordPress, we need to create a standard plugin header. This
    will always be the first piece of code in the plugin file and it is used to identify the plugin
    to WordPress.

    Time for action – Create your first plugin

    In this example, we’re going to write the code to register the plugin with WordPress ,
    describe what the plugin does for the user, check whether it works on the currently installed
    version of WordPress, and to activateit.

    1. Create a file called wp-digg-this.php in your favourite text editor. It is common
      practice to use the plugin name as the name for the plugin file, with dashes ‘-‘
      instead of spaces.
    2. Next, add a plugin information header. The format of the header is always the same
      and you only need to change the relevant information for every plugin:
    3. 
      	<?php
      	/*
      	Plugin Name: WP Digg This
      	Version: 0.1
      	Description: Automatically adds Digg This button to your posts.
      	Author: Vladimir Prelovac
      	Author URI: http://www.prelovac.com/vladimir
      	Plugin URI: http://www.prelovac.com/vladimir/wordpress-plugins/
      	wp-digg-this
      	*/
      	?>
      

    4. Now add the code to check the WordPress version:
    5. 
      	/* Version check */
      	global $wp_version;
      	$exit_msg='WP Digg This requires WordPress 2.5 or newer.
      	<a href="http://codex.wordpress.org/Upgrading_WordPress">Please
      	update!</a>';
      	if (version_compare($wp_version,"2.5","<"))
      	{
      		exit ($exit_msg);
      	}
      	?>
      

    6. Upload your plugin file to the wp-content/plugins folder on your server using
      your FTP client.
    7. Go to your WordPress Plugins admin panel. You should now see your plugin listed
      among other plugins:
    8. This means we have just completed the necessary steps to display our plugin in
      WordPress. Our plugin can be even activated now—although it does not do
      anything useful (yet).
    9. What just happened?

      We created a working plugin template by using a plugin information header and the
      version check code. The plugin header allows the plugin to be identified and displayed
      properly in the plugins admin panel. The version check code will warn users of our plugin
      who have older WordPress versions to upgrade their WordPress installation and prevent
      compatibility problems.

      The plugin information header

      To identify the plugin to WordPress, we need to include a plugin information header with
      each plugin.

      The header is writt en as a PHP comment and contains several fields with
      important information.

      This code alone is enough for the plugin to be registered, displayed in the admin panel and
      readied for activation.

      
      	If your future plugin has more than one PHP file, the plugin information
      	should be placed only in your main file, the one which will include() or
      	require() the other plugin PHP files.
      

      Checking WordPress versions

      To ensure that our plugin is not activated on incompatible WordPress versions, we will
      perform a simple WordPress version check at the very beginning of our code.

      WordPress provides the global variable $wp_version that provides the current WordPress
      version in standard format. We can then use PHP function version_compare() to
      compare this and our required version for the plugin, using the following code:

      
      	if (version_compare($wp_version,"2.6","<"))
      	{
      		// do something if WordPress version is lower then 2.6
      	}
      

      If we want to stop the execution of the plugin upon activation, we can use the exit()
      function with the error message we want to show.

      In our case, we want to show the required version information and display the link to the
      WordPress upgrade site.

      
      	$exit_msg='WP Digg This requires WordPress 2.6 or newer. <a
      	href="http://codex.wordpress.org/Upgrading_WordPress">Please
      	update!</a>';
      	if (version_compare($wp_version,"2.6","<"))
      	{
      		exit ($exit_msg);
      	}
      

      While being simple, this piece of code is also very eff ective. With the constant development
      of WordPress, and newer versions evolving relatively often, you can use version checking to
      prevent potential incompatibility problems.

      The version number of your current WordPress installation can be found in the footer text
      of the admin menu. To begin with, you can use that version in your plugin version check
      (for example 2.6).

      Later, when you learn about WordPress versions and their diff erences, you'll be able to
      lower the version requirement to the minimal your plugin will be compatible with. This will
      allow your plugin to be used on more blogs, as not all blogs always use the latest version of
      WordPress.

      Pages: 1 2 3 4 5

Filed Under: Wordpress Tagged With: Wordpress Plugin

WordPress 2.7

October 1, 2009 by Krishna Srinivasan Leave a Comment

WordPress 2.7 Complete

Using WordPress, you can easily create dynamic blogs and websites with great
content and many outstanding features. It is an ideal tool for developing blogs and
though it is chiefly used for blogging, it can also be used as a complete CMS for a
regular website with very little effort. You can customize the features, incorporate
your own design, and even write your own plugins with ease. Its versatility and ease
of use has attracted a large, enthusiastic, and helpful community of users. Although
it is easy to get started with WordPress, its full power is not immediately obvious.

If you want to create a powerful, fully featured blog or non-blog website in no time,
this book is for you. This book will help you learn everything WordPress has to offer
from the ground up, so you can build your complete website. You will see many of
WordPress’s hidden powers that will help you build a fully functioning website.

What This Book Covers

Chapter 1—Introduction to WordPress introduces everything about blogging, including
what a blog is, the common terms used in blogging and what they mean, what
WordPress has to offer to a blogger, and why to choose it.

Chapter 2—Getting Started explains the choices of where you can build your
WordPress website, upgrading from an older version of WordPress, and getting
familiar with the WordPress Administration Panel.

Chapter 3—Blogging Your Heart Out covers the complete process of creating new posts
for your blog, including applying categories and tags to your post, using the rich text
editor, and controlling the timestamp. It also includes more advanced options such
as including excerpt and trackbacks. This chapter also covers controlling
commenting and discussion on your blog, as well as keeping out comment spam.

Chapter 4—Pages, Images, Plugins and More… explains that blog posts aren’t the only
content in your blog. You also can control pages of static information, upload and
manage images on your site, keep a list of bookmarked links, and add plugins.

Chapter 5—Choosing and Installing Themes covers how to find and use existing themes
from a variety of reliable websites, how to choose which theme is right for your
website or blog, and the process of installing and using your new theme. This
chapter also covers enabling and using widgets in your theme.

Chapter 6—Developing Your Own Theme covers the process of creating your own
theme from soup to nuts. This includes setting up your design to accommodate
your blogging goals, converting your initial build into an authentic WordPress
theme, creating templates within your theme to serve different purposes for
your blog, making your theme widget-friendly, and sharing your theme with
the WordPress community.

Chapter 7—Feeds and Podcasting explains what feeds are and how to add them to your
WordPress website, tracking subscribers to your blog, and aggregating feeds from
other sources on your blog. This chapter also covers using your WordPress website
to create a podcast. (It’s easy!)

Chapter 8—Developing Plugins and Widgets is for the more advanced user. This chapter
shows you how to create plugins and widgets that will work with any installation of
WordPress. It includes step-by-step instructions so you don’t get lost along the way.

Chapter 9—Community Blogging covers managing and handling a multiuser blog,
including a detailed outline of the roles and capabilities included in WordPress.

Chapter 10—WordPress as a CMS covers from start to finish how to use WordPress to
create a non-blog website. This chapter includes explanations of designing your
theme, setting it up, creating custom pages that display post content in non-blog
ways, customizing the home page to contain dynamic content, and creating a
news page.

Chapter11—Administrator’s Reference covers all of the basic things a WordPress
administrator needs to know from system requirements to detailed step-by-step
instructions on installing WordPress, moving your WordPress website from one
place to another, backing up, common template tags, and basic troubleshooting.

Pages, Images, Plugins, and More

You now have the blog part of your website fully under control. By now you may
have noticed that WordPress offers you a lot more than simply posts, comments,
and categories.

In this chapter, we will explore and control all of the other content types that
WordPress already has. You’ll be able to create static pages that aren’t a part of your
ongoing blog, bookmark links that will drive visitors to your friends, and add and
manage built-in image galleries to display photos and other images. You’ll also learn
how to add plugins, which will enhance the capabilities of your entire website.

Pages

At first glance, pages look very similar to posts. They also have a title and a content
area in which we can write extended text. However, pages are handled quite
differently from posts. Pages don’t have a timestamp, categories, or tags. Posts
belong to your blog, which is meant to be a part of an ongoing expanding section of
your website, and are added regularly. Pages are more static, and the regular parts of
your site that stand alone in a separate part of the site.

When you installed WordPress, a page was automatically created for you
(along with the first post and first comment). You can see it by clicking on the
About link under Pages in the sidebar:

Adding a page

To add a new page, go to your WP Admin and navigate to Pages | Add New, or use
the drop-down menu in the top grey menu by clicking on the arrow next to New
Post
and choosing New Page. This will take you to the Add New Page page:

The minimum you need to do to create a new page is type in a title and some
content. Then click on the blue Publish button, just as you would for a post, and
your new page will appear linked in the sidebar of your website.

You’ll recognize most of the fields on this page from the Add New Post page, and
they work the same for pages as they do for posts. Let’s talk about the one new
section, the box called Attributes.

Parent

WordPress allows you to structure your pages hierarchically. This way, you can
organize your website’s pages into main pages and subpages, which is useful if
you’re going to have a lot of pages on your site. For example, if I was writing this
blog along with three other authors, we would each have one page about us on the
site, but they’d be subpages of the main About page. If I was adding one of these
pages, I’d choose About as the parent page for this new page.

Template

Theme designers often offer alternate templates that can be used for special pages.
The default WordPress theme comes with two templates: Archives and Links. Let’s
try using the Archives template.

Just give your new page a title (for example, Blog Archives) and some content
(for example, Let’s experiment with the archives template). Then choose Archives
from the Template pull-down menu and publish your page. When you go to your
site and click on the Blog Archives link in the sidebar, you’ll see this:

As you can see, your title and content both do not appear, which makes this different
from pages that use the default template (such as the About page that we looked
at earlier). The sidebar is also missing. What does appear are the search box, a list of
blog archives organized by month, and a list of archives organized by subject, that
is, Categories.

This particular template doesn’t appear useful because all of its information is
currently in the sidebar of the rest of the site. However, this shows you the power
of a template. If you’re designing a theme for your own website, you can create any
number of templates that have special content.

The Links template creates a similar page, but it lists all of your links. We’ll discuss
this in more detail later.

Order

By default, the pages in your page list on the sidebar of your blog will be in
alphabetical order. If you want them in some other order, you can specify it by
entering numbers in the Order box for all of your pages. Pages with lower numbers
(0) will be listed before pages with higher numbers (5).

As the WordPress developers acknowledge right on this page, this method of
ordering pages is quite clunky. Luckily, there is a plugin that makes ordering pages
much easier.

You can download this from http://wordpress.org/extend/plugins/pagemash/.

Managing pages

To see a list of all the pages on your website in the WP Admin, navigate to
Pages | Edit in the main menu. You’ll see the Edit Pages page:

By now this list format should begin to look familiar to you. You’ve got your list of
pages, and in each row are a number of useful links allowing you to Edit, Quick
Edit, Delete
, or View the page. You can click on an author’s name to filter the list
by that author. You can use the two links at the top, All and Published, to filter the
pages by status. And you can check boxes and mass-edit pages by using the Bulk
Actions
menu at the top and bottom of the list. You can also search your pages with
the search box at the top.

Links

Word Press gives you a very powerful way of organizing external links or
bookmarks on your site. This is a way to link other related blogs—websites
you like, websites that you think your visitors will find useful, or just any category of
link you want—to your blog. Speaking of categories, you can create and manage link
categories that are separate from your blog categories.

When you installed WordPress, it created the link category Blogroll along with a
number of links in that category. You can see them in your blog’s sidebar as follows:

Adding a new link

Let’s add a new link to the Blogroll category. In your WP Admin, navigate to
Links | Add New. This will take you to the Add New Link page, which has a
number of boxes in which you can add information about your new link. Let’s
look at the first three here:

Of all the fields on this page, it’s the top two that are the most important. You need
to give your link a Name, which is the text people will see and can click on. You also
need to give a Web Address, which is the URL of the website that is linked to your
blog. You can add a description, which will show up when visitors hover over the
link. (Alternatively, you can also choose to have the description show up on the page
below the link.)

Now let’s look at the next two boxes in the following screenshot:

The first box in the screenshot above should look familiar because it’s very similar to
the Categories selection box for posts. Keep in mind that link categories are separate
from post categories. On this page, you will only see link categories. You can assign
a category to the new link that you’re adding or create a brand new category by
clicking on the + Add New Category link. Your links will be organized by the
categories on your website. The second box lets you choose whether your visitors
will be taken to a new window, or a new tab, when they click on the link. I generally
recommend always using _blank when sending people to an external website.

The other boxes on this page are used less commonly. You can use the two new
boxes to specify XFN (XHTML Friends Network) relationships between you and
any individuals you link to.


	Learning more

	If you want to learn more about XFN, take a look at this website:
	http://gmpg.org/xfn/.

The final box at the bottom of this page will allow you to specify:

  • An image that belongs with this link (for example, the logo of the company
    whose site you are linking to)
  • The RSS feed for the website you’re linking to
  • Any notes you have about the site, beyond what you entered into
    the Description box
  • A rating for the site from 0 to 9

To make use of any of these pieces of information, you need to have a theme that
recognizes and makes use of them.

At the top right of the page is a Save box with a checkbox that you can check if you
want to keep the link private, that is, if you don’t want it to show up on your site to
anyone but you. Click on the Add Link button in that box to save your new link.

I added a link for a recipe and food website using this form. I filled in only the first
three boxes as seen in this screenshot:

Now when I save and then re-load my website, I see my new link here:

Managing links and categories

You can ma nage your links just as you manage posts and pages. Navigate to Links
and you will see this:

From here, you can click on the name of a link to edit it, click on the URL to visit it, and
see which categories you’ve chosen for it. Using the View all Categories pull-down
menu, you can filter links by categories, change the order, and do bulk deletes.

Just as with post categories, you can manage and add new link categories on the Link
Categories
page. You can access this page by navigating to Links | Link Categories:

From this page, you can both add a new category using the form at the left and also
manage your existing categories using the table at the right.

Media library

The media library is where WordPress stores all of your uploaded files—images,
PDFs, music, video, and so on. To see your media library, navigate to Media in the
main menu:

This is the now-familiar management table. My media library has only one photo
that I uploaded when I posted about the butternut squash soup recipe. As you can
see from this table, it shows me the following:

  • A thumbnail of the image. If this were another type of media, I’d see an icon
    representing the type of media.
  • The title that I gave the file when I uploaded it, along with the
    format extension.
  • The author.
  • Information about which post or page the file is attached to. This will be
    important when it comes to making an image gallery. The uploaded file will
    be attached to the post or page that you are editing while uploading a file.
  • The number of comments waiting on the attached post or page.
  • The date when the file was uploaded.

If you hover over the row with your mouse, links for Edit, Delete, and View will
appear. You can click on the file’s title or the Edit link to edit the Title, Caption, and
Description. You cannot edit anything else about uploaded files.

You can also add a new file to your media library. Navigate to Media | Add New to
get a page similar to the upload media page that you got while uploading a file for a
post. When you click on the Select Files button and select the file to be uploaded, it
will upload it and then give you the options shown in this screenshot:

Enter a title, caption, and description if you want, and click on the Save all changes
button. Your new item will appear in the media library, which will be unattached to
any post or page. However, you’ll still be able to use what you just uploaded in any
post or page.

To do that, click on the Upload/Insert button as you did before. But instead of
choosing a file From Computer, click on the Media Library tab on the top of the box:

When you click on the Show link that is next to the image you want to use, you’ll get
the same set of options you got after uploading an image. Now you can click on the
Insert into Post button.

Adding an image gallery

You can add an image gallery to any page or post in your website without needing
any kind of plugin for WordPress. The following are the simple steps to do this:

  1. Choose a po st or page for your image gallery.
  2. Upload the images you want in that gallery.
  3. Add the special code to the page or post, and save it.

Let’s get started.

Choosing a post or page

For my food blog, I’m going to create a new page called My Food Photos for my
image gallery. You can always do this on an existing page or post as well. Here’s
my new page:

Note where I have left my cursor. I made sure to leave it in a spot on the page where
I want my gallery to show up, that is, underneath my introductory text.

Uploading images

Now click on the Upload/Insert image icon and upload some photos. Each time you
upload a photo, enter the title and then click on the Save All Changes button. You’ll
be taken to the Gallery tab, which will show all of the photos you’ve uploaded to be
attached to this page:

If you want to up load more photos at this point, just click on the From Computer tab
at the top and upload another photo.

When you’ve uploaded all the photos you want (you can add more later), click on
the Insert gallery button. This overlay box will disappear and you’ll see your post
again. The page will have the gallery icon placeholder in the spot where you left the
cursor, as seen in this screenshot:

If you’re in the H TML view, you’ll see the gallery shortcode in that spot:

Note that because I ‘m uploading these photos while adding/editing this particular
page, all of these photos will be “attached” to this page. That’s how I know they’ll be
in the gallery on this page. Any other photos that I’ve uploaded at other times will
not be included. For example, even though I uploaded the Breakfast Shake photo
once already, I had to upload it a second time so that it would be attached to this
page’s gallery.

Now publish or save your page. Now when you view the page, there’s a gallery of
your images as follows:

Tweaking your gallery

There are a number of tweaks you may want to apply to your gallery.

Adding captions to thumbnails

You may want the cap tions to show up underneath your thumbnails on the gallery
page. To do that, just add captions to the images—go to your media library, edit each
image, and give it a caption. The titles that you give the images will show up in the
page title.

Changing the size of the images in the gallery

By default, the gall ery shows thumbnail versions of your images. If you want, you
can change that to be a medium or large version. You just have to edit the gallery
shortcode. In your WP Admin, navigate to Edit Page for this page (in which we
have placed the gallery) and use the HTML editing mode instead of Visual. Change
your gallery shortcode from

to
. These will
be too wide to fit into three columns, so you should change the number of columns
to 1. To do this, change your gallery shortcode to this:
. Update the page and take another look:

Changing the image page

When you click on on e of your thumbnails on the gallery page, you’ll be taken to
the image page, which shows the medium version of the image along with next and
previous thumbnails as follows:

I find this page to be quite unsatisfactory. The main image is too small and the
thumbnails are too large. In fact, instead of thumbnails, I’d prefer to use text—that is,
just the image titles. Unfortunately, the gallery feature in WordPress is still relatively
new, and they haven’t made these things easy to change. You can change this page to
be better, but it requires you to roll up your sleeves and dig into the code a bit.

To change the image size on this page, you have to change the dimensions of your
medium images on the Media Settings page. (You can access this page by navigating
to Settings | Media). This change will be applied only to the images you upload
after the change. So any images that you’ve already uploaded will keep their current
size unless you delete and re-upload them.

You can find a great explanation for replacing thumbnail navigation links with text
links on Michael Fields‘ blog: http://mfields.org/2008/04/26/adding-textlinks-
to-wordpress-gallery/.

Adding plugins

Plugins are little pa ckages of code that you can add to WordPress to increase its
functionality. Developers all over the world create plugins, some of which you can
use for free, whereas some others are available for purchase.

The steps for instal ling a plugin are simple:

  1. Find your plugin.
  2. Download it.
  3. Upload and activate it.
  4. Configure and/or implement it (if necessary).

Finding your plugin

The best place to find plugins is the WordPress Plugin Directory at
http://wordpress.org/extend/plugins/. There are more plugins every day
(as of this writing, there are nearly 4,245) and millions of downloads (22,152,788
and counting). You can search plugins by topic and by tag, as well as see a list of
the most popular, newest, and recently updated plugins. This is the best available
plugin resource and you should always go here first when looking for a plugin.

You can also do Google searches. I recommend searching for the problem you’re
trying to solve and see what plugins other users recommend and why. Often, there
are multiple plugins that perform similar functions, and you will find the feedback
of other WordPress users valuable in choosing between them.

Downloading the plugin

Let’s install a plugin that I think everyone should have. It’s called WP-DB-Backup
and it adds the ability to easily create a complete database export of your blog. This
offers a more thorough backup than the built-in Export function.

You can download the plugin from this page: http://wordpress.org/extend/
plugins/wp-db-backup/.

Before downloading any plugin, check to see which versions of WordPress
the plugin is supposed to work with. If you’re downloading a plugin from the
Wordpress.org website, you’ll see everything you need to know on the right
side of the page:

This plugin requires Version 2.0.3 or higher and will work with all versions up to 2.7,
so we are safe. Now just click on the orange Download button and save the resulting
ZIP file on your computer where you can find it again.

Uploading and activating the plugin

Unlike with themes, you don’t have to unzip the ZIP file. Just go to your WP Admin
and navigate to Plugins | Add New. There are a lot of things on this page, but just
look for the Install a plugin in .zip format section:

Browse to your plugin and then click on the Install Now button.

If the installation is successful, you’ll get a page telling you that the installation was
successful and giving you the option to activate the plugin right from this page:

Click on the Activate Plugin link and you’re done activating your plugin.

If this automatic uploader doesn’t work for you, you can do this the old-fashioned way:

First extract the ZIP file you downloaded so that it’s a folder, probably called
wp-db-backup.

Using your FTP client, upload this folder inside the wp-content/plugins/ folder
of your WordPress installation. You’ll also see the two plugins that WordPress came
with in that folder—akismet and hello.php.

Now go to your WP Admin and navigate to Plugins | Installed. You’ll see the three
plugins on this page. Just click on the Activate link in the WordPress Database
Backup
row:

Now you are ready for the final step, which is to actually make use of this plugin.

Configuring and/or implementing—if necessary

In the case of this plugin, all you have to do is use it. You’ll have a new link in your
menu that you can navigate to. It’s Tools | Backup. When you go to this page, you’ll
be able to choose which tables to back up. If you’ve installed any plugins that add
additional tables, you’ll have the option to choose them as well; I always do. I also
always check the two boxes to exclude spam comments and post revisions.

You can now decide if you want to save the backup to your server, download it, or
have it emailed to you. I suggest downloading it every time.

There is also an option to schedule regular backups. This is not 100% reliable, so you
should probably set up a reminder to check if your backup has been emailed to you or
not. The frequency you choose should depend on how often you edit your site—once a
week is probably often enough for most people.

For other plugins, the configure and/or implementation step may be different.

  • You may not have to do anything. Some plugins simply change the way
    WordPress does some things, and activating them is all you need to do.
  • You may have to configure a plugin’s details before it begins to work. Some
    plugins need you to make choices and set new settings.
  • There may not be a configuration page, but you may have to add some code
    to one of your theme’s template files.

If you’re unsure of what to do after you’ve uploaded and activated your plugin, be
sure to read the readme file that came with your plugin, or look at the Faq on the
plugin’s website.

Many plugin authors accept donations. I strongly recommend giving donations to
the authors of plugins that you find useful. It helps to encourage everyone in the
community to continue writing great plugins that everyone can use.

Auto-installation

The newest version of WordPress, as of 2.7, offers a way for you to search for,
choose, and install new plugins directly through your WP Admin interface. You can
do this by using the Search area on the Plugins | Add New page. If you already
know what plugin you want, you can type it in and follow the onscreen instructions.
I still recommend that you do your research carefully to be sure that you find the
plugin that you want and that it’s compatible with your version of WordPress. Also,
although most of the great plugins are on WordPress.org, there are still more that
can be found elsewhere on the Web. So be sure to do a thorough search.

Summary

This chapter explored all of the content WordPress can manage that’s not directly
about blogging. You learned about static pages, bookmark links, the media library,
image galleries, plugins, and more.

You are now fully equipped to use the WordPress Admin panel to control all of your
website’s content. Next, you’ll want to control the display. In the next chapter we will
start discussing themes.

Filed Under: Wordpress

Follow Us

  • Facebook
  • Pinterest

As a participant in the Amazon Services LLC Associates Program, this site may earn from qualifying purchases. We may also earn commissions on purchases from other retail websites.

JavaBeat

FEATURED TUTORIALS

Answered: Using Java to Convert Int to String

What is new in Java 6.0 Collections API?

The Java 6.0 Compiler API

Copyright © by JavaBeat · All rights reserved