@@ -6,32 +6,32 @@ |
||
| 6 | 6 | |
| 7 | 7 | class Debugger implements Service { |
| 8 | 8 | |
| 9 | - const LOG_NAME = 'freddie_log'; |
|
| 10 | - |
|
| 11 | - public function register() { |
|
| 12 | - $this->register_log(); |
|
| 13 | - } |
|
| 14 | - |
|
| 15 | - public function register_log() :void { |
|
| 16 | - if ( ! get_option( self::LOG_NAME ) ) { |
|
| 17 | - add_option( self::LOG_NAME, [] ); |
|
| 18 | - } |
|
| 19 | - } |
|
| 20 | - |
|
| 21 | - public function get_log() { |
|
| 22 | - return get_option( self::LOG_NAME, [] ); |
|
| 23 | - } |
|
| 24 | - |
|
| 25 | - public function pretty_log() { |
|
| 26 | - $log = $this->get_log(); |
|
| 27 | - return $this->pretty_debug( 'Pretty Log', $log ); |
|
| 28 | - } |
|
| 29 | - |
|
| 30 | - public function pretty_debug( $label, $value ) { |
|
| 31 | - $res = "<strong>{$label}</strong>"; |
|
| 32 | - $res .= "<pre>"; |
|
| 33 | - $res .= esc_html( json_encode( $value, JSON_PRETTY_PRINT ) ); |
|
| 34 | - $res .= "</pre>"; |
|
| 35 | - echo $res; |
|
| 36 | - } |
|
| 9 | + const LOG_NAME = 'freddie_log'; |
|
| 10 | + |
|
| 11 | + public function register() { |
|
| 12 | + $this->register_log(); |
|
| 13 | + } |
|
| 14 | + |
|
| 15 | + public function register_log() :void { |
|
| 16 | + if ( ! get_option( self::LOG_NAME ) ) { |
|
| 17 | + add_option( self::LOG_NAME, [] ); |
|
| 18 | + } |
|
| 19 | + } |
|
| 20 | + |
|
| 21 | + public function get_log() { |
|
| 22 | + return get_option( self::LOG_NAME, [] ); |
|
| 23 | + } |
|
| 24 | + |
|
| 25 | + public function pretty_log() { |
|
| 26 | + $log = $this->get_log(); |
|
| 27 | + return $this->pretty_debug( 'Pretty Log', $log ); |
|
| 28 | + } |
|
| 29 | + |
|
| 30 | + public function pretty_debug( $label, $value ) { |
|
| 31 | + $res = "<strong>{$label}</strong>"; |
|
| 32 | + $res .= "<pre>"; |
|
| 33 | + $res .= esc_html( json_encode( $value, JSON_PRETTY_PRINT ) ); |
|
| 34 | + $res .= "</pre>"; |
|
| 35 | + echo $res; |
|
| 36 | + } |
|
| 37 | 37 | } |
| 38 | 38 | \ No newline at end of file |
@@ -14,12 +14,12 @@ |
||
| 14 | 14 | |
| 15 | 15 | public function register_log() :void { |
| 16 | 16 | if ( ! get_option( self::LOG_NAME ) ) { |
| 17 | - add_option( self::LOG_NAME, [] ); |
|
| 17 | + add_option( self::LOG_NAME, [ ] ); |
|
| 18 | 18 | } |
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | public function get_log() { |
| 22 | - return get_option( self::LOG_NAME, [] ); |
|
| 22 | + return get_option( self::LOG_NAME, [ ] ); |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | public function pretty_log() { |
@@ -6,70 +6,70 @@ |
||
| 6 | 6 | |
| 7 | 7 | final class Recaptcha { |
| 8 | 8 | |
| 9 | - public $recaptcha_options; |
|
| 10 | - public $site_key; |
|
| 11 | - public $secret_key; |
|
| 9 | + public $recaptcha_options; |
|
| 10 | + public $site_key; |
|
| 11 | + public $secret_key; |
|
| 12 | 12 | |
| 13 | - const STATUS = 'yikes-mc-recaptcha-status'; |
|
| 14 | - const SITE_KEY = 'yikes-mc-recaptcha-site-key'; |
|
| 15 | - const SECRET_KEY = 'yikes-mc-recaptcha-secret-key'; |
|
| 13 | + const STATUS = 'yikes-mc-recaptcha-status'; |
|
| 14 | + const SITE_KEY = 'yikes-mc-recaptcha-site-key'; |
|
| 15 | + const SECRET_KEY = 'yikes-mc-recaptcha-secret-key'; |
|
| 16 | 16 | |
| 17 | - public function setup( $recaptcha_options = [] ) { |
|
| 18 | - if ( ! $this->has_recaptcha() ) { |
|
| 19 | - return false; |
|
| 20 | - } |
|
| 21 | - return $this->get_options( $recaptcha_options ); |
|
| 22 | - } |
|
| 17 | + public function setup( $recaptcha_options = [] ) { |
|
| 18 | + if ( ! $this->has_recaptcha() ) { |
|
| 19 | + return false; |
|
| 20 | + } |
|
| 21 | + return $this->get_options( $recaptcha_options ); |
|
| 22 | + } |
|
| 23 | 23 | |
| 24 | - private function has_recaptcha() { |
|
| 25 | - if ( get_option( static::STATUS, '' ) == '1' ) { |
|
| 26 | - return true; |
|
| 27 | - } |
|
| 28 | - return false; |
|
| 29 | - } |
|
| 24 | + private function has_recaptcha() { |
|
| 25 | + if ( get_option( static::STATUS, '' ) == '1' ) { |
|
| 26 | + return true; |
|
| 27 | + } |
|
| 28 | + return false; |
|
| 29 | + } |
|
| 30 | 30 | |
| 31 | - private function get_site_key() { |
|
| 32 | - $site_key = get_option( 'yikes-mc-recaptcha-secret-key' , '' ); |
|
| 33 | - if ( ! $site_key ) { |
|
| 34 | - throw InvalidRecaptcha::from_site_key(); |
|
| 35 | - } |
|
| 36 | - return $site_key; |
|
| 37 | - } |
|
| 31 | + private function get_site_key() { |
|
| 32 | + $site_key = get_option( 'yikes-mc-recaptcha-secret-key' , '' ); |
|
| 33 | + if ( ! $site_key ) { |
|
| 34 | + throw InvalidRecaptcha::from_site_key(); |
|
| 35 | + } |
|
| 36 | + return $site_key; |
|
| 37 | + } |
|
| 38 | 38 | |
| 39 | - private function get_secret_key() { |
|
| 40 | - $secret_key = get_option( 'yikes-mc-recaptcha-secret-key' , '' ); |
|
| 41 | - if ( ! $secret_key ) { |
|
| 42 | - throw InvalidRecaptcha::from_secret_key(); |
|
| 43 | - } |
|
| 44 | - return $secret_key; |
|
| 45 | - } |
|
| 39 | + private function get_secret_key() { |
|
| 40 | + $secret_key = get_option( 'yikes-mc-recaptcha-secret-key' , '' ); |
|
| 41 | + if ( ! $secret_key ) { |
|
| 42 | + throw InvalidRecaptcha::from_secret_key(); |
|
| 43 | + } |
|
| 44 | + return $secret_key; |
|
| 45 | + } |
|
| 46 | 46 | |
| 47 | - private function get_options( $defaults ) { |
|
| 48 | - // Store the site language (to load recaptcha in a specific language). |
|
| 49 | - $locale = get_locale(); |
|
| 50 | - $locale_split = explode( '_', $locale ); |
|
| 47 | + private function get_options( $defaults ) { |
|
| 48 | + // Store the site language (to load recaptcha in a specific language). |
|
| 49 | + $locale = get_locale(); |
|
| 50 | + $locale_split = explode( '_', $locale ); |
|
| 51 | 51 | |
| 52 | - // Setup reCAPTCHA parameters. |
|
| 53 | - $lang = ! empty( $locale_split ) ? $locale_split[0] : $locale; |
|
| 54 | - $lang = ! empty( $defaults['recaptcha_lang'] ) ? $defaults['recaptcha_lang'] : $lang; |
|
| 55 | - $type = ! empty( $defaults['recaptcha_type'] ) ? strtolower( $defaults['recaptcha_type'] ) : 'image'; // setup recaptcha type |
|
| 56 | - $theme = ! empty( $defaults['recaptcha_theme'] ) ? strtolower( $defaults['recaptcha_theme'] ) : 'light'; // setup recaptcha theme |
|
| 57 | - $size = ! empty( $defaults['recaptcha_size'] ) ? strtolower( $defaults['recaptcha_size'] ) : 'normal'; // setup recaptcha size |
|
| 58 | - $data_cb = ! empty( $defaults['recaptcha_data_callback'] ) ? $defaults['recaptcha_data_callback'] : false; // setup recaptcha size |
|
| 59 | - $expired_cb = ! empty( $defaults['recaptcha_expired_callback'] ) ? $defaults['recaptcha_expired_callback'] : false; // setup recaptcha size |
|
| 52 | + // Setup reCAPTCHA parameters. |
|
| 53 | + $lang = ! empty( $locale_split ) ? $locale_split[0] : $locale; |
|
| 54 | + $lang = ! empty( $defaults['recaptcha_lang'] ) ? $defaults['recaptcha_lang'] : $lang; |
|
| 55 | + $type = ! empty( $defaults['recaptcha_type'] ) ? strtolower( $defaults['recaptcha_type'] ) : 'image'; // setup recaptcha type |
|
| 56 | + $theme = ! empty( $defaults['recaptcha_theme'] ) ? strtolower( $defaults['recaptcha_theme'] ) : 'light'; // setup recaptcha theme |
|
| 57 | + $size = ! empty( $defaults['recaptcha_size'] ) ? strtolower( $defaults['recaptcha_size'] ) : 'normal'; // setup recaptcha size |
|
| 58 | + $data_cb = ! empty( $defaults['recaptcha_data_callback'] ) ? $defaults['recaptcha_data_callback'] : false; // setup recaptcha size |
|
| 59 | + $expired_cb = ! empty( $defaults['recaptcha_expired_callback'] ) ? $defaults['recaptcha_expired_callback'] : false; // setup recaptcha size |
|
| 60 | 60 | |
| 61 | - $script_params = '?hl=' . $lang . '&onload=renderReCaptchaCallback&render=explicit'; |
|
| 61 | + $script_params = '?hl=' . $lang . '&onload=renderReCaptchaCallback&render=explicit'; |
|
| 62 | 62 | |
| 63 | - return [ |
|
| 64 | - 'language' => $lang, |
|
| 65 | - 'theme' => $theme, |
|
| 66 | - 'type' => $type, |
|
| 67 | - 'size' => $size, |
|
| 68 | - 'success_callback' => $data_cb, |
|
| 69 | - 'expired_callback' => $expired_cb, |
|
| 70 | - 'script_params' => $script_params, |
|
| 71 | - 'site_key' => $this->get_site_key(), |
|
| 72 | - 'secret_key' => $this->get_secret_key(), |
|
| 73 | - ]; |
|
| 74 | - } |
|
| 63 | + return [ |
|
| 64 | + 'language' => $lang, |
|
| 65 | + 'theme' => $theme, |
|
| 66 | + 'type' => $type, |
|
| 67 | + 'size' => $size, |
|
| 68 | + 'success_callback' => $data_cb, |
|
| 69 | + 'expired_callback' => $expired_cb, |
|
| 70 | + 'script_params' => $script_params, |
|
| 71 | + 'site_key' => $this->get_site_key(), |
|
| 72 | + 'secret_key' => $this->get_secret_key(), |
|
| 73 | + ]; |
|
| 74 | + } |
|
| 75 | 75 | } |
| 76 | 76 | \ No newline at end of file |
@@ -14,7 +14,7 @@ discard block |
||
| 14 | 14 | const SITE_KEY = 'yikes-mc-recaptcha-site-key'; |
| 15 | 15 | const SECRET_KEY = 'yikes-mc-recaptcha-secret-key'; |
| 16 | 16 | |
| 17 | - public function setup( $recaptcha_options = [] ) { |
|
| 17 | + public function setup( $recaptcha_options = [ ] ) { |
|
| 18 | 18 | if ( ! $this->has_recaptcha() ) { |
| 19 | 19 | return false; |
| 20 | 20 | } |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | private function get_site_key() { |
| 32 | - $site_key = get_option( 'yikes-mc-recaptcha-secret-key' , '' ); |
|
| 32 | + $site_key = get_option( 'yikes-mc-recaptcha-secret-key', '' ); |
|
| 33 | 33 | if ( ! $site_key ) { |
| 34 | 34 | throw InvalidRecaptcha::from_site_key(); |
| 35 | 35 | } |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | private function get_secret_key() { |
| 40 | - $secret_key = get_option( 'yikes-mc-recaptcha-secret-key' , '' ); |
|
| 40 | + $secret_key = get_option( 'yikes-mc-recaptcha-secret-key', '' ); |
|
| 41 | 41 | if ( ! $secret_key ) { |
| 42 | 42 | throw InvalidRecaptcha::from_secret_key(); |
| 43 | 43 | } |
@@ -50,13 +50,13 @@ discard block |
||
| 50 | 50 | $locale_split = explode( '_', $locale ); |
| 51 | 51 | |
| 52 | 52 | // Setup reCAPTCHA parameters. |
| 53 | - $lang = ! empty( $locale_split ) ? $locale_split[0] : $locale; |
|
| 54 | - $lang = ! empty( $defaults['recaptcha_lang'] ) ? $defaults['recaptcha_lang'] : $lang; |
|
| 55 | - $type = ! empty( $defaults['recaptcha_type'] ) ? strtolower( $defaults['recaptcha_type'] ) : 'image'; // setup recaptcha type |
|
| 56 | - $theme = ! empty( $defaults['recaptcha_theme'] ) ? strtolower( $defaults['recaptcha_theme'] ) : 'light'; // setup recaptcha theme |
|
| 57 | - $size = ! empty( $defaults['recaptcha_size'] ) ? strtolower( $defaults['recaptcha_size'] ) : 'normal'; // setup recaptcha size |
|
| 58 | - $data_cb = ! empty( $defaults['recaptcha_data_callback'] ) ? $defaults['recaptcha_data_callback'] : false; // setup recaptcha size |
|
| 59 | - $expired_cb = ! empty( $defaults['recaptcha_expired_callback'] ) ? $defaults['recaptcha_expired_callback'] : false; // setup recaptcha size |
|
| 53 | + $lang = ! empty( $locale_split ) ? $locale_split[ 0 ] : $locale; |
|
| 54 | + $lang = ! empty( $defaults[ 'recaptcha_lang' ] ) ? $defaults[ 'recaptcha_lang' ] : $lang; |
|
| 55 | + $type = ! empty( $defaults[ 'recaptcha_type' ] ) ? strtolower( $defaults[ 'recaptcha_type' ] ) : 'image'; // setup recaptcha type |
|
| 56 | + $theme = ! empty( $defaults[ 'recaptcha_theme' ] ) ? strtolower( $defaults[ 'recaptcha_theme' ] ) : 'light'; // setup recaptcha theme |
|
| 57 | + $size = ! empty( $defaults[ 'recaptcha_size' ] ) ? strtolower( $defaults[ 'recaptcha_size' ] ) : 'normal'; // setup recaptcha size |
|
| 58 | + $data_cb = ! empty( $defaults[ 'recaptcha_data_callback' ] ) ? $defaults[ 'recaptcha_data_callback' ] : false; // setup recaptcha size |
|
| 59 | + $expired_cb = ! empty( $defaults[ 'recaptcha_expired_callback' ] ) ? $defaults[ 'recaptcha_expired_callback' ] : false; // setup recaptcha size |
|
| 60 | 60 | |
| 61 | 61 | $script_params = '?hl=' . $lang . '&onload=renderReCaptchaCallback&render=explicit'; |
| 62 | 62 | |
@@ -4,31 +4,31 @@ |
||
| 4 | 4 | |
| 5 | 5 | trait SubmitButton { |
| 6 | 6 | |
| 7 | - public function submit_button_classes() { |
|
| 8 | - $submit_button_classes = 'yikes-easy-mc-submit-button yikes-easy-mc-submit-button-'; |
|
| 9 | - $submit_button_classes .= $this->form_id; |
|
| 10 | - $submit_button_classes .= ' btn btn-primary'; |
|
| 11 | - // Adding additional space in front of these classes. |
|
| 12 | - $submit_button_classes .= ' ' . $this->form_data['form_settings']['yikes-easy-mc-submit-button-classes']; |
|
| 13 | - $submit_button_classes .= $this->admin_class; |
|
| 14 | - return apply_filters( 'yikes-mailchimp-form-submit-button-classes', $submit_button_classes, $this->form_id ); |
|
| 15 | - } |
|
| 7 | + public function submit_button_classes() { |
|
| 8 | + $submit_button_classes = 'yikes-easy-mc-submit-button yikes-easy-mc-submit-button-'; |
|
| 9 | + $submit_button_classes .= $this->form_id; |
|
| 10 | + $submit_button_classes .= ' btn btn-primary'; |
|
| 11 | + // Adding additional space in front of these classes. |
|
| 12 | + $submit_button_classes .= ' ' . $this->form_data['form_settings']['yikes-easy-mc-submit-button-classes']; |
|
| 13 | + $submit_button_classes .= $this->admin_class; |
|
| 14 | + return apply_filters( 'yikes-mailchimp-form-submit-button-classes', $submit_button_classes, $this->form_id ); |
|
| 15 | + } |
|
| 16 | 16 | |
| 17 | - public function submit_button_text( $shortcode_prop ) { |
|
| 18 | - $submit_button_text = ''; |
|
| 19 | - switch( true ) { |
|
| 20 | - case ! empty( $shortcode_prop ): |
|
| 21 | - $submit_button_text = $shortcode_prop; |
|
| 22 | - break; |
|
| 17 | + public function submit_button_text( $shortcode_prop ) { |
|
| 18 | + $submit_button_text = ''; |
|
| 19 | + switch( true ) { |
|
| 20 | + case ! empty( $shortcode_prop ): |
|
| 21 | + $submit_button_text = $shortcode_prop; |
|
| 22 | + break; |
|
| 23 | 23 | |
| 24 | - case $this->form_data['form_settings']['yikes-easy-mc-submit-button-text']: |
|
| 25 | - $submit_button_text = $this->form_data['form_settings']['yikes-easy-mc-submit-button-text']; |
|
| 26 | - break; |
|
| 24 | + case $this->form_data['form_settings']['yikes-easy-mc-submit-button-text']: |
|
| 25 | + $submit_button_text = $this->form_data['form_settings']['yikes-easy-mc-submit-button-text']; |
|
| 26 | + break; |
|
| 27 | 27 | |
| 28 | - default: |
|
| 29 | - $submit_button_text = __( 'Submit', 'yikes-inc-easy-mailchimp-extender' ); |
|
| 30 | - break; |
|
| 31 | - } |
|
| 32 | - return apply_filters( 'yikes-mailchimp-form-submit-button-text', $submit_button_text, $this->form_id ); |
|
| 33 | - } |
|
| 28 | + default: |
|
| 29 | + $submit_button_text = __( 'Submit', 'yikes-inc-easy-mailchimp-extender' ); |
|
| 30 | + break; |
|
| 31 | + } |
|
| 32 | + return apply_filters( 'yikes-mailchimp-form-submit-button-text', $submit_button_text, $this->form_id ); |
|
| 33 | + } |
|
| 34 | 34 | } |
| 35 | 35 | \ No newline at end of file |
@@ -9,20 +9,20 @@ |
||
| 9 | 9 | $submit_button_classes .= $this->form_id; |
| 10 | 10 | $submit_button_classes .= ' btn btn-primary'; |
| 11 | 11 | // Adding additional space in front of these classes. |
| 12 | - $submit_button_classes .= ' ' . $this->form_data['form_settings']['yikes-easy-mc-submit-button-classes']; |
|
| 12 | + $submit_button_classes .= ' ' . $this->form_data[ 'form_settings' ][ 'yikes-easy-mc-submit-button-classes' ]; |
|
| 13 | 13 | $submit_button_classes .= $this->admin_class; |
| 14 | 14 | return apply_filters( 'yikes-mailchimp-form-submit-button-classes', $submit_button_classes, $this->form_id ); |
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | public function submit_button_text( $shortcode_prop ) { |
| 18 | 18 | $submit_button_text = ''; |
| 19 | - switch( true ) { |
|
| 19 | + switch ( true ) { |
|
| 20 | 20 | case ! empty( $shortcode_prop ): |
| 21 | 21 | $submit_button_text = $shortcode_prop; |
| 22 | 22 | break; |
| 23 | 23 | |
| 24 | - case $this->form_data['form_settings']['yikes-easy-mc-submit-button-text']: |
|
| 25 | - $submit_button_text = $this->form_data['form_settings']['yikes-easy-mc-submit-button-text']; |
|
| 24 | + case $this->form_data[ 'form_settings' ][ 'yikes-easy-mc-submit-button-text' ]: |
|
| 25 | + $submit_button_text = $this->form_data[ 'form_settings' ][ 'yikes-easy-mc-submit-button-text' ]; |
|
| 26 | 26 | break; |
| 27 | 27 | |
| 28 | 28 | default: |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | * |
| 74 | 74 | * @var array |
| 75 | 75 | */ |
| 76 | - protected $localizations = []; |
|
| 76 | + protected $localizations = [ ]; |
|
| 77 | 77 | |
| 78 | 78 | /** |
| 79 | 79 | * Instantiate a ScriptAsset object. |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | public function __construct( |
| 92 | 92 | $handle, |
| 93 | 93 | $source, |
| 94 | - $dependencies = [], |
|
| 94 | + $dependencies = [ ], |
|
| 95 | 95 | $version = self::VERSION, |
| 96 | 96 | $in_footer = self::ENQUEUE_HEADER, |
| 97 | 97 | $external = false |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | * @return Closure |
| 128 | 128 | */ |
| 129 | 129 | protected function get_register_closure() { |
| 130 | - return function () { |
|
| 130 | + return function() { |
|
| 131 | 131 | if ( wp_script_is( $this->handle, 'registered' ) ) { |
| 132 | 132 | return; |
| 133 | 133 | } |
@@ -150,7 +150,7 @@ discard block |
||
| 150 | 150 | * @return Closure |
| 151 | 151 | */ |
| 152 | 152 | protected function get_enqueue_closure() { |
| 153 | - return function () { |
|
| 153 | + return function() { |
|
| 154 | 154 | if ( ! wp_script_is( $this->handle, 'registered' ) ) { |
| 155 | 155 | throw FailedToRegister::asset_not_registered( $this->handle ); |
| 156 | 156 | } |
@@ -171,7 +171,7 @@ discard block |
||
| 171 | 171 | * @return Closure |
| 172 | 172 | */ |
| 173 | 173 | protected function get_dequeue_closure() { |
| 174 | - return function () { |
|
| 174 | + return function() { |
|
| 175 | 175 | wp_dequeue_script( $this->handle ); |
| 176 | 176 | }; |
| 177 | 177 | } |
@@ -18,10 +18,10 @@ |
||
| 18 | 18 | |
| 19 | 19 | <div |
| 20 | 20 | class="g-recaptcha" |
| 21 | - data-sitekey="<?= esc_attr( $this->form->recaptcha['site_key'] ); ?>" |
|
| 22 | - data-theme="<?= esc_attr( $this->form->recaptcha['theme'] ); ?>" |
|
| 23 | - data-type="<?= esc_attr( $this->form->recaptcha['type'] ); ?>" |
|
| 24 | - data-size="<?= esc_attr( $this->form->recaptcha['size'] ); ?>" |
|
| 25 | - data-callback="<?= esc_attr( $this->form->recaptcha['success_callback'] ); ?>" |
|
| 26 | - data-expired-callback="<?= esc_attr( $this->form->recaptcha['expired_callback'] ); ?>" |
|
| 21 | + data-sitekey="<?= esc_attr( $this->form->recaptcha[ 'site_key' ] ); ?>" |
|
| 22 | + data-theme="<?= esc_attr( $this->form->recaptcha[ 'theme' ] ); ?>" |
|
| 23 | + data-type="<?= esc_attr( $this->form->recaptcha[ 'type' ] ); ?>" |
|
| 24 | + data-size="<?= esc_attr( $this->form->recaptcha[ 'size' ] ); ?>" |
|
| 25 | + data-callback="<?= esc_attr( $this->form->recaptcha[ 'success_callback' ] ); ?>" |
|
| 26 | + data-expired-callback="<?= esc_attr( $this->form->recaptcha[ 'expired_callback' ] ); ?>" |
|
| 27 | 27 | ></div> |
| 28 | 28 | \ No newline at end of file |
@@ -3,8 +3,8 @@ discard block |
||
| 3 | 3 | namespace YIKES\EasyForms\Form; |
| 4 | 4 | |
| 5 | 5 | trait FormHelper { |
| 6 | - public function form_title( $title, $custom_title, $form_name ) { |
|
| 7 | - if ( $title ) { |
|
| 6 | + public function form_title( $title, $custom_title, $form_name ) { |
|
| 7 | + if ( $title ) { |
|
| 8 | 8 | if ( ! empty( $custom_title ) ) { |
| 9 | 9 | /** |
| 10 | 10 | * Filter the title that is displayed through the shortcode. |
@@ -14,15 +14,15 @@ discard block |
||
| 14 | 14 | */ |
| 15 | 15 | return apply_filters( 'yikes-mailchimp-form-title', apply_filters( 'the_title', $custom_title ), $this->form_id ); |
| 16 | 16 | } else { |
| 17 | - return apply_filters( 'yikes-mailchimp-form-title', apply_filters( 'the_title', $form_name ), $this->form_id ); |
|
| 17 | + return apply_filters( 'yikes-mailchimp-form-title', apply_filters( 'the_title', $form_name ), $this->form_id ); |
|
| 18 | 18 | } |
| 19 | - } |
|
| 19 | + } |
|
| 20 | 20 | |
| 21 | - return false; |
|
| 22 | - } |
|
| 21 | + return false; |
|
| 22 | + } |
|
| 23 | 23 | |
| 24 | - public function form_description( $description, $custom_description ) { |
|
| 25 | - if ( $description ) { |
|
| 24 | + public function form_description( $description, $custom_description ) { |
|
| 25 | + if ( $description ) { |
|
| 26 | 26 | if ( ! empty( $custom_description ) ) { |
| 27 | 27 | /** |
| 28 | 28 | * Filter the description that is displayed through the shortcode. |
@@ -35,11 +35,11 @@ discard block |
||
| 35 | 35 | return apply_filters( 'yikes-mailchimp-form-description', $this->form_data['form_description'], $this->form_id ); |
| 36 | 36 | } |
| 37 | 37 | } else { |
| 38 | - return false; |
|
| 39 | - } |
|
| 40 | - } |
|
| 38 | + return false; |
|
| 39 | + } |
|
| 40 | + } |
|
| 41 | 41 | |
| 42 | - protected function reduce_field_count() { |
|
| 42 | + protected function reduce_field_count() { |
|
| 43 | 43 | $this->field_count = $this->field_count --; |
| 44 | 44 | } |
| 45 | 45 | |
@@ -51,9 +51,9 @@ discard block |
||
| 51 | 51 | $form_classes = $this->form_data['form_settings']['yikes-easy-mc-form-class-names']; |
| 52 | 52 | $form_classes .= ' yikes-easy-mc-form yikes-easy-mc-form-' . $this->form_id; |
| 53 | 53 | |
| 54 | - if ( isset( $this->form_inline ) && $this->form_inline != 0 ) { |
|
| 55 | - $form_classes .= ' yikes-mailchimp-form-inline '; |
|
| 56 | - } |
|
| 54 | + if ( isset( $this->form_inline ) && $this->form_inline != 0 ) { |
|
| 55 | + $form_classes .= ' yikes-mailchimp-form-inline '; |
|
| 56 | + } |
|
| 57 | 57 | |
| 58 | 58 | $form_classes .= ' '; |
| 59 | 59 | |
@@ -63,14 +63,14 @@ discard block |
||
| 63 | 63 | $form_classes .= ' yikes-easy-mc-display-none'; |
| 64 | 64 | } |
| 65 | 65 | |
| 66 | - return $form_classes; |
|
| 66 | + return $form_classes; |
|
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | public function inline_form_override() { |
| 70 | 70 | return isset( $this->has_recaptcha ) || ( function_exists( 'is_plugin_active' ) && is_plugin_active( 'eu-opt-in-compliance-for-mailchimp/yikes-inc-easy-mailchimp-eu-law-compliance-extension.php' ) ); |
| 71 | 71 | } |
| 72 | 72 | |
| 73 | - public function edit_form_link() { |
|
| 73 | + public function edit_form_link() { |
|
| 74 | 74 | if( current_user_can( apply_filters( 'yikes-mailchimp-user-role-access' , 'manage_options' ) ) ) { |
| 75 | 75 | $edit_form_link = '<span class="edit-link">'; |
| 76 | 76 | $edit_form_link .= '<a class="post-edit-link" href="' . esc_url( admin_url( 'admin.php?page=yikes-mailchimp-edit-form&id=' . $this->form_id ) ) . '" title="' . __( 'Edit' , 'yikes-inc-easy-mailchimp-extender' ) . ' ' . ucwords( $this->form_data['form_name'] ) . '">' . __( 'Edit Form' , 'yikes-inc-easy-mailchimp-extender' ) . '</a>'; |
@@ -80,5 +80,5 @@ discard block |
||
| 80 | 80 | $edit_form_link = ''; |
| 81 | 81 | } |
| 82 | 82 | return $edit_form_link; |
| 83 | - } |
|
| 83 | + } |
|
| 84 | 84 | } |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | */ |
| 33 | 33 | return apply_filters( 'yikes-mailchimp-form-description', $custom_description, $this->form_id ); |
| 34 | 34 | } else { |
| 35 | - return apply_filters( 'yikes-mailchimp-form-description', $this->form_data['form_description'], $this->form_id ); |
|
| 35 | + return apply_filters( 'yikes-mailchimp-form-description', $this->form_data[ 'form_description' ], $this->form_id ); |
|
| 36 | 36 | } |
| 37 | 37 | } else { |
| 38 | 38 | return false; |
@@ -40,15 +40,15 @@ discard block |
||
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | protected function reduce_field_count() { |
| 43 | - $this->field_count = $this->field_count --; |
|
| 43 | + $this->field_count = $this->field_count--; |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | protected function set_field_count() { |
| 47 | - return isset( $this->form_data['fields'] ) ? count( $this->form_data['fields'] ) : 0; |
|
| 47 | + return isset( $this->form_data[ 'fields' ] ) ? count( $this->form_data[ 'fields' ] ) : 0; |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | public function form_classes( bool $is_submitted ) { |
| 51 | - $form_classes = $this->form_data['form_settings']['yikes-easy-mc-form-class-names']; |
|
| 51 | + $form_classes = $this->form_data[ 'form_settings' ][ 'yikes-easy-mc-form-class-names' ]; |
|
| 52 | 52 | $form_classes .= ' yikes-easy-mc-form yikes-easy-mc-form-' . $this->form_id; |
| 53 | 53 | |
| 54 | 54 | if ( isset( $this->form_inline ) && $this->form_inline != 0 ) { |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | |
| 60 | 60 | $form_classes = apply_filters( 'yikes-mailchimp-form-class', $form_classes, $this->form_id ); |
| 61 | 61 | |
| 62 | - if ( $is_submitted && $this->form_data['submission_settings']['hide_form_post_signup'] == 1 ) { |
|
| 62 | + if ( $is_submitted && $this->form_data[ 'submission_settings' ][ 'hide_form_post_signup' ] == 1 ) { |
|
| 63 | 63 | $form_classes .= ' yikes-easy-mc-display-none'; |
| 64 | 64 | } |
| 65 | 65 | |
@@ -71,11 +71,11 @@ discard block |
||
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | public function edit_form_link() { |
| 74 | - if( current_user_can( apply_filters( 'yikes-mailchimp-user-role-access' , 'manage_options' ) ) ) { |
|
| 74 | + if ( current_user_can( apply_filters( 'yikes-mailchimp-user-role-access', 'manage_options' ) ) ) { |
|
| 75 | 75 | $edit_form_link = '<span class="edit-link">'; |
| 76 | - $edit_form_link .= '<a class="post-edit-link" href="' . esc_url( admin_url( 'admin.php?page=yikes-mailchimp-edit-form&id=' . $this->form_id ) ) . '" title="' . __( 'Edit' , 'yikes-inc-easy-mailchimp-extender' ) . ' ' . ucwords( $this->form_data['form_name'] ) . '">' . __( 'Edit Form' , 'yikes-inc-easy-mailchimp-extender' ) . '</a>'; |
|
| 76 | + $edit_form_link .= '<a class="post-edit-link" href="' . esc_url( admin_url( 'admin.php?page=yikes-mailchimp-edit-form&id=' . $this->form_id ) ) . '" title="' . __( 'Edit', 'yikes-inc-easy-mailchimp-extender' ) . ' ' . ucwords( $this->form_data[ 'form_name' ] ) . '">' . __( 'Edit Form', 'yikes-inc-easy-mailchimp-extender' ) . '</a>'; |
|
| 77 | 77 | $edit_form_link .= '</span>'; |
| 78 | - $edit_form_link = apply_filters( 'yikes-mailchimp-front-end-form-action-links', $edit_form_link, $this->form_id, ucwords( $this->form_data['form_name'] ) ); |
|
| 78 | + $edit_form_link = apply_filters( 'yikes-mailchimp-front-end-form-action-links', $edit_form_link, $this->form_id, ucwords( $this->form_data[ 'form_name' ] ) ); |
|
| 79 | 79 | } else { |
| 80 | 80 | $edit_form_link = ''; |
| 81 | 81 | } |
@@ -14,11 +14,6 @@ |
||
| 14 | 14 | use YIKES\EasyForms\Field\Field; |
| 15 | 15 | use YIKES\EasyForms\Field\Hidden; |
| 16 | 16 | use YIKES\EasyForms\Field\Types; |
| 17 | -use YIKES\EasyForms\Renderable; |
|
| 18 | -use YIKES\EasyForms\Assets\AssetsAware; |
|
| 19 | -use YIKES\EasyForms\Assets\AssetsAwareness; |
|
| 20 | -use YIKES\EasyForms\Assets\ScriptAsset; |
|
| 21 | -use YIKES\EasyForms\Service; |
|
| 22 | 17 | use YIKES\EasyForms\Model\OptinForm as EasyFormsModel; |
| 23 | 18 | use YIKES\EasyForms\Model\Recaptcha as RecaptchaModel; |
| 24 | 19 | use YIKES\EasyForms\Model\OptinMeta as Meta; |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | * @since %VERSION% |
| 87 | 87 | * @var array |
| 88 | 88 | */ |
| 89 | - private $submitted_data = []; |
|
| 89 | + private $submitted_data = [ ]; |
|
| 90 | 90 | |
| 91 | 91 | /** |
| 92 | 92 | * The validated data for this form. |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | * @since %VERSION% |
| 95 | 95 | * @var array |
| 96 | 96 | */ |
| 97 | - private $valid_data = []; |
|
| 97 | + private $valid_data = [ ]; |
|
| 98 | 98 | |
| 99 | 99 | /** |
| 100 | 100 | * Admin CSS Class |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | $this->form_id = $form_id; |
| 119 | 119 | $this->form_data = $form_data; |
| 120 | 120 | $this->field_count = $this->set_field_count(); |
| 121 | - $this->form_inline = $form_data['form_settings']['yikes-easy-mc-inline-form']; |
|
| 121 | + $this->form_inline = $form_data[ 'form_settings' ][ 'yikes-easy-mc-inline-form' ]; |
|
| 122 | 122 | $this->recaptcha = ( new RecaptchaModel() )->setup( $attr ); |
| 123 | 123 | } |
| 124 | 124 | |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | */ |
| 130 | 130 | private function admin_class() { |
| 131 | 131 | $is_admin = is_user_logged_in() && current_user_can( |
| 132 | - apply_filters( 'yikes-mailchimp-user-role-access' , 'manage_options' ) |
|
| 132 | + apply_filters( 'yikes-mailchimp-user-role-access', 'manage_options' ) |
|
| 133 | 133 | ); |
| 134 | 134 | return $is_admin ? ' admin-logged-in' : ''; |
| 135 | 135 | } |
@@ -161,7 +161,7 @@ discard block |
||
| 161 | 161 | * @since %VERSION% |
| 162 | 162 | */ |
| 163 | 163 | private function create_fields() { |
| 164 | - $fields = []; |
|
| 164 | + $fields = [ ]; |
|
| 165 | 165 | |
| 166 | 166 | // // Manually add the hidden nonce and referrer fields. |
| 167 | 167 | // $fields[] = new Hidden( "yikes_easy_mc_new_subscriber", wp_create_nonce( 'yikes_easy_mc_form_submit' ), $this->form_id ); |
@@ -177,8 +177,8 @@ discard block |
||
| 177 | 177 | // $fields[] = new Hidden( 'yikes-mailchimp-submitted-form', $this->form_id, $this->form_id ); |
| 178 | 178 | |
| 179 | 179 | // Add all of the active fields. |
| 180 | - foreach ( $this->form_data['fields'] as $field ) { |
|
| 181 | - if ( isset( $field['hide'] ) && (string) $field['hide'] === '1' ) { |
|
| 180 | + foreach ( $this->form_data[ 'fields' ] as $field ) { |
|
| 181 | + if ( isset( $field[ 'hide' ] ) && (string) $field[ 'hide' ] === '1' ) { |
|
| 182 | 182 | $this->reduce_field_count(); |
| 183 | 183 | } |
| 184 | 184 | |
@@ -193,7 +193,7 @@ discard block |
||
| 193 | 193 | * |
| 194 | 194 | * @since %VERSION% |
| 195 | 195 | */ |
| 196 | - public function render( array $context = [] ) { |
|
| 196 | + public function render( array $context = [ ] ) { |
|
| 197 | 197 | foreach ( $this->fields as $field ) { |
| 198 | 198 | $field->render(); |
| 199 | 199 | } |
@@ -227,7 +227,7 @@ discard block |
||
| 227 | 227 | * @since %VERSION% |
| 228 | 228 | */ |
| 229 | 229 | public function validate_submission() { |
| 230 | - $valid = []; |
|
| 230 | + $valid = [ ]; |
|
| 231 | 231 | foreach ( $this->fields as $field ) { |
| 232 | 232 | try { |
| 233 | 233 | $submitted = array_key_exists( $field->get_id(), $this->submitted_data ) |
@@ -256,7 +256,7 @@ discard block |
||
| 256 | 256 | */ |
| 257 | 257 | private function get_field_type( $field ) { |
| 258 | 258 | |
| 259 | - $type = array_key_exists( $field['type'], Meta::FIELD_MAP ) ? Meta::FIELD_MAP[ $field['type'] ] : Types::TEXT; |
|
| 259 | + $type = array_key_exists( $field[ 'type' ], Meta::FIELD_MAP ) ? Meta::FIELD_MAP[ $field[ 'type' ] ] : Types::TEXT; |
|
| 260 | 260 | |
| 261 | 261 | /** |
| 262 | 262 | * Filter the class used to instantiate the field. |
@@ -308,9 +308,9 @@ discard block |
||
| 308 | 308 | $classes = $this->get_field_classes( $field ); |
| 309 | 309 | $placeholder = $this->get_placeholder( $field ); |
| 310 | 310 | $description = $this->get_description( $field ); |
| 311 | - $merge = $field['merge']; |
|
| 311 | + $merge = $field[ 'merge' ]; |
|
| 312 | 312 | $hidden = $this->get_hidden( $field ); |
| 313 | - $required = isset( $field['require'] ) ? true : false; |
|
| 313 | + $required = isset( $field[ 'require' ] ) ? true : false; |
|
| 314 | 314 | return [ |
| 315 | 315 | new $type( |
| 316 | 316 | $classes, |
@@ -13,21 +13,21 @@ |
||
| 13 | 13 | |
| 14 | 14 | interface OptinMeta { |
| 15 | 15 | |
| 16 | - const EMAIL = 'email'; |
|
| 17 | - const TEXT = 'text'; |
|
| 18 | - const NUMBER = 'number'; |
|
| 19 | - const URL = 'url'; |
|
| 20 | - const IMAGE_URL = 'imageurl'; |
|
| 21 | - const PHONE = 'phone'; |
|
| 22 | - const ZIP = 'zip'; |
|
| 23 | - const ADDRESS = 'address'; |
|
| 24 | - const DATE = 'date'; |
|
| 25 | - const BIRTHDAY = 'birthday'; |
|
| 26 | - const DROPDOWN = 'dropdown'; |
|
| 27 | - const RADIO = 'radio'; |
|
| 28 | - const CHECKBOX = 'checkbox'; |
|
| 16 | + const EMAIL = 'email'; |
|
| 17 | + const TEXT = 'text'; |
|
| 18 | + const NUMBER = 'number'; |
|
| 19 | + const URL = 'url'; |
|
| 20 | + const IMAGE_URL = 'imageurl'; |
|
| 21 | + const PHONE = 'phone'; |
|
| 22 | + const ZIP = 'zip'; |
|
| 23 | + const ADDRESS = 'address'; |
|
| 24 | + const DATE = 'date'; |
|
| 25 | + const BIRTHDAY = 'birthday'; |
|
| 26 | + const DROPDOWN = 'dropdown'; |
|
| 27 | + const RADIO = 'radio'; |
|
| 28 | + const CHECKBOX = 'checkbox'; |
|
| 29 | 29 | |
| 30 | - const FIELD_MAP = [ |
|
| 30 | + const FIELD_MAP = [ |
|
| 31 | 31 | self::EMAIL => Types::EMAIL, |
| 32 | 32 | self::TEXT => Types::TEXT, |
| 33 | 33 | ]; |
@@ -10,6 +10,10 @@ discard block |
||
| 10 | 10 | namespace YIKES\EasyForms\Form; |
| 11 | 11 | |
| 12 | 12 | trait FieldBuilder { |
| 13 | + |
|
| 14 | + /** |
|
| 15 | + * @param string $field |
|
| 16 | + */ |
|
| 13 | 17 | protected function get_field_classes( $field ) { |
| 14 | 18 | $field_classes = []; |
| 15 | 19 | $label_classes = []; |
@@ -80,6 +84,9 @@ discard block |
||
| 80 | 84 | $this->hidden_label_count = $this->hidden_label_count++; |
| 81 | 85 | } |
| 82 | 86 | |
| 87 | + /** |
|
| 88 | + * @param string $field |
|
| 89 | + */ |
|
| 83 | 90 | protected function get_label( $field ) { |
| 84 | 91 | $label = []; |
| 85 | 92 | if( $field['type'] == 'email' ) { |
@@ -96,6 +103,9 @@ discard block |
||
| 96 | 103 | return $label; |
| 97 | 104 | } |
| 98 | 105 | |
| 106 | + /** |
|
| 107 | + * @param string $field |
|
| 108 | + */ |
|
| 99 | 109 | protected function get_value( $field ) { |
| 100 | 110 | // pass our default value through our filter to parse dynamic data by tag (used solely for 'text' type) |
| 101 | 111 | $default_value = ( isset( $field['default'] ) ? esc_attr( $field['default'] ) : '' ); |
@@ -103,10 +113,16 @@ discard block |
||
| 103 | 113 | return apply_filters( 'yikes-mailchimp-' . $field['merge'] . '-default-value', $default_value, $field, $this->form_id ); |
| 104 | 114 | } |
| 105 | 115 | |
| 116 | + /** |
|
| 117 | + * @param string $field |
|
| 118 | + */ |
|
| 106 | 119 | protected function get_placeholder( $field ) { |
| 107 | 120 | return isset( $field['placeholder'] ) ? $field['placeholder'] : ''; |
| 108 | 121 | } |
| 109 | 122 | |
| 123 | + /** |
|
| 124 | + * @param string $field |
|
| 125 | + */ |
|
| 110 | 126 | protected function get_hidden( $field ) { |
| 111 | 127 | $visible = true; |
| 112 | 128 | // if both hide label and hide field are checked, we gotta hide the field! |
@@ -118,6 +134,9 @@ discard block |
||
| 118 | 134 | return $visible; |
| 119 | 135 | } |
| 120 | 136 | |
| 137 | + /** |
|
| 138 | + * @param string $field |
|
| 139 | + */ |
|
| 121 | 140 | protected function get_description( $field ) { |
| 122 | 141 | $description = ''; |
| 123 | 142 | $show_description = isset( $field['description'] ) ? true : false; |
@@ -10,126 +10,126 @@ |
||
| 10 | 10 | namespace YIKES\EasyForms\Form; |
| 11 | 11 | |
| 12 | 12 | trait FieldBuilder { |
| 13 | - protected function get_field_classes( $field ) { |
|
| 14 | - $field_classes = []; |
|
| 15 | - $label_classes = []; |
|
| 13 | + protected function get_field_classes( $field ) { |
|
| 14 | + $field_classes = []; |
|
| 15 | + $label_classes = []; |
|
| 16 | 16 | |
| 17 | - $field_classes[] = 'yikes-easy-mc-' . $field['type']; |
|
| 18 | - $label_classes[] = $field['merge'] . '-label'; |
|
| 17 | + $field_classes[] = 'yikes-easy-mc-' . $field['type']; |
|
| 18 | + $label_classes[] = $field['merge'] . '-label'; |
|
| 19 | 19 | |
| 20 | - if( $field['additional-classes'] != '' ) { |
|
| 20 | + if( $field['additional-classes'] != '' ) { |
|
| 21 | 21 | |
| 22 | - $field_classes = explode( ' ' , $field['additional-classes'] ); |
|
| 22 | + $field_classes = explode( ' ' , $field['additional-classes'] ); |
|
| 23 | 23 | |
| 24 | - if( in_array( 'field-left-half' , $field_classes ) ) { |
|
| 25 | - $$label_classes[] = 'field-left-half'; |
|
| 26 | - $key = array_search( 'field-left-half' , $field_classes ); |
|
| 27 | - unset( $field_classes[$key] ); |
|
| 28 | - } // input half right |
|
| 29 | - if( in_array( 'field-right-half' , $field_classes ) ) { |
|
| 30 | - $$label_classes[] = 'field-right-half'; |
|
| 31 | - $key = array_search( 'field-right-half' , $field_classes ); |
|
| 32 | - unset( $field_classes[$key] ); |
|
| 33 | - } // input thirds (1/3 width, floated left) |
|
| 34 | - if( in_array( 'field-third' , $field_classes ) ) { |
|
| 35 | - $$label_classes[] = 'field-third'; |
|
| 36 | - $key = array_search( 'field-third' , $field_classes ); |
|
| 37 | - unset( $field_classes[$key] ); |
|
| 38 | - } // 2 column radio |
|
| 39 | - if( in_array( 'option-2-col' , $field_classes ) ) { |
|
| 40 | - $$label_classes[] = 'option-2-col'; |
|
| 41 | - $key = array_search( 'option-2-col' , $field_classes ); |
|
| 42 | - unset( $field_classes[$key] ); |
|
| 43 | - } // 3 column radio |
|
| 44 | - if( in_array( 'option-3-col' , $field_classes ) ) { |
|
| 45 | - $$label_classes[] = 'option-3-col'; |
|
| 46 | - $key = array_search( 'option-3-col' , $field_classes ); |
|
| 47 | - unset( $field_classes[$key] ); |
|
| 48 | - } // 4 column radio |
|
| 49 | - if( in_array( 'option-4-col' , $field_classes ) ) { |
|
| 50 | - $$label_classes[] = 'option-4-col'; |
|
| 51 | - $key = array_search( 'option-4-col' , $field_classes ); |
|
| 52 | - unset( $field_classes[$key] ); |
|
| 53 | - } // inline radio & checkboxes etc |
|
| 54 | - if( in_array( 'option-inline' , $field_classes ) ) { |
|
| 55 | - $$label_classes[] = 'option-inline'; |
|
| 56 | - $key = array_search( 'option-inline' , $field_classes ); |
|
| 57 | - unset( $field_classes[$key] ); |
|
| 58 | - } |
|
| 59 | - } |
|
| 24 | + if( in_array( 'field-left-half' , $field_classes ) ) { |
|
| 25 | + $$label_classes[] = 'field-left-half'; |
|
| 26 | + $key = array_search( 'field-left-half' , $field_classes ); |
|
| 27 | + unset( $field_classes[$key] ); |
|
| 28 | + } // input half right |
|
| 29 | + if( in_array( 'field-right-half' , $field_classes ) ) { |
|
| 30 | + $$label_classes[] = 'field-right-half'; |
|
| 31 | + $key = array_search( 'field-right-half' , $field_classes ); |
|
| 32 | + unset( $field_classes[$key] ); |
|
| 33 | + } // input thirds (1/3 width, floated left) |
|
| 34 | + if( in_array( 'field-third' , $field_classes ) ) { |
|
| 35 | + $$label_classes[] = 'field-third'; |
|
| 36 | + $key = array_search( 'field-third' , $field_classes ); |
|
| 37 | + unset( $field_classes[$key] ); |
|
| 38 | + } // 2 column radio |
|
| 39 | + if( in_array( 'option-2-col' , $field_classes ) ) { |
|
| 40 | + $$label_classes[] = 'option-2-col'; |
|
| 41 | + $key = array_search( 'option-2-col' , $field_classes ); |
|
| 42 | + unset( $field_classes[$key] ); |
|
| 43 | + } // 3 column radio |
|
| 44 | + if( in_array( 'option-3-col' , $field_classes ) ) { |
|
| 45 | + $$label_classes[] = 'option-3-col'; |
|
| 46 | + $key = array_search( 'option-3-col' , $field_classes ); |
|
| 47 | + unset( $field_classes[$key] ); |
|
| 48 | + } // 4 column radio |
|
| 49 | + if( in_array( 'option-4-col' , $field_classes ) ) { |
|
| 50 | + $$label_classes[] = 'option-4-col'; |
|
| 51 | + $key = array_search( 'option-4-col' , $field_classes ); |
|
| 52 | + unset( $field_classes[$key] ); |
|
| 53 | + } // inline radio & checkboxes etc |
|
| 54 | + if( in_array( 'option-inline' , $field_classes ) ) { |
|
| 55 | + $$label_classes[] = 'option-inline'; |
|
| 56 | + $key = array_search( 'option-inline' , $field_classes ); |
|
| 57 | + unset( $field_classes[$key] ); |
|
| 58 | + } |
|
| 59 | + } |
|
| 60 | 60 | |
| 61 | - // if the form is set to inline, add the inline class to our labels |
|
| 62 | - if( $this->form_inline ) { |
|
| 63 | - $label_classes[] = 'label-inline'; |
|
| 64 | - } |
|
| 61 | + // if the form is set to inline, add the inline class to our labels |
|
| 62 | + if( $this->form_inline ) { |
|
| 63 | + $label_classes[] = 'label-inline'; |
|
| 64 | + } |
|
| 65 | 65 | |
| 66 | - if( isset( $field['hide-label'] ) ) { |
|
| 67 | - if( absint( $field['hide-label'] ) === 1 ) { |
|
| 68 | - $this->increase_hidden_label_count(); |
|
| 69 | - $field_classes[] = 'field-no-label'; |
|
| 70 | - } |
|
| 71 | - } |
|
| 66 | + if( isset( $field['hide-label'] ) ) { |
|
| 67 | + if( absint( $field['hide-label'] ) === 1 ) { |
|
| 68 | + $this->increase_hidden_label_count(); |
|
| 69 | + $field_classes[] = 'field-no-label'; |
|
| 70 | + } |
|
| 71 | + } |
|
| 72 | 72 | |
| 73 | - return [ |
|
| 74 | - 'field_classes' => $field_classes, |
|
| 75 | - 'label_classes' => $label_classes, |
|
| 76 | - ]; |
|
| 77 | - } |
|
| 73 | + return [ |
|
| 74 | + 'field_classes' => $field_classes, |
|
| 75 | + 'label_classes' => $label_classes, |
|
| 76 | + ]; |
|
| 77 | + } |
|
| 78 | 78 | |
| 79 | - protected function increase_hidden_label_count() { |
|
| 80 | - $this->hidden_label_count = $this->hidden_label_count++; |
|
| 81 | - } |
|
| 79 | + protected function increase_hidden_label_count() { |
|
| 80 | + $this->hidden_label_count = $this->hidden_label_count++; |
|
| 81 | + } |
|
| 82 | 82 | |
| 83 | - protected function get_label( $field ) { |
|
| 84 | - $label = []; |
|
| 85 | - if( $field['type'] == 'email' ) { |
|
| 86 | - $label['props']['visible'] = ''; |
|
| 87 | - } else { |
|
| 88 | - $label['props']['visible'] = isset( $field['hide'] ) ? 'style="display:none;"' : ''; |
|
| 89 | - } |
|
| 90 | - if ( isset( $field['hide-label'] ) ) { |
|
| 91 | - $label['hide-label'] = true; |
|
| 92 | - } |
|
| 93 | - if ( isset( $field['label'] ) ) { |
|
| 94 | - $label['value'] = $field['label']; |
|
| 95 | - } |
|
| 96 | - return $label; |
|
| 97 | - } |
|
| 83 | + protected function get_label( $field ) { |
|
| 84 | + $label = []; |
|
| 85 | + if( $field['type'] == 'email' ) { |
|
| 86 | + $label['props']['visible'] = ''; |
|
| 87 | + } else { |
|
| 88 | + $label['props']['visible'] = isset( $field['hide'] ) ? 'style="display:none;"' : ''; |
|
| 89 | + } |
|
| 90 | + if ( isset( $field['hide-label'] ) ) { |
|
| 91 | + $label['hide-label'] = true; |
|
| 92 | + } |
|
| 93 | + if ( isset( $field['label'] ) ) { |
|
| 94 | + $label['value'] = $field['label']; |
|
| 95 | + } |
|
| 96 | + return $label; |
|
| 97 | + } |
|
| 98 | 98 | |
| 99 | - protected function get_value( $field ) { |
|
| 100 | - // pass our default value through our filter to parse dynamic data by tag (used solely for 'text' type) |
|
| 101 | - $default_value = ( isset( $field['default'] ) ? esc_attr( $field['default'] ) : '' ); |
|
| 102 | - $default_value = apply_filters( 'yikes-mailchimp-process-default-tag', $default_value ); |
|
| 103 | - return apply_filters( 'yikes-mailchimp-' . $field['merge'] . '-default-value', $default_value, $field, $this->form_id ); |
|
| 104 | - } |
|
| 99 | + protected function get_value( $field ) { |
|
| 100 | + // pass our default value through our filter to parse dynamic data by tag (used solely for 'text' type) |
|
| 101 | + $default_value = ( isset( $field['default'] ) ? esc_attr( $field['default'] ) : '' ); |
|
| 102 | + $default_value = apply_filters( 'yikes-mailchimp-process-default-tag', $default_value ); |
|
| 103 | + return apply_filters( 'yikes-mailchimp-' . $field['merge'] . '-default-value', $default_value, $field, $this->form_id ); |
|
| 104 | + } |
|
| 105 | 105 | |
| 106 | - protected function get_placeholder( $field ) { |
|
| 107 | - return isset( $field['placeholder'] ) ? $field['placeholder'] : ''; |
|
| 108 | - } |
|
| 106 | + protected function get_placeholder( $field ) { |
|
| 107 | + return isset( $field['placeholder'] ) ? $field['placeholder'] : ''; |
|
| 108 | + } |
|
| 109 | 109 | |
| 110 | - protected function get_hidden( $field ) { |
|
| 111 | - $visible = true; |
|
| 112 | - // if both hide label and hide field are checked, we gotta hide the field! |
|
| 113 | - if( isset( $field['hide' ] ) && $field['hide'] == 1 ) { |
|
| 114 | - if( isset( $field['hide-label' ] ) && $field['hide-label'] == 1 ) { |
|
| 115 | - $visible = false; |
|
| 116 | - } |
|
| 117 | - } |
|
| 118 | - return $visible; |
|
| 119 | - } |
|
| 110 | + protected function get_hidden( $field ) { |
|
| 111 | + $visible = true; |
|
| 112 | + // if both hide label and hide field are checked, we gotta hide the field! |
|
| 113 | + if( isset( $field['hide' ] ) && $field['hide'] == 1 ) { |
|
| 114 | + if( isset( $field['hide-label' ] ) && $field['hide-label'] == 1 ) { |
|
| 115 | + $visible = false; |
|
| 116 | + } |
|
| 117 | + } |
|
| 118 | + return $visible; |
|
| 119 | + } |
|
| 120 | 120 | |
| 121 | - protected function get_description( $field ) { |
|
| 122 | - $description = ''; |
|
| 123 | - $show_description = isset( $field['description'] ) ? true : false; |
|
| 124 | - $description_above = isset( $field['description_above'] ) && $field['description_above'] === '1' ? true : false; |
|
| 125 | - if ( $show_description === true ) { |
|
| 126 | - $description = apply_filters( 'yikes-mailchimp-' . $field['merge'] . '-description', esc_attr( stripslashes( $field['description'] ) ), $this->form_id ); |
|
| 127 | - } |
|
| 121 | + protected function get_description( $field ) { |
|
| 122 | + $description = ''; |
|
| 123 | + $show_description = isset( $field['description'] ) ? true : false; |
|
| 124 | + $description_above = isset( $field['description_above'] ) && $field['description_above'] === '1' ? true : false; |
|
| 125 | + if ( $show_description === true ) { |
|
| 126 | + $description = apply_filters( 'yikes-mailchimp-' . $field['merge'] . '-description', esc_attr( stripslashes( $field['description'] ) ), $this->form_id ); |
|
| 127 | + } |
|
| 128 | 128 | |
| 129 | - return [ |
|
| 130 | - 'show_description' => $show_description, |
|
| 131 | - 'description_above' => $description_above, |
|
| 132 | - 'description' => $description, |
|
| 133 | - ]; |
|
| 134 | - } |
|
| 129 | + return [ |
|
| 130 | + 'show_description' => $show_description, |
|
| 131 | + 'description_above' => $description_above, |
|
| 132 | + 'description' => $description, |
|
| 133 | + ]; |
|
| 134 | + } |
|
| 135 | 135 | } |
@@ -11,62 +11,62 @@ discard block |
||
| 11 | 11 | |
| 12 | 12 | trait FieldBuilder { |
| 13 | 13 | protected function get_field_classes( $field ) { |
| 14 | - $field_classes = []; |
|
| 15 | - $label_classes = []; |
|
| 14 | + $field_classes = [ ]; |
|
| 15 | + $label_classes = [ ]; |
|
| 16 | 16 | |
| 17 | - $field_classes[] = 'yikes-easy-mc-' . $field['type']; |
|
| 18 | - $label_classes[] = $field['merge'] . '-label'; |
|
| 17 | + $field_classes[ ] = 'yikes-easy-mc-' . $field[ 'type' ]; |
|
| 18 | + $label_classes[ ] = $field[ 'merge' ] . '-label'; |
|
| 19 | 19 | |
| 20 | - if( $field['additional-classes'] != '' ) { |
|
| 20 | + if ( $field[ 'additional-classes' ] != '' ) { |
|
| 21 | 21 | |
| 22 | - $field_classes = explode( ' ' , $field['additional-classes'] ); |
|
| 22 | + $field_classes = explode( ' ', $field[ 'additional-classes' ] ); |
|
| 23 | 23 | |
| 24 | - if( in_array( 'field-left-half' , $field_classes ) ) { |
|
| 25 | - $$label_classes[] = 'field-left-half'; |
|
| 26 | - $key = array_search( 'field-left-half' , $field_classes ); |
|
| 27 | - unset( $field_classes[$key] ); |
|
| 24 | + if ( in_array( 'field-left-half', $field_classes ) ) { |
|
| 25 | + $$label_classes[ ] = 'field-left-half'; |
|
| 26 | + $key = array_search( 'field-left-half', $field_classes ); |
|
| 27 | + unset( $field_classes[ $key ] ); |
|
| 28 | 28 | } // input half right |
| 29 | - if( in_array( 'field-right-half' , $field_classes ) ) { |
|
| 30 | - $$label_classes[] = 'field-right-half'; |
|
| 31 | - $key = array_search( 'field-right-half' , $field_classes ); |
|
| 32 | - unset( $field_classes[$key] ); |
|
| 29 | + if ( in_array( 'field-right-half', $field_classes ) ) { |
|
| 30 | + $$label_classes[ ] = 'field-right-half'; |
|
| 31 | + $key = array_search( 'field-right-half', $field_classes ); |
|
| 32 | + unset( $field_classes[ $key ] ); |
|
| 33 | 33 | } // input thirds (1/3 width, floated left) |
| 34 | - if( in_array( 'field-third' , $field_classes ) ) { |
|
| 35 | - $$label_classes[] = 'field-third'; |
|
| 36 | - $key = array_search( 'field-third' , $field_classes ); |
|
| 37 | - unset( $field_classes[$key] ); |
|
| 34 | + if ( in_array( 'field-third', $field_classes ) ) { |
|
| 35 | + $$label_classes[ ] = 'field-third'; |
|
| 36 | + $key = array_search( 'field-third', $field_classes ); |
|
| 37 | + unset( $field_classes[ $key ] ); |
|
| 38 | 38 | } // 2 column radio |
| 39 | - if( in_array( 'option-2-col' , $field_classes ) ) { |
|
| 40 | - $$label_classes[] = 'option-2-col'; |
|
| 41 | - $key = array_search( 'option-2-col' , $field_classes ); |
|
| 42 | - unset( $field_classes[$key] ); |
|
| 39 | + if ( in_array( 'option-2-col', $field_classes ) ) { |
|
| 40 | + $$label_classes[ ] = 'option-2-col'; |
|
| 41 | + $key = array_search( 'option-2-col', $field_classes ); |
|
| 42 | + unset( $field_classes[ $key ] ); |
|
| 43 | 43 | } // 3 column radio |
| 44 | - if( in_array( 'option-3-col' , $field_classes ) ) { |
|
| 45 | - $$label_classes[] = 'option-3-col'; |
|
| 46 | - $key = array_search( 'option-3-col' , $field_classes ); |
|
| 47 | - unset( $field_classes[$key] ); |
|
| 44 | + if ( in_array( 'option-3-col', $field_classes ) ) { |
|
| 45 | + $$label_classes[ ] = 'option-3-col'; |
|
| 46 | + $key = array_search( 'option-3-col', $field_classes ); |
|
| 47 | + unset( $field_classes[ $key ] ); |
|
| 48 | 48 | } // 4 column radio |
| 49 | - if( in_array( 'option-4-col' , $field_classes ) ) { |
|
| 50 | - $$label_classes[] = 'option-4-col'; |
|
| 51 | - $key = array_search( 'option-4-col' , $field_classes ); |
|
| 52 | - unset( $field_classes[$key] ); |
|
| 49 | + if ( in_array( 'option-4-col', $field_classes ) ) { |
|
| 50 | + $$label_classes[ ] = 'option-4-col'; |
|
| 51 | + $key = array_search( 'option-4-col', $field_classes ); |
|
| 52 | + unset( $field_classes[ $key ] ); |
|
| 53 | 53 | } // inline radio & checkboxes etc |
| 54 | - if( in_array( 'option-inline' , $field_classes ) ) { |
|
| 55 | - $$label_classes[] = 'option-inline'; |
|
| 56 | - $key = array_search( 'option-inline' , $field_classes ); |
|
| 57 | - unset( $field_classes[$key] ); |
|
| 54 | + if ( in_array( 'option-inline', $field_classes ) ) { |
|
| 55 | + $$label_classes[ ] = 'option-inline'; |
|
| 56 | + $key = array_search( 'option-inline', $field_classes ); |
|
| 57 | + unset( $field_classes[ $key ] ); |
|
| 58 | 58 | } |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | // if the form is set to inline, add the inline class to our labels |
| 62 | - if( $this->form_inline ) { |
|
| 63 | - $label_classes[] = 'label-inline'; |
|
| 62 | + if ( $this->form_inline ) { |
|
| 63 | + $label_classes[ ] = 'label-inline'; |
|
| 64 | 64 | } |
| 65 | 65 | |
| 66 | - if( isset( $field['hide-label'] ) ) { |
|
| 67 | - if( absint( $field['hide-label'] ) === 1 ) { |
|
| 66 | + if ( isset( $field[ 'hide-label' ] ) ) { |
|
| 67 | + if ( absint( $field[ 'hide-label' ] ) === 1 ) { |
|
| 68 | 68 | $this->increase_hidden_label_count(); |
| 69 | - $field_classes[] = 'field-no-label'; |
|
| 69 | + $field_classes[ ] = 'field-no-label'; |
|
| 70 | 70 | } |
| 71 | 71 | } |
| 72 | 72 | |
@@ -81,37 +81,37 @@ discard block |
||
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | protected function get_label( $field ) { |
| 84 | - $label = []; |
|
| 85 | - if( $field['type'] == 'email' ) { |
|
| 86 | - $label['props']['visible'] = ''; |
|
| 84 | + $label = [ ]; |
|
| 85 | + if ( $field[ 'type' ] == 'email' ) { |
|
| 86 | + $label[ 'props' ][ 'visible' ] = ''; |
|
| 87 | 87 | } else { |
| 88 | - $label['props']['visible'] = isset( $field['hide'] ) ? 'style="display:none;"' : ''; |
|
| 88 | + $label[ 'props' ][ 'visible' ] = isset( $field[ 'hide' ] ) ? 'style="display:none;"' : ''; |
|
| 89 | 89 | } |
| 90 | - if ( isset( $field['hide-label'] ) ) { |
|
| 91 | - $label['hide-label'] = true; |
|
| 90 | + if ( isset( $field[ 'hide-label' ] ) ) { |
|
| 91 | + $label[ 'hide-label' ] = true; |
|
| 92 | 92 | } |
| 93 | - if ( isset( $field['label'] ) ) { |
|
| 94 | - $label['value'] = $field['label']; |
|
| 93 | + if ( isset( $field[ 'label' ] ) ) { |
|
| 94 | + $label[ 'value' ] = $field[ 'label' ]; |
|
| 95 | 95 | } |
| 96 | 96 | return $label; |
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | protected function get_value( $field ) { |
| 100 | 100 | // pass our default value through our filter to parse dynamic data by tag (used solely for 'text' type) |
| 101 | - $default_value = ( isset( $field['default'] ) ? esc_attr( $field['default'] ) : '' ); |
|
| 101 | + $default_value = ( isset( $field[ 'default' ] ) ? esc_attr( $field[ 'default' ] ) : '' ); |
|
| 102 | 102 | $default_value = apply_filters( 'yikes-mailchimp-process-default-tag', $default_value ); |
| 103 | - return apply_filters( 'yikes-mailchimp-' . $field['merge'] . '-default-value', $default_value, $field, $this->form_id ); |
|
| 103 | + return apply_filters( 'yikes-mailchimp-' . $field[ 'merge' ] . '-default-value', $default_value, $field, $this->form_id ); |
|
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | protected function get_placeholder( $field ) { |
| 107 | - return isset( $field['placeholder'] ) ? $field['placeholder'] : ''; |
|
| 107 | + return isset( $field[ 'placeholder' ] ) ? $field[ 'placeholder' ] : ''; |
|
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 110 | protected function get_hidden( $field ) { |
| 111 | 111 | $visible = true; |
| 112 | 112 | // if both hide label and hide field are checked, we gotta hide the field! |
| 113 | - if( isset( $field['hide' ] ) && $field['hide'] == 1 ) { |
|
| 114 | - if( isset( $field['hide-label' ] ) && $field['hide-label'] == 1 ) { |
|
| 113 | + if ( isset( $field[ 'hide' ] ) && $field[ 'hide' ] == 1 ) { |
|
| 114 | + if ( isset( $field[ 'hide-label' ] ) && $field[ 'hide-label' ] == 1 ) { |
|
| 115 | 115 | $visible = false; |
| 116 | 116 | } |
| 117 | 117 | } |
@@ -120,10 +120,10 @@ discard block |
||
| 120 | 120 | |
| 121 | 121 | protected function get_description( $field ) { |
| 122 | 122 | $description = ''; |
| 123 | - $show_description = isset( $field['description'] ) ? true : false; |
|
| 124 | - $description_above = isset( $field['description_above'] ) && $field['description_above'] === '1' ? true : false; |
|
| 123 | + $show_description = isset( $field[ 'description' ] ) ? true : false; |
|
| 124 | + $description_above = isset( $field[ 'description_above' ] ) && $field[ 'description_above' ] === '1' ? true : false; |
|
| 125 | 125 | if ( $show_description === true ) { |
| 126 | - $description = apply_filters( 'yikes-mailchimp-' . $field['merge'] . '-description', esc_attr( stripslashes( $field['description'] ) ), $this->form_id ); |
|
| 126 | + $description = apply_filters( 'yikes-mailchimp-' . $field[ 'merge' ] . '-description', esc_attr( stripslashes( $field[ 'description' ] ) ), $this->form_id ); |
|
| 127 | 127 | } |
| 128 | 128 | |
| 129 | 129 | return [ |