Skip to content

Commit 0f2a58d

Browse files
committed
Throttle is_wordpress_com_hosted API call using transient to avoid repeated requests
1 parent 77ad51d commit 0f2a58d

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

facebook-for-wordpress.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,12 @@ public function __construct() {
6767
$this->register_settings_page();
6868

6969
if ( false === get_option( 'is_wordpress_com_hosted' ) ) {
70-
update_option( 'is_wordpress_com_hosted', FacebookWordpressOptions::is_wordpress_com_hosted() );
70+
if ( false === get_transient( 'facebook_wpcom_check' ) ) {
71+
$is_wp_com_hosted = FacebookWordpressOptions::is_wordpress_com_hosted();
72+
73+
update_option( 'is_wordpress_com_hosted', $is_wp_com_hosted );
74+
set_transient( 'facebook_wpcom_check', 1, HOUR_IN_SECONDS );
75+
}
7176
}
7277

7378
new ServerEventAsyncTask();

0 commit comments

Comments
 (0)