/** * Accesses the site in the background at the end of the script execution. * * This is used to trigger cron events in the background and sets a static flag so that it ensures it is done only once per page load. * * @since 1.0.0 */ public static function see($aGet = array(), $fIgnoreLock = false) { if (isset($_GET['doing_wp_cron'])) { return; } // WP Cron if (isset($GLOBALS['pagenow']) && $GLOBALS['pagenow'] == 'admin-ajax.php') { return; } // WP Heart-beat API // Ensures the task is done only once in a page load. static $_bIsCalled; if ($_bIsCalled) { return; } $_bIsCalled = true; // Store the static properties. self::$_fIgnoreLock = $fIgnoreLock ? $fIgnoreLock : self::$_fIgnoreLock; self::$_aGet = (array) $aGet + self::$_aGet; $_sSelfClassName = get_class(); if (did_action('shutdown')) { self::_replyToAccessSite(); return; // important as what the action has performed does not mean the action never will be fired again. } add_action('shutdown', "{$_sSelfClassName}::_replyToAccessSite", 999); // do not pass self::_replyToAccessSite. }