1

I have a wordpress plugin, I want to use colorbox in it, For this i need to import javascript, and css in the plugin.

Here is my plugin code.

<?php

/*
Plugin Name: My Plugin
Plugin URI: http://www.abc.com/
Description: abc
Author: abc
Version: 1.0
Author URI: http://www.abc.com
*/

function calc_form_markup() {
$markup = <<<EOT



<form>

<input type="text" name="author" id="author" value="{$author_default}" size="22" />        
<label for="author"><small>Your name*</small></label><br>
<input type="text" name="email" id="email" value="{$email_default}" size="22" /> <label  
for="email"><small>Your contact e-mail*</small></label><br>
<input type="text" name="subject" id="subject" value="" size="22" /> <label  
for="subject"><small>Subject*</small></label><br> 
<input name="btn" type="button" id="btn" value="Send" onclick="calc();" /><br>

</form>

 EOT;

 return $markup;

}

add_shortcode('calc_form', 'calc_form_markup');

function calc_form_js() { ?>

 <script type="text/javascript">



 function calc()
{
alert ("My javascript function executes successfully...");  
}



</script>


<?php }

add_action('wp_head', 'calc_form_js');

?>

And i want to import following files in the above plugin.

<link rel="stylesheet" href="colorbox.css" />
<script src="jquery.min.js"></script>
<script src="colorbox.js"></script>

Thanks in advance

1 Answer 1

4

Check on the codex the functions wp_register_script and wp_enqueue_script

http://codex.wordpress.org/Function_Reference/wp_enqueue_script

for the css files , it is the same system

http://codex.wordpress.org/Function_Reference/wp_enqueue_style

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.