Skip to content

Commit

Permalink
Merge pull request #239 from Freemius/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
vovafeldman authored Jun 1, 2018
2 parents 937d96a + 6fed54b commit 292ddda
Show file tree
Hide file tree
Showing 11 changed files with 326 additions and 2,540 deletions.
73 changes: 66 additions & 7 deletions includes/class-freemius.php
Original file line number Diff line number Diff line change
Expand Up @@ -3263,10 +3263,61 @@ function get_anonymous_id( $blog_id = null ) {
*/
static function _get_current_wp_user() {
self::require_pluggable_essentials();
self::wp_cookie_constants();

return wp_get_current_user();
}

/**
* Define cookie constants which are required by Freemius::_get_current_wp_user() since
* it uses wp_get_current_user() which needs the cookie constants set. When a plugin
* is network activated the cookie constants are only configured after the network
* plugins activation, therefore, if we don't define those constants WP will throw
* PHP warnings/notices.
*
* @author Vova Feldman (@svovaf)
* @since 2.1.1
*/
private static function wp_cookie_constants() {
if ( defined( 'LOGGED_IN_COOKIE' ) &&
( defined( 'AUTH_COOKIE' ) || defined( 'SECURE_AUTH_COOKIE' ) )
) {
return;
}

/**
* Used to guarantee unique hash cookies
*
* @since 1.5.0
*/
if ( ! defined( 'COOKIEHASH' ) ) {
$siteurl = get_site_option( 'siteurl' );
if ( $siteurl ) {
define( 'COOKIEHASH', md5( $siteurl ) );
} else {
define( 'COOKIEHASH', '' );
}
}

if ( ! defined( 'LOGGED_IN_COOKIE' ) ) {
define( 'LOGGED_IN_COOKIE', 'wordpress_logged_in_' . COOKIEHASH );
}

/**
* @since 2.5.0
*/
if ( ! defined( 'AUTH_COOKIE' ) ) {
define( 'AUTH_COOKIE', 'wordpress_' . COOKIEHASH );
}

/**
* @since 2.6.0
*/
if ( ! defined( 'SECURE_AUTH_COOKIE' ) ) {
define( 'SECURE_AUTH_COOKIE', 'wordpress_sec_' . COOKIEHASH );
}
}

/**
* @author Vova Feldman (@svovaf)
* @since 2.1.0
Expand Down Expand Up @@ -10805,7 +10856,7 @@ function _network_activate_ajax_action() {
$next_page = $this->get_after_activation_url( 'after_network_activation_url' );
}
} else {
$error = $this->get_text_inline( 'invalid_site_details_collection', 'Invalid site details collection.' );
$error = $this->get_text_inline( 'Invalid site details collection.', 'invalid_site_details_collection' );
}

$result = array(
Expand Down Expand Up @@ -14331,16 +14382,17 @@ private function activate_parent_account( Freemius $parent_fs ) {
unset( $parent_fs->_storage->is_pending_activation );
}

// Get user information based on parent's plugin.
$user = $this->get_user();

// First of all, set site info - otherwise we won't
// be able to invoke API calls.
$parent_fs->_site = new FS_Site( $parent_install );
$parent_fs->_user = $user;

// Sync add-on plans.
$parent_fs->_sync_plans();

// Get user information based on parent's plugin.
$user = $this->get_user();

$parent_fs->_set_account( $user, $parent_fs->_site );
}

Expand Down Expand Up @@ -17235,9 +17287,10 @@ private function _get_latest_version_endpoint( $addon_id = false, $type = 'json'

$is_premium = null;
if ( ! $is_addon ) {
$is_premium = $this->is_premium();
$is_premium = ( $this->is_premium() || $this->_can_download_premium() );
} else if ( $this->is_addon_activated( $addon_id ) ) {
$is_premium = self::get_instance_by_id( $addon_id )->is_premium();
$fs_addon = self::get_instance_by_id( $addon_id );
$is_premium = ( $fs_addon->is_premium() || $fs_addon->_can_download_premium() );
}

// If add-on, then append add-on ID.
Expand Down Expand Up @@ -17433,9 +17486,15 @@ function _get_latest_download_local_url( $plugin_id = false ) {

if ( ! empty( $plugin_id ) ) {
$params['plugin_id'] = $plugin_id;
} else if ( $this->is_addon() ) {
$params['plugin_id'] = $this->get_id();
}

return $this->get_account_url( 'download_latest', $params );
$fs = $this->is_addon() ?
$this->get_parent_instance() :
$this;

return $fs->get_account_url( 'download_latest', $params );
}

#endregion Download Plugin ------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion includes/class-fs-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ static function is_api_error_object( $result ) {
return (
is_object( $result ) &&
isset( $result->error ) &&
isset( $result->message )
isset( $result->error->message )
);
}

Expand Down
Binary file modified languages/freemius-da_DK.mo
Binary file not shown.
Loading

0 comments on commit 292ddda

Please sign in to comment.