Skip to content

Commit

Permalink
Merge pull request #241 from ConvertKit/release/1.9.4
Browse files Browse the repository at this point in the history
Release: 1.9.4
  • Loading branch information
ggwicz authored Feb 22, 2021
2 parents 17c8fb2 + d761067 commit 8e260f7
Show file tree
Hide file tree
Showing 9 changed files with 75 additions and 51 deletions.
10 changes: 7 additions & 3 deletions admin/section/class-convertkit-settings-base.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,15 @@ public function get_forms() {
$forms = get_transient( 'convertkit_forms' );

if ( false === $forms ) {
$this->api->update_resources( $this->options['api_key'], $this->options['api_secret'] );

$forms = get_option( 'convertkit_forms' );
if ( ! empty( $this->options['api_key'] ) && ! empty( $this->options['api_secret'] ) ) {

set_transient( 'convertkit_forms', $forms, 2 * MINUTE_IN_SECONDS );
$this->api->update_resources( $this->options['api_key'], $this->options['api_secret'] );

$forms = get_option( 'convertkit_forms' );

set_transient( 'convertkit_forms', $forms, 2 * MINUTE_IN_SECONDS );
}
}

return $forms;
Expand Down
7 changes: 5 additions & 2 deletions admin/section/class-convertkit-settings-general.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,20 @@ public function refresh_resources() {
$api_key = isset( $_REQUEST['api_key'] ) ? $_REQUEST['api_key'] : WP_ConvertKit::get_api_key();
$api_secret = isset( $_REQUEST['api_secret'] ) ? $_REQUEST['api_secret'] : WP_ConvertKit::get_api_secret();

if ( !$api_key ) {
if ( ! $api_key ) {
update_option( 'convertkit_forms', array() );
wp_send_json_error( __( 'Please enter your API key, click "save changes", and try again.', 'convertkit' ) );
wp_die();
}

if ( !$api_secret ) {
if ( ! $api_secret ) {
update_option( 'convertkit_forms', array() );
wp_send_json_error( __( 'Please enter your API secret, click "save changes", and try again.', 'convertkit' ) );
wp_die();
}

delete_transient( 'convertkit_forms' );

$update_resources = $this->api->update_resources( $api_key, $api_secret );

$forms = get_option( 'convertkit_forms', array() );
Expand All @@ -71,6 +73,7 @@ public function refresh_resources() {
* So, if $update_resources is false, we check the character set, and if it's not utf8mb4 then we show a warning
*/
global $wpdb;

if ( $wpdb->get_col_charset( 'wp_options', 'option_value' ) !== 'utf8mb4' ) {
wp_send_json_error( __( 'Updating forms from ConvertKit may have failed. If so, this may be because your database uses the out of date utf8 character set, instead of the newer utf8mb4 character set. Please contact your host to upgrade your database.','convertkit' ) );
wp_die();
Expand Down
2 changes: 1 addition & 1 deletion admin/section/class-convertkit-settings-tools.php
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ function get_system_info() {
$params = array(
'sslverify' => false,
'timeout' => 60,
'user-agent' => 'ConvertKit/' . CONVERTKIT_PLUGIN_VERSION,
'user-agent' => convertkit_wp_get_user_agent(),
'body' => $request
);

Expand Down
2 changes: 2 additions & 0 deletions includes/class-convertkit-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,7 @@ public function get_resource( $url ) {
array(
'timeout' => 10,
'Accept-Encoding' => 'gzip',
'user-agent' => convertkit_wp_get_user_agent(),
)
);

Expand Down Expand Up @@ -510,6 +511,7 @@ private function _get_api_response( $path = '', $api_secret = null ) {
array(
'timeout' => 10,
'Accept-Encoding' => 'gzip',
'user-agent' => convertkit_wp_get_user_agent(),
)
);

Expand Down
19 changes: 19 additions & 0 deletions includes/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,22 @@ function convertkit_wp_debug_enabled() {

return ! empty( $options['debug'] ) && true == $options['debug']; // phpcs:ignore -- Okay use of loose comparison.
}

/**
* Gets a customized version of the WordPress default user agent; includes WP Version, PHP version, and ConvertKit plugin version.
*
* @return string
*/
function convertkit_wp_get_user_agent() {

// Include an unmodified $wp_version.
require ABSPATH . WPINC . '/version.php';

return sprintf(
'WordPress/%1$s;PHP/%2$s;ConvertKit/%3$s;%4$s',
$wp_version,
phpversion(),
CONVERTKIT_PLUGIN_VERSION,
home_url( '/' )
);
}
65 changes: 27 additions & 38 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"title": "ConvertKit",
"author": "ConvertKit",
"license": "GPL-2.0",
"version": "1.9.3",
"version": "1.9.4",
"description": "",
"homepage": "https://github.com/convertkit/ConvertKit-WordPress",
"main": "Gruntfile.js",
Expand Down
15 changes: 11 additions & 4 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
Contributors: nathanbarry, growdev, travisnorthcutt, ggwicz
Donate link: https://convertkit.com
Tags: email, marketing, embed form, convertkit, capture
Requires at least: 4.8
Tested up to: 5.5.3
Stable tag: 1.9.3
Requires at least: 4.9
Tested up to: 5.6.2
Stable tag: 1.9.4
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Expand Down Expand Up @@ -49,8 +49,15 @@ No. You must first have an account on ConvertKit.com, but you do not have to use

== Changelog ==

### 1.9.4 2021-02-22
* New: Increase minimum supported WordPress version to 4.9 and maximum supported WordPress version to 5.6.2
* Fix: Restore original plugin file name (`wp-convertkit.php`), which reverts the breaking file name change (`plugin.php`) released in 1.9.3
* Fix: Fixed inconsistent refreshing of forms in the ConvertKit forms dropdown
* Fix: Fixed occasional "undefined variable" notices regarding the API key and API secret
* Tweak: Add ConvertKit plugin information to useragent of plugin API requests

### 1.9.3 2020-11-11
* New: Increase minimum supported WordPress version to 4.7 and maximum supported WordPress version to 5.5.3
* New: Increase minimum supported WordPress version to 4.8 and maximum supported WordPress version to 5.5.3
* Fix: Fix occasional "undefined variable" notice when viewing ConvertKit forms dropdown
* Fix: Only log transients from `get_form()` method when debugging is enabled
* Tweak: Remove `sslverify => false` argument from main ConvertKit API call
Expand Down
4 changes: 2 additions & 2 deletions wp-convertkit.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Plugin Name: ConvertKit
* Plugin URI: https://convertkit.com/
* Description: Quickly and easily integrate ConvertKit forms into your site.
* Version: 1.9.3
* Version: 1.9.4
* Author: ConvertKit
* Author URI: https://convertkit.com/
* Text Domain: convertkit
Expand All @@ -16,7 +16,7 @@
define( 'CONVERTKIT_PLUGIN_FILE', plugin_basename( __FILE__ ) );
define( 'CONVERTKIT_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
define( 'CONVERTKIT_PLUGIN_PATH', __DIR__ );
define( 'CONVERTKIT_PLUGIN_VERSION', '1.9.3' );
define( 'CONVERTKIT_PLUGIN_VERSION', '1.9.4' );

require_once CONVERTKIT_PLUGIN_PATH . '/vendor/autoload.php';

Expand Down

0 comments on commit 8e260f7

Please sign in to comment.