I’d advise against using the [insert_php] shortcode. It’s not part of the core WP distribution and is intended for simpler PHP scripts than you are envisioning. The extra processing as a shortcode adds unnecessary overhead.
Since you are organizing content, this is really theme territory more than plugin territory. You don’t have to write a theme though. You create a child of your normal theme. Your PHP code would go on a custom page template. Add a new page based on this template so you have a permalink with which to request your content.
Load any javascript with wp_enqueue_script() called from code placed in your child theme’s functions.php. If you must use a plugin instead of a child theme, this is possible, but adding custom page templates from a plugin is rather convoluted.
Instead of adding a bunch of links to all the things I’ve mentioned, I’m going to let you search for them. The Google search from this site’s header works fine. Any links in the search results that go to the Codex or developer resources will be what you want. Ignore links to forums or plugins. If you have trouble finding something specific, let me know, I probably can find it. For the most part though, I figure you can search as well as I can 🙂
Thanks for the feedback. I will investigate your suggestion.
Roy
Thanks bcworkz (@bcworkz) for your feedback.
I’m not clear on how my “page contents” is a child Theme. I envision adding the “image viewer” as one of the elements within a Page or Post. I will continue to see if I can find something similar.
Another question, I would like to add either AJAX calls or regular <input….. submit> calls to allow the viewer to modify what is displayed. In my initial search all I find is in AJAX or <input> interaction with wp-admin.
There is nothing saved. The user is adjusting what is displayed.
Right, that’s my point actually. Your page content and associated code is not part of a child theme, but it should be. By creating a child theme, any custom work you do is safe from theme updates. Adding custom work to distributed themes is dangerous, it can all be lost in an update.
If you’re willing to use AJAX to generate all of your content, you may not need a custom page template. You still need a way to initiate an AJAX request. You could have the user add a shortcode to page content, or automatically create such a page on plugin or theme activation.
While it’s true AJAX requests need to go through /wp-admin/admin-ajax.php, the request can come from anywhere and thus the response is sent back to your script on that anywhere page. Your script can then add the returned data to a DOM element. WP doesn’t know if this script is on an admin page or not, and doesn’t care. The AJAX handler doesn’t need to save anything, but it does need to process the request and return an appropriate response.