@@ -13,7 +13,6 @@ |
||
| 13 | 13 | use YIKES\EasyForms\Assets\AssetsAwareness; |
| 14 | 14 | use YIKES\EasyForms\Assets\ScriptAsset; |
| 15 | 15 | use YIKES\EasyForms\Service; |
| 16 | -use YIKES\EasyForms\View\View; |
|
| 17 | 16 | use YIKES\EasyForms\Model\Recaptcha as RecaptchaModel; |
| 18 | 17 | |
| 19 | 18 | /** |
@@ -23,42 +23,42 @@ discard block |
||
| 23 | 23 | */ |
| 24 | 24 | final class Recaptcha implements Service, AssetsAware { |
| 25 | 25 | |
| 26 | - use AssetsAwareness; |
|
| 26 | + use AssetsAwareness; |
|
| 27 | 27 | |
| 28 | - const VIEW_URI = 'views/recaptcha-box'; |
|
| 29 | - const JS_HANDLE = 'google-recaptcha-js'; |
|
| 30 | - const JS_URI = 'https://www.google.com/recaptcha/api.js'; |
|
| 31 | - const JS_DEPENDENCIES = [ 'jquery', 'form-submission-helpers' ]; |
|
| 32 | - const JS_VERSION = '1.0.0'; |
|
| 28 | + const VIEW_URI = 'views/recaptcha-box'; |
|
| 29 | + const JS_HANDLE = 'google-recaptcha-js'; |
|
| 30 | + const JS_URI = 'https://www.google.com/recaptcha/api.js'; |
|
| 31 | + const JS_DEPENDENCIES = [ 'jquery', 'form-submission-helpers' ]; |
|
| 32 | + const JS_VERSION = '1.0.0'; |
|
| 33 | 33 | |
| 34 | - public function register() { |
|
| 35 | - $this->register_assets(); |
|
| 34 | + public function register() { |
|
| 35 | + $this->register_assets(); |
|
| 36 | 36 | |
| 37 | - add_action( 'easy_forms_do_recaptcha_box', function( $view ) { |
|
| 38 | - $this->enqueue_assets(); |
|
| 39 | - echo $view->render_partial( static::VIEW_URI ); // phpcs:ignore WordPress.Security.EscapeOutput |
|
| 40 | - } ); |
|
| 41 | - } |
|
| 37 | + add_action( 'easy_forms_do_recaptcha_box', function( $view ) { |
|
| 38 | + $this->enqueue_assets(); |
|
| 39 | + echo $view->render_partial( static::VIEW_URI ); // phpcs:ignore WordPress.Security.EscapeOutput |
|
| 40 | + } ); |
|
| 41 | + } |
|
| 42 | 42 | |
| 43 | - /** |
|
| 44 | - * Get the context to pass onto the view. |
|
| 45 | - * |
|
| 46 | - * Override to provide data to the view. |
|
| 47 | - * |
|
| 48 | - * @since %VERSION% |
|
| 49 | - * |
|
| 50 | - * @return array Context to pass onto view. |
|
| 51 | - */ |
|
| 43 | + /** |
|
| 44 | + * Get the context to pass onto the view. |
|
| 45 | + * |
|
| 46 | + * Override to provide data to the view. |
|
| 47 | + * |
|
| 48 | + * @since %VERSION% |
|
| 49 | + * |
|
| 50 | + * @return array Context to pass onto view. |
|
| 51 | + */ |
|
| 52 | 52 | protected function get_context() { |
| 53 | 53 | return $this->recaptcha['recaptcha_options']; |
| 54 | - } |
|
| 54 | + } |
|
| 55 | 55 | |
| 56 | - private function get_script_params() { |
|
| 57 | - $recaptcha_options = ( new RecaptchaModel() )->setup(); |
|
| 58 | - return $recaptcha_options['script_params']; |
|
| 59 | - } |
|
| 56 | + private function get_script_params() { |
|
| 57 | + $recaptcha_options = ( new RecaptchaModel() )->setup(); |
|
| 58 | + return $recaptcha_options['script_params']; |
|
| 59 | + } |
|
| 60 | 60 | |
| 61 | - public function __get( $name ) { |
|
| 61 | + public function __get( $name ) { |
|
| 62 | 62 | switch ( $name ) { |
| 63 | 63 | case 'script_params': |
| 64 | 64 | return $this->get_script_params(); |
@@ -66,23 +66,23 @@ discard block |
||
| 66 | 66 | default: |
| 67 | 67 | return null; |
| 68 | 68 | } |
| 69 | - } |
|
| 69 | + } |
|
| 70 | 70 | |
| 71 | - /** |
|
| 72 | - * Load asset objects for use. |
|
| 73 | - * |
|
| 74 | - * @since %SINCE% |
|
| 75 | - */ |
|
| 71 | + /** |
|
| 72 | + * Load asset objects for use. |
|
| 73 | + * |
|
| 74 | + * @since %SINCE% |
|
| 75 | + */ |
|
| 76 | 76 | protected function load_assets() { |
| 77 | 77 | $this->assets= [ |
| 78 | 78 | new ScriptAsset( |
| 79 | - self::JS_HANDLE, |
|
| 80 | - self::JS_URI . $this->script_params, |
|
| 81 | - self::JS_DEPENDENCIES, |
|
| 82 | - self::JS_VERSION, |
|
| 83 | - ScriptAsset::ENQUEUE_HEADER, |
|
| 84 | - true |
|
| 85 | - ), |
|
| 79 | + self::JS_HANDLE, |
|
| 80 | + self::JS_URI . $this->script_params, |
|
| 81 | + self::JS_DEPENDENCIES, |
|
| 82 | + self::JS_VERSION, |
|
| 83 | + ScriptAsset::ENQUEUE_HEADER, |
|
| 84 | + true |
|
| 85 | + ), |
|
| 86 | 86 | ]; |
| 87 | - } |
|
| 87 | + } |
|
| 88 | 88 | } |
| 89 | 89 | \ No newline at end of file |
@@ -50,12 +50,12 @@ discard block |
||
| 50 | 50 | * @return array Context to pass onto view. |
| 51 | 51 | */ |
| 52 | 52 | protected function get_context() { |
| 53 | - return $this->recaptcha['recaptcha_options']; |
|
| 53 | + return $this->recaptcha[ 'recaptcha_options' ]; |
|
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | private function get_script_params() { |
| 57 | 57 | $recaptcha_options = ( new RecaptchaModel() )->setup(); |
| 58 | - return $recaptcha_options['script_params']; |
|
| 58 | + return $recaptcha_options[ 'script_params' ]; |
|
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | public function __get( $name ) { |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | * @since %SINCE% |
| 75 | 75 | */ |
| 76 | 76 | protected function load_assets() { |
| 77 | - $this->assets= [ |
|
| 77 | + $this->assets = [ |
|
| 78 | 78 | new ScriptAsset( |
| 79 | 79 | self::JS_HANDLE, |
| 80 | 80 | self::JS_URI . $this->script_params, |
@@ -73,7 +73,7 @@ |
||
| 73 | 73 | * |
| 74 | 74 | * @since %SINCE% |
| 75 | 75 | */ |
| 76 | - protected function load_assets() { |
|
| 76 | + protected function load_assets() { |
|
| 77 | 77 | $this->assets= [ |
| 78 | 78 | new ScriptAsset( |
| 79 | 79 | self::JS_HANDLE, |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | * |
| 91 | 91 | * @since %VERSION% |
| 92 | 92 | * |
| 93 | - * @param array $atts Array of shortcode attributes. |
|
| 93 | + * @param array $attr Array of shortcode attributes. |
|
| 94 | 94 | * |
| 95 | 95 | * @return array Context to pass onto view. |
| 96 | 96 | * @throws InvalidPostID When the post ID is not valid. |
@@ -199,7 +199,6 @@ discard block |
||
| 199 | 199 | * |
| 200 | 200 | * @param int $form_id The ID for the form. |
| 201 | 201 | * @param EasyFormsModel $form_data The form Object. |
| 202 | - * @param array $field_classes The classes for fields in the form. |
|
| 203 | 202 | * |
| 204 | 203 | * @return EasyForm |
| 205 | 204 | */ |
@@ -17,7 +17,6 @@ |
||
| 17 | 17 | use YIKES\EasyForms\Model\Subscriber; |
| 18 | 18 | use YIKES\EasyForms\Model\SubscriberRepository; |
| 19 | 19 | use YIKES\EasyForms\Model\OptinForm as EasyFormsModel; |
| 20 | -use YIKES\EasyForms\Model\Recaptcha as RecaptchaModel; |
|
| 21 | 20 | |
| 22 | 21 | /** |
| 23 | 22 | * Class EasyFormsShortcode |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | |
| 29 | 29 | final class EasyFormsShortcode extends BaseShortcode { |
| 30 | 30 | |
| 31 | - const TAG = 'yikes-mailchimp'; |
|
| 31 | + const TAG = 'yikes-mailchimp'; |
|
| 32 | 32 | const VIEW_URI = 'views/easy-forms-shortcode'; |
| 33 | 33 | const SUBMITTED_URI = 'views/easy-forms-shortcode-completed'; |
| 34 | 34 | const DESC_URI = 'views/easy-forms-shortcode-description'; |
@@ -50,14 +50,14 @@ discard block |
||
| 50 | 50 | * @since %VERSION% |
| 51 | 51 | * @var string |
| 52 | 52 | */ |
| 53 | - private $view_uri = self::VIEW_URI; |
|
| 53 | + private $view_uri = self::VIEW_URI; |
|
| 54 | 54 | |
| 55 | - /** |
|
| 56 | - * Get the default array of attributes for the shortcode. |
|
| 57 | - * |
|
| 58 | - * @since %VERSION% |
|
| 59 | - * @return array |
|
| 60 | - */ |
|
| 55 | + /** |
|
| 56 | + * Get the default array of attributes for the shortcode. |
|
| 57 | + * |
|
| 58 | + * @since %VERSION% |
|
| 59 | + * @return array |
|
| 60 | + */ |
|
| 61 | 61 | public function get_default_atts() { |
| 62 | 62 | return [ |
| 63 | 63 | 'form' => '', |
@@ -147,7 +147,7 @@ discard block |
||
| 147 | 147 | } |
| 148 | 148 | } |
| 149 | 149 | |
| 150 | - /** |
|
| 150 | + /** |
|
| 151 | 151 | * Get the View URI to use for rendering the shortcode. |
| 152 | 152 | * |
| 153 | 153 | * @since %VERSION% |
@@ -156,15 +156,15 @@ discard block |
||
| 156 | 156 | */ |
| 157 | 157 | protected function get_view_uri() { |
| 158 | 158 | return $this->view_uri; |
| 159 | - } |
|
| 159 | + } |
|
| 160 | 160 | |
| 161 | - /** |
|
| 162 | - * Set the view URI. |
|
| 163 | - * |
|
| 164 | - * @since %VERSION% |
|
| 165 | - * |
|
| 166 | - * @param string $uri The URI to use. |
|
| 167 | - */ |
|
| 161 | + /** |
|
| 162 | + * Set the view URI. |
|
| 163 | + * |
|
| 164 | + * @since %VERSION% |
|
| 165 | + * |
|
| 166 | + * @param string $uri The URI to use. |
|
| 167 | + */ |
|
| 168 | 168 | private function set_view_uri( $uri ) { |
| 169 | 169 | $this->view_uri = $uri; |
| 170 | 170 | } |
@@ -179,15 +179,15 @@ discard block |
||
| 179 | 179 | return ! empty( $_POST ); |
| 180 | 180 | } |
| 181 | 181 | |
| 182 | - /** |
|
| 183 | - * Render the current Renderable. |
|
| 184 | - * |
|
| 185 | - * @since %VERSION% |
|
| 186 | - * |
|
| 187 | - * @param array $context Context in which to render. |
|
| 188 | - * |
|
| 189 | - * @return string Rendered HTML. |
|
| 190 | - */ |
|
| 182 | + /** |
|
| 183 | + * Render the current Renderable. |
|
| 184 | + * |
|
| 185 | + * @since %VERSION% |
|
| 186 | + * |
|
| 187 | + * @param array $context Context in which to render. |
|
| 188 | + * |
|
| 189 | + * @return string Rendered HTML. |
|
| 190 | + */ |
|
| 191 | 191 | public function render( array $context = [] ) { |
| 192 | 192 | try { |
| 193 | 193 | $this->enqueue_assets(); |
@@ -238,15 +238,15 @@ discard block |
||
| 238 | 238 | return isset( $subscriber ) ? $subscriber : null; |
| 239 | 239 | } |
| 240 | 240 | |
| 241 | - /** |
|
| 242 | - * Convert an exception to a string. |
|
| 243 | - * |
|
| 244 | - * @since %VERSION% |
|
| 245 | - * |
|
| 246 | - * @param \Exception $e The exception object. |
|
| 247 | - * |
|
| 248 | - * @return string |
|
| 249 | - */ |
|
| 241 | + /** |
|
| 242 | + * Convert an exception to a string. |
|
| 243 | + * |
|
| 244 | + * @since %VERSION% |
|
| 245 | + * |
|
| 246 | + * @param \Exception $e The exception object. |
|
| 247 | + * |
|
| 248 | + * @return string |
|
| 249 | + */ |
|
| 250 | 250 | private function exception_to_string( \Exception $e ) { |
| 251 | 251 | return sprintf( |
| 252 | 252 | /* translators: %s refers to the error message */ |
@@ -257,14 +257,14 @@ discard block |
||
| 257 | 257 | |
| 258 | 258 | public function load_assets() { |
| 259 | 259 | $submission_helper = new ScriptAsset( |
| 260 | - 'form-submission-helpers', |
|
| 261 | - 'assets/js/dev/form-submission-helpers', |
|
| 262 | - [ 'jquery' ], |
|
| 263 | - '1.0.0', |
|
| 264 | - ScriptAsset::ENQUEUE_HEADER |
|
| 265 | - ); |
|
| 260 | + 'form-submission-helpers', |
|
| 261 | + 'assets/js/dev/form-submission-helpers', |
|
| 262 | + [ 'jquery' ], |
|
| 263 | + '1.0.0', |
|
| 264 | + ScriptAsset::ENQUEUE_HEADER |
|
| 265 | + ); |
|
| 266 | 266 | |
| 267 | - $submission_helper->add_localization( 'form_submission_helpers', array( |
|
| 267 | + $submission_helper->add_localization( 'form_submission_helpers', array( |
|
| 268 | 268 | 'ajax_url' => esc_url( admin_url( 'admin-ajax.php' ) ), |
| 269 | 269 | 'preloader_url' => apply_filters( 'yikes-mailchimp-preloader', esc_url_raw( admin_url( 'images/wpspin_light.gif' ) ) ), |
| 270 | 270 | 'countries_with_zip' => $this->countries_with_zip(), |
@@ -277,19 +277,19 @@ discard block |
||
| 277 | 277 | } |
| 278 | 278 | |
| 279 | 279 | public function countries_with_zip() { |
| 280 | - return [ |
|
| 281 | - 'US' => 'US', 'GB' => 'GB', 'CA' => 'CA', |
|
| 282 | - 'IE' => 'IE', 'CN' => 'CN', 'IN' => 'IN', |
|
| 283 | - 'AU' => 'AU', 'BR' => 'BR', 'MX' => 'MX', |
|
| 284 | - 'IT' => 'IT', 'NZ' => 'NZ', 'JP' => 'JP', |
|
| 285 | - 'FR' => 'FR', 'GR' => 'GR', 'DE' => 'DE', |
|
| 286 | - 'NL' => 'NL', 'PT' => 'PT', 'ES' => 'ES' |
|
| 287 | - ]; |
|
| 288 | - } |
|
| 280 | + return [ |
|
| 281 | + 'US' => 'US', 'GB' => 'GB', 'CA' => 'CA', |
|
| 282 | + 'IE' => 'IE', 'CN' => 'CN', 'IN' => 'IN', |
|
| 283 | + 'AU' => 'AU', 'BR' => 'BR', 'MX' => 'MX', |
|
| 284 | + 'IT' => 'IT', 'NZ' => 'NZ', 'JP' => 'JP', |
|
| 285 | + 'FR' => 'FR', 'GR' => 'GR', 'DE' => 'DE', |
|
| 286 | + 'NL' => 'NL', 'PT' => 'PT', 'ES' => 'ES' |
|
| 287 | + ]; |
|
| 288 | + } |
|
| 289 | 289 | |
| 290 | - public function page_data() { |
|
| 291 | - global $post; |
|
| 290 | + public function page_data() { |
|
| 291 | + global $post; |
|
| 292 | 292 | $page_data = isset( $post->ID ) ? $post->ID : 0; |
| 293 | 293 | return apply_filters( 'yikes-mailchimp-page-data', $page_data ); |
| 294 | - } |
|
| 294 | + } |
|
| 295 | 295 | } |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | |
| 29 | 29 | final class EasyFormsShortcode extends BaseShortcode { |
| 30 | 30 | |
| 31 | - const TAG = 'yikes-mailchimp'; |
|
| 31 | + const TAG = 'yikes-mailchimp'; |
|
| 32 | 32 | const VIEW_URI = 'views/easy-forms-shortcode'; |
| 33 | 33 | const SUBMITTED_URI = 'views/easy-forms-shortcode-completed'; |
| 34 | 34 | const DESC_URI = 'views/easy-forms-shortcode-description'; |
@@ -97,28 +97,28 @@ discard block |
||
| 97 | 97 | * @throws InvalidPostID When the post ID is not valid. |
| 98 | 98 | */ |
| 99 | 99 | protected function get_context( array $attr ) { |
| 100 | - $form_id = $attr['form'] ? $attr['form'] : '1'; |
|
| 100 | + $form_id = $attr[ 'form' ] ? $attr[ 'form' ] : '1'; |
|
| 101 | 101 | $form_data = ( new EasyFormsModel() )->find( $form_id ); |
| 102 | 102 | |
| 103 | 103 | $this->is_submitted = $this->is_submitting_form(); |
| 104 | 104 | |
| 105 | 105 | // Set up the form object. |
| 106 | 106 | $form = $this->get_optin_form( $form_id, $form_data, $attr ); |
| 107 | - $description = $form->form_description( $attr['description'], $attr['custom_description'] ); |
|
| 107 | + $description = $form->form_description( $attr[ 'description' ], $attr[ 'custom_description' ] ); |
|
| 108 | 108 | |
| 109 | 109 | add_action( 'easy_forms_do_form_description', function( $view ) { |
| 110 | 110 | echo $view->render_partial( static::DESC_URI ); // phpcs:ignore WordPress.Security.EscapeOutput |
| 111 | 111 | } ); |
| 112 | 112 | |
| 113 | 113 | return [ |
| 114 | - 'title' => $form->form_title( $attr['title'], $attr['custom_title'], $form_data['form_name'] ), |
|
| 114 | + 'title' => $form->form_title( $attr[ 'title' ], $attr[ 'custom_title' ], $form_data[ 'form_name' ] ), |
|
| 115 | 115 | 'description' => $description, |
| 116 | 116 | 'form_classes' => $form->form_classes( $this->is_submitted ), |
| 117 | 117 | 'edit_form_link' => $form->edit_form_link(), |
| 118 | 118 | 'submit_button_classes' => $form->submit_button_classes(), |
| 119 | - 'submit_button_text' => $form->submit_button_text( $attr['submit'] ), |
|
| 120 | - 'ajax' => $attr['ajax'], |
|
| 121 | - 'form_settings' => $form_data['form_settings'], |
|
| 119 | + 'submit_button_text' => $form->submit_button_text( $attr[ 'submit' ] ), |
|
| 120 | + 'ajax' => $attr[ 'ajax' ], |
|
| 121 | + 'form_settings' => $form_data[ 'form_settings' ], |
|
| 122 | 122 | 'form_data' => $form_data, |
| 123 | 123 | 'form' => $form, |
| 124 | 124 | 'form_id' => $form_id, |
@@ -188,7 +188,7 @@ discard block |
||
| 188 | 188 | * |
| 189 | 189 | * @return string Rendered HTML. |
| 190 | 190 | */ |
| 191 | - public function render( array $context = [] ) { |
|
| 191 | + public function render( array $context = [ ] ) { |
|
| 192 | 192 | try { |
| 193 | 193 | $this->enqueue_assets(); |
| 194 | 194 | $view = new FormEscapedView( new NoOverrideLocationView( $this->get_view_uri() ) ); |
@@ -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() { |
@@ -13,31 +13,31 @@ |
||
| 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 | self::NUMBER => Types::NUMBER, |
| 34 | 34 | self::URL => Types::URL, |
| 35 | - self::IMAGE_URL => Types::IMAGE_URL, |
|
| 36 | - self::PHONE => Types::PHONE, |
|
| 37 | - self::ZIP => Types::ZIP, |
|
| 38 | - self::ADDRESS => Types::ADDRESS, |
|
| 39 | - self::DATE => Types::DATE, |
|
| 40 | - self::BIRTHDAY => Types::BIRTHDAY, |
|
| 41 | - self::CHECKBOX => Types::CHECKBOX, |
|
| 35 | + self::IMAGE_URL => Types::IMAGE_URL, |
|
| 36 | + self::PHONE => Types::PHONE, |
|
| 37 | + self::ZIP => Types::ZIP, |
|
| 38 | + self::ADDRESS => Types::ADDRESS, |
|
| 39 | + self::DATE => Types::DATE, |
|
| 40 | + self::BIRTHDAY => Types::BIRTHDAY, |
|
| 41 | + self::CHECKBOX => Types::CHECKBOX, |
|
| 42 | 42 | ]; |
| 43 | 43 | } |
@@ -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,25 +3,25 @@ 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 | - $form_title = ''; |
|
| 8 | - switch( true ) { |
|
| 9 | - case ! empty( $custom_title ) && isset( $custom_title ): |
|
| 10 | - $form_title = $custom_title; |
|
| 11 | - break; |
|
| 12 | - case ! empty( $title ) && isset( $title ): |
|
| 13 | - $form_title = $title; |
|
| 14 | - break; |
|
| 15 | - default: |
|
| 16 | - $form_title = $form_name; |
|
| 17 | - break; |
|
| 18 | - } |
|
| 6 | + public function form_title( $title, $custom_title, $form_name ) { |
|
| 7 | + $form_title = ''; |
|
| 8 | + switch( true ) { |
|
| 9 | + case ! empty( $custom_title ) && isset( $custom_title ): |
|
| 10 | + $form_title = $custom_title; |
|
| 11 | + break; |
|
| 12 | + case ! empty( $title ) && isset( $title ): |
|
| 13 | + $form_title = $title; |
|
| 14 | + break; |
|
| 15 | + default: |
|
| 16 | + $form_title = $form_name; |
|
| 17 | + break; |
|
| 18 | + } |
|
| 19 | 19 | |
| 20 | - return apply_filters( 'yikes-mailchimp-form-title', apply_filters( 'the_title', $form_title ), $this->form_id ); |
|
| 21 | - } |
|
| 20 | + return apply_filters( 'yikes-mailchimp-form-title', apply_filters( 'the_title', $form_title ), $this->form_id ); |
|
| 21 | + } |
|
| 22 | 22 | |
| 23 | - public function form_description( $description, $custom_description ) { |
|
| 24 | - if ( $description ) { |
|
| 23 | + public function form_description( $description, $custom_description ) { |
|
| 24 | + if ( $description ) { |
|
| 25 | 25 | if ( ! empty( $custom_description ) ) { |
| 26 | 26 | /** |
| 27 | 27 | * Filter the description that is displayed through the shortcode. |
@@ -34,11 +34,11 @@ discard block |
||
| 34 | 34 | return apply_filters( 'yikes-mailchimp-form-description', $this->form_data['form_description'], $this->form_id ); |
| 35 | 35 | } |
| 36 | 36 | } else { |
| 37 | - return false; |
|
| 38 | - } |
|
| 39 | - } |
|
| 37 | + return false; |
|
| 38 | + } |
|
| 39 | + } |
|
| 40 | 40 | |
| 41 | - protected function reduce_field_count() { |
|
| 41 | + protected function reduce_field_count() { |
|
| 42 | 42 | $this->field_count = $this->field_count --; |
| 43 | 43 | } |
| 44 | 44 | |
@@ -47,24 +47,24 @@ discard block |
||
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | public function form_classes( bool $is_submitted ) { |
| 50 | - $form_classes = 'yikes-easy-mc-form yikes-easy-mc-form-' . $this->form_id; |
|
| 51 | - if ( isset( $this->form_inline ) && $this->form_inline != 0 ) { |
|
| 52 | - $form_classes .= ' yikes-mailchimp-form-inline'; |
|
| 53 | - } |
|
| 50 | + $form_classes = 'yikes-easy-mc-form yikes-easy-mc-form-' . $this->form_id; |
|
| 51 | + if ( isset( $this->form_inline ) && $this->form_inline != 0 ) { |
|
| 52 | + $form_classes .= ' yikes-mailchimp-form-inline'; |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | - if ( $is_submitted && $this->form_data['submission_settings']['hide_form_post_signup'] == 1 ) { |
|
| 56 | - $form_classes .= ' yikes-easy-mc-display-none'; |
|
| 57 | - } |
|
| 55 | + if ( $is_submitted && $this->form_data['submission_settings']['hide_form_post_signup'] == 1 ) { |
|
| 56 | + $form_classes .= ' yikes-easy-mc-display-none'; |
|
| 57 | + } |
|
| 58 | 58 | |
| 59 | - $form_classes .= $this->form_data['form_settings']['yikes-easy-mc-form-class-names']; |
|
| 60 | - return apply_filters( 'yikes-mailchimp-form-class', $form_classes, $this->form_id ); |
|
| 59 | + $form_classes .= $this->form_data['form_settings']['yikes-easy-mc-form-class-names']; |
|
| 60 | + return apply_filters( 'yikes-mailchimp-form-class', $form_classes, $this->form_id ); |
|
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | public function inline_form_override() { |
| 64 | 64 | 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' ) ); |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | - public function edit_form_link() { |
|
| 67 | + public function edit_form_link() { |
|
| 68 | 68 | if( current_user_can( apply_filters( 'yikes-mailchimp-user-role-access' , 'manage_options' ) ) ) { |
| 69 | 69 | $edit_form_link = '<span class="edit-link">'; |
| 70 | 70 | $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>'; |
@@ -74,5 +74,5 @@ discard block |
||
| 74 | 74 | $edit_form_link = ''; |
| 75 | 75 | } |
| 76 | 76 | return $edit_form_link; |
| 77 | - } |
|
| 77 | + } |
|
| 78 | 78 | } |
@@ -5,7 +5,7 @@ discard block |
||
| 5 | 5 | trait FormHelper { |
| 6 | 6 | public function form_title( $title, $custom_title, $form_name ) { |
| 7 | 7 | $form_title = ''; |
| 8 | - switch( true ) { |
|
| 8 | + switch ( true ) { |
|
| 9 | 9 | case ! empty( $custom_title ) && isset( $custom_title ): |
| 10 | 10 | $form_title = $custom_title; |
| 11 | 11 | break; |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | */ |
| 32 | 32 | return apply_filters( 'yikes-mailchimp-form-description', $custom_description, $this->form_id ); |
| 33 | 33 | } else { |
| 34 | - return apply_filters( 'yikes-mailchimp-form-description', $this->form_data['form_description'], $this->form_id ); |
|
| 34 | + return apply_filters( 'yikes-mailchimp-form-description', $this->form_data[ 'form_description' ], $this->form_id ); |
|
| 35 | 35 | } |
| 36 | 36 | } else { |
| 37 | 37 | return false; |
@@ -39,11 +39,11 @@ discard block |
||
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | protected function reduce_field_count() { |
| 42 | - $this->field_count = $this->field_count --; |
|
| 42 | + $this->field_count = $this->field_count--; |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | protected function set_field_count() { |
| 46 | - return isset( $this->form_data['fields'] ) ? count( $this->form_data['fields'] ) : 0; |
|
| 46 | + return isset( $this->form_data[ 'fields' ] ) ? count( $this->form_data[ 'fields' ] ) : 0; |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | public function form_classes( bool $is_submitted ) { |
@@ -52,11 +52,11 @@ discard block |
||
| 52 | 52 | $form_classes .= ' yikes-mailchimp-form-inline'; |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | - if ( $is_submitted && $this->form_data['submission_settings']['hide_form_post_signup'] == 1 ) { |
|
| 56 | - $form_classes .= ' yikes-easy-mc-display-none'; |
|
| 55 | + if ( $is_submitted && $this->form_data[ 'submission_settings' ][ 'hide_form_post_signup' ] == 1 ) { |
|
| 56 | + $form_classes .= ' yikes-easy-mc-display-none'; |
|
| 57 | 57 | } |
| 58 | 58 | |
| 59 | - $form_classes .= $this->form_data['form_settings']['yikes-easy-mc-form-class-names']; |
|
| 59 | + $form_classes .= $this->form_data[ 'form_settings' ][ 'yikes-easy-mc-form-class-names' ]; |
|
| 60 | 60 | return apply_filters( 'yikes-mailchimp-form-class', $form_classes, $this->form_id ); |
| 61 | 61 | } |
| 62 | 62 | |
@@ -65,11 +65,11 @@ discard block |
||
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | public function edit_form_link() { |
| 68 | - if( current_user_can( apply_filters( 'yikes-mailchimp-user-role-access' , 'manage_options' ) ) ) { |
|
| 68 | + if ( current_user_can( apply_filters( 'yikes-mailchimp-user-role-access', 'manage_options' ) ) ) { |
|
| 69 | 69 | $edit_form_link = '<span class="edit-link">'; |
| 70 | - $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>'; |
|
| 70 | + $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>'; |
|
| 71 | 71 | $edit_form_link .= '</span>'; |
| 72 | - $edit_form_link = apply_filters( 'yikes-mailchimp-front-end-form-action-links', $edit_form_link, $this->form_id, ucwords( $this->form_data['form_name'] ) ); |
|
| 72 | + $edit_form_link = apply_filters( 'yikes-mailchimp-front-end-form-action-links', $edit_form_link, $this->form_id, ucwords( $this->form_data[ 'form_name' ] ) ); |
|
| 73 | 73 | } else { |
| 74 | 74 | $edit_form_link = ''; |
| 75 | 75 | } |