@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | <?php |
| 24 | 24 | } |
| 25 | 25 | $main_field_data = $section_data['main_fields']; |
| 26 | - foreach( $main_field_data as $field ) { |
|
| 26 | + foreach( $main_field_data as $field ) { |
|
| 27 | 27 | if( $field['type'] == 'custom' ) { |
| 28 | 28 | // execute the custom callback |
| 29 | 29 | $field['callback'](); |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | <?php |
| 54 | 54 | } |
| 55 | 55 | $sidebar_field_data = $section_data['sidebar_fields']; |
| 56 | - foreach( $sidebar_field_data as $field ) { |
|
| 56 | + foreach( $sidebar_field_data as $field ) { |
|
| 57 | 57 | if( $field['type'] == 'custom' ) { |
| 58 | 58 | // execute the custom callback |
| 59 | 59 | $field['callback'](); |
@@ -54,7 +54,8 @@ |
||
| 54 | 54 | foreach( $new_settings as $option_name => $option_value ) { |
| 55 | 55 | update_option( $option_name, $option_value ); |
| 56 | 56 | } |
| 57 | - } else { // if it's not, then it's an opt-in forms import |
|
| 57 | + } else { |
|
| 58 | +// if it's not, then it's an opt-in forms import |
|
| 58 | 59 | // If this is the first row, then it should be title data. |
| 59 | 60 | if ( 1 === $row ) { |
| 60 | 61 | $titles = $line; |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | * @subpackage Yikes_Inc_Easy_Mailchimp_Extender/includes |
| 19 | 19 | * @author YIKES Inc. <[email protected]> |
| 20 | 20 | */ |
| 21 | -class Yikes_Inc_Easy_Mailchimp_Extender_Activator {
|
|
| 21 | +class Yikes_Inc_Easy_Mailchimp_Extender_Activator { |
|
| 22 | 22 | /** |
| 23 | 23 | * Short Description. Activation hook. |
| 24 | 24 | * |
@@ -26,16 +26,16 @@ discard block |
||
| 26 | 26 | * |
| 27 | 27 | * @since 6.0.0 |
| 28 | 28 | */ |
| 29 | - public static function activate( $network_wide ) {
|
|
| 29 | + public static function activate( $network_wide ) { |
|
| 30 | 30 | global $wpdb; |
| 31 | 31 | |
| 32 | - if ( function_exists( 'is_multisite' ) && is_multisite() ) {
|
|
| 32 | + if ( function_exists( 'is_multisite' ) && is_multisite() ) { |
|
| 33 | 33 | // check if it is a network activation - if so, run the activation function for each blog id |
| 34 | - if ( $network_wide ) {
|
|
| 34 | + if ( $network_wide ) { |
|
| 35 | 35 | $old_blog = $wpdb->blogid; |
| 36 | 36 | // Get all blog ids |
| 37 | 37 | $blogids = $wpdb->get_col("SELECT blog_id FROM $wpdb->blogs");
|
| 38 | - foreach ( $blogids as $blog_id ) {
|
|
| 38 | + foreach ( $blogids as $blog_id ) { |
|
| 39 | 39 | switch_to_blog( $blog_id ); |
| 40 | 40 | self::_activate_yikes_easy_mailchimp( $wpdb ); |
| 41 | 41 | restore_current_blog(); |
@@ -44,7 +44,8 @@ discard block |
||
| 44 | 44 | return; |
| 45 | 45 | } |
| 46 | 46 | self::_activate_yikes_easy_mailchimp( $wpdb ); |
| 47 | - } else { /* end network activate */
|
|
| 47 | + } else { |
|
| 48 | +/* end network activate */ |
|
| 48 | 49 | self::_activate_yikes_easy_mailchimp( $wpdb ); |
| 49 | 50 | } |
| 50 | 51 | } |
@@ -56,7 +57,7 @@ discard block |
||
| 56 | 57 | * |
| 57 | 58 | * @since 6.0.0 |
| 58 | 59 | */ |
| 59 | - static function _activate_yikes_easy_mailchimp( $wpdb ) {
|
|
| 60 | + static function _activate_yikes_easy_mailchimp( $wpdb ) { |
|
| 60 | 61 | |
| 61 | 62 | // single site |
| 62 | 63 | $custom_table_name = $wpdb->prefix . 'yikes_easy_mc_forms'; |
@@ -95,12 +96,12 @@ discard block |
||
| 95 | 96 | |
| 96 | 97 | // create an option for the date that the user initially activated the plugin |
| 97 | 98 | // used to display a two week notice, asking for a review or to upgrade |
| 98 | - if ( ! get_option( 'yikes_easy_mailchimp_activation_date' ) || get_option( 'yikes_easy_mailchimp_activation_date' ) == '' ) {
|
|
| 99 | + if ( ! get_option( 'yikes_easy_mailchimp_activation_date' ) || get_option( 'yikes_easy_mailchimp_activation_date' ) == '' ) { |
|
| 99 | 100 | update_option( 'yikes_easy_mailchimp_activation_date', strtotime( 'now' ) ); |
| 100 | 101 | } |
| 101 | 102 | |
| 102 | 103 | // Create an option for the forms. |
| 103 | - if ( class_exists( 'Yikes_Inc_Easy_MailChimp_Extender_Option_Forms' ) ) {
|
|
| 104 | + if ( class_exists( 'Yikes_Inc_Easy_MailChimp_Extender_Option_Forms' ) ) { |
|
| 104 | 105 | $option_class = new Yikes_Inc_Easy_MailChimp_Extender_Option_Forms(); |
| 105 | 106 | $option_class->create_option(); |
| 106 | 107 | } |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | * @subpackage Yikes_Inc_Easy_Mailchimp_Extender/includes |
| 26 | 26 | * @author YIKES Inc. <[email protected]> |
| 27 | 27 | */ |
| 28 | -class Yikes_Inc_Easy_Mailchimp_Extender {
|
|
| 28 | +class Yikes_Inc_Easy_Mailchimp_Extender { |
|
| 29 | 29 | /** |
| 30 | 30 | * The loader that's responsible for maintaining and registering all hooks that power |
| 31 | 31 | * the plugin. |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | * |
| 71 | 71 | * @param Yikes_Inc_Easy_MailChimp_Extender_Form_Interface $form_interface |
| 72 | 72 | */ |
| 73 | - public function __construct( Yikes_Inc_Easy_MailChimp_Extender_Form_Interface $form_interface ) {
|
|
| 73 | + public function __construct( Yikes_Inc_Easy_MailChimp_Extender_Form_Interface $form_interface ) { |
|
| 74 | 74 | $this->version = YIKES_MC_VERSION; |
| 75 | 75 | $this->form_interface = $form_interface; |
| 76 | 76 | $this->load_dependencies(); |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | * @since 1.0.0 |
| 94 | 94 | * @access private |
| 95 | 95 | */ |
| 96 | - private function load_dependencies() {
|
|
| 96 | + private function load_dependencies() { |
|
| 97 | 97 | /** |
| 98 | 98 | * The class responsible for orchestrating the actions and filters of the |
| 99 | 99 | * core plugin. |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | * @since 1.0.0 |
| 118 | 118 | * @access private |
| 119 | 119 | */ |
| 120 | - private function define_admin_hooks() {
|
|
| 120 | + private function define_admin_hooks() { |
|
| 121 | 121 | $plugin_admin = new Yikes_Inc_Easy_Mailchimp_Forms_Admin( $this->get_yikes_inc_easy_mailchimp_extender(), $this->get_version(), $this->form_interface ); |
| 122 | 122 | $plugin_admin->hooks(); |
| 123 | 123 | $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' ); |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | * @since 1.0.0 |
| 131 | 131 | * @access private |
| 132 | 132 | */ |
| 133 | - private function define_public_hooks() {
|
|
| 133 | + private function define_public_hooks() { |
|
| 134 | 134 | $plugin_public = new Yikes_Inc_Easy_Mailchimp_Extender_Public( $this->get_yikes_inc_easy_mailchimp_extender(), $this->get_version() ); |
| 135 | 135 | } |
| 136 | 136 | /** |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | * |
| 139 | 139 | * @since 1.0.0 |
| 140 | 140 | */ |
| 141 | - public function run() {
|
|
| 141 | + public function run() { |
|
| 142 | 142 | $this->loader->run(); |
| 143 | 143 | } |
| 144 | 144 | /** |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | * @since 1.0.0 |
| 149 | 149 | * @return string The name of the plugin. |
| 150 | 150 | */ |
| 151 | - public function get_yikes_inc_easy_mailchimp_extender() {
|
|
| 151 | + public function get_yikes_inc_easy_mailchimp_extender() { |
|
| 152 | 152 | return $this->yikes_inc_easy_mailchimp_extender; |
| 153 | 153 | } |
| 154 | 154 | /** |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | * @since 1.0.0 |
| 158 | 158 | * @return Yikes_Inc_Easy_Mailchimp_Extender_Loader Orchestrates the hooks of the plugin. |
| 159 | 159 | */ |
| 160 | - public function get_loader() {
|
|
| 160 | + public function get_loader() { |
|
| 161 | 161 | return $this->loader; |
| 162 | 162 | } |
| 163 | 163 | /** |
@@ -166,7 +166,7 @@ discard block |
||
| 166 | 166 | * @since 1.0.0 |
| 167 | 167 | * @return string The version number of the plugin. |
| 168 | 168 | */ |
| 169 | - public function get_version() {
|
|
| 169 | + public function get_version() { |
|
| 170 | 170 | return $this->version; |
| 171 | 171 | } |
| 172 | 172 | } |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | * @subpackage Yikes_Inc_Easy_Mailchimp_Extender/includes |
| 20 | 20 | * @author YIKES Inc. <[email protected]> |
| 21 | 21 | */ |
| 22 | -class Yikes_Inc_Easy_Mailchimp_Extender_Loader {
|
|
| 22 | +class Yikes_Inc_Easy_Mailchimp_Extender_Loader { |
|
| 23 | 23 | /** |
| 24 | 24 | * The array of actions registered with WordPress. |
| 25 | 25 | * |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | * |
| 42 | 42 | * @since 6.0.0 |
| 43 | 43 | */ |
| 44 | - public function __construct() {
|
|
| 44 | + public function __construct() { |
|
| 45 | 45 | $this->actions = array(); |
| 46 | 46 | $this->filters = array(); |
| 47 | 47 | } |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | * @param int Optional $priority The priority at which the function should be fired. |
| 56 | 56 | * @param int Optional $accepted_args The number of arguments that should be passed to the $callback. |
| 57 | 57 | */ |
| 58 | - public function add_action( $hook, $component, $callback, $priority = 10, $accepted_args = 1 ) {
|
|
| 58 | + public function add_action( $hook, $component, $callback, $priority = 10, $accepted_args = 1 ) { |
|
| 59 | 59 | $this->actions = $this->add( $this->actions, $hook, $component, $callback, $priority, $accepted_args ); |
| 60 | 60 | } |
| 61 | 61 | /** |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | * @param int Optional $priority The priority at which the function should be fired. |
| 69 | 69 | * @param int Optional $accepted_args The number of arguments that should be passed to the $callback. |
| 70 | 70 | */ |
| 71 | - public function add_filter( $hook, $component, $callback, $priority = 10, $accepted_args = 1 ) {
|
|
| 71 | + public function add_filter( $hook, $component, $callback, $priority = 10, $accepted_args = 1 ) { |
|
| 72 | 72 | $this->filters = $this->add( $this->filters, $hook, $component, $callback, $priority, $accepted_args ); |
| 73 | 73 | } |
| 74 | 74 | /** |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | * @param int Optional $accepted_args The number of arguments that should be passed to the $callback. |
| 86 | 86 | * @return type The collection of actions and filters registered with WordPress. |
| 87 | 87 | */ |
| 88 | - private function add( $hooks, $hook, $component, $callback, $priority, $accepted_args ) {
|
|
| 88 | + private function add( $hooks, $hook, $component, $callback, $priority, $accepted_args ) { |
|
| 89 | 89 | $hooks[] = array( |
| 90 | 90 | 'hook' => $hook, |
| 91 | 91 | 'component' => $component, |
@@ -100,11 +100,11 @@ discard block |
||
| 100 | 100 | * |
| 101 | 101 | * @since 6.0.0 |
| 102 | 102 | */ |
| 103 | - public function run() {
|
|
| 104 | - foreach ( $this->filters as $hook ) {
|
|
| 103 | + public function run() { |
|
| 104 | + foreach ( $this->filters as $hook ) { |
|
| 105 | 105 | add_filter( $hook['hook'], array( $hook['component'], $hook['callback'] ), $hook['priority'], $hook['accepted_args'] ); |
| 106 | 106 | } |
| 107 | - foreach ( $this->actions as $hook ) {
|
|
| 107 | + foreach ( $this->actions as $hook ) { |
|
| 108 | 108 | add_action( $hook['hook'], array( $hook['component'], $hook['callback'] ), $hook['priority'], $hook['accepted_args'] ); |
| 109 | 109 | } |
| 110 | 110 | } |
@@ -133,7 +133,8 @@ |
||
| 133 | 133 | if( $form_id ) { |
| 134 | 134 | $form_settings = self::yikes_retrieve_form_settings( $form_id ); |
| 135 | 135 | if( isset( $_POST ) && !empty( $_POST ) && isset( $form_id ) && $form_settings['submission_settings']['ajax'] == 0 ) { |
| 136 | - if( $_POST['yikes-mailchimp-submitted-form'] == $form_id ) { // ensure we only process the form that was submitted |
|
| 136 | + if( $_POST['yikes-mailchimp-submitted-form'] == $form_id ) { |
|
| 137 | +// ensure we only process the form that was submitted |
|
| 137 | 138 | |
| 138 | 139 | // Lets include our form processing file |
| 139 | 140 | include_once( YIKES_MC_PATH . 'public/partials/shortcodes/process/process_form_submission.php' ); |
@@ -474,7 +474,9 @@ discard block |
||
| 474 | 474 | $field_array['required'] = isset( $field['require'] ) ? 'required="required"' : ''; |
| 475 | 475 | $label_array['visible'] = isset( $field['hide'] ) ? 'style="display:none;"' : ''; |
| 476 | 476 | $label_class_array[] = ( $tag === 'merge' ) ? $field['merge'] . '-label' : $field['group_id'] . '-label'; |
| 477 | - if ( isset( $field['require'] ) ) $label_class_array[] = 'yikes-mailchimp-field-required'; |
|
| 477 | + if ( isset( $field['require'] ) ) { |
|
| 478 | + $label_class_array[] = 'yikes-mailchimp-field-required'; |
|
| 479 | + } |
|
| 478 | 480 | } |
| 479 | 481 | |
| 480 | 482 | // if both hide label and hide field are checked, we gotta hide the field! |
@@ -761,7 +763,7 @@ discard block |
||
| 761 | 763 | } else { |
| 762 | 764 | $zip_value = $_POST[$field['merge']]; |
| 763 | 765 | } |
| 764 | - } else { |
|
| 766 | + } else { |
|
| 765 | 767 | |
| 766 | 768 | /** |
| 767 | 769 | * A filter to set the default zip code value. |
@@ -1125,7 +1127,7 @@ discard block |
||
| 1125 | 1127 | echo $no_default === true ? '<option value="">' . $no_default_name . '</option>' : ''; |
| 1126 | 1128 | |
| 1127 | 1129 | $i = 0; |
| 1128 | - foreach( $groups as $group_id => $name ) { |
|
| 1130 | + foreach( $groups as $group_id => $name ) { |
|
| 1129 | 1131 | |
| 1130 | 1132 | // If the form was submitted and failed, set the submitted/chosen values as the default |
| 1131 | 1133 | if( isset( $_POST[ 'group-' . $field['group_id'] ] ) && $form_submitted === 0 ) { |
@@ -1174,7 +1176,7 @@ discard block |
||
| 1174 | 1176 | // Turn $default_choice into an array if it isn't already |
| 1175 | 1177 | $default_choice = ( isset( $default_choice ) && is_array( $default_choice ) ) ? $default_choice : array( $default_choice ); |
| 1176 | 1178 | |
| 1177 | - foreach( $groups as $group_id => $name ) { |
|
| 1179 | + foreach( $groups as $group_id => $name ) { |
|
| 1178 | 1180 | ?> |
| 1179 | 1181 | <label for="<?php echo esc_attr( $field['group_id'] ) . '-' . $i; ?>" class="yikes-easy-mc-checkbox-label <?php echo implode( ' ' , $custom_classes ); if ( $x === $count ) { echo ' last-selection'; } ?>" style="display:none;"> |
| 1180 | 1182 | <input |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | * @subpackage Yikes_Inc_Easy_Mailchimp_Extender/includes |
| 26 | 26 | * @author YIKES Inc. <[email protected]> |
| 27 | 27 | */ |
| 28 | -class Yikes_Inc_Easy_Mailchimp_Error_Logging {
|
|
| 28 | +class Yikes_Inc_Easy_Mailchimp_Error_Logging { |
|
| 29 | 29 | |
| 30 | 30 | /** |
| 31 | 31 | * Whether we're doing debugging. |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | * |
| 58 | 58 | * @since 1.0.0 |
| 59 | 59 | */ |
| 60 | - public function __construct() {
|
|
| 60 | + public function __construct() { |
|
| 61 | 61 | $this->is_debugging = WP_DEBUG || (string) get_option( 'yikes-mailchimp-debug-status', '' ) === '1'; |
| 62 | 62 | $this->error_log_file_path = $this->get_error_log_file_path(); |
| 63 | 63 | $this->error_log_folder_path = $this->get_error_log_folder(); |
@@ -78,35 +78,35 @@ discard block |
||
| 78 | 78 | * @param string $error_type The error type. |
| 79 | 79 | * @param string $page The page information. |
| 80 | 80 | */ |
| 81 | - public function maybe_write_to_log( $returned_error, $error_type, $page = '' ) {
|
|
| 82 | - if ( ! $this->is_debugging ) {
|
|
| 81 | + public function maybe_write_to_log( $returned_error, $error_type, $page = '' ) { |
|
| 82 | + if ( ! $this->is_debugging ) { |
|
| 83 | 83 | return; |
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | $this->yikes_easy_mailchimp_write_to_error_log( $returned_error, $error_type, $page ); |
| 87 | 87 | } |
| 88 | 88 | |
| 89 | - public function create_error_log_folder() {
|
|
| 89 | + public function create_error_log_folder() { |
|
| 90 | 90 | |
| 91 | 91 | // If our directory doesn't exist, make it. |
| 92 | - if ( ! file_exists( $this->get_error_log_folder() ) ) {
|
|
| 92 | + if ( ! file_exists( $this->get_error_log_folder() ) ) { |
|
| 93 | 93 | mkdir( $this->get_error_log_folder() ); |
| 94 | 94 | } |
| 95 | 95 | } |
| 96 | 96 | |
| 97 | - public function create_error_log_file() {
|
|
| 97 | + public function create_error_log_file() { |
|
| 98 | 98 | |
| 99 | 99 | // If our error log doesn't exist, make it. |
| 100 | - if ( ! file_exists( $this->error_log_file_path ) ) {
|
|
| 100 | + if ( ! file_exists( $this->error_log_file_path ) ) { |
|
| 101 | 101 | file_put_contents( $this->error_log_file_path, '' ); |
| 102 | 102 | } |
| 103 | 103 | } |
| 104 | 104 | |
| 105 | - private function get_error_log_folder() {
|
|
| 105 | + private function get_error_log_folder() { |
|
| 106 | 106 | return WP_CONTENT_DIR . '/uploads/yikes-log/'; |
| 107 | 107 | } |
| 108 | 108 | |
| 109 | - private function get_error_log_file_path() {
|
|
| 109 | + private function get_error_log_file_path() { |
|
| 110 | 110 | return WP_CONTENT_DIR . '/uploads/yikes-log/yikes-easy-mailchimp-error-log.txt'; |
| 111 | 111 | } |
| 112 | 112 | |
@@ -122,17 +122,17 @@ discard block |
||
| 122 | 122 | * @returned_error |
| 123 | 123 | * @error_type - what was running when the error occured ie (new user subscription, remove user etc) |
| 124 | 124 | */ |
| 125 | - public function yikes_easy_mailchimp_write_to_error_log( $returned_error , $error_type , $page='' ) {
|
|
| 125 | + public function yikes_easy_mailchimp_write_to_error_log( $returned_error , $error_type , $page='' ) { |
|
| 126 | 126 | |
| 127 | 127 | // confirm error logging is toggled on, else lets exit |
| 128 | - if( get_option( 'yikes-mailchimp-debug-status' , '' ) != '1' ) {
|
|
| 128 | + if( get_option( 'yikes-mailchimp-debug-status' , '' ) != '1' ) { |
|
| 129 | 129 | return; |
| 130 | 130 | } |
| 131 | 131 | |
| 132 | 132 | $contents = file_get_contents( $this->error_log_file_path, true ); |
| 133 | 133 | |
| 134 | 134 | // if we pass in a custom page, don't set things up |
| 135 | - if ( empty( $page ) ) {
|
|
| 135 | + if ( empty( $page ) ) { |
|
| 136 | 136 | |
| 137 | 137 | // get the current page, admin or front end? |
| 138 | 138 | $page = is_admin() ? __( 'Admin', 'yikes-inc-easy-mailchimp-extender' ) : __( 'Front End', 'yikes-inc-easy-mailchimp-extender' ); |
@@ -168,20 +168,20 @@ discard block |
||
| 168 | 168 | * |
| 169 | 169 | * @since 5.6 |
| 170 | 170 | */ |
| 171 | - public function yikes_easy_mailchimp_generate_error_log_table() {
|
|
| 171 | + public function yikes_easy_mailchimp_generate_error_log_table() { |
|
| 172 | 172 | |
| 173 | 173 | // ensure file_get_contents exists |
| 174 | - if( function_exists( 'file_get_contents' ) ) {
|
|
| 174 | + if( function_exists( 'file_get_contents' ) ) { |
|
| 175 | 175 | // confirm that our file exists |
| 176 | - if( file_exists( $this->error_log_file_path ) ) {
|
|
| 176 | + if( file_exists( $this->error_log_file_path ) ) { |
|
| 177 | 177 | $error_log_contents = file_get_contents( $this->error_log_file_path, true ); |
| 178 | - if( $error_log_contents === FALSE ) {
|
|
| 178 | + if( $error_log_contents === FALSE ) { |
|
| 179 | 179 | return _e( 'File get contents not available' , 'yikes-inc-easy-mailchimp-extender' ); |
| 180 | 180 | } |
| 181 | - if ( $error_log_contents != '' ) {
|
|
| 181 | + if ( $error_log_contents != '' ) { |
|
| 182 | 182 | // return $error_log_contents; |
| 183 | 183 | print_r( $error_log_contents ); |
| 184 | - } else {
|
|
| 184 | + } else { |
|
| 185 | 185 | ?> |
| 186 | 186 | <!-- table body --> |
| 187 | 187 | <tr class="error-log-tr"> |
@@ -195,7 +195,7 @@ discard block |
||
| 195 | 195 | </tr> |
| 196 | 196 | <?php |
| 197 | 197 | } |
| 198 | - } else {
|
|
| 198 | + } else { |
|
| 199 | 199 | ?> |
| 200 | 200 | <!-- table body --> |
| 201 | 201 | <tr class="error-log-tr"> |
@@ -223,7 +223,8 @@ discard block |
||
| 223 | 223 | </tr> |
| 224 | 224 | <?php |
| 225 | 225 | } |
| 226 | - } else { // if file_get_contents is disabled server side
|
|
| 226 | + } else { |
|
| 227 | +// if file_get_contents is disabled server side |
|
| 227 | 228 | ?> |
| 228 | 229 | <!-- table body --> |
| 229 | 230 | <tr> |
@@ -9,7 +9,7 @@ discard block |
||
| 9 | 9 | /** |
| 10 | 10 | * Main Checkbox Integration class. |
| 11 | 11 | */ |
| 12 | -class Yikes_Easy_MC_Checkbox_Integration_Class {
|
|
| 12 | +class Yikes_Easy_MC_Checkbox_Integration_Class { |
|
| 13 | 13 | |
| 14 | 14 | /** |
| 15 | 15 | * The integration type. |
@@ -28,10 +28,10 @@ discard block |
||
| 28 | 28 | * |
| 29 | 29 | * @return bool Whether the current user is subscribed to a list. |
| 30 | 30 | */ |
| 31 | - public function is_user_already_subscribed( $type, $email = '' ) {
|
|
| 31 | + public function is_user_already_subscribed( $type, $email = '' ) { |
|
| 32 | 32 | // Make sure we have an email address to use. |
| 33 | - if ( empty( $email ) ) {
|
|
| 34 | - if ( ! is_user_logged_in() ) {
|
|
| 33 | + if ( empty( $email ) ) { |
|
| 34 | + if ( ! is_user_logged_in() ) { |
|
| 35 | 35 | return false; |
| 36 | 36 | } |
| 37 | 37 | |
@@ -40,13 +40,13 @@ discard block |
||
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | // Ensure we have a valid email. |
| 43 | - if ( ! is_email( $email ) ) {
|
|
| 43 | + if ( ! is_email( $email ) ) { |
|
| 44 | 44 | return false; |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | // Convert the integration type to a list ID. |
| 48 | 48 | $checkbox_options = get_option( 'optin-checkbox-init', '' ); |
| 49 | - if ( empty( $checkbox_options ) || ! isset( $checkbox_options[ $type ] ) || ! isset( $checkbox_options[ $type ]['associated-list'] ) ) {
|
|
| 49 | + if ( empty( $checkbox_options ) || ! isset( $checkbox_options[ $type ] ) || ! isset( $checkbox_options[ $type ]['associated-list'] ) ) { |
|
| 50 | 50 | return false; |
| 51 | 51 | } |
| 52 | 52 | |
@@ -54,8 +54,8 @@ discard block |
||
| 54 | 54 | $list_ids = is_array( $list_ids ) ? $list_ids : array( $list_ids ); |
| 55 | 55 | |
| 56 | 56 | // Go through each list... |
| 57 | - foreach ( $list_ids as $list_id ) {
|
|
| 58 | - if ( ! $this->is_user_subscribed( $email, $list_id, $type ) ) {
|
|
| 57 | + foreach ( $list_ids as $list_id ) { |
|
| 58 | + if ( ! $this->is_user_subscribed( $email, $list_id, $type ) ) { |
|
| 59 | 59 | return false; |
| 60 | 60 | } |
| 61 | 61 | } |
@@ -74,19 +74,19 @@ discard block |
||
| 74 | 74 | * |
| 75 | 75 | * @return bool Whether the email is subscribed to the list. |
| 76 | 76 | */ |
| 77 | - public function is_user_subscribed( $email, $list_id, $type ) {
|
|
| 77 | + public function is_user_subscribed( $email, $list_id, $type ) { |
|
| 78 | 78 | $email = sanitize_email( $email ); |
| 79 | 79 | $email_hash = md5( $email ); |
| 80 | 80 | |
| 81 | 81 | // Check the API to see the status. |
| 82 | 82 | $response = yikes_get_mc_api_manager()->get_list_handler()->get_member( $list_id, $email_hash, false ); |
| 83 | - if ( is_wp_error( $response ) ) {
|
|
| 83 | + if ( is_wp_error( $response ) ) { |
|
| 84 | 84 | $data = $response->get_error_data(); |
| 85 | 85 | |
| 86 | 86 | // If the error response is a 404, they are not subscribed. |
| 87 | - if ( isset( $data['status'] ) && 404 === (int) $data['status'] ) {
|
|
| 87 | + if ( isset( $data['status'] ) && 404 === (int) $data['status'] ) { |
|
| 88 | 88 | return false; |
| 89 | - } else {
|
|
| 89 | + } else { |
|
| 90 | 90 | $error_logging = new Yikes_Inc_Easy_Mailchimp_Error_Logging(); |
| 91 | 91 | $error_logging->maybe_write_to_log( |
| 92 | 92 | $response->get_error_code(), |
@@ -110,14 +110,14 @@ discard block |
||
| 110 | 110 | * |
| 111 | 111 | * @return string The HTML for the checkbox. |
| 112 | 112 | */ |
| 113 | - public function yikes_get_checkbox() {
|
|
| 113 | + public function yikes_get_checkbox() { |
|
| 114 | 114 | |
| 115 | 115 | // Get our options. |
| 116 | 116 | $checkbox_options = get_option( 'optin-checkbox-init', array() ); |
| 117 | 117 | $has_list_ids = isset( $checkbox_options[ $this->type ]['associated-list'] ) && '-' !== $checkbox_options[ $this->type ]['associated-list']; |
| 118 | 118 | $has_list_ids = $has_list_ids && ! in_array( '-', $checkbox_options[ $this->type ]['associated-list'], true ); |
| 119 | 119 | |
| 120 | - if ( $has_list_ids ) {
|
|
| 120 | + if ( $has_list_ids ) { |
|
| 121 | 121 | $label = isset( $checkbox_options[ $this->type ]['label'] ) && ! empty( $checkbox_options[ $this->type ]['label'] ) ? trim( $checkbox_options[ $this->type ]['label'] ) : __( 'Sign me up for your mailing list.', 'yikes-inc-easy-mailchimp-extender' ); |
| 122 | 122 | $checked = 'true' === $checkbox_options[ $this->type ]['precheck'] ? 'checked="checked"' : ''; |
| 123 | 123 | $before = apply_filters( 'yikes-mailchimp-before-checkbox-html', '' ); |
@@ -144,11 +144,11 @@ discard block |
||
| 144 | 144 | * @param string $type The integration type. |
| 145 | 145 | * @param array $merge_vars The array of form data to send. |
| 146 | 146 | */ |
| 147 | - public function subscribe_user_integration( $email, $type, $merge_vars ) {
|
|
| 147 | + public function subscribe_user_integration( $email, $type, $merge_vars ) { |
|
| 148 | 148 | $options = get_option( 'optin-checkbox-init', '' ); |
| 149 | 149 | |
| 150 | 150 | // Make sure we have a list ID. |
| 151 | - if ( ! isset( $options[ $type ] ) || ! isset( $options[ $type ]['associated-list'] ) ) {
|
|
| 151 | + if ( ! isset( $options[ $type ] ) || ! isset( $options[ $type ]['associated-list'] ) ) { |
|
| 152 | 152 | // @todo: Throw some kind of error? |
| 153 | 153 | return; |
| 154 | 154 | } |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | |
| 158 | 158 | // Check for an IP address. |
| 159 | 159 | $user_ip = sanitize_text_field( $_SERVER['REMOTE_ADDR'] ); |
| 160 | - if ( isset( $merge_vars['OPTIN_IP'] ) ) {
|
|
| 160 | + if ( isset( $merge_vars['OPTIN_IP'] ) ) { |
|
| 161 | 161 | $user_ip = sanitize_text_field( $merge_vars['OPTIN_IP'] ); |
| 162 | 162 | } |
| 163 | 163 | |
@@ -173,19 +173,19 @@ discard block |
||
| 173 | 173 | 'ip_signup' => $user_ip, |
| 174 | 174 | ); |
| 175 | 175 | |
| 176 | - foreach ( $list_ids as $list_id ) {
|
|
| 176 | + foreach ( $list_ids as $list_id ) { |
|
| 177 | 177 | |
| 178 | 178 | $interests = isset( $options[ $type ]['interest-groups'] ) ? $options[ $type ]['interest-groups'] : array(); |
| 179 | 179 | $interests = isset( $interests[ $list_id ] ) ? $interests[ $list_id ] : $interests; |
| 180 | 180 | |
| 181 | 181 | // Only re-format and add interest groups if not empty. |
| 182 | - if ( ! empty( $interests ) ) {
|
|
| 182 | + if ( ! empty( $interests ) ) { |
|
| 183 | 183 | $groups = array(); |
| 184 | 184 | |
| 185 | 185 | // Need to reformat interest groups array as $interest_group_ID => true. |
| 186 | - foreach ( $interests as $interest ) {
|
|
| 187 | - if ( is_array( $interest ) ) {
|
|
| 188 | - foreach ( $interest as $group_id ) {
|
|
| 186 | + foreach ( $interests as $interest ) { |
|
| 187 | + if ( is_array( $interest ) ) { |
|
| 188 | + foreach ( $interest as $group_id ) { |
|
| 189 | 189 | $groups[ $group_id ] = true; |
| 190 | 190 | } |
| 191 | 191 | } |
@@ -217,14 +217,14 @@ discard block |
||
| 217 | 217 | $list_id = apply_filters( 'yikes-mailchimp-checkbox-integration-list-id', $list_id, $data, $type ); |
| 218 | 218 | |
| 219 | 219 | // Don't send an empty merge fields array. |
| 220 | - if ( empty( $data['merge_fields'] ) ) {
|
|
| 220 | + if ( empty( $data['merge_fields'] ) ) { |
|
| 221 | 221 | unset( $data['merge_fields'] ); |
| 222 | 222 | } |
| 223 | 223 | |
| 224 | 224 | // Subscribe the user to the list via the API. |
| 225 | 225 | $response = yikes_get_mc_api_manager()->get_list_handler()->member_subscribe( $list_id, $id, $data ); |
| 226 | 226 | |
| 227 | - if ( is_wp_error( $response ) ) {
|
|
| 227 | + if ( is_wp_error( $response ) ) { |
|
| 228 | 228 | $error_logging = new Yikes_Inc_Easy_Mailchimp_Error_Logging(); |
| 229 | 229 | $error_logging->maybe_write_to_log( |
| 230 | 230 | $response->get_error_code(), |
@@ -242,15 +242,15 @@ discard block |
||
| 242 | 242 | * |
| 243 | 243 | * @param WP_User $user A WP User. |
| 244 | 244 | */ |
| 245 | - public function user_merge_vars( WP_User $user ) {
|
|
| 245 | + public function user_merge_vars( WP_User $user ) { |
|
| 246 | 246 | |
| 247 | 247 | // Setup our array. |
| 248 | 248 | $merge_vars = array(); |
| 249 | 249 | |
| 250 | - if ( ! empty( $user->first_name ) ) {
|
|
| 250 | + if ( ! empty( $user->first_name ) ) { |
|
| 251 | 251 | $merge_vars['FNAME'] = $user->first_name; |
| 252 | 252 | } |
| 253 | - if ( ! empty( $user->last_name ) ) {
|
|
| 253 | + if ( ! empty( $user->last_name ) ) { |
|
| 254 | 254 | $merge_vars['LNAME'] = $user->last_name; |
| 255 | 255 | } |
| 256 | 256 | |
@@ -274,7 +274,7 @@ discard block |
||
| 274 | 274 | * |
| 275 | 275 | * @return bool True if the checkbox was checked. |
| 276 | 276 | */ |
| 277 | - public function was_checkbox_checked( $type ) {
|
|
| 277 | + public function was_checkbox_checked( $type ) { |
|
| 278 | 278 | return isset( $_POST[ 'yikes_mailchimp_checkbox_' . $type ] ) && '1' === filter_var( $_POST[ 'yikes_mailchimp_checkbox_' . $type ], FILTER_SANITIZE_STRING ); |
| 279 | 279 | } |
| 280 | 280 | } |