1

I want to trigger a notification to appear in the bottom of the user's screen when I publish a new post on my Wordpress blog (for very committed readers!).

Edit: I forgot to say, I need c2 lines of the post text to appear in the notification!

I've read up on notifications in the HTML5 API. E.g.: http://www.html5rocks.com/en/tutorials/notifications/quick/

I understand from a previous post on SE that the Javascript (or the client side in general) needs to be passed the notification from the server side. Can a web app give desktop notification

I can add a filter action in Wordpress for when the post is published, using a plugin. http://codex.wordpress.org/Plugin_API#Create_an_Action_Function

Then I think the plugin needs to pass the variable into the JavaScript script, which can then be picked up by the HTML5 API. https://wordpress.stackexchange.com/questions/50770/add-javascript-when-post-is-published

If anybody can help me connect the dots on this, and lay out step by step how it could work, it would be much appreciated! Thanks

(PS apart from Wordpress, none of the tech choices above are mandatory)

Community
  • 1
  • 1
Michael Jones
  • 80
  • 1
  • 7

1 Answers1

0

Use the information from https://wordpress.stackexchange.com/questions/50770/add-javascript-when-post-is-published you provided but instead of doing an alert() in the notice.js example trigger a message with jQuery. There are some notification plugins you could use for minimal coding: http://webtoolkit4.me/2009/08/13/jquery-growl-likenotification-systems/.

Community
  • 1
  • 1
Conner
  • 30,144
  • 8
  • 52
  • 73
  • I think the author wants to have real desktop notifications, not in- browser-tab notifications. Related: http://stackoverflow.com/questions/10470518/javascript-nofitication-solution-library-desktop-audible-popup-titlebar-blin – Mikko Ohtamaa Jul 02 '12 at 22:54
  • Hi, thanks for the replies. Either desktop or in-browser tab is ok as a starting point. The bit I'm really struggling with is piecing together the sequence from the Wordpress action hook, to the script. Thanks again. – Michael Jones Jul 03 '12 at 06:34