当前位置: 首页>>代码示例>>PHP>>正文


PHP WP_Error::remove方法代码示例

本文整理汇总了PHP中WP_Error::remove方法的典型用法代码示例。如果您正苦于以下问题:PHP WP_Error::remove方法的具体用法?PHP WP_Error::remove怎么用?PHP WP_Error::remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在WP_Error的用法示例。


在下文中一共展示了WP_Error::remove方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1:

 /**
  * @ticket 28092
  */
 function test_remove_error()
 {
     $error = new WP_Error();
     $error->add('foo', 'This is the first error message', 'some error data');
     $error->add('foo', 'This is the second error message');
     $error->add('bar', 'This is another error');
     $error->remove('foo');
     // Check the error has been removed.
     $this->assertEmpty($error->get_error_data('foo'));
     $this->assertEmpty($error->get_error_messages('foo'));
     // The 'bar' error should now be the 'first' error retrieved.
     $this->assertEquals('bar', $error->get_error_code());
     $this->assertEmpty($error->get_error_data());
 }
开发者ID:aaemnnosttv,项目名称:develop.git.wordpress.org,代码行数:17,代码来源:errors.php

示例2: getip

 function wp_limit_login_auth_signon($user, $username, $password)
 {
     global $ip, $msg, $wpdb;
     $ip = getip();
     if (empty($username) || empty($password)) {
         // do_action( 'wp_login_failed' );
     }
     if ($_SESSION["popup_flag"] == "true_0152") {
         $tablename = $wpdb->prefix . "limit_login";
         $tablerows = $wpdb->get_results("SELECT `login_id`, `login_ip`,`login_attempts`,`attempt_time`,`locked_time` FROM  `{$tablename}`   WHERE `login_ip` =  '{$ip}'  ORDER BY `login_id` DESC LIMIT 1 ");
         if (count($tablerows) == 1) {
             $time_now = date_create(date('Y-m-d G:i:s'));
             $attempt_time = date_create($tablerows[0]->attempt_time);
             $interval = date_diff($attempt_time, $time_now);
             if ($interval->format("%s") <= 1) {
                 if ($tablerows[0]->login_attempts != 0) {
                     wp_redirect(home_url());
                     exit;
                 } else {
                     return $user;
                 }
             } else {
                 /*$url_first = "http://www.shroomery.org/ythan/proxycheck.php?ip=".$ip;
                   $url_second = "http://check.getipintel.net/check.php?ip=".$ip;
                   $response_first = wp_remote_get($url_first); 
                   $response_second = wp_remote_get($url_second);
                     
                     $ip_check = false;
                    
                    if(($response_first['body']=="N")|| ($response_second['body']<=0.99)){
                         $ip_check = true;
                     } */
                 $ip_check = true;
                 if ($tablerows[0]->login_attempts % 7 == 0) {
                     if ($tablerows[0]->login_attempts != 0) {
                         $attempts = $tablerows[0]->login_attempts;
                         $attempts = $attempts + 1;
                         $_SESSION["popup_flag"] = "first";
                         $update_table = array('login_id' => $tablerows[0]->login_id, 'login_attempts' => $attempts);
                         $wpdb->update($tablename, $update_table, array('login_id' => $tablerows[0]->login_id));
                     }
                 }
                 // proxy or not
                 if ($ip_check == true) {
                     if (!is_numeric($tablerows[0]->locked_time)) {
                         $locked_time = date_create($tablerows[0]->locked_time);
                         $time_now = date_create(date('Y-m-d G:i:s'));
                         $interval = date_diff($locked_time, $time_now);
                         if ($interval->format("%i") <= 10) {
                             $msg = "Sorry..! Please wait 10 minutes..!";
                             $error = new WP_Error();
                             $error->add('wp_to_many_try', $msg);
                             return $error;
                         } else {
                             $update_table = array('login_id' => $tablerows[0]->login_id, 'login_attempts' => 0, 'attempt_time' => date('Y-m-d G:i:s'), 'locked_time' => 0);
                             $wpdb->update($tablename, $update_table, array('login_id' => $tablerows[0]->login_id));
                             return $user;
                         }
                     } else {
                         return $user;
                     }
                 } else {
                     $_SESSION["popup_flag"] = "first";
                     $error = new WP_Error();
                     $error->add('wp_proxy_detection', "Sorry..! Proxy detected..!");
                     return $error;
                 }
             }
         } else {
             return $user;
         }
     } else {
         $_SESSION["popup_flag"] = "first";
         $error = new WP_Error();
         $error->remove('wp_captcha', "Sorry..! captcha");
         return $error;
     }
 }
开发者ID:alessiosantocs,项目名称:aboutalessiowp,代码行数:78,代码来源:wp-limit-login-attempts.php


注:本文中的WP_Error::remove方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。