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/advanced.../admin/includes
File: class-licenses.php
* version
[500] Fix | Delete
* path
[501] Fix | Delete
* options_slug
[502] Fix | Delete
* short option slug (=key)
[503] Fix | Delete
*/
[504] Fix | Delete
$add_ons = apply_filters( 'advanced-ads-add-ons', [] );
[505] Fix | Delete
[506] Fix | Delete
if ( [] === $add_ons ) {
[507] Fix | Delete
return;
[508] Fix | Delete
}
[509] Fix | Delete
[510] Fix | Delete
$licenses = get_option( ADVADS_SLUG . '-licenses', [] );
[511] Fix | Delete
[512] Fix | Delete
foreach ( $add_ons as $_add_on_key => $_add_on ) {
[513] Fix | Delete
[514] Fix | Delete
// check if a license expired over time.
[515] Fix | Delete
$expiry_date = $this->get_license_expires( $_add_on['options_slug'] );
[516] Fix | Delete
$now = time();
[517] Fix | Delete
if ( $expiry_date && 'lifetime' !== $expiry_date && strtotime( $expiry_date ) < $now ) {
[518] Fix | Delete
// remove license status.
[519] Fix | Delete
delete_option( $_add_on['options_slug'] . '-license-status' );
[520] Fix | Delete
}
[521] Fix | Delete
[522] Fix | Delete
// retrieve our license key.
[523] Fix | Delete
$license_key = isset( $licenses[ $_add_on_key ] ) ? $licenses[ $_add_on_key ] : '';
[524] Fix | Delete
[525] Fix | Delete
// by default, EDD looks every 3 hours for updates. The following code block changes that to 24 hours. set_expiration_of_update_option delivers that value.
[526] Fix | Delete
$option_key = 'pre_update_option_edd_sl_' . md5( serialize( basename( $_add_on['path'], '.php' ) . $license_key ) );
[527] Fix | Delete
add_filter( $option_key, [ $this, 'set_expiration_of_update_option' ] );
[528] Fix | Delete
[529] Fix | Delete
new ADVADS_SL_Plugin_Updater(
[530] Fix | Delete
self::API_ENDPOINT,
[531] Fix | Delete
$_add_on['path'],
[532] Fix | Delete
[
[533] Fix | Delete
'version' => $_add_on['version'],
[534] Fix | Delete
'license' => $license_key,
[535] Fix | Delete
'item_name' => $_add_on['name'],
[536] Fix | Delete
'author' => 'Advanced Ads',
[537] Fix | Delete
]
[538] Fix | Delete
);
[539] Fix | Delete
}
[540] Fix | Delete
}
[541] Fix | Delete
[542] Fix | Delete
/**
[543] Fix | Delete
* Set the expiration of the updater transient key to 1 day instead of 1 hour to prevent too many update checks
[544] Fix | Delete
*
[545] Fix | Delete
* @param array $value value array.
[546] Fix | Delete
*
[547] Fix | Delete
* @return array
[548] Fix | Delete
* @since 1.7.14
[549] Fix | Delete
*/
[550] Fix | Delete
public function set_expiration_of_update_option( $value ) {
[551] Fix | Delete
$value['timeout'] = time() + 86400;
[552] Fix | Delete
[553] Fix | Delete
return $value;
[554] Fix | Delete
}
[555] Fix | Delete
[556] Fix | Delete
/**
[557] Fix | Delete
* Add custom messages to plugin updater
[558] Fix | Delete
*
[559] Fix | Delete
* @param bool $reply Whether to bail without returning the package. Default false.
[560] Fix | Delete
* @param string $package The package file name.
[561] Fix | Delete
* @param string $updater The WP_Upgrader instance.
[562] Fix | Delete
*
[563] Fix | Delete
* @return string
[564] Fix | Delete
*
[565] Fix | Delete
* @todo check if this is still working.
[566] Fix | Delete
*/
[567] Fix | Delete
public function addon_upgrade_filter( $reply, $package, $updater ) {
[568] Fix | Delete
if ( isset( $updater->skin->plugin ) ) {
[569] Fix | Delete
$plugin_file = $updater->skin->plugin;
[570] Fix | Delete
} elseif ( isset( $updater->skin->plugin_info['Name'] ) ) {
[571] Fix | Delete
$add_on = $this->get_installed_add_on_by_name( $updater->skin->plugin_info['Name'] );
[572] Fix | Delete
// $add_on['path'] should always be set with out official plugins but might be missing for some local and custom made.
[573] Fix | Delete
if ( isset( $add_on['path'] ) ) {
[574] Fix | Delete
$plugin_file = plugin_basename( $add_on['path'] );
[575] Fix | Delete
}
[576] Fix | Delete
}
[577] Fix | Delete
[578] Fix | Delete
if ( isset( $plugin_file ) && $plugin_file ) {
[579] Fix | Delete
// hides the download url, but makes debugging harder.
[580] Fix | Delete
// $updater->strings['downloading_package'] = __( 'Downloading updated version...', 'advanced-ads' );
[581] Fix | Delete
// $updater->skin->feedback( 'downloading_package' );
[582] Fix | Delete
[583] Fix | Delete
// if AJAX; show direct update link as first possible solution.
[584] Fix | Delete
if ( defined( 'DOING_AJAX' ) ) {
[585] Fix | Delete
$update_link = wp_nonce_url( self_admin_url( 'update.php?action=upgrade-plugin&plugin=' ) . $plugin_file, 'upgrade-plugin_' . $plugin_file );
[586] Fix | Delete
/* translators: %s plugin update link */
[587] Fix | Delete
$updater->strings['download_failed'] = sprintf( __( 'Download failed. <a href="%s">Click here to try another method</a>.', 'advanced-ads' ), $update_link );
[588] Fix | Delete
} else {
[589] Fix | Delete
/* translators: %s download failed knowledgebase link */
[590] Fix | Delete
$updater->strings['download_failed'] = sprintf( __( 'Download failed. <a href="%s" target="_blank">Click here to learn why</a>.', 'advanced-ads' ), 'https://wpadvancedads.com/manual/download-failed-updating-add-ons/#utm_source=advanced-ads&utm_medium=link&utm_campaign=download-failed' );
[591] Fix | Delete
}
[592] Fix | Delete
}
[593] Fix | Delete
[594] Fix | Delete
return $reply;
[595] Fix | Delete
}
[596] Fix | Delete
[597] Fix | Delete
/**
[598] Fix | Delete
* Search if a name is in the add-on array and return the add-on data of it
[599] Fix | Delete
*
[600] Fix | Delete
* @param string $name name of an add-on.
[601] Fix | Delete
*
[602] Fix | Delete
* @return array array with the add-on data
[603] Fix | Delete
*/
[604] Fix | Delete
private function get_installed_add_on_by_name( $name = '' ) {
[605] Fix | Delete
$add_ons = apply_filters( 'advanced-ads-add-ons', [] );
[606] Fix | Delete
[607] Fix | Delete
if ( is_array( $add_ons ) ) {
[608] Fix | Delete
foreach ( $add_ons as $key => $_add_on ) {
[609] Fix | Delete
if ( $_add_on['name'] === $name ) {
[610] Fix | Delete
return $_add_on;
[611] Fix | Delete
}
[612] Fix | Delete
}
[613] Fix | Delete
}
[614] Fix | Delete
[615] Fix | Delete
return null;
[616] Fix | Delete
}
[617] Fix | Delete
[618] Fix | Delete
/**
[619] Fix | Delete
* Check if any license is valid
[620] Fix | Delete
* can be used to display information for any Pro user only, like link to direct support
[621] Fix | Delete
*/
[622] Fix | Delete
public static function any_license_valid() {
[623] Fix | Delete
$add_ons = apply_filters( 'advanced-ads-add-ons', [] );
[624] Fix | Delete
[625] Fix | Delete
if ( [] === $add_ons ) {
[626] Fix | Delete
return false;
[627] Fix | Delete
}
[628] Fix | Delete
[629] Fix | Delete
foreach ( $add_ons as $_add_on ) {
[630] Fix | Delete
$status = self::get_instance()->get_license_status( $_add_on['options_slug'] );
[631] Fix | Delete
[632] Fix | Delete
// check expiry date.
[633] Fix | Delete
$expiry_date = self::get_instance()->get_license_expires( $_add_on['options_slug'] );
[634] Fix | Delete
[635] Fix | Delete
if (
[636] Fix | Delete
(
[637] Fix | Delete
$expiry_date
[638] Fix | Delete
&& strtotime( $expiry_date ) > time()
[639] Fix | Delete
)
[640] Fix | Delete
|| 'valid' === $status
[641] Fix | Delete
|| 'lifetime' === $expiry_date
[642] Fix | Delete
) {
[643] Fix | Delete
return true;
[644] Fix | Delete
}
[645] Fix | Delete
}
[646] Fix | Delete
[647] Fix | Delete
return false;
[648] Fix | Delete
}
[649] Fix | Delete
[650] Fix | Delete
/**
[651] Fix | Delete
* Update the license status based on information retrieved from the version info check
[652] Fix | Delete
*
[653] Fix | Delete
* @param array|WP_Error $response HTTP response or WP_Error object.
[654] Fix | Delete
* @param string $context Context under which the hook is fired.
[655] Fix | Delete
* @param string $class HTTP transport used.
[656] Fix | Delete
* @param array $parsed_args HTTP request arguments.
[657] Fix | Delete
* @param string $url The request URL.
[658] Fix | Delete
* @return array|WP_Error
[659] Fix | Delete
*/
[660] Fix | Delete
public function update_license_after_version_info( $response, $context, $class, $parsed_args, $url ) {
[661] Fix | Delete
[662] Fix | Delete
// bail if this call is not from our version check or returns an issue
[663] Fix | Delete
if ( $url !== self::API_ENDPOINT
[664] Fix | Delete
|| (
[665] Fix | Delete
empty( $parsed_args['body']['edd_action'] )
[666] Fix | Delete
|| 'get_version' !== $parsed_args['body']['edd_action']
[667] Fix | Delete
)
[668] Fix | Delete
|| is_wp_error( $response )
[669] Fix | Delete
) {
[670] Fix | Delete
return $response;
[671] Fix | Delete
}
[672] Fix | Delete
[673] Fix | Delete
$params = json_decode( wp_remote_retrieve_body( $response ) );
[674] Fix | Delete
// return if no name is given to identify the plugin that needs update
[675] Fix | Delete
if ( empty( $params->name ) ) {
[676] Fix | Delete
return $response;
[677] Fix | Delete
}
[678] Fix | Delete
[679] Fix | Delete
$new_license_status = null;
[680] Fix | Delete
$new_expiry_date = null;
[681] Fix | Delete
[682] Fix | Delete
// Some of the conditions could happen at the same time, though due to different conditions in EDD we are safer to have multiple checks
[683] Fix | Delete
if ( isset( $params->valid_until ) ) {
[684] Fix | Delete
if ( 'invalid' === $params->valid_until ) {
[685] Fix | Delete
$new_license_status = 'invalid';
[686] Fix | Delete
}
[687] Fix | Delete
if ( 'lifetime' === $params->valid_until ) {
[688] Fix | Delete
$new_license_status = 'valid';
[689] Fix | Delete
$new_expiry_date = 'lifetime';
[690] Fix | Delete
}
[691] Fix | Delete
// license is timestamp
[692] Fix | Delete
if ( is_int( $params->valid_until ) ) {
[693] Fix | Delete
$new_expiry_date = (int) $params->valid_until;
[694] Fix | Delete
if ( time() < $params->valid_until ) {
[695] Fix | Delete
$new_license_status = 'valid';
[696] Fix | Delete
}
[697] Fix | Delete
}
[698] Fix | Delete
} elseif ( empty( $params->download_link ) || empty( $params->package ) || isset( $params->msg ) ) {
[699] Fix | Delete
// if either of these two parameters is missing then the user does not have a valid license according to our store
[700] Fix | Delete
// if there is a "msg" parameter then the license did also not work for another reason
[701] Fix | Delete
$new_license_status = 'invalid';
[702] Fix | Delete
}
[703] Fix | Delete
[704] Fix | Delete
if ( ! $new_license_status && ! $new_expiry_date ) {
[705] Fix | Delete
return $response;
[706] Fix | Delete
}
[707] Fix | Delete
[708] Fix | Delete
$add_ons = apply_filters( 'advanced-ads-add-ons', [] );
[709] Fix | Delete
[710] Fix | Delete
// look for the add-on with the appropriate license key
[711] Fix | Delete
foreach ( $add_ons as $_add_on_key => $_add_on ) {
[712] Fix | Delete
// identify the add-on based on the name
[713] Fix | Delete
if ( ! isset( $add_on['name'] ) || $params->name !== $add_on['name'] ) {
[714] Fix | Delete
continue;
[715] Fix | Delete
}
[716] Fix | Delete
[717] Fix | Delete
$options_slug = $_add_on['options_slug'];
[718] Fix | Delete
[719] Fix | Delete
if ( $new_license_status ) {
[720] Fix | Delete
update_option( $options_slug . '-license-status', $new_license_status, false );
[721] Fix | Delete
}
[722] Fix | Delete
if ( $new_expiry_date ) {
[723] Fix | Delete
if ( 'lifetime' !== $new_expiry_date ) {
[724] Fix | Delete
$new_expiry_date = gmdate( 'Y-m-d 23:59:49', $new_expiry_date );
[725] Fix | Delete
}
[726] Fix | Delete
update_option( $options_slug . '-license-expires', $new_expiry_date, false );
[727] Fix | Delete
}
[728] Fix | Delete
[729] Fix | Delete
// return with the first match since there should only be one plugin per name
[730] Fix | Delete
return $response;
[731] Fix | Delete
}
[732] Fix | Delete
[733] Fix | Delete
return $response;
[734] Fix | Delete
}
[735] Fix | Delete
}
[736] Fix | Delete
[737] Fix | Delete
12
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function