• Home
  • Contact Me
  • Forum
  • Podcast
WordPress Tavern
Where Every Drink Is On The House
Browse: Home / vladimir prelovac
Talking WordPress With Vladimir Prelovac

Talking WordPress With Vladimir Prelovac

By Jeffro on May 7, 2009

vladimirlogoBack on episode 47 of WordPress Weekly, I had the chance to interview Vladimir Prelovac but due to technical difficulties, I had to edit out the interview. So to make up for that interview, I’ve asked Vladimir a set of questions from the interview which covers most of what was discussed on the show. Thanks to Vladimir for answering these and maybe next time, the interwebs won’t be so mean to us.

What got you involved with the WordPress Project?
Having just quit my job I needed a place where I can settle and find a way to show my skills. That place was WordPress. It was easy to use, fast and had a big enthusiastic community. Sounded like a good plan to me!

I remember clearly that what won me over other platforms was the famous five minutes from starting installation to writing the first post. Simply amazing.

Which has been more difficult for you? Creating a plugin or a theme?
In today’s modern WordPress installations both plugins and themes live the same life, and a theme is often created with an insight of what plugins will be used with it and vice-verse.

Themes are hard to make as people tend to react more directly to visual aspects of design.

Plugins can be even harder, as the variety of possibilities having in mind all features of WordPress and integration with third party services is simply amazing.

Optimization is a big topic as it relates to WordPress. What are some things that the WordPress team could do to increase performance of the software where end users wouldn’t need to optimize as much?
My first suggestion would be to revise the database structure. Often I see WordPress blogs struggling with just a couple of thousands post. It feels like categories and tags are currently handled in a sub-optimal way.

The second thing I think should become a core feature is caching functionality similar to WP Super Cache. Almost all other platforms offer some kind of out-of-box caching mechanism.

Third major area of improvement could be changing the current editor of choice (TinyMCE) as it just feels as not up for the job, both feature and performance wise.

And finally, ability to automatically update third party tools that WordPress uses (jQuery, RSS parser and other libs) without having to wait for next WordPress release will show immediate performance gains when these tools are upgraded.

What inspired you to write the WordPress development book?
When someone comes to you and offers you to write a first book on a certain topic you stop to think will you be up for the job. After I decided I can do it, the prospect of actually creating something that will outlast me was simply to alluring to pass. Writing a book must be one of the hardest things I ever did but I am now enjoying every moment of it.

Is the book aimed towards PHP developers or those who don’t know any PHP?
Well really both in a way. Those who do not know PHP will still be able to understand what the book is about and what WordPress plugin development can bring to them – especially first and the last chapter. Of course PHP knowledge will be a big plus for understanding all details.

For those aspiring to create WordPress plugins, can you provide some developer tips that they should follow?
I have just recently written a whole article on this topic and I think it is best if I just point anyone interested to read it here http://mashable.com/2009/03/25/wordpress-plugin-developer-tips/

What about security? Can you offer some tips on how to develop WordPress plugins using secure code?
As long as the code and hacking is concerned, WordPress has evolved into a pretty secure platform, and you can find some security tips in the above mentioned article.

However, every single plugin you that you use on your blog has the ability to pretty much do anything imaginable to your site (should the plugin author want to do harmful things), and this is in my opinion where biggest security threat to WordPress lies today. Currently the entire community is more or less relying on assumption that plugin authors have good intentions. It is little scary to me.

Is there anything else you’d like to say to the WordPress community?
Read Jeff’s and my blog for latest WordPress happenings

Thanks again to Vladimir for answering these questions and of course, for the plug.

Posted in WordPress | Tagged interview, optimization, vladimir prelovac

Social Bookmarking With WordPress Plugin

Social Bookmarking With WordPress Plugin

By Jeffro on April 12, 2009

In this article by Vladimir Prelovac, we will learn to 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 article alone will allow you to write a lot of similar plugins.

Let’s get moving! This article is extracted from the “WordPress Plugin Development ” book. In this article, 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 flow 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 button 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 article 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 activate it.

  1. Create a file called wp-digg-this.php in your favorite 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:
    <?php/*Plugin Name: WP Digg ThisVersion: 0.1Description: Automatically adds Digg This button to your posts.Author: Vladimir PrelovacAuthor URI: http://www.prelovac.com/vladimirPlugin URI: http://www.prelovac.com/vladimir/wordpress-plugins/wp-digg-this*/?>
  3. Now add the code to check the WordPress version:
    /* Version check */global $wp_version;$exit_msg='WP Digg This requires WordPress 2.5 or newer.<a href="http://codex.wordpress.org/Upgrading_WordPress">Pleaseupdate!</a>';if (version_compare($wp_version,"2.5","<")){exit ($exit_msg);}?>
  4. Upload your plugin file to the wp-content/plugins folder on your server using your FTP client.
  5. Go to your WordPress Plugins admin panel. You should now see your plugin listed among other plugins:

  6. 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).

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 written 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. <ahref="http://codex.wordpress.org/Upgrading_WordPress">Pleaseupdate!</a>';if (version_compare($wp_version,"2.6","<")){exit ($exit_msg);}

