php - color picker issue in plug in development wordpress -


i trying add color picker in wordpress settings api plugin development. facing problem that. have code color picker.

// create function color picker. add_action( 'admin_enqueue_scripts', 'mw_enqueue_color_picker' ); function mw_enqueue_color_picker( $hook_suffix ) { // first check $hook_suffix appropriate admin page wp_enqueue_style( 'wp-color-picker' ); wp_enqueue_script( 'my-script-handle', plugins_url('my-script.js', __file__ ), array( 'wp-color-picker' ), false, true ); 

}

//call in input field option <tr valign="top"> <th scope="row"><label for="cursor_color">scrollbar color</label></th> <td> <input id= "cursor_color" type="text" name="ppmscrollbar_options[cursor_color]" value="<?php echo stripslashes($settings['cursor_color']);?>" class="my-color-field"/><p class="description">select icon holder color here. can add html hex code.</p> </td> </tr> 

//in my-script.js file have written bellow code.

jquery(document).ready(function($){ $('.my-color-field').wpcolorpicker(); }); 

i did not solve issue. can tell me can do?

i'm not sure why code not working, maybe issue not in code posted... following same yours, complete demonstration:

add_action('admin_menu', 'color_pick_so_23696173');  function color_pick_so_23696173() {      $my_page = add_dashboard_page(          'colorpick',          'colorpick',          'add_users',         'colorpick-page',          'color_pick_callback_so_23696173'      );     add_action( "admin_print_scripts-$my_page", 'enqueue_so_23696173' ); } function enqueue_so_23696173()  {     wp_enqueue_style( 'wp-color-picker' );     wp_enqueue_script(          'colorpick',          plugins_url( 'my-script.js', __file__ ),          array( 'wp-color-picker'),         false,         true     ); } function color_pick_callback_so_23696173() {      ?>     <div class="wrap">         <h2>test</h2>         <table>             <tr valign="top">             <th scope="row"><label for="cursor_color">scrollbar color</label></th>             <td>             <input id= "cursor_color" type="text" name="ppmscrollbar_options[cursor_color]" value="" class="my-color-field"/>             <p class="description">select icon holder color here. can add html hex code.</p>             </td>             </tr>         </table>     </div>     <?php } 

and my-script.js same yours.


Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -