WordPress Plugin Development - PowerPoint PPT Presentation

View by Category
About This Presentation
Title:

WordPress Plugin Development

Description:

In simple words if we want to define plugins, then we can say that these are same as addons added to your browser for making certain things simpler for you.in the same way Plugins are added to Wordpress for making things easy and simple. – PowerPoint PPT presentation

Number of Views:788

less

Write a Comment
User Comments (0)
Transcript and Presenter's Notes

Title: WordPress Plugin Development


1
WordPress Plugin Development
  • www.headwaywebsolutions.com

2
  • WordPress is a free CMS (Content Management
    System) and open source blogging tool it has
    totally changed the look on the internet, whether
    we are talking about software or website
    development.
  • Now in this part we will be discussing how to
    create a wordpress plugin with our simple but
    effective steps. Now when we talk about plugins,
    then most probably the non tech guys will think
    of a complex function, followed by the knowledge
    of lot of tech languages which is just a myth and
    this is what we will show here, that how easy it
    is to create a Wordpress plugin, all you need to
    know is a bit of PHP and a basic understanding of
    WP file structure and Admin panel.
  • www.headwaywebsolutions.com

3
  • Now before starting up with how to create a WP
    plugin, I would first like to discuss why to
    develop a wordpress plugin.
  • Why to have a WordPress plugin?
  • In simple words if we want to define plugins,
    then we can say that these are same as addons
    added to your browser for making certain things
    simpler for you.
  • Example All in one SEO plugin from Wordpress is
    a plugin that help you in optimizing your site
    and making it search engine friendly with it
    simple but effective features at a single place,
    some of the features provided by. All in one SEO
    plugin are
  • www.headwaywebsolutions.com

4
  • Google Analytics support
  • Support for Custom Post Types
  • Advanced Canonical URLs
  • Fine tune Page Navigational Links
  • Built-in API so other plugins/themes can access
    and extend functionality
  • ONLY plugin to provide SEO Integration for WP
    e-Commerce sites
  • Nonce Security
  • this is what a simple Plugin can offer you.
  • And developing a pluging will give you a better
    understanding as how things work at the backend
    and another benefit is that being a developer you
    can have a complete control over the function of
    your plugin.
  • www.headwaywebsolutions.com

5
  • Steps of developing a WP plugin
  • www.headwaywebsolutions.com

6
1. WP Folder Structure
  • The wordpress folder structure will show you the
    basic application directory within wordpress, in
    here you will find a Plugin directory where you
    can find all the plugins installed,
  • For smaller plug-ins which only requires a single
    .php file, you can place them directly into the
    plug-ins/ directory. But when you start creating
    more complex applications, it is a better option
    to create a sub directory named after your
    plug-in where you can assemble all JavaScript,
    CSS, and HTML along with the PHP functions.
  • www.headwaywebsolutions.com

7
  • Figure 1
  • www.headwaywebsolutions.com

8
  • Figure 2
  • www.headwaywebsolutions.com

9
  • And if you want to provide your plugin to others
    for download, so that others to get benefited
    from it, then these are the simple things that
    you need to keep in mind before providing a
    readme.txt file, this file should contain your
    name and functionality of the plugin and further
    if you want, that people should know about the
    updates in the plugins then you should provide
    details about each revision.
  • www.headwaywebsolutions.com

10
2. Starting Your PHP File
  • Start with a simple PHP file while creating a new
    plugin. This should be your plug-ins official
    name. For example I have created base code and
    have named the file quick-subscribe-now.php.
  • The first lines of your plug-in must be comment.
    This is extremely important as WordPress will be
    unable to process your file without it. Below is
    an example code snippit you can copy and mold
    towards your own.

11
  • www.headwaywebsolutions.com

12
3. WordPress Naming Conventions And Best
Practices
  • While writing code its best to follow
    regulations and guides set up by WordPress. Since
    there are so many functions defined already, you
    can avoid duplicity by providing prefix label to
    all your variables and function names.
  • www.headwaywebsolutions.com

13
  • lt?php  
  • function Subscribe_Widget()
  • widget_ops array( 'classname' gt
    'subscribe', 'description' gt __('An example
    widget that displays a quick subscribe now
    form.', 'subscribe') )
  • control_ops array( 'width' gt 300, 'height'
    gt 350, 'id_base' gt 'subscribe-widget' )
  • this-gtWP_Widget( 'subscribe-widget',
    __('Subscribe Widget', 'subscribe'), widget_ops,
    control_ops )
  • // the code
  •     
  • ?gt 
  • In the above examples we prefixed all our setting
    names with quick-subscribe-now. This can be
    replaced with any keyword of your choosing
    usually related to your plugin name.
  • www.headwaywebsolutions.com

14
4. Filters and Actions
  • Filters and actions are two completely different
    concepts which relate deeply in the ways they
    manipulate plugin data.
  • Understanding Add_filter()
  • A filter is used on a bit of text or data being
    passed into WordPress. With filters you are quite
    literally able to filter content through your own
    custom written functions to change data in any
    way.
  • Understanding Add_action()
  • Actions are similar to filters in that they dont
    work on bits of data but instead target
    pre-defined areas in your templates and admin
    panel.
  • www.headwaywebsolutions.com

15
  • Example you can apply an action whenever you
    update or edit a pages content. A small list of
    example actions
  • publish_post  called when a post is published or
    when status is changed into published
  • wp_head  called when the template is loaded and
    runs the wp_head() function
  • trackback_post  called whenever a new trackback
    is added into a post
  • www.headwaywebsolutions.com

16
Installing And Running The Plugin
  • Ive created a sample file for the plugin to demo
    if youd like to skip the hard coding. Simply
    download this file (rename it to .php) or
    copy/paste the code into a new PHP document and
    upload this to your /wp-content/plugins directory.
  • www.headwaywebsolutions.com

17
  • www.headwaywebsolutions.com

18
  • Once completed youll want to access the
    WordPress administration panel and browse your
    current set of plug-ins for the demo just
    installed. Once you activate nothing new will
    happen, not until we manually add in our function
    call. To do this simply navigates Appearance -gt
    Editor and look forsingle.php.
  • This file contains the entire template HTML/CSS
    for your basic article post page. Scroll down
    until you find the_content() and replace with the
    example code above. This will limit all your
    article pages to 55 characters no matter what
    view is being used. You could also add in this
    function to similar pages in your templates
    directory such as search.php or archive.php.
  • www.headwaywebsolutions.com

19
  • Thanks You for your valuable time, for more
    information feel free to contact us on
  • www.headwaywebsolutions.com
  • www.headwaywebsolutions.com
About PowerShow.com