Advertisement
Guest User

Untitled

a guest
Mar 18th, 2019
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. class fiche_content{
  2. private $file_base;
  3. private $jenkins_url;
  4.  
  5. function __construct($jenkins_token){
  6. $this->file_base = plugin_dir_path( dirname( __FILE__ ) ) . 'fiche.php';
  7. $this->jenkins_url = $jenkins_url;
  8.  
  9. $this->init();
  10. }
  11.  
  12. function init() {
  13. add_action('wp_head', array( $this, 'js_scripts' ));
  14. add_action('wp_ajax_action_function', array( $this, 'action_function' ));
  15. }
  16.  
  17. function js_scripts(){
  18. $script = "
  19. <script type='text/javascript'>
  20. jQuery(document).ready(function($) {
  21. $(document).on('click', '#launchBuildForm',function(e){
  22. var url =" . $this->jenkins_url . ";
  23. $.ajax({
  24. method:'post',
  25. url: url,
  26. crossDomain: true,
  27. dataType: 'jsonp',
  28. data: {
  29. 'action': 'action_function'
  30. },
  31. success: function (msg) {
  32. console.log(msg);
  33. console.log('success');
  34. },
  35. error: function(jqXHR, textStatus, errorThrown){
  36. console.log(jqXHR, textStatus, errorThrown);
  37. }
  38. });
  39. });
  40. });
  41. </script>
  42. ";
  43. echo $script;
  44. }
  45.  
  46.  
  47. function action_function(){
  48. echo 'test';
  49. wp_die();
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement