5. About Me
• Work for the University of California, Irvine
• Computer Scientist
• Developer Evangelist
• Education Junkie
5
6. About Me
• WordPress Skillz
– Reaching my 10th anniversary developing
with WordPress (waiting for the party hat)
– Started with 2.0.5, building a custom theme.
– Now, I build highly specialized custom themes
and plugins for UCI as well as freelance
clients.
6
7. About Me
• Born in Texas
• Moved 76 times (2 countries, 6 states)
• I have over 130 cousins and second
cousins.
• Pink is my favorite color.
• Owls are my favorite animals.
7
8. About This Presentation
• Geared towards beginner to intermediate
folks
• Assumptions:
– You know what WordPress is.
– You know what PHP, XML, JSON are.
– You’re not afraid to look these things up later
or ask questions.
8
9. WP Heart What?
• WP Heartbeat API
• Bi-Directional Communication between
browser and server… without the user
ever having to trigger an event.
• Using XHR, WP Heartbeat sends ‘ticks’
every 15 seconds by default
9
10. API Information
• An API (Application Programmer
Interface) is a set of methods designed to
share information between systems.
• Usually uses SOAP (Simple Object
Access protocol) or REST
(Representational State Transfer)
services.
– Many cases send data via XML or JSON.
10
11. API Information
• WP Heartbeat API users:
– XMLHttpRequest (XHR) to communicate from
Browser to Server
– REST to send reponse from Server to
Browser
11
12. What Happens During a Beat?
• Browser sends a communication to server
via XHR request. This request can contain
information about the user, browser, or
behavior.
• Server receives the information and may
or may not do anything with it.
• Server hands a response back to Browser.
12
13. When does this happen?
• By default, every 15 seconds when logged
into the admin panel.
• Can be modified with “fast,” “medium,” or
“slow” values.
• Happens at this interval only when the
page is targeted.
• Once untargeted or idle, the tick slows
down.
• After idle for 1 hour, the tick is expired.
13
14. Is there a downside?
• In the beginning there were some
performance issues on some sites
• Some hosts disabled sites for too much
usage
• WordPress 4.1 released fixes that
expanded max heartbeat tick to 120
seconds and completely expires after an
hour.
14
15. Where is it implemented?
• Initially, WP Heartbeat is implemented in
the administrative panel.
– Allows notification of users viewing or editing
posts simultaneously
– Locks posts that are being edited
– Creates Auto-save triggers for post editing.
– Notifies user of session expiration (logout)
15
16. Can it be disabled?
• There are plugins available to control your
Heartbeat Ticks.
16
18. What’s Under the Hood
• heartbeat_settings filter you can modify
– Interval (15 – 60 seconds)
• This overrides the default interval
– Autostart (false)
• This disables autostart
18
19. How do I use it?
• Download and install
https://github.com/jeffikus/pulse
• Or create your own plugin
• Use the console in your browser to view
logged data
• Modify the pulse plugin to meet your
needs.
19
28. What are some uses for this?
• Alerting users of new content posted
• Letting a user know when a friend has
signed on.
• Creating a means of real-time-ish private
messaging
• Dynamically updating widgets/sidebars
(i.e. various advertisements)
• Editors can change content mid-read.
28