| @@ 86-93 (lines=8) @@ | ||
| 83 | // lets confirm the user has a valid API key stored. |
|
| 84 | if ( $this->is_user_mc_api_valid_form( false ) == 'valid' ) {
|
|
| 85 | $list_data = yikes_get_mc_api_manager()->get_list_handler()->get_lists(); |
|
| 86 | if ( is_wp_error( $list_data ) ) {
|
|
| 87 | $error_logging = new Yikes_Inc_Easy_Mailchimp_Error_Logging(); |
|
| 88 | $error_logging->maybe_write_to_log( |
|
| 89 | $list_data->get_error_code(), |
|
| 90 | __( "Get Account Lists" , 'yikes-inc-easy-mailchimp-extender' ), |
|
| 91 | "Integration Settings Page" |
|
| 92 | ); |
|
| 93 | } |
|
| 94 | } else {
|
|
| 95 | ?> |
|
| 96 | <div class="inside"> |
|
| @@ 51-59 (lines=9) @@ | ||
| 48 | } |
|
| 49 | ||
| 50 | $list_data = $list_helper->get_list( $id ); |
|
| 51 | if ( is_wp_error( $list_data ) ) { |
|
| 52 | $error_logging = new Yikes_Inc_Easy_Mailchimp_Error_Logging(); |
|
| 53 | $error_logging->maybe_write_to_log( |
|
| 54 | $list_data->get_error_code(), |
|
| 55 | __( "Get Account Lists", 'yikes-inc-easy-mailchimp-extender' ), |
|
| 56 | "View User Page" |
|
| 57 | ); |
|
| 58 | continue; |
|
| 59 | } |
|
| 60 | ||
| 61 | $additional_lists[ $list_data['id'] ] = $list_data['name']; |
|
| 62 | } |
|
| @@ 66-74 (lines=9) @@ | ||
| 63 | ||
| 64 | /* Build the array of merge variables => value */ |
|
| 65 | $merge_variables = $list_helper->get_merge_fields( $list_id ); |
|
| 66 | if ( is_wp_error( $merge_variables ) ) { |
|
| 67 | $error_logging = new Yikes_Inc_Easy_Mailchimp_Error_Logging(); |
|
| 68 | $error_logging->maybe_write_to_log( |
|
| 69 | $merge_variables->get_error_code(), |
|
| 70 | __( "Get Merge Variables", 'yikes-inc-easy-mailchimp-extender' ), |
|
| 71 | "View User Page" |
|
| 72 | ); |
|
| 73 | $merge_variables = array(); |
|
| 74 | } |
|
| 75 | // loop and display |
|
| 76 | if ( $merge_variables ) { |
|
| 77 | foreach ( $merge_variables['merge_fields'] as $merge_variable ) { |
|
| @@ 89-99 (lines=11) @@ | ||
| 86 | // If the error response is a 404, they are not subscribed. |
|
| 87 | if ( isset( $data['status'] ) && 404 === (int) $data['status'] ) {
|
|
| 88 | return false; |
|
| 89 | } else {
|
|
| 90 | $error_logging = new Yikes_Inc_Easy_Mailchimp_Error_Logging(); |
|
| 91 | $error_logging->maybe_write_to_log( |
|
| 92 | $response->get_error_code(), |
|
| 93 | __( 'Get Member Info', 'yikes-inc-easy-mailchimp-extender' ), |
|
| 94 | 'Checkbox Integrations Page' |
|
| 95 | ); |
|
| 96 | ||
| 97 | // If there was some other error, let's just assume they're not subscribed. |
|
| 98 | return false; |
|
| 99 | } |
|
| 100 | } |
|
| 101 | ||
| 102 | // Look at the status from the API. |
|
| @@ 227-234 (lines=8) @@ | ||
| 224 | // Subscribe the user to the list via the API. |
|
| 225 | $response = yikes_get_mc_api_manager()->get_list_handler()->member_subscribe( $list_id, $id, $data ); |
|
| 226 | ||
| 227 | if ( is_wp_error( $response ) ) {
|
|
| 228 | $error_logging = new Yikes_Inc_Easy_Mailchimp_Error_Logging(); |
|
| 229 | $error_logging->maybe_write_to_log( |
|
| 230 | $response->get_error_code(), |
|
| 231 | __( 'Checkbox Integration Subscribe User', 'yikes-inc-easy-mailchimp-extender' ), |
|
| 232 | 'Checkbox Integrations' |
|
| 233 | ); |
|
| 234 | } |
|
| 235 | } |
|
| 236 | } |
|
| 237 | ||
| @@ 85-93 (lines=9) @@ | ||
| 82 | ||
| 83 | ||
| 84 | $interest_groupings = yikes_get_mc_api_manager()->get_list_handler()->get_interest_categories( $list_id ); |
|
| 85 | if ( is_wp_error( $interest_groupings ) ) { |
|
| 86 | $error_logging = new Yikes_Inc_Easy_Mailchimp_Error_Logging(); |
|
| 87 | $error_logging->maybe_write_to_log( |
|
| 88 | $interest_groupings->get_error_code(), |
|
| 89 | __( "Get Interest Groups", 'yikes-inc-easy-mailchimp-extender' ), |
|
| 90 | "class.ajax.php" |
|
| 91 | ); |
|
| 92 | $interest_groupings = array(); |
|
| 93 | } |
|
| 94 | ||
| 95 | if ( ! empty( $interest_groupings ) ) { |
|
| 96 | require( YIKES_MC_PATH . 'admin/partials/menu/options-sections/templates/integration-interest-groups.php' ); |
|
| @@ 72-80 (lines=9) @@ | ||
| 69 | // Set up our list_handler object. |
|
| 70 | $list_handler = yikes_get_mc_api_manager()->get_list_handler(); |
|
| 71 | $list_data = $list_handler->get_lists(); |
|
| 72 | if ( is_wp_error( $list_data ) ) { |
|
| 73 | $error_logging = new Yikes_Inc_Easy_Mailchimp_Error_Logging(); |
|
| 74 | $error_logging->maybe_write_to_log( |
|
| 75 | $list_data->get_error_code(), |
|
| 76 | __( 'Get Account Lists', 'yikes-inc-easy-mailchimp-extender' ), |
|
| 77 | 'Edit Form Page' |
|
| 78 | ); |
|
| 79 | $list_data = array(); |
|
| 80 | } |
|
| 81 | ||
| 82 | // Get the merge fields. |
|
| 83 | $available_merge_variables = $list_handler->get_merge_fields( $form['list_id'] ); |
|
| @@ 84-92 (lines=9) @@ | ||
| 81 | ||
| 82 | // Get the merge fields. |
|
| 83 | $available_merge_variables = $list_handler->get_merge_fields( $form['list_id'] ); |
|
| 84 | if ( is_wp_error( $available_merge_variables ) ) { |
|
| 85 | $error_logging = new Yikes_Inc_Easy_Mailchimp_Error_Logging(); |
|
| 86 | $error_logging->maybe_write_to_log( |
|
| 87 | $available_merge_variables->get_error_code(), |
|
| 88 | __( 'Get Merge Variables', 'yikes-inc-easy-mailchimp-extender' ), |
|
| 89 | 'Edit Form Page' |
|
| 90 | ); |
|
| 91 | $available_merge_variables = array(); |
|
| 92 | } |
|
| 93 | ||
| 94 | // Get the interest groups. |
|
| 95 | $interest_groupings = $list_handler->get_interest_categories( $form['list_id'] ); |
|
| @@ 96-104 (lines=9) @@ | ||
| 93 | ||
| 94 | // Get the interest groups. |
|
| 95 | $interest_groupings = $list_handler->get_interest_categories( $form['list_id'] ); |
|
| 96 | if ( is_wp_error( $interest_groupings ) ) { |
|
| 97 | $error_logging = new Yikes_Inc_Easy_Mailchimp_Error_Logging(); |
|
| 98 | $error_logging->maybe_write_to_log( |
|
| 99 | $interest_groupings->get_error_code(), |
|
| 100 | __( 'Get Interest Groups', 'yikes-inc-easy-mailchimp-extender' ), |
|
| 101 | 'Edit Form Page' |
|
| 102 | ); |
|
| 103 | $interest_groupings = array(); |
|
| 104 | } |
|
| 105 | ||
| 106 | // Get the tags. |
|
| 107 | $tags = $list_handler->get_segments( $form['list_id'], 'static' ); |
|
| @@ 108-116 (lines=9) @@ | ||
| 105 | ||
| 106 | // Get the tags. |
|
| 107 | $tags = $list_handler->get_segments( $form['list_id'], 'static' ); |
|
| 108 | if ( is_wp_error( $tags ) ) { |
|
| 109 | $error_logging = new Yikes_Inc_Easy_Mailchimp_Error_Logging(); |
|
| 110 | $error_logging->maybe_write_to_log( |
|
| 111 | $tags->get_error_code(), |
|
| 112 | __( 'Get Tags', 'yikes-inc-easy-mailchimp-extender' ), |
|
| 113 | 'Edit Form Page' |
|
| 114 | ); |
|
| 115 | $tags = array(); |
|
| 116 | } |
|
| 117 | ||
| 118 | // Update Form URL. |
|
| 119 | $url = add_query_arg( |
|
| @@ 11-19 (lines=9) @@ | ||
| 8 | /* Store Data if User is Authorized */ |
|
| 9 | if( $this->is_user_mc_api_valid_form( false ) == 'valid' ) { |
|
| 10 | $list_data = yikes_get_mc_api_manager()->get_list_handler()->get_lists(); |
|
| 11 | if ( is_wp_error( $list_data ) ) { |
|
| 12 | $error_logging = new Yikes_Inc_Easy_Mailchimp_Error_Logging(); |
|
| 13 | $error_logging->maybe_write_to_log( |
|
| 14 | $list_data->get_error_code(), |
|
| 15 | __( "Get Account Lists" , 'yikes-inc-easy-mailchimp-extender' ), |
|
| 16 | "Manage Forms Page" |
|
| 17 | ); |
|
| 18 | $list_data = array(); |
|
| 19 | } |
|
| 20 | } else { |
|
| 21 | $list_data = array(); |
|
| 22 | } |
|
| @@ 15-23 (lines=9) @@ | ||
| 12 | ||
| 13 | // List data |
|
| 14 | $list_data = $manager->get_list_handler()->get_lists(); |
|
| 15 | if ( is_wp_error( $list_data ) ) { |
|
| 16 | $error_logging = new Yikes_Inc_Easy_Mailchimp_Error_Logging(); |
|
| 17 | $error_logging->maybe_write_to_log( |
|
| 18 | $list_data->get_error_code(), |
|
| 19 | __( "Get Account Lists", 'yikes-inc-easy-mailchimp-extender' ), |
|
| 20 | "Manage Lists Page" |
|
| 21 | ); |
|
| 22 | $list_data = array(); |
|
| 23 | } |
|
| 24 | ||
| 25 | ||
| 26 | ||
| @@ 24-32 (lines=9) @@ | ||
| 21 | } |
|
| 22 | ||
| 23 | $merge_fields = $list_helper->get_merge_fields( $list_id ); |
|
| 24 | if ( is_wp_error( $merge_fields ) ) { |
|
| 25 | $error_logging = new Yikes_Inc_Easy_Mailchimp_Error_Logging(); |
|
| 26 | $error_logging->maybe_write_to_log( |
|
| 27 | $merge_fields->get_error_code(), |
|
| 28 | __( "Get Merge Variables", 'yikes-inc-easy-mailchimp-extender' ), |
|
| 29 | "View Lists Page" |
|
| 30 | ); |
|
| 31 | $merge_fields = array(); |
|
| 32 | } |
|
| 33 | ||
| 34 | // get the interest group data |
|
| 35 | $interest_groupings = $list_helper->get_interest_categories( $list_id ); |
|
| @@ 36-44 (lines=9) @@ | ||
| 33 | ||
| 34 | // get the interest group data |
|
| 35 | $interest_groupings = $list_helper->get_interest_categories( $list_id ); |
|
| 36 | if ( is_wp_error( $interest_groupings ) ) { |
|
| 37 | $error_logging = new Yikes_Inc_Easy_Mailchimp_Error_Logging(); |
|
| 38 | $error_logging->maybe_write_to_log( |
|
| 39 | $interest_groupings->get_error_code(), |
|
| 40 | __( "Get Interest Groups", 'yikes-inc-easy-mailchimp-extender' ), |
|
| 41 | "View Lists Page" |
|
| 42 | ); |
|
| 43 | $interest_groupings = array(); |
|
| 44 | } |
|
| 45 | ||
| 46 | $no_interest_groupings = '<p class="description">' . __( 'Interest groups are not enabled for this list.', 'yikes-inc-easy-mailchimp-extender' ) . '</p>'; |
|
| 47 | $no_segments = __( 'No segments set up for this list.', 'yikes-inc-easy-mailchimp-extender' ); |
|
| @@ 52-60 (lines=9) @@ | ||
| 49 | ||
| 50 | // Get the full list of members. |
|
| 51 | $members = $list_helper->get_members( $list_id ); |
|
| 52 | if ( is_wp_error( $members ) ) { |
|
| 53 | $error_logging = new Yikes_Inc_Easy_Mailchimp_Error_Logging(); |
|
| 54 | $error_logging->maybe_write_to_log( |
|
| 55 | $members->get_error_code(), |
|
| 56 | __( "Get Subscriber Count", 'yikes-inc-easy-mailchimp-extender' ), |
|
| 57 | "View Lists Page" |
|
| 58 | ); |
|
| 59 | $members = array(); |
|
| 60 | } |
|
| 61 | ||
| 62 | // setup pagination variables |
|
| 63 | $paged = isset( $_REQUEST['paged'] ) ? filter_var( $_REQUEST['paged'], FILTER_SANITIZE_NUMBER_INT ) : 0; |
|