Word Press Plugin Development A Starter Guide For

  • Slides: 27
Download presentation
Word. Press Plugin Development A Starter Guide For Beginners

Word. Press Plugin Development A Starter Guide For Beginners

Md Jahidul Islam (one. Tarek) Senior Executive , Development A. R. Communications Blog: onetarek.

Md Jahidul Islam (one. Tarek) Senior Executive , Development A. R. Communications Blog: onetarek. com Facebook: fb. com/one. Tarek

What is a Plugin? Word. Press Plugins allow easy modification, customization, and enhancement to

What is a Plugin? Word. Press Plugins allow easy modification, customization, and enhancement to a Word. Press blog. Instead of changing the core programming of Word. Press, you can add functionality with Word. Press Plugins. Here is a basic definition: l Word. Press Plugin: A Word. Press Plugin is a program, or a set of one or more functions, written in the PHP scripting language, that adds a specific set of features or services to the Word. Press weblog, which can be seamlessly integrated with the weblog using access points and methods provided by the Word. Press Plugin Application Program Interface (API). l http: //codex. wordpress. org/Writing_a_Plugin l

Why Do We Write a Plugin? l Solve a problem l Extend existing functionality

Why Do We Write a Plugin? l Solve a problem l Extend existing functionality l Save time l Portability l Make money (? ? ? )

How does plug-in works? l As shown in the figure, the host application provides

How does plug-in works? l As shown in the figure, the host application provides services which the plug-in can use, including a way for plug-ins to register themselves with the host application and a protocol for the exchange of data with plug-ins. Plug-ins depend on the services provided by the host application and do not usually work by themselves. Conversely, the host application operates independently of the plug-ins, making it possible for end-users to add and update plugins dynamically without needing to make changes to the host application. http: //en. wikipedia. org/wiki/Plug-in_%28 computing%29

When Plugins are Loaded

When Plugins are Loaded

WP Folder Structure

WP Folder Structure

Starting Your First Plugin STEP 1: Create a new folder inside the folder wp-content/plugins/

Starting Your First Plugin STEP 1: Create a new folder inside the folder wp-content/plugins/ and named it related to your plugin name STEP 2: Creating a new plugin you’ll need to start with a simple PHP file. This can be named anything but should generally reflect your plug-in’s official name. STEP 3: On the top your PHP file put some information about your plugin. The first lines of your plug-in must be comment information for the parsing engine. This is extremely important as Word. Press will be unable to process your file without. Below is an example code snippet.

STEP 4: Save your PHP file. STEP 5: Your are done. Your plugin is

STEP 4: Save your PHP file. STEP 5: Your are done. Your plugin is ready. Now go to dash board plugin list. You will see you plugin name in the list Activate your plugin.

A Real Example Create a PHP file with following codes and save that into

A Real Example Create a PHP file with following codes and save that into the plugins folder with any name , I named it my-floating-bar. php. Now active this plugin and go to your site home page. You will see a red colored bar with some moving texts

Some Necessary Topics to Learn • Custom Post Types • Custom Taxonomy • Custom

Some Necessary Topics to Learn • Custom Post Types • Custom Taxonomy • Custom Metabox • Post Meta • Word. Press API Plugin API(*****) Shortcode API Widgets API Options API Settings API Dashboard Widgets API Quicktags API Rewrite API Transients API • Global Variables • WP Media Library • Plugin and Content Directories • Adding Administration Menus • Creating Options Pages • • • Creating Tables with Plugins Playing With Database Query(WPDB) Custom Queries WP Query AJAX in Plugins WP Nonce Translation(i 18 n) AJAX in Word. Press Cookies Word. Press Feeds XML-RPC Word. Press Coding Standards

Word. Press API l l l Plugin API Shortcode API Widgets API Options API

Word. Press API l l l Plugin API Shortcode API Widgets API Options API Settings API Dashboard Widgets API l Quicktags API l Rewrite API l Transients API l

Plugin API Hooks, Actions, and Filters to use in your Plugins Hooks are provided

Plugin API Hooks, Actions, and Filters to use in your Plugins Hooks are provided by Word. Press to allow your plugin to 'hook into' the rest of Word. Press; that is, to call functions in your plugin at specific times, and thereby set your plugin in motion. There are two kinds of hooks: 1. Actions 2. Filters Actions and filters allow you add your own functionality or modify your site’s behavior by hooking a callback function onto a specific tag in the core code, setting priorities and using parameters and arguments passed to the callback function. Detail: http: //codex. wordpress. org/Plugin_API Codex Action Reference) Codex Filter Reference) The Beginner's Guide to Word. Press Actions and Filters

Actions Hooks Actions allow you to run your own function at a specific point

Actions Hooks Actions allow you to run your own function at a specific point in the processing of the Word. Press. Action hooks are essentially placeholders. Wherever an action hook is placed, it will execute any code that has been “hooked” to it. For example, you might want to do something when a post is published. You may want to send an email with detail about your published post. You may want to add your own HTML/JS code on the footer section of your website. Some example of Action hooks: wp_head, wp_footer, publish_post , save_post , the_post , More How to use action hooks? We can hook our own function at a particular point by using add_action function. add_action( $hook_name, $my_function_to_add, $priority, $accepted_args ); Word. Press will call my function on the specific point by using do_action() function. Example: add_action( “wp_footer”, “my_floating_bar”);

