wp-shortcake / shortcake

Shortcake makes using WordPress shortcodes a piece of cake.
GNU General Public License v2.0
665 stars 143 forks source link

Example of js hooks #768

Open goldenapples opened 6 years ago

goldenapples commented 6 years ago

Example of js hook in post select ajax data, see discussion in https://github.com/wp-shortcake/shortcake/pull/767#issuecomment-325024495

With this in place, you would filter the data being sent with the ajax request something like

wp.shortcake.hooks.addFilter( 'shortcode_tag.attr.ajax-data', function addParams( response ) {
  response.date_query = $( date_query_field ).value;
  return response;
} )

and add any new arguments to the return value you want.