id; } /** * Get Captcha Key. * * @return string */ public function get_key() { return $this->key; } /** * Compact Attribute. * * @param string $form_key * @return void */ protected function compact_attr( $form_key ) { if ( in_array( $form_key, $this->compact_forms ) ) { echo esc_attr( 'data-size' ) . '="' . esc_attr( 'compact' ) . '"'; } } /** * Compact Forms Styles * * @param string $form_key * @return void */ protected function compact_styles( $form_key ) { if ( in_array( $form_key, $this->compact_forms ) ) { echo esc_attr( 'style' ) . '="' . esc_attr( 'display:flex;justify-content:center;' ) . '"'; } } /** * Singular Init. * * @return self */ public static function init() { if ( is_null( static::$instance ) ) { static::$instance = new static(); } return static::$instance; } /** * Constructor. */ protected function __construct() { $this->settings = MainSettings::init(); $this->set_id(); $this->set_identifier(); if ( method_exists( $this, 'setup' ) ) { $this->setup(); } if ( method_exists( $this, 'hooks' ) ) { $this->hooks(); } } /** * Get Form Key. * * @return string */ public function get_form_key() { return $this->form_key; } /** * Set Form Key. * * @param string $form_key * @return void */ public function set_form_key( $form_key ) { $this->form_key = $form_key; } /** * Get Captcha Verficiation HTML ID. * * @return string */ protected function generate_identifier() { return wp_generate_password( 12, false, false ); } /** * Set Captcha Unique ID. * * @return void */ abstract protected function set_id(); /** * Set Captcha Key. * * @return void */ abstract protected function set_key(); /** * Get Assets Keys. * * @return array */ public function get_assets_handles() { return array_column( $this->get_assets(), 'handle' ); } /** * Get Captcha Localize. * * @return array */ public function get_captcha_localize() { return array(); } /** * Set Identifier. * * @return void */ private function set_identifier() { $this->identifier = $this->generate_identifier(); } /** * Get Identifier. * * @return string */ protected function get_identifier() { return $this->identifier; } /** * Get HTML ID. * * @return string */ protected function get_html_id() { return $this->id . '-' . $this->identifier; } /** * Captcha HTML. * * @return void */ public function print_captcha_html( $form_key ) { ?>