WordPress Plugin Development Stirred Not Shaken - Jonathan Desrosiers

1y ago
4 Views
2 Downloads
1.80 MB
46 Pages
Last View : 1m ago
Last Download : 3m ago
Upload by : Harley Spears
Transcription

WordPress Plugin DevelopmentStirred not ShakenJonathan DesrosiersTwitter: @DesrosjWordCamp Providence1

Break the IceTwitter: @Desrosj From Dartmouth, Massachusetts Love Sports (Baseball & Hockey are my 1, 2) Graduated from Johnson & Wales University Providence Love a good challenge and learning new things Hobbies include Kayaking, Photography, and long walks on thebeach.2

WordPress Experience Developing for WordPress since about 2008 (Can’t remember the loveat first site moment) Plugins on the WordPress.org Repository Two years WordPress VIP programming experience for sites likeTechCrunch3

Goals Here Cover the basics, and introduce some advanced practices andmethods. Everyone gets something out of this.Make sense of the many aspects of plugin development. It is extremely easy to become overwhelmed with the massiveamount of tutorials and resources that are available to you. Stirred vs. Shaken4

5

What The Heck’s A Plugin? Plugins are tools to extend the functionality of WordPress.6

Examples Please? Jetpack by WordPress.com Adds WordPress.com features to your self hosted WordPress sites such as GravatarHovercards, Social Media Sharing and more.Gravity Forms Easily create forms in the WP Admin. Provides conversion tracking.7

How To Make A Plugin Four Stages Planning Implementation Release Support8

Use The WordPress Codex9

1. Planning What is the purpose of your plugin? What does it need to do? When should these actions be performed? What are your components? JS? CSS? Will there be an admin panel?10

2. Implementation Follow WordPress Coding Standards http://codex.wordpress.org/WordPress Coding Standards11

What Makes A Good Plugin Feel like it is a part of WordPress If the user can tell where WordPress ends and your plugin begins,you probably should try to do things differently. Only does what it is expected to. It uses WordPress features such as post meta, Settings API, displayclasses such as WP List Table. Don’t reinvent the wheel.Doesn’t break anything else! It just works.12

Don’t Reinvent The Wheel13

Naming Accurately represent your plugin Be unique - Nobody likesa copy cat.14

Plugin Header Plugin Header15

Actions & Filters Actions add functionality. Filters alter or change information.16

Actions Actions are triggered by specific events that take place in WordPress,such as publishing a post, changing themes, or displaying a page ofthe admin panel. Allows you to only execute code when it is needed. Each action hook passes specific information to the functionsattached.17

Action Example18

Some Useful Action Hooks save post init Used to create widget areas, nav menu locations, etc.wp enqueue scripts Runs when a post is saved.Used to enqueue scripts and stylesheets.admin menu Used to add menus to the admin interface.19

Filters Filters are functions that WordPress passes data through, at certainpoints in execution, just before taking some action with the data (suchas adding it to the database or sending it to the browser screen). Filters sit between the database & output, or input and thedatabase. Almost every input and output to the site is passed through at leastone filter. Allows you to alter things to display or save the way you need.20

Filter Example21

Some Useful Filters the content Alter the output of the post contentthe excerpt Alter the output of post excerpt22

Actions & Filters Pretty damn useful. Allow you to alter the output and functionality of the site withouthaving to alter Core WordPress (which you should never do). Allows for easy updates when new WordPress versions areavailable.23

Loading Scripts The Right Way24

Loading Scripts The Right Way25

Loading Scripts The Right Way26

Loading Scripts The Right Way What happens when you have 10 plugins that require jQuery?27

Loading Scripts The Right Way28

Works For Stylesheets Too!29

Admin Only Scripts/Styles30

Passing Dynamic Info to JS wp localize script() - Pass dynamic information to your JS31

Input & Output Sanitation NEVER trust user input. Always make sure your output is formattedproperly.32

Input & Output Sanitation All user input should be sanitized. * kses() - Strips harmful HTML santize text field() - Sanitizes a string for database storageAll output should be properly escaped for display esc attr() - Escapes strings for use in an HTML Attribute. esc js() - Escapes strings for output within script tags esc url() - Sanitizes and escapes a URL.33

