I use the WordPress heartbeat to check a setting on my server from the front-end. If that setting has a specific value I want to stop bothering the server. There for I want to stop/pause the heartbeat. There are no other things depending on the heartbeat. I found wp.heartbeat.stop() over here, but it doesn't work. jQuery(document).ready(function ($) { $(document).on('heartbeat-tick', function (e, data) { [...] if (true == x) { wp.heartbeat.stop(); } [...] } }); I get this error in the …
Here's an interesting experiment: Go to wordpress plugins listing page, notice the activate, deactivate links all have a nonce part in the request. In a second tab, log out of the site, and go back to plugin listing page. After awhile, the page realizes it's not logged in, and pops up a log in screen. Log in, and click an "activate" or "deactivate" button. Notice it gives the nonce-failure message, "are you sure you want to do this"? Because the …
I found that init hook is being called twice and then I try to trace and find out wp-settings.php is also being called twice. I originally want to post a question to find out why. And after some code injection tests. I found out the reason and would like to share here and see if there is anyone have another insight or method or workaround which could avoid the "double calling". And the following is the testing method for finding …
I just disabled Heartbeat with the plugin Heartbeat control and also adding this script in function.php of my child-theme add_action( 'init', 'stop_heartbeat', 1 ); function stop_heartbeat() { wp_deregister_script('heartbeat'); } But i think it's still working and some plugin is overriding it. I still have large cpu spike while the site is in mantainance mode. Is there a function or action that i can use to check if this worked ?
I want to use WP-API heartbeat to open a connection to two displays and have them reflect what the other is saying with each send and tick. It used to work when the heartbeat API came out in 3.6 - but now at the latest version it is outputting an error: SyntaxError: JSON Parse error: Unexpected identifier "SyntaxError" I have tried following other answers on the web to parse the json error or find where it is failing but nothing …
How can I get correct action hook on publish_posts for multiple custom types ? I have a following problem, I can use this hook for posts or single custom post_type, but I don't know correct hook for multiple custom post types: // Post publication for posts add_filter ( 'publish_post', 'notify_published_post' ); function notify_published_post( $post_id ) { I would like to publish to all even future custom post_types, so I would like to get something like this: // Post publication hook …
After I check heartbeat.js file I found that by default WordPress set heartbeat hasFocuse option to true, I want to change this option to false what can I do? What am I trying to achieve? I have a live notification and messages system working depending on heartbeat.js the problem that if I switch from my site tab to any another tab the heartbeat stop working so I don't receive the messages and notification until I switch to my site again. …
I recently thought I'd protect a WP site's /wp-admin folder with Apache's basic auth to provide a crude but somewhat effective additional layer of security (as a second line of defense should the WP install accidentally go out of date or an exploit emerge). However when I did this, I immediately noticed that the site's cached front-end pages started showing the authentication dialog, too! This appears to be because the Ajax heartbeat is being included in all the frontend pages: …
I’m hoping this is something easy to fix although from my tests (very new to WordPress so please go easy with me if these tests are not very good!) doesn’t appear to be. I have a site hosted on SiteGround which was eating through the CPU seconds like nobody’s business. I’ve now managed to put it down to the Heartbeat API calling the admin-ajax.php file so much. Small question about admin-ajax.php if I may? Am I correct in my thinking …
My issue is that when I do a simple Admin Dashboard change, like updating a post or page, I sometimes wait up to 10 minutes for the request to finish. I have tried restarting the process and my server many times; the only way it works is if I wait all 10 minutes or so for the request to finish. Here is a screen shot of what the error looks like: That error will loop 5-10 times, making it take …
I want to disable this just for one Post Type, as it doesn't really matters if there's another user editing it (the main content editing area is Ajaxified and non-admins can only see that). I looked at the core functions but couldn't find an entry point. From the function wp_set_post_lock I'm guessing that I'd have to intercept the get_post_meta, but is there an official way to do it? And there's a second lock that doesn't seem to be affected by …
I've read that Heartbeat can slow a WP site down and I'm assuming if our admins/store managers have a lot of admin windows/tabs open, this will exacerbate the issue. If yes, is there a condition to test and log the calls that Heartbeat makes so I can see if the site slowdown could be related to an excess of Heartbeat calls? I had a look in the documentation and elsewhere but only found ways to deregister the script ( wp_deregister_script('heartbeat'); …
I've got a very strange problem. Actually my server is being attacked by a brute force on wp-login.php. But when I look into the access log file I see that it's from 127.0.0.1... www.*.fr:80 127.0.0.1 - - [29/Apr/2015:18:23:01 +0200] "POST /wp-login.php HTTP/1.0" 200 6254 "-" "-" www.*.fr:80 127.0.0.1 - - [29/Apr/2015:18:23:01 +0200] "POST /wp-login.php HTTP/1.0" 200 6254 "-" "-" www.*.fr:80 127.0.0.1 - - [29/Apr/2015:18:23:01 +0200] "POST /wp-login.php HTTP/1.0" 200 6254 "-" "-" www.*.fr:80 127.0.0.1 - - [29/Apr/2015:18:23:01 +0200] "POST /wp-login.php …
My (shared) web host recently sent me this: "Our server monitoring systems keep indicating high server load persistently maintained by your website (...). Most of the hits are to the /www/www/wp-admin/admin-ajax.php script. We would advise the following: Do not stay logged into the WordPress dashboard through the day. Once you finish your work, you should log out. If you stay logged in and keep the browser window open, WordPress will keep generating hits to admin-ajax.php. ..." When I asked them …
I recently noticed that in Heartbeat API js client there was added option for speed of ticks called "long polling" with 0 interval. I pretty much understand what they try to achieve but I'm confused about how to implement plugin using this feature. For now every time my server received request from browser, hook was fired, data queried, response created and sent back to client. But with 0 interval, I should actually wait in my hook for some event being …
I'm having problems when trying to access data that I've queued using the Heartbeat API. I'm queuing data using wp.heartbeat.enqueue(). For example: var data = { my_key: 'value' }; wp.heartbeat.enqueue( 'my_handle', data, false ); Then later on in my script, I'd like to access the data I've queued. For example: $( document ).on( 'click', '#button', function() { // Here, I want to access the data I've enqueued. }); I've tried doing the following but that doesn't work: $( document ).on( …
My aim is to use the Heartbeat API to check if new posts have been published since the blog's homepage was loaded. If new posts have been published, I will display a link at the top of the screen "16 new posts" which, when clicked, will insert the new posts into the DOM. My problem: How can I check if new posts have been published since the blog's homepage was loaded? My PHP so far: function new_post_check( $response, $data, $screen_id …