jquery - How to add a javascript file to my wordpress plugin? -


i want integrate share button wordpress plugin, know there many plugins it, want button @ end of specific page.

i added controller, 1 loads/registers rest of javascripts, not working.

here code controller

        wp_enqueue_script(             'wpproquiz_front_javascript',             plugins_url('js/wpproquiz_front' . (wpproquiz_dev ? '' : '.min') . '.js', wpproquiz_file),             array('jquery-ui-sortable'),             wpproquiz_version,             $footer         );          wp_register_script(                  //this js file registering             'share_button_javascript',             plugins_url('js/sharebutton.js', __file__)          );          //wp_enqueue_script('share_button_javascript');          wp_localize_script('wpproquiz_front_javascript', 'wpproquizglobal', array(             'ajaxurl' => admin_url('admin-ajax.php'),             'loaddata' => __('loading', 'wp-pro-quiz'),             'questionnotsolved' => __('you must answer question.', 'wp-pro-quiz'),             'questionsnotsolved' => __('you must answer questions before can completed quiz.',                 'wp-pro-quiz'),             'fieldsnotfilled' => __('all fields have filled.', 'wp-pro-quiz')         )); 

and here code in view of same controller

<script>var sharebutton = new sharebutton()</script> <sharebutton>share</sharebutton> 

can tell me doing wrong here?

do this:

wp_enqueue_script(             'wpproquiz_front_javascript',             plugins_url('js/wpproquiz_front' . (wpproquiz_dev ? '' : '.min') . '.js', wpproquiz_file),             array('jquery-ui-sortable'),             wpproquiz_version,             $footer         );          //this js file registering          wp_register_script('share_button_javascript', plugins_url('js/sharebutton.js', __file__), array('jquery'), '', true);        wp_enqueue_script('share_button_javascript');          //wp_enqueue_script('share_button_javascript');          wp_localize_script('wpproquiz_front_javascript', 'wpproquizglobal', array(             'ajaxurl' => admin_url('admin-ajax.php'),             'loaddata' => __('loading', 'wp-pro-quiz'),             'questionnotsolved' => __('you must answer question.', 'wp-pro-quiz'),             'questionsnotsolved' => __('you must answer questions before can completed quiz.',                 'wp-pro-quiz'),             'fieldsnotfilled' => __('all fields have filled.', 'wp-pro-quiz')         )); 

Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -