SlideShare a Scribd company logo
Avinash Kundaliya: Javascript and WordPress
JAVASCRIPT
     &
 WORDPRESS
AVINASH KUNDALIYA (@HARDFIRE)
           <3 JS & PHP
IS JAVASCRIPT
IMPORTANT ??
USED BY 92.3% SITES
 OCTOBER 2012 - W3TECHS.COM
>80% RELY FOR IMPORTANT FUNCTIONALITY
UBIQUITOUS.
CAN MAKE SITE SLOW
  IF DONE THE WRONG WAY
Avinash Kundaliya: Javascript and WordPress
CAN MAKE SITE UNUSABLE
  IF DONE TOTALLY THE WRONG WAY
I AM CONVINCED !!
WE SHOULD USE JS, THE RIGHT WAY
JAVASCRIPT
SOME DIFFERENTIATING PARTS
VAR
GLOBAL SCOPE BY DEFAULT
a=5;
function say() {
    a=3;
    console.log(a);
}
say();
console.log(a);

3
3 // whoa!
USE VAR KEYWORD
a=5;
function say() {
    var a=3;
    console.log(a);
}
say();
console.log(a);

3
5 // thank god! :D
HOISTING
   var val = 'namaste';
   (function() {
     console.log(val); // namaste
   })();

   var val = 'namaste';
   (function() {
     console.log(val); // undefined
     var val = 'ola!';
   })();


Wherever i define my variable, the initialization will be *hoisted*
                          to the top.
THIS
Elsewhere : current object instantiated by the class
    JS : depends on how the function is called.
     this refers to the owner of the function
THIS : WINDOW ( FUNCTION CALL )
function what_is_this() {
    console.log(this);
}
what_is_this(); //window
THIS : OBJECT ( OBJECT METHOD )
var thisObject = {
    thisFunc: function(){
        console.log(this);
    }
}
thisObject.thisFunc(); //thisObject
THIS : OBJECT ( CONSTRUCTING OBJECTS USING NEW )
function WordCamp(year){
    this.year = year;
    this.yellOut = function(){
        console.log("Yay! it is WC "+ this.year);
    }
}
var wc2012 = new WordCamp(2012);
wc2012.yellOut(); // Yay! it is WC 2012




var wc2011 = WordCamp(2011);
wc2012.yellOut(); // Undefined
yellOut(); // Yay! it is WC 2011
FUNCTIONS : FIRST CLASS
FUNCTION DECLARATION
function say() {
    var a=3;
    console.log(a);
}
say();




                        FUNCTION EXPRESSION
var say = function(){
    var a=3;
    console.log(a);
}
say();
function say(func) {
    var a=3;
    func(a);
}
say(console.log);


                       SEE, I CAN PASS FUNCTIONS
function say(func) {
    var a=3;
    func(a);
}
say(function(name){alert(name)});


                 EVEN FUNCTIONS WITHOUT A NAME
CODE TWISTERS
function foo(){
    function bar() {
        return 3;
    }
    return bar();
    function bar() {
        return 8;
    }
}
alert(foo());


                          Output : 8
CODE TWISTERS
 function foo(){
     var bar = function() {
         return 3;
     };
     return bar();
     var bar = function() {
         return 8;
     };
 }
 alert(foo());


                                 Output : 3
Code examples from http://javascriptweblog.wordpress.com/
THINGS MIGHT JUST GO WRONG
function getTenFunctionsBad() {
  var result = [];
  for (var i = 0; i < 10; i++) {
    result.push(function () {
      return i;
    });
  }
  return result;    }
var functionsBad = getTenFunctionsBad();
for (var i = 0; i < 10; i++) {
  console.log(functionsBad[i]());   }

10 , 10 , 10 , 10 , 10 , 10 , 10 , 10 , 10 , 10
BUT WE CAN FIX THEM
function getTenFunctions() {
  var result = [];
  for (var i = 0; i < 10; i++) {
    result.push((function (i) {
      return function () {
        return i;
      }
    })(i));     }
  return result;     }
var functions = getTenFunctions();
for (var i = 0; i < 10; i++) {
  console.log(functions[i]());     }
0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9
OK! LET'S TALK ABOUT WORDPRESS
add_action('wp_head', 'add_my_script');

function add_my_script() {
?>
<script type="text/javascript"
        src="<?php bloginfo('wpurl'); ?>/wp-content/plugins/my-plugin/jquery.js"></sc
ript>

<script type="text/javascript"
        src="<?php bloginfo('wpurl'); ?>/wp-content/plugins/my-plugin/my-script.js"><
/script>

<?php
}
Avinash Kundaliya: Javascript and WordPress
LET'S DO IT LIKE THE PRO'S
    wp_register_script
    wp_deregister_script
    wp_enqueue_script
    wp_dequeue_script
WP_REGISTER_SCRIPT                @COD EX


                    Yo WP! Remember this script

(
$handle, //name of the script
$src, // url to script
$deps, // array of dependencies
$ver, //version of code
$in_footer // place in footer?
);
WP_REGISTER_SCRIPT - EXAMPLE
wp_register_script (
  'mytheme-custom', // handle WP will know JS by
  get_template_directory_uri() . '/js/custom.js',
  array('jquery'), // requires jQuery
  1.0, // version 1.0
  true // can load in footer
);


              Don't hardcode. Use plugins_url or
               get_template_directory_uri

                Many predefined libraries @codex
WP_DEREGISTER_SCRIPT                       @COD EX


                   Yo WP! forget about this script
wp_deregister_script('jquery');
WP_ENQUEUE_SCRIPT                @COD EX


             Yo WP! Please put the script in my page

wp_enqueue_script( $handle , $src , $deps ,
                    $ver , $in_footer );
A LITTLE COMPLEX EXAMPLE
function my_scripts_method() {
    wp_deregister_script( 'jquery' );
    wp_register_script( 'jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/
jquery.min.js');
    wp_enqueue_script( 'jquery' );
}

add_action('wp_enqueue_scripts', 'my_scripts_method');


Use jQuery from google CDN instead of WordPress local
WP_DEQUEUE_SCRIPT           @COD EX


Hey WP! Someone put this script in my page, remove it please
  wp_dequeue_script($handle);
EXAMPLE
wp_register_script( 'jquery.flexslider',
    get_template_directory_uri().'/js/flex.js',
    array('jquery'), '1.7', true );
wp_register_script( 'home-page-slider',
     get_template_directory_uri().'/js/slider.js',
     array('jquery.flexslider'), '1.0', true );
if ( is_front_page() ) {
wp_enqueue_script('home-page-slider');
}
WP_LOCALIZE_SCRIPT                                 @COD EX


            Send data from WordPress to JavaScript
wp_localize_script( $handle, $object_name, $l10n );




                              SIMPLE EXAMPLE
wp_enqueue_script( 'some_handle' );
$translation_array = array( 'some_string' => __( 'Some string to translate' ), 'a_val
ue' => '10' );
wp_localize_script( 'some_handle', 'object_name', $translation_array );

console.log(object_name.some_string);
WP_LOCALIZE_SCRIPT EXAMPLE
wp_localize_script(
  'simplecatch_custom_slider', 'js_value',
  array(
    'transition_effect' => $transition_effect,
    'transition_delay' => $transition_delay,
    'transition_duration' => $transition_duration
  ));
AJAX IN WP
require_once( "../../../../wp-config.php" );
// or require_once( "../../../../wp-load.php" );




                  PLEASE DON'T TRY THIS AT HOME!
WP_AJAX_(ACTION)                     @COD EX

jQuery.post(
   MyAjax.ajaxurl,
   {
      'action':'add_foobar',
      'data':'foobarid'
   },
   function(response){
      alert('The server responded: ' + response);
   }
);
WP_AJAX_(ACTION)
add_action('wp_ajax_add_foobar',
            'prefix_ajax_add_foobar');

function prefix_ajax_add_foobar() {
   //Do Something really awesome here :)
   exit;
}
BUT WHY ?
SUMMING UP
var
this
functions awesomeness
use wordpress helper functions
WHAT NEXT
    "use strict"
    closures
    functional programming
    more quirks : JS Garden
“ Go make something awesome! ”
?
THE END :'(
- AVINASH KUNDALIYA / @HARDFIRE
Avinash Kundaliya: Javascript and WordPress

More Related Content

PPTX
Workshop 1: Good practices in JavaScript
PDF
Complex Sites with Silex
PDF
Workshop 10: ECMAScript 6
PPTX
Webrtc mojo
KEY
Single Page Web Applications with CoffeeScript, Backbone and Jasmine
PDF
Asynchronous programming patterns in Perl
PDF
Ruby - Design patterns tdc2011
PDF
JAVASCRIPT NÃO-OBSTRUTIVO com jQuery
Workshop 1: Good practices in JavaScript
Complex Sites with Silex
Workshop 10: ECMAScript 6
Webrtc mojo
Single Page Web Applications with CoffeeScript, Backbone and Jasmine
Asynchronous programming patterns in Perl
Ruby - Design patterns tdc2011
JAVASCRIPT NÃO-OBSTRUTIVO com jQuery

What's hot (20)

PDF
Desenvolvendo APIs usando Rails - Guru SC 2012
PPT
Testing Javascript with Jasmine
PDF
Aplicacoes dinamicas Rails com Backbone
PDF
Reliable Javascript
PDF
Rails is not just Ruby
PPTX
Zero to SOLID
PDF
06 jQuery #burningkeyboards
PDF
05 JavaScript #burningkeyboards
PDF
Excellent
PDF
How to develop modern web application framework
PDF
優しいWAFの作り方
PDF
Keeping it Small: Getting to know the Slim Micro Framework
PPTX
AngularJS Architecture
PDF
Angular promises and http
PDF
Mojolicious
PDF
Developing apps using Perl
PPTX
Avoiding callback hell in Node js using promises
KEY
amsterdamjs - jQuery 1.5
PDF
Inside Bokete: Web Application with Mojolicious and others
Desenvolvendo APIs usando Rails - Guru SC 2012
Testing Javascript with Jasmine
Aplicacoes dinamicas Rails com Backbone
Reliable Javascript
Rails is not just Ruby
Zero to SOLID
06 jQuery #burningkeyboards
05 JavaScript #burningkeyboards
Excellent
How to develop modern web application framework
優しいWAFの作り方
Keeping it Small: Getting to know the Slim Micro Framework
AngularJS Architecture
Angular promises and http
Mojolicious
Developing apps using Perl
Avoiding callback hell in Node js using promises
amsterdamjs - jQuery 1.5
Inside Bokete: Web Application with Mojolicious and others
Ad

Viewers also liked (7)

PDF
The little-joomla-seo-book-v1
PPT
Reptile repro. and diseases
PPTX
Ecommerce webinar-oct-2010
DOCX
In the kitchen
PDF
3 d design profile [aksatech]
PDF
Webmaster guide-en
PPT
Present forms
The little-joomla-seo-book-v1
Reptile repro. and diseases
Ecommerce webinar-oct-2010
In the kitchen
3 d design profile [aksatech]
Webmaster guide-en
Present forms
Ad

Similar to Avinash Kundaliya: Javascript and WordPress (20)

PPTX
ReactJs presentation
PDF
The Beauty of Java Script
PDF
The Beauty Of Java Script V5a
PDF
Frontin like-a-backer
PDF
jQuery & 10,000 Global Functions: Working with Legacy JavaScript
PPTX
10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)
PDF
Javascript Frameworks for Joomla
PDF
Intro to jquery
PDF
Building Large jQuery Applications
PDF
Virtual Madness @ Etsy
PDF
Ajax on drupal the right way - DrupalCamp Campinas, São Paulo, Brazil 2016
PDF
Future of Web Apps: Google Gears
PDF
jQuery: Events, Animation, Ajax
PPT
WordPress and Ajax
PDF
Frameworks da nova Era PHP FuelPHP
PPT
symfony & jQuery (phpDay)
ODP
JavaScript Web Development
PDF
Dependency Management with RequireJS
PDF
Javascript: the important bits
ReactJs presentation
The Beauty of Java Script
The Beauty Of Java Script V5a
Frontin like-a-backer
jQuery & 10,000 Global Functions: Working with Legacy JavaScript
10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)
Javascript Frameworks for Joomla
Intro to jquery
Building Large jQuery Applications
Virtual Madness @ Etsy
Ajax on drupal the right way - DrupalCamp Campinas, São Paulo, Brazil 2016
Future of Web Apps: Google Gears
jQuery: Events, Animation, Ajax
WordPress and Ajax
Frameworks da nova Era PHP FuelPHP
symfony & jQuery (phpDay)
JavaScript Web Development
Dependency Management with RequireJS
Javascript: the important bits

More from wpnepal (18)

PDF
Mahadev Subedi: WordPress Security & Defense Mechanism
PDF
Pankaj Agrawal: eLearning on WordPress
PPTX
Jimba Tamang: 5 reasons why “Parallax Websites” are awesome and how to create...
PDF
Ujwal Thapa: WordPress as a Blogging Platform
PDF
Yalamber Subba: WordPress Jobs & Freelance Marketplaces
PDF
Vinay Paudel: Optimizing and Speeding up a WordPress site
PDF
Sanjip Shah: Internationalizing and Localizing WordPress Themes
PDF
Utsav Singh Rathour: How, Why and Where to use WordPress multisite
PDF
Rabin Shrestha: Data Validation and Sanitization in WordPress
PDF
Roshan Bhattarai: Scaling WordPress for high traffic sites
PDF
Chandra Prakash Thapa: Make a WordPress Multisite in 20 mins
PDF
Jimba Tamang: Responsive and Retina Design
PDF
Bigyan Ghimire: GovtPress
PDF
Kris Thapa: WP Ambulance
PDF
Chandra Maharzan: Making a successful career out of WordPress
PPTX
Simple Contact Us Plugin Development
PPT
WP Ambulance
PPTX
How to earn and maximize your earnings from your Blog - Pawan Agrawal
Mahadev Subedi: WordPress Security & Defense Mechanism
Pankaj Agrawal: eLearning on WordPress
Jimba Tamang: 5 reasons why “Parallax Websites” are awesome and how to create...
Ujwal Thapa: WordPress as a Blogging Platform
Yalamber Subba: WordPress Jobs & Freelance Marketplaces
Vinay Paudel: Optimizing and Speeding up a WordPress site
Sanjip Shah: Internationalizing and Localizing WordPress Themes
Utsav Singh Rathour: How, Why and Where to use WordPress multisite
Rabin Shrestha: Data Validation and Sanitization in WordPress
Roshan Bhattarai: Scaling WordPress for high traffic sites
Chandra Prakash Thapa: Make a WordPress Multisite in 20 mins
Jimba Tamang: Responsive and Retina Design
Bigyan Ghimire: GovtPress
Kris Thapa: WP Ambulance
Chandra Maharzan: Making a successful career out of WordPress
Simple Contact Us Plugin Development
WP Ambulance
How to earn and maximize your earnings from your Blog - Pawan Agrawal

Recently uploaded (20)

PDF
Computing-Curriculum for Schools in Ghana
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PPTX
Pharma ospi slides which help in ospi learning
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
DOC
Soft-furnishing-By-Architect-A.F.M.Mohiuddin-Akhand.doc
PDF
A systematic review of self-coping strategies used by university students to ...
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PPTX
Cell Types and Its function , kingdom of life
PPTX
master seminar digital applications in india
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PDF
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PPTX
Orientation - ARALprogram of Deped to the Parents.pptx
PDF
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
PDF
O7-L3 Supply Chain Operations - ICLT Program
PPTX
202450812 BayCHI UCSC-SV 20250812 v17.pptx
Computing-Curriculum for Schools in Ghana
human mycosis Human fungal infections are called human mycosis..pptx
Pharma ospi slides which help in ospi learning
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
Soft-furnishing-By-Architect-A.F.M.Mohiuddin-Akhand.doc
A systematic review of self-coping strategies used by university students to ...
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
Final Presentation General Medicine 03-08-2024.pptx
Final Presentation General Medicine 03-08-2024.pptx
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
Cell Types and Its function , kingdom of life
master seminar digital applications in india
STATICS OF THE RIGID BODIES Hibbelers.pdf
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
Abdominal Access Techniques with Prof. Dr. R K Mishra
Orientation - ARALprogram of Deped to the Parents.pptx
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
O7-L3 Supply Chain Operations - ICLT Program
202450812 BayCHI UCSC-SV 20250812 v17.pptx

