@@ -5,33 +5,33 @@ |
||
| 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 | - $field_data = json_decode( $form_data['custom_fields'] , true ); |
|
| 8 | + $field_data = json_decode( $form_data[ 'custom_fields' ], true ); |
|
| 9 | 9 | // This will enqueue the Media Uploader script |
| 10 | 10 | wp_enqueue_media(); |
| 11 | 11 | // And let's not forget the script we wrote earlier |
| 12 | 12 | wp_enqueue_script( 'yikes-mailchimp-file-field-script', plugin_dir_url( __FILE__ ) . 'js/yikes-mc-file-upload.js', array( 'jquery' ), '1.0', false ); |
| 13 | 13 | // print_r( $field_data ); |
| 14 | - wp_localize_script( 'yikes-mailchimp-file-field-script' , 'additional_data' , array( |
|
| 14 | + wp_localize_script( 'yikes-mailchimp-file-field-script', 'additional_data', array( |
|
| 15 | 15 | 'wp_includes_image_url' => includes_url() . 'images/media/' |
| 16 | 16 | ) ); |
| 17 | 17 | $i = 1; |
| 18 | 18 | // create an single item array when nothing is stored yet, loop for one field |
| 19 | - $field_data['incentive-attachment'] = ( isset( $field_data['incentive-attachment'] ) && !empty( $field_data['incentive-attachment'] ) ) ? $field_data['incentive-attachment'] : array( '' ); |
|
| 19 | + $field_data[ 'incentive-attachment' ] = ( isset( $field_data[ 'incentive-attachment' ] ) && ! empty( $field_data[ 'incentive-attachment' ] ) ) ? $field_data[ 'incentive-attachment' ] : array( '' ); |
|
| 20 | 20 | ?> |
| 21 | 21 | |
| 22 | 22 | <div class="yikes-mailchimp-file-field"> |
| 23 | - <label for="image_url" class="widefat"><strong><?php echo $field['label']; ?></strong></label> |
|
| 24 | - <?php foreach( $field_data['incentive-attachment'] as $attachment ) { ?> |
|
| 25 | - <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] : ''; ?>"> |
|
| 26 | - <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' ); ?>"> |
|
| 23 | + <label for="image_url" class="widefat"><strong><?php echo $field[ 'label' ]; ?></strong></label> |
|
| 24 | + <?php foreach ( $field_data[ 'incentive-attachment' ] as $attachment ) { ?> |
|
| 25 | + <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 ] : ''; ?>"> |
|
| 26 | + <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' ); ?>"> |
|
| 27 | 27 | <div class="file-container"> |
| 28 | 28 | <p class="file-remove-wrapper"> |
| 29 | - <a href="#" class="remove-file-button" data-attr-position="<?php echo $i; ?>"><?php _e( 'Remove File' , 'yikes-inc-easy-mailchimp-extender' ); ?></a> |
|
| 29 | + <a href="#" class="remove-file-button" data-attr-position="<?php echo $i; ?>"><?php _e( 'Remove File', 'yikes-inc-easy-mailchimp-extender' ); ?></a> |
|
| 30 | 30 | </p> |
| 31 | 31 | </div> |
| 32 | 32 | <?php $i++; } ?> |
| 33 | - <?php if( isset( $field['repeat'] ) ) { ?> |
|
| 33 | + <?php if ( isset( $field[ 'repeat' ] ) ) { ?> |
|
| 34 | 34 | <a href="#" class="button-secondary add-new-incentive-attachment" data-attr-position="<?php echo $i; ?>"><span class="dashicons dashicons-plus"></span></a> |
| 35 | 35 | <?php } ?> |
| 36 | - <p class="description"><?php echo $field['description']; ?></p> |
|
| 36 | + <p class="description"><?php echo $field[ 'description' ]; ?></p> |
|
| 37 | 37 | </div> |
| 38 | 38 | \ No newline at end of file |
@@ -8,28 +8,28 @@ discard block |
||
| 8 | 8 | // grab our global form_data; |
| 9 | 9 | global $form_data; |
| 10 | 10 | ?> |
| 11 | - <label class="hidden-setting-label yikes-easy-mc-hidden" for="form" id=<?php esc_attr_e( $section_data['id'] ); ?>> |
|
| 11 | + <label class="hidden-setting-label yikes-easy-mc-hidden" for="form" id=<?php esc_attr_e( $section_data[ 'id' ] ); ?>> |
|
| 12 | 12 | <div id="poststuff"> |
| 13 | - <div id="post-body" class="metabox-holder <?php if( self::is_custom_section_two_column( $section_data ) ) { ?> columns-2 <?php } else { ?> columns-1 <?php } ?>"> |
|
| 13 | + <div id="post-body" class="metabox-holder <?php if ( self::is_custom_section_two_column( $section_data ) ) { ?> columns-2 <?php } else { ?> columns-1 <?php } ?>"> |
|
| 14 | 14 | <div id="post-body-content"> |
| 15 | 15 | <div class="meta-box-sortables ui-sortable"> |
| 16 | 16 | <div class="postbox yikes-easy-mc-postbox"> |
| 17 | - <h3 class="edit-form-title"><span><?php echo $section_data['main_title']; ?></span></h3> |
|
| 18 | - <div class="inside <?php esc_attr_e( $section_data['id'] ); ?>-container"> |
|
| 17 | + <h3 class="edit-form-title"><span><?php echo $section_data[ 'main_title' ]; ?></span></h3> |
|
| 18 | + <div class="inside <?php esc_attr_e( $section_data[ 'id' ] ); ?>-container"> |
|
| 19 | 19 | <?php |
| 20 | - if( isset( $section_data['main_description'] ) && $section_data['main_description'] != '' ) { |
|
| 20 | + if ( isset( $section_data[ 'main_description' ] ) && $section_data[ 'main_description' ] != '' ) { |
|
| 21 | 21 | ?> |
| 22 | - <p><?php echo $section_data['main_description']; ?></p> |
|
| 22 | + <p><?php echo $section_data[ 'main_description' ]; ?></p> |
|
| 23 | 23 | <?php |
| 24 | 24 | } |
| 25 | - $main_field_data = $section_data['main_fields']; |
|
| 26 | - foreach( $main_field_data as $field ) { |
|
| 27 | - if( $field['type'] == 'custom' ) { |
|
| 25 | + $main_field_data = $section_data[ 'main_fields' ]; |
|
| 26 | + foreach ( $main_field_data as $field ) { |
|
| 27 | + if ( $field[ 'type' ] == 'custom' ) { |
|
| 28 | 28 | // execute the custom callback |
| 29 | - $field['callback'](); |
|
| 29 | + $field[ 'callback' ](); |
|
| 30 | 30 | } else { |
| 31 | 31 | // include our field files |
| 32 | - include( YIKES_MC_PATH . 'admin/partials/helpers/fields/yikes-mailchimp-' . $field['type'] . '-field.php' ); |
|
| 32 | + include( YIKES_MC_PATH . 'admin/partials/helpers/fields/yikes-mailchimp-' . $field[ 'type' ] . '-field.php' ); |
|
| 33 | 33 | } |
| 34 | 34 | } |
| 35 | 35 | ?> |
@@ -39,27 +39,27 @@ discard block |
||
| 39 | 39 | </div> |
| 40 | 40 | |
| 41 | 41 | <!-- check for single/double box --> |
| 42 | - <?php if( self::is_custom_section_two_column( $section_data ) ) { ?> |
|
| 42 | + <?php if ( self::is_custom_section_two_column( $section_data ) ) { ?> |
|
| 43 | 43 | <!-- begin sidebar --> |
| 44 | 44 | <div id="postbox-container-1" class="postbox-container"> |
| 45 | 45 | <div class="meta-box-sortables"> |
| 46 | 46 | <div class="postbox yikes-easy-mc-postbox"> |
| 47 | - <h3 class="edit-form-title"><span><?php echo $section_data['sidebar_title']; ?></span></h3> |
|
| 48 | - <div class="inside <?php esc_attr_e( $section_data['id'] ); ?>-sidebar-container"> |
|
| 47 | + <h3 class="edit-form-title"><span><?php echo $section_data[ 'sidebar_title' ]; ?></span></h3> |
|
| 48 | + <div class="inside <?php esc_attr_e( $section_data[ 'id' ] ); ?>-sidebar-container"> |
|
| 49 | 49 | <?php |
| 50 | - if( isset( $section_data['sidebar_description'] ) && $section_data['sidebar_description'] != '' ) { |
|
| 50 | + if ( isset( $section_data[ 'sidebar_description' ] ) && $section_data[ 'sidebar_description' ] != '' ) { |
|
| 51 | 51 | ?> |
| 52 | - <p><?php echo $section_data['sidebar_description']; ?></p> |
|
| 52 | + <p><?php echo $section_data[ 'sidebar_description' ]; ?></p> |
|
| 53 | 53 | <?php |
| 54 | 54 | } |
| 55 | - $sidebar_field_data = $section_data['sidebar_fields']; |
|
| 56 | - foreach( $sidebar_field_data as $field ) { |
|
| 57 | - if( $field['type'] == 'custom' ) { |
|
| 55 | + $sidebar_field_data = $section_data[ 'sidebar_fields' ]; |
|
| 56 | + foreach ( $sidebar_field_data as $field ) { |
|
| 57 | + if ( $field[ 'type' ] == 'custom' ) { |
|
| 58 | 58 | // execute the custom callback |
| 59 | - $field['callback'](); |
|
| 59 | + $field[ 'callback' ](); |
|
| 60 | 60 | } else { |
| 61 | 61 | // include our field files |
| 62 | - include( YIKES_MC_PATH . 'admin/partials/helpers/fields/yikes-mailchimp-' . $field['type'] . '-field.php' ); |
|
| 62 | + include( YIKES_MC_PATH . 'admin/partials/helpers/fields/yikes-mailchimp-' . $field[ 'type' ] . '-field.php' ); |
|
| 63 | 63 | } |
| 64 | 64 | } |
| 65 | 65 | ?> |
@@ -14,7 +14,7 @@ discard block |
||
| 14 | 14 | // Widget name will appear in UI |
| 15 | 15 | __( 'Easy MailChimp Forms', 'yikes-inc-easy-mailchimp-extender' ), |
| 16 | 16 | // Widget description |
| 17 | - array( 'description' => __( 'MailChimp opt-in widget for your sidebar.', 'yikes-inc-easy-mailchimp-extender' ), ) |
|
| 17 | + array( 'description' => __( 'MailChimp opt-in widget for your sidebar.', 'yikes-inc-easy-mailchimp-extender' ),) |
|
| 18 | 18 | ); |
| 19 | 19 | |
| 20 | 20 | } |
@@ -27,41 +27,41 @@ discard block |
||
| 27 | 27 | global $wpdb; |
| 28 | 28 | $form_results = $wpdb->get_results( 'SELECT * FROM ' . $wpdb->prefix . 'yikes_easy_mc_forms LIMIT 1', ARRAY_A ); |
| 29 | 29 | |
| 30 | - $title = isset( $instance['title'] ) ? apply_filters( 'widget_title', $instance['title'] ) : __( 'MailChimp Signup Form', 'yikes-inc-easy-mailchimp-extender' ); |
|
| 31 | - $form_id = isset( $instance['form_id'] ) ? $instance['form_id'] : $form_results[0]['id']; |
|
| 32 | - $form_description = isset( $instance['form_description'] ) ? $instance['form_description'] : ''; |
|
| 33 | - $submit_button_text = isset( $instance['submit_text'] ) ? $instance['submit_text'] : __( 'Submit' , 'yikes-inc-easy-mailchimp-extender' ); |
|
| 30 | + $title = isset( $instance[ 'title' ] ) ? apply_filters( 'widget_title', $instance[ 'title' ] ) : __( 'MailChimp Signup Form', 'yikes-inc-easy-mailchimp-extender' ); |
|
| 31 | + $form_id = isset( $instance[ 'form_id' ] ) ? $instance[ 'form_id' ] : $form_results[ 0 ][ 'id' ]; |
|
| 32 | + $form_description = isset( $instance[ 'form_description' ] ) ? $instance[ 'form_description' ] : ''; |
|
| 33 | + $submit_button_text = isset( $instance[ 'submit_text' ] ) ? $instance[ 'submit_text' ] : __( 'Submit', 'yikes-inc-easy-mailchimp-extender' ); |
|
| 34 | 34 | |
| 35 | 35 | $shortcode_attributes = array(); |
| 36 | 36 | // Build our array based on settings chosen |
| 37 | - $sortcode_attributes[] = 'form="' . $form_id .'"'; |
|
| 37 | + $sortcode_attributes[ ] = 'form="' . $form_id . '"'; |
|
| 38 | 38 | // form description |
| 39 | - if( !empty( $form_description ) ) { |
|
| 40 | - $sortcode_attributes[] = 'description="1"'; |
|
| 39 | + if ( ! empty( $form_description ) ) { |
|
| 40 | + $sortcode_attributes[ ] = 'description="1"'; |
|
| 41 | 41 | } |
| 42 | 42 | // submit button text |
| 43 | - $sortcode_attributes[] = 'submit="' . $submit_button_text .'"'; |
|
| 43 | + $sortcode_attributes[ ] = 'submit="' . $submit_button_text . '"'; |
|
| 44 | 44 | |
| 45 | 45 | // before and after widget arguments are defined by themes |
| 46 | - echo $args['before_widget']; |
|
| 46 | + echo $args[ 'before_widget' ]; |
|
| 47 | 47 | |
| 48 | 48 | if ( ! empty( $title ) ) |
| 49 | - echo $args['before_title'] . $title . $args['after_title']; |
|
| 49 | + echo $args[ 'before_title' ] . $title . $args[ 'after_title' ]; |
|
| 50 | 50 | |
| 51 | 51 | // Custom action hooks to place content in the widget before the form |
| 52 | 52 | // See FAQ for examples on usage |
| 53 | - do_action( 'yikes-mailchimp-before-form-'.$form_id ); |
|
| 53 | + do_action( 'yikes-mailchimp-before-form-' . $form_id ); |
|
| 54 | 54 | do_action( 'yikes-mailchimp-before-form' ); |
| 55 | 55 | |
| 56 | 56 | // This is where you run the code and display the output |
| 57 | - echo do_shortcode( '[yikes-mailchimp ' . implode( ' ' , $sortcode_attributes ) . ']' ); |
|
| 57 | + echo do_shortcode( '[yikes-mailchimp ' . implode( ' ', $sortcode_attributes ) . ']' ); |
|
| 58 | 58 | |
| 59 | 59 | // Custom action hooks to place content in the widget after the form |
| 60 | 60 | // See FAQ for examples on usage |
| 61 | - do_action( 'yikes-mailchimp-after-form-'.$form_id ); |
|
| 61 | + do_action( 'yikes-mailchimp-after-form-' . $form_id ); |
|
| 62 | 62 | do_action( 'yikes-mailchimp-after-form' ); |
| 63 | 63 | |
| 64 | - echo $args['after_widget']; |
|
| 64 | + echo $args[ 'after_widget' ]; |
|
| 65 | 65 | |
| 66 | 66 | } |
| 67 | 67 | |
@@ -72,10 +72,10 @@ discard block |
||
| 72 | 72 | global $wpdb; |
| 73 | 73 | $form_results = $wpdb->get_results( 'SELECT * FROM ' . $wpdb->prefix . 'yikes_easy_mc_forms', ARRAY_A ); |
| 74 | 74 | |
| 75 | - if( empty( $form_results ) ) { |
|
| 75 | + if ( empty( $form_results ) ) { |
|
| 76 | 76 | ?> |
| 77 | 77 | <section class="no-forms-widget"> |
| 78 | - <strong><span class="dashicons dashicons-no-alt no-forms-found-icon"></span><?php echo sprintf( __( 'No forms found. It looks like you need to <a href="%s" title="%s">%s</a>.', 'yikes-inc-easy-mailchimp-extender' ), esc_url_raw( admin_url( 'admin.php?page=yikes-inc-easy-mailchimp' ) ), __( 'Create a form' , 'yikes-inc-easy-mailchimp-extender' ), __( 'create a form' , 'yikes-inc-easy-mailchimp-extender' ) ); ?></strong> |
|
| 78 | + <strong><span class="dashicons dashicons-no-alt no-forms-found-icon"></span><?php echo sprintf( __( 'No forms found. It looks like you need to <a href="%s" title="%s">%s</a>.', 'yikes-inc-easy-mailchimp-extender' ), esc_url_raw( admin_url( 'admin.php?page=yikes-inc-easy-mailchimp' ) ), __( 'Create a form', 'yikes-inc-easy-mailchimp-extender' ), __( 'create a form', 'yikes-inc-easy-mailchimp-extender' ) ); ?></strong> |
|
| 79 | 79 | </section> |
| 80 | 80 | <?php |
| 81 | 81 | return; |
@@ -102,9 +102,9 @@ discard block |
||
| 102 | 102 | $submit_text = __( 'Submit', 'yikes-inc-easy-mailchimp-extender' ); |
| 103 | 103 | } |
| 104 | 104 | |
| 105 | - if( get_option( 'yikes-mc-api-validation' , 'invalid_api_key' ) == 'invalid_api_key' ) { |
|
| 105 | + if ( get_option( 'yikes-mc-api-validation', 'invalid_api_key' ) == 'invalid_api_key' ) { |
|
| 106 | 106 | ?> |
| 107 | - <p class="enter-valid-api-error-widget"><strong><?php _e( 'Please enter a valid MailChimp API key to connect your site to MailChimp.' , 'yikes-inc-easy-mailchimp-extender' ); ?></strong></p> |
|
| 107 | + <p class="enter-valid-api-error-widget"><strong><?php _e( 'Please enter a valid MailChimp API key to connect your site to MailChimp.', 'yikes-inc-easy-mailchimp-extender' ); ?></strong></p> |
|
| 108 | 108 | <?php |
| 109 | 109 | return; |
| 110 | 110 | } |
@@ -121,9 +121,9 @@ discard block |
||
| 121 | 121 | <select id="<?php echo $this->get_field_id( 'form_id' ); ?>" name="<?php echo $this->get_field_name( 'form_id' ); ?>" class="widefat"> |
| 122 | 122 | <?php |
| 123 | 123 | // build our array |
| 124 | - foreach( $form_results as $form ) { |
|
| 124 | + foreach ( $form_results as $form ) { |
|
| 125 | 125 | ?> |
| 126 | - <option <?php selected( $selected_form , $form['id'] ); ?> name="<?php echo $this->get_field_name( 'form_id' ); ?>" value="<?php echo $form['id']; ?>"><?php echo stripslashes( $form['form_name'] ); ?></option> |
|
| 126 | + <option <?php selected( $selected_form, $form[ 'id' ] ); ?> name="<?php echo $this->get_field_name( 'form_id' ); ?>" value="<?php echo $form[ 'id' ]; ?>"><?php echo stripslashes( $form[ 'form_name' ] ); ?></option> |
|
| 127 | 127 | <?php |
| 128 | 128 | } |
| 129 | 129 | ?> |
@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | |
| 133 | 133 | <p> |
| 134 | 134 | <label for="<?php echo $this->get_field_id( 'form_description' ); ?>"><?php _e( 'Display Form Description:' ); ?></label> |
| 135 | - <input class="widefat" id="<?php echo $this->get_field_id( 'form_description' ); ?>" name="<?php echo $this->get_field_name( 'form_description' ); ?>" type="checkbox" value="1" <?php if( isset( $instance['form_description'] ) ) { checked( $instance['form_description'] , 1 ); } ?> /> |
|
| 135 | + <input class="widefat" id="<?php echo $this->get_field_id( 'form_description' ); ?>" name="<?php echo $this->get_field_name( 'form_description' ); ?>" type="checkbox" value="1" <?php if ( isset( $instance[ 'form_description' ] ) ) { checked( $instance[ 'form_description' ], 1 ); } ?> /> |
|
| 136 | 136 | </p> |
| 137 | 137 | |
| 138 | 138 | <p> |
@@ -145,10 +145,10 @@ discard block |
||
| 145 | 145 | // Updating widget replacing old instances with new |
| 146 | 146 | public function update( $new_instance, $old_instance ) { |
| 147 | 147 | $instance = array(); |
| 148 | - $instance['title'] = ( ! empty( $new_instance['title'] ) ) ? strip_tags( $new_instance['title'] ) : ''; |
|
| 149 | - $instance['form_id'] = $new_instance['form_id']; |
|
| 150 | - $instance['form_description'] = isset( $new_instance['form_description'] ) ? '1' : ''; |
|
| 151 | - $instance['submit_text'] = ( ! empty( $new_instance['submit_text'] ) ) ? strip_tags( $new_instance['submit_text'] ) : 'Submit'; |
|
| 148 | + $instance[ 'title' ] = ( ! empty( $new_instance[ 'title' ] ) ) ? strip_tags( $new_instance[ 'title' ] ) : ''; |
|
| 149 | + $instance[ 'form_id' ] = $new_instance[ 'form_id' ]; |
|
| 150 | + $instance[ 'form_description' ] = isset( $new_instance[ 'form_description' ] ) ? '1' : ''; |
|
| 151 | + $instance[ 'submit_text' ] = ( ! empty( $new_instance[ 'submit_text' ] ) ) ? strip_tags( $new_instance[ 'submit_text' ] ) : 'Submit'; |
|
| 152 | 152 | return $instance; |
| 153 | 153 | } |
| 154 | 154 | |
@@ -1,9 +1,9 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | - if( isset( $_REQUEST['list-id'] ) ) { |
|
| 3 | - $list_id = sanitize_key( $_REQUEST['list-id'] ); |
|
| 4 | - $api_key = trim( get_option( 'yikes-mc-api-key' , '' ) ); |
|
| 2 | + if ( isset( $_REQUEST[ 'list-id' ] ) ) { |
|
| 3 | + $list_id = sanitize_key( $_REQUEST[ 'list-id' ] ); |
|
| 4 | + $api_key = trim( get_option( 'yikes-mc-api-key', '' ) ); |
|
| 5 | 5 | $dash_position = strpos( $api_key, '-' ); |
| 6 | - if( $dash_position !== false ) { |
|
| 6 | + if ( $dash_position !== false ) { |
|
| 7 | 7 | $api_endpoint = 'https://' . substr( $api_key, $dash_position + 1 ) . '.api.mailchimp.com/2.0/lists/list.json'; |
| 8 | 8 | } |
| 9 | 9 | $list_data = wp_remote_post( $api_endpoint, array( |
@@ -15,40 +15,40 @@ discard block |
||
| 15 | 15 | 'sslverify' => apply_filters( 'yikes-mailchimp-sslverify', true ), |
| 16 | 16 | ) ); |
| 17 | 17 | $list_data = json_decode( wp_remote_retrieve_body( $list_data ), true ); |
| 18 | - if( isset( $list_data['error'] ) ) { |
|
| 19 | - if( WP_DEBUG || get_option( 'yikes-mailchimp-debug-status' , '' ) == '1' ) { |
|
| 18 | + if ( isset( $list_data[ 'error' ] ) ) { |
|
| 19 | + if ( WP_DEBUG || get_option( 'yikes-mailchimp-debug-status', '' ) == '1' ) { |
|
| 20 | 20 | require_once YIKES_MC_PATH . 'includes/error_log/class-yikes-inc-easy-mailchimp-error-logging.php'; |
| 21 | 21 | $error_logging = new Yikes_Inc_Easy_Mailchimp_Error_Logging(); |
| 22 | - $error_logging->yikes_easy_mailchimp_write_to_error_log( $list_data['error'], __( "Get Account Lists" , 'yikes-inc-easy-mailchimp-extender' ), "View Lists Page" ); |
|
| 22 | + $error_logging->yikes_easy_mailchimp_write_to_error_log( $list_data[ 'error' ], __( "Get Account Lists", 'yikes-inc-easy-mailchimp-extender' ), "View Lists Page" ); |
|
| 23 | 23 | } |
| 24 | 24 | } |
| 25 | 25 | // reset our data so we can easily use it |
| 26 | - $list_data = $list_data['data'][0]; |
|
| 26 | + $list_data = $list_data[ 'data' ][ 0 ]; |
|
| 27 | 27 | |
| 28 | - if( $dash_position !== false ) { |
|
| 28 | + if ( $dash_position !== false ) { |
|
| 29 | 29 | $api_endpoint = 'https://' . substr( $api_key, $dash_position + 1 ) . '.api.mailchimp.com/2.0/lists/merge-vars.json'; |
| 30 | 30 | } |
| 31 | 31 | $merge_variables = wp_remote_post( $api_endpoint, array( |
| 32 | 32 | 'body' => array( |
| 33 | 33 | 'apikey' => $api_key, |
| 34 | - 'id' => array( $list_id ) , |
|
| 34 | + 'id' => array( $list_id ), |
|
| 35 | 35 | ), |
| 36 | 36 | 'timeout' => 10, |
| 37 | 37 | 'sslverify' => apply_filters( 'yikes-mailchimp-sslverify', true ), |
| 38 | 38 | ) ); |
| 39 | 39 | $merge_variables = json_decode( wp_remote_retrieve_body( $merge_variables ), true ); |
| 40 | - if( isset( $merge_variables['error'] ) ) { |
|
| 41 | - if( WP_DEBUG || get_option( 'yikes-mailchimp-debug-status' , '' ) == '1' ) { |
|
| 40 | + if ( isset( $merge_variables[ 'error' ] ) ) { |
|
| 41 | + if ( WP_DEBUG || get_option( 'yikes-mailchimp-debug-status', '' ) == '1' ) { |
|
| 42 | 42 | require_once YIKES_MC_PATH . 'includes/error_log/class-yikes-inc-easy-mailchimp-error-logging.php'; |
| 43 | 43 | $error_logging = new Yikes_Inc_Easy_Mailchimp_Error_Logging(); |
| 44 | - $error_logging->yikes_easy_mailchimp_write_to_error_log( $merge_variables['error'], __( "Get Merge Variables" , 'yikes-inc-easy-mailchimp-extender' ), "View Lists Page" ); |
|
| 44 | + $error_logging->yikes_easy_mailchimp_write_to_error_log( $merge_variables[ 'error' ], __( "Get Merge Variables", 'yikes-inc-easy-mailchimp-extender' ), "View Lists Page" ); |
|
| 45 | 45 | } |
| 46 | 46 | } |
| 47 | 47 | // re-store our data |
| 48 | - $merge_variables = $merge_variables['data'][0]['merge_vars']; |
|
| 48 | + $merge_variables = $merge_variables[ 'data' ][ 0 ][ 'merge_vars' ]; |
|
| 49 | 49 | |
| 50 | 50 | // get the interest group data |
| 51 | - if( $dash_position !== false ) { |
|
| 51 | + if ( $dash_position !== false ) { |
|
| 52 | 52 | $api_endpoint = 'https://' . substr( $api_key, $dash_position + 1 ) . '.api.mailchimp.com/2.0/lists/interest-groupings.json'; |
| 53 | 53 | } |
| 54 | 54 | $interest_groupings = wp_remote_post( $api_endpoint, array( |
@@ -62,20 +62,20 @@ discard block |
||
| 62 | 62 | ) ); |
| 63 | 63 | $interest_groupings = json_decode( wp_remote_retrieve_body( $interest_groupings ), true ); |
| 64 | 64 | |
| 65 | - if( isset( $interest_groupings['error'] ) ) { |
|
| 66 | - if( WP_DEBUG || get_option( 'yikes-mailchimp-debug-status' , '' ) == '1' ) { |
|
| 65 | + if ( isset( $interest_groupings[ 'error' ] ) ) { |
|
| 66 | + if ( WP_DEBUG || get_option( 'yikes-mailchimp-debug-status', '' ) == '1' ) { |
|
| 67 | 67 | require_once YIKES_MC_PATH . 'includes/error_log/class-yikes-inc-easy-mailchimp-error-logging.php'; |
| 68 | 68 | $error_logging = new Yikes_Inc_Easy_Mailchimp_Error_Logging(); |
| 69 | - $error_logging->yikes_easy_mailchimp_write_to_error_log( $interest_groupings['error'], __( "Get Interest Groups" , 'yikes-inc-easy-mailchimp-extender' ), "View Lists Page" ); |
|
| 69 | + $error_logging->yikes_easy_mailchimp_write_to_error_log( $interest_groupings[ 'error' ], __( "Get Interest Groups", 'yikes-inc-easy-mailchimp-extender' ), "View Lists Page" ); |
|
| 70 | 70 | } |
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | $no_interest_groupings = '<p class="description">' . __( 'Interest groups are not enabled for this list.', 'yikes-inc-easy-mailchimp-extender' ) . '</p>'; |
| 74 | 74 | |
| 75 | 75 | |
| 76 | - $no_segments = __( 'No segments set up for this list.' , 'yikes-inc-easy-mailchimp-extender' ); |
|
| 76 | + $no_segments = __( 'No segments set up for this list.', 'yikes-inc-easy-mailchimp-extender' ); |
|
| 77 | 77 | // get the segment data |
| 78 | - if( $dash_position !== false ) { |
|
| 78 | + if ( $dash_position !== false ) { |
|
| 79 | 79 | $api_endpoint = 'https://' . substr( $api_key, $dash_position + 1 ) . '.api.mailchimp.com/2.0/lists/segments.json'; |
| 80 | 80 | } |
| 81 | 81 | $segments = wp_remote_post( $api_endpoint, array( |
@@ -90,14 +90,14 @@ discard block |
||
| 90 | 90 | |
| 91 | 91 | |
| 92 | 92 | // setup pagination variables |
| 93 | - $paged = isset( $_REQUEST['paged'] ) ? $_REQUEST['paged'] : '0'; |
|
| 93 | + $paged = isset( $_REQUEST[ 'paged' ] ) ? $_REQUEST[ 'paged' ] : '0'; |
|
| 94 | 94 | |
| 95 | - $limit = apply_filters( 'yikes_admin_list_subscriber_limit' , '20' ); |
|
| 95 | + $limit = apply_filters( 'yikes_admin_list_subscriber_limit', '20' ); |
|
| 96 | 96 | |
| 97 | - $sort_dir = isset( $_REQUEST['sort'] ) ? $_REQUEST['sort'] : 'DESC'; |
|
| 98 | - $column = isset( $_REQUEST['column'] ) ? $_REQUEST['column'] : 'optin_time'; |
|
| 97 | + $sort_dir = isset( $_REQUEST[ 'sort' ] ) ? $_REQUEST[ 'sort' ] : 'DESC'; |
|
| 98 | + $column = isset( $_REQUEST[ 'column' ] ) ? $_REQUEST[ 'column' ] : 'optin_time'; |
|
| 99 | 99 | |
| 100 | - if( $sort_dir == 'DESC' ) { |
|
| 100 | + if ( $sort_dir == 'DESC' ) { |
|
| 101 | 101 | $opposite_sort_dir = 'ASC'; |
| 102 | 102 | $icon = '<span class="dashicons dashicons-arrow-down"></span>'; |
| 103 | 103 | } else { |
@@ -105,12 +105,12 @@ discard block |
||
| 105 | 105 | $icon = '<span class="dashicons dashicons-arrow-up"></span>'; |
| 106 | 106 | } |
| 107 | 107 | |
| 108 | - if( !isset( $_REQUEST['sort'] ) ) { |
|
| 108 | + if ( ! isset( $_REQUEST[ 'sort' ] ) ) { |
|
| 109 | 109 | $icon = ''; |
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | // get all subscribed members |
| 113 | - if( $dash_position !== false ) { |
|
| 113 | + if ( $dash_position !== false ) { |
|
| 114 | 114 | $api_endpoint = 'https://' . substr( $api_key, $dash_position + 1 ) . '.api.mailchimp.com/2.0/lists/members.json'; |
| 115 | 115 | } |
| 116 | 116 | $subscribers_list = wp_remote_post( $api_endpoint, array( |
@@ -128,16 +128,16 @@ discard block |
||
| 128 | 128 | 'sslverify' => apply_filters( 'yikes-mailchimp-sslverify', true ), |
| 129 | 129 | ) ); |
| 130 | 130 | $subscribers_list = json_decode( wp_remote_retrieve_body( $subscribers_list ), true ); |
| 131 | - if( isset( $subscribers_list['error'] ) ) { |
|
| 132 | - if( WP_DEBUG || get_option( 'yikes-mailchimp-debug-status' , '' ) == '1' ) { |
|
| 131 | + if ( isset( $subscribers_list[ 'error' ] ) ) { |
|
| 132 | + if ( WP_DEBUG || get_option( 'yikes-mailchimp-debug-status', '' ) == '1' ) { |
|
| 133 | 133 | require_once YIKES_MC_PATH . 'includes/error_log/class-yikes-inc-easy-mailchimp-error-logging.php'; |
| 134 | 134 | $error_logging = new Yikes_Inc_Easy_Mailchimp_Error_Logging(); |
| 135 | - $error_logging->yikes_easy_mailchimp_write_to_error_log( $subscribers_list['error'], __( "Get Subscriber Count" , 'yikes-inc-easy-mailchimp-extender' ), "View Lists Page" ); |
|
| 135 | + $error_logging->yikes_easy_mailchimp_write_to_error_log( $subscribers_list[ 'error' ], __( "Get Subscriber Count", 'yikes-inc-easy-mailchimp-extender' ), "View Lists Page" ); |
|
| 136 | 136 | } |
| 137 | 137 | } |
| 138 | 138 | |
| 139 | - $total_pages = ceil( $subscribers_list['total'] / $limit ); |
|
| 140 | - if( $total_pages == 0 ) { |
|
| 139 | + $total_pages = ceil( $subscribers_list[ 'total' ] / $limit ); |
|
| 140 | + if ( $total_pages == 0 ) { |
|
| 141 | 141 | $total_pages = '1'; |
| 142 | 142 | } |
| 143 | 143 | |
@@ -146,25 +146,25 @@ discard block |
||
| 146 | 146 | ?> |
| 147 | 147 | <div class="wrap"> |
| 148 | 148 | <!-- Freddie Logo --> |
| 149 | - <img src="<?php echo YIKES_MC_URL . 'includes/images/MailChimp_Assets/Freddie_60px.png'; ?>" alt="<?php __( 'Freddie - MailChimp Mascot' , 'yikes-inc-easy-mailchimp-extender' ); ?>" class="yikes-mc-freddie-logo" /> |
|
| 149 | + <img src="<?php echo YIKES_MC_URL . 'includes/images/MailChimp_Assets/Freddie_60px.png'; ?>" alt="<?php __( 'Freddie - MailChimp Mascot', 'yikes-inc-easy-mailchimp-extender' ); ?>" class="yikes-mc-freddie-logo" /> |
|
| 150 | 150 | |
| 151 | - <h1>YIKES Easy Forms for MailChimp | <?php echo $list_data['name']; ?></h1> |
|
| 151 | + <h1>YIKES Easy Forms for MailChimp | <?php echo $list_data[ 'name' ]; ?></h1> |
|
| 152 | 152 | |
| 153 | 153 | <!-- Settings Page Description --> |
| 154 | - <p class="yikes-easy-mc-about-text about-text"><?php _e( 'View all subscribers below. View additional subscriber info, or add additional fields to this list.' , 'yikes-inc-easy-mailchimp-extender' ); ?></p> |
|
| 155 | - <!-- <p class="add-new-subscriber-button"><a href="#" onclick="jQuery(this).parent().next().slideToggle();" class="add-new-h2"><?php _e( 'New Subscriber' , 'yikes-inc-easy-mailchimp-extender' ); ?></a></p> --> |
|
| 154 | + <p class="yikes-easy-mc-about-text about-text"><?php _e( 'View all subscribers below. View additional subscriber info, or add additional fields to this list.', 'yikes-inc-easy-mailchimp-extender' ); ?></p> |
|
| 155 | + <!-- <p class="add-new-subscriber-button"><a href="#" onclick="jQuery(this).parent().next().slideToggle();" class="add-new-h2"><?php _e( 'New Subscriber', 'yikes-inc-easy-mailchimp-extender' ); ?></a></p> --> |
|
| 156 | 156 | |
| 157 | 157 | <?php |
| 158 | 158 | /* Display our admin notices here */ |
| 159 | 159 | // Unsubscribe user confirmation message |
| 160 | - if( isset( $_REQUEST['user-unsubscribed'] ) && $_REQUEST['user-unsubscribed'] == 'true' ) { |
|
| 160 | + if ( isset( $_REQUEST[ 'user-unsubscribed' ] ) && $_REQUEST[ 'user-unsubscribed' ] == 'true' ) { |
|
| 161 | 161 | ?> |
| 162 | 162 | <div class="updated manage-form-admin-notice"> |
| 163 | 163 | <p><?php _e( 'User successfully unsubscribed.', 'yikes-inc-easy-mailchimp-extender' ); ?></p> |
| 164 | 164 | </div> |
| 165 | 165 | <?php |
| 166 | 166 | } |
| 167 | - if( isset( $_REQUEST['user-unsubscribed'] ) && $_REQUEST['user-unsubscribed'] == 'false' ) { |
|
| 167 | + if ( isset( $_REQUEST[ 'user-unsubscribed' ] ) && $_REQUEST[ 'user-unsubscribed' ] == 'false' ) { |
|
| 168 | 168 | ?> |
| 169 | 169 | <div class="error manage-form-admin-notice"> |
| 170 | 170 | <p><?php _e( "We've encountered an error trying to remove the subscriber. Please try again. If the error persists please get in contact with the YIKES Inc. support staff.", 'yikes-inc-easy-mailchimp-extender' ); ?></p> |
@@ -174,9 +174,9 @@ discard block |
||
| 174 | 174 | ?> |
| 175 | 175 | |
| 176 | 176 | <section class="add-new-subscriber-form-container"> |
| 177 | - <h4><?php _e( 'Add New Subscriber' , 'yikes-inc-easy-mailchimp-extender' ); ?></h4> |
|
| 177 | + <h4><?php _e( 'Add New Subscriber', 'yikes-inc-easy-mailchimp-extender' ); ?></h4> |
|
| 178 | 178 | <form id="add-new-subcscriber"> |
| 179 | - <input type="text" class="regular-text" placeholder="<?php _e( 'User Email Address' , 'yikes-inc-easy-mailchimp-extender' ); ?>" /></p> |
|
| 179 | + <input type="text" class="regular-text" placeholder="<?php _e( 'User Email Address', 'yikes-inc-easy-mailchimp-extender' ); ?>" /></p> |
|
| 180 | 180 | <p><?php echo submit_button( 'Add Subscriber' ); ?></p> |
| 181 | 181 | </form> |
| 182 | 182 | </section> |
@@ -198,8 +198,8 @@ discard block |
||
| 198 | 198 | <!-- TABLE HEAD --> |
| 199 | 199 | <thead> |
| 200 | 200 | <tr> |
| 201 | - <th id="user-email columnname" class="manage-column column-columnname" scope="col"><a id="user-email-sort" href="<?php echo esc_url_raw( add_query_arg( array( 'column' => 'email' , 'sort' => $opposite_sort_dir ) ) ); ?>"><?php _e( 'User Email' , 'yikes-inc-easy-mailchimp-extender' ); echo $icon;?></a></th> |
|
| 202 | - <th id="columnname" class="manage-column column-columnname num" scope="col"><?php _e( 'Email Client' , 'yikes-inc-easy-mailchimp-extender' ); ?></th> |
|
| 201 | + <th id="user-email columnname" class="manage-column column-columnname" scope="col"><a id="user-email-sort" href="<?php echo esc_url_raw( add_query_arg( array( 'column' => 'email', 'sort' => $opposite_sort_dir ) ) ); ?>"><?php _e( 'User Email', 'yikes-inc-easy-mailchimp-extender' ); echo $icon; ?></a></th> |
|
| 202 | + <th id="columnname" class="manage-column column-columnname num" scope="col"><?php _e( 'Email Client', 'yikes-inc-easy-mailchimp-extender' ); ?></th> |
|
| 203 | 203 | </tr> |
| 204 | 204 | </thead> |
| 205 | 205 | <!-- end header --> |
@@ -207,38 +207,38 @@ discard block |
||
| 207 | 207 | <!-- FOOTER --> |
| 208 | 208 | <tfoot> |
| 209 | 209 | <tr> |
| 210 | - <th class="manage-column column-columnname" scope="col"><?php _e( 'User Email' , 'yikes-inc-easy-mailchimp-extender' ); ?></th> |
|
| 211 | - <th class="manage-column column-columnname num" scope="col"><?php _e( 'Email Client' , 'yikes-inc-easy-mailchimp-extender' ); ?></th> |
|
| 210 | + <th class="manage-column column-columnname" scope="col"><?php _e( 'User Email', 'yikes-inc-easy-mailchimp-extender' ); ?></th> |
|
| 211 | + <th class="manage-column column-columnname num" scope="col"><?php _e( 'Email Client', 'yikes-inc-easy-mailchimp-extender' ); ?></th> |
|
| 212 | 212 | </tr> |
| 213 | 213 | </tfoot> |
| 214 | 214 | <!-- end footer --> |
| 215 | 215 | |
| 216 | 216 | <!-- TABLE BODY --> |
| 217 | 217 | <tbody> |
| 218 | - <?php if( $subscribers_list['total'] > 0 ) { |
|
| 218 | + <?php if ( $subscribers_list[ 'total' ] > 0 ) { |
|
| 219 | 219 | $i = 1; |
| 220 | - foreach( $subscribers_list['data'] as $subscriber ) { |
|
| 221 | - $user_id = $subscriber['leid']; |
|
| 220 | + foreach ( $subscribers_list[ 'data' ] as $subscriber ) { |
|
| 221 | + $user_id = $subscriber[ 'leid' ]; |
|
| 222 | 222 | // setup the email client name and icon |
| 223 | - if( !empty( $subscriber['clients'] ) ) { |
|
| 224 | - $user_email_client_name = $subscriber['clients']['name']; |
|
| 225 | - $user_email_client_icon = "<img src='" . esc_url_raw( $subscriber['clients']['icon_url'] ) . "' alt=" . $user_email_client_name . " title=" . $user_email_client_name . ">"; |
|
| 223 | + if ( ! empty( $subscriber[ 'clients' ] ) ) { |
|
| 224 | + $user_email_client_name = $subscriber[ 'clients' ][ 'name' ]; |
|
| 225 | + $user_email_client_icon = "<img src='" . esc_url_raw( $subscriber[ 'clients' ][ 'icon_url' ] ) . "' alt=" . $user_email_client_name . " title=" . $user_email_client_name . ">"; |
|
| 226 | 226 | } else { |
| 227 | 227 | $path = YIKES_MC_URL . "includes/images/na.png"; |
| 228 | - $user_email_client_icon = "<img width='35' src='" . $path . "' alt='" . __( 'not set' , 'yikes-inc-easy-mailchimp-extender' ) . "' title='" . __( 'not set' , 'yikes-inc-easy-mailchimp-extender' ) . "'>"; |
|
| 228 | + $user_email_client_icon = "<img width='35' src='" . $path . "' alt='" . __( 'not set', 'yikes-inc-easy-mailchimp-extender' ) . "' title='" . __( 'not set', 'yikes-inc-easy-mailchimp-extender' ) . "'>"; |
|
| 229 | 229 | } |
| 230 | 230 | |
| 231 | 231 | ?> |
| 232 | - <tr class="<?php if( $i % 2 == 0 ) { echo 'alternate'; } ?>"> |
|
| 232 | + <tr class="<?php if ( $i % 2 == 0 ) { echo 'alternate'; } ?>"> |
|
| 233 | 233 | <td class="column-columnname"> |
| 234 | - <a class="user-email row-title" href="mailto:<?php echo sanitize_email( $subscriber['email'] ); ?>"> |
|
| 235 | - <?php echo sanitize_email( $subscriber['email'] ); ?> |
|
| 234 | + <a class="user-email row-title" href="mailto:<?php echo sanitize_email( $subscriber[ 'email' ] ); ?>"> |
|
| 235 | + <?php echo sanitize_email( $subscriber[ 'email' ] ); ?> |
|
| 236 | 236 | </a> |
| 237 | 237 | <div class="row-actions"> |
| 238 | - <?php $view_user_info_url = esc_url_raw( add_query_arg( array( 'mailchimp-list' => $list_id , 'email-id' => $user_id ), admin_url() . 'admin.php?page=yikes-mailchimp-view-user' ) ); ?> |
|
| 239 | - <span><a href="<?php echo $view_user_info_url; ?>"><?php _e( "View Info." , 'yikes-inc-easy-mailchimp-extender' ); ?></a> |</span> |
|
| 240 | - <?php $url = esc_url_raw( add_query_arg( array( 'action' => 'yikes-easy-mc-unsubscribe-user', 'mailchimp-list' => $list_id , 'nonce' => wp_create_nonce( 'unsubscribe-user-'.$user_id ), 'email_id' => $user_id ) ) ); ?> |
|
| 241 | - <span><a href="<?php echo $url; ?>" onclick="return confirm('<?php printf( __( "Are you sure you want to unsubscribe %s from this mailing list?" , 'yikes-inc-easy-mailchimp-extender' ), sanitize_email( $subscriber['email'] ) ); ?>');" class="yikes-delete-subscriber"><?php _e( "Unsubscribe" , 'yikes-inc-easy-mailchimp-extender' ); ?></a> |
|
| 238 | + <?php $view_user_info_url = esc_url_raw( add_query_arg( array( 'mailchimp-list' => $list_id, 'email-id' => $user_id ), admin_url() . 'admin.php?page=yikes-mailchimp-view-user' ) ); ?> |
|
| 239 | + <span><a href="<?php echo $view_user_info_url; ?>"><?php _e( "View Info.", 'yikes-inc-easy-mailchimp-extender' ); ?></a> |</span> |
|
| 240 | + <?php $url = esc_url_raw( add_query_arg( array( 'action' => 'yikes-easy-mc-unsubscribe-user', 'mailchimp-list' => $list_id, 'nonce' => wp_create_nonce( 'unsubscribe-user-' . $user_id ), 'email_id' => $user_id ) ) ); ?> |
|
| 241 | + <span><a href="<?php echo $url; ?>" onclick="return confirm('<?php printf( __( "Are you sure you want to unsubscribe %s from this mailing list?", 'yikes-inc-easy-mailchimp-extender' ), sanitize_email( $subscriber[ 'email' ] ) ); ?>');" class="yikes-delete-subscriber"><?php _e( "Unsubscribe", 'yikes-inc-easy-mailchimp-extender' ); ?></a> |
|
| 242 | 242 | </div> |
| 243 | 243 | </td> |
| 244 | 244 | <td class="column-columnname num"><?php echo $user_email_client_icon; ?></td> |
@@ -248,7 +248,7 @@ discard block |
||
| 248 | 248 | } |
| 249 | 249 | } else { ?> |
| 250 | 250 | <tr class="no-items"> |
| 251 | - <td class="colspanchange no-current-subscriber-notice" colspan="2"><em><?php _e( 'No one is currently subscribed to this list.' , 'yikes-inc-easy-mailchimp-extender' ); ?></em></td> |
|
| 251 | + <td class="colspanchange no-current-subscriber-notice" colspan="2"><em><?php _e( 'No one is currently subscribed to this list.', 'yikes-inc-easy-mailchimp-extender' ); ?></em></td> |
|
| 252 | 252 | </tr> |
| 253 | 253 | <?php } ?> |
| 254 | 254 | </tbody> |
@@ -260,11 +260,11 @@ discard block |
||
| 260 | 260 | <!-- pagination --> |
| 261 | 261 | <div class="tablenav"> |
| 262 | 262 | <div class="tablenav-pages"> |
| 263 | - <a class='first-page <?php if( $paged == 0 ) { echo 'disabled'; } ?>' title='<?php _e( "Go to the first page" , 'yikes-inc-easy-mailchimp-extender' ); ?>' href='<?php echo esc_url_raw( add_query_arg( array( "paged" => 0 ) ) ); ?>'>«</a> |
|
| 264 | - <a class='prev-page <?php if( $paged == 0 ) { echo 'disabled'; } ?>' title='<?php _e( "Go to the previous page" , 'yikes-inc-easy-mailchimp-extender' ); ?>' href='<?php echo esc_url_raw( add_query_arg( array( "paged" => intval( $paged - 1 ) ) ) ); ?>'>‹</a> |
|
| 265 | - <span class="paging-input"><input class='current-page' title='<?php _e( "Current page" , 'yikes-inc-easy-mailchimp-extender' ); ?>' type='text' name='paged' value='<?php if( $paged == 0 ) { echo '1'; } else { echo intval( $paged + 1 ); } ?>' size='1' /> <?php _e( 'of', 'yikes-inc-easy-mailchimp-extender' ); ?> <span class='total-pages'><?php echo $total_pages; ?></span></span> |
|
| 266 | - <a class='next-page <?php if( $paged == intval( $total_pages - 1 ) ) { echo 'disabled'; } ?>' title='<?php _e( "Go to the next page" , 'yikes-inc-easy-mailchimp-extender' ); ?>' href='<?php echo esc_url_raw( add_query_arg( array( "paged" => intval( $paged + 1 ) ) ) ); ?>'>›</a> |
|
| 267 | - <a class='last-page <?php if( $paged == intval( $total_pages - 1 ) ) { echo 'disabled'; } ?>' title='<?php _e( "Go to the last page" , 'yikes-inc-easy-mailchimp-extender' ); ?>' href='<?php echo esc_url_raw( add_query_arg( array( "paged" => intval( $total_pages - 1 ) ) ) ); ?>'>»</a> |
|
| 263 | + <a class='first-page <?php if ( $paged == 0 ) { echo 'disabled'; } ?>' title='<?php _e( "Go to the first page", 'yikes-inc-easy-mailchimp-extender' ); ?>' href='<?php echo esc_url_raw( add_query_arg( array( "paged" => 0 ) ) ); ?>'>«</a> |
|
| 264 | + <a class='prev-page <?php if ( $paged == 0 ) { echo 'disabled'; } ?>' title='<?php _e( "Go to the previous page", 'yikes-inc-easy-mailchimp-extender' ); ?>' href='<?php echo esc_url_raw( add_query_arg( array( "paged" => intval( $paged - 1 ) ) ) ); ?>'>‹</a> |
|
| 265 | + <span class="paging-input"><input class='current-page' title='<?php _e( "Current page", 'yikes-inc-easy-mailchimp-extender' ); ?>' type='text' name='paged' value='<?php if ( $paged == 0 ) { echo '1'; } else { echo intval( $paged + 1 ); } ?>' size='1' /> <?php _e( 'of', 'yikes-inc-easy-mailchimp-extender' ); ?> <span class='total-pages'><?php echo $total_pages; ?></span></span> |
|
| 266 | + <a class='next-page <?php if ( $paged == intval( $total_pages - 1 ) ) { echo 'disabled'; } ?>' title='<?php _e( "Go to the next page", 'yikes-inc-easy-mailchimp-extender' ); ?>' href='<?php echo esc_url_raw( add_query_arg( array( "paged" => intval( $paged + 1 ) ) ) ); ?>'>›</a> |
|
| 267 | + <a class='last-page <?php if ( $paged == intval( $total_pages - 1 ) ) { echo 'disabled'; } ?>' title='<?php _e( "Go to the last page", 'yikes-inc-easy-mailchimp-extender' ); ?>' href='<?php echo esc_url_raw( add_query_arg( array( "paged" => intval( $total_pages - 1 ) ) ) ); ?>'>»</a> |
|
| 268 | 268 | </div> |
| 269 | 269 | </div> |
| 270 | 270 | |
@@ -279,21 +279,21 @@ discard block |
||
| 279 | 279 | |
| 280 | 280 | <div class="postbox yikes-easy-mc-postbox"> |
| 281 | 281 | |
| 282 | - <h3><?php _e( 'List Overview' , 'yikes-inc-easy-mailchimp-extender' ); ?></h3> |
|
| 282 | + <h3><?php _e( 'List Overview', 'yikes-inc-easy-mailchimp-extender' ); ?></h3> |
|
| 283 | 283 | |
| 284 | 284 | <?php |
| 285 | 285 | // store list rating |
| 286 | - $list_rating = $list_data['list_rating']; |
|
| 287 | - if( $list_rating > 0 ) { |
|
| 288 | - $list_rating_explosion = explode( '.' , $list_rating ); |
|
| 286 | + $list_rating = $list_data[ 'list_rating' ]; |
|
| 287 | + if ( $list_rating > 0 ) { |
|
| 288 | + $list_rating_explosion = explode( '.', $list_rating ); |
|
| 289 | 289 | $star_array = array(); |
| 290 | 290 | $x = 1; |
| 291 | - while( $list_rating_explosion[0] >= $x ) { |
|
| 292 | - $star_array[] = '<span class="dashicons dashicons-star-filled list-rating-star"></span>'; |
|
| 291 | + while ( $list_rating_explosion[ 0 ] >= $x ) { |
|
| 292 | + $star_array[ ] = '<span class="dashicons dashicons-star-filled list-rating-star"></span>'; |
|
| 293 | 293 | $x++; |
| 294 | 294 | } |
| 295 | - if( $list_rating_explosion[1] == '5' ) { |
|
| 296 | - $star_array[] = '<span class="dashicons dashicons-star-half list-rating-star"></span>'; |
|
| 295 | + if ( $list_rating_explosion[ 1 ] == '5' ) { |
|
| 296 | + $star_array[ ] = '<span class="dashicons dashicons-star-half list-rating-star"></span>'; |
|
| 297 | 297 | } |
| 298 | 298 | } else { |
| 299 | 299 | $star_array = array( 'n/a' ); |
@@ -301,40 +301,40 @@ discard block |
||
| 301 | 301 | ?> |
| 302 | 302 | <table class="form-table"> |
| 303 | 303 | <tr valign="top"> |
| 304 | - <td scope="row"><label for="tablecell"><strong><?php _e( 'List Rating' , 'yikes-inc-easy-mailchimp-extender' ); ?></strong></label></td> |
|
| 305 | - <td><?php echo implode( ' ' , $star_array ); ?></td> |
|
| 304 | + <td scope="row"><label for="tablecell"><strong><?php _e( 'List Rating', 'yikes-inc-easy-mailchimp-extender' ); ?></strong></label></td> |
|
| 305 | + <td><?php echo implode( ' ', $star_array ); ?></td> |
|
| 306 | 306 | </tr> |
| 307 | 307 | <tr valign="top"> |
| 308 | - <td scope="row"><label for="tablecell"><strong><?php _e( 'Average Subscribers' , 'yikes-inc-easy-mailchimp-extender' ); ?></strong></label></td> |
|
| 309 | - <td><?php echo $list_data['stats']['avg_sub_rate']; ?><small> / <?php _e( 'month' , 'yikes-inc-easy-mailchimp-extender' ); ?></small></td> |
|
| 308 | + <td scope="row"><label for="tablecell"><strong><?php _e( 'Average Subscribers', 'yikes-inc-easy-mailchimp-extender' ); ?></strong></label></td> |
|
| 309 | + <td><?php echo $list_data[ 'stats' ][ 'avg_sub_rate' ]; ?><small> / <?php _e( 'month', 'yikes-inc-easy-mailchimp-extender' ); ?></small></td> |
|
| 310 | 310 | </tr> |
| 311 | 311 | <tr valign="top"> |
| 312 | - <td scope="row"><label for="tablecell"><strong><?php _e( 'Subscriber Count' , 'yikes-inc-easy-mailchimp-extender' ); ?></strong></label></td> |
|
| 313 | - <td><?php echo intval( $list_data['stats']['member_count'] ); ?></td> |
|
| 312 | + <td scope="row"><label for="tablecell"><strong><?php _e( 'Subscriber Count', 'yikes-inc-easy-mailchimp-extender' ); ?></strong></label></td> |
|
| 313 | + <td><?php echo intval( $list_data[ 'stats' ][ 'member_count' ] ); ?></td> |
|
| 314 | 314 | </tr> |
| 315 | 315 | <tr valign="top"> |
| 316 | - <td scope="row"><label for="tablecell"><strong><?php _e( 'New Since Last Campaign' , 'yikes-inc-easy-mailchimp-extender' ); ?></strong></label></td> |
|
| 317 | - <td><?php echo intval( $list_data['stats']['member_count_since_send'] ); ?></td> |
|
| 316 | + <td scope="row"><label for="tablecell"><strong><?php _e( 'New Since Last Campaign', 'yikes-inc-easy-mailchimp-extender' ); ?></strong></label></td> |
|
| 317 | + <td><?php echo intval( $list_data[ 'stats' ][ 'member_count_since_send' ] ); ?></td> |
|
| 318 | 318 | </tr> |
| 319 | 319 | <tr valign="top"> |
| 320 | - <td scope="row"><label for="tablecell"><strong><?php _e( 'Created' , 'yikes-inc-easy-mailchimp-extender' ); ?></strong></label></td> |
|
| 321 | - <td><?php echo date( get_option('date_format') , strtotime( $list_data['date_created'] ) ); ?></td> |
|
| 320 | + <td scope="row"><label for="tablecell"><strong><?php _e( 'Created', 'yikes-inc-easy-mailchimp-extender' ); ?></strong></label></td> |
|
| 321 | + <td><?php echo date( get_option( 'date_format' ), strtotime( $list_data[ 'date_created' ] ) ); ?></td> |
|
| 322 | 322 | </tr> |
| 323 | 323 | <tr valign="top"> |
| 324 | - <td scope="row"><label for="tablecell"><strong><?php _e( 'List Fields' , 'yikes-inc-easy-mailchimp-extender' ); ?></strong></label></td> |
|
| 325 | - <td><?php echo intval( $list_data['stats']['merge_var_count'] + 1 ); // add 1 for our email field.. ?></td> |
|
| 324 | + <td scope="row"><label for="tablecell"><strong><?php _e( 'List Fields', 'yikes-inc-easy-mailchimp-extender' ); ?></strong></label></td> |
|
| 325 | + <td><?php echo intval( $list_data[ 'stats' ][ 'merge_var_count' ] + 1 ); // add 1 for our email field.. ?></td> |
|
| 326 | 326 | </tr> |
| 327 | 327 | <tr valign="top"> |
| 328 | - <td scope="row"><label for="tablecell"><strong><?php _e( 'Short Signup URL' , 'yikes-inc-easy-mailchimp-extender' ); ?></strong></label></td> |
|
| 329 | - <td><input type="text" class="widefat view-list-sidebar-input" value="<?php echo esc_url_raw( $list_data['subscribe_url_short'] ); ?>" readonly onclick="jQuery(this).select();"></td> |
|
| 328 | + <td scope="row"><label for="tablecell"><strong><?php _e( 'Short Signup URL', 'yikes-inc-easy-mailchimp-extender' ); ?></strong></label></td> |
|
| 329 | + <td><input type="text" class="widefat view-list-sidebar-input" value="<?php echo esc_url_raw( $list_data[ 'subscribe_url_short' ] ); ?>" readonly onclick="jQuery(this).select();"></td> |
|
| 330 | 330 | </tr> |
| 331 | 331 | <tr valign="top"> |
| 332 | - <td scope="row"><label for="tablecell"><strong><?php _e( 'Default From Email' , 'yikes-inc-easy-mailchimp-extender' ); ?></strong></label></td> |
|
| 333 | - <td><input type="text" class="widefat view-list-sidebar-input" value="<?php echo sanitize_email( $list_data['default_from_email'] ); ?>" readonly onclick="jQuery(this).select();"></td> |
|
| 332 | + <td scope="row"><label for="tablecell"><strong><?php _e( 'Default From Email', 'yikes-inc-easy-mailchimp-extender' ); ?></strong></label></td> |
|
| 333 | + <td><input type="text" class="widefat view-list-sidebar-input" value="<?php echo sanitize_email( $list_data[ 'default_from_email' ] ); ?>" readonly onclick="jQuery(this).select();"></td> |
|
| 334 | 334 | </tr> |
| 335 | 335 | <tr valign="top"> |
| 336 | - <td scope="row"><label for="tablecell"><strong><?php _e( 'Default From Name' , 'yikes-inc-easy-mailchimp-extender' ); ?></strong></label></td> |
|
| 337 | - <td><?php echo $list_data['default_from_name']; ?></td> |
|
| 336 | + <td scope="row"><label for="tablecell"><strong><?php _e( 'Default From Name', 'yikes-inc-easy-mailchimp-extender' ); ?></strong></label></td> |
|
| 337 | + <td><?php echo $list_data[ 'default_from_name' ]; ?></td> |
|
| 338 | 338 | </tr> |
| 339 | 339 | </table> |
| 340 | 340 | |
@@ -344,14 +344,14 @@ discard block |
||
| 344 | 344 | <!-- Merge Field Info --> |
| 345 | 345 | <div class="postbox yikes-easy-mc-postbox"> |
| 346 | 346 | |
| 347 | - <h3><?php _e( 'Form Fields' , 'yikes-inc-easy-mailchimp-extender' ); ?></h3> |
|
| 347 | + <h3><?php _e( 'Form Fields', 'yikes-inc-easy-mailchimp-extender' ); ?></h3> |
|
| 348 | 348 | <?php |
| 349 | - if( count( $merge_variables ) >= 1 ) { |
|
| 349 | + if ( count( $merge_variables ) >= 1 ) { |
|
| 350 | 350 | ?><ul class="merge-variable-ul"><?php |
| 351 | 351 | echo '<li class="interest-group-count">' . sprintf( _n( '%d Field', '%d Fields', intval( count( $merge_variables ) ), 'yikes-inc-easy-mailchimp-extender' ), intval( count( $merge_variables ) ) ) . '</li>'; |
| 352 | - foreach( $merge_variables as $merge_variable ) { |
|
| 352 | + foreach ( $merge_variables as $merge_variable ) { |
|
| 353 | 353 | // new action hook @since 6.0.3.8 |
| 354 | - echo '<li class="' . $merge_variable['tag'] . '"><span class="dashicons dashicons-marker"></span>' . $merge_variable['name'] . ' ' . do_action( 'yikes-mailchimp-list-field', $merge_variable ) . '</li>'; |
|
| 354 | + echo '<li class="' . $merge_variable[ 'tag' ] . '"><span class="dashicons dashicons-marker"></span>' . $merge_variable[ 'name' ] . ' ' . do_action( 'yikes-mailchimp-list-field', $merge_variable ) . '</li>'; |
|
| 355 | 355 | } |
| 356 | 356 | ?></ul><?php |
| 357 | 357 | } |
@@ -368,13 +368,13 @@ discard block |
||
| 368 | 368 | <div class="postbox yikes-easy-mc-postbox"> |
| 369 | 369 | |
| 370 | 370 | |
| 371 | - <h3><?php _e( 'Interest Groups Overview' , 'yikes-inc-easy-mailchimp-extender' ); ?></h3> |
|
| 371 | + <h3><?php _e( 'Interest Groups Overview', 'yikes-inc-easy-mailchimp-extender' ); ?></h3> |
|
| 372 | 372 | <?php |
| 373 | - if( isset( $interest_groupings ) && ! isset( $interest_groupings['error'] ) ) { |
|
| 373 | + if ( isset( $interest_groupings ) && ! isset( $interest_groupings[ 'error' ] ) ) { |
|
| 374 | 374 | ?><ul class="interest-group-ul"><?php |
| 375 | 375 | echo '<li class="interest-group-count">' . sprintf( _n( '%d Interest Group', '%d Interest Groups', intval( count( $interest_groupings ) ), 'yikes-inc-easy-mailchimp-extender' ), intval( count( $interest_groupings ) ) ) . '</li>'; |
| 376 | - foreach( $interest_groupings as $interest_group ) { |
|
| 377 | - echo '<li><span class="dashicons dashicons-marker"></span>' . $interest_group['name'] . '<span class="interest-group-title"></span><small title="' . $interest_group['groups'][0]['subscribers'] . ' ' . __( "subscribers assigned to this group" , 'yikes-inc-easy-mailchimp-extender' ) . '">(' . $interest_group['groups'][0]['subscribers'] . ')</small></li>'; |
|
| 376 | + foreach ( $interest_groupings as $interest_group ) { |
|
| 377 | + echo '<li><span class="dashicons dashicons-marker"></span>' . $interest_group[ 'name' ] . '<span class="interest-group-title"></span><small title="' . $interest_group[ 'groups' ][ 0 ][ 'subscribers' ] . ' ' . __( "subscribers assigned to this group", 'yikes-inc-easy-mailchimp-extender' ) . '">(' . $interest_group[ 'groups' ][ 0 ][ 'subscribers' ] . ')</small></li>'; |
|
| 378 | 378 | } |
| 379 | 379 | ?></ul><?php |
| 380 | 380 | } else { |
@@ -397,17 +397,17 @@ discard block |
||
| 397 | 397 | <div class="postbox yikes-easy-mc-postbox"> |
| 398 | 398 | |
| 399 | 399 | |
| 400 | - <h3><?php _e( 'Segments Overview' , 'yikes-inc-easy-mailchimp-extender' ); ?></h3> |
|
| 400 | + <h3><?php _e( 'Segments Overview', 'yikes-inc-easy-mailchimp-extender' ); ?></h3> |
|
| 401 | 401 | <?php |
| 402 | - if( isset( $segments['saved'] ) && count( $segments['saved'] ) >= 1 ) { |
|
| 402 | + if ( isset( $segments[ 'saved' ] ) && count( $segments[ 'saved' ] ) >= 1 ) { |
|
| 403 | 403 | $i = 1; |
| 404 | 404 | ?><ul class="segment-ul"><?php |
| 405 | - echo '<li class="segment-group-count">' . sprintf( _n( '%d Segment', '%d Segments', intval( count( $segments['saved'] ) ), 'yikes-inc-easy-mailchimp-extender' ), intval( count( $segments['saved'] ) ) ) . '</li>'; |
|
| 406 | - foreach( $segments['saved'] as $segment ) { |
|
| 407 | - echo '<li><span class="dashicons dashicons-arrow-right"></span>' . $segment['name'] . ' <small><a href="#" onclick="jQuery(this).parent().parent().next().slideToggle();jQuery(this).toggleText();return false;" data-alt-text="' . __( 'hide conditions' , 'yikes-inc-easy-mailchimp-extender' ) . '">' . __( "view conditions" , 'yikes-inc-easy-mailchimp-extender' ) . '</a></small></li>'; |
|
| 405 | + echo '<li class="segment-group-count">' . sprintf( _n( '%d Segment', '%d Segments', intval( count( $segments[ 'saved' ] ) ), 'yikes-inc-easy-mailchimp-extender' ), intval( count( $segments[ 'saved' ] ) ) ) . '</li>'; |
|
| 406 | + foreach ( $segments[ 'saved' ] as $segment ) { |
|
| 407 | + echo '<li><span class="dashicons dashicons-arrow-right"></span>' . $segment[ 'name' ] . ' <small><a href="#" onclick="jQuery(this).parent().parent().next().slideToggle();jQuery(this).toggleText();return false;" data-alt-text="' . __( 'hide conditions', 'yikes-inc-easy-mailchimp-extender' ) . '">' . __( "view conditions", 'yikes-inc-easy-mailchimp-extender' ) . '</a></small></li>'; |
|
| 408 | 408 | ?><div class="conditionals yikes-easy-mc-hidden"><?php |
| 409 | - foreach( $segment['segment_opts']['conditions'] as $condition ) { |
|
| 410 | - echo '<li><small>' . sprintf( __( 'condition #%s : If %s %s %s', 'yikes-inc-easy-mailchimp-extender' ), intval( $i ), $condition['field'], $condition['op'], $condition['value'] ) . '</small></li>'; |
|
| 409 | + foreach ( $segment[ 'segment_opts' ][ 'conditions' ] as $condition ) { |
|
| 410 | + echo '<li><small>' . sprintf( __( 'condition #%s : If %s %s %s', 'yikes-inc-easy-mailchimp-extender' ), intval( $i ), $condition[ 'field' ], $condition[ 'op' ], $condition[ 'value' ] ) . '</small></li>'; |
|
| 411 | 411 | $i++; |
| 412 | 412 | } |
| 413 | 413 | ?></div><?php |
@@ -422,9 +422,9 @@ discard block |
||
| 422 | 422 | } |
| 423 | 423 | ?> |
| 424 | 424 | <!-- |
| 425 | - <a class="edit-segments-button" href="#" onclick="return false;" class="button-primary"><?php _e( 'Edit Segments' , 'yikes-inc-easy-mailchimp-extender' ); ?></a> |
|
| 425 | + <a class="edit-segments-button" href="#" onclick="return false;" class="button-primary"><?php _e( 'Edit Segments', 'yikes-inc-easy-mailchimp-extender' ); ?></a> |
|
| 426 | 426 | --> |
| 427 | - <p class="description edit-segment-description"><?php _e( 'To edit this lists segments, head over to' , 'yikes-inc-easy-mailchimp-extender' ); ?> <a href="http://www.MailChimp.com" target="_blank">MailChimp</a></p> |
|
| 427 | + <p class="description edit-segment-description"><?php _e( 'To edit this lists segments, head over to', 'yikes-inc-easy-mailchimp-extender' ); ?> <a href="http://www.MailChimp.com" target="_blank">MailChimp</a></p> |
|
| 428 | 428 | |
| 429 | 429 | </div> |
| 430 | 430 | |
@@ -9,30 +9,30 @@ discard block |
||
| 9 | 9 | */ |
| 10 | 10 | |
| 11 | 11 | // enqueue the styles for our migration page.. |
| 12 | - wp_enqueue_style( 'yikes_mc_migrate_option_styles' , YIKES_MC_URL . 'admin/css/yikes-inc-easy-mailchimp-migrate-option-styles.css' ); |
|
| 13 | - wp_enqueue_style( 'animate-css' , YIKES_MC_URL . 'admin/css/animate.min.css' ); |
|
| 12 | + wp_enqueue_style( 'yikes_mc_migrate_option_styles', YIKES_MC_URL . 'admin/css/yikes-inc-easy-mailchimp-migrate-option-styles.css' ); |
|
| 13 | + wp_enqueue_style( 'animate-css', YIKES_MC_URL . 'admin/css/animate.min.css' ); |
|
| 14 | 14 | |
| 15 | 15 | // store our old options |
| 16 | 16 | $old_plugin_options = get_option( 'ykseme_storage' ); |
| 17 | 17 | |
| 18 | 18 | $global_error_messages = array( |
| 19 | - 'success' => __( $old_plugin_options['single-optin-message'] , 'yikes-inc-easy-mailchimp-extender' ), |
|
| 20 | - 'general-error' => __( "Whoops! It looks like something went wrong. Please try again." , 'yikes-inc-easy-mailchimp-extender' ), |
|
| 21 | - 'invalid-email' => __( "Please provide a valid email address." , 'yikes-inc-easy-mailchimp-extender' ), |
|
| 22 | - 'email-exists-error' => __( "The provided email is already subscribed to this list." , 'yikes-inc-easy-mailchimp-extender' ) |
|
| 19 | + 'success' => __( $old_plugin_options[ 'single-optin-message' ], 'yikes-inc-easy-mailchimp-extender' ), |
|
| 20 | + 'general-error' => __( "Whoops! It looks like something went wrong. Please try again.", 'yikes-inc-easy-mailchimp-extender' ), |
|
| 21 | + 'invalid-email' => __( "Please provide a valid email address.", 'yikes-inc-easy-mailchimp-extender' ), |
|
| 22 | + 'email-exists-error' => __( "The provided email is already subscribed to this list.", 'yikes-inc-easy-mailchimp-extender' ) |
|
| 23 | 23 | ); |
| 24 | 24 | |
| 25 | 25 | // if old options are defined... |
| 26 | - if( $old_plugin_options ) { |
|
| 26 | + if ( $old_plugin_options ) { |
|
| 27 | 27 | |
| 28 | 28 | // Verify the NONCE is valid |
| 29 | - check_admin_referer( 'yikes-mc-migrate-options' , 'migrate_options_nonce' ); |
|
| 29 | + check_admin_referer( 'yikes-mc-migrate-options', 'migrate_options_nonce' ); |
|
| 30 | 30 | |
| 31 | 31 | ?> |
| 32 | 32 | |
| 33 | 33 | <div class="wrap" style="text-align:center;"> |
| 34 | - <h3><?php _e( 'Migrating old plugin options' , 'yikes-inc-easy-mailchimp-extender' ); ?><span class="upgrading-ellipse-one">.</span><span class="upgrading-ellipse-two">.</span><span class="upgrading-ellipse-three">.</h3> |
|
| 35 | - <p><?php _e( 'please be patient while your options are updated and the process has completed' , 'yikes-inc-easy-mailchimp-extender' ); ?></p> |
|
| 34 | + <h3><?php _e( 'Migrating old plugin options', 'yikes-inc-easy-mailchimp-extender' ); ?><span class="upgrading-ellipse-one">.</span><span class="upgrading-ellipse-two">.</span><span class="upgrading-ellipse-three">.</h3> |
|
| 35 | + <p><?php _e( 'please be patient while your options are updated and the process has completed', 'yikes-inc-easy-mailchimp-extender' ); ?></p> |
|
| 36 | 36 | <!-- empty list, populate when options get updated --> |
| 37 | 37 | <ul id="options-updated" class="yikes-easy-mc-hidden"> |
| 38 | 38 | <hr /> |
@@ -46,82 +46,82 @@ discard block |
||
| 46 | 46 | |
| 47 | 47 | // loop over our old options, and store them in a new option value |
| 48 | 48 | $do_not_migrate_options = array( |
| 49 | - 'ssl_verify_peer', 'api_validation' , 'widget_yikes_mc_widget' , 'flavor' , 'single-optin-message' , 'double-optin-message' , |
|
| 50 | - 'mailchimp-optIn-default-list' , 'version' , 'yks-mailchimp-jquery-datepicker' , 'ssl_verify_peer' , 'optIn-checkbox' , 'yks-mailchimp-optin-checkbox-text', |
|
| 51 | - 'yks-mailchimp-required-text' , 'optin' |
|
| 49 | + 'ssl_verify_peer', 'api_validation', 'widget_yikes_mc_widget', 'flavor', 'single-optin-message', 'double-optin-message', |
|
| 50 | + 'mailchimp-optIn-default-list', 'version', 'yks-mailchimp-jquery-datepicker', 'ssl_verify_peer', 'optIn-checkbox', 'yks-mailchimp-optin-checkbox-text', |
|
| 51 | + 'yks-mailchimp-required-text', 'optin' |
|
| 52 | 52 | ); |
| 53 | 53 | |
| 54 | - foreach( $old_plugin_options as $option_name => $option_value ) { |
|
| 54 | + foreach ( $old_plugin_options as $option_name => $option_value ) { |
|
| 55 | 55 | |
| 56 | - if( ! in_array( $option_name , $do_not_migrate_options ) ) { |
|
| 56 | + if ( ! in_array( $option_name, $do_not_migrate_options ) ) { |
|
| 57 | 57 | // ajax request to update our options one by one.. |
| 58 | 58 | // if its an array, we need to json encode it |
| 59 | - if( is_array( $option_value ) ) { |
|
| 59 | + if ( is_array( $option_value ) ) { |
|
| 60 | 60 | |
| 61 | - if( $option_name == 'lists' ) { |
|
| 61 | + if ( $option_name == 'lists' ) { |
|
| 62 | 62 | |
| 63 | - if( ! empty( $option_value ) ) { |
|
| 63 | + if ( ! empty( $option_value ) ) { |
|
| 64 | 64 | $settings = 1; |
| 65 | 65 | $form_length = count( $option_value ); |
| 66 | - foreach( $option_value as $mailchimp_form ) { |
|
| 66 | + foreach ( $option_value as $mailchimp_form ) { |
|
| 67 | 67 | // update and pass our placeholder value |
| 68 | 68 | reset( $mailchimp_form ); |
| 69 | - $form_id = $mailchimp_form['id']; |
|
| 69 | + $form_id = $mailchimp_form[ 'id' ]; |
|
| 70 | 70 | |
| 71 | - $fields = $mailchimp_form['fields']; |
|
| 71 | + $fields = $mailchimp_form[ 'fields' ]; |
|
| 72 | 72 | reset( $fields ); |
| 73 | 73 | $first_field_key = key( $fields ); |
| 74 | 74 | $array_keys = array_keys( $fields ); |
| 75 | 75 | |
| 76 | 76 | $x = 1; |
| 77 | 77 | |
| 78 | - foreach( $array_keys as $parent_key ) { |
|
| 78 | + foreach ( $array_keys as $parent_key ) { |
|
| 79 | 79 | |
| 80 | 80 | // alter the field keys so they show up after an import |
| 81 | 81 | $split_parent_key = explode( '-', $parent_key ); |
| 82 | 82 | |
| 83 | - $new_parent_key = ( isset( $split_parent_key[1] ) ) ? strtoupper( $split_parent_key[1] ) : $parent_key; |
|
| 83 | + $new_parent_key = ( isset( $split_parent_key[ 1 ] ) ) ? strtoupper( $split_parent_key[ 1 ] ) : $parent_key; |
|
| 84 | 84 | |
| 85 | - $mailchimp_form['fields'][$new_parent_key] = $mailchimp_form['fields'][$parent_key]; |
|
| 85 | + $mailchimp_form[ 'fields' ][ $new_parent_key ] = $mailchimp_form[ 'fields' ][ $parent_key ]; |
|
| 86 | 86 | |
| 87 | - unset( $mailchimp_form['fields'][$parent_key] ); |
|
| 87 | + unset( $mailchimp_form[ 'fields' ][ $parent_key ] ); |
|
| 88 | 88 | |
| 89 | 89 | // update our placeholder key to be 'placeholder' |
| 90 | - $mailchimp_form['fields'][$new_parent_key]['placeholder'] = isset( $mailchimp_form['fields'][$new_parent_key]['placeholder-'.$form_id.'-'.$x] ) ? $mailchimp_form['fields'][$new_parent_key]['placeholder-'.$form_id.'-'.$x] : ''; |
|
| 90 | + $mailchimp_form[ 'fields' ][ $new_parent_key ][ 'placeholder' ] = isset( $mailchimp_form[ 'fields' ][ $new_parent_key ][ 'placeholder-' . $form_id . '-' . $x ] ) ? $mailchimp_form[ 'fields' ][ $new_parent_key ][ 'placeholder-' . $form_id . '-' . $x ] : ''; |
|
| 91 | 91 | // update field classes |
| 92 | - $mailchimp_form['fields'][$new_parent_key]['additional-classes'] = isset( $mailchimp_form['fields'][$new_parent_key]['custom-field-class-'.$form_id.'-'.$x] ) ? $mailchimp_form['fields'][$new_parent_key]['custom-field-class-'.$form_id.'-'.$x] : ''; |
|
| 92 | + $mailchimp_form[ 'fields' ][ $new_parent_key ][ 'additional-classes' ] = isset( $mailchimp_form[ 'fields' ][ $new_parent_key ][ 'custom-field-class-' . $form_id . '-' . $x ] ) ? $mailchimp_form[ 'fields' ][ $new_parent_key ][ 'custom-field-class-' . $form_id . '-' . $x ] : ''; |
|
| 93 | 93 | // update help field - populate description |
| 94 | - $mailchimp_form['fields'][$new_parent_key]['description'] = isset( $mailchimp_form['fields'][$new_parent_key]['help'] ) ? $mailchimp_form['fields'][$new_parent_key]['help'] : ''; |
|
| 94 | + $mailchimp_form[ 'fields' ][ $new_parent_key ][ 'description' ] = isset( $mailchimp_form[ 'fields' ][ $new_parent_key ][ 'help' ] ) ? $mailchimp_form[ 'fields' ][ $new_parent_key ][ 'help' ] : ''; |
|
| 95 | 95 | // remove the old placeholder structure |
| 96 | - unset( $mailchimp_form['fields'][$new_parent_key]['placeholder-'.$form_id.'-'.$x] ); |
|
| 96 | + unset( $mailchimp_form[ 'fields' ][ $new_parent_key ][ 'placeholder-' . $form_id . '-' . $x ] ); |
|
| 97 | 97 | // remove old custom class structure |
| 98 | - unset( $mailchimp_form['fields'][$new_parent_key]['custom-field-class-'.$form_id.'-'.$x] ); |
|
| 98 | + unset( $mailchimp_form[ 'fields' ][ $new_parent_key ][ 'custom-field-class-' . $form_id . '-' . $x ] ); |
|
| 99 | 99 | // remove old help/description |
| 100 | - unset( $mailchimp_form['fields'][$new_parent_key]['help'] ); |
|
| 100 | + unset( $mailchimp_form[ 'fields' ][ $new_parent_key ][ 'help' ] ); |
|
| 101 | 101 | |
| 102 | 102 | // check if choices is set, and encode them |
| 103 | - if( isset( $mailchimp_form['fields'][$new_parent_key]['choices'] ) && ! empty( $mailchimp_form['fields'][$new_parent_key]['choices'] ) ) { |
|
| 104 | - $mailchimp_form['fields'][$new_parent_key]['choices'] = addslashes( addslashes( json_encode( $mailchimp_form['fields'][$new_parent_key]['choices'] ) ) ); |
|
| 103 | + if ( isset( $mailchimp_form[ 'fields' ][ $new_parent_key ][ 'choices' ] ) && ! empty( $mailchimp_form[ 'fields' ][ $new_parent_key ][ 'choices' ] ) ) { |
|
| 104 | + $mailchimp_form[ 'fields' ][ $new_parent_key ][ 'choices' ] = addslashes( addslashes( json_encode( $mailchimp_form[ 'fields' ][ $new_parent_key ][ 'choices' ] ) ) ); |
|
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | // update 'default' to 'default-choice' for radio/dropdown |
| 108 | - if( isset( $mailchimp_form['fields'][$new_parent_key]['type'] ) && in_array( $mailchimp_form['fields'][$new_parent_key]['type'], array( 'radio', 'dropdown' ) ) ) { |
|
| 109 | - $mailchimp_form['fields'][$new_parent_key]['default_choice'] = $mailchimp_form['fields'][$new_parent_key]['default']; |
|
| 110 | - unset( $mailchimp_form['fields'][$new_parent_key]['default'] ); |
|
| 108 | + if ( isset( $mailchimp_form[ 'fields' ][ $new_parent_key ][ 'type' ] ) && in_array( $mailchimp_form[ 'fields' ][ $new_parent_key ][ 'type' ], array( 'radio', 'dropdown' ) ) ) { |
|
| 109 | + $mailchimp_form[ 'fields' ][ $new_parent_key ][ 'default_choice' ] = $mailchimp_form[ 'fields' ][ $new_parent_key ][ 'default' ]; |
|
| 110 | + unset( $mailchimp_form[ 'fields' ][ $new_parent_key ][ 'default' ] ); |
|
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | // update 'date_format' on 'birthday' and 'date' fields |
| 114 | - if( isset( $mailchimp_form['fields'][$new_parent_key]['type'] ) && in_array( $mailchimp_form['fields'][$new_parent_key]['type'], array( 'date', 'birthday' ) ) ) { |
|
| 115 | - if( $mailchimp_form['fields'][$new_parent_key]['type'] == 'date' ) { // date |
|
| 116 | - $mailchimp_form['fields'][$new_parent_key]['date_format'] = 'MM/DD'; // mailchimp default (can be altered) |
|
| 114 | + if ( isset( $mailchimp_form[ 'fields' ][ $new_parent_key ][ 'type' ] ) && in_array( $mailchimp_form[ 'fields' ][ $new_parent_key ][ 'type' ], array( 'date', 'birthday' ) ) ) { |
|
| 115 | + if ( $mailchimp_form[ 'fields' ][ $new_parent_key ][ 'type' ] == 'date' ) { // date |
|
| 116 | + $mailchimp_form[ 'fields' ][ $new_parent_key ][ 'date_format' ] = 'MM/DD'; // mailchimp default (can be altered) |
|
| 117 | 117 | } else { // birthday |
| 118 | - $mailchimp_form['fields'][$new_parent_key]['date_format'] = 'MM/DD/YYYY'; // mailchimp default (can be altered) |
|
| 118 | + $mailchimp_form[ 'fields' ][ $new_parent_key ][ 'date_format' ] = 'MM/DD/YYYY'; // mailchimp default (can be altered) |
|
| 119 | 119 | } |
| 120 | 120 | } |
| 121 | 121 | |
| 122 | 122 | // update 'phone_format' on 'phone' |
| 123 | - if( isset( $mailchimp_form['fields'][$new_parent_key]['type'] ) && in_array( $mailchimp_form['fields'][$new_parent_key]['type'], array( 'phone' ) ) ) { |
|
| 124 | - $mailchimp_form['fields'][$new_parent_key]['phone_format'] = 'phone_format '; // phone format |
|
| 123 | + if ( isset( $mailchimp_form[ 'fields' ][ $new_parent_key ][ 'type' ] ) && in_array( $mailchimp_form[ 'fields' ][ $new_parent_key ][ 'type' ], array( 'phone' ) ) ) { |
|
| 124 | + $mailchimp_form[ 'fields' ][ $new_parent_key ][ 'phone_format' ] = 'phone_format '; // phone format |
|
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | $x++; |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | |
| 139 | 139 | $.post( ajaxurl, mc_data, function(response) { |
| 140 | 140 | jQuery( '#options-updated' ).show(); |
| 141 | - jQuery( '#options-updated' ).append( '<li class="animated fadeInDown"><?php echo '<strong>'; ?>' + response.form_name + '<?php echo '</strong> ' . __( "successfully imported." , 'yikes-inc-easy-mailchimp-extender' ); ?></li>' ); |
|
| 141 | + jQuery( '#options-updated' ).append( '<li class="animated fadeInDown"><?php echo '<strong>'; ?>' + response.form_name + '<?php echo '</strong> ' . __( "successfully imported.", 'yikes-inc-easy-mailchimp-extender' ); ?></li>' ); |
|
| 142 | 142 | if( response.completed_import ) { |
| 143 | 143 | setTimeout( function() { |
| 144 | 144 | // finished with the loop...lets let the user know....and then redirect them.... |
@@ -147,13 +147,13 @@ discard block |
||
| 147 | 147 | jQuery( '.upgrading-ellipse-two' ).remove(); |
| 148 | 148 | jQuery( '.upgrading-ellipse-three' ).remove(); |
| 149 | 149 | jQuery( '.wrap' ).find( 'h3' ).next().fadeOut(); |
| 150 | - jQuery( '#options-updated' ).append( '<li class="animated fadeInDown migration-complete-notification"><em><?php _e( "Migration Complete. Please wait..." , 'yikes-inc-easy-mailchimp-extender' ); ?> </em> <img src="<?php echo esc_url_raw( admin_url( "images/wpspin_light.gif" ) ); ?>" /></li>' ); |
|
| 150 | + jQuery( '#options-updated' ).append( '<li class="animated fadeInDown migration-complete-notification"><em><?php _e( "Migration Complete. Please wait...", 'yikes-inc-easy-mailchimp-extender' ); ?> </em> <img src="<?php echo esc_url_raw( admin_url( "images/wpspin_light.gif" ) ); ?>" /></li>' ); |
|
| 151 | 151 | // redirect our user to the main plugin page... |
| 152 | 152 | setTimeout( function() { |
| 153 | 153 | <?php |
| 154 | 154 | // migrate options that didnt make it (they were never stored in the 'ykseme_storage' options array) |
| 155 | - add_option( 'yikes-mc-api-validation' , get_option( 'api_validation' , 'invalid_api_key' ) ); |
|
| 156 | - add_option( 'yikes-mc-error-messages' , $global_error_messages ); |
|
| 155 | + add_option( 'yikes-mc-api-validation', get_option( 'api_validation', 'invalid_api_key' ) ); |
|
| 156 | + add_option( 'yikes-mc-error-messages', $global_error_messages ); |
|
| 157 | 157 | // delete our old options after a successful migration (and some new ones that are no longer needed) |
| 158 | 158 | delete_option( 'widget_yikes_mc_widget' ); |
| 159 | 159 | delete_option( 'api_validation' ); |
@@ -174,26 +174,26 @@ discard block |
||
| 174 | 174 | } |
| 175 | 175 | /* Rename our ReCaptcha Options */ |
| 176 | 176 | /* Public Site Key */ |
| 177 | - if( $option_name == 'recaptcha-api-key' ) { |
|
| 177 | + if ( $option_name == 'recaptcha-api-key' ) { |
|
| 178 | 178 | $option_name = 'recaptcha-site-key'; |
| 179 | 179 | } |
| 180 | 180 | /* Private Key */ |
| 181 | - if( $option_name == 'recaptcha-private-api-key' ) { |
|
| 181 | + if ( $option_name == 'recaptcha-private-api-key' ) { |
|
| 182 | 182 | $option_name = 'recaptcha-secret-key'; |
| 183 | 183 | } |
| 184 | 184 | /* Change 'recaptcha-setting' to 'recaptcha-status' */ |
| 185 | 185 | /* Status */ |
| 186 | - if( $option_name == 'recaptcha-setting' ) { |
|
| 186 | + if ( $option_name == 'recaptcha-setting' ) { |
|
| 187 | 187 | $option_name = 'recaptcha-status'; |
| 188 | 188 | } |
| 189 | 189 | /* End re-name ReCaptcha options */ |
| 190 | 190 | |
| 191 | 191 | |
| 192 | - if( is_array( $option_value ) ) { |
|
| 192 | + if ( is_array( $option_value ) ) { |
|
| 193 | 193 | $option_value = json_encode( $option_value ); |
| 194 | 194 | } |
| 195 | 195 | // do noit migrate the lists option, it's not useful to us |
| 196 | - if( $option_name != 'lists' ) { |
|
| 196 | + if ( $option_name != 'lists' ) { |
|
| 197 | 197 | ?> |
| 198 | 198 | var data = { |
| 199 | 199 | 'action': 'migrate_old_plugin_settings', |
@@ -203,7 +203,7 @@ discard block |
||
| 203 | 203 | |
| 204 | 204 | $.post( ajaxurl, data, function(response) { |
| 205 | 205 | jQuery( '#options-updated' ).show(); |
| 206 | - jQuery( '#options-updated' ).append( '<li class="animated fadeInDown"><?php echo '<strong>' . ucwords( str_replace( '_' , ' ' , str_replace( '-' , ' ' , $option_name ) ) ) . '</strong> ' . __( "successfully imported." , 'yikes-inc-easy-mailchimp-extender' ); ?></li>' ); |
|
| 206 | + jQuery( '#options-updated' ).append( '<li class="animated fadeInDown"><?php echo '<strong>' . ucwords( str_replace( '_', ' ', str_replace( '-', ' ', $option_name ) ) ) . '</strong> ' . __( "successfully imported.", 'yikes-inc-easy-mailchimp-extender' ); ?></li>' ); |
|
| 207 | 207 | }); |
| 208 | 208 | <?php |
| 209 | 209 | |
@@ -227,7 +227,7 @@ discard block |
||
| 227 | 227 | }, 2000 ); |
| 228 | 228 | </script> |
| 229 | 229 | <?php |
| 230 | - wp_die( '<strong>' . __( 'Old plugin options do not exist. Redirecting you...' , 'yikes-inc-easy-mailchimp-extender' ) . '</strong>' , 500 ); |
|
| 230 | + wp_die( '<strong>' . __( 'Old plugin options do not exist. Redirecting you...', 'yikes-inc-easy-mailchimp-extender' ) . '</strong>', 500 ); |
|
| 231 | 231 | ?> |
| 232 | 232 | </div> |
| 233 | 233 | <?php |
@@ -12,42 +12,42 @@ discard block |
||
| 12 | 12 | array( |
| 13 | 13 | 'form' => '', // pass in a form, which will retreive the associated list ID -- takes precendence |
| 14 | 14 | 'list' => '', // pass in a specific list ID |
| 15 | - ), $attributes , 'yikes-mailchimp-subscriber-count' ) |
|
| 15 | + ), $attributes, 'yikes-mailchimp-subscriber-count' ) |
|
| 16 | 16 | ); |
| 17 | 17 | |
| 18 | 18 | /* If the user hasn't authenticated yet - bail */ |
| 19 | - if( get_option( 'yikes-mc-api-validation' , 'invalid_api_key' ) != 'valid_api_key' ) { |
|
| 20 | - if( WP_DEBUG ) { |
|
| 19 | + if ( get_option( 'yikes-mc-api-validation', 'invalid_api_key' ) != 'valid_api_key' ) { |
|
| 20 | + if ( WP_DEBUG ) { |
|
| 21 | 21 | return '<strong>' . __( "You don't appear to be connected to MailChimp.", "yikes-inc-easy-mailchimp-extender" ) . '</strong>'; |
| 22 | 22 | } |
| 23 | 23 | return; |
| 24 | 24 | } |
| 25 | 25 | |
| 26 | - $form = ( ! empty( $attributes['form'] ) ) ? str_replace( '"', '', $attributes['form'] ) : false; // replace the sanitize quotes to perform a proper query |
|
| 27 | - $list_id = ( ! empty( $attributes['list'] ) ) ? $attributes['list'] : false; |
|
| 26 | + $form = ( ! empty( $attributes[ 'form' ] ) ) ? str_replace( '"', '', $attributes[ 'form' ] ) : false; // replace the sanitize quotes to perform a proper query |
|
| 27 | + $list_id = ( ! empty( $attributes[ 'list' ] ) ) ? $attributes[ 'list' ] : false; |
|
| 28 | 28 | |
| 29 | 29 | /* If no list ID was passed into the shortcode - bail */ |
| 30 | - if( ! $list_id && ! $form) { |
|
| 31 | - if( WP_DEBUG ) { |
|
| 30 | + if ( ! $list_id && ! $form ) { |
|
| 31 | + if ( WP_DEBUG ) { |
|
| 32 | 32 | return '<strong>' . __( 'You forgot to include the list or form ID.', 'yikes-inc-easy-mailchimp-extender' ) . '</strong>'; |
| 33 | 33 | } |
| 34 | 34 | return; |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | /* if a form ID and a list ID were passed in, use the form ID */ |
| 38 | - if( ( $form ) || ( $form && $list_id ) ) { |
|
| 38 | + if ( ( $form ) || ( $form && $list_id ) ) { |
|
| 39 | 39 | global $wpdb; |
| 40 | 40 | // return it as an array, so we can work with it to build our form below |
| 41 | 41 | $form_results = $wpdb->get_results( 'SELECT * FROM ' . $wpdb->prefix . 'yikes_easy_mc_forms WHERE id = ' . $form . '', ARRAY_A ); |
| 42 | 42 | // confirm we have some results, or return an error |
| 43 | - if( ! $form_results ) { |
|
| 44 | - if( WP_DEBUG ) { |
|
| 45 | - return __( "Oh no...This form doesn't exist. Head back to the manage forms page and select a different form." , 'yikes-inc-easy-mailchimp-extender' ); |
|
| 43 | + if ( ! $form_results ) { |
|
| 44 | + if ( WP_DEBUG ) { |
|
| 45 | + return __( "Oh no...This form doesn't exist. Head back to the manage forms page and select a different form.", 'yikes-inc-easy-mailchimp-extender' ); |
|
| 46 | 46 | } |
| 47 | 47 | return; |
| 48 | 48 | } |
| 49 | - $form_data = $form_results[0]; |
|
| 50 | - $list_id = sanitize_key( $form_data['list_id'] ); // associated list id (users who fill out the form will be subscribed to this list) |
|
| 49 | + $form_data = $form_results[ 0 ]; |
|
| 50 | + $list_id = sanitize_key( $form_data[ 'list_id' ] ); // associated list id (users who fill out the form will be subscribed to this list) |
|
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | // object buffer |
@@ -57,9 +57,9 @@ discard block |
||
| 57 | 57 | try { |
| 58 | 58 | |
| 59 | 59 | // get the api key |
| 60 | - $api_key = trim( get_option( 'yikes-mc-api-key' , '' ) ); |
|
| 60 | + $api_key = trim( get_option( 'yikes-mc-api-key', '' ) ); |
|
| 61 | 61 | $dash_position = strpos( $api_key, '-' ); |
| 62 | - if( $dash_position !== false ) { |
|
| 62 | + if ( $dash_position !== false ) { |
|
| 63 | 63 | $api_endpoint = 'https://' . substr( $api_key, $dash_position + 1 ) . '.api.mailchimp.com/2.0/lists/list.json'; |
| 64 | 64 | } |
| 65 | 65 | |
@@ -76,23 +76,23 @@ discard block |
||
| 76 | 76 | ) ); |
| 77 | 77 | |
| 78 | 78 | $subscriber_count_response = json_decode( wp_remote_retrieve_body( $subscriber_count_response ), true ); |
| 79 | - if( isset( $subscriber_count_response['error'] ) ) { |
|
| 80 | - if( WP_DEBUG || get_option( 'yikes-mailchimp-debug-status' , '' ) == '1' ) { |
|
| 79 | + if ( isset( $subscriber_count_response[ 'error' ] ) ) { |
|
| 80 | + if ( WP_DEBUG || get_option( 'yikes-mailchimp-debug-status', '' ) == '1' ) { |
|
| 81 | 81 | require_once YIKES_MC_PATH . 'includes/error_log/class-yikes-inc-easy-mailchimp-error-logging.php'; |
| 82 | 82 | $error_logging = new Yikes_Inc_Easy_Mailchimp_Error_Logging(); |
| 83 | - $error_logging->yikes_easy_mailchimp_write_to_error_log( $subscriber_count_response['error'], __( "Get Account Lists" , 'yikes-inc-easy-mailchimp-extender' ), "yikes-mailchimp-subscriber-count.php" ); |
|
| 83 | + $error_logging->yikes_easy_mailchimp_write_to_error_log( $subscriber_count_response[ 'error' ], __( "Get Account Lists", 'yikes-inc-easy-mailchimp-extender' ), "yikes-mailchimp-subscriber-count.php" ); |
|
| 84 | 84 | } |
| 85 | 85 | } |
| 86 | 86 | // if more than one list is returned, something went wrong - bail |
| 87 | - if( $subscriber_count_response['total'] != 1 ) { |
|
| 88 | - if( WP_DEBUG ) { |
|
| 87 | + if ( $subscriber_count_response[ 'total' ] != 1 ) { |
|
| 88 | + if ( WP_DEBUG ) { |
|
| 89 | 89 | return '<strong>' . sprintf( __( "It looks like this list wasn't found. Double check the list with with ID '%s' exists.", "yikes-inc-easy-mailchimp-extender" ), $list_id ) . '</strong>'; |
| 90 | 90 | } |
| 91 | 91 | return; |
| 92 | 92 | } |
| 93 | 93 | |
| 94 | 94 | /* type cast the returned value as an integer */ |
| 95 | - echo (int) apply_filters( 'yikes-mailchimp-subscriber-count-value', $subscriber_count_response['data'][0]['stats']['member_count'] ); |
|
| 95 | + echo (int) apply_filters( 'yikes-mailchimp-subscriber-count-value', $subscriber_count_response[ 'data' ][ 0 ][ 'stats' ][ 'member_count' ] ); |
|
| 96 | 96 | |
| 97 | 97 | } catch ( Exception $error ) { |
| 98 | 98 | echo $error->getMessage(); |
@@ -18,7 +18,7 @@ |
||
| 18 | 18 | ), $atts ) |
| 19 | 19 | ); |
| 20 | 20 | |
| 21 | - return '<p><em>' . __( 'This MailChimp shortcode is now deprecated. Please insert the new shortcode to display this form.' , 'yikes-inc-easy-mailchimp-extender' ) . '</em></p>'; |
|
| 21 | + return '<p><em>' . __( 'This MailChimp shortcode is now deprecated. Please insert the new shortcode to display this form.', 'yikes-inc-easy-mailchimp-extender' ) . '</em></p>'; |
|
| 22 | 22 | |
| 23 | 23 | } |
| 24 | 24 | add_shortcode( 'yks-mailchimp-list', 'process_depracated_mailchimp_shortcode' ); ?> |
| 25 | 25 | \ No newline at end of file |
@@ -11,16 +11,16 @@ discard block |
||
| 11 | 11 | */ |
| 12 | 12 | public function __construct() { |
| 13 | 13 | // ajax process form submission |
| 14 | - add_action( 'wp_ajax_nopriv_process_form_submission', array( $this , 'process_form_submission' ), 10 ); |
|
| 15 | - add_action( 'wp_ajax_process_form_submission', array( $this , 'process_form_submission' ), 10 ); |
|
| 14 | + add_action( 'wp_ajax_nopriv_process_form_submission', array( $this, 'process_form_submission' ), 10 ); |
|
| 15 | + add_action( 'wp_ajax_process_form_submission', array( $this, 'process_form_submission' ), 10 ); |
|
| 16 | 16 | |
| 17 | 17 | // ajax send update emails |
| 18 | - add_action( 'wp_ajax_nopriv_easy_forms_send_email', array( $this , 'sendUpdateProfileEmail' ), 10 ); |
|
| 19 | - add_action( 'wp_ajax_easy_forms_send_email', array( $this , 'sendUpdateProfileEmail' ), 10 ); |
|
| 18 | + add_action( 'wp_ajax_nopriv_easy_forms_send_email', array( $this, 'sendUpdateProfileEmail' ), 10 ); |
|
| 19 | + add_action( 'wp_ajax_easy_forms_send_email', array( $this, 'sendUpdateProfileEmail' ), 10 ); |
|
| 20 | 20 | |
| 21 | 21 | // increase submission count for a given form on successful submit |
| 22 | - add_action( 'wp_ajax_nopriv_increase_submission_count' , array( $this , 'increase_submission_count' ), 10 ); |
|
| 23 | - add_action( 'wp_ajax_increase_submission_count' , array( $this , 'increase_submission_count' ), 10 ); |
|
| 22 | + add_action( 'wp_ajax_nopriv_increase_submission_count', array( $this, 'increase_submission_count' ), 10 ); |
|
| 23 | + add_action( 'wp_ajax_increase_submission_count', array( $this, 'increase_submission_count' ), 10 ); |
|
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | /* |
@@ -40,18 +40,18 @@ discard block |
||
| 40 | 40 | */ |
| 41 | 41 | public function increase_submission_count() { |
| 42 | 42 | // store our posted form ID |
| 43 | - $form_id = $_POST['form_id']; |
|
| 43 | + $form_id = $_POST[ 'form_id' ]; |
|
| 44 | 44 | global $wpdb; |
| 45 | 45 | // query the form |
| 46 | 46 | $form_results = $wpdb->get_results( 'SELECT * FROM ' . $wpdb->prefix . 'yikes_easy_mc_forms WHERE id = ' . $form_id . '', ARRAY_A ); |
| 47 | - $form_data = $form_results[0]; |
|
| 47 | + $form_data = $form_results[ 0 ]; |
|
| 48 | 48 | // increase the submission |
| 49 | - $form_data['submissions']++; |
|
| 49 | + $form_data[ 'submissions' ]++; |
|
| 50 | 50 | // update the value in the database |
| 51 | 51 | $wpdb->update( |
| 52 | 52 | $wpdb->prefix . 'yikes_easy_mc_forms', |
| 53 | 53 | array( |
| 54 | - 'submissions' => $form_data['submissions'], |
|
| 54 | + 'submissions' => $form_data[ 'submissions' ], |
|
| 55 | 55 | ), |
| 56 | 56 | array( 'ID' => $form_id ), |
| 57 | 57 | array( |
@@ -68,17 +68,17 @@ discard block |
||
| 68 | 68 | @since v6.0.4.1 |
| 69 | 69 | */ |
| 70 | 70 | public function sendUpdateProfileEmail() { |
| 71 | - $user_email = $_POST['user_email']; |
|
| 72 | - $list_id = $_POST['list_id']; |
|
| 71 | + $user_email = $_POST[ 'user_email' ]; |
|
| 72 | + $list_id = $_POST[ 'list_id' ]; |
|
| 73 | 73 | |
| 74 | - $api_key = trim( get_option( 'yikes-mc-api-key' , '' ) ); |
|
| 74 | + $api_key = trim( get_option( 'yikes-mc-api-key', '' ) ); |
|
| 75 | 75 | $dash_position = strpos( $api_key, '-' ); |
| 76 | - $explode_key = explode( '-' , $api_key ); |
|
| 77 | - $data_center = $explode_key[1]; |
|
| 78 | - $full_site_url = get_bloginfo('url'); |
|
| 76 | + $explode_key = explode( '-', $api_key ); |
|
| 77 | + $data_center = $explode_key[ 1 ]; |
|
| 78 | + $full_site_url = get_bloginfo( 'url' ); |
|
| 79 | 79 | |
| 80 | 80 | // list details api call |
| 81 | - if( $dash_position !== false ) { |
|
| 81 | + if ( $dash_position !== false ) { |
|
| 82 | 82 | $api_endpoint = 'https://' . substr( $api_key, $dash_position + 1 ) . '.api.mailchimp.com/2.0/lists/list.json'; |
| 83 | 83 | } |
| 84 | 84 | $list_details = wp_remote_post( $api_endpoint, array( |
@@ -92,16 +92,16 @@ discard block |
||
| 92 | 92 | 'sslverify' => apply_filters( 'yikes-mailchimp-sslverify', true ) |
| 93 | 93 | ) ); |
| 94 | 94 | $list_details = json_decode( wp_remote_retrieve_body( $list_details ), true ); |
| 95 | - if( isset( $list_details['error'] ) ) { |
|
| 96 | - if( WP_DEBUG || get_option( 'yikes-mailchimp-debug-status' , '' ) == '1' ) { |
|
| 95 | + if ( isset( $list_details[ 'error' ] ) ) { |
|
| 96 | + if ( WP_DEBUG || get_option( 'yikes-mailchimp-debug-status', '' ) == '1' ) { |
|
| 97 | 97 | require_once YIKES_MC_PATH . 'includes/error_log/class-yikes-inc-easy-mailchimp-error-logging.php'; |
| 98 | 98 | $error_logging = new Yikes_Inc_Easy_Mailchimp_Error_Logging(); |
| 99 | - $error_logging->yikes_easy_mailchimp_write_to_error_log( $list_details['error'], __( "Send Update Profile Email - Get Account Lists" , 'yikes-inc-easy-mailchimp-extender' ), "class.public_ajax.php" ); |
|
| 99 | + $error_logging->yikes_easy_mailchimp_write_to_error_log( $list_details[ 'error' ], __( "Send Update Profile Email - Get Account Lists", 'yikes-inc-easy-mailchimp-extender' ), "class.public_ajax.php" ); |
|
| 100 | 100 | } |
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | // account details api call |
| 104 | - if( $dash_position !== false ) { |
|
| 104 | + if ( $dash_position !== false ) { |
|
| 105 | 105 | $api_endpoint = 'https://' . substr( $api_key, $dash_position + 1 ) . '.api.mailchimp.com/2.0/helper/account-details.json'; |
| 106 | 106 | } |
| 107 | 107 | $account_details = wp_remote_post( $api_endpoint, array( |
@@ -112,16 +112,16 @@ discard block |
||
| 112 | 112 | 'sslverify' => apply_filters( 'yikes-mailchimp-sslverify', true ) |
| 113 | 113 | ) ); |
| 114 | 114 | $account_details = json_decode( wp_remote_retrieve_body( $account_details ), true ); |
| 115 | - if( isset( $account_details['error'] ) ) { |
|
| 116 | - if( WP_DEBUG || get_option( 'yikes-mailchimp-debug-status' , '' ) == '1' ) { |
|
| 115 | + if ( isset( $account_details[ 'error' ] ) ) { |
|
| 116 | + if ( WP_DEBUG || get_option( 'yikes-mailchimp-debug-status', '' ) == '1' ) { |
|
| 117 | 117 | require_once YIKES_MC_PATH . 'includes/error_log/class-yikes-inc-easy-mailchimp-error-logging.php'; |
| 118 | 118 | $error_logging = new Yikes_Inc_Easy_Mailchimp_Error_Logging(); |
| 119 | - $error_logging->yikes_easy_mailchimp_write_to_error_log( $account_details['error'], __( "Send Update Profile Email - Get Account Details" , 'yikes-inc-easy-mailchimp-extender' ), "class.public_ajax.php" ); |
|
| 119 | + $error_logging->yikes_easy_mailchimp_write_to_error_log( $account_details[ 'error' ], __( "Send Update Profile Email - Get Account Details", 'yikes-inc-easy-mailchimp-extender' ), "class.public_ajax.php" ); |
|
| 120 | 120 | } |
| 121 | 121 | } |
| 122 | 122 | |
| 123 | 123 | // subscriber details api call |
| 124 | - if( $dash_position !== false ) { |
|
| 124 | + if ( $dash_position !== false ) { |
|
| 125 | 125 | $api_endpoint = 'https://' . substr( $api_key, $dash_position + 1 ) . '.api.mailchimp.com/2.0/lists/member-info.json'; |
| 126 | 126 | } |
| 127 | 127 | $subscriber_account_details = wp_remote_post( $api_endpoint, array( |
@@ -136,27 +136,27 @@ discard block |
||
| 136 | 136 | 'sslverify' => apply_filters( 'yikes-mailchimp-sslverify', true ) |
| 137 | 137 | ) ); |
| 138 | 138 | $subscriber_account_details = json_decode( wp_remote_retrieve_body( $subscriber_account_details ), true ); |
| 139 | - if( isset( $subscriber_account_details['error'] ) ) { |
|
| 140 | - if( WP_DEBUG || get_option( 'yikes-mailchimp-debug-status' , '' ) == '1' ) { |
|
| 139 | + if ( isset( $subscriber_account_details[ 'error' ] ) ) { |
|
| 140 | + if ( WP_DEBUG || get_option( 'yikes-mailchimp-debug-status', '' ) == '1' ) { |
|
| 141 | 141 | require_once YIKES_MC_PATH . 'includes/error_log/class-yikes-inc-easy-mailchimp-error-logging.php'; |
| 142 | 142 | $error_logging = new Yikes_Inc_Easy_Mailchimp_Error_Logging(); |
| 143 | - $error_logging->yikes_easy_mailchimp_write_to_error_log( $subscriber_account_details['error'], __( "Send Update Profile Email - Get Member Info." , 'yikes-inc-easy-mailchimp-extender' ), "class.public_ajax.php" ); |
|
| 143 | + $error_logging->yikes_easy_mailchimp_write_to_error_log( $subscriber_account_details[ 'error' ], __( "Send Update Profile Email - Get Member Info.", 'yikes-inc-easy-mailchimp-extender' ), "class.public_ajax.php" ); |
|
| 144 | 144 | } |
| 145 | 145 | } |
| 146 | 146 | |
| 147 | 147 | // check for errors in any of the calls |
| 148 | - if( isset( $list_details['error'] ) || isset( $account_details['error'] ) || isset( $subscriber_account_details['error'] ) ) { |
|
| 149 | - $error_message = ( isset( $list_details['error'] ) ) ? $list_details['error'] : false; |
|
| 150 | - if( ! $error_message ) { |
|
| 151 | - $error_message = ( isset( $account_details['error'] ) ) ? $account_details['error'] : false; |
|
| 152 | - if( ! $error_message ) { |
|
| 153 | - $error_message = ( isset( $subscriber_account_details['error'] ) ) ? $subscriber_account_details['error'] : false; |
|
| 154 | - if( ! $error_message ) { |
|
| 148 | + if ( isset( $list_details[ 'error' ] ) || isset( $account_details[ 'error' ] ) || isset( $subscriber_account_details[ 'error' ] ) ) { |
|
| 149 | + $error_message = ( isset( $list_details[ 'error' ] ) ) ? $list_details[ 'error' ] : false; |
|
| 150 | + if ( ! $error_message ) { |
|
| 151 | + $error_message = ( isset( $account_details[ 'error' ] ) ) ? $account_details[ 'error' ] : false; |
|
| 152 | + if ( ! $error_message ) { |
|
| 153 | + $error_message = ( isset( $subscriber_account_details[ 'error' ] ) ) ? $subscriber_account_details[ 'error' ] : false; |
|
| 154 | + if ( ! $error_message ) { |
|
| 155 | 155 | $error_message = ''; |
| 156 | 156 | } |
| 157 | 157 | } |
| 158 | 158 | } |
| 159 | - $errorMessage = sprintf( __( 'Error sending update profile email. <strong>Error: %s</strong>. Please contact the site administrator.' , 'yikes-inc-easy-mailchimp-extender' ), $error_message ); |
|
| 159 | + $errorMessage = sprintf( __( 'Error sending update profile email. <strong>Error: %s</strong>. Please contact the site administrator.', 'yikes-inc-easy-mailchimp-extender' ), $error_message ); |
|
| 160 | 160 | wp_send_json_error( |
| 161 | 161 | array( |
| 162 | 162 | 'response_text' => '<div class="yikes-easy-mc-error-message">✕ ' . $errorMessage . '</div>', |
@@ -166,11 +166,11 @@ discard block |
||
| 166 | 166 | } |
| 167 | 167 | |
| 168 | 168 | // send the email! |
| 169 | - $subscriber_id = $subscriber_account_details['data'][0]['id']; |
|
| 170 | - $explode_url = explode( '.' , $account_details['contact']['url'] ); |
|
| 171 | - $update_link_href = 'http://' . $explode_url[1] . '.' . $data_center . '.list-manage1.com/profile?u=' . $account_details['user_id'] . '&id=' . $list_id .'&e=' . $subscriber_id; |
|
| 169 | + $subscriber_id = $subscriber_account_details[ 'data' ][ 0 ][ 'id' ]; |
|
| 170 | + $explode_url = explode( '.', $account_details[ 'contact' ][ 'url' ] ); |
|
| 171 | + $update_link_href = 'http://' . $explode_url[ 1 ] . '.' . $data_center . '.list-manage1.com/profile?u=' . $account_details[ 'user_id' ] . '&id=' . $list_id . '&e=' . $subscriber_id; |
|
| 172 | 172 | $subject = 'MailChimp Profile Update'; |
| 173 | - $headers = 'From: ' . $list_details['data'][0]['default_from_name'] . ' <' . $list_details['data'][0]['default_from_email'] . '>' . "\r\n"; |
|
| 173 | + $headers = 'From: ' . $list_details[ 'data' ][ 0 ][ 'default_from_name' ] . ' <' . $list_details[ 'data' ][ 0 ][ 'default_from_email' ] . '>' . "\r\n"; |
|
| 174 | 174 | $headers .= 'Content-type: text/html'; |
| 175 | 175 | $email_content = '<p>Greetings,</p> <p>A request has been made to update your MailChimp account profile information. To do so please use the following link: <a href="' . $update_link_href . '" title="Update MailChimp Profile">Update MailChimp Profile Info.</a>'; |
| 176 | 176 | $email_content .= "<p>If you did not request this update, please disregard this email.</p>"; |
@@ -183,14 +183,14 @@ discard block |
||
| 183 | 183 | if ( wp_mail( $user_email, apply_filters( 'yikes-mailchimp-update-email-subject', $subject ), apply_filters( 'yikes-mailchimp-update-email-content', $email_content, $update_link_href ), $headers ) ) { |
| 184 | 184 | wp_send_json_success( |
| 185 | 185 | array( |
| 186 | - 'response_text' => '<div class="yikes-easy-mc-success-message">' . sprintf( __( '%s Update email successfully sent. Please check your inbox for the message.' , 'yikes-inc-easy-mailchimp-extender' ), '✔' ) . '</div>', |
|
| 186 | + 'response_text' => '<div class="yikes-easy-mc-success-message">' . sprintf( __( '%s Update email successfully sent. Please check your inbox for the message.', 'yikes-inc-easy-mailchimp-extender' ), '✔' ) . '</div>', |
|
| 187 | 187 | ) |
| 188 | 188 | ); |
| 189 | 189 | exit; |
| 190 | 190 | } else { |
| 191 | 191 | wp_send_json_error( |
| 192 | 192 | array( |
| 193 | - 'response_text' => '<div class="yikes-easy-mc-error-message">' . sprintf( __( '%s Email failed to send. Please contact the site administrator.' , 'yikes-inc-easy-mailchimp-extender' ), '✕' ) . '</div>', |
|
| 193 | + 'response_text' => '<div class="yikes-easy-mc-error-message">' . sprintf( __( '%s Email failed to send. Please contact the site administrator.', 'yikes-inc-easy-mailchimp-extender' ), '✕' ) . '</div>', |
|
| 194 | 194 | ) |
| 195 | 195 | ); |
| 196 | 196 | exit; |
@@ -5,7 +5,7 @@ discard block |
||
| 5 | 5 | */ |
| 6 | 6 | |
| 7 | 7 | // Prevent direct access to the file |
| 8 | - defined('ABSPATH') or die( __( "Whoops, you shouldn't be accessing this file directly. Abort!" , 'yikes-inc-easy-mailchimp-extender' ) ); |
|
| 8 | + defined( 'ABSPATH' ) or die( __( "Whoops, you shouldn't be accessing this file directly. Abort!", 'yikes-inc-easy-mailchimp-extender' ) ); |
|
| 9 | 9 | |
| 10 | 10 | class Yikes_Easy_MC_Checkbox_Integration_Class { |
| 11 | 11 | |
@@ -25,35 +25,35 @@ discard block |
||
| 25 | 25 | */ |
| 26 | 26 | public function is_user_already_subscribed( $integration_type ) { |
| 27 | 27 | // first check if the user is logged in |
| 28 | - if( is_user_logged_in() ) { |
|
| 29 | - $checkbox_options = get_option( 'optin-checkbox-init' , '' ); |
|
| 28 | + if ( is_user_logged_in() ) { |
|
| 29 | + $checkbox_options = get_option( 'optin-checkbox-init', '' ); |
|
| 30 | 30 | $current_user = wp_get_current_user(); |
| 31 | 31 | $email = $current_user->user_email; |
| 32 | 32 | |
| 33 | - $api_key = trim( get_option( 'yikes-mc-api-key' , '' ) ); |
|
| 33 | + $api_key = trim( get_option( 'yikes-mc-api-key', '' ) ); |
|
| 34 | 34 | $dash_position = strpos( $api_key, '-' ); |
| 35 | - if( $dash_position !== false ) { |
|
| 35 | + if ( $dash_position !== false ) { |
|
| 36 | 36 | $api_endpoint = 'https://' . substr( $api_key, $dash_position + 1 ) . '.api.mailchimp.com/2.0/lists/member-info.json'; |
| 37 | 37 | } |
| 38 | 38 | $already_subscribed = wp_remote_post( $api_endpoint, array( |
| 39 | 39 | 'body' => array( |
| 40 | 40 | 'apikey' => $api_key, |
| 41 | - 'id' => $checkbox_options[$integration_type]['associated-list'], |
|
| 41 | + 'id' => $checkbox_options[ $integration_type ][ 'associated-list' ], |
|
| 42 | 42 | 'emails' => array( array( 'email' => sanitize_email( $email ) ) ) |
| 43 | 43 | ), |
| 44 | 44 | 'timeout' => 10, |
| 45 | 45 | 'sslverify' => apply_filters( 'yikes-mailchimp-sslverify', true ) |
| 46 | 46 | ) ); |
| 47 | 47 | $already_subscribed = json_decode( wp_remote_retrieve_body( $already_subscribed ), true ); |
| 48 | - if( isset( $already_subscribed['error'] ) ) { |
|
| 49 | - if( WP_DEBUG || get_option( 'yikes-mailchimp-debug-status' , '' ) == '1' ) { |
|
| 48 | + if ( isset( $already_subscribed[ 'error' ] ) ) { |
|
| 49 | + if ( WP_DEBUG || get_option( 'yikes-mailchimp-debug-status', '' ) == '1' ) { |
|
| 50 | 50 | require_once YIKES_MC_PATH . 'includes/error_log/class-yikes-inc-easy-mailchimp-error-logging.php'; |
| 51 | 51 | $error_logging = new Yikes_Inc_Easy_Mailchimp_Error_Logging(); |
| 52 | - $error_logging->yikes_easy_mailchimp_write_to_error_log( $already_subscribed['error'], __( "Get Member Info" , 'yikes-inc-easy-mailchimp-extender' ), "Checkbox Integrations Page" ); |
|
| 52 | + $error_logging->yikes_easy_mailchimp_write_to_error_log( $already_subscribed[ 'error' ], __( "Get Member Info", 'yikes-inc-easy-mailchimp-extender' ), "Checkbox Integrations Page" ); |
|
| 53 | 53 | } |
| 54 | 54 | } |
| 55 | - if( ! Isset( $already_subscribed['error'] ) ) { |
|
| 56 | - return $already_subscribed['success_count']; |
|
| 55 | + if ( ! Isset( $already_subscribed[ 'error' ] ) ) { |
|
| 56 | + return $already_subscribed[ 'success_count' ]; |
|
| 57 | 57 | } |
| 58 | 58 | } else { |
| 59 | 59 | // if the user isn't logged in |
@@ -69,33 +69,33 @@ discard block |
||
| 69 | 69 | * @$email - users email address entered into the form |
| 70 | 70 | * @$integration_type - pass in the type of checkbox integration |
| 71 | 71 | */ |
| 72 | - public function is_new_registration_already_subscribed( $email , $integration_type ) { |
|
| 72 | + public function is_new_registration_already_subscribed( $email, $integration_type ) { |
|
| 73 | 73 | // first check if the user is logged in |
| 74 | - $checkbox_options = get_option( 'optin-checkbox-init' , '' ); |
|
| 74 | + $checkbox_options = get_option( 'optin-checkbox-init', '' ); |
|
| 75 | 75 | try { |
| 76 | - $api_key = trim( get_option( 'yikes-mc-api-key' , '' ) ); |
|
| 76 | + $api_key = trim( get_option( 'yikes-mc-api-key', '' ) ); |
|
| 77 | 77 | $dash_position = strpos( $api_key, '-' ); |
| 78 | - if( $dash_position !== false ) { |
|
| 78 | + if ( $dash_position !== false ) { |
|
| 79 | 79 | $api_endpoint = 'https://' . substr( $api_key, $dash_position + 1 ) . '.api.mailchimp.com/2.0/lists/member-info.json'; |
| 80 | 80 | } |
| 81 | 81 | $already_subscribed = wp_remote_post( $api_endpoint, array( |
| 82 | 82 | 'body' => array( |
| 83 | 83 | 'apikey' => $api_key, |
| 84 | - 'id' => $checkbox_options[$integration_type]['associated-list'], |
|
| 84 | + 'id' => $checkbox_options[ $integration_type ][ 'associated-list' ], |
|
| 85 | 85 | 'emails' => array( array( 'email' => sanitize_email( $email ) ) ) |
| 86 | 86 | ), |
| 87 | 87 | 'timeout' => 10, |
| 88 | 88 | 'sslverify' => apply_filters( 'yikes-mailchimp-sslverify', true ) |
| 89 | 89 | ) ); |
| 90 | 90 | $already_subscribed = json_decode( wp_remote_retrieve_body( $already_subscribed ), true ); |
| 91 | - if( isset( $already_subscribed['error'] ) ) { |
|
| 92 | - if( WP_DEBUG || get_option( 'yikes-mailchimp-debug-status' , '' ) == '1' ) { |
|
| 91 | + if ( isset( $already_subscribed[ 'error' ] ) ) { |
|
| 92 | + if ( WP_DEBUG || get_option( 'yikes-mailchimp-debug-status', '' ) == '1' ) { |
|
| 93 | 93 | require_once YIKES_MC_PATH . 'includes/error_log/class-yikes-inc-easy-mailchimp-error-logging.php'; |
| 94 | 94 | $error_logging = new Yikes_Inc_Easy_Mailchimp_Error_Logging(); |
| 95 | - $error_logging->yikes_easy_mailchimp_write_to_error_log( $already_subscribed['error'], __( "Get Member Info" , 'yikes-inc-easy-mailchimp-extender' ), "Checkbox Integrations Page" ); |
|
| 95 | + $error_logging->yikes_easy_mailchimp_write_to_error_log( $already_subscribed[ 'error' ], __( "Get Member Info", 'yikes-inc-easy-mailchimp-extender' ), "Checkbox Integrations Page" ); |
|
| 96 | 96 | } |
| 97 | 97 | } |
| 98 | - return $already_subscribed['success_count']; |
|
| 98 | + return $already_subscribed[ 'success_count' ]; |
|
| 99 | 99 | } catch ( Exception $error ) { |
| 100 | 100 | return $error->getMessage(); |
| 101 | 101 | } |
@@ -110,17 +110,17 @@ discard block |
||
| 110 | 110 | // enqueue our checkbox styles whenever the checkbox is displayed |
| 111 | 111 | wp_enqueue_style( 'yikes-easy-mailchimp-checkbox-integration-styles', plugin_dir_url( __FILE__ ) . '../css/yikes-inc-easy-mailchimp-checkbox-integration.min.css' ); |
| 112 | 112 | // store our options |
| 113 | - $checkbox_options = get_option( 'optin-checkbox-init' , '' ); |
|
| 114 | - if( isset( $checkbox_options[$this->type]['associated-list'] ) && $checkbox_options[$this->type]['associated-list'] != '-' ) { |
|
| 115 | - $checked = ( $checkbox_options[$this->type]['precheck'] == 'true' ) ? 'checked' : ''; |
|
| 113 | + $checkbox_options = get_option( 'optin-checkbox-init', '' ); |
|
| 114 | + if ( isset( $checkbox_options[ $this->type ][ 'associated-list' ] ) && $checkbox_options[ $this->type ][ 'associated-list' ] != '-' ) { |
|
| 115 | + $checked = ( $checkbox_options[ $this->type ][ 'precheck' ] == 'true' ) ? 'checked' : ''; |
|
| 116 | 116 | // before checkbox HTML (comment, ...) |
| 117 | 117 | $before = '<!-- Easy Forms for MailChimp by YIKES, Inc. - https://www.yikesinc.com/ -->'; |
| 118 | 118 | $before .= apply_filters( 'yikes-mailchimp-before-checkbox-html', '' ); |
| 119 | 119 | // checkbox |
| 120 | 120 | $content = '<p id="yikes-easy-mailchimp-' . $this->type . '-checkbox" class="yikes-easy-mailchimp-' . $this->type . '-checkbox">'; |
| 121 | 121 | $content .= '<label>'; |
| 122 | - $content .= '<input type="checkbox" name="yikes_mailchimp_checkbox_' . $this->type . '" value="1" '. $checked . ' /> '; |
|
| 123 | - $content .= ( isset( $checkbox_options[$this->type]['label'] ) && trim( $checkbox_options[$this->type]['label'] ) != '' ) ? trim( $checkbox_options[$this->type]['label'] ) : __( 'Sign me up for your mailing list.', 'yikes-inc-easy-mailchimp-extender' ); |
|
| 122 | + $content .= '<input type="checkbox" name="yikes_mailchimp_checkbox_' . $this->type . '" value="1" ' . $checked . ' /> '; |
|
| 123 | + $content .= ( isset( $checkbox_options[ $this->type ][ 'label' ] ) && trim( $checkbox_options[ $this->type ][ 'label' ] ) != '' ) ? trim( $checkbox_options[ $this->type ][ 'label' ] ) : __( 'Sign me up for your mailing list.', 'yikes-inc-easy-mailchimp-extender' ); |
|
| 124 | 124 | $content .= '</label>'; |
| 125 | 125 | $content .= '</p>'; |
| 126 | 126 | // after checkbox HTML (..., honeypot, closing comment) |
@@ -138,43 +138,43 @@ discard block |
||
| 138 | 138 | **/ |
| 139 | 139 | public function subscribe_user_integration( $email, $type, $merge_vars ) { |
| 140 | 140 | // get checkbox data |
| 141 | - $checkbox_options = get_option( 'optin-checkbox-init' , '' ); |
|
| 142 | - if( $type != 'registration_form' ) { |
|
| 141 | + $checkbox_options = get_option( 'optin-checkbox-init', '' ); |
|
| 142 | + if ( $type != 'registration_form' ) { |
|
| 143 | 143 | $update = '1'; |
| 144 | 144 | } else { |
| 145 | 145 | $update = '0'; |
| 146 | 146 | } |
| 147 | 147 | // set ip address |
| 148 | - if( ! isset( $merge_vars['OPTIN_IP'] ) && isset( $_SERVER['REMOTE_ADDR'] ) ) { |
|
| 149 | - $merge_vars['OPTIN_IP'] = sanitize_text_field( $_SERVER['REMOTE_ADDR'] ); |
|
| 148 | + if ( ! isset( $merge_vars[ 'OPTIN_IP' ] ) && isset( $_SERVER[ 'REMOTE_ADDR' ] ) ) { |
|
| 149 | + $merge_vars[ 'OPTIN_IP' ] = sanitize_text_field( $_SERVER[ 'REMOTE_ADDR' ] ); |
|
| 150 | 150 | } |
| 151 | 151 | // set the optin time |
| 152 | - $merge_vars['OPTIN_TIME'] = current_time( 'Y-m-d H:i:s', 1 ); |
|
| 152 | + $merge_vars[ 'OPTIN_TIME' ] = current_time( 'Y-m-d H:i:s', 1 ); |
|
| 153 | 153 | // check for interest groups |
| 154 | - $interest_groups = ( isset( $checkbox_options[$type]['interest-groups'] ) ) ? $checkbox_options[$type]['interest-groups'] : false; |
|
| 154 | + $interest_groups = ( isset( $checkbox_options[ $type ][ 'interest-groups' ] ) ) ? $checkbox_options[ $type ][ 'interest-groups' ] : false; |
|
| 155 | 155 | // if interest groups were found, push them to the merge variable array |
| 156 | - if( $interest_groups ) { |
|
| 157 | - $merge_vars['groupings'] = array(); |
|
| 158 | - foreach( $interest_groups as $interest_group_id => $interest_group_selections ) { |
|
| 156 | + if ( $interest_groups ) { |
|
| 157 | + $merge_vars[ 'groupings' ] = array(); |
|
| 158 | + foreach ( $interest_groups as $interest_group_id => $interest_group_selections ) { |
|
| 159 | 159 | // merge variable interest groups array |
| 160 | - $merge_vars['groupings'][] = array( |
|
| 160 | + $merge_vars[ 'groupings' ][ ] = array( |
|
| 161 | 161 | 'id' => $interest_group_id, |
| 162 | 162 | 'groups' => $interest_group_selections, |
| 163 | 163 | ); |
| 164 | 164 | } |
| 165 | 165 | // replace the interest groups - to avoid any errors thrown if the admin switches lists, or interest groups |
| 166 | - $merge_vars['replace_interests'] = 1; |
|
| 166 | + $merge_vars[ 'replace_interests' ] = 1; |
|
| 167 | 167 | } |
| 168 | 168 | // initialize MailChimp API |
| 169 | - $api_key = trim( get_option( 'yikes-mc-api-key' , '' ) ); |
|
| 169 | + $api_key = trim( get_option( 'yikes-mc-api-key', '' ) ); |
|
| 170 | 170 | $dash_position = strpos( $api_key, '-' ); |
| 171 | - if( $dash_position !== false ) { |
|
| 171 | + if ( $dash_position !== false ) { |
|
| 172 | 172 | $api_endpoint = 'https://' . substr( $api_key, $dash_position + 1 ) . '.api.mailchimp.com/2.0/lists/subscribe.json'; |
| 173 | 173 | } |
| 174 | 174 | $subscribe_response = wp_remote_post( $api_endpoint, array( |
| 175 | 175 | 'body' => apply_filters( 'yikes-mailchimp-checkbox-integration-subscribe-api-request', array( |
| 176 | - 'apikey' => get_option( 'yikes-mc-api-key' , '' ), |
|
| 177 | - 'id' => $checkbox_options[$type]['associated-list'], |
|
| 176 | + 'apikey' => get_option( 'yikes-mc-api-key', '' ), |
|
| 177 | + 'id' => $checkbox_options[ $type ][ 'associated-list' ], |
|
| 178 | 178 | 'email' => array( 'email' => sanitize_email( $email ) ), |
| 179 | 179 | 'merge_vars' => apply_filters( 'yikes-mailchimp-checkbox-integration-merge-variables', $merge_vars, $type ), // filter merge variables |
| 180 | 180 | 'double_optin' => 1, |
@@ -184,13 +184,13 @@ discard block |
||
| 184 | 184 | 'timeout' => 10, |
| 185 | 185 | 'sslverify' => apply_filters( 'yikes-mailchimp-sslverify', true ) |
| 186 | 186 | ) ); |
| 187 | - if( ! Is_wp_error( $subscribe_response ) ) { |
|
| 187 | + if ( ! Is_wp_error( $subscribe_response ) ) { |
|
| 188 | 188 | $response_body = json_decode( wp_remote_retrieve_body( $subscribe_response ), true ); |
| 189 | - if( WP_DEBUG || isset( $response_body['error'] ) ) { |
|
| 190 | - if( get_option( 'yikes-mailchimp-debug-status' , '' ) == '1' ) { |
|
| 189 | + if ( WP_DEBUG || isset( $response_body[ 'error' ] ) ) { |
|
| 190 | + if ( get_option( 'yikes-mailchimp-debug-status', '' ) == '1' ) { |
|
| 191 | 191 | require_once YIKES_MC_PATH . 'includes/error_log/class-yikes-inc-easy-mailchimp-error-logging.php'; |
| 192 | 192 | $error_logging = new Yikes_Inc_Easy_Mailchimp_Error_Logging(); |
| 193 | - $error_logging->yikes_easy_mailchimp_write_to_error_log( $response_body['error'], __( "Checkbox Integration Subscribe User" , 'yikes-inc-easy-mailchimp-extender' ), "Checkbox Integrations" ); |
|
| 193 | + $error_logging->yikes_easy_mailchimp_write_to_error_log( $response_body[ 'error' ], __( "Checkbox Integration Subscribe User", 'yikes-inc-easy-mailchimp-extender' ), "Checkbox Integrations" ); |
|
| 194 | 194 | } |
| 195 | 195 | } |
| 196 | 196 | } |
@@ -206,15 +206,15 @@ discard block |
||
| 206 | 206 | $merge_vars = array( |
| 207 | 207 | 'NAME' => $user->user_login, |
| 208 | 208 | ); |
| 209 | - if( '' !== $user->first_name ) { |
|
| 210 | - $merge_vars['NAME'] = $user->first_name; |
|
| 211 | - $merge_vars['FNAME'] = $user->first_name; |
|
| 209 | + if ( '' !== $user->first_name ) { |
|
| 210 | + $merge_vars[ 'NAME' ] = $user->first_name; |
|
| 211 | + $merge_vars[ 'FNAME' ] = $user->first_name; |
|
| 212 | 212 | } |
| 213 | - if( '' !== $user->last_name ) { |
|
| 214 | - $merge_vars['LNAME'] = $user->last_name; |
|
| 213 | + if ( '' !== $user->last_name ) { |
|
| 214 | + $merge_vars[ 'LNAME' ] = $user->last_name; |
|
| 215 | 215 | } |
| 216 | - if( '' !== $user->first_name && '' !== $user->last_name ) { |
|
| 217 | - $merge_vars['NAME'] = sprintf( '%s %s', $user->first_name, $user->last_name ); |
|
| 216 | + if ( '' !== $user->first_name && '' !== $user->last_name ) { |
|
| 217 | + $merge_vars[ 'NAME' ] = sprintf( '%s %s', $user->first_name, $user->last_name ); |
|
| 218 | 218 | } |
| 219 | 219 | /** |
| 220 | 220 | * @filter `yikes-mailchimp-user-merge-vars` |
@@ -235,7 +235,7 @@ discard block |
||
| 235 | 235 | */ |
| 236 | 236 | public function was_checkbox_checked( $type ) { |
| 237 | 237 | // was sign-up checkbox checked - return the value |
| 238 | - return ( isset( $_POST[ 'yikes_mailchimp_checkbox_'.$type ] ) && $_POST[ 'yikes_mailchimp_checkbox_'.$type ] == 1 ); |
|
| 238 | + return ( isset( $_POST[ 'yikes_mailchimp_checkbox_' . $type ] ) && $_POST[ 'yikes_mailchimp_checkbox_' . $type ] == 1 ); |
|
| 239 | 239 | } |
| 240 | 240 | |
| 241 | 241 | |
@@ -245,15 +245,15 @@ discard block |
||
| 245 | 245 | * @since 6.0.0 |
| 246 | 246 | **/ |
| 247 | 247 | public function yikes_reg_complete_msg( $errors, $redirect_to ) { |
| 248 | - if( isset( $errors->errors['registered'] ) ) { |
|
| 249 | - $email_error = get_option( 'yikes_register_subscription_error' , '' ); |
|
| 250 | - if( isset( $email_error ) && $email_error != '' ) { |
|
| 248 | + if ( isset( $errors->errors[ 'registered' ] ) ) { |
|
| 249 | + $email_error = get_option( 'yikes_register_subscription_error', '' ); |
|
| 250 | + if ( isset( $email_error ) && $email_error != '' ) { |
|
| 251 | 251 | // Use the magic __get method to retrieve the errors array: |
| 252 | 252 | $tmp = $errors->errors; |
| 253 | 253 | $old = 'Registration complete. Please check your e-mail.'; |
| 254 | - foreach( $tmp['registered'] as $index => $msg ) { |
|
| 255 | - if( $msg === $old ) { |
|
| 256 | - $tmp['registered'][$index] = $old . ' <p class="message"><strong>' . __( 'Note' , 'yikes-inc-easy-mailchimp-extender' ) . '</strong>: ' . $email_error . '</p>'; |
|
| 254 | + foreach ( $tmp[ 'registered' ] as $index => $msg ) { |
|
| 255 | + if ( $msg === $old ) { |
|
| 256 | + $tmp[ 'registered' ][ $index ] = $old . ' <p class="message"><strong>' . __( 'Note', 'yikes-inc-easy-mailchimp-extender' ) . '</strong>: ' . $email_error . '</p>'; |
|
| 257 | 257 | } |
| 258 | 258 | } |
| 259 | 259 | // Use the magic __set method to override the errors property: |