While being simple, this piece of code is also very effective. 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 differences, 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.

Checking the plugin

You can go ahead and activate the plugin. The plugin will be activated but will do nothing at this moment.

Time for Action – Testing the version check

  1. Deactivate the plugin and change the version check code to a higher version. For example, replace 2.6 with 5.0.
    if (version_compare($wp_version,"5.0","<"))
  2. Re-upload the plugin and try to activate it again. You will see a WordPress error and a message from the plugin:

What just happened?

The version check fails and the plugin exits with our predefined error message. The same thing will happen to a user trying to use your plugin with outdated WordPress installation, requiring them to update to a newer version.

Have a go Hero

We created a basic plugin that you can now customize.

  • Change the plugin description to include HTML formatting (add bold or links to the description).
  • Test your plugin to see what happens if you have two plugins with the same name (upload a copy of the file under a different name).

WordPress Plugin Development (Beginner’s Guide)
 
WordPress Plugin Development (Beginner's Guide)
  • Build powerful, interactive plug-ins for your blog and to share online
  • Everything you need to create and distribute your own plug-ins following WordPress coding standards
  • Walk through the development of six complete, feature-rich, real-world plug-ins that are being used by thousands of WP users
  • Written by Vladimir Prelovac, WordPress expert and developer of WordPress plug-ins such as Smart YouTube and Plugin Central
  • Part of Packt’s Beginners Guide series: expect step-by-step instructions with an emphasis on experimentation and tweaking code

  http://www.packtpub.com/wordpress-plug-in-development/book


Posted in Plugins | Tagged development, digg, Plugins, vladimir prelovac

WPWeekly Episode 47 – Interview With Vladimir Prelovac

WPWeekly Episode 47 – Interview With Vladimir Prelovac

By Jeffro on March 28, 2009

wordpressweekly1While I really wanted to dive into plugin development with Vladimir Prelovac and talk about his WordPress plugin development book on the show, his Skype connection simply wouldn’t have anything to do with the show. Because the audio quality was so bad, I have edited the show to remove most of the interview so you won’t have to put up with the anger inducing Skype anomalies presented all throughout the first halfhour. So instead of an audio interview, I will most likely send Vladimir a list of questions via email and do things the old fashioned way. Also, David and I certainly had enough WordPress news to talk about which is what we did for the remainder of the show.

Ad Copy:

This episode of WordPress Weekly is sponsored by, WebDevStudios.com. WebDevStudios is a website development company specializing in WordPress support and development services. Contact them today for help with your WordPress powered website.

Stories Discussed:

phpBB Bridge Beta Testers Needed
Google Summer Of Code Projects
Interview With Andrew Ozz
Is WordPress 2.7.1 Really Being Hacked?

WordPress Tavern Listener Poll:

Each week from now on, I’ll be featuring a new listener poll question on WPTavern.com The poll is located in the sidebar on the right hand side of the site.

Last weeks poll question was: Do You Like The Direction WordPress Is Heading?

Out of a total of 31 votes, 23 of you said yes, 6 of you said you have no idea where it’s going and 2 of you voted no.

This Weeks Poll Question Is: Will you be purchasing a copy of WordPress Plugin Development: A Beginners Guide

Plugin Picks Of The Week:

Jeff – Insights -The insights plugin by Vladimir Prelovac enables you to quickly search for blog posts, edit them or insert links to them into the current post, insert flickr images, insert youtube videos, search and link to wikipedia, search google, search news, google blog search, and insert a google map all from within the comforts of your write panel.

David – SEO Smart Links – By Vladimir Prevolac allows you to instantly have links appear for pages, posts, and more without hard coding those links in place. It has made my life easy on more than a few projects, allowing users to quickly dive deeper into my blog.

WordPress Trivia Question:

No Trivia question this week but next week and the week after, I’ll have one WordCamp Chicago ticket to give away as a prize for being the first to answer the trivia question in the chatroom.

Announcements:

Interviewing Joost De Valk at 3PM EST on March 28th, 2009.

WPWeekly Meta:

Next Episode: Saturday March 28th, 2009 3P.M. EST

Subscribe To WPWeekly Via Itunes: Click here to subscribe

Length Of Episode: 53 Minutes

Download The Show: WordPressWeeklyEpisode47.mp3

Listen To Episode #47:

Posted in WordPress Weekly | Tagged Plugins, talkcast, vladimir prelovac, wpweekly | 3 Responses

© Copyright WPTavern 2012 All rights reserved About / Stats / Poll Archive / Site Archive // Powered by WordPress Mtn. Dew And Hybrid