Namespace Your Functions Non Class Approach Prepend a string to all of your functions jwp function name() Prevents fatal PHP errors from duplicate function names.34

Namespace Your Functions Class Approach35

Settings, Post Meta, User Meta Namespace all settings, post meta, and user meta to avoid conflict! jwp user meta key jwp option name36

Only Run Code When Needed! Be specific with your action & filter hooks. Most hooks not only run the default, but also run more specificactions or filters.37

Only Run Code When Needed! Be specific with your action & filter hooks.38

1?IA8@*ts%7 (aka I’m Stuck!)39

1?IA8@*ts%7 (aka I’m Stuck!) Make sure WP DEBUG is turned on. Debug Bar Plugin & Extensions Start with a fresh install of WordPress, and a default theme These are mostly bug free.40

Uninstalling Your Plugin We are sorry to see you go ;-( But we will remove our plugin info for you! Prevents useless entries in the DB Helps users keep their sites optimized.41

Uninstalling Your Plugin Include uninstall.php in your plugin folder42

The Next Level Add admin pages for input, and configuration. Adding AJAX Actions Use Transients for temporary data. Using wp remote get() and wp remote post()43

The Next Level Creating your own hooks and filters I18n (Internationalization) Integrate Crons44

Web Designer's Guide toWordPress45

Questions? Comments? Compliments? Twitter: @Desrosj http://jonathandesrosiers.com Slides will be posted soon.46

What Makes A Good Plugin Feel like it is a part of WordPress If the user can tell where WordPress ends and your plugin begins, you probably should try to do things differently. Only does what it is expected to. It uses WordPress features such as post meta, Settings API, display classes such as WP_List_Table. Don't reinvent the wheel. Doesn't break anything else!

Related Documents:

abrt-plugin-bugzilla x abrt-plugin-filetransfer x abrt-plugin-logger x abrt-plugin-mailx x abrt-plugin-reportuploader x abrt-plugin-runapp x abrt-plugin-sosreport x abrt-python x x abrt-tui x x x abyssinica-fonts x . 3 Oracle Linux and Oracle VM Included .

11. Integrate downloaded Plugin with your Grails project: i. Grails 2.0 users can install Grails Plugin with the following command: grails install-plugin app-forty-two-paas ii. Grails 1.3.3/1.3.7 users need to add an extra plugin repository definition

PLUGIN RIG HOST Thank you for purchasing the Nembrini Audio Plugin Rig Host. The Plugin Rig was created on our customers demand to manage all the Nembrini Audio plugins in a single easy to use interface. Nembrini Audio Plugin Rig allows you to create your dream Fx and Amp chains which you can save and recall at your disposal. This is a perfect environment for the

11. Integrate downloaded Plugin with your Grails project: i. Grails 2.0 users can install Grails Plugin with the following command: grails install-plugin app-forty-two-paas ii. Grails 1.3.3/1.3.7 users need to add an extra plugin repository definition in BuildConfig.groovy: repositories { grailsPlugins() grailsHome() grailsCentral()

Installation and plugin activation 1 The plugin will appear in the Lightroom Classic "Plug-in Manager" after the successful installation. (File- Plug-in Manager). 2 If the LED next to the plugin is gray, the plugin has to be activated first in the status section. 3 In rare cases the plugin won't appear in the "Plug-in Manager" after the

3. WAVES CLA Epic Plugin User Guide CLA Epic User Guide Introduction Thank you for choosing Waves!. 4. WAVES JJP Drums Plugin User Guide WAVES JJP DRUMS User Guide Chapter 1 - Introduction Welcome. 5. WAVES CLA-3A Compressor Limiter Plugin User Manual CLA-3A Compressor Limiter Plugin WAVES CLA-3A User Manual TABLE OF. 6. WAVES CLA-2A .

WordPress Themes WordPress Premium Themes WordPress Free Themes WordPress Plugins ite Templates WordPress Hosting WordPress.com CreativeMarket.com . with crowdfunding b Astoundif plugin and fundif theme. Plugin will empower o

investigate the behaviour and transient response of a fuel cell system for automotive applications. Fuel cell dynamics are subjective to reactant flows, heat management and water transportation inside the fuel cell. Therefore, a control-oriented model has been devised in Aspen Plus Dynamics, which accommodates electrochemical, thermal, feed flow and water crossover models in addition to two .