wordpress plugin add javascript

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.'/'.
18 Comments

About Vladimir

vladimir prelovac Hi! My name is Vladimir Prelovac. I am a computer engineer by profession and an adventurer by state of mind.

"I would love to change the world, I just don't have the source code yet."

Books by Vladimir

WordPress Plugin Devleopment Book WordPress Plugin Development: Beginner's Guide

Published by Packt Publishing, available online through Amazon. Click the image for more information.

Consulting Services

Professional WordPress solutions based on custom developed plugins and themes

Expert on-site WordPress SEO consulting and an 'out-of-the-box thinking' approach to problems