Make WordPress Core

Opened 13 years ago

Closed 13 years ago

Last modified 13 years ago

#18365 closed enhancement (wontfix)

Javascript Access to Basic Wordpress Functions

Reported by: mneil's profile mneil Owned by:
Milestone: Priority: normal
Severity: minor Version:
Component: General Keywords:
Focuses: Cc:


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.



function bloginfo(s)

if(!s)s = "wpurl";
this.wpurl = "<?php bloginfo("wpurl"); ?>";

return this[s];




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.

Change History (2)

#1 @scribu
13 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to wontfix
  • Status changed from new to closed

You're free to pass whatever data you like using wp_localize_script().

No need to clutter the js window object with variables that are only used by plugins.

#2 @scribu
13 years ago

More to the point, yes, bloginfo('wpurl') is more familiar than MyPluginData.wpurl, but the overhead is just not worth it.

Last edited 13 years ago by scribu (previous) (diff)
Note: See TracTickets for help on using tickets.