wordpress wp_localize_script

Best practice for adding JavaScript code to WordPress plugins

This article is intended as a guide on how to add JavaScript code to your plugins. Here is a practical example from WP Wall plugin. Start by hooking your function to wp_print_action: add_action('wp_print_scripts', 'WPWall_ScriptsAction'); Next, add the scripts you want to use: function WPWall_ScriptsAction() { $wp_wall_plugin_url = trailingslashit( get_bloginfo('wpurl') ).PLUGINDIR.'/'. dirname( plugin_basename(__FILE__) ); if (!is_admin()) […]
Comments closed