/**
  * Set up errors and other stuff.
  *
  * @since 1.0.0
  */
 public static function init()
 {
     self::$url = 'https://www.google.com/recaptcha/api/siteverify';
     /**
      * API errors from
      * https://developers.google.com/recaptcha/docs/verify#error-code-reference
      */
     self::$api_errors = array('missing-input-secret' => __('The secret parameter is missing.', 'recaptcha_lightweight_adaptation'), 'invalid-input-secret' => __('The secret parameter is invalid or malformed.', 'recaptcha_lightweight_adaptation'), 'missing-input-response' => __('The response parameter is missing.', 'recaptcha_lightweight_adaptation'), 'invalid-input-response' => __('The response parameter is invalid or malformed.', 'recaptcha_lightweight_adaptation'));
     self::$plugin_errors = array('not_all_data' => __('Not all required data are presents in admin settings or passed to function for check.', 'recaptcha_lightweight_adaptation'), 'invalid_api_answer' => __('The obtained data from Google API have not valid format. Please notify the site administrator.', 'recaptcha_lightweight_adaptation'), 'unknown_api_error_code' => __('Unknown Google API answer and (or) type of errors inside.', 'recaptcha_lightweight_adaptation'));
 }
 /**
  * Load necessary files.
  *
  * @since 1.0.0
  */
 public static function load_dependencies()
 {
     if (is_admin()) {
         // The main admin file.
         require_once plugin_dir_path(dirname(__FILE__)) . 'admin/class-admin.php';
         Recaptcha_Lightweight_Adaptation_Admin::init();
     }
     // The main class for output captcha and other stuff
     require_once plugin_dir_path(dirname(__FILE__)) . 'inc/class-captcha.php';
     Recaptcha_Lightweight_Adaptation_Captcha::init();
     // Google API
     require_once plugin_dir_path(dirname(__FILE__)) . 'inc/class-api.php';
     Recaptcha_Lightweight_Adaptation_API::init();
     // Captcha on wp-login.php page
     require_once plugin_dir_path(dirname(__FILE__)) . 'public/class-wp-login.php';
 }
 /**
  * Default validate submit.
  *
  * @since 1.0.0
  *
  * @return bool|WP_Error
  */
 public static function default_validate()
 {
     $errors = new WP_Error();
     if (!empty($_POST['g-recaptcha-response'])) {
         $validate = Recaptcha_Lightweight_Adaptation_API::validate($_POST['g-recaptcha-response']);
         //$validate = Recaptcha_Lightweight_Adaptation_API::validate( 'jkhkjh' );
         // Not a robot
         if ($validate === true) {
             return true;
         } elseif (is_wp_error($validate)) {
             if (!empty($validate->errors)) {
                 foreach ($validate->errors as $code => $new_error) {
                     $errors->add($code, '<strong>ERROR</strong> ' . $new_error[0]);
                 }
             } else {
                 // We have errors object but no errors inside.
                 $errors->add('unknown_result_of_recaptcha_validation', __('<strong>ERROR</strong> Unknown result of the Recaptcha Light Adaptation plugin validation process.', 'recaptcha_lightweight_adaptation'));
             }
         } else {
             // Unknown result after validation
             $errors->add('unknown_result_of_recaptcha_validation', __('<strong>ERROR</strong> Unknown result of the Recaptcha Light Adaptation plugin validation process.', 'recaptcha_lightweight_adaptation'));
         }
     } else {
         $errors->add('missing_recaptcha_code', __('<strong>ERROR</strong>. Check „I’m not a robot“ checkbox.', 'recaptcha_lightweight_adaptation'));
     }
     return $errors;
 }