WordPress AJAX return 0 – My case

You function name and your ajax action callback name should be same. add_action(‘wp_ajax_pdfAction’,’pdfAction_callback’); add_action(‘wp_ajax_nopriv_pdfAction’,’pdfAction_callback’); function pdfAction_callback(){ $post = $_POST[‘pdfAction’]; echo “something”; wp_die(); } Please update your php code with the above. Currently, your php function is not getting executed. Update: The Ajax Script, $(document).on(‘click’, “#generate-pdf”, function(){ var price1 = $(“#price1”).val(); var price2 = $(“#price2”).val(); $.ajax({ … Read more

I can’t get a return value from Ajax

Returning the result array will only return to the PHP function calling it, instead you actually need to output it by echoing it, and in this case because it is an array, encoding it with JSON before outputting. So return $result becomes: echo json_encode($result); exit; and then add dataType to the javascript call so it … Read more

What are the advantages/disadvantages of using jQuery DOM manipulation as opposed to PHP DOM manipulation?

PHP is running on the server, JavaScript in the client. This means PHP is faster (more resources), the result can be cached, and you have to test only one interpreter. JavaScript – you don’t really need jQuery for this – is more error prone, because of weird clients, blocked resources, or a more limited available … Read more

Gutenberg – Title field required

You could use PluginPrePublishPanel to check for the title and lock publishing if it’s empty. Have a look at the accepted answer here for an example of locking the post – Add pre-publish conditions to the block editor For your example you could modify the checking portion as follows: const { registerPlugin } = wp.plugins; … Read more

Error – ‘create_function is deprecated’ [closed]

You no longer need to use create_function you can instead just use an anonymous function: add_action( ‘gform_preview_footer’, create_function( ”, ‘GFFormDisplay::footer_init_scripts(‘ . $form[‘id’] . ‘);’ ) ); Should be: add_action( ‘gform_preview_footer’, function() use ($form){ GFFormDisplay::footer_init_scripts($form[‘id’]); }); https://www.php.net/manual/en/functions.anonymous.php