Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93

Warning: Undefined array key "page_file_edit_line" in /home/sportsfever/public_html/filemanger/edit_text_line.php on line 32
/home/sportsfe.../httpdocs/clone/wp-conte.../plugins/content-.../inc/freemius/includes
File: class-freemius.php
) {
[12000] Fix | Delete
continue;
[12001] Fix | Delete
}
[12002] Fix | Delete
[12003] Fix | Delete
$license_ids[ $install->license_id ] = true;
[12004] Fix | Delete
}
[12005] Fix | Delete
[12006] Fix | Delete
return array_keys( $license_ids );
[12007] Fix | Delete
}
[12008] Fix | Delete
[12009] Fix | Delete
/**
[12010] Fix | Delete
* @author Vova Feldman (@svovaf)
[12011] Fix | Delete
* @since 1.0.5
[12012] Fix | Delete
*
[12013] Fix | Delete
* @param number $id
[12014] Fix | Delete
*
[12015] Fix | Delete
* @return FS_Plugin_Plan|false
[12016] Fix | Delete
*/
[12017] Fix | Delete
function _get_plan_by_id( $id ) {
[12018] Fix | Delete
$this->_logger->entrance();
[12019] Fix | Delete
[12020] Fix | Delete
if ( ! is_array( $this->_plans ) || 0 === count( $this->_plans ) ) {
[12021] Fix | Delete
$this->_sync_plans();
[12022] Fix | Delete
}
[12023] Fix | Delete
[12024] Fix | Delete
foreach ( $this->_plans as $plan ) {
[12025] Fix | Delete
if ( $id == $plan->id ) {
[12026] Fix | Delete
return $plan;
[12027] Fix | Delete
}
[12028] Fix | Delete
}
[12029] Fix | Delete
[12030] Fix | Delete
return false;
[12031] Fix | Delete
}
[12032] Fix | Delete
[12033] Fix | Delete
/**
[12034] Fix | Delete
* @author Vova Feldman (@svovaf)
[12035] Fix | Delete
* @since 1.1.8.1
[12036] Fix | Delete
*
[12037] Fix | Delete
* @param string $name
[12038] Fix | Delete
*
[12039] Fix | Delete
* @return FS_Plugin_Plan|false
[12040] Fix | Delete
*/
[12041] Fix | Delete
private function get_plan_by_name( $name ) {
[12042] Fix | Delete
$this->_logger->entrance();
[12043] Fix | Delete
[12044] Fix | Delete
if ( ! is_array( $this->_plans ) || 0 === count( $this->_plans ) ) {
[12045] Fix | Delete
$this->_sync_plans();
[12046] Fix | Delete
}
[12047] Fix | Delete
[12048] Fix | Delete
foreach ( $this->_plans as $plan ) {
[12049] Fix | Delete
if ( $name == $plan->name ) {
[12050] Fix | Delete
return $plan;
[12051] Fix | Delete
}
[12052] Fix | Delete
}
[12053] Fix | Delete
[12054] Fix | Delete
return false;
[12055] Fix | Delete
}
[12056] Fix | Delete
[12057] Fix | Delete
/**
[12058] Fix | Delete
* Sync local licenses with remote server.
[12059] Fix | Delete
*
[12060] Fix | Delete
* @author Vova Feldman (@svovaf)
[12061] Fix | Delete
* @since 1.0.6
[12062] Fix | Delete
*
[12063] Fix | Delete
* @param number|bool $site_license_id
[12064] Fix | Delete
* @param number|null $blog_id
[12065] Fix | Delete
*
[12066] Fix | Delete
* @return FS_Plugin_License[]|object
[12067] Fix | Delete
*/
[12068] Fix | Delete
function _sync_licenses( $site_license_id = false, $blog_id = null ) {
[12069] Fix | Delete
$this->_logger->entrance();
[12070] Fix | Delete
[12071] Fix | Delete
$is_network_admin = fs_is_network_admin();
[12072] Fix | Delete
[12073] Fix | Delete
if ( $is_network_admin && is_null( $blog_id ) ) {
[12074] Fix | Delete
$all_licenses = self::get_all_licenses( $this->_module_id );
[12075] Fix | Delete
} else {
[12076] Fix | Delete
$all_licenses = $this->get_user_licenses( $this->_user->id );
[12077] Fix | Delete
}
[12078] Fix | Delete
[12079] Fix | Delete
$foreign_licenses = $this->get_foreign_licenses_info( $all_licenses, $site_license_id );
[12080] Fix | Delete
[12081] Fix | Delete
$all_licenses_map = array();
[12082] Fix | Delete
foreach ( $all_licenses as $license ) {
[12083] Fix | Delete
$all_licenses_map[ $license->id ] = true;
[12084] Fix | Delete
}
[12085] Fix | Delete
[12086] Fix | Delete
$licenses = $this->_fetch_licenses( false, $site_license_id, $foreign_licenses, $blog_id );
[12087] Fix | Delete
[12088] Fix | Delete
if ( $this->is_array_instanceof( $licenses, 'FS_Plugin_License' ) ) {
[12089] Fix | Delete
$licenses_map = array();
[12090] Fix | Delete
foreach ( $licenses as $license ) {
[12091] Fix | Delete
$licenses_map[ $license->id ] = true;
[12092] Fix | Delete
}
[12093] Fix | Delete
[12094] Fix | Delete
// $license_ids_to_keep = $this->get_license_ids_associated_with_installs();
[12095] Fix | Delete
// foreach ( $license_ids_to_keep as $license_id ) {
[12096] Fix | Delete
// if ( isset( $licenses_map[ $license_id ] ) ) {
[12097] Fix | Delete
// continue;
[12098] Fix | Delete
// }
[12099] Fix | Delete
//
[12100] Fix | Delete
// $missing_license = self::_get_license_by_id( $license_id, false );
[12101] Fix | Delete
// if ( is_object( $missing_license ) ) {
[12102] Fix | Delete
// $licenses[] = $missing_license;
[12103] Fix | Delete
// $licenses_map[ $missing_license->id ] = true;
[12104] Fix | Delete
// }
[12105] Fix | Delete
// }
[12106] Fix | Delete
[12107] Fix | Delete
$user_license_ids = $this->get_user_linked_license_ids( $this->_user->id );
[12108] Fix | Delete
[12109] Fix | Delete
foreach ( $user_license_ids as $key => $license_id ) {
[12110] Fix | Delete
if ( ! isset( $licenses_map[ $license_id ] ) ) {
[12111] Fix | Delete
// Remove access to licenses that no longer exist.
[12112] Fix | Delete
unset( $user_license_ids[ $key ] );
[12113] Fix | Delete
}
[12114] Fix | Delete
}
[12115] Fix | Delete
[12116] Fix | Delete
if ( ! empty( $user_license_ids ) ) {
[12117] Fix | Delete
foreach ( $licenses_map as $license_id => $value ) {
[12118] Fix | Delete
if ( ! isset( $all_licenses_map[ $license_id ] ) ) {
[12119] Fix | Delete
// Associate new licenses with the user who triggered the license syncing.
[12120] Fix | Delete
$user_license_ids[] = $license_id;
[12121] Fix | Delete
}
[12122] Fix | Delete
}
[12123] Fix | Delete
[12124] Fix | Delete
$user_license_ids = array_unique( $user_license_ids );
[12125] Fix | Delete
} else {
[12126] Fix | Delete
$user_license_ids = array_keys( $licenses_map );
[12127] Fix | Delete
}
[12128] Fix | Delete
[12129] Fix | Delete
if ( ! $is_network_admin || ! is_null( $blog_id ) ) {
[12130] Fix | Delete
$user_licenses = array();
[12131] Fix | Delete
foreach ( $licenses as $license ) {
[12132] Fix | Delete
if ( ! in_array( $license->id, $user_license_ids ) ) {
[12133] Fix | Delete
continue;
[12134] Fix | Delete
}
[12135] Fix | Delete
[12136] Fix | Delete
$user_licenses[] = $license;
[12137] Fix | Delete
}
[12138] Fix | Delete
[12139] Fix | Delete
$this->_licenses = $user_licenses;
[12140] Fix | Delete
} else {
[12141] Fix | Delete
$this->_licenses = $licenses;
[12142] Fix | Delete
}
[12143] Fix | Delete
[12144] Fix | Delete
$this->set_user_linked_license_ids( $this->_user->id, $user_license_ids );
[12145] Fix | Delete
[12146] Fix | Delete
$this->_store_licenses( true, $this->_module_id, $licenses );
[12147] Fix | Delete
}
[12148] Fix | Delete
[12149] Fix | Delete
// Update current license.
[12150] Fix | Delete
if ( is_object( $this->_license ) ) {
[12151] Fix | Delete
$license = $this->_get_license_by_id( $this->_license->id );
[12152] Fix | Delete
[12153] Fix | Delete
if ( is_object( $license ) ) {
[12154] Fix | Delete
/**
[12155] Fix | Delete
* `$license` can be `false` in case a user change action has just been completed and this method
[12156] Fix | Delete
* has synced the `$this->_licenses` collection for the new user. In this case, the
[12157] Fix | Delete
* `$this->_licenses` collection may have only the newly activated license that is associated with
[12158] Fix | Delete
* the new user. `set_license` will eventually be called in the same request by the logic that
[12159] Fix | Delete
* follows outside this method which will detect that the install's license has been updated, and
[12160] Fix | Delete
* then `_update_site_license` will be called which in turn will call `set_license`.
[12161] Fix | Delete
*
[12162] Fix | Delete
* @author Leo Fajardo (@leorw)
[12163] Fix | Delete
* @since 2.3.2
[12164] Fix | Delete
*/
[12165] Fix | Delete
$this->set_license( $license );
[12166] Fix | Delete
}
[12167] Fix | Delete
}
[12168] Fix | Delete
[12169] Fix | Delete
return $this->_licenses;
[12170] Fix | Delete
}
[12171] Fix | Delete
[12172] Fix | Delete
/**
[12173] Fix | Delete
* @author Vova Feldman (@svovaf)
[12174] Fix | Delete
* @since 1.0.5
[12175] Fix | Delete
*
[12176] Fix | Delete
* @param number $id
[12177] Fix | Delete
* @param bool $sync_licenses
[12178] Fix | Delete
*
[12179] Fix | Delete
* @return FS_Plugin_License|false
[12180] Fix | Delete
*/
[12181] Fix | Delete
function _get_license_by_id( $id, $sync_licenses = true ) {
[12182] Fix | Delete
$this->_logger->entrance();
[12183] Fix | Delete
[12184] Fix | Delete
if ( ! FS_Plugin_License::is_valid_id( $id ) ) {
[12185] Fix | Delete
return false;
[12186] Fix | Delete
}
[12187] Fix | Delete
[12188] Fix | Delete
/**
[12189] Fix | Delete
* When running from the network level admin and opted-in from the network,
[12190] Fix | Delete
* check if the license exists in the network user licenses collection.
[12191] Fix | Delete
*
[12192] Fix | Delete
* @author Vova Feldman (@svovaf)
[12193] Fix | Delete
* @since 2.0.0
[12194] Fix | Delete
*/
[12195] Fix | Delete
if ( fs_is_network_admin() &&
[12196] Fix | Delete
$this->is_network_registered() &&
[12197] Fix | Delete
( ! is_object( $this->_user ) || $this->_storage->network_user_id != $this->_user->id )
[12198] Fix | Delete
) {
[12199] Fix | Delete
$licenses = $this->get_user_licenses( $this->_storage->network_user_id );
[12200] Fix | Delete
[12201] Fix | Delete
foreach ( $licenses as $license ) {
[12202] Fix | Delete
if ( $id == $license->id ) {
[12203] Fix | Delete
return $license;
[12204] Fix | Delete
}
[12205] Fix | Delete
}
[12206] Fix | Delete
}
[12207] Fix | Delete
[12208] Fix | Delete
if ( ! $this->has_any_license() && $sync_licenses ) {
[12209] Fix | Delete
$this->_sync_licenses( $id );
[12210] Fix | Delete
}
[12211] Fix | Delete
[12212] Fix | Delete
if ( is_array( $this->_licenses ) ) {
[12213] Fix | Delete
foreach ( $this->_licenses as $license ) {
[12214] Fix | Delete
if ( $id == $license->id ) {
[12215] Fix | Delete
return $license;
[12216] Fix | Delete
}
[12217] Fix | Delete
}
[12218] Fix | Delete
}
[12219] Fix | Delete
[12220] Fix | Delete
return false;
[12221] Fix | Delete
}
[12222] Fix | Delete
[12223] Fix | Delete
/**
[12224] Fix | Delete
* Get license by ID. Unlike _get_license_by_id(), this method only checks the local storage and return any license, whether it's associated with the current context user/install or not.
[12225] Fix | Delete
*
[12226] Fix | Delete
* @author Vova Feldman (@svovaf)
[12227] Fix | Delete
* @since 2.0.0
[12228] Fix | Delete
*
[12229] Fix | Delete
* @param number $id
[12230] Fix | Delete
*
[12231] Fix | Delete
* @return FS_Plugin_License
[12232] Fix | Delete
*/
[12233] Fix | Delete
private function get_license_by_id( $id ) {
[12234] Fix | Delete
$licenses = self::get_all_licenses( $this->_module_id );
[12235] Fix | Delete
[12236] Fix | Delete
if ( is_array( $licenses ) && ! empty( $licenses ) ) {
[12237] Fix | Delete
foreach ( $licenses as $license ) {
[12238] Fix | Delete
if ( $id == $license->id ) {
[12239] Fix | Delete
return $license;
[12240] Fix | Delete
}
[12241] Fix | Delete
}
[12242] Fix | Delete
}
[12243] Fix | Delete
[12244] Fix | Delete
return null;
[12245] Fix | Delete
}
[12246] Fix | Delete
[12247] Fix | Delete
/**
[12248] Fix | Delete
* Synchronize the site's context license by fetching the license form the API and updating the local data with it.
[12249] Fix | Delete
*
[12250] Fix | Delete
* @author Vova Feldman (@svovaf)
[12251] Fix | Delete
* @since 2.0.0
[12252] Fix | Delete
*
[12253] Fix | Delete
* @return \FS_Plugin_License|mixed
[12254] Fix | Delete
*/
[12255] Fix | Delete
private function sync_site_license() {
[12256] Fix | Delete
$api = $this->get_api_user_scope();
[12257] Fix | Delete
[12258] Fix | Delete
$result = $api->get( "/licenses/{$this->_license->id}.json?license_key=" . urlencode( $this->_license->secret_key ), true );
[12259] Fix | Delete
[12260] Fix | Delete
if ( ! $this->is_api_result_entity( $result ) ) {
[12261] Fix | Delete
return $result;
[12262] Fix | Delete
}
[12263] Fix | Delete
[12264] Fix | Delete
$license = $this->_update_site_license( new FS_Plugin_License( $result ) );
[12265] Fix | Delete
$this->_store_licenses();
[12266] Fix | Delete
[12267] Fix | Delete
return $license;
[12268] Fix | Delete
}
[12269] Fix | Delete
[12270] Fix | Delete
/**
[12271] Fix | Delete
* Get all user's available licenses for the current module.
[12272] Fix | Delete
*
[12273] Fix | Delete
* @author Vova Feldman (@svovaf)
[12274] Fix | Delete
* @since 2.0.0
[12275] Fix | Delete
*
[12276] Fix | Delete
* @param number $user_id
[12277] Fix | Delete
*
[12278] Fix | Delete
* @return FS_Plugin_License[]
[12279] Fix | Delete
*/
[12280] Fix | Delete
private function get_user_licenses( $user_id ) {
[12281] Fix | Delete
$all_licenses = self::get_all_licenses( $this->_module_id );
[12282] Fix | Delete
if ( empty( $all_licenses ) ) {
[12283] Fix | Delete
return array();
[12284] Fix | Delete
}
[12285] Fix | Delete
[12286] Fix | Delete
$user_license_ids = $this->get_user_linked_license_ids( $user_id );
[12287] Fix | Delete
if ( empty( $user_license_ids ) ) {
[12288] Fix | Delete
return array();
[12289] Fix | Delete
}
[12290] Fix | Delete
[12291] Fix | Delete
$licenses = array();
[12292] Fix | Delete
foreach ( $all_licenses as $license ) {
[12293] Fix | Delete
if ( in_array( $license->id, $user_license_ids ) ) {
[12294] Fix | Delete
$licenses[] = $license;
[12295] Fix | Delete
}
[12296] Fix | Delete
}
[12297] Fix | Delete
[12298] Fix | Delete
return $licenses;
[12299] Fix | Delete
}
[12300] Fix | Delete
[12301] Fix | Delete
/**
[12302] Fix | Delete
* Checks if the context license is network activated except on the given blog ID.
[12303] Fix | Delete
*
[12304] Fix | Delete
* @author Vova Feldman (@svovaf)
[12305] Fix | Delete
* @since 2.0.0
[12306] Fix | Delete
*
[12307] Fix | Delete
* @param int $except_blog_id
[12308] Fix | Delete
*
[12309] Fix | Delete
* @return bool
[12310] Fix | Delete
*/
[12311] Fix | Delete
private function is_license_network_active( $except_blog_id = 0 ) {
[12312] Fix | Delete
$this->_logger->entrance();
[12313] Fix | Delete
[12314] Fix | Delete
if ( ! is_object( $this->_license ) ) {
[12315] Fix | Delete
return false;
[12316] Fix | Delete
}
[12317] Fix | Delete
[12318] Fix | Delete
$sites = self::get_sites();
[12319] Fix | Delete
[12320] Fix | Delete
if ( $this->_license->total_activations() < ( count( $sites ) - 1 ) ) {
[12321] Fix | Delete
// There are more sites than the number of activations, so license cannot be network activated.
[12322] Fix | Delete
return false;
[12323] Fix | Delete
}
[12324] Fix | Delete
[12325] Fix | Delete
foreach ( $sites as $site ) {
[12326] Fix | Delete
$blog_id = self::get_site_blog_id( $site );
[12327] Fix | Delete
[12328] Fix | Delete
if ( $except_blog_id == $blog_id ) {
[12329] Fix | Delete
// Skip excluded blog.
[12330] Fix | Delete
continue;
[12331] Fix | Delete
}
[12332] Fix | Delete
[12333] Fix | Delete
$install = $this->get_install_by_blog_id( $blog_id );
[12334] Fix | Delete
[12335] Fix | Delete
if ( is_object( $install ) && $install->license_id != $this->_license->id ) {
[12336] Fix | Delete
return false;
[12337] Fix | Delete
}
[12338] Fix | Delete
}
[12339] Fix | Delete
[12340] Fix | Delete
return true;
[12341] Fix | Delete
}
[12342] Fix | Delete
[12343] Fix | Delete
/**
[12344] Fix | Delete
* Checks if license can be activated on all the network sites (opted-in or skipped) that are not yet associated with a license. If possible, try to make the activation, if not return false.
[12345] Fix | Delete
*
[12346] Fix | Delete
* Notice: On success, this method will also update the license activations counters (without updating the license in the storage).
[12347] Fix | Delete
*
[12348] Fix | Delete
* @author Vova Feldman (@svovaf)
[12349] Fix | Delete
* @since 2.0.0
[12350] Fix | Delete
*
[12351] Fix | Delete
* @param \FS_User $user
[12352] Fix | Delete
* @param \FS_Plugin_License $license
[12353] Fix | Delete
*
[12354] Fix | Delete
* @return bool
[12355] Fix | Delete
*/
[12356] Fix | Delete
private function try_activate_license_on_network( FS_User $user, FS_Plugin_License $license ) {
[12357] Fix | Delete
$this->_logger->entrance();
[12358] Fix | Delete
[12359] Fix | Delete
$result = $this->can_activate_license_on_network( $license );
[12360] Fix | Delete
[12361] Fix | Delete
if ( false === $result ) {
[12362] Fix | Delete
return false;
[12363] Fix | Delete
}
[12364] Fix | Delete
[12365] Fix | Delete
$installs_without_license = $result['installs'];
[12366] Fix | Delete
if ( ! empty( $installs_without_license ) ) {
[12367] Fix | Delete
$this->activate_license_on_many_installs( $user, $license->secret_key, $installs_without_license );
[12368] Fix | Delete
}
[12369] Fix | Delete
[12370] Fix | Delete
$disconnected_site_ids = $result['sites'];
[12371] Fix | Delete
if ( ! empty( $disconnected_site_ids ) ) {
[12372] Fix | Delete
$this->activate_license_on_many_sites( $user, $license->secret_key, $disconnected_site_ids );
[12373] Fix | Delete
}
[12374] Fix | Delete
[12375] Fix | Delete
$this->link_license_2_user( $license->id, $user->id );
[12376] Fix | Delete
[12377] Fix | Delete
// Sync license after activations.
[12378] Fix | Delete
$license->activated += $result['production_count'];
[12379] Fix | Delete
$license->activated_local += $result['localhost_count'];
[12380] Fix | Delete
[12381] Fix | Delete
// $this->_store_licenses()
[12382] Fix | Delete
[12383] Fix | Delete
return true;
[12384] Fix | Delete
}
[12385] Fix | Delete
[12386] Fix | Delete
/**
[12387] Fix | Delete
* Checks if the given license can be activated on the whole network.
[12388] Fix | Delete
*
[12389] Fix | Delete
* @author Vova Feldman (@svovaf)
[12390] Fix | Delete
* @since 2.0.0
[12391] Fix | Delete
*
[12392] Fix | Delete
* @param \FS_Plugin_License $license
[12393] Fix | Delete
*
[12394] Fix | Delete
* @return false|array {
[12395] Fix | Delete
* @type array[int]FS_Site $installs Blog ID to install map.
[12396] Fix | Delete
* @type int[] $sites Non-connected blog IDs.
[12397] Fix | Delete
* @type int $production_count Production sites count.
[12398] Fix | Delete
* @type int $localhost_count Production sites count.
[12399] Fix | Delete
* }
[12400] Fix | Delete
*/
[12401] Fix | Delete
private function can_activate_license_on_network( FS_Plugin_License $license ) {
[12402] Fix | Delete
$sites = self::get_sites();
[12403] Fix | Delete
[12404] Fix | Delete
$production_count = 0;
[12405] Fix | Delete
$localhost_count = 0;
[12406] Fix | Delete
[12407] Fix | Delete
$installs_without_license = array();
[12408] Fix | Delete
$disconnected_site_ids = array();
[12409] Fix | Delete
[12410] Fix | Delete
foreach ( $sites as $site ) {
[12411] Fix | Delete
$blog_id = self::get_site_blog_id( $site );
[12412] Fix | Delete
$install = $this->get_install_by_blog_id( $blog_id );
[12413] Fix | Delete
[12414] Fix | Delete
if ( is_object( $install ) ) {
[12415] Fix | Delete
if ( FS_Plugin_License::is_valid_id( $install->license_id ) ) {
[12416] Fix | Delete
// License already activated on the install.
[12417] Fix | Delete
continue;
[12418] Fix | Delete
}
[12419] Fix | Delete
[12420] Fix | Delete
$url = $install->url;
[12421] Fix | Delete
[12422] Fix | Delete
$installs_without_license[ $blog_id ] = $install;
[12423] Fix | Delete
} else {
[12424] Fix | Delete
$url = is_object( $site ) ?
[12425] Fix | Delete
$site->siteurl :
[12426] Fix | Delete
self::get_unfiltered_site_url( $blog_id );
[12427] Fix | Delete
[12428] Fix | Delete
$disconnected_site_ids[] = $blog_id;
[12429] Fix | Delete
}
[12430] Fix | Delete
[12431] Fix | Delete
if ( FS_Site::is_localhost_by_address( $url ) ) {
[12432] Fix | Delete
$localhost_count ++;
[12433] Fix | Delete
} else {
[12434] Fix | Delete
$production_count ++;
[12435] Fix | Delete
}
[12436] Fix | Delete
}
[12437] Fix | Delete
[12438] Fix | Delete
if ( ! $license->can_activate_bulk( $production_count, $localhost_count ) ) {
[12439] Fix | Delete
return false;
[12440] Fix | Delete
}
[12441] Fix | Delete
[12442] Fix | Delete
return array(
[12443] Fix | Delete
'installs' => $installs_without_license,
[12444] Fix | Delete
'sites' => $disconnected_site_ids,
[12445] Fix | Delete
'production_count' => $production_count,
[12446] Fix | Delete
'localhost_count' => $localhost_count,
[12447] Fix | Delete
);
[12448] Fix | Delete
}
[12449] Fix | Delete
[12450] Fix | Delete
/**
[12451] Fix | Delete
* Activate a given license on a collection of installs.
[12452] Fix | Delete
*
[12453] Fix | Delete
* @author Vova Feldman (@svovaf)
[12454] Fix | Delete
* @since 2.0.0
[12455] Fix | Delete
*
[12456] Fix | Delete
* @param \FS_User $user
[12457] Fix | Delete
* @param string $license_key
[12458] Fix | Delete
* @param array $blog_2_install_map {
[12459] Fix | Delete
* @key int Blog ID.
[12460] Fix | Delete
* @value FS_Site Blog's associated install.
[12461] Fix | Delete
* }
[12462] Fix | Delete
*
[12463] Fix | Delete
* @return mixed|true
[12464] Fix | Delete
*/
[12465] Fix | Delete
private function activate_license_on_many_installs(
[12466] Fix | Delete
FS_User $user,
[12467] Fix | Delete
$license_key,
[12468] Fix | Delete
array $blog_2_install_map
[12469] Fix | Delete
) {
[12470] Fix | Delete
$params = array(
[12471] Fix | Delete
array( 'license_key' => $this->apply_filters( 'license_key', $license_key ) )
[12472] Fix | Delete
);
[12473] Fix | Delete
[12474] Fix | Delete
$install_2_blog_map = array();
[12475] Fix | Delete
foreach ( $blog_2_install_map as $blog_id => $install ) {
[12476] Fix | Delete
$params[] = array( 'id' => $install->id, 'url' => $install->url );
[12477] Fix | Delete
[12478] Fix | Delete
$install_2_blog_map[ $install->id ] = $blog_id;
[12479] Fix | Delete
}
[12480] Fix | Delete
[12481] Fix | Delete
$result = $this->get_api_user_scope_by_user( $user )->call(
[12482] Fix | Delete
"plugins/{$this->_plugin->id}/installs.json",
[12483] Fix | Delete
'PUT',
[12484] Fix | Delete
$params
[12485] Fix | Delete
);
[12486] Fix | Delete
[12487] Fix | Delete
if ( ! $this->is_api_result_object( $result, 'installs' ) ) {
[12488] Fix | Delete
return $result;
[12489] Fix | Delete
}
[12490] Fix | Delete
[12491] Fix | Delete
foreach ( $result->installs as $r_install ) {
[12492] Fix | Delete
$install = new FS_Site( $r_install );
[12493] Fix | Delete
$install->is_disconnected = false;
[12494] Fix | Delete
[12495] Fix | Delete
// Update install.
[12496] Fix | Delete
$this->_store_site(
[12497] Fix | Delete
true,
[12498] Fix | Delete
$install_2_blog_map[ $r_install->id ],
[12499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function