@@ -9,14 +9,14 @@ discard block |
||
| 9 | 9 | * @table_name - table name to impot data to |
| 10 | 10 | */ |
| 11 | 11 | public static function yikes_mailchimp_import_forms( $csv_file ) { |
| 12 | - if ( ! isset( $_REQUEST['action'] ) || $_REQUEST['action'] !== 'yikes-easy-mc-import-forms' ) { |
|
| 12 | + if ( ! isset( $_REQUEST[ 'action' ] ) || $_REQUEST[ 'action' ] !== 'yikes-easy-mc-import-forms' ) { |
|
| 13 | 13 | wp_die( __( 'There was an error during import. If you continue to run into issues, please reach out to the Yikes Inc. support team.', 'yikes-inc-easy-mailchimp-extender' ) ); |
| 14 | 14 | } |
| 15 | 15 | |
| 16 | - $name = $csv_file['csv']['name']; |
|
| 16 | + $name = $csv_file[ 'csv' ][ 'name' ]; |
|
| 17 | 17 | $ext_array = explode( '.', $name ); |
| 18 | 18 | $ext = end( $ext_array ); |
| 19 | - $tmp_name = $csv_file['csv']['tmp_name']; |
|
| 19 | + $tmp_name = $csv_file[ 'csv' ][ 'tmp_name' ]; |
|
| 20 | 20 | |
| 21 | 21 | // Ensure we have a valid file extension. |
| 22 | 22 | if ( 'csv' !== $ext ) { |
@@ -41,17 +41,17 @@ discard block |
||
| 41 | 41 | |
| 42 | 42 | // Check if this is a settings import by confirming the first option is 'yikes-mc-api-key' |
| 43 | 43 | // @todo: this should be a separate method. |
| 44 | - if( $line[0] == 'yikes-mc-api-key' ) { |
|
| 45 | - $options = fgetcsv($file, 10000, ','); |
|
| 44 | + if ( $line[ 0 ] == 'yikes-mc-api-key' ) { |
|
| 45 | + $options = fgetcsv( $file, 10000, ',' ); |
|
| 46 | 46 | $new_settings = array(); |
| 47 | 47 | $x = 0; |
| 48 | 48 | // build our new array $key => $value pair |
| 49 | - foreach( $line as $option_name ) { |
|
| 50 | - $new_settings[$option_name] = $options[$x]; |
|
| 49 | + foreach ( $line as $option_name ) { |
|
| 50 | + $new_settings[ $option_name ] = $options[ $x ]; |
|
| 51 | 51 | $x++; |
| 52 | 52 | } |
| 53 | 53 | // update the options in the databse |
| 54 | - foreach( $new_settings as $option_name => $option_value ) { |
|
| 54 | + foreach ( $new_settings as $option_name => $option_value ) { |
|
| 55 | 55 | update_option( $option_name, $option_value ); |
| 56 | 56 | } |
| 57 | 57 | } else { // if it's not, then it's an opt-in forms import |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | $row++; |
| 81 | 81 | } |
| 82 | 82 | |
| 83 | - fclose($file); |
|
| 83 | + fclose( $file ); |
|
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | /* |
@@ -91,20 +91,20 @@ discard block |
||
| 91 | 91 | */ |
| 92 | 92 | public static function yikes_mailchimp_import_type( $csv_file ) { |
| 93 | 93 | // confirm |
| 94 | - if( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'yikes-easy-mc-import-forms' ) { |
|
| 95 | - $name = $csv_file['csv']['name']; |
|
| 96 | - $ext_array = explode('.', $name); |
|
| 94 | + if ( isset( $_REQUEST[ 'action' ] ) && $_REQUEST[ 'action' ] == 'yikes-easy-mc-import-forms' ) { |
|
| 95 | + $name = $csv_file[ 'csv' ][ 'name' ]; |
|
| 96 | + $ext_array = explode( '.', $name ); |
|
| 97 | 97 | $ext = end( $ext_array ); |
| 98 | - $tmpName = $csv_file['csv']['tmp_name']; |
|
| 99 | - if($ext === 'csv') { |
|
| 100 | - if(($handle = fopen($tmpName, 'r')) !== FALSE) { |
|
| 101 | - $num = count($handle); |
|
| 102 | - $file = fopen( $tmpName, 'r'); |
|
| 98 | + $tmpName = $csv_file[ 'csv' ][ 'tmp_name' ]; |
|
| 99 | + if ( $ext === 'csv' ) { |
|
| 100 | + if ( ( $handle = fopen( $tmpName, 'r' ) ) !== FALSE ) { |
|
| 101 | + $num = count( $handle ); |
|
| 102 | + $file = fopen( $tmpName, 'r' ); |
|
| 103 | 103 | $row = 1; |
| 104 | - $first_line_data = fgetcsv($file, 10000, ','); |
|
| 105 | - if( count( $first_line_data ) > 1 ) { |
|
| 104 | + $first_line_data = fgetcsv( $file, 10000, ',' ); |
|
| 105 | + if ( count( $first_line_data ) > 1 ) { |
|
| 106 | 106 | // Check if this is a settings import by confirming the first option is 'yikes-mc-api-key' |
| 107 | - if( $first_line_data[0] == 'yikes-mc-api-key' ) { |
|
| 107 | + if ( $first_line_data[ 0 ] == 'yikes-mc-api-key' ) { |
|
| 108 | 108 | $import_type = 'import-settings'; |
| 109 | 109 | } else { |
| 110 | 110 | $import_type = 'import-forms'; |
@@ -54,7 +54,8 @@ |
||
| 54 | 54 | foreach( $new_settings as $option_name => $option_value ) { |
| 55 | 55 | update_option( $option_name, $option_value ); |
| 56 | 56 | } |
| 57 | - } else { // if it's not, then it's an opt-in forms import |
|
| 57 | + } else { |
|
| 58 | +// if it's not, then it's an opt-in forms import |
|
| 58 | 59 | // If this is the first row, then it should be title data. |
| 59 | 60 | if ( 1 === $row ) { |
| 60 | 61 | $titles = $line; |
@@ -1,6 +1,6 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -return array ( |
|
| 3 | +return array( |
|
| 4 | 4 | 'yikes_inc_easy_mailchimp_forms_admin' => 'admin/class-yikes-inc-easy-mailchimp-extender-admin.php', |
| 5 | 5 | 'yikes_inc_easy_mailchimp_process_ajax' => 'admin/partials/ajax/class.ajax.php', |
| 6 | 6 | 'yikes_inc_easy_mailchimp_dashboard_widgets' => 'admin/partials/dashboard-widgets/class.list-activity-widget.php', |
@@ -19,7 +19,7 @@ |
||
| 19 | 19 | * |
| 20 | 20 | * @param int $form_id The ID of the form to retrieve. |
| 21 | 21 | * |
| 22 | - * @return array The array of form data. |
|
| 22 | + * @return string The array of form data. |
|
| 23 | 23 | */ |
| 24 | 24 | public function get_form( $form_id ) { |
| 25 | 25 | $all_forms = $this->get_all_forms(); |
@@ -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 ); |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | $titles = array(); |
| 81 | 81 | $content = array(); |
| 82 | 82 | foreach ( $plugin_settings as $option_name => $option_value ) { |
| 83 | - $titles[] = $option_name; |
|
| 83 | + $titles[ ] = $option_name; |
|
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | // Generate the output file. |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | fputcsv( $output_handle, $titles ); |
| 104 | 104 | $first = false; |
| 105 | 105 | } |
| 106 | - $content[] = $option_value; |
|
| 106 | + $content[ ] = $option_value; |
|
| 107 | 107 | |
| 108 | 108 | } |
| 109 | 109 | fputcsv( $output_handle, $content ); |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | */ |
| 94 | 94 | public function update_form( $form_id, $data ) { |
| 95 | 95 | // Prepare the data for the database. |
| 96 | - $data['id'] = $form_id; |
|
| 96 | + $data[ 'id' ] = $form_id; |
|
| 97 | 97 | $save_data = $this->prepare_data_for_db( $data ); |
| 98 | 98 | $formats = $this->get_format_array( $save_data ); |
| 99 | 99 | |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | $form_data = yikes_deep_parse_args( $form_data, $this->get_form_defaults() ); |
| 123 | 123 | |
| 124 | 124 | // If there is an ID set, remove it |
| 125 | - unset( $form_data['id'] ); |
|
| 125 | + unset( $form_data[ 'id' ] ); |
|
| 126 | 126 | |
| 127 | 127 | // Prepare the data for the database |
| 128 | 128 | $save_data = $this->prepare_data_for_db( $form_data ); |
@@ -302,11 +302,11 @@ discard block |
||
| 302 | 302 | case 'redirect_user_on_submit': |
| 303 | 303 | case 'redirect_page': |
| 304 | 304 | case 'id': |
| 305 | - $formats[] = '%d'; |
|
| 305 | + $formats[ ] = '%d'; |
|
| 306 | 306 | break; |
| 307 | 307 | |
| 308 | 308 | default: |
| 309 | - $formats[] = '%s'; |
|
| 309 | + $formats[ ] = '%s'; |
|
| 310 | 310 | } |
| 311 | 311 | } |
| 312 | 312 | |
@@ -346,7 +346,7 @@ discard block |
||
| 346 | 346 | continue; |
| 347 | 347 | } |
| 348 | 348 | |
| 349 | - $data['id'] = $id; |
|
| 349 | + $data[ 'id' ] = $id; |
|
| 350 | 350 | $_form_data = $this->prepare_data_for_db( $data ); |
| 351 | 351 | $formats = $this->get_format_array( $_form_data ); |
| 352 | 352 | |
@@ -5,25 +5,25 @@ |
||
| 5 | 5 | * For help on using, see our documentation [https://yikesplugins.com/support/knowledge-base/product/easy-forms-for-mailchimp/] |
| 6 | 6 | * @since 6.0 |
| 7 | 7 | */ |
| 8 | - if ( is_string( $form_data['custom_fields'] ) ) { |
|
| 9 | - $field_data = json_decode( $form_data['custom_fields'] , true ); |
|
| 10 | - } elseif ( is_array( $form_data['custom_fields'] ) ) { |
|
| 11 | - $field_data = $form_data['custom_fields']; |
|
| 8 | + if ( is_string( $form_data[ 'custom_fields' ] ) ) { |
|
| 9 | + $field_data = json_decode( $form_data[ 'custom_fields' ], true ); |
|
| 10 | + } elseif ( is_array( $form_data[ 'custom_fields' ] ) ) { |
|
| 11 | + $field_data = $form_data[ 'custom_fields' ]; |
|
| 12 | 12 | } |
| 13 | 13 | ?> |
| 14 | 14 | <div class="custom-field-section"> |
| 15 | 15 | <!-- title --> |
| 16 | - <strong><?php echo $field['label']; ?></strong> |
|
| 16 | + <strong><?php echo $field[ 'label' ]; ?></strong> |
|
| 17 | 17 | |
| 18 | 18 | <!-- Dropdown --> |
| 19 | - <select class="custom-select-field" name="custom-field[<?php echo $field['id']; ?>]"> |
|
| 20 | - <?php foreach( $field['options'] as $value => $label ) { ?> |
|
| 21 | - <option value="<?php echo $value; ?>" <?php if( isset( $field_data[$field['id']] ) ) { selected( $field_data[$field['id']] , $value ); } ?>><?php echo $label; ?></option> |
|
| 19 | + <select class="custom-select-field" name="custom-field[<?php echo $field[ 'id' ]; ?>]"> |
|
| 20 | + <?php foreach ( $field[ 'options' ] as $value => $label ) { ?> |
|
| 21 | + <option value="<?php echo $value; ?>" <?php if ( isset( $field_data[ $field[ 'id' ] ] ) ) { selected( $field_data[ $field[ 'id' ] ], $value ); } ?>><?php echo $label; ?></option> |
|
| 22 | 22 | <?php } ?> |
| 23 | 23 | </select> |
| 24 | 24 | |
| 25 | 25 | <!-- description --> |
| 26 | - <?php if( isset( $field['description'] ) && $field['description'] != '' ) { ?> |
|
| 27 | - <p class="description"><?php echo $field['description']; ?></p> |
|
| 26 | + <?php if ( isset( $field[ 'description' ] ) && $field[ 'description' ] != '' ) { ?> |
|
| 27 | + <p class="description"><?php echo $field[ 'description' ]; ?></p> |
|
| 28 | 28 | <?php } ?> |
| 29 | 29 | </div> |
| 30 | 30 | \ No newline at end of file |
@@ -5,16 +5,16 @@ |
||
| 5 | 5 | * For help on using, see our documentation [https://yikesplugins.com/support/knowledge-base/product/easy-forms-for-mailchimp/] |
| 6 | 6 | * @since 6.0 |
| 7 | 7 | */ |
| 8 | - if ( is_string( $form_data['custom_fields'] ) ) { |
|
| 9 | - $field_data = json_decode( $form_data['custom_fields'] , true ); |
|
| 10 | - } elseif ( is_array( $form_data['custom_fields'] ) ) { |
|
| 11 | - $field_data = $form_data['custom_fields']; |
|
| 8 | + if ( is_string( $form_data[ 'custom_fields' ] ) ) { |
|
| 9 | + $field_data = json_decode( $form_data[ 'custom_fields' ], true ); |
|
| 10 | + } elseif ( is_array( $form_data[ 'custom_fields' ] ) ) { |
|
| 11 | + $field_data = $form_data[ 'custom_fields' ]; |
|
| 12 | 12 | } |
| 13 | 13 | ?> |
| 14 | 14 | <label class="custom-field-section"> |
| 15 | - <strong><?php echo $field['label']; ?></strong> |
|
| 16 | - <input type="text" class="widefat" name="custom-field[<?php echo $field['id']; ?>]" id="custom-field" value="<?php echo isset( $field_data[$field['id']] ) ? $field_data[$field['id']] : ''; ?>" placeholder="<?php echo isset( $field['placeholder'] ) ? $field['placeholder'] : ''; ?>"> |
|
| 17 | - <?php if( isset( $field['description'] ) && $field['description'] != '' ) { ?> |
|
| 18 | - <p class="description"><?php echo $field['description']; ?></p> |
|
| 15 | + <strong><?php echo $field[ 'label' ]; ?></strong> |
|
| 16 | + <input type="text" class="widefat" name="custom-field[<?php echo $field[ 'id' ]; ?>]" id="custom-field" value="<?php echo isset( $field_data[ $field[ 'id' ] ] ) ? $field_data[ $field[ 'id' ] ] : ''; ?>" placeholder="<?php echo isset( $field[ 'placeholder' ] ) ? $field[ 'placeholder' ] : ''; ?>"> |
|
| 17 | + <?php if ( isset( $field[ 'description' ] ) && $field[ 'description' ] != '' ) { ?> |
|
| 18 | + <p class="description"><?php echo $field[ 'description' ]; ?></p> |
|
| 19 | 19 | <?php } ?> |
| 20 | 20 | </label> |
| 21 | 21 | \ No newline at end of file |
@@ -5,16 +5,16 @@ |
||
| 5 | 5 | * For help on using, see our documentation [https://yikesplugins.com/support/knowledge-base/product/easy-forms-for-mailchimp/] |
| 6 | 6 | * @since 6.0 |
| 7 | 7 | */ |
| 8 | - if ( is_string( $form_data['custom_fields'] ) ) { |
|
| 9 | - $field_data = json_decode( $form_data['custom_fields'] , true ); |
|
| 10 | - } elseif ( is_array( $form_data['custom_fields'] ) ) { |
|
| 11 | - $field_data = $form_data['custom_fields']; |
|
| 8 | + if ( is_string( $form_data[ 'custom_fields' ] ) ) { |
|
| 9 | + $field_data = json_decode( $form_data[ 'custom_fields' ], true ); |
|
| 10 | + } elseif ( is_array( $form_data[ 'custom_fields' ] ) ) { |
|
| 11 | + $field_data = $form_data[ 'custom_fields' ]; |
|
| 12 | 12 | } |
| 13 | 13 | ?> |
| 14 | 14 | <label class="custom-field-section"> |
| 15 | - <strong><?php echo $field['label']; ?></strong> |
|
| 16 | - <input type="checkbox" class="widefat" name="custom-field[<?php echo $field['id']; ?>]" id="custom-field" value="1" <?php checked( isset( $field_data[$field['id']] ) ? $field_data[$field['id']] : 0, 1, true ); ?>> |
|
| 17 | - <?php if( isset( $field['description'] ) && $field['description'] != '' ) { ?> |
|
| 18 | - <p class="description"><?php echo $field['description']; ?></p> |
|
| 15 | + <strong><?php echo $field[ 'label' ]; ?></strong> |
|
| 16 | + <input type="checkbox" class="widefat" name="custom-field[<?php echo $field[ 'id' ]; ?>]" id="custom-field" value="1" <?php checked( isset( $field_data[ $field[ 'id' ] ] ) ? $field_data[ $field[ 'id' ] ] : 0, 1, true ); ?>> |
|
| 17 | + <?php if ( isset( $field[ 'description' ] ) && $field[ 'description' ] != '' ) { ?> |
|
| 18 | + <p class="description"><?php echo $field[ 'description' ]; ?></p> |
|
| 19 | 19 | <?php } ?> |
| 20 | 20 | </label> |
@@ -5,10 +5,10 @@ discard block |
||
| 5 | 5 | * For help on using, see our documentation [https://yikesplugins.com/support/knowledge-base/product/easy-forms-for-mailchimp/] |
| 6 | 6 | * @since 6.0 |
| 7 | 7 | */ |
| 8 | - if ( is_string( $form_data['custom_fields'] ) ) { |
|
| 9 | - $field_data = json_decode( $form_data['custom_fields'] , true ); |
|
| 10 | - } elseif ( is_array( $form_data['custom_fields'] ) ) { |
|
| 11 | - $field_data = $form_data['custom_fields']; |
|
| 8 | + if ( is_string( $form_data[ 'custom_fields' ] ) ) { |
|
| 9 | + $field_data = json_decode( $form_data[ 'custom_fields' ], true ); |
|
| 10 | + } elseif ( is_array( $form_data[ 'custom_fields' ] ) ) { |
|
| 11 | + $field_data = $form_data[ 'custom_fields' ]; |
|
| 12 | 12 | } |
| 13 | 13 | |
| 14 | 14 | // This will enqueue the Media Uploader script |
@@ -16,27 +16,27 @@ discard block |
||
| 16 | 16 | // And let's not forget the script we wrote earlier |
| 17 | 17 | wp_enqueue_script( 'yikes-mailchimp-file-field-script', plugin_dir_url( __FILE__ ) . 'js/yikes-mc-file-upload.js', array( 'jquery' ), '1.0', false ); |
| 18 | 18 | // print_r( $field_data ); |
| 19 | - wp_localize_script( 'yikes-mailchimp-file-field-script' , 'additional_data' , array( |
|
| 19 | + wp_localize_script( 'yikes-mailchimp-file-field-script', 'additional_data', array( |
|
| 20 | 20 | 'wp_includes_image_url' => includes_url() . 'images/media/' |
| 21 | 21 | ) ); |
| 22 | 22 | $i = 1; |
| 23 | 23 | // create an single item array when nothing is stored yet, loop for one field |
| 24 | - $field_data['incentive-attachment'] = ( isset( $field_data['incentive-attachment'] ) && !empty( $field_data['incentive-attachment'] ) ) ? $field_data['incentive-attachment'] : array( '' ); |
|
| 24 | + $field_data[ 'incentive-attachment' ] = ( isset( $field_data[ 'incentive-attachment' ] ) && ! empty( $field_data[ 'incentive-attachment' ] ) ) ? $field_data[ 'incentive-attachment' ] : array( '' ); |
|
| 25 | 25 | ?> |
| 26 | 26 | |
| 27 | 27 | <div class="yikes-mailchimp-file-field"> |
| 28 | - <label for="image_url" class="widefat"><strong><?php echo $field['label']; ?></strong></label> |
|
| 29 | - <?php foreach( $field_data['incentive-attachment'] as $attachment ) { ?> |
|
| 30 | - <input type="text" name="custom-field[<?php echo $field['id']; ?>][<?php echo $i; ?>]" id="custom-field[<?php echo $field['id']; ?>][<?php echo $i; ?>]" class="file-attachment" value="<?php echo isset( $field_data[$field['id']][$i] ) ? $field_data[$field['id']][$i] : ''; ?>"> |
|
| 31 | - <input type="button" name="upload-btn" id="upload-btn" class="button-secondary" data-attr-position="<?php echo $i; ?>" value="<?php _e( 'Upload File' , 'yikes-inc-easy-mailchimp-extender' ); ?>"> |
|
| 28 | + <label for="image_url" class="widefat"><strong><?php echo $field[ 'label' ]; ?></strong></label> |
|
| 29 | + <?php foreach ( $field_data[ 'incentive-attachment' ] as $attachment ) { ?> |
|
| 30 | + <input type="text" name="custom-field[<?php echo $field[ 'id' ]; ?>][<?php echo $i; ?>]" id="custom-field[<?php echo $field[ 'id' ]; ?>][<?php echo $i; ?>]" class="file-attachment" value="<?php echo isset( $field_data[ $field[ 'id' ] ][ $i ] ) ? $field_data[ $field[ 'id' ] ][ $i ] : ''; ?>"> |
|
| 31 | + <input type="button" name="upload-btn" id="upload-btn" class="button-secondary" data-attr-position="<?php echo $i; ?>" value="<?php _e( 'Upload File', 'yikes-inc-easy-mailchimp-extender' ); ?>"> |
|
| 32 | 32 | <div class="file-container"> |
| 33 | 33 | <p class="file-remove-wrapper"> |
| 34 | - <a href="#" class="remove-file-button" data-attr-position="<?php echo $i; ?>"><?php _e( 'Remove File' , 'yikes-inc-easy-mailchimp-extender' ); ?></a> |
|
| 34 | + <a href="#" class="remove-file-button" data-attr-position="<?php echo $i; ?>"><?php _e( 'Remove File', 'yikes-inc-easy-mailchimp-extender' ); ?></a> |
|
| 35 | 35 | </p> |
| 36 | 36 | </div> |
| 37 | 37 | <?php $i++; } ?> |
| 38 | - <?php if( isset( $field['repeat'] ) ) { ?> |
|
| 38 | + <?php if ( isset( $field[ 'repeat' ] ) ) { ?> |
|
| 39 | 39 | <a href="#" class="button-secondary add-new-incentive-attachment" data-attr-position="<?php echo $i; ?>"><span class="dashicons dashicons-plus"></span></a> |
| 40 | 40 | <?php } ?> |
| 41 | - <p class="description"><?php echo $field['description']; ?></p> |
|
| 41 | + <p class="description"><?php echo $field[ 'description' ]; ?></p> |
|
| 42 | 42 | </div> |
| 43 | 43 | \ No newline at end of file |