Avinash Kundaliya: Javascript and WordPress

  • 2. JAVASCRIPT & WORDPRESS AVINASH KUNDALIYA (@HARDFIRE) <3 JS & PHP
  • 4. USED BY 92.3% SITES OCTOBER 2012 - W3TECHS.COM
  • 5. >80% RELY FOR IMPORTANT FUNCTIONALITY
  • 7. CAN MAKE SITE SLOW IF DONE THE WRONG WAY
  • 9. CAN MAKE SITE UNUSABLE IF DONE TOTALLY THE WRONG WAY
  • 10. I AM CONVINCED !! WE SHOULD USE JS, THE RIGHT WAY
  • 12. VAR
  • 13. GLOBAL SCOPE BY DEFAULT a=5; function say() { a=3; console.log(a); } say(); console.log(a); 3 3 // whoa!
  • 14. USE VAR KEYWORD a=5; function say() { var a=3; console.log(a); } say(); console.log(a); 3 5 // thank god! :D
  • 15. HOISTING var val = 'namaste'; (function() { console.log(val); // namaste })(); var val = 'namaste'; (function() { console.log(val); // undefined var val = 'ola!'; })(); Wherever i define my variable, the initialization will be *hoisted* to the top.
  • 16. THIS Elsewhere : current object instantiated by the class JS : depends on how the function is called. this refers to the owner of the function
  • 17. THIS : WINDOW ( FUNCTION CALL ) function what_is_this() { console.log(this); } what_is_this(); //window
  • 18. THIS : OBJECT ( OBJECT METHOD ) var thisObject = { thisFunc: function(){ console.log(this); } } thisObject.thisFunc(); //thisObject
  • 19. THIS : OBJECT ( CONSTRUCTING OBJECTS USING NEW ) function WordCamp(year){ this.year = year; this.yellOut = function(){ console.log("Yay! it is WC "+ this.year); } } var wc2012 = new WordCamp(2012); wc2012.yellOut(); // Yay! it is WC 2012 var wc2011 = WordCamp(2011); wc2012.yellOut(); // Undefined yellOut(); // Yay! it is WC 2011
  • 21. FUNCTION DECLARATION function say() { var a=3; console.log(a); } say(); FUNCTION EXPRESSION var say = function(){ var a=3; console.log(a); } say();
  • 22. function say(func) { var a=3; func(a); } say(console.log); SEE, I CAN PASS FUNCTIONS function say(func) { var a=3; func(a); } say(function(name){alert(name)}); EVEN FUNCTIONS WITHOUT A NAME
  • 23. CODE TWISTERS function foo(){ function bar() { return 3; } return bar(); function bar() { return 8; } } alert(foo()); Output : 8
  • 24. CODE TWISTERS function foo(){ var bar = function() { return 3; }; return bar(); var bar = function() { return 8; }; } alert(foo()); Output : 3 Code examples from http://javascriptweblog.wordpress.com/
  • 25. THINGS MIGHT JUST GO WRONG function getTenFunctionsBad() { var result = []; for (var i = 0; i < 10; i++) { result.push(function () { return i; }); } return result; } var functionsBad = getTenFunctionsBad(); for (var i = 0; i < 10; i++) { console.log(functionsBad[i]()); } 10 , 10 , 10 , 10 , 10 , 10 , 10 , 10 , 10 , 10
  • 26. BUT WE CAN FIX THEM function getTenFunctions() { var result = []; for (var i = 0; i < 10; i++) { result.push((function (i) { return function () { return i; } })(i)); } return result; } var functions = getTenFunctions(); for (var i = 0; i < 10; i++) { console.log(functions[i]()); } 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9
  • 27. OK! LET'S TALK ABOUT WORDPRESS
  • 28. add_action('wp_head', 'add_my_script'); function add_my_script() { ?> <script type="text/javascript" src="<?php bloginfo('wpurl'); ?>/wp-content/plugins/my-plugin/jquery.js"></sc ript> <script type="text/javascript" src="<?php bloginfo('wpurl'); ?>/wp-content/plugins/my-plugin/my-script.js">< /script> <?php }
  • 30. LET'S DO IT LIKE THE PRO'S wp_register_script wp_deregister_script wp_enqueue_script wp_dequeue_script
  • 31. WP_REGISTER_SCRIPT @COD EX Yo WP! Remember this script ( $handle, //name of the script $src, // url to script $deps, // array of dependencies $ver, //version of code $in_footer // place in footer? );
  • 32. WP_REGISTER_SCRIPT - EXAMPLE wp_register_script ( 'mytheme-custom', // handle WP will know JS by get_template_directory_uri() . '/js/custom.js', array('jquery'), // requires jQuery 1.0, // version 1.0 true // can load in footer ); Don't hardcode. Use plugins_url or get_template_directory_uri Many predefined libraries @codex
  • 33. WP_DEREGISTER_SCRIPT @COD EX Yo WP! forget about this script wp_deregister_script('jquery');
  • 34. WP_ENQUEUE_SCRIPT @COD EX Yo WP! Please put the script in my page wp_enqueue_script( $handle , $src , $deps , $ver , $in_footer );
  • 35. A LITTLE COMPLEX EXAMPLE function my_scripts_method() { wp_deregister_script( 'jquery' ); wp_register_script( 'jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/ jquery.min.js'); wp_enqueue_script( 'jquery' ); } add_action('wp_enqueue_scripts', 'my_scripts_method'); Use jQuery from google CDN instead of WordPress local
  • 36. WP_DEQUEUE_SCRIPT @COD EX Hey WP! Someone put this script in my page, remove it please wp_dequeue_script($handle);
  • 37. EXAMPLE wp_register_script( 'jquery.flexslider', get_template_directory_uri().'/js/flex.js', array('jquery'), '1.7', true ); wp_register_script( 'home-page-slider', get_template_directory_uri().'/js/slider.js', array('jquery.flexslider'), '1.0', true ); if ( is_front_page() ) { wp_enqueue_script('home-page-slider'); }
  • 38. WP_LOCALIZE_SCRIPT @COD EX Send data from WordPress to JavaScript wp_localize_script( $handle, $object_name, $l10n ); SIMPLE EXAMPLE wp_enqueue_script( 'some_handle' ); $translation_array = array( 'some_string' => __( 'Some string to translate' ), 'a_val ue' => '10' ); wp_localize_script( 'some_handle', 'object_name', $translation_array ); console.log(object_name.some_string);
  • 39. WP_LOCALIZE_SCRIPT EXAMPLE wp_localize_script( 'simplecatch_custom_slider', 'js_value', array( 'transition_effect' => $transition_effect, 'transition_delay' => $transition_delay, 'transition_duration' => $transition_duration ));
  • 40. AJAX IN WP require_once( "../../../../wp-config.php" ); // or require_once( "../../../../wp-load.php" ); PLEASE DON'T TRY THIS AT HOME!
  • 41. WP_AJAX_(ACTION) @COD EX jQuery.post( MyAjax.ajaxurl, { 'action':'add_foobar', 'data':'foobarid' }, function(response){ alert('The server responded: ' + response); } );
  • 42. WP_AJAX_(ACTION) add_action('wp_ajax_add_foobar', 'prefix_ajax_add_foobar'); function prefix_ajax_add_foobar() { //Do Something really awesome here :) exit; }
  • 44. SUMMING UP var this functions awesomeness use wordpress helper functions
  • 45. WHAT NEXT "use strict" closures functional programming more quirks : JS Garden “ Go make something awesome! ”
  • 46. ?
  • 47. THE END :'( - AVINASH KUNDALIYA / @HARDFIRE