text* fields named your-name and your-email. ', 'convertkit' );
- echo __( 'These fields will be sent to ConvertKit for the subscription.', 'convertkit' );
- ?>
settings_key][$this->name];
-
- foreach ($fields as $field) {
- list($cf7_form_id, $field_type) = explode('_', $field['id']);
-
- if (!in_array($field_type, $columns)) {
- $table->add_column($field_type, $field['title'], $field['args']['sortable']);
- array_push($columns, $field_type);
- }
-
- if (!isset($rows[$cf7_form_id])) {
- $rows[$cf7_form_id] = array();
- }
-
- $rows[$cf7_form_id][$field_type] = call_user_func($field['callback'], $field['args']);
- }
-
- foreach ($rows as $row) {
- $table->add_item($row);
- }
-
- $table->prepare_items();
- $table->display();
- }
-
- /**
- * Renders the section
- *
- * Called from ConvertKitSettings::display_settings_page()
- * @return void
- */
- public function render() {
- global $wp_settings_sections;
-
- if (!isset($wp_settings_sections[$this->settings_key])) return;
-
- foreach ($wp_settings_sections[$this->settings_key] as $section) {
- if ($section['title']) echo "
+ */
+ public function column_default( $item, $column_name ) {
+ return $item[ $column_name ];
+ }
+
+ /**
+ * Provide a callback function to render the checkbox column
+ *
+ * @param array $item A row's worth of data.
+ * @return string The formatted string with a checkbox
+ */
+ public function column_cb( $item ) {
+ return sprintf(
+ '',
+ $this->_args['singular'],
+ $item['id']
+ );
+ }
+
+ /**
+ * Get the bulk actions for this table
+ *
+ * @return array Bulk actions
+ */
+ public function get_bulk_actions() {
+ return $this->_bulk_actions;
+ }
+
+ /**
+ * Get a list of columns
+ *
+ * @return array
+ */
+ public function get_columns() {
+ return $this->_columns;
+ }
+
+ /**
+ * Add a column to the table
+ *
+ * @param string $key Machine-readable column name.
+ * @param string $title Title shown to the user.
+ * @param boolean $sortable Whether or not this is sortable (defaults false)
+ */
+ public function add_column( $key, $title, $sortable = false ) {
+ $this->_columns[ $key ] = $title;
+
+ if ( $sortable ) {
+ $this->_sortable_columns[ $key ] = array( $key, false );
+ }
+ }
+
+ /**
+ * Add an item (row) to the table
+ *
+ * @param array $item A row's worth of data.
+ */
+ public function add_item( $item ) {
+ array_push( $this->_data, $item );
+ }
+
+ /**
+ * Add a bulk action to the table
+ *
+ * @param string $key Machine-readable action name
+ * @param string $name Title shown to the user
+ */
+ public function add_bulk_action( $key, $name ) {
+ $this->_bulk_actions[ $key ] = $name;
+ }
+
+ /**
+ * Prepares the items (rows) to be rendered
+ */
+ public function prepare_items() {
+ $total_items = count( $this->_data );
+ $per_page = 25;
+
+ $columns = $this->_columns;
+ $hidden = array();
+ $sortable = $this->_sortable_columns;
+
+ $this->_column_headers = array( $columns, $hidden, $sortable );
+
+ $current_page = $this->get_pagenum();
+
+ $sorted_data = $this->reorder( $this->_data );
+
+ $data = array_slice( $sorted_data, ( ( $current_page - 1 ) * $per_page ),$per_page );
+
+ $this->items = $data;
+
+ $this->set_pagination_args( array(
+ 'total_items' => $total_items,
+ 'per_page' => $per_page,
+ 'total_pages' => ceil( $total_items / $per_page ),
+ ));
+ }
+
+ /**
+ * Reorder the data according to the sort parameters
+ *
+ * @return array Row data, sorted
+ */
+ public function reorder( $data ) {
+ function usort_reorder( $a, $b ) {
+
+ if ( empty( $_REQUEST['orderby'] ) ) { // WPCS: CSRF ok.
+ $orderby = 'title';
+ } else {
+ $orderby = sanitize_text_field( wp_unslash( $_REQUEST['orderby'] ) ); // WPCS: CSRF ok.
+ }
+
+ if ( empty( $_REQUEST['order'] ) ) { // WPCS: CSRF ok.
+ $order = 'asc';
+ } else {
+ $order = sanitize_text_field( wp_unslash( $_REQUEST['order'] ) ); // WPCS: CSRF ok.
+ }
+ $result = strcmp( $a[ $orderby ], $b[ $orderby ] ); //Determine sort order.
+ return ( 'asc' === $order ) ? $result : -$result; //Send final sort direction to usort.
+ }
+ usort( $data, 'usort_reorder' );
+
+ return $data;
+ }
+}
diff --git a/lib/convertkit-api.php b/lib/convertkit-api.php
deleted file mode 100644
index f3d2b5bdd..000000000
--- a/lib/convertkit-api.php
+++ /dev/null
@@ -1,288 +0,0 @@
-api_key = $api_key;
- $this->api_secret = $api_secret;
- $this->debug = $debug;
- }
-
- /**
- * Gets a resource index
- *
- * GET /{$resource}/
- *
- * @param string $resource Resource type
- * @return object API response
- */
- public function get_resources($resource) {
-
- if(!array_key_exists($resource, $this->resources)) {
-
- if ( $resource == 'landing_pages' ) {
- $api_response = $this->_get_api_response( 'forms' );
- } else {
- $api_response = $this->_get_api_response( $resource );
- }
-
- if (is_null($api_response) || is_wp_error($api_response) || isset($api_response['error']) || isset($api_response['error_message'])) {
- $this->resources[$resource] = array( array('id' => '-2', 'name' => 'Error contacting API' ) );
- } else {
- $_resource = array();
-
- if ( 'forms' == $resource ) {
- $response = isset( $api_response['forms']) ? $api_response['forms'] : array();
- foreach( $response as $form ) {
- if ( isset( $form['archived'] ) && $form['archived'] )
- continue;
- $_resource[] = $form;
- }
- } elseif ( 'landing_pages' == $resource ) {
-
- $response = isset( $api_response['forms']) ? $api_response['forms'] : array();
- foreach( $response as $landing_page ){
- if ( 'hosted' == $landing_page['type'] ){
- if ( isset( $landing_page['archived'] ) && $landing_page['archived'] )
- continue;
- $_resource[] = $landing_page;
- }
- }
- } elseif ( 'subscription_forms' == $resource ) {
- foreach( $api_response as $mapping ){
- if ( isset( $mapping['archived'] ) && $mapping['archived'] )
- continue;
- $_resource[ $mapping['id'] ] = $mapping['form_id'];
- }
- }
-
- $this->resources[$resource] = $_resource;
- }
- }
-
- return $this->resources[$resource];
- }
-
- /**
- * Adds a subscriber to a form
- *
- * @param string $form_id Form ID
- * @param array $options Array of user data
- * @return object
- */
- public function form_subscribe($form_id, $options) {
- $request = $this->api_version . sprintf('/forms/%s/subscribe', $form_id);
-
- $args = array(
- 'api_key' => $this->api_key,
- 'email' => $options['email'],
- 'name' => $options['name'],
- );
-
- return $this->make_request($request, 'POST', $args);
- }
-
- /**
- * Remove subscription from a form
- *
- * @param array $options Array of user data
- * @return object Response object
- */
- public function form_unsubscribe($options) {
- $request = $this->api_version . '/unsubscribe';
-
- $args = array(
- 'api_secret' => $this->api_secret,
- 'email' => $options['email']
- );
-
- return $this->make_request($request, 'PUT', $args);
- }
-
- /**
- * Get markup from ConvertKit for the provided $url
- *
- * @param $url
- * @return string
- */
- public function get_resource($url) {
- $resource = '';
-
- if(!empty($url) && isset($this->markup[$url])) {
- $resource = $this->markup[$url];
- } else if(!empty($url)) {
- $response = wp_remote_get($url, array( 'timeout' => 10 ));
-
- if(!is_wp_error($response)) {
- if(!function_exists('str_get_html')) {
- require_once(dirname(__FILE__).'/../vendor/simple-html-dom/simple-html-dom.php');
- }
-
- if(!function_exists('url_to_absolute')) {
- require_once(dirname(__FILE__).'/../vendor/url-to-absolute/url-to-absolute.php');
- }
-
- $url_parts = parse_url($url);
-
- $body = wp_remote_retrieve_body($response);
- $html = str_get_html($body);
- foreach($html->find('a, link') as $element) {
- if(isset($element->href)) {
- $element->href = url_to_absolute($url, $element->href);
- }
- }
-
- foreach($html->find('img, script') as $element) {
- if(isset($element->src)) {
- $element->src = url_to_absolute($url, $element->src);
- }
- }
-
- foreach($html->find('form') as $element) {
- if(isset($element->action)) {
- $element->action = url_to_absolute($url, $element->action);
- } else {
- $element->action = $url;
- }
- }
-
- // check `status_code` for 200, otherwise log error
- if ( '200' == $response['response']['code'] ) {
- $this->markup[$url] = $resource = $html->save();
- } else {
- $this->log('Status Code (' . $response['response']['code'] . ') for URL (' . $url .'): ' . $html->save() );
- }
- }
- }
-
- return $resource;
- }
-
- /**
- * Do a remote request.
- *
- * @param string $path
- * @return array
- */
- private function _get_api_response($path = '') {
-
- $args = array('api_key' => $this->api_key);
- $api_path = $this->api_url_base . $this->api_version;
- $url = add_query_arg($args, path_join($api_path, $path));
-
- $this->log( "API Request (_get_api_response): " . $url );
-
- $data = get_transient( 'convertkit_get_api_response' );
-
- if ( ! $data ) {
-
- $response = wp_remote_get( $url, array( 'timeout' => 10, 'sslverify' => false ) );
-
- if ( is_wp_error( $response ) ) {
- $this->log( "Error: " . $response->get_error_message() );
-
- return array( 'error' => $response->get_error_message() );
- } else {
- $data = json_decode( wp_remote_retrieve_body( $response ), true );
- }
-
- set_transient( 'convertkit_get_api_response', $data, 300 );
-
- $this->log( "API Response (_get_api_response): " . print_r( $data, true ) );
- } else {
- $this->log( "Transient Response (_get_api_response)" );
- }
-
- return $data;
- }
-
- /**
- * Make a request to the ConvertKit API
- *
- * @param string $request Request string
- * @param string $method HTTP Method
- * @param array $args Request arguments
- * @return object Response object
- */
- public function make_request($request, $method = 'GET', $args = array()) {
-
- $url = $this->build_request_url($request, $args);
- $this->log( "API Request (make_request): " . $url );
-
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, $url);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($ch, CURLOPT_HEADER, false);
- curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
- if ( 'PUT' == $method ){
- curl_setopt($ch, CURLOPT_PUT, true);
- }
-
- $results = curl_exec($ch);
- curl_close($ch);
-
- $this->log( "API Response (make_request): " . print_r( json_decode( $results ), true) );
-
- return json_decode($results);
- }
-
- /**
- * Build the full request URL
- *
- * @param string $request Request path
- * @param array $args Request arguments
- * @return string Request URL
- */
- public function build_request_url($request, array $args) {
- return $this->api_url_base . $request . '?' . http_build_query( $args );
- }
-
- /**
- * @param $message
- */
- public function log( $message ) {
-
- if ( 'on' == $this->debug ) {
- $dir = dirname( __FILE__ );
-
- $handle = fopen( trailingslashit( $dir ) . 'log.txt', 'a' );
- if ( $handle ) {
- $time = date_i18n( 'm-d-Y @ H:i:s -' );
- fwrite( $handle, $time . " " . $message . "\n" );
- fclose( $handle );
- }
- }
-
- }
-
-}
diff --git a/lib/integration/class-convertkit-contactform7-integration.php b/lib/integration/class-convertkit-contactform7-integration.php
new file mode 100644
index 000000000..5c96192c9
--- /dev/null
+++ b/lib/integration/class-convertkit-contactform7-integration.php
@@ -0,0 +1,84 @@
+options = get_option( '_wp_convertkit_integration_wishlistmember_settings' );
+ $api_key = $general_options && array_key_exists( 'api_key', $general_options ) ? $general_options['api_key'] : null;
+ $api_secret = $general_options && array_key_exists( 'api_secret', $general_options ) ? $general_options['api_secret'] : null;
+ $debug = $general_options && array_key_exists( 'debug', $general_options ) ? $general_options['debug'] : null;
+ $this->api = new ConvertKit_API( $api_key, $api_secret, $debug );
+
+ add_action( 'wpcf7_submit', array( $this, 'handle_wpcf7_submit' ), 10, 2 );
+ }
+
+ /**
+ * Handle checking submitted CF7 forms for a CK form mapping.
+ *
+ * If a mapping is found and options exist then the form submitter is subscribed.
+ *
+ * @param WPCF7_ContactForm $contact_form
+ * @param $result
+ */
+ public function handle_wpcf7_submit( $contact_form, $result ) {
+
+ if ( $result['demo_mode'] ) {
+ return;
+ }
+
+ if ( 'mail_sent' === $result['status'] ) {
+
+ $mapping = get_option( '_wp_convertkit_integration_contactform7_settings' );
+
+ if ( is_array( $mapping ) ) {
+ if ( isset( $mapping[ $contact_form->id() ] ) && 'default' !== $mapping[ $contact_form->id() ] ) {
+ $submission = WPCF7_Submission::get_instance();
+
+ if ( $submission ) {
+ $posted_data = $submission->get_posted_data();
+
+ $name = $posted_data['your-name'];
+ $email = $posted_data['your-email'];
+
+ if ( ! empty( $email ) ) {
+ $this->api->form_subscribe( $mapping[ $contact_form->id() ],
+ array(
+ 'email' => $email,
+ 'name' => $name,
+ )
+ );
+ }
+ }
+ }
+ }
+ }
+ }
+
+}
+
+new ConvertKit_ContactForm7_Integration();
diff --git a/lib/integration/class-convertkit-wishlist-integration.php b/lib/integration/class-convertkit-wishlist-integration.php
new file mode 100644
index 000000000..83917b2c6
--- /dev/null
+++ b/lib/integration/class-convertkit-wishlist-integration.php
@@ -0,0 +1,179 @@
+options = get_option( '_wp_convertkit_integration_wishlistmember_settings' );
+ $api_key = $general_options && array_key_exists( 'api_key', $general_options ) ? $general_options['api_key'] : null;
+ $api_secret = $general_options && array_key_exists( 'api_secret', $general_options ) ? $general_options['api_secret'] : null;
+ $debug = $general_options && array_key_exists( 'debug', $general_options ) ? $general_options['debug'] : null;
+ $this->api = new ConvertKit_API( $api_key,$api_secret,$debug );
+
+ // When a user has levels added or registers check for a mapping to a ConvertKit form.
+ add_action( 'wishlistmember_add_user_levels', array( $this, 'add_user_levels' ), 10, 2 );
+
+ // When a user has levels removed check for a mapping to a ConvertKit tag, or if the subscriber
+ // should be removed from ConvertKit.
+ add_action( 'wishlistmember_remove_user_levels', array( $this, 'remove_user_levels' ), 10, 2 );
+ }
+
+ /**
+ * Callback function for wishlistmember_add_user_levels action
+ *
+ * @param string $member_id ID for member that has just had levels added.
+ * @param array $levels Levels to which member was added.
+ */
+ public function add_user_levels( $member_id, $levels ) {
+ $member = $this->get_member( $member_id );
+
+ foreach ( $levels as $wlm_level_id ) {
+ if ( ! isset( $this->options[ $wlm_level_id . '_form' ] ) ) {
+ continue;
+ }
+
+ $this->member_resource_subscribe(
+ $member,
+ $this->options[ $wlm_level_id . '_form' ]
+ );
+ }
+ }
+
+ /**
+ * Note: Form level unsubscribe is not available in v3 of the API.
+ *
+ * Callback function for wishlistmember_remove_user_levels action
+ *
+ * @param string $member_id ID for member that has just had levels removed.
+ * @param array $levels Levels from which member was removed.
+ */
+ public function remove_user_levels( $member_id, $levels ) {
+
+ $member = $this->get_member( $member_id );
+
+ foreach ( $levels as $wlm_level_id ) {
+ // get the mapping if it is set
+ $unsubscribe = ( isset( $this->options[ $wlm_level_id . '_unsubscribe' ] ) ) ? $this->options[ $wlm_level_id . '_unsubscribe' ] : 0;
+
+ if ( $unsubscribe && 'unsubscribe' === $unsubscribe ) {
+ // If mapping is set to "Unsubscribe from all"
+ $this->member_resource_unsubscribe( $member );
+ } elseif ( $unsubscribe ) {
+ // If mapping is a positive integer then tag customer
+ $this->member_tag( $member, $this->options[ $wlm_level_id . '_unsubscribe' ] );
+ }
+ }
+
+ }
+
+ /**
+ * Subscribes a member to a ConvertKit resource
+ *
+ * @param array $member UserInfo from WishList Member.
+ * @param string $form_id ConvertKit form id.
+ * @return object Response object from API
+ */
+ public function member_resource_subscribe( $member, $form_id ) {
+
+ // Check for temp email.
+ if ( preg_match( '/temp_[a-f0-9]{32}/', $member['user_email'] ) ) {
+ $email = $member['wlm_origemail'];
+ } else {
+ $email = $member['user_email'];
+ }
+
+ // Note Wishlist Member combines first and last name into 'display_name'.
+ return $this->api->form_subscribe(
+ $form_id,
+ array(
+ 'email' => $email,
+ 'name' => $member['display_name'],
+ )
+ );
+ }
+
+ /**
+ * Unsubscribes a member from a ConvertKit resource
+ *
+ * @param array $member UserInfo from WishList Member.
+ * @param string $form_id ConvertKit form id.
+ * @return object Response object from API
+ */
+ public function member_resource_unsubscribe( $member ) {
+ return $this->api->form_unsubscribe(
+ array(
+ 'email' => $member['user_email'],
+ )
+ );
+ }
+
+ /**
+ * Tag a member
+ *
+ * @param array $member UserInfo from WishList Member
+ * @param string $tag ConvertKit Tag ID
+ * @return object Response object from API
+ */
+ public function member_tag( $member, $tag ) {
+ return $this->api->add_tag(
+ $tag,
+ array(
+ 'email' => $member['user_email'],
+ )
+ );
+ }
+
+ /**
+ * Gets a WLM member using the wlmapi functions
+ *
+ * @param string $id The member id.
+ * @return array The member fields from the API request
+ */
+ public function get_member( $id ) {
+ if ( ! function_exists( 'wlmapi_get_member' ) ) {
+ return false;
+ }
+
+ $wlm_get_member = wlmapi_get_member( $id );
+
+ if ( 0 === $wlm_get_member['success'] ) {
+ return false;
+ }
+
+ return $wlm_get_member['member'][0]['UserInfo'];
+ }
+
+}
+
+new ConvertKit_Wishlist_Integration();
diff --git a/lib/integration/contactform7.php b/lib/integration/contactform7.php
deleted file mode 100644
index 9bb5626e1..000000000
--- a/lib/integration/contactform7.php
+++ /dev/null
@@ -1,65 +0,0 @@
-options = get_option('_wp_convertkit_integration_wishlistmember_settings');
- $api_key = $general_options && array_key_exists("api_key", $general_options) ? $general_options['api_key'] : null;
- $api_secret = $general_options && array_key_exists("api_secret", $general_options) ? $general_options['api_secret'] : null;
- $debug = $general_options && array_key_exists("debug", $general_options) ? $general_options['debug'] : null;
- $this->api = new ConvertKitAPI($api_key,$api_secret,$debug);
-
- add_action( 'wpcf7_submit', array( $this, 'handle_wpcf7_submit' ), 10, 2);
- }
-
- /**
- * Handle checking submitted CF7 forms for a CK form mapping.
- *
- * If a mapping is found and options exist then the form submitter is subscribed.
- *
- * @param WPCF7_ContactForm $contact_form
- * @param $result
- */
- public function handle_wpcf7_submit( $contact_form, $result ) {
-
- if ( $result['demo_mode'] ) {
- return;
- }
-
- if ( 'mail_sent' == $result['status'] ) {
-
- $mapping = get_option( '_wp_convertkit_integration_contactform7_settings' );
-
- if ( is_array( $mapping ) ) {
- if ( isset( $mapping[ $contact_form->id() ]) && 'default' != $mapping[ $contact_form->id() ] ) {
- $submission = WPCF7_Submission::get_instance();
-
- if ( $submission ) {
- $posted_data = $submission->get_posted_data();
-
- $name = $posted_data['your-name'];
- $email = $posted_data['your-email'];
-
- if ( ! empty( $email ) ) {
- $this->api->form_subscribe( $mapping[ $contact_form->id() ], array( 'email' => $email, 'name' => $name ) );
- }
- }
- }
- }
- }
- }
-
-}
-
-$convertkit_contactform7_integration = new ConvertKitContactForm7Integration;
diff --git a/lib/integration/wishlist_member.php b/lib/integration/wishlist_member.php
deleted file mode 100644
index dd13bded8..000000000
--- a/lib/integration/wishlist_member.php
+++ /dev/null
@@ -1,146 +0,0 @@
-options = get_option('_wp_convertkit_integration_wishlistmember_settings');
- $api_key = $general_options && array_key_exists("api_key", $general_options) ? $general_options['api_key'] : null;
- $api_secret = $general_options && array_key_exists("api_secret", $general_options) ? $general_options['api_secret'] : null;
- $debug = $general_options && array_key_exists("debug", $general_options) ? $general_options['debug'] : null;
- $this->api = new ConvertKitAPI($api_key,$api_secret,$debug);
-
- add_action(
- 'wishlistmember_add_user_levels', // hook
- array($this, 'add_user_levels'), // function to call
- null, // priority (default is fine)
- 2 // number of arguments passed
- );
-
- add_action(
- 'wishlistmember_remove_user_levels', // hook
- array($this, 'remove_user_levels'), // function to call
- null, // priority
- 2 // number of arguments passed
- );
- }
-
- /**
- * Callback function for wishlistmember_add_user_levels action
- *
- * @param string $member_id ID for member that has just had levels added
- * @param array $levels Levels to which member was added
- */
- public function add_user_levels($member_id, $levels) {
- $member = $this->get_member($member_id);
-
- foreach ($levels as $wlm_level_id) {
- if (!isset($this->options[$wlm_level_id . '_form'])) continue;
-
- $this->member_resource_subscribe(
- $member,
- $this->options[$wlm_level_id . '_form']
- );
- }
- }
-
- /**
- * Note: Form level unsubscribe is not available in v3 of the API.
- *
- * Callback function for wishlistmember_remove_user_levels action
- *
- * @param string $member_id ID for member that has just had levels removed
- * @param array $levels Levels from which member was removed
- */
- public function remove_user_levels($member_id, $levels) {
-
- $member = $this->get_member($member_id);
-
- foreach ($levels as $wlm_level_id) {
- if (
- isset($this->options[$wlm_level_id . '_form'])
- && isset($this->options[$wlm_level_id . '_unsubscribe'])
- && $this->options[$wlm_level_id . '_unsubscribe'] == '1'
- ) {
- $this->member_resource_unsubscribe(
- $member,
- $this->options[$wlm_level_id . '_form']
- );
- }
- }
-
- }
-
- /**
- * Subscribes a member to a ConvertKit resource
- *
- * @param array $member UserInfo from WishList Member
- * @param string $form_id ConvertKit form id
- * @return object Response object from API
- */
- public function member_resource_subscribe($member, $form_id) {
-
- // Check for temp email
- if ( preg_match('/temp_[a-f0-9]{32}/', $member['user_email'] ) ) {
- $email = $member['wlm_origemail'];
- } else {
- $email = $member['user_email'];
- }
-
- // Note Wishlist Member combines first and last name into 'display_name'
- return $this->api->form_subscribe(
- $form_id,
- array(
- 'email' => $email,
- 'name' => $member['display_name'],
- )
- );
- }
-
- /**
- * Unsubscribes a member from a ConvertKit resource
- *
- * @param array $member UserInfo from WishList Member
- * @param string $form_id ConvertKit form id
- * @return object Response object from API
- */
- public function member_resource_unsubscribe($member, $form_id) {
- return $this->api->form_unsubscribe(
- array(
- 'email' => $member['user_email']
- )
- );
- }
-
- /**
- * Gets a WLM member using the wlmapi functions
- *
- * @param string $id The member id
- * @return array The member fields from the API request
- */
- public function get_member($id) {
- if (!function_exists('wlmapi_get_member')) return false;
-
- $wlm_get_member = wlmapi_get_member($id);
-
- if ($wlm_get_member['success'] == 0) return false;
-
- return $wlm_get_member['member'][0]['UserInfo'];
- }
-
- }
-
- $convertkit_wishlist_integration = new ConvertKitWishlistIntegration;
-}
diff --git a/lib/multi_value_field_table.php b/lib/multi_value_field_table.php
deleted file mode 100644
index 47b0c0102..000000000
--- a/lib/multi_value_field_table.php
+++ /dev/null
@@ -1,145 +0,0 @@
- 'item',
- 'plural' => 'items',
- 'ajax' => false
- ));
- }
-
- /**
- * Set default column attributes
- *
- * @param array $item A singular item (one full row's worth of data)
- * @param array $column_name The name/slug of the column to be processed
- * @return string Text or HTML to be placed inside the column
- */
- public function column_default($item, $column_name) {
- return $item[$column_name];
- }
-
- /**
- * Provide a callback function to render the checkbox column
- *
- * @param array $item A row's worth of data
- * @return string The formatted string with a checkbox
- */
- public function column_cb($item) {
- return sprintf(
- '',
- $this->_args['singular'],
- $item['id']
- );
- }
-
- /**
- * Get the bulk actions for this table
- *
- * @return array Bulk actions
- */
- public function get_bulk_actions() {
- return $this->_bulk_actions;
- }
-
- /**
- * Get a list of columns
- *
- * @return array
- */
- public function get_columns() {
- return $this->_columns;
- }
-
- /**
- * Add a column to the table
- *
- * @param string $key Machine-readable column name
- * @param string $title Title shown to the user
- * @param boolean $sortable Whether or not this is sortable (defaults false)
- */
- public function add_column($key, $title, $sortable = false) {
- $this->_columns[$key] = $title;
-
- if ($sortable) $this->_sortable_columns[$key] = array($key, false);
- }
-
- /**
- * Add an item (row) to the table
- *
- * @param array $item A row's worth of data
- */
- public function add_item($item) {
- array_push($this->_data, $item);
- }
-
- /**
- * Add a bulk action to the table
- *
- * @param string $key Machine-readable action name
- * @param string $name Title shown to the user
- */
- public function add_bulk_action($key, $name) {
- $this->_bulk_actions[$key] = $name;
- }
-
- /**
- * Prepares the items (rows) to be rendered
- */
- public function prepare_items() {
- $total_items = count($this->_data);
- $per_page = 25;
-
- $columns = $this->_columns;
- $hidden = array();
- $sortable = $this->_sortable_columns;
-
- $this->_column_headers = array($columns, $hidden, $sortable);
-
- $current_page = $this->get_pagenum();
-
- $sorted_data = $this->reorder($this->_data);
-
- $data = array_slice($sorted_data, (($current_page-1)*$per_page),$per_page);
-
- $this->items = $data;
-
- $this->set_pagination_args(array(
- 'total_items' => $total_items,
- 'per_page' => $per_page,
- 'total_pages' => ceil($total_items/$per_page)
- ));
- }
-
- /**
- * Reorder the data according to the sort parameters
- *
- * @return array Row data, sorted
- */
- public function reorder($data) {
- function usort_reorder($a, $b) {
- $orderby = (!empty($_REQUEST['orderby'])) ? $_REQUEST['orderby'] : 'title'; //If no sort, default to title
- $order = (!empty($_REQUEST['order'])) ? $_REQUEST['order'] : 'asc'; //If no order, default to asc
- $result = strcmp($a[$orderby], $b[$orderby]); //Determine sort order
- return ($order==='asc') ? $result : -$result; //Send final sort direction to usort
- }
- usort($data, 'usort_reorder');
-
- return $data;
- }
-}
diff --git a/lib/template-tags.php b/lib/template-tags.php
index d38c432de..6c93ce649 100644
--- a/lib/template-tags.php
+++ b/lib/template-tags.php
@@ -5,6 +5,6 @@
* @param $attributes
* @return mixed|void
*/
-function wp_convertkit_get_form_embed($attributes) {
- return apply_filters('wp_convertkit_get_form_embed', WP_ConvertKit::get_form_embed($attributes), $attributes);
-}
\ No newline at end of file
+function wp_convertkit_get_form_embed( $attributes ) {
+ return apply_filters( 'wp_convertkit_get_form_embed', WP_ConvertKit::get_form_embed( $attributes ), $attributes );
+}
diff --git a/readme.txt b/readme.txt
index 112b9685f..9b06d6d7e 100755
--- a/readme.txt
+++ b/readme.txt
@@ -4,7 +4,7 @@ Donate link: https://convertkit.com
Tags: email, marketing, embed form, convertkit, capture
Requires at least: 3.6
Tested up to: 4.7.3
-Stable tag: 1.4.6
+Stable tag: 1.4.7
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
@@ -44,6 +44,12 @@ Yes, for it to work you must first have an account on ConvertKit.com
== Changelog ==
+### 1.4.7 2017-06-01
+* Code refactor with WordPress Code Standards
+* Added ability to tag a customer when WishList Member membership lapses
+* Added WishList Member tag a customer
+* Removed curl and replaced with wp_remote_request
+
### 1.4.6 2017-03-29
* Fix for landing pages not appearing.
* Added code to API to not return status_code 404 content
diff --git a/views/backend/meta-boxes/meta-box.php b/views/backend/meta-boxes/meta-box.php
index 809ed6073..24c25e89b 100644
--- a/views/backend/meta-boxes/meta-box.php
+++ b/views/backend/meta-boxes/meta-box.php
@@ -1,47 +1,58 @@
+
-
+
Default to use the form specified on the settings page,', 'convertkit'), esc_attr(esc_url($settings_link)));
- echo __('None to not display a form, or any other option to specify a particular form for this piece of content.', 'convertkit');
+ /* translators: 1: settings url */
+ printf( __( 'Choose Default to use the form specified on the settings page,', 'convertkit' ), esc_attr( esc_url( $settings_link ) ) ); // WPCS: XSS ok.
+ echo __( 'None to not display a form, or any other option to specify a particular form for this piece of content.', 'convertkit' ); // WPCS: XSS ok.
?>