add javascript code wordpress

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

About

vladimir prelovac Vladimir Prelovac is CEO of Prelovac Media, a computer engineer by profession and an adventurer by state of mind. more +


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

Services

Manage multiple WordPress sites

Built for WordPress enthusiasts, ManageWP helps you manage all your WordPress sites from one central location.

Books

WordPress Plugin Devleopment Book Read my book WordPress Plugin Development: Beginner's Guide

Published by Packt Publishing, available online through Amazon.