-->

Monday, June 23, 2014

WordPress Web & Plugins Development – A Beginners Guide


WordPress CMS has changed the way in the field of web development providing new, innovative and prosperous ideas to developers. Today WordPress development is used in several ways benefitting all sort of businesses.

Wordpress development

WordPress is among the best platforms to create your own plugin and enhancing the functionality by placing it in your blog. Plugins can be placed anywhere in your blog. This extensibility provides a better growth to your blog in terms of visits and authority.

WordPress delivers special features for developing unique plugins. As a developer, you can get hold on your blog by developing specific plugins of your requirement. Hiring a professional PHP developer to develop WordPress plugin for your blog may cost you a lot more than you have imagined.

You can build your own plugins and sidebar widgets and get more tuned into deeper areas of WordPress CMS development. It's not just limited to WordPress, but you can also have more knowledge about other content management systems too.

An Introduction of WordPress Folder Structure


As shown in the picture, you can see the list of basic app directories. You'll find a wp-content folder, and within the folder, there is plugins directory. This plugins directory is the home for all the plugins.

If you want to create a small plugin with a single .php file, then it can be directly saved within the plugins directory, however if your file is bit complicated or consists of multiple .php files, then it's better to create a sub-directory named after your plugin.

Wordpress plugin development

You can also create a readme.txt file, as it's important if you are providing your file for downloading. As an author, you can also provide details about several sections of your file.

Let's Begin with Your First PHP File for WordPress Plugin Development


First of all you need to create a simple .php file for a new plugin. You can name anything to .php file, but it's a good practice to name it after your plugin's official name. The first few lines of your code should be information about that plugin and they must be placed in comments for the parsing engine. You can place your information as shown in picture below.

Wordpress web development

You can see the plugin's name within the admin backend panel at the time of activation. It's very similar to the URI placed within the details panel inside the plugins panel.

Best Practices for WordPress Naming Conventions


It's the best practice to create an entire plugin class system to avoid the conflicts between the names of variables and functions, but if you are not familiar with the OOP concepts, then you can write all your code within one sample file.
Now we need few variables to define, which are the key elements to be implemented inside our templates files. Check the example of our file provided below taken from our plugin file with all the core logic code removed.

Wordpress plugin development

It's a better practice to follow all the rules and regulations set by WordPress to avoid collisions. As there are many internal functions within the WordPress file, there are chances of having duplicate functions. Try to make a habit of prefixing a label to all the names of your variables and functions.

Role of Filters & Actions


Filters and Actions play a very important role in developing a WordPress plugin. These two concepts have an in-depth relation in manipulating the plugin data.

Actions and Filters are two standard codes that comes along with WordPress API. The developers can also modify the codes within the Filters and Actions to use it for their new plugin.

Wordpres CMS development

Acknowledging "Add_filter()"


A filter is a piece of data that is passed into WordPress, that allows a developer to easily filter content within your own written code to modify your data as per your needs. For example, you can use the filter to change the content which is availabe in WordPress as a variable set.

Filters provide an easy way to write plugins to customize the look and feel of your website. Filters are generally used for developing sidebar widgets and small functions to modify the looks of you blog post.

Acknowledging "Add_action()"


Actions are much similar to Filters, but instead of using bits of data, they target the pre-defined areas within the template and admin panel. Actions can be applied whenever you edit or change the content of a page. There are some predefined areas where you can target Actions, some of them are listed below.

  • save_post – called when a post/page is created from start or updated
  • trackback_post – called whenever a new trackback is added into a post
  • loop_end – called immediately after the final post has been processed through the WordPress loop
  • wp_head – called when the template is loaded and runs the wp_head() function
  • publish_post – called when a post is published or when status is changed into “published”

Once you'll understand the difference between Actions and Filters, then you'll be able to create a comprehensive plugin for your blog.

Inputting Our Final Plugin Logic


Now we'll put our plugin code in the plugin file. The documentation provided to understand API comes in very handy and provides an excellent resource to developers. You may face some difficulties, if you're not comfortable with PHP language.

Add the function as shown in the picture below within your plugin's header comment, and this code can also be placed within your theme's function. The code provided is for a dynamic content based on limited range of characters.

Wordpress development

Finally Install & Run the Plugin


Once you have completed with the code, you need access to the WordPress administration panel and browse the current plugin file for installation.

Conclusion


It's very important to know the basics to get started with WordPress development. The WordPress plugin development provides a great deal of functionality. You can try practicing these methods on your local installation of WordPress.

Want to develop your own WordPress application or plugin?



About Anna Harris:
working as web content writer and a strategist for a major IT firm specialized in various mobile application development services for iOS, Android, Windows Phone and other operating systems.

Follow Anna Harris On

0 comments:

Post a Comment

 
Blogger Widgets