Filter Hooks Filters allow you to intercept and modify data as it is processed.

Filter Hooks Filters allow you to intercept and modify data as it is processed. For example, you might want not to show any post title more than 60 characters. Then you just need to modify the post title by using your custom function with the filter hook for post title. Some example of Filter hooks: the_content , the_title , wp_title , the_date , the_time , the_permalink , More How to use action hooks? We can modify particular data with our own function by using add_filter function. add_filter( $tag, $function_to_add, $priority, $accepted_args ); Word. Press will pass specific data through my function by using apply_filters function. Example: add_filter( “the_title”, “my_title_limit”);

Shortcode API Introduced in Word. Press 2. 5 is the Shortcode API, a simple

Shortcode API Introduced in Word. Press 2. 5 is the Shortcode API, a simple set of functions for creating macro codes for use in post content. The average user acting as editor has the ability to publish dynamic content using macros, without the need for programming skills. Example: The following shortcode (in the post/page content) would add a photo gallery into the page [gallery] Detail Guide and Tutorial: 1. http: //codex. wordpress. org/Shortcode_API 2. http: //www. smashingmagazine. com/2012/05/01/w ordpress-shortcodes-complete-guide/

Widgets API Widgets were originally designed to provide a simple and easy-to-use way of

Widgets API Widgets were originally designed to provide a simple and easy-to-use way of giving design and structure control of the Word. Press Theme to the user, which is now available on properly "widgetized" Word. Press Themes to include the header, footer, and elsewhere in the Word. Press design and structure. Detail Guide and Tutorials: 1. 2. 3. 4. http: //codex. wordpress. org/Word. Press_Widgets http: //wpengineer. com/1023/wordpress-built-a-widget/ http: //code. tutsplus. com/tutorials/writing-maintainable-wordpresswidgets-part-1 -of-2 --wp-20348 http: //justintadlock. com/archives/2009/05/26/the-complete-guide-to -creating-widgets-in-wordpress-28

Options API The Options API is a simple and standardized way of storing data

Options API The Options API is a simple and standardized way of storing data in the database. The API makes it easy to create, access, update, and delete options. All the data is stored in the wp_options table under a given custom name. This page contains the technical documentation needed to use the Options API. A list of default options can be found in the Option Reference. Detail Guide and Tutorials: http: //codex. wordpress. org/Options_API

Settings API The Settings API, allows admin pages containing settings forms to be managed

Settings API The Settings API, allows admin pages containing settings forms to be managed semi-automatically. It lets you define settings pages, sections within those pages and fields within the sections. Detail Guide and Tutorials: 1. http: //codex. wordpress. org/Settings_API 2. http: //code. tutsplus. com/tutorials/the-complete-guide-to -the-wordpress-settings-api-part-1 -what-it-is-why-itmatters--wp-24060 3. http: //tutorialzine. com/2012/11/option-panel-wordpressplugin-settings-api/

Dashboard Widgets API The Dashboard Widgets API makes it very simple to add new

Dashboard Widgets API The Dashboard Widgets API makes it very simple to add new widgets to the administration dashboard. Detail Guide and Tutorials: 1. http: //codex. wordpress. org/Dashboard_Widgets_API 2. http: //code. tutsplus. com/tutorials/how-to-build-customdashboard-widgets--wp-29778 3. http: //www. wpbeginner. com/wp-themes/how-to-addcustom-dashboard-widgets-in-wordpress/

Quicktags API The Quicktags API allows you to include additional buttons in the Text

Quicktags API The Quicktags API allows you to include additional buttons in the Text (HTML) mode of the Word. Press editor. Detail Guide and Tutorials: 1. http: //codex. wordpress. org/Quicktags_API 2. http: //www. wpexplorer. com/adding-wordpress-customquicktags/

Rewrite API Word. Press allows theme and plugin developers to programmatically specify new, custom

Rewrite API Word. Press allows theme and plugin developers to programmatically specify new, custom rewrite rules Example: http: //wpressians. net/meetup/7 th-meetup/speakers/ Detail Guide and Tutorials: 1. http: //codex. wordpress. org/Rewrite_API 2. http: //codex. wordpress. org/Class_Reference/WP_Rew rite 3. http: //code. tutsplus. com/articles/the-rewrite-api-thebasics--wp-25474

Transients API Word. Press Transients API, which offers a simple and standardized way of

Transients API Word. Press Transients API, which offers a simple and standardized way of storing cached data in the database temporarily by giving it a custom name and a timeframe after which it will expire and be deleted Detail: http: //codex. wordpress. org/Transients_API

Tutorials And Books Tutorials: http: //codex. wordpress. org/Writing_a_Plugin How to Create a Word. Press

Tutorials And Books Tutorials: http: //codex. wordpress. org/Writing_a_Plugin How to Create a Word. Press Plugin Top 6 Word. Press Plugin Development Tutorials 2 Essential Guides and Resources Books: Word. Press Plugin Development (Beginner's Guide) Professional Word. Press Plugin Development

Questions?

Questions?

THANK YOU

THANK YOU