Tuesday, 4 April 2017

How to Add Colorpicker in wordpress.

Add function.php 

function jcorgytce_enqueue_color_picker() {
   wp_enqueue_style( 'wp-color-picker' );
   wp_enqueue_script( 'script_handle', plugins_url('your_javascript_file.js', __FILE__ ), array( 'wp-color-picker' ), false, true );
}
add_action( 'admin_enqueue_scripts', 'my_color_picker_function' );


Add JS file :

<script type="text/javascript">
  jQuery(document).ready(function($){
           $('.color-picker').wpColorPicker();
  });
 </script>


<input type="text" class="color-picker" name="overlay_color" value="#EEE" data-default-color="#effeff" />



No comments:

Post a Comment