Admin WP List Table Columns Missing

This is a bug with the wordpress AJAX trying to update manageedit-pagecolumnshidden on the admin table pages when columns are hidden. It completly breaks the entire admin tables when the table headers are visually hidden. Thanks to Michael Ecklund’s clue I was able to figure it out. I created the Ticket here: https://core.trac.wordpress.org/ticket/29030 And a … Read more

Can’t get result from sql using ajax result

I have made some changes to your code. See now if this works – function myajax_inputtitleSubmit_func() { // check nonce $nonce = $_POST[‘nextNonce’]; if ( ! wp_verify_nonce( $nonce, ‘myajax-next-nonce’ ) ) die ( ‘Busted!’); $zipcode = $_POST[‘zip’]; // generate the response global $wpdb; $tablename = “{$wpdb->prefix}levering”; $sql = “SELECT Levering FROM {$tablename} WHERE Zip LIKE … Read more

Show Post Content with AJAX

Create the JSON endpoint that accepts a WP_Post ID. add_action( ‘rest_api_init’, function() { register_rest_route( ‘api/v2’, ‘/post/(?<id>\d+)’, array ( ‘methods’ => ‘GET’, ‘callback’ => ‘get_post_content’, ) ); } ); Handle the endpoint to return a post’s content based on the ID passed. function get_post_content( WP_REST_Request $request ) { $post = get_post( absint( $request->get_param( ‘id’ ) ) … Read more

Display data on same page as form without refresh

If I understand correctly you need the original form to display the values of what has just been posted. You also need the table to display 0 on values that haven’t been calculated. At the moment the table calculates information perfectly with a submit refreshing the page. You can use the if(isset($_POST[“fieldname”])){ variable you have … Read more

WordPress ajax success response

You can’t use 2 echos for an ajax response. Try this: js: $atj.post(MyAjax.ajaxurl, requestData).done(function(result){ console.log(result); if(result == ‘success’){ $atj(‘.training-form [type=text]’).val(”); $atj(‘.training-form-message’).append(‘<p class=”training-form-complete-message”>Thank you for the email</p>’); } }); php function myajax_submit() { // snip… $mail_check = wp_mail( $to, ‘Email Test’, $message ); remove_filter( ‘wp_mail_content_type’, ‘set_html_content_type’ ); if( $mail_check) echo ‘success’; else echo ‘failure’; exit; }

JSON – Permission Error?

Your problem is that you are checking for nonce and the nonce is stale. It is hard to make a specific comment about the need of using nonce in your case, but in general nonces should be used only for data submission not query.

wordpress count link clicks by ip address

What would you do if the user uses a proxy and randomizes his IP address? There are numerous browser plugins to simplify that to a click of a button to download multiple times. The same goes for cookies. Aside from that you are trying to collect data that allows to identify users, which is illegal … Read more

Correct way to write jQuery functions in WordPress

As suggested in comments, this kind of error is caused by the fact that WordPress loads jquery in noconflict mode. The most common workaround is to wrap all functions in your script file: jQuery(document).ready(function($) { … scripts … } Another, more risky option is to switch off noconflict mode by starting the script file with … Read more

Front-end Ajax File Upload

I use this code to upload if ( ! function_exists( ‘wp_handle_upload’ ) ) { require_once( ABSPATH . ‘wp-admin/includes/file.php’ ); } if($_FILES[‘file’][‘name’] != ”) { $uploadedfile = $_FILES[‘file’]; $upload_overrides = array( ‘test_form’ => false ); $movefile = wp_handle_upload( $uploadedfile, $upload_overrides ); if ( $movefile && ! isset( $movefile[‘error’] ) ) { $file_url = $movefile[‘url’]; $file_url = … Read more