WordPress Shortcode Calling External Script
Posted on 2014-07-27
Colleagues: This is for my own learning process, so I'm not interested in pre-manufactured countdown timers. It's my intent to deliberately reinvent this particular wheel so that I learn the process.
I'm looking for some guidance on how to write and install a WordPress Shortcode that produces a countdown timer. I've made some progress, for example, I expect the shortcode will look something like this:
[countdown]September 15, 2015[/countdown]
The design I'm contemplating would use jQuery/AJAX to repeatedly load() the output of a PHP script into a <div> that would be generated by the shortcode. I'm pretty comfortable that I have the PHP script right and the jQuery right. Where I need some help is the installation of the shortcode and the PHP script.
As I understand it, the countdown_timer() function will go into the functions.php file of my child theme. And in the same file, following the function definition, I would put something like this:
Since the PHP script is a separate program, not part of Wordpress, what is the right way to package it for distribution? And where in the directory structure should I put it?