How to use wp.hooks.addAction() in React JS/Gutenberg?

How to use wp.hooks.addAction? It’s basically like so, just like you’ve attempted: // Hook to the hook_name action. wp.hooks.addAction( ‘hook_name’, ‘namespace’, function(){ console.log( ‘Foo Bar’ ); } ); // Trigger the hook_name action. wp.hooks.doAction( ‘hook_name’ ); Or for hooks which provides one or more parameters to the callback: // Hook to the hook_name action. wp.hooks.addAction( … Read more

WordPress problem with htmlentities

It seems that the “convert_chars” filter is causing the trouble, try removing it by: remove_filter( ‘the_content’, ‘convert_chars’ ); Also try removing the richedit_pre hook (which formats the text for the rich text editor, also uses convert_chars function) by: remove_filter( ‘the_editor_content’, ‘wp_richedit_pre’ ); Hope that helps!

What is the Javascript event for an item being added to the cart in Woocommerce?

Read the source. From woocommerce-ajax.php (in the plugin’s root folder) Javascript/Ajax add to cart /** * AJAX add to cart * * @access public * @return void */ function woocommerce_ajax_add_to_cart() { global $woocommerce; check_ajax_referer( ‘add-to-cart’, ‘security’ ); $product_id = (int) apply_filters(‘woocommerce_add_to_cart_product_id’, $_POST[‘product_id’]); $passed_validation = apply_filters(‘woocommerce_add_to_cart_validation’, true, $product_id, 1); if ($passed_validation && $woocommerce->cart->add_to_cart($product_id, 1)) : // … Read more

update_option in javascript

JavaScript $(window).scroll(function () { if ($(window).scrollTop() >= $(document).height() – $(window).height() – 10) { /***update options***/ $.ajax({ type: ‘POST’, url: ‘http://www.example.com/wp-admin/admin-ajax.php’, data: { action : ‘hit-bottom’, option : $option, // your option variable new_value : $new_value // your new value variable }, dataType: ‘json’ }).done(function( json ) { alert( “Ajax call succeeded, let’s see what the … Read more