Word Press Plugin Development By Nyros Developer
-
Upload
nyros-technologies -
Category
Documents
-
view
2.296 -
download
2
description
Transcript of Word Press Plugin Development By Nyros Developer
![Page 1: Word Press Plugin Development By Nyros Developer](https://reader030.fdocuments.in/reader030/viewer/2022020122/5549986bb4c9050c708b47ca/html5/thumbnails/1.jpg)
WordPress Plugin Development
Presented ByThirupathi.J
![Page 2: Word Press Plugin Development By Nyros Developer](https://reader030.fdocuments.in/reader030/viewer/2022020122/5549986bb4c9050c708b47ca/html5/thumbnails/2.jpg)
Concepts
What is wordpress?
How to install wordpress?
What is wordpress plugin?
What do you need to make a wordpress plugin?
Plugin Structure?
Plugin API?
![Page 3: Word Press Plugin Development By Nyros Developer](https://reader030.fdocuments.in/reader030/viewer/2022020122/5549986bb4c9050c708b47ca/html5/thumbnails/3.jpg)
What is WordPress?
WordPress is an open source blog publishing application powered by PHP and MySQL which can also be used for content management. It has many features including a workflow, a plugin architecture and a templating system.
![Page 4: Word Press Plugin Development By Nyros Developer](https://reader030.fdocuments.in/reader030/viewer/2022020122/5549986bb4c9050c708b47ca/html5/thumbnails/4.jpg)
How to install WordPress?
Download the wordpress latest version from:
http://wordpress.org/download/
![Page 5: Word Press Plugin Development By Nyros Developer](https://reader030.fdocuments.in/reader030/viewer/2022020122/5549986bb4c9050c708b47ca/html5/thumbnails/5.jpg)
What is a WordPress plugin?
Little applications used to enhance functionality or add specific functions tailored to a site's specific needs.
![Page 6: Word Press Plugin Development By Nyros Developer](https://reader030.fdocuments.in/reader030/viewer/2022020122/5549986bb4c9050c708b47ca/html5/thumbnails/6.jpg)
Some plugins:
Capitalize Titles of Pages and Posts WordPress Database Backup WordPress.com StatsComment Hilite
![Page 7: Word Press Plugin Development By Nyros Developer](https://reader030.fdocuments.in/reader030/viewer/2022020122/5549986bb4c9050c708b47ca/html5/thumbnails/7.jpg)
What do you need to make a plugin?
a problem to solvesome PHP knowledge
some spare timea test server with your test wordpress (XAMPP is good.)
![Page 8: Word Press Plugin Development By Nyros Developer](https://reader030.fdocuments.in/reader030/viewer/2022020122/5549986bb4c9050c708b47ca/html5/thumbnails/8.jpg)
Plugin Directory Structure
Your Plugin:/wp-content/plugins/my-plugin
Inside “my-plugin”readme.txtscreenshot-1.pngmy-plugin.php
Always put it in a directory!
Uses 'dashes' and not 'underscores'http://codex.wordpress.org/Writing_a_Plugin#Names.2C_Files.2C_and_Locations
![Page 9: Word Press Plugin Development By Nyros Developer](https://reader030.fdocuments.in/reader030/viewer/2022020122/5549986bb4c9050c708b47ca/html5/thumbnails/9.jpg)
Plugin API
- Enabled "hooks"
- Extend functionality withoutediting the core code
- Two categories:Actions and Filters
![Page 10: Word Press Plugin Development By Nyros Developer](https://reader030.fdocuments.in/reader030/viewer/2022020122/5549986bb4c9050c708b47ca/html5/thumbnails/10.jpg)
2 Kinds of WordPress Hooks
Actions = “Do Something”
Filters = “Transform”
![Page 11: Word Press Plugin Development By Nyros Developer](https://reader030.fdocuments.in/reader030/viewer/2022020122/5549986bb4c9050c708b47ca/html5/thumbnails/11.jpg)
ActionsActions are the hooks that the WordPress core launches at specific points during execution, or when specific events occur. Your plugin can specify that one or more of its PHP functions are executed at these points, using the Action API.
add_action( 'hook_name', 'your_function_name', [priority], [accepted_args] );
![Page 12: Word Press Plugin Development By Nyros Developer](https://reader030.fdocuments.in/reader030/viewer/2022020122/5549986bb4c9050c708b47ca/html5/thumbnails/12.jpg)
Filters
Functions that modify text, lists andvarious types of information that areused and produced by WordPress.
add_filter('hook_name', 'your_filter_function', [priority], [accepted_args]);
![Page 13: Word Press Plugin Development By Nyros Developer](https://reader030.fdocuments.in/reader030/viewer/2022020122/5549986bb4c9050c708b47ca/html5/thumbnails/13.jpg)
Writing Your First Plugin
![Page 14: Word Press Plugin Development By Nyros Developer](https://reader030.fdocuments.in/reader030/viewer/2022020122/5549986bb4c9050c708b47ca/html5/thumbnails/14.jpg)
readme.txt
• http://codex.wordpress.org/Writing_a_Plugin#Readme_File
• http://wordpress.org/extend/plugins/about/readme.txt
Useful only for publishing toWordPress Plugin Directory
Information about your plugin:Description, Installation, Changelog, Donation
Links, Tags, etc...
![Page 15: Word Press Plugin Development By Nyros Developer](https://reader030.fdocuments.in/reader030/viewer/2022020122/5549986bb4c9050c708b47ca/html5/thumbnails/15.jpg)
screenshot-1.png
•Useful only for publishing to•WordPress Plugin Directory
![Page 16: Word Press Plugin Development By Nyros Developer](https://reader030.fdocuments.in/reader030/viewer/2022020122/5549986bb4c9050c708b47ca/html5/thumbnails/16.jpg)
my-plugin.php
4 parts to a pluginPlugin HeaderHooksPHP CodeTemplate Code
![Page 17: Word Press Plugin Development By Nyros Developer](https://reader030.fdocuments.in/reader030/viewer/2022020122/5549986bb4c9050c708b47ca/html5/thumbnails/17.jpg)
File Structure
![Page 18: Word Press Plugin Development By Nyros Developer](https://reader030.fdocuments.in/reader030/viewer/2022020122/5549986bb4c9050c708b47ca/html5/thumbnails/18.jpg)
Plugin Headers
http://codex.wordpress.org/Writing_a_Plugin#Standard_Plugin_Information
![Page 19: Word Press Plugin Development By Nyros Developer](https://reader030.fdocuments.in/reader030/viewer/2022020122/5549986bb4c9050c708b47ca/html5/thumbnails/19.jpg)
Plugin Headers
http://codex.wordpress.org/Writing_a_Plugin#Standard_Plugin_Information
Always on top, no choice
Fill in with your own details
![Page 20: Word Press Plugin Development By Nyros Developer](https://reader030.fdocuments.in/reader030/viewer/2022020122/5549986bb4c9050c708b47ca/html5/thumbnails/20.jpg)
Hooks (Filters)
![Page 21: Word Press Plugin Development By Nyros Developer](https://reader030.fdocuments.in/reader030/viewer/2022020122/5549986bb4c9050c708b47ca/html5/thumbnails/21.jpg)
Hooks (Filters)
After plugin headers (my preferance)
Makes it easier to find
![Page 22: Word Press Plugin Development By Nyros Developer](https://reader030.fdocuments.in/reader030/viewer/2022020122/5549986bb4c9050c708b47ca/html5/thumbnails/22.jpg)
PHP Code
![Page 23: Word Press Plugin Development By Nyros Developer](https://reader030.fdocuments.in/reader030/viewer/2022020122/5549986bb4c9050c708b47ca/html5/thumbnails/23.jpg)
Plugin 1
Figure out what you want to do.
I want to convert all instances of “WordPress” to “WORDPRESS”in a post's content.
![Page 24: Word Press Plugin Development By Nyros Developer](https://reader030.fdocuments.in/reader030/viewer/2022020122/5549986bb4c9050c708b47ca/html5/thumbnails/24.jpg)
the_content (filter)
http://codex.wordpress.org/Plugin_API/Filter_Reference/the_content
![Page 25: Word Press Plugin Development By Nyros Developer](https://reader030.fdocuments.in/reader030/viewer/2022020122/5549986bb4c9050c708b47ca/html5/thumbnails/25.jpg)
add_filter
http://codex.wordpress.org/Plugin_API/Filter_Reference/the_content
![Page 26: Word Press Plugin Development By Nyros Developer](https://reader030.fdocuments.in/reader030/viewer/2022020122/5549986bb4c9050c708b47ca/html5/thumbnails/26.jpg)
add_filter
http://codex.wordpress.org/Plugin_API#Hook_to_WordPress
②
① Hook Name
② Callback
①
![Page 27: Word Press Plugin Development By Nyros Developer](https://reader030.fdocuments.in/reader030/viewer/2022020122/5549986bb4c9050c708b47ca/html5/thumbnails/27.jpg)
Hook Callback
Determines what PHP function to call
Callback can be either:String; orArray of 2 strings (my preference)
![Page 28: Word Press Plugin Development By Nyros Developer](https://reader030.fdocuments.in/reader030/viewer/2022020122/5549986bb4c9050c708b47ca/html5/thumbnails/28.jpg)
Hook Callback
StringCalls a function
Array of 2 stringsCalls a static function in a class
![Page 29: Word Press Plugin Development By Nyros Developer](https://reader030.fdocuments.in/reader030/viewer/2022020122/5549986bb4c9050c708b47ca/html5/thumbnails/29.jpg)
They do the same thing
![Page 30: Word Press Plugin Development By Nyros Developer](https://reader030.fdocuments.in/reader030/viewer/2022020122/5549986bb4c9050c708b47ca/html5/thumbnails/30.jpg)
I Prefer Array Callbacks
Allows me to segment my code
Lower chances of name conflicts
Easily tell which function belongs to which hook
![Page 31: Word Press Plugin Development By Nyros Developer](https://reader030.fdocuments.in/reader030/viewer/2022020122/5549986bb4c9050c708b47ca/html5/thumbnails/31.jpg)
Filters are Transformations
filters have to return a transformation
![Page 32: Word Press Plugin Development By Nyros Developer](https://reader030.fdocuments.in/reader030/viewer/2022020122/5549986bb4c9050c708b47ca/html5/thumbnails/32.jpg)
Filter return Values
A filters return value, is the result of the transformation
②① return
② transformation
①
http://php.net/manual/en/function.preg-replace.php
![Page 33: Word Press Plugin Development By Nyros Developer](https://reader030.fdocuments.in/reader030/viewer/2022020122/5549986bb4c9050c708b47ca/html5/thumbnails/33.jpg)
![Page 34: Word Press Plugin Development By Nyros Developer](https://reader030.fdocuments.in/reader030/viewer/2022020122/5549986bb4c9050c708b47ca/html5/thumbnails/34.jpg)
Plugin 2
Figure out what you want to do.
I want to BOLD all instances of “WORDPRESS”
in a post's content.
![Page 35: Word Press Plugin Development By Nyros Developer](https://reader030.fdocuments.in/reader030/viewer/2022020122/5549986bb4c9050c708b47ca/html5/thumbnails/35.jpg)
Hook Priority
http://codex.wordpress.org/Plugin_API#Hook_to_WordPress
![Page 36: Word Press Plugin Development By Nyros Developer](https://reader030.fdocuments.in/reader030/viewer/2022020122/5549986bb4c9050c708b47ca/html5/thumbnails/36.jpg)
Priority
②
② Callback
① ③②②
③ Priority (optional)
① Hook Name
http://codex.wordpress.org/Plugin_API#Hook_to_WordPress
![Page 37: Word Press Plugin Development By Nyros Developer](https://reader030.fdocuments.in/reader030/viewer/2022020122/5549986bb4c9050c708b47ca/html5/thumbnails/37.jpg)
Which one goes first?
WordPress2WORDPRESS#the_content
ABolderWordPress#the_content
![Page 38: Word Press Plugin Development By Nyros Developer](https://reader030.fdocuments.in/reader030/viewer/2022020122/5549986bb4c9050c708b47ca/html5/thumbnails/38.jpg)
Default Priority
10smaller numbers = higher prioritylarger numbers = lower priority
http://codex.wordpress.org/Plugin_API#Hook_to_WordPress
![Page 39: Word Press Plugin Development By Nyros Developer](https://reader030.fdocuments.in/reader030/viewer/2022020122/5549986bb4c9050c708b47ca/html5/thumbnails/39.jpg)
Therefore
Order of execution:
(10) WordPress2WORDPRESS#the_content(20) ABolderWordPress#the_content
![Page 40: Word Press Plugin Development By Nyros Developer](https://reader030.fdocuments.in/reader030/viewer/2022020122/5549986bb4c9050c708b47ca/html5/thumbnails/40.jpg)
THANK YOU