[wp-trac] [WordPress Trac] #18365: Javascript Access to Basic Wordpress Functions
WordPress Trac
wp-trac at lists.automattic.com
Tue Aug 9 23:39:01 UTC 2011
#18365: Javascript Access to Basic Wordpress Functions
-------------------------+-----------------------------
Reporter: mneil | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: General | Version:
Severity: minor | Keywords:
-------------------------+-----------------------------
I believe it would be useful for developers to add a few of the core
functions of wordpress into JavaScript. For instance, I find myself
needing the site url often. I know there are a few JS contants wordpress
provides, like ajax_url ( and I believe the site url is also available),
but to put these into a format like php would be useful.
Example:
<script>
function bloginfo(s)
{
if(!s)s = "wpurl";
this.wpurl = "<?php bloginfo("wpurl"); ?>";
return this[s];
}
console.log(bloginfo("wpurl"));
</script>
This file could easily be generated and included into the wordpress head
so that at least basic data can be retrieved in a similar manner in both
JavaScript and PHP. If there is any interest in this at all I would be
happy to help come up with the full solution.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/18365>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list