@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | * |
| 61 | 61 | * @var array |
| 62 | 62 | */ |
| 63 | - protected $_context_ = []; |
|
| 63 | + protected $_context_ = [ ]; |
|
| 64 | 64 | |
| 65 | 65 | /** |
| 66 | 66 | * Instantiate a View object. |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | * @return string Rendered HTML. |
| 86 | 86 | * @throws FailedToLoadView If the View URI could not be loaded. |
| 87 | 87 | */ |
| 88 | - public function render( array $context = [] ) { |
|
| 88 | + public function render( array $context = [ ] ) { |
|
| 89 | 89 | |
| 90 | 90 | // Add context to the current instance to make it available within the |
| 91 | 91 | // rendered view. |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | public function render_partial( $uri, array $context = null ) { |
| 141 | 141 | $view = new static( $uri ); |
| 142 | 142 | |
| 143 | - return $view->render( $context ?: $this->_context_ ); |
|
| 143 | + return $view->render( $context ? : $this->_context_ ); |
|
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | /** |
@@ -55,7 +55,7 @@ |
||
| 55 | 55 | * @return string Rendered HTML. |
| 56 | 56 | * @throws FailedToLoadView If the View URI could not be loaded. |
| 57 | 57 | */ |
| 58 | - public function render( array $context = [] ) { |
|
| 58 | + public function render( array $context = [ ] ) { |
|
| 59 | 59 | return wp_kses_post( $this->view->render( $context ) ); |
| 60 | 60 | } |
| 61 | 61 | |
@@ -33,7 +33,7 @@ |
||
| 33 | 33 | * @return string Rendered HTML. |
| 34 | 34 | * @throws FailedToLoadView If the View URI could not be loaded. |
| 35 | 35 | */ |
| 36 | - public function render( array $context = [] ); |
|
| 36 | + public function render( array $context = [ ] ); |
|
| 37 | 37 | |
| 38 | 38 | /** |
| 39 | 39 | * Render a partial view. |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | public function register() { |
| 41 | 41 | $this->register_assets(); |
| 42 | 42 | |
| 43 | - add_action( 'init', function () { |
|
| 43 | + add_action( 'init', function() { |
|
| 44 | 44 | add_shortcode( $this->get_tag(), [ $this, 'process_shortcode' ] ); |
| 45 | 45 | } ); |
| 46 | 46 | } |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | * |
| 71 | 71 | * @return string Rendered HTML. |
| 72 | 72 | */ |
| 73 | - public function render( array $context = [] ) { |
|
| 73 | + public function render( array $context = [ ] ) { |
|
| 74 | 74 | try { |
| 75 | 75 | $this->enqueue_assets(); |
| 76 | 76 | $view = new PostEscapedView( new TemplatedView( $this->get_view_uri() ) ); |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | * @return array Context to pass onto view. |
| 111 | 111 | */ |
| 112 | 112 | protected function get_context( array $atts ) { |
| 113 | - return []; |
|
| 113 | + return [ ]; |
|
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | /** |
@@ -9,10 +9,6 @@ |
||
| 9 | 9 | |
| 10 | 10 | namespace YIKES\EasyForms\Shortcode; |
| 11 | 11 | |
| 12 | -use YIKES\EasyForms\Asset; |
|
| 13 | -use YIKES\EasyForms\AssetAware; |
|
| 14 | -use YIKES\EasyForms\ScriptAsset; |
|
| 15 | -use YIKES\EasyForms\StyleAsset; |
|
| 16 | 12 | use YIKES\EasyForms\Exception; |
| 17 | 13 | use YIKES\EasyForms\View\FormEscapedView; |
| 18 | 14 | use YIKES\EasyForms\View\NoOverrideLocationView; |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | |
| 32 | 32 | final class EasyFormsShortcode extends BaseShortcode { |
| 33 | 33 | |
| 34 | - const TAG = 'yikes-mailchimp'; |
|
| 34 | + const TAG = 'yikes-mailchimp'; |
|
| 35 | 35 | const VIEW_URI = 'views/easy-forms-shortcode'; |
| 36 | 36 | const SUBMITTED_URI = 'views/easy-forms-shortcode-completed'; |
| 37 | 37 | |
@@ -52,26 +52,26 @@ discard block |
||
| 52 | 52 | * @since %VERSION% |
| 53 | 53 | * @var string |
| 54 | 54 | */ |
| 55 | - private $view_uri = self::VIEW_URI; |
|
| 55 | + private $view_uri = self::VIEW_URI; |
|
| 56 | 56 | |
| 57 | - /** |
|
| 58 | - * Register the Shortcode. |
|
| 59 | - * |
|
| 60 | - * @since %VERSION% |
|
| 61 | - */ |
|
| 57 | + /** |
|
| 58 | + * Register the Shortcode. |
|
| 59 | + * |
|
| 60 | + * @since %VERSION% |
|
| 61 | + */ |
|
| 62 | 62 | public function register() { |
| 63 | 63 | parent::register(); |
| 64 | 64 | add_action( 'easy_forms_do_shortcode', function( $atts ) { |
| 65 | 65 | echo $this->process_shortcode( $atts ); // phpcs:ignore WordPress.Security.EscapeOutput |
| 66 | 66 | } ); |
| 67 | - } |
|
| 67 | + } |
|
| 68 | 68 | |
| 69 | - /** |
|
| 70 | - * Get the default array of attributes for the shortcode. |
|
| 71 | - * |
|
| 72 | - * @since %VERSION% |
|
| 73 | - * @return array |
|
| 74 | - */ |
|
| 69 | + /** |
|
| 70 | + * Get the default array of attributes for the shortcode. |
|
| 71 | + * |
|
| 72 | + * @since %VERSION% |
|
| 73 | + * @return array |
|
| 74 | + */ |
|
| 75 | 75 | public function get_default_atts() { |
| 76 | 76 | return [ |
| 77 | 77 | 'form' => '', |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | } |
| 146 | 146 | } |
| 147 | 147 | |
| 148 | - /** |
|
| 148 | + /** |
|
| 149 | 149 | * Get the View URI to use for rendering the shortcode. |
| 150 | 150 | * |
| 151 | 151 | * @since %VERSION% |
@@ -158,15 +158,15 @@ discard block |
||
| 158 | 158 | } |
| 159 | 159 | |
| 160 | 160 | return $this->view_uri; |
| 161 | - } |
|
| 161 | + } |
|
| 162 | 162 | |
| 163 | - /** |
|
| 164 | - * Set the view URI. |
|
| 165 | - * |
|
| 166 | - * @since %VERSION% |
|
| 167 | - * |
|
| 168 | - * @param string $uri The URI to use. |
|
| 169 | - */ |
|
| 163 | + /** |
|
| 164 | + * Set the view URI. |
|
| 165 | + * |
|
| 166 | + * @since %VERSION% |
|
| 167 | + * |
|
| 168 | + * @param string $uri The URI to use. |
|
| 169 | + */ |
|
| 170 | 170 | private function set_view_uri( $uri ) { |
| 171 | 171 | $this->view_uri = $uri; |
| 172 | 172 | } |
@@ -181,15 +181,15 @@ discard block |
||
| 181 | 181 | return ! empty( $_POST ); |
| 182 | 182 | } |
| 183 | 183 | |
| 184 | - /** |
|
| 185 | - * Render the current Renderable. |
|
| 186 | - * |
|
| 187 | - * @since %VERSION% |
|
| 188 | - * |
|
| 189 | - * @param array $context Context in which to render. |
|
| 190 | - * |
|
| 191 | - * @return string Rendered HTML. |
|
| 192 | - */ |
|
| 184 | + /** |
|
| 185 | + * Render the current Renderable. |
|
| 186 | + * |
|
| 187 | + * @since %VERSION% |
|
| 188 | + * |
|
| 189 | + * @param array $context Context in which to render. |
|
| 190 | + * |
|
| 191 | + * @return string Rendered HTML. |
|
| 192 | + */ |
|
| 193 | 193 | public function render( array $context = [] ) { |
| 194 | 194 | try { |
| 195 | 195 | $this->enqueue_assets(); |
@@ -240,15 +240,15 @@ discard block |
||
| 240 | 240 | return isset( $subscriber ) ? $subscriber : null; |
| 241 | 241 | } |
| 242 | 242 | |
| 243 | - /** |
|
| 244 | - * Convert an exception to a string. |
|
| 245 | - * |
|
| 246 | - * @since %VERSION% |
|
| 247 | - * |
|
| 248 | - * @param \Exception $e The exception object. |
|
| 249 | - * |
|
| 250 | - * @return string |
|
| 251 | - */ |
|
| 243 | + /** |
|
| 244 | + * Convert an exception to a string. |
|
| 245 | + * |
|
| 246 | + * @since %VERSION% |
|
| 247 | + * |
|
| 248 | + * @param \Exception $e The exception object. |
|
| 249 | + * |
|
| 250 | + * @return string |
|
| 251 | + */ |
|
| 252 | 252 | private function exception_to_string( \Exception $e ) { |
| 253 | 253 | return sprintf( |
| 254 | 254 | /* translators: %s refers to the error message */ |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | |
| 32 | 32 | final class EasyFormsShortcode extends BaseShortcode { |
| 33 | 33 | |
| 34 | - const TAG = 'yikes-mailchimp'; |
|
| 34 | + const TAG = 'yikes-mailchimp'; |
|
| 35 | 35 | const VIEW_URI = 'views/easy-forms-shortcode'; |
| 36 | 36 | const SUBMITTED_URI = 'views/easy-forms-shortcode-completed'; |
| 37 | 37 | |
@@ -106,16 +106,16 @@ discard block |
||
| 106 | 106 | * @throws InvalidPostID When the post ID is not valid. |
| 107 | 107 | */ |
| 108 | 108 | protected function get_context( array $atts ) { |
| 109 | - $optin_form = ( new OptinFormRepository() )->find( $atts['form'] ); |
|
| 109 | + $optin_form = ( new OptinFormRepository() )->find( $atts[ 'form' ] ); |
|
| 110 | 110 | /** @todo Recaptcha Settings. */ |
| 111 | 111 | $this->is_submitted = $this->is_submitting_form(); |
| 112 | 112 | // Set up the classes we'll use for the form and the individual fields. |
| 113 | - $form_classes = $optin_form['form_settings']['yikes-easy-mc-form-class-names']; |
|
| 113 | + $form_classes = $optin_form[ 'form_settings' ][ 'yikes-easy-mc-form-class-names' ]; |
|
| 114 | 114 | |
| 115 | 115 | // Set up the form object. |
| 116 | 116 | $form = $this->get_optin_form( $optin_form->get_id(), $optin_form, $field_classes ); |
| 117 | 117 | return [ |
| 118 | - 'form_settings' => $optin_form['form_settings'], |
|
| 118 | + 'form_settings' => $optin_form[ 'form_settings' ], |
|
| 119 | 119 | 'optin_form' => $optin_form, |
| 120 | 120 | 'form_id' => $optin_form->get_id(), |
| 121 | 121 | 'form_classes' => $form_classes, |
@@ -190,7 +190,7 @@ discard block |
||
| 190 | 190 | * |
| 191 | 191 | * @return string Rendered HTML. |
| 192 | 192 | */ |
| 193 | - public function render( array $context = [] ) { |
|
| 193 | + public function render( array $context = [ ] ) { |
|
| 194 | 194 | try { |
| 195 | 195 | $this->enqueue_assets(); |
| 196 | 196 | $view = new FormEscapedView( new NoOverrideLocationView( $this->get_view_uri() ) ); |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | * |
| 95 | 95 | * @var array |
| 96 | 96 | */ |
| 97 | - private $allowed_tags = []; |
|
| 97 | + private $allowed_tags = [ ]; |
|
| 98 | 98 | |
| 99 | 99 | /** |
| 100 | 100 | * Instantiate a FormEscapedView object. |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | * @return string Rendered HTML. |
| 142 | 142 | * @throws FailedToLoadView If the View URI could not be loaded. |
| 143 | 143 | */ |
| 144 | - public function render( array $context = [] ) { |
|
| 144 | + public function render( array $context = [ ] ) { |
|
| 145 | 145 | return wp_kses( $this->view->render( $context ), $this->allowed_tags ); |
| 146 | 146 | } |
| 147 | 147 | |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | * @return bool Whether the form was successfully updated. |
| 49 | 49 | */ |
| 50 | 50 | public function update_form( $form_id, $data ) { |
| 51 | - $data['id'] = $form_id; |
|
| 51 | + $data[ 'id' ] = $form_id; |
|
| 52 | 52 | $all_forms = $this->get_all_forms(); |
| 53 | 53 | |
| 54 | 54 | if ( ! isset( $all_forms[ $form_id ] ) ) { |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | $all_ids = $this->get_form_ids(); |
| 80 | 80 | $last_id = end( $all_ids ); |
| 81 | 81 | $new_id = false === $last_id ? 1 : $last_id + 1; |
| 82 | - $form_data['id'] = $new_id; |
|
| 82 | + $form_data[ 'id' ] = $new_id; |
|
| 83 | 83 | |
| 84 | 84 | // Ensure our data is consistently sorted |
| 85 | 85 | ksort( $form_data ); |