Slide 1

Slide 1 text

An Introduction to Plugin Development Cameron Jones

Slide 2

Slide 2 text

@cameronjonesweb An Introduction to Plugin Development What We’re Gonna Build We will be building a plugin to customise the WordPress login screen with our own logo

Slide 3

Slide 3 text

@cameronjonesweb An Introduction to Plugin Development About Me Cameron Jones Freelance WordPress developer Founder of Mongoose Marketplace @cameronjonesweb on all the things ● Made my first website in 2006 with Microsoft Publisher ● Started programming in 2008 with Flash Actionscript 2.0 to make flash games ● Fell in love with WordPress in 2014 ● Released my first plugin on WordPress.org in 2015 ● Released my first premium plugin in 2019

Slide 4

Slide 4 text

@cameronjonesweb An Introduction to Plugin Development What You Need To Know ● What a plugin is ● Where plugins are installed ● A little bit of PHP

Slide 5

Slide 5 text

@cameronjonesweb An Introduction to Plugin Development What You Need To Build A Plugin ● A local development environment ● A text editor

Slide 6

Slide 6 text

@cameronjonesweb An Introduction to Plugin Development Local Development Environments

Slide 7

Slide 7 text

@cameronjonesweb An Introduction to Plugin Development Text Editors

Slide 8

Slide 8 text

@cameronjonesweb An Introduction to Plugin Development That’s All We Need To Get Started

Slide 9

Slide 9 text

@cameronjonesweb An Introduction to Plugin Development WordPress Hook System The WordPress hook system is how WordPress knows when to run your code There are two types of hooks ● Actions ● Filters

Slide 10

Slide 10 text

@cameronjonesweb An Introduction to Plugin Development WordPress Hooks - Syntax & Parameters ● Hook name ● Callback ● Priority ● Arguments

Slide 11

Slide 11 text

@cameronjonesweb An Introduction to Plugin Development WordPress Hooks - Actions Actions are like an event, allowing you to run your code when something specific occurs

Slide 12

Slide 12 text

@cameronjonesweb An Introduction to Plugin Development WordPress Hooks - Filters Filters are like a sieve, allowing you to change data before it gets used

Slide 13

Slide 13 text

@cameronjonesweb An Introduction to Plugin Development WordPress Hooks - Actions

Slide 14

Slide 14 text

@cameronjonesweb An Introduction to Plugin Development WordPress Hooks - Filters

Slide 15

Slide 15 text

@cameronjonesweb An Introduction to Plugin Development WordPress Hook System Pro Tips! ● Add your own hooks to allow other developers to extend your plugin developer.wordpress.org/plugins/hooks/ custom-hooks

Slide 16

Slide 16 text

@cameronjonesweb An Introduction to Plugin Development Can We Build Our Plugin Yet?

Slide 17

Slide 17 text

@cameronjonesweb An Introduction to Plugin Development Building Our Plugin ● Set up the file structure ● Add the plugin file header ● Write our code!

Slide 18

Slide 18 text

@cameronjonesweb An Introduction to Plugin Development Set Up Our File Structure ● Create a folder inside wp-content/plugins for our plugin ● Create a PHP file in our folder ● Create a CSS file in our folder ● Copy our logo into the folder

Slide 19

Slide 19 text

@cameronjonesweb An Introduction to Plugin Development Set Up Our File Structure Pro Tips! ● Make the folder name as unique as possible to avoid conflicts with plugins on WordPress.org ● Use the same name for the folder and the PHP file

Slide 20

Slide 20 text

@cameronjonesweb An Introduction to Plugin Development Add The Plugin File Header The Plugin File Header provides WordPress with important information about our plugin. It is added to the main PHP file for the plugin.

Slide 21

Slide 21 text

@cameronjonesweb An Introduction to Plugin Development Plugin File Header

Slide 22

Slide 22 text

@cameronjonesweb An Introduction to Plugin Development Plugin File Header Pro Tips! ● Your plugin will need to be licensed under the GPL v2 (or later) if you wish to distribute it

Slide 23

Slide 23 text

@cameronjonesweb An Introduction to Plugin Development Prevent Direct File Access

Slide 24

Slide 24 text

@cameronjonesweb An Introduction to Plugin Development Load Our Custom Styles On The Login Page

Slide 25

Slide 25 text

@cameronjonesweb An Introduction to Plugin Development Load Our Custom Styles On The Login Page Pro Tips! ● Make your function and variable names as unique as possible to avoid conflicts with other plugins and themes

Slide 26

Slide 26 text

@cameronjonesweb An Introduction to Plugin Development Replace The Logo On The Login Page

Slide 27

Slide 27 text

@cameronjonesweb An Introduction to Plugin Development Change The Link The Logo Goes To

Slide 28

Slide 28 text

@cameronjonesweb An Introduction to Plugin Development Change The Logo Link Text

Slide 29

Slide 29 text

@cameronjonesweb An Introduction to Plugin Development Tada

Slide 30

Slide 30 text

@cameronjonesweb An Introduction to Plugin Development Can I Release This On WordPress.org?

Slide 31

Slide 31 text

@cameronjonesweb An Introduction to Plugin Development Can I Release This On WordPress.org? Pro Tips! ● Your plugin should adhere to the plugin guidelines developer.wordpress.org/plugins/ wordpress-org/detailed-plugin- guidelines ● You will need to learn how to use SVN developer.wordpress.org/plugins/ wordpress-org/how-to-use-subversion

Slide 32

Slide 32 text

@cameronjonesweb An Introduction to Plugin Development Can I Release This On WordPress.org? Pro Tips! ● Adhere to the WordPress coding standards make.wordpress.org/core/handbook/best -practices/coding-standards ● Make sure your plugin is translatable developer.wordpress.org/plugins/ internationalization/localization

Slide 33

Slide 33 text

@cameronjonesweb An Introduction to Plugin Development Can I Release This On WordPress.org? Pro Tips! ● Use nonces and capability checks when processing forms ● Always escape and sanitise user input developer.wordpress.org/plugins/security

Slide 34

Slide 34 text

@cameronjonesweb An Introduction to Plugin Development WordPress Plugin Development For Beginners skl.sh/2IrEvrA

Slide 35

Slide 35 text

@cameronjonesweb An Introduction to Plugin Development Links For demo code and slides visit: mongoosemarketplace.com/wcbne19