Skip to content

Commit

Permalink
7.3.3
Browse files Browse the repository at this point in the history
  • Loading branch information
chriscct7 committed Dec 31, 2018
1 parent e64af55 commit ad1bda0
Show file tree
Hide file tree
Showing 13 changed files with 160 additions and 112 deletions.
2 changes: 1 addition & 1 deletion assets/css/admin.css
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@
#monsterinsights-settings-pages{padding:20px 0}
.monsterinsights-main-nav-tabs label{margin-top:7px;display:block;color:#444851}
.monsterinsights-sub-nav-tabs label{margin-top:7px;display:block}
#monsterinsights-settings-pages #monsterinsights-settings-submit{margin:40px 0 0 0px}
#monsterinsights-settings-pages #monsterinsights-settings-submit, #monsterinsights-settings-pages #monsterinsights-network-settings-submit{margin:40px 0 0 0px}
#monsterinsights-settings-pages #monsterinsights-refresh-submit{margin-left:10px;vertical-align:baseline;}
input.monsterinsights-large-checkbox{zoom:1.5}
#monsterinsights-settings-pages input[type="text"],#monsterinsights-settings-pages input[type="number"],#monsterinsights-settings-pages input[type="password"],#monsterinsights-settings-pages input[type=email], #monsterinsights-settings-pages select,#monsterinsights-settings-pages textarea{width:350px;padding-right:0;font-size:13px;border-width:2px;border-radius:3px;border-color:#e4e9ee;box-shadow:none}
Expand Down
2 changes: 1 addition & 1 deletion assets/css/admin.min.css

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public function get_feed_urls( $url ) {
}

// Check if WPForms is active.
if ( class_exists( 'WPForms', false ) ) {
if ( function_exists( 'wpforms' ) ) {
$feed_urls[] = 'https://wpforms.com/feed/';
}

Expand Down
4 changes: 2 additions & 2 deletions googleanalytics.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Author: MonsterInsights
* Author URI: https://www.monsterinsights.com/?utm_source=liteplugin&utm_medium=pluginheader&utm_campaign=authoruri&utm_content=7%2E0%2E0
*
* Version: 7.3.2
* Version: 7.3.3
* Requires at least: 3.8.0
* Tested up to: 5.0
*
Expand Down Expand Up @@ -69,7 +69,7 @@ final class MonsterInsights_Lite {
* @access public
* @var string $version Plugin version.
*/
public $version = '7.3.2';
public $version = '7.3.3';

/**
* Plugin file.
Expand Down
9 changes: 6 additions & 3 deletions includes/admin/api-auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ public function maybe_authenticate(){
'network' => is_network_admin() ? 'network' : 'site',
'siteurl' => is_network_admin() ? network_admin_url() : site_url(),
'return' => is_network_admin() ? network_admin_url( 'admin.php?page=monsterinsights_network' ) : admin_url( 'admin.php?page=monsterinsights_settings' ),
'testurl' => 'https://api.monsterinsights.com/v2/test/',
), $this->get_route( 'https://' . monsterinsights_get_api_url() . 'auth/new/{type}' ) );

if ( monsterinsights_is_pro_version() ) {
Expand Down Expand Up @@ -260,6 +261,7 @@ public function maybe_reauthenticate(){
'key' => MonsterInsights()->auth->get_key(),
'token' => MonsterInsights()->auth->get_token(),
'return' => is_network_admin() ? network_admin_url( 'admin.php?page=monsterinsights_network' ) : admin_url( 'admin.php?page=monsterinsights_settings' ),
'testurl' => 'https://api.monsterinsights.com/v2/test/',
), $this->get_route( 'https://' . monsterinsights_get_api_url() . 'auth/reauth/{type}' ) );

if ( monsterinsights_is_pro_version() ) {
Expand Down Expand Up @@ -384,7 +386,7 @@ public function verify_auth( $credentials = array() ){
}

$network = ! empty( $_REQUEST['network'] ) ? $_REQUEST['network'] === 'network' : $this->is_network_admin();
$api = new MonsterInsights_API_Request( $this->get_route( 'auth/verify/{type}/' ), array( 'network' => $network, 'tt' => $this->get_tt(), 'key' => $creds['key'], 'token' => $creds['token'] ) );
$api = new MonsterInsights_API_Request( $this->get_route( 'auth/verify/{type}/' ), array( 'network' => $network, 'tt' => $this->get_tt(), 'key' => $creds['key'], 'token' => $creds['token'], 'testurl' => 'https://api.monsterinsights.com/v2/test/' ) );
$ret = $api->request();

if ( is_wp_error( $ret ) ) {
Expand Down Expand Up @@ -462,7 +464,7 @@ public function delete_auth( $force = false ){
}
}

$api = new MonsterInsights_API_Request( $this->get_route( 'auth/delete/{type}/' ), array( 'network' => $this->is_network_admin(), 'tt' => $this->get_tt(), 'key' => $creds['key'], 'token' => $creds['token'] ) );
$api = new MonsterInsights_API_Request( $this->get_route( 'auth/delete/{type}/' ), array( 'network' => $this->is_network_admin(), 'tt' => $this->get_tt(), 'key' => $creds['key'], 'token' => $creds['token'], 'testurl' => 'https://api.monsterinsights.com/v2/test/' ) );
$ret = $api->request();

if ( is_wp_error( $ret ) && ! $force ) {
Expand Down Expand Up @@ -495,7 +497,8 @@ public function uninstall_network_auth() {
'network' => true,
'tt' => $this->get_tt(),
'key' => $creds['key'],
'token' => $creds['token']
'token' => $creds['token'],
'testurl' => 'https://api.monsterinsights.com/v2/test/'
) );
// Force the network admin url otherwise this will fail not finding the url in relay.
$api->site_url = network_admin_url();
Expand Down
12 changes: 10 additions & 2 deletions includes/admin/common.php
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,11 @@ function monsterinsights_remove_conflicting_asset_files() {
'font2_css', // Fix for Add Social Share
'font3_css', // Fix for Add Social Share
'hover_css', // Fix for Add Social Share
'fontend_styling' // Fix for Add Social Share
'fontend_styling', // Fix for Add Social Share
'datatable', // WP Todo
'bootstrap', // WP Todo
'flipclock', // WP Todo
'repuso_css_admin', // Social testimonials and reviews by Repuso
);

$scripts = array(
Expand Down Expand Up @@ -327,7 +331,11 @@ function monsterinsights_remove_conflicting_asset_files() {
'material-wp', // Fix for MaterialWP plugin
'wp-color-picker-alpha', // Fix for MaterialWP plugin
'grandtour-theme-script', // Grandtour Theme
'swifty-img-widget-admin-script', // Fix for Swifty Image Widget.
'swifty-img-widget-admin-script', // Fix for Swifty Image Widget
'datatable', // WP Todo
'flipclock', // WP Todo
'bootstrap', // WP Todo
'repuso_js_admin', // Social testimonials and reviews by Repuso
);

if ( ! empty( $styles ) ) {
Expand Down
2 changes: 2 additions & 0 deletions includes/admin/licensing/license-actions.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ public function verify_key() {
is_network_admin() ? MonsterInsights()->license->set_network_license( $option ) : MonsterInsights()->license->set_site_license( $option );
delete_transient( '_monsterinsights_addons' );
monsterinsights_get_addons_data( $option['key'] );
// Make sure users can now update their plugins if they previously an expired key.
wp_clean_plugins_cache( true );
}

/**
Expand Down
20 changes: 16 additions & 4 deletions includes/admin/licensing/updater.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class MonsterInsights_Updater {
* @var bool|string
*/
public $key = false;

/**
* Holds the update data returned from the API.
*
Expand All @@ -87,7 +87,7 @@ class MonsterInsights_Updater {
* @var bool|object
*/
public $update = false;

/**
* Holds the plugin info details for the update.
*
Expand Down Expand Up @@ -138,8 +138,20 @@ public function __construct( array $config ) {
// ManageWP premium update filters
//add_filter( 'mwp_premium_update_notification', array( $this, 'premium_update_push' ) );
//add_filter( 'mwp_premium_perform_update', array( $this, 'premium_update' ) );

// Add additional info if the license is expired.
add_action( 'in_plugin_update_message-'. $this->plugin_path, array( $this, 'maybe_show_license_expired_message' ), 10, 2 );
}

public function maybe_show_license_expired_message( $plugin_data, $response ) {
// If there's no download link but there is an update available there's an issue with the license.
if ( empty( $response->package ) ) {
$settings_url = is_network_admin() ? network_admin_url( 'admin.php?page=monsterinsights_network' ) : admin_url( 'admin.php?page=monsterinsights_settings' );
// Translators: First one is a link to the settings page, second one is closing tag, third is a link to MonsterInsights.com
echo '<br />' . sprintf( __( 'In order to enable updates, you need to have a valid license key on the %1$ssettings page%2$s. If your license key is expired or you need a new key, then %3$sclick here to purchase MonsterInsights Pro%2$s.', 'google-analytics-for-wordpress' ), '<a href="' . esc_url( $settings_url ) . '">', '</a>', '<a href="' . monsterinsights_get_url( 'Plugin update', $this->plugin_name ) . '">' );
}
}

/**
* Infuse plugin update details when WordPress runs its update checker.
*
Expand Down Expand Up @@ -269,7 +281,7 @@ public function set_plugins_api( $default_api ) {
$api->sections['description'] = $description;
} else {
$api->sections = array();
}
}

$api->download_link = isset( $this->info->download_link ) ? $this->info->download_link : '';

Expand Down Expand Up @@ -368,4 +380,4 @@ public function perform_remote_request( $action, $body = array(), $headers = arr
return json_decode( $response_body );

}
}
}
15 changes: 8 additions & 7 deletions includes/admin/pages/network-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ function monsterinsights_network_page() {
?>
<h1><?php esc_html_e( 'Network Settings', 'google-analytics-for-wordpress'); ?></h1>
<p><?php esc_html_e( 'Activate your MonsterInsights license key on this panel to hide the license key settings and addon pages for subsites.', 'google-analytics-for-wordpress'); ?></p>
<form id="monsterinsights-network-general-tab" method="post">

<table class="form-table">
<tbody>
<?php if ( monsterinsights_is_pro_version() ) {
Expand Down Expand Up @@ -137,16 +139,13 @@ function monsterinsights_network_page() {
$network_ua = MonsterInsights()->auth->get_network_manual_ua();
?>
<tr id="monsterinsights-google-ua-box" <?php echo (empty( $network_ua ) ? 'class="monsterinsights-hideme"' : ''); ?> >
<form id="monsterinsights-network-general-tab" method="post">
<th scope="row">
<th scope="row">
<label for="monsterinsights-google-ua"><?php esc_html_e( 'Network UA code', 'google-analytics-for-wordpress' ); ?></label>
</th>
<td>
<input type="text" id="monsterinsights-network-ua-code" name="network_manual_ua_code" value="<?php echo esc_html( MonsterInsights()->auth->get_network_manual_ua() ); ?>" /><?php submit_button( esc_html__( 'Save Network UA code', 'google-analytics-for-wordpress' ), 'button-action', 'monsterinsights-network-settings-submit', false ); ?>
<p class="description"><?php esc_html_e( 'This is the default UA code to use for subsites of a network (can be overriden at the single site level).', 'google-analytics-for-wordpress' ); ?></p>
<?php wp_nonce_field( 'monsterinsights-network-settings-nonce', 'monsterinsights-network-settings-nonce' ); ?>
</td>
</form>
</tr>
<?php } ?>
<!-- Upgrade Doc -->
Expand All @@ -172,6 +171,9 @@ function monsterinsights_network_page() {
?>
</tbody>
</table>
<?php wp_nonce_field( 'monsterinsights-network-settings-nonce', 'monsterinsights-network-settings-nonce' ); ?>
<?php submit_button( esc_html__( 'Save Changes', 'google-analytics-for-wordpress' ), 'primary', 'monsterinsights-network-settings-submit', false ); ?>
</form>
</div>
</div>
</div>
Expand Down Expand Up @@ -219,7 +221,7 @@ function monsterinsights_network_settings_save_general() {
} else if ( empty( $manual_ua_code ) && $manual_ua_code_old ) {
// Deleted manual
MonsterInsights()->auth->delete_network_manual_ua();
} else if ( isset( $_POST['network_manual_ua_code'] ) && empty( $manual_ua_code ) ) {
} else if ( isset( $_POST['network_manual_ua_code'] ) && empty( $manual_ua_code ) && ! empty( $_POST['network_manual_ua_code'] ) ) {
$throw_notice = true;
} else {
// Not UA before or after
Expand All @@ -229,8 +231,7 @@ function monsterinsights_network_settings_save_general() {
$network_hide_am_notices = isset( $_POST['network_hide_am_notices'] ) ? 1 : 0;
$network_hide_am_notices_old = monsterinsights_get_option( 'network_hide_am_notices', false );
if ( $network_hide_am_notices != $network_hide_am_notices_old ) {
monsterinsights_update_option( 'network_hide_am_notices', $network_hide_am_notices );
$throw_notice = true;
monsterinsights_update_option( 'network_hide_am_notices', $network_hide_am_notices );
}

// Output an admin notice so the user knows what happened
Expand Down
6 changes: 3 additions & 3 deletions includes/admin/reports/overview.php
Original file line number Diff line number Diff line change
Expand Up @@ -904,9 +904,9 @@ public function get_referrals( $data ) {
'<span class="monsterinsights-reports-list-count">'
. $i .
'.</span>' .
'<img class="monsterinsights-reports-referral-icon" src="https://www.google.com/s2/favicons?domain=' . $referralsdata['url'] . '" width="16px" height="16px" />' .
'<img class="monsterinsights-reports-referral-icon" src="https://www.google.com/s2/favicons?domain=' . esc_url( $referralsdata['url'] ) . '" width="16px" height="16px" />' .
'<span class="monsterinsights-reports-list-text">'
. $referralsdata['url'] .
. esc_html( $referralsdata['url'] ) .
'</span>
<span class="monsterinsights-reports-list-number">'
. number_format_i18n( $referralsdata['sessions'] ) .
Expand Down Expand Up @@ -951,7 +951,7 @@ public function get_toppages( $data ) {
'. </span>&nbsp;' .
'<span class="monsterinsights-reports-list-text">'
. $opening
. $toppagesdata['title']
. esc_html( $toppagesdata['title'] )
. $closing .
'</span>' .
'<span class="monsterinsights-reports-list-number">' .
Expand Down
21 changes: 18 additions & 3 deletions includes/api-request.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,15 @@ final class MonsterInsights_API_Request {
*/
public $plugin = false;

/**
* URL to test connection with.
*
* @since 7.3.2
*
* @var string
*/
public $testurl = '';

/**
* Additional data to add to request body
*
Expand Down Expand Up @@ -163,7 +172,8 @@ public function __construct( $route, $args, $method = 'POST' ) {
}
$this->plugin = MonsterInsights()->plugin_slug;
$this->miversion = MONSTERINSIGHTS_VERSION;
$this->sitei = ! empty( $args['sitei'] ) ? $args['sitei'] : '';
$this->sitei = ! empty( $args['sitei'] ) ? $args['sitei'] : '';
$this->testurl = ! empty( $args['testurl'] ) ? $args['testurl'] : '';
}

/**
Expand Down Expand Up @@ -273,6 +283,11 @@ public function request() {
// Perform the query and retrieve the response.
$response = 'GET' == $this->method ? wp_remote_get( esc_url_raw( $this->url ) . '?' . $string, $data ) : wp_remote_post( esc_url_raw( $this->url ), $data );
//return new WP_Error( 'debug', '<pre>' . var_export( $response, true ) . '</pre>' );

if ( is_wp_error( $response ) ) {
return $response;
}

$response_code = wp_remote_retrieve_response_code( $response );
$response_body = json_decode( wp_remote_retrieve_body( $response ), true );
//return new WP_Error( 'debug', '<pre>' . var_export( $response_body, true ) . '</pre>' );
Expand Down Expand Up @@ -374,7 +389,7 @@ private function is_blocked( $url = '' ) {
// and for image linking purposes in Google Images. We use it to test outbound connections since it is run on google.com
// and is only a few bytes large. Plus on Google's main CDN so it loads in most places in 0.07 seconds or less. Perfect for our
// use case of quickly testing outbound connections.
$testurl = 'http://www.google.com/blank.html';
$testurl = ! empty( $this->testurl ) ? $this->testurl :'http://www.google.com/blank.html';
if ( defined( 'WP_HTTP_BLOCK_EXTERNAL' ) && WP_HTTP_BLOCK_EXTERNAL ) {
if ( defined( 'WP_ACCESSIBLE_HOSTS' ) ) {
$wp_http = new WP_Http();
Expand Down Expand Up @@ -410,7 +425,7 @@ private function is_blocked( $url = '' ) {
'body' => ''
);
$response = wp_remote_get( $testurl, $params );

if( ! is_wp_error( $response ) && $response['response']['code'] >= 200 && $response['response']['code'] < 300 ) {
return false;
} else {
Expand Down
Loading

0 comments on commit ad1bda0

Please sign in to comment.