public function getRemoteShareCount($share_url) { $count_api = $this->network_data["count_api"]; if ($count_api == '') { return false; } // no api $network = $this->network; $timeout = 60; // prevent the same requests from running multiple times ( i.e. one page, many collections on same url ) . $locked = maxUtils::get_transient('mbcol-shares-' . $network . '-' . $share_url . '-lock'); if ($locked == true) { return 'locked'; } // try again on next refresh. //lock out next request while this one is still running. maxUtils::set_transient('mbcol-shares-' . $network . '-' . $share_url . '-lock', true, $timeout); $count_api = str_replace("{url}", $share_url, $count_api); $func = $this->network_data["count_function"]; $count = $this->{$func}($count_api); if (defined('MAXBUTTONS_DEBUG') && MAXBUTTONS_DEBUG) { $admin = MB()->getClass("admin"); $admin->log("Get Remote Share", "Call: {$count_api} - Network : " . $this->network . " - Count: {$count} \n "); } if ($count !== false) { $network = $this->network; $check_time = $this->network_data["count_check_time"]; // set count maxUtils::set_transient('mbcol-shares-' . $network . '-' . $share_url, $count, $check_time); } // remove lock maxUtils::delete_transient('mbcol-shares-' . $network . '-' . $share_url . '-lock'); return $count; }