本文整理汇总了PHP中wfUtils::hasLoginCookie方法的典型用法代码示例。如果您正苦于以下问题:PHP wfUtils::hasLoginCookie方法的具体用法?PHP wfUtils::hasLoginCookie怎么用?PHP wfUtils::hasLoginCookie使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wfUtils
的用法示例。
在下文中一共展示了wfUtils::hasLoginCookie方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setupCaching
public static function setupCaching()
{
self::$cacheType = wfConfig::get('cacheType');
if (self::$cacheType != 'php' && self::$cacheType != 'falcon') {
return;
//cache is disabled
}
if (wfUtils::hasLoginCookie()) {
add_action('publish_post', 'wfCache::action_publishPost');
add_action('publish_page', 'wfCache::action_publishPost');
foreach (array('clean_object_term_cache', 'clean_post_cache', 'clean_term_cache', 'clean_page_cache', 'after_switch_theme', 'customize_save_after', 'activated_plugin', 'deactivated_plugin', 'update_option_sidebars_widgets') as $action) {
add_action($action, 'wfCache::action_clearPageCache');
//Schedules a cache clear for immediately so it won't lag current request.
}
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
foreach (array('/\\/wp\\-admin\\/options\\.php$/', '/\\/wp\\-admin\\/options\\-permalink\\.php$/') as $pattern) {
if (preg_match($pattern, $_SERVER['REQUEST_URI'])) {
self::scheduleCacheClear();
break;
}
}
}
}
add_action('wordfence_cache_clear', 'wfCache::scheduledCacheClear');
add_action('wordfence_update_blocked_IPs', 'wfCache::scheduleUpdateBlockedIPs');
add_action('comment_post', 'wfCache::action_commentPost');
//Might not be logged in
add_filter('wp_redirect', 'wfCache::redirectFilter');
//Routines to clear cache run even if cache is disabled
$file = self::fileFromRequest($_SERVER['HTTP_HOST'] ? $_SERVER['HTTP_HOST'] : $_SERVER['SERVER_NAME'], $_SERVER['REQUEST_URI']);
$fileDeleted = false;
$doDelete = false;
if ($_SERVER['REQUEST_METHOD'] != 'GET') {
//If our URL is hit with a POST, PUT, DELETE or any other non 'GET' request, then clear cache.
$doDelete = true;
}
if ($doDelete) {
@unlink($file);
$fileDeleted = true;
}
add_action('wp_logout', 'wfCache::logout');
if (self::isCachable()) {
if (!$fileDeleted && self::$cacheType == 'php') {
//Then serve the file if it's still valid
$stat = @stat($file);
if ($stat) {
$age = time() - $stat[9];
if ($age < 10000) {
readfile($file);
//sends file to stdout
die;
}
}
}
ob_start('wfCache::obComplete');
//Setup routine to store the file
}
}
示例2: install_actions
public static function install_actions()
{
register_activation_hook(WORDFENCE_FCPATH, 'wordfence::installPlugin');
register_deactivation_hook(WORDFENCE_FCPATH, 'wordfence::uninstallPlugin');
$versionInOptions = get_option('wordfence_version', false);
if (!$versionInOptions || version_compare(WORDFENCE_VERSION, $versionInOptions, '>')) {
//Either there is no version in options or the version in options is greater and we need to run the upgrade
self::runInstall();
}
self::initProtection();
//These access wfConfig::get('apiKey') and will fail if runInstall hasn't executed.
wfCache::setupCaching();
if (defined('MULTISITE') && MULTISITE === true) {
global $blog_id;
if ($blog_id == 1 && get_option('wordfenceActivated') != 1) {
return;
}
//Because the plugin is active once installed, even before it's network activated, for site 1 (WordPress team, why?!)
}
//User may be logged in or not, so register both handlers
add_action('wp_ajax_nopriv_wordfence_logHuman', 'wordfence::ajax_logHuman_callback');
add_action('wp_ajax_nopriv_wordfence_doScan', 'wordfence::ajax_doScan_callback');
add_action('wp_ajax_nopriv_wordfence_testAjax', 'wordfence::ajax_testAjax_callback');
add_action('wp_ajax_nopriv_wordfence_perfLog', 'wordfence::ajax_perfLog_callback');
if (wfUtils::hasLoginCookie()) {
//may be logged in. Fast way to check. These aren't secure functions, this is just a perf optimization, along with every other use of hasLoginCookie()
add_action('wp_ajax_wordfence_perfLog', 'wordfence::ajax_perfLog_callback');
add_action('wp_ajax_wordfence_logHuman', 'wordfence::ajax_logHuman_callback');
add_action('wp_ajax_wordfence_doScan', 'wordfence::ajax_doScan_callback');
add_action('wp_ajax_wordfence_testAjax', 'wordfence::ajax_testAjax_callback');
if (is_multisite()) {
add_action('wp_network_dashboard_setup', 'wordfence::addDashboardWidget');
} else {
add_action('wp_dashboard_setup', 'wordfence::addDashboardWidget');
}
}
add_action('wordfence_start_scheduled_scan', 'wordfence::wordfenceStartScheduledScan');
add_action('wordfence_daily_cron', 'wordfence::dailyCron');
add_action('wordfence_daily_autoUpdate', 'wfConfig::autoUpdate');
add_action('wordfence_hourly_cron', 'wordfence::hourlyCron');
add_action('plugins_loaded', 'wordfence::veryFirstAction');
add_action('init', 'wordfence::initAction');
add_action('template_redirect', 'wordfence::templateRedir', 1001);
add_action('shutdown', 'wordfence::shutdownAction');
if (version_compare(PHP_VERSION, '5.4.0') >= 0) {
add_action('wp_authenticate', 'wordfence::authActionNew', 1, 2);
} else {
add_action('wp_authenticate', 'wordfence::authActionOld', 1, 2);
}
add_filter('authenticate', 'wordfence::authenticateFilter', 99, 3);
if (self::isLockedOut(wfUtils::getIP())) {
add_filter('xmlrpc_enabled', '__return_false');
}
add_action('login_init', 'wordfence::loginInitAction');
add_action('wp_login', 'wordfence::loginAction');
add_action('wp_logout', 'wordfence::logoutAction');
add_action('lostpassword_post', 'wordfence::lostPasswordPost', '1');
if (wfUtils::hasLoginCookie()) {
add_action('user_profile_update_errors', 'wordfence::validateProfileUpdate', 0, 3);
add_action('profile_update', 'wordfence::profileUpdateAction', '99', 2);
add_action('validate_password_reset', 'wordfence::validatePassword', 10, 2);
}
add_action('publish_future_post', 'wordfence::publishFuturePost');
add_action('mobile_setup', 'wordfence::jetpackMobileSetup');
//Action called in Jetpack Mobile Theme: modules/minileven/minileven.php
// Add actions for the email summary
add_action('wordfence_email_activity_report', array('wfActivityReport', 'executeCronJob'));
//For debugging
//add_filter( 'cron_schedules', 'wordfence::cronAddSchedules' );
add_filter('wp_redirect', 'wordfence::wpRedirectFilter', 99, 2);
add_filter('pre_comment_approved', 'wordfence::preCommentApprovedFilter', '99', 2);
//html|xhtml|atom|rss2|rdf|comment|export
if (wfConfig::get('other_hideWPVersion')) {
add_filter('style_loader_src', 'wordfence::replaceVersion');
add_filter('script_loader_src', 'wordfence::replaceVersion');
add_action('upgrader_process_complete', 'wordfence::hideReadme');
}
add_filter('get_the_generator_html', 'wordfence::genFilter', 99, 2);
add_filter('get_the_generator_xhtml', 'wordfence::genFilter', 99, 2);
add_filter('get_the_generator_atom', 'wordfence::genFilter', 99, 2);
add_filter('get_the_generator_rss2', 'wordfence::genFilter', 99, 2);
add_filter('get_the_generator_rdf', 'wordfence::genFilter', 99, 2);
add_filter('get_the_generator_comment', 'wordfence::genFilter', 99, 2);
add_filter('get_the_generator_export', 'wordfence::genFilter', 99, 2);
add_filter('registration_errors', 'wordfence::registrationFilter', 99, 3);
// Change GoDaddy's limit login mu-plugin since it can interfere with the two factor auth message.
if (self::hasGDLimitLoginsMUPlugin()) {
add_action('login_errors', array('wordfence', 'fixGDLimitLoginsErrors'), 11);
}
if (is_admin()) {
add_action('admin_init', 'wordfence::admin_init');
if (is_multisite()) {
if (wfUtils::isAdminPageMU()) {
add_action('network_admin_menu', 'wordfence::admin_menus');
}
//else don't show menu
} else {
add_action('admin_menu', 'wordfence::admin_menus');
}
add_filter('pre_update_option_permalink_structure', 'wordfence::disablePermalinksFilter', 10, 2);
//.........这里部分代码省略.........
示例3: install_actions
public static function install_actions()
{
self::initProtection();
if (wfUtils::hasLoginCookie()) {
//Fast way of checking if user may be logged in. Not secure, but these are only available if you're signed in.
register_activation_hook(WP_PLUGIN_DIR . '/wordfence/wordfence.php', 'wordfence::installPlugin');
register_deactivation_hook(WP_PLUGIN_DIR . '/wordfence/wordfence.php', 'wordfence::uninstallPlugin');
}
$versionInOptions = get_option('wordfence_version', false);
if (!$versionInOptions || version_compare(WORDFENCE_VERSION, $versionInOptions, '>')) {
//Either there is no version in options or the version in options is greater and we need to run the upgrade
self::runInstall();
}
//These access wfConfig::get('apiKey') and will fail if runInstall hasn't executed.
wfCache::setupCaching();
if (defined('MULTISITE') && MULTISITE === true) {
global $blog_id;
if ($blog_id == 1 && get_option('wordfenceActivated') != 1) {
return;
}
//Because the plugin is active once installed, even before it's network activated, for site 1 (WordPress team, why?!)
}
//User may be logged in or not, so register both handlers
add_action('wp_ajax_nopriv_wordfence_logHuman', 'wordfence::ajax_logHuman_callback');
add_action('wp_ajax_nopriv_wordfence_doScan', 'wordfence::ajax_doScan_callback');
add_action('wp_ajax_nopriv_wordfence_testAjax', 'wordfence::ajax_testAjax_callback');
add_action('wp_ajax_nopriv_wordfence_perfLog', 'wordfence::ajax_perfLog_callback');
if (wfUtils::hasLoginCookie()) {
//may be logged in. Fast way to check. These aren't secure functions, this is just a perf optimization, along with every other use of hasLoginCookie()
add_action('wp_ajax_wordfence_perfLog', 'wordfence::ajax_perfLog_callback');
add_action('wp_ajax_wordfence_logHuman', 'wordfence::ajax_logHuman_callback');
add_action('wp_ajax_wordfence_doScan', 'wordfence::ajax_doScan_callback');
add_action('wp_ajax_wordfence_testAjax', 'wordfence::ajax_testAjax_callback');
if (is_multisite()) {
add_action('wp_network_dashboard_setup', 'wordfence::addDashboardWidget');
} else {
add_action('wp_dashboard_setup', 'wordfence::addDashboardWidget');
}
}
add_action('wordfence_start_scheduled_scan', 'wordfence::wordfenceStartScheduledScan');
add_action('wordfence_daily_cron', 'wordfence::dailyCron');
add_action('wordfence_daily_autoUpdate', 'wfConfig::autoUpdate');
add_action('wordfence_hourly_cron', 'wordfence::hourlyCron');
add_action('plugins_loaded', 'wordfence::veryFirstAction');
add_action('init', 'wordfence::initAction');
add_action('template_redirect', 'wordfence::templateRedir');
add_action('shutdown', 'wordfence::shutdownAction');
if (version_compare(PHP_VERSION, '5.4.0') >= 0) {
add_action('wp_authenticate', 'wordfence::authActionNew', 1, 2);
} else {
add_action('wp_authenticate', 'wordfence::authActionOld', 1, 2);
}
add_filter('authenticate', 'wordfence::authenticateFilter', 99, 3);
add_action('login_init', 'wordfence::loginInitAction');
add_action('wp_login', 'wordfence::loginAction');
add_action('wp_logout', 'wordfence::logoutAction');
add_action('lostpassword_post', 'wordfence::lostPasswordPost', '1');
if (wfUtils::hasLoginCookie()) {
add_action('user_profile_update_errors', 'wordfence::validateProfileUpdate', 0, 3);
add_action('profile_update', 'wordfence::profileUpdateAction', '99', 2);
add_action('validate_password_reset', 'wordfence::validatePassword', 10, 2);
}
add_action('publish_future_post', 'wordfence::publishFuturePost');
add_action('mobile_setup', 'wordfence::jetpackMobileSetup');
//Action called in Jetpack Mobile Theme: modules/minileven/minileven.php
// Add actions for the email summary
add_action('wordfence_email_activity_report', array('wfActivityReport', 'executeCronJob'));
//For debugging
//add_filter( 'cron_schedules', 'wordfence::cronAddSchedules' );
add_filter('wp_redirect', 'wordfence::wpRedirectFilter', 99, 2);
add_filter('pre_comment_approved', 'wordfence::preCommentApprovedFilter', '99', 2);
//html|xhtml|atom|rss2|rdf|comment|export
add_filter('get_the_generator_html', 'wordfence::genFilter', 99, 2);
add_filter('get_the_generator_xhtml', 'wordfence::genFilter', 99, 2);
add_filter('get_the_generator_atom', 'wordfence::genFilter', 99, 2);
add_filter('get_the_generator_rss2', 'wordfence::genFilter', 99, 2);
add_filter('get_the_generator_rdf', 'wordfence::genFilter', 99, 2);
add_filter('get_the_generator_comment', 'wordfence::genFilter', 99, 2);
add_filter('get_the_generator_export', 'wordfence::genFilter', 99, 2);
add_filter('registration_errors', 'wordfence::registrationFilter', 99, 3);
// Change GoDaddy's limit login mu-plugin since it can interfere with the two factor auth message.
if (self::hasGDLimitLoginsMUPlugin()) {
add_action('login_errors', array('wordfence', 'fixGDLimitLoginsErrors'), 11);
}
if (is_admin()) {
add_action('admin_init', 'wordfence::admin_init');
if (is_multisite()) {
if (wfUtils::isAdminPageMU()) {
add_action('network_admin_menu', 'wordfence::admin_menus');
}
//else don't show menu
} else {
add_action('admin_menu', 'wordfence::admin_menus');
}
add_filter('pre_update_option_permalink_structure', 'wordfence::disablePermalinksFilter', 10, 2);
if (preg_match('/^(?:falcon|php)$/', wfConfig::get('cacheType'))) {
add_filter('post_row_actions', 'wordfence::postRowActions', 0, 2);
add_filter('page_row_actions', 'wordfence::pageRowActions', 0, 2);
add_action('post_submitbox_start', 'wordfence::postSubmitboxStart');
}
//.........这里部分代码省略.........
示例4: install_actions
public static function install_actions()
{
if (wfUtils::hasLoginCookie()) {
//Fast way of checking if user may be logged in. Not secure, but these are only available if you're signed in.
register_activation_hook(WP_PLUGIN_DIR . '/wordfence/wordfence.php', 'wordfence::installPlugin');
register_deactivation_hook(WP_PLUGIN_DIR . '/wordfence/wordfence.php', 'wordfence::uninstallPlugin');
}
$versionInOptions = get_option('wordfence_version', false);
if (!$versionInOptions || version_compare(WORDFENCE_VERSION, $versionInOptions, '>')) {
//Either there is no version in options or the version in options is greater and we need to run the upgrade
self::runInstall();
}
//These access wfConfig::get('apiKey') and will fail if runInstall hasn't executed.
wfCache::setupCaching();
if (defined('MULTISITE') && MULTISITE === true) {
global $blog_id;
if ($blog_id == 1 && get_option('wordfenceActivated') != 1) {
return;
}
//Because the plugin is active once installed, even before it's network activated, for site 1 (WordPress team, why?!)
}
//User may be logged in or not, so register both handlers
add_action('wp_ajax_nopriv_wordfence_logHuman', 'wordfence::ajax_logHuman_callback');
add_action('wp_ajax_nopriv_wordfence_doScan', 'wordfence::ajax_doScan_callback');
add_action('wp_ajax_nopriv_wordfence_testAjax', 'wordfence::ajax_testAjax_callback');
add_action('wp_ajax_nopriv_wordfence_perfLog', 'wordfence::ajax_perfLog_callback');
if (wfUtils::hasLoginCookie()) {
//may be logged in. Fast way to check. These aren't secure functions, this is just a perf optimization, along with every other use of hasLoginCookie()
add_action('wp_ajax_wordfence_perfLog', 'wordfence::ajax_perfLog_callback');
add_action('wp_ajax_wordfence_logHuman', 'wordfence::ajax_logHuman_callback');
add_action('wp_ajax_wordfence_doScan', 'wordfence::ajax_doScan_callback');
add_action('wp_ajax_wordfence_testAjax', 'wordfence::ajax_testAjax_callback');
}
add_action('wordfence_start_scheduled_scan', 'wordfence::wordfenceStartScheduledScan');
add_action('wordfence_daily_cron', 'wordfence::dailyCron');
add_action('wordfence_hourly_cron', 'wordfence::hourlyCron');
add_action('plugins_loaded', 'wordfence::veryFirstAction');
add_action('init', 'wordfence::initAction');
add_action('template_redirect', 'wordfence::templateRedir');
add_action('shutdown', 'wordfence::shutdownAction');
if (version_compare(PHP_VERSION, '5.4.0') >= 0) {
add_action('wp_authenticate', 'wordfence::authActionNew', 1, 2);
} else {
add_action('wp_authenticate', 'wordfence::authActionOld', 1, 2);
}
add_action('login_init', 'wordfence::loginInitAction');
add_action('wp_login', 'wordfence::loginAction');
add_action('wp_logout', 'wordfence::logoutAction');
add_action('lostpassword_post', 'wordfence::lostPasswordPost', '1');
if (wfUtils::hasLoginCookie()) {
add_action('user_profile_update_errors', 'wordfence::validateProfileUpdate', 0, 3);
add_action('profile_update', 'wordfence::profileUpdateAction', '99', 2);
add_action('validate_password_reset', 'wordfence::validatePassword', 10, 2);
}
add_filter('pre_comment_approved', 'wordfence::preCommentApprovedFilter', '99', 2);
add_filter('authenticate', 'wordfence::authenticateFilter', 99, 3);
//html|xhtml|atom|rss2|rdf|comment|export
add_filter('get_the_generator_html', 'wordfence::genFilter', 99, 2);
add_filter('get_the_generator_xhtml', 'wordfence::genFilter', 99, 2);
add_filter('get_the_generator_atom', 'wordfence::genFilter', 99, 2);
add_filter('get_the_generator_rss2', 'wordfence::genFilter', 99, 2);
add_filter('get_the_generator_rdf', 'wordfence::genFilter', 99, 2);
add_filter('get_the_generator_comment', 'wordfence::genFilter', 99, 2);
add_filter('get_the_generator_export', 'wordfence::genFilter', 99, 2);
add_filter('registration_errors', 'wordfence::registrationFilter', 99, 3);
if (is_admin()) {
add_action('admin_init', 'wordfence::admin_init');
if (is_multisite()) {
if (wfUtils::isAdminPageMU()) {
add_action('network_admin_menu', 'wordfence::admin_menus');
}
//else don't show menu
} else {
add_action('admin_menu', 'wordfence::admin_menus');
}
add_filter('pre_update_option_permalink_structure', 'wordfence::disablePermalinksFilter', 10, 2);
}
}